@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.
@@ -0,0 +1,209 @@
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/use-resizable.ts
21
+ var use_resizable_exports = {};
22
+ __export(use_resizable_exports, {
23
+ ResizableProvider: () => ResizableProvider,
24
+ useResizable: () => useResizable,
25
+ useResizableContext: () => useResizableContext,
26
+ useResizableItem: () => useResizableItem,
27
+ useResizableTrigger: () => useResizableTrigger
28
+ });
29
+ module.exports = __toCommonJS(use_resizable_exports);
30
+ var import_utils = require("@yamada-ui/utils");
31
+ var import_react = require("react");
32
+ var import_react_resizable_panels = require("react-resizable-panels");
33
+ var [ResizableProvider, useResizableContext] = (0, import_utils.createContext)({
34
+ name: "ResizableContext",
35
+ errorMessage: `useResizableContext returned is 'undefined'. Seems you forgot to wrap the components in "<Resizable />"`
36
+ });
37
+ var useResizable = ({
38
+ id,
39
+ direction = "horizontal",
40
+ storageKey,
41
+ keyboardStep,
42
+ isDisabled = false,
43
+ onLayout,
44
+ storage,
45
+ ref,
46
+ groupProps,
47
+ ...rest
48
+ }) => {
49
+ id != null ? id : id = (0, import_react.useId)();
50
+ const getContainerProps = (0, import_react.useCallback)(
51
+ (props = {}, ref2 = null) => ({ ...props, ref: ref2, ...rest }),
52
+ [rest]
53
+ );
54
+ const getGroupProps = (0, import_react.useCallback)(
55
+ (props = {}) => {
56
+ const { as, ...rest2 } = groupProps != null ? groupProps : {};
57
+ return {
58
+ ...props,
59
+ id,
60
+ direction,
61
+ tagName: as,
62
+ autoSaveId: storageKey,
63
+ keyboardResizeBy: keyboardStep,
64
+ onLayout,
65
+ storage,
66
+ ...rest2
67
+ };
68
+ },
69
+ [id, direction, groupProps, storageKey, keyboardStep, onLayout, storage]
70
+ );
71
+ (0, import_react.useEffect)(() => {
72
+ if (!id)
73
+ return;
74
+ const el = (0, import_react_resizable_panels.getPanelGroupElement)(id);
75
+ if (ref)
76
+ ref.current = el;
77
+ }, [ref, id]);
78
+ return {
79
+ isDisabled,
80
+ getContainerProps,
81
+ getGroupProps
82
+ };
83
+ };
84
+ var useResizableItem = ({
85
+ id,
86
+ ref,
87
+ collapsedSize,
88
+ collapsible,
89
+ defaultSize,
90
+ maxSize,
91
+ minSize,
92
+ onCollapse,
93
+ onExpand,
94
+ onResize,
95
+ order,
96
+ controlRef,
97
+ itemProps,
98
+ ...innerProps
99
+ }) => {
100
+ id != null ? id : id = (0, import_react.useId)();
101
+ const getPanelProps = (0, import_react.useCallback)(
102
+ (props = {}) => {
103
+ const { as, ...rest } = itemProps != null ? itemProps : {};
104
+ return {
105
+ ...props,
106
+ ref: controlRef,
107
+ id,
108
+ tagName: as,
109
+ collapsible,
110
+ defaultSize,
111
+ maxSize,
112
+ minSize,
113
+ collapsedSize,
114
+ onCollapse,
115
+ onExpand,
116
+ onResize,
117
+ order,
118
+ ...rest
119
+ };
120
+ },
121
+ [
122
+ id,
123
+ controlRef,
124
+ itemProps,
125
+ collapsedSize,
126
+ collapsible,
127
+ defaultSize,
128
+ maxSize,
129
+ minSize,
130
+ onCollapse,
131
+ onExpand,
132
+ onResize,
133
+ order
134
+ ]
135
+ );
136
+ const getItemProps = (0, import_react.useCallback)(
137
+ (props = {}, ref2 = null) => ({ ...props, ref: ref2, ...innerProps }),
138
+ [innerProps]
139
+ );
140
+ (0, import_react.useEffect)(() => {
141
+ if (!id)
142
+ return;
143
+ const el = (0, import_react_resizable_panels.getPanelElement)(id);
144
+ if (ref)
145
+ ref.current = el;
146
+ }, [ref, id]);
147
+ return {
148
+ getPanelProps,
149
+ getItemProps
150
+ };
151
+ };
152
+ var useResizableTrigger = ({
153
+ id,
154
+ ref,
155
+ as,
156
+ disabled,
157
+ isDisabled,
158
+ onDragging,
159
+ ...rest
160
+ }) => {
161
+ id != null ? id : id = (0, import_react.useId)();
162
+ const { isDisabled: isGroupDisabled } = useResizableContext();
163
+ const [isActive, setIsActive] = (0, import_react.useState)(false);
164
+ const trulyDisabled = disabled || isDisabled || isGroupDisabled;
165
+ const getTriggerProps = (0, import_react.useCallback)(
166
+ (props = {}) => ({
167
+ ...props,
168
+ id,
169
+ tagName: as,
170
+ disabled: trulyDisabled,
171
+ onDragging: (0, import_utils.handlerAll)(onDragging, (isActive2) => setIsActive(isActive2)),
172
+ ...rest,
173
+ "data-active": (0, import_utils.dataAttr)(isActive),
174
+ style: {
175
+ ...props.style,
176
+ ...rest.style,
177
+ ...trulyDisabled ? { cursor: "default" } : {}
178
+ }
179
+ }),
180
+ [id, as, trulyDisabled, onDragging, rest, isActive]
181
+ );
182
+ const getIconProps = (0, import_react.useCallback)(
183
+ (props = {}, ref2 = null) => ({
184
+ ...props,
185
+ ref: ref2,
186
+ "data-active": (0, import_utils.dataAttr)(isActive)
187
+ }),
188
+ [isActive]
189
+ );
190
+ (0, import_react.useEffect)(() => {
191
+ if (!id)
192
+ return;
193
+ const el = (0, import_react_resizable_panels.getResizeHandleElement)(id);
194
+ if (ref)
195
+ ref.current = el;
196
+ }, [ref, id]);
197
+ return {
198
+ getTriggerProps,
199
+ getIconProps
200
+ };
201
+ };
202
+ // Annotate the CommonJS export names for ESM import in node:
203
+ 0 && (module.exports = {
204
+ ResizableProvider,
205
+ useResizable,
206
+ useResizableContext,
207
+ useResizableItem,
208
+ useResizableTrigger
209
+ });
@@ -0,0 +1,14 @@
1
+ import {
2
+ ResizableProvider,
3
+ useResizable,
4
+ useResizableContext,
5
+ useResizableItem,
6
+ useResizableTrigger
7
+ } from "./chunk-DVZSQNDW.mjs";
8
+ export {
9
+ ResizableProvider,
10
+ useResizable,
11
+ useResizableContext,
12
+ useResizableItem,
13
+ useResizableTrigger
14
+ };
package/package.json ADDED
@@ -0,0 +1,78 @@
1
+ {
2
+ "name": "@yamada-ui/resizable",
3
+ "version": "1.0.0",
4
+ "description": "Yamada UI resizable component",
5
+ "keywords": [
6
+ "yamada",
7
+ "yamada ui",
8
+ "react",
9
+ "emotion",
10
+ "component",
11
+ "accordion",
12
+ "ui",
13
+ "uikit",
14
+ "styled",
15
+ "style-props",
16
+ "styled-component",
17
+ "css-in-js"
18
+ ],
19
+ "author": "Hirotomo Yamada <hirotomo.yamada@avap.co.jp>",
20
+ "license": "MIT",
21
+ "main": "dist/index.js",
22
+ "files": [
23
+ "dist"
24
+ ],
25
+ "sideEffects": false,
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "homepage": "https://yamada-ui.com",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/hirotomoyamada/yamada-ui",
33
+ "directory": "packages/components/resizable"
34
+ },
35
+ "bugs": {
36
+ "url": "https://github.com/hirotomoyamada/yamada-ui/issues"
37
+ },
38
+ "dependencies": {
39
+ "react-resizable-panels": "^1.0.7",
40
+ "@yamada-ui/core": "1.1.1",
41
+ "@yamada-ui/utils": "1.0.0",
42
+ "@yamada-ui/icon": "1.0.2"
43
+ },
44
+ "devDependencies": {
45
+ "clean-package": "2.2.0",
46
+ "react": "^18.0.0"
47
+ },
48
+ "peerDependencies": {
49
+ "react": ">=18"
50
+ },
51
+ "clean-package": "../../../clean-package.config.json",
52
+ "tsup": {
53
+ "clean": true,
54
+ "target": "es2019",
55
+ "format": [
56
+ "cjs",
57
+ "esm"
58
+ ]
59
+ },
60
+ "module": "dist/index.mjs",
61
+ "types": "dist/index.d.ts",
62
+ "exports": {
63
+ ".": {
64
+ "types": "./dist/index.d.ts",
65
+ "import": "./dist/index.mjs",
66
+ "require": "./dist/index.js"
67
+ },
68
+ "./package.json": "./package.json"
69
+ },
70
+ "scripts": {
71
+ "dev": "pnpm build:fast -- --watch",
72
+ "build": "tsup src --dts",
73
+ "build:fast": "tsup src",
74
+ "clean": "rimraf dist .turbo",
75
+ "typecheck": "tsc --noEmit",
76
+ "gen:docs": "tsx ../../../scripts/generate-docs"
77
+ }
78
+ }