@sdxc/ui 2026.11.18 → 2026.11.22
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 +133 -1
- package/dist/app/index.d.ts +1 -0
- package/dist/app/index.js +1 -0
- package/dist/app/mixins/command-palette.js +10 -2
- package/dist/app/mixins/log-viewer.js +17 -14
- package/dist/app/mixins/route-dialog.d.ts +17 -0
- package/dist/app/mixins/route-dialog.js +53 -0
- package/dist/app/optimistic-toggle.js +6 -0
- package/dist/app/route-dialog.d.ts +38 -0
- package/dist/app/route-dialog.js +49 -0
- package/dist/audio/equalizer.d.ts +24 -0
- package/dist/audio/equalizer.js +57 -0
- package/dist/audio/index.d.ts +16 -0
- package/dist/audio/index.js +16 -0
- package/dist/audio/media-tile.d.ts +38 -0
- package/dist/audio/media-tile.js +98 -0
- package/dist/audio/player-bar.d.ts +108 -0
- package/dist/audio/player-bar.js +338 -0
- package/dist/audio/queue-list.d.ts +56 -0
- package/dist/audio/queue-list.js +102 -0
- package/dist/audio/track-list.d.ts +91 -0
- package/dist/audio/track-list.js +226 -0
- package/dist/audio/utils/media-session.d.ts +44 -0
- package/dist/audio/utils/media-session.js +87 -0
- package/dist/audio/utils/play-queue.d.ts +98 -0
- package/dist/audio/utils/play-queue.js +149 -0
- package/dist/audio/utils/track-time.d.ts +28 -0
- package/dist/audio/utils/track-time.js +36 -0
- package/dist/chat/composer-format.d.ts +35 -0
- package/dist/chat/composer-format.js +84 -0
- package/dist/chat/index.d.ts +6 -0
- package/dist/chat/index.js +6 -0
- package/dist/chat/mention-menu.d.ts +43 -0
- package/dist/chat/mention-menu.js +70 -0
- package/dist/chat/message-group.d.ts +92 -0
- package/dist/chat/message-group.js +222 -0
- package/dist/chat/mixins/composer-format.d.ts +28 -0
- package/dist/chat/mixins/composer-format.js +80 -0
- package/dist/chat/mixins/composer-send.d.ts +2 -2
- package/dist/chat/mixins/composer-send.js +4 -2
- package/dist/chat/mixins/mention-menu.d.ts +41 -0
- package/dist/chat/mixins/mention-menu.js +213 -0
- package/dist/chat/mixins/reaction-sync.d.ts +47 -0
- package/dist/chat/mixins/reaction-sync.js +172 -0
- package/dist/chat/reaction-bar.d.ts +70 -0
- package/dist/chat/reaction-bar.js +108 -0
- package/dist/chat/typing-indicator.d.ts +42 -0
- package/dist/chat/typing-indicator.js +68 -0
- package/dist/chat/utils/composer-text.d.ts +38 -0
- package/dist/chat/utils/composer-text.js +86 -0
- package/dist/chat/utils/markdown-format.d.ts +30 -0
- package/dist/chat/utils/markdown-format.js +158 -0
- package/dist/chat/utils/mention-query.d.ts +55 -0
- package/dist/chat/utils/mention-query.js +60 -0
- package/dist/commerce/cart-drawer.d.ts +69 -0
- package/dist/commerce/cart-drawer.js +163 -0
- package/dist/commerce/cart-line.d.ts +32 -0
- package/dist/commerce/cart-line.js +43 -0
- package/dist/commerce/checkout-layout.d.ts +32 -0
- package/dist/commerce/checkout-layout.js +51 -0
- package/dist/commerce/facet-filters.d.ts +121 -0
- package/dist/commerce/facet-filters.js +318 -0
- package/dist/commerce/fulfilment-note.d.ts +28 -0
- package/dist/commerce/fulfilment-note.js +26 -0
- package/dist/commerce/index.d.ts +27 -0
- package/dist/commerce/index.js +27 -0
- package/dist/commerce/item-options-dialog.d.ts +67 -0
- package/dist/commerce/item-options-dialog.js +150 -0
- package/dist/commerce/menu-item-card.d.ts +37 -0
- package/dist/commerce/menu-item-card.js +96 -0
- package/dist/commerce/option-group.d.ts +62 -0
- package/dist/commerce/option-group.js +121 -0
- package/dist/commerce/order-summary.d.ts +42 -0
- package/dist/commerce/order-summary.js +76 -0
- package/dist/commerce/order-tracker.d.ts +80 -0
- package/dist/commerce/order-tracker.js +178 -0
- package/dist/commerce/price.d.ts +52 -0
- package/dist/commerce/price.js +108 -0
- package/dist/commerce/product-card.d.ts +53 -0
- package/dist/commerce/product-card.js +127 -0
- package/dist/commerce/product-gallery.d.ts +70 -0
- package/dist/commerce/product-gallery.js +186 -0
- package/dist/commerce/promo-code.d.ts +56 -0
- package/dist/commerce/promo-code.js +101 -0
- package/dist/commerce/quantity-stepper.d.ts +42 -0
- package/dist/commerce/quantity-stepper.js +53 -0
- package/dist/commerce/question-list.d.ts +53 -0
- package/dist/commerce/question-list.js +92 -0
- package/dist/commerce/shipping-estimate.d.ts +53 -0
- package/dist/commerce/shipping-estimate.js +39 -0
- package/dist/commerce/sort-select.d.ts +38 -0
- package/dist/commerce/sort-select.js +38 -0
- package/dist/commerce/variant-picker.d.ts +75 -0
- package/dist/commerce/variant-picker.js +135 -0
- package/dist/components/amount.d.ts +46 -0
- package/dist/components/amount.js +34 -0
- package/dist/components/autocomplete.d.ts +82 -0
- package/dist/components/autocomplete.js +114 -0
- package/dist/components/carousel.d.ts +31 -1
- package/dist/components/carousel.js +66 -3
- package/dist/components/index.d.ts +11 -0
- package/dist/components/index.js +11 -0
- package/dist/components/letterbox.d.ts +47 -0
- package/dist/components/letterbox.js +56 -0
- package/dist/components/lightbox.d.ts +88 -0
- package/dist/components/lightbox.js +224 -0
- package/dist/components/media-grid.d.ts +53 -0
- package/dist/components/media-grid.js +89 -0
- package/dist/components/range-months.d.ts +100 -0
- package/dist/components/range-months.js +274 -0
- package/dist/components/rating-input.d.ts +33 -0
- package/dist/components/rating-input.js +63 -0
- package/dist/components/rating.d.ts +38 -0
- package/dist/components/rating.js +66 -0
- package/dist/components/review-card.d.ts +39 -0
- package/dist/components/review-card.js +59 -0
- package/dist/components/section-bar.d.ts +57 -0
- package/dist/components/section-bar.js +140 -0
- package/dist/components/step-indicator.d.ts +46 -0
- package/dist/components/step-indicator.js +96 -0
- package/dist/finance/index.d.ts +10 -0
- package/dist/finance/index.js +10 -0
- package/dist/finance/ledger.d.ts +60 -0
- package/dist/finance/ledger.js +93 -0
- package/dist/finance/payment-card.d.ts +49 -0
- package/dist/finance/payment-card.js +115 -0
- package/dist/map/engine.d.ts +49 -0
- package/dist/map/engine.js +591 -0
- package/dist/map/index.d.ts +12 -0
- package/dist/map/index.js +12 -0
- package/dist/map/map-canvas.d.ts +101 -0
- package/dist/map/map-canvas.js +275 -0
- package/dist/map/map.d.ts +217 -0
- package/dist/map/map.js +598 -0
- package/dist/map/mixins/map-link.d.ts +30 -0
- package/dist/map/mixins/map-link.js +116 -0
- package/dist/map/utils/basemap.d.ts +88 -0
- package/dist/map/utils/basemap.js +84 -0
- package/dist/map/utils/cluster.d.ts +43 -0
- package/dist/map/utils/cluster.js +80 -0
- package/dist/map/utils/mercator.d.ts +66 -0
- package/dist/map/utils/mercator.js +92 -0
- package/dist/map/utils/stage.d.ts +24 -0
- package/dist/map/utils/stage.js +49 -0
- package/dist/mixins/autocomplete.d.ts +28 -0
- package/dist/mixins/autocomplete.js +283 -0
- package/dist/mixins/carousel-controls.d.ts +14 -3
- package/dist/mixins/carousel-controls.js +89 -30
- package/dist/mixins/index.d.ts +2 -0
- package/dist/mixins/index.js +2 -0
- package/dist/mixins/lightbox-controls.d.ts +34 -0
- package/dist/mixins/lightbox-controls.js +176 -0
- package/dist/schedule/agenda.d.ts +63 -0
- package/dist/schedule/agenda.js +221 -0
- package/dist/schedule/day-strip.d.ts +50 -0
- package/dist/schedule/day-strip.js +136 -0
- package/dist/schedule/free-busy.d.ts +96 -0
- package/dist/schedule/free-busy.js +285 -0
- package/dist/schedule/index.d.ts +15 -0
- package/dist/schedule/index.js +15 -0
- package/dist/schedule/mixins/day-strip-scroll.d.ts +16 -0
- package/dist/schedule/mixins/day-strip-scroll.js +40 -0
- package/dist/schedule/mixins/time-grid-drag.d.ts +24 -0
- package/dist/schedule/mixins/time-grid-drag.js +532 -0
- package/dist/schedule/month-view.d.ts +68 -0
- package/dist/schedule/month-view.js +301 -0
- package/dist/schedule/time-grid.d.ts +168 -0
- package/dist/schedule/time-grid.js +417 -0
- package/dist/schedule/utils/time-grid-layout.d.ts +50 -0
- package/dist/schedule/utils/time-grid-layout.js +93 -0
- package/dist/schedule/year-view.d.ts +46 -0
- package/dist/schedule/year-view.js +142 -0
- package/dist/styles/index.d.ts +1 -0
- package/dist/styles/index.js +1 -0
- package/dist/styles/typewriter-text.d.ts +20 -0
- package/dist/styles/typewriter-text.js +23 -0
- package/dist/test/map.d.ts +18 -0
- package/dist/test/map.js +96 -0
- package/dist/test/reels.d.ts +30 -0
- package/dist/test/reels.js +41 -0
- package/dist/test/stories.d.ts +31 -0
- package/dist/test/stories.js +66 -0
- package/dist/travel/boarding-pass.d.ts +107 -0
- package/dist/travel/boarding-pass.js +293 -0
- package/dist/travel/car-offer.d.ts +70 -0
- package/dist/travel/car-offer.js +127 -0
- package/dist/travel/fare-calendar.d.ts +85 -0
- package/dist/travel/fare-calendar.js +233 -0
- package/dist/travel/fare-options.d.ts +84 -0
- package/dist/travel/fare-options.js +142 -0
- package/dist/travel/flight-itinerary.d.ts +84 -0
- package/dist/travel/flight-itinerary.js +112 -0
- package/dist/travel/flight-option.d.ts +58 -0
- package/dist/travel/flight-option.js +111 -0
- package/dist/travel/flight-segment.d.ts +105 -0
- package/dist/travel/flight-segment.js +174 -0
- package/dist/travel/index.d.ts +20 -0
- package/dist/travel/index.js +20 -0
- package/dist/travel/package-savings.d.ts +74 -0
- package/dist/travel/package-savings.js +128 -0
- package/dist/travel/price-breakdown.d.ts +66 -0
- package/dist/travel/price-breakdown.js +102 -0
- package/dist/travel/rating-breakdown.d.ts +81 -0
- package/dist/travel/rating-breakdown.js +132 -0
- package/dist/travel/seat-map.d.ts +108 -0
- package/dist/travel/seat-map.js +371 -0
- package/dist/travel/trip-timeline.d.ts +84 -0
- package/dist/travel/trip-timeline.js +212 -0
- package/dist/utils/gamepad-presses.d.ts +21 -0
- package/dist/utils/gamepad-presses.js +28 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/move-focus.d.ts +20 -0
- package/dist/utils/move-focus.js +28 -0
- package/dist/utils/range-months.d.ts +54 -0
- package/dist/utils/range-months.js +98 -0
- package/dist/utils/swipe-direction.d.ts +23 -0
- package/dist/utils/swipe-direction.js +27 -0
- package/dist/utils/typewriter.d.ts +49 -0
- package/dist/utils/typewriter.js +171 -0
- package/dist/video/index.d.ts +6 -2
- package/dist/video/index.js +6 -2
- package/dist/video/mixins/reel-feed-sync.d.ts +41 -0
- package/dist/video/mixins/reel-feed-sync.js +430 -0
- package/dist/video/mixins/story-viewer-sync.d.ts +31 -0
- package/dist/video/mixins/story-viewer-sync.js +391 -0
- package/dist/video/reel-feed.d.ts +95 -0
- package/dist/video/reel-feed.js +124 -0
- package/dist/video/story-ring.d.ts +32 -0
- package/dist/video/story-ring.js +42 -0
- package/dist/video/story-viewer.d.ts +85 -0
- package/dist/video/story-viewer.js +250 -0
- package/package.json +21 -2
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The dialog an item opens before it goes in the cart: its picture, name and description,
|
|
3
|
+
* its option groups, a quantity and an add button carrying the running price. It is a native
|
|
4
|
+
* `<dialog>`, a sheet from the bottom on a phone and centred from a tablet up.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { Handle, RemixNode } from "remix/component";
|
|
10
|
+
/** Prop types for {@link ItemOptionsDialog}. */
|
|
11
|
+
export declare namespace ItemOptionsDialog {
|
|
12
|
+
/** Props accepted by {@link ItemOptionsDialog}. */
|
|
13
|
+
interface Props {
|
|
14
|
+
/** The dialog's id, which the item's button names with `commandfor`. */
|
|
15
|
+
id: string;
|
|
16
|
+
/** Where the form posts. */
|
|
17
|
+
action: string;
|
|
18
|
+
title: string;
|
|
19
|
+
description?: RemixNode;
|
|
20
|
+
/** The item's price as the reader sees it, under the description. */
|
|
21
|
+
price?: RemixNode;
|
|
22
|
+
/** Tags beside the price, such as dietary badges. */
|
|
23
|
+
badges?: RemixNode;
|
|
24
|
+
/** A picture across the top, such as the dish. */
|
|
25
|
+
media?: RemixNode;
|
|
26
|
+
/** The colour behind the picture. */
|
|
27
|
+
mediaBackground?: string;
|
|
28
|
+
/** The item's base price in minor units, which the running total starts from. */
|
|
29
|
+
base: number;
|
|
30
|
+
/** The ISO 4217 code totals are written in. */
|
|
31
|
+
currency: string;
|
|
32
|
+
locale?: string;
|
|
33
|
+
/** Hidden fields the post carries, such as the item id and the page to return to. */
|
|
34
|
+
fields?: Record<string, string>;
|
|
35
|
+
/** The {@link OptionGroup}s. */
|
|
36
|
+
children?: RemixNode;
|
|
37
|
+
/** A quantity field; omitted, the item is added one at a time. */
|
|
38
|
+
quantity?: {
|
|
39
|
+
label: string;
|
|
40
|
+
name?: string;
|
|
41
|
+
max?: number;
|
|
42
|
+
};
|
|
43
|
+
/** A note above the add button, such as a warning that the cart will be replaced. */
|
|
44
|
+
notice?: RemixNode;
|
|
45
|
+
/**
|
|
46
|
+
* The add button's words before the price, such as "Add to cart". Put a
|
|
47
|
+
* `<span data-options-qty>1</span>` in it to show the quantity live.
|
|
48
|
+
*/
|
|
49
|
+
submitLabel: RemixNode;
|
|
50
|
+
/** The total the button shows before any pick, already formatted. */
|
|
51
|
+
total: string;
|
|
52
|
+
/** Keeps the item from being added, such as while the shop is closed. */
|
|
53
|
+
disabled?: boolean;
|
|
54
|
+
/** The close button's name, such as "Close". */
|
|
55
|
+
closeLabel: string;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Renders the dialog, its form and its {@link OptionsLive} island. Without script the form
|
|
60
|
+
* still posts every pick; the button shows the base total until the server prices it.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* <ItemOptionsDialog id="item-tacos" action="/cart/add" title="Al pastor trio" base={1150} currency="USD" total="$11.50" submitLabel="Add to cart" closeLabel="Close">
|
|
64
|
+
* <OptionGroup name="tortilla" title="Tortilla" required choices={choices} />
|
|
65
|
+
* </ItemOptionsDialog>
|
|
66
|
+
*/
|
|
67
|
+
export declare function ItemOptionsDialog(handle: Handle<ItemOptionsDialog.Props>): () => import("remix/component").RemixElement;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "remix/component/jsx-runtime";
|
|
2
|
+
import { XIcon } from "@sdxc/icons";
|
|
3
|
+
import { raw } from "@sdxc/u/general";
|
|
4
|
+
import { motionReduce } from "@sdxc/u/responsive";
|
|
5
|
+
import { when } from "@sdxc/u/state";
|
|
6
|
+
import { OptionsLive } from "./option-group.js";
|
|
7
|
+
/** From here the dialog is centred rather than a bottom sheet. */
|
|
8
|
+
const WIDE = "(min-width: 48rem)";
|
|
9
|
+
/**
|
|
10
|
+
* Renders the dialog, its form and its {@link OptionsLive} island. Without script the form
|
|
11
|
+
* still posts every pick; the button shows the base total until the server prices it.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* <ItemOptionsDialog id="item-tacos" action="/cart/add" title="Al pastor trio" base={1150} currency="USD" total="$11.50" submitLabel="Add to cart" closeLabel="Close">
|
|
15
|
+
* <OptionGroup name="tortilla" title="Tortilla" required choices={choices} />
|
|
16
|
+
* </ItemOptionsDialog>
|
|
17
|
+
*/
|
|
18
|
+
export function ItemOptionsDialog(handle) {
|
|
19
|
+
return () => {
|
|
20
|
+
let props = handle.props;
|
|
21
|
+
let formId = `${props.id}-form`;
|
|
22
|
+
return (_jsxs("dialog", { id: props.id, closedby: "any", "aria-labelledby": `${props.id}-title`, "data-slot": "item-options-dialog", mix: [
|
|
23
|
+
raw({
|
|
24
|
+
inlineSize: "100%",
|
|
25
|
+
maxInlineSize: "100%",
|
|
26
|
+
maxBlockSize: "92dvh",
|
|
27
|
+
margin: "auto auto 0",
|
|
28
|
+
padding: "0",
|
|
29
|
+
border: "0",
|
|
30
|
+
borderRadius: "1.25rem 1.25rem 0 0",
|
|
31
|
+
color: "var(--ui-neutral-fg)",
|
|
32
|
+
backgroundColor: "var(--ui-bg-raised, var(--ui-bg))",
|
|
33
|
+
boxShadow: "0 -12px 40px -12px rgb(0 0 0 / 0.35)",
|
|
34
|
+
overflow: "hidden",
|
|
35
|
+
"&::backdrop": { backgroundColor: "rgb(10 6 8 / 0.5)", backdropFilter: "blur(2px)" },
|
|
36
|
+
"&[open]": { display: "flex", flexDirection: "column" },
|
|
37
|
+
"@keyframes ui-item-options-in": {
|
|
38
|
+
from: { translate: "0 2rem", opacity: "0" },
|
|
39
|
+
to: { translate: "0 0", opacity: "1" },
|
|
40
|
+
},
|
|
41
|
+
"&[open]:modal": {
|
|
42
|
+
animation: "ui-item-options-in 220ms cubic-bezier(0.2, 0.8, 0.2, 1)",
|
|
43
|
+
},
|
|
44
|
+
[`@media ${WIDE}`]: {
|
|
45
|
+
inlineSize: "min(34rem, calc(100vw - 2rem))",
|
|
46
|
+
maxBlockSize: "min(88dvh, 52rem)",
|
|
47
|
+
margin: "auto",
|
|
48
|
+
borderRadius: "1.25rem",
|
|
49
|
+
},
|
|
50
|
+
}),
|
|
51
|
+
motionReduce(raw({ "&[open]:modal": { animation: "none" } })),
|
|
52
|
+
], children: [_jsxs("form", { id: formId, method: "post", action: props.action, "data-base": String(props.base), mix: [
|
|
53
|
+
raw({ display: "flex", flexDirection: "column", flex: "1 1 auto", minBlockSize: "0" }),
|
|
54
|
+
], children: [Object.entries(props.fields ?? {}).map(([name, value]) => (_jsx("input", { type: "hidden", name: name, value: value }))), _jsxs("div", { mix: [raw({ flex: "1 1 auto", overflowY: "auto", overscrollBehavior: "contain" })], children: [_jsxs("div", { mix: [
|
|
55
|
+
raw({
|
|
56
|
+
position: "relative",
|
|
57
|
+
display: "grid",
|
|
58
|
+
placeItems: "center",
|
|
59
|
+
minBlockSize: props.media === undefined ? "3.5rem" : "11rem",
|
|
60
|
+
backgroundColor: props.mediaBackground ?? "var(--ui-neutral-bg-tint)",
|
|
61
|
+
"& > [data-slot=item-options-media]": { inlineSize: "9rem" },
|
|
62
|
+
}),
|
|
63
|
+
], children: [props.media === undefined ? null : (_jsx("span", { "data-slot": "item-options-media", children: props.media })), _jsx("button", { type: "button", commandfor: props.id, command: "close", "aria-label": props.closeLabel, mix: [
|
|
64
|
+
raw({
|
|
65
|
+
position: "absolute",
|
|
66
|
+
insetBlockStart: "0.75rem",
|
|
67
|
+
insetInlineEnd: "0.75rem",
|
|
68
|
+
display: "grid",
|
|
69
|
+
placeItems: "center",
|
|
70
|
+
inlineSize: "2.5rem",
|
|
71
|
+
blockSize: "2.5rem",
|
|
72
|
+
padding: "0",
|
|
73
|
+
border: "0",
|
|
74
|
+
borderRadius: "999px",
|
|
75
|
+
color: "oklch(0.25 0.02 40)",
|
|
76
|
+
backgroundColor: "rgb(255 255 255 / 0.85)",
|
|
77
|
+
cursor: "pointer",
|
|
78
|
+
}),
|
|
79
|
+
when("&:focus-visible", raw({ outline: "2px solid var(--ui-brand-ring)", outlineOffset: "2px" })),
|
|
80
|
+
], children: _jsx(XIcon, { "aria-hidden": "true", size: 18 }) })] }), _jsxs("div", { mix: [raw({ display: "grid", gap: "1.5rem", padding: "1.25rem 1.25rem 1.5rem" })], children: [_jsxs("div", { mix: [raw({ display: "grid", gap: "0.375rem" })], children: [_jsx("h2", { id: `${props.id}-title`, mix: [
|
|
81
|
+
raw({
|
|
82
|
+
margin: "0",
|
|
83
|
+
fontSize: "1.375rem",
|
|
84
|
+
fontWeight: "800",
|
|
85
|
+
letterSpacing: "-0.02em",
|
|
86
|
+
color: "var(--ui-neutral-fg-emphasis)",
|
|
87
|
+
}),
|
|
88
|
+
], children: props.title }), props.description === undefined ? null : (_jsx("p", { mix: [raw({ margin: "0", lineHeight: "1.5" })], children: props.description })), props.price === undefined && props.badges === undefined ? null : (_jsxs("p", { mix: [
|
|
89
|
+
raw({
|
|
90
|
+
display: "flex",
|
|
91
|
+
alignItems: "center",
|
|
92
|
+
gap: "0.5rem",
|
|
93
|
+
margin: "0",
|
|
94
|
+
fontWeight: "650",
|
|
95
|
+
}),
|
|
96
|
+
], children: [props.price, props.badges] }))] }), props.children, props.quantity === undefined ? null : (_jsxs("label", { mix: [
|
|
97
|
+
raw({
|
|
98
|
+
display: "flex",
|
|
99
|
+
alignItems: "center",
|
|
100
|
+
justifyContent: "space-between",
|
|
101
|
+
gap: "1rem",
|
|
102
|
+
}),
|
|
103
|
+
], children: [_jsx("span", { mix: [raw({ fontWeight: "750", color: "var(--ui-neutral-fg-emphasis)" })], children: props.quantity.label }), _jsx("input", { type: "number", name: props.quantity.name ?? "qty", value: "1", min: "1", max: String(props.quantity.max ?? 20), inputmode: "numeric", "data-options-qty-field": "", mix: [
|
|
104
|
+
raw({
|
|
105
|
+
inlineSize: "5rem",
|
|
106
|
+
blockSize: "2.5rem",
|
|
107
|
+
paddingInline: "0.75rem",
|
|
108
|
+
boxSizing: "border-box",
|
|
109
|
+
border: "1px solid var(--ui-neutral-border)",
|
|
110
|
+
borderRadius: "0.75rem",
|
|
111
|
+
font: "inherit",
|
|
112
|
+
fontWeight: "700",
|
|
113
|
+
textAlign: "center",
|
|
114
|
+
color: "var(--ui-neutral-fg-emphasis)",
|
|
115
|
+
backgroundColor: "var(--ui-bg)",
|
|
116
|
+
}),
|
|
117
|
+
when("&:focus", raw({ outline: "2px solid var(--ui-brand-ring)", outlineOffset: "1px" })),
|
|
118
|
+
] })] }))] })] }), _jsxs("div", { mix: [
|
|
119
|
+
raw({
|
|
120
|
+
display: "grid",
|
|
121
|
+
gap: "0.625rem",
|
|
122
|
+
padding: "0.875rem 1.25rem calc(0.875rem + env(safe-area-inset-bottom, 0px))",
|
|
123
|
+
borderBlockStart: "1px solid var(--ui-neutral-border)",
|
|
124
|
+
}),
|
|
125
|
+
], children: [props.notice === undefined ? null : (_jsx("div", { "data-slot": "item-options-notice", mix: [raw({ fontSize: "0.875rem", lineHeight: "1.4" })], children: props.notice })), _jsxs("button", { type: "submit", disabled: props.disabled, "data-slot": "item-options-submit", mix: [
|
|
126
|
+
raw({
|
|
127
|
+
display: "flex",
|
|
128
|
+
alignItems: "center",
|
|
129
|
+
justifyContent: "space-between",
|
|
130
|
+
gap: "1rem",
|
|
131
|
+
inlineSize: "100%",
|
|
132
|
+
blockSize: "3.25rem",
|
|
133
|
+
paddingInline: "1.25rem",
|
|
134
|
+
border: "0",
|
|
135
|
+
borderRadius: "999px",
|
|
136
|
+
font: "inherit",
|
|
137
|
+
fontSize: "1rem",
|
|
138
|
+
fontWeight: "750",
|
|
139
|
+
color: "var(--ui-brand-fg-on-solid, white)",
|
|
140
|
+
backgroundColor: "var(--ui-brand-bg-solid)",
|
|
141
|
+
cursor: "pointer",
|
|
142
|
+
}),
|
|
143
|
+
when("&:hover", raw({
|
|
144
|
+
backgroundColor: "var(--ui-brand-bg-solid-hover, var(--ui-brand-bg-solid))",
|
|
145
|
+
})),
|
|
146
|
+
when("&:focus-visible", raw({ outline: "2px solid var(--ui-brand-ring)", outlineOffset: "2px" })),
|
|
147
|
+
when("&:disabled", raw({ opacity: "0.5", cursor: "not-allowed" })),
|
|
148
|
+
], children: [_jsx("span", { children: props.submitLabel }), _jsx("span", { "data-options-total": "", mix: [raw({ fontVariantNumeric: "tabular-nums" })], children: props.total })] })] })] }), _jsx(OptionsLive, { form: formId, currency: props.currency, locale: props.locale })] }));
|
|
149
|
+
};
|
|
150
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An item on a menu as one card: its name, a two-line description, its price and tags beside
|
|
3
|
+
* its picture, with a round + over the picture. The whole card is a button that opens the
|
|
4
|
+
* item's options dialog through Invoker Commands, so it opens without script.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { Handle, RemixNode } from "remix/component";
|
|
10
|
+
/** Prop types for {@link MenuItemCard}. */
|
|
11
|
+
export declare namespace MenuItemCard {
|
|
12
|
+
/** Props accepted by {@link MenuItemCard}. */
|
|
13
|
+
interface Props {
|
|
14
|
+
/** The id of the dialog the card opens. */
|
|
15
|
+
dialog: string;
|
|
16
|
+
name: string;
|
|
17
|
+
description?: string;
|
|
18
|
+
/** The price as the reader sees it, such as "$11.50" or "From $11.50". */
|
|
19
|
+
price: RemixNode;
|
|
20
|
+
/** Words or badges after the price, such as "Popular" or a dietary tag. */
|
|
21
|
+
badges?: RemixNode;
|
|
22
|
+
/** The picture, such as the dish; the card shows no picture when unset. */
|
|
23
|
+
media?: RemixNode;
|
|
24
|
+
/** The colour behind the picture. */
|
|
25
|
+
mediaBackground?: string;
|
|
26
|
+
/** Hides the + when the item cannot be added now; the card still opens its details. */
|
|
27
|
+
unavailable?: boolean;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Renders the card. It fills its grid cell, so a row of cards lines up whatever each
|
|
32
|
+
* description's length.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* <MenuItemCard dialog="item-tacos" name="Al pastor trio" description="Spit-roasted pork, pineapple" price="$11.50" media={<img src="/tacos.svg" alt="" />} />
|
|
36
|
+
*/
|
|
37
|
+
export declare function MenuItemCard(handle: Handle<MenuItemCard.Props>): () => import("remix/component").RemixElement;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "remix/component/jsx-runtime";
|
|
2
|
+
import { PlusIcon } from "@sdxc/icons";
|
|
3
|
+
import { raw } from "@sdxc/u/general";
|
|
4
|
+
import { motionReduce } from "@sdxc/u/responsive";
|
|
5
|
+
import { when } from "@sdxc/u/state";
|
|
6
|
+
/**
|
|
7
|
+
* Renders the card. It fills its grid cell, so a row of cards lines up whatever each
|
|
8
|
+
* description's length.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* <MenuItemCard dialog="item-tacos" name="Al pastor trio" description="Spit-roasted pork, pineapple" price="$11.50" media={<img src="/tacos.svg" alt="" />} />
|
|
12
|
+
*/
|
|
13
|
+
export function MenuItemCard(handle) {
|
|
14
|
+
return () => {
|
|
15
|
+
let { badges, description, dialog, media, mediaBackground, name, price, unavailable = false, } = handle.props;
|
|
16
|
+
return (_jsxs("button", { type: "button", commandfor: dialog, command: "show-modal", "aria-haspopup": "dialog", "data-slot": "menu-item-card", mix: [
|
|
17
|
+
raw({
|
|
18
|
+
display: "grid",
|
|
19
|
+
gridTemplateColumns: media === undefined ? "minmax(0, 1fr)" : "minmax(0, 1fr) 6.5rem",
|
|
20
|
+
gap: "1rem",
|
|
21
|
+
inlineSize: "100%",
|
|
22
|
+
blockSize: "100%",
|
|
23
|
+
padding: "1rem",
|
|
24
|
+
boxSizing: "border-box",
|
|
25
|
+
border: "0",
|
|
26
|
+
borderRadius: "var(--ui-radius-lg, 1rem)",
|
|
27
|
+
font: "inherit",
|
|
28
|
+
textAlign: "start",
|
|
29
|
+
color: "inherit",
|
|
30
|
+
backgroundColor: "var(--ui-bg-raised, var(--ui-bg))",
|
|
31
|
+
boxShadow: "inset 0 0 0 1px var(--ui-neutral-border)",
|
|
32
|
+
cursor: "pointer",
|
|
33
|
+
transition: "box-shadow 160ms ease",
|
|
34
|
+
}),
|
|
35
|
+
when("&:hover", raw({
|
|
36
|
+
boxShadow: "inset 0 0 0 1px var(--ui-neutral-border-strong, var(--ui-neutral-fg-muted))",
|
|
37
|
+
})),
|
|
38
|
+
when("&:focus-visible", raw({ outline: "2px solid var(--ui-brand-ring)", outlineOffset: "2px" })),
|
|
39
|
+
when(":target > &", raw({ boxShadow: "inset 0 0 0 2px var(--ui-brand-ring)" })),
|
|
40
|
+
motionReduce(raw({ transition: "none" })),
|
|
41
|
+
], children: [_jsxs("span", { mix: [
|
|
42
|
+
raw({ display: "grid", alignContent: "start", gap: "0.3125rem", minInlineSize: "0" }),
|
|
43
|
+
], children: [_jsx("span", { mix: [
|
|
44
|
+
raw({ fontSize: "1rem", fontWeight: "700", color: "var(--ui-neutral-fg-emphasis)" }),
|
|
45
|
+
], children: name }), description === undefined ? null : (_jsx("span", { mix: [
|
|
46
|
+
raw({
|
|
47
|
+
display: "-webkit-box",
|
|
48
|
+
WebkitLineClamp: "2",
|
|
49
|
+
WebkitBoxOrient: "vertical",
|
|
50
|
+
overflow: "hidden",
|
|
51
|
+
fontSize: "0.875rem",
|
|
52
|
+
lineHeight: "1.45",
|
|
53
|
+
color: "var(--ui-neutral-fg-muted)",
|
|
54
|
+
}),
|
|
55
|
+
], children: description })), _jsxs("span", { mix: [
|
|
56
|
+
raw({
|
|
57
|
+
display: "flex",
|
|
58
|
+
flexWrap: "wrap",
|
|
59
|
+
alignItems: "center",
|
|
60
|
+
gap: "0.5rem",
|
|
61
|
+
marginBlockStart: "0.25rem",
|
|
62
|
+
}),
|
|
63
|
+
], children: [_jsx("span", { mix: [
|
|
64
|
+
raw({
|
|
65
|
+
fontWeight: "650",
|
|
66
|
+
fontVariantNumeric: "tabular-nums",
|
|
67
|
+
color: "var(--ui-neutral-fg-emphasis)",
|
|
68
|
+
}),
|
|
69
|
+
], children: price }), badges] })] }), media === undefined ? null : (_jsxs("span", { "data-slot": "menu-item-card-media", mix: [
|
|
70
|
+
raw({
|
|
71
|
+
position: "relative",
|
|
72
|
+
alignSelf: "start",
|
|
73
|
+
inlineSize: "6.5rem",
|
|
74
|
+
blockSize: "6.5rem",
|
|
75
|
+
padding: "0.5rem",
|
|
76
|
+
boxSizing: "border-box",
|
|
77
|
+
borderRadius: "0.875rem",
|
|
78
|
+
backgroundColor: mediaBackground ?? "var(--ui-neutral-bg-tint)",
|
|
79
|
+
}),
|
|
80
|
+
], children: [media, unavailable ? null : (_jsx("span", { "aria-hidden": "true", "data-slot": "menu-item-card-add", mix: [
|
|
81
|
+
raw({
|
|
82
|
+
position: "absolute",
|
|
83
|
+
insetInlineEnd: "-0.375rem",
|
|
84
|
+
insetBlockEnd: "-0.375rem",
|
|
85
|
+
display: "grid",
|
|
86
|
+
placeItems: "center",
|
|
87
|
+
inlineSize: "2.25rem",
|
|
88
|
+
blockSize: "2.25rem",
|
|
89
|
+
borderRadius: "999px",
|
|
90
|
+
color: "var(--ui-neutral-fg-emphasis)",
|
|
91
|
+
backgroundColor: "var(--ui-bg-raised, var(--ui-bg))",
|
|
92
|
+
boxShadow: "0 0 0 1px var(--ui-neutral-border), 0 4px 10px -4px rgb(0 0 0 / 0.3)",
|
|
93
|
+
}),
|
|
94
|
+
], children: _jsx(PlusIcon, { size: 18 }) }))] }))] }));
|
|
95
|
+
};
|
|
96
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Priced choices for something being ordered: a group is a fieldset of radios when one pick
|
|
3
|
+
* is required, or of checkboxes up to a limit when the picks are extras, each with what it
|
|
4
|
+
* adds to the price. Its island reprices the form live and holds each group to its limit.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { EntryComponent, Handle, Props as TagProps } from "remix/component";
|
|
10
|
+
/** Prop types for {@link OptionGroup} and {@link OptionsLive}. */
|
|
11
|
+
export declare namespace OptionGroup {
|
|
12
|
+
/** One pick. */
|
|
13
|
+
interface Choice {
|
|
14
|
+
/** The value the form posts. */
|
|
15
|
+
value: string;
|
|
16
|
+
label: string;
|
|
17
|
+
/** What it adds, in the currency's minor units; `0` for a pick included in the price. */
|
|
18
|
+
price: number;
|
|
19
|
+
/** The price as the reader sees it, such as "+$0.50"; nothing is drawn when unset. */
|
|
20
|
+
priceLabel?: string;
|
|
21
|
+
}
|
|
22
|
+
/** Props accepted by {@link OptionGroup}; the host is a `<fieldset>`. */
|
|
23
|
+
interface Props extends Omit<TagProps<"fieldset">, "children" | "name"> {
|
|
24
|
+
/** The field every pick posts as. */
|
|
25
|
+
name: string;
|
|
26
|
+
title: string;
|
|
27
|
+
/** A line under the title, such as "Pick one" or "Optional, up to 3". */
|
|
28
|
+
hint?: string;
|
|
29
|
+
/** Takes exactly one pick, drawn as radios; otherwise checkboxes. */
|
|
30
|
+
required?: boolean;
|
|
31
|
+
/** How many checkboxes may be ticked; ignored when `required`. @default 1 */
|
|
32
|
+
max?: number;
|
|
33
|
+
choices: Choice[];
|
|
34
|
+
/** The values ticked at first. */
|
|
35
|
+
defaultValue?: string[];
|
|
36
|
+
/** The badge a required group carries, such as "Required". */
|
|
37
|
+
requiredLabel?: string;
|
|
38
|
+
}
|
|
39
|
+
/** Props {@link OptionsLive} serializes for hydration. */
|
|
40
|
+
type LiveProps = {
|
|
41
|
+
/** The id of the form whose total follows its picks. */
|
|
42
|
+
form: string;
|
|
43
|
+
/** The ISO 4217 code totals are written in, such as "USD". */
|
|
44
|
+
currency: string;
|
|
45
|
+
/** The locale totals are written in; the reader's own when unset. */
|
|
46
|
+
locale?: string;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Renders a group: its title, hint and Required badge in the legend, then one row per pick
|
|
51
|
+
* with its price at the end. Every input carries `data-price`, which {@link OptionsLive} sums.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* <OptionGroup name="tortilla" title="Tortilla" hint="Pick one" required requiredLabel="Required" choices={[{ value: "corn", label: "Blue corn", price: 0 }, { value: "flour", label: "Flour", price: 50, priceLabel: "+$0.50" }]} />
|
|
55
|
+
*/
|
|
56
|
+
export declare function OptionGroup(handle: Handle<OptionGroup.Props>): () => import("remix/component").RemixElement;
|
|
57
|
+
/**
|
|
58
|
+
* The island behind an options form. Each change reprices `[data-options-total]`: the
|
|
59
|
+
* form's `data-base` plus every ticked `data-price`, times its `data-options-qty-field`. It
|
|
60
|
+
* also stops an optional group at its limit and closes an enclosing dialog as the form posts.
|
|
61
|
+
*/
|
|
62
|
+
export declare const OptionsLive: EntryComponent<OptionGroup.LiveProps>;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "remix/component/jsx-runtime";
|
|
2
|
+
import { mergeMix, raw } from "@sdxc/u/general";
|
|
3
|
+
import { clientEntry } from "remix/component";
|
|
4
|
+
/**
|
|
5
|
+
* Renders a group: its title, hint and Required badge in the legend, then one row per pick
|
|
6
|
+
* with its price at the end. Every input carries `data-price`, which {@link OptionsLive} sums.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* <OptionGroup name="tortilla" title="Tortilla" hint="Pick one" required requiredLabel="Required" choices={[{ value: "corn", label: "Blue corn", price: 0 }, { value: "flour", label: "Flour", price: 50, priceLabel: "+$0.50" }]} />
|
|
10
|
+
*/
|
|
11
|
+
export function OptionGroup(handle) {
|
|
12
|
+
return () => {
|
|
13
|
+
let { choices, defaultValue = [], hint, max = 1, mix, name, required = false, requiredLabel, title, ...rest } = handle.props;
|
|
14
|
+
return (_jsxs("fieldset", { ...rest, "data-slot": "option-group", "data-max": required ? undefined : String(max), mix: mergeMix([raw({ display: "grid", gap: "0.25rem", margin: "0", padding: "0", border: "0" })], mix), children: [_jsxs("legend", { mix: [
|
|
15
|
+
raw({
|
|
16
|
+
display: "flex",
|
|
17
|
+
alignItems: "center",
|
|
18
|
+
justifyContent: "space-between",
|
|
19
|
+
gap: "0.75rem",
|
|
20
|
+
inlineSize: "100%",
|
|
21
|
+
padding: "0",
|
|
22
|
+
marginBlockEnd: "0.375rem",
|
|
23
|
+
}),
|
|
24
|
+
], children: [_jsxs("span", { mix: [raw({ display: "grid", gap: "0.0625rem" })], children: [_jsx("span", { mix: [
|
|
25
|
+
raw({
|
|
26
|
+
fontSize: "1rem",
|
|
27
|
+
fontWeight: "750",
|
|
28
|
+
color: "var(--ui-neutral-fg-emphasis)",
|
|
29
|
+
}),
|
|
30
|
+
], children: title }), hint === undefined ? null : (_jsx("span", { mix: [raw({ fontSize: "0.8125rem", color: "var(--ui-neutral-fg-muted)" })], children: hint }))] }), required && requiredLabel !== undefined ? (_jsx("span", { "data-slot": "option-group-required", mix: [
|
|
31
|
+
raw({
|
|
32
|
+
flexShrink: "0",
|
|
33
|
+
paddingInline: "0.5rem",
|
|
34
|
+
paddingBlock: "0.125rem",
|
|
35
|
+
borderRadius: "999px",
|
|
36
|
+
fontSize: "0.75rem",
|
|
37
|
+
fontWeight: "700",
|
|
38
|
+
color: "var(--ui-neutral-fg-on-solid)",
|
|
39
|
+
backgroundColor: "var(--ui-neutral-bg-solid)",
|
|
40
|
+
}),
|
|
41
|
+
], children: requiredLabel })) : null] }), choices.map((choice, index) => (_jsxs("label", { "data-slot": "option-group-choice", mix: [
|
|
42
|
+
raw({
|
|
43
|
+
display: "grid",
|
|
44
|
+
gridTemplateColumns: "1.25rem minmax(0, 1fr) auto",
|
|
45
|
+
alignItems: "center",
|
|
46
|
+
gap: "0.75rem",
|
|
47
|
+
minBlockSize: "2.75rem",
|
|
48
|
+
paddingInline: "0.25rem",
|
|
49
|
+
borderBlockEnd: "1px solid var(--ui-neutral-border)",
|
|
50
|
+
cursor: "pointer",
|
|
51
|
+
"&:has(input:disabled)": { opacity: "0.5", cursor: "not-allowed" },
|
|
52
|
+
"& input": {
|
|
53
|
+
inlineSize: "1.125rem",
|
|
54
|
+
blockSize: "1.125rem",
|
|
55
|
+
margin: "0",
|
|
56
|
+
accentColor: "var(--ui-color-brand-600)",
|
|
57
|
+
},
|
|
58
|
+
}),
|
|
59
|
+
], children: [_jsx("input", { type: required ? "radio" : "checkbox", name: name, value: choice.value, "data-price": String(choice.price), checked: defaultValue.includes(choice.value) ? true : undefined, required: required && index === 0 ? true : undefined }), _jsx("span", { mix: [raw({ color: "var(--ui-neutral-fg-emphasis)" })], children: choice.label }), _jsx("span", { mix: [
|
|
60
|
+
raw({
|
|
61
|
+
fontSize: "0.875rem",
|
|
62
|
+
fontVariantNumeric: "tabular-nums",
|
|
63
|
+
color: "var(--ui-neutral-fg-muted)",
|
|
64
|
+
}),
|
|
65
|
+
], children: choice.priceLabel ?? "" })] })))] }));
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Writes an amount in minor units in a currency, with the currency's own number of decimals.
|
|
70
|
+
*
|
|
71
|
+
* @example formatMinor(1150, "USD", "en-US") // "$11.50"
|
|
72
|
+
*/
|
|
73
|
+
function formatMinor(minor, currency, locale) {
|
|
74
|
+
let format = new Intl.NumberFormat(locale, { style: "currency", currency });
|
|
75
|
+
let digits = format.resolvedOptions().maximumFractionDigits ?? 2;
|
|
76
|
+
return format.format(minor / 10 ** digits);
|
|
77
|
+
}
|
|
78
|
+
/** Prices one form as it stands and holds each optional group to its limit. */
|
|
79
|
+
function reprice(form, props) {
|
|
80
|
+
let base = Number(form.dataset.base ?? "0");
|
|
81
|
+
let picks = [...form.querySelectorAll("input[data-price]:checked")].reduce((sum, input) => sum + Number(input.dataset.price ?? "0"), 0);
|
|
82
|
+
let field = form.querySelector("input[data-options-qty-field]");
|
|
83
|
+
let max = Number(field?.max || "99");
|
|
84
|
+
let qty = field === null ? 1 : Math.min(Math.max(Number(field.value) || 1, 1), max);
|
|
85
|
+
for (let total of form.querySelectorAll("[data-options-total]")) {
|
|
86
|
+
total.textContent = formatMinor((base + picks) * qty, props.currency, props.locale);
|
|
87
|
+
}
|
|
88
|
+
for (let count of form.querySelectorAll("[data-options-qty]")) {
|
|
89
|
+
count.textContent = String(qty);
|
|
90
|
+
}
|
|
91
|
+
for (let group of form.querySelectorAll("fieldset[data-max]")) {
|
|
92
|
+
let limit = Number(group.dataset.max ?? "0");
|
|
93
|
+
let boxes = [...group.querySelectorAll("input[type=checkbox]")];
|
|
94
|
+
let full = boxes.filter((box) => box.checked).length >= limit;
|
|
95
|
+
for (let box of boxes)
|
|
96
|
+
box.disabled = full && !box.checked;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* The island behind an options form. Each change reprices `[data-options-total]`: the
|
|
101
|
+
* form's `data-base` plus every ticked `data-price`, times its `data-options-qty-field`. It
|
|
102
|
+
* also stops an optional group at its limit and closes an enclosing dialog as the form posts.
|
|
103
|
+
*/
|
|
104
|
+
export const OptionsLive = clientEntry("@sdxc/ui/commerce/option-group#OptionsLive", function OptionsLive(handle) {
|
|
105
|
+
handle.queueTask(() => {
|
|
106
|
+
let form = document.getElementById(handle.props.form);
|
|
107
|
+
if (!(form instanceof HTMLFormElement) || handle.signal.aborted)
|
|
108
|
+
return;
|
|
109
|
+
let target = form;
|
|
110
|
+
let update = () => reprice(target, handle.props);
|
|
111
|
+
target.addEventListener("input", update, { signal: handle.signal });
|
|
112
|
+
target.addEventListener("change", update, { signal: handle.signal });
|
|
113
|
+
target.addEventListener("submit", () => {
|
|
114
|
+
let dialog = target.closest("dialog");
|
|
115
|
+
if (dialog !== null)
|
|
116
|
+
queueMicrotask(() => dialog.close());
|
|
117
|
+
}, { signal: handle.signal });
|
|
118
|
+
update();
|
|
119
|
+
});
|
|
120
|
+
return () => _jsx("span", { hidden: true, "data-slot": "options-live" });
|
|
121
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a checkout is buying: the lines and the price breakdown. On a phone it folds behind a
|
|
3
|
+
* "Show order summary · €48.00" row so the form leads; from 56rem it is always open beside the
|
|
4
|
+
* form. Both come from one `<details>`, so the fold works without script.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { Handle, Props as TagProps, RemixNode } from "remix/component";
|
|
10
|
+
/** Prop types for {@link OrderSummary}. */
|
|
11
|
+
export declare namespace OrderSummary {
|
|
12
|
+
/** The words the summary carries. */
|
|
13
|
+
interface Labels {
|
|
14
|
+
/** The folded row's words, such as "Show order summary". */
|
|
15
|
+
show: string;
|
|
16
|
+
/** The summary's heading, such as "Order summary". */
|
|
17
|
+
heading: string;
|
|
18
|
+
}
|
|
19
|
+
/** Props accepted by {@link OrderSummary}; the host is a `<details>` or a `<section>`. */
|
|
20
|
+
interface Props extends Omit<TagProps<"section">, "children"> {
|
|
21
|
+
/** The lines, usually a `<ul>` of `CartLine`. */
|
|
22
|
+
lines: RemixNode;
|
|
23
|
+
/** The charges, usually a `PriceBreakdown` ending in its total. */
|
|
24
|
+
breakdown: RemixNode;
|
|
25
|
+
/** The order total, shown on the folded row so a phone sees it before unfolding. */
|
|
26
|
+
total: RemixNode;
|
|
27
|
+
/** Folds the summary below 56rem. @default false */
|
|
28
|
+
collapsible?: boolean;
|
|
29
|
+
/** Starts a collapsible summary unfolded on a phone. @default false */
|
|
30
|
+
open?: boolean;
|
|
31
|
+
labels: Labels;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Renders the heading, lines and breakdown. A collapsible summary is a `<details>` whose
|
|
36
|
+
* summary row shows on narrow screens only; from 56rem the row hides and the content shows
|
|
37
|
+
* whether or not the disclosure is open, through `::details-content`.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* <OrderSummary collapsible lines={<ul>…</ul>} breakdown={<PriceBreakdown>…</PriceBreakdown>} total="€48.00" labels={{ show: "Show order summary", heading: "Order summary" }} />
|
|
41
|
+
*/
|
|
42
|
+
export declare function OrderSummary(handle: Handle<OrderSummary.Props>): () => import("remix/component").RemixElement;
|