@sdxc/ui 2026.10.12 → 2026.10.14
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 +524 -668
- package/dist/animations/transitions.d.ts +45 -20
- package/dist/animations/transitions.js +108 -35
- package/dist/behaviors/announcer.js +2 -1
- package/dist/behaviors/toaster.js +2 -1
- package/dist/components/accordion.js +5 -9
- package/dist/components/alert-dialog.js +3 -3
- package/dist/components/alert.js +11 -2
- package/dist/components/attachment.js +1 -1
- package/dist/components/badge.js +2 -1
- package/dist/components/breadcrumbs.js +17 -9
- package/dist/components/bubble.js +6 -5
- package/dist/components/button.d.ts +14 -0
- package/dist/components/button.js +61 -20
- package/dist/components/calendar.js +12 -8
- package/dist/components/card.d.ts +5 -3
- package/dist/components/card.js +32 -14
- package/dist/components/carousel.js +4 -6
- package/dist/components/chart.js +5 -4
- package/dist/components/checkbox.js +2 -2
- package/dist/components/color-picker.js +8 -11
- package/dist/components/color-slider.js +16 -5
- package/dist/components/color-swatch-picker.js +7 -4
- package/dist/components/color-wheel.js +7 -9
- package/dist/components/combobox.js +5 -1
- package/dist/components/command.d.ts +3 -3
- package/dist/components/command.js +25 -28
- package/dist/components/context-menu.js +4 -4
- package/dist/components/date-field.js +2 -1
- package/dist/components/date-picker.js +12 -16
- package/dist/components/description.js +2 -2
- package/dist/components/dialog.js +19 -15
- package/dist/components/disclosure.js +15 -17
- package/dist/components/drawer.d.ts +5 -5
- package/dist/components/drawer.js +38 -33
- package/dist/components/drop-indicator.js +4 -10
- package/dist/components/empty.js +13 -6
- package/dist/components/field-error.js +2 -1
- package/dist/components/file-trigger.js +7 -10
- package/dist/components/grid-list.js +15 -16
- package/dist/components/group.js +5 -6
- package/dist/components/heading.js +2 -1
- package/dist/components/hover-card.js +4 -5
- package/dist/components/image-placeholder.js +17 -12
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/input.js +8 -11
- package/dist/components/item.js +4 -7
- package/dist/components/keyboard.js +9 -9
- package/dist/components/link-button.js +26 -8
- package/dist/components/listbox.d.ts +3 -2
- package/dist/components/listbox.js +9 -8
- package/dist/components/menu.js +6 -6
- package/dist/components/menubar.js +6 -5
- package/dist/components/message-scroller.js +4 -6
- package/dist/components/message.js +2 -2
- package/dist/components/meter.js +2 -2
- package/dist/components/modal.d.ts +2 -2
- package/dist/components/modal.js +12 -24
- package/dist/components/navigation-menu.js +5 -4
- package/dist/components/number-field.js +6 -6
- package/dist/components/overlay-arrow.js +2 -2
- package/dist/components/pagination.js +3 -1
- package/dist/components/popover.js +7 -19
- package/dist/components/progress-bar.js +2 -2
- package/dist/components/range-calendar.js +5 -3
- package/dist/components/resizable.js +8 -3
- package/dist/components/search-field.js +7 -7
- package/dist/components/select.js +26 -39
- package/dist/components/sheet.js +30 -22
- package/dist/components/shortcut-list.js +2 -2
- package/dist/components/sidebar.js +24 -22
- package/dist/components/slider.d.ts +3 -3
- package/dist/components/slider.js +18 -6
- package/dist/components/switch.js +2 -2
- package/dist/components/table.d.ts +15 -2
- package/dist/components/table.js +36 -14
- package/dist/components/tag-group.js +10 -5
- package/dist/components/text.js +2 -2
- package/dist/components/time-field.js +2 -1
- package/dist/components/toast.js +5 -2
- package/dist/components/toggle-button.js +28 -12
- package/dist/components/tree.js +9 -5
- package/dist/components/typeset.js +5 -2
- package/dist/components/youtube-embed.d.ts +35 -0
- package/dist/components/youtube-embed.js +29 -0
- package/dist/mixins/carousel-controls.js +11 -15
- package/dist/mixins/clear-field.js +4 -5
- package/dist/mixins/context-menu.js +5 -8
- package/dist/mixins/grid-list-keys.js +5 -2
- package/dist/mixins/listbox-keys.js +1 -1
- package/dist/mixins/message-follow.js +7 -13
- package/dist/mixins/treeKeys.js +5 -3
- package/dist/styles/floating-surface.d.ts +62 -14
- package/dist/styles/floating-surface.js +67 -10
- package/dist/styles/hit-area.d.ts +36 -0
- package/dist/styles/hit-area.js +48 -0
- package/dist/styles/index.d.ts +1 -0
- package/dist/styles/index.js +1 -0
- package/dist/styles/output-caption-text.d.ts +3 -2
- package/dist/styles/output-caption-text.js +4 -3
- package/dist/styles/range-thumb-appearance.js +17 -18
- package/dist/utils/glyph-edges.d.ts +24 -0
- package/dist/utils/glyph-edges.js +46 -0
- package/package.json +5 -4
- package/src/reset.css +4 -1
- package/src/theme.css +49 -2
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* The core CSS-only enter/exit transition system: the `enterExit()` composer
|
|
3
3
|
* and the `fade()`/`zoom()`/`slide()` presets built on top of it. Every
|
|
4
4
|
* factory returns a `css()`-compatible style mixin driven entirely by
|
|
5
|
-
* platform state
|
|
5
|
+
* platform state; exits run shorter and travel less than entries.
|
|
6
6
|
*
|
|
7
7
|
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
8
8
|
* @copyright Sergio Xalambrí 2026
|
|
@@ -13,21 +13,36 @@ import type { CSSMixinDescriptor } from "remix/component";
|
|
|
13
13
|
*/
|
|
14
14
|
export declare namespace EnterExit {
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* `
|
|
16
|
+
* The off-stage value of each animated CSS property; the entered state is
|
|
17
|
+
* always that property's reset (`1` for opacity, `none` for `scale`,
|
|
18
|
+
* `translate` and `filter`). Omitted fields leave their property as is.
|
|
19
19
|
*/
|
|
20
|
-
interface
|
|
21
|
-
/**
|
|
20
|
+
interface Values {
|
|
21
|
+
/** Off-stage `opacity`, 0 to 1. */
|
|
22
22
|
opacity?: number;
|
|
23
|
-
/**
|
|
23
|
+
/** Off-stage `scale` factor, e.g. `0.95`. */
|
|
24
24
|
scale?: number;
|
|
25
|
-
/**
|
|
25
|
+
/** Off-stage `translate` value, e.g. `"0 0.5rem"`. */
|
|
26
26
|
translate?: string;
|
|
27
|
-
/**
|
|
27
|
+
/** Off-stage `filter: blur()` radius in pixels, e.g. `4`. */
|
|
28
|
+
blur?: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The top-level values are where the host enters from. `exit` overrides
|
|
32
|
+
* any of them for where it leaves to, and a property only `exit` names
|
|
33
|
+
* enters from its reset, so a surface can blur away without blurring in.
|
|
34
|
+
*/
|
|
35
|
+
interface Options extends Values {
|
|
36
|
+
/** Where the host leaves to, per property; each omitted field reuses its entry value. */
|
|
37
|
+
exit?: Values;
|
|
38
|
+
/** Entry duration in milliseconds. Defaults to `durations.normal`. */
|
|
28
39
|
duration?: number;
|
|
29
|
-
/** A `transition-timing-function` value. Defaults to `easings.standard`. */
|
|
40
|
+
/** A `transition-timing-function` value for the entry. Defaults to `easings.standard`. */
|
|
30
41
|
easing?: string;
|
|
42
|
+
/** Exit duration in milliseconds. Defaults to three quarters of `duration`. */
|
|
43
|
+
exitDuration?: number;
|
|
44
|
+
/** A `transition-timing-function` value for the exit. Defaults to `easing`. */
|
|
45
|
+
exitEasing?: string;
|
|
31
46
|
/**
|
|
32
47
|
* A selector fragment relative to the host (e.g. `"[data-visible]"`)
|
|
33
48
|
* marking the entered state, replacing the `[open]`/`:popover-open`
|
|
@@ -37,11 +52,13 @@ export declare namespace EnterExit {
|
|
|
37
52
|
}
|
|
38
53
|
}
|
|
39
54
|
/**
|
|
40
|
-
* Composes a CSS-only enter/exit transition mixin
|
|
41
|
-
*
|
|
42
|
-
*
|
|
55
|
+
* Composes a CSS-only enter/exit transition mixin: `@starting-style` paints
|
|
56
|
+
* the first entered frame from the entry values, and closing transitions to
|
|
57
|
+
* the exit values on the exit timing. Every change is a transition, so a
|
|
58
|
+
* reversal mid-flight retargets smoothly. Owns the host's `transition`, so
|
|
59
|
+
* apply exactly one animation factory per host.
|
|
43
60
|
*
|
|
44
|
-
* @param options
|
|
61
|
+
* @param options Entry and exit values, their timing, and the entered-state selector.
|
|
45
62
|
* @returns A `css()` mixin ready for a host element's `mix` prop.
|
|
46
63
|
* @example
|
|
47
64
|
* <div id="filters" popover="auto" mix={enterExit({ opacity: 0, scale: 0.95, duration: 150 })}>
|
|
@@ -49,6 +66,8 @@ export declare namespace EnterExit {
|
|
|
49
66
|
* </div>;
|
|
50
67
|
* @example
|
|
51
68
|
* <div data-visible mix={enterExit({ opacity: 0, when: "[data-visible]" })}>...</div>;
|
|
69
|
+
* @example
|
|
70
|
+
* <dialog mix={enterExit({ translate: "100% 0", exit: { translate: "1rem 0", opacity: 0, blur: 4 } })}>...</dialog>;
|
|
52
71
|
*/
|
|
53
72
|
export declare function enterExit(options?: EnterExit.Options): CSSMixinDescriptor;
|
|
54
73
|
/**
|
|
@@ -58,6 +77,8 @@ export declare namespace Fade {
|
|
|
58
77
|
interface Options {
|
|
59
78
|
/** Exit-state opacity (0 to 1). Defaults to `0` — fully transparent when closed. */
|
|
60
79
|
opacity?: number;
|
|
80
|
+
/** Blur radius in pixels the host softens from and to while it fades. */
|
|
81
|
+
blur?: number;
|
|
61
82
|
/** Transition duration in milliseconds. Defaults to `durations.normal`. */
|
|
62
83
|
duration?: number;
|
|
63
84
|
/** A `transition-timing-function` value. Defaults to `easings.standard`. */
|
|
@@ -85,8 +106,10 @@ export declare namespace Zoom {
|
|
|
85
106
|
interface Options {
|
|
86
107
|
/** Exit-state opacity (0 to 1). Defaults to `0`. */
|
|
87
108
|
opacity?: number;
|
|
88
|
-
/**
|
|
109
|
+
/** Scale factor the host enters from (e.g. `0.95`). Defaults to `0.95`. */
|
|
89
110
|
scale?: number;
|
|
111
|
+
/** Blur radius in pixels the host softens from and to while it scales. */
|
|
112
|
+
blur?: number;
|
|
90
113
|
/** Transition duration in milliseconds. Defaults to `durations.normal`. */
|
|
91
114
|
duration?: number;
|
|
92
115
|
/** A `transition-timing-function` value. Defaults to `easings.standard`. */
|
|
@@ -97,8 +120,8 @@ export declare namespace Zoom {
|
|
|
97
120
|
}
|
|
98
121
|
/**
|
|
99
122
|
* A fade paired with a scale, entering from slightly smaller than rest and
|
|
100
|
-
* exiting back down to it
|
|
101
|
-
*
|
|
123
|
+
* exiting halfway back down to it, so leaving reads quieter than arriving:
|
|
124
|
+
* sugar over {@link enterExit} for the dialog/menu/popover "pop".
|
|
102
125
|
*
|
|
103
126
|
* @param options Exit-state opacity and scale, timing, and entered-state selector.
|
|
104
127
|
* @returns A `css()` mixin ready for a host element's `mix` prop.
|
|
@@ -116,8 +139,10 @@ export declare namespace Slide {
|
|
|
116
139
|
type From = "top" | "right" | "bottom" | "left";
|
|
117
140
|
interface Options {
|
|
118
141
|
from: From;
|
|
119
|
-
/** How far
|
|
142
|
+
/** How far off its resting position the host enters from. Defaults to `"0.5rem"`; the exit travels half of it. */
|
|
120
143
|
distance?: string;
|
|
144
|
+
/** Blur radius in pixels the host softens from and to while it travels. */
|
|
145
|
+
blur?: number;
|
|
121
146
|
/** Exit-state opacity (0 to 1). Defaults to `0`. */
|
|
122
147
|
opacity?: number;
|
|
123
148
|
/** Transition duration in milliseconds. Defaults to `durations.normal`. */
|
|
@@ -130,8 +155,8 @@ export declare namespace Slide {
|
|
|
130
155
|
}
|
|
131
156
|
/**
|
|
132
157
|
* A fade paired with a directional offset, entering from just off one edge
|
|
133
|
-
* of its resting position and exiting back toward it
|
|
134
|
-
*
|
|
158
|
+
* of its resting position and exiting half that distance back toward it, so
|
|
159
|
+
* leaving reads quieter than arriving: sugar over {@link enterExit}.
|
|
135
160
|
*
|
|
136
161
|
* @param options Which edge to travel from, the offset distance, opacity, timing, and entered-state selector.
|
|
137
162
|
* @returns A `css()` mixin ready for a host element's `mix` prop.
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { css } from "remix/component";
|
|
2
2
|
import { durations, easings } from "./tokens.js";
|
|
3
3
|
const RESET_TRANSFORM = "none";
|
|
4
|
+
const RESET_FILTER = "none";
|
|
4
5
|
const DEFAULT_DURATION_MS = durations.normal;
|
|
5
6
|
const DEFAULT_EASING = easings.standard;
|
|
7
|
+
/**
|
|
8
|
+
* Share of the entry duration an exit takes by default: leaving is the
|
|
9
|
+
* moment the reader has already moved on from, so it resolves sooner than
|
|
10
|
+
* the arrival they were waiting for.
|
|
11
|
+
*/
|
|
12
|
+
const EXIT_DURATION_RATIO = 0.75;
|
|
13
|
+
/** Properties whose motion `prefers-reduced-motion: reduce` removes, keeping only opacity. */
|
|
14
|
+
const MOTION_PROPERTIES = new Set(["scale", "translate", "filter"]);
|
|
6
15
|
/**
|
|
7
16
|
* Default entered-state selector: matches the `open` attribute shared by
|
|
8
17
|
* `<dialog open>` and `<details open>`, and the `:popover-open` pseudo-class
|
|
@@ -10,11 +19,44 @@ const DEFAULT_EASING = easings.standard;
|
|
|
10
19
|
*/
|
|
11
20
|
const DEFAULT_ENTERED_SELECTOR = "&[open], &:popover-open";
|
|
12
21
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
22
|
+
* The CSS declaration each {@link EnterExit.Values} field animates, in the
|
|
23
|
+
* order they are listed in `transition-property`, with the declared value
|
|
24
|
+
* for an off-stage value and for the entered state.
|
|
25
|
+
*/
|
|
26
|
+
const CHANNELS = [
|
|
27
|
+
{
|
|
28
|
+
key: "opacity",
|
|
29
|
+
property: "opacity",
|
|
30
|
+
value: (value) => value,
|
|
31
|
+
reset: 1,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
key: "scale",
|
|
35
|
+
property: "scale",
|
|
36
|
+
value: (value) => String(value),
|
|
37
|
+
reset: RESET_TRANSFORM,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
key: "translate",
|
|
41
|
+
property: "translate",
|
|
42
|
+
value: (value) => value,
|
|
43
|
+
reset: RESET_TRANSFORM,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
key: "blur",
|
|
47
|
+
property: "filter",
|
|
48
|
+
value: (value) => `blur(${value}px)`,
|
|
49
|
+
reset: RESET_FILTER,
|
|
50
|
+
},
|
|
51
|
+
];
|
|
52
|
+
/**
|
|
53
|
+
* Composes a CSS-only enter/exit transition mixin: `@starting-style` paints
|
|
54
|
+
* the first entered frame from the entry values, and closing transitions to
|
|
55
|
+
* the exit values on the exit timing. Every change is a transition, so a
|
|
56
|
+
* reversal mid-flight retargets smoothly. Owns the host's `transition`, so
|
|
57
|
+
* apply exactly one animation factory per host.
|
|
16
58
|
*
|
|
17
|
-
* @param options
|
|
59
|
+
* @param options Entry and exit values, their timing, and the entered-state selector.
|
|
18
60
|
* @returns A `css()` mixin ready for a host element's `mix` prop.
|
|
19
61
|
* @example
|
|
20
62
|
* <div id="filters" popover="auto" mix={enterExit({ opacity: 0, scale: 0.95, duration: 150 })}>
|
|
@@ -22,47 +64,56 @@ const DEFAULT_ENTERED_SELECTOR = "&[open], &:popover-open";
|
|
|
22
64
|
* </div>;
|
|
23
65
|
* @example
|
|
24
66
|
* <div data-visible mix={enterExit({ opacity: 0, when: "[data-visible]" })}>...</div>;
|
|
67
|
+
* @example
|
|
68
|
+
* <dialog mix={enterExit({ translate: "100% 0", exit: { translate: "1rem 0", opacity: 0, blur: 4 } })}>...</dialog>;
|
|
25
69
|
*/
|
|
26
70
|
export function enterExit(options = {}) {
|
|
27
71
|
let duration = options.duration ?? DEFAULT_DURATION_MS;
|
|
28
72
|
let easing = options.easing ?? DEFAULT_EASING;
|
|
73
|
+
let exitDuration = options.exitDuration ?? Math.round(duration * EXIT_DURATION_RATIO);
|
|
74
|
+
let exitEasing = options.exitEasing ?? easing;
|
|
75
|
+
let exit = options.exit ?? {};
|
|
29
76
|
let entered = options.when ? `&${options.when}` : DEFAULT_ENTERED_SELECTOR;
|
|
30
77
|
let transitionProperties = [];
|
|
78
|
+
let entryState = {};
|
|
31
79
|
let exitState = {};
|
|
32
80
|
let enteredState = {};
|
|
33
81
|
let reducedMotion = {};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
82
|
+
for (let channel of CHANNELS) {
|
|
83
|
+
let entry = options[channel.key];
|
|
84
|
+
let leave = exit[channel.key] ?? entry;
|
|
85
|
+
if (entry === undefined && leave === undefined)
|
|
86
|
+
continue;
|
|
87
|
+
transitionProperties.push(channel.property);
|
|
88
|
+
Object.assign(entryState, {
|
|
89
|
+
[channel.property]: entry === undefined ? channel.reset : channel.value(entry),
|
|
90
|
+
});
|
|
91
|
+
Object.assign(exitState, {
|
|
92
|
+
[channel.property]: leave === undefined ? channel.reset : channel.value(leave),
|
|
93
|
+
});
|
|
94
|
+
Object.assign(enteredState, { [channel.property]: channel.reset });
|
|
95
|
+
if (MOTION_PROPERTIES.has(channel.property)) {
|
|
96
|
+
Object.assign(reducedMotion, { [channel.property]: channel.reset });
|
|
97
|
+
}
|
|
50
98
|
}
|
|
51
99
|
transitionProperties.push("display", "overlay");
|
|
52
100
|
let startingStyle = {};
|
|
53
|
-
startingStyle[entered] =
|
|
101
|
+
startingStyle[entered] = entryState;
|
|
54
102
|
reducedMotion.transitionProperty = transitionProperties
|
|
55
|
-
.filter((property) => property
|
|
103
|
+
.filter((property) => !MOTION_PROPERTIES.has(property))
|
|
56
104
|
.join(", ");
|
|
57
105
|
let output = Object.assign({}, exitState, {
|
|
58
106
|
transitionProperty: transitionProperties.join(", "),
|
|
59
|
-
transitionDuration: `${
|
|
60
|
-
transitionTimingFunction:
|
|
107
|
+
transitionDuration: `${exitDuration}ms`,
|
|
108
|
+
transitionTimingFunction: exitEasing,
|
|
61
109
|
transitionBehavior: "allow-discrete",
|
|
62
110
|
"@starting-style": startingStyle,
|
|
63
111
|
"@media (prefers-reduced-motion: reduce)": reducedMotion,
|
|
64
112
|
});
|
|
65
|
-
output[entered] = enteredState
|
|
113
|
+
output[entered] = Object.assign(enteredState, {
|
|
114
|
+
transitionDuration: `${duration}ms`,
|
|
115
|
+
transitionTimingFunction: easing,
|
|
116
|
+
});
|
|
66
117
|
return css(output);
|
|
67
118
|
}
|
|
68
119
|
const DEFAULT_FADE_OPACITY = 0;
|
|
@@ -80,6 +131,7 @@ const DEFAULT_FADE_OPACITY = 0;
|
|
|
80
131
|
export function fade(options = {}) {
|
|
81
132
|
return enterExit({
|
|
82
133
|
opacity: options.opacity ?? DEFAULT_FADE_OPACITY,
|
|
134
|
+
blur: options.blur,
|
|
83
135
|
duration: options.duration,
|
|
84
136
|
easing: options.easing,
|
|
85
137
|
when: options.when,
|
|
@@ -89,8 +141,8 @@ const DEFAULT_ZOOM_OPACITY = 0;
|
|
|
89
141
|
const DEFAULT_ZOOM_SCALE = 0.95;
|
|
90
142
|
/**
|
|
91
143
|
* A fade paired with a scale, entering from slightly smaller than rest and
|
|
92
|
-
* exiting back down to it
|
|
93
|
-
*
|
|
144
|
+
* exiting halfway back down to it, so leaving reads quieter than arriving:
|
|
145
|
+
* sugar over {@link enterExit} for the dialog/menu/popover "pop".
|
|
94
146
|
*
|
|
95
147
|
* @param options Exit-state opacity and scale, timing, and entered-state selector.
|
|
96
148
|
* @returns A `css()` mixin ready for a host element's `mix` prop.
|
|
@@ -100,9 +152,12 @@ const DEFAULT_ZOOM_SCALE = 0.95;
|
|
|
100
152
|
* </dialog>;
|
|
101
153
|
*/
|
|
102
154
|
export function zoom(options = {}) {
|
|
155
|
+
let scale = options.scale ?? DEFAULT_ZOOM_SCALE;
|
|
103
156
|
return enterExit({
|
|
104
157
|
opacity: options.opacity ?? DEFAULT_ZOOM_OPACITY,
|
|
105
|
-
scale
|
|
158
|
+
scale,
|
|
159
|
+
blur: options.blur,
|
|
160
|
+
exit: { scale: Number((1 - (1 - scale) / 2).toFixed(4)) },
|
|
106
161
|
duration: options.duration,
|
|
107
162
|
easing: options.easing,
|
|
108
163
|
when: options.when,
|
|
@@ -110,23 +165,38 @@ export function zoom(options = {}) {
|
|
|
110
165
|
}
|
|
111
166
|
const DEFAULT_SLIDE_OPACITY = 0;
|
|
112
167
|
const DEFAULT_SLIDE_DISTANCE = "0.5rem";
|
|
113
|
-
/**
|
|
168
|
+
/**
|
|
169
|
+
* Matches a plain length (`0.5rem`, `12px`, `.5em`, `50%`) whose number can be
|
|
170
|
+
* halved directly. The three numeric alternatives are mutually exclusive so a
|
|
171
|
+
* long run of digits still costs linear time when the string is not a length.
|
|
172
|
+
*/
|
|
173
|
+
const PLAIN_LENGTH = /^(\d+\.\d+|\d+|\.\d+)([a-z%]*)$/i;
|
|
174
|
+
/** Negates a length, keeping a plain length readable (`-0.5rem`) and wrapping anything else in `calc()`. */
|
|
175
|
+
function negate(distance) {
|
|
176
|
+
return PLAIN_LENGTH.test(distance) ? `-${distance}` : `calc(-1 * ${distance})`;
|
|
177
|
+
}
|
|
178
|
+
/** Halves a length, keeping a plain length readable (`0.25rem`) and wrapping anything else in `calc()`. */
|
|
179
|
+
function halve(distance) {
|
|
180
|
+
let match = PLAIN_LENGTH.exec(distance);
|
|
181
|
+
return match ? `${Number(match[1]) / 2}${match[2]}` : `calc(${distance} / 2)`;
|
|
182
|
+
}
|
|
183
|
+
/** Builds the `translate` value that offsets the host toward the given edge. */
|
|
114
184
|
function offsetFor(from, distance) {
|
|
115
185
|
switch (from) {
|
|
116
186
|
case "top":
|
|
117
|
-
return `0
|
|
187
|
+
return `0 ${negate(distance)}`;
|
|
118
188
|
case "bottom":
|
|
119
189
|
return `0 ${distance}`;
|
|
120
190
|
case "left":
|
|
121
|
-
return
|
|
191
|
+
return `${negate(distance)} 0`;
|
|
122
192
|
case "right":
|
|
123
193
|
return `${distance} 0`;
|
|
124
194
|
}
|
|
125
195
|
}
|
|
126
196
|
/**
|
|
127
197
|
* A fade paired with a directional offset, entering from just off one edge
|
|
128
|
-
* of its resting position and exiting back toward it
|
|
129
|
-
*
|
|
198
|
+
* of its resting position and exiting half that distance back toward it, so
|
|
199
|
+
* leaving reads quieter than arriving: sugar over {@link enterExit}.
|
|
130
200
|
*
|
|
131
201
|
* @param options Which edge to travel from, the offset distance, opacity, timing, and entered-state selector.
|
|
132
202
|
* @returns A `css()` mixin ready for a host element's `mix` prop.
|
|
@@ -136,10 +206,13 @@ function offsetFor(from, distance) {
|
|
|
136
206
|
* </dialog>;
|
|
137
207
|
*/
|
|
138
208
|
export function slide(options) {
|
|
139
|
-
let { from, distance, opacity, duration, easing, when } = options;
|
|
209
|
+
let { from, distance, opacity, blur, duration, easing, when } = options;
|
|
210
|
+
let resolvedDistance = distance ?? DEFAULT_SLIDE_DISTANCE;
|
|
140
211
|
return enterExit({
|
|
141
212
|
opacity: opacity ?? DEFAULT_SLIDE_OPACITY,
|
|
142
|
-
translate: offsetFor(from,
|
|
213
|
+
translate: offsetFor(from, resolvedDistance),
|
|
214
|
+
blur,
|
|
215
|
+
exit: { translate: offsetFor(from, halve(resolvedDistance)) },
|
|
143
216
|
duration,
|
|
144
217
|
easing,
|
|
145
218
|
when,
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
8
8
|
* @copyright Sergio Xalambrí 2026
|
|
9
9
|
*/
|
|
10
|
+
import { generateUUID } from "@sdxc/uuid/v4";
|
|
10
11
|
import { TypedEventTarget } from "remix/component";
|
|
11
12
|
const DEFAULT_PRIORITY = "polite";
|
|
12
13
|
/**
|
|
@@ -56,7 +57,7 @@ export class Announcer extends TypedEventTarget {
|
|
|
56
57
|
* announcer.announce("5 results found");
|
|
57
58
|
*/
|
|
58
59
|
announce(text, priority = DEFAULT_PRIORITY) {
|
|
59
|
-
let message = { id:
|
|
60
|
+
let message = { id: generateUUID(), text, priority };
|
|
60
61
|
if (priority === "assertive") {
|
|
61
62
|
let index = this.#queue.findIndex((queued) => queued.priority !== "assertive");
|
|
62
63
|
if (index === -1)
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
8
8
|
* @copyright Sergio Xalambrí 2026
|
|
9
9
|
*/
|
|
10
|
+
import { generateUUID } from "@sdxc/uuid/v4";
|
|
10
11
|
import { TypedEventTarget } from "remix/component";
|
|
11
12
|
import { dispatchChange } from "../utils/dispatch-change.js";
|
|
12
13
|
/** Auto-dismiss delay, in milliseconds, a toast uses when {@link Toaster.AddOptions.duration} is omitted. */
|
|
@@ -68,7 +69,7 @@ export class Toaster extends TypedEventTarget {
|
|
|
68
69
|
* toaster.add({ title: "Saved" }, { duration: 3000 })
|
|
69
70
|
*/
|
|
70
71
|
add(data, options = {}) {
|
|
71
|
-
let id = options.id ??
|
|
72
|
+
let id = options.id ?? generateUUID();
|
|
72
73
|
let duration = options.duration === undefined ? this.#defaultDuration : options.duration;
|
|
73
74
|
let existing = this.#toasts.get(id);
|
|
74
75
|
if (existing)
|
|
@@ -6,7 +6,7 @@ import { media } from "@sdxc/u/responsive";
|
|
|
6
6
|
import { bs, is, pb, pbe, pi } from "@sdxc/u/size";
|
|
7
7
|
import { hover, open, when } from "@sdxc/u/state";
|
|
8
8
|
import { rotate } from "@sdxc/u/transform";
|
|
9
|
-
import { text, textDecoration } from "@sdxc/u/typography";
|
|
9
|
+
import { pretty, text, textDecoration } from "@sdxc/u/typography";
|
|
10
10
|
import { Disclosure } from "./disclosure.js";
|
|
11
11
|
/**
|
|
12
12
|
* Renders the list's root host: a plain `<div>` that stacks
|
|
@@ -146,9 +146,9 @@ Accordion.Trigger = function AccordionTrigger(handle) {
|
|
|
146
146
|
};
|
|
147
147
|
};
|
|
148
148
|
/**
|
|
149
|
-
* Renders {@link Accordion.ContentProps.children} as the section's revealed
|
|
150
|
-
*
|
|
151
|
-
* muted text sized for supporting copy.
|
|
149
|
+
* Renders {@link Accordion.ContentProps.children} as the section's revealed body:
|
|
150
|
+
* {@link Disclosure.Panel} running edge to edge like its trigger, with block-end
|
|
151
|
+
* padding and small, muted text sized for supporting copy.
|
|
152
152
|
*
|
|
153
153
|
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
154
154
|
* @returns The render function producing the body's markup.
|
|
@@ -160,10 +160,6 @@ Accordion.Trigger = function AccordionTrigger(handle) {
|
|
|
160
160
|
Accordion.Content = function AccordionContent(handle) {
|
|
161
161
|
return () => {
|
|
162
162
|
let { mix, ...rest } = handle.props;
|
|
163
|
-
|
|
164
|
-
* A row in an accordion runs edge to edge, the way its trigger does, so the panel's
|
|
165
|
-
* own inline inset is released here rather than carried through.
|
|
166
|
-
*/
|
|
167
|
-
return _jsx(Disclosure.Panel, { ...rest, mix: [pi(0), pbe(4), fg("neutral"), text("sm"), mix] });
|
|
163
|
+
return (_jsx(Disclosure.Panel, { ...rest, mix: [pi(0), pbe(4), fg("neutral"), text("sm"), pretty(), mix] }));
|
|
168
164
|
};
|
|
169
165
|
};
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "remix/component/jsx-runtime";
|
|
|
2
2
|
import { fg } from "@sdxc/u/color";
|
|
3
3
|
import { flex, gap, justify, vstack } from "@sdxc/u/layout";
|
|
4
4
|
import { mbs } from "@sdxc/u/size";
|
|
5
|
-
import { text, weight } from "@sdxc/u/typography";
|
|
5
|
+
import { balance, pretty, text, weight } from "@sdxc/u/typography";
|
|
6
6
|
import { Button } from "./button.js";
|
|
7
7
|
import { Dialog } from "./dialog.js";
|
|
8
8
|
import { resolveHeadingLevel, TAG_BY_LEVEL } from "./heading-scope.js";
|
|
@@ -84,7 +84,7 @@ AlertDialog.Title = function AlertDialogTitle(handle) {
|
|
|
84
84
|
let { mix, ...rest } = handle.props;
|
|
85
85
|
let resolved = resolveHeadingLevel(handle);
|
|
86
86
|
let Tag = TAG_BY_LEVEL[resolved];
|
|
87
|
-
return (_jsx(Tag, { ...rest, "data-slot": "title", mix: [fg("neutral.emphasis"), weight("semibold"), text("lg"), mix], children: rest.children }));
|
|
87
|
+
return (_jsx(Tag, { ...rest, "data-slot": "title", mix: [fg("neutral.emphasis"), weight("semibold"), text("lg"), balance(), mix], children: rest.children }));
|
|
88
88
|
};
|
|
89
89
|
};
|
|
90
90
|
/**
|
|
@@ -100,7 +100,7 @@ AlertDialog.Title = function AlertDialogTitle(handle) {
|
|
|
100
100
|
AlertDialog.Description = function AlertDialogDescription(handle) {
|
|
101
101
|
return () => {
|
|
102
102
|
let { mix, ...rest } = handle.props;
|
|
103
|
-
return (_jsx("p", { ...rest, "data-slot": "description", mix: [fg("neutral.muted"), text("sm"), mix], children: rest.children }));
|
|
103
|
+
return (_jsx("p", { ...rest, "data-slot": "description", mix: [fg("neutral.muted"), text("sm"), pretty(), mix], children: rest.children }));
|
|
104
104
|
};
|
|
105
105
|
};
|
|
106
106
|
/**
|
package/dist/components/alert.js
CHANGED
|
@@ -4,7 +4,7 @@ import { rounded } from "@sdxc/u/effects";
|
|
|
4
4
|
import { absolute, basis, gap, grow, inset, relative, self, shrink, vstack } from "@sdxc/u/layout";
|
|
5
5
|
import { bs, is, mbe, minIs, p, pis } from "@sdxc/u/size";
|
|
6
6
|
import { when } from "@sdxc/u/state";
|
|
7
|
-
import { fontSize, leading, tracking, weight } from "@sdxc/u/typography";
|
|
7
|
+
import { balance, fontSize, leading, pretty, tracking, weight } from "@sdxc/u/typography";
|
|
8
8
|
import { attrs } from "remix/component";
|
|
9
9
|
import { semanticColorPanel } from "../styles/semantic-color-panel.js";
|
|
10
10
|
import { DEFAULT_ICON_ARIA_HIDDEN } from "../utils/decorative-icon.js";
|
|
@@ -121,7 +121,15 @@ Alert.Title = function AlertTitle(handle) {
|
|
|
121
121
|
let { children, mix, ...rest } = handle.props;
|
|
122
122
|
let resolved = resolveHeadingLevel(handle);
|
|
123
123
|
let Tag = TAG_BY_LEVEL[resolved];
|
|
124
|
-
return (_jsx(Tag, { ...rest, "data-heading-level": resolved, "data-slot": "title", mix: [
|
|
124
|
+
return (_jsx(Tag, { ...rest, "data-heading-level": resolved, "data-slot": "title", mix: [
|
|
125
|
+
mbe(1),
|
|
126
|
+
weight("medium"),
|
|
127
|
+
leading(1),
|
|
128
|
+
tracking("tight"),
|
|
129
|
+
fontSize("sm"),
|
|
130
|
+
balance(),
|
|
131
|
+
mix,
|
|
132
|
+
], children: children }));
|
|
125
133
|
};
|
|
126
134
|
};
|
|
127
135
|
/**
|
|
@@ -138,6 +146,7 @@ Alert.Description = function AlertDescription(handle) {
|
|
|
138
146
|
return (_jsx("p", { ...rest, "data-slot": "description", mix: [
|
|
139
147
|
leading("relaxed"),
|
|
140
148
|
when("& p", leading("relaxed")),
|
|
149
|
+
pretty(),
|
|
141
150
|
fontSize("sm"),
|
|
142
151
|
fg(colorMix("oklab", { color: "currentcolor", weight: 70 }, "transparent")),
|
|
143
152
|
mix,
|
|
@@ -174,7 +174,7 @@ Attachment.Title = function AttachmentTitle(handle) {
|
|
|
174
174
|
weight("semibold"),
|
|
175
175
|
truncate(),
|
|
176
176
|
text("sm"),
|
|
177
|
-
|
|
177
|
+
/**
|
|
178
178
|
* The loop settles visible, because this host carries the file's name: a gated
|
|
179
179
|
* loop rests hidden outside its gate, which suits an element that exists only
|
|
180
180
|
* as a loading cue and would leave every finished upload unnamed.
|
package/dist/components/badge.js
CHANGED
|
@@ -5,7 +5,7 @@ import { userSelect } from "@sdxc/u/general";
|
|
|
5
5
|
import { gap, inlineFlex, items, shrink } from "@sdxc/u/layout";
|
|
6
6
|
import { bs, is, pb, pi } from "@sdxc/u/size";
|
|
7
7
|
import { data, when } from "@sdxc/u/state";
|
|
8
|
-
import { fontSize, leading, nowrap, weight } from "@sdxc/u/typography";
|
|
8
|
+
import { fontSize, leading, nowrap, tabularNums, weight } from "@sdxc/u/typography";
|
|
9
9
|
import { attrs } from "remix/component";
|
|
10
10
|
import { DEFAULT_ICON_ARIA_HIDDEN } from "../utils/decorative-icon.js";
|
|
11
11
|
/** Semantic color role {@link Badge} falls back to when `color` is omitted. */
|
|
@@ -44,6 +44,7 @@ export function Badge(handle) {
|
|
|
44
44
|
pb(0.5),
|
|
45
45
|
leading(1),
|
|
46
46
|
weight("semibold"),
|
|
47
|
+
tabularNums(),
|
|
47
48
|
nowrap(),
|
|
48
49
|
transition("color, background-color, border-color, outline-color, text-decoration-color, fill, stroke"),
|
|
49
50
|
fontSize("xs"),
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "remix/component/jsx-runtime";
|
|
2
2
|
import { fg } from "@sdxc/u/color";
|
|
3
|
-
import { listStyle,
|
|
4
|
-
import { flex,
|
|
5
|
-
import { m,
|
|
3
|
+
import { listStyle, pseudoContent } from "@sdxc/u/general";
|
|
4
|
+
import { flex, items } from "@sdxc/u/layout";
|
|
5
|
+
import { m, mb, mis, p, pb, pi } from "@sdxc/u/size";
|
|
6
6
|
import { data, hover, when } from "@sdxc/u/state";
|
|
7
7
|
import { fontSize, textDecoration, weight } from "@sdxc/u/typography";
|
|
8
8
|
import { warnIfNoAccessibleLabel } from "../utils/warn-if-no-accessible-name.js";
|
|
@@ -39,8 +39,8 @@ export function Breadcrumbs(handle) {
|
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
41
|
* Renders the trail's `<ol>` list, resetting native list markers and spacing
|
|
42
|
-
* and laying {@link Breadcrumbs.Item} children out
|
|
43
|
-
*
|
|
42
|
+
* and laying {@link Breadcrumbs.Item} children out in a row whose spacing
|
|
43
|
+
* comes from each {@link Breadcrumbs.Link}'s padding, so the gaps stay clickable.
|
|
44
44
|
*
|
|
45
45
|
* @param handle Runtime handle carrying the host `<ol>`'s props.
|
|
46
46
|
* @returns The render function producing the list's markup.
|
|
@@ -54,7 +54,7 @@ export function Breadcrumbs(handle) {
|
|
|
54
54
|
Breadcrumbs.List = function BreadcrumbsList(handle) {
|
|
55
55
|
return () => {
|
|
56
56
|
let { mix, ...rest } = handle.props;
|
|
57
|
-
return (_jsx("ol", { ...rest, "data-slot": "list", mix: [flex(), items("center"),
|
|
57
|
+
return (_jsx("ol", { ...rest, "data-slot": "list", mix: [flex(), items("center"), m(0), p(0), listStyle(), mix] }));
|
|
58
58
|
};
|
|
59
59
|
};
|
|
60
60
|
/**
|
|
@@ -75,12 +75,10 @@ Breadcrumbs.Item = function BreadcrumbsItem(handle) {
|
|
|
75
75
|
return (_jsx("li", { ...rest, "data-slot": "item", mix: [
|
|
76
76
|
flex(),
|
|
77
77
|
items("center"),
|
|
78
|
-
gap(1),
|
|
79
78
|
when("&:not(:last-child)::after", [
|
|
80
|
-
mi(1),
|
|
81
79
|
fg("neutral.muted"),
|
|
82
80
|
fontSize("sm"),
|
|
83
|
-
|
|
81
|
+
pseudoContent('"›"'),
|
|
84
82
|
]),
|
|
85
83
|
mix,
|
|
86
84
|
] }));
|
|
@@ -108,6 +106,16 @@ Breadcrumbs.Link = function BreadcrumbsLink(handle) {
|
|
|
108
106
|
let resolvedColor = color ?? DEFAULT_COLOR;
|
|
109
107
|
return (_jsx(Link, { color: resolvedColor, ...rest, "data-slot": "link", mix: [
|
|
110
108
|
fontSize("sm"),
|
|
109
|
+
/**
|
|
110
|
+
* The space around each separator lives in the link's own padding, so the
|
|
111
|
+
* whole gap is clickable; the block padding reaches a 24px target and its
|
|
112
|
+
* negative margin keeps the row at the text's height. The trail's first link
|
|
113
|
+
* pulls back by its padding so the trail stays flush with its container.
|
|
114
|
+
*/
|
|
115
|
+
pi(2),
|
|
116
|
+
pb(0.5),
|
|
117
|
+
mb(-0.5),
|
|
118
|
+
when('[data-slot="item"]:first-child > &', mis(-2)),
|
|
111
119
|
textDecoration("none"),
|
|
112
120
|
hover(textDecoration("none")),
|
|
113
121
|
data("color", "neutral", [fg("neutral.muted"), hover(fg("neutral"))]),
|
|
@@ -5,7 +5,7 @@ import { raw, vars } from "@sdxc/u/general";
|
|
|
5
5
|
import { block, flex, flexWrap, gap, items, vstack } from "@sdxc/u/layout";
|
|
6
6
|
import { maxIs, mie, mis, pb, pbe, pi, width } from "@sdxc/u/size";
|
|
7
7
|
import { data, when } from "@sdxc/u/state";
|
|
8
|
-
import { wordBreak } from "@sdxc/u/typography";
|
|
8
|
+
import { pretty, wordBreak } from "@sdxc/u/typography";
|
|
9
9
|
import { attrs } from "remix/component";
|
|
10
10
|
/** Selector matching every framed variant, the ones that hug their own text. */
|
|
11
11
|
const FRAMED = '&:not([data-variant="ghost"])';
|
|
@@ -120,6 +120,7 @@ Bubble.Content = function BubbleContent(handle) {
|
|
|
120
120
|
overflowWrap: "break-word",
|
|
121
121
|
}),
|
|
122
122
|
wordBreak("break-word"),
|
|
123
|
+
pretty(),
|
|
123
124
|
mix,
|
|
124
125
|
], children: children }));
|
|
125
126
|
};
|
|
@@ -162,10 +163,10 @@ Bubble.Reactions = function BubbleReactions(handle) {
|
|
|
162
163
|
flexWrap("wrap"),
|
|
163
164
|
items("center"),
|
|
164
165
|
gap(1),
|
|
165
|
-
|
|
166
|
-
* The row sits on the line the turn's own text sits on
|
|
167
|
-
*
|
|
168
|
-
*
|
|
166
|
+
/**
|
|
167
|
+
* The row sits on the line the turn's own text sits on and clears the frame's lower
|
|
168
|
+
* edge, inset to match the content beside it, so the reactions stay clear of the
|
|
169
|
+
* message's last line.
|
|
169
170
|
*/
|
|
170
171
|
pi(3.5),
|
|
171
172
|
pbe(2.5),
|
|
@@ -61,4 +61,18 @@ export declare namespace Button {
|
|
|
61
61
|
parts?: PartsProps;
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Visual state lives in `data-color`/`data-variant`/`data-size` on the host, so
|
|
66
|
+
* hover, pressed, and focus-visible stay on native pseudo-classes. `type` precedes
|
|
67
|
+
* the spread so the platform sees it while parsing `command`/`commandfor`.
|
|
68
|
+
*
|
|
69
|
+
* @param handle Runtime handle carrying the host `<button>`'s props.
|
|
70
|
+
* @returns The render function producing the button's markup.
|
|
71
|
+
* @example
|
|
72
|
+
* <Button type="submit">{t("actions.save")}</Button>
|
|
73
|
+
* @example
|
|
74
|
+
* <Button color="danger" variant="outline" size="sm">{t("actions.delete")}</Button>
|
|
75
|
+
* @example
|
|
76
|
+
* <Button type="submit" isPending={isSubmitting}>{t("actions.save")}</Button>
|
|
77
|
+
*/
|
|
64
78
|
export declare function Button(handle: Handle<Button.Props>): () => import("remix/component").RemixElement;
|