@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
|
@@ -0,0 +1,185 @@
|
|
|
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-trigger.tsx
|
|
21
|
+
var resizable_trigger_exports = {};
|
|
22
|
+
__export(resizable_trigger_exports, {
|
|
23
|
+
ResizableTrigger: () => ResizableTrigger,
|
|
24
|
+
ResizableTriggerIcon: () => ResizableTriggerIcon
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(resizable_trigger_exports);
|
|
27
|
+
var import_core = require("@yamada-ui/core");
|
|
28
|
+
var import_icon = require("@yamada-ui/icon");
|
|
29
|
+
var import_utils2 = require("@yamada-ui/utils");
|
|
30
|
+
var import_react_resizable_panels2 = require("react-resizable-panels");
|
|
31
|
+
|
|
32
|
+
// src/use-resizable.ts
|
|
33
|
+
var import_utils = require("@yamada-ui/utils");
|
|
34
|
+
var import_react = require("react");
|
|
35
|
+
var import_react_resizable_panels = require("react-resizable-panels");
|
|
36
|
+
var [ResizableProvider, useResizableContext] = (0, import_utils.createContext)({
|
|
37
|
+
name: "ResizableContext",
|
|
38
|
+
errorMessage: `useResizableContext returned is 'undefined'. Seems you forgot to wrap the components in "<Resizable />"`
|
|
39
|
+
});
|
|
40
|
+
var useResizableTrigger = ({
|
|
41
|
+
id,
|
|
42
|
+
ref,
|
|
43
|
+
as,
|
|
44
|
+
disabled,
|
|
45
|
+
isDisabled,
|
|
46
|
+
onDragging,
|
|
47
|
+
...rest
|
|
48
|
+
}) => {
|
|
49
|
+
id != null ? id : id = (0, import_react.useId)();
|
|
50
|
+
const { isDisabled: isGroupDisabled } = useResizableContext();
|
|
51
|
+
const [isActive, setIsActive] = (0, import_react.useState)(false);
|
|
52
|
+
const trulyDisabled = disabled || isDisabled || isGroupDisabled;
|
|
53
|
+
const getTriggerProps = (0, import_react.useCallback)(
|
|
54
|
+
(props = {}) => ({
|
|
55
|
+
...props,
|
|
56
|
+
id,
|
|
57
|
+
tagName: as,
|
|
58
|
+
disabled: trulyDisabled,
|
|
59
|
+
onDragging: (0, import_utils.handlerAll)(onDragging, (isActive2) => setIsActive(isActive2)),
|
|
60
|
+
...rest,
|
|
61
|
+
"data-active": (0, import_utils.dataAttr)(isActive),
|
|
62
|
+
style: {
|
|
63
|
+
...props.style,
|
|
64
|
+
...rest.style,
|
|
65
|
+
...trulyDisabled ? { cursor: "default" } : {}
|
|
66
|
+
}
|
|
67
|
+
}),
|
|
68
|
+
[id, as, trulyDisabled, onDragging, rest, isActive]
|
|
69
|
+
);
|
|
70
|
+
const getIconProps = (0, import_react.useCallback)(
|
|
71
|
+
(props = {}, ref2 = null) => ({
|
|
72
|
+
...props,
|
|
73
|
+
ref: ref2,
|
|
74
|
+
"data-active": (0, import_utils.dataAttr)(isActive)
|
|
75
|
+
}),
|
|
76
|
+
[isActive]
|
|
77
|
+
);
|
|
78
|
+
(0, import_react.useEffect)(() => {
|
|
79
|
+
if (!id)
|
|
80
|
+
return;
|
|
81
|
+
const el = (0, import_react_resizable_panels.getResizeHandleElement)(id);
|
|
82
|
+
if (ref)
|
|
83
|
+
ref.current = el;
|
|
84
|
+
}, [ref, id]);
|
|
85
|
+
return {
|
|
86
|
+
getTriggerProps,
|
|
87
|
+
getIconProps
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
// src/resizable-trigger.tsx
|
|
92
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
93
|
+
var ResizableTrigger = (0, import_core.forwardRef)(
|
|
94
|
+
({ className, icon, children, iconProps, ...rest }, ref) => {
|
|
95
|
+
const { styles } = useResizableContext();
|
|
96
|
+
const { getTriggerProps, getIconProps } = useResizableTrigger({
|
|
97
|
+
ref,
|
|
98
|
+
...rest
|
|
99
|
+
});
|
|
100
|
+
const css = { position: "relative", ...styles.trigger };
|
|
101
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
102
|
+
import_core.ui.div,
|
|
103
|
+
{
|
|
104
|
+
as: import_react_resizable_panels2.PanelResizeHandle,
|
|
105
|
+
className: (0, import_utils2.cx)("ui-resizable__trigger", className),
|
|
106
|
+
__css: css,
|
|
107
|
+
...getTriggerProps(),
|
|
108
|
+
children: [
|
|
109
|
+
icon ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
110
|
+
import_core.ui.div,
|
|
111
|
+
{
|
|
112
|
+
className: "ui-resizable__trigger__icon",
|
|
113
|
+
__css: {
|
|
114
|
+
position: "absolute",
|
|
115
|
+
top: "50%",
|
|
116
|
+
left: "50%",
|
|
117
|
+
transform: "auto",
|
|
118
|
+
translateY: "-50%",
|
|
119
|
+
translateX: "-50%",
|
|
120
|
+
display: "flex",
|
|
121
|
+
justifyContent: "center",
|
|
122
|
+
alignItems: "center",
|
|
123
|
+
...styles.icon
|
|
124
|
+
},
|
|
125
|
+
...getIconProps(iconProps),
|
|
126
|
+
children: icon
|
|
127
|
+
}
|
|
128
|
+
) : null,
|
|
129
|
+
children
|
|
130
|
+
]
|
|
131
|
+
}
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
);
|
|
135
|
+
var ResizableTriggerIcon = (rest) => {
|
|
136
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_icon.Icon, { viewBox: "0 0 23 39", w: "2", h: "4", ...rest, children: [
|
|
137
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
138
|
+
"path",
|
|
139
|
+
{
|
|
140
|
+
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",
|
|
141
|
+
fill: "currentColor"
|
|
142
|
+
}
|
|
143
|
+
),
|
|
144
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
145
|
+
"path",
|
|
146
|
+
{
|
|
147
|
+
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",
|
|
148
|
+
fill: "currentColor"
|
|
149
|
+
}
|
|
150
|
+
),
|
|
151
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
152
|
+
"path",
|
|
153
|
+
{
|
|
154
|
+
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",
|
|
155
|
+
fill: "currentColor"
|
|
156
|
+
}
|
|
157
|
+
),
|
|
158
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
159
|
+
"path",
|
|
160
|
+
{
|
|
161
|
+
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",
|
|
162
|
+
fill: "currentColor"
|
|
163
|
+
}
|
|
164
|
+
),
|
|
165
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
166
|
+
"path",
|
|
167
|
+
{
|
|
168
|
+
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",
|
|
169
|
+
fill: "currentColor"
|
|
170
|
+
}
|
|
171
|
+
),
|
|
172
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
173
|
+
"path",
|
|
174
|
+
{
|
|
175
|
+
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",
|
|
176
|
+
fill: "currentColor"
|
|
177
|
+
}
|
|
178
|
+
)
|
|
179
|
+
] });
|
|
180
|
+
};
|
|
181
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
182
|
+
0 && (module.exports = {
|
|
183
|
+
ResizableTrigger,
|
|
184
|
+
ResizableTriggerIcon
|
|
185
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as _yamada_ui_core from '@yamada-ui/core';
|
|
2
|
+
import { HTMLUIProps, ThemeProps } from '@yamada-ui/core';
|
|
3
|
+
import { ForwardedRef } from 'react';
|
|
4
|
+
import { UseResizableProps } from './use-resizable.mjs';
|
|
5
|
+
import '@yamada-ui/utils';
|
|
6
|
+
import 'react-resizable-panels';
|
|
7
|
+
|
|
8
|
+
type ResizableOptions = {
|
|
9
|
+
/**
|
|
10
|
+
* Ref for resizable container element.
|
|
11
|
+
*/
|
|
12
|
+
containerRef?: ForwardedRef<HTMLDivElement>;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* `Resizable` is accessible resizable panel groups and layouts with keyboard support.
|
|
16
|
+
*
|
|
17
|
+
* @see Docs https://yamada-ui.com/components/data-display/resizable
|
|
18
|
+
*/
|
|
19
|
+
type ResizableProps = Omit<HTMLUIProps<"div">, "direction"> & ThemeProps<"Resizable"> & Omit<UseResizableProps, "ref"> & ResizableOptions;
|
|
20
|
+
declare const Resizable: _yamada_ui_core.Component<"div", ResizableProps>;
|
|
21
|
+
|
|
22
|
+
export { Resizable, type ResizableProps };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as _yamada_ui_core from '@yamada-ui/core';
|
|
2
|
+
import { HTMLUIProps, ThemeProps } from '@yamada-ui/core';
|
|
3
|
+
import { ForwardedRef } from 'react';
|
|
4
|
+
import { UseResizableProps } from './use-resizable.js';
|
|
5
|
+
import '@yamada-ui/utils';
|
|
6
|
+
import 'react-resizable-panels';
|
|
7
|
+
|
|
8
|
+
type ResizableOptions = {
|
|
9
|
+
/**
|
|
10
|
+
* Ref for resizable container element.
|
|
11
|
+
*/
|
|
12
|
+
containerRef?: ForwardedRef<HTMLDivElement>;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* `Resizable` is accessible resizable panel groups and layouts with keyboard support.
|
|
16
|
+
*
|
|
17
|
+
* @see Docs https://yamada-ui.com/components/data-display/resizable
|
|
18
|
+
*/
|
|
19
|
+
type ResizableProps = Omit<HTMLUIProps<"div">, "direction"> & ThemeProps<"Resizable"> & Omit<UseResizableProps, "ref"> & ResizableOptions;
|
|
20
|
+
declare const Resizable: _yamada_ui_core.Component<"div", ResizableProps>;
|
|
21
|
+
|
|
22
|
+
export { Resizable, type ResizableProps };
|
|
@@ -0,0 +1,114 @@
|
|
|
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.tsx
|
|
21
|
+
var resizable_exports = {};
|
|
22
|
+
__export(resizable_exports, {
|
|
23
|
+
Resizable: () => Resizable
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(resizable_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 useResizable = ({
|
|
39
|
+
id,
|
|
40
|
+
direction = "horizontal",
|
|
41
|
+
storageKey,
|
|
42
|
+
keyboardStep,
|
|
43
|
+
isDisabled = false,
|
|
44
|
+
onLayout,
|
|
45
|
+
storage,
|
|
46
|
+
ref,
|
|
47
|
+
groupProps,
|
|
48
|
+
...rest
|
|
49
|
+
}) => {
|
|
50
|
+
id != null ? id : id = (0, import_react.useId)();
|
|
51
|
+
const getContainerProps = (0, import_react.useCallback)(
|
|
52
|
+
(props = {}, ref2 = null) => ({ ...props, ref: ref2, ...rest }),
|
|
53
|
+
[rest]
|
|
54
|
+
);
|
|
55
|
+
const getGroupProps = (0, import_react.useCallback)(
|
|
56
|
+
(props = {}) => {
|
|
57
|
+
const { as, ...rest2 } = groupProps != null ? groupProps : {};
|
|
58
|
+
return {
|
|
59
|
+
...props,
|
|
60
|
+
id,
|
|
61
|
+
direction,
|
|
62
|
+
tagName: as,
|
|
63
|
+
autoSaveId: storageKey,
|
|
64
|
+
keyboardResizeBy: keyboardStep,
|
|
65
|
+
onLayout,
|
|
66
|
+
storage,
|
|
67
|
+
...rest2
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
[id, direction, groupProps, storageKey, keyboardStep, onLayout, storage]
|
|
71
|
+
);
|
|
72
|
+
(0, import_react.useEffect)(() => {
|
|
73
|
+
if (!id)
|
|
74
|
+
return;
|
|
75
|
+
const el = (0, import_react_resizable_panels.getPanelGroupElement)(id);
|
|
76
|
+
if (ref)
|
|
77
|
+
ref.current = el;
|
|
78
|
+
}, [ref, id]);
|
|
79
|
+
return {
|
|
80
|
+
isDisabled,
|
|
81
|
+
getContainerProps,
|
|
82
|
+
getGroupProps
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// src/resizable.tsx
|
|
87
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
88
|
+
var Resizable = (0, import_core.forwardRef)(
|
|
89
|
+
({ direction = "horizontal", ...props }, ref) => {
|
|
90
|
+
const [styles, mergedProps] = (0, import_core.useMultiComponentStyle)("Resizable", {
|
|
91
|
+
direction,
|
|
92
|
+
...props
|
|
93
|
+
});
|
|
94
|
+
const { className, children, containerRef, ...computedProps } = (0, import_core.omitThemeProps)(mergedProps);
|
|
95
|
+
const { getContainerProps, getGroupProps, ...rest } = useResizable({
|
|
96
|
+
ref,
|
|
97
|
+
...computedProps
|
|
98
|
+
});
|
|
99
|
+
const css = { w: "full", h: "full", ...styles.container };
|
|
100
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ResizableProvider, { value: { styles, ...rest }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
101
|
+
import_core.ui.div,
|
|
102
|
+
{
|
|
103
|
+
className: (0, import_utils2.cx)("ui-resizable", className),
|
|
104
|
+
__css: css,
|
|
105
|
+
...getContainerProps({}, containerRef),
|
|
106
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_resizable_panels2.PanelGroup, { ...getGroupProps(), children })
|
|
107
|
+
}
|
|
108
|
+
) });
|
|
109
|
+
}
|
|
110
|
+
);
|
|
111
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
112
|
+
0 && (module.exports = {
|
|
113
|
+
Resizable
|
|
114
|
+
});
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ForwardedRef, RefObject } from 'react';
|
|
3
|
+
import { HTMLUIProps, UIPropGetter, CSSUIObject } from '@yamada-ui/core';
|
|
4
|
+
import { PropGetter } from '@yamada-ui/utils';
|
|
5
|
+
import { PanelGroupStorage, ImperativePanelHandle, PanelGroupOnLayout, PanelGroupProps, PanelProps, PanelResizeHandleProps } from 'react-resizable-panels';
|
|
6
|
+
|
|
7
|
+
type GroupPropGetter = (props?: Partial<PanelGroupProps>) => PanelGroupProps;
|
|
8
|
+
type ItemPropGetter = (props?: PanelProps) => PanelProps;
|
|
9
|
+
type TriggerPropGetter = (props?: PanelResizeHandleProps) => PanelResizeHandleProps;
|
|
10
|
+
type As = {
|
|
11
|
+
as?: keyof HTMLElementTagNameMap;
|
|
12
|
+
};
|
|
13
|
+
type ResizableGroupProps = Omit<PanelGroupProps, "id" | "tagName" | "children"> & As;
|
|
14
|
+
type ResizableItemProps = Omit<PanelProps, "id" | "tagName" | "children"> & As;
|
|
15
|
+
type ResizableTriggerProps = Omit<PanelResizeHandleProps, "id" | "tagName" | "children"> & As;
|
|
16
|
+
type ResizableStorage = PanelGroupStorage;
|
|
17
|
+
type ResizableItemControl = ImperativePanelHandle;
|
|
18
|
+
type ResizableContext = {
|
|
19
|
+
isDisabled: boolean;
|
|
20
|
+
styles: Record<string, CSSUIObject>;
|
|
21
|
+
};
|
|
22
|
+
declare const ResizableProvider: react.Provider<ResizableContext>;
|
|
23
|
+
declare const useResizableContext: () => ResizableContext;
|
|
24
|
+
type UseResizableProps = {
|
|
25
|
+
/**
|
|
26
|
+
* id assigned to resizable element.
|
|
27
|
+
*/
|
|
28
|
+
id?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Ref for resizable element.
|
|
31
|
+
*/
|
|
32
|
+
ref?: ForwardedRef<HTMLElement>;
|
|
33
|
+
/**
|
|
34
|
+
* The direction of the resizable.
|
|
35
|
+
*
|
|
36
|
+
* @default "horizontal"
|
|
37
|
+
*/
|
|
38
|
+
direction?: "horizontal" | "vertical";
|
|
39
|
+
/**
|
|
40
|
+
* If `true`, the resizable trigger will be disabled.
|
|
41
|
+
*/
|
|
42
|
+
isDisabled?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Unit to resize by keyboard operation.
|
|
45
|
+
*
|
|
46
|
+
* @default 10
|
|
47
|
+
*/
|
|
48
|
+
keyboardStep?: number;
|
|
49
|
+
/**
|
|
50
|
+
* Key of value saved in storage.
|
|
51
|
+
* By default, it is saved to `local storage`.
|
|
52
|
+
*/
|
|
53
|
+
storageKey?: string;
|
|
54
|
+
/**
|
|
55
|
+
* A callback that gets and sets a value in custom storage.
|
|
56
|
+
*/
|
|
57
|
+
storage?: PanelGroupStorage;
|
|
58
|
+
/**
|
|
59
|
+
* The callback invoked when resizable items are resized.
|
|
60
|
+
*/
|
|
61
|
+
onLayout?: PanelGroupOnLayout;
|
|
62
|
+
/**
|
|
63
|
+
* Props for resizable component.
|
|
64
|
+
*/
|
|
65
|
+
groupProps?: ResizableGroupProps;
|
|
66
|
+
};
|
|
67
|
+
declare const useResizable: ({ id, direction, storageKey, keyboardStep, isDisabled, onLayout, storage, ref, groupProps, ...rest }: UseResizableProps) => {
|
|
68
|
+
isDisabled: boolean;
|
|
69
|
+
getContainerProps: PropGetter;
|
|
70
|
+
getGroupProps: GroupPropGetter;
|
|
71
|
+
};
|
|
72
|
+
type UseResizableReturn = ReturnType<typeof useResizable>;
|
|
73
|
+
type UseResizableItemOptions = {
|
|
74
|
+
/**
|
|
75
|
+
* id assigned to resizable item element.
|
|
76
|
+
*/
|
|
77
|
+
id?: string;
|
|
78
|
+
/**
|
|
79
|
+
* Ref for resizable item element.
|
|
80
|
+
*/
|
|
81
|
+
ref?: ForwardedRef<HTMLElement>;
|
|
82
|
+
/**
|
|
83
|
+
* If `true`, the resizable item can be collapsed.
|
|
84
|
+
*
|
|
85
|
+
* @default false
|
|
86
|
+
*/
|
|
87
|
+
collapsible?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* The collapsed size of the resizable item.
|
|
90
|
+
*/
|
|
91
|
+
collapsedSize?: number;
|
|
92
|
+
/**
|
|
93
|
+
* The initial size of the resizable item.
|
|
94
|
+
*/
|
|
95
|
+
defaultSize?: number;
|
|
96
|
+
/**
|
|
97
|
+
* The minimum allowed value of the resizable item.
|
|
98
|
+
*/
|
|
99
|
+
minSize?: number;
|
|
100
|
+
/**
|
|
101
|
+
* The maximum allowed value of the resizable item.
|
|
102
|
+
*/
|
|
103
|
+
maxSize?: number;
|
|
104
|
+
/**
|
|
105
|
+
* The callback invoked when resizable item are collapsed.
|
|
106
|
+
*/
|
|
107
|
+
onCollapse?: () => void;
|
|
108
|
+
/**
|
|
109
|
+
* The callback invoked when resizable item are expanded.
|
|
110
|
+
*/
|
|
111
|
+
onExpand?: () => void;
|
|
112
|
+
/**
|
|
113
|
+
* The callback invoked when resizable item are resized.
|
|
114
|
+
*/
|
|
115
|
+
onResize?: (size: number, prevSize: number | undefined) => void;
|
|
116
|
+
/**
|
|
117
|
+
* Order for the resizable item.
|
|
118
|
+
*/
|
|
119
|
+
order?: number;
|
|
120
|
+
/**
|
|
121
|
+
* Ref of the resizable item callback.
|
|
122
|
+
*/
|
|
123
|
+
controlRef?: RefObject<ResizableItemControl>;
|
|
124
|
+
/**
|
|
125
|
+
* Props for resizable item component.
|
|
126
|
+
*/
|
|
127
|
+
itemProps?: ResizableItemProps;
|
|
128
|
+
};
|
|
129
|
+
type UseResizableItemProps = Omit<HTMLUIProps<"div">, keyof UseResizableItemOptions> & UseResizableItemOptions;
|
|
130
|
+
declare const useResizableItem: ({ id, ref, collapsedSize, collapsible, defaultSize, maxSize, minSize, onCollapse, onExpand, onResize, order, controlRef, itemProps, ...innerProps }: UseResizableItemProps) => {
|
|
131
|
+
getPanelProps: ItemPropGetter;
|
|
132
|
+
getItemProps: UIPropGetter;
|
|
133
|
+
};
|
|
134
|
+
type UseResizableItemReturn = ReturnType<typeof useResizableItem>;
|
|
135
|
+
type UseResizableTriggerOptions = {
|
|
136
|
+
/**
|
|
137
|
+
* id assigned to resizable trigger element.
|
|
138
|
+
*/
|
|
139
|
+
id?: string;
|
|
140
|
+
/**
|
|
141
|
+
* Ref for resizable trigger element.
|
|
142
|
+
*/
|
|
143
|
+
ref?: ForwardedRef<HTMLElement>;
|
|
144
|
+
/**
|
|
145
|
+
* If `true`, the resizable trigger will be disabled.
|
|
146
|
+
*
|
|
147
|
+
* @default false
|
|
148
|
+
*/
|
|
149
|
+
isDisabled?: boolean;
|
|
150
|
+
/**
|
|
151
|
+
* The callback invoked when resizable trigger are dragged.
|
|
152
|
+
*/
|
|
153
|
+
onDragging?: (isDragging: boolean) => void;
|
|
154
|
+
};
|
|
155
|
+
type UseResizableTriggerProps = HTMLUIProps<"div"> & ResizableTriggerProps & UseResizableTriggerOptions;
|
|
156
|
+
declare const useResizableTrigger: ({ id, ref, as, disabled, isDisabled, onDragging, ...rest }: UseResizableTriggerProps) => {
|
|
157
|
+
getTriggerProps: TriggerPropGetter;
|
|
158
|
+
getIconProps: UIPropGetter;
|
|
159
|
+
};
|
|
160
|
+
type UseResizableTriggerReturn = ReturnType<typeof useResizableTrigger>;
|
|
161
|
+
|
|
162
|
+
export { type ResizableItemControl, ResizableProvider, type ResizableStorage, type UseResizableItemProps, type UseResizableItemReturn, type UseResizableProps, type UseResizableReturn, type UseResizableTriggerProps, type UseResizableTriggerReturn, useResizable, useResizableContext, useResizableItem, useResizableTrigger };
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ForwardedRef, RefObject } from 'react';
|
|
3
|
+
import { HTMLUIProps, UIPropGetter, CSSUIObject } from '@yamada-ui/core';
|
|
4
|
+
import { PropGetter } from '@yamada-ui/utils';
|
|
5
|
+
import { PanelGroupStorage, ImperativePanelHandle, PanelGroupOnLayout, PanelGroupProps, PanelProps, PanelResizeHandleProps } from 'react-resizable-panels';
|
|
6
|
+
|
|
7
|
+
type GroupPropGetter = (props?: Partial<PanelGroupProps>) => PanelGroupProps;
|
|
8
|
+
type ItemPropGetter = (props?: PanelProps) => PanelProps;
|
|
9
|
+
type TriggerPropGetter = (props?: PanelResizeHandleProps) => PanelResizeHandleProps;
|
|
10
|
+
type As = {
|
|
11
|
+
as?: keyof HTMLElementTagNameMap;
|
|
12
|
+
};
|
|
13
|
+
type ResizableGroupProps = Omit<PanelGroupProps, "id" | "tagName" | "children"> & As;
|
|
14
|
+
type ResizableItemProps = Omit<PanelProps, "id" | "tagName" | "children"> & As;
|
|
15
|
+
type ResizableTriggerProps = Omit<PanelResizeHandleProps, "id" | "tagName" | "children"> & As;
|
|
16
|
+
type ResizableStorage = PanelGroupStorage;
|
|
17
|
+
type ResizableItemControl = ImperativePanelHandle;
|
|
18
|
+
type ResizableContext = {
|
|
19
|
+
isDisabled: boolean;
|
|
20
|
+
styles: Record<string, CSSUIObject>;
|
|
21
|
+
};
|
|
22
|
+
declare const ResizableProvider: react.Provider<ResizableContext>;
|
|
23
|
+
declare const useResizableContext: () => ResizableContext;
|
|
24
|
+
type UseResizableProps = {
|
|
25
|
+
/**
|
|
26
|
+
* id assigned to resizable element.
|
|
27
|
+
*/
|
|
28
|
+
id?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Ref for resizable element.
|
|
31
|
+
*/
|
|
32
|
+
ref?: ForwardedRef<HTMLElement>;
|
|
33
|
+
/**
|
|
34
|
+
* The direction of the resizable.
|
|
35
|
+
*
|
|
36
|
+
* @default "horizontal"
|
|
37
|
+
*/
|
|
38
|
+
direction?: "horizontal" | "vertical";
|
|
39
|
+
/**
|
|
40
|
+
* If `true`, the resizable trigger will be disabled.
|
|
41
|
+
*/
|
|
42
|
+
isDisabled?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Unit to resize by keyboard operation.
|
|
45
|
+
*
|
|
46
|
+
* @default 10
|
|
47
|
+
*/
|
|
48
|
+
keyboardStep?: number;
|
|
49
|
+
/**
|
|
50
|
+
* Key of value saved in storage.
|
|
51
|
+
* By default, it is saved to `local storage`.
|
|
52
|
+
*/
|
|
53
|
+
storageKey?: string;
|
|
54
|
+
/**
|
|
55
|
+
* A callback that gets and sets a value in custom storage.
|
|
56
|
+
*/
|
|
57
|
+
storage?: PanelGroupStorage;
|
|
58
|
+
/**
|
|
59
|
+
* The callback invoked when resizable items are resized.
|
|
60
|
+
*/
|
|
61
|
+
onLayout?: PanelGroupOnLayout;
|
|
62
|
+
/**
|
|
63
|
+
* Props for resizable component.
|
|
64
|
+
*/
|
|
65
|
+
groupProps?: ResizableGroupProps;
|
|
66
|
+
};
|
|
67
|
+
declare const useResizable: ({ id, direction, storageKey, keyboardStep, isDisabled, onLayout, storage, ref, groupProps, ...rest }: UseResizableProps) => {
|
|
68
|
+
isDisabled: boolean;
|
|
69
|
+
getContainerProps: PropGetter;
|
|
70
|
+
getGroupProps: GroupPropGetter;
|
|
71
|
+
};
|
|
72
|
+
type UseResizableReturn = ReturnType<typeof useResizable>;
|
|
73
|
+
type UseResizableItemOptions = {
|
|
74
|
+
/**
|
|
75
|
+
* id assigned to resizable item element.
|
|
76
|
+
*/
|
|
77
|
+
id?: string;
|
|
78
|
+
/**
|
|
79
|
+
* Ref for resizable item element.
|
|
80
|
+
*/
|
|
81
|
+
ref?: ForwardedRef<HTMLElement>;
|
|
82
|
+
/**
|
|
83
|
+
* If `true`, the resizable item can be collapsed.
|
|
84
|
+
*
|
|
85
|
+
* @default false
|
|
86
|
+
*/
|
|
87
|
+
collapsible?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* The collapsed size of the resizable item.
|
|
90
|
+
*/
|
|
91
|
+
collapsedSize?: number;
|
|
92
|
+
/**
|
|
93
|
+
* The initial size of the resizable item.
|
|
94
|
+
*/
|
|
95
|
+
defaultSize?: number;
|
|
96
|
+
/**
|
|
97
|
+
* The minimum allowed value of the resizable item.
|
|
98
|
+
*/
|
|
99
|
+
minSize?: number;
|
|
100
|
+
/**
|
|
101
|
+
* The maximum allowed value of the resizable item.
|
|
102
|
+
*/
|
|
103
|
+
maxSize?: number;
|
|
104
|
+
/**
|
|
105
|
+
* The callback invoked when resizable item are collapsed.
|
|
106
|
+
*/
|
|
107
|
+
onCollapse?: () => void;
|
|
108
|
+
/**
|
|
109
|
+
* The callback invoked when resizable item are expanded.
|
|
110
|
+
*/
|
|
111
|
+
onExpand?: () => void;
|
|
112
|
+
/**
|
|
113
|
+
* The callback invoked when resizable item are resized.
|
|
114
|
+
*/
|
|
115
|
+
onResize?: (size: number, prevSize: number | undefined) => void;
|
|
116
|
+
/**
|
|
117
|
+
* Order for the resizable item.
|
|
118
|
+
*/
|
|
119
|
+
order?: number;
|
|
120
|
+
/**
|
|
121
|
+
* Ref of the resizable item callback.
|
|
122
|
+
*/
|
|
123
|
+
controlRef?: RefObject<ResizableItemControl>;
|
|
124
|
+
/**
|
|
125
|
+
* Props for resizable item component.
|
|
126
|
+
*/
|
|
127
|
+
itemProps?: ResizableItemProps;
|
|
128
|
+
};
|
|
129
|
+
type UseResizableItemProps = Omit<HTMLUIProps<"div">, keyof UseResizableItemOptions> & UseResizableItemOptions;
|
|
130
|
+
declare const useResizableItem: ({ id, ref, collapsedSize, collapsible, defaultSize, maxSize, minSize, onCollapse, onExpand, onResize, order, controlRef, itemProps, ...innerProps }: UseResizableItemProps) => {
|
|
131
|
+
getPanelProps: ItemPropGetter;
|
|
132
|
+
getItemProps: UIPropGetter;
|
|
133
|
+
};
|
|
134
|
+
type UseResizableItemReturn = ReturnType<typeof useResizableItem>;
|
|
135
|
+
type UseResizableTriggerOptions = {
|
|
136
|
+
/**
|
|
137
|
+
* id assigned to resizable trigger element.
|
|
138
|
+
*/
|
|
139
|
+
id?: string;
|
|
140
|
+
/**
|
|
141
|
+
* Ref for resizable trigger element.
|
|
142
|
+
*/
|
|
143
|
+
ref?: ForwardedRef<HTMLElement>;
|
|
144
|
+
/**
|
|
145
|
+
* If `true`, the resizable trigger will be disabled.
|
|
146
|
+
*
|
|
147
|
+
* @default false
|
|
148
|
+
*/
|
|
149
|
+
isDisabled?: boolean;
|
|
150
|
+
/**
|
|
151
|
+
* The callback invoked when resizable trigger are dragged.
|
|
152
|
+
*/
|
|
153
|
+
onDragging?: (isDragging: boolean) => void;
|
|
154
|
+
};
|
|
155
|
+
type UseResizableTriggerProps = HTMLUIProps<"div"> & ResizableTriggerProps & UseResizableTriggerOptions;
|
|
156
|
+
declare const useResizableTrigger: ({ id, ref, as, disabled, isDisabled, onDragging, ...rest }: UseResizableTriggerProps) => {
|
|
157
|
+
getTriggerProps: TriggerPropGetter;
|
|
158
|
+
getIconProps: UIPropGetter;
|
|
159
|
+
};
|
|
160
|
+
type UseResizableTriggerReturn = ReturnType<typeof useResizableTrigger>;
|
|
161
|
+
|
|
162
|
+
export { type ResizableItemControl, ResizableProvider, type ResizableStorage, type UseResizableItemProps, type UseResizableItemReturn, type UseResizableProps, type UseResizableReturn, type UseResizableTriggerProps, type UseResizableTriggerReturn, useResizable, useResizableContext, useResizableItem, useResizableTrigger };
|