@versini/ui-panel 8.1.2 → 8.1.4

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.
Files changed (2) hide show
  1. package/dist/index.js +16 -198
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  /*!
2
- @versini/ui-panel v8.1.2
2
+ @versini/ui-panel v8.1.4
3
3
  © 2025 gizmette.com
4
4
  */
5
5
 
6
6
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
- import { FloatingFocusManager, FloatingNode, FloatingOverlay, FloatingPortal, FloatingTree, useClick, useDismiss, useFloating, useFloatingNodeId, useFloatingParentNodeId, useInteractions, useMergeRefs, useRole } from "@floating-ui/react";
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,194 +22,11 @@ const NONE = "none";
22
22
 
23
23
  ;// CONCATENATED MODULE: external "react/jsx-runtime"
24
24
 
25
- ;// CONCATENATED MODULE: external "@floating-ui/react"
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: ../ui-modal/dist/index.js
32
- /*!
33
- @versini/ui-modal v3.3.2
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 */ // Subscribe this modal to the FloatingTree for nested modal support
47
- const nodeId = useFloatingNodeId();
48
- const data = useFloating({
49
- nodeId,
50
- open,
51
- onOpenChange: setOpen
52
- });
53
- const context = data.context;
54
- const click = useClick(context, {
55
- enabled: controlledOpen == null
56
- });
57
- const dismiss = useDismiss(context, {
58
- outsidePress: false,
59
- outsidePressEvent: "mousedown",
60
- bubbles: {
61
- escapeKey: false
62
- }
63
- });
64
- const role = useRole(context);
65
- const interactions = useInteractions([
66
- click,
67
- dismiss,
68
- role
69
- ]);
70
- return useMemo(()=>({
71
- open,
72
- setOpen,
73
- ...interactions,
74
- ...data,
75
- labelId,
76
- descriptionId,
77
- setLabelId,
78
- setDescriptionId,
79
- initialFocus,
80
- nodeId
81
- }), [
82
- open,
83
- setOpen,
84
- interactions,
85
- data,
86
- labelId,
87
- descriptionId,
88
- initialFocus,
89
- nodeId
90
- ]);
91
- }
92
- const useModalContext = ()=>{
93
- const context = useContext(ModalContext);
94
- /* v8 ignore start */ if (context == null) {
95
- throw new Error("Modal components must be wrapped in <Modal />");
96
- }
97
- /* v8 ignore stop */ return context;
98
- };
99
- function ModalComponent({ children, ...options }) {
100
- const dialog = useModal(options);
101
- return /*#__PURE__*/ jsx(ModalContext.Provider, {
102
- value: dialog,
103
- children: children
104
- });
105
- }
106
- /**
107
- * Modal component that supports proper nesting with ESC key handling.
108
- * Automatically wraps root modals in FloatingTree for nested modal support.
109
- */ function Modal(props) {
110
- const parentId = useFloatingParentNodeId();
111
- // If this is a root modal (no parent), wrap with FloatingTree
112
- if (parentId === null) {
113
- return /*#__PURE__*/ jsx(FloatingTree, {
114
- children: /*#__PURE__*/ jsx(ModalComponent, {
115
- ...props
116
- })
117
- });
118
- }
119
- // Nested modal - FloatingTree already exists
120
- return /*#__PURE__*/ jsx(ModalComponent, {
121
- ...props
122
- });
123
- }
124
- const Modal_ModalContent = /*#__PURE__*/ forwardRef(function ModalContent(props, propRef) {
125
- const { context: floatingContext, nodeId, ...context } = useModalContext();
126
- const ref = useMergeRefs([
127
- context.refs.setFloating,
128
- propRef
129
- ]);
130
- /* v8 ignore start */ if (!floatingContext.open) {
131
- return null;
132
- }
133
- /* v8 ignore stop */ const { overlayBackground, ...rest } = props;
134
- const overlayClass = clsx("grid place-items-center", {
135
- [`${overlayBackground}`]: overlayBackground,
136
- "bg-black sm:bg-black/[.8]": !overlayBackground
137
- });
138
- return /*#__PURE__*/ jsx(FloatingNode, {
139
- id: nodeId,
140
- children: /*#__PURE__*/ jsx(FloatingPortal, {
141
- children: /*#__PURE__*/ jsx(FloatingOverlay, {
142
- className: overlayClass,
143
- lockScroll: true,
144
- children: /*#__PURE__*/ jsx(FloatingFocusManager, {
145
- context: floatingContext,
146
- initialFocus: context.initialFocus,
147
- children: /*#__PURE__*/ jsx("div", {
148
- ref: ref,
149
- "aria-labelledby": context.labelId,
150
- "aria-describedby": context.descriptionId,
151
- ...context.getFloatingProps(rest),
152
- children: rest.children
153
- })
154
- })
155
- })
156
- })
157
- });
158
- });
159
- const Modal_ModalHeading = /*#__PURE__*/ forwardRef(function ModalHeading({ children, ...props }, ref) {
160
- const { setLabelId } = useModalContext();
161
- const id = useId();
162
- // Only sets `aria-labelledby` on the Modal root element
163
- // if this component is mounted inside it.
164
- useLayoutEffect(()=>{
165
- setLabelId(id);
166
- return ()=>setLabelId(undefined);
167
- }, [
168
- id,
169
- setLabelId
170
- ]);
171
- return /*#__PURE__*/ jsx("h1", {
172
- ...props,
173
- ref: ref,
174
- id: id,
175
- children: children
176
- });
177
- });
178
- const Modal_ModalDescription = /*#__PURE__*/ forwardRef(function ModalDescription({ children, ...props }, ref) {
179
- const { setDescriptionId } = useModalContext();
180
- const id = useId();
181
- // Only sets `aria-describedby` on the Modal root element
182
- // if this component is mounted inside it.
183
- useLayoutEffect(()=>{
184
- setDescriptionId(id);
185
- return ()=>setDescriptionId(undefined);
186
- }, [
187
- id,
188
- setDescriptionId
189
- ]);
190
- return /*#__PURE__*/ jsx("div", {
191
- ...props,
192
- ref: ref,
193
- id: id,
194
- children: children
195
- });
196
- });
197
- const Modal_ModalClose = /*#__PURE__*/ forwardRef(function ModalClose(props, ref) {
198
- const { setOpen } = useModalContext();
199
- const { trigger, className, ...rest } = props;
200
- const handleClose = useCallback(()=>setOpen(false), [
201
- setOpen
202
- ]);
203
- return /*#__PURE__*/ jsx("div", {
204
- className: className,
205
- children: /*#__PURE__*/ cloneElement(trigger, {
206
- ref,
207
- onClick: handleClose,
208
- ...rest
209
- })
210
- });
211
- });
212
- /* v8 ignore start */ /* v8 ignore stop */
29
+ ;// CONCATENATED MODULE: external "clsx"
213
30
 
214
31
  ;// CONCATENATED MODULE: ./src/components/Panel/utilities.ts
215
32
 
@@ -311,9 +128,8 @@ const Panel = ({ open, onOpenChange, title, children, footer, borderMode = "ligh
311
128
  hasFooter: Boolean(footer)
312
129
  });
313
130
  /**
314
- * If the panel is opened, set the document
315
- * title to the panel's title. If it's closed,
316
- * 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.
317
133
  */ /* v8 ignore start - document title manipulation */ useEffect(()=>{
318
134
  if (open) {
319
135
  originalTitleRef.current = document.title;
@@ -340,9 +156,10 @@ const Panel = ({ open, onOpenChange, title, children, footer, borderMode = "ligh
340
156
  } : {
341
157
  transform: "translateY(-666vh)"
342
158
  });
343
- // Small delay to ensure the opening state is applied after
344
- // the component is rendered.
345
- const timer = setTimeout(()=>{
159
+ /**
160
+ * Small delay to ensure the opening state is applied after the component is
161
+ * rendered.
162
+ */ const timer = setTimeout(()=>{
346
163
  setAnimationStyles(!animation ? {} : animationType === /* inlined export .ANIMATION_FADE */ ("fade") ? {
347
164
  opacity: 1
348
165
  } : {
@@ -361,18 +178,18 @@ const Panel = ({ open, onOpenChange, title, children, footer, borderMode = "ligh
361
178
  open: open,
362
179
  onOpenChange: onOpenChange,
363
180
  initialFocus: initialFocus,
364
- children: /*#__PURE__*/ jsx(Modal_ModalContent, {
181
+ children: /*#__PURE__*/ jsx(ModalContent, {
365
182
  className: panelClassName.outerWrapper,
366
183
  style: {
367
184
  ...animationStyles
368
185
  },
369
- children: /*#__PURE__*/ jsxs(Modal_ModalDescription, {
186
+ children: /*#__PURE__*/ jsxs(ModalDescription, {
370
187
  className: panelClassName.innerWrapper,
371
188
  children: [
372
189
  /*#__PURE__*/ jsxs("div", {
373
190
  className: panelClassName.header,
374
191
  children: [
375
- /*#__PURE__*/ jsx(Modal_ModalClose, {
192
+ /*#__PURE__*/ jsx(ModalClose, {
376
193
  className: panelClassName.closeWrapper,
377
194
  trigger: /*#__PURE__*/ jsx("button", {
378
195
  className: panelClassName.closeButton,
@@ -395,7 +212,7 @@ const Panel = ({ open, onOpenChange, title, children, footer, borderMode = "ligh
395
212
  })
396
213
  })
397
214
  }),
398
- /*#__PURE__*/ jsx(Modal_ModalHeading, {
215
+ /*#__PURE__*/ jsx(ModalHeading, {
399
216
  className: panelClassName.title,
400
217
  children: title
401
218
  })
@@ -420,6 +237,7 @@ const Panel = ({ open, onOpenChange, title, children, footer, borderMode = "ligh
420
237
  };
421
238
 
422
239
  ;// CONCATENATED MODULE: ./src/components/index.ts
240
+ // @v8-ignore-start
423
241
 
424
242
 
425
243
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@versini/ui-panel",
3
- "version": "8.1.2",
3
+ "version": "8.1.4",
4
4
  "license": "MIT",
5
5
  "author": "Arno Versini",
6
6
  "publishConfig": {
@@ -42,19 +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.2"
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.3",
50
50
  "clsx": "2.1.1",
51
51
  "tailwindcss": "4.1.18"
52
52
  },
53
53
  "peerDependencies": {
54
- "@floating-ui/react": ">=0.27.0"
54
+ "@floating-ui/react": ">=0.27.16"
55
55
  },
56
56
  "sideEffects": [
57
57
  "**/*.css"
58
58
  ],
59
- "gitHead": "8840cff6a204379e7da9fd65494e5ea280cfc7ab"
59
+ "gitHead": "9fedab179e688f845d193b1f0b5365639dd4beb0"
60
60
  }