@sincpro/web-ui 2.13.0 → 2.14.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 +15 -5
- package/dist/components/gallery/Gallery.d.ts +29 -0
- package/dist/components/gallery/Gallery.js +78 -0
- package/dist/components/gallery/Lightbox.d.ts +28 -0
- package/dist/components/gallery/Lightbox.js +59 -0
- package/dist/components/gallery/index.d.ts +2 -0
- package/dist/components/gallery/index.js +3 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +2 -0
- package/dist/components/listing/ColumnsMenu.js +4 -2
- package/dist/components/listing/columns.d.ts +3 -0
- package/dist/components/listing/columns.js +4 -0
- package/dist/components/plans/PlanCard.d.ts +43 -0
- package/dist/components/plans/PlanCard.js +35 -0
- package/dist/components/plans/index.d.ts +1 -0
- package/dist/components/plans/index.js +2 -0
- package/dist/components/search/CriteriaChips.d.ts +14 -1
- package/dist/components/search/CriteriaChips.js +118 -10
- package/dist/components/search/JoinWord.js +8 -14
- package/dist/components/search/SearchBar.d.ts +10 -1
- package/dist/components/search/SearchBar.js +715 -176
- package/dist/components/search/WordChoice.d.ts +19 -0
- package/dist/components/search/WordChoice.js +8 -0
- package/dist/components/search/criteria.d.ts +27 -0
- package/dist/components/search/criteria.js +33 -0
- package/dist/components/search/index.d.ts +2 -2
- package/dist/components/search/index.js +2 -2
- package/dist/components/search/query.d.ts +24 -0
- package/dist/components/search/query.js +29 -0
- package/dist/components/shell/AppFrame.d.ts +4 -0
- package/dist/components/shell/AppFrame.js +4 -1
- package/dist/components/shell/Inbox.d.ts +53 -0
- package/dist/components/shell/Inbox.js +55 -0
- package/dist/components/shell/SearchEntry.js +2 -3
- package/dist/components/shell/TopBar.d.ts +4 -2
- package/dist/components/shell/TopBar.js +3 -3
- package/dist/components/shell/index.d.ts +1 -0
- package/dist/components/shell/index.js +3 -0
- package/dist/foundations/copy.es.js +60 -1
- package/dist/foundations/form.d.ts +7 -0
- package/dist/foundations/form.js +1 -0
- package/dist/foundations/uiCopy.d.ts +85 -2
- package/dist/foundations/uiCopy.js +60 -1
- package/dist/primitives/choice/RadioGroup.d.ts +1 -1
- package/dist/primitives/choice/RadioGroup.js +29 -0
- package/dist/primitives/choice/Rating.d.ts +32 -0
- package/dist/primitives/choice/Rating.js +75 -0
- package/dist/primitives/choice/Slider.d.ts +19 -0
- package/dist/primitives/choice/Slider.js +27 -2
- package/dist/primitives/choice/index.d.ts +2 -1
- package/dist/primitives/choice/index.js +4 -1
- package/dist/primitives/choice/options.d.ts +4 -0
- package/dist/primitives/field/Field.js +1 -0
- package/dist/primitives/hint/Kbd.d.ts +23 -0
- package/dist/primitives/hint/Kbd.js +23 -0
- package/dist/primitives/hint/index.d.ts +1 -0
- package/dist/primitives/hint/index.js +2 -0
- package/dist/primitives/menu/ContextMenu.d.ts +29 -0
- package/dist/primitives/menu/ContextMenu.js +74 -0
- package/dist/primitives/menu/Menu.d.ts +4 -1
- package/dist/primitives/menu/Menu.js +2 -2
- package/dist/primitives/menu/index.d.ts +1 -0
- package/dist/primitives/menu/index.js +2 -0
- package/dist/primitives/notice/Banner.d.ts +27 -0
- package/dist/primitives/notice/Banner.js +21 -0
- package/dist/primitives/notice/Callout.d.ts +4 -4
- package/dist/primitives/notice/Callout.js +8 -19
- package/dist/primitives/notice/Notice.d.ts +38 -10
- package/dist/primitives/notice/Notice.js +48 -9
- package/dist/primitives/notice/index.d.ts +3 -1
- package/dist/primitives/notice/index.js +3 -0
- package/dist/primitives/notice/tones.d.ts +8 -0
- package/dist/primitives/notice/tones.js +22 -0
- package/dist/primitives/value/Price.d.ts +31 -0
- package/dist/primitives/value/Price.js +32 -0
- package/dist/primitives/value/QrCode.d.ts +32 -0
- package/dist/primitives/value/QrCode.js +53 -0
- package/dist/primitives/value/index.d.ts +3 -0
- package/dist/primitives/value/index.js +6 -0
- package/dist/primitives/value/priceFormat.d.ts +12 -0
- package/dist/primitives/value/priceFormat.js +22 -0
- package/dist/tokens.css +39 -0
- package/dist/views/list/ListView.js +22 -3
- package/dist/views/list/types.d.ts +8 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -297,19 +297,24 @@ of classes that change with the next refactor:
|
|
|
297
297
|
}
|
|
298
298
|
```
|
|
299
299
|
|
|
300
|
-
The parts: `button`, `icon-button`, `control`, `popover`, `menu`, `menu.trigger`,
|
|
300
|
+
The parts: `button`, `icon-button`, `control`, `popover`, `menu`, `menu.trigger`, `context-menu`,
|
|
301
301
|
`menu.section`, `menu.item`, `menu.fold`, `dialog`, `block`, `record-card` (with `data-layout`
|
|
302
302
|
`card` | `compact` | `tile`), `record-card.title`, `record-card.figure`, `record-card.fields`,
|
|
303
303
|
`record-card.media`, `record-card.badge`, `record-card.footer`, `record-card.stripe`,
|
|
304
304
|
`board.lane`, `list.tiles`, `elapsed`, `keypad`, `keypad.key`, `keypad.screen`, `stepper`,
|
|
305
|
-
`radio-group
|
|
305
|
+
`radio-group` (with `data-look` `list` | `cards` | `swatches`), `radio-group.card`,
|
|
306
|
+
`radio-group.swatch`, `radio-group.chosen`, `tags.count`, `skeleton` (with `data-shape` `rows` | `table` | `tiles` | `board`), `empty` (with `data-size="page"` when it has a title or a picture), `empty.visual`,
|
|
307
|
+
`empty.title`, `outcome`, `outcome.figure`, `receipt`,
|
|
306
308
|
`receipt.document`, `receipt.lines`, `receipt.totals`, `kiosk`, `kiosk.attract`,
|
|
307
309
|
`kiosk.content`, `kiosk.reach`, `board.tile`,
|
|
308
310
|
`board.stat`, `board.stat.value`, `activity.changes`, `file-list`, `file-list.file`, `file-value`, `metric`, `metric.detail`, `tag`, `tags.item`, `search`, `search.field`, `search.chip`,
|
|
309
|
-
`search.panel`, `search.suggestions`, `search.suggestion`, `search.record`, `search.
|
|
310
|
-
`search.keys`, `search-entry`, `search-entry.keys`, `table`, `table.pile`, `yes-no`,
|
|
311
|
+
`search.panel`, `search.suggestions`, `search.suggestion`, `search.record`, `search.recent`,
|
|
312
|
+
`search.advanced`, `search.keys`, `search.completion`, `search.undo`, `search.slash`, `search-entry`, `search-entry.keys`, `table`, `table.pile`, `yes-no`,
|
|
311
313
|
`table.head`, `row.ways`, `topbar`, `topbar.brand`, `topbar.menus`, `topbar.actions`, `topbar.user`,
|
|
312
|
-
`frame`, `frame.bar`, `frame.sidebar`, `frame.main`, `
|
|
314
|
+
`frame`, `frame.banner`, `frame.bar`, `frame.sidebar`, `frame.main`, `banner`, `banner.action`,
|
|
315
|
+
`inbox`, `inbox.item` (with `data-unread`), `kbd`, `plans`, `plan` (with `data-highlight`, `data-current`), `plan.highlight`, `plan.price`,
|
|
316
|
+
`plan.features`, `plan.action`, `qr`, `price`, `price.before`, `range-slider`, `rating`, `gallery`,
|
|
317
|
+
`gallery.main`, `gallery.strip`, `lightbox`, `sidebar`, `sidebar.brand`,
|
|
313
318
|
`sidebar.user`, `sidebar.search`, `sidebar.nav`, `sidebar.account`, `navigation`,
|
|
314
319
|
`navigation.item`, `dirty.blocked`, `dirty.bar`, `field`, `field.label`, `form.section`,
|
|
315
320
|
`form.index`, `dock`, `dock.pill`, `dock.bare`, `pager`, `pagination`, `smart`, `guide`, `guide.veil`, `guide.spot`, `guide.card`,
|
|
@@ -335,6 +340,11 @@ attract screen, `idleAfter`, a reduced-height mode). The Storybook page «Tácti
|
|
|
335
340
|
orders them by what they solve; `5 · Plantillas/Mostrador` has the till, the express till, the
|
|
336
341
|
kitchen, the kiosk and the shop.
|
|
337
342
|
|
|
343
|
+
For a shop's product page and a customer portal: `Price` (the price before struck, the discount
|
|
344
|
+
computed), `Rating` (an average with its figure, or the opinion asked), `Gallery` (with a
|
|
345
|
+
full-size `Lightbox`), `Inbox` (the bell in `TopBar systray`, or `InboxList` as a page), and
|
|
346
|
+
`Banner` — a notice about the whole application, in `AppFrame banner`.
|
|
347
|
+
|
|
338
348
|
#### A form that explains itself: the «settings» style
|
|
339
349
|
|
|
340
350
|
The default form is the dense sheet of an ERP — label | control, two columns, help behind a
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type GalleryImage } from "./Lightbox.js";
|
|
2
|
+
declare const ASPECT: {
|
|
3
|
+
readonly square: "aspect-square";
|
|
4
|
+
readonly tile: "aspect-(--aspect-tile)";
|
|
5
|
+
readonly wide: "aspect-video";
|
|
6
|
+
};
|
|
7
|
+
export type GalleryProps = {
|
|
8
|
+
images: readonly GalleryImage[];
|
|
9
|
+
/** The shape of the main image. The photos are never cropped inside it: `contain`. */
|
|
10
|
+
aspect?: keyof typeof ASPECT;
|
|
11
|
+
/** Which image is shown, when the application holds it (a variant chosen shows its photo). */
|
|
12
|
+
index?: number;
|
|
13
|
+
onIndexChange?: (next: number) => void;
|
|
14
|
+
/** Pressing the image opens it at full size (`Lightbox`). On by default. */
|
|
15
|
+
zoom?: boolean;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The images of ONE thing — a product, a property, an asset, a damage reported: a big one, the
|
|
19
|
+
* strip of the rest under it, and full size on a press.
|
|
20
|
+
*
|
|
21
|
+
* Context: a product's page lives on its photos, and a carousel that turns by itself is a
|
|
22
|
+
* photo nobody chose to see. Here the person moves it: the arrows at the sides, the strip, the
|
|
23
|
+
* keyboard's arrows, a finger swiping. Where they are is written («2 de 5»), never only a dot.
|
|
24
|
+
* The image is never cropped (`object-contain` on the ground tone): a cropped product is a
|
|
25
|
+
* different product. Controlled or not: a shop that changes the photo when a colour is chosen
|
|
26
|
+
* passes `index`.
|
|
27
|
+
*/
|
|
28
|
+
export declare function Gallery({ images, aspect, index: indexProp, onIndexChange, zoom, }: GalleryProps): import("react").JSX.Element;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { Lightbox, wrapIndex, } from "./Lightbox.js";
|
|
4
|
+
import { fillCopy, useUiCopy } from "../../foundations/copy.js";
|
|
5
|
+
import { IconButton } from "../../primitives/button/Button.js";
|
|
6
|
+
import { ChevronLeft, ChevronRight, ImageOff } from "lucide-react";
|
|
7
|
+
import { useRef, useState } from "react";
|
|
8
|
+
const ASPECT = {
|
|
9
|
+
square: "aspect-square",
|
|
10
|
+
/* The tile's 4:3 — the same box `RecordCard layout="tile"` draws a product in. */
|
|
11
|
+
tile: "aspect-(--aspect-tile)",
|
|
12
|
+
wide: "aspect-video",
|
|
13
|
+
};
|
|
14
|
+
/* A finger that moves this far sideways meant «next», not «open». */
|
|
15
|
+
const SWIPE = 40;
|
|
16
|
+
/**
|
|
17
|
+
* The images of ONE thing — a product, a property, an asset, a damage reported: a big one, the
|
|
18
|
+
* strip of the rest under it, and full size on a press.
|
|
19
|
+
*
|
|
20
|
+
* Context: a product's page lives on its photos, and a carousel that turns by itself is a
|
|
21
|
+
* photo nobody chose to see. Here the person moves it: the arrows at the sides, the strip, the
|
|
22
|
+
* keyboard's arrows, a finger swiping. Where they are is written («2 de 5»), never only a dot.
|
|
23
|
+
* The image is never cropped (`object-contain` on the ground tone): a cropped product is a
|
|
24
|
+
* different product. Controlled or not: a shop that changes the photo when a colour is chosen
|
|
25
|
+
* passes `index`.
|
|
26
|
+
*/
|
|
27
|
+
export function Gallery({ images, aspect = "square", index: indexProp, onIndexChange, zoom = true, }) {
|
|
28
|
+
const copy = useUiCopy();
|
|
29
|
+
const [own, setOwn] = useState(0);
|
|
30
|
+
const [open, setOpen] = useState(false);
|
|
31
|
+
const swipe = useRef(null);
|
|
32
|
+
const total = images.length;
|
|
33
|
+
const index = wrapIndex(indexProp ?? own, total);
|
|
34
|
+
const image = images[index];
|
|
35
|
+
const show = (next) => {
|
|
36
|
+
const at = wrapIndex(next, total);
|
|
37
|
+
if (indexProp === undefined)
|
|
38
|
+
setOwn(at);
|
|
39
|
+
onIndexChange?.(at);
|
|
40
|
+
};
|
|
41
|
+
const position = (at) => fillCopy(copy.gallery.position, { index: at + 1, total });
|
|
42
|
+
const keys = (event) => {
|
|
43
|
+
if (total < 2)
|
|
44
|
+
return;
|
|
45
|
+
if (event.key === "ArrowRight")
|
|
46
|
+
show(index + 1);
|
|
47
|
+
else if (event.key === "ArrowLeft")
|
|
48
|
+
show(index - 1);
|
|
49
|
+
else
|
|
50
|
+
return;
|
|
51
|
+
event.preventDefault();
|
|
52
|
+
};
|
|
53
|
+
const down = (event) => {
|
|
54
|
+
swipe.current = { x: event.clientX, moved: false };
|
|
55
|
+
};
|
|
56
|
+
const up = (event) => {
|
|
57
|
+
const start = swipe.current;
|
|
58
|
+
if (start === null || total < 2)
|
|
59
|
+
return;
|
|
60
|
+
const dx = event.clientX - start.x;
|
|
61
|
+
if (Math.abs(dx) < SWIPE)
|
|
62
|
+
return;
|
|
63
|
+
start.moved = true;
|
|
64
|
+
show(index + (dx < 0 ? 1 : -1));
|
|
65
|
+
};
|
|
66
|
+
if (image === undefined) {
|
|
67
|
+
return (_jsxs("div", { "data-ui": "gallery", className: `flex w-full flex-col items-center justify-center gap-2 rounded-ui-card bg-ground text-muted ${ASPECT[aspect]}`, children: [_jsx(ImageOff, { className: "size-8", strokeWidth: 1.5, "aria-hidden": true }), _jsx("p", { className: "text-meta", children: copy.gallery.empty })] }));
|
|
68
|
+
}
|
|
69
|
+
const picture = (_jsx("img", { src: image.src, alt: image.alt, draggable: false, className: "size-full object-contain select-none" }));
|
|
70
|
+
return (_jsxs("div", { role: "group", "aria-label": copy.gallery.label, "aria-roledescription": copy.gallery.roledescription, "data-ui": "gallery", className: "flex min-w-0 flex-col gap-2", onKeyDown: keys, children: [_jsxs("div", { "data-ui": "gallery.main", className: `relative w-full overflow-clip rounded-ui-card bg-ground touch-pan-y ${ASPECT[aspect]}`, onPointerDown: down, onPointerUp: up, children: [zoom ? (_jsx("button", { type: "button", "aria-label": `${copy.gallery.open}: ${image.alt}`, className: "size-full cursor-zoom-in outline-0 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary", onClick: () => {
|
|
71
|
+
/* The press that ended a swipe is not an «open». */
|
|
72
|
+
if (swipe.current?.moved === true)
|
|
73
|
+
return;
|
|
74
|
+
setOpen(true);
|
|
75
|
+
}, children: picture })) : (picture), total < 2 ? null : (_jsxs(_Fragment, { children: [_jsx("span", { className: "absolute top-1/2 left-2 -translate-y-1/2 rounded-pill bg-surface/85 shadow-raised", children: _jsx(IconButton, { icon: ChevronLeft, label: copy.gallery.previous, size: "md", surface: "canvas", onClick: () => show(index - 1) }) }), _jsx("span", { className: "absolute top-1/2 right-2 -translate-y-1/2 rounded-pill bg-surface/85 shadow-raised", children: _jsx(IconButton, { icon: ChevronRight, label: copy.gallery.next, size: "md", surface: "canvas", onClick: () => show(index + 1) }) }), _jsxs("span", { "aria-live": "polite", className: "absolute right-2 bottom-2 rounded-pill bg-surface/85 px-2 py-0.5 text-micro font-medium text-ink tabular-nums shadow-raised", children: [index + 1, " / ", total, _jsx("span", { className: "sr-only", children: `, ${position(index)}` })] })] }))] }), total < 2 ? null : (_jsx("div", { "data-ui": "gallery.strip", className: "flex gap-2 overflow-x-auto pb-1", children: images.map((one, at) => (_jsx("button", { type: "button", "aria-label": `${position(at)}: ${one.alt}`, "aria-current": at === index ? "true" : undefined, onClick: () => show(at), className: `size-14 shrink-0 overflow-clip rounded-control border-2 bg-ground transition-colors duration-(--duration-instant) focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary ${at === index
|
|
76
|
+
? "border-primary"
|
|
77
|
+
: "border-transparent hover:border-line-strong"}`, children: _jsx("img", { src: one.thumb ?? one.src, alt: "", className: "size-full object-cover" }) }, `${one.src}-${at}`))) })), zoom ? (_jsx(Lightbox, { images: images, index: index, onIndexChange: show, open: open, onClose: () => setOpen(false) })) : null] }));
|
|
78
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type GalleryImage = {
|
|
2
|
+
src: string;
|
|
3
|
+
/** What the image shows, said: «Silla Nórdica, vista de frente». Not optional — an image
|
|
4
|
+
* without words is a hole for a screen reader. */
|
|
5
|
+
alt: string;
|
|
6
|
+
/** A smaller file for the strip of thumbnails; the `src` when absent. */
|
|
7
|
+
thumb?: string;
|
|
8
|
+
};
|
|
9
|
+
export type LightboxProps = {
|
|
10
|
+
images: readonly GalleryImage[];
|
|
11
|
+
/** Which one is shown. */
|
|
12
|
+
index: number;
|
|
13
|
+
onIndexChange: (next: number) => void;
|
|
14
|
+
open: boolean;
|
|
15
|
+
onClose: () => void;
|
|
16
|
+
};
|
|
17
|
+
/** The step that wraps: past the last comes the first, the way a shop's photos go round. */
|
|
18
|
+
export declare function wrapIndex(index: number, total: number): number;
|
|
19
|
+
/**
|
|
20
|
+
* The image at full size, over everything: a product's photo, a damage reported with the
|
|
21
|
+
* phone, a scanned receipt.
|
|
22
|
+
*
|
|
23
|
+
* Context: a modal of React Aria — focus goes in, Escape and the ✕ close it, focus comes back
|
|
24
|
+
* to the image that opened it — on a near-black veil, with the controls on the chrome palette
|
|
25
|
+
* so they read on it. The arrows of the keyboard and the buttons at the sides step through the
|
|
26
|
+
* images; the position is written («2 de 5») so «where am I» never depends on counting dots.
|
|
27
|
+
*/
|
|
28
|
+
export declare function Lightbox({ images, index, onIndexChange, open, onClose }: LightboxProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { fillCopy, useUiCopy } from "../../foundations/copy.js";
|
|
4
|
+
import { SurfaceProvider } from "../../foundations/surface.js";
|
|
5
|
+
import { tv } from "../../foundations/variants.js";
|
|
6
|
+
import { IconButton } from "../../primitives/button/Button.js";
|
|
7
|
+
import { ChevronLeft, ChevronRight, X } from "lucide-react";
|
|
8
|
+
import { useEffect } from "react";
|
|
9
|
+
import { Dialog, Modal, ModalOverlay } from "react-aria-components";
|
|
10
|
+
/* Almost the scrim itself, not a dialog's 40 % veil: the page under it is not what the window
|
|
11
|
+
is about — the image is. At 90 % the page still showed around a light photo and competed with
|
|
12
|
+
it (seen in the gallery's story). Never 100 %: a veil is a share of the scrim (tokens.test). */
|
|
13
|
+
const overlay = tv({
|
|
14
|
+
base: "fixed inset-0 z-50 bg-scrim/95 transition-opacity duration-(--duration-quick) ease-(--ease-out)",
|
|
15
|
+
variants: {
|
|
16
|
+
isEntering: { true: "opacity-0" },
|
|
17
|
+
isExiting: { true: "opacity-0" },
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
/** The step that wraps: past the last comes the first, the way a shop's photos go round. */
|
|
21
|
+
export function wrapIndex(index, total) {
|
|
22
|
+
return total === 0 ? 0 : ((index % total) + total) % total;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The image at full size, over everything: a product's photo, a damage reported with the
|
|
26
|
+
* phone, a scanned receipt.
|
|
27
|
+
*
|
|
28
|
+
* Context: a modal of React Aria — focus goes in, Escape and the ✕ close it, focus comes back
|
|
29
|
+
* to the image that opened it — on a near-black veil, with the controls on the chrome palette
|
|
30
|
+
* so they read on it. The arrows of the keyboard and the buttons at the sides step through the
|
|
31
|
+
* images; the position is written («2 de 5») so «where am I» never depends on counting dots.
|
|
32
|
+
*/
|
|
33
|
+
export function Lightbox({ images, index, onIndexChange, open, onClose }) {
|
|
34
|
+
const copy = useUiCopy();
|
|
35
|
+
const total = images.length;
|
|
36
|
+
const image = images[wrapIndex(index, total)];
|
|
37
|
+
const go = (step) => onIndexChange(wrapIndex(index + step, total));
|
|
38
|
+
/* On the window and not on the dialog: the focus starts ON the dialog, and a key pressed
|
|
39
|
+
there never reaches a handler inside it. */
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
if (!open || total < 2)
|
|
42
|
+
return;
|
|
43
|
+
const keys = (event) => {
|
|
44
|
+
if (event.key !== "ArrowRight" && event.key !== "ArrowLeft")
|
|
45
|
+
return;
|
|
46
|
+
event.preventDefault();
|
|
47
|
+
onIndexChange(wrapIndex(index + (event.key === "ArrowRight" ? 1 : -1), total));
|
|
48
|
+
};
|
|
49
|
+
window.addEventListener("keydown", keys);
|
|
50
|
+
return () => window.removeEventListener("keydown", keys);
|
|
51
|
+
}, [open, total, index, onIndexChange]);
|
|
52
|
+
return (_jsx(ModalOverlay, { isOpen: open && image !== undefined, onOpenChange: (next) => {
|
|
53
|
+
if (!next)
|
|
54
|
+
onClose();
|
|
55
|
+
}, isDismissable: true, className: overlay, children: _jsx(Modal, { className: "fixed inset-0 outline-0", children: _jsx(Dialog, { "aria-label": image?.alt ?? copy.gallery.label, className: "flex size-full flex-col outline-0", "data-ui": "lightbox", children: _jsxs(SurfaceProvider, { value: "chrome", children: [_jsxs("div", { className: "flex shrink-0 items-center justify-between gap-3 px-4 py-3", children: [_jsx("p", { className: "min-w-0 truncate text-meta text-chrome-ink", "aria-live": "polite", children: fillCopy(copy.gallery.position, {
|
|
56
|
+
index: wrapIndex(index, total) + 1,
|
|
57
|
+
total,
|
|
58
|
+
}) }), _jsx(IconButton, { icon: X, label: copy.gallery.close, size: "md", onClick: onClose })] }), _jsxs("div", { className: "relative flex min-h-0 flex-1 items-center justify-center px-4 pb-6 sm:px-16", children: [image === undefined ? null : (_jsx("img", { src: image.src, alt: image.alt, className: "max-h-full max-w-full rounded-control object-contain select-none", draggable: false })), total < 2 ? null : (_jsxs(_Fragment, { children: [_jsx("span", { className: "absolute top-1/2 left-2 -translate-y-1/2 rounded-pill bg-chrome-ink/12", children: _jsx(IconButton, { icon: ChevronLeft, label: copy.gallery.previous, size: "lg", onClick: () => go(-1) }) }), _jsx("span", { className: "absolute top-1/2 right-2 -translate-y-1/2 rounded-pill bg-chrome-ink/12", children: _jsx(IconButton, { icon: ChevronRight, label: copy.gallery.next, size: "lg", onClick: () => go(1) }) })] }))] })] }) }) }) }));
|
|
59
|
+
}
|
|
@@ -8,11 +8,13 @@ export * from "./chat/index.js";
|
|
|
8
8
|
export * from "./flow/index.js";
|
|
9
9
|
export * from "./form/index.js";
|
|
10
10
|
export * from "./frame/index.js";
|
|
11
|
+
export * from "./gallery/index.js";
|
|
11
12
|
export * from "./gantt/index.js";
|
|
12
13
|
export * from "./guide/index.js";
|
|
13
14
|
export * from "./lines/index.js";
|
|
14
15
|
export * from "./listing/index.js";
|
|
15
16
|
export * from "./navigation/index.js";
|
|
17
|
+
export * from "./plans/index.js";
|
|
16
18
|
export * from "./preview/index.js";
|
|
17
19
|
export * from "./receipt/index.js";
|
|
18
20
|
export * from "./record/index.js";
|
package/dist/components/index.js
CHANGED
|
@@ -9,11 +9,13 @@ export * from "./chat/index.js";
|
|
|
9
9
|
export * from "./flow/index.js";
|
|
10
10
|
export * from "./form/index.js";
|
|
11
11
|
export * from "./frame/index.js";
|
|
12
|
+
export * from "./gallery/index.js";
|
|
12
13
|
export * from "./gantt/index.js";
|
|
13
14
|
export * from "./guide/index.js";
|
|
14
15
|
export * from "./lines/index.js";
|
|
15
16
|
export * from "./listing/index.js";
|
|
16
17
|
export * from "./navigation/index.js";
|
|
18
|
+
export * from "./plans/index.js";
|
|
17
19
|
export * from "./preview/index.js";
|
|
18
20
|
export * from "./receipt/index.js";
|
|
19
21
|
export * from "./record/index.js";
|
|
@@ -44,8 +44,10 @@ export function ColumnsMenu({ control, surface, addPath, }) {
|
|
|
44
44
|
{ label: copy.frame.required, options: requiredOptions },
|
|
45
45
|
{ label: copy.frame.optional, options: optionalOptions },
|
|
46
46
|
];
|
|
47
|
-
const
|
|
48
|
-
|
|
47
|
+
const menu = (_jsx(Menu, { label: copy.frame.columns, icon: Columns3, groups: groups, onSelect: control.toggle, closeOnSelect: false,
|
|
48
|
+
/* Marked when the person changed the columns — not when the view's own defaults hide an
|
|
49
|
+
optional one: at rest every such list read as «something is set here». */
|
|
50
|
+
active: control.changed, ...(surface === undefined ? {} : { surface }), size: "sm" }));
|
|
49
51
|
return picker === null ? (menu) : (_jsxs("span", { className: "flex items-center gap-1.5", children: [menu, picker] }));
|
|
50
52
|
}
|
|
51
53
|
/* `specsFromColumns` is plain (`columnSpecs.ts`), without the directive; re-exported so every
|
|
@@ -20,6 +20,9 @@ export type ColumnControl = {
|
|
|
20
20
|
optional: readonly ColumnSpec[];
|
|
21
21
|
required: readonly ColumnSpec[];
|
|
22
22
|
hasOptional: boolean;
|
|
23
|
+
/** The visible set is not the view's default: the person added or took a column away. What
|
|
24
|
+
* the columns menu marks itself for — a column the view hides by default is not a choice. */
|
|
25
|
+
changed: boolean;
|
|
23
26
|
};
|
|
24
27
|
export type { ColumnSpec };
|
|
25
28
|
export { defaultVisibleIds, isRequiredColumn, reconcileVisible, toggleColumn, visibleColumns, };
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
import { defaultVisibleIds, isRequiredColumn, reconcileVisible, toggleColumn, visibleColumns, } from "./columnSpecs.js";
|
|
3
3
|
import { useCallback, useState } from "react";
|
|
4
4
|
export { defaultVisibleIds, isRequiredColumn, reconcileVisible, toggleColumn, visibleColumns, };
|
|
5
|
+
function sameSet(a, b) {
|
|
6
|
+
return a.length === b.length && a.every((id) => b.includes(id));
|
|
7
|
+
}
|
|
5
8
|
export function useColumnControl(columns, options = {}) {
|
|
6
9
|
const signature = columns.map((column) => column.id).join("\0");
|
|
7
10
|
const [owned, setOwned] = useState(() => defaultVisibleIds(columns));
|
|
@@ -31,5 +34,6 @@ export function useColumnControl(columns, options = {}) {
|
|
|
31
34
|
optional,
|
|
32
35
|
required,
|
|
33
36
|
hasOptional: optional.length > 0,
|
|
37
|
+
changed: !sameSet(visibleIds, defaultVisibleIds(columns)),
|
|
34
38
|
};
|
|
35
39
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type PriceProps } from "../../primitives/value/Price.js";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
export type PlanFeature = {
|
|
4
|
+
label: string;
|
|
5
|
+
/** `false` draws it as NOT included — kept in the list so plans compare line by line. */
|
|
6
|
+
included?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type PlanCardProps = {
|
|
9
|
+
name: string;
|
|
10
|
+
/** Who it is for, in one line: «Para una empresa con un local». */
|
|
11
|
+
description?: string;
|
|
12
|
+
/** The price as `Price` takes it — usually with `per` («mes») and, on a yearly offer, the
|
|
13
|
+
* monthly price before as `compareAt`. Absent for «a convenir». */
|
|
14
|
+
price?: Omit<PriceProps, "size">;
|
|
15
|
+
/** What is written where the price would be when there is none: «A convenir». */
|
|
16
|
+
priceLabel?: string;
|
|
17
|
+
features?: readonly PlanFeature[];
|
|
18
|
+
/** The button that takes it — the recommended plan's is the screen's one primary; the rest
|
|
19
|
+
* are secondary. The application decides. */
|
|
20
|
+
action?: ReactNode;
|
|
21
|
+
/** A word over the card that sets it apart: «Recomendado», «Más elegido». */
|
|
22
|
+
highlight?: string;
|
|
23
|
+
/** The plan the person is on: a tag says so, and its action usually goes away. */
|
|
24
|
+
current?: boolean;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* One plan of an offer: a subscription in a portal, a membership in a shop, the licences of an
|
|
28
|
+
* ERP — the name, who it is for, the price, what it includes, and the button that takes it.
|
|
29
|
+
*
|
|
30
|
+
* Context: plans are COMPARED, so every card has the same anatomy in the same order and a
|
|
31
|
+
* feature a plan lacks stays in its list, marked «no incluye» — a list that just gets shorter
|
|
32
|
+
* makes the reader do the diff. Included and not are an icon AND a word for a screen reader,
|
|
33
|
+
* never a colour alone. The highlighted plan is framed in the selection's navy, not the gold:
|
|
34
|
+
* the gold is its button, the one primary of the screen. Placed in `Plans`, the cards share
|
|
35
|
+
* their height, so the buttons line up at the bottom.
|
|
36
|
+
*/
|
|
37
|
+
export declare function PlanCard({ name, description, price, priceLabel, features, action, highlight, current, }: PlanCardProps): import("react").JSX.Element;
|
|
38
|
+
/** The plans of an offer side by side, as many as the row takes, each as tall as the tallest
|
|
39
|
+
* — stacked on a phone. Its name says what is being chosen: «Planes de Quipu». */
|
|
40
|
+
export declare function Plans({ label, children }: {
|
|
41
|
+
label: string;
|
|
42
|
+
children: ReactNode;
|
|
43
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useUiCopy } from "../../foundations/copy.js";
|
|
4
|
+
import { Tag } from "../../primitives/tag/Tag.js";
|
|
5
|
+
import { Price } from "../../primitives/value/Price.js";
|
|
6
|
+
import { Check, Minus } from "lucide-react";
|
|
7
|
+
/**
|
|
8
|
+
* One plan of an offer: a subscription in a portal, a membership in a shop, the licences of an
|
|
9
|
+
* ERP — the name, who it is for, the price, what it includes, and the button that takes it.
|
|
10
|
+
*
|
|
11
|
+
* Context: plans are COMPARED, so every card has the same anatomy in the same order and a
|
|
12
|
+
* feature a plan lacks stays in its list, marked «no incluye» — a list that just gets shorter
|
|
13
|
+
* makes the reader do the diff. Included and not are an icon AND a word for a screen reader,
|
|
14
|
+
* never a colour alone. The highlighted plan is framed in the selection's navy, not the gold:
|
|
15
|
+
* the gold is its button, the one primary of the screen. Placed in `Plans`, the cards share
|
|
16
|
+
* their height, so the buttons line up at the bottom.
|
|
17
|
+
*/
|
|
18
|
+
export function PlanCard({ name, description, price, priceLabel, features, action, highlight, current = false, }) {
|
|
19
|
+
const copy = useUiCopy();
|
|
20
|
+
return (_jsxs("article", { "data-ui": "plan", ...(highlight === undefined ? {} : { "data-highlight": "" }), ...(current ? { "data-current": "" } : {}), "aria-label": name, className: `relative flex min-w-0 flex-col gap-4 rounded-ui-card border bg-ui-card p-5 ${highlight === undefined
|
|
21
|
+
? "border-ui-card-border"
|
|
22
|
+
: "border-primary ring-1 ring-primary"}`, children: [highlight === undefined ? null : (_jsx("span", { "data-ui": "plan.highlight", className: "absolute -top-3 left-5 rounded-pill bg-primary px-2.5 py-0.5 text-micro font-semibold text-surface", children: highlight })), _jsxs("header", { className: "flex min-w-0 flex-col gap-1", children: [_jsxs("div", { className: "flex min-w-0 flex-wrap items-center gap-2", children: [_jsx("h3", { className: "text-title font-semibold text-ink", children: name }), current ? _jsx(Tag, { tone: "info", children: copy.plans.current }) : null] }), description === undefined ? null : (_jsx("p", { className: "text-meta text-muted", children: description }))] }), _jsx("div", { "data-ui": "plan.price", className: "min-h-16", children: price === undefined ? (_jsx("p", { className: "text-display font-semibold text-ink", children: priceLabel ?? copy.plans.onRequest })) : (_jsx(Price, { ...price, size: "lg" })) }), features === undefined || features.length === 0 ? null : (_jsx("ul", { "data-ui": "plan.features", className: "flex flex-col gap-2", children: features.map((feature) => {
|
|
23
|
+
const included = feature.included !== false;
|
|
24
|
+
const Icon = included ? Check : Minus;
|
|
25
|
+
return (_jsxs("li", { className: `flex min-w-0 items-start gap-2 text-meta ${included ? "text-ink" : "text-muted"}`, children: [_jsx(Icon, { "aria-hidden": true, strokeWidth: 2.25, className: `mt-0.5 size-(--size-icon-md) shrink-0 ${included ? "text-good" : "text-muted"}` }), _jsxs("span", { className: "min-w-0", children: [_jsxs("span", { className: "sr-only", children: [included ? copy.plans.included : copy.plans.excluded, ":", " "] }), feature.label] })] }, feature.label));
|
|
26
|
+
}) })), action === undefined ? null : (
|
|
27
|
+
/* At the bottom whatever the list's length: in `Plans` every card is as tall as the
|
|
28
|
+
tallest, so the buttons line up. */
|
|
29
|
+
_jsx("div", { "data-ui": "plan.action", className: "mt-auto flex flex-col pt-2 *:w-full", children: action }))] }));
|
|
30
|
+
}
|
|
31
|
+
/** The plans of an offer side by side, as many as the row takes, each as tall as the tallest
|
|
32
|
+
* — stacked on a phone. Its name says what is being chosen: «Planes de Quipu». */
|
|
33
|
+
export function Plans({ label, children }) {
|
|
34
|
+
return (_jsx("section", { "aria-label": label, "data-ui": "plans", className: "grid min-w-0 grid-cols-(--grid-plans) items-stretch gap-x-4 gap-y-6 pt-3", children: children }));
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PlanCard, type PlanCardProps, type PlanFeature, Plans, } from "./PlanCard.js";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type CriteriaJoin, type CriteriaPath, type SearchCriteria } from "./criteria.js";
|
|
2
|
+
import { type QueryField } from "./query.js";
|
|
2
3
|
import type { Surface } from "../../foundations/types.js";
|
|
3
4
|
export type CriteriaChipsProps = {
|
|
4
5
|
/** What the bar has set. Groups and filters mixed: here they are separated. */
|
|
@@ -22,6 +23,18 @@ export type CriteriaChipsProps = {
|
|
|
22
23
|
/** How many facets show before the rest fold into «+N» (the grouping chain counts as one).
|
|
23
24
|
* Below `@md` of the bar only the first one shows. `Infinity` never folds. */
|
|
24
25
|
collapseAfter?: number;
|
|
26
|
+
/** The fields the bar asks about. With them a chip the bar wrote reads in its parts — field,
|
|
27
|
+
* comparison, value — and each part is touched on its own (see `chipParts`). */
|
|
28
|
+
fields?: readonly QueryField[];
|
|
29
|
+
/** One instance changed in place: a chip's comparison or value, edited on the chip. */
|
|
30
|
+
onReplace?: (path: CriteriaPath, next: SearchCriteria) => void;
|
|
31
|
+
/** The piece marked from the keyboard, by its place in `facetPaths`: ringed, never folded. */
|
|
32
|
+
marked?: number;
|
|
33
|
+
/** The piece whose value is being edited in place — Enter on a marked chip. */
|
|
34
|
+
editing?: number;
|
|
35
|
+
/** The edit in place ended — set or given up. `giveBack`: it ended from the keyboard (Enter,
|
|
36
|
+
* Escape) and the focus goes back to whoever owns it; a blur went somewhere on purpose. */
|
|
37
|
+
onEdited?: (giveBack: boolean) => void;
|
|
25
38
|
surface?: Surface;
|
|
26
39
|
};
|
|
27
|
-
export declare function CriteriaChips({ criteria, onOpen, onJoin, onRemove, onRemoveMany, open, collapseAfter, surface, }: CriteriaChipsProps): import("react").JSX.Element;
|
|
40
|
+
export declare function CriteriaChips({ criteria, onOpen, onJoin, onRemove, onRemoveMany, open, collapseAfter, fields, onReplace, marked, editing, onEdited, surface, }: CriteriaChipsProps): import("react").JSX.Element;
|