@yamada-ui/resizable 1.0.9-dev-20240313151005 → 1.0.9-dev-20240314115905
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/{chunk-4VTPHGNN.mjs → chunk-3BJMVXCF.mjs} +3 -1
- package/dist/chunk-3BJMVXCF.mjs.map +1 -0
- package/dist/{chunk-VGC5VWTA.mjs → chunk-BXVDBZXS.mjs} +3 -1
- package/dist/chunk-BXVDBZXS.mjs.map +1 -0
- package/dist/{chunk-Z6HNBICR.mjs → chunk-DJKFV3FP.mjs} +3 -1
- package/dist/chunk-DJKFV3FP.mjs.map +1 -0
- package/dist/{chunk-DTRCWMPS.mjs → chunk-R6EC3EDW.mjs} +3 -0
- package/dist/chunk-R6EC3EDW.mjs.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +6 -4
- package/dist/index.mjs.map +1 -0
- package/dist/resizable-item.js +2 -0
- package/dist/resizable-item.js.map +1 -0
- package/dist/resizable-item.mjs +4 -2
- package/dist/resizable-item.mjs.map +1 -0
- package/dist/resizable-trigger.js +2 -0
- package/dist/resizable-trigger.js.map +1 -0
- package/dist/resizable-trigger.mjs +4 -2
- package/dist/resizable-trigger.mjs.map +1 -0
- package/dist/resizable.js +2 -0
- package/dist/resizable.js.map +1 -0
- package/dist/resizable.mjs +4 -2
- package/dist/resizable.mjs.map +1 -0
- package/dist/use-resizable.js +2 -0
- package/dist/use-resizable.js.map +1 -0
- package/dist/use-resizable.mjs +3 -1
- package/dist/use-resizable.mjs.map +1 -0
- package/package.json +8 -4
@@ -1,7 +1,8 @@
|
|
1
|
+
"use client"
|
1
2
|
import {
|
2
3
|
ResizableProvider,
|
3
4
|
useResizable
|
4
|
-
} from "./chunk-
|
5
|
+
} from "./chunk-R6EC3EDW.mjs";
|
5
6
|
|
6
7
|
// src/resizable.tsx
|
7
8
|
import {
|
@@ -40,3 +41,4 @@ var Resizable = forwardRef(
|
|
40
41
|
export {
|
41
42
|
Resizable
|
42
43
|
};
|
44
|
+
//# sourceMappingURL=chunk-3BJMVXCF.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/resizable.tsx"],"sourcesContent":["import type { CSSUIObject, HTMLUIProps, ThemeProps } from \"@yamada-ui/core\"\nimport {\n ui,\n forwardRef,\n useMultiComponentStyle,\n omitThemeProps,\n} from \"@yamada-ui/core\"\nimport { cx } from \"@yamada-ui/utils\"\nimport type { ForwardedRef } from \"react\"\nimport { PanelGroup } from \"react-resizable-panels\"\nimport type { UseResizableProps } from \"./use-resizable\"\nimport { ResizableProvider, useResizable } from \"./use-resizable\"\n\ntype ResizableOptions = {\n /**\n * Ref for resizable container element.\n */\n containerRef?: ForwardedRef<HTMLDivElement>\n}\n\n/**\n * `Resizable` is accessible resizable panel groups and layouts with keyboard support.\n *\n * @see Docs https://yamada-ui.com/components/data-display/resizable\n */\nexport type ResizableProps = Omit<HTMLUIProps<\"div\">, \"direction\"> &\n ThemeProps<\"Resizable\"> &\n Omit<UseResizableProps, \"ref\"> &\n ResizableOptions\n\nexport const Resizable = forwardRef<ResizableProps, \"div\">(\n ({ direction = \"horizontal\", ...props }, ref) => {\n const [styles, mergedProps] = useMultiComponentStyle(\"Resizable\", {\n direction,\n ...props,\n })\n const { className, children, containerRef, ...computedProps } =\n omitThemeProps(mergedProps)\n const { getContainerProps, getGroupProps, ...rest } = useResizable({\n ref,\n ...computedProps,\n })\n\n const css: CSSUIObject = { w: \"100%\", h: \"100%\", ...styles.container }\n\n return (\n <ResizableProvider value={{ styles, ...rest }}>\n <ui.div\n className={cx(\"ui-resizable\", className)}\n __css={css}\n {...getContainerProps({}, containerRef)}\n >\n <PanelGroup {...getGroupProps()}>{children}</PanelGroup>\n </ui.div>\n </ResizableProvider>\n )\n },\n)\n"],"mappings":";;;;;;;AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,UAAU;AAEnB,SAAS,kBAAkB;AA2CjB;AAtBH,IAAM,YAAY;AAAA,EACvB,CAAC,EAAE,YAAY,cAAc,GAAG,MAAM,GAAG,QAAQ;AAC/C,UAAM,CAAC,QAAQ,WAAW,IAAI,uBAAuB,aAAa;AAAA,MAChE;AAAA,MACA,GAAG;AAAA,IACL,CAAC;AACD,UAAM,EAAE,WAAW,UAAU,cAAc,GAAG,cAAc,IAC1D,eAAe,WAAW;AAC5B,UAAM,EAAE,mBAAmB,eAAe,GAAG,KAAK,IAAI,aAAa;AAAA,MACjE;AAAA,MACA,GAAG;AAAA,IACL,CAAC;AAED,UAAM,MAAmB,EAAE,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,UAAU;AAErE,WACE,oBAAC,qBAAkB,OAAO,EAAE,QAAQ,GAAG,KAAK,GAC1C;AAAA,MAAC,GAAG;AAAA,MAAH;AAAA,QACC,WAAW,GAAG,gBAAgB,SAAS;AAAA,QACvC,OAAO;AAAA,QACN,GAAG,kBAAkB,CAAC,GAAG,YAAY;AAAA,QAEtC,8BAAC,cAAY,GAAG,cAAc,GAAI,UAAS;AAAA;AAAA,IAC7C,GACF;AAAA,EAEJ;AACF;","names":[]}
|
@@ -1,7 +1,8 @@
|
|
1
|
+
"use client"
|
1
2
|
import {
|
2
3
|
useResizableContext,
|
3
4
|
useResizableItem
|
4
|
-
} from "./chunk-
|
5
|
+
} from "./chunk-R6EC3EDW.mjs";
|
5
6
|
|
6
7
|
// src/resizable-item.tsx
|
7
8
|
import { ui, forwardRef } from "@yamada-ui/core";
|
@@ -71,3 +72,4 @@ var ResizableItem = forwardRef(
|
|
71
72
|
export {
|
72
73
|
ResizableItem
|
73
74
|
};
|
75
|
+
//# sourceMappingURL=chunk-BXVDBZXS.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/resizable-item.tsx"],"sourcesContent":["import type { CSSUIObject } from \"@yamada-ui/core\"\nimport { ui, forwardRef } from \"@yamada-ui/core\"\nimport { cx } from \"@yamada-ui/utils\"\nimport type { ForwardedRef } from \"react\"\nimport { Panel } from \"react-resizable-panels\"\nimport type { UseResizableItemProps } from \"./use-resizable\"\nimport { useResizableContext, useResizableItem } from \"./use-resizable\"\n\nconst panelProps = new Set([\"order\"])\n\nconst UIPanel = ui(Panel, { disableStyleProp: (prop) => panelProps.has(prop) })\n\ntype ResizableItemOptions = {\n /**\n * Ref for resizable item inner element.\n */\n innerRef?: ForwardedRef<HTMLDivElement>\n}\n\nexport type ResizableItemProps = Omit<UseResizableItemProps, \"ref\"> &\n ResizableItemOptions\n\nexport const ResizableItem = forwardRef<ResizableItemProps, \"div\">(\n (\n {\n className,\n children,\n innerRef,\n w,\n width,\n minW,\n minWidth,\n maxW,\n maxWidth,\n h,\n height,\n minH,\n minHeight,\n maxH,\n maxHeight,\n boxSize,\n ...rest\n },\n ref,\n ) => {\n const { styles } = useResizableContext()\n const { getPanelProps, getItemProps } = useResizableItem({\n ref,\n ...rest,\n })\n\n const css: CSSUIObject = { boxSize: \"100%\", ...styles.item }\n\n return (\n <UIPanel\n {...getPanelProps({\n w,\n width,\n minW,\n minWidth,\n maxW,\n maxWidth,\n h,\n height,\n minH,\n minHeight,\n maxH,\n maxHeight,\n boxSize,\n })}\n >\n <ui.div\n className={cx(\"ui-resizable__item\", className)}\n __css={css}\n {...getItemProps({}, innerRef)}\n >\n {children}\n </ui.div>\n </UIPanel>\n )\n },\n)\n"],"mappings":";;;;;;;AACA,SAAS,IAAI,kBAAkB;AAC/B,SAAS,UAAU;AAEnB,SAAS,aAAa;AAmEd;AA/DR,IAAM,aAAa,oBAAI,IAAI,CAAC,OAAO,CAAC;AAEpC,IAAM,UAAU,GAAG,OAAO,EAAE,kBAAkB,CAAC,SAAS,WAAW,IAAI,IAAI,EAAE,CAAC;AAYvE,IAAM,gBAAgB;AAAA,EAC3B,CACE;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,GACA,QACG;AACH,UAAM,EAAE,OAAO,IAAI,oBAAoB;AACvC,UAAM,EAAE,eAAe,aAAa,IAAI,iBAAiB;AAAA,MACvD;AAAA,MACA,GAAG;AAAA,IACL,CAAC;AAED,UAAM,MAAmB,EAAE,SAAS,QAAQ,GAAG,OAAO,KAAK;AAE3D,WACE;AAAA,MAAC;AAAA;AAAA,QACE,GAAG,cAAc;AAAA,UAChB;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACF,CAAC;AAAA,QAED;AAAA,UAAC,GAAG;AAAA,UAAH;AAAA,YACC,WAAW,GAAG,sBAAsB,SAAS;AAAA,YAC7C,OAAO;AAAA,YACN,GAAG,aAAa,CAAC,GAAG,QAAQ;AAAA,YAE5B;AAAA;AAAA,QACH;AAAA;AAAA,IACF;AAAA,EAEJ;AACF;","names":[]}
|
@@ -1,7 +1,8 @@
|
|
1
|
+
"use client"
|
1
2
|
import {
|
2
3
|
useResizableContext,
|
3
4
|
useResizableTrigger
|
4
|
-
} from "./chunk-
|
5
|
+
} from "./chunk-R6EC3EDW.mjs";
|
5
6
|
|
6
7
|
// src/resizable-trigger.tsx
|
7
8
|
import { ui, forwardRef } from "@yamada-ui/core";
|
@@ -102,3 +103,4 @@ export {
|
|
102
103
|
ResizableTrigger,
|
103
104
|
ResizableTriggerIcon
|
104
105
|
};
|
106
|
+
//# sourceMappingURL=chunk-DJKFV3FP.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/resizable-trigger.tsx"],"sourcesContent":["import type { CSSUIObject, HTMLUIProps } from \"@yamada-ui/core\"\nimport { ui, forwardRef } from \"@yamada-ui/core\"\nimport type { IconProps } from \"@yamada-ui/icon\"\nimport { Icon } from \"@yamada-ui/icon\"\nimport { cx } from \"@yamada-ui/utils\"\nimport type { FC, ReactElement } from \"react\"\nimport { PanelResizeHandle } from \"react-resizable-panels\"\nimport type { UseResizableTriggerProps } from \"./use-resizable\"\nimport { useResizableContext, useResizableTrigger } from \"./use-resizable\"\n\ntype ResizableTriggerOptions = {\n /**\n * The resizable trigger icon to use.\n */\n icon?: ReactElement\n /**\n * Props for resizable trigger icon component.\n */\n iconProps?: HTMLUIProps<\"div\">\n}\n\nexport type ResizableTriggerProps = Omit<HTMLUIProps<\"div\">, \"as\"> &\n Omit<UseResizableTriggerProps, \"ref\"> &\n ResizableTriggerOptions\n\nexport const ResizableTrigger = forwardRef<ResizableTriggerProps, \"div\", false>(\n ({ className, icon, children, iconProps, ...rest }, ref) => {\n const { styles } = useResizableContext()\n const { getTriggerProps, getIconProps } = useResizableTrigger({\n ref,\n ...rest,\n })\n\n const css: CSSUIObject = { position: \"relative\", ...styles.trigger }\n\n return (\n <ui.div\n as={PanelResizeHandle}\n className={cx(\"ui-resizable__trigger\", className)}\n __css={css}\n {...getTriggerProps()}\n >\n {icon ? (\n <ui.div\n className=\"ui-resizable__trigger__icon\"\n __css={{\n position: \"absolute\",\n top: \"50%\",\n left: \"50%\",\n transform: \"auto\",\n translateY: \"-50%\",\n translateX: \"-50%\",\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n ...styles.icon,\n }}\n {...getIconProps(iconProps)}\n >\n {icon}\n </ui.div>\n ) : null}\n\n {children}\n </ui.div>\n )\n },\n)\n\nexport type ResizableTriggerIconProps = IconProps\n\nexport const ResizableTriggerIcon: FC<ResizableTriggerIconProps> = (rest) => {\n return (\n <Icon viewBox=\"0 0 23 39\" w=\"2\" h=\"4\" {...rest}>\n <path\n d=\"M 5 0 C 7.761 0 10 2.239 10 5 C 10 7.761 7.761 10 5 10 C 2.239 10 0 7.761 0 5 C 0 2.239 2.239 0 5 0 Z\"\n fill=\"currentColor\"\n />\n\n <path\n d=\"M 19 0 C 21.761 0 24 2.239 24 5 C 24 7.761 21.761 10 19 10 C 16.239 10 14 7.761 14 5 C 14 2.239 16.239 0 19 0 Z\"\n fill=\"currentColor\"\n />\n\n <path\n d=\"M 19 14 C 21.761 14 24 16.239 24 19 C 24 21.761 21.761 24 19 24 C 16.239 24 14 21.761 14 19 C 14 16.239 16.239 14 19 14 Z\"\n fill=\"currentColor\"\n />\n\n <path\n d=\"M 5 14 C 7.761 14 10 16.239 10 19 C 10 21.761 7.761 24 5 24 C 2.239 24 0 21.761 0 19 C 0 16.239 2.239 14 5 14 Z\"\n fill=\"currentColor\"\n />\n\n <path\n d=\"M 5 28 C 7.761 28 10 30.239 10 33 C 10 35.761 7.761 38 5 38 C 2.239 38 0 35.761 0 33 C 0 30.239 2.239 28 5 28 Z\"\n fill=\"currentColor\"\n />\n\n <path\n d=\"M 19 28 C 21.761 28 24 30.239 24 33 C 24 35.761 21.761 38 19 38 C 16.239 38 14 35.761 14 33 C 14 30.239 16.239 28 19 28 Z\"\n fill=\"currentColor\"\n />\n </Icon>\n )\n}\n"],"mappings":";;;;;;;AACA,SAAS,IAAI,kBAAkB;AAE/B,SAAS,YAAY;AACrB,SAAS,UAAU;AAEnB,SAAS,yBAAyB;AA8B5B,SAOI,KAPJ;AAXC,IAAM,mBAAmB;AAAA,EAC9B,CAAC,EAAE,WAAW,MAAM,UAAU,WAAW,GAAG,KAAK,GAAG,QAAQ;AAC1D,UAAM,EAAE,OAAO,IAAI,oBAAoB;AACvC,UAAM,EAAE,iBAAiB,aAAa,IAAI,oBAAoB;AAAA,MAC5D;AAAA,MACA,GAAG;AAAA,IACL,CAAC;AAED,UAAM,MAAmB,EAAE,UAAU,YAAY,GAAG,OAAO,QAAQ;AAEnE,WACE;AAAA,MAAC,GAAG;AAAA,MAAH;AAAA,QACC,IAAI;AAAA,QACJ,WAAW,GAAG,yBAAyB,SAAS;AAAA,QAChD,OAAO;AAAA,QACN,GAAG,gBAAgB;AAAA,QAEnB;AAAA,iBACC;AAAA,YAAC,GAAG;AAAA,YAAH;AAAA,cACC,WAAU;AAAA,cACV,OAAO;AAAA,gBACL,UAAU;AAAA,gBACV,KAAK;AAAA,gBACL,MAAM;AAAA,gBACN,WAAW;AAAA,gBACX,YAAY;AAAA,gBACZ,YAAY;AAAA,gBACZ,SAAS;AAAA,gBACT,gBAAgB;AAAA,gBAChB,YAAY;AAAA,gBACZ,GAAG,OAAO;AAAA,cACZ;AAAA,cACC,GAAG,aAAa,SAAS;AAAA,cAEzB;AAAA;AAAA,UACH,IACE;AAAA,UAEH;AAAA;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AAIO,IAAM,uBAAsD,CAAC,SAAS;AAC3E,SACE,qBAAC,QAAK,SAAQ,aAAY,GAAE,KAAI,GAAE,KAAK,GAAG,MACxC;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,GAAE;AAAA,QACF,MAAK;AAAA;AAAA,IACP;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,GAAE;AAAA,QACF,MAAK;AAAA;AAAA,IACP;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,GAAE;AAAA,QACF,MAAK;AAAA;AAAA,IACP;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,GAAE;AAAA,QACF,MAAK;AAAA;AAAA,IACP;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,GAAE;AAAA,QACF,MAAK;AAAA;AAAA,IACP;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,GAAE;AAAA,QACF,MAAK;AAAA;AAAA,IACP;AAAA,KACF;AAEJ;","names":[]}
|
@@ -1,3 +1,5 @@
|
|
1
|
+
"use client"
|
2
|
+
|
1
3
|
// src/use-resizable.ts
|
2
4
|
import { createContext, dataAttr, handlerAll } from "@yamada-ui/utils";
|
3
5
|
import { useCallback, useEffect, useId, useState } from "react";
|
@@ -183,3 +185,4 @@ export {
|
|
183
185
|
useResizableItem,
|
184
186
|
useResizableTrigger
|
185
187
|
};
|
188
|
+
//# sourceMappingURL=chunk-R6EC3EDW.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/use-resizable.ts"],"sourcesContent":["import type { CSSUIObject, HTMLUIProps, UIPropGetter } from \"@yamada-ui/core\"\nimport type { PropGetter } from \"@yamada-ui/utils\"\nimport { createContext, dataAttr, handlerAll } from \"@yamada-ui/utils\"\nimport type { ForwardedRef, RefObject } from \"react\"\nimport { useCallback, useEffect, useId, useState } from \"react\"\nimport {\n getPanelElement,\n getPanelGroupElement,\n getResizeHandleElement,\n} from \"react-resizable-panels\"\nimport type {\n PanelResizeHandleProps,\n PanelGroupProps,\n PanelProps,\n PanelGroupOnLayout,\n PanelGroupStorage,\n ImperativePanelHandle,\n} from \"react-resizable-panels\"\n\ntype GroupPropGetter = (props?: Partial<PanelGroupProps>) => PanelGroupProps\ntype ItemPropGetter = (props?: HTMLUIProps<\"div\"> & PanelProps) => PanelProps\ntype TriggerPropGetter = (\n props?: PanelResizeHandleProps,\n) => PanelResizeHandleProps\n\ntype As = { as?: keyof HTMLElementTagNameMap }\n\ntype ResizableGroupProps = Omit<\n PanelGroupProps,\n \"id\" | \"tagName\" | \"children\"\n> &\n As\ntype ResizableItemProps = Omit<PanelProps, \"id\" | \"tagName\" | \"children\"> & As\ntype ResizableTriggerProps = Omit<\n PanelResizeHandleProps,\n \"id\" | \"tagName\" | \"children\"\n> &\n As\n\nexport type ResizableStorage = PanelGroupStorage\nexport type ResizableItemControl = ImperativePanelHandle\n\ntype ResizableContext = {\n isDisabled: boolean\n styles: Record<string, CSSUIObject>\n}\n\nexport const [ResizableProvider, useResizableContext] =\n createContext<ResizableContext>({\n name: \"ResizableContext\",\n errorMessage: `useResizableContext returned is 'undefined'. Seems you forgot to wrap the components in \"<Resizable />\"`,\n })\n\nexport type UseResizableProps = {\n /**\n * id assigned to resizable element.\n */\n id?: string\n /**\n * Ref for resizable element.\n */\n ref?: ForwardedRef<HTMLElement>\n /**\n * The direction of the resizable.\n *\n * @default \"horizontal\"\n */\n direction?: \"horizontal\" | \"vertical\"\n /**\n * If `true`, the resizable trigger will be disabled.\n */\n isDisabled?: boolean\n /**\n * Unit to resize by keyboard operation.\n *\n * @default 10\n */\n keyboardStep?: number\n /**\n * Key of value saved in storage.\n * By default, it is saved to `local storage`.\n */\n storageKey?: string\n /**\n * A callback that gets and sets a value in custom storage.\n */\n storage?: PanelGroupStorage\n /**\n * The callback invoked when resizable items are resized.\n */\n onLayout?: PanelGroupOnLayout\n /**\n * Props for resizable component.\n */\n groupProps?: ResizableGroupProps\n}\n\nexport const useResizable = ({\n id,\n direction = \"horizontal\",\n storageKey,\n keyboardStep,\n isDisabled = false,\n onLayout,\n storage,\n ref,\n groupProps,\n ...rest\n}: UseResizableProps) => {\n id ??= useId()\n\n const getContainerProps: PropGetter = useCallback(\n (props = {}, ref = null) => ({ ...props, ref, ...rest }),\n [rest],\n )\n\n const getGroupProps: GroupPropGetter = useCallback(\n (props = {}) => {\n const { as, ...rest } = groupProps ?? {}\n\n return {\n ...props,\n id,\n direction,\n tagName: as,\n autoSaveId: storageKey,\n keyboardResizeBy: keyboardStep,\n onLayout,\n storage,\n ...rest,\n }\n },\n [id, direction, groupProps, storageKey, keyboardStep, onLayout, storage],\n )\n\n useEffect(() => {\n if (!id) return\n\n const el = getPanelGroupElement(id)\n\n // @ts-expect-error\n if (ref) ref.current = el\n }, [ref, id])\n\n return {\n isDisabled,\n getContainerProps,\n getGroupProps,\n }\n}\n\nexport type UseResizableReturn = ReturnType<typeof useResizable>\n\ntype UseResizableItemOptions = {\n /**\n * id assigned to resizable item element.\n */\n id?: string\n /**\n * Ref for resizable item element.\n */\n ref?: ForwardedRef<HTMLElement>\n /**\n * If `true`, the resizable item can be collapsed.\n *\n * @default false\n */\n collapsible?: boolean\n /**\n * The collapsed size of the resizable item.\n */\n collapsedSize?: number\n /**\n * The initial size of the resizable item.\n */\n defaultSize?: number\n /**\n * The minimum allowed value of the resizable item.\n */\n minSize?: number\n /**\n * The maximum allowed value of the resizable item.\n */\n maxSize?: number\n /**\n * The callback invoked when resizable item are collapsed.\n */\n onCollapse?: () => void\n /**\n * The callback invoked when resizable item are expanded.\n */\n onExpand?: () => void\n /**\n * The callback invoked when resizable item are resized.\n */\n onResize?: (size: number, prevSize: number | undefined) => void\n /**\n * Order for the resizable item.\n */\n order?: number\n /**\n * Ref of the resizable item callback.\n */\n controlRef?: RefObject<ResizableItemControl>\n /**\n * Props for resizable item container element.\n */\n containerProps?: Omit<HTMLUIProps<\"div\">, \"as\"> & ResizableItemProps\n}\n\nexport type UseResizableItemProps = Omit<\n HTMLUIProps<\"div\">,\n keyof UseResizableItemOptions\n> &\n UseResizableItemOptions\n\nexport const useResizableItem = ({\n id,\n ref,\n collapsedSize,\n collapsible,\n defaultSize,\n maxSize,\n minSize,\n onCollapse,\n onExpand,\n onResize,\n order,\n controlRef,\n containerProps,\n ...innerProps\n}: UseResizableItemProps) => {\n id ??= useId()\n\n const getPanelProps: ItemPropGetter = useCallback(\n (props = {}) => {\n const { as, ...rest } = containerProps ?? {}\n\n return {\n ...props,\n ref: controlRef,\n id,\n tagName: as,\n collapsible,\n defaultSize,\n maxSize,\n minSize,\n collapsedSize,\n onCollapse,\n onExpand,\n onResize,\n order,\n ...rest,\n }\n },\n [\n id,\n controlRef,\n containerProps,\n collapsedSize,\n collapsible,\n defaultSize,\n maxSize,\n minSize,\n onCollapse,\n onExpand,\n onResize,\n order,\n ],\n )\n\n const getItemProps: UIPropGetter = useCallback(\n (props = {}, ref = null) => ({ ...props, ref, ...innerProps }),\n [innerProps],\n )\n\n useEffect(() => {\n if (!id) return\n\n const el = getPanelElement(id)\n\n // @ts-expect-error\n if (ref) ref.current = el\n }, [ref, id])\n\n return {\n getPanelProps,\n getItemProps,\n }\n}\n\nexport type UseResizableItemReturn = ReturnType<typeof useResizableItem>\n\ntype UseResizableTriggerOptions = {\n /**\n * id assigned to resizable trigger element.\n */\n id?: string\n /**\n * Ref for resizable trigger element.\n */\n ref?: ForwardedRef<HTMLElement>\n /**\n * If `true`, the resizable trigger will be disabled.\n *\n * @default false\n */\n isDisabled?: boolean\n /**\n * The callback invoked when resizable trigger are dragged.\n */\n onDragging?: (isDragging: boolean) => void\n}\n\nexport type UseResizableTriggerProps = HTMLUIProps<\"div\"> &\n ResizableTriggerProps &\n UseResizableTriggerOptions\n\nexport const useResizableTrigger = ({\n id,\n ref,\n as,\n disabled,\n isDisabled,\n onDragging,\n ...rest\n}: UseResizableTriggerProps) => {\n id ??= useId()\n\n const { isDisabled: isGroupDisabled } = useResizableContext()\n const [isActive, setIsActive] = useState<boolean>(false)\n\n const trulyDisabled = disabled || isDisabled || isGroupDisabled\n\n const getTriggerProps: TriggerPropGetter = useCallback(\n (props = {}) => ({\n ...props,\n id,\n tagName: as,\n disabled: trulyDisabled,\n onDragging: handlerAll(onDragging, (isActive) => setIsActive(isActive)),\n ...rest,\n \"data-active\": dataAttr(isActive),\n style: {\n ...props.style,\n ...rest.style,\n ...(trulyDisabled ? { cursor: \"default\" } : {}),\n },\n }),\n [id, as, trulyDisabled, onDragging, rest, isActive],\n )\n\n const getIconProps: UIPropGetter = useCallback(\n (props = {}, ref = null) => ({\n ...props,\n ref,\n \"data-active\": dataAttr(isActive),\n }),\n [isActive],\n )\n\n useEffect(() => {\n if (!id) return\n\n const el = getResizeHandleElement(id)\n\n // @ts-expect-error\n if (ref) ref.current = el\n }, [ref, id])\n\n return {\n getTriggerProps,\n getIconProps,\n }\n}\n\nexport type UseResizableTriggerReturn = ReturnType<typeof useResizableTrigger>\n"],"mappings":";;;AAEA,SAAS,eAAe,UAAU,kBAAkB;AAEpD,SAAS,aAAa,WAAW,OAAO,gBAAgB;AACxD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAsCA,IAAM,CAAC,mBAAmB,mBAAmB,IAClD,cAAgC;AAAA,EAC9B,MAAM;AAAA,EACN,cAAc;AAChB,CAAC;AA8CI,IAAM,eAAe,CAA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AAM;AAAA,QACT,GAAG,KAAK;AAAA,QACR,GAAI,gBAAgB,EAAE,QAAQ,UAAU,IAAI,CAAC;AAAA,MAC/C;AAAA,IACF;AAAA,IACA,CAAC,IAAI,IAAI,eAAe,YAAY,MAAM,QAAQ;AAAA,EACpD;AAEA,QAAM,eAA6B;AAAA,IACjC,CAAC,QAAQ,CAAC,GAAGF,OAAM,UAAU;AAAA,MAC3B,GAAG;AAAA,MACH,KAAAA;AAAA,MACA,eAAe,SAAS,QAAQ;AAAA,IAClC;AAAA,IACA,CAAC,QAAQ;AAAA,EACX;AAEA,YAAU,MAAM;AACd,QAAI,CAAC;AAAI;AAET,UAAM,KAAK,uBAAuB,EAAE;AAGpC,QAAI;AAAK,UAAI,UAAU;AAAA,EACzB,GAAG,CAAC,KAAK,EAAE,CAAC;AAEZ,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":["ref","rest","isActive"]}
|
package/dist/index.js
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
"use client"
|
1
2
|
"use strict";
|
2
3
|
var __defProp = Object.defineProperty;
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
@@ -398,3 +399,4 @@ var ResizableTriggerIcon = (rest) => {
|
|
398
399
|
ResizableTrigger,
|
399
400
|
ResizableTriggerIcon
|
400
401
|
});
|
402
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/resizable.tsx","../src/use-resizable.ts","../src/resizable-item.tsx","../src/resizable-trigger.tsx"],"sourcesContent":["export { Resizable } from \"./resizable\"\nexport type { ResizableProps } from \"./resizable\"\nexport { ResizableItem } from \"./resizable-item\"\nexport type { ResizableItemProps } from \"./resizable-item\"\nexport { ResizableTrigger, ResizableTriggerIcon } from \"./resizable-trigger\"\nexport type {\n ResizableTriggerProps,\n ResizableTriggerIconProps,\n} from \"./resizable-trigger\"\nexport type { ResizableStorage, ResizableItemControl } from \"./use-resizable\"\n","import type { CSSUIObject, HTMLUIProps, ThemeProps } from \"@yamada-ui/core\"\nimport {\n ui,\n forwardRef,\n useMultiComponentStyle,\n omitThemeProps,\n} from \"@yamada-ui/core\"\nimport { cx } from \"@yamada-ui/utils\"\nimport type { ForwardedRef } from \"react\"\nimport { PanelGroup } from \"react-resizable-panels\"\nimport type { UseResizableProps } from \"./use-resizable\"\nimport { ResizableProvider, useResizable } from \"./use-resizable\"\n\ntype ResizableOptions = {\n /**\n * Ref for resizable container element.\n */\n containerRef?: ForwardedRef<HTMLDivElement>\n}\n\n/**\n * `Resizable` is accessible resizable panel groups and layouts with keyboard support.\n *\n * @see Docs https://yamada-ui.com/components/data-display/resizable\n */\nexport type ResizableProps = Omit<HTMLUIProps<\"div\">, \"direction\"> &\n ThemeProps<\"Resizable\"> &\n Omit<UseResizableProps, \"ref\"> &\n ResizableOptions\n\nexport const Resizable = forwardRef<ResizableProps, \"div\">(\n ({ direction = \"horizontal\", ...props }, ref) => {\n const [styles, mergedProps] = useMultiComponentStyle(\"Resizable\", {\n direction,\n ...props,\n })\n const { className, children, containerRef, ...computedProps } =\n omitThemeProps(mergedProps)\n const { getContainerProps, getGroupProps, ...rest } = useResizable({\n ref,\n ...computedProps,\n })\n\n const css: CSSUIObject = { w: \"100%\", h: \"100%\", ...styles.container }\n\n return (\n <ResizableProvider value={{ styles, ...rest }}>\n <ui.div\n className={cx(\"ui-resizable\", className)}\n __css={css}\n {...getContainerProps({}, containerRef)}\n >\n <PanelGroup {...getGroupProps()}>{children}</PanelGroup>\n </ui.div>\n </ResizableProvider>\n )\n },\n)\n","import type { CSSUIObject, HTMLUIProps, UIPropGetter } from \"@yamada-ui/core\"\nimport type { PropGetter } from \"@yamada-ui/utils\"\nimport { createContext, dataAttr, handlerAll } from \"@yamada-ui/utils\"\nimport type { ForwardedRef, RefObject } from \"react\"\nimport { useCallback, useEffect, useId, useState } from \"react\"\nimport {\n getPanelElement,\n getPanelGroupElement,\n getResizeHandleElement,\n} from \"react-resizable-panels\"\nimport type {\n PanelResizeHandleProps,\n PanelGroupProps,\n PanelProps,\n PanelGroupOnLayout,\n PanelGroupStorage,\n ImperativePanelHandle,\n} from \"react-resizable-panels\"\n\ntype GroupPropGetter = (props?: Partial<PanelGroupProps>) => PanelGroupProps\ntype ItemPropGetter = (props?: HTMLUIProps<\"div\"> & PanelProps) => PanelProps\ntype TriggerPropGetter = (\n props?: PanelResizeHandleProps,\n) => PanelResizeHandleProps\n\ntype As = { as?: keyof HTMLElementTagNameMap }\n\ntype ResizableGroupProps = Omit<\n PanelGroupProps,\n \"id\" | \"tagName\" | \"children\"\n> &\n As\ntype ResizableItemProps = Omit<PanelProps, \"id\" | \"tagName\" | \"children\"> & As\ntype ResizableTriggerProps = Omit<\n PanelResizeHandleProps,\n \"id\" | \"tagName\" | \"children\"\n> &\n As\n\nexport type ResizableStorage = PanelGroupStorage\nexport type ResizableItemControl = ImperativePanelHandle\n\ntype ResizableContext = {\n isDisabled: boolean\n styles: Record<string, CSSUIObject>\n}\n\nexport const [ResizableProvider, useResizableContext] =\n createContext<ResizableContext>({\n name: \"ResizableContext\",\n errorMessage: `useResizableContext returned is 'undefined'. Seems you forgot to wrap the components in \"<Resizable />\"`,\n })\n\nexport type UseResizableProps = {\n /**\n * id assigned to resizable element.\n */\n id?: string\n /**\n * Ref for resizable element.\n */\n ref?: ForwardedRef<HTMLElement>\n /**\n * The direction of the resizable.\n *\n * @default \"horizontal\"\n */\n direction?: \"horizontal\" | \"vertical\"\n /**\n * If `true`, the resizable trigger will be disabled.\n */\n isDisabled?: boolean\n /**\n * Unit to resize by keyboard operation.\n *\n * @default 10\n */\n keyboardStep?: number\n /**\n * Key of value saved in storage.\n * By default, it is saved to `local storage`.\n */\n storageKey?: string\n /**\n * A callback that gets and sets a value in custom storage.\n */\n storage?: PanelGroupStorage\n /**\n * The callback invoked when resizable items are resized.\n */\n onLayout?: PanelGroupOnLayout\n /**\n * Props for resizable component.\n */\n groupProps?: ResizableGroupProps\n}\n\nexport const useResizable = ({\n id,\n direction = \"horizontal\",\n storageKey,\n keyboardStep,\n isDisabled = false,\n onLayout,\n storage,\n ref,\n groupProps,\n ...rest\n}: UseResizableProps) => {\n id ??= useId()\n\n const getContainerProps: PropGetter = useCallback(\n (props = {}, ref = null) => ({ ...props, ref, ...rest }),\n [rest],\n )\n\n const getGroupProps: GroupPropGetter = useCallback(\n (props = {}) => {\n const { as, ...rest } = groupProps ?? {}\n\n return {\n ...props,\n id,\n direction,\n tagName: as,\n autoSaveId: storageKey,\n keyboardResizeBy: keyboardStep,\n onLayout,\n storage,\n ...rest,\n }\n },\n [id, direction, groupProps, storageKey, keyboardStep, onLayout, storage],\n )\n\n useEffect(() => {\n if (!id) return\n\n const el = getPanelGroupElement(id)\n\n // @ts-expect-error\n if (ref) ref.current = el\n }, [ref, id])\n\n return {\n isDisabled,\n getContainerProps,\n getGroupProps,\n }\n}\n\nexport type UseResizableReturn = ReturnType<typeof useResizable>\n\ntype UseResizableItemOptions = {\n /**\n * id assigned to resizable item element.\n */\n id?: string\n /**\n * Ref for resizable item element.\n */\n ref?: ForwardedRef<HTMLElement>\n /**\n * If `true`, the resizable item can be collapsed.\n *\n * @default false\n */\n collapsible?: boolean\n /**\n * The collapsed size of the resizable item.\n */\n collapsedSize?: number\n /**\n * The initial size of the resizable item.\n */\n defaultSize?: number\n /**\n * The minimum allowed value of the resizable item.\n */\n minSize?: number\n /**\n * The maximum allowed value of the resizable item.\n */\n maxSize?: number\n /**\n * The callback invoked when resizable item are collapsed.\n */\n onCollapse?: () => void\n /**\n * The callback invoked when resizable item are expanded.\n */\n onExpand?: () => void\n /**\n * The callback invoked when resizable item are resized.\n */\n onResize?: (size: number, prevSize: number | undefined) => void\n /**\n * Order for the resizable item.\n */\n order?: number\n /**\n * Ref of the resizable item callback.\n */\n controlRef?: RefObject<ResizableItemControl>\n /**\n * Props for resizable item container element.\n */\n containerProps?: Omit<HTMLUIProps<\"div\">, \"as\"> & ResizableItemProps\n}\n\nexport type UseResizableItemProps = Omit<\n HTMLUIProps<\"div\">,\n keyof UseResizableItemOptions\n> &\n UseResizableItemOptions\n\nexport const useResizableItem = ({\n id,\n ref,\n collapsedSize,\n collapsible,\n defaultSize,\n maxSize,\n minSize,\n onCollapse,\n onExpand,\n onResize,\n order,\n controlRef,\n containerProps,\n ...innerProps\n}: UseResizableItemProps) => {\n id ??= useId()\n\n const getPanelProps: ItemPropGetter = useCallback(\n (props = {}) => {\n const { as, ...rest } = containerProps ?? {}\n\n return {\n ...props,\n ref: controlRef,\n id,\n tagName: as,\n collapsible,\n defaultSize,\n maxSize,\n minSize,\n collapsedSize,\n onCollapse,\n onExpand,\n onResize,\n order,\n ...rest,\n }\n },\n [\n id,\n controlRef,\n containerProps,\n collapsedSize,\n collapsible,\n defaultSize,\n maxSize,\n minSize,\n onCollapse,\n onExpand,\n onResize,\n order,\n ],\n )\n\n const getItemProps: UIPropGetter = useCallback(\n (props = {}, ref = null) => ({ ...props, ref, ...innerProps }),\n [innerProps],\n )\n\n useEffect(() => {\n if (!id) return\n\n const el = getPanelElement(id)\n\n // @ts-expect-error\n if (ref) ref.current = el\n }, [ref, id])\n\n return {\n getPanelProps,\n getItemProps,\n }\n}\n\nexport type UseResizableItemReturn = ReturnType<typeof useResizableItem>\n\ntype UseResizableTriggerOptions = {\n /**\n * id assigned to resizable trigger element.\n */\n id?: string\n /**\n * Ref for resizable trigger element.\n */\n ref?: ForwardedRef<HTMLElement>\n /**\n * If `true`, the resizable trigger will be disabled.\n *\n * @default false\n */\n isDisabled?: boolean\n /**\n * The callback invoked when resizable trigger are dragged.\n */\n onDragging?: (isDragging: boolean) => void\n}\n\nexport type UseResizableTriggerProps = HTMLUIProps<\"div\"> &\n ResizableTriggerProps &\n UseResizableTriggerOptions\n\nexport const useResizableTrigger = ({\n id,\n ref,\n as,\n disabled,\n isDisabled,\n onDragging,\n ...rest\n}: UseResizableTriggerProps) => {\n id ??= useId()\n\n const { isDisabled: isGroupDisabled } = useResizableContext()\n const [isActive, setIsActive] = useState<boolean>(false)\n\n const trulyDisabled = disabled || isDisabled || isGroupDisabled\n\n const getTriggerProps: TriggerPropGetter = useCallback(\n (props = {}) => ({\n ...props,\n id,\n tagName: as,\n disabled: trulyDisabled,\n onDragging: handlerAll(onDragging, (isActive) => setIsActive(isActive)),\n ...rest,\n \"data-active\": dataAttr(isActive),\n style: {\n ...props.style,\n ...rest.style,\n ...(trulyDisabled ? { cursor: \"default\" } : {}),\n },\n }),\n [id, as, trulyDisabled, onDragging, rest, isActive],\n )\n\n const getIconProps: UIPropGetter = useCallback(\n (props = {}, ref = null) => ({\n ...props,\n ref,\n \"data-active\": dataAttr(isActive),\n }),\n [isActive],\n )\n\n useEffect(() => {\n if (!id) return\n\n const el = getResizeHandleElement(id)\n\n // @ts-expect-error\n if (ref) ref.current = el\n }, [ref, id])\n\n return {\n getTriggerProps,\n getIconProps,\n }\n}\n\nexport type UseResizableTriggerReturn = ReturnType<typeof useResizableTrigger>\n","import type { CSSUIObject } from \"@yamada-ui/core\"\nimport { ui, forwardRef } from \"@yamada-ui/core\"\nimport { cx } from \"@yamada-ui/utils\"\nimport type { ForwardedRef } from \"react\"\nimport { Panel } from \"react-resizable-panels\"\nimport type { UseResizableItemProps } from \"./use-resizable\"\nimport { useResizableContext, useResizableItem } from \"./use-resizable\"\n\nconst panelProps = new Set([\"order\"])\n\nconst UIPanel = ui(Panel, { disableStyleProp: (prop) => panelProps.has(prop) })\n\ntype ResizableItemOptions = {\n /**\n * Ref for resizable item inner element.\n */\n innerRef?: ForwardedRef<HTMLDivElement>\n}\n\nexport type ResizableItemProps = Omit<UseResizableItemProps, \"ref\"> &\n ResizableItemOptions\n\nexport const ResizableItem = forwardRef<ResizableItemProps, \"div\">(\n (\n {\n className,\n children,\n innerRef,\n w,\n width,\n minW,\n minWidth,\n maxW,\n maxWidth,\n h,\n height,\n minH,\n minHeight,\n maxH,\n maxHeight,\n boxSize,\n ...rest\n },\n ref,\n ) => {\n const { styles } = useResizableContext()\n const { getPanelProps, getItemProps } = useResizableItem({\n ref,\n ...rest,\n })\n\n const css: CSSUIObject = { boxSize: \"100%\", ...styles.item }\n\n return (\n <UIPanel\n {...getPanelProps({\n w,\n width,\n minW,\n minWidth,\n maxW,\n maxWidth,\n h,\n height,\n minH,\n minHeight,\n maxH,\n maxHeight,\n boxSize,\n })}\n >\n <ui.div\n className={cx(\"ui-resizable__item\", className)}\n __css={css}\n {...getItemProps({}, innerRef)}\n >\n {children}\n </ui.div>\n </UIPanel>\n )\n },\n)\n","import type { CSSUIObject, HTMLUIProps } from \"@yamada-ui/core\"\nimport { ui, forwardRef } from \"@yamada-ui/core\"\nimport type { IconProps } from \"@yamada-ui/icon\"\nimport { Icon } from \"@yamada-ui/icon\"\nimport { cx } from \"@yamada-ui/utils\"\nimport type { FC, ReactElement } from \"react\"\nimport { PanelResizeHandle } from \"react-resizable-panels\"\nimport type { UseResizableTriggerProps } from \"./use-resizable\"\nimport { useResizableContext, useResizableTrigger } from \"./use-resizable\"\n\ntype ResizableTriggerOptions = {\n /**\n * The resizable trigger icon to use.\n */\n icon?: ReactElement\n /**\n * Props for resizable trigger icon component.\n */\n iconProps?: HTMLUIProps<\"div\">\n}\n\nexport type ResizableTriggerProps = Omit<HTMLUIProps<\"div\">, \"as\"> &\n Omit<UseResizableTriggerProps, \"ref\"> &\n ResizableTriggerOptions\n\nexport const ResizableTrigger = forwardRef<ResizableTriggerProps, \"div\", false>(\n ({ className, icon, children, iconProps, ...rest }, ref) => {\n const { styles } = useResizableContext()\n const { getTriggerProps, getIconProps } = useResizableTrigger({\n ref,\n ...rest,\n })\n\n const css: CSSUIObject = { position: \"relative\", ...styles.trigger }\n\n return (\n <ui.div\n as={PanelResizeHandle}\n className={cx(\"ui-resizable__trigger\", className)}\n __css={css}\n {...getTriggerProps()}\n >\n {icon ? (\n <ui.div\n className=\"ui-resizable__trigger__icon\"\n __css={{\n position: \"absolute\",\n top: \"50%\",\n left: \"50%\",\n transform: \"auto\",\n translateY: \"-50%\",\n translateX: \"-50%\",\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n ...styles.icon,\n }}\n {...getIconProps(iconProps)}\n >\n {icon}\n </ui.div>\n ) : null}\n\n {children}\n </ui.div>\n )\n },\n)\n\nexport type ResizableTriggerIconProps = IconProps\n\nexport const ResizableTriggerIcon: FC<ResizableTriggerIconProps> = (rest) => {\n return (\n <Icon viewBox=\"0 0 23 39\" w=\"2\" h=\"4\" {...rest}>\n <path\n d=\"M 5 0 C 7.761 0 10 2.239 10 5 C 10 7.761 7.761 10 5 10 C 2.239 10 0 7.761 0 5 C 0 2.239 2.239 0 5 0 Z\"\n fill=\"currentColor\"\n />\n\n <path\n d=\"M 19 0 C 21.761 0 24 2.239 24 5 C 24 7.761 21.761 10 19 10 C 16.239 10 14 7.761 14 5 C 14 2.239 16.239 0 19 0 Z\"\n fill=\"currentColor\"\n />\n\n <path\n d=\"M 19 14 C 21.761 14 24 16.239 24 19 C 24 21.761 21.761 24 19 24 C 16.239 24 14 21.761 14 19 C 14 16.239 16.239 14 19 14 Z\"\n fill=\"currentColor\"\n />\n\n <path\n d=\"M 5 14 C 7.761 14 10 16.239 10 19 C 10 21.761 7.761 24 5 24 C 2.239 24 0 21.761 0 19 C 0 16.239 2.239 14 5 14 Z\"\n fill=\"currentColor\"\n />\n\n <path\n d=\"M 5 28 C 7.761 28 10 30.239 10 33 C 10 35.761 7.761 38 5 38 C 2.239 38 0 35.761 0 33 C 0 30.239 2.239 28 5 28 Z\"\n fill=\"currentColor\"\n />\n\n <path\n d=\"M 19 28 C 21.761 28 24 30.239 24 33 C 24 35.761 21.761 38 19 38 C 16.239 38 14 35.761 14 33 C 14 30.239 16.239 28 19 28 Z\"\n fill=\"currentColor\"\n />\n </Icon>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,kBAKO;AACP,IAAAA,gBA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P;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,GAAE;AAAA,QACF,MAAK;AAAA;AAAA,IACP;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,GAAE;AAAA,QACF,MAAK;AAAA;AAAA,IACP;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,GAAE;AAAA,QACF,MAAK;AAAA;AAAA,IACP;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,GAAE;AAAA,QACF,MAAK;AAAA;AAAA,IACP;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,GAAE;AAAA,QACF,MAAK;AAAA;AAAA,IACP;AAAA,KACF;AAEJ;","names":["import_utils","import_react_resizable_panels","ref","rest","isActive","import_core","import_utils","import_react_resizable_panels","import_jsx_runtime","import_core","import_utils","import_react_resizable_panels","import_jsx_runtime"]}
|
package/dist/index.mjs
CHANGED
@@ -1,17 +1,19 @@
|
|
1
|
+
"use client"
|
1
2
|
import {
|
2
3
|
ResizableItem
|
3
|
-
} from "./chunk-
|
4
|
+
} from "./chunk-BXVDBZXS.mjs";
|
4
5
|
import {
|
5
6
|
ResizableTrigger,
|
6
7
|
ResizableTriggerIcon
|
7
|
-
} from "./chunk-
|
8
|
+
} from "./chunk-DJKFV3FP.mjs";
|
8
9
|
import {
|
9
10
|
Resizable
|
10
|
-
} from "./chunk-
|
11
|
-
import "./chunk-
|
11
|
+
} from "./chunk-3BJMVXCF.mjs";
|
12
|
+
import "./chunk-R6EC3EDW.mjs";
|
12
13
|
export {
|
13
14
|
Resizable,
|
14
15
|
ResizableItem,
|
15
16
|
ResizableTrigger,
|
16
17
|
ResizableTriggerIcon
|
17
18
|
};
|
19
|
+
//# sourceMappingURL=index.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/resizable-item.js
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
"use client"
|
1
2
|
"use strict";
|
2
3
|
var __defProp = Object.defineProperty;
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
@@ -169,3 +170,4 @@ var ResizableItem = (0, import_core.forwardRef)(
|
|
169
170
|
0 && (module.exports = {
|
170
171
|
ResizableItem
|
171
172
|
});
|
173
|
+
//# sourceMappingURL=resizable-item.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/resizable-item.tsx","../src/use-resizable.ts"],"sourcesContent":["import type { CSSUIObject } from \"@yamada-ui/core\"\nimport { ui, forwardRef } from \"@yamada-ui/core\"\nimport { cx } from \"@yamada-ui/utils\"\nimport type { ForwardedRef } from \"react\"\nimport { Panel } from \"react-resizable-panels\"\nimport type { UseResizableItemProps } from \"./use-resizable\"\nimport { useResizableContext, useResizableItem } from \"./use-resizable\"\n\nconst panelProps = new Set([\"order\"])\n\nconst UIPanel = ui(Panel, { disableStyleProp: (prop) => panelProps.has(prop) })\n\ntype ResizableItemOptions = {\n /**\n * Ref for resizable item inner element.\n */\n innerRef?: ForwardedRef<HTMLDivElement>\n}\n\nexport type ResizableItemProps = Omit<UseResizableItemProps, \"ref\"> &\n ResizableItemOptions\n\nexport const ResizableItem = forwardRef<ResizableItemProps, \"div\">(\n (\n {\n className,\n children,\n innerRef,\n w,\n width,\n minW,\n minWidth,\n maxW,\n maxWidth,\n h,\n height,\n minH,\n minHeight,\n maxH,\n maxHeight,\n boxSize,\n ...rest\n },\n ref,\n ) => {\n const { styles } = useResizableContext()\n const { getPanelProps, getItemProps } = useResizableItem({\n ref,\n ...rest,\n })\n\n const css: CSSUIObject = { boxSize: \"100%\", ...styles.item }\n\n return (\n <UIPanel\n {...getPanelProps({\n w,\n width,\n minW,\n minWidth,\n maxW,\n maxWidth,\n h,\n height,\n minH,\n minHeight,\n maxH,\n maxHeight,\n boxSize,\n })}\n >\n <ui.div\n className={cx(\"ui-resizable__item\", className)}\n __css={css}\n {...getItemProps({}, innerRef)}\n >\n {children}\n </ui.div>\n </UIPanel>\n )\n },\n)\n","import type { CSSUIObject, HTMLUIProps, UIPropGetter } from \"@yamada-ui/core\"\nimport type { PropGetter } from \"@yamada-ui/utils\"\nimport { createContext, dataAttr, handlerAll } from \"@yamada-ui/utils\"\nimport type { ForwardedRef, RefObject } from \"react\"\nimport { useCallback, useEffect, useId, useState } from \"react\"\nimport {\n getPanelElement,\n getPanelGroupElement,\n getResizeHandleElement,\n} from \"react-resizable-panels\"\nimport type {\n PanelResizeHandleProps,\n PanelGroupProps,\n PanelProps,\n PanelGroupOnLayout,\n PanelGroupStorage,\n ImperativePanelHandle,\n} from \"react-resizable-panels\"\n\ntype GroupPropGetter = (props?: Partial<PanelGroupProps>) => PanelGroupProps\ntype ItemPropGetter = (props?: HTMLUIProps<\"div\"> & PanelProps) => PanelProps\ntype TriggerPropGetter = (\n props?: PanelResizeHandleProps,\n) => PanelResizeHandleProps\n\ntype As = { as?: keyof HTMLElementTagNameMap }\n\ntype ResizableGroupProps = Omit<\n PanelGroupProps,\n \"id\" | \"tagName\" | \"children\"\n> &\n As\ntype ResizableItemProps = Omit<PanelProps, \"id\" | \"tagName\" | \"children\"> & As\ntype ResizableTriggerProps = Omit<\n PanelResizeHandleProps,\n \"id\" | \"tagName\" | \"children\"\n> &\n As\n\nexport type ResizableStorage = PanelGroupStorage\nexport type ResizableItemControl = ImperativePanelHandle\n\ntype ResizableContext = {\n isDisabled: boolean\n styles: Record<string, CSSUIObject>\n}\n\nexport const [ResizableProvider, useResizableContext] =\n createContext<ResizableContext>({\n name: \"ResizableContext\",\n errorMessage: `useResizableContext returned is 'undefined'. Seems you forgot to wrap the components in \"<Resizable />\"`,\n })\n\nexport type UseResizableProps = {\n /**\n * id assigned to resizable element.\n */\n id?: string\n /**\n * Ref for resizable element.\n */\n ref?: ForwardedRef<HTMLElement>\n /**\n * The direction of the resizable.\n *\n * @default \"horizontal\"\n */\n direction?: \"horizontal\" | \"vertical\"\n /**\n * If `true`, the resizable trigger will be disabled.\n */\n isDisabled?: boolean\n /**\n * Unit to resize by keyboard operation.\n *\n * @default 10\n */\n keyboardStep?: number\n /**\n * Key of value saved in storage.\n * By default, it is saved to `local storage`.\n */\n storageKey?: string\n /**\n * A callback that gets and sets a value in custom storage.\n */\n storage?: PanelGroupStorage\n /**\n * The callback invoked when resizable items are resized.\n */\n onLayout?: PanelGroupOnLayout\n /**\n * Props for resizable component.\n */\n groupProps?: ResizableGroupProps\n}\n\nexport const useResizable = ({\n id,\n direction = \"horizontal\",\n storageKey,\n keyboardStep,\n isDisabled = false,\n onLayout,\n storage,\n ref,\n groupProps,\n ...rest\n}: UseResizableProps) => {\n id ??= useId()\n\n const getContainerProps: PropGetter = useCallback(\n (props = {}, ref = null) => ({ ...props, ref, ...rest }),\n [rest],\n )\n\n const getGroupProps: GroupPropGetter = useCallback(\n (props = {}) => {\n const { as, ...rest } = groupProps ?? {}\n\n return {\n ...props,\n id,\n direction,\n tagName: as,\n autoSaveId: storageKey,\n keyboardResizeBy: keyboardStep,\n onLayout,\n storage,\n ...rest,\n }\n },\n [id, direction, groupProps, storageKey, keyboardStep, onLayout, storage],\n )\n\n useEffect(() => {\n if (!id) return\n\n const el = getPanelGroupElement(id)\n\n // @ts-expect-error\n if (ref) ref.current = el\n }, [ref, id])\n\n return {\n isDisabled,\n getContainerProps,\n getGroupProps,\n }\n}\n\nexport type UseResizableReturn = ReturnType<typeof useResizable>\n\ntype UseResizableItemOptions = {\n /**\n * id assigned to resizable item element.\n */\n id?: string\n /**\n * Ref for resizable item element.\n */\n ref?: ForwardedRef<HTMLElement>\n /**\n * If `true`, the resizable item can be collapsed.\n *\n * @default false\n */\n collapsible?: boolean\n /**\n * The collapsed size of the resizable item.\n */\n collapsedSize?: number\n /**\n * The initial size of the resizable item.\n */\n defaultSize?: number\n /**\n * The minimum allowed value of the resizable item.\n */\n minSize?: number\n /**\n * The maximum allowed value of the resizable item.\n */\n maxSize?: number\n /**\n * The callback invoked when resizable item are collapsed.\n */\n onCollapse?: () => void\n /**\n * The callback invoked when resizable item are expanded.\n */\n onExpand?: () => void\n /**\n * The callback invoked when resizable item are resized.\n */\n onResize?: (size: number, prevSize: number | undefined) => void\n /**\n * Order for the resizable item.\n */\n order?: number\n /**\n * Ref of the resizable item callback.\n */\n controlRef?: RefObject<ResizableItemControl>\n /**\n * Props for resizable item container element.\n */\n containerProps?: Omit<HTMLUIProps<\"div\">, \"as\"> & ResizableItemProps\n}\n\nexport type UseResizableItemProps = Omit<\n HTMLUIProps<\"div\">,\n keyof UseResizableItemOptions\n> &\n UseResizableItemOptions\n\nexport const useResizableItem = ({\n id,\n ref,\n collapsedSize,\n collapsible,\n defaultSize,\n maxSize,\n minSize,\n onCollapse,\n onExpand,\n onResize,\n order,\n controlRef,\n containerProps,\n ...innerProps\n}: UseResizableItemProps) => {\n id ??= useId()\n\n const getPanelProps: ItemPropGetter = useCallback(\n (props = {}) => {\n const { as, ...rest } = containerProps ?? {}\n\n return {\n ...props,\n ref: controlRef,\n id,\n tagName: as,\n collapsible,\n defaultSize,\n maxSize,\n minSize,\n collapsedSize,\n onCollapse,\n onExpand,\n onResize,\n order,\n ...rest,\n }\n },\n [\n id,\n controlRef,\n containerProps,\n collapsedSize,\n collapsible,\n defaultSize,\n maxSize,\n minSize,\n onCollapse,\n onExpand,\n onResize,\n order,\n ],\n )\n\n const getItemProps: UIPropGetter = useCallback(\n (props = {}, ref = null) => ({ ...props, ref, ...innerProps }),\n [innerProps],\n )\n\n useEffect(() => {\n if (!id) return\n\n const el = getPanelElement(id)\n\n // @ts-expect-error\n if (ref) ref.current = el\n }, [ref, id])\n\n return {\n getPanelProps,\n getItemProps,\n }\n}\n\nexport type UseResizableItemReturn = ReturnType<typeof useResizableItem>\n\ntype UseResizableTriggerOptions = {\n /**\n * id assigned to resizable trigger element.\n */\n id?: string\n /**\n * Ref for resizable trigger element.\n */\n ref?: ForwardedRef<HTMLElement>\n /**\n * If `true`, the resizable trigger will be disabled.\n *\n * @default false\n */\n isDisabled?: boolean\n /**\n * The callback invoked when resizable trigger are dragged.\n */\n onDragging?: (isDragging: boolean) => void\n}\n\nexport type UseResizableTriggerProps = HTMLUIProps<\"div\"> &\n ResizableTriggerProps &\n UseResizableTriggerOptions\n\nexport const useResizableTrigger = ({\n id,\n ref,\n as,\n disabled,\n isDisabled,\n onDragging,\n ...rest\n}: UseResizableTriggerProps) => {\n id ??= useId()\n\n const { isDisabled: isGroupDisabled } = useResizableContext()\n const [isActive, setIsActive] = useState<boolean>(false)\n\n const trulyDisabled = disabled || isDisabled || isGroupDisabled\n\n const getTriggerProps: TriggerPropGetter = useCallback(\n (props = {}) => ({\n ...props,\n id,\n tagName: as,\n disabled: trulyDisabled,\n onDragging: handlerAll(onDragging, (isActive) => setIsActive(isActive)),\n ...rest,\n \"data-active\": dataAttr(isActive),\n style: {\n ...props.style,\n ...rest.style,\n ...(trulyDisabled ? { cursor: \"default\" } : {}),\n },\n }),\n [id, as, trulyDisabled, onDragging, rest, isActive],\n )\n\n const getIconProps: UIPropGetter = useCallback(\n (props = {}, ref = null) => ({\n ...props,\n ref,\n \"data-active\": dataAttr(isActive),\n }),\n [isActive],\n )\n\n useEffect(() => {\n if (!id) return\n\n const el = getResizeHandleElement(id)\n\n // @ts-expect-error\n if (ref) ref.current = el\n }, [ref, id])\n\n return {\n getTriggerProps,\n getIconProps,\n }\n}\n\nexport type UseResizableTriggerReturn = ReturnType<typeof useResizableTrigger>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAA+B;AAC/B,IAAAA,gBAAmB;AAEnB,IAAAC,iCAAsB;;;ACFtB,mBAAoD;AAEpD,mBAAwD;AACxD,oCAIO;AAsCA,IAAM,CAAC,mBAAmB,mBAAmB,QAClD,4BAAgC;AAAA,EAC9B,MAAM;AAAA,EACN,cAAc;AAChB,CAAC;AAqKI,IAAM,mBAAmB,CAAC;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA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;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,GACA,QACG;AACH,UAAM,EAAE,OAAO,IAAI,oBAAoB;AACvC,UAAM,EAAE,eAAe,aAAa,IAAI,iBAAiB;AAAA,MACvD;AAAA,MACA,GAAG;AAAA,IACL,CAAC;AAED,UAAM,MAAmB,EAAE,SAAS,QAAQ,GAAG,OAAO,KAAK;AAE3D,WACE;AAAA,MAAC;AAAA;AAAA,QACE,GAAG,cAAc;AAAA,UAChB;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACF,CAAC;AAAA,QAED;AAAA,UAAC,eAAG;AAAA,UAAH;AAAA,YACC,eAAW,kBAAG,sBAAsB,SAAS;AAAA,YAC7C,OAAO;AAAA,YACN,GAAG,aAAa,CAAC,GAAG,QAAQ;AAAA,YAE5B;AAAA;AAAA,QACH;AAAA;AAAA,IACF;AAAA,EAEJ;AACF;","names":["import_utils","import_react_resizable_panels","ref"]}
|
package/dist/resizable-item.mjs
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
@@ -1,3 +1,4 @@
|
|
1
|
+
"use client"
|
1
2
|
"use strict";
|
2
3
|
var __defProp = Object.defineProperty;
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
@@ -183,3 +184,4 @@ var ResizableTriggerIcon = (rest) => {
|
|
183
184
|
ResizableTrigger,
|
184
185
|
ResizableTriggerIcon
|
185
186
|
});
|
187
|
+
//# sourceMappingURL=resizable-trigger.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/resizable-trigger.tsx","../src/use-resizable.ts"],"sourcesContent":["import type { CSSUIObject, HTMLUIProps } from \"@yamada-ui/core\"\nimport { ui, forwardRef } from \"@yamada-ui/core\"\nimport type { IconProps } from \"@yamada-ui/icon\"\nimport { Icon } from \"@yamada-ui/icon\"\nimport { cx } from \"@yamada-ui/utils\"\nimport type { FC, ReactElement } from \"react\"\nimport { PanelResizeHandle } from \"react-resizable-panels\"\nimport type { UseResizableTriggerProps } from \"./use-resizable\"\nimport { useResizableContext, useResizableTrigger } from \"./use-resizable\"\n\ntype ResizableTriggerOptions = {\n /**\n * The resizable trigger icon to use.\n */\n icon?: ReactElement\n /**\n * Props for resizable trigger icon component.\n */\n iconProps?: HTMLUIProps<\"div\">\n}\n\nexport type ResizableTriggerProps = Omit<HTMLUIProps<\"div\">, \"as\"> &\n Omit<UseResizableTriggerProps, \"ref\"> &\n ResizableTriggerOptions\n\nexport const ResizableTrigger = forwardRef<ResizableTriggerProps, \"div\", false>(\n ({ className, icon, children, iconProps, ...rest }, ref) => {\n const { styles } = useResizableContext()\n const { getTriggerProps, getIconProps } = useResizableTrigger({\n ref,\n ...rest,\n })\n\n const css: CSSUIObject = { position: \"relative\", ...styles.trigger }\n\n return (\n <ui.div\n as={PanelResizeHandle}\n className={cx(\"ui-resizable__trigger\", className)}\n __css={css}\n {...getTriggerProps()}\n >\n {icon ? (\n <ui.div\n className=\"ui-resizable__trigger__icon\"\n __css={{\n position: \"absolute\",\n top: \"50%\",\n left: \"50%\",\n transform: \"auto\",\n translateY: \"-50%\",\n translateX: \"-50%\",\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n ...styles.icon,\n }}\n {...getIconProps(iconProps)}\n >\n {icon}\n </ui.div>\n ) : null}\n\n {children}\n </ui.div>\n )\n },\n)\n\nexport type ResizableTriggerIconProps = IconProps\n\nexport const ResizableTriggerIcon: FC<ResizableTriggerIconProps> = (rest) => {\n return (\n <Icon viewBox=\"0 0 23 39\" w=\"2\" h=\"4\" {...rest}>\n <path\n d=\"M 5 0 C 7.761 0 10 2.239 10 5 C 10 7.761 7.761 10 5 10 C 2.239 10 0 7.761 0 5 C 0 2.239 2.239 0 5 0 Z\"\n fill=\"currentColor\"\n />\n\n <path\n d=\"M 19 0 C 21.761 0 24 2.239 24 5 C 24 7.761 21.761 10 19 10 C 16.239 10 14 7.761 14 5 C 14 2.239 16.239 0 19 0 Z\"\n fill=\"currentColor\"\n />\n\n <path\n d=\"M 19 14 C 21.761 14 24 16.239 24 19 C 24 21.761 21.761 24 19 24 C 16.239 24 14 21.761 14 19 C 14 16.239 16.239 14 19 14 Z\"\n fill=\"currentColor\"\n />\n\n <path\n d=\"M 5 14 C 7.761 14 10 16.239 10 19 C 10 21.761 7.761 24 5 24 C 2.239 24 0 21.761 0 19 C 0 16.239 2.239 14 5 14 Z\"\n fill=\"currentColor\"\n />\n\n <path\n d=\"M 5 28 C 7.761 28 10 30.239 10 33 C 10 35.761 7.761 38 5 38 C 2.239 38 0 35.761 0 33 C 0 30.239 2.239 28 5 28 Z\"\n fill=\"currentColor\"\n />\n\n <path\n d=\"M 19 28 C 21.761 28 24 30.239 24 33 C 24 35.761 21.761 38 19 38 C 16.239 38 14 35.761 14 33 C 14 30.239 16.239 28 19 28 Z\"\n fill=\"currentColor\"\n />\n </Icon>\n )\n}\n","import type { CSSUIObject, HTMLUIProps, UIPropGetter } from \"@yamada-ui/core\"\nimport type { PropGetter } from \"@yamada-ui/utils\"\nimport { createContext, dataAttr, handlerAll } from \"@yamada-ui/utils\"\nimport type { ForwardedRef, RefObject } from \"react\"\nimport { useCallback, useEffect, useId, useState } from \"react\"\nimport {\n getPanelElement,\n getPanelGroupElement,\n getResizeHandleElement,\n} from \"react-resizable-panels\"\nimport type {\n PanelResizeHandleProps,\n PanelGroupProps,\n PanelProps,\n PanelGroupOnLayout,\n PanelGroupStorage,\n ImperativePanelHandle,\n} from \"react-resizable-panels\"\n\ntype GroupPropGetter = (props?: Partial<PanelGroupProps>) => PanelGroupProps\ntype ItemPropGetter = (props?: HTMLUIProps<\"div\"> & PanelProps) => PanelProps\ntype TriggerPropGetter = (\n props?: PanelResizeHandleProps,\n) => PanelResizeHandleProps\n\ntype As = { as?: keyof HTMLElementTagNameMap }\n\ntype ResizableGroupProps = Omit<\n PanelGroupProps,\n \"id\" | \"tagName\" | \"children\"\n> &\n As\ntype ResizableItemProps = Omit<PanelProps, \"id\" | \"tagName\" | \"children\"> & As\ntype ResizableTriggerProps = Omit<\n PanelResizeHandleProps,\n \"id\" | \"tagName\" | \"children\"\n> &\n As\n\nexport type ResizableStorage = PanelGroupStorage\nexport type ResizableItemControl = ImperativePanelHandle\n\ntype ResizableContext = {\n isDisabled: boolean\n styles: Record<string, CSSUIObject>\n}\n\nexport const [ResizableProvider, useResizableContext] =\n createContext<ResizableContext>({\n name: \"ResizableContext\",\n errorMessage: `useResizableContext returned is 'undefined'. Seems you forgot to wrap the components in \"<Resizable />\"`,\n })\n\nexport type UseResizableProps = {\n /**\n * id assigned to resizable element.\n */\n id?: string\n /**\n * Ref for resizable element.\n */\n ref?: ForwardedRef<HTMLElement>\n /**\n * The direction of the resizable.\n *\n * @default \"horizontal\"\n */\n direction?: \"horizontal\" | \"vertical\"\n /**\n * If `true`, the resizable trigger will be disabled.\n */\n isDisabled?: boolean\n /**\n * Unit to resize by keyboard operation.\n *\n * @default 10\n */\n keyboardStep?: number\n /**\n * Key of value saved in storage.\n * By default, it is saved to `local storage`.\n */\n storageKey?: string\n /**\n * A callback that gets and sets a value in custom storage.\n */\n storage?: PanelGroupStorage\n /**\n * The callback invoked when resizable items are resized.\n */\n onLayout?: PanelGroupOnLayout\n /**\n * Props for resizable component.\n */\n groupProps?: ResizableGroupProps\n}\n\nexport const useResizable = ({\n id,\n direction = \"horizontal\",\n storageKey,\n keyboardStep,\n isDisabled = false,\n onLayout,\n storage,\n ref,\n groupProps,\n ...rest\n}: UseResizableProps) => {\n id ??= useId()\n\n const getContainerProps: PropGetter = useCallback(\n (props = {}, ref = null) => ({ ...props, ref, ...rest }),\n [rest],\n )\n\n const getGroupProps: GroupPropGetter = useCallback(\n (props = {}) => {\n const { as, ...rest } = groupProps ?? {}\n\n return {\n ...props,\n id,\n direction,\n tagName: as,\n autoSaveId: storageKey,\n keyboardResizeBy: keyboardStep,\n onLayout,\n storage,\n ...rest,\n }\n },\n [id, direction, groupProps, storageKey, keyboardStep, onLayout, storage],\n )\n\n useEffect(() => {\n if (!id) return\n\n const el = getPanelGroupElement(id)\n\n // @ts-expect-error\n if (ref) ref.current = el\n }, [ref, id])\n\n return {\n isDisabled,\n getContainerProps,\n getGroupProps,\n }\n}\n\nexport type UseResizableReturn = ReturnType<typeof useResizable>\n\ntype UseResizableItemOptions = {\n /**\n * id assigned to resizable item element.\n */\n id?: string\n /**\n * Ref for resizable item element.\n */\n ref?: ForwardedRef<HTMLElement>\n /**\n * If `true`, the resizable item can be collapsed.\n *\n * @default false\n */\n collapsible?: boolean\n /**\n * The collapsed size of the resizable item.\n */\n collapsedSize?: number\n /**\n * The initial size of the resizable item.\n */\n defaultSize?: number\n /**\n * The minimum allowed value of the resizable item.\n */\n minSize?: number\n /**\n * The maximum allowed value of the resizable item.\n */\n maxSize?: number\n /**\n * The callback invoked when resizable item are collapsed.\n */\n onCollapse?: () => void\n /**\n * The callback invoked when resizable item are expanded.\n */\n onExpand?: () => void\n /**\n * The callback invoked when resizable item are resized.\n */\n onResize?: (size: number, prevSize: number | undefined) => void\n /**\n * Order for the resizable item.\n */\n order?: number\n /**\n * Ref of the resizable item callback.\n */\n controlRef?: RefObject<ResizableItemControl>\n /**\n * Props for resizable item container element.\n */\n containerProps?: Omit<HTMLUIProps<\"div\">, \"as\"> & ResizableItemProps\n}\n\nexport type UseResizableItemProps = Omit<\n HTMLUIProps<\"div\">,\n keyof UseResizableItemOptions\n> &\n UseResizableItemOptions\n\nexport const useResizableItem = ({\n id,\n ref,\n collapsedSize,\n collapsible,\n defaultSize,\n maxSize,\n minSize,\n onCollapse,\n onExpand,\n onResize,\n order,\n controlRef,\n containerProps,\n ...innerProps\n}: UseResizableItemProps) => {\n id ??= useId()\n\n const getPanelProps: ItemPropGetter = useCallback(\n (props = {}) => {\n const { as, ...rest } = containerProps ?? {}\n\n return {\n ...props,\n ref: controlRef,\n id,\n tagName: as,\n collapsible,\n defaultSize,\n maxSize,\n minSize,\n collapsedSize,\n onCollapse,\n onExpand,\n onResize,\n order,\n ...rest,\n }\n },\n [\n id,\n controlRef,\n containerProps,\n collapsedSize,\n collapsible,\n defaultSize,\n maxSize,\n minSize,\n onCollapse,\n onExpand,\n onResize,\n order,\n ],\n )\n\n const getItemProps: UIPropGetter = useCallback(\n (props = {}, ref = null) => ({ ...props, ref, ...innerProps }),\n [innerProps],\n )\n\n useEffect(() => {\n if (!id) return\n\n const el = getPanelElement(id)\n\n // @ts-expect-error\n if (ref) ref.current = el\n }, [ref, id])\n\n return {\n getPanelProps,\n getItemProps,\n }\n}\n\nexport type UseResizableItemReturn = ReturnType<typeof useResizableItem>\n\ntype UseResizableTriggerOptions = {\n /**\n * id assigned to resizable trigger element.\n */\n id?: string\n /**\n * Ref for resizable trigger element.\n */\n ref?: ForwardedRef<HTMLElement>\n /**\n * If `true`, the resizable trigger will be disabled.\n *\n * @default false\n */\n isDisabled?: boolean\n /**\n * The callback invoked when resizable trigger are dragged.\n */\n onDragging?: (isDragging: boolean) => void\n}\n\nexport type UseResizableTriggerProps = HTMLUIProps<\"div\"> &\n ResizableTriggerProps &\n UseResizableTriggerOptions\n\nexport const useResizableTrigger = ({\n id,\n ref,\n as,\n disabled,\n isDisabled,\n onDragging,\n ...rest\n}: UseResizableTriggerProps) => {\n id ??= useId()\n\n const { isDisabled: isGroupDisabled } = useResizableContext()\n const [isActive, setIsActive] = useState<boolean>(false)\n\n const trulyDisabled = disabled || isDisabled || isGroupDisabled\n\n const getTriggerProps: TriggerPropGetter = useCallback(\n (props = {}) => ({\n ...props,\n id,\n tagName: as,\n disabled: trulyDisabled,\n onDragging: handlerAll(onDragging, (isActive) => setIsActive(isActive)),\n ...rest,\n \"data-active\": dataAttr(isActive),\n style: {\n ...props.style,\n ...rest.style,\n ...(trulyDisabled ? { cursor: \"default\" } : {}),\n },\n }),\n [id, as, trulyDisabled, onDragging, rest, isActive],\n )\n\n const getIconProps: UIPropGetter = useCallback(\n (props = {}, ref = null) => ({\n ...props,\n ref,\n \"data-active\": dataAttr(isActive),\n }),\n [isActive],\n )\n\n useEffect(() => {\n if (!id) return\n\n const el = getResizeHandleElement(id)\n\n // @ts-expect-error\n if (ref) ref.current = el\n }, [ref, id])\n\n return {\n getTriggerProps,\n getIconProps,\n }\n}\n\nexport type UseResizableTriggerReturn = ReturnType<typeof useResizableTrigger>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAA+B;AAE/B,kBAAqB;AACrB,IAAAA,gBAAmB;AAEnB,IAAAC,iCAAkC;;;ACJlC,mBAAoD;AAEpD,mBAAwD;AACxD,oCAIO;AAsCA,IAAM,CAAC,mBAAmB,mBAAmB,QAClD,4BAAgC;AAAA,EAC9B,MAAM;AAAA,EACN,cAAc;AAChB,CAAC;AA2QI,IAAM,sBAAsB,CAAC;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAgC;AAC9B,6BAAO,oBAAM;AAEb,QAAM,EAAE,YAAY,gBAAgB,IAAI,oBAAoB;AAC5D,QAAM,CAAC,UAAU,WAAW,QAAI,uBAAkB,KAAK;AAEvD,QAAM,gBAAgB,YAAY,cAAc;AAEhD,QAAM,sBAAqC;AAAA,IACzC,CAAC,QAAQ,CAAC,OAAO;AAAA,MACf,GAAG;AAAA,MACH;AAAA,MACA,SAAS;AAAA,MACT,UAAU;AAAA,MACV,gBAAY,yBAAW,YAAY,CAACC,cAAa,YAAYA,SAAQ,CAAC;AAAA,MACtE,GAAG;AAAA,MACH,mBAAe,uBAAS,QAAQ;AAAA,MAChC,OAAO;AAAA,QACL,GAAG,M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;AAAA,gBAChB,YAAY;AAAA,gBACZ,GAAG,OAAO;AAAA,cACZ;AAAA,cACC,GAAG,aAAa,SAAS;AAAA,cAEzB;AAAA;AAAA,UACH,IACE;AAAA,UAEH;AAAA;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AAIO,IAAM,uBAAsD,CAAC,SAAS;AAC3E,SACE,6CAAC,oBAAK,SAAQ,aAAY,GAAE,KAAI,GAAE,KAAK,GAAG,MACxC;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,GAAE;AAAA,QACF,MAAK;AAAA;AAAA,IACP;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,GAAE;AAAA,QACF,MAAK;AAAA;AAAA,IACP;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,GAAE;AAAA,QACF,MAAK;AAAA;AAAA,IACP;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,GAAE;AAAA,QACF,MAAK;AAAA;AAAA,IACP;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,GAAE;AAAA,QACF,MAAK;AAAA;AAAA,IACP;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,GAAE;AAAA,QACF,MAAK;AAAA;AAAA,IACP;AAAA,KACF;AAEJ;","names":["import_utils","import_react_resizable_panels","isActive","ref"]}
|
@@ -1,9 +1,11 @@
|
|
1
|
+
"use client"
|
1
2
|
import {
|
2
3
|
ResizableTrigger,
|
3
4
|
ResizableTriggerIcon
|
4
|
-
} from "./chunk-
|
5
|
-
import "./chunk-
|
5
|
+
} from "./chunk-DJKFV3FP.mjs";
|
6
|
+
import "./chunk-R6EC3EDW.mjs";
|
6
7
|
export {
|
7
8
|
ResizableTrigger,
|
8
9
|
ResizableTriggerIcon
|
9
10
|
};
|
11
|
+
//# sourceMappingURL=resizable-trigger.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/resizable.js
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
"use client"
|
1
2
|
"use strict";
|
2
3
|
var __defProp = Object.defineProperty;
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
@@ -112,3 +113,4 @@ var Resizable = (0, import_core.forwardRef)(
|
|
112
113
|
0 && (module.exports = {
|
113
114
|
Resizable
|
114
115
|
});
|
116
|
+
//# sourceMappingURL=resizable.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/resizable.tsx","../src/use-resizable.ts"],"sourcesContent":["import type { CSSUIObject, HTMLUIProps, ThemeProps } from \"@yamada-ui/core\"\nimport {\n ui,\n forwardRef,\n useMultiComponentStyle,\n omitThemeProps,\n} from \"@yamada-ui/core\"\nimport { cx } from \"@yamada-ui/utils\"\nimport type { ForwardedRef } from \"react\"\nimport { PanelGroup } from \"react-resizable-panels\"\nimport type { UseResizableProps } from \"./use-resizable\"\nimport { ResizableProvider, useResizable } from \"./use-resizable\"\n\ntype ResizableOptions = {\n /**\n * Ref for resizable container element.\n */\n containerRef?: ForwardedRef<HTMLDivElement>\n}\n\n/**\n * `Resizable` is accessible resizable panel groups and layouts with keyboard support.\n *\n * @see Docs https://yamada-ui.com/components/data-display/resizable\n */\nexport type ResizableProps = Omit<HTMLUIProps<\"div\">, \"direction\"> &\n ThemeProps<\"Resizable\"> &\n Omit<UseResizableProps, \"ref\"> &\n ResizableOptions\n\nexport const Resizable = forwardRef<ResizableProps, \"div\">(\n ({ direction = \"horizontal\", ...props }, ref) => {\n const [styles, mergedProps] = useMultiComponentStyle(\"Resizable\", {\n direction,\n ...props,\n })\n const { className, children, containerRef, ...computedProps } =\n omitThemeProps(mergedProps)\n const { getContainerProps, getGroupProps, ...rest } = useResizable({\n ref,\n ...computedProps,\n })\n\n const css: CSSUIObject = { w: \"100%\", h: \"100%\", ...styles.container }\n\n return (\n <ResizableProvider value={{ styles, ...rest }}>\n <ui.div\n className={cx(\"ui-resizable\", className)}\n __css={css}\n {...getContainerProps({}, containerRef)}\n >\n <PanelGroup {...getGroupProps()}>{children}</PanelGroup>\n </ui.div>\n </ResizableProvider>\n )\n },\n)\n","import type { CSSUIObject, HTMLUIProps, UIPropGetter } from \"@yamada-ui/core\"\nimport type { PropGetter } from \"@yamada-ui/utils\"\nimport { createContext, dataAttr, handlerAll } from \"@yamada-ui/utils\"\nimport type { ForwardedRef, RefObject } from \"react\"\nimport { useCallback, useEffect, useId, useState } from \"react\"\nimport {\n getPanelElement,\n getPanelGroupElement,\n getResizeHandleElement,\n} from \"react-resizable-panels\"\nimport type {\n PanelResizeHandleProps,\n PanelGroupProps,\n PanelProps,\n PanelGroupOnLayout,\n PanelGroupStorage,\n ImperativePanelHandle,\n} from \"react-resizable-panels\"\n\ntype GroupPropGetter = (props?: Partial<PanelGroupProps>) => PanelGroupProps\ntype ItemPropGetter = (props?: HTMLUIProps<\"div\"> & PanelProps) => PanelProps\ntype TriggerPropGetter = (\n props?: PanelResizeHandleProps,\n) => PanelResizeHandleProps\n\ntype As = { as?: keyof HTMLElementTagNameMap }\n\ntype ResizableGroupProps = Omit<\n PanelGroupProps,\n \"id\" | \"tagName\" | \"children\"\n> &\n As\ntype ResizableItemProps = Omit<PanelProps, \"id\" | \"tagName\" | \"children\"> & As\ntype ResizableTriggerProps = Omit<\n PanelResizeHandleProps,\n \"id\" | \"tagName\" | \"children\"\n> &\n As\n\nexport type ResizableStorage = PanelGroupStorage\nexport type ResizableItemControl = ImperativePanelHandle\n\ntype ResizableContext = {\n isDisabled: boolean\n styles: Record<string, CSSUIObject>\n}\n\nexport const [ResizableProvider, useResizableContext] =\n createContext<ResizableContext>({\n name: \"ResizableContext\",\n errorMessage: `useResizableContext returned is 'undefined'. Seems you forgot to wrap the components in \"<Resizable />\"`,\n })\n\nexport type UseResizableProps = {\n /**\n * id assigned to resizable element.\n */\n id?: string\n /**\n * Ref for resizable element.\n */\n ref?: ForwardedRef<HTMLElement>\n /**\n * The direction of the resizable.\n *\n * @default \"horizontal\"\n */\n direction?: \"horizontal\" | \"vertical\"\n /**\n * If `true`, the resizable trigger will be disabled.\n */\n isDisabled?: boolean\n /**\n * Unit to resize by keyboard operation.\n *\n * @default 10\n */\n keyboardStep?: number\n /**\n * Key of value saved in storage.\n * By default, it is saved to `local storage`.\n */\n storageKey?: string\n /**\n * A callback that gets and sets a value in custom storage.\n */\n storage?: PanelGroupStorage\n /**\n * The callback invoked when resizable items are resized.\n */\n onLayout?: PanelGroupOnLayout\n /**\n * Props for resizable component.\n */\n groupProps?: ResizableGroupProps\n}\n\nexport const useResizable = ({\n id,\n direction = \"horizontal\",\n storageKey,\n keyboardStep,\n isDisabled = false,\n onLayout,\n storage,\n ref,\n groupProps,\n ...rest\n}: UseResizableProps) => {\n id ??= useId()\n\n const getContainerProps: PropGetter = useCallback(\n (props = {}, ref = null) => ({ ...props, ref, ...rest }),\n [rest],\n )\n\n const getGroupProps: GroupPropGetter = useCallback(\n (props = {}) => {\n const { as, ...rest } = groupProps ?? {}\n\n return {\n ...props,\n id,\n direction,\n tagName: as,\n autoSaveId: storageKey,\n keyboardResizeBy: keyboardStep,\n onLayout,\n storage,\n ...rest,\n }\n },\n [id, direction, groupProps, storageKey, keyboardStep, onLayout, storage],\n )\n\n useEffect(() => {\n if (!id) return\n\n const el = getPanelGroupElement(id)\n\n // @ts-expect-error\n if (ref) ref.current = el\n }, [ref, id])\n\n return {\n isDisabled,\n getContainerProps,\n getGroupProps,\n }\n}\n\nexport type UseResizableReturn = ReturnType<typeof useResizable>\n\ntype UseResizableItemOptions = {\n /**\n * id assigned to resizable item element.\n */\n id?: string\n /**\n * Ref for resizable item element.\n */\n ref?: ForwardedRef<HTMLElement>\n /**\n * If `true`, the resizable item can be collapsed.\n *\n * @default false\n */\n collapsible?: boolean\n /**\n * The collapsed size of the resizable item.\n */\n collapsedSize?: number\n /**\n * The initial size of the resizable item.\n */\n defaultSize?: number\n /**\n * The minimum allowed value of the resizable item.\n */\n minSize?: number\n /**\n * The maximum allowed value of the resizable item.\n */\n maxSize?: number\n /**\n * The callback invoked when resizable item are collapsed.\n */\n onCollapse?: () => void\n /**\n * The callback invoked when resizable item are expanded.\n */\n onExpand?: () => void\n /**\n * The callback invoked when resizable item are resized.\n */\n onResize?: (size: number, prevSize: number | undefined) => void\n /**\n * Order for the resizable item.\n */\n order?: number\n /**\n * Ref of the resizable item callback.\n */\n controlRef?: RefObject<ResizableItemControl>\n /**\n * Props for resizable item container element.\n */\n containerProps?: Omit<HTMLUIProps<\"div\">, \"as\"> & ResizableItemProps\n}\n\nexport type UseResizableItemProps = Omit<\n HTMLUIProps<\"div\">,\n keyof UseResizableItemOptions\n> &\n UseResizableItemOptions\n\nexport const useResizableItem = ({\n id,\n ref,\n collapsedSize,\n collapsible,\n defaultSize,\n maxSize,\n minSize,\n onCollapse,\n onExpand,\n onResize,\n order,\n controlRef,\n containerProps,\n ...innerProps\n}: UseResizableItemProps) => {\n id ??= useId()\n\n const getPanelProps: ItemPropGetter = useCallback(\n (props = {}) => {\n const { as, ...rest } = containerProps ?? {}\n\n return {\n ...props,\n ref: controlRef,\n id,\n tagName: as,\n collapsible,\n defaultSize,\n maxSize,\n minSize,\n collapsedSize,\n onCollapse,\n onExpand,\n onResize,\n order,\n ...rest,\n }\n },\n [\n id,\n controlRef,\n containerProps,\n collapsedSize,\n collapsible,\n defaultSize,\n maxSize,\n minSize,\n onCollapse,\n onExpand,\n onResize,\n order,\n ],\n )\n\n const getItemProps: UIPropGetter = useCallback(\n (props = {}, ref = null) => ({ ...props, ref, ...innerProps }),\n [innerProps],\n )\n\n useEffect(() => {\n if (!id) return\n\n const el = getPanelElement(id)\n\n // @ts-expect-error\n if (ref) ref.current = el\n }, [ref, id])\n\n return {\n getPanelProps,\n getItemProps,\n }\n}\n\nexport type UseResizableItemReturn = ReturnType<typeof useResizableItem>\n\ntype UseResizableTriggerOptions = {\n /**\n * id assigned to resizable trigger element.\n */\n id?: string\n /**\n * Ref for resizable trigger element.\n */\n ref?: ForwardedRef<HTMLElement>\n /**\n * If `true`, the resizable trigger will be disabled.\n *\n * @default false\n */\n isDisabled?: boolean\n /**\n * The callback invoked when resizable trigger are dragged.\n */\n onDragging?: (isDragging: boolean) => void\n}\n\nexport type UseResizableTriggerProps = HTMLUIProps<\"div\"> &\n ResizableTriggerProps &\n UseResizableTriggerOptions\n\nexport const useResizableTrigger = ({\n id,\n ref,\n as,\n disabled,\n isDisabled,\n onDragging,\n ...rest\n}: UseResizableTriggerProps) => {\n id ??= useId()\n\n const { isDisabled: isGroupDisabled } = useResizableContext()\n const [isActive, setIsActive] = useState<boolean>(false)\n\n const trulyDisabled = disabled || isDisabled || isGroupDisabled\n\n const getTriggerProps: TriggerPropGetter = useCallback(\n (props = {}) => ({\n ...props,\n id,\n tagName: as,\n disabled: trulyDisabled,\n onDragging: handlerAll(onDragging, (isActive) => setIsActive(isActive)),\n ...rest,\n \"data-active\": dataAttr(isActive),\n style: {\n ...props.style,\n ...rest.style,\n ...(trulyDisabled ? { cursor: \"default\" } : {}),\n },\n }),\n [id, as, trulyDisabled, onDragging, rest, isActive],\n )\n\n const getIconProps: UIPropGetter = useCallback(\n (props = {}, ref = null) => ({\n ...props,\n ref,\n \"data-active\": dataAttr(isActive),\n }),\n [isActive],\n )\n\n useEffect(() => {\n if (!id) return\n\n const el = getResizeHandleElement(id)\n\n // @ts-expect-error\n if (ref) ref.current = el\n }, [ref, id])\n\n return {\n getTriggerProps,\n getIconProps,\n }\n}\n\nexport type UseResizableTriggerReturn = ReturnType<typeof useResizableTrigger>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAKO;AACP,IAAAA,gBAAmB;AAEnB,IAAAC,iCAA2B;;;ACP3B,mBAAoD;AAEpD,mBAAwD;AACxD,oCAIO;AAsCA,IAAM,CAAC,mBAAmB,mBAAmB,QAClD,4BAAgC;AAAA,EAC9B,MAAM;AAAA,EACN,cAAc;AAChB,CAAC;AA8CI,IAAM,eAAe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L,CAAC;AAED,UAAM,MAAmB,EAAE,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,UAAU;AAErE,WACE,4CAAC,qBAAkB,OAAO,EAAE,QAAQ,GAAG,KAAK,GAC1C;AAAA,MAAC,eAAG;AAAA,MAAH;AAAA,QACC,eAAW,kBAAG,gBAAgB,SAAS;AAAA,QACvC,OAAO;AAAA,QACN,GAAG,kBAAkB,CAAC,GAAG,YAAY;AAAA,QAEtC,sDAAC,6CAAY,GAAG,cAAc,GAAI,UAAS;AAAA;AAAA,IAC7C,GACF;AAAA,EAEJ;AACF;","names":["import_utils","import_react_resizable_panels","ref","rest"]}
|
package/dist/resizable.mjs
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/use-resizable.js
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
"use client"
|
1
2
|
"use strict";
|
2
3
|
var __defProp = Object.defineProperty;
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
@@ -207,3 +208,4 @@ var useResizableTrigger = ({
|
|
207
208
|
useResizableItem,
|
208
209
|
useResizableTrigger
|
209
210
|
});
|
211
|
+
//# sourceMappingURL=use-resizable.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/use-resizable.ts"],"sourcesContent":["import type { CSSUIObject, HTMLUIProps, UIPropGetter } from \"@yamada-ui/core\"\nimport type { PropGetter } from \"@yamada-ui/utils\"\nimport { createContext, dataAttr, handlerAll } from \"@yamada-ui/utils\"\nimport type { ForwardedRef, RefObject } from \"react\"\nimport { useCallback, useEffect, useId, useState } from \"react\"\nimport {\n getPanelElement,\n getPanelGroupElement,\n getResizeHandleElement,\n} from \"react-resizable-panels\"\nimport type {\n PanelResizeHandleProps,\n PanelGroupProps,\n PanelProps,\n PanelGroupOnLayout,\n PanelGroupStorage,\n ImperativePanelHandle,\n} from \"react-resizable-panels\"\n\ntype GroupPropGetter = (props?: Partial<PanelGroupProps>) => PanelGroupProps\ntype ItemPropGetter = (props?: HTMLUIProps<\"div\"> & PanelProps) => PanelProps\ntype TriggerPropGetter = (\n props?: PanelResizeHandleProps,\n) => PanelResizeHandleProps\n\ntype As = { as?: keyof HTMLElementTagNameMap }\n\ntype ResizableGroupProps = Omit<\n PanelGroupProps,\n \"id\" | \"tagName\" | \"children\"\n> &\n As\ntype ResizableItemProps = Omit<PanelProps, \"id\" | \"tagName\" | \"children\"> & As\ntype ResizableTriggerProps = Omit<\n PanelResizeHandleProps,\n \"id\" | \"tagName\" | \"children\"\n> &\n As\n\nexport type ResizableStorage = PanelGroupStorage\nexport type ResizableItemControl = ImperativePanelHandle\n\ntype ResizableContext = {\n isDisabled: boolean\n styles: Record<string, CSSUIObject>\n}\n\nexport const [ResizableProvider, useResizableContext] =\n createContext<ResizableContext>({\n name: \"ResizableContext\",\n errorMessage: `useResizableContext returned is 'undefined'. Seems you forgot to wrap the components in \"<Resizable />\"`,\n })\n\nexport type UseResizableProps = {\n /**\n * id assigned to resizable element.\n */\n id?: string\n /**\n * Ref for resizable element.\n */\n ref?: ForwardedRef<HTMLElement>\n /**\n * The direction of the resizable.\n *\n * @default \"horizontal\"\n */\n direction?: \"horizontal\" | \"vertical\"\n /**\n * If `true`, the resizable trigger will be disabled.\n */\n isDisabled?: boolean\n /**\n * Unit to resize by keyboard operation.\n *\n * @default 10\n */\n keyboardStep?: number\n /**\n * Key of value saved in storage.\n * By default, it is saved to `local storage`.\n */\n storageKey?: string\n /**\n * A callback that gets and sets a value in custom storage.\n */\n storage?: PanelGroupStorage\n /**\n * The callback invoked when resizable items are resized.\n */\n onLayout?: PanelGroupOnLayout\n /**\n * Props for resizable component.\n */\n groupProps?: ResizableGroupProps\n}\n\nexport const useResizable = ({\n id,\n direction = \"horizontal\",\n storageKey,\n keyboardStep,\n isDisabled = false,\n onLayout,\n storage,\n ref,\n groupProps,\n ...rest\n}: UseResizableProps) => {\n id ??= useId()\n\n const getContainerProps: PropGetter = useCallback(\n (props = {}, ref = null) => ({ ...props, ref, ...rest }),\n [rest],\n )\n\n const getGroupProps: GroupPropGetter = useCallback(\n (props = {}) => {\n const { as, ...rest } = groupProps ?? {}\n\n return {\n ...props,\n id,\n direction,\n tagName: as,\n autoSaveId: storageKey,\n keyboardResizeBy: keyboardStep,\n onLayout,\n storage,\n ...rest,\n }\n },\n [id, direction, groupProps, storageKey, keyboardStep, onLayout, storage],\n )\n\n useEffect(() => {\n if (!id) return\n\n const el = getPanelGroupElement(id)\n\n // @ts-expect-error\n if (ref) ref.current = el\n }, [ref, id])\n\n return {\n isDisabled,\n getContainerProps,\n getGroupProps,\n }\n}\n\nexport type UseResizableReturn = ReturnType<typeof useResizable>\n\ntype UseResizableItemOptions = {\n /**\n * id assigned to resizable item element.\n */\n id?: string\n /**\n * Ref for resizable item element.\n */\n ref?: ForwardedRef<HTMLElement>\n /**\n * If `true`, the resizable item can be collapsed.\n *\n * @default false\n */\n collapsible?: boolean\n /**\n * The collapsed size of the resizable item.\n */\n collapsedSize?: number\n /**\n * The initial size of the resizable item.\n */\n defaultSize?: number\n /**\n * The minimum allowed value of the resizable item.\n */\n minSize?: number\n /**\n * The maximum allowed value of the resizable item.\n */\n maxSize?: number\n /**\n * The callback invoked when resizable item are collapsed.\n */\n onCollapse?: () => void\n /**\n * The callback invoked when resizable item are expanded.\n */\n onExpand?: () => void\n /**\n * The callback invoked when resizable item are resized.\n */\n onResize?: (size: number, prevSize: number | undefined) => void\n /**\n * Order for the resizable item.\n */\n order?: number\n /**\n * Ref of the resizable item callback.\n */\n controlRef?: RefObject<ResizableItemControl>\n /**\n * Props for resizable item container element.\n */\n containerProps?: Omit<HTMLUIProps<\"div\">, \"as\"> & ResizableItemProps\n}\n\nexport type UseResizableItemProps = Omit<\n HTMLUIProps<\"div\">,\n keyof UseResizableItemOptions\n> &\n UseResizableItemOptions\n\nexport const useResizableItem = ({\n id,\n ref,\n collapsedSize,\n collapsible,\n defaultSize,\n maxSize,\n minSize,\n onCollapse,\n onExpand,\n onResize,\n order,\n controlRef,\n containerProps,\n ...innerProps\n}: UseResizableItemProps) => {\n id ??= useId()\n\n const getPanelProps: ItemPropGetter = useCallback(\n (props = {}) => {\n const { as, ...rest } = containerProps ?? {}\n\n return {\n ...props,\n ref: controlRef,\n id,\n tagName: as,\n collapsible,\n defaultSize,\n maxSize,\n minSize,\n collapsedSize,\n onCollapse,\n onExpand,\n onResize,\n order,\n ...rest,\n }\n },\n [\n id,\n controlRef,\n containerProps,\n collapsedSize,\n collapsible,\n defaultSize,\n maxSize,\n minSize,\n onCollapse,\n onExpand,\n onResize,\n order,\n ],\n )\n\n const getItemProps: UIPropGetter = useCallback(\n (props = {}, ref = null) => ({ ...props, ref, ...innerProps }),\n [innerProps],\n )\n\n useEffect(() => {\n if (!id) return\n\n const el = getPanelElement(id)\n\n // @ts-expect-error\n if (ref) ref.current = el\n }, [ref, id])\n\n return {\n getPanelProps,\n getItemProps,\n }\n}\n\nexport type UseResizableItemReturn = ReturnType<typeof useResizableItem>\n\ntype UseResizableTriggerOptions = {\n /**\n * id assigned to resizable trigger element.\n */\n id?: string\n /**\n * Ref for resizable trigger element.\n */\n ref?: ForwardedRef<HTMLElement>\n /**\n * If `true`, the resizable trigger will be disabled.\n *\n * @default false\n */\n isDisabled?: boolean\n /**\n * The callback invoked when resizable trigger are dragged.\n */\n onDragging?: (isDragging: boolean) => void\n}\n\nexport type UseResizableTriggerProps = HTMLUIProps<\"div\"> &\n ResizableTriggerProps &\n UseResizableTriggerOptions\n\nexport const useResizableTrigger = ({\n id,\n ref,\n as,\n disabled,\n isDisabled,\n onDragging,\n ...rest\n}: UseResizableTriggerProps) => {\n id ??= useId()\n\n const { isDisabled: isGroupDisabled } = useResizableContext()\n const [isActive, setIsActive] = useState<boolean>(false)\n\n const trulyDisabled = disabled || isDisabled || isGroupDisabled\n\n const getTriggerProps: TriggerPropGetter = useCallback(\n (props = {}) => ({\n ...props,\n id,\n tagName: as,\n disabled: trulyDisabled,\n onDragging: handlerAll(onDragging, (isActive) => setIsActive(isActive)),\n ...rest,\n \"data-active\": dataAttr(isActive),\n style: {\n ...props.style,\n ...rest.style,\n ...(trulyDisabled ? { cursor: \"default\" } : {}),\n },\n }),\n [id, as, trulyDisabled, onDragging, rest, isActive],\n )\n\n const getIconProps: UIPropGetter = useCallback(\n (props = {}, ref = null) => ({\n ...props,\n ref,\n \"data-active\": dataAttr(isActive),\n }),\n [isActive],\n )\n\n useEffect(() => {\n if (!id) return\n\n const el = getResizeHandleElement(id)\n\n // @ts-expect-error\n if (ref) ref.current = el\n }, [ref, id])\n\n return {\n getTriggerProps,\n getIconProps,\n }\n}\n\nexport type UseResizableTriggerReturn = ReturnType<typeof useResizableTrigger>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAoD;AAEpD,mBAAwD;AACxD,oCAIO;AAsCA,IAAM,CAAC,mBAAmB,mBAAmB,QAClD,4BAAgC;AAAA,EAC9B,MAAM;AAAA,EACN,cAAc;AAChB,CAAC;AA8CI,IAAM,eAAe,CAAC;AAAA,EAC3B;AAAA,EACA,YAAY;AAAA,EACZ;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAyB;AACvB,6BAAO,oBAAM;AAEb,QAAM,wBAAgC;AAAA,IACpC,CAAC,QAAQ,CAAC,GAAGA,OAAM,UAAU,EAAE,GAAG,OAAO,KAAAA,MAAK,GAAG,KAAK;AAAA,IACtD,CAAC,IAAI;AAAA,EACP;AAEA,QAAM,oBAAiC;AAAA,IACrC,CAAC,QAAQ,CAAC,MAAM;AACd,YAAM,EAAE,IAAI,GAAGC,MAAK,IAAI,kCAAc,CAAC;AAEvC,aAAO;AAAA,QACL,GAAG;AAAA,QACH;AAAA,QACA;AAAA,QACA,SAAS;AAAA,QACT,YAAY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AAE,CAAC;AAEZ,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":["ref","rest","isActive"]}
|
package/dist/use-resizable.mjs
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
+
"use client"
|
1
2
|
import {
|
2
3
|
ResizableProvider,
|
3
4
|
useResizable,
|
4
5
|
useResizableContext,
|
5
6
|
useResizableItem,
|
6
7
|
useResizableTrigger
|
7
|
-
} from "./chunk-
|
8
|
+
} from "./chunk-R6EC3EDW.mjs";
|
8
9
|
export {
|
9
10
|
ResizableProvider,
|
10
11
|
useResizable,
|
@@ -12,3 +13,4 @@ export {
|
|
12
13
|
useResizableItem,
|
13
14
|
useResizableTrigger
|
14
15
|
};
|
16
|
+
//# sourceMappingURL=use-resizable.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@yamada-ui/resizable",
|
3
|
-
"version": "1.0.9-dev-
|
3
|
+
"version": "1.0.9-dev-20240314115905",
|
4
4
|
"description": "Yamada UI resizable component",
|
5
5
|
"keywords": [
|
6
6
|
"yamada",
|
@@ -37,9 +37,9 @@
|
|
37
37
|
},
|
38
38
|
"dependencies": {
|
39
39
|
"react-resizable-panels": "^2.0.8",
|
40
|
+
"@yamada-ui/core": "1.4.4-dev-20240314115905",
|
40
41
|
"@yamada-ui/utils": "1.0.7",
|
41
|
-
"@yamada-ui/icon": "1.0.16-dev-
|
42
|
-
"@yamada-ui/core": "1.4.4-dev-20240313151005"
|
42
|
+
"@yamada-ui/icon": "1.0.16-dev-20240314115905"
|
43
43
|
},
|
44
44
|
"devDependencies": {
|
45
45
|
"clean-package": "2.2.0",
|
@@ -55,7 +55,11 @@
|
|
55
55
|
"format": [
|
56
56
|
"cjs",
|
57
57
|
"esm"
|
58
|
-
]
|
58
|
+
],
|
59
|
+
"banner": {
|
60
|
+
"js": "\"use client\""
|
61
|
+
},
|
62
|
+
"sourcemap": true
|
59
63
|
},
|
60
64
|
"module": "dist/index.mjs",
|
61
65
|
"types": "dist/index.d.ts",
|