@yamada-ui/reorder 2.0.9 → 2.0.10-dev-20240917033401

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,185 +24,25 @@ __export(reorder_trigger_exports, {
24
24
  ReorderTrigger: () => ReorderTrigger
25
25
  });
26
26
  module.exports = __toCommonJS(reorder_trigger_exports);
27
- var import_core3 = require("@yamada-ui/core");
27
+ var import_core = require("@yamada-ui/core");
28
28
  var import_icon = require("@yamada-ui/icon");
29
- var import_utils3 = require("@yamada-ui/utils");
30
-
31
- // src/reorder.tsx
32
- var import_core2 = require("@yamada-ui/core");
33
- var import_motion2 = require("@yamada-ui/motion");
34
29
  var import_utils2 = require("@yamada-ui/utils");
35
- var import_react2 = require("react");
36
30
 
37
- // src/reorder-item.tsx
38
- var import_core = require("@yamada-ui/core");
39
- var import_motion = require("@yamada-ui/motion");
31
+ // src/reorder-context.ts
40
32
  var import_utils = require("@yamada-ui/utils");
41
- var import_react = require("react");
42
- var import_jsx_runtime = require("react/jsx-runtime");
43
- var [ReorderItemProvider, useReorderItemContext] = (0, import_utils.createContext)({
33
+ var [ReorderProvider, useReorderContext] = (0, import_utils.createContext)({
44
34
  name: "ReorderContext",
45
- errorMessage: `useReorderItemContext returned is 'undefined'. Seems you forgot to wrap the components in "<ReorderItem />"`
35
+ errorMessage: `useReorderContext returned is 'undefined'. Seems you forgot to wrap the components in "<Reorder />"`
46
36
  });
47
- var ReorderItem = (0, import_react.forwardRef)(
48
- ({ className, label, value, children, ...rest }, ref) => {
49
- var _a;
50
- const { orientation, styles } = useReorderContext();
51
- const dragControls = (0, import_motion.useDragControls)();
52
- const [hasTrigger, setHasTrigger] = (0, import_react.useState)(false);
53
- const [isDrag, setIsDrag] = (0, import_react.useState)(false);
54
- const x = (0, import_motion.useMotionValue)(0);
55
- const y = (0, import_motion.useMotionValue)(0);
56
- const register = (0, import_react.useCallback)(
57
- (node) => setHasTrigger(!!node),
58
- []
59
- );
60
- (0, import_react.useEffect)(() => {
61
- const unsubscribeX = x.on("change", (x2) => {
62
- if (orientation === "horizontal") setIsDrag(x2 !== 0);
63
- });
64
- const unsubscribeY = y.on("change", (y2) => {
65
- if (orientation === "vertical") setIsDrag(y2 !== 0);
66
- });
67
- return () => {
68
- unsubscribeX();
69
- unsubscribeY();
70
- };
71
- }, [orientation, x, y]);
72
- const css = {
73
- _selected: {
74
- cursor: "grabbing"
75
- },
76
- ...!hasTrigger ? { cursor: "grab" } : { userSelect: "none" },
77
- ...styles.item,
78
- ...!hasTrigger ? {
79
- _selected: {
80
- ...(_a = styles.item) == null ? void 0 : _a._selected,
81
- cursor: "grabbing"
82
- }
83
- } : {}
84
- };
85
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReorderItemProvider, { value: { register, isDrag, dragControls }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
86
- import_core.ui.li,
87
- {
88
- ref,
89
- as: import_motion.MotionReorder.Item,
90
- className: (0, import_utils.cx)("ui-reorder__item", className),
91
- value,
92
- __css: css,
93
- ...rest,
94
- dragListener: !hasTrigger,
95
- dragControls,
96
- "data-selected": (0, import_utils.dataAttr)(isDrag),
97
- style: { ...rest.style, x, y },
98
- children: children != null ? children : label
99
- }
100
- ) });
101
- }
102
- );
103
- ReorderItem.displayName = "ReorderItem";
104
-
105
- // src/reorder.tsx
106
- var import_jsx_runtime2 = require("react/jsx-runtime");
107
- var [ReorderProvider, useReorderContext] = (0, import_utils2.createContext)({
37
+ var [ReorderItemProvider, useReorderItemContext] = (0, import_utils.createContext)({
108
38
  name: "ReorderContext",
109
- errorMessage: `useReorderContext returned is 'undefined'. Seems you forgot to wrap the components in "<Reorder />"`
39
+ errorMessage: `useReorderItemContext returned is 'undefined'. Seems you forgot to wrap the components in "<ReorderItem />"`
110
40
  });
111
- var omitDuplicated = (values) => Array.from(new Set(values));
112
- var pickDuplicated = (values) => values.filter(
113
- (value, index, self) => self.indexOf(value) === index && index !== self.lastIndexOf(value)
114
- );
115
- var Reorder = (0, import_react2.forwardRef)(
116
- (props, ref) => {
117
- const [styles, mergedProps] = (0, import_core2.useMultiComponentStyle)("Reorder", props);
118
- const {
119
- className,
120
- orientation = "vertical",
121
- gap = "fallback(4, 1rem)",
122
- items = [],
123
- onChange,
124
- onCompleteChange,
125
- children,
126
- ...rest
127
- } = (0, import_core2.omitThemeProps)(mergedProps);
128
- const axis = orientation === "vertical" ? "y" : "x";
129
- const validChildren = (0, import_utils2.getValidChildren)(children);
130
- const hasChildren = !!validChildren.length;
131
- const defaultValues = (0, import_react2.useMemo)(() => {
132
- const values2 = hasChildren ? validChildren.map(({ props: props2 }) => props2.value) : items.map(({ value }) => value);
133
- const duplicatedValues = pickDuplicated(values2);
134
- if (duplicatedValues.length)
135
- console.warn(
136
- `Reorder: 'value' of 'ReorderItem' must not be duplicated. duplicate 'value' is '${duplicatedValues.join(
137
- `', '`
138
- )}' `
139
- );
140
- return omitDuplicated(values2);
141
- }, [hasChildren, validChildren, items]);
142
- const prevDefaultValues = (0, import_react2.useRef)(defaultValues);
143
- const [values, setValues] = (0, import_react2.useState)(defaultValues);
144
- const prevValues = (0, import_react2.useRef)(defaultValues);
145
- const onReorder = (0, import_react2.useCallback)(
146
- (newValues) => {
147
- setValues(newValues);
148
- onChange == null ? void 0 : onChange(newValues);
149
- },
150
- [onChange]
151
- );
152
- const onCompleteReorder = (0, import_react2.useCallback)(() => {
153
- const isEqual = JSON.stringify(prevValues.current) === JSON.stringify(values);
154
- if (isEqual) return;
155
- prevValues.current = values;
156
- onCompleteChange == null ? void 0 : onCompleteChange(values);
157
- }, [onCompleteChange, values]);
158
- (0, import_utils2.useUpdateEffect)(() => {
159
- const isEqual = JSON.stringify(defaultValues) === JSON.stringify(prevDefaultValues.current);
160
- if (isEqual) return;
161
- prevValues.current = defaultValues;
162
- prevDefaultValues.current = defaultValues;
163
- setValues(defaultValues);
164
- }, [defaultValues]);
165
- const cloneChildren = (0, import_react2.useMemo)(
166
- () => values.map((value) => {
167
- if (hasChildren) {
168
- return validChildren.find(({ props: props2 }) => props2.value === value);
169
- } else {
170
- const props2 = items.find((item) => item.value === value);
171
- return props2 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ReorderItem, { ...props2 }, props2.value) : null;
172
- }
173
- }),
174
- [values, hasChildren, validChildren, items]
175
- );
176
- const css = {
177
- display: "flex",
178
- flexDirection: orientation === "vertical" ? "column" : "row",
179
- gap,
180
- ...styles.container
181
- };
182
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ReorderProvider, { value: { orientation, styles }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
183
- import_core2.ui.ul,
184
- {
185
- ref,
186
- as: import_motion2.MotionReorder.Group,
187
- className: (0, import_utils2.cx)("ui-reorder", className),
188
- axis,
189
- values,
190
- onReorder,
191
- __css: css,
192
- ...rest,
193
- onMouseUp: (0, import_utils2.handlerAll)(rest.onMouseUp, onCompleteReorder),
194
- onTouchEnd: (0, import_utils2.handlerAll)(rest.onTouchEnd, onCompleteReorder),
195
- children: cloneChildren
196
- }
197
- ) });
198
- }
199
- );
200
- Reorder.displayName = "Reorder";
201
41
 
202
42
  // src/reorder-trigger.tsx
203
- var import_jsx_runtime3 = require("react/jsx-runtime");
204
- var ReorderTrigger = (0, import_core3.forwardRef)(
205
- ({ className, children = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ReorderTriggerIcon, {}), ...rest }, ref) => {
43
+ var import_jsx_runtime = require("react/jsx-runtime");
44
+ var ReorderTrigger = (0, import_core.forwardRef)(
45
+ ({ className, children = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReorderTriggerIcon, {}), ...rest }, ref) => {
206
46
  const { styles } = useReorderContext();
207
47
  const { register, isDrag, dragControls } = useReorderItemContext();
208
48
  const css = {
@@ -215,15 +55,15 @@ var ReorderTrigger = (0, import_core3.forwardRef)(
215
55
  },
216
56
  ...styles.trigger
217
57
  };
218
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
219
- import_core3.ui.div,
58
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
59
+ import_core.ui.div,
220
60
  {
221
- ref: (0, import_utils3.mergeRefs)(register, ref),
222
- className: (0, import_utils3.cx)("ui-reorder__trigger", className),
61
+ ref: (0, import_utils2.mergeRefs)(register, ref),
62
+ className: (0, import_utils2.cx)("ui-reorder__trigger", className),
223
63
  __css: css,
224
64
  ...rest,
225
- "data-selected": (0, import_utils3.dataAttr)(isDrag),
226
- onPointerDown: (0, import_utils3.handlerAll)(
65
+ "data-selected": (0, import_utils2.dataAttr)(isDrag),
66
+ onPointerDown: (0, import_utils2.handlerAll)(
227
67
  rest.onPointerDown,
228
68
  (ev) => dragControls.start(ev)
229
69
  ),
@@ -233,64 +73,64 @@ var ReorderTrigger = (0, import_core3.forwardRef)(
233
73
  }
234
74
  );
235
75
  var ReorderTriggerIcon = (rest) => {
236
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_icon.Icon, { viewBox: "0 0 39 39", ...rest, children: [
237
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
76
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_icon.Icon, { viewBox: "0 0 39 39", ...rest, children: [
77
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
238
78
  "path",
239
79
  {
240
80
  d: "M 5 0 C 7.761 0 10 2.239 10 5 C 10 7.761 7.761 10 5 10 C 2.239 10 0 7.761 0 5 C 0 2.239 2.239 0 5 0 Z",
241
81
  fill: "currentColor"
242
82
  }
243
83
  ),
244
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
84
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
245
85
  "path",
246
86
  {
247
87
  d: "M 19 0 C 21.761 0 24 2.239 24 5 C 24 7.761 21.761 10 19 10 C 16.239 10 14 7.761 14 5 C 14 2.239 16.239 0 19 0 Z",
248
88
  fill: "currentColor"
249
89
  }
250
90
  ),
251
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
91
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
252
92
  "path",
253
93
  {
254
94
  d: "M 33 0 C 35.761 0 38 2.239 38 5 C 38 7.761 35.761 10 33 10 C 30.239 10 28 7.761 28 5 C 28 2.239 30.239 0 33 0 Z",
255
95
  fill: "currentColor"
256
96
  }
257
97
  ),
258
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
98
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
259
99
  "path",
260
100
  {
261
101
  d: "M 33 14 C 35.761 14 38 16.239 38 19 C 38 21.761 35.761 24 33 24 C 30.239 24 28 21.761 28 19 C 28 16.239 30.239 14 33 14 Z",
262
102
  fill: "currentColor"
263
103
  }
264
104
  ),
265
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
105
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
266
106
  "path",
267
107
  {
268
108
  d: "M 19 14 C 21.761 14 24 16.239 24 19 C 24 21.761 21.761 24 19 24 C 16.239 24 14 21.761 14 19 C 14 16.239 16.239 14 19 14 Z",
269
109
  fill: "currentColor"
270
110
  }
271
111
  ),
272
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
112
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
273
113
  "path",
274
114
  {
275
115
  d: "M 5 14 C 7.761 14 10 16.239 10 19 C 10 21.761 7.761 24 5 24 C 2.239 24 0 21.761 0 19 C 0 16.239 2.239 14 5 14 Z",
276
116
  fill: "currentColor"
277
117
  }
278
118
  ),
279
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
119
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
280
120
  "path",
281
121
  {
282
122
  d: "M 5 28 C 7.761 28 10 30.239 10 33 C 10 35.761 7.761 38 5 38 C 2.239 38 0 35.761 0 33 C 0 30.239 2.239 28 5 28 Z",
283
123
  fill: "currentColor"
284
124
  }
285
125
  ),
286
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
126
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
287
127
  "path",
288
128
  {
289
129
  d: "M 19 28 C 21.761 28 24 30.239 24 33 C 24 35.761 21.761 38 19 38 C 16.239 38 14 35.761 14 33 C 14 30.239 16.239 28 19 28 Z",
290
130
  fill: "currentColor"
291
131
  }
292
132
  ),
293
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
133
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
294
134
  "path",
295
135
  {
296
136
  d: "M 33 28 C 35.761 28 38 30.239 38 33 C 38 35.761 35.761 38 33 38 C 30.239 38 28 35.761 28 33 C 28 30.239 30.239 28 33 28 Z",
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/reorder-trigger.tsx","../src/reorder.tsx","../src/reorder-item.tsx"],"sourcesContent":["import type { HTMLUIProps, CSSUIObject } from \"@yamada-ui/core\"\nimport { ui, forwardRef } from \"@yamada-ui/core\"\nimport type { IconProps } from \"@yamada-ui/icon\"\nimport { Icon } from \"@yamada-ui/icon\"\nimport { cx, handlerAll, mergeRefs, dataAttr } from \"@yamada-ui/utils\"\nimport type { FC } from \"react\"\nimport { useReorderContext } from \"./reorder\"\nimport { useReorderItemContext } from \"./reorder-item\"\n\nexport type ReorderTriggerProps = HTMLUIProps<\"div\">\n\nexport const ReorderTrigger = forwardRef<ReorderTriggerProps, \"div\">(\n ({ className, children = <ReorderTriggerIcon />, ...rest }, ref) => {\n const { styles } = useReorderContext()\n const { register, isDrag, dragControls } = useReorderItemContext()\n\n const css: CSSUIObject = {\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n cursor: \"grab\",\n _selected: {\n cursor: \"grabbing\",\n },\n ...styles.trigger,\n }\n\n return (\n <ui.div\n ref={mergeRefs(register, ref)}\n className={cx(\"ui-reorder__trigger\", className)}\n __css={css}\n {...rest}\n data-selected={dataAttr(isDrag)}\n onPointerDown={handlerAll(rest.onPointerDown, (ev) =>\n dragControls.start(ev),\n )}\n >\n {children}\n </ui.div>\n )\n },\n)\n\nconst ReorderTriggerIcon: FC<IconProps> = (rest) => {\n return (\n <Icon viewBox=\"0 0 39 39\" {...rest}>\n <path\n d=\"M 5 0 C 7.761 0 10 2.239 10 5 C 10 7.761 7.761 10 5 10 C 2.239 10 0 7.761 0 5 C 0 2.239 2.239 0 5 0 Z\"\n fill=\"currentColor\"\n />\n\n <path\n d=\"M 19 0 C 21.761 0 24 2.239 24 5 C 24 7.761 21.761 10 19 10 C 16.239 10 14 7.761 14 5 C 14 2.239 16.239 0 19 0 Z\"\n fill=\"currentColor\"\n />\n\n <path\n d=\"M 33 0 C 35.761 0 38 2.239 38 5 C 38 7.761 35.761 10 33 10 C 30.239 10 28 7.761 28 5 C 28 2.239 30.239 0 33 0 Z\"\n fill=\"currentColor\"\n />\n\n <path\n d=\"M 33 14 C 35.761 14 38 16.239 38 19 C 38 21.761 35.761 24 33 24 C 30.239 24 28 21.761 28 19 C 28 16.239 30.239 14 33 14 Z\"\n fill=\"currentColor\"\n />\n\n <path\n d=\"M 19 14 C 21.761 14 24 16.239 24 19 C 24 21.761 21.761 24 19 24 C 16.239 24 14 21.761 14 19 C 14 16.239 16.239 14 19 14 Z\"\n fill=\"currentColor\"\n />\n\n <path\n d=\"M 5 14 C 7.761 14 10 16.239 10 19 C 10 21.761 7.761 24 5 24 C 2.239 24 0 21.761 0 19 C 0 16.239 2.239 14 5 14 Z\"\n fill=\"currentColor\"\n />\n\n <path\n d=\"M 5 28 C 7.761 28 10 30.239 10 33 C 10 35.761 7.761 38 5 38 C 2.239 38 0 35.761 0 33 C 0 30.239 2.239 28 5 28 Z\"\n fill=\"currentColor\"\n />\n\n <path\n d=\"M 19 28 C 21.761 28 24 30.239 24 33 C 24 35.761 21.761 38 19 38 C 16.239 38 14 35.761 14 33 C 14 30.239 16.239 28 19 28 Z\"\n fill=\"currentColor\"\n />\n\n <path\n d=\"M 33 28 C 35.761 28 38 30.239 38 33 C 38 35.761 35.761 38 33 38 C 30.239 38 28 35.761 28 33 C 28 30.239 30.239 28 33 28 Z\"\n fill=\"currentColor\"\n />\n </Icon>\n )\n}\n","import type {\n CSSUIObject,\n ComponentArgs,\n HTMLUIProps,\n ThemeProps,\n} from \"@yamada-ui/core\"\nimport { ui, useMultiComponentStyle, omitThemeProps } from \"@yamada-ui/core\"\nimport type { HTMLMotionProps } from \"@yamada-ui/motion\"\nimport { MotionReorder } from \"@yamada-ui/motion\"\nimport type { Merge } from \"@yamada-ui/utils\"\nimport {\n createContext,\n cx,\n getValidChildren,\n handlerAll,\n useUpdateEffect,\n} from \"@yamada-ui/utils\"\nimport type { ForwardedRef, PropsWithChildren } from \"react\"\nimport { forwardRef, useCallback, useMemo, useRef, useState } from \"react\"\nimport { ReorderItem, type ReorderItemProps } from \"./reorder-item\"\n\ntype ReorderContext = {\n orientation: \"vertical\" | \"horizontal\"\n styles: Record<string, CSSUIObject>\n}\n\nexport const [ReorderProvider, useReorderContext] =\n createContext<ReorderContext>({\n name: \"ReorderContext\",\n errorMessage: `useReorderContext returned is 'undefined'. Seems you forgot to wrap the components in \"<Reorder />\"`,\n })\n\nexport type ReorderGenerateItem<Y extends any = string> = ReorderItemProps<Y>\n\ntype ReorderOptions<Y extends any = string> = {\n /**\n * The orientation of the reorder.\n *\n * @default 'vertical'\n */\n orientation?: \"vertical\" | \"horizontal\"\n /**\n * If provided, generate reorder items based on items.\n *\n */\n items?: ReorderGenerateItem[]\n /**\n * The callback invoked when reorder items are moved.\n */\n onChange?: (values: Y[]) => void\n /**\n * The callback invoked when the movement of reorder items is completed.\n */\n onCompleteChange?: (values: Y[]) => void\n}\n\nexport type ReorderProps<Y extends any = string> = Omit<\n Merge<HTMLUIProps<\"ul\">, HTMLMotionProps<\"ul\">>,\n \"onChange\" | \"transition\" | \"children\"\n> &\n PropsWithChildren &\n ThemeProps<\"Reorder\"> &\n ReorderOptions<Y>\n\nconst omitDuplicated = <Y extends any = string>(values: Y[]): Y[] =>\n Array.from(new Set(values))\n\nconst pickDuplicated = <Y extends any = string>(values: Y[]): Y[] =>\n values.filter(\n (value, index, self) =>\n self.indexOf(value) === index && index !== self.lastIndexOf(value),\n )\n\n/**\n * `Reorder` is a component that allows you to change the order of items using drag and drop.\n *\n * @see Docs https://yamada-ui.com/components/data-display/reorder\n */\nexport const Reorder = forwardRef(\n <Y extends any = string>(\n props: ReorderProps<Y>,\n ref: ForwardedRef<HTMLUListElement>,\n ) => {\n const [styles, mergedProps] = useMultiComponentStyle(\"Reorder\", props)\n const {\n className,\n orientation = \"vertical\",\n gap = \"fallback(4, 1rem)\",\n items = [],\n onChange,\n onCompleteChange,\n children,\n ...rest\n } = omitThemeProps(mergedProps)\n\n const axis = orientation === \"vertical\" ? \"y\" : \"x\"\n\n const validChildren = getValidChildren(children)\n const hasChildren = !!validChildren.length\n\n const defaultValues = useMemo(() => {\n const values = hasChildren\n ? validChildren.map(({ props }) => props.value)\n : items.map(({ value }) => value)\n\n const duplicatedValues = pickDuplicated(values)\n\n if (duplicatedValues.length)\n console.warn(\n `Reorder: 'value' of 'ReorderItem' must not be duplicated. duplicate 'value' is '${duplicatedValues.join(\n `', '`,\n )}' `,\n )\n\n return omitDuplicated(values)\n }, [hasChildren, validChildren, items])\n const prevDefaultValues = useRef<Y[]>(defaultValues)\n\n const [values, setValues] = useState<Y[]>(defaultValues)\n const prevValues = useRef<Y[]>(defaultValues)\n\n const onReorder = useCallback(\n (newValues: Y[]) => {\n setValues(newValues)\n\n onChange?.(newValues)\n },\n [onChange],\n )\n\n const onCompleteReorder = useCallback(() => {\n const isEqual =\n JSON.stringify(prevValues.current) === JSON.stringify(values)\n\n if (isEqual) return\n\n prevValues.current = values\n\n onCompleteChange?.(values)\n }, [onCompleteChange, values])\n\n useUpdateEffect(() => {\n const isEqual =\n JSON.stringify(defaultValues) ===\n JSON.stringify(prevDefaultValues.current)\n\n if (isEqual) return\n\n prevValues.current = defaultValues\n prevDefaultValues.current = defaultValues\n\n setValues(defaultValues)\n }, [defaultValues])\n\n const cloneChildren = useMemo(\n () =>\n values.map((value) => {\n if (hasChildren) {\n return validChildren.find(({ props }) => props.value === value)\n } else {\n const props = items.find((item) => item.value === value)\n\n return props ? <ReorderItem key={props.value} {...props} /> : null\n }\n }),\n [values, hasChildren, validChildren, items],\n )\n\n const css: CSSUIObject = {\n display: \"flex\",\n flexDirection: orientation === \"vertical\" ? \"column\" : \"row\",\n gap,\n ...styles.container,\n }\n\n return (\n <ReorderProvider value={{ orientation, styles }}>\n <ui.ul\n ref={ref}\n as={MotionReorder.Group<Y>}\n className={cx(\"ui-reorder\", className)}\n axis={axis}\n values={values}\n onReorder={onReorder}\n __css={css}\n {...rest}\n onMouseUp={handlerAll(rest.onMouseUp, onCompleteReorder)}\n onTouchEnd={handlerAll(rest.onTouchEnd, onCompleteReorder)}\n >\n {cloneChildren}\n </ui.ul>\n </ReorderProvider>\n )\n },\n) as {\n <Y extends any = string>(\n props: ReorderProps<Y> & { ref?: ForwardedRef<HTMLUListElement> },\n ): JSX.Element\n} & ComponentArgs\n\nReorder.displayName = \"Reorder\"\n","import type { HTMLUIProps, CSSUIObject, ComponentArgs } from \"@yamada-ui/core\"\nimport { ui } from \"@yamada-ui/core\"\nimport type { HTMLMotionProps, DragControls } from \"@yamada-ui/motion\"\nimport {\n MotionReorder,\n useMotionValue,\n useDragControls,\n} from \"@yamada-ui/motion\"\nimport { createContext, cx, dataAttr } from \"@yamada-ui/utils\"\nimport type { Merge } from \"@yamada-ui/utils\"\nimport type { ForwardedRef, PropsWithChildren, ReactNode } from \"react\"\nimport { forwardRef, useCallback, useEffect, useState } from \"react\"\nimport { useReorderContext } from \"./reorder\"\n\ntype ReorderItemContext = {\n register: (node: HTMLElement | null) => void\n isDrag: boolean\n dragControls: DragControls\n}\n\nexport const [ReorderItemProvider, useReorderItemContext] =\n createContext<ReorderItemContext>({\n name: \"ReorderContext\",\n errorMessage: `useReorderItemContext returned is 'undefined'. Seems you forgot to wrap the components in \"<ReorderItem />\"`,\n })\n\ntype ReorderItemOptions<Y extends any = string> = {\n /**\n * The label of the reorder item.\n */\n label?: ReactNode\n /**\n * The value of the reorder item.\n */\n value: Y\n}\n\nexport type ReorderItemProps<Y extends any = string> = Omit<\n Merge<HTMLUIProps<\"li\">, HTMLMotionProps<\"li\">>,\n \"value\" | \"transition\" | \"children\"\n> &\n PropsWithChildren &\n ReorderItemOptions<Y>\n\nexport const ReorderItem = forwardRef(\n <Y extends any = string>(\n { className, label, value, children, ...rest }: ReorderItemProps<Y>,\n ref: ForwardedRef<HTMLLIElement>,\n ) => {\n const { orientation, styles } = useReorderContext()\n\n const dragControls = useDragControls()\n\n const [hasTrigger, setHasTrigger] = useState<boolean>(false)\n const [isDrag, setIsDrag] = useState<boolean>(false)\n\n const x = useMotionValue(0)\n const y = useMotionValue(0)\n\n const register = useCallback(\n (node: HTMLElement | null) => setHasTrigger(!!node),\n [],\n )\n\n useEffect(() => {\n const unsubscribeX = x.on(\"change\", (x) => {\n if (orientation === \"horizontal\") setIsDrag(x !== 0)\n })\n const unsubscribeY = y.on(\"change\", (y) => {\n if (orientation === \"vertical\") setIsDrag(y !== 0)\n })\n\n return () => {\n unsubscribeX()\n unsubscribeY()\n }\n }, [orientation, x, y])\n\n const css: CSSUIObject = {\n _selected: {\n cursor: \"grabbing\",\n },\n ...(!hasTrigger ? { cursor: \"grab\" } : { userSelect: \"none\" }),\n ...styles.item,\n ...(!hasTrigger\n ? {\n _selected: {\n ...styles.item?._selected,\n cursor: \"grabbing\",\n },\n }\n : {}),\n }\n\n return (\n <ReorderItemProvider value={{ register, isDrag, dragControls }}>\n <ui.li\n ref={ref}\n as={MotionReorder.Item}\n className={cx(\"ui-reorder__item\", className)}\n value={value}\n __css={css}\n {...rest}\n dragListener={!hasTrigger}\n dragControls={dragControls}\n data-selected={dataAttr(isDrag)}\n style={{ ...rest.style, x, y }}\n >\n {children ?? label}\n </ui.li>\n </ReorderItemProvider>\n )\n },\n) as {\n <Y extends any = string>(\n props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AAEJ;","names":["import_core","import_utils","import_core","import_motion","import_utils","import_react","x","y","import_jsx_runtime","values","props","import_jsx_runtime"]}
1
+ {"version":3,"sources":["../src/reorder-trigger.tsx","../src/reorder-context.ts"],"sourcesContent":["import type { HTMLUIProps, CSSUIObject } from \"@yamada-ui/core\"\nimport { ui, forwardRef } from \"@yamada-ui/core\"\nimport type { IconProps } from \"@yamada-ui/icon\"\nimport { Icon } from \"@yamada-ui/icon\"\nimport { cx, handlerAll, mergeRefs, dataAttr } from \"@yamada-ui/utils\"\nimport type { FC } from \"react\"\nimport { useReorderContext, useReorderItemContext } from \"./reorder-context\"\n\nexport interface ReorderTriggerProps extends HTMLUIProps {}\n\nexport const ReorderTrigger = forwardRef<ReorderTriggerProps, \"div\">(\n ({ className, children = <ReorderTriggerIcon />, ...rest }, ref) => {\n const { styles } = useReorderContext()\n const { register, isDrag, dragControls } = useReorderItemContext()\n\n const css: CSSUIObject = {\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n cursor: \"grab\",\n _selected: {\n cursor: \"grabbing\",\n },\n ...styles.trigger,\n }\n\n return (\n <ui.div\n ref={mergeRefs(register, ref)}\n className={cx(\"ui-reorder__trigger\", className)}\n __css={css}\n {...rest}\n data-selected={dataAttr(isDrag)}\n onPointerDown={handlerAll(rest.onPointerDown, (ev) =>\n dragControls.start(ev),\n )}\n >\n {children}\n </ui.div>\n )\n },\n)\n\nconst ReorderTriggerIcon: FC<IconProps> = (rest) => {\n return (\n <Icon viewBox=\"0 0 39 39\" {...rest}>\n <path\n d=\"M 5 0 C 7.761 0 10 2.239 10 5 C 10 7.761 7.761 10 5 10 C 2.239 10 0 7.761 0 5 C 0 2.239 2.239 0 5 0 Z\"\n fill=\"currentColor\"\n />\n\n <path\n d=\"M 19 0 C 21.761 0 24 2.239 24 5 C 24 7.761 21.761 10 19 10 C 16.239 10 14 7.761 14 5 C 14 2.239 16.239 0 19 0 Z\"\n fill=\"currentColor\"\n />\n\n <path\n d=\"M 33 0 C 35.761 0 38 2.239 38 5 C 38 7.761 35.761 10 33 10 C 30.239 10 28 7.761 28 5 C 28 2.239 30.239 0 33 0 Z\"\n fill=\"currentColor\"\n />\n\n <path\n d=\"M 33 14 C 35.761 14 38 16.239 38 19 C 38 21.761 35.761 24 33 24 C 30.239 24 28 21.761 28 19 C 28 16.239 30.239 14 33 14 Z\"\n fill=\"currentColor\"\n />\n\n <path\n d=\"M 19 14 C 21.761 14 24 16.239 24 19 C 24 21.761 21.761 24 19 24 C 16.239 24 14 21.761 14 19 C 14 16.239 16.239 14 19 14 Z\"\n fill=\"currentColor\"\n />\n\n <path\n d=\"M 5 14 C 7.761 14 10 16.239 10 19 C 10 21.761 7.761 24 5 24 C 2.239 24 0 21.761 0 19 C 0 16.239 2.239 14 5 14 Z\"\n fill=\"currentColor\"\n />\n\n <path\n d=\"M 5 28 C 7.761 28 10 30.239 10 33 C 10 35.761 7.761 38 5 38 C 2.239 38 0 35.761 0 33 C 0 30.239 2.239 28 5 28 Z\"\n fill=\"currentColor\"\n />\n\n <path\n d=\"M 19 28 C 21.761 28 24 30.239 24 33 C 24 35.761 21.761 38 19 38 C 16.239 38 14 35.761 14 33 C 14 30.239 16.239 28 19 28 Z\"\n fill=\"currentColor\"\n />\n\n <path\n d=\"M 33 28 C 35.761 28 38 30.239 38 33 C 38 35.761 35.761 38 33 38 C 30.239 38 28 35.761 28 33 C 28 30.239 30.239 28 33 28 Z\"\n fill=\"currentColor\"\n />\n </Icon>\n )\n}\n","import type { CSSUIObject } from \"@yamada-ui/core\"\nimport type { DragControls } from \"@yamada-ui/motion\"\nimport { createContext } from \"@yamada-ui/utils\"\n\ninterface ReorderContext {\n orientation: \"vertical\" | \"horizontal\"\n styles: { [key: string]: CSSUIObject }\n}\n\nexport const [ReorderProvider, useReorderContext] =\n createContext<ReorderContext>({\n name: \"ReorderContext\",\n errorMessage: `useReorderContext returned is 'undefined'. Seems you forgot to wrap the components in \"<Reorder />\"`,\n })\n\ninterface ReorderItemContext {\n register: (node: HTMLElement | null) => void\n isDrag: boolean\n dragControls: DragControls\n}\n\nexport const [ReorderItemProvider, useReorderItemContext] =\n createContext<ReorderItemContext>({\n name: \"ReorderContext\",\n errorMessage: `useReorderItemContext returned is 'undefined'. Seems you forgot to wrap the components in \"<ReorderItem />\"`,\n })\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAA+B;AAE/B,kBAAqB;AACrB,IAAAA,gBAAoD;;;ACFpD,mBAA8B;AAOvB,IAAM,CAAC,iBAAiB,iBAAiB,QAC9C,4BAA8B;AAAA,EAC5B,MAAM;AAAA,EACN,cAAc;AAChB,CAAC;AAQI,IAAM,CAAC,qBAAqB,qBAAqB,QACtD,4BAAkC;AAAA,EAChC,MAAM;AAAA,EACN,cAAc;AAChB,CAAC;;;ADdwB;AADpB,IAAM,qBAAiB;AAAA,EAC5B,CAAC,EAAE,WAAW,WAAW,4CAAC,sBAAmB,GAAI,GAAG,KAAK,GAAG,QAAQ;AAClE,UAAM,EAAE,OAAO,IAAI,kBAAkB;AACrC,UAAM,EAAE,UAAU,QAAQ,aAAa,IAAI,sBAAsB;AAEjE,UAAM,MAAmB;AAAA,MACvB,SAAS;AAAA,MACT,gBAAgB;AAAA,MAChB,YAAY;AAAA,MACZ,QAAQ;AAAA,MACR,WAAW;AAAA,QACT,QAAQ;AAAA,MACV;AAAA,MACA,GAAG,OAAO;AAAA,IACZ;AAEA,WACE;AAAA,MAAC,eAAG;AAAA,MAAH;AAAA,QACC,SAAK,yBAAU,UAAU,GAAG;AAAA,QAC5B,eAAW,kBAAG,uBAAuB,SAAS;AAAA,QAC9C,OAAO;AAAA,QACN,GAAG;AAAA,QACJ,qBAAe,wBAAS,MAAM;AAAA,QAC9B,mBAAe;AAAA,UAAW,KAAK;AAAA,UAAe,CAAC,OAC7C,aAAa,MAAM,EAAE;AAAA,QACvB;AAAA,QAEC;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AAEA,IAAM,qBAAoC,CAAC,SAAS;AAClD,SACE,6CAAC,oBAAK,SAAQ,aAAa,GAAG,MAC5B;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,GAAE;AAAA,QACF,MAAK;AAAA;AAAA,IACP;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,GAAE;AAAA,QACF,MAAK;AAAA;AAAA,IACP;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,GAAE;AAAA,QACF,MAAK;AAAA;AAAA,IACP;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,GAAE;AAAA,QACF,MAAK;AAAA;AAAA,IACP;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,GAAE;AAAA,QACF,MAAK;AAAA;AAAA,IACP;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,GAAE;AAAA,QACF,MAAK;AAAA;AAAA,IACP;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,GAAE;AAAA,QACF,MAAK;AAAA;AAAA,IACP;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,GAAE;AAAA,QACF,MAAK;AAAA;AAAA,IACP;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,GAAE;AAAA,QACF,MAAK;AAAA;AAAA,IACP;AAAA,KACF;AAEJ;","names":["import_utils"]}
@@ -1,8 +1,8 @@
1
1
  "use client"
2
2
  import {
3
3
  ReorderTrigger
4
- } from "./chunk-RFRSMH24.mjs";
5
- import "./chunk-LKWVADXG.mjs";
4
+ } from "./chunk-PMOLBS6N.mjs";
5
+ import "./chunk-BBGHU5EB.mjs";
6
6
  export {
7
7
  ReorderTrigger
8
8
  };
@@ -1,18 +1,11 @@
1
- import * as react from 'react';
2
- import { PropsWithChildren, ForwardedRef } from 'react';
3
- import { HTMLUIProps, ThemeProps, ComponentArgs, CSSUIObject } from '@yamada-ui/core';
1
+ import { HTMLUIProps, ThemeProps, ComponentArgs } from '@yamada-ui/core';
4
2
  import { HTMLMotionProps } from '@yamada-ui/motion';
5
3
  import { Merge } from '@yamada-ui/utils';
4
+ import { PropsWithChildren, RefAttributes } from 'react';
6
5
  import { ReorderItemProps } from './reorder-item.mjs';
7
6
 
8
- type ReorderContext = {
9
- orientation: "vertical" | "horizontal";
10
- styles: Record<string, CSSUIObject>;
11
- };
12
- declare const ReorderProvider: react.Provider<ReorderContext>;
13
- declare const useReorderContext: () => ReorderContext;
14
7
  type ReorderGenerateItem<Y extends any = string> = ReorderItemProps<Y>;
15
- type ReorderOptions<Y extends any = string> = {
8
+ interface ReorderOptions<Y extends any = string> {
16
9
  /**
17
10
  * The orientation of the reorder.
18
11
  *
@@ -32,17 +25,16 @@ type ReorderOptions<Y extends any = string> = {
32
25
  * The callback invoked when the movement of reorder items is completed.
33
26
  */
34
27
  onCompleteChange?: (values: Y[]) => void;
35
- };
36
- type ReorderProps<Y extends any = string> = Omit<Merge<HTMLUIProps<"ul">, HTMLMotionProps<"ul">>, "onChange" | "transition" | "children"> & PropsWithChildren & ThemeProps<"Reorder"> & ReorderOptions<Y>;
28
+ }
29
+ interface ReorderProps<Y extends any = string> extends Omit<Merge<HTMLUIProps<"ul">, HTMLMotionProps<"ul">>, "onChange" | "transition" | "children">, PropsWithChildren, ThemeProps<"Reorder">, ReorderOptions<Y> {
30
+ }
37
31
  /**
38
32
  * `Reorder` is a component that allows you to change the order of items using drag and drop.
39
33
  *
40
34
  * @see Docs https://yamada-ui.com/components/data-display/reorder
41
35
  */
42
36
  declare const Reorder: {
43
- <Y extends any = string>(props: ReorderProps<Y> & {
44
- ref?: ForwardedRef<HTMLUListElement>;
45
- }): JSX.Element;
37
+ <Y = string>(props: ReorderProps<Y> & RefAttributes<HTMLUListElement>): JSX.Element;
46
38
  } & ComponentArgs;
47
39
 
48
- export { Reorder, type ReorderGenerateItem, type ReorderProps, ReorderProvider, useReorderContext };
40
+ export { Reorder, type ReorderGenerateItem, type ReorderProps };
package/dist/reorder.d.ts CHANGED
@@ -1,18 +1,11 @@
1
- import * as react from 'react';
2
- import { PropsWithChildren, ForwardedRef } from 'react';
3
- import { HTMLUIProps, ThemeProps, ComponentArgs, CSSUIObject } from '@yamada-ui/core';
1
+ import { HTMLUIProps, ThemeProps, ComponentArgs } from '@yamada-ui/core';
4
2
  import { HTMLMotionProps } from '@yamada-ui/motion';
5
3
  import { Merge } from '@yamada-ui/utils';
4
+ import { PropsWithChildren, RefAttributes } from 'react';
6
5
  import { ReorderItemProps } from './reorder-item.js';
7
6
 
8
- type ReorderContext = {
9
- orientation: "vertical" | "horizontal";
10
- styles: Record<string, CSSUIObject>;
11
- };
12
- declare const ReorderProvider: react.Provider<ReorderContext>;
13
- declare const useReorderContext: () => ReorderContext;
14
7
  type ReorderGenerateItem<Y extends any = string> = ReorderItemProps<Y>;
15
- type ReorderOptions<Y extends any = string> = {
8
+ interface ReorderOptions<Y extends any = string> {
16
9
  /**
17
10
  * The orientation of the reorder.
18
11
  *
@@ -32,17 +25,16 @@ type ReorderOptions<Y extends any = string> = {
32
25
  * The callback invoked when the movement of reorder items is completed.
33
26
  */
34
27
  onCompleteChange?: (values: Y[]) => void;
35
- };
36
- type ReorderProps<Y extends any = string> = Omit<Merge<HTMLUIProps<"ul">, HTMLMotionProps<"ul">>, "onChange" | "transition" | "children"> & PropsWithChildren & ThemeProps<"Reorder"> & ReorderOptions<Y>;
28
+ }
29
+ interface ReorderProps<Y extends any = string> extends Omit<Merge<HTMLUIProps<"ul">, HTMLMotionProps<"ul">>, "onChange" | "transition" | "children">, PropsWithChildren, ThemeProps<"Reorder">, ReorderOptions<Y> {
30
+ }
37
31
  /**
38
32
  * `Reorder` is a component that allows you to change the order of items using drag and drop.
39
33
  *
40
34
  * @see Docs https://yamada-ui.com/components/data-display/reorder
41
35
  */
42
36
  declare const Reorder: {
43
- <Y extends any = string>(props: ReorderProps<Y> & {
44
- ref?: ForwardedRef<HTMLUListElement>;
45
- }): JSX.Element;
37
+ <Y = string>(props: ReorderProps<Y> & RefAttributes<HTMLUListElement>): JSX.Element;
46
38
  } & ComponentArgs;
47
39
 
48
- export { Reorder, type ReorderGenerateItem, type ReorderProps, ReorderProvider, useReorderContext };
40
+ export { Reorder, type ReorderGenerateItem, type ReorderProps };
package/dist/reorder.js CHANGED
@@ -21,26 +21,31 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  // src/reorder.tsx
22
22
  var reorder_exports = {};
23
23
  __export(reorder_exports, {
24
- Reorder: () => Reorder,
25
- ReorderProvider: () => ReorderProvider,
26
- useReorderContext: () => useReorderContext
24
+ Reorder: () => Reorder
27
25
  });
28
26
  module.exports = __toCommonJS(reorder_exports);
29
27
  var import_core2 = require("@yamada-ui/core");
30
28
  var import_motion2 = require("@yamada-ui/motion");
31
- var import_utils2 = require("@yamada-ui/utils");
29
+ var import_utils3 = require("@yamada-ui/utils");
32
30
  var import_react2 = require("react");
33
31
 
34
- // src/reorder-item.tsx
35
- var import_core = require("@yamada-ui/core");
36
- var import_motion = require("@yamada-ui/motion");
32
+ // src/reorder-context.ts
37
33
  var import_utils = require("@yamada-ui/utils");
38
- var import_react = require("react");
39
- var import_jsx_runtime = require("react/jsx-runtime");
34
+ var [ReorderProvider, useReorderContext] = (0, import_utils.createContext)({
35
+ name: "ReorderContext",
36
+ errorMessage: `useReorderContext returned is 'undefined'. Seems you forgot to wrap the components in "<Reorder />"`
37
+ });
40
38
  var [ReorderItemProvider, useReorderItemContext] = (0, import_utils.createContext)({
41
39
  name: "ReorderContext",
42
40
  errorMessage: `useReorderItemContext returned is 'undefined'. Seems you forgot to wrap the components in "<ReorderItem />"`
43
41
  });
42
+
43
+ // src/reorder-item.tsx
44
+ var import_core = require("@yamada-ui/core");
45
+ var import_motion = require("@yamada-ui/motion");
46
+ var import_utils2 = require("@yamada-ui/utils");
47
+ var import_react = require("react");
48
+ var import_jsx_runtime = require("react/jsx-runtime");
44
49
  var ReorderItem = (0, import_react.forwardRef)(
45
50
  ({ className, label, value, children, ...rest }, ref) => {
46
51
  var _a;
@@ -84,13 +89,13 @@ var ReorderItem = (0, import_react.forwardRef)(
84
89
  {
85
90
  ref,
86
91
  as: import_motion.MotionReorder.Item,
87
- className: (0, import_utils.cx)("ui-reorder__item", className),
92
+ className: (0, import_utils2.cx)("ui-reorder__item", className),
88
93
  value,
89
94
  __css: css,
90
95
  ...rest,
91
96
  dragListener: !hasTrigger,
92
97
  dragControls,
93
- "data-selected": (0, import_utils.dataAttr)(isDrag),
98
+ "data-selected": (0, import_utils2.dataAttr)(isDrag),
94
99
  style: { ...rest.style, x, y },
95
100
  children: children != null ? children : label
96
101
  }
@@ -101,17 +106,13 @@ ReorderItem.displayName = "ReorderItem";
101
106
 
102
107
  // src/reorder.tsx
103
108
  var import_jsx_runtime2 = require("react/jsx-runtime");
104
- var [ReorderProvider, useReorderContext] = (0, import_utils2.createContext)({
105
- name: "ReorderContext",
106
- errorMessage: `useReorderContext returned is 'undefined'. Seems you forgot to wrap the components in "<Reorder />"`
107
- });
108
109
  var omitDuplicated = (values) => Array.from(new Set(values));
109
110
  var pickDuplicated = (values) => values.filter(
110
111
  (value, index, self) => self.indexOf(value) === index && index !== self.lastIndexOf(value)
111
112
  );
112
113
  var Reorder = (0, import_react2.forwardRef)(
113
114
  (props, ref) => {
114
- const [styles, mergedProps] = (0, import_core2.useMultiComponentStyle)("Reorder", props);
115
+ const [styles, mergedProps] = (0, import_core2.useComponentMultiStyle)("Reorder", props);
115
116
  const {
116
117
  className,
117
118
  orientation = "vertical",
@@ -123,7 +124,7 @@ var Reorder = (0, import_react2.forwardRef)(
123
124
  ...rest
124
125
  } = (0, import_core2.omitThemeProps)(mergedProps);
125
126
  const axis = orientation === "vertical" ? "y" : "x";
126
- const validChildren = (0, import_utils2.getValidChildren)(children);
127
+ const validChildren = (0, import_utils3.getValidChildren)(children);
127
128
  const hasChildren = !!validChildren.length;
128
129
  const defaultValues = (0, import_react2.useMemo)(() => {
129
130
  const values2 = hasChildren ? validChildren.map(({ props: props2 }) => props2.value) : items.map(({ value }) => value);
@@ -152,7 +153,7 @@ var Reorder = (0, import_react2.forwardRef)(
152
153
  prevValues.current = values;
153
154
  onCompleteChange == null ? void 0 : onCompleteChange(values);
154
155
  }, [onCompleteChange, values]);
155
- (0, import_utils2.useUpdateEffect)(() => {
156
+ (0, import_utils3.useUpdateEffect)(() => {
156
157
  const isEqual = JSON.stringify(defaultValues) === JSON.stringify(prevDefaultValues.current);
157
158
  if (isEqual) return;
158
159
  prevValues.current = defaultValues;
@@ -181,14 +182,14 @@ var Reorder = (0, import_react2.forwardRef)(
181
182
  {
182
183
  ref,
183
184
  as: import_motion2.MotionReorder.Group,
184
- className: (0, import_utils2.cx)("ui-reorder", className),
185
+ className: (0, import_utils3.cx)("ui-reorder", className),
185
186
  axis,
186
187
  values,
187
188
  onReorder,
188
189
  __css: css,
189
190
  ...rest,
190
- onMouseUp: (0, import_utils2.handlerAll)(rest.onMouseUp, onCompleteReorder),
191
- onTouchEnd: (0, import_utils2.handlerAll)(rest.onTouchEnd, onCompleteReorder),
191
+ onMouseUp: (0, import_utils3.handlerAll)(rest.onMouseUp, onCompleteReorder),
192
+ onTouchEnd: (0, import_utils3.handlerAll)(rest.onTouchEnd, onCompleteReorder),
192
193
  children: cloneChildren
193
194
  }
194
195
  ) });
@@ -197,8 +198,6 @@ var Reorder = (0, import_react2.forwardRef)(
197
198
  Reorder.displayName = "Reorder";
198
199
  // Annotate the CommonJS export names for ESM import in node:
199
200
  0 && (module.exports = {
200
- Reorder,
201
- ReorderProvider,
202
- useReorderContext
201
+ Reorder
203
202
  });
204
203
  //# sourceMappingURL=reorder.js.map