@misael703/ui 1.3.0 → 1.5.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/README.md +6 -6
- package/dist/{chunk-PSJVU4E4.js → chunk-2UTXUFZY.js} +33 -10
- package/dist/chunk-2UTXUFZY.js.map +1 -0
- package/dist/{chunk-3N4IBCLW.mjs → chunk-7D6Y33UY.mjs} +4 -4
- package/dist/{chunk-3N4IBCLW.mjs.map → chunk-7D6Y33UY.mjs.map} +1 -1
- package/dist/{chunk-GCW5JYWQ.js → chunk-EUB4PHPI.js} +56 -2
- package/dist/chunk-EUB4PHPI.js.map +1 -0
- package/dist/{chunk-GIOMV3J7.js → chunk-FL4ZCWUF.js} +7 -3
- package/dist/chunk-FL4ZCWUF.js.map +1 -0
- package/dist/{chunk-LXNHGGAK.js → chunk-IALAIASX.js} +4 -4
- package/dist/{chunk-LXNHGGAK.js.map → chunk-IALAIASX.js.map} +1 -1
- package/dist/chunk-IEPKSPBX.mjs +97 -0
- package/dist/chunk-IEPKSPBX.mjs.map +1 -0
- package/dist/{chunk-V26K66NP.mjs → chunk-JBUMN6Q4.mjs} +33 -10
- package/dist/chunk-JBUMN6Q4.mjs.map +1 -0
- package/dist/{chunk-7VG64AY7.mjs → chunk-JWGK5HKF.mjs} +3 -3
- package/dist/{chunk-7VG64AY7.mjs.map → chunk-JWGK5HKF.mjs.map} +1 -1
- package/dist/{chunk-TBAKKSAN.js → chunk-LK2PFMDU.js} +4 -4
- package/dist/{chunk-TBAKKSAN.js.map → chunk-LK2PFMDU.js.map} +1 -1
- package/dist/{chunk-FXM7OKDQ.js → chunk-LKBYMAGV.js} +3 -3
- package/dist/chunk-LKBYMAGV.js.map +1 -0
- package/dist/{chunk-26KJA67X.js → chunk-QSMUGO5F.js} +13 -15
- package/dist/chunk-QSMUGO5F.js.map +1 -0
- package/dist/{chunk-REL2RZTI.js → chunk-S5BIOB34.js} +6 -6
- package/dist/{chunk-REL2RZTI.js.map → chunk-S5BIOB34.js.map} +1 -1
- package/dist/{chunk-HBUP7XO2.js → chunk-TI5QCUAV.js} +4 -4
- package/dist/{chunk-HBUP7XO2.js.map → chunk-TI5QCUAV.js.map} +1 -1
- package/dist/{chunk-XXUSZD5I.mjs → chunk-U3JH4T3A.mjs} +7 -3
- package/dist/chunk-U3JH4T3A.mjs.map +1 -0
- package/dist/{chunk-33PU6AH7.mjs → chunk-X6VCY7MD.mjs} +3 -3
- package/dist/chunk-X6VCY7MD.mjs.map +1 -0
- package/dist/{chunk-SYX4GZ7E.mjs → chunk-YIZ2QRHJ.mjs} +13 -15
- package/dist/chunk-YIZ2QRHJ.mjs.map +1 -0
- package/dist/{chunk-C35GKQJO.mjs → chunk-YXSKREHS.mjs} +3 -3
- package/dist/{chunk-C35GKQJO.mjs.map → chunk-YXSKREHS.mjs.map} +1 -1
- package/dist/{chunk-R76SJURE.mjs → chunk-Z67IZS4P.mjs} +3 -3
- package/dist/{chunk-R76SJURE.mjs.map → chunk-Z67IZS4P.mjs.map} +1 -1
- package/dist/components/Button.d.mts +6 -0
- package/dist/components/Button.d.ts +6 -0
- package/dist/components/Button.js +4 -3
- package/dist/components/Button.mjs +2 -1
- package/dist/components/Commerce.js +14 -14
- package/dist/components/Commerce.mjs +3 -3
- package/dist/components/Display.d.mts +6 -0
- package/dist/components/Display.d.ts +6 -0
- package/dist/components/Display.js +13 -12
- package/dist/components/Display.mjs +2 -1
- package/dist/components/Editing.js +8 -8
- package/dist/components/Editing.mjs +3 -3
- package/dist/components/Layout.js +19 -19
- package/dist/components/Layout.mjs +2 -2
- package/dist/components/Overlay.js +4 -4
- package/dist/components/Overlay.mjs +2 -2
- package/dist/components/Primitives.d.mts +12 -1
- package/dist/components/Primitives.d.ts +12 -1
- package/dist/components/Primitives.js +12 -4
- package/dist/components/Primitives.mjs +1 -1
- package/dist/components/Toast.js +3 -3
- package/dist/components/Toast.mjs +1 -1
- package/dist/hooks/index.js +2 -2
- package/dist/hooks/index.mjs +1 -1
- package/dist/hooks/useDelayedUnmount.d.mts +0 -16
- package/dist/hooks/useDelayedUnmount.d.ts +0 -16
- package/dist/hooks/useDelayedUnmount.js +2 -2
- package/dist/hooks/useDelayedUnmount.mjs +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +79 -71
- package/dist/index.mjs +9 -9
- package/dist/styles.css +1 -1
- package/dist/tokens.css +1 -1
- package/package.json +1 -1
- package/dist/chunk-26KJA67X.js.map +0 -1
- package/dist/chunk-33PU6AH7.mjs.map +0 -1
- package/dist/chunk-6MEOR4YO.mjs +0 -45
- package/dist/chunk-6MEOR4YO.mjs.map +0 -1
- package/dist/chunk-FXM7OKDQ.js.map +0 -1
- package/dist/chunk-GCW5JYWQ.js.map +0 -1
- package/dist/chunk-GIOMV3J7.js.map +0 -1
- package/dist/chunk-PSJVU4E4.js.map +0 -1
- package/dist/chunk-SYX4GZ7E.mjs.map +0 -1
- package/dist/chunk-V26K66NP.mjs.map +0 -1
- package/dist/chunk-XXUSZD5I.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -112,14 +112,14 @@ El reverso: **si tu reset global no está en un layer, gana sobre el kit**. El c
|
|
|
112
112
|
|
|
113
113
|
Tres formas de evitarlo, ordenadas de menos a más invasiva:
|
|
114
114
|
|
|
115
|
-
1. **Envolver tus estilos en un layer también
|
|
115
|
+
1. **Envolver tus estilos en un layer también**: agrega `@import "tailwindcss"` (Tailwind v4) o `@layer base, components, utilities;` (Tailwind v3) explícitamente, y asegúrate de que tus utilidades vivan dentro de layers. Cuando ambos están layered, el orden de capas controla quién gana.
|
|
116
116
|
2. **Desactivar el preflight** — en `tailwind.config.js`: `corePlugins: { preflight: false }`. Te pierde el reset pero el kit queda intacto.
|
|
117
|
-
3. **Override puntual desde tu app
|
|
117
|
+
3. **Override puntual desde tu app**: si solo te molesta un componente, puedes re-establecer la propiedad afuera de cualquier layer:
|
|
118
118
|
```css
|
|
119
119
|
.card[class*="card--accent-"] { border-style: solid; }
|
|
120
120
|
```
|
|
121
121
|
|
|
122
|
-
A partir de v0.4.5 el kit mitiga este problema en `Card` usando `box-shadow inset` para la accent rail en vez de `border-left`. Otros componentes con bordes finos (`Input`, `Select`, `Table`) siguen dependiendo de `border-*` y son afectados por el preflight
|
|
122
|
+
A partir de v0.4.5 el kit mitiga este problema en `Card` usando `box-shadow inset` para la accent rail en vez de `border-left`. Otros componentes con bordes finos (`Input`, `Select`, `Table`) siguen dependiendo de `border-*` y son afectados por el preflight. Si te pasa, usa la opción (1) o (2).
|
|
123
123
|
|
|
124
124
|
---
|
|
125
125
|
|
|
@@ -270,7 +270,7 @@ Heredan `color` del padre y aceptan `size`, `strokeWidth`, `className` y `title`
|
|
|
270
270
|
|
|
271
271
|
### Fuentes (opcional)
|
|
272
272
|
|
|
273
|
-
Si no
|
|
273
|
+
Si no usas `next/font`, puedes cargar Outfit (display) + DM Sans (body) empaquetadas con el kit. Ambas son variable fonts, total ~80 KB:
|
|
274
274
|
|
|
275
275
|
```ts
|
|
276
276
|
// app/layout.tsx
|
|
@@ -315,7 +315,7 @@ Los tokens viven en `:root`. La paleta de marca y los tokens semánticos están
|
|
|
315
315
|
.my-card { background: var(--bg-surface); color: var(--fg-default); }
|
|
316
316
|
```
|
|
317
317
|
|
|
318
|
-
¿Solo
|
|
318
|
+
¿Solo quieres los tokens (sin los componentes)? Importa únicamente `tokens.css`:
|
|
319
319
|
|
|
320
320
|
```ts
|
|
321
321
|
import '@misael703/ui/tokens.css';
|
|
@@ -323,7 +323,7 @@ import '@misael703/ui/tokens.css';
|
|
|
323
323
|
|
|
324
324
|
### Superficies invertidas (zonas con bg oscuro)
|
|
325
325
|
|
|
326
|
-
El kit resetea `color` en `<p>`, `<h1>`–`<h6>`, anchors y `.caption` para mantener consistencia tipográfica. Cuando
|
|
326
|
+
El kit resetea `color` en `<p>`, `<h1>`–`<h6>`, anchors y `.caption` para mantener consistencia tipográfica. Cuando metes esos elementos dentro de un footer / hero / sidebar oscuro, el color heredado del kit gana sobre el `color` del padre (especificidad). Para invertir el subtree completo en una línea, usa `.surface-inverse`:
|
|
327
327
|
|
|
328
328
|
```html
|
|
329
329
|
<footer class="surface-inverse surface-inverse--brand">
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var chunkEUB4PHPI_js = require('./chunk-EUB4PHPI.js');
|
|
3
4
|
var chunkPASF6T4H_js = require('./chunk-PASF6T4H.js');
|
|
4
5
|
var React = require('react');
|
|
5
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
@@ -34,20 +35,42 @@ var Button = React__namespace.forwardRef(function Button2({
|
|
|
34
35
|
className,
|
|
35
36
|
disabled,
|
|
36
37
|
children,
|
|
38
|
+
asChild = false,
|
|
37
39
|
...rest
|
|
38
40
|
}, ref) {
|
|
41
|
+
const cls = chunkPASF6T4H_js.cx(
|
|
42
|
+
"btn",
|
|
43
|
+
`btn--${variant}`,
|
|
44
|
+
`btn--${size}`,
|
|
45
|
+
fullWidth && "btn--block",
|
|
46
|
+
loading && "is-loading",
|
|
47
|
+
className
|
|
48
|
+
);
|
|
49
|
+
if (asChild) {
|
|
50
|
+
const blocked = disabled || loading;
|
|
51
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
52
|
+
chunkEUB4PHPI_js.Slot,
|
|
53
|
+
{
|
|
54
|
+
ref,
|
|
55
|
+
className: cls,
|
|
56
|
+
"aria-busy": loading || void 0,
|
|
57
|
+
"aria-disabled": blocked || void 0,
|
|
58
|
+
"data-disabled": blocked || void 0,
|
|
59
|
+
...rest,
|
|
60
|
+
children: [
|
|
61
|
+
loading && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "spinner spinner--inverse", "aria-hidden": "true" }),
|
|
62
|
+
!loading && iconLeft,
|
|
63
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkEUB4PHPI_js.Slottable, { children }),
|
|
64
|
+
!loading && iconRight
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
}
|
|
39
69
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
40
70
|
"button",
|
|
41
71
|
{
|
|
42
72
|
ref,
|
|
43
|
-
className:
|
|
44
|
-
"btn",
|
|
45
|
-
`btn--${variant}`,
|
|
46
|
-
`btn--${size}`,
|
|
47
|
-
fullWidth && "btn--block",
|
|
48
|
-
loading && "is-loading",
|
|
49
|
-
className
|
|
50
|
-
),
|
|
73
|
+
className: cls,
|
|
51
74
|
disabled: disabled || loading,
|
|
52
75
|
"aria-busy": loading || void 0,
|
|
53
76
|
...rest,
|
|
@@ -68,5 +91,5 @@ var ButtonGroup = React__namespace.forwardRef(
|
|
|
68
91
|
|
|
69
92
|
exports.Button = Button;
|
|
70
93
|
exports.ButtonGroup = ButtonGroup;
|
|
71
|
-
//# sourceMappingURL=chunk-
|
|
72
|
-
//# sourceMappingURL=chunk-
|
|
94
|
+
//# sourceMappingURL=chunk-2UTXUFZY.js.map
|
|
95
|
+
//# sourceMappingURL=chunk-2UTXUFZY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/Button.tsx"],"names":["React","Button","cx","jsxs","Slot","jsx","Slottable","ButtonGroup"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCO,IAAM,MAAA,GAAeA,gBAAA,CAAA,UAAA,CAA2C,SAASC,OAAAA,CAC9E;AAAA,EACE,OAAA,GAAU,SAAA;AAAA,EACV,IAAA,GAAO,IAAA;AAAA,EACP,OAAA,GAAU,KAAA;AAAA,EACV,QAAA;AAAA,EACA,SAAA;AAAA,EACA,SAAA,GAAY,KAAA;AAAA,EACZ,SAAA;AAAA,EACA,QAAA;AAAA,EACA,QAAA;AAAA,EACA,OAAA,GAAU,KAAA;AAAA,EACV,GAAG;AACL,CAAA,EACA,GAAA,EACA;AACA,EAAA,MAAM,GAAA,GAAMC,mBAAA;AAAA,IACV,KAAA;AAAA,IACA,QAAQ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/B,SAASO,aAAY,EAAE,SAAA,EAAW,OAAO,OAAA,EAAS,GAAG,IAAA,EAAK,EAAG,GAAA,EAAK;AAChE,IAAA,uBAAOF,cAAA,CAAC,KAAA,EAAA,EAAI,GAAA,EAAU,IAAA,EAAY,SAAA,EAAWH,oBAAG,WAAA,EAAa,SAAS,CAAA,EAAI,GAAG,IAAA,EAAM,CAAA;AAAA,EACrF;AACF","file":"chunk-2UTXUFZY.js","sourcesContent":["import * as React from 'react';\nimport { cx } from '../utils/cx';\nimport { Slot, Slottable } from './Primitives';\n\nexport type ButtonVariant =\n | 'primary'\n | 'secondary'\n | 'outline'\n | 'ghost'\n | 'subtle'\n | 'danger'\n | 'success'\n | 'warning'\n | 'link';\n\nexport type ButtonSize = 'sm' | 'md' | 'lg';\n\nexport interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n variant?: ButtonVariant;\n size?: ButtonSize;\n loading?: boolean;\n iconLeft?: React.ReactNode;\n iconRight?: React.ReactNode;\n fullWidth?: boolean;\n /**\n * Render as the provided single child element instead of `<button>`\n * (e.g. `next/link`'s `<a>`). The kit's classes, ref and handlers are\n * merged onto that element; `iconLeft`/`iconRight`/loading are preserved.\n */\n asChild?: boolean;\n}\n\nexport const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(function Button(\n {\n variant = 'primary',\n size = 'md',\n loading = false,\n iconLeft,\n iconRight,\n fullWidth = false,\n className,\n disabled,\n children,\n asChild = false,\n ...rest\n },\n ref\n) {\n const cls = cx(\n 'btn',\n `btn--${variant}`,\n `btn--${size}`,\n fullWidth && 'btn--block',\n loading && 'is-loading',\n className\n );\n\n if (asChild) {\n const blocked = disabled || loading;\n return (\n <Slot\n ref={ref as React.Ref<HTMLElement>}\n className={cls}\n aria-busy={loading || undefined}\n aria-disabled={blocked || undefined}\n data-disabled={blocked || undefined}\n {...rest}\n >\n {loading && <span className=\"spinner spinner--inverse\" aria-hidden=\"true\" />}\n {!loading && iconLeft}\n <Slottable>{children}</Slottable>\n {!loading && iconRight}\n </Slot>\n );\n }\n\n return (\n <button\n ref={ref}\n className={cls}\n disabled={disabled || loading}\n aria-busy={loading || undefined}\n {...rest}\n >\n {loading && <span className=\"spinner spinner--inverse\" aria-hidden=\"true\" />}\n {!loading && iconLeft}\n {children}\n {!loading && iconRight}\n </button>\n );\n});\n\n// ---------- ButtonGroup --------------------------------------------------\nexport const ButtonGroup = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(\n function ButtonGroup({ className, role = 'group', ...rest }, ref) {\n return <div ref={ref} role={role} className={cx('btn-group', className)} {...rest} />;\n }\n);\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useDelayedUnmount } from './chunk-
|
|
1
|
+
import { useDelayedUnmount } from './chunk-U3JH4T3A.mjs';
|
|
2
2
|
import { useLocale } from './chunk-ZRFSTYRL.mjs';
|
|
3
3
|
import { X } from './chunk-CIBJKJV3.mjs';
|
|
4
4
|
import { cx } from './chunk-IEPCH3JB.mjs';
|
|
@@ -6,7 +6,7 @@ import * as React from 'react';
|
|
|
6
6
|
import { createPortal } from 'react-dom';
|
|
7
7
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
8
8
|
|
|
9
|
-
var EXIT_MS =
|
|
9
|
+
var EXIT_MS = 150;
|
|
10
10
|
function useEscape(active, onClose, enabled) {
|
|
11
11
|
React.useEffect(() => {
|
|
12
12
|
if (typeof document === "undefined") return;
|
|
@@ -170,5 +170,5 @@ function Drawer({
|
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
export { Drawer, Modal };
|
|
173
|
-
//# sourceMappingURL=chunk-
|
|
174
|
-
//# sourceMappingURL=chunk-
|
|
173
|
+
//# sourceMappingURL=chunk-7D6Y33UY.mjs.map
|
|
174
|
+
//# sourceMappingURL=chunk-7D6Y33UY.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Overlay.tsx"],"names":[],"mappings":";;;;;;;;AA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,EAAA,EAAE,IAAA,EAAM,IAAI,CAAA,EAAE;AAAA,eAAA,EAClH,CAAA;AAAA,8BAEF,GAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,cAAA,EAAgB,QAAA,EAAS,CAAA;AAAA,cACvC,MAAA,oBAAU,GAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,kBAAkB,QAAA,EAAA,MAAA,EAAO;AAAA;AAAA;AAAA;AACrD;AAAA,KACF;AAAA,IACA,QAAA,CAAS;AAAA,GACX;AACF","file":"chunk-3N4IBCLW.mjs","sourcesContent":["'use client';\nimport * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { cx } from '../utils/cx';\nimport { X } from './Icons';\nimport { useLocale } from '../locale/LocaleProvider';\nimport { useDelayedUnmount } from '../hooks/useDelayedUnmount';\n\n// Exit animation duration in ms. Must match the `is-closing` keyframes\n// in src/styles/index.css (`.modal-backdrop`, `.drawer-backdrop`).\nconst EXIT_MS = 200;\n\nexport interface OverlayProps {\n open: boolean;\n onClose: () => void;\n title?: React.ReactNode;\n children?: React.ReactNode;\n footer?: React.ReactNode;\n size?: 'sm' | 'md' | 'lg';\n closeOnBackdrop?: boolean;\n closeOnEsc?: boolean;\n className?: string;\n}\n\nfunction useEscape(active: boolean, onClose: () => void, enabled: boolean) {\n React.useEffect(() => {\n if (typeof document === 'undefined') return;\n if (!active || !enabled) return;\n const onKey = (e: KeyboardEvent) => {\n if (e.key === 'Escape') onClose();\n };\n document.addEventListener('keydown', onKey);\n return () => document.removeEventListener('keydown', onKey);\n }, [active, enabled, onClose]);\n}\n\nfunction useFocusTrap(ref: React.RefObject<HTMLElement>, active: boolean) {\n React.useEffect(() => {\n if (typeof document === 'undefined') return;\n if (!active || !ref.current) return;\n const node = ref.current;\n const previously = document.activeElement as HTMLElement | null;\n const focusables = () =>\n Array.from(\n node.querySelectorAll<HTMLElement>(\n 'a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex=\"-1\"])'\n )\n );\n const first = focusables()[0];\n first?.focus();\n const onKey = (e: KeyboardEvent) => {\n if (e.key !== 'Tab') return;\n const list = focusables();\n if (list.length === 0) return;\n const f = list[0], l = list[list.length - 1];\n if (e.shiftKey && document.activeElement === f) {\n e.preventDefault(); l.focus();\n } else if (!e.shiftKey && document.activeElement === l) {\n e.preventDefault(); f.focus();\n }\n };\n document.addEventListener('keydown', onKey);\n return () => {\n document.removeEventListener('keydown', onKey);\n previously?.focus?.();\n };\n }, [active, ref]);\n}\n\n// Lock body scroll while any overlay is open. Stacked overlays share a single\n// counter so closing the inner one doesn't release the lock for the outer one.\nlet scrollLockCount = 0;\nlet originalOverflow = '';\nfunction useScrollLock(active: boolean) {\n React.useEffect(() => {\n if (typeof document === 'undefined') return;\n if (!active) return;\n if (scrollLockCount === 0) {\n originalOverflow = document.body.style.overflow;\n document.body.style.overflow = 'hidden';\n }\n scrollLockCount++;\n return () => {\n scrollLockCount--;\n if (scrollLockCount === 0) {\n document.body.style.overflow = originalOverflow;\n }\n };\n }, [active]);\n}\n\nexport function Modal({\n open, onClose, title, children, footer, size = 'md',\n closeOnBackdrop = true, closeOnEsc = true, className,\n}: OverlayProps) {\n const ref = React.useRef<HTMLDivElement>(null);\n const titleId = React.useId();\n const t = useLocale();\n // useDelayedUnmount keeps the DOM mounted during exit animation. The\n // a11y/scroll-lock hooks still consume `open` (the user's intent), not\n // `mounted` — we don't want to trap focus or block scroll while\n // animating out.\n const { mounted, closing } = useDelayedUnmount(open, EXIT_MS);\n useEscape(open, onClose, closeOnEsc);\n useFocusTrap(ref, open);\n useScrollLock(open);\n if (!mounted || typeof document === 'undefined') return null;\n return createPortal(\n <div\n className={cx('modal-backdrop', closing && 'is-closing')}\n onClick={() => closeOnBackdrop && onClose()}\n >\n <div\n ref={ref}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby={title ? titleId : undefined}\n className={cx('modal', `modal--${size}`, closing && 'is-closing', className)}\n onClick={(e) => e.stopPropagation()}\n >\n {title && (\n <div className=\"modal__header\">\n <div id={titleId} className=\"modal__title\">{title}</div>\n <button type=\"button\" className=\"modal__close\" onClick={onClose} aria-label={t['modal.close']}><X size={18} /></button>\n </div>\n )}\n <div className=\"modal__body\">{children}</div>\n {footer && <div className=\"modal__footer\">{footer}</div>}\n </div>\n </div>,\n document.body\n );\n}\n\nexport interface DrawerProps extends OverlayProps {\n side?: 'left' | 'right';\n}\n\nexport function Drawer({\n open, onClose, title, children, footer, side = 'right',\n closeOnBackdrop = true, closeOnEsc = true, className,\n}: DrawerProps) {\n const ref = React.useRef<HTMLDivElement>(null);\n const titleId = React.useId();\n const t = useLocale();\n const { mounted, closing } = useDelayedUnmount(open, EXIT_MS);\n useEscape(open, onClose, closeOnEsc);\n useFocusTrap(ref, open);\n useScrollLock(open);\n if (!mounted || typeof document === 'undefined') return null;\n return createPortal(\n <div\n className={cx('drawer-backdrop', closing && 'is-closing')}\n onClick={() => closeOnBackdrop && onClose()}\n >\n <div\n ref={ref}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby={title ? titleId : undefined}\n className={cx('drawer', `drawer--${side}`, closing && 'is-closing', className)}\n onClick={(e) => e.stopPropagation()}\n >\n {title && (\n <div className=\"drawer__header\">\n <div id={titleId} className=\"drawer__title\">{title}</div>\n <button type=\"button\" className=\"drawer__close\" onClick={onClose} aria-label={t['drawer.close']}><X size={18} /></button>\n </div>\n )}\n <div className=\"drawer__body\">{children}</div>\n {footer && <div className=\"drawer__footer\">{footer}</div>}\n </div>\n </div>,\n document.body\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/Overlay.tsx"],"names":[],"mappings":";;;;;;;;AAWA,IAAM,OAAA,GAAU,GAAA;AAchB,SAAS,SAAA,CAAU,MAAA,EAAiB,OAAA,EAAqB,OAAA,EAAkB;AACzE,EAAM,gBAAU,MAAM;AACpB,IAAA,IAAI,OAAO,aAAa,WAAA,EAAa;AACrC,IAAA,IAAI,CAAC,MA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CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,kBAAkB,QAAA,EAAA,MAAA,EAAO;AAAA;AAAA;AAAA;AACrD;AAAA,KACF;AAAA,IACA,QAAA,CAAS;AAAA,GACX;AACF","file":"chunk-7D6Y33UY.mjs","sourcesContent":["'use client';\nimport * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { cx } from '../utils/cx';\nimport { X } from './Icons';\nimport { useLocale } from '../locale/LocaleProvider';\nimport { useDelayedUnmount } from '../hooks/useDelayedUnmount';\n\n// Exit animation duration in ms. Must match `--duration-exit` and the\n// `is-closing` keyframes in src/styles/index.css (`.modal-backdrop`,\n// `.drawer-backdrop`).\nconst EXIT_MS = 150;\n\nexport interface OverlayProps {\n open: boolean;\n onClose: () => void;\n title?: React.ReactNode;\n children?: React.ReactNode;\n footer?: React.ReactNode;\n size?: 'sm' | 'md' | 'lg';\n closeOnBackdrop?: boolean;\n closeOnEsc?: boolean;\n className?: string;\n}\n\nfunction useEscape(active: boolean, onClose: () => void, enabled: boolean) {\n React.useEffect(() => {\n if (typeof document === 'undefined') return;\n if (!active || !enabled) return;\n const onKey = (e: KeyboardEvent) => {\n if (e.key === 'Escape') onClose();\n };\n document.addEventListener('keydown', onKey);\n return () => document.removeEventListener('keydown', onKey);\n }, [active, enabled, onClose]);\n}\n\nfunction useFocusTrap(ref: React.RefObject<HTMLElement>, active: boolean) {\n React.useEffect(() => {\n if (typeof document === 'undefined') return;\n if (!active || !ref.current) return;\n const node = ref.current;\n const previously = document.activeElement as HTMLElement | null;\n const focusables = () =>\n Array.from(\n node.querySelectorAll<HTMLElement>(\n 'a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex=\"-1\"])'\n )\n );\n const first = focusables()[0];\n first?.focus();\n const onKey = (e: KeyboardEvent) => {\n if (e.key !== 'Tab') return;\n const list = focusables();\n if (list.length === 0) return;\n const f = list[0], l = list[list.length - 1];\n if (e.shiftKey && document.activeElement === f) {\n e.preventDefault(); l.focus();\n } else if (!e.shiftKey && document.activeElement === l) {\n e.preventDefault(); f.focus();\n }\n };\n document.addEventListener('keydown', onKey);\n return () => {\n document.removeEventListener('keydown', onKey);\n previously?.focus?.();\n };\n }, [active, ref]);\n}\n\n// Lock body scroll while any overlay is open. Stacked overlays share a single\n// counter so closing the inner one doesn't release the lock for the outer one.\nlet scrollLockCount = 0;\nlet originalOverflow = '';\nfunction useScrollLock(active: boolean) {\n React.useEffect(() => {\n if (typeof document === 'undefined') return;\n if (!active) return;\n if (scrollLockCount === 0) {\n originalOverflow = document.body.style.overflow;\n document.body.style.overflow = 'hidden';\n }\n scrollLockCount++;\n return () => {\n scrollLockCount--;\n if (scrollLockCount === 0) {\n document.body.style.overflow = originalOverflow;\n }\n };\n }, [active]);\n}\n\nexport function Modal({\n open, onClose, title, children, footer, size = 'md',\n closeOnBackdrop = true, closeOnEsc = true, className,\n}: OverlayProps) {\n const ref = React.useRef<HTMLDivElement>(null);\n const titleId = React.useId();\n const t = useLocale();\n // useDelayedUnmount keeps the DOM mounted during exit animation. The\n // a11y/scroll-lock hooks still consume `open` (the user's intent), not\n // `mounted` — we don't want to trap focus or block scroll while\n // animating out.\n const { mounted, closing } = useDelayedUnmount(open, EXIT_MS);\n useEscape(open, onClose, closeOnEsc);\n useFocusTrap(ref, open);\n useScrollLock(open);\n if (!mounted || typeof document === 'undefined') return null;\n return createPortal(\n <div\n className={cx('modal-backdrop', closing && 'is-closing')}\n onClick={() => closeOnBackdrop && onClose()}\n >\n <div\n ref={ref}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby={title ? titleId : undefined}\n className={cx('modal', `modal--${size}`, closing && 'is-closing', className)}\n onClick={(e) => e.stopPropagation()}\n >\n {title && (\n <div className=\"modal__header\">\n <div id={titleId} className=\"modal__title\">{title}</div>\n <button type=\"button\" className=\"modal__close\" onClick={onClose} aria-label={t['modal.close']}><X size={18} /></button>\n </div>\n )}\n <div className=\"modal__body\">{children}</div>\n {footer && <div className=\"modal__footer\">{footer}</div>}\n </div>\n </div>,\n document.body\n );\n}\n\nexport interface DrawerProps extends OverlayProps {\n side?: 'left' | 'right';\n}\n\nexport function Drawer({\n open, onClose, title, children, footer, side = 'right',\n closeOnBackdrop = true, closeOnEsc = true, className,\n}: DrawerProps) {\n const ref = React.useRef<HTMLDivElement>(null);\n const titleId = React.useId();\n const t = useLocale();\n const { mounted, closing } = useDelayedUnmount(open, EXIT_MS);\n useEscape(open, onClose, closeOnEsc);\n useFocusTrap(ref, open);\n useScrollLock(open);\n if (!mounted || typeof document === 'undefined') return null;\n return createPortal(\n <div\n className={cx('drawer-backdrop', closing && 'is-closing')}\n onClick={() => closeOnBackdrop && onClose()}\n >\n <div\n ref={ref}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby={title ? titleId : undefined}\n className={cx('drawer', `drawer--${side}`, closing && 'is-closing', className)}\n onClick={(e) => e.stopPropagation()}\n >\n {title && (\n <div className=\"drawer__header\">\n <div id={titleId} className=\"drawer__title\">{title}</div>\n <button type=\"button\" className=\"drawer__close\" onClick={onClose} aria-label={t['drawer.close']}><X size={18} /></button>\n </div>\n )}\n <div className=\"drawer__body\">{children}</div>\n {footer && <div className=\"drawer__footer\">{footer}</div>}\n </div>\n </div>,\n document.body\n );\n}\n"]}
|
|
@@ -61,9 +61,63 @@ var ScrollArea = React__namespace.forwardRef(function ScrollArea2({ maxHeight, o
|
|
|
61
61
|
}
|
|
62
62
|
);
|
|
63
63
|
});
|
|
64
|
+
function composeRefs(...refs) {
|
|
65
|
+
return (node) => {
|
|
66
|
+
for (const ref of refs) {
|
|
67
|
+
if (typeof ref === "function") ref(node);
|
|
68
|
+
else if (ref != null) ref.current = node;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function readRef(el) {
|
|
73
|
+
const fromProps = el.props.ref;
|
|
74
|
+
const fromEl = el.ref;
|
|
75
|
+
return fromProps ?? fromEl;
|
|
76
|
+
}
|
|
77
|
+
function mergeProps(slotProps, childProps) {
|
|
78
|
+
const merged = { ...slotProps };
|
|
79
|
+
for (const key of Object.keys(childProps)) {
|
|
80
|
+
const slotValue = slotProps[key];
|
|
81
|
+
const childValue = childProps[key];
|
|
82
|
+
if (/^on[A-Z]/.test(key) && typeof slotValue === "function" && typeof childValue === "function") {
|
|
83
|
+
merged[key] = (...args) => {
|
|
84
|
+
childValue(...args);
|
|
85
|
+
slotValue(...args);
|
|
86
|
+
};
|
|
87
|
+
} else if (key === "className") {
|
|
88
|
+
merged[key] = chunkPASF6T4H_js.cx(slotProps.className, childProps.className);
|
|
89
|
+
} else if (key === "style") {
|
|
90
|
+
merged[key] = { ...slotProps.style, ...childProps.style };
|
|
91
|
+
} else {
|
|
92
|
+
merged[key] = childValue !== void 0 ? childValue : slotValue;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return merged;
|
|
96
|
+
}
|
|
97
|
+
function Slottable({ children }) {
|
|
98
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
|
99
|
+
}
|
|
100
|
+
var Slot = React__namespace.forwardRef(
|
|
101
|
+
function Slot2({ children, ...slotProps }, ref) {
|
|
102
|
+
const childArray = React__namespace.Children.toArray(children);
|
|
103
|
+
const slottable = childArray.find(
|
|
104
|
+
(c) => React__namespace.isValidElement(c) && c.type === Slottable
|
|
105
|
+
);
|
|
106
|
+
const target = slottable ? slottable.props.children : children;
|
|
107
|
+
if (!React__namespace.isValidElement(target)) return null;
|
|
108
|
+
const element = target;
|
|
109
|
+
const merged = mergeProps(slotProps, element.props);
|
|
110
|
+
const composed = ref ? composeRefs(ref, readRef(element)) : readRef(element);
|
|
111
|
+
merged.ref = composed;
|
|
112
|
+
const newChildren = slottable ? childArray.map((c) => c === slottable ? element.props.children : c) : element.props.children;
|
|
113
|
+
return React__namespace.cloneElement(element, merged, ...React__namespace.Children.toArray(newChildren));
|
|
114
|
+
}
|
|
115
|
+
);
|
|
64
116
|
|
|
65
117
|
exports.AspectRatio = AspectRatio;
|
|
66
118
|
exports.ScrollArea = ScrollArea;
|
|
67
119
|
exports.Separator = Separator;
|
|
68
|
-
|
|
69
|
-
|
|
120
|
+
exports.Slot = Slot;
|
|
121
|
+
exports.Slottable = Slottable;
|
|
122
|
+
//# sourceMappingURL=chunk-EUB4PHPI.js.map
|
|
123
|
+
//# sourceMappingURL=chunk-EUB4PHPI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/Primitives.tsx"],"names":["React","AspectRatio","jsx","cx","Separator","ScrollArea","Slot"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AASO,IAAM,WAAA,GAAoBA,gBAAA,CAAA,UAAA,CAA6C,SAASC,YAAAA,CACrF,EAAE,KAAA,GAAQ,EAAA,GAAK,CAAA,EAAG,KAAA,EAAO,SAAA,EAAW,QAAA,EAAU,GAAG,IAAA,IACjD,GAAA,EACA;AACA,EAAA,uBACEC,cAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,SAAA,EAAWC,mBAAA,CAAG,cAAA,EAAgB,SAAS,CAAA;AAAA,MACvC,KAAA,EAAO,EAAE,QAAA,EAAU,UAAA,EAAY,KAAA,EAAO,MAAA,EAAQ,WAAA,EAAa,MAAA,CAAO,KAAK,CAAA,EAAG,GAAG,KAAA,EAAM;AAAA,MAClF,GAAG,IAAA;AAAA,MAEH;AAAA;AAAA,GACH;AAEJ,CAAC;AAQM,IAAM,SAAA,GAAkBH,gBAAA,CAAA,UAAA,CAA2C,SAASI,UAAAA,CACjF,EAAE,WAAA,GAAc,YAAA,EAAc,UAAA,GAAa,IAAA,EAAM,SAAA,EAAW,GAAG,IAAA,IAC/D,GAAA,EACA;AACA,EAAA,MAAM,IAAA,GAAO,UAAA,GAAa,EAAE,IAAA,EAAM,MAAA,KAAW,EAAE,IAAA,EAAM,WAAA,EAAa,kBAAA,EAAoB,WAAA,EAAY;AAClG,E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EAAS,CAAA;AACrB;AAMO,IAAM,IAAA,GAAaH,gBAAA,CAAA,UAAA;AAAA,EACxB,SAASM,KAAAA,CAAK,EAAE,UAAU,GAAG,SAAA,IAAa,GAAA,EAAK;AAC7C,IAAA,MAAM,UAAA,GAAmBN,gBAAA,CAAA,QAAA,CAAS,OAAA,CAAQ,QAAQ,CAAA;AAClD,IAAA,MAAM,YAAY,UAAA,CAAW,IAAA;AAAA,MAC3B,CAAC,CAAA,KAAYA,gBAAA,CAAA,cAAA,CAAe,CAAC,CAAA,IAAK,EAAE,IAAA,KAAS;AAAA,KAC/C;AAEA,IAAA,MAAM,MAAA,GAAS,SAAA,GACV,SAAA,CAAU,KAAA,CAAyC,QAAA,GACpD,QAAA;AAEJ,IAAA,IAAI,CAAOA,gBAAA,CAAA,cAAA,CAAe,MAAM,CAAA,EAAG,OAAO,IAAA;AAC1C,IAAA,MAAM,OAAA,GAAU,MAAA;AAEhB,IAAA,MAAM,MAAA,GAAS,UAAA,CAAW,SAAA,EAAuB,OAAA,CAAQ,KAAiB,CAAA;AAC1E,IAAA,MAAM,QAAA,GAAW,MAAM,WAAA,CAAY,GAAA,EAAK,QAAQ,OAAO,CAAC,CAAA,GAAI,OAAA,CAAQ,OAAO,CAAA;AAC3E,IAAC,OAAwC,GAAA,GAAM,QAAA;AAI/C,IAAA,MAAM,WAAA,GAAc,SAAA,GAChB,UAAA,CAAW,GAAA,CAAI,CAAC,CAAA,KAAO,CAAA,KAAM,SAAA,GAAY,OAAA,CAAQ,KAAA,CAAM,QAAA,GAAW,CAAE,CAAA,GACpE,QAAQ,KAAA,CAAM,QAAA;AAElB,IAAA,OAAaA,8BAAa,OAAA,EAAS,MAAA,EAAQ,GAASA,gBAAA,CAAA,QAAA,CAAS,OAAA,CAAQ,WAAW,CAAC,CAAA;AAAA,EACnF;AACF","file":"chunk-EUB4PHPI.js","sourcesContent":["'use client';\nimport * as React from 'react';\nimport { cx } from '../utils/cx';\n\n// ---------- AspectRatio ------------------------------------------------\nexport interface AspectRatioProps extends React.HTMLAttributes<HTMLDivElement> {\n ratio?: number;\n}\n\nexport const AspectRatio = React.forwardRef<HTMLDivElement, AspectRatioProps>(function AspectRatio(\n { ratio = 16 / 9, style, className, children, ...rest },\n ref\n) {\n return (\n <div\n ref={ref}\n className={cx('aspect-ratio', className)}\n style={{ position: 'relative', width: '100%', aspectRatio: String(ratio), ...style }}\n {...rest}\n >\n {children}\n </div>\n );\n});\n\n// ---------- Separator --------------------------------------------------\nexport interface SeparatorProps extends React.HTMLAttributes<HTMLDivElement> {\n orientation?: 'horizontal' | 'vertical';\n decorative?: boolean;\n}\n\nexport const Separator = React.forwardRef<HTMLDivElement, SeparatorProps>(function Separator(\n { orientation = 'horizontal', decorative = true, className, ...rest },\n ref\n) {\n const a11y = decorative ? { role: 'none' } : { role: 'separator', 'aria-orientation': orientation };\n return (\n <div\n ref={ref}\n {...a11y}\n className={cx('separator', `separator--${orientation}`, className)}\n {...rest}\n />\n );\n});\n\n// ---------- ScrollArea -------------------------------------------------\nexport interface ScrollAreaProps extends React.HTMLAttributes<HTMLDivElement> {\n maxHeight?: number | string;\n orientation?: 'vertical' | 'horizontal' | 'both';\n}\n\nexport const ScrollArea = React.forwardRef<HTMLDivElement, ScrollAreaProps>(function ScrollArea(\n { maxHeight, orientation = 'vertical', className, style, children, ...rest },\n ref\n) {\n const overflow =\n orientation === 'horizontal'\n ? { overflowX: 'auto' as const, overflowY: 'hidden' as const }\n : orientation === 'both'\n ? { overflow: 'auto' as const }\n : { overflowY: 'auto' as const, overflowX: 'hidden' as const };\n return (\n <div\n ref={ref}\n className={cx('scroll-area', `scroll-area--${orientation}`, className)}\n style={{ ...overflow, maxHeight, ...style }}\n {...rest}\n >\n {children}\n </div>\n );\n});\n\n// ---------- Slot (polymorphism: the `asChild` pattern) -----------------\n// Dependency-free reimplementation of the well-known Slot/Slottable pattern.\n// Lets a component render *as* a consumer-provided element (e.g. next/link's\n// <a>) while still injecting its own className, handlers, ref and ARIA.\n\ntype AnyProps = Record<string, unknown>;\n\nfunction composeRefs<T>(...refs: Array<React.Ref<T> | undefined>): React.RefCallback<T> {\n return (node) => {\n for (const ref of refs) {\n if (typeof ref === 'function') ref(node);\n else if (ref != null) (ref as React.MutableRefObject<T | null>).current = node;\n }\n };\n}\n\nfunction readRef(el: React.ReactElement): React.Ref<unknown> | undefined {\n // React 18 exposes ref on the element; React 19 moves it into props.\n const fromProps = (el.props as { ref?: React.Ref<unknown> }).ref;\n const fromEl = (el as { ref?: React.Ref<unknown> }).ref;\n return fromProps ?? fromEl;\n}\n\nfunction mergeProps(slotProps: AnyProps, childProps: AnyProps): AnyProps {\n const merged: AnyProps = { ...slotProps };\n for (const key of Object.keys(childProps)) {\n const slotValue = slotProps[key];\n const childValue = childProps[key];\n if (/^on[A-Z]/.test(key) && typeof slotValue === 'function' && typeof childValue === 'function') {\n // Child's own handler runs first, then the component's.\n merged[key] = (...args: unknown[]) => {\n (childValue as (...a: unknown[]) => unknown)(...args);\n (slotValue as (...a: unknown[]) => unknown)(...args);\n };\n } else if (key === 'className') {\n merged[key] = cx(slotProps.className as string, childProps.className as string);\n } else if (key === 'style') {\n merged[key] = { ...(slotProps.style as object), ...(childProps.style as object) };\n } else {\n merged[key] = childValue !== undefined ? childValue : slotValue;\n }\n }\n return merged;\n}\n\n/**\n * Marks which child of an `asChild` component is the element to merge onto.\n * Siblings (icons, spinners) are preserved as the slotted element's children.\n */\nexport function Slottable({ children }: { children: React.ReactNode }): React.ReactElement {\n return <>{children}</>;\n}\n\nexport interface SlotProps {\n children?: React.ReactNode;\n}\n\nexport const Slot = React.forwardRef<HTMLElement, SlotProps & React.HTMLAttributes<HTMLElement>>(\n function Slot({ children, ...slotProps }, ref) {\n const childArray = React.Children.toArray(children);\n const slottable = childArray.find(\n (c) => React.isValidElement(c) && c.type === Slottable,\n ) as React.ReactElement | undefined;\n\n const target = slottable\n ? (slottable.props as { children?: React.ReactNode }).children\n : children;\n\n if (!React.isValidElement(target)) return null;\n const element = target as React.ReactElement<{ children?: React.ReactNode }>;\n\n const merged = mergeProps(slotProps as AnyProps, element.props as AnyProps);\n const composed = ref ? composeRefs(ref, readRef(element)) : readRef(element);\n (merged as { ref?: React.Ref<unknown> }).ref = composed;\n\n // With Slottable, the component's own siblings replace the marker and\n // become the slotted element's children (its original children last).\n const newChildren = slottable\n ? childArray.map((c) => (c === slottable ? element.props.children : c))\n : element.props.children;\n\n return React.cloneElement(element, merged, ...React.Children.toArray(newChildren));\n },\n);\n"]}
|
|
@@ -23,6 +23,9 @@ function _interopNamespace(e) {
|
|
|
23
23
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
24
24
|
|
|
25
25
|
// src/hooks/useDelayedUnmount.ts
|
|
26
|
+
function prefersReducedMotion() {
|
|
27
|
+
return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
28
|
+
}
|
|
26
29
|
function useDelayedUnmount(open, durationMs) {
|
|
27
30
|
const [mounted, setMounted] = React__namespace.useState(open);
|
|
28
31
|
const [closing, setClosing] = React__namespace.useState(false);
|
|
@@ -34,15 +37,16 @@ function useDelayedUnmount(open, durationMs) {
|
|
|
34
37
|
}
|
|
35
38
|
if (!mounted) return;
|
|
36
39
|
setClosing(true);
|
|
40
|
+
const delay = prefersReducedMotion() ? 0 : durationMs;
|
|
37
41
|
const handle = setTimeout(() => {
|
|
38
42
|
setMounted(false);
|
|
39
43
|
setClosing(false);
|
|
40
|
-
},
|
|
44
|
+
}, delay);
|
|
41
45
|
return () => clearTimeout(handle);
|
|
42
46
|
}, [open, durationMs, mounted]);
|
|
43
47
|
return { mounted, closing };
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
exports.useDelayedUnmount = useDelayedUnmount;
|
|
47
|
-
//# sourceMappingURL=chunk-
|
|
48
|
-
//# sourceMappingURL=chunk-
|
|
51
|
+
//# sourceMappingURL=chunk-FL4ZCWUF.js.map
|
|
52
|
+
//# sourceMappingURL=chunk-FL4ZCWUF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/useDelayedUnmount.ts"],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,SAAS,oBAAA,GAAgC;AACvC,EAAA,OACE,OAAO,MAAA,KAAW,WAAA,IAClB,OAAO,MAAA,CAAO,eAAe,UAAA,IAC7B,MAAA,CAAO,UAAA,CAAW,kCAAkC,CAAA,CAAE,OAAA;AAE1D;AAEO,SAAS,iBAAA,CAAkB,MAAe,UAAA,EAAoB;AACnE,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,CAAA,GAAUA,0BAAS,IAAI,CAAA;AACjD,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,CAAA,GAAUA,0BAAS,KAAK,CAAA;AAElD,EAAMA,2BAAU,MAAM;AACpB,IAAA,IAAI,IAAA,EAAM;AACR,MAAA,UAAA,CAAW,IAAI,CAAA;AACf,MAAA,UAAA,CAAW,KAAK,CAAA;AAChB,MAAA;AAAA,IACF;AACA,IAAA,IAAI,CAAC,OAAA,EAAS;AACd,IAAA,UAAA,CAAW,IAAI,CAAA;AAIf,IAAA,MAAM,KAAA,GAAQ,oBAAA,EAAqB,GAAI,CAAA,GAAI,UAAA;AAC3C,IAAA,MAAM,MAAA,GAAS,WAAW,MAAM;AAC9B,MAAA,UAAA,CAAW,KAAK,CAAA;AAChB,MAAA,UAAA,CAAW,KAAK,CAAA;AAAA,IAClB,GAAG,KAAK,CAAA;AACR,IAAA,OAAO,MAAM,aAAa,MAAM,CAAA;AAAA,EAClC,CAAA,EAAG,CAAC,IAAA,EAAM,UAAA,EAAY,OAAO,CAAC,CAAA;AAE9B,EAAA,OAAO,EAAE,SAAS,OAAA,EAAQ;AAC5B","file":"chunk-FL4ZCWUF.js","sourcesContent":["import * as React from 'react';\n\n/**\n * Delays unmounting of a component so an exit animation can play.\n *\n * When `open` flips to false, the hook keeps `mounted` true for `durationMs`\n * (giving CSS time to play `is-closing` keyframes) and then flips it to\n * false. The `closing` flag toggles during that window so the consumer can\n * apply a class like `is-closing` for the CSS animation.\n *\n * Usage:\n *\n * ```tsx\n * const { mounted, closing } = useDelayedUnmount(open, 200);\n * if (!mounted) return null;\n * return <div className={cx('modal', closing && 'is-closing')} />\n * ```\n */\nfunction prefersReducedMotion(): boolean {\n return (\n typeof window !== 'undefined' &&\n typeof window.matchMedia === 'function' &&\n window.matchMedia('(prefers-reduced-motion: reduce)').matches\n );\n}\n\nexport function useDelayedUnmount(open: boolean, durationMs: number) {\n const [mounted, setMounted] = React.useState(open);\n const [closing, setClosing] = React.useState(false);\n\n React.useEffect(() => {\n if (open) {\n setMounted(true);\n setClosing(false);\n return;\n }\n if (!mounted) return;\n setClosing(true);\n // The global prefers-reduced-motion guard makes the exit animation\n // instant; don't keep the element mounted for the (now invisible)\n // duration, it would just block/delay for those users.\n const delay = prefersReducedMotion() ? 0 : durationMs;\n const handle = setTimeout(() => {\n setMounted(false);\n setClosing(false);\n }, delay);\n return () => clearTimeout(handle);\n }, [open, durationMs, mounted]);\n\n return { mounted, closing };\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkS5BIOB34_js = require('./chunk-S5BIOB34.js');
|
|
4
4
|
var chunkHYUINOPJ_js = require('./chunk-HYUINOPJ.js');
|
|
5
5
|
var chunkTEQ67JKX_js = require('./chunk-TEQ67JKX.js');
|
|
6
6
|
var chunkRQOTH7I7_js = require('./chunk-RQOTH7I7.js');
|
|
@@ -54,7 +54,7 @@ function ConfirmDialog({
|
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
56
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
57
|
-
|
|
57
|
+
chunkS5BIOB34_js.Modal,
|
|
58
58
|
{
|
|
59
59
|
open,
|
|
60
60
|
onClose,
|
|
@@ -193,5 +193,5 @@ exports.DescriptionList = DescriptionList;
|
|
|
193
193
|
exports.DescriptionListItem = DescriptionListItem;
|
|
194
194
|
exports.DiffViewer = DiffViewer;
|
|
195
195
|
exports.TransferList = TransferList;
|
|
196
|
-
//# sourceMappingURL=chunk-
|
|
197
|
-
//# sourceMappingURL=chunk-
|
|
196
|
+
//# sourceMappingURL=chunk-IALAIASX.js.map
|
|
197
|
+
//# sourceMappingURL=chunk-IALAIASX.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Editing.tsx"],"names":["React","useLocale","jsx","Modal","jsxs","Fragment","cx","Checkbox","ChevronRight","ChevronLeft"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBO,SAAS,aAAA,CAAc;AAAA,EAC5B,IAAA;AAAA,EAAM,OAAA;AAAA,EAAS,SAAA;AAAA,EAAW,KAAA;AAAA,EAAO,WAAA;AAAA,EACjC,YAAA;AAAA,EAAc,WAAA;AAAA,EACd,IAAA,GAAO,SAAA;AAAA,EAAW;AACpB,CAAA,EAAuB;AACrB,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAUA,0BAAS,KAAK,CAAA;AAC5C,EAAA,MAAM,SAAS,OAAA,IAAW,IAAA;AAC1B,EAAA,MAAM,IAAIC,0BAAA,EAAU;AACpB,EAAA,MAAM,WAAA,GAAc,YAAA,IAAgB,CAAA,CAAE,gBAAgB,CAAA;AACtD,EAAA,MAAM,UAAA,GAAa,WAAA,IAAe,CAAA,CAAE,eAAe,CAAA;AAEnD,EAAA,MAAM,gBAAgB,YAAY;AAChC,IAAA,IAAI;AACF,MAAA,OAAA,CAAQ,IAAI,CAAA;AACZ,MAAA,MAAM,SAAA,EAAU;AAChB,MAAA,OAAA,EAAQ;AAAA,IACV,CAAA,SAAE;AACA,MAAA,OAAA,CAAQ,KAAK,CAAA;AAAA,IACf;AAAA,EACF,CAAA;AAEA,EAAA,uBACEC,cAAA;AAAA,IAACC,sBAAA;AAAA,IAAA;AAAA,MACC,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AAA,EAAU,oBAAA,EACb,QAAA,EAAA;AAAA,sBAAAF,cAAA,CAAC,YAAO,IAAA,EAAK,QAAA,EAAS,WAAU,0BAAA,EAA2B,QAAA,EAAU,YAAY,IAAA,KAAS,CAAA,EAAG,SAAS,SAAA,EAAW,YAAA,EAAY,EAAE,yBAAyB,CAAA,EACtJ,yCAACM,6BAAA,EAAA,EAAa,IAAA,EAAM,IAAI,CAAA,EAC1B,CAAA;AAAA,sBACAN,cAAA,CAAC,YAAO,IAAA,EAAK,QAAA,EAAS,WAAU,0BAAA,EAA2B,QAAA,EAAU,aAAa,IAAA,KAAS,CAAA,EAAG,SAAS,QAAA,EAAU,YAAA,EAAY,EAAE,yBAAyB,CAAA,EACtJ,yCAACO,4BAAA,EAAA,EAAY,IAAA,EAAM,IAAI,CAAA,EACzB;AAAA,KAAA,EACF,CAAA;AAAA,IACC,YAAA,CAAa,QAAA,EAAU,KAAA,EAAO,YAAA,EAAc,eAAe;AAAA,GAAA,EAC9D,CAAA;AAEJ","file":"chunk-LXNHGGAK.js","sourcesContent":["'use client';\nimport * as React from 'react';\nimport { cx } from '../utils/cx';\nimport { Modal } from './Overlay';\nimport { ChevronLeft, ChevronRight } from './Icons';\nimport { Checkbox } from './Form';\nimport { useLocale } from '../locale/LocaleProvider';\n\n// ---------- ConfirmDialog -----------------------------------------------\nexport interface ConfirmDialogProps {\n open: boolean;\n onClose: () => void;\n onConfirm: () => void | Promise<void>;\n title: React.ReactNode;\n description?: React.ReactNode;\n confirmLabel?: React.ReactNode;\n cancelLabel?: React.ReactNode;\n /** 'danger' usa botón rojo. */\n tone?: 'default' | 'danger';\n /** Si true, deshabilita el confirm mientras se ejecuta. */\n loading?: boolean;\n}\n\nexport function ConfirmDialog({\n open, onClose, onConfirm, title, description,\n confirmLabel, cancelLabel,\n tone = 'default', loading,\n}: ConfirmDialogProps) {\n const [busy, setBusy] = React.useState(false);\n const isBusy = loading ?? busy;\n const t = useLocale();\n const confirmText = confirmLabel ?? t['common.confirm'];\n const cancelText = cancelLabel ?? t['common.cancel'];\n\n const handleConfirm = async () => {\n try {\n setBusy(true);\n await onConfirm();\n onClose();\n } finally {\n setBusy(false);\n }\n };\n\n return (\n <Modal\n open={open}\n onClose={onClose}\n size=\"sm\"\n title={title}\n footer={\n <>\n <button type=\"button\" className=\"btn btn--ghost btn--md\" onClick={onClose} disabled={isBusy}>\n {cancelText}\n </button>\n <button\n type=\"button\"\n className={cx('btn', tone === 'danger' ? 'btn--danger' : 'btn--primary', 'btn--md')}\n onClick={handleConfirm}\n disabled={isBusy}\n aria-busy={isBusy || undefined}\n >\n {isBusy ? <span className=\"spinner spinner--inverse\" aria-hidden=\"true\" /> : null}\n {confirmText}\n </button>\n </>\n }\n >\n {description && <p className=\"confirm__desc\">{description}</p>}\n </Modal>\n );\n}\n\n// ---------- DescriptionList (KeyValue editable) ------------------------\nexport interface DescriptionListItemProps {\n label: React.ReactNode;\n value: React.ReactNode;\n /** Si se pasa, el valor se vuelve editable inline. */\n onEdit?: () => void;\n editable?: boolean;\n}\n\nexport function DescriptionList({ children, className, ...rest }: React.HTMLAttributes<HTMLDListElement>) {\n return <dl className={cx('desc-list', className)} {...rest}>{children}</dl>;\n}\n\nexport function DescriptionListItem({ label, value, onEdit, editable }: DescriptionListItemProps) {\n const t = useLocale();\n return (\n <>\n <dt className=\"desc-list__label\">{label}</dt>\n <dd className=\"desc-list__value\">\n <span>{value}</span>\n {editable && onEdit && (\n <button type=\"button\" className=\"desc-list__edit\" onClick={onEdit}>\n {t['descList.edit']}\n </button>\n )}\n </dd>\n </>\n );\n}\n\n// ---------- DiffViewer (before / after) --------------------------------\nexport interface DiffEntry {\n field: React.ReactNode;\n before: React.ReactNode;\n after: React.ReactNode;\n}\n\nexport interface DiffViewerProps extends React.HTMLAttributes<HTMLDivElement> {\n entries: DiffEntry[];\n}\n\nexport function DiffViewer({ entries, className, ...rest }: DiffViewerProps) {\n const t = useLocale();\n // data-label feeds the mobile stacked layout's ::before pseudo-elements\n // so the \"Antes\" / \"Después\" labels remain i18n-able.\n const beforeLabel = typeof t['diff.before'] === 'string' ? t['diff.before'] : undefined;\n const afterLabel = typeof t['diff.after'] === 'string' ? t['diff.after'] : undefined;\n return (\n <div className={cx('diff', className)} role=\"table\" aria-label={t['diff.label']} {...rest}>\n <div className=\"diff__head\" role=\"row\">\n <div role=\"columnheader\">{t['diff.field']}</div>\n <div role=\"columnheader\">{t['diff.before']}</div>\n <div role=\"columnheader\">{t['diff.after']}</div>\n </div>\n {entries.map((e, i) => (\n <div key={i} className=\"diff__row\" role=\"row\">\n <div className=\"diff__field\" role=\"cell\">{e.field}</div>\n <div className=\"diff__before\" role=\"cell\" data-label={beforeLabel}><del>{e.before}</del></div>\n <div className=\"diff__after\" role=\"cell\" data-label={afterLabel}><ins>{e.after}</ins></div>\n </div>\n ))}\n </div>\n );\n}\n\n// ---------- TransferList (dual list select) ----------------------------\nexport interface TransferItem {\n id: string;\n label: React.ReactNode;\n description?: React.ReactNode;\n disabled?: boolean;\n}\n\nexport interface TransferListProps {\n source: TransferItem[];\n selected: TransferItem[];\n onChange: (selected: TransferItem[]) => void;\n sourceTitle?: React.ReactNode;\n selectedTitle?: React.ReactNode;\n className?: string;\n}\n\nexport function TransferList({\n source, selected, onChange,\n sourceTitle, selectedTitle,\n className,\n}: TransferListProps) {\n const [leftChecked, setLeftChecked] = React.useState<Set<string>>(new Set());\n const [rightChecked, setRightChecked] = React.useState<Set<string>>(new Set());\n const t = useLocale();\n const srcTitle = sourceTitle ?? t['transfer.available'];\n const selTitle = selectedTitle ?? t['transfer.assigned'];\n\n // Without memo, every checkbox click rebuilt selectedIds and re-filtered\n // `source` to compute `left`. At ~500 source items that's a measurable\n // O(n) hit per click.\n const selectedIds = React.useMemo(\n () => new Set(selected.map((s) => s.id)),\n [selected]\n );\n const left = React.useMemo(\n () => source.filter((s) => !selectedIds.has(s.id)),\n [source, selectedIds]\n );\n const right = selected;\n\n const moveRight = () => {\n const toMove = left.filter((i) => leftChecked.has(i.id));\n onChange([...right, ...toMove]);\n setLeftChecked(new Set());\n };\n const moveLeft = () => {\n onChange(right.filter((i) => !rightChecked.has(i.id)));\n setRightChecked(new Set());\n };\n\n const toggleCheck = (set: Set<string>, setSet: (s: Set<string>) => void, id: string) => {\n const next = new Set(set);\n if (next.has(id)) next.delete(id); else next.add(id);\n setSet(next);\n };\n\n const renderColumn = (title: React.ReactNode, items: TransferItem[], checked: Set<string>, setChecked: (s: Set<string>) => void) => (\n <div className=\"transfer__col\">\n <div className=\"transfer__col-head\">\n <span className=\"transfer__col-title\">{title}</span>\n <span className=\"transfer__col-count\">{items.length}</span>\n </div>\n <ul className=\"transfer__list\" role=\"listbox\" aria-label={typeof title === 'string' ? title : undefined}>\n {items.length === 0 ? (\n <li className=\"transfer__empty\">{t['transfer.empty']}</li>\n ) : items.map((it) => (\n <li\n key={it.id}\n className={cx('transfer__item', checked.has(it.id) && 'is-checked', it.disabled && 'is-disabled')}\n role=\"option\"\n aria-selected={checked.has(it.id)}\n onClick={() => !it.disabled && toggleCheck(checked, setChecked, it.id)}\n >\n <span onClick={(e) => e.stopPropagation()}>\n <Checkbox\n checked={checked.has(it.id)}\n disabled={it.disabled}\n onChange={() => toggleCheck(checked, setChecked, it.id)}\n />\n </span>\n <div className=\"transfer__item-body\">\n <div>{it.label}</div>\n {it.description && <div className=\"transfer__item-desc\">{it.description}</div>}\n </div>\n </li>\n ))}\n </ul>\n </div>\n );\n\n return (\n <div className={cx('transfer', className)}>\n {renderColumn(srcTitle, left, leftChecked, setLeftChecked)}\n <div className=\"transfer__controls\">\n <button type=\"button\" className=\"btn btn--outline btn--sm\" disabled={leftChecked.size === 0} onClick={moveRight} aria-label={t['transfer.assignSelected']}>\n <ChevronRight size={16} />\n </button>\n <button type=\"button\" className=\"btn btn--outline btn--sm\" disabled={rightChecked.size === 0} onClick={moveLeft} aria-label={t['transfer.removeSelected']}>\n <ChevronLeft size={16} />\n </button>\n </div>\n {renderColumn(selTitle, right, rightChecked, setRightChecked)}\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/Editing.tsx"],"names":["React","useLocale","jsx","Modal","jsxs","Fragment","cx","Checkbox","ChevronRight","ChevronLeft"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBO,SAAS,aAAA,CAAc;AAAA,EAC5B,IAAA;AAAA,EAAM,OAAA;AAAA,EAAS,SAAA;AAAA,EAAW,KAAA;AAAA,EAAO,WAAA;AAAA,EACjC,YAAA;AAAA,EAAc,WAAA;AAAA,EACd,IAAA,GAAO,SAAA;AAAA,EAAW;AACpB,CAAA,EAAuB;AACrB,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAUA,0BAAS,KAAK,CAAA;AAC5C,EAAA,MAAM,SAAS,OAAA,IAAW,IAAA;AAC1B,EAAA,MAAM,IAAIC,0BAAA,EAAU;AACpB,EAAA,MAAM,WAAA,GAAc,YAAA,IAAgB,CAAA,CAAE,gBAAgB,CAAA;AACtD,EAAA,MAAM,UAAA,GAAa,WAAA,IAAe,CAAA,CAAE,eAAe,CAAA;AAEnD,EAAA,MAAM,gBAAgB,YAAY;AAChC,IAAA,IAAI;AACF,MAAA,OAAA,CAAQ,IAAI,CAAA;AACZ,MAAA,MAAM,SAAA,EAAU;AAChB,MAAA,OAAA,EAAQ;AAAA,IACV,CAAA,SAAE;AACA,MAAA,OAAA,CAAQ,KAAK,CAAA;AAAA,IACf;AAAA,EACF,CAAA;AAEA,EAAA,uBACEC,cAAA;AAAA,IAACC,sBAAA;AAAA,IAAA;AAAA,MACC,IAAA;AAAA,MACA,OAAA;AAAA,MACA,IAAA,EAAK,IAAA;AAAA,MACL,KAAA;AAAA,MACA,wBACEC,eAAA,CAAAC,mBAAA,EAAA,EACE,QAAA,EAAA;AAAA,wBAAAH,cAAA,CAAC,QAAA,EAAA,EAAO,MAAK,QAAA,EAAS,SAAA,EAAU,0BAAyB,OAAA,EAAS,OAAA,EAAS,QAAA,EAAU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M,IAAI,CAAA,EAC1B,CAAA;AAAA,sBACAN,cAAA,CAAC,YAAO,IAAA,EAAK,QAAA,EAAS,WAAU,0BAAA,EAA2B,QAAA,EAAU,aAAa,IAAA,KAAS,CAAA,EAAG,SAAS,QAAA,EAAU,YAAA,EAAY,EAAE,yBAAyB,CAAA,EACtJ,yCAACO,4BAAA,EAAA,EAAY,IAAA,EAAM,IAAI,CAAA,EACzB;AAAA,KAAA,EACF,CAAA;AAAA,IACC,YAAA,CAAa,QAAA,EAAU,KAAA,EAAO,YAAA,EAAc,eAAe;AAAA,GAAA,EAC9D,CAAA;AAEJ","file":"chunk-IALAIASX.js","sourcesContent":["'use client';\nimport * as React from 'react';\nimport { cx } from '../utils/cx';\nimport { Modal } from './Overlay';\nimport { ChevronLeft, ChevronRight } from './Icons';\nimport { Checkbox } from './Form';\nimport { useLocale } from '../locale/LocaleProvider';\n\n// ---------- ConfirmDialog -----------------------------------------------\nexport interface ConfirmDialogProps {\n open: boolean;\n onClose: () => void;\n onConfirm: () => void | Promise<void>;\n title: React.ReactNode;\n description?: React.ReactNode;\n confirmLabel?: React.ReactNode;\n cancelLabel?: React.ReactNode;\n /** 'danger' usa botón rojo. */\n tone?: 'default' | 'danger';\n /** Si true, deshabilita el confirm mientras se ejecuta. */\n loading?: boolean;\n}\n\nexport function ConfirmDialog({\n open, onClose, onConfirm, title, description,\n confirmLabel, cancelLabel,\n tone = 'default', loading,\n}: ConfirmDialogProps) {\n const [busy, setBusy] = React.useState(false);\n const isBusy = loading ?? busy;\n const t = useLocale();\n const confirmText = confirmLabel ?? t['common.confirm'];\n const cancelText = cancelLabel ?? t['common.cancel'];\n\n const handleConfirm = async () => {\n try {\n setBusy(true);\n await onConfirm();\n onClose();\n } finally {\n setBusy(false);\n }\n };\n\n return (\n <Modal\n open={open}\n onClose={onClose}\n size=\"sm\"\n title={title}\n footer={\n <>\n <button type=\"button\" className=\"btn btn--ghost btn--md\" onClick={onClose} disabled={isBusy}>\n {cancelText}\n </button>\n <button\n type=\"button\"\n className={cx('btn', tone === 'danger' ? 'btn--danger' : 'btn--primary', 'btn--md')}\n onClick={handleConfirm}\n disabled={isBusy}\n aria-busy={isBusy || undefined}\n >\n {isBusy ? <span className=\"spinner spinner--inverse\" aria-hidden=\"true\" /> : null}\n {confirmText}\n </button>\n </>\n }\n >\n {description && <p className=\"confirm__desc\">{description}</p>}\n </Modal>\n );\n}\n\n// ---------- DescriptionList (KeyValue editable) ------------------------\nexport interface DescriptionListItemProps {\n label: React.ReactNode;\n value: React.ReactNode;\n /** Si se pasa, el valor se vuelve editable inline. */\n onEdit?: () => void;\n editable?: boolean;\n}\n\nexport function DescriptionList({ children, className, ...rest }: React.HTMLAttributes<HTMLDListElement>) {\n return <dl className={cx('desc-list', className)} {...rest}>{children}</dl>;\n}\n\nexport function DescriptionListItem({ label, value, onEdit, editable }: DescriptionListItemProps) {\n const t = useLocale();\n return (\n <>\n <dt className=\"desc-list__label\">{label}</dt>\n <dd className=\"desc-list__value\">\n <span>{value}</span>\n {editable && onEdit && (\n <button type=\"button\" className=\"desc-list__edit\" onClick={onEdit}>\n {t['descList.edit']}\n </button>\n )}\n </dd>\n </>\n );\n}\n\n// ---------- DiffViewer (before / after) --------------------------------\nexport interface DiffEntry {\n field: React.ReactNode;\n before: React.ReactNode;\n after: React.ReactNode;\n}\n\nexport interface DiffViewerProps extends React.HTMLAttributes<HTMLDivElement> {\n entries: DiffEntry[];\n}\n\nexport function DiffViewer({ entries, className, ...rest }: DiffViewerProps) {\n const t = useLocale();\n // data-label feeds the mobile stacked layout's ::before pseudo-elements\n // so the \"Antes\" / \"Después\" labels remain i18n-able.\n const beforeLabel = typeof t['diff.before'] === 'string' ? t['diff.before'] : undefined;\n const afterLabel = typeof t['diff.after'] === 'string' ? t['diff.after'] : undefined;\n return (\n <div className={cx('diff', className)} role=\"table\" aria-label={t['diff.label']} {...rest}>\n <div className=\"diff__head\" role=\"row\">\n <div role=\"columnheader\">{t['diff.field']}</div>\n <div role=\"columnheader\">{t['diff.before']}</div>\n <div role=\"columnheader\">{t['diff.after']}</div>\n </div>\n {entries.map((e, i) => (\n <div key={i} className=\"diff__row\" role=\"row\">\n <div className=\"diff__field\" role=\"cell\">{e.field}</div>\n <div className=\"diff__before\" role=\"cell\" data-label={beforeLabel}><del>{e.before}</del></div>\n <div className=\"diff__after\" role=\"cell\" data-label={afterLabel}><ins>{e.after}</ins></div>\n </div>\n ))}\n </div>\n );\n}\n\n// ---------- TransferList (dual list select) ----------------------------\nexport interface TransferItem {\n id: string;\n label: React.ReactNode;\n description?: React.ReactNode;\n disabled?: boolean;\n}\n\nexport interface TransferListProps {\n source: TransferItem[];\n selected: TransferItem[];\n onChange: (selected: TransferItem[]) => void;\n sourceTitle?: React.ReactNode;\n selectedTitle?: React.ReactNode;\n className?: string;\n}\n\nexport function TransferList({\n source, selected, onChange,\n sourceTitle, selectedTitle,\n className,\n}: TransferListProps) {\n const [leftChecked, setLeftChecked] = React.useState<Set<string>>(new Set());\n const [rightChecked, setRightChecked] = React.useState<Set<string>>(new Set());\n const t = useLocale();\n const srcTitle = sourceTitle ?? t['transfer.available'];\n const selTitle = selectedTitle ?? t['transfer.assigned'];\n\n // Without memo, every checkbox click rebuilt selectedIds and re-filtered\n // `source` to compute `left`. At ~500 source items that's a measurable\n // O(n) hit per click.\n const selectedIds = React.useMemo(\n () => new Set(selected.map((s) => s.id)),\n [selected]\n );\n const left = React.useMemo(\n () => source.filter((s) => !selectedIds.has(s.id)),\n [source, selectedIds]\n );\n const right = selected;\n\n const moveRight = () => {\n const toMove = left.filter((i) => leftChecked.has(i.id));\n onChange([...right, ...toMove]);\n setLeftChecked(new Set());\n };\n const moveLeft = () => {\n onChange(right.filter((i) => !rightChecked.has(i.id)));\n setRightChecked(new Set());\n };\n\n const toggleCheck = (set: Set<string>, setSet: (s: Set<string>) => void, id: string) => {\n const next = new Set(set);\n if (next.has(id)) next.delete(id); else next.add(id);\n setSet(next);\n };\n\n const renderColumn = (title: React.ReactNode, items: TransferItem[], checked: Set<string>, setChecked: (s: Set<string>) => void) => (\n <div className=\"transfer__col\">\n <div className=\"transfer__col-head\">\n <span className=\"transfer__col-title\">{title}</span>\n <span className=\"transfer__col-count\">{items.length}</span>\n </div>\n <ul className=\"transfer__list\" role=\"listbox\" aria-label={typeof title === 'string' ? title : undefined}>\n {items.length === 0 ? (\n <li className=\"transfer__empty\">{t['transfer.empty']}</li>\n ) : items.map((it) => (\n <li\n key={it.id}\n className={cx('transfer__item', checked.has(it.id) && 'is-checked', it.disabled && 'is-disabled')}\n role=\"option\"\n aria-selected={checked.has(it.id)}\n onClick={() => !it.disabled && toggleCheck(checked, setChecked, it.id)}\n >\n <span onClick={(e) => e.stopPropagation()}>\n <Checkbox\n checked={checked.has(it.id)}\n disabled={it.disabled}\n onChange={() => toggleCheck(checked, setChecked, it.id)}\n />\n </span>\n <div className=\"transfer__item-body\">\n <div>{it.label}</div>\n {it.description && <div className=\"transfer__item-desc\">{it.description}</div>}\n </div>\n </li>\n ))}\n </ul>\n </div>\n );\n\n return (\n <div className={cx('transfer', className)}>\n {renderColumn(srcTitle, left, leftChecked, setLeftChecked)}\n <div className=\"transfer__controls\">\n <button type=\"button\" className=\"btn btn--outline btn--sm\" disabled={leftChecked.size === 0} onClick={moveRight} aria-label={t['transfer.assignSelected']}>\n <ChevronRight size={16} />\n </button>\n <button type=\"button\" className=\"btn btn--outline btn--sm\" disabled={rightChecked.size === 0} onClick={moveLeft} aria-label={t['transfer.removeSelected']}>\n <ChevronLeft size={16} />\n </button>\n </div>\n {renderColumn(selTitle, right, rightChecked, setRightChecked)}\n </div>\n );\n}\n"]}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { cx } from './chunk-IEPCH3JB.mjs';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
var AspectRatio = React.forwardRef(function AspectRatio2({ ratio = 16 / 9, style, className, children, ...rest }, ref) {
|
|
6
|
+
return /* @__PURE__ */ jsx(
|
|
7
|
+
"div",
|
|
8
|
+
{
|
|
9
|
+
ref,
|
|
10
|
+
className: cx("aspect-ratio", className),
|
|
11
|
+
style: { position: "relative", width: "100%", aspectRatio: String(ratio), ...style },
|
|
12
|
+
...rest,
|
|
13
|
+
children
|
|
14
|
+
}
|
|
15
|
+
);
|
|
16
|
+
});
|
|
17
|
+
var Separator = React.forwardRef(function Separator2({ orientation = "horizontal", decorative = true, className, ...rest }, ref) {
|
|
18
|
+
const a11y = decorative ? { role: "none" } : { role: "separator", "aria-orientation": orientation };
|
|
19
|
+
return /* @__PURE__ */ jsx(
|
|
20
|
+
"div",
|
|
21
|
+
{
|
|
22
|
+
ref,
|
|
23
|
+
...a11y,
|
|
24
|
+
className: cx("separator", `separator--${orientation}`, className),
|
|
25
|
+
...rest
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
});
|
|
29
|
+
var ScrollArea = React.forwardRef(function ScrollArea2({ maxHeight, orientation = "vertical", className, style, children, ...rest }, ref) {
|
|
30
|
+
const overflow = orientation === "horizontal" ? { overflowX: "auto", overflowY: "hidden" } : orientation === "both" ? { overflow: "auto" } : { overflowY: "auto", overflowX: "hidden" };
|
|
31
|
+
return /* @__PURE__ */ jsx(
|
|
32
|
+
"div",
|
|
33
|
+
{
|
|
34
|
+
ref,
|
|
35
|
+
className: cx("scroll-area", `scroll-area--${orientation}`, className),
|
|
36
|
+
style: { ...overflow, maxHeight, ...style },
|
|
37
|
+
...rest,
|
|
38
|
+
children
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
});
|
|
42
|
+
function composeRefs(...refs) {
|
|
43
|
+
return (node) => {
|
|
44
|
+
for (const ref of refs) {
|
|
45
|
+
if (typeof ref === "function") ref(node);
|
|
46
|
+
else if (ref != null) ref.current = node;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function readRef(el) {
|
|
51
|
+
const fromProps = el.props.ref;
|
|
52
|
+
const fromEl = el.ref;
|
|
53
|
+
return fromProps ?? fromEl;
|
|
54
|
+
}
|
|
55
|
+
function mergeProps(slotProps, childProps) {
|
|
56
|
+
const merged = { ...slotProps };
|
|
57
|
+
for (const key of Object.keys(childProps)) {
|
|
58
|
+
const slotValue = slotProps[key];
|
|
59
|
+
const childValue = childProps[key];
|
|
60
|
+
if (/^on[A-Z]/.test(key) && typeof slotValue === "function" && typeof childValue === "function") {
|
|
61
|
+
merged[key] = (...args) => {
|
|
62
|
+
childValue(...args);
|
|
63
|
+
slotValue(...args);
|
|
64
|
+
};
|
|
65
|
+
} else if (key === "className") {
|
|
66
|
+
merged[key] = cx(slotProps.className, childProps.className);
|
|
67
|
+
} else if (key === "style") {
|
|
68
|
+
merged[key] = { ...slotProps.style, ...childProps.style };
|
|
69
|
+
} else {
|
|
70
|
+
merged[key] = childValue !== void 0 ? childValue : slotValue;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return merged;
|
|
74
|
+
}
|
|
75
|
+
function Slottable({ children }) {
|
|
76
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
77
|
+
}
|
|
78
|
+
var Slot = React.forwardRef(
|
|
79
|
+
function Slot2({ children, ...slotProps }, ref) {
|
|
80
|
+
const childArray = React.Children.toArray(children);
|
|
81
|
+
const slottable = childArray.find(
|
|
82
|
+
(c) => React.isValidElement(c) && c.type === Slottable
|
|
83
|
+
);
|
|
84
|
+
const target = slottable ? slottable.props.children : children;
|
|
85
|
+
if (!React.isValidElement(target)) return null;
|
|
86
|
+
const element = target;
|
|
87
|
+
const merged = mergeProps(slotProps, element.props);
|
|
88
|
+
const composed = ref ? composeRefs(ref, readRef(element)) : readRef(element);
|
|
89
|
+
merged.ref = composed;
|
|
90
|
+
const newChildren = slottable ? childArray.map((c) => c === slottable ? element.props.children : c) : element.props.children;
|
|
91
|
+
return React.cloneElement(element, merged, ...React.Children.toArray(newChildren));
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
export { AspectRatio, ScrollArea, Separator, Slot, Slottable };
|
|
96
|
+
//# sourceMappingURL=chunk-IEPKSPBX.mjs.map
|
|
97
|
+
//# sourceMappingURL=chunk-IEPKSPBX.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/Primitives.tsx"],"names":["AspectRatio","Separator","ScrollArea","Slot"],"mappings":";;;;AASO,IAAM,WAAA,GAAoB,KAAA,CAAA,UAAA,CAA6C,SAASA,YAAAA,CACrF,EAAE,KAAA,GAAQ,EAAA,GAAK,CAAA,EAAG,KAAA,EAAO,SAAA,EAAW,QAAA,EAAU,GAAG,IAAA,IACjD,GAAA,EACA;AACA,EAAA,uBACE,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,SAAA,EAAW,EAAA,CAAG,cAAA,EAAgB,SAAS,CAAA;AAAA,MACvC,KAAA,EAAO,EAAE,QAAA,EAAU,UAAA,EAAY,KAAA,EAAO,MAAA,EAAQ,WAAA,EAAa,MAAA,CAAO,KAAK,CAAA,EAAG,GAAG,KAAA,EAAM;AAAA,MAClF,GAAG,IAAA;AAAA,MAEH;AAAA;AAAA,GACH;AAEJ,CAAC;AAQM,IAAM,SAAA,GAAkB,KAAA,CAAA,UAAA,CAA2C,SAASC,UAAAA,CACjF,EAAE,WAAA,GAAc,YAAA,EAAc,UAAA,GAAa,IAAA,EAAM,SAAA,EAAW,GAAG,IAAA,IAC/D,GAAA,EACA;AACA,EAAA,MAAM,IAAA,GAAO,UAAA,GAAa,EAAE,IAAA,EAAM,MAAA,KAAW,EAAE,IAAA,EAAM,WAAA,EAAa,kBAAA,EAAoB,WAAA,EAAY;AAClG,EAAA,uBACE,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACC,GAAG,IAAA;AAAA,MACJ,WAAW,EAAA,CAAG,WAAA,EAAa,CAAA,WAAA,EAAc,WAAW,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,KAAA,CAAA,QAAA,CAAS,OAAA,CAAQ,QAAQ,CAAA;AAClD,IAAA,MAAM,YAAY,UAAA,CAAW,IAAA;AAAA,MAC3B,CAAC,CAAA,KAAY,KAAA,CAAA,cAAA,CAAe,CAAC,CAAA,IAAK,EAAE,IAAA,KAAS;AAAA,KAC/C;AAEA,IAAA,MAAM,MAAA,GAAS,SAAA,GACV,SAAA,CAAU,KAAA,CAAyC,QAAA,GACpD,QAAA;AAEJ,IAAA,IAAI,CAAO,KAAA,CAAA,cAAA,CAAe,MAAM,CAAA,EAAG,OAAO,IAAA;AAC1C,IAAA,MAAM,OAAA,GAAU,MAAA;AAEhB,IAAA,MAAM,MAAA,GAAS,UAAA,CAAW,SAAA,EAAuB,OAAA,CAAQ,KAAiB,CAAA;AAC1E,IAAA,MAAM,QAAA,GAAW,MAAM,WAAA,CAAY,GAAA,EAAK,QAAQ,OAAO,CAAC,CAAA,GAAI,OAAA,CAAQ,OAAO,CAAA;AAC3E,IAAC,OAAwC,GAAA,GAAM,QAAA;AAI/C,IAAA,MAAM,WAAA,GAAc,SAAA,GAChB,UAAA,CAAW,GAAA,CAAI,CAAC,CAAA,KAAO,CAAA,KAAM,SAAA,GAAY,OAAA,CAAQ,KAAA,CAAM,QAAA,GAAW,CAAE,CAAA,GACpE,QAAQ,KAAA,CAAM,QAAA;AAElB,IAAA,OAAa,mBAAa,OAAA,EAAS,MAAA,EAAQ,GAAS,KAAA,CAAA,QAAA,CAAS,OAAA,CAAQ,WAAW,CAAC,CAAA;AAAA,EACnF;AACF","file":"chunk-IEPKSPBX.mjs","sourcesContent":["'use client';\nimport * as React from 'react';\nimport { cx } from '../utils/cx';\n\n// ---------- AspectRatio ------------------------------------------------\nexport interface AspectRatioProps extends React.HTMLAttributes<HTMLDivElement> {\n ratio?: number;\n}\n\nexport const AspectRatio = React.forwardRef<HTMLDivElement, AspectRatioProps>(function AspectRatio(\n { ratio = 16 / 9, style, className, children, ...rest },\n ref\n) {\n return (\n <div\n ref={ref}\n className={cx('aspect-ratio', className)}\n style={{ position: 'relative', width: '100%', aspectRatio: String(ratio), ...style }}\n {...rest}\n >\n {children}\n </div>\n );\n});\n\n// ---------- Separator --------------------------------------------------\nexport interface SeparatorProps extends React.HTMLAttributes<HTMLDivElement> {\n orientation?: 'horizontal' | 'vertical';\n decorative?: boolean;\n}\n\nexport const Separator = React.forwardRef<HTMLDivElement, SeparatorProps>(function Separator(\n { orientation = 'horizontal', decorative = true, className, ...rest },\n ref\n) {\n const a11y = decorative ? { role: 'none' } : { role: 'separator', 'aria-orientation': orientation };\n return (\n <div\n ref={ref}\n {...a11y}\n className={cx('separator', `separator--${orientation}`, className)}\n {...rest}\n />\n );\n});\n\n// ---------- ScrollArea -------------------------------------------------\nexport interface ScrollAreaProps extends React.HTMLAttributes<HTMLDivElement> {\n maxHeight?: number | string;\n orientation?: 'vertical' | 'horizontal' | 'both';\n}\n\nexport const ScrollArea = React.forwardRef<HTMLDivElement, ScrollAreaProps>(function ScrollArea(\n { maxHeight, orientation = 'vertical', className, style, children, ...rest },\n ref\n) {\n const overflow =\n orientation === 'horizontal'\n ? { overflowX: 'auto' as const, overflowY: 'hidden' as const }\n : orientation === 'both'\n ? { overflow: 'auto' as const }\n : { overflowY: 'auto' as const, overflowX: 'hidden' as const };\n return (\n <div\n ref={ref}\n className={cx('scroll-area', `scroll-area--${orientation}`, className)}\n style={{ ...overflow, maxHeight, ...style }}\n {...rest}\n >\n {children}\n </div>\n );\n});\n\n// ---------- Slot (polymorphism: the `asChild` pattern) -----------------\n// Dependency-free reimplementation of the well-known Slot/Slottable pattern.\n// Lets a component render *as* a consumer-provided element (e.g. next/link's\n// <a>) while still injecting its own className, handlers, ref and ARIA.\n\ntype AnyProps = Record<string, unknown>;\n\nfunction composeRefs<T>(...refs: Array<React.Ref<T> | undefined>): React.RefCallback<T> {\n return (node) => {\n for (const ref of refs) {\n if (typeof ref === 'function') ref(node);\n else if (ref != null) (ref as React.MutableRefObject<T | null>).current = node;\n }\n };\n}\n\nfunction readRef(el: React.ReactElement): React.Ref<unknown> | undefined {\n // React 18 exposes ref on the element; React 19 moves it into props.\n const fromProps = (el.props as { ref?: React.Ref<unknown> }).ref;\n const fromEl = (el as { ref?: React.Ref<unknown> }).ref;\n return fromProps ?? fromEl;\n}\n\nfunction mergeProps(slotProps: AnyProps, childProps: AnyProps): AnyProps {\n const merged: AnyProps = { ...slotProps };\n for (const key of Object.keys(childProps)) {\n const slotValue = slotProps[key];\n const childValue = childProps[key];\n if (/^on[A-Z]/.test(key) && typeof slotValue === 'function' && typeof childValue === 'function') {\n // Child's own handler runs first, then the component's.\n merged[key] = (...args: unknown[]) => {\n (childValue as (...a: unknown[]) => unknown)(...args);\n (slotValue as (...a: unknown[]) => unknown)(...args);\n };\n } else if (key === 'className') {\n merged[key] = cx(slotProps.className as string, childProps.className as string);\n } else if (key === 'style') {\n merged[key] = { ...(slotProps.style as object), ...(childProps.style as object) };\n } else {\n merged[key] = childValue !== undefined ? childValue : slotValue;\n }\n }\n return merged;\n}\n\n/**\n * Marks which child of an `asChild` component is the element to merge onto.\n * Siblings (icons, spinners) are preserved as the slotted element's children.\n */\nexport function Slottable({ children }: { children: React.ReactNode }): React.ReactElement {\n return <>{children}</>;\n}\n\nexport interface SlotProps {\n children?: React.ReactNode;\n}\n\nexport const Slot = React.forwardRef<HTMLElement, SlotProps & React.HTMLAttributes<HTMLElement>>(\n function Slot({ children, ...slotProps }, ref) {\n const childArray = React.Children.toArray(children);\n const slottable = childArray.find(\n (c) => React.isValidElement(c) && c.type === Slottable,\n ) as React.ReactElement | undefined;\n\n const target = slottable\n ? (slottable.props as { children?: React.ReactNode }).children\n : children;\n\n if (!React.isValidElement(target)) return null;\n const element = target as React.ReactElement<{ children?: React.ReactNode }>;\n\n const merged = mergeProps(slotProps as AnyProps, element.props as AnyProps);\n const composed = ref ? composeRefs(ref, readRef(element)) : readRef(element);\n (merged as { ref?: React.Ref<unknown> }).ref = composed;\n\n // With Slottable, the component's own siblings replace the marker and\n // become the slotted element's children (its original children last).\n const newChildren = slottable\n ? childArray.map((c) => (c === slottable ? element.props.children : c))\n : element.props.children;\n\n return React.cloneElement(element, merged, ...React.Children.toArray(newChildren));\n },\n);\n"]}
|