MCPcopy Index your code
hub / github.com/SortableJS/react-sortablejs / getChildren

Method getChildren

src/react-sortable.tsx:100–146  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

98 }
99
100 private getChildren() {
101 const {
102 children,
103 dataIdAttr,
104 selectedClass = "sortable-selected",
105 chosenClass = "sortable-chosen",
106 /* eslint-disable */
107 dragClass = "sortable-drag",
108 fallbackClass = "sortable-falback",
109 ghostClass = "sortable-ghost",
110 swapClass = "sortable-swap-highlight",
111 /* eslint-enable */
112 filter = "sortable-filter",
113 list,
114 } = this.props;
115
116 // if no children, don't do anything.
117 if (!children || children == null) return null;
118 const dataid = dataIdAttr || "data-id";
119 /* eslint-disable-next-line */
120 return Children.map(children as ReactElement<any>[], (child, index) => {
121 if (child === undefined) return undefined;
122
123 const item = list[index] || {};
124 const { className: prevClassName } = child.props;
125
126 // @todo - handle the function if avalable. I don't think anyone will be doing this soon.
127 const filtered = typeof filter === "string" && {
128 [filter.replace(".", "")]: !!item.filtered,
129 };
130
131 const className = classNames(prevClassName, {
132 [selectedClass]: item.selected,
133 [chosenClass]: item.chosen,
134 ...filtered,
135 // [dragClass]: true,
136 // [fallbackClass]: true,
137 // [ghostClass]: true,
138 // [swapClass]: true
139 });
140
141 return cloneElement(child, {
142 [dataid]: child.key,
143 className,
144 });
145 });
146 }
147
148 /** Appends the `sortable` property to this component */
149 private get sortable(): Sortable | null {

Callers 2

renderMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected