@yamada-ui/react 2.2.11-dev-20261023062215 → 2.2.11-dev-20261024022120
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.
- package/dist/cjs/components/reorder/use-reorder.cjs +2 -1
- package/dist/cjs/components/reorder/use-reorder.cjs.map +1 -1
- package/dist/esm/components/reorder/use-reorder.js +2 -1
- package/dist/esm/components/reorder/use-reorder.js.map +1 -1
- package/dist/types/components/autocomplete/autocomplete.style.d.ts +1 -1
- package/dist/types/components/calendar/calendar.style.d.ts +2 -2
- package/dist/types/components/color-selector/color-selector.style.d.ts +2 -2
- package/dist/types/components/editable/editable.d.ts +1 -1
- package/dist/types/components/editable/editable.style.d.ts +1 -1
- package/dist/types/components/number-input/number-input.style.d.ts +1 -1
- package/dist/types/components/reorder/use-reorder.d.ts +1 -1
- package/package.json +2 -2
|
@@ -12,9 +12,10 @@ const getAlternativeValue = ({ children, label } = {}) => serializeValue(childre
|
|
|
12
12
|
const serializeValue = (value) => (0, require_utils_index.utils_exports.isObject)(value) || (0, require_utils_index.utils_exports.isArray)(value) ? JSON.stringify(value) : value;
|
|
13
13
|
const [ReorderContext, useReorderContext] = require_context.createContext({ name: "ReorderContext" });
|
|
14
14
|
const [ReorderItemContext, useReorderItemContext] = require_context.createContext({ name: "ReorderItemContext" });
|
|
15
|
-
const useReorder = ({ ref, children, item, items = [], orientation = "vertical", onChange, onCompleteChange, ...rest } = {}) => {
|
|
15
|
+
const useReorder = ({ ref, children, item: itemProp, items = [], orientation = "vertical", onChange, onCompleteChange, ...rest } = {}) => {
|
|
16
16
|
const axis = orientation === "vertical" ? "y" : "x";
|
|
17
17
|
const validChildren = require_children.useValidChildren(children);
|
|
18
|
+
const [item] = require_children.useValidChildren(itemProp);
|
|
18
19
|
const hasChildren = !!validChildren.length;
|
|
19
20
|
const defaultValues = (0, react.useMemo)(() => {
|
|
20
21
|
const values = hasChildren ? validChildren.map(({ props }) => props.value ?? getAlternativeValue(props)) : items.map((props) => props.value ?? getAlternativeValue(props));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-reorder.cjs","names":["createContext","useValidChildren","useMemo","useRef","useState","cloneElement","useCallback","mergeProps","useDragControls","useMotionValue","mergeRefs"],"sources":["../../../../src/components/reorder/use-reorder.ts"],"sourcesContent":["\"use client\"\n\nimport type { HTMLMotionProps, Reorder } from \"motion/react\"\nimport type { PropsWithChildren, ReactElement, ReactNode } from \"react\"\nimport type { Orientation, PropGetter } from \"../../core\"\nimport type { Dict, Merge } from \"../../utils\"\nimport { useDragControls, useMotionValue } from \"motion/react\"\nimport {\n cloneElement,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\"\nimport { mergeProps } from \"../../core\"\nimport {\n createContext,\n dataAttr,\n handlerAll,\n isArray,\n isObject,\n mergeRefs,\n useUpdateEffect,\n useValidChildren,\n} from \"../../utils\"\n\nconst getAlternativeValue = ({ children, label }: Dict = {}) =>\n serializeValue(children ?? label)\n\nconst serializeValue = (value: any) =>\n isObject(value) || isArray(value) ? JSON.stringify(value) : value\n\ntype ReorderGroupProps<Y = string> = Merge<\n HTMLMotionProps<\"ul\">,\n Pick<\n Parameters<typeof Reorder.Group<Y[]>>[0],\n \"axis\" | \"onReorder\" | \"values\"\n >\n>\ntype ReorderItemProps<Y = string> = Merge<\n HTMLMotionProps<\"li\">,\n Partial<Pick<Parameters<typeof Reorder.Item<Y>>[0], \"layout\" | \"value\">>\n>\n\ninterface ReorderContext extends Pick<UseReorderProps, \"orientation\"> {}\n\nconst [ReorderContext, useReorderContext] = createContext<ReorderContext>({\n name: \"ReorderContext\",\n})\n\nexport { ReorderContext, useReorderContext }\n\ninterface ReorderItemContext {\n getTriggerProps: PropGetter\n}\n\nconst [ReorderItemContext, useReorderItemContext] =\n createContext<ReorderItemContext>({\n name: \"ReorderItemContext\",\n })\n\nexport { ReorderItemContext, useReorderItemContext }\n\nexport interface UseReorderProps<Y = string>\n extends\n Partial<Omit<ReorderGroupProps<Y>, \"children\" | \"onChange\" | \"values\">>,\n PropsWithChildren {\n /**\n * The component to be used for the item.\n */\n item?: ReactElement<any>\n /**\n * If provided, generate reorder items based on items.\n *\n */\n items?: UseReorderItemProps<Y>[]\n /**\n * The orientation of the reorder.\n *\n * @default 'vertical'\n */\n orientation?: Orientation\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 const useReorder = <Y = string>({\n ref,\n children,\n item,\n items = [],\n orientation = \"vertical\",\n onChange,\n onCompleteChange,\n ...rest\n}: UseReorderProps<Y> = {}) => {\n const axis = orientation === \"vertical\" ? \"y\" : \"x\"\n const validChildren = useValidChildren(children)\n const hasChildren = !!validChildren.length\n const defaultValues = useMemo(() => {\n const values = hasChildren\n ? validChildren.map(\n ({ props }) => props.value ?? getAlternativeValue(props),\n )\n : items.map((props) => props.value ?? getAlternativeValue(props))\n\n const duplicatedValues = values.filter(\n (value, index, self) =>\n self.indexOf(value) === index && index !== self.lastIndexOf(value),\n )\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 Array.from(new Set(values))\n }, [hasChildren, validChildren, items])\n const childMap = useMemo(() => {\n return Object.fromEntries(\n validChildren.map((child) => [\n serializeValue(child.props.value) ??\n serializeValue(getAlternativeValue(child.props)),\n child,\n ]),\n )\n }, [validChildren])\n const itemMap = useMemo(() => {\n return Object.fromEntries(\n items.map((props) => [\n serializeValue(props.value) ??\n serializeValue(getAlternativeValue(props)),\n props,\n ]),\n )\n }, [items])\n const prevDefaultValues = useRef<Y[]>(defaultValues)\n const [values, setValues] = useState<Y[]>(defaultValues)\n const prevValues = useRef<Y[]>(defaultValues)\n const cloneChildren = useMemo(\n () =>\n values.map((value) => {\n if (hasChildren) {\n return childMap[serializeValue(value)]\n } else {\n const props = itemMap[serializeValue(value)]\n\n return props && item\n ? cloneElement(item, { key: serializeValue(props.value), ...props })\n : null\n }\n }),\n [values, hasChildren, childMap, itemMap, item],\n )\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 equal = JSON.stringify(prevValues.current) === JSON.stringify(values)\n\n if (equal) return\n\n prevValues.current = values\n\n onCompleteChange?.(values)\n }, [onCompleteChange, values])\n\n useUpdateEffect(() => {\n const equal =\n JSON.stringify(defaultValues) ===\n JSON.stringify(prevDefaultValues.current)\n\n if (equal) return\n\n prevValues.current = defaultValues\n prevDefaultValues.current = defaultValues\n\n setValues(defaultValues)\n }, [defaultValues])\n\n const getRootProps: PropGetter<\n Partial<Omit<ReorderGroupProps<Y>, \"values\">>,\n undefined,\n ReorderGroupProps<Y>\n > = useCallback(\n (props = {}) =>\n mergeProps(\n { axis, values },\n rest,\n props,\n { ref },\n {\n onMouseUp: onCompleteReorder,\n onReorder,\n onTouchEnd: onCompleteReorder,\n },\n )(),\n [rest, ref, onCompleteReorder, onReorder, axis, values],\n )\n\n return { children: cloneChildren, orientation, values, getRootProps }\n}\n\nexport type UseReorderReturn<Y = string> = ReturnType<typeof useReorder<Y>>\n\nexport interface UseReorderItemProps<Y = string> extends ReorderItemProps<Y> {\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 const useReorderItem = <Y = string>({\n ref,\n label,\n value,\n ...rest\n}: UseReorderItemProps<Y>) => {\n const { orientation } = useReorderContext()\n const dragControls = useDragControls()\n const [hasTrigger, setHasTrigger] = useState<boolean>(false)\n const [drag, setDrag] = useState<boolean>(false)\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\") setDrag(x !== 0)\n })\n const unsubscribeY = y.on(\"change\", (y) => {\n if (orientation === \"vertical\") setDrag(y !== 0)\n })\n\n return () => {\n unsubscribeX()\n unsubscribeY()\n }\n }, [orientation, x, y])\n\n const getItemProps: PropGetter<\n Omit<HTMLMotionProps<\"li\">, \"layout\" | \"value\"> &\n Pick<ReorderItemProps<Y>, \"layout\">,\n undefined,\n ReorderItemProps<Y>\n > = useCallback(\n (props = {}) => {\n const children = props.children ?? rest.children ?? label\n\n const merged = mergeProps(\n {\n \"data-has-trigger\": dataAttr(hasTrigger),\n \"data-selected\": dataAttr(drag),\n dragControls,\n dragListener: !hasTrigger,\n value: value ?? getAlternativeValue({ children }),\n },\n props,\n rest,\n { ref },\n )()\n\n return {\n ...merged,\n style: { x, y, ...props.style, ...rest.style },\n children,\n }\n },\n [ref, rest, dragControls, hasTrigger, value, x, y, drag, label],\n )\n\n const getTriggerProps: PropGetter = useCallback(\n (props = {}) => ({\n ...props,\n ref: mergeRefs(register, props.ref),\n \"data-selected\": dataAttr(drag),\n onPointerDown: handlerAll(props.onPointerDown, (ev) =>\n dragControls.start(ev),\n ),\n }),\n [drag, dragControls, register],\n )\n\n return { getItemProps, getTriggerProps }\n}\n\nexport type UseReorderItemReturn<Y = string> = ReturnType<\n typeof useReorderItem<Y>\n>\n"],"mappings":";;;;;;;;;;AA2BA,MAAM,uBAAuB,EAAE,UAAU,UAAgB,CAAC,MACxD,eAAe,YAAY,KAAK;AAElC,MAAM,kBAAkB,WAAA,GAAA,oBAAA,cACtB,SAAA,CAAS,KAAK,MAAA,GAAA,oBAAA,cAAK,QAAA,CAAQ,KAAK,IAAI,KAAK,UAAU,KAAK,IAAI;AAgB9D,MAAM,CAAC,gBAAgB,qBAAqBA,gBAAAA,cAA8B,EACxE,MAAM,iBACR,CAAC;AAQD,MAAM,CAAC,oBAAoB,yBACzBA,gBAAAA,cAAkC,EAChC,MAAM,qBACR,CAAC;AA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GAZaD,MAAAA,YAAAA,EACjC,QAAQ,CAAC,OAAO;GACf,GAAG;GACH,KAAKI,YAAAA,UAAU,UAAU,MAAM,GAAG;GAClC,kBAAA,GAAA,oBAAA,cAAiB,SAAA,CAAS,IAAI;GAC9B,gBAAA,GAAA,oBAAA,cAAe,WAAA,CAAW,MAAM,gBAAgB,OAC9C,aAAa,MAAM,EAAE,CACvB;EACF,IACA;GAAC;GAAM;GAAc;EAAQ,CAGM;CAAE;AACzC"}
|
|
1
|
+
{"version":3,"file":"use-reorder.cjs","names":["createContext","useValidChildren","useMemo","useRef","useState","cloneElement","useCallback","mergeProps","useDragControls","useMotionValue","mergeRefs"],"sources":["../../../../src/components/reorder/use-reorder.ts"],"sourcesContent":["\"use client\"\n\nimport type { HTMLMotionProps, Reorder } from \"motion/react\"\nimport type { PropsWithChildren, ReactElement, ReactNode } from \"react\"\nimport type { Orientation, PropGetter } from \"../../core\"\nimport type { Dict, Merge } from \"../../utils\"\nimport { useDragControls, useMotionValue } from \"motion/react\"\nimport {\n cloneElement,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\"\nimport { mergeProps } from \"../../core\"\nimport {\n createContext,\n dataAttr,\n handlerAll,\n isArray,\n isObject,\n mergeRefs,\n useUpdateEffect,\n useValidChildren,\n} from \"../../utils\"\n\nconst getAlternativeValue = ({ children, label }: Dict = {}) =>\n serializeValue(children ?? label)\n\nconst serializeValue = (value: any) =>\n isObject(value) || isArray(value) ? JSON.stringify(value) : value\n\ntype ReorderGroupProps<Y = string> = Merge<\n HTMLMotionProps<\"ul\">,\n Pick<\n Parameters<typeof Reorder.Group<Y[]>>[0],\n \"axis\" | \"onReorder\" | \"values\"\n >\n>\ntype ReorderItemProps<Y = string> = Merge<\n HTMLMotionProps<\"li\">,\n Partial<Pick<Parameters<typeof Reorder.Item<Y>>[0], \"layout\" | \"value\">>\n>\n\ninterface ReorderContext extends Pick<UseReorderProps, \"orientation\"> {}\n\nconst [ReorderContext, useReorderContext] = createContext<ReorderContext>({\n name: \"ReorderContext\",\n})\n\nexport { ReorderContext, useReorderContext }\n\ninterface ReorderItemContext {\n getTriggerProps: PropGetter\n}\n\nconst [ReorderItemContext, useReorderItemContext] =\n createContext<ReorderItemContext>({\n name: \"ReorderItemContext\",\n })\n\nexport { ReorderItemContext, useReorderItemContext }\n\nexport interface UseReorderProps<Y = string>\n extends\n Partial<Omit<ReorderGroupProps<Y>, \"children\" | \"onChange\" | \"values\">>,\n PropsWithChildren {\n /**\n * The component to be used for the item.\n */\n item?: ReactElement<any>\n /**\n * If provided, generate reorder items based on items.\n *\n */\n items?: UseReorderItemProps<Y>[]\n /**\n * The orientation of the reorder.\n *\n * @default 'vertical'\n */\n orientation?: Orientation\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 const useReorder = <Y = string>({\n ref,\n children,\n item: itemProp,\n items = [],\n orientation = \"vertical\",\n onChange,\n onCompleteChange,\n ...rest\n}: UseReorderProps<Y> = {}) => {\n const axis = orientation === \"vertical\" ? \"y\" : \"x\"\n const validChildren = useValidChildren(children)\n const [item] = useValidChildren(itemProp)\n const hasChildren = !!validChildren.length\n const defaultValues = useMemo(() => {\n const values = hasChildren\n ? validChildren.map(\n ({ props }) => props.value ?? getAlternativeValue(props),\n )\n : items.map((props) => props.value ?? getAlternativeValue(props))\n\n const duplicatedValues = values.filter(\n (value, index, self) =>\n self.indexOf(value) === index && index !== self.lastIndexOf(value),\n )\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 Array.from(new Set(values))\n }, [hasChildren, validChildren, items])\n const childMap = useMemo(() => {\n return Object.fromEntries(\n validChildren.map((child) => [\n serializeValue(child.props.value) ??\n serializeValue(getAlternativeValue(child.props)),\n child,\n ]),\n )\n }, [validChildren])\n const itemMap = useMemo(() => {\n return Object.fromEntries(\n items.map((props) => [\n serializeValue(props.value) ??\n serializeValue(getAlternativeValue(props)),\n props,\n ]),\n )\n }, [items])\n const prevDefaultValues = useRef<Y[]>(defaultValues)\n const [values, setValues] = useState<Y[]>(defaultValues)\n const prevValues = useRef<Y[]>(defaultValues)\n const cloneChildren = useMemo(\n () =>\n values.map((value) => {\n if (hasChildren) {\n return childMap[serializeValue(value)]\n } else {\n const props = itemMap[serializeValue(value)]\n\n return props && item\n ? cloneElement(item, { key: serializeValue(props.value), ...props })\n : null\n }\n }),\n [values, hasChildren, childMap, itemMap, item],\n )\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 equal = JSON.stringify(prevValues.current) === JSON.stringify(values)\n\n if (equal) return\n\n prevValues.current = values\n\n onCompleteChange?.(values)\n }, [onCompleteChange, values])\n\n useUpdateEffect(() => {\n const equal =\n JSON.stringify(defaultValues) ===\n JSON.stringify(prevDefaultValues.current)\n\n if (equal) return\n\n prevValues.current = defaultValues\n prevDefaultValues.current = defaultValues\n\n setValues(defaultValues)\n }, [defaultValues])\n\n const getRootProps: PropGetter<\n Partial<Omit<ReorderGroupProps<Y>, \"values\">>,\n undefined,\n ReorderGroupProps<Y>\n > = useCallback(\n (props = {}) =>\n mergeProps(\n { axis, values },\n rest,\n props,\n { ref },\n {\n onMouseUp: onCompleteReorder,\n onReorder,\n onTouchEnd: onCompleteReorder,\n },\n )(),\n [rest, ref, onCompleteReorder, onReorder, axis, values],\n )\n\n return { children: cloneChildren, orientation, values, getRootProps }\n}\n\nexport type UseReorderReturn<Y = string> = ReturnType<typeof useReorder<Y>>\n\nexport interface UseReorderItemProps<Y = string> extends ReorderItemProps<Y> {\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 const useReorderItem = <Y = string>({\n ref,\n label,\n value,\n ...rest\n}: UseReorderItemProps<Y>) => {\n const { orientation } = useReorderContext()\n const dragControls = useDragControls()\n const [hasTrigger, setHasTrigger] = useState<boolean>(false)\n const [drag, setDrag] = useState<boolean>(false)\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\") setDrag(x !== 0)\n })\n const unsubscribeY = y.on(\"change\", (y) => {\n if (orientation === \"vertical\") setDrag(y !== 0)\n })\n\n return () => {\n unsubscribeX()\n unsubscribeY()\n }\n }, [orientation, x, y])\n\n const getItemProps: PropGetter<\n Omit<HTMLMotionProps<\"li\">, \"layout\" | \"value\"> &\n Pick<ReorderItemProps<Y>, \"layout\">,\n undefined,\n ReorderItemProps<Y>\n > = useCallback(\n (props = {}) => {\n const children = props.children ?? rest.children ?? label\n\n const merged = mergeProps(\n {\n \"data-has-trigger\": dataAttr(hasTrigger),\n \"data-selected\": dataAttr(drag),\n dragControls,\n dragListener: !hasTrigger,\n value: value ?? getAlternativeValue({ children }),\n },\n props,\n rest,\n { ref },\n )()\n\n return {\n ...merged,\n style: { x, y, ...props.style, ...rest.style },\n children,\n }\n },\n [ref, rest, dragControls, hasTrigger, value, x, y, drag, label],\n )\n\n const getTriggerProps: PropGetter = useCallback(\n (props = {}) => ({\n ...props,\n ref: mergeRefs(register, props.ref),\n \"data-selected\": dataAttr(drag),\n onPointerDown: handlerAll(props.onPointerDown, (ev) =>\n dragControls.start(ev),\n ),\n }),\n [drag, dragControls, register],\n )\n\n return { getItemProps, getTriggerProps }\n}\n\nexport type UseReorderItemReturn<Y = string> = ReturnType<\n typeof useReorderItem<Y>\n>\n"],"mappings":";;;;;;;;;;AA2BA,MAAM,uBAAuB,EAAE,UAAU,UAAgB,CAAC,MACxD,eAAe,YAAY,KAAK;AAElC,MAAM,kBAAkB,WA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AA,GAAA,oBAAA,cAAiB,SAAA,CAAS,IAAI;KAC9B;KACA,cAAc,CAAC;KACf,OAAO,SAAS,oBAAoB,EAAE,SAAS,CAAC;IAClD,GACA,OACA,MACA,EAAE,IAAI,CACR,CAAC,CAGS;IACR,OAAO;KAAE;KAAG;KAAG,GAAG,MAAM;KAAO,GAAG,KAAK;IAAM;IAC7C;GACF;EACF,GACA;GAAC;GAAK;GAAM;GAAc;GAAY;GAAO;GAAG;GAAG;GAAM;EAAK,CAe5C;EAAG,kBAAA,GAZaD,MAAAA,YAAAA,EACjC,QAAQ,CAAC,OAAO;GACf,GAAG;GACH,KAAKI,YAAAA,UAAU,UAAU,MAAM,GAAG;GAClC,kBAAA,GAAA,oBAAA,cAAiB,SAAA,CAAS,IAAI;GAC9B,gBAAA,GAAA,oBAAA,cAAe,WAAA,CAAW,MAAM,gBAAgB,OAC9C,aAAa,MAAM,EAAE,CACvB;EACF,IACA;GAAC;GAAM;GAAc;EAAQ,CAGM;CAAE;AACzC"}
|
|
@@ -12,9 +12,10 @@ const getAlternativeValue = ({ children, label } = {}) => serializeValue(childre
|
|
|
12
12
|
const serializeValue = (value) => (0, utils_exports.isObject)(value) || (0, utils_exports.isArray)(value) ? JSON.stringify(value) : value;
|
|
13
13
|
const [ReorderContext, useReorderContext] = createContext$1({ name: "ReorderContext" });
|
|
14
14
|
const [ReorderItemContext, useReorderItemContext] = createContext$1({ name: "ReorderItemContext" });
|
|
15
|
-
const useReorder = ({ ref, children, item, items = [], orientation = "vertical", onChange, onCompleteChange, ...rest } = {}) => {
|
|
15
|
+
const useReorder = ({ ref, children, item: itemProp, items = [], orientation = "vertical", onChange, onCompleteChange, ...rest } = {}) => {
|
|
16
16
|
const axis = orientation === "vertical" ? "y" : "x";
|
|
17
17
|
const validChildren = useValidChildren(children);
|
|
18
|
+
const [item] = useValidChildren(itemProp);
|
|
18
19
|
const hasChildren = !!validChildren.length;
|
|
19
20
|
const defaultValues = useMemo(() => {
|
|
20
21
|
const values = hasChildren ? validChildren.map(({ props }) => props.value ?? getAlternativeValue(props)) : items.map((props) => props.value ?? getAlternativeValue(props));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-reorder.js","names":["isObject","isArray","createContext","dataAttr","handlerAll"],"sources":["../../../../src/components/reorder/use-reorder.ts"],"sourcesContent":["\"use client\"\n\nimport type { HTMLMotionProps, Reorder } from \"motion/react\"\nimport type { PropsWithChildren, ReactElement, ReactNode } from \"react\"\nimport type { Orientation, PropGetter } from \"../../core\"\nimport type { Dict, Merge } from \"../../utils\"\nimport { useDragControls, useMotionValue } from \"motion/react\"\nimport {\n cloneElement,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\"\nimport { mergeProps } from \"../../core\"\nimport {\n createContext,\n dataAttr,\n handlerAll,\n isArray,\n isObject,\n mergeRefs,\n useUpdateEffect,\n useValidChildren,\n} from \"../../utils\"\n\nconst getAlternativeValue = ({ children, label }: Dict = {}) =>\n serializeValue(children ?? label)\n\nconst serializeValue = (value: any) =>\n isObject(value) || isArray(value) ? JSON.stringify(value) : value\n\ntype ReorderGroupProps<Y = string> = Merge<\n HTMLMotionProps<\"ul\">,\n Pick<\n Parameters<typeof Reorder.Group<Y[]>>[0],\n \"axis\" | \"onReorder\" | \"values\"\n >\n>\ntype ReorderItemProps<Y = string> = Merge<\n HTMLMotionProps<\"li\">,\n Partial<Pick<Parameters<typeof Reorder.Item<Y>>[0], \"layout\" | \"value\">>\n>\n\ninterface ReorderContext extends Pick<UseReorderProps, \"orientation\"> {}\n\nconst [ReorderContext, useReorderContext] = createContext<ReorderContext>({\n name: \"ReorderContext\",\n})\n\nexport { ReorderContext, useReorderContext }\n\ninterface ReorderItemContext {\n getTriggerProps: PropGetter\n}\n\nconst [ReorderItemContext, useReorderItemContext] =\n createContext<ReorderItemContext>({\n name: \"ReorderItemContext\",\n })\n\nexport { ReorderItemContext, useReorderItemContext }\n\nexport interface UseReorderProps<Y = string>\n extends\n Partial<Omit<ReorderGroupProps<Y>, \"children\" | \"onChange\" | \"values\">>,\n PropsWithChildren {\n /**\n * The component to be used for the item.\n */\n item?: ReactElement<any>\n /**\n * If provided, generate reorder items based on items.\n *\n */\n items?: UseReorderItemProps<Y>[]\n /**\n * The orientation of the reorder.\n *\n * @default 'vertical'\n */\n orientation?: Orientation\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 const useReorder = <Y = string>({\n ref,\n children,\n item,\n items = [],\n orientation = \"vertical\",\n onChange,\n onCompleteChange,\n ...rest\n}: UseReorderProps<Y> = {}) => {\n const axis = orientation === \"vertical\" ? \"y\" : \"x\"\n const validChildren = useValidChildren(children)\n const hasChildren = !!validChildren.length\n const defaultValues = useMemo(() => {\n const values = hasChildren\n ? validChildren.map(\n ({ props }) => props.value ?? getAlternativeValue(props),\n )\n : items.map((props) => props.value ?? getAlternativeValue(props))\n\n const duplicatedValues = values.filter(\n (value, index, self) =>\n self.indexOf(value) === index && index !== self.lastIndexOf(value),\n )\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 Array.from(new Set(values))\n }, [hasChildren, validChildren, items])\n const childMap = useMemo(() => {\n return Object.fromEntries(\n validChildren.map((child) => [\n serializeValue(child.props.value) ??\n serializeValue(getAlternativeValue(child.props)),\n child,\n ]),\n )\n }, [validChildren])\n const itemMap = useMemo(() => {\n return Object.fromEntries(\n items.map((props) => [\n serializeValue(props.value) ??\n serializeValue(getAlternativeValue(props)),\n props,\n ]),\n )\n }, [items])\n const prevDefaultValues = useRef<Y[]>(defaultValues)\n const [values, setValues] = useState<Y[]>(defaultValues)\n const prevValues = useRef<Y[]>(defaultValues)\n const cloneChildren = useMemo(\n () =>\n values.map((value) => {\n if (hasChildren) {\n return childMap[serializeValue(value)]\n } else {\n const props = itemMap[serializeValue(value)]\n\n return props && item\n ? cloneElement(item, { key: serializeValue(props.value), ...props })\n : null\n }\n }),\n [values, hasChildren, childMap, itemMap, item],\n )\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 equal = JSON.stringify(prevValues.current) === JSON.stringify(values)\n\n if (equal) return\n\n prevValues.current = values\n\n onCompleteChange?.(values)\n }, [onCompleteChange, values])\n\n useUpdateEffect(() => {\n const equal =\n JSON.stringify(defaultValues) ===\n JSON.stringify(prevDefaultValues.current)\n\n if (equal) return\n\n prevValues.current = defaultValues\n prevDefaultValues.current = defaultValues\n\n setValues(defaultValues)\n }, [defaultValues])\n\n const getRootProps: PropGetter<\n Partial<Omit<ReorderGroupProps<Y>, \"values\">>,\n undefined,\n ReorderGroupProps<Y>\n > = useCallback(\n (props = {}) =>\n mergeProps(\n { axis, values },\n rest,\n props,\n { ref },\n {\n onMouseUp: onCompleteReorder,\n onReorder,\n onTouchEnd: onCompleteReorder,\n },\n )(),\n [rest, ref, onCompleteReorder, onReorder, axis, values],\n )\n\n return { children: cloneChildren, orientation, values, getRootProps }\n}\n\nexport type UseReorderReturn<Y = string> = ReturnType<typeof useReorder<Y>>\n\nexport interface UseReorderItemProps<Y = string> extends ReorderItemProps<Y> {\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 const useReorderItem = <Y = string>({\n ref,\n label,\n value,\n ...rest\n}: UseReorderItemProps<Y>) => {\n const { orientation } = useReorderContext()\n const dragControls = useDragControls()\n const [hasTrigger, setHasTrigger] = useState<boolean>(false)\n const [drag, setDrag] = useState<boolean>(false)\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\") setDrag(x !== 0)\n })\n const unsubscribeY = y.on(\"change\", (y) => {\n if (orientation === \"vertical\") setDrag(y !== 0)\n })\n\n return () => {\n unsubscribeX()\n unsubscribeY()\n }\n }, [orientation, x, y])\n\n const getItemProps: PropGetter<\n Omit<HTMLMotionProps<\"li\">, \"layout\" | \"value\"> &\n Pick<ReorderItemProps<Y>, \"layout\">,\n undefined,\n ReorderItemProps<Y>\n > = useCallback(\n (props = {}) => {\n const children = props.children ?? rest.children ?? label\n\n const merged = mergeProps(\n {\n \"data-has-trigger\": dataAttr(hasTrigger),\n \"data-selected\": dataAttr(drag),\n dragControls,\n dragListener: !hasTrigger,\n value: value ?? getAlternativeValue({ children }),\n },\n props,\n rest,\n { ref },\n )()\n\n return {\n ...merged,\n style: { x, y, ...props.style, ...rest.style },\n children,\n }\n },\n [ref, rest, dragControls, hasTrigger, value, x, y, drag, label],\n )\n\n const getTriggerProps: PropGetter = useCallback(\n (props = {}) => ({\n ...props,\n ref: mergeRefs(register, props.ref),\n \"data-selected\": dataAttr(drag),\n onPointerDown: handlerAll(props.onPointerDown, (ev) =>\n dragControls.start(ev),\n ),\n }),\n [drag, dragControls, register],\n )\n\n return { getItemProps, getTriggerProps }\n}\n\nexport type UseReorderItemReturn<Y = string> = ReturnType<\n typeof useReorderItem<Y>\n>\n"],"mappings":";;;;;;;;;;AA2BA,MAAM,uBAAuB,EAAE,UAAU,UAAgB,CAAC,MACxD,eAAe,YAAY,KAAK;AAElC,MAAM,kBAAkB,WAAA,GACtBA,cAAAA,SAAAA,CAAS,KAAK,MAAA,GAAKC,cAAAA,QAAAA,CAAQ,KAAK,IAAI,KAAK,UAAU,KAAK,IAAI;AAgB9D,MAAM,CAAC,gBAAgB,qBAAqBC,gBAA8B,EACxE,MAAM,iBACR,CAAC;AAQD,MAAM,CAAC,oBAAoB,yBACzBA,gBAAkC,EAChC,MAAM,qBACR,CAAC;AAiCH,MAAa,cAA0B,EACrC,K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E,GAAG,WAAW,MAAM;GACzC,IAAI,gBAAgB,cAAc,QAAQ,MAAM,CAAC;EACnD,CAAC;EACD,MAAM,eAAe,EAAE,GAAG,WAAW,MAAM;GACzC,IAAI,gBAAgB,YAAY,QAAQ,MAAM,CAAC;EACjD,CAAC;EAED,aAAa;GACX,aAAa;GACb,aAAa;EACf;CACF,GAAG;EAAC;EAAa;EAAG;CAAC,CAAC;CA6CtB,OAAO;EAAE,cAtCL,aACD,QAAQ,CAAC,MAAM;GACd,MAAM,WAAW,MAAM,YAAY,KAAK,YAAY;GAepD,OAAO;IACL,GAda,WACb;KACE,qBAAA,GAAoBC,cAAAA,SAAAA,CAAS,UAAU;KACvC,kBAAA,GAAiBA,cAAAA,SAAAA,CAAS,IAAI;KAC9B;KACA,cAAc,CAAC;KACf,OAAO,SAAS,oBAAoB,EAAE,SAAS,CAAC;IAClD,GACA,OACA,MACA,EAAE,IAAI,CACR,CAAC,CAGS;IACR,OAAO;KAAE;KAAG;KAAG,GAAG,MAAM;KAAO,GAAG,KAAK;IAAM;IAC7C;GACF;EACF,GACA;GAAC;GAAK;GAAM;GAAc;GAAY;GAAO;GAAG;GAAG;GAAM;EAAK,CAe5C;EAAG,iBAZa,aACjC,QAAQ,CAAC,OAAO;GACf,GAAG;GACH,KAAK,UAAU,UAAU,MAAM,GAAG;GAClC,kBAAA,GAAiBA,cAAAA,SAAAA,CAAS,IAAI;GAC9B,gBAAA,GAAeC,cAAAA,WAAAA,CAAW,MAAM,gBAAgB,OAC9C,aAAa,MAAM,EAAE,CACvB;EACF,IACA;GAAC;GAAM;GAAc;EAAQ,CAGM;CAAE;AACzC"}
|
|
1
|
+
{"version":3,"file":"use-reorder.js","names":["isObject","isArray","createContext","dataAttr","handlerAll"],"sources":["../../../../src/components/reorder/use-reorder.ts"],"sourcesContent":["\"use client\"\n\nimport type { HTMLMotionProps, Reorder } from \"motion/react\"\nimport type { PropsWithChildren, ReactElement, ReactNode } from \"react\"\nimport type { Orientation, PropGetter } from \"../../core\"\nimport type { Dict, Merge } from \"../../utils\"\nimport { useDragControls, useMotionValue } from \"motion/react\"\nimport {\n cloneElement,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\"\nimport { mergeProps } from \"../../core\"\nimport {\n createContext,\n dataAttr,\n handlerAll,\n isArray,\n isObject,\n mergeRefs,\n useUpdateEffect,\n useValidChildren,\n} from \"../../utils\"\n\nconst getAlternativeValue = ({ children, label }: Dict = {}) =>\n serializeValue(children ?? label)\n\nconst serializeValue = (value: any) =>\n isObject(value) || isArray(value) ? JSON.stringify(value) : value\n\ntype ReorderGroupProps<Y = string> = Merge<\n HTMLMotionProps<\"ul\">,\n Pick<\n Parameters<typeof Reorder.Group<Y[]>>[0],\n \"axis\" | \"onReorder\" | \"values\"\n >\n>\ntype ReorderItemProps<Y = string> = Merge<\n HTMLMotionProps<\"li\">,\n Partial<Pick<Parameters<typeof Reorder.Item<Y>>[0], \"layout\" | \"value\">>\n>\n\ninterface ReorderContext extends Pick<UseReorderProps, \"orientation\"> {}\n\nconst [ReorderContext, useReorderContext] = createContext<ReorderContext>({\n name: \"ReorderContext\",\n})\n\nexport { ReorderContext, useReorderContext }\n\ninterface ReorderItemContext {\n getTriggerProps: PropGetter\n}\n\nconst [ReorderItemContext, useReorderItemContext] =\n createContext<ReorderItemContext>({\n name: \"ReorderItemContext\",\n })\n\nexport { ReorderItemContext, useReorderItemContext }\n\nexport interface UseReorderProps<Y = string>\n extends\n Partial<Omit<ReorderGroupProps<Y>, \"children\" | \"onChange\" | \"values\">>,\n PropsWithChildren {\n /**\n * The component to be used for the item.\n */\n item?: ReactElement<any>\n /**\n * If provided, generate reorder items based on items.\n *\n */\n items?: UseReorderItemProps<Y>[]\n /**\n * The orientation of the reorder.\n *\n * @default 'vertical'\n */\n orientation?: Orientation\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 const useReorder = <Y = string>({\n ref,\n children,\n item: itemProp,\n items = [],\n orientation = \"vertical\",\n onChange,\n onCompleteChange,\n ...rest\n}: UseReorderProps<Y> = {}) => {\n const axis = orientation === \"vertical\" ? \"y\" : \"x\"\n const validChildren = useValidChildren(children)\n const [item] = useValidChildren(itemProp)\n const hasChildren = !!validChildren.length\n const defaultValues = useMemo(() => {\n const values = hasChildren\n ? validChildren.map(\n ({ props }) => props.value ?? getAlternativeValue(props),\n )\n : items.map((props) => props.value ?? getAlternativeValue(props))\n\n const duplicatedValues = values.filter(\n (value, index, self) =>\n self.indexOf(value) === index && index !== self.lastIndexOf(value),\n )\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 Array.from(new Set(values))\n }, [hasChildren, validChildren, items])\n const childMap = useMemo(() => {\n return Object.fromEntries(\n validChildren.map((child) => [\n serializeValue(child.props.value) ??\n serializeValue(getAlternativeValue(child.props)),\n child,\n ]),\n )\n }, [validChildren])\n const itemMap = useMemo(() => {\n return Object.fromEntries(\n items.map((props) => [\n serializeValue(props.value) ??\n serializeValue(getAlternativeValue(props)),\n props,\n ]),\n )\n }, [items])\n const prevDefaultValues = useRef<Y[]>(defaultValues)\n const [values, setValues] = useState<Y[]>(defaultValues)\n const prevValues = useRef<Y[]>(defaultValues)\n const cloneChildren = useMemo(\n () =>\n values.map((value) => {\n if (hasChildren) {\n return childMap[serializeValue(value)]\n } else {\n const props = itemMap[serializeValue(value)]\n\n return props && item\n ? cloneElement(item, { key: serializeValue(props.value), ...props })\n : null\n }\n }),\n [values, hasChildren, childMap, itemMap, item],\n )\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 equal = JSON.stringify(prevValues.current) === JSON.stringify(values)\n\n if (equal) return\n\n prevValues.current = values\n\n onCompleteChange?.(values)\n }, [onCompleteChange, values])\n\n useUpdateEffect(() => {\n const equal =\n JSON.stringify(defaultValues) ===\n JSON.stringify(prevDefaultValues.current)\n\n if (equal) return\n\n prevValues.current = defaultValues\n prevDefaultValues.current = defaultValues\n\n setValues(defaultValues)\n }, [defaultValues])\n\n const getRootProps: PropGetter<\n Partial<Omit<ReorderGroupProps<Y>, \"values\">>,\n undefined,\n ReorderGroupProps<Y>\n > = useCallback(\n (props = {}) =>\n mergeProps(\n { axis, values },\n rest,\n props,\n { ref },\n {\n onMouseUp: onCompleteReorder,\n onReorder,\n onTouchEnd: onCompleteReorder,\n },\n )(),\n [rest, ref, onCompleteReorder, onReorder, axis, values],\n )\n\n return { children: cloneChildren, orientation, values, getRootProps }\n}\n\nexport type UseReorderReturn<Y = string> = ReturnType<typeof useReorder<Y>>\n\nexport interface UseReorderItemProps<Y = string> extends ReorderItemProps<Y> {\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 const useReorderItem = <Y = string>({\n ref,\n label,\n value,\n ...rest\n}: UseReorderItemProps<Y>) => {\n const { orientation } = useReorderContext()\n const dragControls = useDragControls()\n const [hasTrigger, setHasTrigger] = useState<boolean>(false)\n const [drag, setDrag] = useState<boolean>(false)\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\") setDrag(x !== 0)\n })\n const unsubscribeY = y.on(\"change\", (y) => {\n if (orientation === \"vertical\") setDrag(y !== 0)\n })\n\n return () => {\n unsubscribeX()\n unsubscribeY()\n }\n }, [orientation, x, y])\n\n const getItemProps: PropGetter<\n Omit<HTMLMotionProps<\"li\">, \"layout\" | \"value\"> &\n Pick<ReorderItemProps<Y>, \"layout\">,\n undefined,\n ReorderItemProps<Y>\n > = useCallback(\n (props = {}) => {\n const children = props.children ?? rest.children ?? label\n\n const merged = mergeProps(\n {\n \"data-has-trigger\": dataAttr(hasTrigger),\n \"data-selected\": dataAttr(drag),\n dragControls,\n dragListener: !hasTrigger,\n value: value ?? getAlternativeValue({ children }),\n },\n props,\n rest,\n { ref },\n )()\n\n return {\n ...merged,\n style: { x, y, ...props.style, ...rest.style },\n children,\n }\n },\n [ref, rest, dragControls, hasTrigger, value, x, y, drag, label],\n )\n\n const getTriggerProps: PropGetter = useCallback(\n (props = {}) => ({\n ...props,\n ref: mergeRefs(register, props.ref),\n \"data-selected\": dataAttr(drag),\n onPointerDown: handlerAll(props.onPointerDown, (ev) =>\n dragControls.start(ev),\n ),\n }),\n [drag, dragControls, register],\n )\n\n return { getItemProps, getTriggerProps }\n}\n\nexport type UseReorderItemReturn<Y = string> = ReturnType<\n typeof useReorderItem<Y>\n>\n"],"mappings":";;;;;;;;;;AA2BA,MAAM,uBAAuB,EAAE,UAAU,UAAgB,CAAC,MACxD,eAAe,YAAY,KAAK;AAElC,MAAM,kBAAkB,WAAA,GACtBA,cAAAA,SAAAA,CAAS,KAAK,MAAA,GAAKC,cAAAA,QAAAA,CAAQ,KAAK,IAAI,KAAK,UAAU,KAAK,IAAI;AAgB9D,MAAM,CAAC,gBAAgB,qBAAqBC,gBAA8B,EACxE,MAAM,iBACR,CAAC;AAQD,MAAM,CAAC,oBAAoB,yBACzBA,gBAAkC,EAChC,MAAM,qBACR,CAAC;AAiCH,MAAa,cAA0B,EACrC,KACA,UACA,MAAM,UACN,QAAQ,CAAC,GACT,cAAc,YACd,UACA,kBACA,GAAG,SACmB,CAAC,MAAM;CAC7B,MAAM,OAAO,gBAAgB,aAAa,MAAM;CAChD,MAAM,gBAAgB,iBAAiB,QAAQ;CAC/C,MAAM,CAAC,QAAQ,iBAAiB,QAAQ;CACxC,MAAM,cAAc,CAAC,CAAC,cAAc;CACpC,MAAM,gBAAgB,cAAc;EAClC,MAAM,SAAS,cACX,c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G;CAAC,CAAC;CA6CtB,OAAO;EAAE,cAtCL,aACD,QAAQ,CAAC,MAAM;GACd,MAAM,WAAW,MAAM,YAAY,KAAK,YAAY;GAepD,OAAO;IACL,GAda,WACb;KACE,qBAAA,GAAoBC,cAAAA,SAAAA,CAAS,UAAU;KACvC,kBAAA,GAAiBA,cAAAA,SAAAA,CAAS,IAAI;KAC9B;KACA,cAAc,CAAC;KACf,OAAO,SAAS,oBAAoB,EAAE,SAAS,CAAC;IAClD,GACA,OACA,MACA,EAAE,IAAI,CACR,CAAC,CAGS;IACR,OAAO;KAAE;KAAG;KAAG,GAAG,MAAM;KAAO,GAAG,KAAK;IAAM;IAC7C;GACF;EACF,GACA;GAAC;GAAK;GAAM;GAAc;GAAY;GAAO;GAAG;GAAG;GAAM;EAAK,CAe5C;EAAG,iBAZa,aACjC,QAAQ,CAAC,OAAO;GACf,GAAG;GACH,KAAK,UAAU,UAAU,MAAM,GAAG;GAClC,kBAAA,GAAiBA,cAAAA,SAAAA,CAAS,IAAI;GAC9B,gBAAA,GAAeC,cAAAA,WAAAA,CAAW,MAAM,gBAAgB,OAC9C,aAAa,MAAM,EAAE,CACvB;EACF,IACA;GAAC;GAAM;GAAc;EAAQ,CAGM;CAAE;AACzC"}
|
|
@@ -2,7 +2,7 @@ import { ComponentSlotStyle } from "../../core/system/index.type.js";
|
|
|
2
2
|
import { CSSPropObject, CSSSlotObject } from "../../core/css/index.type.js";
|
|
3
3
|
import "../../index.js";
|
|
4
4
|
//#region src/components/autocomplete/autocomplete.style.d.ts
|
|
5
|
-
export declare const autocompleteStyle: ComponentSlotStyle<"input" | "label" | "option" | "content" | "group" | "separator" | "icon" | "root" | "indicator" | "field" | "
|
|
5
|
+
export declare const autocompleteStyle: ComponentSlotStyle<"input" | "label" | "option" | "content" | "group" | "separator" | "icon" | "root" | "indicator" | "field" | "valueText" | "empty", CSSPropObject<CSSSlotObject<"input" | "label" | "option" | "content" | "group" | "separator" | "icon" | "root" | "indicator" | "field" | "valueText" | "empty">>, {
|
|
6
6
|
xs: {
|
|
7
7
|
empty: {
|
|
8
8
|
gap: "1.5";
|
|
@@ -2,7 +2,7 @@ import { ComponentSlotStyle } from "../../core/system/index.type.js";
|
|
|
2
2
|
import { CSSModifierObject, CSSSlotObject } from "../../core/css/index.type.js";
|
|
3
3
|
import "../../index.js";
|
|
4
4
|
//#region src/components/calendar/calendar.style.d.ts
|
|
5
|
-
export declare const calendarStyle: ComponentSlotStyle<"button" | "select" | "cell" | "navigation" | "row" | "separator" | "next" | "root" | "month" | "week" | "control" | "weekday" | "day" | "months" | "years" | "weeks"
|
|
5
|
+
export declare const calendarStyle: ComponentSlotStyle<"button" | "select" | "cell" | "navigation" | "row" | "separator" | "next" | "root" | "month" | "week" | "prev" | "control" | "weekday" | "day" | "months" | "years" | "weeks", {
|
|
6
6
|
/**
|
|
7
7
|
* If `true`, the calendar will be fixed rows.
|
|
8
8
|
*
|
|
@@ -74,7 +74,7 @@ export declare const calendarStyle: ComponentSlotStyle<"button" | "select" | "ce
|
|
|
74
74
|
"--font-size": "fontSizes.xl";
|
|
75
75
|
};
|
|
76
76
|
};
|
|
77
|
-
}, CSSModifierObject<CSSSlotObject<"button" | "select" | "cell" | "navigation" | "row" | "separator" | "next" | "root" | "month" | "week" | "control" | "weekday" | "day" | "months" | "years" | "weeks"
|
|
77
|
+
}, CSSModifierObject<CSSSlotObject<"button" | "select" | "cell" | "navigation" | "row" | "separator" | "next" | "root" | "month" | "week" | "prev" | "control" | "weekday" | "day" | "months" | "years" | "weeks">>>;
|
|
78
78
|
export type CalendarStyle = typeof calendarStyle;
|
|
79
79
|
//#endregion
|
|
80
80
|
//# sourceMappingURL=calendar.style.d.ts.map
|
|
@@ -2,7 +2,7 @@ import { ComponentSlotStyle } from "../../core/system/index.type.js";
|
|
|
2
2
|
import { CSSModifierObject, CSSSlotObject } from "../../core/css/index.type.js";
|
|
3
3
|
import "../../index.js";
|
|
4
4
|
//#region src/components/color-selector/color-selector.style.d.ts
|
|
5
|
-
export declare const colorSelectorStyle: ComponentSlotStyle<"root" | "hueSlider" | "saturationSlider" | "eyeDropper" | "
|
|
5
|
+
export declare const colorSelectorStyle: ComponentSlotStyle<"root" | "hueSlider" | "saturationSlider" | "eyeDropper" | "alphaSlider" | "colorSwatchGroup" | "colorSwatchGroupLabel" | "colorSwatchItem", {
|
|
6
6
|
/**
|
|
7
7
|
* The shape of the thumb and color swatch.
|
|
8
8
|
*
|
|
@@ -23,7 +23,7 @@ export declare const colorSelectorStyle: ComponentSlotStyle<"root" | "hueSlider"
|
|
|
23
23
|
md: {};
|
|
24
24
|
lg: {};
|
|
25
25
|
xl: {};
|
|
26
|
-
}, CSSModifierObject<CSSSlotObject<"root" | "hueSlider" | "saturationSlider" | "eyeDropper" | "
|
|
26
|
+
}, CSSModifierObject<CSSSlotObject<"root" | "hueSlider" | "saturationSlider" | "eyeDropper" | "alphaSlider" | "colorSwatchGroup" | "colorSwatchGroupLabel" | "colorSwatchItem">>>;
|
|
27
27
|
export type ColorSelectorStyle = typeof colorSelectorStyle;
|
|
28
28
|
//#endregion
|
|
29
29
|
//# sourceMappingURL=color-selector.style.d.ts.map
|
|
@@ -23,7 +23,7 @@ declare const EditablePropsContext: import("react").Context<Partial<EditableRoot
|
|
|
23
23
|
*
|
|
24
24
|
* @see https://yamada-ui.com/docs/components/editable
|
|
25
25
|
*/
|
|
26
|
-
export declare const EditableRoot: Component<({ children, errorBorderColor, focusBorderColor, ...props }: WithoutThemeProps<EditableRootProps, ComponentSlotStyle<"input" | "textarea" | "root" | "
|
|
26
|
+
export declare const EditableRoot: Component<({ children, errorBorderColor, focusBorderColor, ...props }: WithoutThemeProps<EditableRootProps, ComponentSlotStyle<"input" | "textarea" | "root" | "preview" | "control", CSSPropObject<CSSSlotObject<"input" | "textarea" | "root" | "preview" | "control">>, CSSModifierObject<CSSSlotObject<"input" | "textarea" | "root" | "preview" | "control">>, CSSModifierObject<CSSSlotObject<"input" | "textarea" | "root" | "preview" | "control">>>, keyof EditableRootProps>) => import("react").JSX.Element, EditableRootProps>;
|
|
27
27
|
export interface EditablePreviewProps extends HTMLStyledProps<"span"> {}
|
|
28
28
|
export declare const EditablePreview: Component<"span", EditablePreviewProps>;
|
|
29
29
|
export interface EditableInputProps extends HTMLStyledProps<"input"> {}
|
|
@@ -2,7 +2,7 @@ import { ComponentSlotStyle } from "../../core/system/index.type.js";
|
|
|
2
2
|
import { CSSModifierObject, CSSPropObject, CSSSlotObject } from "../../core/css/index.type.js";
|
|
3
3
|
import "../../index.js";
|
|
4
4
|
//#region src/components/editable/editable.style.d.ts
|
|
5
|
-
export declare const editableStyle: ComponentSlotStyle<"input" | "textarea" | "root" | "
|
|
5
|
+
export declare const editableStyle: ComponentSlotStyle<"input" | "textarea" | "root" | "preview" | "control", CSSPropObject<CSSSlotObject<"input" | "textarea" | "root" | "preview" | "control">>, CSSModifierObject<CSSSlotObject<"input" | "textarea" | "root" | "preview" | "control">>, CSSModifierObject<CSSSlotObject<"input" | "textarea" | "root" | "preview" | "control">>>;
|
|
6
6
|
export type EditableStyle = typeof editableStyle;
|
|
7
7
|
//#endregion
|
|
8
8
|
//# sourceMappingURL=editable.style.d.ts.map
|
|
@@ -2,7 +2,7 @@ import { ComponentSlotStyle } from "../../core/system/index.type.js";
|
|
|
2
2
|
import { CSSPropObject, CSSSlotObject } from "../../core/css/index.type.js";
|
|
3
3
|
import "../../index.js";
|
|
4
4
|
//#region src/components/number-input/number-input.style.d.ts
|
|
5
|
-
export declare const numberInputStyle: ComponentSlotStyle<"button" | "root" | "
|
|
5
|
+
export declare const numberInputStyle: ComponentSlotStyle<"button" | "root" | "field" | "decrement" | "increment" | "control", CSSPropObject<CSSSlotObject<"button" | "root" | "field" | "decrement" | "increment" | "control">>, {
|
|
6
6
|
xs: {
|
|
7
7
|
control: {
|
|
8
8
|
boxSize: "calc({--height} - {spaces.2})";
|
|
@@ -38,7 +38,7 @@ export interface UseReorderProps<Y = string> extends Partial<Omit<ReorderGroupPr
|
|
|
38
38
|
*/
|
|
39
39
|
onCompleteChange?: (values: Y[]) => void;
|
|
40
40
|
}
|
|
41
|
-
export declare const useReorder: <Y = string>({ ref, children, item, items, orientation, onChange, onCompleteChange, ...rest }?: UseReorderProps<Y>) => {
|
|
41
|
+
export declare const useReorder: <Y = string>({ ref, children, item: itemProp, items, orientation, onChange, onCompleteChange, ...rest }?: UseReorderProps<Y>) => {
|
|
42
42
|
children: any[];
|
|
43
43
|
orientation: Orientation;
|
|
44
44
|
values: Y[];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yamada-ui/react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.2.11-dev-
|
|
4
|
+
"version": "2.2.11-dev-20261024022120",
|
|
5
5
|
"description": "React UI components of the Yamada, by the Yamada, for the Yamada built with React and Emotion",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"yamada",
|
|
@@ -126,7 +126,7 @@
|
|
|
126
126
|
"@emotion/utils": "^1.4.2",
|
|
127
127
|
"@floating-ui/react-dom": "^2.1.9",
|
|
128
128
|
"@tanstack/react-table": "^8.21.3",
|
|
129
|
-
"@yamada-ui/utils": "2.1.8-dev-
|
|
129
|
+
"@yamada-ui/utils": "2.1.8-dev-20261024022120",
|
|
130
130
|
"copy-to-clipboard": "3.3.3",
|
|
131
131
|
"csstype": "^3.2.3",
|
|
132
132
|
"dayjs": "^1.11.23",
|