@sdxc/ui 2026.9.14 → 2026.9.28
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/dist/animations/keyframes.d.ts +6 -0
- package/dist/animations/keyframes.js +8 -4
- package/dist/components/accordion.js +5 -1
- package/dist/components/alert-dialog.js +2 -2
- package/dist/components/attachment.js +7 -2
- package/dist/components/bubble.js +14 -20
- package/dist/components/button.d.ts +0 -14
- package/dist/components/button.js +60 -19
- package/dist/components/calendar.js +12 -5
- package/dist/components/card.js +8 -1
- package/dist/components/carousel.js +9 -3
- package/dist/components/color-picker.js +23 -4
- package/dist/components/color-slider.js +11 -1
- package/dist/components/color-wheel.js +14 -4
- package/dist/components/command.js +34 -7
- package/dist/components/date-picker.d.ts +20 -53
- package/dist/components/date-picker.js +50 -108
- package/dist/components/date-range-picker.d.ts +22 -43
- package/dist/components/date-range-picker.js +8 -52
- package/dist/components/dialog.js +15 -3
- package/dist/components/disclosure.d.ts +4 -1
- package/dist/components/disclosure.js +52 -11
- package/dist/components/drawer.js +16 -0
- package/dist/components/drop-indicator.d.ts +9 -8
- package/dist/components/drop-indicator.js +19 -6
- package/dist/components/empty.js +18 -3
- package/dist/components/file-trigger.js +35 -15
- package/dist/components/form.d.ts +15 -1
- package/dist/components/form.js +16 -6
- package/dist/components/grid-list.js +23 -7
- package/dist/components/group.d.ts +6 -6
- package/dist/components/group.js +28 -6
- package/dist/components/hover-card.js +38 -2
- package/dist/components/image-placeholder.js +8 -2
- package/dist/components/input.js +22 -21
- package/dist/components/item.js +9 -1
- package/dist/components/keyboard.d.ts +7 -7
- package/dist/components/keyboard.js +33 -7
- package/dist/components/link-button.js +32 -18
- package/dist/components/listbox.js +10 -1
- package/dist/components/menu.js +8 -2
- package/dist/components/message-scroller.js +19 -6
- package/dist/components/meter.js +17 -8
- package/dist/components/number-field.js +9 -3
- package/dist/components/overlay-arrow.js +16 -2
- package/dist/components/popover.js +31 -8
- package/dist/components/range-calendar.js +18 -4
- package/dist/components/search-field.d.ts +26 -1
- package/dist/components/search-field.js +84 -4
- package/dist/components/select.d.ts +7 -1
- package/dist/components/select.js +33 -29
- package/dist/components/sidebar.js +32 -11
- package/dist/components/slider.js +10 -6
- package/dist/components/table.js +2 -2
- package/dist/components/toggle-button.js +39 -15
- package/dist/components/tree.d.ts +6 -6
- package/dist/components/tree.js +25 -9
- package/dist/components/typeset.js +12 -1
- package/dist/mixins/calendar-keys.d.ts +6 -6
- package/dist/mixins/calendar-keys.js +35 -6
- package/dist/mixins/carousel-controls.d.ts +4 -2
- package/dist/mixins/carousel-controls.js +71 -20
- package/dist/mixins/clear-field.d.ts +9 -7
- package/dist/mixins/clear-field.js +25 -8
- package/dist/mixins/command-keys.js +22 -7
- package/dist/mixins/context-menu.d.ts +2 -0
- package/dist/mixins/context-menu.js +27 -1
- package/dist/mixins/copy-to-clipboard.js +15 -1
- package/dist/mixins/grid-list-keys.d.ts +6 -6
- package/dist/mixins/grid-list-keys.js +28 -6
- package/dist/mixins/hotkey.js +16 -9
- package/dist/mixins/index.d.ts +1 -0
- package/dist/mixins/index.js +1 -0
- package/dist/mixins/listbox-keys.js +20 -2
- package/dist/mixins/message-follow.js +50 -12
- package/dist/mixins/mirror-selected-option.d.ts +24 -0
- package/dist/mixins/mirror-selected-option.js +35 -0
- package/dist/mixins/treeKeys.d.ts +3 -2
- package/dist/mixins/treeKeys.js +53 -6
- package/dist/mixins/validate.d.ts +1 -1
- package/package.json +2 -2
- package/src/theme.css +33 -3
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx } from "remix/ui/jsx-runtime";
|
|
2
2
|
import { bg, borderEdge, fg, outline } from "@sdxc/u/color";
|
|
3
3
|
import { opacity, roundedCorner, rounded, transition, transitionDuration } from "@sdxc/u/effects";
|
|
4
|
-
import { cursor, listStyle, raw } from "@sdxc/u/general";
|
|
5
|
-
import { flex, flexCol, gap, hidden, interpolateSize, items } from "@sdxc/u/layout";
|
|
4
|
+
import { cursor, listStyle, pointerEvents, raw } from "@sdxc/u/general";
|
|
5
|
+
import { flex, flexCol, gap, hidden, interpolateSize, items, shrink } from "@sdxc/u/layout";
|
|
6
6
|
import { overflow } from "@sdxc/u/overflow";
|
|
7
7
|
import { media } from "@sdxc/u/responsive";
|
|
8
|
-
import { bs, is, m, pb, pi } from "@sdxc/u/size";
|
|
9
|
-
import { detailsContent, hover, when } from "@sdxc/u/state";
|
|
8
|
+
import { bs, is, m, pb, pbe, pi } from "@sdxc/u/size";
|
|
9
|
+
import { detailsContent, hover, open, when } from "@sdxc/u/state";
|
|
10
|
+
import { rotate } from "@sdxc/u/transform";
|
|
10
11
|
import { textAlign, weight } from "@sdxc/u/typography";
|
|
11
12
|
import { panelChrome } from "../styles/panel-chrome.js";
|
|
12
13
|
import { resolveHeadingLevel, TAG_BY_LEVEL } from "./heading-scope.js";
|
|
@@ -19,7 +20,10 @@ import { resolveHeadingLevel, TAG_BY_LEVEL } from "./heading-scope.js";
|
|
|
19
20
|
* @returns The render function producing the section's markup.
|
|
20
21
|
* @example
|
|
21
22
|
* <Disclosure>
|
|
22
|
-
* <Disclosure.Trigger>
|
|
23
|
+
* <Disclosure.Trigger>
|
|
24
|
+
* {t("faq.refunds.question")}
|
|
25
|
+
* <ChevronDownIcon data-slot="icon" aria-hidden="true" />
|
|
26
|
+
* </Disclosure.Trigger>
|
|
23
27
|
* <Disclosure.Panel>
|
|
24
28
|
* <p>{t("faq.refunds.answer")}</p>
|
|
25
29
|
* </Disclosure.Panel>
|
|
@@ -48,7 +52,17 @@ export function Disclosure(handle) {
|
|
|
48
52
|
transitionDuration("200ms"),
|
|
49
53
|
]),
|
|
50
54
|
when("&[open]::details-content", bs("auto")),
|
|
51
|
-
|
|
55
|
+
/*
|
|
56
|
+
* The glyph a trigger carries as `data-slot="icon"` turns over while the section
|
|
57
|
+
* is open, the same rule `Accordion` states: the section owns the turn because
|
|
58
|
+
* only it knows it is open, and the trigger owns which glyph turns.
|
|
59
|
+
*/
|
|
60
|
+
open(when('& summary [data-slot="icon"]', rotate(180))),
|
|
61
|
+
when('& summary [data-slot="icon"]', transition("transform", { duration: 200 })),
|
|
62
|
+
media("(prefers-reduced-motion: reduce)", [
|
|
63
|
+
detailsContent(transitionDuration("0s")),
|
|
64
|
+
when('& summary [data-slot="icon"]', transitionDuration("0s")),
|
|
65
|
+
]),
|
|
52
66
|
mix,
|
|
53
67
|
], children: children }));
|
|
54
68
|
};
|
|
@@ -75,8 +89,11 @@ Disclosure.Header = function DisclosureHeader(handle) {
|
|
|
75
89
|
};
|
|
76
90
|
/**
|
|
77
91
|
* Renders {@link Disclosure.TriggerProps.children} inside a native `<summary>`
|
|
78
|
-
* with its marker suppressed so a consumer
|
|
79
|
-
* `
|
|
92
|
+
* with its marker suppressed, so the indicator is a glyph the consumer passes as a
|
|
93
|
+
* child carrying `data-slot="icon"` — which the section turns over while it is open.
|
|
94
|
+
* `aria-disabled="true"` also stops the section toggling: the row leaves the tab order and
|
|
95
|
+
* stops taking pointer events, which is what a `<summary>` has in place of the `disabled`
|
|
96
|
+
* a button would carry.
|
|
80
97
|
*
|
|
81
98
|
* @param handle Runtime handle carrying the host `<summary>`'s props.
|
|
82
99
|
* @returns The render function producing the trigger's markup.
|
|
@@ -88,7 +105,14 @@ Disclosure.Header = function DisclosureHeader(handle) {
|
|
|
88
105
|
Disclosure.Trigger = function DisclosureTrigger(handle) {
|
|
89
106
|
return () => {
|
|
90
107
|
let { children, mix, ...rest } = handle.props;
|
|
91
|
-
|
|
108
|
+
/*
|
|
109
|
+
* A `<summary>` has no `disabled`, so a row marked disabled is taken out of the tab
|
|
110
|
+
* order to stop Enter and Space reaching it. Paired with the pointer-events rule
|
|
111
|
+
* below, that is the whole of what `disabled` would do, and it holds before any
|
|
112
|
+
* script runs rather than waiting for a handler to cancel the toggle.
|
|
113
|
+
*/
|
|
114
|
+
let disabled = rest["aria-disabled"] === "true";
|
|
115
|
+
return (_jsx("summary", { ...rest, tabIndex: disabled ? -1 : rest.tabIndex, mix: [
|
|
92
116
|
when("&:focus-visible", outline({ color: "brand.ring", offset: 2 })),
|
|
93
117
|
flex(),
|
|
94
118
|
is("full"),
|
|
@@ -101,11 +125,17 @@ Disclosure.Trigger = function DisclosureTrigger(handle) {
|
|
|
101
125
|
weight("medium"),
|
|
102
126
|
fg("neutral.emphasis"),
|
|
103
127
|
hover(bg("neutral.tint")),
|
|
104
|
-
when('&[aria-disabled="true"]', opacity(50)),
|
|
128
|
+
when('&[aria-disabled="true"]', [opacity(50), pointerEvents("none")]),
|
|
105
129
|
cursor("pointer"),
|
|
106
130
|
listStyle(),
|
|
107
131
|
when("&::-webkit-details-marker", hidden()),
|
|
108
132
|
when("&::marker", raw({ content: '""' })),
|
|
133
|
+
/*
|
|
134
|
+
* The indicator is measured against the label it sits beside rather than against
|
|
135
|
+
* whatever an icon set draws at, and holds that measure when a long label
|
|
136
|
+
* squeezes the row.
|
|
137
|
+
*/
|
|
138
|
+
when('& [data-slot="icon"]', [is(4), bs(4), shrink()]),
|
|
109
139
|
transition("color, background-color, border-color, outline-color, text-decoration-color, fill, stroke"),
|
|
110
140
|
when('&[aria-disabled="true"]', cursor("not-allowed")),
|
|
111
141
|
mix,
|
|
@@ -127,7 +157,18 @@ Disclosure.Trigger = function DisclosureTrigger(handle) {
|
|
|
127
157
|
Disclosure.Panel = function DisclosurePanel(handle) {
|
|
128
158
|
return () => {
|
|
129
159
|
let { children, mix, ...rest } = handle.props;
|
|
130
|
-
return (_jsx("div", { ...rest, mix: [
|
|
160
|
+
return (_jsx("div", { ...rest, mix: [
|
|
161
|
+
overflow(),
|
|
162
|
+
/*
|
|
163
|
+
* The panel is inset to the same line the trigger's label sits on, so the
|
|
164
|
+
* section reads as one block rather than as a label indented above content
|
|
165
|
+
* running to the border. The block-start stays open because the trigger's own
|
|
166
|
+
* padding already separates the two.
|
|
167
|
+
*/
|
|
168
|
+
pi(3),
|
|
169
|
+
pbe(3),
|
|
170
|
+
mix,
|
|
171
|
+
], children: children }));
|
|
131
172
|
};
|
|
132
173
|
};
|
|
133
174
|
/**
|
|
@@ -52,8 +52,19 @@ export function Drawer(handle) {
|
|
|
52
52
|
}),
|
|
53
53
|
willChange("transform"),
|
|
54
54
|
transitionBehavior("allow-discrete"),
|
|
55
|
+
/*
|
|
56
|
+
* Each placement releases the edge it does not dock to. The dialog underneath
|
|
57
|
+
* constrains all four and centres itself between them, so naming only the near
|
|
58
|
+
* edge leaves that centring in force and the drawer away from the edge asked for.
|
|
59
|
+
*
|
|
60
|
+
* Both measures are stated for the same reason: a `<dialog>` sizes to its
|
|
61
|
+
* content on both axes, so pinning the two opposite insets does not stretch it.
|
|
62
|
+
* Each placement therefore gives the edge it docks to a depth and tells the
|
|
63
|
+
* other axis to fill.
|
|
64
|
+
*/
|
|
55
65
|
data("placement", "top", [
|
|
56
66
|
insBs("0"),
|
|
67
|
+
insBe("auto"),
|
|
57
68
|
insIs("0"),
|
|
58
69
|
insIe("0"),
|
|
59
70
|
bs("24rem"),
|
|
@@ -65,6 +76,7 @@ export function Drawer(handle) {
|
|
|
65
76
|
]),
|
|
66
77
|
data("placement", "bottom", [
|
|
67
78
|
insBe("0"),
|
|
79
|
+
insBs("auto"),
|
|
68
80
|
insIs("0"),
|
|
69
81
|
insIe("0"),
|
|
70
82
|
bs("24rem"),
|
|
@@ -78,8 +90,10 @@ export function Drawer(handle) {
|
|
|
78
90
|
insBs("0"),
|
|
79
91
|
insBe("0"),
|
|
80
92
|
insLeft("0"),
|
|
93
|
+
insRight("auto"),
|
|
81
94
|
is("22rem"),
|
|
82
95
|
maxIs("90vw"),
|
|
96
|
+
bs("full"),
|
|
83
97
|
maxBs("none"),
|
|
84
98
|
translateX("-100%"),
|
|
85
99
|
when("&[open]", translateX(0)),
|
|
@@ -88,8 +102,10 @@ export function Drawer(handle) {
|
|
|
88
102
|
insBs("0"),
|
|
89
103
|
insBe("0"),
|
|
90
104
|
insRight("0"),
|
|
105
|
+
insLeft("auto"),
|
|
91
106
|
is("22rem"),
|
|
92
107
|
maxIs("90vw"),
|
|
108
|
+
bs("full"),
|
|
93
109
|
maxBs("none"),
|
|
94
110
|
translateX("100%"),
|
|
95
111
|
when("&[open]", translateX(0)),
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A thin bar rendered in the gap between two items of a reorderable list,
|
|
3
|
-
* marking where a dragged item will land. It
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
3
|
+
* marking where a dragged item will land. It holds its space and paints
|
|
4
|
+
* nothing until it becomes the pointer's current drop target, so a list can
|
|
5
|
+
* carry one bar per gap and let each one answer for itself: the gaps stay the
|
|
6
|
+
* same size throughout the drag, and only the one being pointed at is drawn.
|
|
7
7
|
*
|
|
8
8
|
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
9
9
|
* @copyright Sergio Xalambrí 2026
|
|
@@ -19,16 +19,17 @@ export declare namespace DropIndicator {
|
|
|
19
19
|
interface Props extends TagProps<"div"> {
|
|
20
20
|
/**
|
|
21
21
|
* Whether this bar marks the pointer's current drop target. Renders
|
|
22
|
-
* the host's `data-drop-target` attribute when `true`,
|
|
23
|
-
*
|
|
22
|
+
* the host's `data-drop-target` attribute when `true`, which is what
|
|
23
|
+
* draws the bar. Defaults to {@link DEFAULT_IS_DROP_TARGET}.
|
|
24
24
|
*/
|
|
25
25
|
isDropTarget?: boolean;
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
29
|
* Renders a full-width, hairline-thick, fully rounded bar shaped for the gap
|
|
30
|
-
* between two items in a reorderable list.
|
|
31
|
-
*
|
|
30
|
+
* between two items in a reorderable list. The host's `data-drop-target`
|
|
31
|
+
* attribute is what paints it: transparent without it, the primary solid color
|
|
32
|
+
* with it.
|
|
32
33
|
*
|
|
33
34
|
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
34
35
|
* @returns The render function producing the bar's markup.
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx } from "remix/ui/jsx-runtime";
|
|
2
2
|
import { bg } from "@sdxc/u/color";
|
|
3
|
-
import { rounded } from "@sdxc/u/effects";
|
|
3
|
+
import { rounded, transition } from "@sdxc/u/effects";
|
|
4
4
|
import { bs, is } from "@sdxc/u/size";
|
|
5
5
|
import { when } from "@sdxc/u/state";
|
|
6
6
|
import { attrs } from "remix/ui";
|
|
7
7
|
/**
|
|
8
|
-
* Default {@link DropIndicator.Props.isDropTarget},
|
|
9
|
-
*
|
|
8
|
+
* Default {@link DropIndicator.Props.isDropTarget}, leaving the bar unpainted
|
|
9
|
+
* until a consumer marks it as the active target.
|
|
10
10
|
*/
|
|
11
11
|
const DEFAULT_IS_DROP_TARGET = false;
|
|
12
12
|
/**
|
|
@@ -17,8 +17,9 @@ const DEFAULT_IS_DROP_TARGET = false;
|
|
|
17
17
|
const DEFAULT_ARIA_HIDDEN = "true";
|
|
18
18
|
/**
|
|
19
19
|
* Renders a full-width, hairline-thick, fully rounded bar shaped for the gap
|
|
20
|
-
* between two items in a reorderable list.
|
|
21
|
-
*
|
|
20
|
+
* between two items in a reorderable list. The host's `data-drop-target`
|
|
21
|
+
* attribute is what paints it: transparent without it, the primary solid color
|
|
22
|
+
* with it.
|
|
22
23
|
*
|
|
23
24
|
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
24
25
|
* @returns The render function producing the bar's markup.
|
|
@@ -39,7 +40,19 @@ export function DropIndicator(handle) {
|
|
|
39
40
|
is("full"),
|
|
40
41
|
bs("0.125rem"),
|
|
41
42
|
rounded("full"),
|
|
42
|
-
|
|
43
|
+
transition("background-color", { duration: 150 }),
|
|
44
|
+
/*
|
|
45
|
+
* A bar that marks every gap at rest marks nothing: the list reads as though
|
|
46
|
+
* it were ruled, and the gap being pointed at looks like all the others. The
|
|
47
|
+
* resting bar therefore paints nothing while keeping its place in the layout,
|
|
48
|
+
* so the list neither reflows nor jumps when one of them lights up.
|
|
49
|
+
*
|
|
50
|
+
* The two states are written as selectors that exclude each other rather than
|
|
51
|
+
* as a resting value a state rule overrides, because each entry compiles into
|
|
52
|
+
* its own cascade layer and a plain utility's layer can land after the state
|
|
53
|
+
* rule meant to beat it — which leaves the active bar painted like the rest.
|
|
54
|
+
*/
|
|
55
|
+
when("&:not([data-drop-target])", bg("transparent")),
|
|
43
56
|
when("&[data-drop-target]", bg("brand.solid")),
|
|
44
57
|
mix,
|
|
45
58
|
] }));
|
package/dist/components/empty.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "remix/ui/jsx-runtime";
|
|
2
2
|
import { bg, border, colorMix, fg } from "@sdxc/u/color";
|
|
3
3
|
import { rounded } from "@sdxc/u/effects";
|
|
4
|
-
import { flex, flexCol, gap, items, justify } from "@sdxc/u/layout";
|
|
4
|
+
import { flex, flexCol, flexWrap, gap, items, justify } from "@sdxc/u/layout";
|
|
5
5
|
import { bs, is, mbs, p } from "@sdxc/u/size";
|
|
6
6
|
import { fontSize, leading, textAlign, tracking, weight } from "@sdxc/u/typography";
|
|
7
7
|
import { attrs } from "remix/ui";
|
|
@@ -116,7 +116,9 @@ Empty.Description = function EmptyDescription(handle) {
|
|
|
116
116
|
};
|
|
117
117
|
/**
|
|
118
118
|
* Renders {@link Empty.ActionProps.children} as the empty state's
|
|
119
|
-
* call-to-action slot, spaced a touch below the
|
|
119
|
+
* call-to-action slot: a centered, wrapping row spaced a touch below the
|
|
120
|
+
* text above it, so a state offering more than one action lays them out
|
|
121
|
+
* rather than running them together.
|
|
120
122
|
*
|
|
121
123
|
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
122
124
|
* @returns The render function producing the action slot's markup.
|
|
@@ -124,6 +126,19 @@ Empty.Description = function EmptyDescription(handle) {
|
|
|
124
126
|
Empty.Action = function EmptyAction(handle) {
|
|
125
127
|
return () => {
|
|
126
128
|
let { children, mix, ...rest } = handle.props;
|
|
127
|
-
return (_jsx("div", { ...rest, "data-slot": "action", mix: [
|
|
129
|
+
return (_jsx("div", { ...rest, "data-slot": "action", mix: [
|
|
130
|
+
/*
|
|
131
|
+
* The slot holds however many actions the state offers, so it lays them out
|
|
132
|
+
* rather than leaving them to sit flush against each other: a centered row
|
|
133
|
+
* that wraps, since two buttons side by side outgrow a narrow panel.
|
|
134
|
+
*/
|
|
135
|
+
flex(),
|
|
136
|
+
flexWrap(),
|
|
137
|
+
items("center"),
|
|
138
|
+
justify("center"),
|
|
139
|
+
gap(2),
|
|
140
|
+
mbs(1),
|
|
141
|
+
mix,
|
|
142
|
+
], children: children }));
|
|
128
143
|
};
|
|
129
144
|
};
|
|
@@ -3,8 +3,8 @@ import { visuallyHidden } from "@sdxc/u/a11y";
|
|
|
3
3
|
import { bg, border, fg, outline } from "@sdxc/u/color";
|
|
4
4
|
import { opacity, rounded } from "@sdxc/u/effects";
|
|
5
5
|
import { cursor, userSelect } from "@sdxc/u/general";
|
|
6
|
-
import { gap, inlineFlex, items, justify } from "@sdxc/u/layout";
|
|
7
|
-
import { pb, pi } from "@sdxc/u/size";
|
|
6
|
+
import { gap, inlineFlex, items, justify, shrink } from "@sdxc/u/layout";
|
|
7
|
+
import { bs, is, minBs, pb, pi } from "@sdxc/u/size";
|
|
8
8
|
import { active, data, hover, when } from "@sdxc/u/state";
|
|
9
9
|
import { text, weight } from "@sdxc/u/typography";
|
|
10
10
|
import { attrs } from "remix/ui";
|
|
@@ -52,6 +52,14 @@ export function FileTrigger(handle) {
|
|
|
52
52
|
items("center"),
|
|
53
53
|
justify("center"),
|
|
54
54
|
gap(2),
|
|
55
|
+
/*
|
|
56
|
+
* A glyph is measured against the label it sits beside rather than against
|
|
57
|
+
* whatever an icon set draws at, so the row keeps the height its text and
|
|
58
|
+
* padding ask for, and it never shrinks: squeeze the row and the default
|
|
59
|
+
* `flex-shrink: 1` compresses the glyph rather than the words, and a squashed
|
|
60
|
+
* icon reads as a rendering fault.
|
|
61
|
+
*/
|
|
62
|
+
when("& > svg", [shrink(), is(4), bs(4)]),
|
|
55
63
|
rounded("md"),
|
|
56
64
|
weight("medium"),
|
|
57
65
|
when("&:has(input:focus-visible)", [
|
|
@@ -67,8 +75,20 @@ export function FileTrigger(handle) {
|
|
|
67
75
|
pi("1rem"),
|
|
68
76
|
pb("0.5rem"),
|
|
69
77
|
text("sm"),
|
|
70
|
-
|
|
71
|
-
|
|
78
|
+
/*
|
|
79
|
+
* The row measure is stated rather than left to fall out of the padding and
|
|
80
|
+
* the border, so the control lines up with a field of the same size when a
|
|
81
|
+
* Group fuses the two, and still grows when a long label wraps.
|
|
82
|
+
*/
|
|
83
|
+
minBs("2.5rem"),
|
|
84
|
+
data("size", "sm", [
|
|
85
|
+
pi("0.75rem"),
|
|
86
|
+
pb("0.375rem"),
|
|
87
|
+
text("xs"),
|
|
88
|
+
minBs("2rem"),
|
|
89
|
+
when("& > svg", [is(3), bs(3)]),
|
|
90
|
+
]),
|
|
91
|
+
data("size", "lg", [pi("1.25rem"), pb("0.625rem"), text("base"), minBs("3rem")]),
|
|
72
92
|
data("variant", "solid", [
|
|
73
93
|
data("color", "brand", [
|
|
74
94
|
bg("brand.solid"),
|
|
@@ -102,36 +122,36 @@ export function FileTrigger(handle) {
|
|
|
102
122
|
]),
|
|
103
123
|
]),
|
|
104
124
|
data("variant", "outline", [
|
|
105
|
-
border({ width:
|
|
125
|
+
border({ width: 1, noStyleDefault: true }),
|
|
106
126
|
bg("transparent"),
|
|
107
127
|
data("color", "brand", [
|
|
108
|
-
border("brand
|
|
128
|
+
border("brand"),
|
|
109
129
|
fg("brand"),
|
|
110
|
-
hover(bg("brand.tint")),
|
|
130
|
+
hover([bg("brand.tint"), border("brand.border-hover")]),
|
|
111
131
|
active(bg("brand.bg-tint-hover")),
|
|
112
132
|
]),
|
|
113
133
|
data("color", "neutral", [
|
|
114
|
-
border("neutral
|
|
134
|
+
border("neutral"),
|
|
115
135
|
fg("neutral"),
|
|
116
|
-
hover(bg("neutral.tint")),
|
|
136
|
+
hover([bg("neutral.tint"), border("neutral.border-hover")]),
|
|
117
137
|
active(bg("neutral.bg-tint-hover")),
|
|
118
138
|
]),
|
|
119
139
|
data("color", "success", [
|
|
120
|
-
border("success
|
|
140
|
+
border("success"),
|
|
121
141
|
fg("success"),
|
|
122
|
-
hover(bg("success.tint")),
|
|
142
|
+
hover([bg("success.tint"), border("success.border-hover")]),
|
|
123
143
|
active(bg("success.bg-tint-hover")),
|
|
124
144
|
]),
|
|
125
145
|
data("color", "warning", [
|
|
126
|
-
border("warning
|
|
146
|
+
border("warning"),
|
|
127
147
|
fg("warning"),
|
|
128
|
-
hover(bg("warning.tint")),
|
|
148
|
+
hover([bg("warning.tint"), border("warning.border-hover")]),
|
|
129
149
|
active(bg("warning.bg-tint-hover")),
|
|
130
150
|
]),
|
|
131
151
|
data("color", "danger", [
|
|
132
|
-
border("danger
|
|
152
|
+
border("danger"),
|
|
133
153
|
fg("danger"),
|
|
134
|
-
hover(bg("danger.tint")),
|
|
154
|
+
hover([bg("danger.tint"), border("danger.border-hover")]),
|
|
135
155
|
active(bg("danger.bg-tint-hover")),
|
|
136
156
|
]),
|
|
137
157
|
]),
|
|
@@ -52,6 +52,16 @@ export declare namespace Form {
|
|
|
52
52
|
* @returns Whether `name` is the first invalid field this render.
|
|
53
53
|
*/
|
|
54
54
|
isFirstInvalid(name: string): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Every issue with no `path` at all — a failure that names no single
|
|
57
|
+
* field, such as a server-side refusal decided before any field was
|
|
58
|
+
* reached. {@link Form} already renders these through its own leading
|
|
59
|
+
* `Alert`; a caller reaches for this only to render them somewhere
|
|
60
|
+
* else instead.
|
|
61
|
+
*
|
|
62
|
+
* @returns The form-level issues, in {@link Form.Props.issues} order.
|
|
63
|
+
*/
|
|
64
|
+
getFormIssues(): ReadonlyArray<Issue>;
|
|
55
65
|
}
|
|
56
66
|
/**
|
|
57
67
|
* Props accepted by {@link Form}.
|
|
@@ -72,7 +82,11 @@ export declare namespace Form {
|
|
|
72
82
|
/**
|
|
73
83
|
* Renders a native `<form>` laying children out in a single column, and
|
|
74
84
|
* provides {@link Form.Context} so descendant fields resolve their own
|
|
75
|
-
* issues by name and focus the first invalid field with no client JS.
|
|
85
|
+
* issues by name and focus the first invalid field with no client JS. An
|
|
86
|
+
* issue with no `path` names no field to attach to, so it renders as its
|
|
87
|
+
* own leading `Alert` instead of being silently unreachable — a refusal
|
|
88
|
+
* decided before any field was reached still reaches the person filling
|
|
89
|
+
* the form in.
|
|
76
90
|
*
|
|
77
91
|
* @param handle Runtime handle carrying the host `<form>`'s props and providing {@link Form.Context}.
|
|
78
92
|
* @returns The render function producing the form's markup.
|
package/dist/components/form.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { jsx as _jsx } from "remix/ui/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "remix/ui/jsx-runtime";
|
|
2
2
|
import { flex, flexCol, gap } from "@sdxc/u/layout";
|
|
3
|
+
import { Alert } from "./alert.js";
|
|
3
4
|
/** {@link Form.Props.issues} fallback for a first, not-yet-submitted render. */
|
|
4
5
|
const DEFAULT_ISSUES = [];
|
|
5
6
|
/** Shared empty result {@link Form.Context.getIssues} returns for a field with no matching issue. */
|
|
@@ -19,8 +20,9 @@ function resolveFieldName(path) {
|
|
|
19
20
|
.join(".");
|
|
20
21
|
}
|
|
21
22
|
/**
|
|
22
|
-
* Groups `issues` by the field name each one's `path` resolves to
|
|
23
|
-
*
|
|
23
|
+
* Groups `issues` by the field name each one's `path` resolves to. An issue
|
|
24
|
+
* with no path names no field to group under, so {@link Form} reads those
|
|
25
|
+
* separately, through {@link Form.Context.getFormIssues}.
|
|
24
26
|
*
|
|
25
27
|
* @param issues Issues to group, typically {@link Form.Props.issues} as-is.
|
|
26
28
|
* @returns A map from field name to every issue addressed to it, in `issues` order.
|
|
@@ -42,7 +44,11 @@ function groupIssuesByField(issues) {
|
|
|
42
44
|
/**
|
|
43
45
|
* Renders a native `<form>` laying children out in a single column, and
|
|
44
46
|
* provides {@link Form.Context} so descendant fields resolve their own
|
|
45
|
-
* issues by name and focus the first invalid field with no client JS.
|
|
47
|
+
* issues by name and focus the first invalid field with no client JS. An
|
|
48
|
+
* issue with no `path` names no field to attach to, so it renders as its
|
|
49
|
+
* own leading `Alert` instead of being silently unreachable — a refusal
|
|
50
|
+
* decided before any field was reached still reaches the person filling
|
|
51
|
+
* the form in.
|
|
46
52
|
*
|
|
47
53
|
* @param handle Runtime handle carrying the host `<form>`'s props and providing {@link Form.Context}.
|
|
48
54
|
* @returns The render function producing the form's markup.
|
|
@@ -55,8 +61,9 @@ function groupIssuesByField(issues) {
|
|
|
55
61
|
*/
|
|
56
62
|
export function Form(handle) {
|
|
57
63
|
return () => {
|
|
58
|
-
let { issues = DEFAULT_ISSUES, mix, ...rest } = handle.props;
|
|
64
|
+
let { issues = DEFAULT_ISSUES, mix, children, ...rest } = handle.props;
|
|
59
65
|
let byField = groupIssuesByField(issues);
|
|
66
|
+
let formIssues = issues.filter((issue) => resolveFieldName(issue.path) === undefined);
|
|
60
67
|
let firstInvalidField = issues
|
|
61
68
|
.map((issue) => resolveFieldName(issue.path))
|
|
62
69
|
.find((name) => name !== undefined);
|
|
@@ -67,8 +74,11 @@ export function Form(handle) {
|
|
|
67
74
|
isFirstInvalid(name) {
|
|
68
75
|
return name === firstInvalidField;
|
|
69
76
|
},
|
|
77
|
+
getFormIssues() {
|
|
78
|
+
return formIssues;
|
|
79
|
+
},
|
|
70
80
|
});
|
|
71
|
-
return
|
|
81
|
+
return (_jsxs("form", { ...rest, mix: [flex(), flexCol(), gap(4), mix], children: [formIssues.length > 0 && (_jsx(Alert, { color: "danger", "data-slot": "form-issues", children: _jsx(Alert.Description, { children: formIssues.map((issue) => issue.message).join(" ") }) })), children] }));
|
|
72
82
|
};
|
|
73
83
|
}
|
|
74
84
|
/**
|
|
@@ -3,10 +3,10 @@ import { GripVerticalIcon } from "@sdxc/icons";
|
|
|
3
3
|
import { bg, borderEdge, fg, outline } from "@sdxc/u/color";
|
|
4
4
|
import { opacity, rounded } from "@sdxc/u/effects";
|
|
5
5
|
import { cursor } from "@sdxc/u/general";
|
|
6
|
-
import { container, flex, flexCol, gap, grid, gridTemplate, items, virtualize, } from "@sdxc/u/layout";
|
|
6
|
+
import { container, flex, flexCol, gap, grid, gridTemplate, items, shrink, virtualize, } from "@sdxc/u/layout";
|
|
7
7
|
import { at } from "@sdxc/u/responsive";
|
|
8
|
-
import { mbs, pb, pbs, pi } from "@sdxc/u/size";
|
|
9
|
-
import { active, data,
|
|
8
|
+
import { bs, is, mbs, pb, pbs, pi } from "@sdxc/u/size";
|
|
9
|
+
import { active, data, not, when } from "@sdxc/u/state";
|
|
10
10
|
import { text, textTransform, tracking, weight } from "@sdxc/u/typography";
|
|
11
11
|
import { attrs } from "remix/ui";
|
|
12
12
|
import { interactiveTransition } from "../styles/interactive-transition.js";
|
|
@@ -112,14 +112,30 @@ GridList.Item = function GridListItem(handle) {
|
|
|
112
112
|
flex(),
|
|
113
113
|
items("center"),
|
|
114
114
|
gap(2),
|
|
115
|
+
/*
|
|
116
|
+
* A glyph a row leads with is measured against the row's text rather than
|
|
117
|
+
* against whatever an icon set draws at, and holds that measure when the row
|
|
118
|
+
* runs out of space: the default `flex-shrink: 1` otherwise squeezes it by
|
|
119
|
+
* however much that row's own text overruns, so every row lands on a
|
|
120
|
+
* different width and the column of glyphs reads as a rendering fault.
|
|
121
|
+
*/
|
|
122
|
+
when("& > svg", [shrink(), is(4), bs(4)]),
|
|
115
123
|
rounded("md"),
|
|
116
124
|
pb(2),
|
|
117
125
|
pi(2),
|
|
118
126
|
fg("neutral.emphasis"),
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
127
|
+
/*
|
|
128
|
+
* A selected row answers "which ones", so it is tinted far enough off the
|
|
129
|
+
* surface to be read at a glance: the plain tint is the same lightness as the
|
|
130
|
+
* list's own background and leaves a selection invisible. Pointer states and
|
|
131
|
+
* selection are written as selectors that exclude each other, so a hovered
|
|
132
|
+
* row keeps saying it is selected whichever order the layers land in.
|
|
133
|
+
*/
|
|
134
|
+
when('&:hover:not([aria-selected="true"])', bg("neutral.bg-tint-hover")),
|
|
135
|
+
when('&:active:not([aria-selected="true"])', bg("neutral.bg-tint-pressed")),
|
|
136
|
+
when('&:focus:not([aria-selected="true"])', bg("neutral.bg-tint-hover")),
|
|
137
|
+
when('&[aria-selected="true"]', bg("brand.bg-tint-hover")),
|
|
138
|
+
when('&[aria-selected="true"]:hover', bg("brand.bg-tint-pressed")),
|
|
123
139
|
when('&[aria-disabled="true"]', opacity(50)),
|
|
124
140
|
cursor("default"),
|
|
125
141
|
outline("none"),
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* A visual and semantic wrapper binding a cluster of related controls into
|
|
3
3
|
* one unit — a text input paired with its clear button, a row of segmented
|
|
4
4
|
* buttons, a search field with a trailing submit action. The host lays its
|
|
5
|
-
* children out in a single row
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* children out in a single row, joining their edges so the cluster reads as one
|
|
6
|
+
* control, with the seam between two of them drawn structurally rather than
|
|
7
|
+
* through any tracked state.
|
|
8
8
|
*
|
|
9
9
|
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
10
10
|
* @copyright Sergio Xalambrí 2026
|
|
@@ -23,9 +23,9 @@ export declare namespace Group {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
* Lays children out in a centered flex row with no border, background, or
|
|
27
|
-
*
|
|
28
|
-
*
|
|
26
|
+
* Lays children out in a centered flex row with no border, background, or gap, joining
|
|
27
|
+
* their edges into one shape: only the cluster's outer corners stay round, and the seam
|
|
28
|
+
* two controls share is drawn once. Focus is shown by whichever control holds it.
|
|
29
29
|
*
|
|
30
30
|
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
31
31
|
* @returns The render function producing the group's markup.
|
package/dist/components/group.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "remix/ui/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { outlineColor } from "@sdxc/u/color";
|
|
3
|
+
import { roundedCorner } from "@sdxc/u/effects";
|
|
3
4
|
import { flex, items } from "@sdxc/u/layout";
|
|
5
|
+
import { mis } from "@sdxc/u/size";
|
|
6
|
+
import { z } from "@sdxc/u/stacking";
|
|
4
7
|
import { when } from "@sdxc/u/state";
|
|
5
8
|
import { attrs } from "remix/ui";
|
|
6
9
|
/**
|
|
@@ -10,9 +13,9 @@ import { attrs } from "remix/ui";
|
|
|
10
13
|
*/
|
|
11
14
|
const DEFAULT_ROLE = "group";
|
|
12
15
|
/**
|
|
13
|
-
* Lays children out in a centered flex row with no border, background, or
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
+
* Lays children out in a centered flex row with no border, background, or gap, joining
|
|
17
|
+
* their edges into one shape: only the cluster's outer corners stay round, and the seam
|
|
18
|
+
* two controls share is drawn once. Focus is shown by whichever control holds it.
|
|
16
19
|
*
|
|
17
20
|
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
18
21
|
* @returns The render function producing the group's markup.
|
|
@@ -34,10 +37,29 @@ export function Group(handle) {
|
|
|
34
37
|
let { mix, ...rest } = handle.props;
|
|
35
38
|
return (_jsx("div", { ...rest, mix: [
|
|
36
39
|
attrs({ role: DEFAULT_ROLE }),
|
|
37
|
-
when("&:has(:focus-visible)", outline({ color: "brand.ring", offset: 2 })),
|
|
38
40
|
flex(),
|
|
39
41
|
items("center"),
|
|
40
|
-
|
|
42
|
+
/*
|
|
43
|
+
* The controls compose into one shape, so the cluster keeps the rounding on
|
|
44
|
+
* its own outer corners and the seam where two of them meet is drawn once.
|
|
45
|
+
*/
|
|
46
|
+
when("& > *:not(:first-child)", [
|
|
47
|
+
roundedCorner("start-start", "none"),
|
|
48
|
+
roundedCorner("end-start", "none"),
|
|
49
|
+
mis("-1px"),
|
|
50
|
+
]),
|
|
51
|
+
when("& > *:not(:last-child)", [
|
|
52
|
+
roundedCorner("start-end", "none"),
|
|
53
|
+
roundedCorner("end-end", "none"),
|
|
54
|
+
]),
|
|
55
|
+
/*
|
|
56
|
+
* Focus is shown by the control that holds it, since a ring around the whole
|
|
57
|
+
* cluster says a group is focused without saying which of its controls is.
|
|
58
|
+
* The focused one is raised so its ring crosses the seam it shares with a
|
|
59
|
+
* neighbour rather than being painted over by it.
|
|
60
|
+
*/
|
|
61
|
+
when("& > *:focus-visible", z(1)),
|
|
62
|
+
when('&[aria-invalid="true"] > *:focus-visible', outlineColor("danger")),
|
|
41
63
|
mix,
|
|
42
64
|
] }));
|
|
43
65
|
};
|