@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,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A bundle's price beside what its parts cost apart: a line per part (flight, stay, car) with
|
|
3
|
+
* its separate price struck through, then the bundled price large with a "You save" badge.
|
|
4
|
+
* Prices arrive formatted; the summary sits beside the parts once its container is wide.
|
|
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
|
+
/**
|
|
11
|
+
* Prop types for {@link PackageSavings} and its compound parts.
|
|
12
|
+
*/
|
|
13
|
+
export declare namespace PackageSavings {
|
|
14
|
+
/** What a part is, which picks its icon. */
|
|
15
|
+
type Kind = "flight" | "stay" | "car" | "activity";
|
|
16
|
+
/** What {@link PackageSavings} shares with its parts. */
|
|
17
|
+
interface Context {
|
|
18
|
+
separateLabel?: string;
|
|
19
|
+
}
|
|
20
|
+
/** Every native `<section>` attribute, plus the bundle's price and what it saves. */
|
|
21
|
+
interface Props extends Omit<TagProps<"section">, "title"> {
|
|
22
|
+
/** What the bundle is, such as "Flight + Hotel + Car", over the parts. */
|
|
23
|
+
title?: RemixNode;
|
|
24
|
+
/** The saving as a badge, such as "You save $212". */
|
|
25
|
+
savings: RemixNode;
|
|
26
|
+
/** What the bundled price is, such as "Package price". */
|
|
27
|
+
bundleLabel: RemixNode;
|
|
28
|
+
/** The bundled price, formatted, such as "$1,486". */
|
|
29
|
+
bundlePrice: string;
|
|
30
|
+
/** What the price covers, such as "2 travellers · taxes included", under it. */
|
|
31
|
+
bundleDetail?: RemixNode;
|
|
32
|
+
/** The parts' prices added up, struck through above the bundled price, such as "$1,698". */
|
|
33
|
+
separateTotal?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Read before every struck price, such as "Booked separately", since a strike-through
|
|
36
|
+
* is silent to most screen readers.
|
|
37
|
+
*/
|
|
38
|
+
separateLabel?: string;
|
|
39
|
+
/** A booking button or link under the bundled price. */
|
|
40
|
+
action?: RemixNode;
|
|
41
|
+
/** The {@link PackageSavings.Part} lines. */
|
|
42
|
+
children: RemixNode;
|
|
43
|
+
}
|
|
44
|
+
/** Every native `<li>` attribute, plus what the part is and costs alone. */
|
|
45
|
+
interface PartProps extends Omit<TagProps<"li">, "children"> {
|
|
46
|
+
kind: Kind;
|
|
47
|
+
/** A glyph in place of the kind's own. */
|
|
48
|
+
icon?: RemixNode;
|
|
49
|
+
/** What the part is, such as "Return flights MRW ⇄ VLS". */
|
|
50
|
+
label: RemixNode;
|
|
51
|
+
/** A second line, such as "Larkwing Air · Economy". */
|
|
52
|
+
detail?: RemixNode;
|
|
53
|
+
/** What the part costs booked alone, formatted, such as "$684"; drawn struck through. */
|
|
54
|
+
price: string;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Renders the bundle: a `<section>` whose title and parts list sit over the bundled price under
|
|
59
|
+
* 32rem, and beside it from there. The parts total is struck through over the bundled price,
|
|
60
|
+
* and the saving is a success-toned badge beside it.
|
|
61
|
+
*
|
|
62
|
+
* @param handle Runtime handle carrying the section's props and sharing the struck-price words.
|
|
63
|
+
* @returns The render function producing the bundle's markup.
|
|
64
|
+
* @example
|
|
65
|
+
* <PackageSavings title="Flight + Hotel" savings="You save $212" bundleLabel="Package price"
|
|
66
|
+
* bundlePrice="$1,486" separateTotal="$1,698" separateLabel="Booked separately">
|
|
67
|
+
* <PackageSavings.Part kind="flight" label="Return flights MRW ⇄ VLS" price="$684" />
|
|
68
|
+
* <PackageSavings.Part kind="stay" label="5 nights at Hotel Saltmarsh" price="$1,014" />
|
|
69
|
+
* </PackageSavings>
|
|
70
|
+
*/
|
|
71
|
+
export declare function PackageSavings(handle: Handle<PackageSavings.Props, PackageSavings.Context>): () => import("remix/component").RemixElement;
|
|
72
|
+
export declare namespace PackageSavings {
|
|
73
|
+
var Part: (handle: Handle<PackageSavings.PartProps>) => () => import("remix/component").RemixElement;
|
|
74
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "remix/component/jsx-runtime";
|
|
2
|
+
import { BedDoubleIcon, CarIcon, PlaneIcon, TicketIcon } from "@sdxc/icons";
|
|
3
|
+
import { visuallyHidden } from "@sdxc/u/a11y";
|
|
4
|
+
import { bg, border, fg } from "@sdxc/u/color";
|
|
5
|
+
import { rounded } from "@sdxc/u/effects";
|
|
6
|
+
import { listStyle, raw, mergeMix } from "@sdxc/u/general";
|
|
7
|
+
import { container, flex, gap, grid, inlineFlex, items, justify, vstack } from "@sdxc/u/layout";
|
|
8
|
+
import { at } from "@sdxc/u/responsive";
|
|
9
|
+
import { bs, is, m, minIs, p } from "@sdxc/u/size";
|
|
10
|
+
import { when } from "@sdxc/u/state";
|
|
11
|
+
import { leading, tabularNums, text, weight } from "@sdxc/u/typography";
|
|
12
|
+
/** Container the summary names, so it lays out by its own width. */
|
|
13
|
+
const CONTAINER_NAME = "ui-package-savings";
|
|
14
|
+
/** Summary width from which the bundled price sits beside the parts. */
|
|
15
|
+
const SIDE_BY_SIDE_WIDTH = "32rem";
|
|
16
|
+
/**
|
|
17
|
+
* The glyph for a part of each kind.
|
|
18
|
+
*
|
|
19
|
+
* @param kind What the part is.
|
|
20
|
+
* @returns A 16px icon for the kind.
|
|
21
|
+
*/
|
|
22
|
+
function kindIcon(kind) {
|
|
23
|
+
if (kind === "flight")
|
|
24
|
+
return _jsx(PlaneIcon, { size: 16 });
|
|
25
|
+
if (kind === "stay")
|
|
26
|
+
return _jsx(BedDoubleIcon, { size: 16 });
|
|
27
|
+
if (kind === "car")
|
|
28
|
+
return _jsx(CarIcon, { size: 16 });
|
|
29
|
+
return _jsx(TicketIcon, { size: 16 });
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A price as it would cost apart: muted and inside `<s>`, led by hidden words that say so.
|
|
33
|
+
*
|
|
34
|
+
* @param handle Runtime handle carrying the price and its hidden lead.
|
|
35
|
+
* @returns The render function producing the struck price.
|
|
36
|
+
*/
|
|
37
|
+
function StruckPrice(handle) {
|
|
38
|
+
return () => {
|
|
39
|
+
let { price, label } = handle.props;
|
|
40
|
+
return (_jsxs(_Fragment, { children: [label === undefined ? null : _jsx("span", { mix: [visuallyHidden()], children: `${label}: ` }), _jsx("s", { "data-slot": "package-savings-separate", mix: [fg("neutral.muted"), tabularNums()], children: price })] }));
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Renders the bundle: a `<section>` whose title and parts list sit over the bundled price under
|
|
45
|
+
* 32rem, and beside it from there. The parts total is struck through over the bundled price,
|
|
46
|
+
* and the saving is a success-toned badge beside it.
|
|
47
|
+
*
|
|
48
|
+
* @param handle Runtime handle carrying the section's props and sharing the struck-price words.
|
|
49
|
+
* @returns The render function producing the bundle's markup.
|
|
50
|
+
* @example
|
|
51
|
+
* <PackageSavings title="Flight + Hotel" savings="You save $212" bundleLabel="Package price"
|
|
52
|
+
* bundlePrice="$1,486" separateTotal="$1,698" separateLabel="Booked separately">
|
|
53
|
+
* <PackageSavings.Part kind="flight" label="Return flights MRW ⇄ VLS" price="$684" />
|
|
54
|
+
* <PackageSavings.Part kind="stay" label="5 nights at Hotel Saltmarsh" price="$1,014" />
|
|
55
|
+
* </PackageSavings>
|
|
56
|
+
*/
|
|
57
|
+
export function PackageSavings(handle) {
|
|
58
|
+
return () => {
|
|
59
|
+
let { title, savings, bundleLabel, bundlePrice, bundleDetail, separateTotal, separateLabel, action, children, mix, ...rest } = handle.props;
|
|
60
|
+
handle.context.set({ separateLabel });
|
|
61
|
+
return (_jsx("section", { "data-slot": "package-savings", ...rest, mix: mergeMix([container(CONTAINER_NAME, "inline-size"), minIs(0), text("sm")], mix), children: _jsxs("div", { "data-slot": "package-savings-body", mix: [
|
|
62
|
+
grid(),
|
|
63
|
+
gap(4),
|
|
64
|
+
at(SIDE_BY_SIDE_WIDTH, CONTAINER_NAME, raw({
|
|
65
|
+
gridTemplateColumns: "minmax(0, 1fr) minmax(11rem, auto)",
|
|
66
|
+
columnGap: "1.5rem",
|
|
67
|
+
alignItems: "start",
|
|
68
|
+
})),
|
|
69
|
+
], children: [_jsxs("div", { mix: [vstack({ gap: 3 }), minIs(0)], children: [title === undefined ? null : (_jsx("p", { "data-slot": "package-savings-title", mix: [m(0), weight("semibold"), fg("neutral.emphasis")], children: title })), _jsx("ul", { "data-slot": "package-savings-parts", mix: [m(0), p(0), listStyle("none"), vstack({ gap: 3 })], children: children })] }), _jsxs("div", { "data-slot": "package-savings-bundle", mix: [
|
|
70
|
+
vstack({ gap: 2 }),
|
|
71
|
+
p(4),
|
|
72
|
+
rounded("lg"),
|
|
73
|
+
bg("success.tint"),
|
|
74
|
+
border({ color: "success.border", width: 1 }),
|
|
75
|
+
], children: [_jsxs("div", { mix: [flex(), items("center"), justify("between"), raw({ flexWrap: "wrap" }), gap(2)], children: [_jsx("span", { "data-slot": "package-savings-bundle-label", mix: [text("xs"), weight("medium"), fg("neutral.emphasis")], children: bundleLabel }), _jsx("span", { "data-slot": "package-savings-badge", mix: [
|
|
76
|
+
inlineFlex(),
|
|
77
|
+
raw({ paddingInline: "0.5rem", paddingBlock: "0.125rem" }),
|
|
78
|
+
rounded("full"),
|
|
79
|
+
bg("success.solid"),
|
|
80
|
+
fg("success.onSolid"),
|
|
81
|
+
text("xs"),
|
|
82
|
+
weight("semibold"),
|
|
83
|
+
leading(1.4),
|
|
84
|
+
], children: savings })] }), _jsxs("p", { mix: [m(0), flex(), items("baseline"), raw({ flexWrap: "wrap" }), gap(2)], children: [separateTotal === undefined ? null : (_jsx("span", { mix: [text("sm")], children: _jsx(StruckPrice, { price: separateTotal, label: separateLabel }) })), _jsx("output", { "data-slot": "package-savings-price", mix: [
|
|
85
|
+
text("2xl"),
|
|
86
|
+
weight("semibold"),
|
|
87
|
+
leading(1.1),
|
|
88
|
+
tabularNums(),
|
|
89
|
+
fg("neutral.emphasis"),
|
|
90
|
+
], children: bundlePrice })] }), bundleDetail === undefined ? null : (_jsx("span", { "data-slot": "package-savings-bundle-detail", mix: [text("xs"), fg("neutral.muted")], children: bundleDetail })), action === undefined ? null : (_jsx("div", { "data-slot": "package-savings-action", mix: [
|
|
91
|
+
flex(),
|
|
92
|
+
raw({ marginBlockStart: "0.25rem" }),
|
|
93
|
+
when("& > *", raw({ flex: "1 1 auto" })),
|
|
94
|
+
], children: action }))] })] }) }));
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Renders one part of the bundle: its icon in a tinted square, its label and detail, and what
|
|
99
|
+
* it costs alone struck through at the end, led by the bundle's `separateLabel` when set.
|
|
100
|
+
*
|
|
101
|
+
* @param handle Runtime handle carrying the part's props.
|
|
102
|
+
* @returns The render function producing the part's list item.
|
|
103
|
+
* @example
|
|
104
|
+
* <PackageSavings.Part kind="car" label="Compact car, 5 days" detail="Tallow Rent" price="$190" />
|
|
105
|
+
*/
|
|
106
|
+
PackageSavings.Part = function PackageSavingsPart(handle) {
|
|
107
|
+
return () => {
|
|
108
|
+
let { kind, icon, label, detail, price, mix, ...rest } = handle.props;
|
|
109
|
+
let { separateLabel } = handle.context.get(PackageSavings);
|
|
110
|
+
return (_jsxs("li", { "data-slot": "package-savings-part", "data-kind": kind, ...rest, mix: mergeMix([
|
|
111
|
+
grid(),
|
|
112
|
+
raw({
|
|
113
|
+
gridTemplateColumns: "2rem minmax(0, 1fr) auto",
|
|
114
|
+
columnGap: "0.75rem",
|
|
115
|
+
alignItems: "center",
|
|
116
|
+
}),
|
|
117
|
+
], mix), children: [_jsx("span", { "aria-hidden": "true", mix: [
|
|
118
|
+
inlineFlex(),
|
|
119
|
+
items("center"),
|
|
120
|
+
justify("center"),
|
|
121
|
+
is("2rem"),
|
|
122
|
+
bs("2rem"),
|
|
123
|
+
rounded("md"),
|
|
124
|
+
bg("neutral.tint"),
|
|
125
|
+
fg("neutral.muted"),
|
|
126
|
+
], children: icon ?? kindIcon(kind) }), _jsxs("span", { mix: [vstack({ gap: 0.5 }), minIs(0)], children: [_jsx("span", { "data-slot": "package-savings-part-label", mix: [weight("medium"), fg("neutral.emphasis"), raw({ overflowWrap: "anywhere" })], children: label }), detail === undefined ? null : (_jsx("span", { mix: [text("xs"), fg("neutral.muted")], children: detail }))] }), _jsx("span", { mix: [raw({ whiteSpace: "nowrap", textAlign: "end" })], children: _jsx(StruckPrice, { price: price, label: separateLabel }) })] }));
|
|
127
|
+
};
|
|
128
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A receipt block as a `<dl>`: one line per charge with its working beneath, discounts in
|
|
3
|
+
* green with a minus, and a bold total under a rule. Amounts arrive formatted and sit
|
|
4
|
+
* end-aligned in tabular figures, and a named line wraps its amount in an `<output>`.
|
|
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
|
+
/**
|
|
11
|
+
* Prop types for {@link PriceBreakdown} and its compound parts.
|
|
12
|
+
*/
|
|
13
|
+
export declare namespace PriceBreakdown {
|
|
14
|
+
/** `"discount"` colours the line green and signs its amount with a minus. */
|
|
15
|
+
type Tone = "default" | "discount";
|
|
16
|
+
/** Every native `<div>` attribute, plus the lines and an optional note under them. */
|
|
17
|
+
interface Props extends TagProps<"div"> {
|
|
18
|
+
/**
|
|
19
|
+
* Small muted text under the total, such as "You won't be charged yet"; it sits
|
|
20
|
+
* after the `<dl>`, since a description list holds only label/value groups.
|
|
21
|
+
*/
|
|
22
|
+
note?: RemixNode;
|
|
23
|
+
}
|
|
24
|
+
/** What every amount-bearing line takes. */
|
|
25
|
+
interface AmountProps extends Omit<TagProps<"div">, "children"> {
|
|
26
|
+
/** What the charge is, such as "Cleaning fee". */
|
|
27
|
+
label: RemixNode;
|
|
28
|
+
/** The amount, formatted by the caller, such as "$728.00". */
|
|
29
|
+
amount: string;
|
|
30
|
+
/**
|
|
31
|
+
* Wraps the amount in `<output name>`, so a script finds it by name
|
|
32
|
+
* (`form.elements.namedItem("nights-total")`) and updates it in place.
|
|
33
|
+
*/
|
|
34
|
+
name?: string;
|
|
35
|
+
/** Written to `data-line`, a key a script can find the whole line by. */
|
|
36
|
+
line?: string;
|
|
37
|
+
}
|
|
38
|
+
/** Props accepted by {@link PriceBreakdown.Line}. */
|
|
39
|
+
interface LineProps extends AmountProps {
|
|
40
|
+
/** How the amount was worked out, such as "$182 × 4 nights", in small type beneath. */
|
|
41
|
+
detail?: RemixNode;
|
|
42
|
+
/** @default "default" */
|
|
43
|
+
tone?: Tone;
|
|
44
|
+
}
|
|
45
|
+
/** Props accepted by {@link PriceBreakdown.Total}. */
|
|
46
|
+
interface TotalProps extends AmountProps {
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Renders the receipt: a `<dl>` whose lines each pair a `<dt>` label with a `<dd>` amount,
|
|
51
|
+
* so the pairing survives in the accessibility tree, and the `note` centred beneath it.
|
|
52
|
+
*
|
|
53
|
+
* @param handle Runtime handle carrying the wrapper's props.
|
|
54
|
+
* @returns The render function producing the receipt's markup.
|
|
55
|
+
* @example
|
|
56
|
+
* <PriceBreakdown note="You won't be charged yet">
|
|
57
|
+
* <PriceBreakdown.Line label="4 nights" detail="$182 × 4 nights" amount="$728.00" name="nights" />
|
|
58
|
+
* <PriceBreakdown.Line label="Weekly stay discount" amount="$72.80" tone="discount" />
|
|
59
|
+
* <PriceBreakdown.Total label="Total" amount="$745.20" name="total" />
|
|
60
|
+
* </PriceBreakdown>
|
|
61
|
+
*/
|
|
62
|
+
export declare function PriceBreakdown(handle: Handle<PriceBreakdown.Props>): () => import("remix/component").RemixElement;
|
|
63
|
+
export declare namespace PriceBreakdown {
|
|
64
|
+
var Line: (handle: Handle<PriceBreakdown.LineProps>) => () => import("remix/component").RemixElement;
|
|
65
|
+
var Total: (handle: Handle<PriceBreakdown.TotalProps>) => () => import("remix/component").RemixElement;
|
|
66
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "remix/component/jsx-runtime";
|
|
2
|
+
import { border, fg } from "@sdxc/u/color";
|
|
3
|
+
import { raw, mergeMix } from "@sdxc/u/general";
|
|
4
|
+
import { vstack } from "@sdxc/u/layout";
|
|
5
|
+
import { m, minIs, p } from "@sdxc/u/size";
|
|
6
|
+
import { leading, tabularNums, text, weight } from "@sdxc/u/typography";
|
|
7
|
+
/** The sign a discount's amount gains when the caller formatted it without one. */
|
|
8
|
+
const MINUS = "−";
|
|
9
|
+
/**
|
|
10
|
+
* Signs a discount's amount with a minus unless it already carries one.
|
|
11
|
+
*
|
|
12
|
+
* @param amount The amount as the caller formatted it.
|
|
13
|
+
* @returns The amount led by exactly one minus sign.
|
|
14
|
+
*/
|
|
15
|
+
function asDiscount(amount) {
|
|
16
|
+
let trimmed = amount.trim();
|
|
17
|
+
return /^[-−–]/.test(trimmed) ? trimmed : `${MINUS}${trimmed}`;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The amount itself, inside an `<output>` when it has a name. An output keeps the text it
|
|
21
|
+
* is given and is reachable through its form's `elements`, which is how an island prices
|
|
22
|
+
* a changed stay without re-rendering the receipt.
|
|
23
|
+
*
|
|
24
|
+
* @param handle Runtime handle carrying the amount and its name.
|
|
25
|
+
* @returns The render function producing the amount's markup.
|
|
26
|
+
*/
|
|
27
|
+
function AmountValue(handle) {
|
|
28
|
+
return () => {
|
|
29
|
+
let { amount, name } = handle.props;
|
|
30
|
+
if (name === undefined)
|
|
31
|
+
return _jsx(_Fragment, { children: amount });
|
|
32
|
+
return _jsx("output", { name: name, children: amount });
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Renders the receipt: a `<dl>` whose lines each pair a `<dt>` label with a `<dd>` amount,
|
|
37
|
+
* so the pairing survives in the accessibility tree, and the `note` centred beneath it.
|
|
38
|
+
*
|
|
39
|
+
* @param handle Runtime handle carrying the wrapper's props.
|
|
40
|
+
* @returns The render function producing the receipt's markup.
|
|
41
|
+
* @example
|
|
42
|
+
* <PriceBreakdown note="You won't be charged yet">
|
|
43
|
+
* <PriceBreakdown.Line label="4 nights" detail="$182 × 4 nights" amount="$728.00" name="nights" />
|
|
44
|
+
* <PriceBreakdown.Line label="Weekly stay discount" amount="$72.80" tone="discount" />
|
|
45
|
+
* <PriceBreakdown.Total label="Total" amount="$745.20" name="total" />
|
|
46
|
+
* </PriceBreakdown>
|
|
47
|
+
*/
|
|
48
|
+
export function PriceBreakdown(handle) {
|
|
49
|
+
return () => {
|
|
50
|
+
let { note, children, mix, ...rest } = handle.props;
|
|
51
|
+
return (_jsxs("div", { "data-slot": "price-breakdown", ...rest, mix: mergeMix([minIs(0), vstack({ gap: 4 }), text("sm")], mix), children: [_jsx("dl", { mix: [m(0), vstack({ gap: 3 })], children: children }), note === undefined ? null : (_jsx("p", { "data-slot": "price-breakdown-note", mix: [m(0), text("xs"), fg("neutral.muted"), raw({ textAlign: "center" })], children: note }))] }));
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/** Columns every line shares: the label takes what is left, the amount what it needs. */
|
|
55
|
+
const LINE_COLUMNS = raw({
|
|
56
|
+
display: "grid",
|
|
57
|
+
gridTemplateColumns: "minmax(0, 1fr) auto",
|
|
58
|
+
columnGap: "1rem",
|
|
59
|
+
alignItems: "baseline",
|
|
60
|
+
});
|
|
61
|
+
/**
|
|
62
|
+
* Renders one charge: its label, the working under it in muted small type, and its amount
|
|
63
|
+
* at the end. A discount is green and its amount is signed with a minus.
|
|
64
|
+
*
|
|
65
|
+
* @param handle Runtime handle carrying the line's props.
|
|
66
|
+
* @returns The render function producing the line's markup.
|
|
67
|
+
* @example
|
|
68
|
+
* <PriceBreakdown.Line label="Cleaning fee" amount="$45.00" />
|
|
69
|
+
* @example
|
|
70
|
+
* <PriceBreakdown.Line label="Early-bird discount" amount="$30.00" tone="discount" line="discount" />
|
|
71
|
+
*/
|
|
72
|
+
PriceBreakdown.Line = function PriceBreakdownLine(handle) {
|
|
73
|
+
return () => {
|
|
74
|
+
let { label, amount, name, line, detail, tone, mix, ...rest } = handle.props;
|
|
75
|
+
let discount = tone === "discount";
|
|
76
|
+
return (_jsxs("div", { "data-slot": "price-breakdown-line", "data-line": line, "data-tone": discount ? "discount" : undefined, ...rest, mix: mergeMix([LINE_COLUMNS, discount ? fg("success") : fg("neutral.emphasis")], mix), children: [_jsxs("dt", { mix: [m(0), minIs(0), leading("1.4")], children: [label, detail === undefined ? null : (_jsx("span", { "data-slot": "price-breakdown-detail", mix: [raw({ display: "block" }), text("xs"), fg("neutral.muted"), tabularNums()], children: detail }))] }), _jsx("dd", { mix: [m(0), tabularNums(), raw({ textAlign: "end", whiteSpace: "nowrap" })], children: _jsx(AmountValue, { amount: discount ? asDiscount(amount) : amount, name: name }) })] }));
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Renders the total: the same columns as a line, set bold and a step larger under a rule
|
|
81
|
+
* that closes off the charges above it.
|
|
82
|
+
*
|
|
83
|
+
* @param handle Runtime handle carrying the total's props.
|
|
84
|
+
* @returns The render function producing the total's markup.
|
|
85
|
+
* @example
|
|
86
|
+
* <PriceBreakdown.Total label="Total (USD)" amount="$745.20" name="total" />
|
|
87
|
+
*/
|
|
88
|
+
PriceBreakdown.Total = function PriceBreakdownTotal(handle) {
|
|
89
|
+
return () => {
|
|
90
|
+
let { label, amount, name, line, mix, ...rest } = handle.props;
|
|
91
|
+
return (_jsxs("div", { "data-slot": "price-breakdown-total", "data-line": line, ...rest, mix: mergeMix([
|
|
92
|
+
LINE_COLUMNS,
|
|
93
|
+
border({ color: "neutral.border", width: 0 }),
|
|
94
|
+
raw({ borderBlockStartWidth: "1px", borderBlockStartStyle: "solid" }),
|
|
95
|
+
p(0),
|
|
96
|
+
raw({ paddingBlockStart: "0.75rem" }),
|
|
97
|
+
text("base"),
|
|
98
|
+
weight("semibold"),
|
|
99
|
+
fg("neutral.emphasis"),
|
|
100
|
+
], mix), children: [_jsx("dt", { mix: [m(0), minIs(0)], children: label }), _jsx("dd", { mix: [m(0), tabularNums(), raw({ textAlign: "end", whiteSpace: "nowrap" })], children: _jsx(AmountValue, { amount: amount, name: name }) })] }));
|
|
101
|
+
};
|
|
102
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A reviews summary: the average score set large beside a star and the review count, then
|
|
3
|
+
* groups of bars, one per star level or per category. Each bar is an ARIA meter named by its
|
|
4
|
+
* label, and a category group runs two to a row once its own container is wide enough.
|
|
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
|
+
/**
|
|
11
|
+
* Prop types for {@link RatingBreakdown} and its compound parts.
|
|
12
|
+
*/
|
|
13
|
+
export declare namespace RatingBreakdown {
|
|
14
|
+
/**
|
|
15
|
+
* `"stars"` sets each bar on one line, label and figure either side of it, for the share
|
|
16
|
+
* of reviews at each star level; `"categories"` sets the label over its bar, two to a row
|
|
17
|
+
* when there is room, for per-category scores.
|
|
18
|
+
*/
|
|
19
|
+
type Kind = "stars" | "categories";
|
|
20
|
+
/** What a {@link RatingBreakdown.Group} shares with its bars. */
|
|
21
|
+
interface GroupContext {
|
|
22
|
+
kind: Kind;
|
|
23
|
+
}
|
|
24
|
+
/** Every native `<section>` attribute, plus the headline score. */
|
|
25
|
+
interface Props extends TagProps<"section"> {
|
|
26
|
+
/** The average rating, such as `4.86`. */
|
|
27
|
+
score: number;
|
|
28
|
+
/** @default 5 */
|
|
29
|
+
max?: number;
|
|
30
|
+
/**
|
|
31
|
+
* The score as shown, already formatted for the reader's locale.
|
|
32
|
+
*
|
|
33
|
+
* @default score.toFixed(2)
|
|
34
|
+
*/
|
|
35
|
+
display?: string;
|
|
36
|
+
/** The review count as shown, such as "128 reviews". */
|
|
37
|
+
count?: RemixNode;
|
|
38
|
+
/**
|
|
39
|
+
* What follows the score for a screen reader, completing "4.86 out of 5".
|
|
40
|
+
*
|
|
41
|
+
* @default "out of {max}"
|
|
42
|
+
*/
|
|
43
|
+
outOf?: string;
|
|
44
|
+
}
|
|
45
|
+
/** Every native `<ul>` attribute, plus how its bars lay out. */
|
|
46
|
+
interface GroupProps extends TagProps<"ul"> {
|
|
47
|
+
kind: Kind;
|
|
48
|
+
}
|
|
49
|
+
/** Every native `<li>` attribute, plus what the bar measures. */
|
|
50
|
+
interface BarProps extends Omit<TagProps<"li">, "children"> {
|
|
51
|
+
/** What the bar measures, such as "5 stars" or "Cleanliness"; it names the meter. */
|
|
52
|
+
label: string;
|
|
53
|
+
/** Drawn before the label, such as a star or a category's icon. */
|
|
54
|
+
icon?: RemixNode;
|
|
55
|
+
/** The measured amount: a share from 0 to `max`, or a category's score. */
|
|
56
|
+
value: number;
|
|
57
|
+
/** @default 1 for a "stars" group, 5 for a "categories" group */
|
|
58
|
+
max?: number;
|
|
59
|
+
/** The figure shown at the bar's end and read as its value, such as "92%" or "4.9". */
|
|
60
|
+
display: string;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Renders the summary: a `<section>` opening with the score, its star and the review count,
|
|
65
|
+
* followed by its {@link RatingBreakdown.Group} children. A screen reader hears the score as
|
|
66
|
+
* "4.86 out of 5".
|
|
67
|
+
*
|
|
68
|
+
* @param handle Runtime handle carrying the section's props.
|
|
69
|
+
* @returns The render function producing the summary's markup.
|
|
70
|
+
* @example
|
|
71
|
+
* <RatingBreakdown score={4.86} count="128 reviews">
|
|
72
|
+
* <RatingBreakdown.Group kind="stars" aria-label="Ratings by star">
|
|
73
|
+
* <RatingBreakdown.Bar label="5 stars" value={0.92} display="92%" />
|
|
74
|
+
* </RatingBreakdown.Group>
|
|
75
|
+
* </RatingBreakdown>
|
|
76
|
+
*/
|
|
77
|
+
export declare function RatingBreakdown(handle: Handle<RatingBreakdown.Props>): () => import("remix/component").RemixElement;
|
|
78
|
+
export declare namespace RatingBreakdown {
|
|
79
|
+
var Group: (handle: Handle<RatingBreakdown.GroupProps, RatingBreakdown.GroupContext>) => () => import("remix/component").RemixElement;
|
|
80
|
+
var Bar: (handle: Handle<RatingBreakdown.BarProps>) => () => import("remix/component").RemixElement;
|
|
81
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "remix/component/jsx-runtime";
|
|
2
|
+
import { StarIcon } from "@sdxc/icons";
|
|
3
|
+
import { visuallyHidden } from "@sdxc/u/a11y";
|
|
4
|
+
import { bg, fg } from "@sdxc/u/color";
|
|
5
|
+
import { rounded } from "@sdxc/u/effects";
|
|
6
|
+
import { raw, mergeMix } from "@sdxc/u/general";
|
|
7
|
+
import { container, flex, gap, grid, items, vstack } from "@sdxc/u/layout";
|
|
8
|
+
import { at } from "@sdxc/u/responsive";
|
|
9
|
+
import { bs, m, minIs, p } from "@sdxc/u/size";
|
|
10
|
+
import { when } from "@sdxc/u/state";
|
|
11
|
+
import { leading, tabularNums, text, tracking, weight } from "@sdxc/u/typography";
|
|
12
|
+
/** Container the summary names, so a category group measures the summary, not the page. */
|
|
13
|
+
const CONTAINER_NAME = "ui-rating-breakdown";
|
|
14
|
+
/** Summary width from which a category group sets its bars two to a row. */
|
|
15
|
+
const TWO_COLUMN_WIDTH = "30rem";
|
|
16
|
+
/** Top of the scale when `max` is left out: a five-star rating. */
|
|
17
|
+
const DEFAULT_MAX = 5;
|
|
18
|
+
/**
|
|
19
|
+
* Renders the summary: a `<section>` opening with the score, its star and the review count,
|
|
20
|
+
* followed by its {@link RatingBreakdown.Group} children. A screen reader hears the score as
|
|
21
|
+
* "4.86 out of 5".
|
|
22
|
+
*
|
|
23
|
+
* @param handle Runtime handle carrying the section's props.
|
|
24
|
+
* @returns The render function producing the summary's markup.
|
|
25
|
+
* @example
|
|
26
|
+
* <RatingBreakdown score={4.86} count="128 reviews">
|
|
27
|
+
* <RatingBreakdown.Group kind="stars" aria-label="Ratings by star">
|
|
28
|
+
* <RatingBreakdown.Bar label="5 stars" value={0.92} display="92%" />
|
|
29
|
+
* </RatingBreakdown.Group>
|
|
30
|
+
* </RatingBreakdown>
|
|
31
|
+
*/
|
|
32
|
+
export function RatingBreakdown(handle) {
|
|
33
|
+
return () => {
|
|
34
|
+
let { score, max, display, count, outOf, children, mix, ...rest } = handle.props;
|
|
35
|
+
let top = max ?? DEFAULT_MAX;
|
|
36
|
+
return (_jsxs("section", { "data-slot": "rating-breakdown", ...rest, mix: mergeMix([container(CONTAINER_NAME, "inline-size"), vstack({ gap: 5 })], mix), children: [_jsxs("p", { "data-slot": "rating-breakdown-score", mix: [m(0), flex(), items("center"), gap(2), raw({ flexWrap: "wrap" })], children: [_jsx("span", { "aria-hidden": "true", mix: [flex(), raw({ color: "var(--ui-warning-fg)" })], children: _jsx(StarIcon, { size: 28, fill: "currentColor", "stroke-width": 0 }) }), _jsxs("span", { mix: [
|
|
37
|
+
text("3xl"),
|
|
38
|
+
weight("semibold"),
|
|
39
|
+
tracking("tight"),
|
|
40
|
+
leading(1),
|
|
41
|
+
tabularNums(),
|
|
42
|
+
fg("neutral.emphasis"),
|
|
43
|
+
], children: [display ?? score.toFixed(2), _jsx("span", { mix: [visuallyHidden()], children: ` ${outOf ?? `out of ${top}`}` })] }), count === undefined ? null : (_jsx("span", { "data-slot": "rating-breakdown-count", mix: [text("sm"), fg("neutral.muted")], children: count }))] }), children] }));
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Renders a list of bars of one kind: star levels one under another, or categories in a
|
|
48
|
+
* grid that runs two to a row once the summary is 30rem wide. Name each group with
|
|
49
|
+
* `aria-label` when a summary holds more than one.
|
|
50
|
+
*
|
|
51
|
+
* @param handle Runtime handle carrying the list's props and providing its kind to the bars.
|
|
52
|
+
* @returns The render function producing the list's markup.
|
|
53
|
+
* @example
|
|
54
|
+
* <RatingBreakdown.Group kind="categories" aria-label="Ratings by category">
|
|
55
|
+
* <RatingBreakdown.Bar label="Cleanliness" icon={<SparklesIcon />} value={4.9} display="4.9" />
|
|
56
|
+
* </RatingBreakdown.Group>
|
|
57
|
+
*/
|
|
58
|
+
RatingBreakdown.Group = function RatingBreakdownGroup(handle) {
|
|
59
|
+
return () => {
|
|
60
|
+
let { kind, mix, ...rest } = handle.props;
|
|
61
|
+
handle.context.set({ kind });
|
|
62
|
+
return (_jsx("ul", { "data-slot": "rating-breakdown-group", "data-kind": kind, ...rest, mix: mergeMix([
|
|
63
|
+
m(0),
|
|
64
|
+
p(0),
|
|
65
|
+
raw({ listStyle: "none" }),
|
|
66
|
+
grid(),
|
|
67
|
+
kind === "stars"
|
|
68
|
+
? gap(2)
|
|
69
|
+
: [
|
|
70
|
+
raw({ columnGap: "2rem", rowGap: "1rem" }),
|
|
71
|
+
at(TWO_COLUMN_WIDTH, CONTAINER_NAME, raw({ gridTemplateColumns: "repeat(2, minmax(0, 1fr))" })),
|
|
72
|
+
],
|
|
73
|
+
], mix) }));
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Renders one bar as an ARIA meter named by `label` and valued by `display`, filled to
|
|
78
|
+
* `value / max` of its track; the figure at its end is hidden from assistive technology,
|
|
79
|
+
* which reads it as the meter's value. Values outside `0..max` are clamped.
|
|
80
|
+
*
|
|
81
|
+
* @param handle Runtime handle carrying the item's props.
|
|
82
|
+
* @returns The render function producing the bar's markup.
|
|
83
|
+
* @example
|
|
84
|
+
* <RatingBreakdown.Bar label="4 stars" value={0.06} display="6%" />
|
|
85
|
+
* @example
|
|
86
|
+
* <RatingBreakdown.Bar label="Location" icon={<MapPinIcon />} value={4.7} display="4.7" />
|
|
87
|
+
*/
|
|
88
|
+
RatingBreakdown.Bar = function RatingBreakdownBar(handle) {
|
|
89
|
+
return () => {
|
|
90
|
+
let { label, icon, value, max, display, mix, ...rest } = handle.props;
|
|
91
|
+
let { kind } = handle.context.get(RatingBreakdown.Group);
|
|
92
|
+
let top = max ?? (kind === "stars" ? 1 : DEFAULT_MAX);
|
|
93
|
+
let share = top > 0 ? Math.max(0, Math.min(1, value / top)) : 0;
|
|
94
|
+
let labelId = `${handle.id}-label`;
|
|
95
|
+
let stars = kind === "stars";
|
|
96
|
+
return (_jsxs("li", { "data-slot": "rating-breakdown-bar", ...rest, mix: mergeMix([
|
|
97
|
+
grid(),
|
|
98
|
+
items("center"),
|
|
99
|
+
text("sm"),
|
|
100
|
+
stars
|
|
101
|
+
? raw({
|
|
102
|
+
gridTemplateColumns: "minmax(3.5rem, auto) minmax(0, 1fr) 2.75rem",
|
|
103
|
+
columnGap: "0.75rem",
|
|
104
|
+
})
|
|
105
|
+
: raw({
|
|
106
|
+
gridTemplateColumns: "minmax(0, 1fr) auto",
|
|
107
|
+
gridTemplateAreas: '"label value" "track track"',
|
|
108
|
+
columnGap: "0.75rem",
|
|
109
|
+
rowGap: "0.375rem",
|
|
110
|
+
}),
|
|
111
|
+
], mix), children: [_jsxs("span", { id: labelId, "data-slot": "rating-breakdown-label", mix: [
|
|
112
|
+
flex(),
|
|
113
|
+
items("center"),
|
|
114
|
+
gap(1.5),
|
|
115
|
+
minIs(0),
|
|
116
|
+
fg(stars ? "neutral.muted" : "neutral.emphasis"),
|
|
117
|
+
stars ? null : raw({ gridArea: "label" }),
|
|
118
|
+
when("& > svg", raw({ inlineSize: "1rem", blockSize: "1rem", flexShrink: 0 })),
|
|
119
|
+
], children: [icon, label] }), _jsx("div", { role: "meter", "aria-labelledby": labelId, "aria-valuemin": 0, "aria-valuemax": top, "aria-valuenow": value, "aria-valuetext": display, "data-slot": "rating-breakdown-track", mix: [
|
|
120
|
+
bs("0.375rem"),
|
|
121
|
+
rounded("full"),
|
|
122
|
+
bg("neutral.border"),
|
|
123
|
+
raw({ overflow: "hidden" }),
|
|
124
|
+
stars ? null : raw({ gridArea: "track" }),
|
|
125
|
+
], children: _jsx("div", { "data-slot": "rating-breakdown-fill", style: { inlineSize: `${share * 100}%` }, mix: [bs("100%"), rounded("full"), bg("neutral.solid")] }) }), _jsx("span", { "aria-hidden": "true", "data-slot": "rating-breakdown-value", mix: [
|
|
126
|
+
tabularNums(),
|
|
127
|
+
raw({ textAlign: "end" }),
|
|
128
|
+
fg(stars ? "neutral.muted" : "neutral.emphasis"),
|
|
129
|
+
stars ? null : [weight("semibold"), raw({ gridArea: "value" })],
|
|
130
|
+
], children: display })] }));
|
|
131
|
+
};
|
|
132
|
+
};
|