@yamada-ui/react 2.2.11-dev-20261022095950 → 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/breadcrumb/use-breadcrumb.cjs +2 -1
- package/dist/cjs/components/breadcrumb/use-breadcrumb.cjs.map +1 -1
- 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/breadcrumb/use-breadcrumb.js +2 -1
- package/dist/esm/components/breadcrumb/use-breadcrumb.js.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/accordion/accordion.style.d.ts +1 -1
- package/dist/types/components/alert/alert.style.d.ts +1 -1
- package/dist/types/components/autocomplete/autocomplete.style.d.ts +1 -1
- package/dist/types/components/breadcrumb/use-breadcrumb.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/dropzone/dropzone.d.ts +1 -1
- package/dist/types/components/dropzone/dropzone.style.d.ts +1 -1
- 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/field/use-field-props.d.ts +1 -1
- package/dist/types/components/file-button/use-file-button.d.ts +2 -2
- package/dist/types/components/file-input/use-file-input.d.ts +2 -2
- package/dist/types/components/native-accordion/native-accordion.style.d.ts +2 -2
- package/dist/types/components/number-input/number-input.style.d.ts +1 -1
- package/dist/types/components/progress/use-progress.d.ts +3 -3
- package/dist/types/components/reorder/use-reorder.d.ts +1 -1
- package/dist/types/components/tabs/tabs.style.d.ts +1 -1
- package/dist/types/components/tree/use-tree.d.ts +3 -3
- package/dist/types/hooks/use-clickable/index.d.ts +2 -2
- package/package.json +2 -2
|
@@ -5,8 +5,9 @@ const require_props = require("../../core/components/props.cjs");
|
|
|
5
5
|
const require_i18n_provider = require("../../providers/i18n-provider/i18n-provider.cjs");
|
|
6
6
|
let react = require("react");
|
|
7
7
|
//#region src/components/breadcrumb/use-breadcrumb.tsx
|
|
8
|
-
const useBreadcrumb = ({ children, ellipsis, endBoundaries = 0, items = [], link, startBoundaries = 0, ...rest } = {}) => {
|
|
8
|
+
const useBreadcrumb = ({ children, ellipsis, endBoundaries = 0, items = [], link: linkProp, startBoundaries = 0, ...rest } = {}) => {
|
|
9
9
|
const validChildren = require_children.useValidChildren(children);
|
|
10
|
+
const [link] = require_children.useValidChildren(linkProp);
|
|
10
11
|
const length = validChildren.length || items.length;
|
|
11
12
|
const { t } = require_i18n_provider.useI18n("breadcrumb");
|
|
12
13
|
const hasBoundaries = startBoundaries + endBoundaries > 0 && length > startBoundaries + endBoundaries;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-breadcrumb.cjs","names":["useValidChildren","useI18n","useCallback","cloneElement","useMemo","mergeProps"],"sources":["../../../../src/components/breadcrumb/use-breadcrumb.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ReactElement, ReactNode } from \"react\"\nimport type { HTMLProps, PropGetter } from \"../../core\"\nimport type { ReactNodeOrFunction } from \"../../utils\"\nimport { cloneElement, useCallback, useMemo } from \"react\"\nimport { mergeProps } from \"../../core\"\nimport { useI18n } from \"../../providers/i18n-provider\"\nimport { runIfFn, useValidChildren } from \"../../utils\"\n\nexport interface BreadcrumbItem extends HTMLProps<\"a\"> {\n currentPage?: boolean\n label?: ReactNode\n}\n\nexport interface UseBreadcrumbProps extends HTMLProps<\"nav\"> {\n /**\n * The icon to be used in the ellipsis.\n */\n ellipsis?: ReactNodeOrFunction<{ items: BreadcrumbItem[] }>\n /**\n * Number of elements visible on the end(right) edges.\n *\n * @default 0\n */\n endBoundaries?: number\n /**\n * If provided, generate breadcrumb items based on items.\n */\n items?: BreadcrumbItem[]\n /**\n * The component to be used for the link.\n */\n link?: ReactElement<any>\n /**\n * Number of elements visible on the start(left) edges.\n *\n * @default 0\n */\n startBoundaries?: number\n}\n\nexport const useBreadcrumb = ({\n children,\n ellipsis,\n endBoundaries = 0,\n items = [],\n link,\n startBoundaries = 0,\n ...rest\n}: UseBreadcrumbProps = {}) => {\n const validChildren = useValidChildren(children)\n const length = validChildren.length || items.length\n const { t } = useI18n(\"breadcrumb\")\n\n const hasBoundaries =\n startBoundaries + endBoundaries > 0 &&\n length > startBoundaries + endBoundaries\n\n const renderLink = useCallback(\n (items: BreadcrumbItem[]) => {\n if (!link) return []\n\n return items.map(({ label, ...rest }) =>\n cloneElement<any>(link, { ...link.props, children: label, ...rest }),\n )\n },\n [link],\n )\n\n const renderEllipsis = useCallback(\n (items: BreadcrumbItem[]) => {\n if (!ellipsis) return null\n\n return runIfFn(ellipsis, { items })\n },\n [ellipsis],\n )\n\n const splitItems = useCallback(\n (items: BreadcrumbItem[]) => {\n const length = items.length\n const firstItems = items.slice(0, startBoundaries)\n const ellipsisItems = items.slice(startBoundaries, length - endBoundaries)\n const lastItems = items.slice(length - endBoundaries)\n\n return [firstItems, ellipsisItems, lastItems] as const\n },\n [startBoundaries, endBoundaries],\n )\n\n const cloneChildren = useMemo(() => {\n const hasChildren = !!validChildren.length\n\n if (hasChildren) {\n return validChildren\n } else if (hasBoundaries) {\n const [firstItems, ellipsisItems, lastItems] = splitItems(items)\n\n return [\n ...renderLink(firstItems),\n renderEllipsis(ellipsisItems),\n ...renderLink(lastItems),\n ]\n } else {\n return renderLink(items)\n }\n }, [\n validChildren,\n items,\n hasBoundaries,\n renderEllipsis,\n renderLink,\n splitItems,\n ])\n\n const getRootProps: PropGetter<\"nav\"> = useCallback(\n (props) => mergeProps({ \"aria-label\": t(\"Breadcrumb\") }, rest, props)(),\n [rest, t],\n )\n\n const getListProps: PropGetter<\"ol\"> = useCallback(\n (props) => ({ ...props }),\n [],\n )\n\n const getLinkProps: PropGetter<\"a\", { currentPage?: boolean }> = useCallback(\n ({ href, currentPage, ...props } = {}) => ({\n href: !currentPage ? href : undefined,\n \"aria-current\": currentPage ? \"page\" : undefined,\n ...props,\n }),\n [],\n )\n\n const getEllipsisProps: PropGetter<\"svg\"> = useCallback(\n (props) => ({\n \"aria-label\": t(\"Ellipsis\"),\n role: \"presentation\",\n ...props,\n }),\n [t],\n )\n\n return {\n children: cloneChildren,\n getEllipsisProps,\n getLinkProps,\n getListProps,\n getRootProps,\n }\n}\n\nexport type UseBreadcrumbReturn = ReturnType<typeof useBreadcrumb>\n"],"mappings":";;;;;;;AA0CA,MAAa,iBAAiB,EAC5B,UACA,UACA,gBAAgB,GAChB,QAAQ,CAAC,GACT,
|
|
1
|
+
{"version":3,"file":"use-breadcrumb.cjs","names":["useValidChildren","useI18n","useCallback","cloneElement","useMemo","mergeProps"],"sources":["../../../../src/components/breadcrumb/use-breadcrumb.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ReactElement, ReactNode } from \"react\"\nimport type { HTMLProps, PropGetter } from \"../../core\"\nimport type { ReactNodeOrFunction } from \"../../utils\"\nimport { cloneElement, useCallback, useMemo } from \"react\"\nimport { mergeProps } from \"../../core\"\nimport { useI18n } from \"../../providers/i18n-provider\"\nimport { runIfFn, useValidChildren } from \"../../utils\"\n\nexport interface BreadcrumbItem extends HTMLProps<\"a\"> {\n currentPage?: boolean\n label?: ReactNode\n}\n\nexport interface UseBreadcrumbProps extends HTMLProps<\"nav\"> {\n /**\n * The icon to be used in the ellipsis.\n */\n ellipsis?: ReactNodeOrFunction<{ items: BreadcrumbItem[] }>\n /**\n * Number of elements visible on the end(right) edges.\n *\n * @default 0\n */\n endBoundaries?: number\n /**\n * If provided, generate breadcrumb items based on items.\n */\n items?: BreadcrumbItem[]\n /**\n * The component to be used for the link.\n */\n link?: ReactElement<any>\n /**\n * Number of elements visible on the start(left) edges.\n *\n * @default 0\n */\n startBoundaries?: number\n}\n\nexport const useBreadcrumb = ({\n children,\n ellipsis,\n endBoundaries = 0,\n items = [],\n link: linkProp,\n startBoundaries = 0,\n ...rest\n}: UseBreadcrumbProps = {}) => {\n const validChildren = useValidChildren(children)\n const [link] = useValidChildren(linkProp)\n const length = validChildren.length || items.length\n const { t } = useI18n(\"breadcrumb\")\n\n const hasBoundaries =\n startBoundaries + endBoundaries > 0 &&\n length > startBoundaries + endBoundaries\n\n const renderLink = useCallback(\n (items: BreadcrumbItem[]) => {\n if (!link) return []\n\n return items.map(({ label, ...rest }) =>\n cloneElement<any>(link, { ...link.props, children: label, ...rest }),\n )\n },\n [link],\n )\n\n const renderEllipsis = useCallback(\n (items: BreadcrumbItem[]) => {\n if (!ellipsis) return null\n\n return runIfFn(ellipsis, { items })\n },\n [ellipsis],\n )\n\n const splitItems = useCallback(\n (items: BreadcrumbItem[]) => {\n const length = items.length\n const firstItems = items.slice(0, startBoundaries)\n const ellipsisItems = items.slice(startBoundaries, length - endBoundaries)\n const lastItems = items.slice(length - endBoundaries)\n\n return [firstItems, ellipsisItems, lastItems] as const\n },\n [startBoundaries, endBoundaries],\n )\n\n const cloneChildren = useMemo(() => {\n const hasChildren = !!validChildren.length\n\n if (hasChildren) {\n return validChildren\n } else if (hasBoundaries) {\n const [firstItems, ellipsisItems, lastItems] = splitItems(items)\n\n return [\n ...renderLink(firstItems),\n renderEllipsis(ellipsisItems),\n ...renderLink(lastItems),\n ]\n } else {\n return renderLink(items)\n }\n }, [\n validChildren,\n items,\n hasBoundaries,\n renderEllipsis,\n renderLink,\n splitItems,\n ])\n\n const getRootProps: PropGetter<\"nav\"> = useCallback(\n (props) => mergeProps({ \"aria-label\": t(\"Breadcrumb\") }, rest, props)(),\n [rest, t],\n )\n\n const getListProps: PropGetter<\"ol\"> = useCallback(\n (props) => ({ ...props }),\n [],\n )\n\n const getLinkProps: PropGetter<\"a\", { currentPage?: boolean }> = useCallback(\n ({ href, currentPage, ...props } = {}) => ({\n href: !currentPage ? href : undefined,\n \"aria-current\": currentPage ? \"page\" : undefined,\n ...props,\n }),\n [],\n )\n\n const getEllipsisProps: PropGetter<\"svg\"> = useCallback(\n (props) => ({\n \"aria-label\": t(\"Ellipsis\"),\n role: \"presentation\",\n ...props,\n }),\n [t],\n )\n\n return {\n children: cloneChildren,\n getEllipsisProps,\n getLinkProps,\n getListProps,\n getRootProps,\n }\n}\n\nexport type UseBreadcrumbReturn = ReturnType<typeof useBreadcrumb>\n"],"mappings":";;;;;;;AA0CA,MAAa,iBAAiB,EAC5B,UACA,UACA,gBAAgB,GAChB,QAAQ,CAAC,GACT,MAAM,UACN,kBAAkB,GAClB,GAAG,SACmB,CAAC,MAAM;CAC7B,MAAM,gBAAgBA,iBAAAA,iBAAiB,QAAQ;CAC/C,MAAM,CAAC,QAAQA,iBAAAA,iBAAiB,QAAQ;CACxC,MAAM,SAAS,cAAc,UAAU,MAAM;CAC7C,MAAM,EAAE,MAAMC,sBAAAA,QAAQ,YAAY;CAElC,MAAM,gBACJ,kBAAkB,gBAAgB,KAClC,SAAS,kBAAkB;CAE7B,MAAM,cAAA,GAAaC,MAAAA,YAAAA,EAChB,UAA4B;EAC3B,IAAI,CAAC,MAAM,OAAO,CAAC;EAEnB,OAAO,MAAM,KAAK,EAAE,OAAO,GAAG,YAAA,GAC5BC,MAAAA,aAAAA,CAAkB,MAAM;GAAE,GAAG,KAAK;GAAO,UAAU;GAAO,GAAG;EAAK,CAAC,CACrE;CACF,GACA,CAAC,IAAI,CACP;CAEA,MAAM,kBAAA,GAAiBD,MAAAA,YAAAA,EACpB,UAA4B;EAC3B,IAAI,CAAC,UAAU,OAAO;EAEtB,QAAA,GAAA,oBAAA,cAAO,QAAA,CAAQ,UAAU,EAAE,MAAM,CAAC;CACpC,GACA,CAAC,QAAQ,CACX;CAEA,MAAM,cAAA,GAAaA,MAAAA,YAAAA,EAChB,UAA4B;EAC3B,MAAM,SAAS,MAAM;EAKrB,OAAO;GAJY,MAAM,MAAM,GAAG,eAIjB;GAHK,MAAM,MAAM,iBAAiB,SAAS,aAG5B;GAFd,MAAM,MAAM,SAAS,aAEI;EAAC;CAC9C,GACA,CAAC,iBAAiB,aAAa,CACjC;CAEA,MAAM,iBAAA,GAAgBE,MAAAA,QAAAA,OAAc;EAGlC,IAAI,CAFiB,CAAC,cAAc,QAGlC,OAAO;OACF,IAAI,eAAe;GACxB,MAAM,CAAC,YAAY,eAAe,aAAa,WAAW,KAAK;GAE/D,OAAO;IACL,GAAG,WAAW,UAAU;IACxB,eAAe,aAAa;IAC5B,GAAG,WAAW,SAAS;GACzB;EACF,OACE,OAAO,WAAW,KAAK;CAE3B,GAAG;EACD;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CAED,MAAM,gBAAA,GAAkCF,MAAAA,YAAAA,EACrC,UAAUG,cAAAA,WAAW,EAAE,cAAc,EAAE,YAAY,EAAE,GAAG,MAAM,KAAK,CAAC,CAAC,GACtE,CAAC,MAAM,CAAC,CACV;CAEA,MAAM,gBAAA,GAAiCH,MAAAA,YAAAA,EACpC,WAAW,EAAE,GAAG,MAAM,IACvB,CAAC,CACH;CAEA,MAAM,gBAAA,GAA2DA,MAAAA,YAAAA,EAC9D,EAAE,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO;EACzC,MAAM,CAAC,cAAc,OAAO,KAAA;EAC5B,gBAAgB,cAAc,SAAS,KAAA;EACvC,GAAG;CACL,IACA,CAAC,CACH;CAWA,OAAO;EACL,UAAU;EACV,mBAAA,GAX0CA,MAAAA,YAAAA,EACzC,WAAW;GACV,cAAc,EAAE,UAAU;GAC1B,MAAM;GACN,GAAG;EACL,IACA,CAAC,CAAC,CAKa;EACf;EACA;EACA;CACF;AACF"}
|
|
@@ -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 UseReorderIt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,YAAY;GAepD,OAAO;IACL,GAdaC,cAAAA,WACb;KACE,qBAAA,GAAA,oBAAA,cAAoB,SAAA,CAAS,UAAU;KACvC,kBAAA,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"}
|
|
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,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;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,gBAAgBC,iBAAAA,iBAAiB,QAAQ;CAC/C,MAAM,CAAC,QAAQA,iBAAAA,iBAAiB,QAAQ;CACxC,MAAM,cAAc,CAAC,CAAC,cAAc;CACpC,MAAM,iBAAA,GAAgBC,MAAAA,QAAAA,OAAc;EAClC,MAAM,SAAS,cACX,cAAc,KACX,EAAE,YAAY,MAAM,SAAS,oBAAoB,KAAK,CACzD,IACA,MAAM,KAAK,UAAU,MAAM,SAAS,oBAAoB,KAAK,CAAC;EAElE,MAAM,mBAAmB,OAAO,QAC7B,OAAO,OAAO,SACb,KAAK,QAAQ,KAAK,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AgB,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,eAAA,GAtCLA,MAAAA,YAAAA,EACD,QAAQ,CAAC,MAAM;GACd,MAAM,WAAW,MAAM,YAAY,KAAK,YAAY;GAepD,OAAO;IACL,GAdaC,cAAAA,WACb;KACE,qBAAA,GAAA,oBAAA,cAAoB,SAAA,CAAS,UAAU;KACvC,kBAAA,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"}
|
|
@@ -5,8 +5,9 @@ import { mergeProps } from "../../core/components/props.js";
|
|
|
5
5
|
import { useI18n } from "../../providers/i18n-provider/i18n-provider.js";
|
|
6
6
|
import { cloneElement, useCallback, useMemo } from "react";
|
|
7
7
|
//#region src/components/breadcrumb/use-breadcrumb.tsx
|
|
8
|
-
const useBreadcrumb = ({ children, ellipsis, endBoundaries = 0, items = [], link, startBoundaries = 0, ...rest } = {}) => {
|
|
8
|
+
const useBreadcrumb = ({ children, ellipsis, endBoundaries = 0, items = [], link: linkProp, startBoundaries = 0, ...rest } = {}) => {
|
|
9
9
|
const validChildren = useValidChildren(children);
|
|
10
|
+
const [link] = useValidChildren(linkProp);
|
|
10
11
|
const length = validChildren.length || items.length;
|
|
11
12
|
const { t } = useI18n("breadcrumb");
|
|
12
13
|
const hasBoundaries = startBoundaries + endBoundaries > 0 && length > startBoundaries + endBoundaries;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-breadcrumb.js","names":["runIfFn"],"sources":["../../../../src/components/breadcrumb/use-breadcrumb.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ReactElement, ReactNode } from \"react\"\nimport type { HTMLProps, PropGetter } from \"../../core\"\nimport type { ReactNodeOrFunction } from \"../../utils\"\nimport { cloneElement, useCallback, useMemo } from \"react\"\nimport { mergeProps } from \"../../core\"\nimport { useI18n } from \"../../providers/i18n-provider\"\nimport { runIfFn, useValidChildren } from \"../../utils\"\n\nexport interface BreadcrumbItem extends HTMLProps<\"a\"> {\n currentPage?: boolean\n label?: ReactNode\n}\n\nexport interface UseBreadcrumbProps extends HTMLProps<\"nav\"> {\n /**\n * The icon to be used in the ellipsis.\n */\n ellipsis?: ReactNodeOrFunction<{ items: BreadcrumbItem[] }>\n /**\n * Number of elements visible on the end(right) edges.\n *\n * @default 0\n */\n endBoundaries?: number\n /**\n * If provided, generate breadcrumb items based on items.\n */\n items?: BreadcrumbItem[]\n /**\n * The component to be used for the link.\n */\n link?: ReactElement<any>\n /**\n * Number of elements visible on the start(left) edges.\n *\n * @default 0\n */\n startBoundaries?: number\n}\n\nexport const useBreadcrumb = ({\n children,\n ellipsis,\n endBoundaries = 0,\n items = [],\n link,\n startBoundaries = 0,\n ...rest\n}: UseBreadcrumbProps = {}) => {\n const validChildren = useValidChildren(children)\n const length = validChildren.length || items.length\n const { t } = useI18n(\"breadcrumb\")\n\n const hasBoundaries =\n startBoundaries + endBoundaries > 0 &&\n length > startBoundaries + endBoundaries\n\n const renderLink = useCallback(\n (items: BreadcrumbItem[]) => {\n if (!link) return []\n\n return items.map(({ label, ...rest }) =>\n cloneElement<any>(link, { ...link.props, children: label, ...rest }),\n )\n },\n [link],\n )\n\n const renderEllipsis = useCallback(\n (items: BreadcrumbItem[]) => {\n if (!ellipsis) return null\n\n return runIfFn(ellipsis, { items })\n },\n [ellipsis],\n )\n\n const splitItems = useCallback(\n (items: BreadcrumbItem[]) => {\n const length = items.length\n const firstItems = items.slice(0, startBoundaries)\n const ellipsisItems = items.slice(startBoundaries, length - endBoundaries)\n const lastItems = items.slice(length - endBoundaries)\n\n return [firstItems, ellipsisItems, lastItems] as const\n },\n [startBoundaries, endBoundaries],\n )\n\n const cloneChildren = useMemo(() => {\n const hasChildren = !!validChildren.length\n\n if (hasChildren) {\n return validChildren\n } else if (hasBoundaries) {\n const [firstItems, ellipsisItems, lastItems] = splitItems(items)\n\n return [\n ...renderLink(firstItems),\n renderEllipsis(ellipsisItems),\n ...renderLink(lastItems),\n ]\n } else {\n return renderLink(items)\n }\n }, [\n validChildren,\n items,\n hasBoundaries,\n renderEllipsis,\n renderLink,\n splitItems,\n ])\n\n const getRootProps: PropGetter<\"nav\"> = useCallback(\n (props) => mergeProps({ \"aria-label\": t(\"Breadcrumb\") }, rest, props)(),\n [rest, t],\n )\n\n const getListProps: PropGetter<\"ol\"> = useCallback(\n (props) => ({ ...props }),\n [],\n )\n\n const getLinkProps: PropGetter<\"a\", { currentPage?: boolean }> = useCallback(\n ({ href, currentPage, ...props } = {}) => ({\n href: !currentPage ? href : undefined,\n \"aria-current\": currentPage ? \"page\" : undefined,\n ...props,\n }),\n [],\n )\n\n const getEllipsisProps: PropGetter<\"svg\"> = useCallback(\n (props) => ({\n \"aria-label\": t(\"Ellipsis\"),\n role: \"presentation\",\n ...props,\n }),\n [t],\n )\n\n return {\n children: cloneChildren,\n getEllipsisProps,\n getLinkProps,\n getListProps,\n getRootProps,\n }\n}\n\nexport type UseBreadcrumbReturn = ReturnType<typeof useBreadcrumb>\n"],"mappings":";;;;;;;AA0CA,MAAa,iBAAiB,EAC5B,UACA,UACA,gBAAgB,GAChB,QAAQ,CAAC,GACT,
|
|
1
|
+
{"version":3,"file":"use-breadcrumb.js","names":["runIfFn"],"sources":["../../../../src/components/breadcrumb/use-breadcrumb.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ReactElement, ReactNode } from \"react\"\nimport type { HTMLProps, PropGetter } from \"../../core\"\nimport type { ReactNodeOrFunction } from \"../../utils\"\nimport { cloneElement, useCallback, useMemo } from \"react\"\nimport { mergeProps } from \"../../core\"\nimport { useI18n } from \"../../providers/i18n-provider\"\nimport { runIfFn, useValidChildren } from \"../../utils\"\n\nexport interface BreadcrumbItem extends HTMLProps<\"a\"> {\n currentPage?: boolean\n label?: ReactNode\n}\n\nexport interface UseBreadcrumbProps extends HTMLProps<\"nav\"> {\n /**\n * The icon to be used in the ellipsis.\n */\n ellipsis?: ReactNodeOrFunction<{ items: BreadcrumbItem[] }>\n /**\n * Number of elements visible on the end(right) edges.\n *\n * @default 0\n */\n endBoundaries?: number\n /**\n * If provided, generate breadcrumb items based on items.\n */\n items?: BreadcrumbItem[]\n /**\n * The component to be used for the link.\n */\n link?: ReactElement<any>\n /**\n * Number of elements visible on the start(left) edges.\n *\n * @default 0\n */\n startBoundaries?: number\n}\n\nexport const useBreadcrumb = ({\n children,\n ellipsis,\n endBoundaries = 0,\n items = [],\n link: linkProp,\n startBoundaries = 0,\n ...rest\n}: UseBreadcrumbProps = {}) => {\n const validChildren = useValidChildren(children)\n const [link] = useValidChildren(linkProp)\n const length = validChildren.length || items.length\n const { t } = useI18n(\"breadcrumb\")\n\n const hasBoundaries =\n startBoundaries + endBoundaries > 0 &&\n length > startBoundaries + endBoundaries\n\n const renderLink = useCallback(\n (items: BreadcrumbItem[]) => {\n if (!link) return []\n\n return items.map(({ label, ...rest }) =>\n cloneElement<any>(link, { ...link.props, children: label, ...rest }),\n )\n },\n [link],\n )\n\n const renderEllipsis = useCallback(\n (items: BreadcrumbItem[]) => {\n if (!ellipsis) return null\n\n return runIfFn(ellipsis, { items })\n },\n [ellipsis],\n )\n\n const splitItems = useCallback(\n (items: BreadcrumbItem[]) => {\n const length = items.length\n const firstItems = items.slice(0, startBoundaries)\n const ellipsisItems = items.slice(startBoundaries, length - endBoundaries)\n const lastItems = items.slice(length - endBoundaries)\n\n return [firstItems, ellipsisItems, lastItems] as const\n },\n [startBoundaries, endBoundaries],\n )\n\n const cloneChildren = useMemo(() => {\n const hasChildren = !!validChildren.length\n\n if (hasChildren) {\n return validChildren\n } else if (hasBoundaries) {\n const [firstItems, ellipsisItems, lastItems] = splitItems(items)\n\n return [\n ...renderLink(firstItems),\n renderEllipsis(ellipsisItems),\n ...renderLink(lastItems),\n ]\n } else {\n return renderLink(items)\n }\n }, [\n validChildren,\n items,\n hasBoundaries,\n renderEllipsis,\n renderLink,\n splitItems,\n ])\n\n const getRootProps: PropGetter<\"nav\"> = useCallback(\n (props) => mergeProps({ \"aria-label\": t(\"Breadcrumb\") }, rest, props)(),\n [rest, t],\n )\n\n const getListProps: PropGetter<\"ol\"> = useCallback(\n (props) => ({ ...props }),\n [],\n )\n\n const getLinkProps: PropGetter<\"a\", { currentPage?: boolean }> = useCallback(\n ({ href, currentPage, ...props } = {}) => ({\n href: !currentPage ? href : undefined,\n \"aria-current\": currentPage ? \"page\" : undefined,\n ...props,\n }),\n [],\n )\n\n const getEllipsisProps: PropGetter<\"svg\"> = useCallback(\n (props) => ({\n \"aria-label\": t(\"Ellipsis\"),\n role: \"presentation\",\n ...props,\n }),\n [t],\n )\n\n return {\n children: cloneChildren,\n getEllipsisProps,\n getLinkProps,\n getListProps,\n getRootProps,\n }\n}\n\nexport type UseBreadcrumbReturn = ReturnType<typeof useBreadcrumb>\n"],"mappings":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CAAC;CAED,MAAM,eAAkC,aACrC,UAAU,WAAW,EAAE,cAAc,EAAE,YAAY,EAAE,GAAG,MAAM,KAAK,CAAC,CAAC,GACtE,CAAC,MAAM,CAAC,CACV;CAEA,MAAM,eAAiC,aACpC,WAAW,EAAE,GAAG,MAAM,IACvB,CAAC,CACH;CAEA,MAAM,eAA2D,aAC9D,EAAE,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO;EACzC,MAAM,CAAC,cAAc,OAAO,KAAA;EAC5B,gBAAgB,cAAc,SAAS,KAAA;EACvC,GAAG;CACL,IACA,CAAC,CACH;CAWA,OAAO;EACL,UAAU;EACV,kBAX0C,aACzC,WAAW;GACV,cAAc,EAAE,UAAU;GAC1B,MAAM;GACN,GAAG;EACL,IACA,CAAC,CAAC,CAKa;EACf;EACA;EACA;CACF;AACF"}
|
|
@@ -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,KACA,UACA,MACA,QAAQ,CAAC,GACT,cAAc,YACd,UACA,kBACA,GAAG,SACmB,CAAC,MAAM;CAC7B,MAAM,OAAO,gBAAgB,aAA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AAW,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,cAAc,KACX,EAAE,YAAY,MAAM,SAAS,oBAAoB,KAAK,CACzD,IACA,MAAM,KAAK,UAAU,MAAM,SAAS,oBAAoB,KAAK,CAAC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AepD,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 { CSSModifierObject, CSSPropObject, CSSSlotObject } from "../../core/css/index.type.js";
|
|
3
3
|
import "../../index.js";
|
|
4
4
|
//#region src/components/accordion/accordion.style.d.ts
|
|
5
|
-
export declare const accordionStyle: ComponentSlotStyle<"button" | "
|
|
5
|
+
export declare const accordionStyle: ComponentSlotStyle<"button" | "panel" | "icon" | "root" | "item", CSSPropObject<CSSSlotObject<"button" | "panel" | "icon" | "root" | "item">>, CSSModifierObject<CSSSlotObject<"button" | "panel" | "icon" | "root" | "item">>, {
|
|
6
6
|
panel: {
|
|
7
7
|
button: {
|
|
8
8
|
rounded: "l2";
|
|
@@ -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/alert/alert.style.d.ts
|
|
5
|
-
export declare const alertStyle: ComponentSlotStyle<"
|
|
5
|
+
export declare const alertStyle: ComponentSlotStyle<"title" | "loading" | "icon" | "root" | "description", CSSPropObject<CSSSlotObject<"title" | "loading" | "icon" | "root" | "description">>, CSSModifierObject<CSSSlotObject<"title" | "loading" | "icon" | "root" | "description">>, {
|
|
6
6
|
island: {
|
|
7
7
|
description: {
|
|
8
8
|
color: "fg.muted";
|
|
@@ -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";
|
|
@@ -36,7 +36,7 @@ export interface UseBreadcrumbProps extends HTMLProps<"nav"> {
|
|
|
36
36
|
*/
|
|
37
37
|
startBoundaries?: number;
|
|
38
38
|
}
|
|
39
|
-
export declare const useBreadcrumb: ({ children, ellipsis, endBoundaries, items, link, startBoundaries, ...rest }?: UseBreadcrumbProps) => {
|
|
39
|
+
export declare const useBreadcrumb: ({ children, ellipsis, endBoundaries, items, link: linkProp, startBoundaries, ...rest }?: UseBreadcrumbProps) => {
|
|
40
40
|
children: (string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | ReactElement<any, string | import("react").JSXElementConstructor<any>> | null | undefined)[];
|
|
41
41
|
getEllipsisProps: PropGetter<"svg", undefined, undefined>;
|
|
42
42
|
getLinkProps: PropGetter<"a", {
|
|
@@ -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
|
|
@@ -34,7 +34,7 @@ declare const DropzonePropsContext: import("react").Context<Partial<DropzoneRoot
|
|
|
34
34
|
*
|
|
35
35
|
* @see https://yamada-ui.com/docs/components/dropzone
|
|
36
36
|
*/
|
|
37
|
-
export declare const DropzoneRoot: Component<({ children, errorBorderColor, focusBorderColor, loadingScheme, inputProps, loadingProps, overlayProps, ...rest }: WithoutThemeProps<DropzoneRootProps, ComponentSlotStyle<"
|
|
37
|
+
export declare const DropzoneRoot: Component<({ children, errorBorderColor, focusBorderColor, loadingScheme, inputProps, loadingProps, overlayProps, ...rest }: WithoutThemeProps<DropzoneRootProps, ComponentSlotStyle<"title" | "overlay" | "loading" | "icon" | "root" | "description", CSSPropObject<CSSSlotObject<"title" | "overlay" | "loading" | "icon" | "root" | "description">>, {
|
|
38
38
|
xs: {
|
|
39
39
|
root: {
|
|
40
40
|
minH: "xs";
|
|
@@ -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/dropzone/dropzone.style.d.ts
|
|
5
|
-
export declare const dropzoneStyle: ComponentSlotStyle<"
|
|
5
|
+
export declare const dropzoneStyle: ComponentSlotStyle<"title" | "overlay" | "loading" | "icon" | "root" | "description", CSSPropObject<CSSSlotObject<"title" | "overlay" | "loading" | "icon" | "root" | "description">>, {
|
|
6
6
|
xs: {
|
|
7
7
|
root: {
|
|
8
8
|
minH: "xs";
|
|
@@ -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
|
|
@@ -17,7 +17,7 @@ export declare const useFieldProps: <Y extends HTMLElement, M extends Dict>({ id
|
|
|
17
17
|
disabled: boolean | undefined;
|
|
18
18
|
readOnly: boolean | undefined;
|
|
19
19
|
required: boolean | undefined;
|
|
20
|
-
} & Omit<M & UseFieldProps<Y>, "
|
|
20
|
+
} & Omit<M & UseFieldProps<Y>, "disabled" | "readOnly" | "id" | "aria-describedby" | "onFocus" | "onBlur" | "invalid" | "name" | "required" | "notSupportReadOnly">;
|
|
21
21
|
ariaProps: {
|
|
22
22
|
"aria-describedby": any;
|
|
23
23
|
"aria-disabled": (boolean | "true" | "false") | undefined;
|
|
@@ -9,7 +9,7 @@ import "../../index.js";
|
|
|
9
9
|
//#region src/components/file-button/use-file-button.d.ts
|
|
10
10
|
export interface UseFileButtonProps extends UseFileInputProps<"button">, FieldProps {}
|
|
11
11
|
export declare const useFileButton: (props?: UseFileButtonProps) => {
|
|
12
|
-
clickableProps: (Omit<UseClickableProps<HTMLElement, import("@yamada-ui/utils").Dict<any>>, "ref" | "tabIndex" | "onKeyDown" | "onKeyUp" | "onClick" | "onMouseDown" | "onMouseLeave" | "onMouseOver" | "onMouseUp" | "clickOnEnter" | "clickOnSpace" | "
|
|
12
|
+
clickableProps: (Omit<UseClickableProps<HTMLElement, import("@yamada-ui/utils").Dict<any>>, "disabled" | "ref" | "tabIndex" | "onKeyDown" | "onKeyUp" | "onClick" | "onMouseDown" | "onMouseLeave" | "onMouseOver" | "onMouseUp" | "clickOnEnter" | "clickOnSpace" | "disableTouchBehavior" | "focusable" | "focusOnClick"> & {
|
|
13
13
|
ref: (node: any) => void;
|
|
14
14
|
type: "button";
|
|
15
15
|
"aria-disabled": boolean | undefined;
|
|
@@ -21,7 +21,7 @@ export declare const useFileButton: (props?: UseFileButtonProps) => {
|
|
|
21
21
|
onMouseLeave: import("react").MouseEventHandler<HTMLElement> | undefined;
|
|
22
22
|
onMouseOver: import("react").MouseEventHandler<HTMLElement> | undefined;
|
|
23
23
|
onMouseUp: import("react").MouseEventHandler<HTMLElement> | undefined;
|
|
24
|
-
}) | (Omit<UseClickableProps<HTMLElement, import("@yamada-ui/utils").Dict<any>>, "ref" | "tabIndex" | "onKeyDown" | "onKeyUp" | "onClick" | "onMouseDown" | "onMouseLeave" | "onMouseOver" | "onMouseUp" | "clickOnEnter" | "clickOnSpace" | "
|
|
24
|
+
}) | (Omit<UseClickableProps<HTMLElement, import("@yamada-ui/utils").Dict<any>>, "disabled" | "ref" | "tabIndex" | "onKeyDown" | "onKeyUp" | "onClick" | "onMouseDown" | "onMouseLeave" | "onMouseOver" | "onMouseUp" | "clickOnEnter" | "clickOnSpace" | "disableTouchBehavior" | "focusable" | "focusOnClick"> & {
|
|
25
25
|
ref: (node: any) => void;
|
|
26
26
|
"aria-disabled": "true" | undefined;
|
|
27
27
|
"data-active": string | undefined;
|
|
@@ -31,7 +31,7 @@ export declare const useFileInput: <Y extends "button" | "input" = "input">(prop
|
|
|
31
31
|
readOnly: boolean | undefined;
|
|
32
32
|
required: boolean | undefined;
|
|
33
33
|
values: File[] | undefined;
|
|
34
|
-
clickableProps: (Omit<UseClickableProps<HTMLElement, Dict<any>>, "ref" | "tabIndex" | "onKeyDown" | "onKeyUp" | "onClick" | "onMouseDown" | "onMouseLeave" | "onMouseOver" | "onMouseUp" | "clickOnEnter" | "clickOnSpace" | "
|
|
34
|
+
clickableProps: (Omit<UseClickableProps<HTMLElement, Dict<any>>, "disabled" | "ref" | "tabIndex" | "onKeyDown" | "onKeyUp" | "onClick" | "onMouseDown" | "onMouseLeave" | "onMouseOver" | "onMouseUp" | "clickOnEnter" | "clickOnSpace" | "disableTouchBehavior" | "focusable" | "focusOnClick"> & {
|
|
35
35
|
ref: (node: any) => void;
|
|
36
36
|
type: "button";
|
|
37
37
|
"aria-disabled": boolean | undefined;
|
|
@@ -43,7 +43,7 @@ export declare const useFileInput: <Y extends "button" | "input" = "input">(prop
|
|
|
43
43
|
onMouseLeave: import("react").MouseEventHandler<HTMLElement> | undefined;
|
|
44
44
|
onMouseOver: import("react").MouseEventHandler<HTMLElement> | undefined;
|
|
45
45
|
onMouseUp: import("react").MouseEventHandler<HTMLElement> | undefined;
|
|
46
|
-
}) | (Omit<UseClickableProps<HTMLElement, Dict<any>>, "ref" | "tabIndex" | "onKeyDown" | "onKeyUp" | "onClick" | "onMouseDown" | "onMouseLeave" | "onMouseOver" | "onMouseUp" | "clickOnEnter" | "clickOnSpace" | "
|
|
46
|
+
}) | (Omit<UseClickableProps<HTMLElement, Dict<any>>, "disabled" | "ref" | "tabIndex" | "onKeyDown" | "onKeyUp" | "onClick" | "onMouseDown" | "onMouseLeave" | "onMouseOver" | "onMouseUp" | "clickOnEnter" | "clickOnSpace" | "disableTouchBehavior" | "focusable" | "focusOnClick"> & {
|
|
47
47
|
ref: (node: any) => void;
|
|
48
48
|
"aria-disabled": "true" | undefined;
|
|
49
49
|
"data-active": string | undefined;
|
|
@@ -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/native-accordion/native-accordion.style.d.ts
|
|
5
|
-
export declare const nativeAccordionStyle: ComponentSlotStyle<"button" | "
|
|
5
|
+
export declare const nativeAccordionStyle: ComponentSlotStyle<"button" | "panel" | "icon" | "root" | "item", {
|
|
6
6
|
/**
|
|
7
7
|
* If `true`, animate the accordion items when they are expanded or collapsed.
|
|
8
8
|
*
|
|
@@ -32,7 +32,7 @@ export declare const nativeAccordionStyle: ComponentSlotStyle<"button" | "icon"
|
|
|
32
32
|
};
|
|
33
33
|
};
|
|
34
34
|
};
|
|
35
|
-
}, CSSModifierObject<CSSSlotObject<"button" | "
|
|
35
|
+
}, CSSModifierObject<CSSSlotObject<"button" | "panel" | "icon" | "root" | "item">>, {
|
|
36
36
|
panel: {
|
|
37
37
|
button: {
|
|
38
38
|
rounded: "l2";
|
|
@@ -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})";
|
|
@@ -24,9 +24,9 @@ export interface UseProgressProps {
|
|
|
24
24
|
export declare const useProgress: <Y extends "div" | "svg" = "div">({ max, min, value }?: UseProgressProps) => {
|
|
25
25
|
percent: number;
|
|
26
26
|
getRangeProps: (props?: HTMLProps<Y extends "svg" ? "circle" : "div">) => {
|
|
27
|
-
ref?: import("react").JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["ref"] | undefined;
|
|
28
27
|
slot?: import("react").JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["slot"] | undefined;
|
|
29
28
|
style?: import("react").JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["style"] | undefined;
|
|
29
|
+
ref?: import("react").JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["ref"] | undefined;
|
|
30
30
|
suppressHydrationWarning?: import("react").JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["suppressHydrationWarning"] | undefined;
|
|
31
31
|
className?: import("react").JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["className"] | undefined;
|
|
32
32
|
id?: import("react").JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["id"] | undefined;
|
|
@@ -262,9 +262,9 @@ export declare const useProgress: <Y extends "div" | "svg" = "div">({ max, min,
|
|
|
262
262
|
"data-indeterminate": string | undefined;
|
|
263
263
|
};
|
|
264
264
|
getRootProps: (props?: HTMLProps<Y>) => {
|
|
265
|
-
ref?: import("react").JSX.IntrinsicElements[Y]["ref"] | undefined;
|
|
266
265
|
slot?: import("react").JSX.IntrinsicElements[Y]["slot"] | undefined;
|
|
267
266
|
style?: import("react").JSX.IntrinsicElements[Y]["style"] | undefined;
|
|
267
|
+
ref?: import("react").JSX.IntrinsicElements[Y]["ref"] | undefined;
|
|
268
268
|
suppressHydrationWarning?: import("react").JSX.IntrinsicElements[Y]["suppressHydrationWarning"] | undefined;
|
|
269
269
|
className?: import("react").JSX.IntrinsicElements[Y]["className"] | undefined;
|
|
270
270
|
id?: import("react").JSX.IntrinsicElements[Y]["id"] | undefined;
|
|
@@ -500,9 +500,9 @@ export declare const useProgress: <Y extends "div" | "svg" = "div">({ max, min,
|
|
|
500
500
|
"data-indeterminate": string | undefined;
|
|
501
501
|
};
|
|
502
502
|
getTrackProps: (props?: HTMLProps<Y extends "svg" ? "circle" : "div">) => {
|
|
503
|
-
ref?: import("react").JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["ref"] | undefined;
|
|
504
503
|
slot?: import("react").JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["slot"] | undefined;
|
|
505
504
|
style?: import("react").JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["style"] | undefined;
|
|
505
|
+
ref?: import("react").JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["ref"] | undefined;
|
|
506
506
|
suppressHydrationWarning?: import("react").JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["suppressHydrationWarning"] | undefined;
|
|
507
507
|
className?: import("react").JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["className"] | undefined;
|
|
508
508
|
id?: import("react").JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["id"] | undefined;
|
|
@@ -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[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ComponentSlotStyle } from "../../core/system/index.type.js";
|
|
2
2
|
import "../../index.js";
|
|
3
3
|
//#region src/components/tabs/tabs.style.d.ts
|
|
4
|
-
export declare const tabsStyle: ComponentSlotStyle<"
|
|
4
|
+
export declare const tabsStyle: ComponentSlotStyle<"panel" | "list" | "tab" | "root", {
|
|
5
5
|
/**
|
|
6
6
|
* The alignment of the tabs.
|
|
7
7
|
*
|
|
@@ -214,11 +214,12 @@ export declare const useTreeItem: ({ asyncChildren, children: childrenProp, defa
|
|
|
214
214
|
level: number;
|
|
215
215
|
props: {
|
|
216
216
|
[key: `data-${string}`]: string | undefined;
|
|
217
|
-
ref?: import("react").Ref<HTMLDivElement> | undefined;
|
|
218
217
|
slot?: string | undefined | undefined;
|
|
219
218
|
style?: import("react").CSSProperties | undefined;
|
|
220
219
|
title?: string | undefined | undefined;
|
|
221
220
|
translate?: "yes" | "no" | undefined | undefined;
|
|
221
|
+
hidden?: boolean | undefined | undefined;
|
|
222
|
+
ref?: import("react").Ref<HTMLDivElement> | undefined;
|
|
222
223
|
defaultChecked?: boolean | undefined | undefined;
|
|
223
224
|
defaultValue?: string | number | readonly string[] | undefined;
|
|
224
225
|
suppressContentEditableWarning?: boolean | undefined | undefined;
|
|
@@ -227,12 +228,11 @@ export declare const useTreeItem: ({ asyncChildren, children: childrenProp, defa
|
|
|
227
228
|
autoCapitalize?: "off" | "none" | "on" | "sentences" | "words" | "characters" | undefined | (string & {}) | undefined;
|
|
228
229
|
autoFocus?: boolean | undefined | undefined;
|
|
229
230
|
className?: string | undefined | undefined;
|
|
230
|
-
contentEditable?: (boolean | "true" | "false") | "
|
|
231
|
+
contentEditable?: "inherit" | (boolean | "true" | "false") | "plaintext-only" | undefined;
|
|
231
232
|
contextMenu?: string | undefined | undefined;
|
|
232
233
|
dir?: string | undefined | undefined;
|
|
233
234
|
draggable?: (boolean | "true" | "false") | undefined;
|
|
234
235
|
enterKeyHint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined | undefined;
|
|
235
|
-
hidden?: boolean | undefined | undefined;
|
|
236
236
|
id?: string | undefined | undefined;
|
|
237
237
|
lang?: string | undefined | undefined;
|
|
238
238
|
nonce?: string | undefined | undefined;
|
|
@@ -46,7 +46,7 @@ export type UseClickableProps<Y extends HTMLElement = HTMLElement, M extends Use
|
|
|
46
46
|
*/
|
|
47
47
|
ref?: Ref<Y>;
|
|
48
48
|
};
|
|
49
|
-
export declare const useClickable: <Y extends HTMLElement = HTMLElement, M extends UseClickableElementProps<Y> = UseClickableElementProps<Y>>({ ref, clickOnEnter, clickOnSpace, disabled, disableTouchBehavior, focusable, focusOnClick, tabIndex: tabIndexProp, onClick: onClickProp, onKeyDown: onKeyDownProp, onKeyUp: onKeyUpProp, onMouseDown: onMouseDownProp, onMouseLeave: onMouseLeaveProp, onMouseOver: onMouseOverProp, onMouseUp: onMouseUpProp, ...props }?: UseClickableProps<Y, M>) => (Omit<UseClickableProps<Y, M>, "ref" | "tabIndex" | "onKeyDown" | "onKeyUp" | "onClick" | "onMouseDown" | "onMouseLeave" | "onMouseOver" | "onMouseUp" | "clickOnEnter" | "clickOnSpace" | "
|
|
49
|
+
export declare const useClickable: <Y extends HTMLElement = HTMLElement, M extends UseClickableElementProps<Y> = UseClickableElementProps<Y>>({ ref, clickOnEnter, clickOnSpace, disabled, disableTouchBehavior, focusable, focusOnClick, tabIndex: tabIndexProp, onClick: onClickProp, onKeyDown: onKeyDownProp, onKeyUp: onKeyUpProp, onMouseDown: onMouseDownProp, onMouseLeave: onMouseLeaveProp, onMouseOver: onMouseOverProp, onMouseUp: onMouseUpProp, ...props }?: UseClickableProps<Y, M>) => (Omit<UseClickableProps<Y, M>, "disabled" | "ref" | "tabIndex" | "onKeyDown" | "onKeyUp" | "onClick" | "onMouseDown" | "onMouseLeave" | "onMouseOver" | "onMouseUp" | "clickOnEnter" | "clickOnSpace" | "disableTouchBehavior" | "focusable" | "focusOnClick"> & {
|
|
50
50
|
ref: (node: any) => void;
|
|
51
51
|
type: "button";
|
|
52
52
|
"aria-disabled": boolean | undefined;
|
|
@@ -58,7 +58,7 @@ export declare const useClickable: <Y extends HTMLElement = HTMLElement, M exten
|
|
|
58
58
|
onMouseLeave: import("react").MouseEventHandler<Y> | undefined;
|
|
59
59
|
onMouseOver: import("react").MouseEventHandler<Y> | undefined;
|
|
60
60
|
onMouseUp: import("react").MouseEventHandler<Y> | undefined;
|
|
61
|
-
}) | (Omit<UseClickableProps<Y, M>, "ref" | "tabIndex" | "onKeyDown" | "onKeyUp" | "onClick" | "onMouseDown" | "onMouseLeave" | "onMouseOver" | "onMouseUp" | "clickOnEnter" | "clickOnSpace" | "
|
|
61
|
+
}) | (Omit<UseClickableProps<Y, M>, "disabled" | "ref" | "tabIndex" | "onKeyDown" | "onKeyUp" | "onClick" | "onMouseDown" | "onMouseLeave" | "onMouseOver" | "onMouseUp" | "clickOnEnter" | "clickOnSpace" | "disableTouchBehavior" | "focusable" | "focusOnClick"> & {
|
|
62
62
|
ref: (node: any) => void;
|
|
63
63
|
"aria-disabled": "true" | undefined;
|
|
64
64
|
"data-active": string | undefined;
|
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",
|