@versini/ui-panel 3.4.0 → 3.4.1
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/index.js +174 -11
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
@versini/ui-panel v3.4.
|
|
2
|
+
@versini/ui-panel v3.4.1
|
|
3
3
|
© 2025 gizmette.com
|
|
4
4
|
*/
|
|
5
5
|
try {
|
|
6
6
|
if (!window.__VERSINI_UI_PANEL__) {
|
|
7
7
|
window.__VERSINI_UI_PANEL__ = {
|
|
8
|
-
version: "3.4.
|
|
9
|
-
buildTime: "11/04/2025
|
|
8
|
+
version: "3.4.1",
|
|
9
|
+
buildTime: "11/04/2025 04:32 PM EST",
|
|
10
10
|
homepage: "https://github.com/aversini/ui-components",
|
|
11
11
|
license: "MIT",
|
|
12
12
|
};
|
|
@@ -18,9 +18,9 @@ try {
|
|
|
18
18
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
19
19
|
import { ButtonIcon } from "@versini/ui-button";
|
|
20
20
|
import { IconClose } from "@versini/ui-icons";
|
|
21
|
-
import {
|
|
22
|
-
import { useEffect, useRef, useState } from "react";
|
|
21
|
+
import { FloatingFocusManager, FloatingOverlay, FloatingPortal, useClick, useDismiss, useFloating, useInteractions, useMergeRefs, useRole } from "@floating-ui/react";
|
|
23
22
|
import clsx from "clsx";
|
|
23
|
+
import { cloneElement, createContext, forwardRef, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
24
24
|
|
|
25
25
|
;// CONCATENATED MODULE: ./src/common/constants.ts
|
|
26
26
|
const MESSAGEBOX_CLASSNAME = "av-messagebox";
|
|
@@ -32,11 +32,174 @@ const PANEL_CLASSNAME = "av-panel";
|
|
|
32
32
|
|
|
33
33
|
;// CONCATENATED MODULE: external "@versini/ui-icons"
|
|
34
34
|
|
|
35
|
-
;// CONCATENATED MODULE: external "@
|
|
35
|
+
;// CONCATENATED MODULE: external "@floating-ui/react"
|
|
36
|
+
|
|
37
|
+
;// CONCATENATED MODULE: external "clsx"
|
|
36
38
|
|
|
37
39
|
;// CONCATENATED MODULE: external "react"
|
|
38
40
|
|
|
39
|
-
;// CONCATENATED MODULE:
|
|
41
|
+
;// CONCATENATED MODULE: ../ui-modal/dist/index.js
|
|
42
|
+
/*!
|
|
43
|
+
@versini/ui-modal v3.1.0
|
|
44
|
+
© 2025 gizmette.com
|
|
45
|
+
*/ try {
|
|
46
|
+
if (!window.__VERSINI_UI_MODAL__) {
|
|
47
|
+
window.__VERSINI_UI_MODAL__ = {
|
|
48
|
+
version: "3.1.0",
|
|
49
|
+
buildTime: "11/04/2025 04:31 PM EST",
|
|
50
|
+
homepage: "https://github.com/aversini/ui-components",
|
|
51
|
+
license: "MIT"
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
} catch (error) {
|
|
55
|
+
// nothing to declare officer
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
const ModalContext = /*#__PURE__*/ createContext(null);
|
|
62
|
+
function useModal({ initialOpen = false, open: controlledOpen, onOpenChange: setControlledOpen } = {}) {
|
|
63
|
+
const [uncontrolledOpen, setUncontrolledOpen] = useState(initialOpen);
|
|
64
|
+
const [labelId, setLabelId] = useState();
|
|
65
|
+
const [descriptionId, setDescriptionId] = useState();
|
|
66
|
+
/* v8 ignore next 2 */ const open = controlledOpen ?? uncontrolledOpen;
|
|
67
|
+
const setOpen = setControlledOpen ?? setUncontrolledOpen;
|
|
68
|
+
const data = useFloating({
|
|
69
|
+
open,
|
|
70
|
+
onOpenChange: setOpen
|
|
71
|
+
});
|
|
72
|
+
const context = data.context;
|
|
73
|
+
const click = useClick(context, {
|
|
74
|
+
enabled: controlledOpen == null
|
|
75
|
+
});
|
|
76
|
+
const dismiss = useDismiss(context, {
|
|
77
|
+
outsidePress: false,
|
|
78
|
+
outsidePressEvent: "mousedown"
|
|
79
|
+
});
|
|
80
|
+
const role = useRole(context);
|
|
81
|
+
const interactions = useInteractions([
|
|
82
|
+
click,
|
|
83
|
+
dismiss,
|
|
84
|
+
role
|
|
85
|
+
]);
|
|
86
|
+
return useMemo(()=>({
|
|
87
|
+
open,
|
|
88
|
+
setOpen,
|
|
89
|
+
...interactions,
|
|
90
|
+
...data,
|
|
91
|
+
labelId,
|
|
92
|
+
descriptionId,
|
|
93
|
+
setLabelId,
|
|
94
|
+
setDescriptionId
|
|
95
|
+
}), [
|
|
96
|
+
open,
|
|
97
|
+
setOpen,
|
|
98
|
+
interactions,
|
|
99
|
+
data,
|
|
100
|
+
labelId,
|
|
101
|
+
descriptionId
|
|
102
|
+
]);
|
|
103
|
+
}
|
|
104
|
+
const useModalContext = ()=>{
|
|
105
|
+
const context = useContext(ModalContext);
|
|
106
|
+
/* v8 ignore next 3 */ if (context == null) {
|
|
107
|
+
throw new Error("Modal components must be wrapped in <Modal />");
|
|
108
|
+
}
|
|
109
|
+
return context;
|
|
110
|
+
};
|
|
111
|
+
function Modal({ children, ...options }) {
|
|
112
|
+
const dialog = useModal(options);
|
|
113
|
+
return /*#__PURE__*/ jsx(ModalContext.Provider, {
|
|
114
|
+
value: dialog,
|
|
115
|
+
children: children
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
const Modal_ModalContent = /*#__PURE__*/ forwardRef(function ModalContent(props, propRef) {
|
|
119
|
+
const { context: floatingContext, ...context } = useModalContext();
|
|
120
|
+
const ref = useMergeRefs([
|
|
121
|
+
context.refs.setFloating,
|
|
122
|
+
propRef
|
|
123
|
+
]);
|
|
124
|
+
/* v8 ignore next 3 */ if (!floatingContext.open) {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
const { overlayBackground, ...rest } = props;
|
|
128
|
+
const overlayClass = clsx("grid place-items-center", {
|
|
129
|
+
[`${overlayBackground}`]: overlayBackground,
|
|
130
|
+
"bg-black sm:bg-black/[.8]": !overlayBackground
|
|
131
|
+
});
|
|
132
|
+
return /*#__PURE__*/ jsx(FloatingPortal, {
|
|
133
|
+
children: /*#__PURE__*/ jsx(FloatingOverlay, {
|
|
134
|
+
className: overlayClass,
|
|
135
|
+
lockScroll: true,
|
|
136
|
+
children: /*#__PURE__*/ jsx(FloatingFocusManager, {
|
|
137
|
+
context: floatingContext,
|
|
138
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
139
|
+
ref: ref,
|
|
140
|
+
"aria-labelledby": context.labelId,
|
|
141
|
+
"aria-describedby": context.descriptionId,
|
|
142
|
+
...context.getFloatingProps(rest),
|
|
143
|
+
children: rest.children
|
|
144
|
+
})
|
|
145
|
+
})
|
|
146
|
+
})
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
const Modal_ModalHeading = /*#__PURE__*/ forwardRef(function ModalHeading({ children, ...props }, ref) {
|
|
150
|
+
const { setLabelId } = useModalContext();
|
|
151
|
+
const id = useId();
|
|
152
|
+
// Only sets `aria-labelledby` on the Modal root element
|
|
153
|
+
// if this component is mounted inside it.
|
|
154
|
+
useLayoutEffect(()=>{
|
|
155
|
+
setLabelId(id);
|
|
156
|
+
return ()=>setLabelId(undefined);
|
|
157
|
+
}, [
|
|
158
|
+
id,
|
|
159
|
+
setLabelId
|
|
160
|
+
]);
|
|
161
|
+
return /*#__PURE__*/ jsx("h1", {
|
|
162
|
+
...props,
|
|
163
|
+
ref: ref,
|
|
164
|
+
id: id,
|
|
165
|
+
children: children
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
const Modal_ModalDescription = /*#__PURE__*/ forwardRef(function ModalDescription({ children, ...props }, ref) {
|
|
169
|
+
const { setDescriptionId } = useModalContext();
|
|
170
|
+
const id = useId();
|
|
171
|
+
// Only sets `aria-describedby` on the Modal root element
|
|
172
|
+
// if this component is mounted inside it.
|
|
173
|
+
useLayoutEffect(()=>{
|
|
174
|
+
setDescriptionId(id);
|
|
175
|
+
return ()=>setDescriptionId(undefined);
|
|
176
|
+
}, [
|
|
177
|
+
id,
|
|
178
|
+
setDescriptionId
|
|
179
|
+
]);
|
|
180
|
+
return /*#__PURE__*/ jsx("div", {
|
|
181
|
+
...props,
|
|
182
|
+
ref: ref,
|
|
183
|
+
id: id,
|
|
184
|
+
children: children
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
const Modal_ModalClose = /*#__PURE__*/ forwardRef(function ModalClose(props, ref) {
|
|
188
|
+
const { setOpen } = useModalContext();
|
|
189
|
+
const { trigger, className, ...rest } = props;
|
|
190
|
+
const handleClose = useCallback(()=>setOpen(false), [
|
|
191
|
+
setOpen
|
|
192
|
+
]);
|
|
193
|
+
return /*#__PURE__*/ jsx("div", {
|
|
194
|
+
className: className,
|
|
195
|
+
children: /*#__PURE__*/ cloneElement(trigger, {
|
|
196
|
+
ref,
|
|
197
|
+
onClick: handleClose,
|
|
198
|
+
...rest
|
|
199
|
+
})
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
/* v8 ignore next 1 */
|
|
40
203
|
|
|
41
204
|
;// CONCATENATED MODULE: ./src/components/Panel/utilities.ts
|
|
42
205
|
|
|
@@ -152,14 +315,14 @@ const Panel = ({ open, onOpenChange, title, children, footer, borderMode = "ligh
|
|
|
152
315
|
children: open && /*#__PURE__*/ jsx(Modal, {
|
|
153
316
|
open: open,
|
|
154
317
|
onOpenChange: onOpenChange,
|
|
155
|
-
children: /*#__PURE__*/ jsxs(
|
|
318
|
+
children: /*#__PURE__*/ jsxs(Modal_ModalContent, {
|
|
156
319
|
className: panelClassName.main,
|
|
157
320
|
style: animationStyles,
|
|
158
321
|
children: [
|
|
159
322
|
/*#__PURE__*/ jsxs("div", {
|
|
160
323
|
className: "flex flex-row-reverse items-center justify-between",
|
|
161
324
|
children: [
|
|
162
|
-
/*#__PURE__*/ jsx(
|
|
325
|
+
/*#__PURE__*/ jsx(Modal_ModalClose, {
|
|
163
326
|
className: panelClassName.close,
|
|
164
327
|
trigger: /*#__PURE__*/ jsx(ButtonIcon, {
|
|
165
328
|
mode: "dark",
|
|
@@ -171,13 +334,13 @@ const Panel = ({ open, onOpenChange, title, children, footer, borderMode = "ligh
|
|
|
171
334
|
})
|
|
172
335
|
})
|
|
173
336
|
}),
|
|
174
|
-
/*#__PURE__*/ jsx(
|
|
337
|
+
/*#__PURE__*/ jsx(Modal_ModalHeading, {
|
|
175
338
|
className: panelClassName.header,
|
|
176
339
|
children: title
|
|
177
340
|
})
|
|
178
341
|
]
|
|
179
342
|
}),
|
|
180
|
-
/*#__PURE__*/ jsx(
|
|
343
|
+
/*#__PURE__*/ jsx(Modal_ModalDescription, {
|
|
181
344
|
className: panelClassName.content,
|
|
182
345
|
children: children
|
|
183
346
|
}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@versini/ui-panel",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Arno Versini",
|
|
6
6
|
"publishConfig": {
|
|
@@ -37,18 +37,18 @@
|
|
|
37
37
|
"test": "vitest run"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@testing-library/jest-dom": "6.9.1"
|
|
40
|
+
"@testing-library/jest-dom": "6.9.1",
|
|
41
|
+
"@versini/ui-modal": "3.1.0"
|
|
41
42
|
},
|
|
42
43
|
"dependencies": {
|
|
43
44
|
"@tailwindcss/typography": "0.5.19",
|
|
44
45
|
"@versini/ui-button": "8.3.1",
|
|
45
46
|
"@versini/ui-icons": "4.15.1",
|
|
46
|
-
"@versini/ui-modal": "3.1.0",
|
|
47
47
|
"clsx": "2.1.1",
|
|
48
48
|
"tailwindcss": "4.1.16"
|
|
49
49
|
},
|
|
50
50
|
"sideEffects": [
|
|
51
51
|
"**/*.css"
|
|
52
52
|
],
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "21bcec6f5180d6197a7b9073ccae1035bba245c5"
|
|
54
54
|
}
|