@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,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A text field with a styled suggestion list under it, for a "Where are you going?" box or an
|
|
3
|
+
* address field. The server renders a plain input with a native `<datalist>`, and the
|
|
4
|
+
* {@link AutocompleteSync} island upgrades it to a combobox over a filtered, iconed listbox.
|
|
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
|
+
export { AUTOCOMPLETE_SELECT_EVENT } from "../mixins/autocomplete.js";
|
|
11
|
+
export type { AutocompleteSelectDetail } from "../mixins/autocomplete.js";
|
|
12
|
+
/** Prop types for {@link Autocomplete}. */
|
|
13
|
+
export declare namespace Autocomplete {
|
|
14
|
+
/** One suggestion: what the hidden field submits, what the field shows, and how it reads. */
|
|
15
|
+
interface Option {
|
|
16
|
+
/** Submitted through `valueName` when picked, such as a place id. */
|
|
17
|
+
value: string;
|
|
18
|
+
/** Shown in the list and written into the field when picked. */
|
|
19
|
+
label: string;
|
|
20
|
+
/** A second line under the label, also searched as the reader types. */
|
|
21
|
+
description?: string;
|
|
22
|
+
/** A glyph before the label, such as an icon from `@sdxc/icons`. */
|
|
23
|
+
icon?: RemixNode;
|
|
24
|
+
}
|
|
25
|
+
/** Per-part styling for the elements the autocomplete composes. */
|
|
26
|
+
interface PartsProps {
|
|
27
|
+
/** The text field. */
|
|
28
|
+
input?: TagProps<"input">["mix"];
|
|
29
|
+
/** The floating list surface. */
|
|
30
|
+
list?: TagProps<"div">["mix"];
|
|
31
|
+
/** Every option row. */
|
|
32
|
+
option?: TagProps<"div">["mix"];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Every native `<input>` attribute but the ones the combobox owns, which land on the field;
|
|
36
|
+
* `mix` styles the wrapper around the field and its list.
|
|
37
|
+
*/
|
|
38
|
+
interface Props extends Omit<TagProps<"input">, "type" | "list" | "role" | "children" | "mix" | "value" | "color"> {
|
|
39
|
+
/** The field's `id`, from which every other id the autocomplete needs derives. */
|
|
40
|
+
id: string;
|
|
41
|
+
/** The field's accessible name; pass `aria-labelledby` instead to point at a visible label. */
|
|
42
|
+
label?: string;
|
|
43
|
+
/** The suggestions, in the order the list shows them. */
|
|
44
|
+
options: Array<Option>;
|
|
45
|
+
/** Shown at the top of the list while the field is empty, such as "Suggested destinations". */
|
|
46
|
+
heading?: RemixNode;
|
|
47
|
+
/** Shown in the list when nothing matches. @default "No matches" */
|
|
48
|
+
emptyLabel?: RemixNode;
|
|
49
|
+
/** Names a hidden field carrying the picked option's `value`, emptied once the text is edited. */
|
|
50
|
+
valueName?: string;
|
|
51
|
+
/**
|
|
52
|
+
* `"field"` draws the bordered input; `"bare"` drops its border, background, padding and focus
|
|
53
|
+
* ring, for a field set inside a pill that draws them with `:focus-within`.
|
|
54
|
+
* @default "field"
|
|
55
|
+
*/
|
|
56
|
+
variant?: "field" | "bare";
|
|
57
|
+
/** Styling for the wrapper. */
|
|
58
|
+
mix?: TagProps<"div">["mix"];
|
|
59
|
+
/** Per-part styling. */
|
|
60
|
+
parts?: PartsProps;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Renders the field, its `<datalist>`, a hidden list of styled options and the island that
|
|
65
|
+
* swaps one for the other. Picking fires `change` and an `autocomplete-select` event on the
|
|
66
|
+
* field with `{ value, label }`; Enter on an option never submits the form.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* <Autocomplete id="where" name="where" label="Where to?" heading="Suggested destinations"
|
|
70
|
+
* valueName="placeId" options={[{ value: "lis", label: "Lisbon", description: "Portugal" }]} />
|
|
71
|
+
* @example
|
|
72
|
+
* <Autocomplete id="q" name="q" variant="bare" aria-labelledby="where-label" options={places} />
|
|
73
|
+
*/
|
|
74
|
+
export declare function Autocomplete(handle: Handle<Autocomplete.Props>): () => import("remix/component").RemixElement;
|
|
75
|
+
/**
|
|
76
|
+
* The island inside every {@link Autocomplete}: once hydrated it drops the field's datalist,
|
|
77
|
+
* makes the field a combobox and opens the styled list on focus and typing. It renders only a
|
|
78
|
+
* hidden marker, so the field and options stay server markup styled by the caller's mixins.
|
|
79
|
+
*
|
|
80
|
+
* @example <AutocompleteSync />
|
|
81
|
+
*/
|
|
82
|
+
export declare const AutocompleteSync: EntryComponent<Record<never, never>>;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "remix/component/jsx-runtime";
|
|
2
|
+
import { bg, fg } from "@sdxc/u/color";
|
|
3
|
+
import { rounded } from "@sdxc/u/effects";
|
|
4
|
+
import { cursor, mergeMix, raw } from "@sdxc/u/general";
|
|
5
|
+
import { hstack } from "@sdxc/u/layout";
|
|
6
|
+
import { pb, pi } from "@sdxc/u/size";
|
|
7
|
+
import { hover, when } from "@sdxc/u/state";
|
|
8
|
+
import { text, truncate } from "@sdxc/u/typography";
|
|
9
|
+
import { clientEntry } from "remix/component";
|
|
10
|
+
import { autocomplete } from "../mixins/autocomplete.js";
|
|
11
|
+
import { floatingSurface, surfaceInset } from "../styles/floating-surface.js";
|
|
12
|
+
import { warnIfNoAccessibleLabel } from "../utils/warn-if-no-accessible-name.js";
|
|
13
|
+
import { Input } from "./input.js";
|
|
14
|
+
export { AUTOCOMPLETE_SELECT_EVENT } from "../mixins/autocomplete.js";
|
|
15
|
+
/** What the list says when the typed text matches no option and the caller names nothing. */
|
|
16
|
+
const DEFAULT_EMPTY_LABEL = "No matches";
|
|
17
|
+
/**
|
|
18
|
+
* Renders the field, its `<datalist>`, a hidden list of styled options and the island that
|
|
19
|
+
* swaps one for the other. Picking fires `change` and an `autocomplete-select` event on the
|
|
20
|
+
* field with `{ value, label }`; Enter on an option never submits the form.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* <Autocomplete id="where" name="where" label="Where to?" heading="Suggested destinations"
|
|
24
|
+
* valueName="placeId" options={[{ value: "lis", label: "Lisbon", description: "Portugal" }]} />
|
|
25
|
+
* @example
|
|
26
|
+
* <Autocomplete id="q" name="q" variant="bare" aria-labelledby="where-label" options={places} />
|
|
27
|
+
*/
|
|
28
|
+
export function Autocomplete(handle) {
|
|
29
|
+
return () => {
|
|
30
|
+
let { id, label, options, heading, emptyLabel = DEFAULT_EMPTY_LABEL, valueName, variant = "field", mix, parts, autoComplete = "off", ...rest } = handle.props;
|
|
31
|
+
let labelledBy = rest["aria-labelledby"];
|
|
32
|
+
warnIfNoAccessibleLabel({ "aria-label": label, "aria-labelledby": labelledBy }, "Autocomplete: pass `label` or `aria-labelledby` so the field and its list have a name.");
|
|
33
|
+
return (_jsxs("div", { "data-slot": "autocomplete", "data-variant": variant, mix: mergeMix([raw({ position: "relative", inlineSize: "100%", minInlineSize: "0" })], mix), children: [_jsx(Input, { ...rest, id: id, "aria-label": label, autoComplete: autoComplete, list: `${id}-suggestions`, "data-autocomplete-input": "", mix: mergeMix([
|
|
34
|
+
raw({ minInlineSize: "0", textOverflow: "ellipsis" }),
|
|
35
|
+
when('[data-variant="bare"] > &', [
|
|
36
|
+
raw({
|
|
37
|
+
borderWidth: "0",
|
|
38
|
+
backgroundColor: "transparent",
|
|
39
|
+
paddingInline: "0",
|
|
40
|
+
outline: "none",
|
|
41
|
+
boxShadow: "none",
|
|
42
|
+
}),
|
|
43
|
+
]),
|
|
44
|
+
], parts?.input) }), valueName ? (_jsx("input", { type: "hidden", name: valueName, value: "", "data-autocomplete-value": "" })) : null, _jsx("datalist", { id: `${id}-suggestions`, children: options.map((option) => (_jsx("option", { value: option.label }))) }), _jsxs("div", { id: `${id}-popup`, popover: "manual", "data-autocomplete-popup": "", mix: mergeMix([
|
|
45
|
+
floatingSurface(),
|
|
46
|
+
surfaceInset(),
|
|
47
|
+
raw({
|
|
48
|
+
position: "fixed",
|
|
49
|
+
inset: "auto",
|
|
50
|
+
margin: "0",
|
|
51
|
+
boxSizing: "border-box",
|
|
52
|
+
overflowY: "auto",
|
|
53
|
+
overscrollBehavior: "contain",
|
|
54
|
+
color: "var(--ui-neutral-fg-emphasis)",
|
|
55
|
+
}),
|
|
56
|
+
when("&:not(:popover-open)", raw({ display: "none !important" })),
|
|
57
|
+
], parts?.list), children: [heading ? (_jsx("div", { id: `${id}-heading`, "data-autocomplete-heading": "", mix: [
|
|
58
|
+
pi(3),
|
|
59
|
+
raw({
|
|
60
|
+
paddingBlock: "0.375rem",
|
|
61
|
+
fontSize: "0.75rem",
|
|
62
|
+
fontWeight: "600",
|
|
63
|
+
color: "var(--ui-neutral-fg-muted)",
|
|
64
|
+
}),
|
|
65
|
+
], children: heading })) : null, _jsx("div", { id: `${id}-listbox`, role: "listbox", "aria-label": label, "aria-labelledby": labelledBy, "data-autocomplete-listbox": "", children: options.map((option, index) => (_jsx(AutocompleteOption, { id: `${id}-option-${index}`, option: option, mix: parts?.option }))) }), _jsx("div", { "data-autocomplete-empty": "", hidden: true, mix: [pi(3), pb(2), text("sm"), fg("neutral.muted")], children: emptyLabel })] }), _jsx(AutocompleteSync, {})] }));
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* One row of the list: the icon in a tinted square, the label over its description, both
|
|
70
|
+
* truncating so a long place name never widens the list. A row is at least the pointer
|
|
71
|
+
* target size tall, which grows to 44px on a touch screen.
|
|
72
|
+
*/
|
|
73
|
+
function AutocompleteOption(handle) {
|
|
74
|
+
return () => {
|
|
75
|
+
let { id, option, mix } = handle.props;
|
|
76
|
+
return (_jsxs("div", { id: id, role: "option", "aria-selected": "false", "data-autocomplete-option": "", "data-value": option.value, "data-label": option.label, "data-description": option.description, mix: mergeMix([
|
|
77
|
+
hstack({ align: "center", gap: 3 }),
|
|
78
|
+
rounded("md"),
|
|
79
|
+
pi(3),
|
|
80
|
+
pb(1.5),
|
|
81
|
+
cursor("default"),
|
|
82
|
+
raw({
|
|
83
|
+
minBlockSize: "max(2.75rem, var(--ui-target-size))",
|
|
84
|
+
scrollMarginBlock: "0.25rem",
|
|
85
|
+
}),
|
|
86
|
+
hover(bg("neutral.bg-tint-hover")),
|
|
87
|
+
when('&[aria-selected="true"]', [bg("brand.bg-tint-pressed")]),
|
|
88
|
+
when("&[hidden]", raw({ display: "none" })),
|
|
89
|
+
when("& mark", raw({ backgroundColor: "transparent", color: "inherit", fontWeight: "700" })),
|
|
90
|
+
], mix), children: [option.icon ? (_jsx("span", { "aria-hidden": "true", mix: [
|
|
91
|
+
rounded("md"),
|
|
92
|
+
bg("neutral.bg-tint-hover"),
|
|
93
|
+
fg("neutral"),
|
|
94
|
+
raw({
|
|
95
|
+
display: "grid",
|
|
96
|
+
placeItems: "center",
|
|
97
|
+
flexShrink: "0",
|
|
98
|
+
inlineSize: "2rem",
|
|
99
|
+
blockSize: "2rem",
|
|
100
|
+
"& svg": { inlineSize: "1rem", blockSize: "1rem" },
|
|
101
|
+
}),
|
|
102
|
+
], children: option.icon })) : null, _jsxs("span", { mix: [raw({ display: "grid", minInlineSize: "0", flex: "1" })], children: [_jsx("span", { "data-autocomplete-label": "", mix: [truncate(), text("sm"), fg("neutral.emphasis")], children: option.label }), option.description ? (_jsx("span", { "data-autocomplete-description": "", mix: [truncate(), text("xs"), fg("neutral.muted")], children: option.description })) : null] })] }));
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The island inside every {@link Autocomplete}: once hydrated it drops the field's datalist,
|
|
107
|
+
* makes the field a combobox and opens the styled list on focus and typing. It renders only a
|
|
108
|
+
* hidden marker, so the field and options stay server markup styled by the caller's mixins.
|
|
109
|
+
*
|
|
110
|
+
* @example <AutocompleteSync />
|
|
111
|
+
*/
|
|
112
|
+
export const AutocompleteSync = clientEntry("@sdxc/ui/autocomplete#AutocompleteSync", function AutocompleteSync() {
|
|
113
|
+
return () => _jsx("span", { hidden: true, mix: [autocomplete()] });
|
|
114
|
+
});
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
10
10
|
* @copyright Sergio Xalambrí 2026
|
|
11
11
|
*/
|
|
12
|
-
import type { Handle, Props as TagProps } from "remix/component";
|
|
12
|
+
import type { EntryComponent, Handle, Props as TagProps } from "remix/component";
|
|
13
13
|
import { Button } from "./button.js";
|
|
14
14
|
/**
|
|
15
15
|
* Prop types for {@link Carousel} and its compound parts.
|
|
@@ -58,6 +58,26 @@ export declare namespace Carousel {
|
|
|
58
58
|
* Every {@link Button.Props} field, with `commandfor` required and `command`
|
|
59
59
|
* narrowed to the verb the paired mixin listens for.
|
|
60
60
|
*/
|
|
61
|
+
/** Every native `<div>` attribute, plus the dots' viewport, count and names. */
|
|
62
|
+
interface DotsProps extends Omit<TagProps<"div">, "children"> {
|
|
63
|
+
/** `id` of the {@link Carousel.Viewport} the dots move. */
|
|
64
|
+
commandfor: string;
|
|
65
|
+
/** How many slides the viewport holds, one dot each. */
|
|
66
|
+
count: number;
|
|
67
|
+
/** Each dot's accessible name, from its zero-based index, such as "Photo 2 of 3". */
|
|
68
|
+
label: (index: number) => string;
|
|
69
|
+
/** The slide the page renders in view, marked before script runs. @default 0 */
|
|
70
|
+
current?: number;
|
|
71
|
+
}
|
|
72
|
+
/** Every native `<span>` attribute, plus the viewport it reads and its size. */
|
|
73
|
+
interface CountProps extends Omit<TagProps<"span">, "children"> {
|
|
74
|
+
/** `id` of the {@link Carousel.Viewport} whose position it shows. */
|
|
75
|
+
viewport: string;
|
|
76
|
+
/** How many slides the viewport holds. */
|
|
77
|
+
total: number;
|
|
78
|
+
/** The slide the page renders in view. @default 0 */
|
|
79
|
+
current?: number;
|
|
80
|
+
}
|
|
61
81
|
interface NextProps extends Omit<Button.Props, "commandfor" | "command"> {
|
|
62
82
|
/** `id` of the {@link Carousel.Viewport} this control scrolls forward through. */
|
|
63
83
|
commandfor: string;
|
|
@@ -108,4 +128,14 @@ export declare namespace Carousel {
|
|
|
108
128
|
var Controls: (handle: Handle<Carousel.ControlsProps>) => () => import("remix/component").RemixElement;
|
|
109
129
|
var Previous: (handle: Handle<Carousel.PreviousProps>) => () => import("remix/component").RemixElement;
|
|
110
130
|
var Next: (handle: Handle<Carousel.NextProps>) => () => import("remix/component").RemixElement;
|
|
131
|
+
var Dots: (handle: Handle<Carousel.DotsProps>) => () => import("remix/component").RemixElement;
|
|
132
|
+
var Count: (handle: Handle<Carousel.CountProps>) => () => import("remix/component").RemixElement;
|
|
111
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* The island that runs a Carousel without a page-written island around its viewport: a
|
|
136
|
+
* hidden marker placed anywhere inside the {@link Carousel} root. It loads from
|
|
137
|
+
* `@sdxc/ui/carousel`, which the app's browser entry maps to an import.
|
|
138
|
+
*
|
|
139
|
+
* @example <Carousel>…<CarouselSync /></Carousel>
|
|
140
|
+
*/
|
|
141
|
+
export declare const CarouselSync: EntryComponent<Record<never, never>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx } from "remix/component/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "remix/component/jsx-runtime";
|
|
2
2
|
import { ChevronLeftIcon, ChevronRightIcon } from "@sdxc/icons";
|
|
3
3
|
import { outline } from "@sdxc/u/color";
|
|
4
4
|
import { raw, vars, mergeMix } from "@sdxc/u/general";
|
|
@@ -6,7 +6,8 @@ import { flex, flexCol, gap, grow, items, justify, shrink } from "@sdxc/u/layout
|
|
|
6
6
|
import { media } from "@sdxc/u/responsive";
|
|
7
7
|
import { bs, is, minIs, pi } from "@sdxc/u/size";
|
|
8
8
|
import { when } from "@sdxc/u/state";
|
|
9
|
-
import { attrs } from "remix/component";
|
|
9
|
+
import { attrs, clientEntry } from "remix/component";
|
|
10
|
+
import { carouselSync } from "../mixins/carousel-controls.js";
|
|
10
11
|
import { Button } from "./button.js";
|
|
11
12
|
/** Native ARIA role applied to {@link Carousel.Viewport} unless a consumer overrides it. */
|
|
12
13
|
const DEFAULT_VIEWPORT_ROLE = "group";
|
|
@@ -149,7 +150,7 @@ Carousel.Track = function CarouselTrack(handle) {
|
|
|
149
150
|
Carousel.Slide = function CarouselSlide(handle) {
|
|
150
151
|
return () => {
|
|
151
152
|
let { mix, ...rest } = handle.props;
|
|
152
|
-
return (_jsx("div", { ...rest, "data-slot": "slide", mix: mergeMix([
|
|
153
|
+
return (_jsx("div", { ...rest, "data-slot": "slide", "data-carousel-slide": "", mix: mergeMix([
|
|
153
154
|
attrs({ role: DEFAULT_SLIDE_ROLE }),
|
|
154
155
|
grow(0),
|
|
155
156
|
shrink(0),
|
|
@@ -223,3 +224,65 @@ Carousel.Next = function CarouselNext(handle) {
|
|
|
223
224
|
return (_jsx(Button, { ...rest, type: "button", variant: resolvedVariant, color: resolvedColor, size: resolvedSize, command: resolvedCommand, "data-slot": "next", mix: mergeMix([minIs(0), when("& > svg", [is(4), bs(4)])], mix), children: children ?? _jsx(ChevronRightIcon, {}) }));
|
|
224
225
|
};
|
|
225
226
|
};
|
|
227
|
+
/**
|
|
228
|
+
* A row of dots, one `--ui-goto` invoker per slide, the one in view marked with
|
|
229
|
+
* `aria-current`. Each dot draws 6px inside a 24px target, so a row reads as a position
|
|
230
|
+
* indicator and still takes a thumb; it needs `carouselControls()` or {@link CarouselSync}.
|
|
231
|
+
*
|
|
232
|
+
* @example <Carousel.Dots commandfor="photos" count={3} label={(i) => `Photo ${i + 1} of 3`} />
|
|
233
|
+
*/
|
|
234
|
+
Carousel.Dots = function CarouselDots(handle) {
|
|
235
|
+
return () => {
|
|
236
|
+
let { commandfor, count, current = 0, label, mix, ...rest } = handle.props;
|
|
237
|
+
return (_jsx("div", { ...rest, "data-slot": "dots", mix: mergeMix([flex(), justify("center"), items("center")], mix), children: Array.from({ length: count }, (_, index) => (_jsx("button", { type: "button", commandfor: commandfor, command: "--ui-goto", "data-slide": String(index), "aria-label": label(index), "aria-current": index === current ? "true" : undefined, mix: [
|
|
238
|
+
raw({
|
|
239
|
+
display: "grid",
|
|
240
|
+
placeItems: "center",
|
|
241
|
+
inlineSize: "var(--ui-carousel-dot-target, 1.5rem)",
|
|
242
|
+
blockSize: "var(--ui-carousel-dot-target, 1.5rem)",
|
|
243
|
+
marginInline: "calc((var(--ui-carousel-dot-target, 1.5rem) - 0.75rem) / -2)",
|
|
244
|
+
padding: "0",
|
|
245
|
+
border: "0",
|
|
246
|
+
background: "transparent",
|
|
247
|
+
cursor: "pointer",
|
|
248
|
+
"&::before": {
|
|
249
|
+
content: '""',
|
|
250
|
+
inlineSize: "0.375rem",
|
|
251
|
+
blockSize: "0.375rem",
|
|
252
|
+
borderRadius: "999px",
|
|
253
|
+
backgroundColor: "var(--ui-carousel-dot, color-mix(in oklch, currentColor 45%, transparent))",
|
|
254
|
+
transition: "background-color 150ms ease, scale 150ms ease",
|
|
255
|
+
},
|
|
256
|
+
}),
|
|
257
|
+
when('&[aria-current="true"]::before', raw({
|
|
258
|
+
backgroundColor: "var(--ui-carousel-dot-current, currentColor)",
|
|
259
|
+
scale: "1.25",
|
|
260
|
+
})),
|
|
261
|
+
when("&:focus-visible", outline({ color: "brand.ring", offset: 0 })),
|
|
262
|
+
media("(prefers-reduced-motion: reduce)", raw({ "&::before": { transition: "none" } })),
|
|
263
|
+
] }))) }));
|
|
264
|
+
};
|
|
265
|
+
};
|
|
266
|
+
/**
|
|
267
|
+
* The position as `n / N` in tabular figures, rewritten as the viewport scrolls by
|
|
268
|
+
* `carouselControls()` or {@link CarouselSync}. It is hidden from assistive tech, since
|
|
269
|
+
* the dots' current marker already says the same.
|
|
270
|
+
*
|
|
271
|
+
* @example <Carousel.Count viewport="photos" total={3} />
|
|
272
|
+
*/
|
|
273
|
+
Carousel.Count = function CarouselCount(handle) {
|
|
274
|
+
return () => {
|
|
275
|
+
let { current = 0, mix, total, viewport, ...rest } = handle.props;
|
|
276
|
+
return (_jsxs("span", { ...rest, "aria-hidden": "true", "data-slot": "count", "data-carousel-count-for": viewport, mix: mergeMix([raw({ fontVariantNumeric: "tabular-nums" })], mix), children: [current + 1, " / ", total] }));
|
|
277
|
+
};
|
|
278
|
+
};
|
|
279
|
+
/**
|
|
280
|
+
* The island that runs a Carousel without a page-written island around its viewport: a
|
|
281
|
+
* hidden marker placed anywhere inside the {@link Carousel} root. It loads from
|
|
282
|
+
* `@sdxc/ui/carousel`, which the app's browser entry maps to an import.
|
|
283
|
+
*
|
|
284
|
+
* @example <Carousel>…<CarouselSync /></Carousel>
|
|
285
|
+
*/
|
|
286
|
+
export const CarouselSync = clientEntry("@sdxc/ui/carousel#CarouselSync", function CarouselSync() {
|
|
287
|
+
return () => _jsx("span", { hidden: true, mix: [carouselSync()] });
|
|
288
|
+
});
|
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
export * from "./accordion.js";
|
|
11
11
|
export * from "./alert-dialog.js";
|
|
12
12
|
export * from "./alert.js";
|
|
13
|
+
export * from "./amount.js";
|
|
13
14
|
export * from "./aspect-ratio.js";
|
|
15
|
+
export * from "./autocomplete.js";
|
|
14
16
|
export * from "./avatar.js";
|
|
15
17
|
export * from "./badge.js";
|
|
16
18
|
export * from "./breadcrumbs.js";
|
|
@@ -47,10 +49,13 @@ export * from "./item.js";
|
|
|
47
49
|
export * from "./keyboard.js";
|
|
48
50
|
export * from "./label-chip.js";
|
|
49
51
|
export * from "./label.js";
|
|
52
|
+
export * from "./letterbox.js";
|
|
53
|
+
export * from "./lightbox.js";
|
|
50
54
|
export * from "./link-button.js";
|
|
51
55
|
export * from "./link.js";
|
|
52
56
|
export * from "./listbox.js";
|
|
53
57
|
export * from "./logo.js";
|
|
58
|
+
export * from "./media-grid.js";
|
|
54
59
|
export * from "./menu.js";
|
|
55
60
|
export * from "./meter.js";
|
|
56
61
|
export * from "./modal.js";
|
|
@@ -64,9 +69,13 @@ export * from "./popover.js";
|
|
|
64
69
|
export * from "./progress-bar.js";
|
|
65
70
|
export * from "./radio-group.js";
|
|
66
71
|
export * from "./range-calendar.js";
|
|
72
|
+
export * from "./range-months.js";
|
|
73
|
+
export * from "./rating-input.js";
|
|
74
|
+
export * from "./rating.js";
|
|
67
75
|
export * from "./scroll-area.js";
|
|
68
76
|
export * from "./search-field.js";
|
|
69
77
|
export * from "./section.js";
|
|
78
|
+
export * from "./section-bar.js";
|
|
70
79
|
export * from "./select.js";
|
|
71
80
|
export * from "./selection-indicator.js";
|
|
72
81
|
export * from "./sentinel-row.js";
|
|
@@ -76,6 +85,7 @@ export * from "./sheet.js";
|
|
|
76
85
|
export * from "./sidebar.js";
|
|
77
86
|
export * from "./slider.js";
|
|
78
87
|
export * from "./spinner.js";
|
|
88
|
+
export * from "./step-indicator.js";
|
|
79
89
|
export * from "./switch.js";
|
|
80
90
|
export * from "./tabs.js";
|
|
81
91
|
export * from "./tag-group.js";
|
|
@@ -90,5 +100,6 @@ export * from "./youtube-embed.js";
|
|
|
90
100
|
export * from "./banner.js";
|
|
91
101
|
export * from "./property-list.js";
|
|
92
102
|
export * from "./relative-time.js";
|
|
103
|
+
export * from "./review-card.js";
|
|
93
104
|
export * from "./status-dot.js";
|
|
94
105
|
export * from "./timeline.js";
|
package/dist/components/index.js
CHANGED
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
export * from "./accordion.js";
|
|
11
11
|
export * from "./alert-dialog.js";
|
|
12
12
|
export * from "./alert.js";
|
|
13
|
+
export * from "./amount.js";
|
|
13
14
|
export * from "./aspect-ratio.js";
|
|
15
|
+
export * from "./autocomplete.js";
|
|
14
16
|
export * from "./avatar.js";
|
|
15
17
|
export * from "./badge.js";
|
|
16
18
|
export * from "./breadcrumbs.js";
|
|
@@ -47,10 +49,13 @@ export * from "./item.js";
|
|
|
47
49
|
export * from "./keyboard.js";
|
|
48
50
|
export * from "./label-chip.js";
|
|
49
51
|
export * from "./label.js";
|
|
52
|
+
export * from "./letterbox.js";
|
|
53
|
+
export * from "./lightbox.js";
|
|
50
54
|
export * from "./link-button.js";
|
|
51
55
|
export * from "./link.js";
|
|
52
56
|
export * from "./listbox.js";
|
|
53
57
|
export * from "./logo.js";
|
|
58
|
+
export * from "./media-grid.js";
|
|
54
59
|
export * from "./menu.js";
|
|
55
60
|
export * from "./meter.js";
|
|
56
61
|
export * from "./modal.js";
|
|
@@ -64,9 +69,13 @@ export * from "./popover.js";
|
|
|
64
69
|
export * from "./progress-bar.js";
|
|
65
70
|
export * from "./radio-group.js";
|
|
66
71
|
export * from "./range-calendar.js";
|
|
72
|
+
export * from "./range-months.js";
|
|
73
|
+
export * from "./rating-input.js";
|
|
74
|
+
export * from "./rating.js";
|
|
67
75
|
export * from "./scroll-area.js";
|
|
68
76
|
export * from "./search-field.js";
|
|
69
77
|
export * from "./section.js";
|
|
78
|
+
export * from "./section-bar.js";
|
|
70
79
|
export * from "./select.js";
|
|
71
80
|
export * from "./selection-indicator.js";
|
|
72
81
|
export * from "./sentinel-row.js";
|
|
@@ -76,6 +85,7 @@ export * from "./sheet.js";
|
|
|
76
85
|
export * from "./sidebar.js";
|
|
77
86
|
export * from "./slider.js";
|
|
78
87
|
export * from "./spinner.js";
|
|
88
|
+
export * from "./step-indicator.js";
|
|
79
89
|
export * from "./switch.js";
|
|
80
90
|
export * from "./tabs.js";
|
|
81
91
|
export * from "./tag-group.js";
|
|
@@ -90,5 +100,6 @@ export * from "./youtube-embed.js";
|
|
|
90
100
|
export * from "./banner.js";
|
|
91
101
|
export * from "./property-list.js";
|
|
92
102
|
export * from "./relative-time.js";
|
|
103
|
+
export * from "./review-card.js";
|
|
93
104
|
export * from "./status-dot.js";
|
|
94
105
|
export * from "./timeline.js";
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A frame that fills whatever box holds it and centres a fixed-ratio surface inside, with bars
|
|
3
|
+
* on the two sides the ratio leaves empty. The surface is a size container, so content drawn on
|
|
4
|
+
* it in `cqw`/`cqh` scales with it: a slide, a game screen or a player at any window size.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { Handle, Props as TagProps } from "remix/component";
|
|
10
|
+
/**
|
|
11
|
+
* Prop types for {@link Letterbox}.
|
|
12
|
+
*/
|
|
13
|
+
export declare namespace Letterbox {
|
|
14
|
+
/**
|
|
15
|
+
* Props accepted by {@link Letterbox}.
|
|
16
|
+
*/
|
|
17
|
+
interface Props extends TagProps<"div"> {
|
|
18
|
+
/**
|
|
19
|
+
* Width divided by height of the surface, as a number so the frame can size the surface
|
|
20
|
+
* with it (`4 / 3`, `1`).
|
|
21
|
+
*
|
|
22
|
+
* @default 16 / 9
|
|
23
|
+
*/
|
|
24
|
+
ratio?: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Props accepted by {@link Letterbox.Surface}.
|
|
28
|
+
*/
|
|
29
|
+
interface SurfaceProps extends TagProps<"div"> {
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Fills its container and paints the bars in `--ui-letterbox-bars` (black by default). In a
|
|
34
|
+
* container with no definite height the frame takes its height from its width at the ratio, so
|
|
35
|
+
* the surface fills it with no bars. The ratio rides on `--ui-letterbox-ratio`.
|
|
36
|
+
*
|
|
37
|
+
* @param handle Runtime handle carrying the frame's props.
|
|
38
|
+
* @returns The render function producing the frame's markup.
|
|
39
|
+
* @example
|
|
40
|
+
* <Letterbox ratio={16 / 9}>
|
|
41
|
+
* <Letterbox.Surface mix={css({ fontSize: "4cqh" })}>Slide one</Letterbox.Surface>
|
|
42
|
+
* </Letterbox>
|
|
43
|
+
*/
|
|
44
|
+
export declare function Letterbox(handle: Handle<Letterbox.Props>): () => import("remix/component").RemixElement;
|
|
45
|
+
export declare namespace Letterbox {
|
|
46
|
+
var Surface: (handle: Handle<Letterbox.SurfaceProps>) => () => import("remix/component").RemixElement;
|
|
47
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { jsx as _jsx } from "remix/component/jsx-runtime";
|
|
2
|
+
import { mergeMix } from "@sdxc/u/general";
|
|
3
|
+
import { css } from "remix/component";
|
|
4
|
+
import { mergeStyle } from "../utils/merge-style.js";
|
|
5
|
+
/** 16:9, the widescreen ratio a frame keeps without a `ratio` prop. */
|
|
6
|
+
const DEFAULT_RATIO = 16 / 9;
|
|
7
|
+
/**
|
|
8
|
+
* Fills its container and paints the bars in `--ui-letterbox-bars` (black by default). In a
|
|
9
|
+
* container with no definite height the frame takes its height from its width at the ratio, so
|
|
10
|
+
* the surface fills it with no bars. The ratio rides on `--ui-letterbox-ratio`.
|
|
11
|
+
*
|
|
12
|
+
* @param handle Runtime handle carrying the frame's props.
|
|
13
|
+
* @returns The render function producing the frame's markup.
|
|
14
|
+
* @example
|
|
15
|
+
* <Letterbox ratio={16 / 9}>
|
|
16
|
+
* <Letterbox.Surface mix={css({ fontSize: "4cqh" })}>Slide one</Letterbox.Surface>
|
|
17
|
+
* </Letterbox>
|
|
18
|
+
*/
|
|
19
|
+
export function Letterbox(handle) {
|
|
20
|
+
return () => {
|
|
21
|
+
let { ratio, style, mix, ...rest } = handle.props;
|
|
22
|
+
return (_jsx("div", { ...rest, "data-slot": "letterbox", style: mergeStyle(style, { "--ui-letterbox-ratio": String(ratio ?? DEFAULT_RATIO) }), mix: mergeMix(css({
|
|
23
|
+
position: "relative",
|
|
24
|
+
inlineSize: "100%",
|
|
25
|
+
blockSize: "100%",
|
|
26
|
+
aspectRatio: "var(--ui-letterbox-ratio)",
|
|
27
|
+
containerType: "size",
|
|
28
|
+
overflow: "hidden",
|
|
29
|
+
background: "var(--ui-letterbox-bars, #000)",
|
|
30
|
+
}), mix) }));
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The fixed-ratio area inside a {@link Letterbox}: as large as fits the frame, centred on both
|
|
35
|
+
* axes, and a size container, so its children size in `cqw`/`cqh` of the surface itself. Name
|
|
36
|
+
* the container through `mix` to target it from an `@container` query.
|
|
37
|
+
*
|
|
38
|
+
* @param handle Runtime handle carrying the surface's props.
|
|
39
|
+
* @returns The render function producing the surface's markup.
|
|
40
|
+
* @example
|
|
41
|
+
* <Letterbox.Surface mix={css({ containerName: "slide" })}>{slide}</Letterbox.Surface>
|
|
42
|
+
*/
|
|
43
|
+
Letterbox.Surface = function LetterboxSurface(handle) {
|
|
44
|
+
return () => {
|
|
45
|
+
let { mix, ...rest } = handle.props;
|
|
46
|
+
return (_jsx("div", { ...rest, "data-slot": "surface", mix: mergeMix(css({
|
|
47
|
+
position: "absolute",
|
|
48
|
+
inset: 0,
|
|
49
|
+
margin: "auto",
|
|
50
|
+
inlineSize: "min(100cqw, calc(100cqh * var(--ui-letterbox-ratio)))",
|
|
51
|
+
blockSize: "min(100cqh, calc(100cqw / var(--ui-letterbox-ratio)))",
|
|
52
|
+
containerType: "size",
|
|
53
|
+
overflow: "clip",
|
|
54
|
+
}), mix) }));
|
|
55
|
+
};
|
|
56
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A full-screen photo viewer for a gallery, as a native `<dialog>` a trigger opens through
|
|
3
|
+
* Invoker Commands. Every photo sits in a scroll-snap track with its own address, so swiping
|
|
4
|
+
* and the step links work without script; a small island adds arrow keys and opening at a photo.
|
|
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
|
+
/**
|
|
11
|
+
* Prop types for {@link Lightbox} and its compound parts.
|
|
12
|
+
*/
|
|
13
|
+
export declare namespace Lightbox {
|
|
14
|
+
/** One photo in the gallery. */
|
|
15
|
+
interface Photo {
|
|
16
|
+
/** The image's address; leave it out to draw the photo with `art` instead. */
|
|
17
|
+
src?: string;
|
|
18
|
+
/** Candidate sources, as the native `srcset`. */
|
|
19
|
+
srcset?: string;
|
|
20
|
+
/** What the photo shows, for a reader who cannot see it. */
|
|
21
|
+
alt: string;
|
|
22
|
+
/** A line under the photo, such as the room it shows. */
|
|
23
|
+
caption?: RemixNode;
|
|
24
|
+
/**
|
|
25
|
+
* Drawn content standing in for `src`, such as an inline SVG with a `viewBox`; it is
|
|
26
|
+
* scaled to fit the viewer as an image would be.
|
|
27
|
+
*/
|
|
28
|
+
art?: RemixNode;
|
|
29
|
+
}
|
|
30
|
+
/** The words each control is named by. */
|
|
31
|
+
interface Labels {
|
|
32
|
+
/** @default "Close" */
|
|
33
|
+
close: string;
|
|
34
|
+
/** @default "Previous photo" */
|
|
35
|
+
previous: string;
|
|
36
|
+
/** @default "Next photo" */
|
|
37
|
+
next: string;
|
|
38
|
+
}
|
|
39
|
+
/** Every native `<dialog>` attribute, plus the gallery. */
|
|
40
|
+
interface Props extends Omit<TagProps<"dialog">, "children" | "open"> {
|
|
41
|
+
/** Targeted by each trigger's `commandfor`, and the prefix of every photo's own id. */
|
|
42
|
+
id: string;
|
|
43
|
+
/** The gallery's name, such as "Photos of Fern Cabin", read when the viewer opens. */
|
|
44
|
+
label: string;
|
|
45
|
+
photos: Photo[];
|
|
46
|
+
/**
|
|
47
|
+
* Renders the viewer already open at this zero-based photo, for a page whose address
|
|
48
|
+
* names one (`?photo=3`). Without script it is a non-modal dialog covering the page;
|
|
49
|
+
* the island reopens it as a modal.
|
|
50
|
+
*/
|
|
51
|
+
initial?: number;
|
|
52
|
+
labels?: Partial<Labels>;
|
|
53
|
+
}
|
|
54
|
+
/** Every native `<button>` attribute, plus the viewer and photo it opens. */
|
|
55
|
+
interface TriggerProps extends Omit<TagProps<"button">, "commandfor" | "command"> {
|
|
56
|
+
/** `id` of the {@link Lightbox} this opens. */
|
|
57
|
+
lightbox: string;
|
|
58
|
+
/**
|
|
59
|
+
* Zero-based photo the viewer opens at once the island has loaded.
|
|
60
|
+
*
|
|
61
|
+
* @default 0
|
|
62
|
+
*/
|
|
63
|
+
index?: number;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Loads the viewer's script: the hidden host whose mixin wires the arrow keys, the
|
|
68
|
+
* index-aware triggers and the live region. It loads from `@sdxc/ui/lightbox`, which the
|
|
69
|
+
* app's browser entry maps; {@link Lightbox} renders it, so a page never places it itself.
|
|
70
|
+
*/
|
|
71
|
+
export declare const LightboxControls: EntryComponent<Record<never, never>>;
|
|
72
|
+
/**
|
|
73
|
+
* Renders the viewer: a full-screen dark `<dialog>` with a close button, one slide per photo
|
|
74
|
+
* (contained, with "n / N" and its caption) and step links between neighbours. Opened from a
|
|
75
|
+
* {@link Lightbox.Trigger}; Escape and the close button dismiss it.
|
|
76
|
+
*
|
|
77
|
+
* @param handle Runtime handle carrying the dialog's props.
|
|
78
|
+
* @returns The render function producing the viewer's markup.
|
|
79
|
+
* @example
|
|
80
|
+
* <Lightbox.Trigger lightbox="cabin-photos" index={2}><img src={thumb} alt="" /></Lightbox.Trigger>
|
|
81
|
+
* <Lightbox id="cabin-photos" label="Photos of Fern Cabin" photos={photos} />
|
|
82
|
+
* @example
|
|
83
|
+
* <Lightbox id="cabin-photos" label="Photos" photos={photos} initial={Number(url.searchParams.get("photo")) - 1} />
|
|
84
|
+
*/
|
|
85
|
+
export declare function Lightbox(handle: Handle<Lightbox.Props>): () => import("remix/component").RemixElement;
|
|
86
|
+
export declare namespace Lightbox {
|
|
87
|
+
var Trigger: (handle: Handle<Lightbox.TriggerProps>) => () => import("remix/component").RemixElement;
|
|
88
|
+
}
|