@yamada-ui/resizable 1.1.14-dev-20241005220629 → 1.1.14-dev-20241006000212
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/{chunk-AWBXGQXB.mjs → chunk-GF5FUJZL.mjs} +10 -10
- package/dist/{chunk-AWBXGQXB.mjs.map → chunk-GF5FUJZL.mjs.map} +1 -1
- package/dist/{chunk-YBL74RYZ.mjs → chunk-MV5OACWH.mjs} +6 -6
- package/dist/{chunk-YBL74RYZ.mjs.map → chunk-MV5OACWH.mjs.map} +1 -1
- package/dist/{chunk-E3WJJXQT.mjs → chunk-VA7EJWLN.mjs} +31 -26
- package/dist/chunk-VA7EJWLN.mjs.map +1 -0
- package/dist/{chunk-GKF6QUMG.mjs → chunk-WFROFCPD.mjs} +22 -22
- package/dist/chunk-WFROFCPD.mjs.map +1 -0
- package/dist/index.js +52 -52
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -4
- package/dist/resizable-item.js +29 -29
- package/dist/resizable-item.js.map +1 -1
- package/dist/resizable-item.mjs +2 -2
- package/dist/resizable-trigger.js +14 -14
- package/dist/resizable-trigger.js.map +1 -1
- package/dist/resizable-trigger.mjs +2 -2
- package/dist/resizable.js +9 -9
- package/dist/resizable.js.map +1 -1
- package/dist/resizable.mjs +2 -2
- package/dist/use-resizable.d.mts +30 -30
- package/dist/use-resizable.d.ts +30 -30
- package/dist/use-resizable.js +24 -24
- package/dist/use-resizable.js.map +1 -1
- package/dist/use-resizable.mjs +1 -1
- package/package.json +4 -4
- package/dist/chunk-E3WJJXQT.mjs.map +0 -1
- package/dist/chunk-GKF6QUMG.mjs.map +0 -1
package/dist/resizable.mjs
CHANGED
package/dist/use-resizable.d.mts
CHANGED
@@ -7,11 +7,11 @@ import { PanelGroupStorage, ImperativePanelHandle, PanelGroupOnLayout, PanelGrou
|
|
7
7
|
interface As {
|
8
8
|
as?: keyof HTMLElementTagNameMap;
|
9
9
|
}
|
10
|
-
interface ResizableGroupProps extends Omit<Partial<PanelGroupProps>, "
|
10
|
+
interface ResizableGroupProps extends Omit<Partial<PanelGroupProps>, "children" | "id" | "tagName">, As {
|
11
11
|
}
|
12
|
-
interface ResizableItemProps extends Omit<PanelProps, "
|
12
|
+
interface ResizableItemProps extends Omit<PanelProps, "children" | "id" | "tagName">, As {
|
13
13
|
}
|
14
|
-
interface ResizableTriggerProps extends Omit<PanelResizeHandleProps, "
|
14
|
+
interface ResizableTriggerProps extends Omit<PanelResizeHandleProps, "children" | "id" | "tagName">, As {
|
15
15
|
}
|
16
16
|
interface ResizableStorage extends PanelGroupStorage {
|
17
17
|
}
|
@@ -20,7 +20,7 @@ interface ResizableItemControl extends ImperativePanelHandle {
|
|
20
20
|
interface ResizableContext {
|
21
21
|
isDisabled: boolean;
|
22
22
|
styles: {
|
23
|
-
[key: string]: CSSUIObject;
|
23
|
+
[key: string]: CSSUIObject | undefined;
|
24
24
|
};
|
25
25
|
}
|
26
26
|
declare const ResizableProvider: react.Provider<ResizableContext>;
|
@@ -50,25 +50,25 @@ interface UseResizableProps {
|
|
50
50
|
* @default 10
|
51
51
|
*/
|
52
52
|
keyboardStep?: number;
|
53
|
+
/**
|
54
|
+
* A callback that gets and sets a value in custom storage.
|
55
|
+
*/
|
56
|
+
storage?: PanelGroupStorage;
|
53
57
|
/**
|
54
58
|
* Key of value saved in storage.
|
55
59
|
* By default, it is saved to `local storage`.
|
56
60
|
*/
|
57
61
|
storageKey?: string;
|
58
62
|
/**
|
59
|
-
*
|
63
|
+
* Props for resizable component.
|
60
64
|
*/
|
61
|
-
|
65
|
+
groupProps?: ResizableGroupProps;
|
62
66
|
/**
|
63
67
|
* The callback invoked when resizable items are resized.
|
64
68
|
*/
|
65
69
|
onLayout?: PanelGroupOnLayout;
|
66
|
-
/**
|
67
|
-
* Props for resizable component.
|
68
|
-
*/
|
69
|
-
groupProps?: ResizableGroupProps;
|
70
70
|
}
|
71
|
-
declare const useResizable: ({ id,
|
71
|
+
declare const useResizable: ({ id, ref, direction, isDisabled, keyboardStep, storage, storageKey, groupProps, onLayout, ...rest }: UseResizableProps) => {
|
72
72
|
isDisabled: boolean;
|
73
73
|
getContainerProps: PropGetter<"div", undefined>;
|
74
74
|
getGroupProps: (props?: Partial<PanelGroupProps>) => PanelGroupProps;
|
@@ -83,6 +83,10 @@ interface UseResizableItemOptions {
|
|
83
83
|
* Ref for resizable item element.
|
84
84
|
*/
|
85
85
|
ref?: ForwardedRef<HTMLElement>;
|
86
|
+
/**
|
87
|
+
* The collapsed size of the resizable item.
|
88
|
+
*/
|
89
|
+
collapsedSize?: number;
|
86
90
|
/**
|
87
91
|
* If `true`, the resizable item can be collapsed.
|
88
92
|
*
|
@@ -90,21 +94,29 @@ interface UseResizableItemOptions {
|
|
90
94
|
*/
|
91
95
|
collapsible?: boolean;
|
92
96
|
/**
|
93
|
-
*
|
97
|
+
* Ref of the resizable item callback.
|
94
98
|
*/
|
95
|
-
|
99
|
+
controlRef?: RefObject<ResizableItemControl>;
|
96
100
|
/**
|
97
101
|
* The initial size of the resizable item.
|
98
102
|
*/
|
99
103
|
defaultSize?: number;
|
104
|
+
/**
|
105
|
+
* The maximum allowed value of the resizable item.
|
106
|
+
*/
|
107
|
+
maxSize?: number;
|
100
108
|
/**
|
101
109
|
* The minimum allowed value of the resizable item.
|
102
110
|
*/
|
103
111
|
minSize?: number;
|
104
112
|
/**
|
105
|
-
*
|
113
|
+
* Order for the resizable item.
|
106
114
|
*/
|
107
|
-
|
115
|
+
order?: number;
|
116
|
+
/**
|
117
|
+
* Props for resizable item container element.
|
118
|
+
*/
|
119
|
+
containerProps?: Omit<HTMLUIProps, "as"> & ResizableItemProps;
|
108
120
|
/**
|
109
121
|
* The callback invoked when resizable item are collapsed.
|
110
122
|
*/
|
@@ -117,24 +129,12 @@ interface UseResizableItemOptions {
|
|
117
129
|
* The callback invoked when resizable item are resized.
|
118
130
|
*/
|
119
131
|
onResize?: (size: number, prevSize: number | undefined) => void;
|
120
|
-
/**
|
121
|
-
* Order for the resizable item.
|
122
|
-
*/
|
123
|
-
order?: number;
|
124
|
-
/**
|
125
|
-
* Ref of the resizable item callback.
|
126
|
-
*/
|
127
|
-
controlRef?: RefObject<ResizableItemControl>;
|
128
|
-
/**
|
129
|
-
* Props for resizable item container element.
|
130
|
-
*/
|
131
|
-
containerProps?: Omit<HTMLUIProps, "as"> & ResizableItemProps;
|
132
132
|
}
|
133
133
|
interface UseResizableItemProps extends Omit<HTMLUIProps, keyof UseResizableItemOptions>, UseResizableItemOptions {
|
134
134
|
}
|
135
|
-
declare const useResizableItem: ({ id, ref, collapsedSize, collapsible, defaultSize, maxSize, minSize,
|
136
|
-
getPanelProps: PropGetter<Merge<HTMLUIProps, PanelProps>, PanelProps>;
|
135
|
+
declare const useResizableItem: ({ id, ref, collapsedSize, collapsible, controlRef, defaultSize, maxSize, minSize, order, containerProps, onCollapse, onExpand, onResize, ...innerProps }: UseResizableItemProps) => {
|
137
136
|
getItemProps: PropGetter<"div", undefined>;
|
137
|
+
getPanelProps: PropGetter<Merge<HTMLUIProps, PanelProps>, PanelProps>;
|
138
138
|
};
|
139
139
|
type UseResizableItemReturn = ReturnType<typeof useResizableItem>;
|
140
140
|
interface UseResizableTriggerOptions {
|
@@ -160,8 +160,8 @@ interface UseResizableTriggerOptions {
|
|
160
160
|
interface UseResizableTriggerProps extends Merge<ResizableTriggerProps, Omit<HTMLUIPropsWithoutAs, "id" | "onBlur" | "onFocus">>, UseResizableTriggerOptions {
|
161
161
|
}
|
162
162
|
declare const useResizableTrigger: ({ id, ref, as, disabled, isDisabled, onDragging, ...rest }: UseResizableTriggerProps) => {
|
163
|
-
getTriggerProps: PropGetter<PanelResizeHandleProps, PanelResizeHandleProps>;
|
164
163
|
getIconProps: PropGetter<"div", undefined>;
|
164
|
+
getTriggerProps: PropGetter<PanelResizeHandleProps, PanelResizeHandleProps>;
|
165
165
|
};
|
166
166
|
type UseResizableTriggerReturn = ReturnType<typeof useResizableTrigger>;
|
167
167
|
|
package/dist/use-resizable.d.ts
CHANGED
@@ -7,11 +7,11 @@ import { PanelGroupStorage, ImperativePanelHandle, PanelGroupOnLayout, PanelGrou
|
|
7
7
|
interface As {
|
8
8
|
as?: keyof HTMLElementTagNameMap;
|
9
9
|
}
|
10
|
-
interface ResizableGroupProps extends Omit<Partial<PanelGroupProps>, "
|
10
|
+
interface ResizableGroupProps extends Omit<Partial<PanelGroupProps>, "children" | "id" | "tagName">, As {
|
11
11
|
}
|
12
|
-
interface ResizableItemProps extends Omit<PanelProps, "
|
12
|
+
interface ResizableItemProps extends Omit<PanelProps, "children" | "id" | "tagName">, As {
|
13
13
|
}
|
14
|
-
interface ResizableTriggerProps extends Omit<PanelResizeHandleProps, "
|
14
|
+
interface ResizableTriggerProps extends Omit<PanelResizeHandleProps, "children" | "id" | "tagName">, As {
|
15
15
|
}
|
16
16
|
interface ResizableStorage extends PanelGroupStorage {
|
17
17
|
}
|
@@ -20,7 +20,7 @@ interface ResizableItemControl extends ImperativePanelHandle {
|
|
20
20
|
interface ResizableContext {
|
21
21
|
isDisabled: boolean;
|
22
22
|
styles: {
|
23
|
-
[key: string]: CSSUIObject;
|
23
|
+
[key: string]: CSSUIObject | undefined;
|
24
24
|
};
|
25
25
|
}
|
26
26
|
declare const ResizableProvider: react.Provider<ResizableContext>;
|
@@ -50,25 +50,25 @@ interface UseResizableProps {
|
|
50
50
|
* @default 10
|
51
51
|
*/
|
52
52
|
keyboardStep?: number;
|
53
|
+
/**
|
54
|
+
* A callback that gets and sets a value in custom storage.
|
55
|
+
*/
|
56
|
+
storage?: PanelGroupStorage;
|
53
57
|
/**
|
54
58
|
* Key of value saved in storage.
|
55
59
|
* By default, it is saved to `local storage`.
|
56
60
|
*/
|
57
61
|
storageKey?: string;
|
58
62
|
/**
|
59
|
-
*
|
63
|
+
* Props for resizable component.
|
60
64
|
*/
|
61
|
-
|
65
|
+
groupProps?: ResizableGroupProps;
|
62
66
|
/**
|
63
67
|
* The callback invoked when resizable items are resized.
|
64
68
|
*/
|
65
69
|
onLayout?: PanelGroupOnLayout;
|
66
|
-
/**
|
67
|
-
* Props for resizable component.
|
68
|
-
*/
|
69
|
-
groupProps?: ResizableGroupProps;
|
70
70
|
}
|
71
|
-
declare const useResizable: ({ id,
|
71
|
+
declare const useResizable: ({ id, ref, direction, isDisabled, keyboardStep, storage, storageKey, groupProps, onLayout, ...rest }: UseResizableProps) => {
|
72
72
|
isDisabled: boolean;
|
73
73
|
getContainerProps: PropGetter<"div", undefined>;
|
74
74
|
getGroupProps: (props?: Partial<PanelGroupProps>) => PanelGroupProps;
|
@@ -83,6 +83,10 @@ interface UseResizableItemOptions {
|
|
83
83
|
* Ref for resizable item element.
|
84
84
|
*/
|
85
85
|
ref?: ForwardedRef<HTMLElement>;
|
86
|
+
/**
|
87
|
+
* The collapsed size of the resizable item.
|
88
|
+
*/
|
89
|
+
collapsedSize?: number;
|
86
90
|
/**
|
87
91
|
* If `true`, the resizable item can be collapsed.
|
88
92
|
*
|
@@ -90,21 +94,29 @@ interface UseResizableItemOptions {
|
|
90
94
|
*/
|
91
95
|
collapsible?: boolean;
|
92
96
|
/**
|
93
|
-
*
|
97
|
+
* Ref of the resizable item callback.
|
94
98
|
*/
|
95
|
-
|
99
|
+
controlRef?: RefObject<ResizableItemControl>;
|
96
100
|
/**
|
97
101
|
* The initial size of the resizable item.
|
98
102
|
*/
|
99
103
|
defaultSize?: number;
|
104
|
+
/**
|
105
|
+
* The maximum allowed value of the resizable item.
|
106
|
+
*/
|
107
|
+
maxSize?: number;
|
100
108
|
/**
|
101
109
|
* The minimum allowed value of the resizable item.
|
102
110
|
*/
|
103
111
|
minSize?: number;
|
104
112
|
/**
|
105
|
-
*
|
113
|
+
* Order for the resizable item.
|
106
114
|
*/
|
107
|
-
|
115
|
+
order?: number;
|
116
|
+
/**
|
117
|
+
* Props for resizable item container element.
|
118
|
+
*/
|
119
|
+
containerProps?: Omit<HTMLUIProps, "as"> & ResizableItemProps;
|
108
120
|
/**
|
109
121
|
* The callback invoked when resizable item are collapsed.
|
110
122
|
*/
|
@@ -117,24 +129,12 @@ interface UseResizableItemOptions {
|
|
117
129
|
* The callback invoked when resizable item are resized.
|
118
130
|
*/
|
119
131
|
onResize?: (size: number, prevSize: number | undefined) => void;
|
120
|
-
/**
|
121
|
-
* Order for the resizable item.
|
122
|
-
*/
|
123
|
-
order?: number;
|
124
|
-
/**
|
125
|
-
* Ref of the resizable item callback.
|
126
|
-
*/
|
127
|
-
controlRef?: RefObject<ResizableItemControl>;
|
128
|
-
/**
|
129
|
-
* Props for resizable item container element.
|
130
|
-
*/
|
131
|
-
containerProps?: Omit<HTMLUIProps, "as"> & ResizableItemProps;
|
132
132
|
}
|
133
133
|
interface UseResizableItemProps extends Omit<HTMLUIProps, keyof UseResizableItemOptions>, UseResizableItemOptions {
|
134
134
|
}
|
135
|
-
declare const useResizableItem: ({ id, ref, collapsedSize, collapsible, defaultSize, maxSize, minSize,
|
136
|
-
getPanelProps: PropGetter<Merge<HTMLUIProps, PanelProps>, PanelProps>;
|
135
|
+
declare const useResizableItem: ({ id, ref, collapsedSize, collapsible, controlRef, defaultSize, maxSize, minSize, order, containerProps, onCollapse, onExpand, onResize, ...innerProps }: UseResizableItemProps) => {
|
137
136
|
getItemProps: PropGetter<"div", undefined>;
|
137
|
+
getPanelProps: PropGetter<Merge<HTMLUIProps, PanelProps>, PanelProps>;
|
138
138
|
};
|
139
139
|
type UseResizableItemReturn = ReturnType<typeof useResizableItem>;
|
140
140
|
interface UseResizableTriggerOptions {
|
@@ -160,8 +160,8 @@ interface UseResizableTriggerOptions {
|
|
160
160
|
interface UseResizableTriggerProps extends Merge<ResizableTriggerProps, Omit<HTMLUIPropsWithoutAs, "id" | "onBlur" | "onFocus">>, UseResizableTriggerOptions {
|
161
161
|
}
|
162
162
|
declare const useResizableTrigger: ({ id, ref, as, disabled, isDisabled, onDragging, ...rest }: UseResizableTriggerProps) => {
|
163
|
-
getTriggerProps: PropGetter<PanelResizeHandleProps, PanelResizeHandleProps>;
|
164
163
|
getIconProps: PropGetter<"div", undefined>;
|
164
|
+
getTriggerProps: PropGetter<PanelResizeHandleProps, PanelResizeHandleProps>;
|
165
165
|
};
|
166
166
|
type UseResizableTriggerReturn = ReturnType<typeof useResizableTrigger>;
|
167
167
|
|
package/dist/use-resizable.js
CHANGED
@@ -37,14 +37,14 @@ var [ResizableProvider, useResizableContext] = (0, import_utils.createContext)({
|
|
37
37
|
});
|
38
38
|
var useResizable = ({
|
39
39
|
id,
|
40
|
+
ref,
|
40
41
|
direction = "horizontal",
|
41
|
-
storageKey,
|
42
|
-
keyboardStep,
|
43
42
|
isDisabled = false,
|
44
|
-
|
43
|
+
keyboardStep,
|
45
44
|
storage,
|
46
|
-
|
45
|
+
storageKey,
|
47
46
|
groupProps,
|
47
|
+
onLayout,
|
48
48
|
...rest
|
49
49
|
}) => {
|
50
50
|
const uuid = (0, import_react.useId)();
|
@@ -59,12 +59,12 @@ var useResizable = ({
|
|
59
59
|
return {
|
60
60
|
...props,
|
61
61
|
id,
|
62
|
-
direction,
|
63
|
-
tagName: as,
|
64
62
|
autoSaveId: storageKey,
|
63
|
+
direction,
|
65
64
|
keyboardResizeBy: keyboardStep,
|
66
|
-
onLayout,
|
67
65
|
storage,
|
66
|
+
tagName: as,
|
67
|
+
onLayout,
|
68
68
|
...rest2
|
69
69
|
};
|
70
70
|
},
|
@@ -73,7 +73,7 @@ var useResizable = ({
|
|
73
73
|
(0, import_react.useEffect)(() => {
|
74
74
|
if (!id) return;
|
75
75
|
const el = (0, import_react_resizable_panels.getPanelGroupElement)(id);
|
76
|
-
if (ref) ref.current = el;
|
76
|
+
if ((0, import_utils.isRefObject)(ref)) ref.current = el;
|
77
77
|
}, [ref, id]);
|
78
78
|
return {
|
79
79
|
isDisabled,
|
@@ -86,15 +86,15 @@ var useResizableItem = ({
|
|
86
86
|
ref,
|
87
87
|
collapsedSize,
|
88
88
|
collapsible,
|
89
|
+
controlRef,
|
89
90
|
defaultSize,
|
90
91
|
maxSize,
|
91
92
|
minSize,
|
93
|
+
order,
|
94
|
+
containerProps,
|
92
95
|
onCollapse,
|
93
96
|
onExpand,
|
94
97
|
onResize,
|
95
|
-
order,
|
96
|
-
controlRef,
|
97
|
-
containerProps,
|
98
98
|
...innerProps
|
99
99
|
}) => {
|
100
100
|
const uuid = (0, import_react.useId)();
|
@@ -104,18 +104,18 @@ var useResizableItem = ({
|
|
104
104
|
const { as, ...rest } = containerProps != null ? containerProps : {};
|
105
105
|
return {
|
106
106
|
...props,
|
107
|
-
ref: controlRef,
|
108
107
|
id,
|
109
|
-
|
108
|
+
ref: controlRef,
|
109
|
+
collapsedSize,
|
110
110
|
collapsible,
|
111
111
|
defaultSize,
|
112
112
|
maxSize,
|
113
113
|
minSize,
|
114
|
-
|
114
|
+
order,
|
115
|
+
tagName: as,
|
115
116
|
onCollapse,
|
116
117
|
onExpand,
|
117
118
|
onResize,
|
118
|
-
order,
|
119
119
|
...collapsible ? { "aria-labelledby": id } : { "aria-label": id },
|
120
120
|
...rest
|
121
121
|
};
|
@@ -142,11 +142,11 @@ var useResizableItem = ({
|
|
142
142
|
(0, import_react.useEffect)(() => {
|
143
143
|
if (!id) return;
|
144
144
|
const el = (0, import_react_resizable_panels.getPanelElement)(id);
|
145
|
-
if (ref) ref.current = el;
|
145
|
+
if ((0, import_utils.isRefObject)(ref)) ref.current = el;
|
146
146
|
}, [ref, id]);
|
147
147
|
return {
|
148
|
-
|
149
|
-
|
148
|
+
getItemProps,
|
149
|
+
getPanelProps
|
150
150
|
};
|
151
151
|
};
|
152
152
|
var useResizableTrigger = ({
|
@@ -167,16 +167,16 @@ var useResizableTrigger = ({
|
|
167
167
|
(props = {}) => ({
|
168
168
|
...props,
|
169
169
|
id,
|
170
|
-
tagName: as,
|
171
170
|
disabled: trulyDisabled,
|
171
|
+
tagName: as,
|
172
172
|
onDragging: (0, import_utils.handlerAll)(onDragging, (isActive2) => setIsActive(isActive2)),
|
173
173
|
...rest,
|
174
|
-
"data-active": (0, import_utils.dataAttr)(isActive),
|
175
174
|
style: {
|
176
175
|
...props.style,
|
177
176
|
...rest.style,
|
178
177
|
...trulyDisabled ? { cursor: "default" } : {}
|
179
|
-
}
|
178
|
+
},
|
179
|
+
"data-active": (0, import_utils.dataAttr)(isActive)
|
180
180
|
}),
|
181
181
|
[id, as, trulyDisabled, onDragging, rest, isActive]
|
182
182
|
);
|
@@ -191,11 +191,11 @@ var useResizableTrigger = ({
|
|
191
191
|
(0, import_react.useEffect)(() => {
|
192
192
|
if (!id) return;
|
193
193
|
const el = (0, import_react_resizable_panels.getResizeHandleElement)(id);
|
194
|
-
if (ref) ref.current = el;
|
194
|
+
if ((0, import_utils.isRefObject)(ref)) ref.current = el;
|
195
195
|
}, [ref, id]);
|
196
196
|
return {
|
197
|
-
|
198
|
-
|
197
|
+
getIconProps,
|
198
|
+
getTriggerProps
|
199
199
|
};
|
200
200
|
};
|
201
201
|
// Annotate the CommonJS export names for ESM import in node:
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/use-resizable.ts"],"sourcesContent":["import type {\n CSSUIObject,\n HTMLUIProps,\n HTMLUIPropsWithoutAs,\n PropGetter,\n} from \"@yamada-ui/core\"\nimport type { Merge } 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\ninterface As {\n as?: keyof HTMLElementTagNameMap\n}\n\ninterface ResizableGroupProps\n extends Omit<Partial<PanelGroupProps>, \"id\" | \"tagName\" | \"children\">,\n As {}\ninterface ResizableItemProps\n extends Omit<PanelProps, \"id\" | \"tagName\" | \"children\">,\n As {}\ninterface ResizableTriggerProps\n extends Omit<PanelResizeHandleProps, \"id\" | \"tagName\" | \"children\">,\n As {}\n\nexport interface ResizableStorage extends PanelGroupStorage {}\nexport interface ResizableItemControl extends ImperativePanelHandle {}\n\ninterface ResizableContext {\n isDisabled: boolean\n styles: { [key: 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 interface 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 const uuid = useId()\n\n id ??= uuid\n\n const getContainerProps: PropGetter = useCallback(\n (props = {}, ref = null) => ({ ...props, ref, ...rest }),\n [rest],\n )\n\n const getGroupProps = useCallback(\n (props: Partial<PanelGroupProps> = {}): PanelGroupProps => {\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\ninterface 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, \"as\"> & ResizableItemProps\n}\n\nexport interface UseResizableItemProps\n extends Omit<HTMLUIProps, keyof UseResizableItemOptions>,\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 const uuid = useId()\n\n id ??= uuid\n\n const getPanelProps: PropGetter<\n Merge<HTMLUIProps, PanelProps>,\n PanelProps\n > = 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 ...(collapsible ? { \"aria-labelledby\": id } : { \"aria-label\": id }),\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: PropGetter = 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\ninterface 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 interface UseResizableTriggerProps\n extends Merge<\n ResizableTriggerProps,\n Omit<HTMLUIPropsWithoutAs, \"id\" | \"onBlur\" | \"onFocus\">\n >,\n UseResizableTriggerOptions {}\n\nexport const useResizableTrigger = ({\n id,\n ref,\n as,\n disabled,\n isDisabled,\n onDragging,\n ...rest\n}: UseResizableTriggerProps) => {\n const uuid = useId()\n\n id ??= uuid\n\n const { isDisabled: isGroupDisabled } = useResizableContext()\n const [isActive, setIsActive] = useState<boolean>(false)\n\n const trulyDisabled = disabled || isDisabled || isGroupDisabled\n\n const getTriggerProps: PropGetter<\n PanelResizeHandleProps,\n PanelResizeHandleProps\n > = useCallback(\n (props = {}) =>\n ({\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 }) as PanelResizeHandleProps,\n [id, as, trulyDisabled, onDragging, rest, isActive],\n )\n\n const getIconProps: PropGetter = 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;AAOA,mBAAoD;AAEpD,mBAAwD;AACxD,oCAIO;AAgCA,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,QAAM,WAAO,oBAAM;AAEnB,yBAAO;AAEP,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,oBAAgB;AAAA,IACpB,CAAC,QAAkC,CAAC,MAAuB;AACzD,YAAM,EAAE,IAAI,GAAGC,MAAK,IAAI,kCAAc,CAAC;AAEvC,aAAO;AAAA,QACL,GAAG;AAAA,QACH;AAAA,QACA;AAAA,QACA,SAAS;AAAA,QACT,YAAY;AAAA,QACZ,kBAAkB;A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AK,sDAAuB,EAAE;AAGpC,QAAI,IAAK,KAAI,UAAU;AAAA,EACzB,GAAG,CAAC,KAAK,EAAE,CAAC;AAEZ,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":["ref","rest","isActive"]}
|
1
|
+
{"version":3,"sources":["../src/use-resizable.ts"],"sourcesContent":["import type {\n CSSUIObject,\n HTMLUIProps,\n HTMLUIPropsWithoutAs,\n PropGetter,\n} from \"@yamada-ui/core\"\nimport type { Merge } from \"@yamada-ui/utils\"\nimport type { ForwardedRef, RefObject } from \"react\"\nimport type {\n ImperativePanelHandle,\n PanelGroupOnLayout,\n PanelGroupProps,\n PanelGroupStorage,\n PanelProps,\n PanelResizeHandleProps,\n} from \"react-resizable-panels\"\nimport {\n createContext,\n dataAttr,\n handlerAll,\n isRefObject,\n} from \"@yamada-ui/utils\"\nimport { useCallback, useEffect, useId, useState } from \"react\"\nimport {\n getPanelElement,\n getPanelGroupElement,\n getResizeHandleElement,\n} from \"react-resizable-panels\"\n\ninterface As {\n as?: keyof HTMLElementTagNameMap\n}\n\ninterface ResizableGroupProps\n extends Omit<Partial<PanelGroupProps>, \"children\" | \"id\" | \"tagName\">,\n As {}\ninterface ResizableItemProps\n extends Omit<PanelProps, \"children\" | \"id\" | \"tagName\">,\n As {}\ninterface ResizableTriggerProps\n extends Omit<PanelResizeHandleProps, \"children\" | \"id\" | \"tagName\">,\n As {}\n\nexport interface ResizableStorage extends PanelGroupStorage {}\nexport interface ResizableItemControl extends ImperativePanelHandle {}\n\ninterface ResizableContext {\n isDisabled: boolean\n styles: { [key: string]: CSSUIObject | undefined }\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 interface 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 * A callback that gets and sets a value in custom storage.\n */\n storage?: PanelGroupStorage\n /**\n * Key of value saved in storage.\n * By default, it is saved to `local storage`.\n */\n storageKey?: string\n /**\n * Props for resizable component.\n */\n groupProps?: ResizableGroupProps\n /**\n * The callback invoked when resizable items are resized.\n */\n onLayout?: PanelGroupOnLayout\n}\n\nexport const useResizable = ({\n id,\n ref,\n direction = \"horizontal\",\n isDisabled = false,\n keyboardStep,\n storage,\n storageKey,\n groupProps,\n onLayout,\n ...rest\n}: UseResizableProps) => {\n const uuid = useId()\n\n id ??= uuid\n\n const getContainerProps: PropGetter = useCallback(\n (props = {}, ref = null) => ({ ...props, ref, ...rest }),\n [rest],\n )\n\n const getGroupProps = useCallback(\n (props: Partial<PanelGroupProps> = {}): PanelGroupProps => {\n const { as, ...rest } = groupProps ?? {}\n\n return {\n ...props,\n id,\n autoSaveId: storageKey,\n direction,\n keyboardResizeBy: keyboardStep,\n storage,\n tagName: as,\n onLayout,\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 if (isRefObject(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\ninterface 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 * The collapsed size of the resizable item.\n */\n collapsedSize?: number\n /**\n * If `true`, the resizable item can be collapsed.\n *\n * @default false\n */\n collapsible?: boolean\n /**\n * Ref of the resizable item callback.\n */\n controlRef?: RefObject<ResizableItemControl>\n /**\n * The initial size of the resizable item.\n */\n defaultSize?: number\n /**\n * The maximum allowed value of the resizable item.\n */\n maxSize?: number\n /**\n * The minimum allowed value of the resizable item.\n */\n minSize?: number\n /**\n * Order for the resizable item.\n */\n order?: number\n /**\n * Props for resizable item container element.\n */\n containerProps?: Omit<HTMLUIProps, \"as\"> & ResizableItemProps\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\nexport interface UseResizableItemProps\n extends Omit<HTMLUIProps, keyof UseResizableItemOptions>,\n UseResizableItemOptions {}\n\nexport const useResizableItem = ({\n id,\n ref,\n collapsedSize,\n collapsible,\n controlRef,\n defaultSize,\n maxSize,\n minSize,\n order,\n containerProps,\n onCollapse,\n onExpand,\n onResize,\n ...innerProps\n}: UseResizableItemProps) => {\n const uuid = useId()\n\n id ??= uuid\n\n const getPanelProps: PropGetter<\n Merge<HTMLUIProps, PanelProps>,\n PanelProps\n > = useCallback(\n (props = {}) => {\n const { as, ...rest } = containerProps ?? {}\n\n return {\n ...props,\n id,\n ref: controlRef,\n collapsedSize,\n collapsible,\n defaultSize,\n maxSize,\n minSize,\n order,\n tagName: as,\n onCollapse,\n onExpand,\n onResize,\n ...(collapsible ? { \"aria-labelledby\": id } : { \"aria-label\": id }),\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: PropGetter = 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 if (isRefObject(ref)) ref.current = el\n }, [ref, id])\n\n return {\n getItemProps,\n getPanelProps,\n }\n}\n\nexport type UseResizableItemReturn = ReturnType<typeof useResizableItem>\n\ninterface 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 interface UseResizableTriggerProps\n extends Merge<\n ResizableTriggerProps,\n Omit<HTMLUIPropsWithoutAs, \"id\" | \"onBlur\" | \"onFocus\">\n >,\n UseResizableTriggerOptions {}\n\nexport const useResizableTrigger = ({\n id,\n ref,\n as,\n disabled,\n isDisabled,\n onDragging,\n ...rest\n}: UseResizableTriggerProps) => {\n const uuid = useId()\n\n id ??= uuid\n\n const { isDisabled: isGroupDisabled } = useResizableContext()\n const [isActive, setIsActive] = useState<boolean>(false)\n\n const trulyDisabled = disabled || isDisabled || isGroupDisabled\n\n const getTriggerProps: PropGetter<\n PanelResizeHandleProps,\n PanelResizeHandleProps\n > = useCallback(\n (props = {}) =>\n ({\n ...props,\n id,\n disabled: trulyDisabled,\n tagName: as,\n onDragging: handlerAll(onDragging, (isActive) => setIsActive(isActive)),\n ...rest,\n style: {\n ...props.style,\n ...rest.style,\n ...(trulyDisabled ? { cursor: \"default\" } : {}),\n },\n \"data-active\": dataAttr(isActive),\n }) as PanelResizeHandleProps,\n [id, as, trulyDisabled, onDragging, rest, isActive],\n )\n\n const getIconProps: PropGetter = 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 if (isRefObject(ref)) ref.current = el\n }, [ref, id])\n\n return {\n getIconProps,\n getTriggerProps,\n }\n}\n\nexport type UseResizableTriggerReturn = ReturnType<typeof useResizableTrigger>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAA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gBAAgB,IAAI,oBAAoB;AAC5D,QAAM,CAAC,UAAU,WAAW,QAAI,uBAAkB,KAAK;AAEvD,QAAM,gBAAgB,YAAY,cAAc;AAEhD,QAAM,sBAGF;AAAA,IACF,CAAC,QAAQ,CAAC,OACP;AAAA,MACC,GAAG;AAAA,MACH;AAAA,MACA,UAAU;AAAA,MACV,SAAS;AAAA,MACT,gBAAY,yBAAW,YAAY,CAACE,cAAa,YAAYA,SAAQ,CAAC;AAAA,MACtE,GAAG;AAAA,MACH,OAAO;AAAA,QACL,GAAG,MAAM;AAAA,QACT,GAAG,KAAK;AAAA,QACR,GAAI,gBAAgB,EAAE,QAAQ,UAAU,IAAI,CAAC;AAAA,MAC/C;AAAA,MACA,mBAAe,uBAAS,QAAQ;AAAA,IAClC;AAAA,IACF,CAAC,IAAI,IAAI,eAAe,YAAY,MAAM,QAAQ;AAAA,EACpD;AAEA,QAAM,mBAA2B;AAAA,IAC/B,CAAC,QAAQ,CAAC,GAAGF,OAAM,UAAU;AAAA,MAC3B,GAAG;AAAA,MACH,KAAAA;AAAA,MACA,mBAAe,uBAAS,QAAQ;AAAA,IAClC;AAAA,IACA,CAAC,QAAQ;AAAA,EACX;AAEA,8BAAU,MAAM;AACd,QAAI,CAAC,GAAI;AAET,UAAM,SAAK,sDAAuB,EAAE;AAEpC,YAAI,0BAAY,GAAG,EAAG,KAAI,UAAU;AAAA,EACtC,GAAG,CAAC,KAAK,EAAE,CAAC;AAEZ,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":["ref","rest","isActive"]}
|
package/dist/use-resizable.mjs
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@yamada-ui/resizable",
|
3
|
-
"version": "1.1.14-dev-
|
3
|
+
"version": "1.1.14-dev-20241006000212",
|
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.1.3",
|
40
|
-
"@yamada-ui/core": "1.15.2-dev-
|
41
|
-
"@yamada-ui/icon": "1.1.8-dev-
|
42
|
-
"@yamada-ui/utils": "1.5.
|
40
|
+
"@yamada-ui/core": "1.15.2-dev-20241006000212",
|
41
|
+
"@yamada-ui/icon": "1.1.8-dev-20241006000212",
|
42
|
+
"@yamada-ui/utils": "1.5.3-dev-20241006000212"
|
43
43
|
},
|
44
44
|
"devDependencies": {
|
45
45
|
"clean-package": "2.2.0",
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/use-resizable.ts"],"sourcesContent":["import type {\n CSSUIObject,\n HTMLUIProps,\n HTMLUIPropsWithoutAs,\n PropGetter,\n} from \"@yamada-ui/core\"\nimport type { Merge } 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\ninterface As {\n as?: keyof HTMLElementTagNameMap\n}\n\ninterface ResizableGroupProps\n extends Omit<Partial<PanelGroupProps>, \"id\" | \"tagName\" | \"children\">,\n As {}\ninterface ResizableItemProps\n extends Omit<PanelProps, \"id\" | \"tagName\" | \"children\">,\n As {}\ninterface ResizableTriggerProps\n extends Omit<PanelResizeHandleProps, \"id\" | \"tagName\" | \"children\">,\n As {}\n\nexport interface ResizableStorage extends PanelGroupStorage {}\nexport interface ResizableItemControl extends ImperativePanelHandle {}\n\ninterface ResizableContext {\n isDisabled: boolean\n styles: { [key: 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 interface 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 const uuid = useId()\n\n id ??= uuid\n\n const getContainerProps: PropGetter = useCallback(\n (props = {}, ref = null) => ({ ...props, ref, ...rest }),\n [rest],\n )\n\n const getGroupProps = useCallback(\n (props: Partial<PanelGroupProps> = {}): PanelGroupProps => {\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\ninterface 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, \"as\"> & ResizableItemProps\n}\n\nexport interface UseResizableItemProps\n extends Omit<HTMLUIProps, keyof UseResizableItemOptions>,\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 const uuid = useId()\n\n id ??= uuid\n\n const getPanelProps: PropGetter<\n Merge<HTMLUIProps, PanelProps>,\n PanelProps\n > = 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 ...(collapsible ? { \"aria-labelledby\": id } : { \"aria-label\": id }),\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: PropGetter = 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\ninterface 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 interface UseResizableTriggerProps\n extends Merge<\n ResizableTriggerProps,\n Omit<HTMLUIPropsWithoutAs, \"id\" | \"onBlur\" | \"onFocus\">\n >,\n UseResizableTriggerOptions {}\n\nexport const useResizableTrigger = ({\n id,\n ref,\n as,\n disabled,\n isDisabled,\n onDragging,\n ...rest\n}: UseResizableTriggerProps) => {\n const uuid = useId()\n\n id ??= uuid\n\n const { isDisabled: isGroupDisabled } = useResizableContext()\n const [isActive, setIsActive] = useState<boolean>(false)\n\n const trulyDisabled = disabled || isDisabled || isGroupDisabled\n\n const getTriggerProps: PropGetter<\n PanelResizeHandleProps,\n PanelResizeHandleProps\n > = useCallback(\n (props = {}) =>\n ({\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 }) as PanelResizeHandleProps,\n [id, as, trulyDisabled, onDragging, rest, isActive],\n )\n\n const getIconProps: PropGetter = 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":";;;AAOA,SAAS,eAAe,UAAU,kBAAkB;AAEpD,SAAS,aAAa,WAAW,OAAO,gBAAgB;AACxD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAgCA,IAAM,CAAC,mBAAmB,mBAAmB,IAClD,cAAgC;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,QAAM,OAAO,MAAM;AAEnB,yBAAO;AAEP,QAAM,oBAAgC;AAAA,IACpC,CAAC,QAAQ,CAAC,GAAGA,OAAM,UAAU,EAAE,GAAG,OAAO,KAAAA,MAAK,GAAG,KAAK;AAAA,IACtD,CAAC,IAAI;AAAA,EACP;AAEA,QAAM,gBAAgB;AAAA,IACpB,CAAC,QAAkC,CAAC,MAAuB;AACzD,YAAM,EAAE,IAAI,GAAGC,MAAK,IAAI,kCAAc,CAAC;AAEvC,aAAO;AAAA,QACL,GAAG;AAAA,QACH;AAAA,QACA;AAAA,QACA,SAAS;AAAA,QACT,YAAY;AAAA,QACZ,kBAAkB;AAAA,QAClB;AAAA,QACA;AAAA,QACA,GAAGA;AAAA,MACL;AAAA,IACF;AAAA,IACA,CAAC,IAAI,WAAW,YAAY,YAAY,cAAc,UAAU,OAAO;AAAA,EACzE;AAEA,YAAU,MAAM;AACd,QAAI,CAAC,GAAI;AAET,UAAM,KAAK,qBAAqB,EAAE;AAGlC,QAAI,IAAK,KAAI,UAAU;AAAA,EACzB,GAAG,CAAC,K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AAsB,CAAC;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAgC;AAC9B,QAAM,OAAO,MAAM;AAEnB,yBAAO;AAEP,QAAM,EAAE,YAAY,gBAAgB,IAAI,oBAAoB;AAC5D,QAAM,CAAC,UAAU,WAAW,IAAI,SAAkB,KAAK;AAEvD,QAAM,gBAAgB,YAAY,cAAc;AAEhD,QAAM,kBAGF;AAAA,IACF,CAAC,QAAQ,CAAC,OACP;AAAA,MACC,GAAG;AAAA,MACH;AAAA,MACA,SAAS;AAAA,MACT,UAAU;AAAA,MACV,YAAY,WAAW,YAAY,CAACE,cAAa,YAAYA,SAAQ,CAAC;AAAA,MACtE,GAAG;AAAA,MACH,eAAe,SAAS,QAAQ;AAAA,MAChC,OAAO;AAAA,QACL,GAAG,MAAM;AAAA,QACT,GAAG,KAAK;AAAA,QACR,GAAI,gBAAgB,EAAE,QAAQ,UAAU,IAAI,CAAC;AAAA,MAC/C;AAAA,IACF;AAAA,IACF,CAAC,IAAI,IAAI,eAAe,YAAY,MAAM,QAAQ;AAAA,EACpD;AAEA,QAAM,eAA2B;AAAA,IAC/B,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,GAAI;AAET,UAAM,KAAK,uBAAuB,EAAE;AAGpC,QAAI,IAAK,KAAI,UAAU;AAAA,EACzB,GAAG,CAAC,KAAK,EAAE,CAAC;AAEZ,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":["ref","rest","isActive"]}
|
@@ -1 +0,0 @@
|
|
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\ninterface ResizableItemOptions {\n /**\n * Ref for resizable item inner element.\n */\n innerRef?: ForwardedRef<HTMLDivElement>\n}\n\nexport interface ResizableItemProps\n extends 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;AAoEd;AAhER,IAAM,aAAa,oBAAI,IAAI,CAAC,OAAO,CAAC;AAEpC,IAAM,UAAU,GAAG,OAAO,EAAE,kBAAkB,CAAC,SAAS,WAAW,IAAI,IAAI,EAAE,CAAC;AAavE,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":[]}
|