@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,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Markdown edits a chat composer's formatting controls make: wrapping a selection in
|
|
3
|
+
* inline markers, a code fence or a link, and prefixing lines as a quote or a list. Pure
|
|
4
|
+
* text in, text and selection out, so every edit is testable without a field.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
/** The marker each inline action writes on both sides of the selection. */
|
|
10
|
+
const INLINE_MARKERS = { bold: "**", italic: "_", strike: "~~", code: "`" };
|
|
11
|
+
/** The prefix each line action writes at the start of every selected line. */
|
|
12
|
+
const LINE_PREFIXES = { quote: "> ", list: "- " };
|
|
13
|
+
/** The fence a multi-line code selection is wrapped in. */
|
|
14
|
+
const FENCE = "```";
|
|
15
|
+
/** The placeholder a new link points to, selected so typing replaces it. */
|
|
16
|
+
const LINK_PLACEHOLDER = "url";
|
|
17
|
+
/**
|
|
18
|
+
* Applies a Markdown format to `start`–`end` of `value`. Applying an action to text it already
|
|
19
|
+
* formats removes the format, so each button toggles; an empty selection writes the markers
|
|
20
|
+
* with the caret between them.
|
|
21
|
+
*
|
|
22
|
+
* @param value The field's text.
|
|
23
|
+
* @param start The selection's start.
|
|
24
|
+
* @param end The selection's end.
|
|
25
|
+
* @param action The format to apply.
|
|
26
|
+
* @returns The new text and the range to select in it.
|
|
27
|
+
* @example applyFormat("hi there", 3, 8, "bold") // { value: "hi **there**", start: 5, end: 10 }
|
|
28
|
+
* @example applyFormat("a\nb", 0, 3, "list") // { value: "- a\n- b", start: 0, end: 7 }
|
|
29
|
+
*/
|
|
30
|
+
export function applyFormat(value, start, end, action) {
|
|
31
|
+
let from = Math.max(0, Math.min(start, end, value.length));
|
|
32
|
+
let to = Math.min(value.length, Math.max(start, end));
|
|
33
|
+
if (action === "quote" || action === "list") {
|
|
34
|
+
return prefixLines(value, from, to, LINE_PREFIXES[action]);
|
|
35
|
+
}
|
|
36
|
+
if (action === "link")
|
|
37
|
+
return link(value, from, to);
|
|
38
|
+
if (action === "code" && value.slice(from, to).trimEnd().includes("\n")) {
|
|
39
|
+
return fence(value, from, to);
|
|
40
|
+
}
|
|
41
|
+
return wrap(value, from, to, INLINE_MARKERS[action]);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Wraps the selection in `marker`, or unwraps it when the markers already sit inside or just
|
|
45
|
+
* outside it. Whitespace at the selection's edges stays outside the markers, where Markdown
|
|
46
|
+
* expects it.
|
|
47
|
+
*/
|
|
48
|
+
function wrap(value, start, end, marker) {
|
|
49
|
+
let size = marker.length;
|
|
50
|
+
let selected = value.slice(start, end);
|
|
51
|
+
if (selected.length >= size * 2 && selected.startsWith(marker) && selected.endsWith(marker)) {
|
|
52
|
+
let inner = selected.slice(size, -size);
|
|
53
|
+
return {
|
|
54
|
+
value: value.slice(0, start) + inner + value.slice(end),
|
|
55
|
+
start,
|
|
56
|
+
end: start + inner.length,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
if (start >= size &&
|
|
60
|
+
value.slice(start - size, start) === marker &&
|
|
61
|
+
value.slice(end, end + size) === marker) {
|
|
62
|
+
return {
|
|
63
|
+
value: value.slice(0, start - size) + selected + value.slice(end + size),
|
|
64
|
+
start: start - size,
|
|
65
|
+
end: end - size,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
let core = selected.trim();
|
|
69
|
+
let from = core === "" ? start : start + selected.indexOf(core);
|
|
70
|
+
let to = core === "" ? end : from + core.length;
|
|
71
|
+
return {
|
|
72
|
+
value: value.slice(0, from) + marker + value.slice(from, to) + marker + value.slice(to),
|
|
73
|
+
start: from + size,
|
|
74
|
+
end: to + size,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Wraps a multi-line selection in a code fence on lines of its own, or removes the fence
|
|
79
|
+
* the selection is already wrapped in.
|
|
80
|
+
*/
|
|
81
|
+
function fence(value, start, end) {
|
|
82
|
+
let to = value.slice(start, end).endsWith("\n") ? end - 1 : end;
|
|
83
|
+
let selected = value.slice(start, to);
|
|
84
|
+
let open = `${FENCE}\n`;
|
|
85
|
+
let close = `\n${FENCE}`;
|
|
86
|
+
if (selected.startsWith(open) && selected.endsWith(close) && selected.length >= 8) {
|
|
87
|
+
let inner = selected.slice(open.length, -close.length);
|
|
88
|
+
return {
|
|
89
|
+
value: value.slice(0, start) + inner + value.slice(to),
|
|
90
|
+
start,
|
|
91
|
+
end: start + inner.length,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
if (value.slice(start - open.length, start) === open &&
|
|
95
|
+
value.slice(to, to + close.length) === close) {
|
|
96
|
+
return {
|
|
97
|
+
value: value.slice(0, start - open.length) + selected + value.slice(to + close.length),
|
|
98
|
+
start: start - open.length,
|
|
99
|
+
end: to - open.length,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
let before = start > 0 && value[start - 1] !== "\n" ? `\n${open}` : open;
|
|
103
|
+
let after = to < value.length && value[to] !== "\n" ? `${close}\n` : close;
|
|
104
|
+
return {
|
|
105
|
+
value: value.slice(0, start) + before + selected + after + value.slice(to),
|
|
106
|
+
start: start + before.length,
|
|
107
|
+
end: start + before.length + selected.length,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Turns the selection into a link's text and selects the placeholder address, or turns a
|
|
112
|
+
* selected `[text](address)` back into its text.
|
|
113
|
+
*/
|
|
114
|
+
function link(value, start, end) {
|
|
115
|
+
let selected = value.slice(start, end);
|
|
116
|
+
let existing = /^\[([^\]]*)\]\(([^)]*)\)$/.exec(selected);
|
|
117
|
+
if (existing) {
|
|
118
|
+
let text = existing[1] ?? "";
|
|
119
|
+
return {
|
|
120
|
+
value: value.slice(0, start) + text + value.slice(end),
|
|
121
|
+
start,
|
|
122
|
+
end: start + text.length,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
let address = start + selected.length + 3;
|
|
126
|
+
return {
|
|
127
|
+
value: `${value.slice(0, start)}[${selected}](${LINK_PLACEHOLDER})${value.slice(end)}`,
|
|
128
|
+
start: address,
|
|
129
|
+
end: address + LINK_PLACEHOLDER.length,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Writes `prefix` before every line the selection touches, or removes it when every one of
|
|
134
|
+
* them already starts with it. A caret keeps its place in its line's text; a range selects
|
|
135
|
+
* the whole block, so pressing again toggles the same lines.
|
|
136
|
+
*/
|
|
137
|
+
function prefixLines(value, start, end, prefix) {
|
|
138
|
+
let lineStart = value.lastIndexOf("\n", start - 1) + 1;
|
|
139
|
+
let blockEnd = end > start && value[end - 1] === "\n" ? end - 1 : end;
|
|
140
|
+
let found = value.indexOf("\n", blockEnd);
|
|
141
|
+
let lineEnd = found === -1 ? value.length : found;
|
|
142
|
+
let lines = value.slice(lineStart, lineEnd).split("\n");
|
|
143
|
+
let bare = prefix.trimEnd();
|
|
144
|
+
let prefixed = lines.every((line) => line.startsWith(prefix) || line === bare);
|
|
145
|
+
let next = lines.map((line) => {
|
|
146
|
+
if (!prefixed)
|
|
147
|
+
return line.startsWith(prefix) ? line : prefix + line;
|
|
148
|
+
return line.startsWith(prefix) ? line.slice(prefix.length) : "";
|
|
149
|
+
});
|
|
150
|
+
let block = next.join("\n");
|
|
151
|
+
let result = value.slice(0, lineStart) + block + value.slice(lineEnd);
|
|
152
|
+
if (start === end) {
|
|
153
|
+
let shift = (next[0]?.length ?? 0) - (lines[0]?.length ?? 0);
|
|
154
|
+
let caret = Math.max(lineStart, start + shift);
|
|
155
|
+
return { value: result, start: caret, end: caret };
|
|
156
|
+
}
|
|
157
|
+
return { value: result, start: lineStart, end: lineStart + block.length };
|
|
158
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads a mention out of a composer's text: whether the caret sits in an `@handle` being
|
|
3
|
+
* typed, and which people it names. Pure text in, matches out, so the menu's rules are
|
|
4
|
+
* testable without a field.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Someone a mention can name. Plain data, since the list crosses into the browser with
|
|
11
|
+
* the menu's island.
|
|
12
|
+
*/
|
|
13
|
+
export type MentionPerson = {
|
|
14
|
+
/** Stable across renders; the option's `id` is built from it. */
|
|
15
|
+
id: string;
|
|
16
|
+
/** Written after the trigger when picked, such as `ana` for `@ana`. */
|
|
17
|
+
handle: string;
|
|
18
|
+
name: string;
|
|
19
|
+
/** A short muted line beside the handle, such as a role or a status. */
|
|
20
|
+
detail?: string;
|
|
21
|
+
/** One or two letters shown in the tile before the name. */
|
|
22
|
+
initials: string;
|
|
23
|
+
/** Any CSS color the tile fills with; a neutral tint when omitted. */
|
|
24
|
+
color?: string;
|
|
25
|
+
};
|
|
26
|
+
/** Where a mention being typed starts, and what has been typed after its trigger. */
|
|
27
|
+
export interface MentionQuery {
|
|
28
|
+
/** The index of the trigger character. */
|
|
29
|
+
start: number;
|
|
30
|
+
/** The text between the trigger and the caret, empty right after the trigger. */
|
|
31
|
+
query: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The mention the caret is in, when it sits right after a trigger and handle characters and
|
|
35
|
+
* that trigger starts a word, so an email address or a trigger mid-word opens nothing.
|
|
36
|
+
*
|
|
37
|
+
* @param text The field's text.
|
|
38
|
+
* @param caret The caret's index in it.
|
|
39
|
+
* @param trigger The character that starts a mention.
|
|
40
|
+
* @returns Where the mention starts and its query, or `null` when the caret is in none.
|
|
41
|
+
* @example mentionQuery("ping @an", 8) // { start: 5, query: "an" }
|
|
42
|
+
* @example mentionQuery("me@host", 7) // null
|
|
43
|
+
*/
|
|
44
|
+
export declare function mentionQuery(text: string, caret: number, trigger?: string): MentionQuery | null;
|
|
45
|
+
/**
|
|
46
|
+
* The people a query names, at most `limit` of them: first those whose handle or a word of
|
|
47
|
+
* whose name starts with it, then those holding it anywhere, each group in the list's order
|
|
48
|
+
* and ignoring case. An empty query lists the first `limit` people.
|
|
49
|
+
*
|
|
50
|
+
* @param people Everyone who can be mentioned.
|
|
51
|
+
* @param query What has been typed after the trigger.
|
|
52
|
+
* @param limit How many matches to return.
|
|
53
|
+
* @returns The matches, best first.
|
|
54
|
+
*/
|
|
55
|
+
export declare function mentionMatches(people: readonly MentionPerson[], query: string, limit: number): MentionPerson[];
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads a mention out of a composer's text: whether the caret sits in an `@handle` being
|
|
3
|
+
* typed, and which people it names. Pure text in, matches out, so the menu's rules are
|
|
4
|
+
* testable without a field.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
/** A character a handle may hold: letters and digits in any script, `_`, `.` and `-`. */
|
|
10
|
+
const HANDLE_CHARACTER = /[\p{L}\p{N}_.-]/u;
|
|
11
|
+
/**
|
|
12
|
+
* The mention the caret is in, when it sits right after a trigger and handle characters and
|
|
13
|
+
* that trigger starts a word, so an email address or a trigger mid-word opens nothing.
|
|
14
|
+
*
|
|
15
|
+
* @param text The field's text.
|
|
16
|
+
* @param caret The caret's index in it.
|
|
17
|
+
* @param trigger The character that starts a mention.
|
|
18
|
+
* @returns Where the mention starts and its query, or `null` when the caret is in none.
|
|
19
|
+
* @example mentionQuery("ping @an", 8) // { start: 5, query: "an" }
|
|
20
|
+
* @example mentionQuery("me@host", 7) // null
|
|
21
|
+
*/
|
|
22
|
+
export function mentionQuery(text, caret, trigger = "@") {
|
|
23
|
+
let index = Math.min(caret, text.length);
|
|
24
|
+
while (index > 0 && HANDLE_CHARACTER.test(text[index - 1] ?? ""))
|
|
25
|
+
index -= 1;
|
|
26
|
+
let start = index - trigger.length;
|
|
27
|
+
if (start < 0 || text.slice(start, index) !== trigger)
|
|
28
|
+
return null;
|
|
29
|
+
let before = text[start - 1];
|
|
30
|
+
if (before !== undefined && !/\s/.test(before))
|
|
31
|
+
return null;
|
|
32
|
+
return { start, query: text.slice(index, caret) };
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The people a query names, at most `limit` of them: first those whose handle or a word of
|
|
36
|
+
* whose name starts with it, then those holding it anywhere, each group in the list's order
|
|
37
|
+
* and ignoring case. An empty query lists the first `limit` people.
|
|
38
|
+
*
|
|
39
|
+
* @param people Everyone who can be mentioned.
|
|
40
|
+
* @param query What has been typed after the trigger.
|
|
41
|
+
* @param limit How many matches to return.
|
|
42
|
+
* @returns The matches, best first.
|
|
43
|
+
*/
|
|
44
|
+
export function mentionMatches(people, query, limit) {
|
|
45
|
+
let needle = query.toLowerCase();
|
|
46
|
+
let prefixed = [];
|
|
47
|
+
let contained = [];
|
|
48
|
+
for (let person of people) {
|
|
49
|
+
let handle = person.handle.toLowerCase();
|
|
50
|
+
let name = person.name.toLowerCase();
|
|
51
|
+
let words = name.split(/\s+/);
|
|
52
|
+
if (handle.startsWith(needle) || words.some((word) => word.startsWith(needle))) {
|
|
53
|
+
prefixed.push(person);
|
|
54
|
+
}
|
|
55
|
+
else if (handle.includes(needle) || name.includes(needle)) {
|
|
56
|
+
contained.push(person);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return [...prefixed, ...contained].slice(0, Math.max(0, limit));
|
|
60
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The bag a shop slides in from the side: the lines, a note such as a free-shipping meter, the
|
|
3
|
+
* subtotal and the way to checkout, in a drawer the header's bag link opens. The link goes to
|
|
4
|
+
* the cart page without script, and opens the drawer in place once the page has hydrated.
|
|
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 CartDrawer} and {@link CartDrawer.Trigger}. */
|
|
11
|
+
export declare namespace CartDrawer {
|
|
12
|
+
/** The words the drawer's controls carry. */
|
|
13
|
+
interface Labels {
|
|
14
|
+
checkout: string;
|
|
15
|
+
viewCart: string;
|
|
16
|
+
/** The close button's name. */
|
|
17
|
+
close: string;
|
|
18
|
+
}
|
|
19
|
+
/** Props accepted by {@link CartDrawer}; the host is the drawer's `<dialog>`. */
|
|
20
|
+
interface Props {
|
|
21
|
+
/** The dialog's id, which {@link CartDrawer.Trigger} names as its `drawer`. */
|
|
22
|
+
id: string;
|
|
23
|
+
title: RemixNode;
|
|
24
|
+
/** The lines, usually a `<ul>` of `CartLine`; leave it out for an empty bag. */
|
|
25
|
+
children?: RemixNode;
|
|
26
|
+
/** Shown in place of the lines, subtotal and checkout when the bag is empty. */
|
|
27
|
+
empty?: RemixNode;
|
|
28
|
+
/** The subtotal as the reader sees it, set beside its own label by the caller. */
|
|
29
|
+
subtotal: RemixNode;
|
|
30
|
+
/** Above the subtotal, such as a free-shipping meter. */
|
|
31
|
+
note?: RemixNode;
|
|
32
|
+
checkoutHref: string;
|
|
33
|
+
cartHref: string;
|
|
34
|
+
labels: Labels;
|
|
35
|
+
}
|
|
36
|
+
/** Props accepted by {@link CartDrawer.Trigger}; the host is an `<a>` named by `label` and `count`. */
|
|
37
|
+
interface TriggerProps extends Pick<TagProps<"a">, "id" | "mix" | "title"> {
|
|
38
|
+
/** The id of the {@link CartDrawer} it opens. */
|
|
39
|
+
drawer: string;
|
|
40
|
+
/** The cart page, followed when the drawer is absent or the page has no script. */
|
|
41
|
+
href: string;
|
|
42
|
+
/** How many items the bag holds; the badge hides at zero. */
|
|
43
|
+
count: number;
|
|
44
|
+
/** The link's name, such as "Bag"; the count is appended for assistive tech. */
|
|
45
|
+
label: string;
|
|
46
|
+
/** Appended to the name with `{n}` for the count. @default "{n} items" */
|
|
47
|
+
countLabel?: string;
|
|
48
|
+
}
|
|
49
|
+
/** Props {@link CartDrawerLive} serializes for hydration. */
|
|
50
|
+
type LiveProps = Record<never, never>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Opens the drawer a bag link names instead of following it. One listener on the document
|
|
54
|
+
* serves every bag link on the page, and a click another listener already took is left alone,
|
|
55
|
+
* so several triggers never open the drawer twice. A link whose drawer is missing navigates.
|
|
56
|
+
*/
|
|
57
|
+
export declare const CartDrawerLive: EntryComponent<CartDrawer.LiveProps>;
|
|
58
|
+
/**
|
|
59
|
+
* Renders the drawer docked to the right edge: the title and close button, the lines
|
|
60
|
+
* scrolling between them and a footer holding the note, the subtotal, a full-width checkout
|
|
61
|
+
* link and a link to the cart page. An empty bag shows `empty` alone.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* <CartDrawer id="bag" title="Your bag" subtotal={<Amount value={4800} currency="EUR" />} checkoutHref="/checkout" cartHref="/cart" labels={{ checkout: "Checkout", viewCart: "View bag", close: "Close" }}><ul>…</ul></CartDrawer>
|
|
65
|
+
*/
|
|
66
|
+
export declare function CartDrawer(handle: Handle<CartDrawer.Props>): () => import("remix/component").RemixElement;
|
|
67
|
+
export declare namespace CartDrawer {
|
|
68
|
+
var Trigger: (handle: Handle<CartDrawer.TriggerProps>) => () => import("remix/component").RemixElement;
|
|
69
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "remix/component/jsx-runtime";
|
|
2
|
+
import { ShoppingBagIcon } from "@sdxc/icons";
|
|
3
|
+
import { mergeMix, raw } from "@sdxc/u/general";
|
|
4
|
+
import { clientEntry } from "remix/component";
|
|
5
|
+
import { Drawer } from "../components/drawer.js";
|
|
6
|
+
import { LinkButton } from "../components/link-button.js";
|
|
7
|
+
/** Whether a click asks for the link's page somewhere else: a new tab, window or download. */
|
|
8
|
+
function opensElsewhere(event, link) {
|
|
9
|
+
return (event.button !== 0 ||
|
|
10
|
+
event.metaKey ||
|
|
11
|
+
event.ctrlKey ||
|
|
12
|
+
event.shiftKey ||
|
|
13
|
+
event.altKey ||
|
|
14
|
+
(link.target !== "" && link.target !== "_self"));
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Opens the drawer a bag link names instead of following it. One listener on the document
|
|
18
|
+
* serves every bag link on the page, and a click another listener already took is left alone,
|
|
19
|
+
* so several triggers never open the drawer twice. A link whose drawer is missing navigates.
|
|
20
|
+
*/
|
|
21
|
+
export const CartDrawerLive = clientEntry("@sdxc/ui/commerce/cart-drawer#CartDrawerLive", function CartDrawerLive(handle) {
|
|
22
|
+
handle.queueTask(() => {
|
|
23
|
+
if (handle.signal.aborted)
|
|
24
|
+
return;
|
|
25
|
+
document.addEventListener("click", (event) => {
|
|
26
|
+
if (event.defaultPrevented || !(event.target instanceof Element))
|
|
27
|
+
return;
|
|
28
|
+
let link = event.target.closest("a[data-cart-drawer]");
|
|
29
|
+
if (link === null || opensElsewhere(event, link))
|
|
30
|
+
return;
|
|
31
|
+
let dialog = document.getElementById(link.dataset.cartDrawer ?? "");
|
|
32
|
+
if (!(dialog instanceof HTMLDialogElement))
|
|
33
|
+
return;
|
|
34
|
+
event.preventDefault();
|
|
35
|
+
if (!dialog.open)
|
|
36
|
+
dialog.showModal();
|
|
37
|
+
}, { signal: handle.signal });
|
|
38
|
+
});
|
|
39
|
+
return () => _jsx("span", { hidden: true, "data-slot": "cart-drawer-live" });
|
|
40
|
+
});
|
|
41
|
+
/**
|
|
42
|
+
* Renders the drawer docked to the right edge: the title and close button, the lines
|
|
43
|
+
* scrolling between them and a footer holding the note, the subtotal, a full-width checkout
|
|
44
|
+
* link and a link to the cart page. An empty bag shows `empty` alone.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* <CartDrawer id="bag" title="Your bag" subtotal={<Amount value={4800} currency="EUR" />} checkoutHref="/checkout" cartHref="/cart" labels={{ checkout: "Checkout", viewCart: "View bag", close: "Close" }}><ul>…</ul></CartDrawer>
|
|
48
|
+
*/
|
|
49
|
+
export function CartDrawer(handle) {
|
|
50
|
+
return () => {
|
|
51
|
+
let { cartHref, checkoutHref, children, empty, id, labels, note, subtotal, title } = handle.props;
|
|
52
|
+
let titleId = `${id}-title`;
|
|
53
|
+
let isEmpty = children === undefined ||
|
|
54
|
+
children === null ||
|
|
55
|
+
children === false ||
|
|
56
|
+
(Array.isArray(children) && children.length === 0);
|
|
57
|
+
return (_jsxs(Drawer, { id: id, placement: "right", closedby: "any", "aria-labelledby": titleId, "data-cart-drawer-panel": "", mix: [
|
|
58
|
+
raw({
|
|
59
|
+
inlineSize: "min(26rem, 100vw)",
|
|
60
|
+
maxInlineSize: "100vw",
|
|
61
|
+
gap: "0",
|
|
62
|
+
padding: "0",
|
|
63
|
+
}),
|
|
64
|
+
], children: [_jsx(Drawer.Header, { mix: [
|
|
65
|
+
raw({
|
|
66
|
+
paddingBlock: "1.25rem 1rem",
|
|
67
|
+
paddingInline: "1.25rem 3.5rem",
|
|
68
|
+
textAlign: "start",
|
|
69
|
+
borderBlockEnd: "1px solid var(--ui-neutral-border)",
|
|
70
|
+
}),
|
|
71
|
+
], children: _jsx(Drawer.Title, { id: titleId, children: title }) }), _jsx(Drawer.Close, { commandfor: id, "aria-label": labels.close }), _jsx("div", { "data-slot": "cart-drawer-lines", mix: [
|
|
72
|
+
raw({
|
|
73
|
+
flex: "1 1 auto",
|
|
74
|
+
minBlockSize: "0",
|
|
75
|
+
overflowY: "auto",
|
|
76
|
+
overscrollBehavior: "contain",
|
|
77
|
+
paddingInline: "1.25rem",
|
|
78
|
+
"& > ul": { margin: "0", padding: "0", listStyle: "none" },
|
|
79
|
+
}),
|
|
80
|
+
], children: isEmpty ? (_jsx("div", { "data-slot": "cart-drawer-empty", mix: [
|
|
81
|
+
raw({
|
|
82
|
+
paddingBlock: "2.5rem",
|
|
83
|
+
textAlign: "center",
|
|
84
|
+
color: "var(--ui-neutral-fg-muted)",
|
|
85
|
+
}),
|
|
86
|
+
], children: empty })) : (children) }), isEmpty ? null : (_jsxs("div", { "data-slot": "cart-drawer-footer", mix: [
|
|
87
|
+
raw({
|
|
88
|
+
display: "grid",
|
|
89
|
+
gap: "0.75rem",
|
|
90
|
+
padding: "1rem 1.25rem 1.25rem",
|
|
91
|
+
borderBlockStart: "1px solid var(--ui-neutral-border)",
|
|
92
|
+
backgroundColor: "var(--ui-neutral-bg-tint, transparent)",
|
|
93
|
+
}),
|
|
94
|
+
], children: [note === undefined ? null : _jsx("div", { "data-slot": "cart-drawer-note", children: note }), _jsx("div", { "data-slot": "cart-drawer-subtotal", mix: [
|
|
95
|
+
raw({
|
|
96
|
+
display: "flex",
|
|
97
|
+
justifyContent: "space-between",
|
|
98
|
+
alignItems: "baseline",
|
|
99
|
+
gap: "1rem",
|
|
100
|
+
fontWeight: "650",
|
|
101
|
+
color: "var(--ui-neutral-fg-emphasis)",
|
|
102
|
+
fontVariantNumeric: "tabular-nums",
|
|
103
|
+
}),
|
|
104
|
+
], children: subtotal }), _jsx(LinkButton, { href: checkoutHref, size: "lg", mix: [raw({ inlineSize: "100%" })], children: labels.checkout }), _jsx("a", { href: cartHref, mix: [
|
|
105
|
+
raw({
|
|
106
|
+
justifySelf: "center",
|
|
107
|
+
fontSize: "0.875rem",
|
|
108
|
+
color: "var(--ui-neutral-fg)",
|
|
109
|
+
textDecoration: "underline",
|
|
110
|
+
textUnderlineOffset: "0.2em",
|
|
111
|
+
}),
|
|
112
|
+
], children: labels.viewCart })] }))] }));
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Renders the header's bag link: an icon with a count badge, named "Bag, 2 items" for
|
|
117
|
+
* assistive tech. It follows `href` until {@link CartDrawerLive} runs, then opens the drawer
|
|
118
|
+
* in place when that drawer is on the page.
|
|
119
|
+
*
|
|
120
|
+
* @example <CartDrawer.Trigger drawer="bag" href="/cart" count={2} label="Bag" />
|
|
121
|
+
*/
|
|
122
|
+
CartDrawer.Trigger = function CartDrawerTrigger(handle) {
|
|
123
|
+
return () => {
|
|
124
|
+
let { count, countLabel = "{n} items", drawer, href, label, mix, ...rest } = handle.props;
|
|
125
|
+
let name = `${label}, ${countLabel.replace("{n}", String(count))}`;
|
|
126
|
+
return (_jsxs(_Fragment, { children: [_jsxs("a", { ...rest, href: href, "aria-label": name, "aria-haspopup": "dialog", "data-cart-drawer": drawer, "data-slot": "cart-drawer-trigger", mix: mergeMix([
|
|
127
|
+
raw({
|
|
128
|
+
position: "relative",
|
|
129
|
+
display: "inline-grid",
|
|
130
|
+
placeItems: "center",
|
|
131
|
+
inlineSize: "2.75rem",
|
|
132
|
+
blockSize: "2.75rem",
|
|
133
|
+
borderRadius: "999px",
|
|
134
|
+
color: "var(--ui-neutral-fg-emphasis)",
|
|
135
|
+
"& > svg": { inlineSize: "1.375rem", blockSize: "1.375rem" },
|
|
136
|
+
"&:hover": { backgroundColor: "var(--ui-neutral-bg-tint-hover)" },
|
|
137
|
+
"&:focus-visible": {
|
|
138
|
+
outline: "2px solid var(--ui-brand-ring)",
|
|
139
|
+
outlineOffset: "2px",
|
|
140
|
+
},
|
|
141
|
+
}),
|
|
142
|
+
], mix), children: [_jsx(ShoppingBagIcon, { "aria-hidden": "true" }), count > 0 ? (_jsx("span", { "data-slot": "cart-drawer-count", "aria-hidden": "true", mix: [
|
|
143
|
+
raw({
|
|
144
|
+
position: "absolute",
|
|
145
|
+
insetBlockStart: "0.125rem",
|
|
146
|
+
insetInlineEnd: "0.0625rem",
|
|
147
|
+
minInlineSize: "1.125rem",
|
|
148
|
+
blockSize: "1.125rem",
|
|
149
|
+
paddingInline: "0.3125rem",
|
|
150
|
+
boxSizing: "border-box",
|
|
151
|
+
borderRadius: "999px",
|
|
152
|
+
display: "grid",
|
|
153
|
+
placeItems: "center",
|
|
154
|
+
fontSize: "0.6875rem",
|
|
155
|
+
fontWeight: "700",
|
|
156
|
+
lineHeight: "1",
|
|
157
|
+
fontVariantNumeric: "tabular-nums",
|
|
158
|
+
color: "var(--ui-brand-fg-on-solid)",
|
|
159
|
+
backgroundColor: "var(--ui-brand-bg-solid)",
|
|
160
|
+
}),
|
|
161
|
+
], children: count > 99 ? "99+" : String(count) })) : null] }), _jsx(CartDrawerLive, {})] }));
|
|
162
|
+
};
|
|
163
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One line of a cart or an order: a small picture, the item's name, the picks that made it
|
|
3
|
+
* and its price, with room at the end for a control such as a quantity stepper. Lines sit in
|
|
4
|
+
* a list separated by hairlines.
|
|
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 CartLine}. */
|
|
11
|
+
export declare namespace CartLine {
|
|
12
|
+
/** Props accepted by {@link CartLine}; the host is an `<li>`. */
|
|
13
|
+
interface Props extends Omit<TagProps<"li">, "children"> {
|
|
14
|
+
name: RemixNode;
|
|
15
|
+
/** The picks, such as "Blue corn · Guacamole". */
|
|
16
|
+
details?: RemixNode;
|
|
17
|
+
/** The line's price as the reader sees it. */
|
|
18
|
+
price: RemixNode;
|
|
19
|
+
media?: RemixNode;
|
|
20
|
+
/** The colour behind the picture. */
|
|
21
|
+
mediaBackground?: string;
|
|
22
|
+
/** A control at the end, such as a {@link QuantityStepper}. */
|
|
23
|
+
action?: RemixNode;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Renders the line inside a list the caller draws.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* <ul><CartLine name="Al pastor trio" details="Blue corn · Verde" price="$11.50" action={<QuantityStepper … />} /></ul>
|
|
31
|
+
*/
|
|
32
|
+
export declare function CartLine(handle: Handle<CartLine.Props>): () => import("remix/component").RemixElement;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "remix/component/jsx-runtime";
|
|
2
|
+
import { mergeMix, raw } from "@sdxc/u/general";
|
|
3
|
+
/**
|
|
4
|
+
* Renders the line inside a list the caller draws.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* <ul><CartLine name="Al pastor trio" details="Blue corn · Verde" price="$11.50" action={<QuantityStepper … />} /></ul>
|
|
8
|
+
*/
|
|
9
|
+
export function CartLine(handle) {
|
|
10
|
+
return () => {
|
|
11
|
+
let { action, details, media, mediaBackground, mix, name, price, ...rest } = handle.props;
|
|
12
|
+
return (_jsxs("li", { ...rest, "data-slot": "cart-line", mix: mergeMix([
|
|
13
|
+
raw({
|
|
14
|
+
display: "grid",
|
|
15
|
+
gridTemplateColumns: `${media === undefined ? "" : "3rem "}minmax(0, 1fr) auto`,
|
|
16
|
+
alignItems: "center",
|
|
17
|
+
gap: "0.75rem",
|
|
18
|
+
paddingBlock: "0.75rem",
|
|
19
|
+
borderBlockEnd: "1px solid var(--ui-neutral-border)",
|
|
20
|
+
}),
|
|
21
|
+
], mix), children: [media === undefined ? null : (_jsx("span", { "data-slot": "cart-line-media", mix: [
|
|
22
|
+
raw({
|
|
23
|
+
display: "grid",
|
|
24
|
+
placeItems: "center",
|
|
25
|
+
inlineSize: "3rem",
|
|
26
|
+
blockSize: "3rem",
|
|
27
|
+
padding: "0.25rem",
|
|
28
|
+
boxSizing: "border-box",
|
|
29
|
+
borderRadius: "0.75rem",
|
|
30
|
+
overflow: "clip",
|
|
31
|
+
backgroundColor: mediaBackground ?? "var(--ui-neutral-bg-tint)",
|
|
32
|
+
}),
|
|
33
|
+
], children: media })), _jsxs("span", { mix: [raw({ display: "grid", gap: "0.125rem", minInlineSize: "0" })], children: [_jsx("span", { mix: [raw({ fontWeight: "650", color: "var(--ui-neutral-fg-emphasis)" })], children: name }), details === undefined ? null : (_jsx("span", { mix: [
|
|
34
|
+
raw({
|
|
35
|
+
fontSize: "0.8125rem",
|
|
36
|
+
lineHeight: "1.35",
|
|
37
|
+
color: "var(--ui-neutral-fg-muted)",
|
|
38
|
+
}),
|
|
39
|
+
], children: details })), _jsx("span", { mix: [
|
|
40
|
+
raw({ fontSize: "0.875rem", fontWeight: "600", fontVariantNumeric: "tabular-nums" }),
|
|
41
|
+
], children: price })] }), action === undefined ? _jsx("span", {}) : action] }));
|
|
42
|
+
};
|
|
43
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The frame of a checkout page: the form with its steps on one side and the order summary on
|
|
3
|
+
* the other, held in view as the form scrolls. On a phone the summary comes first, folded, so
|
|
4
|
+
* the buyer sees the total before the steps and the form.
|
|
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 CheckoutLayout}. */
|
|
11
|
+
export declare namespace CheckoutLayout {
|
|
12
|
+
/** Props accepted by {@link CheckoutLayout}; the host is a `<div>`. */
|
|
13
|
+
interface Props extends Omit<TagProps<"div">, "children"> {
|
|
14
|
+
/** The progress through checkout, such as a step indicator. */
|
|
15
|
+
steps?: RemixNode;
|
|
16
|
+
/** The order, usually a collapsible `OrderSummary`. */
|
|
17
|
+
summary: RemixNode;
|
|
18
|
+
/** The form of the current step. */
|
|
19
|
+
children: RemixNode;
|
|
20
|
+
/** Under the summary, such as payment marks or a returns promise. */
|
|
21
|
+
aside?: RemixNode;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Renders one column on a phone, summary then steps then form. From 56rem the form takes the
|
|
26
|
+
* flexible column and the summary a 24rem column on a tinted band, sticky to the top so the
|
|
27
|
+
* total stays in view; the whole frame stops at 70rem.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* <CheckoutLayout steps={<StepIndicator … />} summary={<OrderSummary collapsible … />}><form method="post">…</form></CheckoutLayout>
|
|
31
|
+
*/
|
|
32
|
+
export declare function CheckoutLayout(handle: Handle<CheckoutLayout.Props>): () => import("remix/component").RemixElement;
|