@sdxc/ui 2026.11.17 → 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 +139 -2
- 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/mixins/video-player-sync.js +138 -5
- 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/dist/video/video-card.d.ts +3 -1
- package/dist/video/video-card.js +15 -5
- package/dist/video/video-player.d.ts +33 -0
- package/dist/video/video-player.js +226 -20
- package/package.json +21 -2
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "remix/component/jsx-runtime";
|
|
2
|
+
import { ChevronDownIcon } from "@sdxc/icons";
|
|
3
|
+
import { mergeMix, raw } from "@sdxc/u/general";
|
|
4
|
+
import { motionReduce } from "@sdxc/u/responsive";
|
|
5
|
+
/** From this width the summary sits open beside the form. */
|
|
6
|
+
const WIDE = "(min-width: 56rem)";
|
|
7
|
+
/**
|
|
8
|
+
* Renders the heading, lines and breakdown. A collapsible summary is a `<details>` whose
|
|
9
|
+
* summary row shows on narrow screens only; from 56rem the row hides and the content shows
|
|
10
|
+
* whether or not the disclosure is open, through `::details-content`.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* <OrderSummary collapsible lines={<ul>…</ul>} breakdown={<PriceBreakdown>…</PriceBreakdown>} total="€48.00" labels={{ show: "Show order summary", heading: "Order summary" }} />
|
|
14
|
+
*/
|
|
15
|
+
export function OrderSummary(handle) {
|
|
16
|
+
return () => {
|
|
17
|
+
let { breakdown, collapsible = false, labels, lines, mix, open, total, ...rest } = handle.props;
|
|
18
|
+
let body = (_jsxs("div", { "data-slot": "order-summary-body", mix: [raw({ display: "grid", gap: "1rem" })], children: [_jsx("p", { "data-slot": "order-summary-heading", mix: [
|
|
19
|
+
raw({
|
|
20
|
+
margin: "0",
|
|
21
|
+
fontSize: "1rem",
|
|
22
|
+
fontWeight: "650",
|
|
23
|
+
color: "var(--ui-neutral-fg-emphasis)",
|
|
24
|
+
}),
|
|
25
|
+
], children: labels.heading }), _jsx("div", { "data-slot": "order-summary-lines", mix: [raw({ "& > ul": { margin: "0", padding: "0", listStyle: "none" } })], children: lines }), _jsx("div", { "data-slot": "order-summary-breakdown", children: breakdown })] }));
|
|
26
|
+
if (!collapsible) {
|
|
27
|
+
return (_jsx("section", { ...rest, "aria-label": labels.heading, "data-slot": "order-summary", mix: mergeMix([raw({ display: "block" })], mix), children: body }));
|
|
28
|
+
}
|
|
29
|
+
return (_jsxs("details", { ...rest, open: open, "data-slot": "order-summary", "data-collapsible": "", mix: mergeMix([
|
|
30
|
+
raw({
|
|
31
|
+
display: "block",
|
|
32
|
+
"&[open] > summary [data-chevron]": { rotate: "180deg" },
|
|
33
|
+
"&[open] > summary": { marginBlockEnd: "1rem" },
|
|
34
|
+
[`@media ${WIDE}`]: {
|
|
35
|
+
"&::details-content": {
|
|
36
|
+
contentVisibility: "visible",
|
|
37
|
+
display: "contents",
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
}),
|
|
41
|
+
], mix), children: [_jsxs("summary", { "data-slot": "order-summary-toggle", mix: [
|
|
42
|
+
raw({
|
|
43
|
+
display: "flex",
|
|
44
|
+
alignItems: "center",
|
|
45
|
+
gap: "0.5rem",
|
|
46
|
+
minBlockSize: "2.75rem",
|
|
47
|
+
fontSize: "0.9375rem",
|
|
48
|
+
fontWeight: "600",
|
|
49
|
+
color: "var(--ui-brand-fg)",
|
|
50
|
+
cursor: "pointer",
|
|
51
|
+
listStyle: "none",
|
|
52
|
+
"&::-webkit-details-marker": { display: "none" },
|
|
53
|
+
"& [data-chevron]": {
|
|
54
|
+
inlineSize: "1rem",
|
|
55
|
+
blockSize: "1rem",
|
|
56
|
+
transition: "rotate 160ms ease",
|
|
57
|
+
},
|
|
58
|
+
"&:focus-visible": {
|
|
59
|
+
outline: "2px solid var(--ui-brand-ring)",
|
|
60
|
+
outlineOffset: "2px",
|
|
61
|
+
borderRadius: "0.25rem",
|
|
62
|
+
},
|
|
63
|
+
[`@media ${WIDE}`]: { display: "none" },
|
|
64
|
+
}),
|
|
65
|
+
motionReduce(raw({ "& [data-chevron]": { transition: "none" } })),
|
|
66
|
+
], children: [_jsx("span", { children: labels.show }), _jsx(ChevronDownIcon, { "aria-hidden": "true", "data-chevron": "" }), _jsx("span", { "data-slot": "order-summary-total", mix: [
|
|
67
|
+
raw({
|
|
68
|
+
marginInlineStart: "auto",
|
|
69
|
+
fontSize: "1rem",
|
|
70
|
+
fontWeight: "700",
|
|
71
|
+
fontVariantNumeric: "tabular-nums",
|
|
72
|
+
color: "var(--ui-neutral-fg-emphasis)",
|
|
73
|
+
}),
|
|
74
|
+
], children: total })] }), body] }));
|
|
75
|
+
};
|
|
76
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An order on its way: the steps from placed to delivered as a timeline whose rows are done,
|
|
3
|
+
* current or still to come, and an island that follows a text stream of progress so the
|
|
4
|
+
* steps, the headline, the arrival estimate and any map marker on the page move live.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { EntryComponent, Handle, Props as TagProps, RemixNode } from "remix/component";
|
|
10
|
+
/** Prop types for {@link OrderSteps} and {@link OrderLive}. */
|
|
11
|
+
export declare namespace OrderSteps {
|
|
12
|
+
/** One step of an order. */
|
|
13
|
+
interface Step {
|
|
14
|
+
/** The id the stream names the step by. */
|
|
15
|
+
id: string;
|
|
16
|
+
label: string;
|
|
17
|
+
/** Under the label in small muted type, such as a date or where the parcel was scanned. */
|
|
18
|
+
detail?: RemixNode;
|
|
19
|
+
}
|
|
20
|
+
/** Props accepted by {@link OrderSteps}; the host is an `<ol>`. */
|
|
21
|
+
interface Props extends Omit<TagProps<"ol">, "children"> {
|
|
22
|
+
steps: Step[];
|
|
23
|
+
/** The id of the step reached; every earlier one is done. */
|
|
24
|
+
current: string;
|
|
25
|
+
}
|
|
26
|
+
/** Props {@link OrderLive} serializes for hydration. */
|
|
27
|
+
type LiveProps = {
|
|
28
|
+
/**
|
|
29
|
+
* A URL answering the order's progress as `text/plain`, one line per update:
|
|
30
|
+
* `<step id> <progress 0–1> <minutes left>`, such as `on-the-way 0.420 9`.
|
|
31
|
+
*/
|
|
32
|
+
src: string;
|
|
33
|
+
/** The id of the element holding the steps, the headline, the estimate and the map. */
|
|
34
|
+
root: string;
|
|
35
|
+
/** The step ids in order; the last one means arrived. */
|
|
36
|
+
steps: string[];
|
|
37
|
+
/** The headline for each step, by step id, written into `[data-order-headline]`. */
|
|
38
|
+
headlines: Record<string, string>;
|
|
39
|
+
/** The words around the estimate. */
|
|
40
|
+
labels: {
|
|
41
|
+
/** Over the estimate while on the way, such as "Arriving in". */
|
|
42
|
+
arriving: string;
|
|
43
|
+
/** Over it once arrived, such as "Delivered". */
|
|
44
|
+
arrived: string;
|
|
45
|
+
/** The estimate once arrived, such as "Arrived". */
|
|
46
|
+
done: string;
|
|
47
|
+
/** The estimate on the way, with `{n}` for the minutes, such as "{n} min". */
|
|
48
|
+
minutes: string;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/** Where a step stands against the step reached. */
|
|
53
|
+
export declare function orderStepState(index: number, reached: number): "done" | "current" | "todo";
|
|
54
|
+
/**
|
|
55
|
+
* Renders the steps as a vertical timeline: a filled dot and rail for each done step, a ring
|
|
56
|
+
* that pulses on the current one, and hollow dots for the rest.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* <OrderSteps current="preparing" steps={[{ id: "placed", label: "Order placed" }, { id: "preparing", label: "Being prepared" }, { id: "delivered", label: "Delivered" }]} />
|
|
60
|
+
*/
|
|
61
|
+
export declare function OrderSteps(handle: Handle<OrderSteps.Props>): () => import("remix/component").RemixElement;
|
|
62
|
+
/** One progress line read back. */
|
|
63
|
+
interface Reading {
|
|
64
|
+
step: string;
|
|
65
|
+
progress: number;
|
|
66
|
+
minutes: number;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Reads one stream line, or `undefined` for one it cannot.
|
|
70
|
+
*
|
|
71
|
+
* @example parseOrderLine("on-the-way 0.420 9", ["on-the-way"]) // { step: "on-the-way", progress: 0.42, minutes: 9 }
|
|
72
|
+
*/
|
|
73
|
+
export declare function parseOrderLine(line: string, steps: string[]): Reading | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* Follows an order's progress stream and draws each line as it lands. A dropped connection
|
|
76
|
+
* is retried after a pause while the order is still on its way, so a phone waking from sleep
|
|
77
|
+
* picks the order back up; it stops once the last step arrives.
|
|
78
|
+
*/
|
|
79
|
+
export declare const OrderLive: EntryComponent<OrderSteps.LiveProps>;
|
|
80
|
+
export {};
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "remix/component/jsx-runtime";
|
|
2
|
+
import { CheckIcon } from "@sdxc/icons";
|
|
3
|
+
import { mergeMix, raw } from "@sdxc/u/general";
|
|
4
|
+
import { motionReduce } from "@sdxc/u/responsive";
|
|
5
|
+
import { clientEntry } from "remix/component";
|
|
6
|
+
/** Where a step stands against the step reached. */
|
|
7
|
+
export function orderStepState(index, reached) {
|
|
8
|
+
if (index < reached)
|
|
9
|
+
return "done";
|
|
10
|
+
return index === reached ? "current" : "todo";
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Renders the steps as a vertical timeline: a filled dot and rail for each done step, a ring
|
|
14
|
+
* that pulses on the current one, and hollow dots for the rest.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* <OrderSteps current="preparing" steps={[{ id: "placed", label: "Order placed" }, { id: "preparing", label: "Being prepared" }, { id: "delivered", label: "Delivered" }]} />
|
|
18
|
+
*/
|
|
19
|
+
export function OrderSteps(handle) {
|
|
20
|
+
return () => {
|
|
21
|
+
let { current, mix, steps, ...rest } = handle.props;
|
|
22
|
+
let reached = Math.max(steps.findIndex((step) => step.id === current), 0);
|
|
23
|
+
return (_jsx("ol", { ...rest, "data-slot": "order-steps", mix: mergeMix([raw({ margin: "0", padding: "0", listStyle: "none" })], mix), children: steps.map((step, index) => {
|
|
24
|
+
let state = orderStepState(index, reached);
|
|
25
|
+
return (_jsxs("li", { "data-order-step": step.id, "data-state": state, "aria-current": state === "current" ? "step" : undefined, mix: [
|
|
26
|
+
raw({
|
|
27
|
+
position: "relative",
|
|
28
|
+
display: "grid",
|
|
29
|
+
gridTemplateColumns: "1.5rem minmax(0, 1fr)",
|
|
30
|
+
gap: "0.875rem",
|
|
31
|
+
paddingBlockEnd: "1.125rem",
|
|
32
|
+
color: "var(--ui-neutral-fg-muted)",
|
|
33
|
+
"&:last-child": { paddingBlockEnd: "0" },
|
|
34
|
+
"&::before": {
|
|
35
|
+
content: '""',
|
|
36
|
+
position: "absolute",
|
|
37
|
+
insetInlineStart: "calc(0.75rem - 1px)",
|
|
38
|
+
insetBlockStart: "1.5rem",
|
|
39
|
+
insetBlockEnd: "0",
|
|
40
|
+
inlineSize: "2px",
|
|
41
|
+
backgroundColor: "var(--ui-neutral-border)",
|
|
42
|
+
},
|
|
43
|
+
"&:last-child::before": { display: "none" },
|
|
44
|
+
"& [data-dot]": {
|
|
45
|
+
display: "grid",
|
|
46
|
+
placeItems: "center",
|
|
47
|
+
inlineSize: "1.5rem",
|
|
48
|
+
blockSize: "1.5rem",
|
|
49
|
+
borderRadius: "999px",
|
|
50
|
+
boxShadow: "inset 0 0 0 2px var(--ui-neutral-border)",
|
|
51
|
+
backgroundColor: "var(--ui-bg-raised, var(--ui-bg))",
|
|
52
|
+
color: "transparent",
|
|
53
|
+
transition: "background-color 300ms ease, box-shadow 300ms ease",
|
|
54
|
+
},
|
|
55
|
+
"&[data-state='done']": { color: "var(--ui-neutral-fg)" },
|
|
56
|
+
"&[data-state='done']::before": { backgroundColor: "var(--ui-color-brand-600)" },
|
|
57
|
+
"&[data-state='done'] [data-dot]": {
|
|
58
|
+
color: "white",
|
|
59
|
+
backgroundColor: "var(--ui-color-brand-600)",
|
|
60
|
+
boxShadow: "none",
|
|
61
|
+
},
|
|
62
|
+
"&[data-state='current']": {
|
|
63
|
+
color: "var(--ui-neutral-fg-emphasis)",
|
|
64
|
+
fontWeight: "700",
|
|
65
|
+
},
|
|
66
|
+
"&[data-state='current'] [data-dot]": {
|
|
67
|
+
boxShadow: "inset 0 0 0 6px var(--ui-color-brand-600)",
|
|
68
|
+
animation: "ui-order-pulse 1.6s ease-out infinite",
|
|
69
|
+
},
|
|
70
|
+
"@keyframes ui-order-pulse": {
|
|
71
|
+
"0%": {
|
|
72
|
+
outline: "0 solid color-mix(in oklch, var(--ui-color-brand-500) 50%, transparent)",
|
|
73
|
+
},
|
|
74
|
+
"100%": { outline: "10px solid transparent" },
|
|
75
|
+
},
|
|
76
|
+
}),
|
|
77
|
+
motionReduce(raw({ "& [data-dot]": { transition: "none", animation: "none !important" } })),
|
|
78
|
+
], children: [_jsx("span", { "data-dot": "", children: _jsx(CheckIcon, { "aria-hidden": "true", size: 13 }) }), step.detail === undefined ? (_jsx("span", { mix: [raw({ alignSelf: "center" })], children: step.label })) : (_jsxs("span", { mix: [raw({ display: "grid", gap: "0.125rem", alignSelf: "center" })], children: [_jsx("span", { children: step.label }), _jsx("span", { "data-slot": "order-step-detail", mix: [
|
|
79
|
+
raw({
|
|
80
|
+
fontSize: "0.8125rem",
|
|
81
|
+
fontWeight: "400",
|
|
82
|
+
color: "var(--ui-neutral-fg-muted)",
|
|
83
|
+
}),
|
|
84
|
+
], children: step.detail })] }))] }));
|
|
85
|
+
}) }));
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Reads one stream line, or `undefined` for one it cannot.
|
|
90
|
+
*
|
|
91
|
+
* @example parseOrderLine("on-the-way 0.420 9", ["on-the-way"]) // { step: "on-the-way", progress: 0.42, minutes: 9 }
|
|
92
|
+
*/
|
|
93
|
+
export function parseOrderLine(line, steps) {
|
|
94
|
+
let [step = "", progress = "", minutes = ""] = line.trim().split(" ");
|
|
95
|
+
let position = Number(progress);
|
|
96
|
+
let left = Number(minutes);
|
|
97
|
+
if (!steps.includes(step) || !Number.isFinite(position) || !Number.isFinite(left))
|
|
98
|
+
return undefined;
|
|
99
|
+
return { step, progress: Math.min(Math.max(position, 0), 1), minutes: left };
|
|
100
|
+
}
|
|
101
|
+
/** Draws one reading into the page. */
|
|
102
|
+
function apply(root, reading, props) {
|
|
103
|
+
let reached = props.steps.indexOf(reading.step);
|
|
104
|
+
for (let row of root.querySelectorAll("[data-order-step]")) {
|
|
105
|
+
let state = orderStepState(props.steps.indexOf(row.dataset.orderStep ?? ""), reached);
|
|
106
|
+
row.dataset.state = state;
|
|
107
|
+
if (state === "current")
|
|
108
|
+
row.setAttribute("aria-current", "step");
|
|
109
|
+
else
|
|
110
|
+
row.removeAttribute("aria-current");
|
|
111
|
+
}
|
|
112
|
+
let arrived = reading.step === props.steps.at(-1);
|
|
113
|
+
let headline = props.headlines[reading.step];
|
|
114
|
+
for (let node of root.querySelectorAll("[data-order-headline]")) {
|
|
115
|
+
if (headline !== undefined && node.textContent !== headline)
|
|
116
|
+
node.textContent = headline;
|
|
117
|
+
}
|
|
118
|
+
for (let node of root.querySelectorAll("[data-order-eta]")) {
|
|
119
|
+
node.textContent = arrived
|
|
120
|
+
? props.labels.done
|
|
121
|
+
: props.labels.minutes.replace("{n}", String(reading.minutes));
|
|
122
|
+
}
|
|
123
|
+
for (let node of root.querySelectorAll("[data-order-eta-label]")) {
|
|
124
|
+
node.textContent = arrived ? props.labels.arrived : props.labels.arriving;
|
|
125
|
+
}
|
|
126
|
+
root.dataset.orderState = reading.step;
|
|
127
|
+
for (let marker of root.querySelectorAll("[data-map-marker]")) {
|
|
128
|
+
marker.style.setProperty("--ui-map-progress", String(reading.progress));
|
|
129
|
+
}
|
|
130
|
+
for (let done of root.querySelectorAll('[data-route-part="done"]')) {
|
|
131
|
+
done.setAttribute("stroke-dasharray", `${reading.progress} 2`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Follows an order's progress stream and draws each line as it lands. A dropped connection
|
|
136
|
+
* is retried after a pause while the order is still on its way, so a phone waking from sleep
|
|
137
|
+
* picks the order back up; it stops once the last step arrives.
|
|
138
|
+
*/
|
|
139
|
+
export const OrderLive = clientEntry("@sdxc/ui/commerce/order-tracker#OrderLive", function OrderLive(handle) {
|
|
140
|
+
/** Reads the stream to its end; resolves whether the order arrived. */
|
|
141
|
+
async function follow(root) {
|
|
142
|
+
let response = await fetch(handle.props.src, { signal: handle.signal, cache: "no-store" });
|
|
143
|
+
if (!response.ok || response.body === null)
|
|
144
|
+
return true;
|
|
145
|
+
let reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
|
|
146
|
+
let buffer = "";
|
|
147
|
+
let arrived = false;
|
|
148
|
+
while (true) {
|
|
149
|
+
let { done, value } = await reader.read();
|
|
150
|
+
if (done)
|
|
151
|
+
break;
|
|
152
|
+
buffer += value;
|
|
153
|
+
let lines = buffer.split("\n");
|
|
154
|
+
buffer = lines.pop() ?? "";
|
|
155
|
+
for (let line of lines) {
|
|
156
|
+
let reading = parseOrderLine(line, handle.props.steps);
|
|
157
|
+
if (reading === undefined)
|
|
158
|
+
continue;
|
|
159
|
+
apply(root, reading, handle.props);
|
|
160
|
+
arrived = reading.step === handle.props.steps.at(-1);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return arrived;
|
|
164
|
+
}
|
|
165
|
+
handle.queueTask(async () => {
|
|
166
|
+
let root = document.getElementById(handle.props.root);
|
|
167
|
+
if (root === null)
|
|
168
|
+
return;
|
|
169
|
+
let target = root;
|
|
170
|
+
for (let attempt = 0; attempt < 5 && !handle.signal.aborted; attempt++) {
|
|
171
|
+
let arrived = await follow(target).catch(() => false);
|
|
172
|
+
if (arrived || handle.signal.aborted)
|
|
173
|
+
return;
|
|
174
|
+
await new Promise((resolve) => setTimeout(resolve, 2000));
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
return () => _jsx("span", { hidden: true, "data-slot": "order-live" });
|
|
178
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A product's price as a shop shows it: the amount, an optional "From" before it, the
|
|
3
|
+
* compare-at price struck through with how much is saved, and the cost of each instalment.
|
|
4
|
+
* Every figure comes from integer minor units, so the line never rounds differently twice.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { Handle } from "remix/component";
|
|
10
|
+
/** Prop types for {@link Price}. */
|
|
11
|
+
export declare namespace Price {
|
|
12
|
+
/** The words around the figures; `{percent}`, `{n}` and `{amount}` are filled in. */
|
|
13
|
+
interface Labels {
|
|
14
|
+
/** Leads a starting price, such as "From". */
|
|
15
|
+
from: string;
|
|
16
|
+
/** Read before the struck-through price by assistive tech, such as "Was". */
|
|
17
|
+
was: string;
|
|
18
|
+
/** The saving tag, such as "Save {percent}%". */
|
|
19
|
+
save: string;
|
|
20
|
+
/** The instalments line, such as "or {n} × {amount}". */
|
|
21
|
+
installments: string;
|
|
22
|
+
}
|
|
23
|
+
/** Props accepted by {@link Price}. */
|
|
24
|
+
interface Props {
|
|
25
|
+
/** The price in the currency's minor units. */
|
|
26
|
+
amount: number;
|
|
27
|
+
/** The ISO 4217 code, such as `USD`. */
|
|
28
|
+
currency: string;
|
|
29
|
+
/** @default "en-US" */
|
|
30
|
+
locale?: string;
|
|
31
|
+
/** The earlier price in minor units; drawn struck through only when above `amount`. */
|
|
32
|
+
compareAt?: number;
|
|
33
|
+
/** Marks `amount` as the lowest of several prices, such as the smallest size. */
|
|
34
|
+
from?: boolean;
|
|
35
|
+
/** Splits the price into this many payments; a line shows the first share when 2 or more. */
|
|
36
|
+
installments?: number;
|
|
37
|
+
/** @default "md" */
|
|
38
|
+
size?: "sm" | "md" | "lg";
|
|
39
|
+
labels?: Partial<Labels>;
|
|
40
|
+
/** Draws the price as a `<span>`, for a price inside a line of text. @default false */
|
|
41
|
+
inline?: boolean;
|
|
42
|
+
id?: string;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Renders the price. A compare-at price at or below `amount` is ignored, so a stale sale
|
|
47
|
+
* price never shows a negative saving.
|
|
48
|
+
*
|
|
49
|
+
* @example <Price amount={4500} currency="USD" compareAt={6000} />
|
|
50
|
+
* @example <Price amount={2900} currency="EUR" locale="de-DE" from installments={4} />
|
|
51
|
+
*/
|
|
52
|
+
export declare function Price(handle: Handle<Price.Props>): () => import("remix/component").RemixElement;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "remix/component/jsx-runtime";
|
|
2
|
+
import { allocate } from "@sdxc/money";
|
|
3
|
+
import { visuallyHidden } from "@sdxc/u/a11y";
|
|
4
|
+
import { raw } from "@sdxc/u/general";
|
|
5
|
+
import { Amount } from "../components/amount.js";
|
|
6
|
+
/** The words a price reads with when `labels` leaves them out. */
|
|
7
|
+
const DEFAULT_LABELS = {
|
|
8
|
+
from: "From",
|
|
9
|
+
was: "Was",
|
|
10
|
+
save: "Save {percent}%",
|
|
11
|
+
installments: "or {n} × {amount}",
|
|
12
|
+
};
|
|
13
|
+
/** The font size of the current amount at each size. */
|
|
14
|
+
const SIZES = { sm: "0.875rem", md: "1rem", lg: "1.5rem" };
|
|
15
|
+
/**
|
|
16
|
+
* Fills each `{name}` in a template with its value, keeping nodes as nodes so an amount
|
|
17
|
+
* stays a `<data>` element inside the sentence.
|
|
18
|
+
*
|
|
19
|
+
* @example fill("or {n} × {amount}", { n: "4", amount: <Amount … /> })
|
|
20
|
+
*/
|
|
21
|
+
function fill(template, values) {
|
|
22
|
+
return template
|
|
23
|
+
.split(/(\{\w+\})/)
|
|
24
|
+
.filter((part) => part !== "")
|
|
25
|
+
.map((part) => {
|
|
26
|
+
let key = /^\{(\w+)\}$/.exec(part)?.[1];
|
|
27
|
+
return key !== undefined && key in values ? values[key] : part;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The whole percent saved going from `compareAt` to `amount`, rounded down so the tag
|
|
32
|
+
* never promises more than the shopper saves.
|
|
33
|
+
*/
|
|
34
|
+
function savedPercent(amount, compareAt) {
|
|
35
|
+
if (compareAt <= 0 || amount >= compareAt)
|
|
36
|
+
return 0;
|
|
37
|
+
return Math.floor(((compareAt - amount) / compareAt) * 100);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Renders the price. A compare-at price at or below `amount` is ignored, so a stale sale
|
|
41
|
+
* price never shows a negative saving.
|
|
42
|
+
*
|
|
43
|
+
* @example <Price amount={4500} currency="USD" compareAt={6000} />
|
|
44
|
+
* @example <Price amount={2900} currency="EUR" locale="de-DE" from installments={4} />
|
|
45
|
+
*/
|
|
46
|
+
export function Price(handle) {
|
|
47
|
+
return () => {
|
|
48
|
+
let { amount, compareAt, currency, from = false, id, inline = false, installments, labels, locale, size = "md", } = handle.props;
|
|
49
|
+
let words = { ...DEFAULT_LABELS, ...labels };
|
|
50
|
+
let percent = compareAt === undefined ? 0 : savedPercent(amount, compareAt);
|
|
51
|
+
let was = compareAt !== undefined && compareAt > amount ? compareAt : undefined;
|
|
52
|
+
let onSale = was !== undefined;
|
|
53
|
+
let parts = installments !== undefined && installments >= 2 ? installments : 0;
|
|
54
|
+
let share = parts === 0 ? 0 : (allocate(amount, parts)[0] ?? 0);
|
|
55
|
+
let content = [
|
|
56
|
+
_jsxs("span", { "data-slot": "price-current", mix: [
|
|
57
|
+
raw({
|
|
58
|
+
fontSize: SIZES[size],
|
|
59
|
+
fontWeight: "650",
|
|
60
|
+
color: onSale
|
|
61
|
+
? "var(--ui-danger-fg, var(--ui-neutral-fg-emphasis))"
|
|
62
|
+
: "var(--ui-neutral-fg-emphasis)",
|
|
63
|
+
}),
|
|
64
|
+
], children: [from ? _jsx("span", { "data-slot": "price-from", children: `${words.from} ` }) : null, _jsx(Amount, { value: amount, currency: currency, locale: locale })] }),
|
|
65
|
+
was !== undefined ? (_jsxs("s", { "data-slot": "price-compare", mix: [
|
|
66
|
+
raw({
|
|
67
|
+
fontSize: size === "lg" ? "1rem" : "0.875em",
|
|
68
|
+
color: "var(--ui-neutral-fg-muted)",
|
|
69
|
+
}),
|
|
70
|
+
], children: [_jsx("span", { mix: [visuallyHidden()], children: `${words.was} ` }), _jsx(Amount, { value: was, currency: currency, locale: locale })] })) : null,
|
|
71
|
+
onSale && percent > 0 ? (_jsx("span", { "data-slot": "price-save", mix: [
|
|
72
|
+
raw({
|
|
73
|
+
alignSelf: "center",
|
|
74
|
+
paddingInline: "0.4375rem",
|
|
75
|
+
paddingBlock: "0.0625rem",
|
|
76
|
+
borderRadius: "999px",
|
|
77
|
+
fontSize: "0.75rem",
|
|
78
|
+
fontWeight: "650",
|
|
79
|
+
lineHeight: "1.4",
|
|
80
|
+
color: "var(--ui-success-fg, var(--ui-neutral-fg-emphasis))",
|
|
81
|
+
backgroundColor: "var(--ui-success-bg-tint, var(--ui-neutral-bg-tint))",
|
|
82
|
+
}),
|
|
83
|
+
], children: fill(words.save, { percent: String(percent) }) })) : null,
|
|
84
|
+
parts === 0 ? null : (_jsx("span", { "data-slot": "price-installments", mix: [
|
|
85
|
+
raw({
|
|
86
|
+
flexBasis: "100%",
|
|
87
|
+
fontSize: "0.8125rem",
|
|
88
|
+
color: "var(--ui-neutral-fg-muted)",
|
|
89
|
+
}),
|
|
90
|
+
], children: fill(words.installments, {
|
|
91
|
+
n: String(parts),
|
|
92
|
+
amount: _jsx(Amount, { value: share, currency: currency, locale: locale }),
|
|
93
|
+
}) })),
|
|
94
|
+
];
|
|
95
|
+
let styles = [
|
|
96
|
+
raw({
|
|
97
|
+
display: inline ? "inline-flex" : "flex",
|
|
98
|
+
flexWrap: "wrap",
|
|
99
|
+
alignItems: "baseline",
|
|
100
|
+
columnGap: "0.5rem",
|
|
101
|
+
rowGap: "0.125rem",
|
|
102
|
+
margin: "0",
|
|
103
|
+
fontVariantNumeric: "tabular-nums",
|
|
104
|
+
}),
|
|
105
|
+
];
|
|
106
|
+
return inline ? (_jsx("span", { id: id, "data-slot": "price", "data-size": size, mix: styles, children: content })) : (_jsx("p", { id: id, "data-slot": "price", "data-size": size, mix: styles, children: content }));
|
|
107
|
+
};
|
|
108
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A product in a shop's grid: its picture at a fixed ratio, the title, a subtitle, the price
|
|
3
|
+
* and the colours it comes in. The title's link covers the whole card, so the card is one
|
|
4
|
+
* tab stop, while a control such as a wishlist button sits above it at the picture's corner.
|
|
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 ProductCard}. */
|
|
11
|
+
export declare namespace ProductCard {
|
|
12
|
+
/** One colour the product comes in. */
|
|
13
|
+
interface Swatch {
|
|
14
|
+
name: string;
|
|
15
|
+
/** Any CSS colour or gradient. */
|
|
16
|
+
color: string;
|
|
17
|
+
}
|
|
18
|
+
/** Props accepted by {@link ProductCard}; the host is an `<article>`. */
|
|
19
|
+
interface Props extends Omit<TagProps<"article">, "children" | "title"> {
|
|
20
|
+
/** The product's page; the title links there and the link covers the card. */
|
|
21
|
+
href: string;
|
|
22
|
+
title: RemixNode;
|
|
23
|
+
/** A line under the title, such as the artist or the material. */
|
|
24
|
+
subtitle?: RemixNode;
|
|
25
|
+
media: RemixNode;
|
|
26
|
+
/** A second picture the card crossfades to on hover and focus, such as the poster framed. */
|
|
27
|
+
hoverMedia?: RemixNode;
|
|
28
|
+
/** The colour behind the picture. */
|
|
29
|
+
mediaBackground?: string;
|
|
30
|
+
/** The picture's aspect ratio. @default "4 / 5" */
|
|
31
|
+
ratio?: string;
|
|
32
|
+
/** The price, such as a {@link Price}. */
|
|
33
|
+
price: RemixNode;
|
|
34
|
+
/** Tags over the picture's top-start corner, such as "New" or "Sale". */
|
|
35
|
+
badges?: RemixNode;
|
|
36
|
+
/** The colours the product comes in; five dots show, then "+N". */
|
|
37
|
+
swatches?: Swatch[];
|
|
38
|
+
/** The swatch list's accessible name. @default "Colours" */
|
|
39
|
+
swatchesLabel?: string;
|
|
40
|
+
/** A control over the picture's top-end corner, such as a wishlist form; it stays clickable. */
|
|
41
|
+
action?: RemixNode;
|
|
42
|
+
/** The title's heading level. @default 3 */
|
|
43
|
+
headingLevel?: 2 | 3 | 4;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Renders the card. The title link's `::after` fills the article, so a click anywhere opens
|
|
48
|
+
* the product, and `badges` and `action` sit on a layer above it to stay reachable.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* <ProductCard href="/posters/dune" title="Dune at dusk" subtitle="Ana Ortiz" media={<img src="/dune.jpg" alt="" />} price={<Price amount={4500} currency="USD" />} swatches={[{ name: "Oak", color: "#b58a5a" }]} />
|
|
52
|
+
*/
|
|
53
|
+
export declare function ProductCard(handle: Handle<ProductCard.Props>): () => import("remix/component").RemixElement;
|