@yamada-ui/resizable 1.0.0
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/LICENSE +21 -0
- package/README.md +28 -0
- package/dist/chunk-DVZSQNDW.mjs +185 -0
- package/dist/chunk-OSM43TND.mjs +42 -0
- package/dist/chunk-PA5IMAOA.mjs +33 -0
- package/dist/chunk-VSORTT66.mjs +104 -0
- package/dist/index.d.mts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +360 -0
- package/dist/index.mjs +17 -0
- package/dist/resizable-item.d.mts +16 -0
- package/dist/resizable-item.d.ts +16 -0
- package/dist/resizable-item.js +131 -0
- package/dist/resizable-item.mjs +7 -0
- package/dist/resizable-trigger.d.mts +24 -0
- package/dist/resizable-trigger.d.ts +24 -0
- package/dist/resizable-trigger.js +185 -0
- package/dist/resizable-trigger.mjs +9 -0
- package/dist/resizable.d.mts +22 -0
- package/dist/resizable.d.ts +22 -0
- package/dist/resizable.js +114 -0
- package/dist/resizable.mjs +7 -0
- package/dist/use-resizable.d.mts +162 -0
- package/dist/use-resizable.d.ts +162 -0
- package/dist/use-resizable.js +209 -0
- package/dist/use-resizable.mjs +14 -0
- package/package.json +78 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
Resizable: () => Resizable,
|
|
24
|
+
ResizableItem: () => ResizableItem,
|
|
25
|
+
ResizableTrigger: () => ResizableTrigger,
|
|
26
|
+
ResizableTriggerIcon: () => ResizableTriggerIcon
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(src_exports);
|
|
29
|
+
|
|
30
|
+
// src/resizable.tsx
|
|
31
|
+
var import_core = require("@yamada-ui/core");
|
|
32
|
+
var import_utils2 = require("@yamada-ui/utils");
|
|
33
|
+
var import_react_resizable_panels2 = require("react-resizable-panels");
|
|
34
|
+
|
|
35
|
+
// src/use-resizable.ts
|
|
36
|
+
var import_utils = require("@yamada-ui/utils");
|
|
37
|
+
var import_react = require("react");
|
|
38
|
+
var import_react_resizable_panels = require("react-resizable-panels");
|
|
39
|
+
var [ResizableProvider, useResizableContext] = (0, import_utils.createContext)({
|
|
40
|
+
name: "ResizableContext",
|
|
41
|
+
errorMessage: `useResizableContext returned is 'undefined'. Seems you forgot to wrap the components in "<Resizable />"`
|
|
42
|
+
});
|
|
43
|
+
var useResizable = ({
|
|
44
|
+
id,
|
|
45
|
+
direction = "horizontal",
|
|
46
|
+
storageKey,
|
|
47
|
+
keyboardStep,
|
|
48
|
+
isDisabled = false,
|
|
49
|
+
onLayout,
|
|
50
|
+
storage,
|
|
51
|
+
ref,
|
|
52
|
+
groupProps,
|
|
53
|
+
...rest
|
|
54
|
+
}) => {
|
|
55
|
+
id != null ? id : id = (0, import_react.useId)();
|
|
56
|
+
const getContainerProps = (0, import_react.useCallback)(
|
|
57
|
+
(props = {}, ref2 = null) => ({ ...props, ref: ref2, ...rest }),
|
|
58
|
+
[rest]
|
|
59
|
+
);
|
|
60
|
+
const getGroupProps = (0, import_react.useCallback)(
|
|
61
|
+
(props = {}) => {
|
|
62
|
+
const { as, ...rest2 } = groupProps != null ? groupProps : {};
|
|
63
|
+
return {
|
|
64
|
+
...props,
|
|
65
|
+
id,
|
|
66
|
+
direction,
|
|
67
|
+
tagName: as,
|
|
68
|
+
autoSaveId: storageKey,
|
|
69
|
+
keyboardResizeBy: keyboardStep,
|
|
70
|
+
onLayout,
|
|
71
|
+
storage,
|
|
72
|
+
...rest2
|
|
73
|
+
};
|
|
74
|
+
},
|
|
75
|
+
[id, direction, groupProps, storageKey, keyboardStep, onLayout, storage]
|
|
76
|
+
);
|
|
77
|
+
(0, import_react.useEffect)(() => {
|
|
78
|
+
if (!id)
|
|
79
|
+
return;
|
|
80
|
+
const el = (0, import_react_resizable_panels.getPanelGroupElement)(id);
|
|
81
|
+
if (ref)
|
|
82
|
+
ref.current = el;
|
|
83
|
+
}, [ref, id]);
|
|
84
|
+
return {
|
|
85
|
+
isDisabled,
|
|
86
|
+
getContainerProps,
|
|
87
|
+
getGroupProps
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
var useResizableItem = ({
|
|
91
|
+
id,
|
|
92
|
+
ref,
|
|
93
|
+
collapsedSize,
|
|
94
|
+
collapsible,
|
|
95
|
+
defaultSize,
|
|
96
|
+
maxSize,
|
|
97
|
+
minSize,
|
|
98
|
+
onCollapse,
|
|
99
|
+
onExpand,
|
|
100
|
+
onResize,
|
|
101
|
+
order,
|
|
102
|
+
controlRef,
|
|
103
|
+
itemProps,
|
|
104
|
+
...innerProps
|
|
105
|
+
}) => {
|
|
106
|
+
id != null ? id : id = (0, import_react.useId)();
|
|
107
|
+
const getPanelProps = (0, import_react.useCallback)(
|
|
108
|
+
(props = {}) => {
|
|
109
|
+
const { as, ...rest } = itemProps != null ? itemProps : {};
|
|
110
|
+
return {
|
|
111
|
+
...props,
|
|
112
|
+
ref: controlRef,
|
|
113
|
+
id,
|
|
114
|
+
tagName: as,
|
|
115
|
+
collapsible,
|
|
116
|
+
defaultSize,
|
|
117
|
+
maxSize,
|
|
118
|
+
minSize,
|
|
119
|
+
collapsedSize,
|
|
120
|
+
onCollapse,
|
|
121
|
+
onExpand,
|
|
122
|
+
onResize,
|
|
123
|
+
order,
|
|
124
|
+
...rest
|
|
125
|
+
};
|
|
126
|
+
},
|
|
127
|
+
[
|
|
128
|
+
id,
|
|
129
|
+
controlRef,
|
|
130
|
+
itemProps,
|
|
131
|
+
collapsedSize,
|
|
132
|
+
collapsible,
|
|
133
|
+
defaultSize,
|
|
134
|
+
maxSize,
|
|
135
|
+
minSize,
|
|
136
|
+
onCollapse,
|
|
137
|
+
onExpand,
|
|
138
|
+
onResize,
|
|
139
|
+
order
|
|
140
|
+
]
|
|
141
|
+
);
|
|
142
|
+
const getItemProps = (0, import_react.useCallback)(
|
|
143
|
+
(props = {}, ref2 = null) => ({ ...props, ref: ref2, ...innerProps }),
|
|
144
|
+
[innerProps]
|
|
145
|
+
);
|
|
146
|
+
(0, import_react.useEffect)(() => {
|
|
147
|
+
if (!id)
|
|
148
|
+
return;
|
|
149
|
+
const el = (0, import_react_resizable_panels.getPanelElement)(id);
|
|
150
|
+
if (ref)
|
|
151
|
+
ref.current = el;
|
|
152
|
+
}, [ref, id]);
|
|
153
|
+
return {
|
|
154
|
+
getPanelProps,
|
|
155
|
+
getItemProps
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
var useResizableTrigger = ({
|
|
159
|
+
id,
|
|
160
|
+
ref,
|
|
161
|
+
as,
|
|
162
|
+
disabled,
|
|
163
|
+
isDisabled,
|
|
164
|
+
onDragging,
|
|
165
|
+
...rest
|
|
166
|
+
}) => {
|
|
167
|
+
id != null ? id : id = (0, import_react.useId)();
|
|
168
|
+
const { isDisabled: isGroupDisabled } = useResizableContext();
|
|
169
|
+
const [isActive, setIsActive] = (0, import_react.useState)(false);
|
|
170
|
+
const trulyDisabled = disabled || isDisabled || isGroupDisabled;
|
|
171
|
+
const getTriggerProps = (0, import_react.useCallback)(
|
|
172
|
+
(props = {}) => ({
|
|
173
|
+
...props,
|
|
174
|
+
id,
|
|
175
|
+
tagName: as,
|
|
176
|
+
disabled: trulyDisabled,
|
|
177
|
+
onDragging: (0, import_utils.handlerAll)(onDragging, (isActive2) => setIsActive(isActive2)),
|
|
178
|
+
...rest,
|
|
179
|
+
"data-active": (0, import_utils.dataAttr)(isActive),
|
|
180
|
+
style: {
|
|
181
|
+
...props.style,
|
|
182
|
+
...rest.style,
|
|
183
|
+
...trulyDisabled ? { cursor: "default" } : {}
|
|
184
|
+
}
|
|
185
|
+
}),
|
|
186
|
+
[id, as, trulyDisabled, onDragging, rest, isActive]
|
|
187
|
+
);
|
|
188
|
+
const getIconProps = (0, import_react.useCallback)(
|
|
189
|
+
(props = {}, ref2 = null) => ({
|
|
190
|
+
...props,
|
|
191
|
+
ref: ref2,
|
|
192
|
+
"data-active": (0, import_utils.dataAttr)(isActive)
|
|
193
|
+
}),
|
|
194
|
+
[isActive]
|
|
195
|
+
);
|
|
196
|
+
(0, import_react.useEffect)(() => {
|
|
197
|
+
if (!id)
|
|
198
|
+
return;
|
|
199
|
+
const el = (0, import_react_resizable_panels.getResizeHandleElement)(id);
|
|
200
|
+
if (ref)
|
|
201
|
+
ref.current = el;
|
|
202
|
+
}, [ref, id]);
|
|
203
|
+
return {
|
|
204
|
+
getTriggerProps,
|
|
205
|
+
getIconProps
|
|
206
|
+
};
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
// src/resizable.tsx
|
|
210
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
211
|
+
var Resizable = (0, import_core.forwardRef)(
|
|
212
|
+
({ direction = "horizontal", ...props }, ref) => {
|
|
213
|
+
const [styles, mergedProps] = (0, import_core.useMultiComponentStyle)("Resizable", {
|
|
214
|
+
direction,
|
|
215
|
+
...props
|
|
216
|
+
});
|
|
217
|
+
const { className, children, containerRef, ...computedProps } = (0, import_core.omitThemeProps)(mergedProps);
|
|
218
|
+
const { getContainerProps, getGroupProps, ...rest } = useResizable({
|
|
219
|
+
ref,
|
|
220
|
+
...computedProps
|
|
221
|
+
});
|
|
222
|
+
const css = { w: "full", h: "full", ...styles.container };
|
|
223
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ResizableProvider, { value: { styles, ...rest }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
224
|
+
import_core.ui.div,
|
|
225
|
+
{
|
|
226
|
+
className: (0, import_utils2.cx)("ui-resizable", className),
|
|
227
|
+
__css: css,
|
|
228
|
+
...getContainerProps({}, containerRef),
|
|
229
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_resizable_panels2.PanelGroup, { ...getGroupProps(), children })
|
|
230
|
+
}
|
|
231
|
+
) });
|
|
232
|
+
}
|
|
233
|
+
);
|
|
234
|
+
|
|
235
|
+
// src/resizable-item.tsx
|
|
236
|
+
var import_core2 = require("@yamada-ui/core");
|
|
237
|
+
var import_utils3 = require("@yamada-ui/utils");
|
|
238
|
+
var import_react_resizable_panels3 = require("react-resizable-panels");
|
|
239
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
240
|
+
var ResizableItem = (0, import_core2.forwardRef)(
|
|
241
|
+
({ className, children, innerRef, ...rest }, ref) => {
|
|
242
|
+
const { styles } = useResizableContext();
|
|
243
|
+
const { getPanelProps, getItemProps } = useResizableItem({
|
|
244
|
+
ref,
|
|
245
|
+
...rest
|
|
246
|
+
});
|
|
247
|
+
const css = { boxSize: "full", ...styles.item };
|
|
248
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_resizable_panels3.Panel, { ...getPanelProps(), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
249
|
+
import_core2.ui.div,
|
|
250
|
+
{
|
|
251
|
+
className: (0, import_utils3.cx)("ui-resizable__item", className),
|
|
252
|
+
__css: css,
|
|
253
|
+
...getItemProps({}, innerRef),
|
|
254
|
+
children
|
|
255
|
+
}
|
|
256
|
+
) });
|
|
257
|
+
}
|
|
258
|
+
);
|
|
259
|
+
|
|
260
|
+
// src/resizable-trigger.tsx
|
|
261
|
+
var import_core3 = require("@yamada-ui/core");
|
|
262
|
+
var import_icon = require("@yamada-ui/icon");
|
|
263
|
+
var import_utils4 = require("@yamada-ui/utils");
|
|
264
|
+
var import_react_resizable_panels4 = require("react-resizable-panels");
|
|
265
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
266
|
+
var ResizableTrigger = (0, import_core3.forwardRef)(
|
|
267
|
+
({ className, icon, children, iconProps, ...rest }, ref) => {
|
|
268
|
+
const { styles } = useResizableContext();
|
|
269
|
+
const { getTriggerProps, getIconProps } = useResizableTrigger({
|
|
270
|
+
ref,
|
|
271
|
+
...rest
|
|
272
|
+
});
|
|
273
|
+
const css = { position: "relative", ...styles.trigger };
|
|
274
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
275
|
+
import_core3.ui.div,
|
|
276
|
+
{
|
|
277
|
+
as: import_react_resizable_panels4.PanelResizeHandle,
|
|
278
|
+
className: (0, import_utils4.cx)("ui-resizable__trigger", className),
|
|
279
|
+
__css: css,
|
|
280
|
+
...getTriggerProps(),
|
|
281
|
+
children: [
|
|
282
|
+
icon ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
283
|
+
import_core3.ui.div,
|
|
284
|
+
{
|
|
285
|
+
className: "ui-resizable__trigger__icon",
|
|
286
|
+
__css: {
|
|
287
|
+
position: "absolute",
|
|
288
|
+
top: "50%",
|
|
289
|
+
left: "50%",
|
|
290
|
+
transform: "auto",
|
|
291
|
+
translateY: "-50%",
|
|
292
|
+
translateX: "-50%",
|
|
293
|
+
display: "flex",
|
|
294
|
+
justifyContent: "center",
|
|
295
|
+
alignItems: "center",
|
|
296
|
+
...styles.icon
|
|
297
|
+
},
|
|
298
|
+
...getIconProps(iconProps),
|
|
299
|
+
children: icon
|
|
300
|
+
}
|
|
301
|
+
) : null,
|
|
302
|
+
children
|
|
303
|
+
]
|
|
304
|
+
}
|
|
305
|
+
);
|
|
306
|
+
}
|
|
307
|
+
);
|
|
308
|
+
var ResizableTriggerIcon = (rest) => {
|
|
309
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_icon.Icon, { viewBox: "0 0 23 39", w: "2", h: "4", ...rest, children: [
|
|
310
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
311
|
+
"path",
|
|
312
|
+
{
|
|
313
|
+
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",
|
|
314
|
+
fill: "currentColor"
|
|
315
|
+
}
|
|
316
|
+
),
|
|
317
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
318
|
+
"path",
|
|
319
|
+
{
|
|
320
|
+
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",
|
|
321
|
+
fill: "currentColor"
|
|
322
|
+
}
|
|
323
|
+
),
|
|
324
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
325
|
+
"path",
|
|
326
|
+
{
|
|
327
|
+
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",
|
|
328
|
+
fill: "currentColor"
|
|
329
|
+
}
|
|
330
|
+
),
|
|
331
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
332
|
+
"path",
|
|
333
|
+
{
|
|
334
|
+
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",
|
|
335
|
+
fill: "currentColor"
|
|
336
|
+
}
|
|
337
|
+
),
|
|
338
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
339
|
+
"path",
|
|
340
|
+
{
|
|
341
|
+
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",
|
|
342
|
+
fill: "currentColor"
|
|
343
|
+
}
|
|
344
|
+
),
|
|
345
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
346
|
+
"path",
|
|
347
|
+
{
|
|
348
|
+
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",
|
|
349
|
+
fill: "currentColor"
|
|
350
|
+
}
|
|
351
|
+
)
|
|
352
|
+
] });
|
|
353
|
+
};
|
|
354
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
355
|
+
0 && (module.exports = {
|
|
356
|
+
Resizable,
|
|
357
|
+
ResizableItem,
|
|
358
|
+
ResizableTrigger,
|
|
359
|
+
ResizableTriggerIcon
|
|
360
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ResizableItem
|
|
3
|
+
} from "./chunk-PA5IMAOA.mjs";
|
|
4
|
+
import {
|
|
5
|
+
ResizableTrigger,
|
|
6
|
+
ResizableTriggerIcon
|
|
7
|
+
} from "./chunk-VSORTT66.mjs";
|
|
8
|
+
import {
|
|
9
|
+
Resizable
|
|
10
|
+
} from "./chunk-OSM43TND.mjs";
|
|
11
|
+
import "./chunk-DVZSQNDW.mjs";
|
|
12
|
+
export {
|
|
13
|
+
Resizable,
|
|
14
|
+
ResizableItem,
|
|
15
|
+
ResizableTrigger,
|
|
16
|
+
ResizableTriggerIcon
|
|
17
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as _yamada_ui_core from '@yamada-ui/core';
|
|
2
|
+
import { ForwardedRef } from 'react';
|
|
3
|
+
import { UseResizableItemProps } from './use-resizable.mjs';
|
|
4
|
+
import '@yamada-ui/utils';
|
|
5
|
+
import 'react-resizable-panels';
|
|
6
|
+
|
|
7
|
+
type ResizableItemOptions = {
|
|
8
|
+
/**
|
|
9
|
+
* Ref for resizable item inner element.
|
|
10
|
+
*/
|
|
11
|
+
innerRef?: ForwardedRef<HTMLDivElement>;
|
|
12
|
+
};
|
|
13
|
+
type ResizableItemProps = Omit<UseResizableItemProps, "ref"> & ResizableItemOptions;
|
|
14
|
+
declare const ResizableItem: _yamada_ui_core.Component<"div", ResizableItemProps>;
|
|
15
|
+
|
|
16
|
+
export { ResizableItem, type ResizableItemProps };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as _yamada_ui_core from '@yamada-ui/core';
|
|
2
|
+
import { ForwardedRef } from 'react';
|
|
3
|
+
import { UseResizableItemProps } from './use-resizable.js';
|
|
4
|
+
import '@yamada-ui/utils';
|
|
5
|
+
import 'react-resizable-panels';
|
|
6
|
+
|
|
7
|
+
type ResizableItemOptions = {
|
|
8
|
+
/**
|
|
9
|
+
* Ref for resizable item inner element.
|
|
10
|
+
*/
|
|
11
|
+
innerRef?: ForwardedRef<HTMLDivElement>;
|
|
12
|
+
};
|
|
13
|
+
type ResizableItemProps = Omit<UseResizableItemProps, "ref"> & ResizableItemOptions;
|
|
14
|
+
declare const ResizableItem: _yamada_ui_core.Component<"div", ResizableItemProps>;
|
|
15
|
+
|
|
16
|
+
export { ResizableItem, type ResizableItemProps };
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/resizable-item.tsx
|
|
21
|
+
var resizable_item_exports = {};
|
|
22
|
+
__export(resizable_item_exports, {
|
|
23
|
+
ResizableItem: () => ResizableItem
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(resizable_item_exports);
|
|
26
|
+
var import_core = require("@yamada-ui/core");
|
|
27
|
+
var import_utils2 = require("@yamada-ui/utils");
|
|
28
|
+
var import_react_resizable_panels2 = require("react-resizable-panels");
|
|
29
|
+
|
|
30
|
+
// src/use-resizable.ts
|
|
31
|
+
var import_utils = require("@yamada-ui/utils");
|
|
32
|
+
var import_react = require("react");
|
|
33
|
+
var import_react_resizable_panels = require("react-resizable-panels");
|
|
34
|
+
var [ResizableProvider, useResizableContext] = (0, import_utils.createContext)({
|
|
35
|
+
name: "ResizableContext",
|
|
36
|
+
errorMessage: `useResizableContext returned is 'undefined'. Seems you forgot to wrap the components in "<Resizable />"`
|
|
37
|
+
});
|
|
38
|
+
var useResizableItem = ({
|
|
39
|
+
id,
|
|
40
|
+
ref,
|
|
41
|
+
collapsedSize,
|
|
42
|
+
collapsible,
|
|
43
|
+
defaultSize,
|
|
44
|
+
maxSize,
|
|
45
|
+
minSize,
|
|
46
|
+
onCollapse,
|
|
47
|
+
onExpand,
|
|
48
|
+
onResize,
|
|
49
|
+
order,
|
|
50
|
+
controlRef,
|
|
51
|
+
itemProps,
|
|
52
|
+
...innerProps
|
|
53
|
+
}) => {
|
|
54
|
+
id != null ? id : id = (0, import_react.useId)();
|
|
55
|
+
const getPanelProps = (0, import_react.useCallback)(
|
|
56
|
+
(props = {}) => {
|
|
57
|
+
const { as, ...rest } = itemProps != null ? itemProps : {};
|
|
58
|
+
return {
|
|
59
|
+
...props,
|
|
60
|
+
ref: controlRef,
|
|
61
|
+
id,
|
|
62
|
+
tagName: as,
|
|
63
|
+
collapsible,
|
|
64
|
+
defaultSize,
|
|
65
|
+
maxSize,
|
|
66
|
+
minSize,
|
|
67
|
+
collapsedSize,
|
|
68
|
+
onCollapse,
|
|
69
|
+
onExpand,
|
|
70
|
+
onResize,
|
|
71
|
+
order,
|
|
72
|
+
...rest
|
|
73
|
+
};
|
|
74
|
+
},
|
|
75
|
+
[
|
|
76
|
+
id,
|
|
77
|
+
controlRef,
|
|
78
|
+
itemProps,
|
|
79
|
+
collapsedSize,
|
|
80
|
+
collapsible,
|
|
81
|
+
defaultSize,
|
|
82
|
+
maxSize,
|
|
83
|
+
minSize,
|
|
84
|
+
onCollapse,
|
|
85
|
+
onExpand,
|
|
86
|
+
onResize,
|
|
87
|
+
order
|
|
88
|
+
]
|
|
89
|
+
);
|
|
90
|
+
const getItemProps = (0, import_react.useCallback)(
|
|
91
|
+
(props = {}, ref2 = null) => ({ ...props, ref: ref2, ...innerProps }),
|
|
92
|
+
[innerProps]
|
|
93
|
+
);
|
|
94
|
+
(0, import_react.useEffect)(() => {
|
|
95
|
+
if (!id)
|
|
96
|
+
return;
|
|
97
|
+
const el = (0, import_react_resizable_panels.getPanelElement)(id);
|
|
98
|
+
if (ref)
|
|
99
|
+
ref.current = el;
|
|
100
|
+
}, [ref, id]);
|
|
101
|
+
return {
|
|
102
|
+
getPanelProps,
|
|
103
|
+
getItemProps
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
// src/resizable-item.tsx
|
|
108
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
109
|
+
var ResizableItem = (0, import_core.forwardRef)(
|
|
110
|
+
({ className, children, innerRef, ...rest }, ref) => {
|
|
111
|
+
const { styles } = useResizableContext();
|
|
112
|
+
const { getPanelProps, getItemProps } = useResizableItem({
|
|
113
|
+
ref,
|
|
114
|
+
...rest
|
|
115
|
+
});
|
|
116
|
+
const css = { boxSize: "full", ...styles.item };
|
|
117
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_resizable_panels2.Panel, { ...getPanelProps(), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
118
|
+
import_core.ui.div,
|
|
119
|
+
{
|
|
120
|
+
className: (0, import_utils2.cx)("ui-resizable__item", className),
|
|
121
|
+
__css: css,
|
|
122
|
+
...getItemProps({}, innerRef),
|
|
123
|
+
children
|
|
124
|
+
}
|
|
125
|
+
) });
|
|
126
|
+
}
|
|
127
|
+
);
|
|
128
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
129
|
+
0 && (module.exports = {
|
|
130
|
+
ResizableItem
|
|
131
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as _yamada_ui_core from '@yamada-ui/core';
|
|
2
|
+
import { HTMLUIProps } from '@yamada-ui/core';
|
|
3
|
+
import { IconProps } from '@yamada-ui/icon';
|
|
4
|
+
import { FC, ReactElement } from 'react';
|
|
5
|
+
import { UseResizableTriggerProps } from './use-resizable.mjs';
|
|
6
|
+
import '@yamada-ui/utils';
|
|
7
|
+
import 'react-resizable-panels';
|
|
8
|
+
|
|
9
|
+
type ResizableTriggerOptions = {
|
|
10
|
+
/**
|
|
11
|
+
* The resizable trigger icon to use.
|
|
12
|
+
*/
|
|
13
|
+
icon?: ReactElement;
|
|
14
|
+
/**
|
|
15
|
+
* Props for resizable trigger icon component.
|
|
16
|
+
*/
|
|
17
|
+
iconProps?: HTMLUIProps<"div">;
|
|
18
|
+
};
|
|
19
|
+
type ResizableTriggerProps = Omit<HTMLUIProps<"div">, "as"> & Omit<UseResizableTriggerProps, "ref"> & ResizableTriggerOptions;
|
|
20
|
+
declare const ResizableTrigger: _yamada_ui_core.Component<"div", ResizableTriggerProps>;
|
|
21
|
+
type ResizableTriggerIconProps = IconProps;
|
|
22
|
+
declare const ResizableTriggerIcon: FC<ResizableTriggerIconProps>;
|
|
23
|
+
|
|
24
|
+
export { ResizableTrigger, ResizableTriggerIcon, type ResizableTriggerIconProps, type ResizableTriggerProps };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as _yamada_ui_core from '@yamada-ui/core';
|
|
2
|
+
import { HTMLUIProps } from '@yamada-ui/core';
|
|
3
|
+
import { IconProps } from '@yamada-ui/icon';
|
|
4
|
+
import { FC, ReactElement } from 'react';
|
|
5
|
+
import { UseResizableTriggerProps } from './use-resizable.js';
|
|
6
|
+
import '@yamada-ui/utils';
|
|
7
|
+
import 'react-resizable-panels';
|
|
8
|
+
|
|
9
|
+
type ResizableTriggerOptions = {
|
|
10
|
+
/**
|
|
11
|
+
* The resizable trigger icon to use.
|
|
12
|
+
*/
|
|
13
|
+
icon?: ReactElement;
|
|
14
|
+
/**
|
|
15
|
+
* Props for resizable trigger icon component.
|
|
16
|
+
*/
|
|
17
|
+
iconProps?: HTMLUIProps<"div">;
|
|
18
|
+
};
|
|
19
|
+
type ResizableTriggerProps = Omit<HTMLUIProps<"div">, "as"> & Omit<UseResizableTriggerProps, "ref"> & ResizableTriggerOptions;
|
|
20
|
+
declare const ResizableTrigger: _yamada_ui_core.Component<"div", ResizableTriggerProps>;
|
|
21
|
+
type ResizableTriggerIconProps = IconProps;
|
|
22
|
+
declare const ResizableTriggerIcon: FC<ResizableTriggerIconProps>;
|
|
23
|
+
|
|
24
|
+
export { ResizableTrigger, ResizableTriggerIcon, type ResizableTriggerIconProps, type ResizableTriggerProps };
|