@nubitio/ui 1.1.1 → 1.2.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/dist/index.cjs CHANGED
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
16
16
  }
17
17
  return to;
18
18
  };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
20
20
  value: mod,
21
21
  enumerable: true
22
22
  }) : target, mod));
@@ -24,8 +24,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
24
24
  let react = require("react");
25
25
  react = __toESM(react, 1);
26
26
  let react_jsx_runtime = require("react/jsx-runtime");
27
- let react_dom = require("react-dom");
27
+ let _base_ui_react_dialog = require("@base-ui/react/dialog");
28
28
  let react_dropzone = require("react-dropzone");
29
+ let _base_ui_react_select = require("@base-ui/react/select");
30
+ let react_aria_components = require("react-aria-components");
31
+ let _base_ui_react_menu = require("@base-ui/react/menu");
32
+ let _internationalized_date = require("@internationalized/date");
33
+ let _base_ui_react_popover = require("@base-ui/react/popover");
34
+ let _base_ui_react_tooltip = require("@base-ui/react/tooltip");
29
35
  //#region packages/ui/Avatar.tsx
30
36
  /**
31
37
  * 8 semantic hues aligned with the Fluent / @nubitio design palette.
@@ -65,12 +71,13 @@ const Avatar = ({ owner = "", size, variant = "md", shape = "circle", alt, class
65
71
  const px = size ?? NAMED_SIZES[variant];
66
72
  const initials = getAvatarInitials(owner);
67
73
  const hue = getAvatarHue(owner);
74
+ const classes = [
75
+ "nb-avatar",
76
+ shape === "square" && "nb-avatar--square",
77
+ className
78
+ ].filter(Boolean).join(" ");
68
79
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
69
- className: [
70
- "nb-avatar",
71
- shape === "square" && "nb-avatar--square",
72
- className
73
- ].filter(Boolean).join(" "),
80
+ className: classes,
74
81
  role: "img",
75
82
  "aria-label": alt ?? (owner || "Avatar"),
76
83
  style: {
@@ -83,32 +90,104 @@ const Avatar = ({ owner = "", size, variant = "md", shape = "circle", alt, class
83
90
  });
84
91
  };
85
92
  //#endregion
93
+ //#region packages/ui/OverlayContainer.tsx
94
+ /** Keeps nested portals within the modal's focus and accessibility boundary. */
95
+ const OverlayContainerContext = (0, react.createContext)(null);
96
+ const useOverlayContainer = () => (0, react.useContext)(OverlayContainerContext);
97
+ //#endregion
98
+ //#region packages/ui/ModalSurface.tsx
99
+ /** Shared modal behavior for centered dialogs and side sheets. */
100
+ function ModalSurface({ open, onClose, children, rootClassName, className, style, scrimClassName, scrimLabel, labelledBy, ariaLabel, role = "dialog", keepMounted = false, restoreFocus = true, closeOnEscape = true, initialFocus, closeOnOutsideClick = true }) {
101
+ const parentContainer = useOverlayContainer();
102
+ const [container, setContainer] = (0, react.useState)(null);
103
+ const returnFocus = (0, react.useRef)(null);
104
+ (0, react.useLayoutEffect)(() => {
105
+ if (!open) return;
106
+ const active = document.activeElement;
107
+ if (active instanceof HTMLElement && !container?.contains(active)) returnFocus.current = active;
108
+ }, [open, container]);
109
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_dialog.Dialog.Root, {
110
+ open,
111
+ disablePointerDismissal: !closeOnOutsideClick,
112
+ onOpenChange: (next, details) => {
113
+ if (!next) {
114
+ if (details.reason === "escape-key" && !closeOnEscape) details.cancel();
115
+ else onClose();
116
+ }
117
+ },
118
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_base_ui_react_dialog.Dialog.Portal, {
119
+ container: parentContainer ?? void 0,
120
+ keepMounted,
121
+ className: rootClassName,
122
+ "aria-hidden": !open || void 0,
123
+ style: {
124
+ visibility: open ? void 0 : "hidden",
125
+ pointerEvents: open ? void 0 : "none"
126
+ },
127
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_dialog.Dialog.Backdrop, {
128
+ forceRender: true,
129
+ className: scrimClassName,
130
+ render: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
131
+ type: "button",
132
+ tabIndex: -1,
133
+ "aria-label": scrimLabel
134
+ })
135
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_dialog.Dialog.Popup, {
136
+ ref: setContainer,
137
+ role,
138
+ "aria-labelledby": labelledBy,
139
+ "aria-label": ariaLabel,
140
+ className,
141
+ style,
142
+ finalFocus: restoreFocus ? () => returnFocus.current ?? true : false,
143
+ initialFocus,
144
+ onKeyDown: (event) => {
145
+ if (event.key === "Escape" && !event.defaultPrevented) {
146
+ event.stopPropagation();
147
+ if (closeOnEscape) onClose();
148
+ }
149
+ },
150
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OverlayContainerContext.Provider, {
151
+ value: container,
152
+ children
153
+ })
154
+ })]
155
+ })
156
+ });
157
+ }
158
+ //#endregion
86
159
  //#region packages/ui/Button.tsx
87
- const cx$5 = (...values) => values.filter(Boolean).join(" ");
88
- const Button = ({ variant = "secondary", size = "md", fullWidth = false, icon, loading = false, className, children, disabled, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
89
- ...props,
90
- type: props.type ?? "button",
91
- disabled: disabled || loading,
92
- "aria-busy": loading || void 0,
93
- className: cx$5("nb-button", `nb-button--${variant}`, size === "sm" && "nb-button--sm", fullWidth && "nb-button--full", className),
94
- children: [loading ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
95
- className: "nb-button-spinner",
96
- "aria-hidden": "true"
97
- }) : icon ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
98
- className: icon,
99
- "aria-hidden": "true"
100
- }) : null, children]
160
+ const cx$2 = (...values) => values.filter(Boolean).join(" ");
161
+ const Button = (0, react.forwardRef)(function Button({ variant = "secondary", size = "md", fullWidth = false, icon, loading = false, className, children, disabled, ...props }, ref) {
162
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
163
+ ...props,
164
+ ref,
165
+ type: props.type ?? "button",
166
+ disabled: disabled || loading,
167
+ "aria-busy": loading || void 0,
168
+ className: cx$2("nb-button", `nb-button--${variant}`, size === "sm" && "nb-button--sm", fullWidth && "nb-button--full", className),
169
+ children: [loading ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
170
+ className: "nb-button-spinner",
171
+ "aria-hidden": "true"
172
+ }) : icon ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
173
+ className: icon,
174
+ "aria-hidden": "true"
175
+ }) : null, children]
176
+ });
101
177
  });
102
- const IconButton = ({ icon, label, variant = "default", className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
103
- ...props,
104
- type: props.type ?? "button",
105
- "aria-label": props["aria-label"] ?? label,
106
- title: props.title ?? label,
107
- className: cx$5("nb-icon-button", variant === "danger" && "nb-icon-button--danger", className),
108
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
109
- className: icon,
110
- "aria-hidden": "true"
111
- })
178
+ const IconButton = (0, react.forwardRef)(function IconButton({ icon, label, variant = "default", className, ...props }, ref) {
179
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
180
+ ...props,
181
+ ref,
182
+ type: props.type ?? "button",
183
+ "aria-label": props["aria-label"] ?? label,
184
+ title: props.title ?? label,
185
+ className: cx$2("nb-icon-button", variant === "danger" && "nb-icon-button--danger", className),
186
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
187
+ className: icon,
188
+ "aria-hidden": "true"
189
+ })
190
+ });
112
191
  });
113
192
  //#endregion
114
193
  //#region packages/ui/UiStrings.tsx
@@ -121,6 +200,9 @@ const EN_UI_STRINGS = {
121
200
  openCalendar: "Open calendar",
122
201
  selectDate: "Select date",
123
202
  selectDateRange: "Select date range",
203
+ startDate: "Start date",
204
+ endDate: "End date",
205
+ selectTime: "Select time",
124
206
  previousMonth: "Previous month",
125
207
  nextMonth: "Next month",
126
208
  previousYear: "Previous year",
@@ -128,6 +210,16 @@ const EN_UI_STRINGS = {
128
210
  selectMonthAndYear: "Select month and year",
129
211
  selectYear: "Select year",
130
212
  clear: "Clear",
213
+ openOptions: "Open options",
214
+ noOptions: "No options found",
215
+ searching: "Searching…",
216
+ searchFailed: "Could not load options",
217
+ enterSearch: "Type to search",
218
+ loadingMore: "Loading more…",
219
+ loadMore: "Load more",
220
+ retrySearch: "Retry search",
221
+ selectedOptions: "Selected options",
222
+ removeOption: "Remove",
131
223
  today: "Today",
132
224
  cancel: "Cancel",
133
225
  confirm: "Confirm",
@@ -138,7 +230,38 @@ const EN_UI_STRINGS = {
138
230
  view: "View",
139
231
  pages: "Pages",
140
232
  previousPage: "Previous page",
141
- nextPage: "Next page"
233
+ nextPage: "Next page",
234
+ settingsMenu: "Display settings",
235
+ accentColor: "Accent color",
236
+ accentColors: "Accent colors",
237
+ density: "Density",
238
+ interfaceDensity: "Interface density",
239
+ densityNormal: "Normal",
240
+ densityCompact: "Compact",
241
+ mainNavigation: "Main navigation",
242
+ mainMenu: "Main menu",
243
+ closeMenu: "Close menu",
244
+ toggleMenu: "Toggle menu",
245
+ mainToolbar: "Main toolbar",
246
+ mainContent: "Main content",
247
+ userMenu: "User menu",
248
+ loadingSession: "Loading session",
249
+ textFormatting: "Text formatting",
250
+ bold: "Bold (Ctrl+B)",
251
+ italic: "Italic (Ctrl+I)",
252
+ strikethrough: "Strikethrough",
253
+ heading2: "Heading 2",
254
+ heading3: "Heading 3",
255
+ bulletList: "Bullet list",
256
+ orderedList: "Ordered list",
257
+ blockquote: "Blockquote",
258
+ addLink: "Add link",
259
+ removeLink: "Remove link",
260
+ undo: "Undo (Ctrl+Z)",
261
+ redo: "Redo (Ctrl+Y)",
262
+ featureUnavailable: "This feature is not available on your current plan.",
263
+ featureRequiresPlan: "This feature requires the {plan} plan. Upgrade your plan to unlock it.",
264
+ viewPlans: "View plans"
142
265
  };
143
266
  const ES_UI_STRINGS = {
144
267
  close: "Cerrar",
@@ -149,6 +272,9 @@ const ES_UI_STRINGS = {
149
272
  openCalendar: "Abrir calendario",
150
273
  selectDate: "Seleccionar fecha",
151
274
  selectDateRange: "Seleccionar rango de fechas",
275
+ startDate: "Fecha inicio",
276
+ endDate: "Fecha fin",
277
+ selectTime: "Seleccionar hora",
152
278
  previousMonth: "Mes anterior",
153
279
  nextMonth: "Mes siguiente",
154
280
  previousYear: "Año anterior",
@@ -156,6 +282,16 @@ const ES_UI_STRINGS = {
156
282
  selectMonthAndYear: "Seleccionar mes y año",
157
283
  selectYear: "Seleccionar año",
158
284
  clear: "Limpiar",
285
+ openOptions: "Abrir opciones",
286
+ noOptions: "No se encontraron opciones",
287
+ searching: "Buscando…",
288
+ searchFailed: "No se pudieron cargar las opciones",
289
+ enterSearch: "Escribe para buscar",
290
+ loadingMore: "Cargando más…",
291
+ loadMore: "Cargar más",
292
+ retrySearch: "Reintentar búsqueda",
293
+ selectedOptions: "Opciones seleccionadas",
294
+ removeOption: "Quitar",
159
295
  today: "Hoy",
160
296
  cancel: "Cancelar",
161
297
  confirm: "Confirmar",
@@ -166,7 +302,38 @@ const ES_UI_STRINGS = {
166
302
  view: "Ver",
167
303
  pages: "Páginas",
168
304
  previousPage: "Página anterior",
169
- nextPage: "Página siguiente"
305
+ nextPage: "Página siguiente",
306
+ settingsMenu: "Ajustes de visualización",
307
+ accentColor: "Color de acento",
308
+ accentColors: "Colores de acento",
309
+ density: "Densidad",
310
+ interfaceDensity: "Densidad de interfaz",
311
+ densityNormal: "Normal",
312
+ densityCompact: "Compacta",
313
+ mainNavigation: "Navegación principal",
314
+ mainMenu: "Menú principal",
315
+ closeMenu: "Cerrar menú",
316
+ toggleMenu: "Alternar menú",
317
+ mainToolbar: "Barra de herramientas principal",
318
+ mainContent: "Contenido principal",
319
+ userMenu: "Menú de usuario",
320
+ loadingSession: "Cargando sesión",
321
+ textFormatting: "Formato de texto",
322
+ bold: "Negrita (Ctrl+B)",
323
+ italic: "Cursiva (Ctrl+I)",
324
+ strikethrough: "Tachado",
325
+ heading2: "Título 2",
326
+ heading3: "Título 3",
327
+ bulletList: "Lista con viñetas",
328
+ orderedList: "Lista numerada",
329
+ blockquote: "Cita",
330
+ addLink: "Añadir enlace",
331
+ removeLink: "Quitar enlace",
332
+ undo: "Deshacer (Ctrl+Z)",
333
+ redo: "Rehacer (Ctrl+Y)",
334
+ featureUnavailable: "Esta función no está disponible en tu plan actual.",
335
+ featureRequiresPlan: "Esta función requiere el plan {plan}. Actualiza tu plan para desbloquearla.",
336
+ viewPlans: "Ver planes"
170
337
  };
171
338
  const UiStringsContext = (0, react.createContext)(EN_UI_STRINGS);
172
339
  const UiStringsProvider = ({ strings, children }) => {
@@ -187,115 +354,75 @@ const formatSize = (value) => {
187
354
  return typeof value === "number" ? `${value}px` : value;
188
355
  };
189
356
  const joinClassNames = (...values) => values.filter(Boolean).join(" ");
190
- const AppDialog = ({ visible, open, title, onClose, children, footer, width, maxWidth, height, fullScreen = false, showCloseButton = true, closeLabel, scrimLabel, closeOnOutsideClick = true, closeOnEscape = true, restoreFocus = true, keepMounted = false, rootClassName, className, headerClassName, titleClassName, bodyClassName, footerClassName, role = "dialog" }) => {
357
+ const AppDialog = ({ visible, open, title, onClose, children, footer, width, maxWidth, height, fullScreen = false, showCloseButton = true, closeLabel, scrimLabel, closeOnOutsideClick = true, closeOnEscape = true, restoreFocus = true, keepMounted = false, initialFocus, rootClassName, className, headerClassName, titleClassName, bodyClassName, footerClassName, role = "dialog" }) => {
191
358
  const strings = useUiStrings();
192
359
  const resolvedCloseLabel = closeLabel ?? strings.close;
193
360
  const resolvedScrimLabel = scrimLabel ?? strings.closeDialog;
194
361
  const isVisible = visible ?? open ?? false;
195
362
  const titleId = (0, react.useId)();
196
- const dialogRef = (0, react.useRef)(null);
197
- const lastFocusedElementRef = (0, react.useRef)(null);
198
- const restoreFocusRef = (0, react.useRef)(restoreFocus);
199
- (0, react.useEffect)(() => {
200
- restoreFocusRef.current = restoreFocus;
201
- }, [restoreFocus]);
202
- (0, react.useEffect)(() => {
203
- if (!isVisible) return;
204
- lastFocusedElementRef.current = document.activeElement;
205
- window.setTimeout(() => {
206
- (dialogRef.current?.querySelector("button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\"-1\"])"))?.focus();
207
- });
208
- return () => {
209
- if (restoreFocusRef.current) lastFocusedElementRef.current?.focus?.();
210
- };
211
- }, [isVisible]);
212
- (0, react.useEffect)(() => {
213
- if (!isVisible || !closeOnEscape) return;
214
- const handleKeyDown = (event) => {
215
- if (event.key === "Escape") {
216
- event.preventDefault();
217
- onClose();
218
- }
219
- };
220
- document.addEventListener("keydown", handleKeyDown);
221
- return () => document.removeEventListener("keydown", handleKeyDown);
222
- }, [
223
- closeOnEscape,
363
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(ModalSurface, {
364
+ open: isVisible,
224
365
  onClose,
225
- isVisible
226
- ]);
227
- if (!isVisible && !keepMounted) return null;
228
- return (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
229
- className: joinClassNames("nb-dialog-root", rootClassName),
230
- "aria-hidden": !isVisible,
366
+ rootClassName: joinClassNames("nb-dialog-root", rootClassName),
367
+ className: joinClassNames("nb-dialog", fullScreen && "nb-dialog--fullscreen", className),
368
+ scrimClassName: "nb-dialog__scrim",
369
+ scrimLabel: resolvedScrimLabel,
370
+ labelledBy: titleId,
371
+ role,
372
+ closeOnEscape,
373
+ closeOnOutsideClick,
374
+ restoreFocus,
375
+ keepMounted,
376
+ initialFocus,
231
377
  style: {
232
- pointerEvents: isVisible ? void 0 : "none",
233
- visibility: isVisible ? void 0 : "hidden"
378
+ width: formatSize(width),
379
+ maxWidth: formatSize(maxWidth),
380
+ height: formatSize(height)
234
381
  },
235
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
236
- className: "nb-dialog__scrim",
237
- type: "button",
238
- "aria-label": resolvedScrimLabel,
239
- onClick: closeOnOutsideClick ? onClose : void 0
240
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
241
- className: joinClassNames("nb-dialog", fullScreen && "nb-dialog--fullscreen", className),
242
- role,
243
- "aria-modal": "true",
244
- "aria-labelledby": titleId,
245
- ref: dialogRef,
246
- onKeyDownCapture: (event) => {
247
- if (!closeOnEscape && event.key === "Escape") {
248
- event.preventDefault();
249
- event.stopPropagation();
250
- }
251
- },
252
- style: {
253
- width: formatSize(width),
254
- maxWidth: formatSize(maxWidth),
255
- height: formatSize(height)
256
- },
257
- children: [
258
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
259
- className: joinClassNames("nb-dialog__header", headerClassName),
260
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
261
- className: joinClassNames("nb-dialog__title", titleClassName),
262
- id: titleId,
263
- children: title
264
- }), showCloseButton && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconButton, {
265
- className: "nb-dialog__close",
266
- icon: "ph ph-x",
267
- label: resolvedCloseLabel,
268
- onClick: onClose
269
- })]
270
- }),
271
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
272
- className: joinClassNames("nb-dialog__body", bodyClassName),
273
- children
274
- }),
275
- footer && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
276
- className: joinClassNames("nb-dialog__footer", footerClassName),
277
- children: footer
278
- })
279
- ]
280
- })]
281
- }), document.body);
382
+ children: [
383
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
384
+ className: joinClassNames("nb-dialog__header", headerClassName),
385
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
386
+ className: joinClassNames("nb-dialog__title", titleClassName),
387
+ id: titleId,
388
+ children: title
389
+ }), showCloseButton && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconButton, {
390
+ className: "nb-dialog__close",
391
+ icon: "ph ph-x",
392
+ label: resolvedCloseLabel,
393
+ onClick: onClose
394
+ })]
395
+ }),
396
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
397
+ className: joinClassNames("nb-dialog__body", bodyClassName),
398
+ children
399
+ }),
400
+ footer && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
401
+ className: joinClassNames("nb-dialog__footer", footerClassName),
402
+ children: footer
403
+ })
404
+ ]
405
+ });
282
406
  };
283
407
  //#endregion
284
408
  //#region packages/ui/ConfirmDialog.tsx
285
409
  function ConfirmDialog({ open, title, message, onConfirm, onCancel, confirmLabel, cancelLabel, variant = "warning" }) {
286
410
  const strings = useUiStrings();
411
+ const cancelRef = (0, react.useRef)(null);
287
412
  const resolvedConfirmLabel = confirmLabel ?? strings.confirm;
413
+ const resolvedCancelLabel = cancelLabel ?? strings.cancel;
288
414
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AppDialog, {
289
415
  open,
290
416
  title,
291
417
  onClose: onCancel,
292
418
  maxWidth: 420,
293
419
  role: "alertdialog",
420
+ initialFocus: cancelRef,
294
421
  footer: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
295
422
  variant: "secondary",
296
423
  onClick: onCancel,
297
- autoFocus: true,
298
- children: cancelLabel ?? strings.cancel
424
+ ref: cancelRef,
425
+ children: resolvedCancelLabel
299
426
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
300
427
  variant: variant === "danger" ? "danger" : "primary",
301
428
  onClick: onConfirm,
@@ -380,10 +507,10 @@ const Card = ({ title, description, variant = "auth", className, children }) =>
380
507
  };
381
508
  //#endregion
382
509
  //#region packages/ui/FormControls.tsx
383
- const cx$4 = (...values) => values.filter(Boolean).join(" ");
510
+ const cx$1 = (...values) => values.filter(Boolean).join(" ");
384
511
  const FormField = ({ label, error, helpText, children, className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
385
512
  ...props,
386
- className: cx$4("nb-form-field", !!error && "nb-form-field--error", className),
513
+ className: cx$1("nb-form-field", !!error && "nb-form-field--error", className),
387
514
  children: [
388
515
  label && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
389
516
  className: "nb-form-field__label",
@@ -404,14 +531,14 @@ const TextField = (0, react.forwardRef)(function TextField({ className, invalid,
404
531
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
405
532
  ...props,
406
533
  ref,
407
- className: cx$4("nb-input", invalid && "nb-input--invalid", className)
534
+ className: cx$1("nb-input", invalid && "nb-input--invalid", className)
408
535
  });
409
536
  });
410
537
  const SelectField = (0, react.forwardRef)(function SelectField({ className, invalid, children, ...props }, ref) {
411
538
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("select", {
412
539
  ...props,
413
540
  ref,
414
- className: cx$4("nb-input", "nb-select", invalid && "nb-input--invalid", className),
541
+ className: cx$1("nb-input", "nb-select", invalid && "nb-input--invalid", className),
415
542
  children
416
543
  });
417
544
  });
@@ -419,12 +546,12 @@ const TextAreaField = (0, react.forwardRef)(function TextAreaField({ className,
419
546
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
420
547
  ...props,
421
548
  ref,
422
- className: cx$4("nb-input", "nb-textarea", invalid && "nb-input--invalid", className)
549
+ className: cx$1("nb-input", "nb-textarea", invalid && "nb-input--invalid", className)
423
550
  });
424
551
  });
425
552
  //#endregion
426
553
  //#region packages/ui/FileDropzone.tsx
427
- function cx$3(...values) {
554
+ function cx(...values) {
428
555
  return values.filter(Boolean).join(" ");
429
556
  }
430
557
  function buildDropzoneAccept(accept) {
@@ -469,10 +596,10 @@ function FileDropzone({ accept, value = null, image = false, disabled = false, r
469
596
  const placeholderTitle = isDragActive ? labels?.dropPrompt ?? "Drop file here" : image ? labels?.imagePrompt ?? "Drop image here or click to browse" : labels?.prompt ?? "Drop file here or click to browse";
470
597
  const placeholderHint = image ? labels?.imageHint ?? "PNG, JPG, WebP or GIF" : labels?.hint ?? "Select one file";
471
598
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
472
- className: cx$3("nb-file-dropzone", image && "nb-file-dropzone--image", invalid && "nb-file-dropzone--invalid", className),
599
+ className: cx("nb-file-dropzone", image && "nb-file-dropzone--image", invalid && "nb-file-dropzone--invalid", className),
473
600
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
474
- ...getRootProps({ className: cx$3("nb-file-dropzone__zone", isDragActive && "nb-file-dropzone__zone--active", hasContent && "nb-file-dropzone__zone--filled", uploading && "nb-file-dropzone__zone--uploading", !isInteractive && "nb-file-dropzone__zone--disabled") }),
475
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", { ...getInputProps({
601
+ ...getRootProps({ className: cx("nb-file-dropzone__zone", isDragActive && "nb-file-dropzone__zone--active", hasContent && "nb-file-dropzone__zone--filled", uploading && "nb-file-dropzone__zone--uploading", disabled && "nb-file-dropzone__zone--disabled", readOnly && "nb-file-dropzone__zone--readonly") }),
602
+ children: [!readOnly && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", { ...getInputProps({
476
603
  id: inputId,
477
604
  "aria-label": inputLabel
478
605
  }) }), hasContent ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
@@ -545,9 +672,9 @@ function FileDropzone({ accept, value = null, image = false, disabled = false, r
545
672
  }),
546
673
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
547
674
  className: "nb-file-dropzone__title",
548
- children: placeholderTitle
675
+ children: readOnly ? labels?.empty ?? (image ? "No image" : "No file") : placeholderTitle
549
676
  }),
550
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
677
+ !readOnly && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
551
678
  className: "nb-file-dropzone__hint",
552
679
  children: placeholderHint
553
680
  })
@@ -564,390 +691,532 @@ function FileDropzone({ accept, value = null, image = false, disabled = false, r
564
691
  });
565
692
  }
566
693
  //#endregion
567
- //#region packages/ui/useFloatingPanel.ts
568
- /** Style applied to an anchored panel before its first position is computed. */
569
- const HIDDEN_PANEL_STYLE = {
570
- position: "fixed",
571
- visibility: "hidden",
572
- margin: 0
573
- };
574
- /**
575
- * Fixed-position style for a panel anchored to an element, clamped to the
576
- * viewport with an 8px gutter and flipped above the anchor when it fits
577
- * better there.
578
- */
579
- function computeAnchoredStyle(anchor, options = {}) {
580
- if (!anchor) return HIDDEN_PANEL_STYLE;
581
- const { align = "start", minWidth = 0, matchAnchorWidth = false, offset = 4, flipThreshold = 250, zIndex = 9999 } = options;
582
- const rect = anchor.getBoundingClientRect();
583
- const width = Math.max(matchAnchorWidth ? rect.width : 0, minWidth);
584
- const left = align === "end" ? Math.max(8, Math.min(rect.right - width, window.innerWidth - width - 8)) : Math.max(8, Math.min(rect.left, window.innerWidth - width - 8));
585
- const spaceBelow = window.innerHeight - rect.bottom;
586
- if (spaceBelow < flipThreshold && rect.top > spaceBelow) return {
587
- position: "fixed",
588
- left: `${left}px`,
589
- width: `${width}px`,
590
- bottom: `${window.innerHeight - rect.top + offset}px`,
591
- top: "auto",
592
- margin: 0,
593
- zIndex,
594
- visibility: "visible"
595
- };
596
- return {
597
- position: "fixed",
598
- left: `${left}px`,
599
- width: `${width}px`,
600
- top: `${rect.bottom + offset}px`,
601
- bottom: "auto",
602
- margin: 0,
603
- zIndex,
604
- visibility: "visible"
605
- };
606
- }
607
- function useFloatingPanel(options = {}) {
608
- const [open, setOpenState] = (0, react.useState)(false);
609
- const [panelStyle, setPanelStyle] = (0, react.useState)(HIDDEN_PANEL_STYLE);
610
- const containerRef = (0, react.useRef)(null);
611
- const panelRef = (0, react.useRef)(null);
612
- const optionsRef = (0, react.useRef)(options);
613
- optionsRef.current = options;
614
- const anchored = !!options.computeStyle;
615
- const dismissEvent = options.dismissEvent ?? "pointerdown";
616
- const setOpen = (0, react.useCallback)((next) => {
617
- setOpenState(next);
618
- if (!next) optionsRef.current.onClose?.();
619
- optionsRef.current.onOpenChange?.(next);
620
- }, []);
621
- const applyStyle = (0, react.useCallback)(() => {
622
- const compute = optionsRef.current.computeStyle;
623
- if (!compute) return;
624
- const style = compute(containerRef.current);
625
- if (style) setPanelStyle(style);
626
- }, []);
627
- const openPanel = (0, react.useCallback)(() => {
628
- applyStyle();
629
- setOpen(true);
630
- }, [applyStyle, setOpen]);
631
- const toggle = (0, react.useCallback)(() => open ? setOpen(false) : openPanel(), [
694
+ //#region packages/ui/AppDropdown.tsx
695
+ function AppDropdown({ id: idProp, ariaLabel, label, icon, value, options, onChange, disabled = false, placeholder = "Seleccionar…", variant = "form", className, showFieldLabel = variant === "form", menuMinWidth, error, helpText, menuHeader, menuFooter, onOpenChange }) {
696
+ const generatedId = (0, react.useId)();
697
+ const id = idProp ?? generatedId;
698
+ const container = useOverlayContainer();
699
+ const [open, setOpen] = (0, react.useState)(false);
700
+ const selected = options.find((option) => option.value === value);
701
+ const labelled = !!label && (showFieldLabel || variant === "toolbar");
702
+ const message = error ?? helpText;
703
+ const iconClass = icon?.startsWith("ph ") ? icon : icon?.startsWith("ph-") ? `ph ${icon}` : `ph ph-${icon}`;
704
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_select.Select.Root, {
705
+ value,
706
+ onValueChange: (next) => {
707
+ if (next !== null) onChange(next);
708
+ },
709
+ disabled,
632
710
  open,
633
- openPanel,
634
- setOpen
635
- ]);
711
+ onOpenChange: (next) => {
712
+ setOpen(next);
713
+ onOpenChange?.(next);
714
+ },
715
+ modal: false,
716
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
717
+ className: showFieldLabel && variant !== "toolbar" ? "nb-form-field" : void 0,
718
+ children: [
719
+ showFieldLabel && variant !== "toolbar" && label && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
720
+ className: "nb-form-field__label",
721
+ id: `${id}-label`,
722
+ htmlFor: id,
723
+ children: label
724
+ }),
725
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
726
+ className: [
727
+ "nb-dropdown",
728
+ `nb-dropdown--${variant}`,
729
+ open && "nb-dropdown--open",
730
+ disabled && "nb-dropdown--disabled",
731
+ className
732
+ ].filter(Boolean).join(" "),
733
+ children: [
734
+ variant === "toolbar" && label && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
735
+ className: "nb-dropdown__toolbar-label",
736
+ id: `${id}-label`,
737
+ children: [icon && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
738
+ className: iconClass,
739
+ "aria-hidden": "true"
740
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: label })]
741
+ }),
742
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_base_ui_react_select.Select.Trigger, {
743
+ id,
744
+ className: "nb-dropdown__trigger",
745
+ onKeyDownCapture: (event) => {
746
+ if (open && event.key === "Escape") {
747
+ event.preventDefault();
748
+ event.stopPropagation();
749
+ setOpen(false);
750
+ onOpenChange?.(false);
751
+ }
752
+ },
753
+ "aria-label": ariaLabel,
754
+ "aria-labelledby": ariaLabel ? void 0 : labelled ? `${id}-label ${id}-value` : `${id}-value`,
755
+ "aria-describedby": message ? `${id}-message` : void 0,
756
+ "aria-invalid": !!error || void 0,
757
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
758
+ className: "nb-dropdown__value",
759
+ id: `${id}-value`,
760
+ children: selected?.selectedLabel ?? selected?.label ?? placeholder
761
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
762
+ className: "ph ph-caret-down nb-dropdown__caret",
763
+ "aria-hidden": "true"
764
+ })]
765
+ }),
766
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_select.Select.Portal, {
767
+ container: container ?? void 0,
768
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_select.Select.Positioner, {
769
+ align: "start",
770
+ sideOffset: 4,
771
+ alignItemWithTrigger: false,
772
+ className: "nb-dropdown-positioner",
773
+ style: { minWidth: menuMinWidth },
774
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_base_ui_react_select.Select.Popup, {
775
+ onKeyDownCapture: (event) => {
776
+ if (event.key === "Escape") {
777
+ event.preventDefault();
778
+ event.stopPropagation();
779
+ setOpen(false);
780
+ onOpenChange?.(false);
781
+ }
782
+ },
783
+ className: `nb-dropdown__menu nb-dropdown__menu--${variant}`,
784
+ children: [
785
+ menuHeader,
786
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_select.Select.List, {
787
+ className: "nb-dropdown__menu-list",
788
+ children: options.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_base_ui_react_select.Select.Item, {
789
+ value: option.value,
790
+ label: option.label,
791
+ disabled: option.disabled,
792
+ className: ({ selected }) => `nb-dropdown__option${selected ? " nb-dropdown__option--active" : ""}`,
793
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_base_ui_react_select.Select.ItemText, {
794
+ className: "nb-dropdown__option-content",
795
+ children: [option.iconText && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
796
+ className: "nb-dropdown__option-icon",
797
+ "aria-hidden": "true",
798
+ children: option.iconText
799
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: option.label })]
800
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_select.Select.ItemIndicator, {
801
+ className: "nb-dropdown__selected",
802
+ "aria-hidden": "true",
803
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", { className: "ph ph-check" })
804
+ })]
805
+ }, option.value))
806
+ }),
807
+ menuFooter
808
+ ]
809
+ })
810
+ })
811
+ })
812
+ ]
813
+ }),
814
+ message && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
815
+ id: `${id}-message`,
816
+ className: error ? "nb-form-field__error" : "nb-form-field__help",
817
+ role: error ? "alert" : void 0,
818
+ children: message
819
+ })
820
+ ]
821
+ })
822
+ });
823
+ }
824
+ //#endregion
825
+ //#region packages/ui/useComboboxOptions.ts
826
+ function mergeOptions(...groups) {
827
+ const map = /* @__PURE__ */ new Map();
828
+ for (const group of groups) for (const option of group) map.set(option.value, option);
829
+ return [...map.values()];
830
+ }
831
+ function useComboboxOptions({ options, selected, loadOptions, open, query, debounceMs, minSearchLength }) {
832
+ const [state, setState] = (0, react.useState)({
833
+ query: "",
834
+ options: [],
835
+ known: [],
836
+ loading: false,
837
+ failed: false
838
+ });
839
+ const [revision, setRevision] = (0, react.useState)(0);
840
+ const generation = (0, react.useRef)(0);
841
+ const request = (0, react.useRef)(null);
842
+ const normalizedQuery = query.trim();
843
+ const eligible = normalizedQuery.length >= minSearchLength;
636
844
  (0, react.useEffect)(() => {
637
- if (!open) return;
638
- const handleOutside = (e) => {
639
- const target = e.target;
640
- if (containerRef.current?.contains(target) || panelRef.current?.contains(target)) return;
641
- setOpen(false);
642
- };
643
- const handleKeyDown = (e) => {
644
- if (e.key !== "Escape") return;
645
- setOpen(false);
646
- optionsRef.current.onEscape?.(e);
647
- };
648
- document.addEventListener(dismissEvent, handleOutside);
649
- document.addEventListener("keydown", handleKeyDown);
845
+ const currentGeneration = ++generation.current;
846
+ request.current?.abort();
847
+ request.current = null;
848
+ if (!loadOptions || !open || !eligible) return;
849
+ const controller = new AbortController();
850
+ request.current = controller;
851
+ const timer = setTimeout(async () => {
852
+ setState((previous) => ({
853
+ loader: loadOptions,
854
+ query: normalizedQuery,
855
+ options: [],
856
+ known: previous.loader === loadOptions ? previous.known : [],
857
+ loading: true,
858
+ failed: false
859
+ }));
860
+ try {
861
+ const page = await loadOptions(normalizedQuery, { signal: controller.signal });
862
+ if (controller.signal.aborted || generation.current !== currentGeneration) return;
863
+ setState((previous) => ({
864
+ loader: loadOptions,
865
+ query: normalizedQuery,
866
+ options: mergeOptions(page.options),
867
+ known: mergeOptions(previous.known, page.options),
868
+ nextCursor: page.nextCursor,
869
+ loading: false,
870
+ failed: false
871
+ }));
872
+ } catch {
873
+ if (controller.signal.aborted || generation.current !== currentGeneration) return;
874
+ setState((previous) => ({
875
+ ...previous,
876
+ loading: false,
877
+ failed: true
878
+ }));
879
+ } finally {
880
+ if (request.current === controller) request.current = null;
881
+ }
882
+ }, Math.max(0, debounceMs));
650
883
  return () => {
651
- document.removeEventListener(dismissEvent, handleOutside);
652
- document.removeEventListener("keydown", handleKeyDown);
884
+ clearTimeout(timer);
885
+ controller.abort();
653
886
  };
654
887
  }, [
655
- dismissEvent,
888
+ loadOptions,
656
889
  open,
657
- setOpen
890
+ normalizedQuery,
891
+ eligible,
892
+ debounceMs,
893
+ revision
658
894
  ]);
659
- (0, react.useLayoutEffect)(() => {
660
- if (!open || !anchored) return;
661
- const update = () => {
662
- const container = containerRef.current;
663
- if (!container) return;
664
- if (optionsRef.current.closeOnViewportExit) {
665
- const rect = container.getBoundingClientRect();
666
- if ((rect.width > 0 || rect.height > 0) && (rect.top >= window.innerHeight || rect.bottom <= 0)) {
667
- setOpen(false);
668
- return;
669
- }
670
- }
671
- applyStyle();
672
- };
673
- update();
674
- window.addEventListener("resize", update);
675
- window.addEventListener("scroll", update, {
676
- capture: true,
677
- passive: true
678
- });
679
- return () => {
680
- window.removeEventListener("resize", update);
681
- window.removeEventListener("scroll", update, { capture: true });
682
- };
895
+ const current = state.loader === loadOptions && state.query === normalizedQuery;
896
+ const loading = !!loadOptions && open && eligible && (!current || state.loading);
897
+ const failed = !!loadOptions && open && current && state.failed;
898
+ const known = mergeOptions(options, state.loader === loadOptions ? state.known : []);
899
+ const pinned = known.filter((option) => selected.includes(option.value));
900
+ const items = loadOptions ? mergeOptions(pinned, current && eligible ? state.options : []) : options;
901
+ const loadMore = (0, react.useCallback)(async () => {
902
+ if (!loadOptions || !open || !current || state.loading || request.current || state.nextCursor == null || !eligible) return;
903
+ const controller = new AbortController();
904
+ const currentGeneration = generation.current;
905
+ request.current = controller;
906
+ setState((previous) => ({
907
+ ...previous,
908
+ loading: true,
909
+ failed: false
910
+ }));
911
+ try {
912
+ const page = await loadOptions(normalizedQuery, {
913
+ signal: controller.signal,
914
+ cursor: state.nextCursor
915
+ });
916
+ if (controller.signal.aborted || currentGeneration !== generation.current) return;
917
+ setState((previous) => ({
918
+ ...previous,
919
+ options: mergeOptions(previous.options, page.options),
920
+ known: mergeOptions(previous.known, page.options),
921
+ nextCursor: page.nextCursor,
922
+ loading: false,
923
+ failed: false
924
+ }));
925
+ } catch {
926
+ if (controller.signal.aborted || currentGeneration !== generation.current) return;
927
+ setState((previous) => ({
928
+ ...previous,
929
+ loading: false,
930
+ failed: true
931
+ }));
932
+ } finally {
933
+ if (request.current === controller) request.current = null;
934
+ }
683
935
  }, [
684
- anchored,
685
- applyStyle,
936
+ loadOptions,
686
937
  open,
687
- setOpen
938
+ current,
939
+ state.loading,
940
+ state.nextCursor,
941
+ eligible,
942
+ normalizedQuery
688
943
  ]);
689
- return {
944
+ (0, react.useEffect)(() => () => {
945
+ request.current?.abort();
946
+ }, [
690
947
  open,
691
- setOpen,
692
- toggle,
693
- openPanel,
694
- containerRef,
695
- panelRef,
696
- panelStyle
948
+ normalizedQuery,
949
+ loadOptions
950
+ ]);
951
+ return {
952
+ items,
953
+ known,
954
+ loading,
955
+ failed,
956
+ eligible,
957
+ hasMore: !!loadOptions && open && eligible && current && state.nextCursor != null,
958
+ loadMore,
959
+ retry: () => setRevision((previous) => previous + 1)
697
960
  };
698
961
  }
699
962
  //#endregion
700
- //#region packages/ui/AppDropdown.tsx
701
- function cx$2(...values) {
702
- return values.filter(Boolean).join(" ");
703
- }
704
- function normalizeIcon$2(icon) {
705
- if (!icon) return void 0;
706
- if (icon.startsWith("ph ")) return icon;
707
- if (icon.startsWith("ph-")) return `ph ${icon}`;
708
- return `ph ph-${icon}`;
709
- }
710
- function AppDropdown({ id: idProp, label, icon, value, options, onChange, disabled = false, placeholder = "Seleccionar…", variant = "form", className, showFieldLabel = variant === "form", menuMinWidth, error, helpText, menuHeader, menuFooter, onOpenChange }) {
711
- const generatedId = (0, react.useId)();
712
- const id = idProp ?? generatedId;
713
- const { open, setOpen: setMenuOpen, openPanel: openMenu, containerRef, panelRef: menuRef, panelStyle: menuStyle } = useFloatingPanel({
714
- onOpenChange,
715
- dismissEvent: "mousedown",
716
- closeOnViewportExit: true,
717
- computeStyle: (container) => {
718
- return computeAnchoredStyle(container?.querySelector(".nb-dropdown__trigger") ?? container, {
719
- matchAnchorWidth: true,
720
- minWidth: menuMinWidth ?? 72
721
- });
722
- }
963
+ //#region packages/ui/Combobox.tsx
964
+ const Combobox = (0, react.forwardRef)(function Combobox(props, ref) {
965
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectionCombobox, {
966
+ ...props,
967
+ inputRef: ref,
968
+ multiple: false,
969
+ onChange: (value) => props.onChange(typeof value === "string" ? value : null)
723
970
  });
724
- const selected = options.find((option) => option.value === value);
725
- const control = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
726
- ref: containerRef,
727
- className: cx$2("nb-dropdown", `nb-dropdown--${variant}`, open && "nb-dropdown--open", disabled && "nb-dropdown--disabled", className),
728
- role: "group",
729
- "aria-labelledby": label ? `${id}-label` : void 0,
971
+ });
972
+ const MultiSelect = (0, react.forwardRef)(function MultiSelect(props, ref) {
973
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectionCombobox, {
974
+ ...props,
975
+ inputRef: ref,
976
+ multiple: true,
977
+ onChange: (value) => props.onChange(Array.isArray(value) ? value : [])
978
+ });
979
+ });
980
+ function SelectionCombobox({ options, value, onChange, label, error, helpText, invalid = false, clearable = true, emptyMessage, openLabel, clearLabel, id, name, disabled, readOnly, required, form, className, inputClassName, "aria-describedby": describedBy, loadOptions, debounceMs = 250, minSearchLength = 0, loadingMessage, searchErrorMessage, onOpenChange, multiple, inputRef, selectedLabel, removeLabel, ...inputProps }) {
981
+ const overlayContainer = useOverlayContainer();
982
+ const generatedId = (0, react.useId)();
983
+ const inputId = id ?? generatedId;
984
+ const strings = useUiStrings();
985
+ const [open, setOpen] = (0, react.useState)(false);
986
+ const [query, setQuery] = (0, react.useState)("");
987
+ const selected = Array.isArray(value) ? value : value === null ? [] : [value];
988
+ const remote = useComboboxOptions({
989
+ options,
990
+ selected,
991
+ loadOptions,
992
+ open: open && !disabled && !readOnly,
993
+ query,
994
+ debounceMs,
995
+ minSearchLength
996
+ });
997
+ const message = error ?? helpText;
998
+ const messageId = `${inputId}-message`;
999
+ const description = [describedBy, message ? messageId : void 0].filter(Boolean).join(" ") || void 0;
1000
+ const selectedOptions = selected.map((key) => remote.known.find((option) => option.value === key) ?? {
1001
+ value: key,
1002
+ label: key
1003
+ });
1004
+ const remoteStatus = remote.failed ? searchErrorMessage ?? strings.searchFailed : remote.loading ? loadingMessage ?? strings.searching : !remote.eligible && loadOptions ? strings.enterSearch : void 0;
1005
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_aria_components.ComboBox, {
1006
+ ...loadOptions ? { items: remote.items } : { defaultItems: options },
1007
+ selectionMode: multiple ? "multiple" : "single",
1008
+ value,
1009
+ onChange: (keys) => onChange(Array.isArray(keys) ? keys.map(String) : keys === null ? null : String(keys)),
1010
+ onInputChange: setQuery,
1011
+ onOpenChange: (nextOpen, trigger) => {
1012
+ setOpen(nextOpen);
1013
+ onOpenChange?.(nextOpen);
1014
+ if (!nextOpen || trigger !== "input") setQuery("");
1015
+ },
1016
+ name,
1017
+ form,
1018
+ isDisabled: disabled,
1019
+ isReadOnly: readOnly,
1020
+ isRequired: required,
1021
+ isInvalid: invalid || !!error,
1022
+ allowsEmptyCollection: true,
1023
+ "aria-label": inputProps["aria-label"],
1024
+ "aria-labelledby": inputProps["aria-labelledby"],
1025
+ className: `nb-form-field${className ? ` ${className}` : ""}`,
730
1026
  children: [
731
- variant === "toolbar" && label && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
732
- className: "nb-dropdown__toolbar-label",
733
- id: `${id}-label`,
734
- children: [icon && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
735
- className: normalizeIcon$2(icon),
736
- "aria-hidden": "true"
737
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: label })]
1027
+ label && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.Label, {
1028
+ className: "nb-form-field__label",
1029
+ children: label
738
1030
  }),
739
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
740
- type: "button",
741
- className: "nb-dropdown__trigger",
742
- "aria-haspopup": "listbox",
743
- "aria-expanded": open,
744
- "aria-labelledby": label ? `${id}-label ${id}-value` : `${id}-value`,
745
- disabled,
746
- onClick: () => open ? setMenuOpen(false) : openMenu(),
747
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
748
- className: "nb-dropdown__value",
749
- id: `${id}-value`,
750
- children: selected?.selectedLabel ?? selected?.label ?? placeholder
751
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
752
- className: "ph ph-caret-down nb-dropdown__caret",
753
- "aria-hidden": "true"
1031
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1032
+ className: "nb-combobox",
1033
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.Input, {
1034
+ ...inputProps,
1035
+ ref: inputRef,
1036
+ id: inputId,
1037
+ className: `nb-input nb-combobox__input${invalid || error ? " nb-input--invalid" : ""}${inputClassName ? ` ${inputClassName}` : ""}`,
1038
+ onKeyDown: (event) => {
1039
+ inputProps.onKeyDown?.(event);
1040
+ if (open && event.key === "Escape") event.stopPropagation();
1041
+ if (!event.defaultPrevented && event.key === "PageDown" && remote.hasMore) {
1042
+ event.preventDefault();
1043
+ remote.loadMore();
1044
+ }
1045
+ },
1046
+ "aria-invalid": inputProps["aria-invalid"] ?? (invalid || !!error || void 0),
1047
+ "aria-describedby": description
1048
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1049
+ className: "nb-combobox__actions",
1050
+ children: [clearable && !readOnly && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ComboboxClear, {
1051
+ label: clearLabel ?? strings.clear,
1052
+ disabled,
1053
+ multiple
1054
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.Button, {
1055
+ className: "nb-combobox__action",
1056
+ "aria-label": openLabel ?? strings.openOptions,
1057
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
1058
+ viewBox: "0 0 24 24",
1059
+ "aria-hidden": "true",
1060
+ focusable: "false",
1061
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "m6 9 6 6 6-6" })
1062
+ })
1063
+ })]
754
1064
  })]
755
1065
  }),
756
- open && !disabled && (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
757
- ref: menuRef,
758
- className: cx$2("nb-dropdown__menu", `nb-dropdown__menu--${variant}`),
759
- style: menuStyle,
1066
+ multiple && selectedOptions.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.ComboBoxValue, { children: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.TagGroup, {
1067
+ "aria-label": selectedLabel ?? strings.selectedOptions,
1068
+ onRemove: disabled || readOnly ? void 0 : (keys) => onChange(selected.filter((key) => !keys.has(key))),
1069
+ className: "nb-combobox-tags",
1070
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.TagList, {
1071
+ items: selectedOptions,
1072
+ children: (option) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_aria_components.Tag, {
1073
+ id: option.value,
1074
+ textValue: option.label,
1075
+ className: "nb-combobox-tags__tag",
1076
+ children: [option.label, !disabled && !readOnly && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.Button, {
1077
+ slot: "remove",
1078
+ className: "nb-combobox-tags__remove",
1079
+ "aria-label": removeLabel?.(option) ?? strings.removeOption,
1080
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
1081
+ viewBox: "0 0 24 24",
1082
+ "aria-hidden": "true",
1083
+ focusable: "false",
1084
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "m6 6 12 12M18 6 6 18" })
1085
+ })
1086
+ })]
1087
+ })
1088
+ })
1089
+ }) }),
1090
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_aria_components.Popover, {
1091
+ UNSTABLE_portalContainer: overlayContainer ?? void 0,
1092
+ className: "nb-combobox-popup",
1093
+ offset: 4,
1094
+ isNonModal: true,
1095
+ onScroll: (event) => {
1096
+ const panel = event.currentTarget;
1097
+ if (panel.scrollHeight - panel.scrollTop <= panel.clientHeight + 20) remote.loadMore();
1098
+ },
760
1099
  children: [
761
- menuHeader,
762
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
763
- role: "listbox",
764
- "aria-labelledby": label ? `${id}-label` : void 0,
765
- className: "nb-dropdown__menu-list",
766
- children: options.map((option) => {
767
- const isActive = option.value === value;
768
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", {
769
- role: "presentation",
770
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
771
- type: "button",
772
- role: "option",
773
- "aria-selected": isActive,
774
- disabled: option.disabled,
775
- className: cx$2("nb-dropdown__option", isActive && "nb-dropdown__option--active"),
776
- onClick: () => {
777
- if (option.disabled) return;
778
- onChange(option.value);
779
- setMenuOpen(false);
780
- },
781
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
782
- className: "nb-dropdown__option-content",
783
- children: [option.iconText && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
784
- className: "nb-dropdown__option-icon",
785
- "aria-hidden": "true",
786
- children: option.iconText
787
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: option.label })]
788
- })
789
- })
790
- }, option.value);
1100
+ remoteStatus && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1101
+ className: "nb-combobox-popup__empty",
1102
+ role: remote.failed ? "alert" : "status",
1103
+ children: remoteStatus
1104
+ }),
1105
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.ListBox, {
1106
+ className: "nb-combobox-popup__list",
1107
+ "aria-busy": remote.loading || void 0,
1108
+ renderEmptyState: () => remoteStatus ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1109
+ className: "nb-combobox-popup__empty",
1110
+ children: emptyMessage ?? strings.noOptions
1111
+ }),
1112
+ children: (option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.ListBoxItem, {
1113
+ id: option.value,
1114
+ textValue: option.label,
1115
+ isDisabled: option.disabled,
1116
+ className: "nb-combobox-popup__item",
1117
+ children: ({ isSelected }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1118
+ className: "nb-combobox-popup__indicator",
1119
+ "aria-hidden": "true",
1120
+ children: isSelected ? "✓" : ""
1121
+ }), option.content ?? option.label] })
791
1122
  })
792
1123
  }),
793
- menuFooter
1124
+ remote.hasMore && !remote.failed && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.Button, {
1125
+ slot: null,
1126
+ className: "nb-combobox__action",
1127
+ isDisabled: remote.loading,
1128
+ onPress: () => {
1129
+ remote.loadMore();
1130
+ },
1131
+ children: strings.loadMore
1132
+ }),
1133
+ remote.failed && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.Button, {
1134
+ className: "nb-combobox__action",
1135
+ onPress: remote.retry,
1136
+ children: strings.retrySearch
1137
+ })
794
1138
  ]
795
- }), document.body)
796
- ]
797
- });
798
- if (!showFieldLabel || variant === "toolbar") return control;
799
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
800
- className: cx$2("nb-form-field", !!error && "nb-form-field--error"),
801
- htmlFor: id,
802
- children: [
803
- label && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
804
- className: "nb-form-field__label",
805
- id: `${id}-label`,
806
- children: label
807
1139
  }),
808
- control,
809
- error ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
810
- className: "nb-form-field__error",
811
- role: "alert",
812
- children: error
813
- }) : helpText ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
814
- className: "nb-form-field__help",
815
- children: helpText
816
- }) : null
1140
+ message && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1141
+ id: messageId,
1142
+ className: error ? "nb-form-field__error" : "nb-form-field__help",
1143
+ role: error ? "alert" : void 0,
1144
+ children: message
1145
+ })
817
1146
  ]
818
1147
  });
819
1148
  }
1149
+ function ComboboxClear({ label, disabled, multiple }) {
1150
+ const state = (0, react.useContext)(react_aria_components.ComboBoxStateContext);
1151
+ const hasValue = multiple ? Array.isArray(state?.value) && state.value.length > 0 : !!state?.inputValue;
1152
+ if (!state || !hasValue || state.isOpen) return null;
1153
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.Button, {
1154
+ slot: null,
1155
+ isDisabled: disabled,
1156
+ className: "nb-combobox__action nb-combobox__clear",
1157
+ "aria-label": label,
1158
+ onPress: () => {
1159
+ state.setValue(multiple ? [] : null);
1160
+ state.setInputValue("");
1161
+ },
1162
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
1163
+ viewBox: "0 0 24 24",
1164
+ "aria-hidden": "true",
1165
+ focusable: "false",
1166
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "m6 6 12 12M18 6 6 18" })
1167
+ })
1168
+ });
1169
+ }
820
1170
  //#endregion
821
1171
  //#region packages/ui/SearchableAppDropdown.tsx
822
- function normalizeSearch(value) {
823
- return value.trim().toLowerCase();
824
- }
825
- function filterOptions(options, query) {
826
- const needle = normalizeSearch(query);
827
- if (!needle) return options;
828
- return options.filter((option) => {
829
- return [
830
- option.label,
831
- option.selectedLabel,
832
- option.value
833
- ].filter(Boolean).join(" ").toLowerCase().includes(needle);
834
- });
835
- }
836
- function SearchableAppDropdown({ options = [], searchable = true, searchPlaceholder = "Buscar…", onSearch, minSearchLength = 2, emptySearchLabel = "Sin resultados", loadingLabel = "Buscando…", selectedOption = null, value, onChange, placeholder, disabled, ...rest }) {
837
- const searchInputId = (0, react.useId)();
838
- const [open, setOpen] = (0, react.useState)(false);
839
- const [searchQuery, setSearchQuery] = (0, react.useState)("");
840
- const [remoteOptions, setRemoteOptions] = (0, react.useState)([]);
841
- const [loading, setLoading] = (0, react.useState)(false);
842
- const requestIdRef = (0, react.useRef)(0);
843
- const staticSelected = (0, react.useMemo)(() => options.find((option) => option.value === value) ?? selectedOption ?? null, [
844
- options,
845
- selectedOption,
846
- value
847
- ]);
848
- const resolvedOptions = (0, react.useMemo)(() => {
849
- const merged = /* @__PURE__ */ new Map();
850
- for (const option of [...options, ...remoteOptions]) if (option.value) merged.set(option.value, option);
851
- if (staticSelected?.value) merged.set(staticSelected.value, staticSelected);
852
- const base = Array.from(merged.values()).filter((option) => option.value !== "");
853
- if (!searchable) return base;
854
- if (onSearch) return base;
855
- return filterOptions(base, searchQuery);
856
- }, [
857
- onSearch,
858
- options,
859
- remoteOptions,
860
- searchable,
861
- searchQuery,
862
- staticSelected
863
- ]);
864
- const runSearch = (0, react.useCallback)(async (query) => {
865
- if (!onSearch) return;
866
- const trimmed = query.trim();
867
- if (trimmed.length < minSearchLength) {
868
- setRemoteOptions([]);
869
- setLoading(false);
870
- return;
871
- }
872
- const requestId = ++requestIdRef.current;
873
- setLoading(true);
874
- try {
875
- const results = await onSearch(trimmed);
876
- if (requestId !== requestIdRef.current) return;
877
- setRemoteOptions(results.filter((option) => option.value !== ""));
878
- } catch {
879
- if (requestId !== requestIdRef.current) return;
880
- setRemoteOptions([]);
881
- } finally {
882
- if (requestId === requestIdRef.current) setLoading(false);
883
- }
884
- }, [minSearchLength, onSearch]);
885
- (0, react.useEffect)(() => {
886
- if (!open || !onSearch) return;
887
- const timer = window.setTimeout(() => {
888
- runSearch(searchQuery);
889
- }, 250);
890
- return () => window.clearTimeout(timer);
891
- }, [
892
- open,
893
- onSearch,
894
- runSearch,
895
- searchQuery
896
- ]);
897
- (0, react.useEffect)(() => {
898
- if (open) return;
899
- setSearchQuery("");
900
- setRemoteOptions([]);
901
- setLoading(false);
902
- }, [open]);
903
- const menuHeader = searchable ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
904
- className: "nb-searchable-dropdown__search",
905
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
906
- className: "ph ph-magnifying-glass",
907
- "aria-hidden": "true"
908
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
909
- id: searchInputId,
910
- type: "search",
911
- value: searchQuery,
912
- onChange: (event) => setSearchQuery(event.target.value),
913
- placeholder: searchPlaceholder,
914
- autoComplete: "off",
915
- onKeyDown: (event) => event.stopPropagation()
916
- })]
917
- }) : null;
918
- const menuFooter = (() => {
919
- if (!searchable || !onSearch) return null;
920
- if (loading) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
921
- className: "nb-searchable-dropdown__status",
922
- children: loadingLabel
923
- });
924
- if (searchQuery.trim().length < minSearchLength) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
925
- className: "nb-searchable-dropdown__status",
926
- children: [
927
- "Escribe al menos ",
928
- minSearchLength,
929
- " caracteres"
930
- ]
931
- });
932
- if (resolvedOptions.length === 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
933
- className: "nb-searchable-dropdown__status",
934
- children: emptySearchLabel
935
- });
936
- return null;
937
- })();
938
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AppDropdown, {
1172
+ const toOption = (option) => ({
1173
+ value: option.value,
1174
+ label: option.selectedLabel ?? option.label,
1175
+ disabled: option.disabled,
1176
+ content: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1177
+ className: "nb-dropdown__option-content",
1178
+ children: [option.iconText && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1179
+ className: "nb-dropdown__option-icon",
1180
+ "aria-hidden": "true",
1181
+ children: option.iconText
1182
+ }), option.label]
1183
+ })
1184
+ });
1185
+ function SearchableAppDropdown({ options = [], searchable = true, searchPlaceholder = "Buscar…", onSearch, minSearchLength = 2, emptySearchLabel = "Sin resultados", loadingLabel = "Buscando…", selectedOption, value, onChange, placeholder, disabled, label, showFieldLabel, variant, icon: _icon, menuMinWidth: _menuMinWidth, menuHeader: _header, menuFooter: _footer, ...rest }) {
1186
+ const loadOptions = (0, react.useCallback)(async (query, { signal }) => {
1187
+ const results = await onSearch(query.trim());
1188
+ if (signal.aborted) throw new DOMException("Search cancelled", "AbortError");
1189
+ return { options: results.map(toOption) };
1190
+ }, [onSearch]);
1191
+ if (!searchable) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AppDropdown, {
939
1192
  ...rest,
1193
+ options,
940
1194
  value,
941
1195
  onChange,
942
1196
  placeholder,
943
1197
  disabled,
944
- options: [{
945
- value: "",
946
- label: placeholder ?? "Seleccionar…"
947
- }, ...resolvedOptions],
948
- menuHeader,
949
- menuFooter,
950
- onOpenChange: setOpen
1198
+ label,
1199
+ showFieldLabel,
1200
+ variant,
1201
+ icon: _icon,
1202
+ menuMinWidth: _menuMinWidth,
1203
+ menuHeader: _header,
1204
+ menuFooter: _footer
1205
+ });
1206
+ const seeds = selectedOption && !options.some((option) => option.value === selectedOption.value) ? [...options, selectedOption] : options;
1207
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Combobox, {
1208
+ ...rest,
1209
+ label: showFieldLabel === false ? void 0 : label,
1210
+ "aria-label": showFieldLabel === false && typeof label === "string" ? label : void 0,
1211
+ placeholder: placeholder ?? searchPlaceholder,
1212
+ options: seeds.map(toOption),
1213
+ value: value || null,
1214
+ onChange: (next) => onChange(next ?? ""),
1215
+ disabled,
1216
+ loadOptions: onSearch ? loadOptions : void 0,
1217
+ minSearchLength,
1218
+ emptyMessage: emptySearchLabel,
1219
+ loadingMessage: loadingLabel
951
1220
  });
952
1221
  }
953
1222
  //#endregion
@@ -1010,7 +1279,7 @@ function applyThemeAttributes(theme, themePrefix) {
1010
1279
  themeValues.forEach((value) => root.classList.remove(`${themePrefix}${value}`));
1011
1280
  root.classList.add(`${themePrefix}${theme}`);
1012
1281
  }
1013
- const ThemeProvider = ({ storageKey = "nb-theme", themePrefix = "nb-theme-", basePath = "/themes/", children }) => {
1282
+ const ThemeProvider = ({ storageKey = "nb-theme", themePrefix = "nb-theme-", basePath = "/themes/", visualStyle = "default", children }) => {
1014
1283
  const getPersistedMode = () => {
1015
1284
  const persisted = window.localStorage.getItem(storageKey);
1016
1285
  return persisted && themeModes.includes(persisted) ? persisted : "auto";
@@ -1019,6 +1288,15 @@ const ThemeProvider = ({ storageKey = "nb-theme", themePrefix = "nb-theme-", bas
1019
1288
  const [systemTheme, setSystemTheme] = (0, react.useState)(getSystemTheme);
1020
1289
  const [isLoaded, setIsLoaded] = (0, react.useState)(false);
1021
1290
  const theme = (0, react.useMemo)(() => resolveTheme(mode, systemTheme), [mode, systemTheme]);
1291
+ (0, react.useEffect)(() => {
1292
+ const root = document.documentElement;
1293
+ const previous = root.getAttribute("data-visual-style");
1294
+ root.setAttribute("data-visual-style", visualStyle);
1295
+ return () => {
1296
+ if (previous === null) root.removeAttribute("data-visual-style");
1297
+ else root.setAttribute("data-visual-style", previous);
1298
+ };
1299
+ }, [visualStyle]);
1022
1300
  (0, react.useEffect)(() => {
1023
1301
  applyThemeAttributes(theme, themePrefix);
1024
1302
  setThemeToDOM(`${basePath}${themePrefix}${theme}.css`).then(() => setIsLoaded(true));
@@ -1174,21 +1452,22 @@ function useAccentColor() {
1174
1452
  //#endregion
1175
1453
  //#region packages/ui/SettingsPanel.tsx
1176
1454
  const SettingsPanel = ({ onClose: _onClose }) => {
1455
+ const strings = useUiStrings();
1177
1456
  const { density, toggleDensity } = useDensity();
1178
1457
  const { accent, changeAccent, presets } = useAccentColor();
1179
1458
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1180
1459
  className: "nb-settings-panel",
1181
1460
  role: "menu",
1182
- "aria-label": "Display settings",
1461
+ "aria-label": strings.settingsMenu,
1183
1462
  children: [
1184
1463
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1185
1464
  className: "nb-settings-panel__heading",
1186
- children: "Color de acento"
1465
+ children: strings.accentColor
1187
1466
  }),
1188
1467
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1189
1468
  className: "nb-settings-panel__swatches",
1190
1469
  role: "group",
1191
- "aria-label": "Colores de acento",
1470
+ "aria-label": strings.accentColors,
1192
1471
  children: presets.map((preset) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1193
1472
  className: "nb-settings-panel__swatch",
1194
1473
  type: "button",
@@ -1205,12 +1484,12 @@ const SettingsPanel = ({ onClose: _onClose }) => {
1205
1484
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("hr", { className: "nb-settings-panel__divider" }),
1206
1485
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1207
1486
  className: "nb-settings-panel__heading",
1208
- children: "Densidad"
1487
+ children: strings.density
1209
1488
  }),
1210
1489
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1211
1490
  className: "nb-settings-panel__density",
1212
1491
  role: "group",
1213
- "aria-label": "Densidad de interfaz",
1492
+ "aria-label": strings.interfaceDensity,
1214
1493
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1215
1494
  className: "nb-settings-panel__density-btn",
1216
1495
  type: "button",
@@ -1219,7 +1498,7 @@ const SettingsPanel = ({ onClose: _onClose }) => {
1219
1498
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
1220
1499
  className: "ph ph-rows",
1221
1500
  "aria-hidden": "true"
1222
- }), "Normal"]
1501
+ }), strings.densityNormal]
1223
1502
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1224
1503
  className: "nb-settings-panel__density-btn",
1225
1504
  type: "button",
@@ -1228,7 +1507,7 @@ const SettingsPanel = ({ onClose: _onClose }) => {
1228
1507
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
1229
1508
  className: "ph ph-rows-plus-bottom",
1230
1509
  "aria-hidden": "true"
1231
- }), "Compact"]
1510
+ }), strings.densityCompact]
1232
1511
  })]
1233
1512
  })
1234
1513
  ]
@@ -1237,22 +1516,25 @@ const SettingsPanel = ({ onClose: _onClose }) => {
1237
1516
  //#endregion
1238
1517
  //#region packages/ui/Badge.tsx
1239
1518
  const Badge = ({ variant = "primary", size = "md", outlined = false, pill = true, dot = false, children, className }) => {
1519
+ const classes = [
1520
+ "nb-badge",
1521
+ `nb-badge--${variant}`,
1522
+ size === "sm" && "nb-badge--sm",
1523
+ outlined && "nb-badge--outlined",
1524
+ pill && "nb-badge--pill",
1525
+ dot && "nb-badge--dot",
1526
+ className
1527
+ ].filter(Boolean).join(" ");
1240
1528
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1241
- className: [
1242
- "nb-badge",
1243
- `nb-badge--${variant}`,
1244
- size === "sm" && "nb-badge--sm",
1245
- outlined && "nb-badge--outlined",
1246
- pill && "nb-badge--pill",
1247
- dot && "nb-badge--dot",
1248
- className
1249
- ].filter(Boolean).join(" "),
1529
+ className: classes,
1250
1530
  children: dot ? null : children
1251
1531
  });
1252
1532
  };
1253
1533
  //#endregion
1254
1534
  //#region packages/ui/FeatureGate.tsx
1255
- function FeatureGate({ featureKey, children, enabled = false, behavior = "lock", planBadge = "Pro", upgradeMessage, upgradeUrl = "/settings", lockTooltip = "Esta función no está disponible en tu plan actual." }) {
1535
+ function FeatureGate({ featureKey, children, enabled = false, behavior = "lock", planBadge = "Pro", upgradeMessage, upgradeUrl = "/settings", lockTooltip }) {
1536
+ const strings = useUiStrings();
1537
+ const tooltip = lockTooltip ?? strings.featureUnavailable;
1256
1538
  if (enabled) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1257
1539
  className: "feature-gate",
1258
1540
  children
@@ -1265,15 +1547,16 @@ function FeatureGate({ featureKey, children, enabled = false, behavior = "lock",
1265
1547
  });
1266
1548
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1267
1549
  className: "feature-gate--locked",
1268
- title: lockTooltip,
1269
- "aria-label": lockTooltip,
1550
+ title: tooltip,
1551
+ "aria-label": tooltip,
1270
1552
  role: "presentation",
1271
1553
  children
1272
1554
  });
1273
1555
  }
1274
1556
  function UpgradeGate({ planBadge, upgradeMessage, upgradeUrl, children }) {
1557
+ const strings = useUiStrings();
1275
1558
  const [open, setOpen] = (0, react.useState)(false);
1276
- const message = upgradeMessage ?? `Esta función requiere el plan ${planBadge}. Actualiza tu plan para desbloquearla.`;
1559
+ const message = upgradeMessage ?? strings.featureRequiresPlan.replace("{plan}", planBadge);
1277
1560
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1278
1561
  className: "feature-gate--upgrade",
1279
1562
  onBlur: (e) => {
@@ -1309,13 +1592,13 @@ function UpgradeGate({ planBadge, upgradeMessage, upgradeUrl, children }) {
1309
1592
  children: [
1310
1593
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconButton, {
1311
1594
  icon: "ph ph-x",
1312
- label: "Cerrar",
1595
+ label: strings.close,
1313
1596
  onClick: () => setOpen(false)
1314
1597
  }),
1315
1598
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: message }),
1316
1599
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
1317
1600
  href: upgradeUrl,
1318
- children: "Ver planes"
1601
+ children: strings.viewPlans
1319
1602
  })
1320
1603
  ]
1321
1604
  })
@@ -1356,22 +1639,23 @@ const DEFAULT_ICONS = {
1356
1639
  warning: "warning",
1357
1640
  success: "check-circle"
1358
1641
  };
1359
- const EmptyState = ({ icon, variant = "default", title, description, action, size = "md", fill = false, className }) => {
1642
+ const EmptyState = ({ icon, illustration, variant = "default", title, description, action, size = "md", fill = false, className }) => {
1360
1643
  const iconName = icon ?? DEFAULT_ICONS[variant];
1644
+ const classes = [
1645
+ "nb-empty-state",
1646
+ `nb-empty-state--${variant}`,
1647
+ `nb-empty-state--${size}`,
1648
+ fill && "nb-empty-state--fill",
1649
+ className
1650
+ ].filter(Boolean).join(" ");
1361
1651
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1362
- className: [
1363
- "nb-empty-state",
1364
- `nb-empty-state--${variant}`,
1365
- `nb-empty-state--${size}`,
1366
- fill && "nb-empty-state--fill",
1367
- className
1368
- ].filter(Boolean).join(" "),
1652
+ className: classes,
1369
1653
  role: "status",
1370
1654
  "aria-live": "polite",
1371
1655
  children: [
1372
1656
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1373
1657
  className: "nb-empty-state__icon-wrap",
1374
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
1658
+ children: illustration ?? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
1375
1659
  className: `ph ph-${iconName}`,
1376
1660
  "aria-hidden": "true"
1377
1661
  })
@@ -1398,12 +1682,13 @@ const EmptyState = ({ icon, variant = "default", title, description, action, siz
1398
1682
  * Use for category filters, tag lists, and multi-select inputs.
1399
1683
  */
1400
1684
  const Chip = ({ label, active = false, count, icon, size = "md", disabled = false, onClick, className = "" }) => {
1685
+ const sizeClass = size !== "md" ? ` nb-chip--${size}` : "";
1401
1686
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1402
1687
  type: "button",
1403
1688
  role: "checkbox",
1404
1689
  "aria-checked": active,
1405
1690
  disabled,
1406
- className: `nb-chip${size !== "md" ? ` nb-chip--${size}` : ""}${active ? " is-active" : ""}${className ? ` ${className}` : ""}`,
1691
+ className: `nb-chip${sizeClass}${active ? " is-active" : ""}${className ? ` ${className}` : ""}`,
1407
1692
  onClick,
1408
1693
  children: [
1409
1694
  icon && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
@@ -1451,73 +1736,51 @@ const Toggle = ({ checked, onChange, label, size = "md", disabled = false, "aria
1451
1736
  };
1452
1737
  //#endregion
1453
1738
  //#region packages/ui/ContextMenu.tsx
1454
- const MENU_MIN_WIDTH = 190;
1455
- /**
1456
- * Three-dot overflow context menu.
1457
- * Replaces the legacy `shared/ui/library/card-menu/CardMenu` component.
1458
- *
1459
- * Features over CardMenu:
1460
- * - `danger` variant items
1461
- * - `separator` support
1462
- * - `icon` per item
1463
- * - Custom trigger slot
1464
- * - Left/right alignment
1465
- * - Click-outside + Escape to close
1466
- * - Portalled dropdown (avoids clip inside scrollable tables)
1467
- */
1468
1739
  const ContextMenu = ({ items, visible = true, trigger, triggerLabel = "Opciones", align = "right", className = "" }) => {
1469
- const { open, setOpen, toggle, containerRef, panelRef: menuRef, panelStyle: menuStyle } = useFloatingPanel({
1470
- dismissEvent: "mousedown",
1471
- closeOnViewportExit: true,
1472
- computeStyle: (container) => computeAnchoredStyle(container, {
1473
- align: align === "right" ? "end" : "start",
1474
- minWidth: MENU_MIN_WIDTH,
1475
- flipThreshold: 200,
1476
- zIndex: 1600
1477
- })
1478
- });
1740
+ const container = useOverlayContainer();
1741
+ const triggerRef = (0, react.useRef)(null);
1742
+ const restoreFocus = (0, react.useRef)(false);
1479
1743
  if (!visible) return null;
1480
- const dropdown = open ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
1481
- ref: menuRef,
1482
- className: "nb-context-menu__dropdown nb-context-menu__dropdown--portaled",
1483
- role: "menu",
1484
- style: menuStyle,
1485
- children: items.map((item, idx) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react.default.Fragment, { children: [item.separator && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", {
1486
- role: "none",
1487
- "aria-hidden": "true",
1488
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "nb-context-menu__separator" })
1489
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", {
1490
- role: "none",
1491
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1492
- type: "button",
1493
- role: "menuitem",
1494
- disabled: item.disabled,
1495
- "aria-disabled": item.disabled,
1496
- className: `nb-context-menu__item${item.danger ? " nb-context-menu__item--danger" : ""}`,
1497
- onClick: () => {
1498
- setOpen(false);
1499
- item.onClick?.();
1500
- },
1501
- children: [item.icon && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
1502
- className: item.icon,
1503
- "aria-hidden": "true"
1504
- }), item.label]
1505
- })
1506
- })] }, idx))
1507
- }) : null;
1508
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1509
- ref: containerRef,
1510
- className: `nb-context-menu${className ? ` ${className}` : ""}`,
1511
- children: [trigger ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1512
- onClick: toggle,
1513
- children: trigger
1514
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconButton, {
1515
- icon: "ph ph-dots-three",
1516
- label: triggerLabel,
1517
- "aria-haspopup": "menu",
1518
- "aria-expanded": open,
1519
- onClick: toggle
1520
- }), dropdown && (0, react_dom.createPortal)(dropdown, document.body)]
1744
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_menu.Menu.Root, {
1745
+ modal: false,
1746
+ onOpenChange: (open, details) => {
1747
+ restoreFocus.current = !open && (details.reason === "item-press" || details.reason === "escape-key");
1748
+ },
1749
+ onOpenChangeComplete: (open) => {
1750
+ if (!open && restoreFocus.current) triggerRef.current?.focus({ preventScroll: true });
1751
+ },
1752
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1753
+ className: `nb-context-menu${className ? ` ${className}` : ""}`,
1754
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_menu.Menu.Trigger, {
1755
+ ref: triggerRef,
1756
+ render: (0, react.isValidElement)(trigger) ? trigger : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconButton, {
1757
+ icon: "ph ph-dots-three",
1758
+ label: triggerLabel,
1759
+ children: trigger
1760
+ })
1761
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_menu.Menu.Portal, {
1762
+ container: container ?? void 0,
1763
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_menu.Menu.Positioner, {
1764
+ align: align === "right" ? "end" : "start",
1765
+ sideOffset: 4,
1766
+ className: "nb-context-menu-positioner",
1767
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_menu.Menu.Popup, {
1768
+ finalFocus: triggerRef,
1769
+ className: "nb-context-menu__dropdown",
1770
+ children: items.map((item, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react.default.Fragment, { children: [item.separator && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_menu.Menu.Separator, { className: "nb-context-menu__separator" }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_base_ui_react_menu.Menu.Item, {
1771
+ disabled: item.disabled,
1772
+ label: item.label,
1773
+ className: `nb-context-menu__item${item.danger ? " nb-context-menu__item--danger" : ""}`,
1774
+ onClick: item.onClick,
1775
+ children: [item.icon && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
1776
+ className: item.icon,
1777
+ "aria-hidden": "true"
1778
+ }), item.label]
1779
+ })] }, index))
1780
+ })
1781
+ })
1782
+ })]
1783
+ })
1521
1784
  });
1522
1785
  };
1523
1786
  //#endregion
@@ -1842,6 +2105,7 @@ const CollapsibleSection = ({ label, icon, open, onToggle, children, trailing, c
1842
2105
  className: "nb-collapsible__header",
1843
2106
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1844
2107
  type: "button",
2108
+ id: `${bodyId}-trigger`,
1845
2109
  className: "nb-collapsible__trigger",
1846
2110
  "aria-expanded": open,
1847
2111
  "aria-controls": bodyId,
@@ -1868,1122 +2132,699 @@ const CollapsibleSection = ({ label, icon, open, onToggle, children, trailing, c
1868
2132
  id: bodyId,
1869
2133
  className: ["nb-collapsible__body", bodyClassName].filter(Boolean).join(" "),
1870
2134
  role: "region",
1871
- "aria-labelledby": void 0,
2135
+ "aria-labelledby": `${bodyId}-trigger`,
1872
2136
  hidden: !open,
1873
2137
  children
1874
2138
  })]
1875
2139
  });
1876
2140
  };
1877
2141
  //#endregion
1878
- //#region packages/ui/DatePicker.tsx
1879
- const cx$1 = (...values) => values.filter(Boolean).join(" ");
1880
- const ISO_DATE_RE$1 = /^\d{4}-\d{2}-\d{2}$/;
1881
- const getLocale$1 = (override) => override || document.documentElement.lang || navigator.language || "en-US";
1882
- const pad$1 = (value) => String(value).padStart(2, "0");
1883
- const toIsoDate$1 = (date) => `${date.getFullYear()}-${pad$1(date.getMonth() + 1)}-${pad$1(date.getDate())}`;
1884
- const parseIsoDate$1 = (value) => {
1885
- if (!value || !ISO_DATE_RE$1.test(value)) return null;
1886
- const [year, month, day] = value.split("-").map(Number);
1887
- const date = new Date(year, month - 1, day);
1888
- if (date.getFullYear() !== year || date.getMonth() !== month - 1 || date.getDate() !== day) return null;
1889
- return date;
1890
- };
1891
- const startOfMonth$1 = (date) => new Date(date.getFullYear(), date.getMonth(), 1);
1892
- const addMonths$1 = (date, months) => new Date(date.getFullYear(), date.getMonth() + months, 1);
1893
- const formatDisplayDate$1 = (value, locale) => {
1894
- const date = parseIsoDate$1(value);
1895
- if (!date) return "";
1896
- return new Intl.DateTimeFormat(getLocale$1(locale), {
1897
- day: "2-digit",
1898
- month: "2-digit",
1899
- year: "numeric"
1900
- }).format(date);
1901
- };
1902
- const formatMonthLabel$1 = (date, locale) => new Intl.DateTimeFormat(getLocale$1(locale), {
1903
- month: "long",
1904
- year: "numeric"
1905
- }).format(date);
1906
- /**
1907
- * Locale-aware first day of week.
1908
- * Uses Intl.Locale.weekInfo (Chrome 99+, FF 126+, Safari 17+) with fallback heuristic.
1909
- */
1910
- const getFirstDayOfWeek = (locale) => {
1911
- try {
1912
- const info = new Intl.Locale(getLocale$1(locale)).weekInfo;
1913
- if (info && typeof info.firstDay === "number") return info.firstDay === 7 ? 0 : info.firstDay;
1914
- } catch {}
1915
- const country = (getLocale$1(locale).split("-")[1] ?? "").toUpperCase();
1916
- return [
1917
- "US",
1918
- "CA",
1919
- "MX",
1920
- "CN",
1921
- "JP",
1922
- "KR",
1923
- "SA",
1924
- "EG",
1925
- "IL",
1926
- "BR"
1927
- ].includes(country) ? 0 : 1;
1928
- };
1929
- const buildCalendarDays$1 = (month, min, max, locale) => {
1930
- const first = startOfMonth$1(month);
1931
- const firstDayOfWeek = getFirstDayOfWeek(locale);
1932
- const offset = (first.getDay() - firstDayOfWeek + 7) % 7;
1933
- const minDate = parseIsoDate$1(min);
1934
- const maxDate = parseIsoDate$1(max);
1935
- const start = new Date(first);
1936
- start.setDate(first.getDate() - offset);
1937
- return Array.from({ length: 42 }, (_, i) => {
1938
- const date = new Date(start);
1939
- date.setDate(start.getDate() + i);
1940
- return {
2142
+ //#region packages/ui/CalendarContent.tsx
2143
+ /** Shared presentation; React Aria owns navigation, focus and range preview. */
2144
+ function CalendarContent() {
2145
+ const strings = useUiStrings();
2146
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("header", {
2147
+ className: "nb-calendar__header",
2148
+ children: [
2149
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.Button, {
2150
+ slot: "previous",
2151
+ className: "nb-date-picker__nav",
2152
+ "aria-label": strings.previousMonth,
2153
+ children: "‹"
2154
+ }),
2155
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2156
+ className: "nb-calendar__selectors",
2157
+ children: [
2158
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.Heading, { className: "nb-calendar__heading" }),
2159
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.CalendarMonthPicker, { children: ({ items, value, onChange, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("select", {
2160
+ ...props,
2161
+ value,
2162
+ onChange: (event) => onChange(Number(event.target.value)),
2163
+ children: items.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
2164
+ value: item.id,
2165
+ children: item.formatted
2166
+ }, item.id))
2167
+ }) }),
2168
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.CalendarYearPicker, { children: ({ items, value, onChange, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("select", {
2169
+ ...props,
2170
+ value,
2171
+ onChange: (event) => onChange(Number(event.target.value)),
2172
+ children: items.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
2173
+ value: item.id,
2174
+ children: item.formatted
2175
+ }, item.id))
2176
+ }) })
2177
+ ]
2178
+ }),
2179
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.Button, {
2180
+ slot: "next",
2181
+ className: "nb-date-picker__nav",
2182
+ "aria-label": strings.nextMonth,
2183
+ children: "›"
2184
+ })
2185
+ ]
2186
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_aria_components.CalendarGrid, {
2187
+ className: "nb-calendar__grid",
2188
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.CalendarGridHeader, { children: (day) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.CalendarHeaderCell, {
2189
+ className: "nb-calendar__weekday",
2190
+ children: day
2191
+ }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.CalendarGridBody, { children: (date) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.CalendarCell, {
1941
2192
  date,
1942
- iso: toIsoDate$1(date),
1943
- inCurrentMonth: date.getMonth() === month.getMonth(),
1944
- disabled: Boolean(minDate && date < minDate || maxDate && date > maxDate)
1945
- };
1946
- });
1947
- };
1948
- const isIsoDateDisabled = (iso, min, max) => {
1949
- const date = parseIsoDate$1(iso);
1950
- if (!date) return true;
1951
- const minDate = parseIsoDate$1(min);
1952
- const maxDate = parseIsoDate$1(max);
1953
- return Boolean(minDate && date < minDate || maxDate && date > maxDate);
1954
- };
1955
- const weekDayLabels = (locale) => {
1956
- const firstDayOfWeek = getFirstDayOfWeek(locale);
1957
- const anchor = new Date(2026, 5, 7);
1958
- const formatter = new Intl.DateTimeFormat(getLocale$1(locale), { weekday: "narrow" });
1959
- return Array.from({ length: 7 }, (_, i) => {
1960
- const date = new Date(anchor);
1961
- date.setDate(anchor.getDate() + (firstDayOfWeek + i) % 7);
1962
- return formatter.format(date);
2193
+ className: "nb-calendar__day"
2194
+ }) })]
2195
+ })] });
2196
+ }
2197
+ /** A parent modal owns containment; a standalone picker needs its own focus scope. */
2198
+ function CalendarDialog({ id, ariaLabel, children }) {
2199
+ return useOverlayContainer() ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("section", {
2200
+ id,
2201
+ "aria-label": ariaLabel,
2202
+ role: "dialog",
2203
+ tabIndex: -1,
2204
+ children
2205
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.Dialog, {
2206
+ id,
2207
+ "aria-label": ariaLabel,
2208
+ children
1963
2209
  });
2210
+ }
2211
+ //#endregion
2212
+ //#region packages/ui/dateValues.ts
2213
+ const getDateLocale = (locale) => locale || typeof document !== "undefined" && document.documentElement.lang || typeof navigator !== "undefined" && navigator.language || "en-US";
2214
+ const calendarDate = (value) => {
2215
+ if (!value || !/^\d{4}-\d{2}-\d{2}$/.test(value)) return null;
2216
+ try {
2217
+ return (0, _internationalized_date.parseDate)(value);
2218
+ } catch {
2219
+ return null;
2220
+ }
1964
2221
  };
1965
- /** Short month labels (Jan, Feb, …) — capitalized for display. */
1966
- const getMonthLabels = (locale) => {
1967
- const formatter = new Intl.DateTimeFormat(getLocale$1(locale), { month: "short" });
1968
- return Array.from({ length: 12 }, (_, i) => {
1969
- const label = formatter.format(new Date(2024, i, 1));
1970
- return label.charAt(0).toUpperCase() + label.slice(1).replace(".", "");
1971
- });
2222
+ const formatDate = (value, locale) => {
2223
+ const date = calendarDate(value);
2224
+ return date ? new Intl.DateTimeFormat(locale, {
2225
+ day: "2-digit",
2226
+ month: "2-digit",
2227
+ year: "numeric",
2228
+ timeZone: "UTC"
2229
+ }).format(date.toDate("UTC")) : "";
1972
2230
  };
1973
- /** Year range: 12-year block containing the given year. */
1974
- const getYearRangeStart = (year) => Math.floor(year / 12) * 12;
1975
- /**
1976
- * Applies dd/mm/yyyy mask.
1977
- * Auto-inserts trailing slash when adding the 2nd or 4th digit.
1978
- * Does NOT add trailing slash when the user is deleting.
1979
- */
1980
- const applyDateMask = (rawValue, prevValue) => {
2231
+ const dateAllowed = (value, min, max) => Boolean(calendarDate(value)) && (!min || value >= min) && (!max || value <= max);
2232
+ const dateOrder = (locale) => new Intl.DateTimeFormat(getDateLocale(locale), {
2233
+ day: "2-digit",
2234
+ month: "2-digit",
2235
+ year: "numeric",
2236
+ timeZone: "UTC"
2237
+ }).formatToParts(new Date(Date.UTC(2026, 10, 23))).filter((part) => [
2238
+ "day",
2239
+ "month",
2240
+ "year"
2241
+ ].includes(part.type)).map((part) => part.type);
2242
+ const datePlaceholder = (locale) => dateOrder(locale).map((part) => part === "year" ? "yyyy" : part === "month" ? "mm" : "dd").join("/");
2243
+ const applyDateMask = (rawValue, prevValue, locale) => {
2244
+ if (/^\d{4}-\d{2}-\d{2}$/.test(rawValue)) return rawValue;
1981
2245
  const digits = rawValue.replace(/\D/g, "").slice(0, 8);
1982
- const prevDigits = prevValue.replace(/\D/g, "");
1983
- const isAdding = digits.length > prevDigits.length;
1984
- if (digits.length === 0) return "";
1985
- let result = digits.slice(0, 2);
1986
- if (digits.length > 2) result += "/" + digits.slice(2, 4);
1987
- if (digits.length > 4) result += "/" + digits.slice(4, 8);
1988
- if (isAdding && (digits.length === 2 || digits.length === 4)) result += "/";
2246
+ const adding = digits.length > prevValue.replace(/\D/g, "").length;
2247
+ const sizes = dateOrder(locale ?? "es-PE").map((part) => part === "year" ? 4 : 2);
2248
+ let offset = 0;
2249
+ let result = "";
2250
+ for (const [i, size] of sizes.entries()) {
2251
+ result += digits.slice(offset, offset + size);
2252
+ offset += size;
2253
+ if (i < 2 && (digits.length > offset || adding && digits.length === offset)) result += "/";
2254
+ }
1989
2255
  return result;
1990
2256
  };
1991
- /**
1992
- * Parses dd/mm/yyyy or ISO yyyy-mm-dd to ISO string.
1993
- * Returns null if not a valid date.
1994
- */
1995
2257
  const parseDisplayDate = (text, locale) => {
1996
- const match = text.match(/^(\d{1,2})[/-](\d{1,2})[/-](\d{4})$/);
1997
- if (match) {
1998
- const [, a, b, year] = match;
1999
- const [dd, mm] = (getLocale$1(locale).split("-")[1] ?? "").toUpperCase() === "US" ? [b, a] : [a, b];
2000
- const iso = `${year}-${mm.padStart(2, "0")}-${dd.padStart(2, "0")}`;
2001
- return parseIsoDate$1(iso) ? iso : null;
2002
- }
2003
- if (ISO_DATE_RE$1.test(text)) return parseIsoDate$1(text) ? text : null;
2004
- return null;
2258
+ if (calendarDate(text)) return text;
2259
+ const order = dateOrder(locale);
2260
+ const digits = text.match(/\d+/g);
2261
+ if (!digits || digits.length !== 3) return null;
2262
+ const fields = Object.fromEntries(order.map((key, i) => [key, digits[i]]));
2263
+ if (fields.year?.length !== 4) return null;
2264
+ const iso = `${fields.year}-${fields.month?.padStart(2, "0")}-${fields.day?.padStart(2, "0")}`;
2265
+ return calendarDate(iso) ? iso : null;
2005
2266
  };
2006
- const DatePicker = (0, react.forwardRef)(function DatePicker({ id, name, value, placeholder = "dd/mm/yyyy", disabled = false, readOnly = false, required = false, invalid = false, clearable = true, locale, min, max, className, ariaLabel, onChange, onBlur }, ref) {
2007
- const generatedId = (0, react.useId)();
2008
- const inputId = id ?? generatedId;
2009
- const panelId = `${inputId}-panel`;
2010
- const strings = useUiStrings();
2011
- const selectedDate = parseIsoDate$1(value);
2012
- const resolvedLocale = getLocale$1(locale);
2013
- const displayValue = formatDisplayDate$1(value, resolvedLocale);
2014
- const [viewMode, setViewMode] = (0, react.useState)("days");
2015
- const [month, setMonth] = (0, react.useState)(() => startOfMonth$1(selectedDate ?? /* @__PURE__ */ new Date()));
2016
- const [yearRangeStart, setYearRangeStart] = (0, react.useState)(() => getYearRangeStart((/* @__PURE__ */ new Date()).getFullYear()));
2017
- const [focusedIso, setFocusedIso] = (0, react.useState)(null);
2018
- const [inputText, setInputText] = (0, react.useState)("");
2019
- const [isEditing, setIsEditing] = (0, react.useState)(false);
2020
- const inputRef = (0, react.useRef)(null);
2021
- const triggerRef = (0, react.useRef)(null);
2022
- const { open, setOpen, containerRef: rootRef, panelRef, panelStyle } = useFloatingPanel({
2023
- onClose: () => {
2024
- setFocusedIso(null);
2025
- setViewMode("days");
2026
- },
2027
- onEscape: (e) => {
2028
- e.preventDefault();
2029
- inputRef.current?.focus();
2267
+ //#endregion
2268
+ //#region packages/ui/DateTextInput.tsx
2269
+ /** Keeps the real input/ref/ID contract used by CRUD forms. */
2270
+ const DateTextInput = (0, react.forwardRef)(function DateTextInput({ value, locale, min, max, onChange, onOpen, onBlur, onKeyDown, ...props }, ref) {
2271
+ const [draft, setDraft] = (0, react.useState)(null);
2272
+ const commit = () => {
2273
+ if (draft === null) return;
2274
+ const iso = parseDisplayDate(draft.trim(), locale);
2275
+ if (!draft.trim()) onChange("");
2276
+ else if (iso && dateAllowed(iso, min, max)) onChange(iso);
2277
+ setDraft(null);
2278
+ };
2279
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
2280
+ ...props,
2281
+ ref,
2282
+ type: "text",
2283
+ inputMode: "numeric",
2284
+ onPointerDown: (event) => event.stopPropagation(),
2285
+ onPointerUp: (event) => event.stopPropagation(),
2286
+ onMouseDown: (event) => event.stopPropagation(),
2287
+ onClick: (event) => event.stopPropagation(),
2288
+ value: draft ?? formatDate(value, locale),
2289
+ onChange: (event) => setDraft(applyDateMask(event.target.value, draft ?? "", locale)),
2290
+ onBlur: (event) => {
2291
+ commit();
2292
+ onBlur?.(event);
2030
2293
  },
2031
- computeStyle: () => {
2032
- const rect = triggerRef.current?.getBoundingClientRect();
2033
- if (!rect) return null;
2034
- const panelWidth = panelRef.current?.offsetWidth ?? 296;
2035
- const left = Math.min(Math.max(8, rect.left), window.innerWidth - panelWidth - 8);
2036
- const top = Math.min(rect.bottom + 6, window.innerHeight - 380);
2037
- return {
2038
- left,
2039
- top: Math.max(8, top)
2040
- };
2294
+ onKeyDown: (event) => {
2295
+ if (event.key !== "Escape") event.stopPropagation();
2296
+ onKeyDown?.(event);
2297
+ if (event.defaultPrevented) return;
2298
+ if (event.key === "Enter") {
2299
+ event.preventDefault();
2300
+ commit();
2301
+ }
2302
+ if (event.key === "Escape") setDraft(null);
2303
+ if (event.key === "ArrowDown" && !props.disabled && !props.readOnly) {
2304
+ event.preventDefault();
2305
+ commit();
2306
+ onOpen();
2307
+ }
2041
2308
  }
2042
2309
  });
2043
- const days = (0, react.useMemo)(() => buildCalendarDays$1(month, min, max, resolvedLocale), [
2044
- max,
2045
- min,
2046
- month,
2047
- resolvedLocale
2048
- ]);
2049
- const weekdayLabels = (0, react.useMemo)(() => weekDayLabels(resolvedLocale), [resolvedLocale]);
2050
- const monthLabels = (0, react.useMemo)(() => getMonthLabels(resolvedLocale), [resolvedLocale]);
2051
- const selectedIso = selectedDate ? toIsoDate$1(selectedDate) : "";
2052
- (0, react.useEffect)(() => {
2053
- if (selectedDate) setMonth(startOfMonth$1(selectedDate));
2054
- }, [value]);
2310
+ });
2311
+ //#endregion
2312
+ //#region packages/ui/useCalendarPopover.ts
2313
+ /** Bridge focus restoration between React Aria's popup and a parent Base UI modal. */
2314
+ function useCalendarPopover() {
2315
+ const container = useOverlayContainer();
2316
+ const groupRef = (0, react.useRef)(null);
2317
+ const panelRef = (0, react.useRef)(null);
2318
+ const frame = (0, react.useRef)(null);
2319
+ const outsideTarget = (0, react.useRef)(null);
2320
+ const [open, updateOpen] = (0, react.useState)(false);
2055
2321
  (0, react.useEffect)(() => {
2056
- if (!open) return;
2057
- const initialIso = selectedDate ? toIsoDate$1(selectedDate) : toIsoDate$1(/* @__PURE__ */ new Date());
2058
- setFocusedIso(initialIso);
2059
- window.setTimeout(() => {
2060
- panelRef.current?.querySelector(`[data-iso="${initialIso}"]`)?.focus();
2061
- }, 0);
2062
- }, [open]);
2063
- const commitValue = (0, react.useCallback)((nextValue) => {
2064
- onChange?.(nextValue);
2065
- setOpen(false);
2066
- setIsEditing(false);
2067
- setInputText("");
2068
- window.setTimeout(() => inputRef.current?.focus());
2069
- }, [onChange, setOpen]);
2070
- const handleToday = (0, react.useCallback)(() => {
2071
- const today = toIsoDate$1(/* @__PURE__ */ new Date());
2072
- if (isIsoDateDisabled(today, min, max)) return;
2073
- setMonth(startOfMonth$1(parseIsoDate$1(today)));
2074
- commitValue(today);
2075
- }, [
2076
- min,
2077
- max,
2078
- commitValue
2079
- ]);
2080
- const handleClear = (0, react.useCallback)((e) => {
2081
- e.preventDefault();
2082
- commitValue("");
2083
- }, [commitValue]);
2084
- const handleInputFocus = () => {
2085
- setIsEditing(true);
2086
- setInputText(displayValue);
2087
- window.setTimeout(() => inputRef.current?.select(), 0);
2088
- };
2089
- const handleInputChange = (e) => {
2090
- if (readOnly || disabled) return;
2091
- setInputText(applyDateMask(e.target.value, inputText));
2092
- };
2093
- const handleInputBlur = (e) => {
2094
- const related = e.relatedTarget;
2095
- if (rootRef.current?.contains(related) || panelRef.current?.contains(related)) return;
2096
- setIsEditing(false);
2097
- const parsed = parseDisplayDate(inputText, resolvedLocale);
2098
- if (parsed !== null) {
2099
- if (parsed !== value) onChange?.(parsed);
2100
- } else if (inputText === "" && value) onChange?.("");
2101
- setInputText("");
2102
- onBlur?.(e);
2103
- };
2104
- const handleInputKeyDown = (e) => {
2105
- if (e.key === "Enter") {
2106
- e.preventDefault();
2107
- const parsed = parseDisplayDate(inputText, resolvedLocale);
2108
- if (parsed !== null) commitValue(parsed);
2109
- else if (inputText === "") commitValue("");
2110
- } else if (e.key === "ArrowDown" || e.key === "F4") {
2111
- e.preventDefault();
2112
- if (!readOnly && !disabled) setOpen(true);
2113
- } else if (e.key === "Escape" && open) setOpen(false);
2114
- };
2115
- const handleCalendarPointerDown = (e) => {
2116
- e.preventDefault();
2117
- if (readOnly || disabled) return;
2118
- setOpen(!open);
2119
- };
2120
- const handleDayKeyDown = (0, react.useCallback)((e, iso) => {
2121
- if (![
2122
- "ArrowLeft",
2123
- "ArrowRight",
2124
- "ArrowUp",
2125
- "ArrowDown",
2126
- "Enter",
2127
- " "
2128
- ].includes(e.key)) return;
2129
- e.preventDefault();
2130
- if (e.key === "Enter" || e.key === " ") {
2131
- const day = days.find((d) => d.iso === iso);
2132
- if (day && !day.disabled) commitValue(iso);
2133
- return;
2134
- }
2135
- const delta = {
2136
- ArrowLeft: -1,
2137
- ArrowRight: 1,
2138
- ArrowUp: -7,
2139
- ArrowDown: 7
2140
- }[e.key] ?? 0;
2141
- const current = parseIsoDate$1(iso);
2142
- if (!current) return;
2143
- const next = new Date(current);
2144
- next.setDate(current.getDate() + delta);
2145
- const nextIso = toIsoDate$1(next);
2146
- if (next.getMonth() !== month.getMonth() || next.getFullYear() !== month.getFullYear()) setMonth(startOfMonth$1(next));
2147
- setFocusedIso(nextIso);
2148
- window.setTimeout(() => {
2149
- panelRef.current?.querySelector(`[data-iso="${nextIso}"]`)?.focus();
2150
- }, 0);
2151
- }, [
2152
- days,
2153
- month,
2154
- commitValue,
2155
- panelRef
2156
- ]);
2157
- const handleMonthSelect = (monthIndex) => {
2158
- setMonth(new Date(month.getFullYear(), monthIndex, 1));
2159
- setViewMode("days");
2160
- };
2161
- const handleYearSelect = (year) => {
2162
- setMonth(new Date(year, month.getMonth(), 1));
2163
- setViewMode("months");
2164
- };
2165
- const setInputRef = (node) => {
2166
- inputRef.current = node;
2167
- if (typeof ref === "function") ref(node);
2168
- else if (ref) ref.current = node;
2322
+ if (!open || !container) return;
2323
+ const rememberTarget = (event) => {
2324
+ if (event.target instanceof Element && container.contains(event.target) && !panelRef.current?.contains(event.target)) outsideTarget.current = event.target.closest("input, button, select, textarea, a[href], [tabindex]:not([tabindex=\"-1\"])");
2325
+ };
2326
+ document.addEventListener("pointerdown", rememberTarget, true);
2327
+ return () => document.removeEventListener("pointerdown", rememberTarget, true);
2328
+ }, [open, container]);
2329
+ (0, react.useEffect)(() => () => {
2330
+ if (frame.current !== null) cancelAnimationFrame(frame.current);
2331
+ }, []);
2332
+ return {
2333
+ container,
2334
+ groupRef,
2335
+ panelRef,
2336
+ open,
2337
+ setOpen: (0, react.useCallback)((next) => {
2338
+ if (frame.current !== null) cancelAnimationFrame(frame.current);
2339
+ if (next) outsideTarget.current = null;
2340
+ const active = document.activeElement;
2341
+ const target = outsideTarget.current ?? groupRef.current?.querySelector("input");
2342
+ const restore = !next && container && (outsideTarget.current || panelRef.current?.contains(active));
2343
+ updateOpen(next);
2344
+ if (restore) frame.current = requestAnimationFrame(() => {
2345
+ frame.current = requestAnimationFrame(() => {
2346
+ frame.current = null;
2347
+ if (document.activeElement === active || document.activeElement === container || document.activeElement === document.body) target?.focus();
2348
+ });
2349
+ });
2350
+ }, [container])
2169
2351
  };
2170
- const todayIso = toIsoDate$1(/* @__PURE__ */ new Date());
2171
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2172
- ref: rootRef,
2173
- className: cx$1("nb-date-picker", className),
2174
- children: [
2175
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
2176
- type: "hidden",
2177
- name,
2178
- value: value ?? "",
2179
- required
2180
- }),
2181
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2182
- ref: triggerRef,
2183
- className: cx$1("nb-date-picker__trigger", invalid && "nb-date-picker__trigger--invalid", readOnly && "nb-date-picker__trigger--readonly", open && "nb-date-picker__trigger--open", disabled && "nb-date-picker__trigger--disabled"),
2184
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
2185
- ref: setInputRef,
2186
- id: inputId,
2187
- type: "text",
2188
- inputMode: "numeric",
2189
- className: cx$1("nb-date-picker__input", !isEditing && !displayValue && "nb-date-picker__input--placeholder"),
2190
- value: isEditing ? inputText : displayValue,
2191
- placeholder,
2192
- disabled,
2193
- readOnly,
2194
- "aria-label": ariaLabel,
2195
- role: "combobox",
2196
- "aria-haspopup": "dialog",
2197
- "aria-expanded": open,
2198
- "aria-controls": open ? panelId : void 0,
2199
- "aria-invalid": invalid || void 0,
2200
- "aria-required": required || void 0,
2201
- autoComplete: "off",
2202
- onFocus: handleInputFocus,
2203
- onBlur: handleInputBlur,
2204
- onChange: handleInputChange,
2205
- onKeyDown: handleInputKeyDown
2206
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2207
- className: "nb-date-picker__icons",
2208
- children: [clearable && displayValue && !disabled && !readOnly && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2209
- role: "button",
2210
- tabIndex: -1,
2211
- className: "nb-date-picker__clear",
2212
- "aria-label": strings.clearDate,
2213
- onPointerDown: handleClear,
2214
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
2215
- className: "ph ph-x",
2216
- "aria-hidden": "true"
2217
- })
2218
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2219
- role: "button",
2220
- tabIndex: -1,
2221
- className: "nb-date-picker__calendar-btn",
2222
- "aria-label": strings.openCalendar,
2223
- onPointerDown: handleCalendarPointerDown,
2224
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
2225
- className: "ph ph-calendar-blank",
2226
- "aria-hidden": "true"
2227
- })
2228
- })]
2229
- })]
2230
- }),
2231
- open && (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2232
- ref: panelRef,
2233
- id: panelId,
2234
- className: "nb-date-picker__panel",
2235
- role: "dialog",
2236
- "aria-label": strings.selectDate,
2237
- style: panelStyle,
2238
- children: [
2239
- viewMode === "days" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
2240
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2241
- className: "nb-date-picker__header",
2242
- children: [
2243
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2244
- type: "button",
2245
- className: "nb-date-picker__nav",
2246
- "aria-label": strings.previousMonth,
2247
- onClick: () => setMonth((m) => addMonths$1(m, -1)),
2248
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
2249
- className: "ph ph-caret-left",
2250
- "aria-hidden": "true"
2251
- })
2252
- }),
2253
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
2254
- type: "button",
2255
- className: "nb-date-picker__month nb-date-picker__month--clickable",
2256
- "aria-label": strings.selectMonthAndYear,
2257
- onClick: () => setViewMode("months"),
2258
- children: [formatMonthLabel$1(month, resolvedLocale), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
2259
- className: "ph ph-caret-down nb-date-picker__month-caret",
2260
- "aria-hidden": "true"
2261
- })]
2262
- }),
2263
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2264
- type: "button",
2265
- className: "nb-date-picker__nav",
2266
- "aria-label": strings.nextMonth,
2267
- onClick: () => setMonth((m) => addMonths$1(m, 1)),
2268
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
2269
- className: "ph ph-caret-right",
2270
- "aria-hidden": "true"
2271
- })
2272
- })
2273
- ]
2274
- }),
2275
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2276
- className: "nb-date-picker__weekdays",
2277
- "aria-hidden": "true",
2278
- children: weekdayLabels.map((label, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: label }, `${label}-${i}`))
2352
+ }
2353
+ //#endregion
2354
+ //#region packages/ui/DatePicker.tsx
2355
+ const DatePicker = (0, react.forwardRef)(function DatePicker({ id, name, value, placeholder, disabled = false, readOnly = false, required = false, invalid = false, clearable = true, locale, min, max, className, ariaLabel, onChange, onBlur }, ref) {
2356
+ const generatedId = (0, react.useId)();
2357
+ const inputId = id ?? generatedId;
2358
+ const { container, groupRef, panelRef, open, setOpen } = useCalendarPopover();
2359
+ const strings = useUiStrings();
2360
+ const resolvedLocale = getDateLocale(locale);
2361
+ const change = (next) => onChange?.(next);
2362
+ const todayIso = (0, _internationalized_date.today)((0, _internationalized_date.getLocalTimeZone)()).toString();
2363
+ const prefix = "nb-date-picker";
2364
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.I18nProvider, {
2365
+ locale: resolvedLocale,
2366
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_aria_components.DatePicker, {
2367
+ "aria-label": ariaLabel ?? strings.selectDate,
2368
+ value: calendarDate(value),
2369
+ onChange: (date) => change(date?.toString() ?? ""),
2370
+ minValue: calendarDate(min) ?? void 0,
2371
+ maxValue: calendarDate(max) ?? void 0,
2372
+ isDisabled: disabled,
2373
+ isReadOnly: readOnly,
2374
+ isRequired: required,
2375
+ isInvalid: invalid,
2376
+ validationBehavior: "aria",
2377
+ isOpen: open,
2378
+ onOpenChange: setOpen,
2379
+ className: [prefix, className].filter(Boolean).join(" "),
2380
+ children: [
2381
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
2382
+ type: "hidden",
2383
+ name,
2384
+ value: value ?? "",
2385
+ disabled
2386
+ }),
2387
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_aria_components.Group, {
2388
+ ref: groupRef,
2389
+ className: [
2390
+ `${prefix}__trigger`,
2391
+ disabled && `${prefix}__trigger--disabled`,
2392
+ readOnly && `${prefix}__trigger--readonly`,
2393
+ invalid && `${prefix}__trigger--invalid`,
2394
+ open && `${prefix}__trigger--open`
2395
+ ].filter(Boolean).join(" "),
2396
+ children: [
2397
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DateTextInput, {
2398
+ ref,
2399
+ id: inputId,
2400
+ value,
2401
+ locale: resolvedLocale,
2402
+ min,
2403
+ max,
2404
+ placeholder: placeholder ?? datePlaceholder(resolvedLocale),
2405
+ disabled,
2406
+ readOnly,
2407
+ required,
2408
+ "aria-label": ariaLabel ?? (id ? void 0 : strings.selectDate),
2409
+ "aria-invalid": invalid || void 0,
2410
+ role: "combobox",
2411
+ "aria-haspopup": "dialog",
2412
+ "aria-expanded": open,
2413
+ "aria-controls": open ? `${inputId}-panel` : void 0,
2414
+ className: `${prefix}__input`,
2415
+ onChange: change,
2416
+ onOpen: () => setOpen(true),
2417
+ onBlur,
2418
+ onKeyDown: (event) => {
2419
+ if (event.key === "Escape" && open) {
2420
+ event.stopPropagation();
2421
+ setOpen(false);
2422
+ }
2423
+ }
2279
2424
  }),
2280
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2281
- className: "nb-date-picker__days",
2282
- role: "grid",
2283
- "aria-label": formatMonthLabel$1(month, resolvedLocale),
2284
- children: days.map((day) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2285
- "data-iso": day.iso,
2286
- type: "button",
2287
- className: cx$1("nb-date-picker__day", !day.inCurrentMonth && "nb-date-picker__day--muted", day.iso === selectedIso && "nb-date-picker__day--selected", day.iso === todayIso && "nb-date-picker__day--today"),
2288
- disabled: day.disabled,
2289
- role: "gridcell",
2290
- "aria-selected": day.iso === selectedIso,
2291
- tabIndex: day.iso === (focusedIso ?? selectedIso ?? todayIso) ? 0 : -1,
2292
- onClick: () => commitValue(day.iso),
2293
- onKeyDown: (e) => handleDayKeyDown(e, day.iso),
2294
- children: day.date.getDate()
2295
- }, day.iso))
2425
+ clearable && value && !disabled && !readOnly && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.Button, {
2426
+ slot: null,
2427
+ className: `${prefix}__clear`,
2428
+ "aria-label": strings.clearDate,
2429
+ onPress: () => change(""),
2430
+ children: "×"
2296
2431
  }),
2297
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2298
- className: "nb-date-picker__footer",
2299
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2300
- type: "button",
2301
- className: "nb-date-picker__text-button",
2302
- onClick: () => commitValue(""),
2432
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.Button, {
2433
+ className: `${prefix}__calendar-btn`,
2434
+ "aria-label": strings.openCalendar,
2435
+ onPress: () => groupRef.current?.querySelector("input")?.focus(),
2436
+ isDisabled: disabled || readOnly,
2437
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
2438
+ "aria-hidden": "true",
2439
+ className: "ph ph-calendar-blank"
2440
+ })
2441
+ })
2442
+ ]
2443
+ }),
2444
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.Popover, {
2445
+ isNonModal: Boolean(container),
2446
+ ref: panelRef,
2447
+ UNSTABLE_portalContainer: container ?? void 0,
2448
+ className: `${prefix}__panel`,
2449
+ offset: 4,
2450
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(CalendarDialog, {
2451
+ id: `${inputId}-panel`,
2452
+ ariaLabel: strings.selectDate,
2453
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.Calendar, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CalendarContent, {}) }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2454
+ className: `${prefix}__footer`,
2455
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.Button, {
2456
+ slot: null,
2457
+ className: `${prefix}__text-button`,
2458
+ onPress: () => {
2459
+ change("");
2460
+ setOpen(false);
2461
+ },
2303
2462
  children: strings.clear
2304
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2305
- type: "button",
2306
- className: "nb-date-picker__text-button",
2307
- onClick: handleToday,
2463
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.Button, {
2464
+ slot: null,
2465
+ className: `${prefix}__text-button`,
2466
+ isDisabled: !dateAllowed(todayIso, min, max),
2467
+ onPress: () => {
2468
+ change(todayIso);
2469
+ setOpen(false);
2470
+ },
2308
2471
  children: strings.today
2309
2472
  })]
2310
- })
2311
- ] }),
2312
- viewMode === "months" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
2313
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2314
- className: "nb-date-picker__header",
2315
- children: [
2316
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2317
- type: "button",
2318
- className: "nb-date-picker__nav",
2319
- "aria-label": strings.previousYear,
2320
- onClick: () => setMonth((m) => new Date(m.getFullYear() - 1, m.getMonth(), 1)),
2321
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
2322
- className: "ph ph-caret-left",
2323
- "aria-hidden": "true"
2324
- })
2325
- }),
2326
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
2327
- type: "button",
2328
- className: "nb-date-picker__month nb-date-picker__month--clickable",
2329
- "aria-label": strings.selectYear,
2330
- onClick: () => {
2331
- setYearRangeStart(getYearRangeStart(month.getFullYear()));
2332
- setViewMode("years");
2333
- },
2334
- children: [month.getFullYear(), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
2335
- className: "ph ph-caret-down nb-date-picker__month-caret",
2336
- "aria-hidden": "true"
2337
- })]
2338
- }),
2339
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2340
- type: "button",
2341
- className: "nb-date-picker__nav",
2342
- "aria-label": strings.nextYear,
2343
- onClick: () => setMonth((m) => new Date(m.getFullYear() + 1, m.getMonth(), 1)),
2344
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
2345
- className: "ph ph-caret-right",
2346
- "aria-hidden": "true"
2347
- })
2348
- })
2349
- ]
2350
- }),
2351
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2352
- className: "nb-date-picker__months-grid",
2353
- role: "grid",
2354
- "aria-label": `${month.getFullYear()}`,
2355
- children: monthLabels.map((label, i) => {
2356
- const isSelected = selectedDate ? selectedDate.getMonth() === i && selectedDate.getFullYear() === month.getFullYear() : false;
2357
- const isCurrent = (/* @__PURE__ */ new Date()).getMonth() === i && (/* @__PURE__ */ new Date()).getFullYear() === month.getFullYear();
2358
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2359
- type: "button",
2360
- className: cx$1("nb-date-picker__month-cell", isSelected && "nb-date-picker__month-cell--selected", isCurrent && "nb-date-picker__month-cell--current"),
2361
- role: "gridcell",
2362
- "aria-selected": isSelected,
2363
- onClick: () => handleMonthSelect(i),
2364
- children: label
2365
- }, i);
2366
- })
2367
- }),
2368
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2369
- className: "nb-date-picker__footer",
2370
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
2371
- type: "button",
2372
- className: "nb-date-picker__text-button",
2373
- onClick: () => setViewMode("days"),
2374
- children: [
2375
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
2376
- className: "ph ph-arrow-left",
2377
- "aria-hidden": "true"
2378
- }),
2379
- " ",
2380
- strings.back
2381
- ]
2382
- })
2383
- })
2384
- ] }),
2385
- viewMode === "years" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
2386
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2387
- className: "nb-date-picker__header",
2388
- children: [
2389
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2390
- type: "button",
2391
- className: "nb-date-picker__nav",
2392
- "aria-label": strings.previousYears,
2393
- onClick: () => setYearRangeStart((y) => y - 12),
2394
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
2395
- className: "ph ph-caret-left",
2396
- "aria-hidden": "true"
2397
- })
2398
- }),
2399
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2400
- className: "nb-date-picker__month",
2401
- children: [
2402
- yearRangeStart,
2403
- "–",
2404
- yearRangeStart + 11
2405
- ]
2406
- }),
2407
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2408
- type: "button",
2409
- className: "nb-date-picker__nav",
2410
- "aria-label": strings.nextYears,
2411
- onClick: () => setYearRangeStart((y) => y + 12),
2412
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
2413
- className: "ph ph-caret-right",
2414
- "aria-hidden": "true"
2415
- })
2416
- })
2417
- ]
2418
- }),
2419
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2420
- className: "nb-date-picker__years-grid",
2421
- role: "grid",
2422
- "aria-label": `${yearRangeStart}–${yearRangeStart + 11}`,
2423
- children: Array.from({ length: 12 }, (_, i) => yearRangeStart + i).map((year) => {
2424
- const isSelected = selectedDate ? selectedDate.getFullYear() === year : false;
2425
- const isCurrent = (/* @__PURE__ */ new Date()).getFullYear() === year;
2426
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2427
- type: "button",
2428
- className: cx$1("nb-date-picker__year-cell", isSelected && "nb-date-picker__year-cell--selected", isCurrent && "nb-date-picker__year-cell--current"),
2429
- role: "gridcell",
2430
- "aria-selected": isSelected,
2431
- onClick: () => handleYearSelect(year),
2432
- children: year
2433
- }, year);
2434
- })
2435
- }),
2436
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2437
- className: "nb-date-picker__footer",
2438
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
2439
- type: "button",
2440
- className: "nb-date-picker__text-button",
2441
- onClick: () => setViewMode("months"),
2442
- children: [
2443
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
2444
- className: "ph ph-arrow-left",
2445
- "aria-hidden": "true"
2446
- }),
2447
- " ",
2448
- strings.back
2449
- ]
2450
- })
2451
- })
2452
- ] })
2453
- ]
2454
- }), document.body)
2455
- ]
2473
+ })]
2474
+ })
2475
+ })
2476
+ ]
2477
+ })
2456
2478
  });
2457
2479
  });
2458
2480
  //#endregion
2459
2481
  //#region packages/ui/DateRangePicker.tsx
2460
- /**
2461
- * DateRangePicker — enterprise date range selector.
2462
- *
2463
- * A single trigger with two text inputs (start + end) sharing one calendar
2464
- * panel. Supports hover-preview, range highlighting, keyboard entry, min/max
2465
- * constraints, and full density/theme token compliance.
2466
- *
2467
- * Usage:
2468
- * <DateRangePicker
2469
- * startValue="2026-06-01"
2470
- * endValue="2026-06-30"
2471
- * onChange={(start, end) => ...}
2472
- * />
2473
- */
2474
- const ISO_DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
2475
- const pad = (v) => String(v).padStart(2, "0");
2476
- const toIsoDate = (d) => `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;
2477
- const parseIsoDate = (value) => {
2478
- if (!value || !ISO_DATE_RE.test(value)) return null;
2479
- const [year, month, day] = value.split("-").map(Number);
2480
- const d = new Date(year, month - 1, day);
2481
- if (d.getFullYear() !== year || d.getMonth() !== month - 1 || d.getDate() !== day) return null;
2482
- return d;
2483
- };
2484
- const cx = (...vals) => vals.filter(Boolean).join(" ");
2485
- const getLocale = (override) => override || document.documentElement.lang || navigator.language || "en-US";
2486
- const startOfMonth = (date) => new Date(date.getFullYear(), date.getMonth(), 1);
2487
- const addMonths = (date, months) => new Date(date.getFullYear(), date.getMonth() + months, 1);
2488
- const formatDisplayDate = (value, locale) => {
2489
- const date = parseIsoDate(value);
2490
- if (!date) return "";
2491
- return new Intl.DateTimeFormat(getLocale(locale), {
2492
- day: "2-digit",
2493
- month: "2-digit",
2494
- year: "numeric"
2495
- }).format(date);
2496
- };
2497
- const formatMonthLabel = (date, locale) => new Intl.DateTimeFormat(getLocale(locale), {
2498
- month: "long",
2499
- year: "numeric"
2500
- }).format(date);
2501
- const buildCalendarDays = (month, min, max, locale) => {
2502
- const first = startOfMonth(month);
2503
- const firstDayOfWeek = getFirstDayOfWeek(locale);
2504
- const offset = (first.getDay() - firstDayOfWeek + 7) % 7;
2505
- const minDate = parseIsoDate(min);
2506
- const maxDate = parseIsoDate(max);
2507
- const start = new Date(first);
2508
- start.setDate(first.getDate() - offset);
2509
- return Array.from({ length: 42 }, (_, i) => {
2510
- const date = new Date(start);
2511
- date.setDate(start.getDate() + i);
2512
- return {
2513
- date,
2514
- iso: toIsoDate(date),
2515
- inCurrentMonth: date.getMonth() === month.getMonth(),
2516
- disabled: Boolean(minDate && date < minDate || maxDate && date > maxDate)
2517
- };
2518
- });
2519
- };
2520
- const getDayRoleInRange = (iso, startIso, endIso) => {
2521
- if (!startIso) return "none";
2522
- if (!endIso || startIso === endIso) return iso === startIso ? "single" : "none";
2523
- if (iso === startIso) return "start";
2524
- if (iso === endIso) return "end";
2525
- if (iso > startIso && iso < endIso) return "in-range";
2526
- return "none";
2527
- };
2528
- function DateRangePicker({ startValue, endValue, placeholder = "dd/mm/yyyy", disabled = false, readOnly = false, required = false, invalid = false, locale, min, max, className, ariaLabel, onChange, onBlur }) {
2529
- const startId = (0, react.useId)();
2530
- const endId = (0, react.useId)();
2482
+ function DateRangePicker({ startValue, endValue, placeholder, disabled = false, clearable = true, readOnly = false, required = false, invalid = false, locale, min, max, className, ariaLabel, onChange, onBlur }) {
2483
+ const { container, groupRef, panelRef, open, setOpen } = useCalendarPopover();
2531
2484
  const strings = useUiStrings();
2532
- const resolvedLocale = getLocale(locale);
2533
- const startDisplay = formatDisplayDate(startValue, resolvedLocale);
2534
- const endDisplay = formatDisplayDate(endValue, resolvedLocale);
2535
- const startIso = parseIsoDate(startValue) ? startValue : null;
2536
- const endIso = parseIsoDate(endValue) ? endValue : null;
2537
- const [phase, setPhase] = (0, react.useState)("idle");
2538
- const [pendingStart, setPendingStart] = (0, react.useState)(null);
2539
- const [hoverIso, setHoverIso] = (0, react.useState)(null);
2540
- const [month, setMonth] = (0, react.useState)(() => startOfMonth(parseIsoDate(startValue) ?? /* @__PURE__ */ new Date()));
2541
- const [startText, setStartText] = (0, react.useState)("");
2542
- const [endText, setEndText] = (0, react.useState)("");
2543
- const [editingField, setEditingField] = (0, react.useState)(null);
2544
- const triggerRef = (0, react.useRef)(null);
2545
- const startInputRef = (0, react.useRef)(null);
2546
- const endInputRef = (0, react.useRef)(null);
2547
- const days = (0, react.useMemo)(() => buildCalendarDays(month, min, max, resolvedLocale), [
2548
- month,
2485
+ const resolvedLocale = getDateLocale(locale);
2486
+ const start = calendarDate(startValue);
2487
+ const end = calendarDate(endValue);
2488
+ const change = (a, b) => a && b && a > b ? onChange?.(b, a) : onChange?.(a, b);
2489
+ const todayIso = (0, _internationalized_date.today)((0, _internationalized_date.getLocalTimeZone)()).toString();
2490
+ const prefix = "nb-date-range-picker";
2491
+ const inputProps = {
2492
+ locale: resolvedLocale,
2549
2493
  min,
2550
2494
  max,
2551
- resolvedLocale
2552
- ]);
2553
- const weekdayLbls = (0, react.useMemo)(() => weekDayLabels(resolvedLocale), [resolvedLocale]);
2554
- const todayIso = toIsoDate(/* @__PURE__ */ new Date());
2555
- (0, react.useEffect)(() => {
2556
- const anchor = parseIsoDate(startValue) ?? parseIsoDate(endValue);
2557
- if (anchor) setMonth(startOfMonth(anchor));
2558
- }, [startValue]);
2559
- const { open, setOpen, containerRef: rootRef, panelRef, panelStyle } = useFloatingPanel({
2560
- onClose: () => {
2561
- setPhase("idle");
2562
- setPendingStart(null);
2563
- setHoverIso(null);
2564
- },
2565
- onEscape: (e) => {
2566
- e.preventDefault();
2567
- startInputRef.current?.focus();
2568
- },
2569
- computeStyle: () => {
2570
- const rect = triggerRef.current?.getBoundingClientRect();
2571
- if (!rect) return null;
2572
- const panelWidth = panelRef.current?.offsetWidth ?? 296;
2573
- const left = Math.min(Math.max(8, rect.left), window.innerWidth - panelWidth - 8);
2574
- const top = Math.min(rect.bottom + 6, window.innerHeight - 380);
2575
- return {
2576
- left,
2577
- top: Math.max(8, top)
2578
- };
2579
- }
2580
- });
2581
- const closePanel = (0, react.useCallback)(() => {
2582
- setOpen(false);
2583
- }, [setOpen]);
2584
- const commitRange = (0, react.useCallback)((start, end) => {
2585
- const [a, b] = start <= end ? [start, end] : [end, start];
2586
- onChange?.(a, b);
2587
- closePanel();
2588
- window.setTimeout(() => startInputRef.current?.focus());
2589
- }, [onChange, closePanel]);
2590
- const handleDayClick = (0, react.useCallback)((iso) => {
2591
- if (phase === "idle") {
2592
- setPendingStart(iso);
2593
- setPhase("selecting-end");
2594
- } else commitRange(pendingStart ?? iso, iso);
2595
- }, [
2596
- phase,
2597
- pendingStart,
2598
- commitRange
2599
- ]);
2600
- const getEffectiveRange = () => {
2601
- if (phase === "selecting-end" && pendingStart) {
2602
- const effectiveEnd = hoverIso ?? null;
2603
- return {
2604
- effectiveStart: pendingStart <= (effectiveEnd ?? pendingStart) ? pendingStart : effectiveEnd,
2605
- effectiveEnd: pendingStart <= (effectiveEnd ?? pendingStart) ? effectiveEnd : pendingStart
2606
- };
2607
- }
2608
- return {
2609
- effectiveStart: startIso,
2610
- effectiveEnd: endIso
2611
- };
2612
- };
2613
- const { effectiveStart, effectiveEnd } = getEffectiveRange();
2614
- const handleStartFocus = () => {
2615
- setEditingField("start");
2616
- setStartText(startDisplay);
2617
- window.setTimeout(() => startInputRef.current?.select(), 0);
2618
- };
2619
- const handleEndFocus = () => {
2620
- setEditingField("end");
2621
- setEndText(endDisplay);
2622
- window.setTimeout(() => endInputRef.current?.select(), 0);
2623
- };
2624
- const handleStartChange = (e) => {
2625
- if (readOnly || disabled) return;
2626
- setStartText(applyDateMask(e.target.value, startText));
2627
- };
2628
- const handleEndChange = (e) => {
2629
- if (readOnly || disabled) return;
2630
- setEndText(applyDateMask(e.target.value, endText));
2631
- };
2632
- const commitTextInput = (field, text) => {
2633
- const parsed = parseDisplayDate(text, resolvedLocale);
2634
- if (parsed !== null) {
2635
- const newStart = field === "start" ? parsed : startIso ?? "";
2636
- const newEnd = field === "end" ? parsed : endIso ?? "";
2637
- if (newStart && newEnd) {
2638
- const [a, b] = newStart <= newEnd ? [newStart, newEnd] : [newEnd, newStart];
2639
- onChange?.(a, b);
2640
- } else if (field === "start") onChange?.(parsed, endIso ?? "");
2641
- else onChange?.(startIso ?? "", parsed);
2642
- } else if (text === "") if (field === "start") onChange?.("", endIso ?? "");
2643
- else onChange?.(startIso ?? "", "");
2644
- };
2645
- const handleStartBlur = (e) => {
2646
- const related = e.relatedTarget;
2647
- if (rootRef.current?.contains(related) || panelRef.current?.contains(related)) return;
2648
- commitTextInput("start", startText);
2649
- setEditingField(null);
2650
- setStartText("");
2651
- onBlur?.(e);
2652
- };
2653
- const handleEndBlur = (e) => {
2654
- const related = e.relatedTarget;
2655
- if (rootRef.current?.contains(related) || panelRef.current?.contains(related)) return;
2656
- commitTextInput("end", endText);
2657
- setEditingField(null);
2658
- setEndText("");
2659
- onBlur?.(e);
2660
- };
2661
- const handleStartKeyDown = (e) => {
2662
- if (e.key === "Enter") {
2663
- e.preventDefault();
2664
- const parsed = parseDisplayDate(startText);
2665
- if (parsed) onChange?.(parsed, endIso ?? "");
2666
- endInputRef.current?.focus();
2667
- } else if (e.key === "ArrowDown" || e.key === "F4") {
2668
- e.preventDefault();
2669
- if (!readOnly && !disabled) setOpen(true);
2670
- }
2671
- };
2672
- const handleEndKeyDown = (e) => {
2673
- if (e.key === "Enter") {
2674
- e.preventDefault();
2675
- const parsed = parseDisplayDate(endText);
2676
- if (parsed) onChange?.(startIso ?? "", parsed);
2677
- } else if (e.key === "ArrowDown" || e.key === "F4") {
2678
- e.preventDefault();
2679
- if (!readOnly && !disabled) setOpen(true);
2495
+ placeholder: placeholder ?? datePlaceholder(resolvedLocale),
2496
+ disabled,
2497
+ readOnly,
2498
+ required,
2499
+ "aria-invalid": invalid || void 0,
2500
+ className: `${prefix}__input`,
2501
+ onOpen: () => setOpen(true),
2502
+ onBlur,
2503
+ onKeyDown: (event) => {
2504
+ if (event.key === "Escape" && open) {
2505
+ event.stopPropagation();
2506
+ setOpen(false);
2507
+ }
2680
2508
  }
2681
2509
  };
2682
- const handleCalendarPointerDown = (e) => {
2683
- e.preventDefault();
2684
- if (readOnly || disabled) return;
2685
- setOpen(!open);
2686
- };
2687
- const handleClear = (e) => {
2688
- e.preventDefault();
2689
- onChange?.("", "");
2690
- closePanel();
2691
- };
2692
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2693
- ref: rootRef,
2694
- className: cx("nb-date-range-picker", className),
2695
- children: [
2696
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2697
- ref: triggerRef,
2698
- className: cx("nb-date-range-picker__trigger", invalid && "nb-date-range-picker__trigger--invalid", readOnly && "nb-date-range-picker__trigger--readonly", open && "nb-date-range-picker__trigger--open", disabled && "nb-date-range-picker__trigger--disabled"),
2699
- "aria-label": ariaLabel,
2700
- children: [
2701
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
2702
- ref: startInputRef,
2703
- id: startId,
2704
- type: "text",
2705
- inputMode: "numeric",
2706
- className: cx("nb-date-range-picker__input", !editingField && !startDisplay && "nb-date-range-picker__input--placeholder"),
2707
- value: editingField === "start" ? startText : startDisplay,
2708
- placeholder,
2709
- disabled,
2710
- readOnly,
2711
- autoComplete: "off",
2712
- "aria-label": `Fecha inicio${ariaLabel ? ` ${ariaLabel}` : ""}`,
2713
- "aria-required": required || void 0,
2714
- onFocus: handleStartFocus,
2715
- onBlur: handleStartBlur,
2716
- onChange: handleStartChange,
2717
- onKeyDown: handleStartKeyDown
2718
- }),
2719
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2720
- className: "nb-date-range-picker__sep",
2721
- "aria-hidden": "true",
2722
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", { className: "ph ph-arrow-right" })
2723
- }),
2724
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
2725
- ref: endInputRef,
2726
- id: endId,
2727
- type: "text",
2728
- inputMode: "numeric",
2729
- className: cx("nb-date-range-picker__input", !editingField && !endDisplay && "nb-date-range-picker__input--placeholder"),
2730
- value: editingField === "end" ? endText : endDisplay,
2731
- placeholder,
2732
- disabled,
2733
- readOnly,
2734
- autoComplete: "off",
2735
- "aria-label": `Fecha fin${ariaLabel ? ` ${ariaLabel}` : ""}`,
2736
- onFocus: handleEndFocus,
2737
- onBlur: handleEndBlur,
2738
- onChange: handleEndChange,
2739
- onKeyDown: handleEndKeyDown
2740
- }),
2741
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2742
- className: "nb-date-range-picker__icons",
2743
- children: [(startDisplay || endDisplay) && !disabled && !readOnly && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2744
- role: "button",
2745
- tabIndex: -1,
2746
- className: "nb-date-range-picker__clear",
2747
- "aria-label": strings.clearDateRange,
2748
- onPointerDown: handleClear,
2749
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
2750
- className: "ph ph-x",
2751
- "aria-hidden": "true"
2752
- })
2753
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2754
- role: "button",
2755
- tabIndex: -1,
2756
- className: "nb-date-range-picker__calendar-btn",
2757
- "aria-label": strings.openCalendar,
2758
- onPointerDown: handleCalendarPointerDown,
2759
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
2760
- className: "ph ph-calendar-blank",
2761
- "aria-hidden": "true"
2762
- })
2763
- })]
2764
- })
2765
- ]
2766
- }),
2767
- phase === "selecting-end" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2768
- className: "nb-date-range-picker__hint",
2769
- role: "status",
2770
- "aria-live": "polite",
2771
- children: "Selecciona la fecha de fin"
2772
- }),
2773
- open && (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2774
- ref: panelRef,
2775
- className: "nb-date-range-picker__panel",
2776
- role: "dialog",
2777
- "aria-label": strings.selectDateRange,
2778
- style: panelStyle,
2510
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.I18nProvider, {
2511
+ locale: resolvedLocale,
2512
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_aria_components.DateRangePicker, {
2513
+ "aria-label": ariaLabel ?? strings.selectDateRange,
2514
+ value: start && end && start.compare(end) <= 0 ? {
2515
+ start,
2516
+ end
2517
+ } : null,
2518
+ onChange: (range) => change(range?.start.toString() ?? "", range?.end.toString() ?? ""),
2519
+ minValue: calendarDate(min) ?? void 0,
2520
+ maxValue: calendarDate(max) ?? void 0,
2521
+ placeholderValue: start ?? end ?? void 0,
2522
+ isDisabled: disabled,
2523
+ isReadOnly: readOnly,
2524
+ isRequired: required,
2525
+ isInvalid: invalid,
2526
+ validationBehavior: "aria",
2527
+ isOpen: open,
2528
+ onOpenChange: setOpen,
2529
+ className: [prefix, className].filter(Boolean).join(" "),
2530
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_aria_components.Group, {
2531
+ ref: groupRef,
2532
+ className: [
2533
+ `${prefix}__trigger`,
2534
+ disabled && `${prefix}__trigger--disabled`,
2535
+ readOnly && `${prefix}__trigger--readonly`,
2536
+ invalid && `${prefix}__trigger--invalid`,
2537
+ open && `${prefix}__trigger--open`
2538
+ ].filter(Boolean).join(" "),
2779
2539
  children: [
2780
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2781
- className: "nb-date-range-picker__header",
2782
- children: [
2783
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2784
- type: "button",
2785
- className: "nb-date-range-picker__nav",
2786
- "aria-label": strings.previousMonth,
2787
- onClick: () => setMonth((m) => addMonths(m, -1)),
2788
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
2789
- className: "ph ph-caret-left",
2790
- "aria-hidden": "true"
2791
- })
2792
- }),
2793
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2794
- className: "nb-date-range-picker__month",
2795
- "aria-live": "polite",
2796
- children: formatMonthLabel(month, resolvedLocale)
2797
- }),
2798
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2799
- type: "button",
2800
- className: "nb-date-range-picker__nav",
2801
- "aria-label": strings.nextMonth,
2802
- onClick: () => setMonth((m) => addMonths(m, 1)),
2803
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
2804
- className: "ph ph-caret-right",
2805
- "aria-hidden": "true"
2806
- })
2807
- })
2808
- ]
2540
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DateTextInput, {
2541
+ ...inputProps,
2542
+ "aria-label": [strings.startDate, ariaLabel].filter(Boolean).join(" "),
2543
+ value: startValue,
2544
+ onChange: (next) => change(next, endValue ?? "")
2809
2545
  }),
2810
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2811
- className: "nb-date-range-picker__weekdays",
2546
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2547
+ className: `${prefix}__sep`,
2812
2548
  "aria-hidden": "true",
2813
- children: weekdayLbls.map((label, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: label }, `${label}-${i}`))
2549
+ children: "→"
2814
2550
  }),
2815
- phase === "selecting-end" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2816
- className: "nb-date-range-picker__phase-banner",
2817
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
2818
- className: "ph ph-info",
2819
- "aria-hidden": "true"
2820
- }), "Ahora selecciona la fecha de fin"]
2551
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DateTextInput, {
2552
+ ...inputProps,
2553
+ "aria-label": [strings.endDate, ariaLabel].filter(Boolean).join(" "),
2554
+ value: endValue,
2555
+ onChange: (next) => change(startValue ?? "", next)
2821
2556
  }),
2822
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2823
- className: "nb-date-range-picker__days",
2824
- role: "grid",
2825
- "aria-label": formatMonthLabel(month, resolvedLocale),
2826
- children: days.map((day) => {
2827
- const role = getDayRoleInRange(day.iso, effectiveStart, effectiveEnd);
2828
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2829
- type: "button",
2830
- className: cx("nb-date-range-picker__day", !day.inCurrentMonth && "nb-date-range-picker__day--muted", day.iso === todayIso && "nb-date-range-picker__day--today", role === "start" && "nb-date-range-picker__day--range-start", role === "end" && "nb-date-range-picker__day--range-end", role === "in-range" && "nb-date-range-picker__day--in-range", role === "single" && "nb-date-range-picker__day--range-single", phase === "selecting-end" && "nb-date-range-picker__day--selecting"),
2831
- disabled: day.disabled,
2832
- role: "gridcell",
2833
- "aria-selected": role !== "none",
2834
- onMouseEnter: () => phase === "selecting-end" && setHoverIso(day.iso),
2835
- onMouseLeave: () => phase === "selecting-end" && setHoverIso(null),
2836
- onClick: () => !day.disabled && handleDayClick(day.iso),
2837
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2838
- className: "nb-date-range-picker__day-inner",
2839
- children: day.date.getDate()
2840
- })
2841
- }, day.iso);
2842
- })
2557
+ clearable && (startValue || endValue) && !disabled && !readOnly && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.Button, {
2558
+ slot: null,
2559
+ className: `${prefix}__clear`,
2560
+ "aria-label": strings.clearDateRange,
2561
+ onPress: () => change("", ""),
2562
+ children: "×"
2843
2563
  }),
2844
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2845
- className: "nb-date-range-picker__footer",
2846
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2847
- type: "button",
2848
- className: "nb-date-range-picker__text-button",
2849
- onClick: () => {
2850
- onChange?.("", "");
2851
- closePanel();
2564
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.Button, {
2565
+ className: `${prefix}__calendar-btn`,
2566
+ "aria-label": strings.openCalendar,
2567
+ onPress: () => groupRef.current?.querySelector("input")?.focus(),
2568
+ isDisabled: disabled || readOnly,
2569
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
2570
+ "aria-hidden": "true",
2571
+ className: "ph ph-calendar-blank"
2572
+ })
2573
+ })
2574
+ ]
2575
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.Popover, {
2576
+ isNonModal: Boolean(container),
2577
+ ref: panelRef,
2578
+ UNSTABLE_portalContainer: container ?? void 0,
2579
+ className: `${prefix}__panel`,
2580
+ offset: 4,
2581
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(CalendarDialog, {
2582
+ ariaLabel: strings.selectDateRange,
2583
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.RangeCalendar, {
2584
+ className: "nb-calendar--range",
2585
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CalendarContent, {})
2586
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2587
+ className: `${prefix}__footer`,
2588
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.Button, {
2589
+ slot: null,
2590
+ className: `${prefix}__text-button`,
2591
+ onPress: () => {
2592
+ change("", "");
2593
+ setOpen(false);
2852
2594
  },
2853
2595
  children: strings.clear
2854
- }), phase === "selecting-end" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2855
- type: "button",
2856
- className: "nb-date-range-picker__text-button",
2857
- onClick: () => {
2858
- setPendingStart(null);
2859
- setPhase("idle");
2860
- setHoverIso(null);
2861
- },
2862
- children: strings.cancel
2863
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2864
- type: "button",
2865
- className: "nb-date-range-picker__text-button",
2866
- onClick: () => {
2867
- const today = toIsoDate(/* @__PURE__ */ new Date());
2868
- setMonth(startOfMonth(/* @__PURE__ */ new Date()));
2869
- if (!startIso) onChange?.(today, endIso ?? "");
2870
- else if (!endIso) onChange?.(startIso, today);
2871
- else onChange?.(today, today);
2872
- closePanel();
2596
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.Button, {
2597
+ slot: null,
2598
+ className: `${prefix}__text-button`,
2599
+ isDisabled: !dateAllowed(todayIso, min, max),
2600
+ onPress: () => {
2601
+ change(todayIso, todayIso);
2602
+ setOpen(false);
2873
2603
  },
2874
2604
  children: strings.today
2875
2605
  })]
2876
- })
2877
- ]
2878
- }), document.body)
2879
- ]
2606
+ })]
2607
+ })
2608
+ })]
2609
+ })
2880
2610
  });
2881
2611
  }
2882
2612
  //#endregion
2883
2613
  //#region packages/ui/Popover.tsx
2884
2614
  const Popover = ({ trigger, panel, align = "end", ariaLabel, className }) => {
2885
- const { open, setOpen, toggle, containerRef } = useFloatingPanel();
2886
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2887
- ref: containerRef,
2888
- className: [
2889
- "nb-popover",
2890
- `nb-popover--${align}`,
2891
- open && "nb-popover--open",
2892
- className
2893
- ].filter(Boolean).join(" "),
2894
- children: [trigger({
2895
- open,
2896
- toggle
2897
- }), open && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2898
- className: "nb-popover__panel",
2899
- role: "dialog",
2900
- "aria-label": ariaLabel,
2901
- children: panel({ close: () => setOpen(false) })
2902
- })]
2615
+ const [open, setOpen] = (0, react.useState)(false);
2616
+ const triggerRef = (0, react.useRef)(null);
2617
+ const [restoreFocus, setRestoreFocus] = (0, react.useState)(true);
2618
+ const changeOpen = (next) => {
2619
+ setRestoreFocus(true);
2620
+ setOpen(next);
2621
+ };
2622
+ const container = useOverlayContainer();
2623
+ const triggerNode = trigger({
2624
+ open,
2625
+ toggle: () => changeOpen(!open)
2626
+ });
2627
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_popover.Popover.Root, {
2628
+ open,
2629
+ onOpenChange: (next, details) => {
2630
+ setRestoreFocus(details.reason !== "outside-press" && details.reason !== "focus-out");
2631
+ setOpen(next);
2632
+ },
2633
+ onOpenChangeComplete: (next) => {
2634
+ if (!next && restoreFocus) triggerRef.current?.focus({ preventScroll: true });
2635
+ },
2636
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2637
+ className: [
2638
+ "nb-popover",
2639
+ `nb-popover--${align}`,
2640
+ open && "nb-popover--open",
2641
+ className
2642
+ ].filter(Boolean).join(" "),
2643
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_popover.Popover.Trigger, {
2644
+ ref: triggerRef,
2645
+ render: (0, react.isValidElement)(triggerNode) ? triggerNode : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2646
+ type: "button",
2647
+ children: triggerNode
2648
+ })
2649
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_popover.Popover.Portal, {
2650
+ container: container ?? void 0,
2651
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_popover.Popover.Positioner, {
2652
+ align,
2653
+ sideOffset: 8,
2654
+ className: "nb-popover-positioner",
2655
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_popover.Popover.Popup, {
2656
+ finalFocus: triggerRef,
2657
+ onKeyDownCapture: (event) => {
2658
+ if (event.key === "Escape") {
2659
+ event.preventDefault();
2660
+ event.stopPropagation();
2661
+ changeOpen(false);
2662
+ }
2663
+ },
2664
+ className: "nb-popover__panel",
2665
+ "aria-label": ariaLabel,
2666
+ children: panel({ close: () => changeOpen(false) })
2667
+ })
2668
+ })
2669
+ })]
2670
+ })
2903
2671
  });
2904
2672
  };
2905
2673
  //#endregion
2674
+ //#region packages/ui/useFloatingPanel.ts
2675
+ /** Style applied to an anchored panel before its first position is computed. */
2676
+ const HIDDEN_PANEL_STYLE = {
2677
+ position: "fixed",
2678
+ visibility: "hidden",
2679
+ margin: 0
2680
+ };
2681
+ function useFloatingPanel(options = {}) {
2682
+ const [open, setOpenState] = (0, react.useState)(false);
2683
+ const [panelStyle, setPanelStyle] = (0, react.useState)(HIDDEN_PANEL_STYLE);
2684
+ const containerRef = (0, react.useRef)(null);
2685
+ const panelRef = (0, react.useRef)(null);
2686
+ const optionsRef = (0, react.useRef)(options);
2687
+ optionsRef.current = options;
2688
+ const anchored = !!options.computeStyle;
2689
+ const dismissEvent = options.dismissEvent ?? "pointerdown";
2690
+ const setOpen = (0, react.useCallback)((next) => {
2691
+ setOpenState(next);
2692
+ if (!next) optionsRef.current.onClose?.();
2693
+ optionsRef.current.onOpenChange?.(next);
2694
+ }, []);
2695
+ const applyStyle = (0, react.useCallback)(() => {
2696
+ const compute = optionsRef.current.computeStyle;
2697
+ if (!compute) return;
2698
+ const style = compute(containerRef.current);
2699
+ if (style) setPanelStyle(style);
2700
+ }, []);
2701
+ const openPanel = (0, react.useCallback)(() => {
2702
+ applyStyle();
2703
+ setOpen(true);
2704
+ }, [applyStyle, setOpen]);
2705
+ const toggle = (0, react.useCallback)(() => open ? setOpen(false) : openPanel(), [
2706
+ open,
2707
+ openPanel,
2708
+ setOpen
2709
+ ]);
2710
+ (0, react.useEffect)(() => {
2711
+ if (!open) return;
2712
+ const handleOutside = (e) => {
2713
+ const target = e.target;
2714
+ if (containerRef.current?.contains(target) || panelRef.current?.contains(target)) return;
2715
+ setOpen(false);
2716
+ };
2717
+ const handleKeyDown = (e) => {
2718
+ if (e.key !== "Escape" || e.defaultPrevented) return;
2719
+ e.preventDefault();
2720
+ e.stopPropagation();
2721
+ setOpen(false);
2722
+ optionsRef.current.onEscape?.(e);
2723
+ };
2724
+ document.addEventListener(dismissEvent, handleOutside);
2725
+ document.addEventListener("keydown", handleKeyDown, true);
2726
+ return () => {
2727
+ document.removeEventListener(dismissEvent, handleOutside);
2728
+ document.removeEventListener("keydown", handleKeyDown, true);
2729
+ };
2730
+ }, [
2731
+ dismissEvent,
2732
+ open,
2733
+ setOpen
2734
+ ]);
2735
+ (0, react.useLayoutEffect)(() => {
2736
+ if (!open || !anchored) return;
2737
+ const update = () => {
2738
+ const container = containerRef.current;
2739
+ if (!container) return;
2740
+ if (optionsRef.current.closeOnViewportExit) {
2741
+ const rect = container.getBoundingClientRect();
2742
+ if ((rect.width > 0 || rect.height > 0) && (rect.top >= window.innerHeight || rect.bottom <= 0)) {
2743
+ setOpen(false);
2744
+ return;
2745
+ }
2746
+ }
2747
+ applyStyle();
2748
+ };
2749
+ update();
2750
+ window.addEventListener("resize", update);
2751
+ window.addEventListener("scroll", update, {
2752
+ capture: true,
2753
+ passive: true
2754
+ });
2755
+ return () => {
2756
+ window.removeEventListener("resize", update);
2757
+ window.removeEventListener("scroll", update, { capture: true });
2758
+ };
2759
+ }, [
2760
+ anchored,
2761
+ applyStyle,
2762
+ open,
2763
+ setOpen
2764
+ ]);
2765
+ return {
2766
+ open,
2767
+ setOpen,
2768
+ toggle,
2769
+ openPanel,
2770
+ containerRef,
2771
+ panelRef,
2772
+ panelStyle
2773
+ };
2774
+ }
2775
+ //#endregion
2906
2776
  //#region packages/ui/Drawer.tsx
2907
2777
  const formatWidth = (value) => {
2908
2778
  if (value === void 0) return void 0;
2909
2779
  return typeof value === "number" ? `${value}px` : value;
2910
2780
  };
2911
- const Drawer = ({ isOpen, onClose, title, width, side = "right", scrim = "subtle", children, footer, closeLabel, scrimLabel, className, "aria-label": ariaLabel }) => {
2781
+ const Drawer = ({ isOpen, busy = false, onClose, title, width, side = "right", scrim = "subtle", children, footer, closeLabel, scrimLabel, className, "aria-label": ariaLabel }) => {
2912
2782
  const strings = useUiStrings();
2913
2783
  const resolvedCloseLabel = closeLabel ?? strings.close;
2914
2784
  const resolvedScrimLabel = scrimLabel ?? strings.closePanel;
2915
2785
  const titleId = (0, react.useId)();
2916
- const panelRef = (0, react.useRef)(null);
2917
- const lastFocusRef = (0, react.useRef)(null);
2918
- (0, react.useEffect)(() => {
2919
- if (!isOpen) return;
2920
- lastFocusRef.current = document.activeElement;
2921
- const timer = window.setTimeout(() => {
2922
- (panelRef.current?.querySelector("button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\"-1\"])"))?.focus();
2923
- });
2924
- return () => {
2925
- clearTimeout(timer);
2926
- lastFocusRef.current?.focus?.();
2927
- };
2928
- }, [isOpen]);
2929
- (0, react.useEffect)(() => {
2930
- if (!isOpen) return;
2931
- const handler = (e) => {
2932
- if (e.key === "Escape") {
2933
- e.preventDefault();
2934
- onClose();
2935
- }
2936
- };
2937
- document.addEventListener("keydown", handler);
2938
- return () => document.removeEventListener("keydown", handler);
2939
- }, [isOpen, onClose]);
2940
- return (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2941
- className: [
2786
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(ModalSurface, {
2787
+ open: isOpen,
2788
+ onClose,
2789
+ closeOnEscape: !busy,
2790
+ closeOnOutsideClick: !busy,
2791
+ rootClassName: [
2942
2792
  "nb-drawer-root",
2943
2793
  isOpen && "nb-drawer-root--open",
2944
2794
  `nb-drawer-root--${side}`
2945
2795
  ].filter(Boolean).join(" "),
2946
- "aria-hidden": !isOpen,
2947
- style: { pointerEvents: isOpen ? void 0 : "none" },
2948
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2949
- className: `nb-drawer__scrim nb-drawer__scrim--${scrim}`,
2950
- type: "button",
2951
- "aria-label": resolvedScrimLabel,
2952
- tabIndex: -1,
2953
- onClick: onClose
2954
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("aside", {
2955
- ref: panelRef,
2956
- className: ["nb-drawer", className].filter(Boolean).join(" "),
2957
- role: "dialog",
2958
- "aria-modal": "false",
2959
- "aria-labelledby": title ? titleId : void 0,
2960
- "aria-label": !title ? ariaLabel : void 0,
2961
- style: { width: formatWidth(width) },
2962
- children: [
2963
- title !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("header", {
2964
- className: "nb-drawer__header",
2965
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
2966
- className: "nb-drawer__title",
2967
- id: titleId,
2968
- children: title
2969
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconButton, {
2970
- className: "nb-drawer__close",
2971
- icon: "ph ph-x",
2972
- label: resolvedCloseLabel,
2973
- onClick: onClose
2974
- })]
2975
- }),
2976
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2977
- className: "nb-drawer__body",
2978
- children
2979
- }),
2980
- footer && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("footer", {
2981
- className: "nb-drawer__footer",
2982
- children: footer
2983
- })
2984
- ]
2985
- })]
2986
- }), document.body);
2796
+ className: ["nb-drawer", className].filter(Boolean).join(" "),
2797
+ scrimClassName: `nb-drawer__scrim nb-drawer__scrim--${scrim}`,
2798
+ scrimLabel: resolvedScrimLabel,
2799
+ labelledBy: title ? titleId : void 0,
2800
+ ariaLabel: !title ? ariaLabel : void 0,
2801
+ style: { width: formatWidth(width) },
2802
+ keepMounted: true,
2803
+ children: [
2804
+ title !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("header", {
2805
+ className: "nb-drawer__header",
2806
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
2807
+ className: "nb-drawer__title",
2808
+ id: titleId,
2809
+ children: title
2810
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconButton, {
2811
+ className: "nb-drawer__close",
2812
+ icon: "ph ph-x",
2813
+ label: resolvedCloseLabel,
2814
+ onClick: onClose,
2815
+ disabled: busy
2816
+ })]
2817
+ }),
2818
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2819
+ className: "nb-drawer__body",
2820
+ children
2821
+ }),
2822
+ footer && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("footer", {
2823
+ className: "nb-drawer__footer",
2824
+ children: footer
2825
+ })
2826
+ ]
2827
+ });
2987
2828
  };
2988
2829
  //#endregion
2989
2830
  //#region packages/ui/Timeline.tsx
@@ -3022,13 +2863,14 @@ function TimelineMarker({ status, variant, marker }) {
3022
2863
  }
3023
2864
  function TimelineItem({ status, title, marker, timestamp, dateTime, tone = "default", children, className }) {
3024
2865
  const variant = useTimelineVariant();
2866
+ const classes = [
2867
+ "nb-timeline__item",
2868
+ `nb-timeline__item--${status}`,
2869
+ variant === "log" && `nb-timeline__item--tone-${tone}`,
2870
+ className
2871
+ ].filter(Boolean).join(" ");
3025
2872
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
3026
- className: [
3027
- "nb-timeline__item",
3028
- `nb-timeline__item--${status}`,
3029
- variant === "log" && `nb-timeline__item--tone-${tone}`,
3030
- className
3031
- ].filter(Boolean).join(" "),
2873
+ className: classes,
3032
2874
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3033
2875
  className: "nb-timeline__marker-col",
3034
2876
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TimelineMarker, {
@@ -3092,7 +2934,7 @@ function Page({ children, fill, wide, narrow, gap = 5, className, ...props }) {
3092
2934
  }
3093
2935
  //#endregion
3094
2936
  //#region packages/ui/PageHeader.tsx
3095
- function PageHeader({ title, subtitle, breadcrumb, breadcrumbSlot, badge, actions, className }) {
2937
+ function PageHeader({ title, subtitle, metadata, breadcrumb, breadcrumbSlot, badge, actions, className }) {
3096
2938
  const breadcrumbNode = breadcrumbSlot ?? (breadcrumb ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("a", {
3097
2939
  href: breadcrumb.href,
3098
2940
  className: "nb-page-header__breadcrumb",
@@ -3111,6 +2953,10 @@ function PageHeader({ title, subtitle, breadcrumb, breadcrumbSlot, badge, action
3111
2953
  className: "nb-page-header__title",
3112
2954
  children: title
3113
2955
  }),
2956
+ metadata && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2957
+ className: "nb-page-header__metadata",
2958
+ children: metadata
2959
+ }),
3114
2960
  subtitle && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3115
2961
  className: "nb-page-header__subtitle",
3116
2962
  children: subtitle
@@ -3161,8 +3007,9 @@ function Grid({ children, cols = 12, gap = 4, minColWidth, fill, className, styl
3161
3007
  ...style,
3162
3008
  ...minColWidth ? { "--nb-grid-min-col": minColWidth } : {}
3163
3009
  };
3010
+ const colsClass = cols === 12 ? "nb-grid--cols-12" : cols === "auto" ? "nb-grid--cols-auto" : `nb-grid--cols-${cols}`;
3164
3011
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3165
- className: joinClasses("nb-grid", cols === 12 ? "nb-grid--cols-12" : cols === "auto" ? "nb-grid--cols-auto" : `nb-grid--cols-${cols}`, gapClass("nb-grid", gap), fill && "nb-grid--fill", className),
3012
+ className: joinClasses("nb-grid", colsClass, gapClass("nb-grid", gap), fill && "nb-grid--fill", className),
3166
3013
  style: gridStyle,
3167
3014
  ...props,
3168
3015
  children
@@ -3179,9 +3026,9 @@ function Col({ children, span, spanSm, spanMd, spanLg, fullWidth, className, ...
3179
3026
  }
3180
3027
  //#endregion
3181
3028
  //#region packages/ui/Section.tsx
3182
- function Section({ title, children, className }) {
3029
+ function Section({ title, children, className, variant = "label" }) {
3183
3030
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
3184
- className: joinClasses("nb-section", className),
3031
+ className: joinClasses("nb-section", variant === "panel" && "nb-section--panel", className),
3185
3032
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
3186
3033
  className: "nb-section__title",
3187
3034
  children: title
@@ -3384,6 +3231,241 @@ function useConfirm() {
3384
3231
  };
3385
3232
  }
3386
3233
  //#endregion
3234
+ //#region packages/ui/Checkbox.tsx
3235
+ /** Native checkbox, including the mixed state used by bulk selection. */
3236
+ const Checkbox = (0, react.forwardRef)(function Checkbox({ label, indeterminate = false, invalid = false, id, className, ...props }, ref) {
3237
+ const generatedId = (0, react.useId)();
3238
+ const inputRef = (0, react.useRef)(null);
3239
+ (0, react.useEffect)(() => {
3240
+ if (inputRef.current) inputRef.current.indeterminate = indeterminate;
3241
+ }, [indeterminate]);
3242
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
3243
+ className: `nb-selection-control${className ? ` ${className}` : ""}`,
3244
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
3245
+ ...props,
3246
+ id: id ?? generatedId,
3247
+ type: "checkbox",
3248
+ "aria-invalid": props["aria-invalid"] ?? (invalid || void 0),
3249
+ ref: (node) => {
3250
+ inputRef.current = node;
3251
+ if (typeof ref === "function") return ref(node);
3252
+ if (ref) ref.current = node;
3253
+ }
3254
+ }), label && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: label })]
3255
+ });
3256
+ });
3257
+ //#endregion
3258
+ //#region packages/ui/RadioGroup.tsx
3259
+ /** Native radios share a name for browser keyboard navigation and form submission. */
3260
+ function RadioGroup({ label, name, value, options, onChange, orientation = "vertical", required, invalid = false, disabled, className, ...props }) {
3261
+ const generatedName = (0, react.useId)();
3262
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("fieldset", {
3263
+ ...props,
3264
+ disabled,
3265
+ "aria-invalid": props["aria-invalid"] ?? (invalid || void 0),
3266
+ className: `nb-radio-group${className ? ` ${className}` : ""}`,
3267
+ children: [label && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("legend", { children: label }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3268
+ className: `nb-radio-group__options nb-radio-group__options--${orientation}`,
3269
+ children: options.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
3270
+ className: "nb-selection-control",
3271
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
3272
+ type: "radio",
3273
+ name: name ?? generatedName,
3274
+ value: option.value,
3275
+ checked: value === option.value,
3276
+ disabled: disabled || option.disabled,
3277
+ required,
3278
+ onChange: () => onChange(option.value)
3279
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: option.label })]
3280
+ }, option.value))
3281
+ })]
3282
+ });
3283
+ }
3284
+ //#endregion
3285
+ //#region packages/ui/Tabs.tsx
3286
+ function Tabs({ items, value, onChange, "aria-label": ariaLabel, orientation = "horizontal", activationMode = "automatic", keepMounted = false, className }) {
3287
+ const id = (0, react.useId)();
3288
+ const listRef = (0, react.useRef)(null);
3289
+ const [focusedValue, setFocusedValue] = (0, react.useState)(null);
3290
+ const selectedIndex = items.findIndex((item) => item.value === value && !item.disabled);
3291
+ const focusedIndex = items.findIndex((item) => item.value === focusedValue && !item.disabled);
3292
+ const tabStop = activationMode === "manual" && focusedIndex >= 0 ? focusedIndex : selectedIndex >= 0 ? selectedIndex : items.findIndex((item) => !item.disabled);
3293
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3294
+ className: `nb-tabs nb-tabs--${orientation}${className ? ` ${className}` : ""}`,
3295
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3296
+ ref: listRef,
3297
+ role: "tablist",
3298
+ "aria-label": ariaLabel,
3299
+ "aria-orientation": orientation,
3300
+ className: "nb-tabs__list",
3301
+ children: items.map((item, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
3302
+ type: "button",
3303
+ role: "tab",
3304
+ id: `${id}-tab-${index}`,
3305
+ "aria-controls": `${id}-panel-${index}`,
3306
+ "aria-selected": index === selectedIndex,
3307
+ disabled: item.disabled,
3308
+ tabIndex: index === tabStop ? 0 : -1,
3309
+ className: "nb-tabs__tab",
3310
+ onFocus: () => setFocusedValue(item.value),
3311
+ onClick: () => onChange(item.value),
3312
+ onKeyDown: (event) => {
3313
+ const nextKey = orientation === "horizontal" ? "ArrowRight" : "ArrowDown";
3314
+ if (![
3315
+ nextKey,
3316
+ orientation === "horizontal" ? "ArrowLeft" : "ArrowUp",
3317
+ "Home",
3318
+ "End"
3319
+ ].includes(event.key)) return;
3320
+ event.preventDefault();
3321
+ const enabled = items.map((entry, i) => entry.disabled ? -1 : i).filter((i) => i >= 0);
3322
+ const position = enabled.indexOf(index);
3323
+ const next = event.key === "Home" ? enabled[0] : event.key === "End" ? enabled[enabled.length - 1] : enabled[(position + (event.key === nextKey ? 1 : -1) + enabled.length) % enabled.length];
3324
+ if (next === void 0) return;
3325
+ listRef.current?.querySelectorAll("[role=\"tab\"]")[next]?.focus();
3326
+ if (activationMode === "automatic") onChange(items[next].value);
3327
+ },
3328
+ children: item.label
3329
+ }, item.value))
3330
+ }), items.map((item, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3331
+ role: "tabpanel",
3332
+ id: `${id}-panel-${index}`,
3333
+ "aria-labelledby": `${id}-tab-${index}`,
3334
+ hidden: index !== selectedIndex,
3335
+ tabIndex: 0,
3336
+ className: "nb-tabs__panel",
3337
+ children: keepMounted || index === selectedIndex ? item.content : null
3338
+ }, item.value))]
3339
+ });
3340
+ }
3341
+ //#endregion
3342
+ //#region packages/ui/Spinner.tsx
3343
+ function Spinner({ label, size = "md", className, ...props }) {
3344
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3345
+ ...props,
3346
+ className: `nb-spinner nb-spinner--${size}${className ? ` ${className}` : ""}`,
3347
+ role: label ? "status" : void 0,
3348
+ "aria-label": label,
3349
+ "aria-hidden": label ? void 0 : true
3350
+ });
3351
+ }
3352
+ //#endregion
3353
+ //#region packages/ui/Progress.tsx
3354
+ /** Omit value for indeterminate progress; max defaults to 100. */
3355
+ function Progress({ label, id, max = 100, className, ...props }) {
3356
+ const generatedId = (0, react.useId)();
3357
+ const progressId = id ?? generatedId;
3358
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3359
+ className: "nb-progress-field",
3360
+ children: [label && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
3361
+ htmlFor: progressId,
3362
+ children: label
3363
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("progress", {
3364
+ ...props,
3365
+ id: progressId,
3366
+ max,
3367
+ className: `nb-progress${className ? ` ${className}` : ""}`
3368
+ })]
3369
+ });
3370
+ }
3371
+ //#endregion
3372
+ //#region packages/ui/Tooltip.tsx
3373
+ const TooltipProvider = _base_ui_react_tooltip.Tooltip.Provider;
3374
+ /** Uses the existing child as the trigger without adding a nested button. */
3375
+ function Tooltip({ children, content, side = "top", delay, disabled, className }) {
3376
+ const overlayContainer = useOverlayContainer();
3377
+ const id = (0, react.useId)();
3378
+ const [open, setOpen] = (0, react.useState)(false);
3379
+ const description = [children.props["aria-describedby"], open && !disabled ? id : void 0].filter(Boolean).join(" ") || void 0;
3380
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_base_ui_react_tooltip.Tooltip.Root, {
3381
+ open,
3382
+ disabled,
3383
+ onOpenChange: setOpen,
3384
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_tooltip.Tooltip.Trigger, {
3385
+ render: (0, react.cloneElement)(children, { "aria-describedby": description }),
3386
+ onKeyDownCapture: (event) => {
3387
+ if (open && event.key === "Escape") {
3388
+ event.stopPropagation();
3389
+ setOpen(false);
3390
+ }
3391
+ },
3392
+ delay
3393
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_tooltip.Tooltip.Portal, {
3394
+ container: overlayContainer ?? void 0,
3395
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_tooltip.Tooltip.Positioner, {
3396
+ side,
3397
+ sideOffset: 8,
3398
+ className: "nb-tooltip-positioner",
3399
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_tooltip.Tooltip.Popup, {
3400
+ id,
3401
+ role: "tooltip",
3402
+ className: `nb-tooltip${className ? ` ${className}` : ""}`,
3403
+ children: content
3404
+ })
3405
+ })
3406
+ })]
3407
+ });
3408
+ }
3409
+ //#endregion
3410
+ //#region packages/ui/TimePicker.tsx
3411
+ const timeValue = (value) => {
3412
+ if (!value) return null;
3413
+ try {
3414
+ return (0, _internationalized_date.parseTime)(value);
3415
+ } catch {
3416
+ return null;
3417
+ }
3418
+ };
3419
+ /** Accessible segmented time entry. Values never pass through Date or a timezone. */
3420
+ const TimePicker = (0, react.forwardRef)(function TimePicker({ id, name, value, onChange, onBlur, min, max, locale, hourCycle, granularity = "minute", disabled, readOnly, required, invalid, className, ariaLabel }, ref) {
3421
+ const strings = useUiStrings();
3422
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.I18nProvider, {
3423
+ locale: getDateLocale(locale),
3424
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.TimeField, {
3425
+ id,
3426
+ name,
3427
+ "aria-label": ariaLabel ?? strings.selectTime,
3428
+ value: timeValue(value),
3429
+ onChange: (next) => onChange?.(next ? next.toString().slice(0, granularity === "second" ? 8 : 5) : ""),
3430
+ onBlur,
3431
+ minValue: timeValue(min) ?? void 0,
3432
+ maxValue: timeValue(max) ?? void 0,
3433
+ granularity,
3434
+ hourCycle,
3435
+ isDisabled: disabled,
3436
+ isReadOnly: readOnly,
3437
+ isRequired: required,
3438
+ isInvalid: invalid,
3439
+ validationBehavior: "aria",
3440
+ className: ["nb-time-picker", className].filter(Boolean).join(" "),
3441
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.DateInput, {
3442
+ ref,
3443
+ className: "nb-time-picker__input",
3444
+ children: (segment) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.DateSegment, {
3445
+ segment,
3446
+ className: "nb-time-picker__segment"
3447
+ })
3448
+ })
3449
+ })
3450
+ });
3451
+ });
3452
+ //#endregion
3453
+ //#region packages/ui/DetailLayout.tsx
3454
+ /** Responsive main/aside composition for record detail pages. */
3455
+ function DetailLayout({ children, aside, asideLabel, className }) {
3456
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3457
+ className: joinClasses("nb-detail-layout", className),
3458
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3459
+ className: "nb-detail-layout__main",
3460
+ children
3461
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("aside", {
3462
+ className: "nb-detail-layout__aside",
3463
+ "aria-label": asideLabel,
3464
+ children: aside
3465
+ })]
3466
+ });
3467
+ }
3468
+ //#endregion
3387
3469
  exports.ACCENT_PRESETS = ACCENT_PRESETS;
3388
3470
  exports.Alert = Alert;
3389
3471
  exports.AppDialog = AppDialog;
@@ -3393,11 +3475,13 @@ exports.Avatar = Avatar;
3393
3475
  exports.Badge = Badge;
3394
3476
  exports.Button = Button;
3395
3477
  exports.Card = Card;
3478
+ exports.Checkbox = Checkbox;
3396
3479
  exports.Chip = Chip;
3397
3480
  exports.Cluster = Cluster;
3398
3481
  exports.Code = Code;
3399
3482
  exports.Col = Col;
3400
3483
  exports.CollapsibleSection = CollapsibleSection;
3484
+ exports.Combobox = Combobox;
3401
3485
  exports.ConfirmDialog = ConfirmDialog;
3402
3486
  exports.ContextMenu = ContextMenu;
3403
3487
  exports.DataTable = DataTable;
@@ -3406,6 +3490,7 @@ exports.DateRangePicker = DateRangePicker;
3406
3490
  exports.DensityContext = DensityContext;
3407
3491
  exports.DensityProvider = DensityProvider;
3408
3492
  exports.DescriptionList = DescriptionList;
3493
+ exports.DetailLayout = DetailLayout;
3409
3494
  exports.Drawer = Drawer;
3410
3495
  exports.EN_UI_STRINGS = EN_UI_STRINGS;
3411
3496
  exports.ES_UI_STRINGS = ES_UI_STRINGS;
@@ -3420,11 +3505,14 @@ exports.Grid = Grid;
3420
3505
  exports.HubPanel = HubPanel;
3421
3506
  exports.IconButton = IconButton;
3422
3507
  exports.KpiMetricRow = KpiMetricRow;
3508
+ exports.MultiSelect = MultiSelect;
3423
3509
  exports.OperationCardGrid = OperationCardGrid;
3424
3510
  exports.Page = Page;
3425
3511
  exports.PageHeader = PageHeader;
3426
3512
  exports.Pagination = Pagination;
3427
3513
  exports.Popover = Popover;
3514
+ exports.Progress = Progress;
3515
+ exports.RadioGroup = RadioGroup;
3428
3516
  exports.Row = Row;
3429
3517
  exports.RowActions = RowActions;
3430
3518
  exports.ScopeTabs = ScopeTabs;
@@ -3434,17 +3522,22 @@ exports.SegmentedControl = SegmentedControl;
3434
3522
  exports.SelectField = SelectField;
3435
3523
  exports.SettingsPanel = SettingsPanel;
3436
3524
  exports.Skeleton = Skeleton;
3525
+ exports.Spinner = Spinner;
3437
3526
  exports.Stack = Stack;
3438
3527
  exports.StatCard = StatCard;
3528
+ exports.Tabs = Tabs;
3439
3529
  exports.Text = Text;
3440
3530
  exports.TextAreaField = TextAreaField;
3441
3531
  exports.TextField = TextField;
3442
3532
  exports.ThemeContext = ThemeContext;
3443
3533
  exports.ThemeProvider = ThemeProvider;
3444
3534
  exports.ThemeSwitcher = ThemeSwitcher;
3535
+ exports.TimePicker = TimePicker;
3445
3536
  exports.Timeline = Timeline;
3446
3537
  exports.TimelineItem = TimelineItem;
3447
3538
  exports.Toggle = Toggle;
3539
+ exports.Tooltip = Tooltip;
3540
+ exports.TooltipProvider = TooltipProvider;
3448
3541
  exports.UiStringsProvider = UiStringsProvider;
3449
3542
  exports.getAvatarHue = getAvatarHue;
3450
3543
  exports.getAvatarInitials = getAvatarInitials;
@@ -3452,5 +3545,6 @@ exports.useAccentColor = useAccentColor;
3452
3545
  exports.useConfirm = useConfirm;
3453
3546
  exports.useDensity = useDensity;
3454
3547
  exports.useFloatingPanel = useFloatingPanel;
3548
+ exports.useOverlayContainer = useOverlayContainer;
3455
3549
  exports.useTheme = useTheme;
3456
3550
  exports.useUiStrings = useUiStrings;