@versini/ui-panel 8.1.1 → 8.1.3
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 +15 -169
- package/package.json +7 -4
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
@versini/ui-panel v8.1.
|
|
2
|
+
@versini/ui-panel v8.1.3
|
|
3
3
|
© 2025 gizmette.com
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
-
import {
|
|
7
|
+
import { Modal, ModalClose, ModalContent, ModalDescription, ModalHeading } from "@versini/ui-modal";
|
|
8
|
+
import { useEffect, useRef, useState } from "react";
|
|
8
9
|
import clsx from "clsx";
|
|
9
|
-
import { cloneElement, createContext, forwardRef, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
10
10
|
|
|
11
11
|
;// CONCATENATED MODULE: ./src/common/constants.ts
|
|
12
12
|
const MESSAGEBOX_CLASSNAME = "av-messagebox";
|
|
@@ -22,165 +22,11 @@ const NONE = "none";
|
|
|
22
22
|
|
|
23
23
|
;// CONCATENATED MODULE: external "react/jsx-runtime"
|
|
24
24
|
|
|
25
|
-
;// CONCATENATED MODULE: external "@
|
|
26
|
-
|
|
27
|
-
;// CONCATENATED MODULE: external "clsx"
|
|
25
|
+
;// CONCATENATED MODULE: external "@versini/ui-modal"
|
|
28
26
|
|
|
29
27
|
;// CONCATENATED MODULE: external "react"
|
|
30
28
|
|
|
31
|
-
;// CONCATENATED MODULE:
|
|
32
|
-
/*!
|
|
33
|
-
@versini/ui-modal v3.3.1
|
|
34
|
-
© 2025 gizmette.com
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const ModalContext = /*#__PURE__*/ createContext(null);
|
|
40
|
-
function useModal({ initialOpen = false, open: controlledOpen, onOpenChange: setControlledOpen, initialFocus } = {}) {
|
|
41
|
-
const [uncontrolledOpen, setUncontrolledOpen] = useState(initialOpen);
|
|
42
|
-
const [labelId, setLabelId] = useState();
|
|
43
|
-
const [descriptionId, setDescriptionId] = useState();
|
|
44
|
-
/* v8 ignore start */ const open = controlledOpen ?? uncontrolledOpen;
|
|
45
|
-
const setOpen = setControlledOpen ?? setUncontrolledOpen;
|
|
46
|
-
/* v8 ignore stop */ const data = useFloating({
|
|
47
|
-
open,
|
|
48
|
-
onOpenChange: setOpen
|
|
49
|
-
});
|
|
50
|
-
const context = data.context;
|
|
51
|
-
const click = useClick(context, {
|
|
52
|
-
enabled: controlledOpen == null
|
|
53
|
-
});
|
|
54
|
-
const dismiss = useDismiss(context, {
|
|
55
|
-
outsidePress: false,
|
|
56
|
-
outsidePressEvent: "mousedown"
|
|
57
|
-
});
|
|
58
|
-
const role = useRole(context);
|
|
59
|
-
const interactions = useInteractions([
|
|
60
|
-
click,
|
|
61
|
-
dismiss,
|
|
62
|
-
role
|
|
63
|
-
]);
|
|
64
|
-
return useMemo(()=>({
|
|
65
|
-
open,
|
|
66
|
-
setOpen,
|
|
67
|
-
...interactions,
|
|
68
|
-
...data,
|
|
69
|
-
labelId,
|
|
70
|
-
descriptionId,
|
|
71
|
-
setLabelId,
|
|
72
|
-
setDescriptionId,
|
|
73
|
-
initialFocus
|
|
74
|
-
}), [
|
|
75
|
-
open,
|
|
76
|
-
setOpen,
|
|
77
|
-
interactions,
|
|
78
|
-
data,
|
|
79
|
-
labelId,
|
|
80
|
-
descriptionId,
|
|
81
|
-
initialFocus
|
|
82
|
-
]);
|
|
83
|
-
}
|
|
84
|
-
const useModalContext = ()=>{
|
|
85
|
-
const context = useContext(ModalContext);
|
|
86
|
-
/* v8 ignore start */ if (context == null) {
|
|
87
|
-
throw new Error("Modal components must be wrapped in <Modal />");
|
|
88
|
-
}
|
|
89
|
-
/* v8 ignore stop */ return context;
|
|
90
|
-
};
|
|
91
|
-
function Modal({ children, ...options }) {
|
|
92
|
-
const dialog = useModal(options);
|
|
93
|
-
return /*#__PURE__*/ jsx(ModalContext.Provider, {
|
|
94
|
-
value: dialog,
|
|
95
|
-
children: children
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
const Modal_ModalContent = /*#__PURE__*/ forwardRef(function ModalContent(props, propRef) {
|
|
99
|
-
const { context: floatingContext, ...context } = useModalContext();
|
|
100
|
-
const ref = useMergeRefs([
|
|
101
|
-
context.refs.setFloating,
|
|
102
|
-
propRef
|
|
103
|
-
]);
|
|
104
|
-
/* v8 ignore start */ if (!floatingContext.open) {
|
|
105
|
-
return null;
|
|
106
|
-
}
|
|
107
|
-
/* v8 ignore stop */ const { overlayBackground, ...rest } = props;
|
|
108
|
-
const overlayClass = clsx("grid place-items-center", {
|
|
109
|
-
[`${overlayBackground}`]: overlayBackground,
|
|
110
|
-
"bg-black sm:bg-black/[.8]": !overlayBackground
|
|
111
|
-
});
|
|
112
|
-
return /*#__PURE__*/ jsx(FloatingPortal, {
|
|
113
|
-
children: /*#__PURE__*/ jsx(FloatingOverlay, {
|
|
114
|
-
className: overlayClass,
|
|
115
|
-
lockScroll: true,
|
|
116
|
-
children: /*#__PURE__*/ jsx(FloatingFocusManager, {
|
|
117
|
-
context: floatingContext,
|
|
118
|
-
initialFocus: context.initialFocus,
|
|
119
|
-
children: /*#__PURE__*/ jsx("div", {
|
|
120
|
-
ref: ref,
|
|
121
|
-
"aria-labelledby": context.labelId,
|
|
122
|
-
"aria-describedby": context.descriptionId,
|
|
123
|
-
...context.getFloatingProps(rest),
|
|
124
|
-
children: rest.children
|
|
125
|
-
})
|
|
126
|
-
})
|
|
127
|
-
})
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
const Modal_ModalHeading = /*#__PURE__*/ forwardRef(function ModalHeading({ children, ...props }, ref) {
|
|
131
|
-
const { setLabelId } = useModalContext();
|
|
132
|
-
const id = useId();
|
|
133
|
-
// Only sets `aria-labelledby` on the Modal root element
|
|
134
|
-
// if this component is mounted inside it.
|
|
135
|
-
useLayoutEffect(()=>{
|
|
136
|
-
setLabelId(id);
|
|
137
|
-
return ()=>setLabelId(undefined);
|
|
138
|
-
}, [
|
|
139
|
-
id,
|
|
140
|
-
setLabelId
|
|
141
|
-
]);
|
|
142
|
-
return /*#__PURE__*/ jsx("h1", {
|
|
143
|
-
...props,
|
|
144
|
-
ref: ref,
|
|
145
|
-
id: id,
|
|
146
|
-
children: children
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
const Modal_ModalDescription = /*#__PURE__*/ forwardRef(function ModalDescription({ children, ...props }, ref) {
|
|
150
|
-
const { setDescriptionId } = useModalContext();
|
|
151
|
-
const id = useId();
|
|
152
|
-
// Only sets `aria-describedby` on the Modal root element
|
|
153
|
-
// if this component is mounted inside it.
|
|
154
|
-
useLayoutEffect(()=>{
|
|
155
|
-
setDescriptionId(id);
|
|
156
|
-
return ()=>setDescriptionId(undefined);
|
|
157
|
-
}, [
|
|
158
|
-
id,
|
|
159
|
-
setDescriptionId
|
|
160
|
-
]);
|
|
161
|
-
return /*#__PURE__*/ jsx("div", {
|
|
162
|
-
...props,
|
|
163
|
-
ref: ref,
|
|
164
|
-
id: id,
|
|
165
|
-
children: children
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
const Modal_ModalClose = /*#__PURE__*/ forwardRef(function ModalClose(props, ref) {
|
|
169
|
-
const { setOpen } = useModalContext();
|
|
170
|
-
const { trigger, className, ...rest } = props;
|
|
171
|
-
const handleClose = useCallback(()=>setOpen(false), [
|
|
172
|
-
setOpen
|
|
173
|
-
]);
|
|
174
|
-
return /*#__PURE__*/ jsx("div", {
|
|
175
|
-
className: className,
|
|
176
|
-
children: /*#__PURE__*/ cloneElement(trigger, {
|
|
177
|
-
ref,
|
|
178
|
-
onClick: handleClose,
|
|
179
|
-
...rest
|
|
180
|
-
})
|
|
181
|
-
});
|
|
182
|
-
});
|
|
183
|
-
/* v8 ignore start */ /* v8 ignore stop */
|
|
29
|
+
;// CONCATENATED MODULE: external "clsx"
|
|
184
30
|
|
|
185
31
|
;// CONCATENATED MODULE: ./src/components/Panel/utilities.ts
|
|
186
32
|
|
|
@@ -282,9 +128,8 @@ const Panel = ({ open, onOpenChange, title, children, footer, borderMode = "ligh
|
|
|
282
128
|
hasFooter: Boolean(footer)
|
|
283
129
|
});
|
|
284
130
|
/**
|
|
285
|
-
* If the panel is opened, set the document
|
|
286
|
-
*
|
|
287
|
-
* restore the original document.title.
|
|
131
|
+
* If the panel is opened, set the document title to the panel's title. If it's
|
|
132
|
+
* closed, restore the original document.title.
|
|
288
133
|
*/ /* v8 ignore start - document title manipulation */ useEffect(()=>{
|
|
289
134
|
if (open) {
|
|
290
135
|
originalTitleRef.current = document.title;
|
|
@@ -311,9 +156,10 @@ const Panel = ({ open, onOpenChange, title, children, footer, borderMode = "ligh
|
|
|
311
156
|
} : {
|
|
312
157
|
transform: "translateY(-666vh)"
|
|
313
158
|
});
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
159
|
+
/**
|
|
160
|
+
* Small delay to ensure the opening state is applied after the component is
|
|
161
|
+
* rendered.
|
|
162
|
+
*/ const timer = setTimeout(()=>{
|
|
317
163
|
setAnimationStyles(!animation ? {} : animationType === /* inlined export .ANIMATION_FADE */ ("fade") ? {
|
|
318
164
|
opacity: 1
|
|
319
165
|
} : {
|
|
@@ -332,18 +178,18 @@ const Panel = ({ open, onOpenChange, title, children, footer, borderMode = "ligh
|
|
|
332
178
|
open: open,
|
|
333
179
|
onOpenChange: onOpenChange,
|
|
334
180
|
initialFocus: initialFocus,
|
|
335
|
-
children: /*#__PURE__*/ jsx(
|
|
181
|
+
children: /*#__PURE__*/ jsx(ModalContent, {
|
|
336
182
|
className: panelClassName.outerWrapper,
|
|
337
183
|
style: {
|
|
338
184
|
...animationStyles
|
|
339
185
|
},
|
|
340
|
-
children: /*#__PURE__*/ jsxs(
|
|
186
|
+
children: /*#__PURE__*/ jsxs(ModalDescription, {
|
|
341
187
|
className: panelClassName.innerWrapper,
|
|
342
188
|
children: [
|
|
343
189
|
/*#__PURE__*/ jsxs("div", {
|
|
344
190
|
className: panelClassName.header,
|
|
345
191
|
children: [
|
|
346
|
-
/*#__PURE__*/ jsx(
|
|
192
|
+
/*#__PURE__*/ jsx(ModalClose, {
|
|
347
193
|
className: panelClassName.closeWrapper,
|
|
348
194
|
trigger: /*#__PURE__*/ jsx("button", {
|
|
349
195
|
className: panelClassName.closeButton,
|
|
@@ -366,7 +212,7 @@ const Panel = ({ open, onOpenChange, title, children, footer, borderMode = "ligh
|
|
|
366
212
|
})
|
|
367
213
|
})
|
|
368
214
|
}),
|
|
369
|
-
/*#__PURE__*/ jsx(
|
|
215
|
+
/*#__PURE__*/ jsx(ModalHeading, {
|
|
370
216
|
className: panelClassName.title,
|
|
371
217
|
children: title
|
|
372
218
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@versini/ui-panel",
|
|
3
|
-
"version": "8.1.
|
|
3
|
+
"version": "8.1.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Arno Versini",
|
|
6
6
|
"publishConfig": {
|
|
@@ -42,16 +42,19 @@
|
|
|
42
42
|
"test": "vitest run"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@testing-library/jest-dom": "6.9.1"
|
|
46
|
-
"@versini/ui-modal": "3.3.1"
|
|
45
|
+
"@testing-library/jest-dom": "6.9.1"
|
|
47
46
|
},
|
|
48
47
|
"dependencies": {
|
|
49
48
|
"@tailwindcss/typography": "0.5.19",
|
|
49
|
+
"@versini/ui-modal": "3.3.2",
|
|
50
50
|
"clsx": "2.1.1",
|
|
51
51
|
"tailwindcss": "4.1.18"
|
|
52
52
|
},
|
|
53
|
+
"peerDependencies": {
|
|
54
|
+
"@floating-ui/react": ">=0.27.0"
|
|
55
|
+
},
|
|
53
56
|
"sideEffects": [
|
|
54
57
|
"**/*.css"
|
|
55
58
|
],
|
|
56
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "b356a479b6ee29fd3d3dbabc59658ebdac6255d1"
|
|
57
60
|
}
|