@sdxc/ui 0.0.0-pre.1
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/LICENSE.md +21 -0
- package/README.md +812 -0
- package/dist/animations/index.d.ts +12 -0
- package/dist/animations/index.js +12 -0
- package/dist/animations/keyframes.d.ts +162 -0
- package/dist/animations/keyframes.js +297 -0
- package/dist/animations/scroll.d.ts +154 -0
- package/dist/animations/scroll.js +228 -0
- package/dist/animations/tokens.d.ts +47 -0
- package/dist/animations/tokens.js +47 -0
- package/dist/animations/transitions.d.ts +143 -0
- package/dist/animations/transitions.js +147 -0
- package/dist/behaviors/announcer.d.ts +90 -0
- package/dist/behaviors/announcer.js +93 -0
- package/dist/behaviors/calendar-model.d.ts +218 -0
- package/dist/behaviors/calendar-model.js +376 -0
- package/dist/behaviors/drag-session.d.ts +119 -0
- package/dist/behaviors/drag-session.js +110 -0
- package/dist/behaviors/filter-model.d.ts +117 -0
- package/dist/behaviors/filter-model.js +185 -0
- package/dist/behaviors/index.d.ts +16 -0
- package/dist/behaviors/index.js +16 -0
- package/dist/behaviors/resize-session.d.ts +115 -0
- package/dist/behaviors/resize-session.js +157 -0
- package/dist/behaviors/scroll-follow-model.d.ts +180 -0
- package/dist/behaviors/scroll-follow-model.js +197 -0
- package/dist/behaviors/selection-model.d.ts +129 -0
- package/dist/behaviors/selection-model.js +259 -0
- package/dist/behaviors/toaster.d.ts +144 -0
- package/dist/behaviors/toaster.js +228 -0
- package/dist/components/accordion.d.ts +93 -0
- package/dist/components/accordion.js +165 -0
- package/dist/components/alert-dialog.d.ts +110 -0
- package/dist/components/alert-dialog.js +169 -0
- package/dist/components/alert.d.ts +109 -0
- package/dist/components/alert.js +160 -0
- package/dist/components/aspect-ratio.d.ts +44 -0
- package/dist/components/aspect-ratio.js +35 -0
- package/dist/components/attachment.d.ts +146 -0
- package/dist/components/attachment.js +320 -0
- package/dist/components/avatar.d.ts +118 -0
- package/dist/components/avatar.js +89 -0
- package/dist/components/badge.d.ts +66 -0
- package/dist/components/badge.js +129 -0
- package/dist/components/breadcrumbs.d.ts +67 -0
- package/dist/components/breadcrumbs.js +121 -0
- package/dist/components/bubble.d.ts +91 -0
- package/dist/components/bubble.js +216 -0
- package/dist/components/button.d.ts +78 -0
- package/dist/components/button.js +207 -0
- package/dist/components/calendar.d.ts +166 -0
- package/dist/components/calendar.js +320 -0
- package/dist/components/card.d.ts +82 -0
- package/dist/components/card.js +126 -0
- package/dist/components/carousel.d.ts +96 -0
- package/dist/components/carousel.js +214 -0
- package/dist/components/chart.d.ts +485 -0
- package/dist/components/chart.js +563 -0
- package/dist/components/checkbox-group.d.ts +58 -0
- package/dist/components/checkbox-group.js +53 -0
- package/dist/components/checkbox.d.ts +61 -0
- package/dist/components/checkbox.js +81 -0
- package/dist/components/color-area.d.ts +83 -0
- package/dist/components/color-area.js +251 -0
- package/dist/components/color-field.d.ts +128 -0
- package/dist/components/color-field.js +73 -0
- package/dist/components/color-picker.d.ts +132 -0
- package/dist/components/color-picker.js +183 -0
- package/dist/components/color-slider.d.ts +103 -0
- package/dist/components/color-slider.js +198 -0
- package/dist/components/color-swatch-picker.d.ts +106 -0
- package/dist/components/color-swatch-picker.js +75 -0
- package/dist/components/color-swatch.d.ts +57 -0
- package/dist/components/color-swatch.js +82 -0
- package/dist/components/color-wheel.d.ts +58 -0
- package/dist/components/color-wheel.js +160 -0
- package/dist/components/combobox.d.ts +73 -0
- package/dist/components/combobox.js +108 -0
- package/dist/components/command.d.ts +80 -0
- package/dist/components/command.js +151 -0
- package/dist/components/confirm.d.ts +124 -0
- package/dist/components/confirm.js +56 -0
- package/dist/components/context-menu.d.ts +108 -0
- package/dist/components/context-menu.js +200 -0
- package/dist/components/date-field.d.ts +110 -0
- package/dist/components/date-field.js +49 -0
- package/dist/components/date-picker.d.ts +136 -0
- package/dist/components/date-picker.js +155 -0
- package/dist/components/date-range-picker.d.ts +152 -0
- package/dist/components/date-range-picker.js +106 -0
- package/dist/components/description.d.ts +36 -0
- package/dist/components/description.js +21 -0
- package/dist/components/dialog.d.ts +97 -0
- package/dist/components/dialog.js +203 -0
- package/dist/components/disclosure.d.ts +85 -0
- package/dist/components/disclosure.js +180 -0
- package/dist/components/drawer.d.ts +82 -0
- package/dist/components/drawer.js +162 -0
- package/dist/components/drop-indicator.d.ts +43 -0
- package/dist/components/drop-indicator.js +47 -0
- package/dist/components/drop-zone.d.ts +73 -0
- package/dist/components/drop-zone.js +54 -0
- package/dist/components/empty.d.ts +89 -0
- package/dist/components/empty.js +129 -0
- package/dist/components/field-error.d.ts +41 -0
- package/dist/components/field-error.js +36 -0
- package/dist/components/file-trigger.d.ts +84 -0
- package/dist/components/file-trigger.js +169 -0
- package/dist/components/form.d.ts +118 -0
- package/dist/components/form.js +113 -0
- package/dist/components/grid-list.d.ts +112 -0
- package/dist/components/grid-list.js +220 -0
- package/dist/components/group.d.ts +45 -0
- package/dist/components/group.js +44 -0
- package/dist/components/header.d.ts +33 -0
- package/dist/components/header.js +29 -0
- package/dist/components/heading-scope.d.ts +83 -0
- package/dist/components/heading-scope.js +82 -0
- package/dist/components/heading.d.ts +50 -0
- package/dist/components/heading.js +31 -0
- package/dist/components/hover-card.d.ts +77 -0
- package/dist/components/hover-card.js +151 -0
- package/dist/components/image-placeholder.d.ts +105 -0
- package/dist/components/image-placeholder.js +212 -0
- package/dist/components/index.d.ts +109 -0
- package/dist/components/index.js +109 -0
- package/dist/components/input.d.ts +53 -0
- package/dist/components/input.js +76 -0
- package/dist/components/item.d.ts +97 -0
- package/dist/components/item.js +185 -0
- package/dist/components/keyboard.d.ts +33 -0
- package/dist/components/keyboard.js +20 -0
- package/dist/components/label.d.ts +38 -0
- package/dist/components/label.js +24 -0
- package/dist/components/link-button.d.ts +59 -0
- package/dist/components/link-button.js +174 -0
- package/dist/components/link.d.ts +43 -0
- package/dist/components/link.js +85 -0
- package/dist/components/listbox.d.ts +119 -0
- package/dist/components/listbox.js +114 -0
- package/dist/components/logo.d.ts +117 -0
- package/dist/components/logo.js +89 -0
- package/dist/components/marker.d.ts +82 -0
- package/dist/components/marker.js +163 -0
- package/dist/components/menu.d.ts +90 -0
- package/dist/components/menu.js +146 -0
- package/dist/components/menubar.d.ts +54 -0
- package/dist/components/menubar.js +118 -0
- package/dist/components/message-scroller.d.ts +109 -0
- package/dist/components/message-scroller.js +180 -0
- package/dist/components/message.d.ts +104 -0
- package/dist/components/message.js +200 -0
- package/dist/components/meter.d.ts +60 -0
- package/dist/components/meter.js +110 -0
- package/dist/components/modal.d.ts +71 -0
- package/dist/components/modal.js +120 -0
- package/dist/components/nav-link.d.ts +53 -0
- package/dist/components/nav-link.js +83 -0
- package/dist/components/navigation-menu.d.ts +150 -0
- package/dist/components/navigation-menu.js +381 -0
- package/dist/components/number-field.d.ts +76 -0
- package/dist/components/number-field.js +190 -0
- package/dist/components/otp-field.d.ts +68 -0
- package/dist/components/otp-field.js +46 -0
- package/dist/components/overlay-arrow.d.ts +51 -0
- package/dist/components/overlay-arrow.js +77 -0
- package/dist/components/pagination.d.ts +67 -0
- package/dist/components/pagination.js +164 -0
- package/dist/components/popover.d.ts +69 -0
- package/dist/components/popover.js +68 -0
- package/dist/components/progress-bar.d.ts +53 -0
- package/dist/components/progress-bar.js +90 -0
- package/dist/components/radio-group.d.ts +102 -0
- package/dist/components/radio-group.js +114 -0
- package/dist/components/range-calendar.d.ts +169 -0
- package/dist/components/range-calendar.js +216 -0
- package/dist/components/resizable.d.ts +98 -0
- package/dist/components/resizable.js +151 -0
- package/dist/components/scroll-area.d.ts +54 -0
- package/dist/components/scroll-area.js +89 -0
- package/dist/components/search-field.d.ts +55 -0
- package/dist/components/search-field.js +49 -0
- package/dist/components/section.d.ts +37 -0
- package/dist/components/section.js +22 -0
- package/dist/components/select.d.ts +96 -0
- package/dist/components/select.js +285 -0
- package/dist/components/selection-indicator.d.ts +47 -0
- package/dist/components/selection-indicator.js +50 -0
- package/dist/components/sentinel-row.d.ts +22 -0
- package/dist/components/sentinel-row.js +29 -0
- package/dist/components/separator.d.ts +35 -0
- package/dist/components/separator.js +48 -0
- package/dist/components/shared-element.d.ts +45 -0
- package/dist/components/shared-element.js +48 -0
- package/dist/components/sheet.d.ts +78 -0
- package/dist/components/sheet.js +167 -0
- package/dist/components/sidebar.d.ts +288 -0
- package/dist/components/sidebar.js +1068 -0
- package/dist/components/skeleton.d.ts +36 -0
- package/dist/components/skeleton.js +38 -0
- package/dist/components/slider.d.ts +102 -0
- package/dist/components/slider.js +179 -0
- package/dist/components/spinner.d.ts +55 -0
- package/dist/components/spinner.js +51 -0
- package/dist/components/switch.d.ts +47 -0
- package/dist/components/switch.js +82 -0
- package/dist/components/table.d.ts +139 -0
- package/dist/components/table.js +216 -0
- package/dist/components/tabs.d.ts +124 -0
- package/dist/components/tabs.js +246 -0
- package/dist/components/tag-group.d.ts +83 -0
- package/dist/components/tag-group.js +157 -0
- package/dist/components/text-field.d.ts +119 -0
- package/dist/components/text-field.js +51 -0
- package/dist/components/text.d.ts +34 -0
- package/dist/components/text.js +19 -0
- package/dist/components/textarea.d.ts +52 -0
- package/dist/components/textarea.js +82 -0
- package/dist/components/time-field.d.ts +110 -0
- package/dist/components/time-field.js +48 -0
- package/dist/components/toast.d.ts +149 -0
- package/dist/components/toast.js +365 -0
- package/dist/components/toggle-button.d.ts +115 -0
- package/dist/components/toggle-button.js +237 -0
- package/dist/components/toolbar.d.ts +47 -0
- package/dist/components/toolbar.js +54 -0
- package/dist/components/tooltip.d.ts +52 -0
- package/dist/components/tooltip.js +92 -0
- package/dist/components/tree.d.ts +123 -0
- package/dist/components/tree.js +239 -0
- package/dist/components/typeset.d.ts +53 -0
- package/dist/components/typeset.js +271 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +8 -0
- package/dist/mixins/aria-checked.d.ts +42 -0
- package/dist/mixins/aria-checked.js +127 -0
- package/dist/mixins/attachment-trigger.d.ts +64 -0
- package/dist/mixins/attachment-trigger.js +190 -0
- package/dist/mixins/calendar-keys.d.ts +27 -0
- package/dist/mixins/calendar-keys.js +113 -0
- package/dist/mixins/carousel-controls.d.ts +30 -0
- package/dist/mixins/carousel-controls.js +222 -0
- package/dist/mixins/chart-tooltip.d.ts +118 -0
- package/dist/mixins/chart-tooltip.js +323 -0
- package/dist/mixins/clear-field.d.ts +60 -0
- package/dist/mixins/clear-field.js +100 -0
- package/dist/mixins/color-area-drag.d.ts +58 -0
- package/dist/mixins/color-area-drag.js +162 -0
- package/dist/mixins/color-channel-sync.d.ts +73 -0
- package/dist/mixins/color-channel-sync.js +169 -0
- package/dist/mixins/color-preview.d.ts +28 -0
- package/dist/mixins/color-preview.js +77 -0
- package/dist/mixins/color-wheel-drag.d.ts +58 -0
- package/dist/mixins/color-wheel-drag.js +139 -0
- package/dist/mixins/combobox-filter.d.ts +59 -0
- package/dist/mixins/combobox-filter.js +81 -0
- package/dist/mixins/command-filter.d.ts +55 -0
- package/dist/mixins/command-filter.js +121 -0
- package/dist/mixins/command-keys.d.ts +31 -0
- package/dist/mixins/command-keys.js +116 -0
- package/dist/mixins/context-menu.d.ts +24 -0
- package/dist/mixins/context-menu.js +64 -0
- package/dist/mixins/copy-to-clipboard.d.ts +64 -0
- package/dist/mixins/copy-to-clipboard.js +109 -0
- package/dist/mixins/dismiss.d.ts +77 -0
- package/dist/mixins/dismiss.js +151 -0
- package/dist/mixins/drag-reorder.d.ts +88 -0
- package/dist/mixins/drag-reorder.js +214 -0
- package/dist/mixins/drop-zone.d.ts +52 -0
- package/dist/mixins/drop-zone.js +132 -0
- package/dist/mixins/dual-range.d.ts +60 -0
- package/dist/mixins/dual-range.js +100 -0
- package/dist/mixins/grid-list-keys.d.ts +34 -0
- package/dist/mixins/grid-list-keys.js +260 -0
- package/dist/mixins/heading-level-fallback.d.ts +81 -0
- package/dist/mixins/heading-level-fallback.js +112 -0
- package/dist/mixins/hotkey.d.ts +26 -0
- package/dist/mixins/hotkey.js +132 -0
- package/dist/mixins/image-fallback.d.ts +57 -0
- package/dist/mixins/image-fallback.js +86 -0
- package/dist/mixins/index.d.ts +48 -0
- package/dist/mixins/index.js +48 -0
- package/dist/mixins/listbox-keys.d.ts +52 -0
- package/dist/mixins/listbox-keys.js +63 -0
- package/dist/mixins/long-press.d.ts +76 -0
- package/dist/mixins/long-press.js +130 -0
- package/dist/mixins/menu-keys.d.ts +40 -0
- package/dist/mixins/menu-keys.js +117 -0
- package/dist/mixins/menubar-keys.d.ts +59 -0
- package/dist/mixins/menubar-keys.js +230 -0
- package/dist/mixins/message-follow.d.ts +56 -0
- package/dist/mixins/message-follow.js +368 -0
- package/dist/mixins/otp-slots.d.ts +53 -0
- package/dist/mixins/otp-slots.js +175 -0
- package/dist/mixins/persist.d.ts +36 -0
- package/dist/mixins/persist.js +78 -0
- package/dist/mixins/press-toggle.d.ts +43 -0
- package/dist/mixins/press-toggle.js +61 -0
- package/dist/mixins/range-preview.d.ts +26 -0
- package/dist/mixins/range-preview.js +120 -0
- package/dist/mixins/resize-handle.d.ts +101 -0
- package/dist/mixins/resize-handle.js +288 -0
- package/dist/mixins/stepper.d.ts +81 -0
- package/dist/mixins/stepper.js +194 -0
- package/dist/mixins/tab-keys.d.ts +30 -0
- package/dist/mixins/tab-keys.js +63 -0
- package/dist/mixins/theme-toggle.d.ts +82 -0
- package/dist/mixins/theme-toggle.js +158 -0
- package/dist/mixins/track-host-node.d.ts +34 -0
- package/dist/mixins/track-host-node.js +42 -0
- package/dist/mixins/treeKeys.d.ts +57 -0
- package/dist/mixins/treeKeys.js +266 -0
- package/dist/mixins/validate.d.ts +65 -0
- package/dist/mixins/validate.js +139 -0
- package/dist/mixins/view-transition.d.ts +56 -0
- package/dist/mixins/view-transition.js +111 -0
- package/dist/styles/chart-palette.d.ts +34 -0
- package/dist/styles/chart-palette.js +27 -0
- package/dist/styles/field-stack-layout.d.ts +27 -0
- package/dist/styles/field-stack-layout.js +16 -0
- package/dist/styles/floating-surface.d.ts +32 -0
- package/dist/styles/floating-surface.js +30 -0
- package/dist/styles/graphic-host.d.ts +25 -0
- package/dist/styles/graphic-host.js +18 -0
- package/dist/styles/index.d.ts +20 -0
- package/dist/styles/index.js +20 -0
- package/dist/styles/interactive-transition.d.ts +32 -0
- package/dist/styles/interactive-transition.js +32 -0
- package/dist/styles/legend-toggle.d.ts +29 -0
- package/dist/styles/legend-toggle.js +24 -0
- package/dist/styles/output-caption-text.d.ts +22 -0
- package/dist/styles/output-caption-text.js +15 -0
- package/dist/styles/panel-chrome.d.ts +34 -0
- package/dist/styles/panel-chrome.js +26 -0
- package/dist/styles/range-thumb-appearance.d.ts +36 -0
- package/dist/styles/range-thumb-appearance.js +76 -0
- package/dist/styles/rtl-aware-gradient-direction.d.ts +28 -0
- package/dist/styles/rtl-aware-gradient-direction.js +28 -0
- package/dist/styles/semantic-color-panel.d.ts +35 -0
- package/dist/styles/semantic-color-panel.js +41 -0
- package/dist/utils/chart-marker-indices.d.ts +22 -0
- package/dist/utils/chart-marker-indices.js +45 -0
- package/dist/utils/chart-path.d.ts +86 -0
- package/dist/utils/chart-path.js +122 -0
- package/dist/utils/chart-scale.d.ts +182 -0
- package/dist/utils/chart-scale.js +221 -0
- package/dist/utils/color-math.d.ts +252 -0
- package/dist/utils/color-math.js +480 -0
- package/dist/utils/command-event.d.ts +24 -0
- package/dist/utils/command-event.js +26 -0
- package/dist/utils/css-styles.d.ts +21 -0
- package/dist/utils/css-styles.js +11 -0
- package/dist/utils/decorative-icon.d.ts +15 -0
- package/dist/utils/decorative-icon.js +15 -0
- package/dist/utils/disabled-selector.d.ts +22 -0
- package/dist/utils/disabled-selector.js +22 -0
- package/dist/utils/dispatch-change.d.ts +17 -0
- package/dist/utils/dispatch-change.js +19 -0
- package/dist/utils/field-parts.d.ts +26 -0
- package/dist/utils/field-parts.js +12 -0
- package/dist/utils/full-turn-radians.d.ts +16 -0
- package/dist/utils/full-turn-radians.js +16 -0
- package/dist/utils/geometry.d.ts +14 -0
- package/dist/utils/geometry.js +9 -0
- package/dist/utils/has-accessible-text.d.ts +19 -0
- package/dist/utils/has-accessible-text.js +30 -0
- package/dist/utils/hue-spectrum.d.ts +19 -0
- package/dist/utils/hue-spectrum.js +19 -0
- package/dist/utils/index.d.ts +35 -0
- package/dist/utils/index.js +35 -0
- package/dist/utils/is-new-primary-press.d.ts +29 -0
- package/dist/utils/is-new-primary-press.js +31 -0
- package/dist/utils/keyboard-nav.d.ts +64 -0
- package/dist/utils/keyboard-nav.js +79 -0
- package/dist/utils/merge-style.d.ts +33 -0
- package/dist/utils/merge-style.js +30 -0
- package/dist/utils/paired-range-inputs.d.ts +26 -0
- package/dist/utils/paired-range-inputs.js +29 -0
- package/dist/utils/placement.d.ts +18 -0
- package/dist/utils/placement.js +12 -0
- package/dist/utils/prefers-reduced-motion.d.ts +17 -0
- package/dist/utils/prefers-reduced-motion.js +19 -0
- package/dist/utils/resolve-field-wiring.d.ts +83 -0
- package/dist/utils/resolve-field-wiring.js +53 -0
- package/dist/utils/resolve-fill-percent.d.ts +28 -0
- package/dist/utils/resolve-fill-percent.js +34 -0
- package/dist/utils/round-precision.d.ts +22 -0
- package/dist/utils/round-precision.js +25 -0
- package/dist/utils/semantic-color-panel.d.ts +35 -0
- package/dist/utils/semantic-color-panel.js +28 -0
- package/dist/utils/semantic-color.d.ts +17 -0
- package/dist/utils/semantic-color.js +11 -0
- package/dist/utils/warn-if-no-accessible-name.d.ts +52 -0
- package/dist/utils/warn-if-no-accessible-name.js +55 -0
- package/dist/utils/write-cookie.d.ts +35 -0
- package/dist/utils/write-cookie.js +37 -0
- package/package.json +32 -0
- package/src/reset.css +223 -0
- package/src/theme.css +146 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Applies a shared `remix/data-schema` field schema to a native form
|
|
3
|
+
* control's current value, layering the verdict onto the field's Constraint
|
|
4
|
+
* Validation API state via `setCustomValidity()` and mirroring it into the
|
|
5
|
+
* field's `FieldError` slot once the browser flags it invalid, since no HTML
|
|
6
|
+
* constraint attribute expresses a schema-shaped check on its own.
|
|
7
|
+
*
|
|
8
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
9
|
+
* @copyright Sergio Xalambrí 2026
|
|
10
|
+
*/
|
|
11
|
+
import type { Schema } from "remix/data-schema";
|
|
12
|
+
/**
|
|
13
|
+
* Native form control types that implement the Constraint Validation API —
|
|
14
|
+
* `setCustomValidity()`, `validationMessage`, and the `invalid` event —
|
|
15
|
+
* {@link validate} lays a schema's verdict onto.
|
|
16
|
+
*/
|
|
17
|
+
export type ValidatableField = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
|
|
18
|
+
/**
|
|
19
|
+
* Attribute the FieldError slot exposes itself on. Since `aria-describedby`
|
|
20
|
+
* may list a Description alongside a FieldError, {@link validate} walks
|
|
21
|
+
* those ids and mirrors the verdict into the first one carrying this attribute.
|
|
22
|
+
*/
|
|
23
|
+
export declare const FIELD_ERROR_ATTRIBUTE = "data-field-error";
|
|
24
|
+
/** DOM event type dispatched by {@link validate} whenever running its schema changes whether a field is valid. */
|
|
25
|
+
declare const VALIDATE_CHANGE_EVENT: "ui:validate-change";
|
|
26
|
+
declare global {
|
|
27
|
+
interface HTMLElementEventMap {
|
|
28
|
+
[VALIDATE_CHANGE_EVENT]: ValidateChangeEvent;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Dispatched on a field by {@link validate} whenever running its schema
|
|
33
|
+
* changes whether the field is valid, so a consumer can react — disabling a
|
|
34
|
+
* submit button, a live-region announcement — without polling `validity`.
|
|
35
|
+
*/
|
|
36
|
+
export declare class ValidateChangeEvent extends Event {
|
|
37
|
+
/** `true` once the field's current value satisfies the schema and every other constraint. */
|
|
38
|
+
readonly valid: boolean;
|
|
39
|
+
/** The message now sitting in `validationMessage`, empty once `valid` is `true`. */
|
|
40
|
+
readonly message: string;
|
|
41
|
+
/**
|
|
42
|
+
* @param init Snapshot of the field's validity at dispatch time.
|
|
43
|
+
*/
|
|
44
|
+
constructor(init: {
|
|
45
|
+
valid: boolean;
|
|
46
|
+
message: string;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Adds schema-driven client validation to a form field: `input` keeps its
|
|
51
|
+
* Constraint Validation state current via `setCustomValidity()`, and once
|
|
52
|
+
* reported invalid, mirrors the message into the FieldError slot instead of the native bubble, dispatching {@link ValidateChangeEvent} on change.
|
|
53
|
+
*
|
|
54
|
+
* @param schema Schema checked against the field's raw string value —
|
|
55
|
+
* typically the same schema the server parses the submitted form with.
|
|
56
|
+
* @example
|
|
57
|
+
* import * as s from "remix/data-schema";
|
|
58
|
+
* import * as checks from "remix/data-schema/checks";
|
|
59
|
+
*
|
|
60
|
+
* let EmailSchema = s.string().pipe(checks.minLength(1), checks.email());
|
|
61
|
+
* <input name="email" type="email" required aria-describedby="email-error" mix={[validate(EmailSchema)]} />
|
|
62
|
+
* <p id="email-error" data-field-error hidden />
|
|
63
|
+
*/
|
|
64
|
+
export declare const validate: import("remix/ui").MixinFactory<HTMLElement, [schema: Schema<string, unknown>], import("remix/ui").ElementProps>;
|
|
65
|
+
export {};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Applies a shared `remix/data-schema` field schema to a native form
|
|
3
|
+
* control's current value, layering the verdict onto the field's Constraint
|
|
4
|
+
* Validation API state via `setCustomValidity()` and mirroring it into the
|
|
5
|
+
* field's `FieldError` slot once the browser flags it invalid, since no HTML
|
|
6
|
+
* constraint attribute expresses a schema-shaped check on its own.
|
|
7
|
+
*
|
|
8
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
9
|
+
* @copyright Sergio Xalambrí 2026
|
|
10
|
+
*/
|
|
11
|
+
import { parseSafe } from "remix/data-schema";
|
|
12
|
+
import { createElement, createMixin, on } from "remix/ui";
|
|
13
|
+
/**
|
|
14
|
+
* Attribute the FieldError slot exposes itself on. Since `aria-describedby`
|
|
15
|
+
* may list a Description alongside a FieldError, {@link validate} walks
|
|
16
|
+
* those ids and mirrors the verdict into the first one carrying this attribute.
|
|
17
|
+
*/
|
|
18
|
+
export const FIELD_ERROR_ATTRIBUTE = "data-field-error";
|
|
19
|
+
/** DOM event type dispatched by {@link validate} whenever running its schema changes whether a field is valid. */
|
|
20
|
+
const VALIDATE_CHANGE_EVENT = "ui:validate-change";
|
|
21
|
+
/**
|
|
22
|
+
* Dispatched on a field by {@link validate} whenever running its schema
|
|
23
|
+
* changes whether the field is valid, so a consumer can react — disabling a
|
|
24
|
+
* submit button, a live-region announcement — without polling `validity`.
|
|
25
|
+
*/
|
|
26
|
+
export class ValidateChangeEvent extends Event {
|
|
27
|
+
/** `true` once the field's current value satisfies the schema and every other constraint. */
|
|
28
|
+
valid;
|
|
29
|
+
/** The message now sitting in `validationMessage`, empty once `valid` is `true`. */
|
|
30
|
+
message;
|
|
31
|
+
/**
|
|
32
|
+
* @param init Snapshot of the field's validity at dispatch time.
|
|
33
|
+
*/
|
|
34
|
+
constructor(init) {
|
|
35
|
+
super(VALIDATE_CHANGE_EVENT, { bubbles: true });
|
|
36
|
+
this.valid = init.valid;
|
|
37
|
+
this.message = init.message;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Runs `schema` against `field`'s current value and layers the verdict onto
|
|
42
|
+
* its native validity via `setCustomValidity()` — an empty string clears any
|
|
43
|
+
* prior custom error, leaving the field's other constraints to keep deciding.
|
|
44
|
+
*
|
|
45
|
+
* @param field Field whose value `schema` checks.
|
|
46
|
+
* @param schema Schema `field.value` is validated against.
|
|
47
|
+
* @returns The message now sitting in `field.validationMessage`, which may
|
|
48
|
+
* come from `schema`, from an untouched native constraint, or be empty when
|
|
49
|
+
* the field is fully valid.
|
|
50
|
+
*/
|
|
51
|
+
function applySchema(field, schema) {
|
|
52
|
+
let result = parseSafe(schema, field.value);
|
|
53
|
+
let message = result.success ? "" : (result.issues[0]?.message ?? "");
|
|
54
|
+
field.setCustomValidity(message);
|
|
55
|
+
return field.validationMessage;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Finds the FieldError slot associated with `field` by walking the ids its
|
|
59
|
+
* `aria-describedby` lists and returning the first one carrying
|
|
60
|
+
* {@link FIELD_ERROR_ATTRIBUTE}.
|
|
61
|
+
*
|
|
62
|
+
* @param field Field whose `aria-describedby` is searched.
|
|
63
|
+
* @returns The FieldError element, or `null` when none is wired or found.
|
|
64
|
+
*/
|
|
65
|
+
function findFieldErrorSlot(field) {
|
|
66
|
+
let describedBy = field.getAttribute("aria-describedby");
|
|
67
|
+
if (describedBy === null)
|
|
68
|
+
return null;
|
|
69
|
+
for (let id of describedBy.split(/\s+/)) {
|
|
70
|
+
let candidate = field.ownerDocument.getElementById(id);
|
|
71
|
+
if (candidate?.hasAttribute(FIELD_ERROR_ATTRIBUTE))
|
|
72
|
+
return candidate;
|
|
73
|
+
}
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Mirrors `message` onto `field` and its FieldError slot: sets `aria-invalid`
|
|
78
|
+
* for assistive technology since `:user-invalid` styling needs no script
|
|
79
|
+
* help, and writes `message` into the slot from {@link findFieldErrorSlot}, hiding it once empty.
|
|
80
|
+
*
|
|
81
|
+
* @param field Field the message belongs to.
|
|
82
|
+
* @param message Current `validationMessage`, empty when `field` is valid.
|
|
83
|
+
*/
|
|
84
|
+
function mirrorValidity(field, message) {
|
|
85
|
+
field.setAttribute("aria-invalid", message === "" ? "false" : "true");
|
|
86
|
+
let slot = findFieldErrorSlot(field);
|
|
87
|
+
if (slot === null) {
|
|
88
|
+
if (import.meta.env.DEV && message !== "") {
|
|
89
|
+
console.warn("validate(): no FieldError slot found through this field's aria-describedby; " +
|
|
90
|
+
`add ${FIELD_ERROR_ATTRIBUTE} to the element the field describes its error with.`);
|
|
91
|
+
}
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
slot.textContent = message;
|
|
95
|
+
slot.hidden = message === "";
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Adds schema-driven client validation to a form field: `input` keeps its
|
|
99
|
+
* Constraint Validation state current via `setCustomValidity()`, and once
|
|
100
|
+
* reported invalid, mirrors the message into the FieldError slot instead of the native bubble, dispatching {@link ValidateChangeEvent} on change.
|
|
101
|
+
*
|
|
102
|
+
* @param schema Schema checked against the field's raw string value —
|
|
103
|
+
* typically the same schema the server parses the submitted form with.
|
|
104
|
+
* @example
|
|
105
|
+
* import * as s from "remix/data-schema";
|
|
106
|
+
* import * as checks from "remix/data-schema/checks";
|
|
107
|
+
*
|
|
108
|
+
* let EmailSchema = s.string().pipe(checks.minLength(1), checks.email());
|
|
109
|
+
* <input name="email" type="email" required aria-describedby="email-error" mix={[validate(EmailSchema)]} />
|
|
110
|
+
* <p id="email-error" data-field-error hidden />
|
|
111
|
+
*/
|
|
112
|
+
export const validate = createMixin((handle) => {
|
|
113
|
+
let hasReported = false;
|
|
114
|
+
handle.addEventListener("remove", () => {
|
|
115
|
+
hasReported = false;
|
|
116
|
+
});
|
|
117
|
+
return (schema) => {
|
|
118
|
+
return createElement(handle.element, {
|
|
119
|
+
mix: [
|
|
120
|
+
on("input", (event) => {
|
|
121
|
+
let field = event.currentTarget;
|
|
122
|
+
let message = applySchema(field, schema);
|
|
123
|
+
if (!hasReported)
|
|
124
|
+
return;
|
|
125
|
+
mirrorValidity(field, message);
|
|
126
|
+
field.dispatchEvent(new ValidateChangeEvent({ valid: message === "", message }));
|
|
127
|
+
}),
|
|
128
|
+
on("invalid", (event) => {
|
|
129
|
+
event.preventDefault();
|
|
130
|
+
let field = event.currentTarget;
|
|
131
|
+
hasReported = true;
|
|
132
|
+
let message = field.validationMessage;
|
|
133
|
+
mirrorValidity(field, message);
|
|
134
|
+
field.dispatchEvent(new ValidateChangeEvent({ valid: message === "", message }));
|
|
135
|
+
}, true),
|
|
136
|
+
],
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridges a SharedElement's enclosing Frame to the native View Transition
|
|
3
|
+
* API: each Frame reload now runs inside `document.startViewTransition()`,
|
|
4
|
+
* since the platform only opens one when script explicitly wraps an
|
|
5
|
+
* in-place update, so elements sharing a `view-transition-name` morph
|
|
6
|
+
* across the reload instead of popping, one transition shared per Frame.
|
|
7
|
+
*
|
|
8
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
9
|
+
* @copyright Sergio Xalambrí 2026
|
|
10
|
+
*/
|
|
11
|
+
import type { MixinFactory } from "remix/ui";
|
|
12
|
+
/**
|
|
13
|
+
* `data-*` attribute {@link viewTransition} sets on a SharedElement's host
|
|
14
|
+
* while its Frame's transition is in flight, so styling can suppress hover
|
|
15
|
+
* affordances or pointer input for the span of the morph.
|
|
16
|
+
*/
|
|
17
|
+
export declare const TRANSITIONING_ATTRIBUTE = "data-transitioning";
|
|
18
|
+
/** DOM event type dispatched on a SharedElement's host by {@link viewTransition} each time its Frame starts reloading. */
|
|
19
|
+
declare const VIEW_TRANSITION_EVENT: "ui:view-transition";
|
|
20
|
+
declare global {
|
|
21
|
+
interface HTMLElementEventMap {
|
|
22
|
+
[VIEW_TRANSITION_EVENT]: ViewTransitionEvent;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The object `document.startViewTransition()` returns, referenced
|
|
27
|
+
* structurally so this module never has to name the DOM's own
|
|
28
|
+
* `ViewTransition` global directly.
|
|
29
|
+
*/
|
|
30
|
+
type NativeViewTransition = ReturnType<Document["startViewTransition"]>;
|
|
31
|
+
/**
|
|
32
|
+
* Dispatched on a SharedElement's host by {@link viewTransition} each time
|
|
33
|
+
* its Frame starts reloading, carrying the native transition so a consumer
|
|
34
|
+
* can await it or call `skipTransition()` — or `null` when the browser lacks `startViewTransition()` or the visitor prefers reduced motion.
|
|
35
|
+
*/
|
|
36
|
+
export declare class ViewTransitionEvent extends Event {
|
|
37
|
+
/** The transition the reload now runs inside, or `null` when none could be opened. */
|
|
38
|
+
readonly transition: NativeViewTransition | null;
|
|
39
|
+
/**
|
|
40
|
+
* @param transition The transition the reload now runs inside, or `null` when none could be opened.
|
|
41
|
+
*/
|
|
42
|
+
constructor(transition: NativeViewTransition | null);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Wraps a SharedElement's enclosing Frame reload in one native view
|
|
46
|
+
* transition, shared by every SharedElement on that Frame, so elements
|
|
47
|
+
* sharing a `view-transition-name` morph instead of popping — settling `finished` on success and failure alike keeps a skipped transition from stranding the host or surfacing as an unhandled rejection.
|
|
48
|
+
*
|
|
49
|
+
* @returns A mixin descriptor for a SharedElement's `mix` prop.
|
|
50
|
+
* @example
|
|
51
|
+
* <SharedElement id="cover" mix={viewTransition()}>
|
|
52
|
+
* <img src={cover.src} alt={cover.alt} />
|
|
53
|
+
* </SharedElement>
|
|
54
|
+
*/
|
|
55
|
+
export declare const viewTransition: MixinFactory<HTMLElement>;
|
|
56
|
+
export {};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridges a SharedElement's enclosing Frame to the native View Transition
|
|
3
|
+
* API: each Frame reload now runs inside `document.startViewTransition()`,
|
|
4
|
+
* since the platform only opens one when script explicitly wraps an
|
|
5
|
+
* in-place update, so elements sharing a `view-transition-name` morph
|
|
6
|
+
* across the reload instead of popping, one transition shared per Frame.
|
|
7
|
+
*
|
|
8
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
9
|
+
* @copyright Sergio Xalambrí 2026
|
|
10
|
+
*/
|
|
11
|
+
import { createElement, createMixin } from "remix/ui";
|
|
12
|
+
import { prefersReducedMotion } from "../utils/prefers-reduced-motion.js";
|
|
13
|
+
import { trackHostNode } from "./track-host-node.js";
|
|
14
|
+
/**
|
|
15
|
+
* `data-*` attribute {@link viewTransition} sets on a SharedElement's host
|
|
16
|
+
* while its Frame's transition is in flight, so styling can suppress hover
|
|
17
|
+
* affordances or pointer input for the span of the morph.
|
|
18
|
+
*/
|
|
19
|
+
export const TRANSITIONING_ATTRIBUTE = "data-transitioning";
|
|
20
|
+
/** DOM event type dispatched on a SharedElement's host by {@link viewTransition} each time its Frame starts reloading. */
|
|
21
|
+
const VIEW_TRANSITION_EVENT = "ui:view-transition";
|
|
22
|
+
/**
|
|
23
|
+
* Dispatched on a SharedElement's host by {@link viewTransition} each time
|
|
24
|
+
* its Frame starts reloading, carrying the native transition so a consumer
|
|
25
|
+
* can await it or call `skipTransition()` — or `null` when the browser lacks `startViewTransition()` or the visitor prefers reduced motion.
|
|
26
|
+
*/
|
|
27
|
+
export class ViewTransitionEvent extends Event {
|
|
28
|
+
/** The transition the reload now runs inside, or `null` when none could be opened. */
|
|
29
|
+
transition;
|
|
30
|
+
/**
|
|
31
|
+
* @param transition The transition the reload now runs inside, or `null` when none could be opened.
|
|
32
|
+
*/
|
|
33
|
+
constructor(transition) {
|
|
34
|
+
super(VIEW_TRANSITION_EVENT, { bubbles: true });
|
|
35
|
+
this.transition = transition;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Transition state currently in flight per Frame, so every SharedElement
|
|
40
|
+
* mixin instance reacting to the same Frame's `reloadStart` reuses the one
|
|
41
|
+
* transition already opened for it instead of opening a second.
|
|
42
|
+
*/
|
|
43
|
+
const frameTransitions = new WeakMap();
|
|
44
|
+
/**
|
|
45
|
+
* Opens (or reuses) the native transition wrapping `frame`'s current reload,
|
|
46
|
+
* skipping `startViewTransition()` when unsupported or reduced motion is
|
|
47
|
+
* preferred, staying open until {@link settleFrameTransition} reports it done.
|
|
48
|
+
*
|
|
49
|
+
* @param frame Frame whose reload this transition wraps.
|
|
50
|
+
*/
|
|
51
|
+
function ensureFrameTransition(frame) {
|
|
52
|
+
let existing = frameTransitions.get(frame);
|
|
53
|
+
if (existing)
|
|
54
|
+
return existing;
|
|
55
|
+
let state = { transition: null, completed: false };
|
|
56
|
+
let supportsViewTransitions = typeof document.startViewTransition === "function";
|
|
57
|
+
if (supportsViewTransitions && !prefersReducedMotion()) {
|
|
58
|
+
state.transition = document.startViewTransition(() => new Promise((resolve) => {
|
|
59
|
+
if (state.completed)
|
|
60
|
+
resolve();
|
|
61
|
+
else
|
|
62
|
+
state.resolveUpdate = resolve;
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
frameTransitions.set(frame, state);
|
|
66
|
+
return state;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Marks `frame`'s in-flight transition complete, resolving its update
|
|
70
|
+
* callback now if already invoked, or leaving {@link ensureFrameTransition}'s
|
|
71
|
+
* executor to resolve it once invoked, then clears state for the next reload.
|
|
72
|
+
*
|
|
73
|
+
* @param frame Frame whose reload just finished.
|
|
74
|
+
*/
|
|
75
|
+
function settleFrameTransition(frame) {
|
|
76
|
+
let state = frameTransitions.get(frame);
|
|
77
|
+
if (!state)
|
|
78
|
+
return;
|
|
79
|
+
state.completed = true;
|
|
80
|
+
state.resolveUpdate?.();
|
|
81
|
+
frameTransitions.delete(frame);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Wraps a SharedElement's enclosing Frame reload in one native view
|
|
85
|
+
* transition, shared by every SharedElement on that Frame, so elements
|
|
86
|
+
* sharing a `view-transition-name` morph instead of popping — settling `finished` on success and failure alike keeps a skipped transition from stranding the host or surfacing as an unhandled rejection.
|
|
87
|
+
*
|
|
88
|
+
* @returns A mixin descriptor for a SharedElement's `mix` prop.
|
|
89
|
+
* @example
|
|
90
|
+
* <SharedElement id="cover" mix={viewTransition()}>
|
|
91
|
+
* <img src={cover.src} alt={cover.alt} />
|
|
92
|
+
* </SharedElement>
|
|
93
|
+
*/
|
|
94
|
+
export const viewTransition = createMixin((handle) => {
|
|
95
|
+
let getHostNode = trackHostNode(handle);
|
|
96
|
+
let frame = handle.frame;
|
|
97
|
+
frame.addEventListener("reloadStart", () => {
|
|
98
|
+
let state = ensureFrameTransition(frame);
|
|
99
|
+
let hostNode = getHostNode();
|
|
100
|
+
hostNode?.dispatchEvent(new ViewTransitionEvent(state.transition));
|
|
101
|
+
if (!state.transition)
|
|
102
|
+
return;
|
|
103
|
+
let stopTransitioning = () => getHostNode()?.removeAttribute(TRANSITIONING_ATTRIBUTE);
|
|
104
|
+
hostNode?.toggleAttribute(TRANSITIONING_ATTRIBUTE, true);
|
|
105
|
+
void state.transition.finished.then(stopTransitioning, stopTransitioning);
|
|
106
|
+
}, { signal: handle.signal });
|
|
107
|
+
frame.addEventListener("reloadComplete", () => settleFrameTransition(frame), {
|
|
108
|
+
signal: handle.signal,
|
|
109
|
+
});
|
|
110
|
+
return () => createElement(handle.element, {});
|
|
111
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The eight-slot categorical color contract shared by every chart's plotted
|
|
3
|
+
* elements, addressed everywhere through a `data-color` attribute.
|
|
4
|
+
* {@link CHART_COLOR_SLOT_COUNT} sets how many `--ui-chart-*` slots a series
|
|
5
|
+
* cycles through, and {@link chartPalette} generates one CSS rule per slot
|
|
6
|
+
* since a selector can't be parameterized by a loop.
|
|
7
|
+
*
|
|
8
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
9
|
+
* @copyright Sergio Xalambrí 2026
|
|
10
|
+
*/
|
|
11
|
+
import type { ElementProps, MixinDescriptor } from "remix/ui";
|
|
12
|
+
import type { CSSStyles } from "../utils/css-styles.js";
|
|
13
|
+
/**
|
|
14
|
+
* Number of categorical color slots a chart's `--ui-chart-*` palette spans.
|
|
15
|
+
* A series, wedge, or bar whose position in its own list outgrows this
|
|
16
|
+
* count wraps back around to the first slot.
|
|
17
|
+
*/
|
|
18
|
+
export declare const CHART_COLOR_SLOT_COUNT = 8;
|
|
19
|
+
/**
|
|
20
|
+
* Composes the mixin painting `property` from whichever of the
|
|
21
|
+
* {@link CHART_COLOR_SLOT_COUNT} categorical slots an element's own
|
|
22
|
+
* `data-color` attribute names, one rule generated per slot.
|
|
23
|
+
*
|
|
24
|
+
* @param property The CSS property each rule sets, read from the matching `--ui-chart-*` variable.
|
|
25
|
+
* @param combinator Selector combinator placed between the mixin's own host and its `[data-color]` match. Defaults to `""`, matching the host itself.
|
|
26
|
+
* @returns A `css()` mixin ready for a host element's `mix` prop.
|
|
27
|
+
* @example
|
|
28
|
+
* <span data-color={String(color)} mix={[chartPalette("color"), css({ display: "inline-block" })]} />;
|
|
29
|
+
* @example
|
|
30
|
+
* // A chart root painting every nested `[data-color]` descendant from one
|
|
31
|
+
* // shared mixin.
|
|
32
|
+
* <svg mix={[chartPalette("fill", " "), css({ display: "block" })]}>{children}</svg>;
|
|
33
|
+
*/
|
|
34
|
+
export declare function chartPalette<Node extends Element = Element>(property: "color" | "fill" | "backgroundColor", combinator?: string): MixinDescriptor<Node, [styles: CSSStyles], ElementProps>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { combine, raw, var as varUtility } from "@sdxc/u/general";
|
|
2
|
+
import { when } from "@sdxc/u/state";
|
|
3
|
+
/**
|
|
4
|
+
* Number of categorical color slots a chart's `--ui-chart-*` palette spans.
|
|
5
|
+
* A series, wedge, or bar whose position in its own list outgrows this
|
|
6
|
+
* count wraps back around to the first slot.
|
|
7
|
+
*/
|
|
8
|
+
export const CHART_COLOR_SLOT_COUNT = 8;
|
|
9
|
+
/**
|
|
10
|
+
* Composes the mixin painting `property` from whichever of the
|
|
11
|
+
* {@link CHART_COLOR_SLOT_COUNT} categorical slots an element's own
|
|
12
|
+
* `data-color` attribute names, one rule generated per slot.
|
|
13
|
+
*
|
|
14
|
+
* @param property The CSS property each rule sets, read from the matching `--ui-chart-*` variable.
|
|
15
|
+
* @param combinator Selector combinator placed between the mixin's own host and its `[data-color]` match. Defaults to `""`, matching the host itself.
|
|
16
|
+
* @returns A `css()` mixin ready for a host element's `mix` prop.
|
|
17
|
+
* @example
|
|
18
|
+
* <span data-color={String(color)} mix={[chartPalette("color"), css({ display: "inline-block" })]} />;
|
|
19
|
+
* @example
|
|
20
|
+
* // A chart root painting every nested `[data-color]` descendant from one
|
|
21
|
+
* // shared mixin.
|
|
22
|
+
* <svg mix={[chartPalette("fill", " "), css({ display: "block" })]}>{children}</svg>;
|
|
23
|
+
*/
|
|
24
|
+
export function chartPalette(property, combinator = "") {
|
|
25
|
+
let slots = Array.from({ length: CHART_COLOR_SLOT_COUNT }, (_, index) => index + 1);
|
|
26
|
+
return combine(slots.map((slot) => when(`&${combinator}[data-color="${slot}"]`, raw({ [property]: varUtility(`ui-chart-${slot}`) }))));
|
|
27
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The single-column stacking layout shared by every field convenience
|
|
3
|
+
* wrapper's outermost host: its caption, control, and optional supporting
|
|
4
|
+
* passage or validation message lay out in a narrow vertical stack with a
|
|
5
|
+
* small gap between them, keeping a label sitting close to the control it
|
|
6
|
+
* describes.
|
|
7
|
+
*
|
|
8
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
9
|
+
* @copyright Sergio Xalambrí 2026
|
|
10
|
+
*/
|
|
11
|
+
import type { ElementProps, MixinDescriptor } from "remix/ui";
|
|
12
|
+
import type { CSSStyles } from "../utils/css-styles.js";
|
|
13
|
+
/**
|
|
14
|
+
* Composes the single-column stack — a `0.25rem` gap between a field's own
|
|
15
|
+
* caption, control, and optional supporting text — for a host's `mix` prop.
|
|
16
|
+
* Compose a separate `css()` call for the wider gap between whole fields.
|
|
17
|
+
*
|
|
18
|
+
* @returns A `css()` mixin ready for a host element's `mix` prop.
|
|
19
|
+
* @example
|
|
20
|
+
* <div data-slot="date-field" mix={[fieldStackLayout(), mix]}>
|
|
21
|
+
* <Label htmlFor={handle.id}>{label}</Label>
|
|
22
|
+
* <Input id={handle.id} />
|
|
23
|
+
* </div>;
|
|
24
|
+
*/
|
|
25
|
+
export declare function fieldStackLayout<Node extends Element = Element>(): MixinDescriptor<Node, [
|
|
26
|
+
styles: CSSStyles
|
|
27
|
+
], ElementProps>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { vstack } from "@sdxc/u/layout";
|
|
2
|
+
/**
|
|
3
|
+
* Composes the single-column stack — a `0.25rem` gap between a field's own
|
|
4
|
+
* caption, control, and optional supporting text — for a host's `mix` prop.
|
|
5
|
+
* Compose a separate `css()` call for the wider gap between whole fields.
|
|
6
|
+
*
|
|
7
|
+
* @returns A `css()` mixin ready for a host element's `mix` prop.
|
|
8
|
+
* @example
|
|
9
|
+
* <div data-slot="date-field" mix={[fieldStackLayout(), mix]}>
|
|
10
|
+
* <Label htmlFor={handle.id}>{label}</Label>
|
|
11
|
+
* <Input id={handle.id} />
|
|
12
|
+
* </div>;
|
|
13
|
+
*/
|
|
14
|
+
export function fieldStackLayout() {
|
|
15
|
+
return vstack({ gap: "0.25rem" });
|
|
16
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The border, rounding, tint, and elevation shadow a floating surface — an
|
|
3
|
+
* anchored popover, a hover-revealed card, a multi-item navigation panel, or
|
|
4
|
+
* a searchable command list — carries on its own host element, ahead of
|
|
5
|
+
* whatever placement, motion, and content styling that surface layers on
|
|
6
|
+
* top.
|
|
7
|
+
*
|
|
8
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
9
|
+
* @copyright Sergio Xalambrí 2026
|
|
10
|
+
*/
|
|
11
|
+
import type { ElementProps, MixinDescriptor } from "remix/ui";
|
|
12
|
+
import type { CSSStyles } from "../utils/css-styles.js";
|
|
13
|
+
/**
|
|
14
|
+
* Composes the shared floating-surface border, tint, and elevation shadow as
|
|
15
|
+
* a `css()` mixin. The shadow keeps a literal fallback shaped like `@sdxc/u`'s
|
|
16
|
+
* `lg` step, under the `--ui-shadow-md` variable name.
|
|
17
|
+
*
|
|
18
|
+
* @returns A `css()` mixin ready for a host element's `mix` prop.
|
|
19
|
+
* @example
|
|
20
|
+
* <div
|
|
21
|
+
* popover="auto"
|
|
22
|
+
* mix={[
|
|
23
|
+
* floatingSurface(),
|
|
24
|
+
* css({ margin: "0", inset: "auto" }),
|
|
25
|
+
* ]}
|
|
26
|
+
* >
|
|
27
|
+
* {content}
|
|
28
|
+
* </div>;
|
|
29
|
+
*/
|
|
30
|
+
export declare function floatingSurface<Node extends Element = Element>(): MixinDescriptor<Node, [
|
|
31
|
+
styles: CSSStyles
|
|
32
|
+
], ElementProps>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { bg, border } from "@sdxc/u/color";
|
|
2
|
+
import { rounded } from "@sdxc/u/effects";
|
|
3
|
+
import { combine, raw } from "@sdxc/u/general";
|
|
4
|
+
/**
|
|
5
|
+
* Composes the shared floating-surface border, tint, and elevation shadow as
|
|
6
|
+
* a `css()` mixin. The shadow keeps a literal fallback shaped like `@sdxc/u`'s
|
|
7
|
+
* `lg` step, under the `--ui-shadow-md` variable name.
|
|
8
|
+
*
|
|
9
|
+
* @returns A `css()` mixin ready for a host element's `mix` prop.
|
|
10
|
+
* @example
|
|
11
|
+
* <div
|
|
12
|
+
* popover="auto"
|
|
13
|
+
* mix={[
|
|
14
|
+
* floatingSurface(),
|
|
15
|
+
* css({ margin: "0", inset: "auto" }),
|
|
16
|
+
* ]}
|
|
17
|
+
* >
|
|
18
|
+
* {content}
|
|
19
|
+
* </div>;
|
|
20
|
+
*/
|
|
21
|
+
export function floatingSurface() {
|
|
22
|
+
return combine([
|
|
23
|
+
rounded("lg"),
|
|
24
|
+
border({ color: "neutral", width: 1 }),
|
|
25
|
+
bg("neutral.tint"),
|
|
26
|
+
raw({
|
|
27
|
+
boxShadow: "var(--ui-shadow-md, 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1))",
|
|
28
|
+
}),
|
|
29
|
+
]);
|
|
30
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The flex-item layout and current-color declarations shared by a leading
|
|
3
|
+
* graphic slot — whichever of an icon or a loading graphic currently
|
|
4
|
+
* occupies that slot — so the two stay laid out identically and a host can
|
|
5
|
+
* swap between them without the rest of its layout shifting.
|
|
6
|
+
*
|
|
7
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
8
|
+
* @copyright Sergio Xalambrí 2026
|
|
9
|
+
*/
|
|
10
|
+
import type { ElementProps, MixinDescriptor } from "remix/ui";
|
|
11
|
+
import type { CSSStyles } from "../utils/css-styles.js";
|
|
12
|
+
/**
|
|
13
|
+
* A shrink-resistant, nudged-down, current-colored mixin for a leading
|
|
14
|
+
* graphic slot, keeping an icon and a loading graphic laid out identically.
|
|
15
|
+
* `fg("currentcolor")` matches `@sdxc/u`'s case-normalized token lookup.
|
|
16
|
+
*
|
|
17
|
+
* @returns A `css()` mixin ready for a host element's `mix` prop.
|
|
18
|
+
* @example
|
|
19
|
+
* <div data-slot="icon" mix={[graphicHostStyle(), css({ ...ownStyles })]}>
|
|
20
|
+
* <CircleCheckIcon />
|
|
21
|
+
* </div>;
|
|
22
|
+
*/
|
|
23
|
+
export declare function graphicHostStyle<Node extends Element = Element>(): MixinDescriptor<Node, [
|
|
24
|
+
styles: CSSStyles
|
|
25
|
+
], ElementProps>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { fg } from "@sdxc/u/color";
|
|
2
|
+
import { combine } from "@sdxc/u/general";
|
|
3
|
+
import { shrink } from "@sdxc/u/layout";
|
|
4
|
+
import { mbs } from "@sdxc/u/size";
|
|
5
|
+
/**
|
|
6
|
+
* A shrink-resistant, nudged-down, current-colored mixin for a leading
|
|
7
|
+
* graphic slot, keeping an icon and a loading graphic laid out identically.
|
|
8
|
+
* `fg("currentcolor")` matches `@sdxc/u`'s case-normalized token lookup.
|
|
9
|
+
*
|
|
10
|
+
* @returns A `css()` mixin ready for a host element's `mix` prop.
|
|
11
|
+
* @example
|
|
12
|
+
* <div data-slot="icon" mix={[graphicHostStyle(), css({ ...ownStyles })]}>
|
|
13
|
+
* <CircleCheckIcon />
|
|
14
|
+
* </div>;
|
|
15
|
+
*/
|
|
16
|
+
export function graphicHostStyle() {
|
|
17
|
+
return combine([shrink(), mbs("0.125rem"), fg("currentcolor")]);
|
|
18
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Barrel for the style-mixin layer: `css()` mixin factories a component
|
|
3
|
+
* composes directly in its own `mix` array for a recurring border, focus
|
|
4
|
+
* ring, panel chrome, or gradient recipe shared across several components,
|
|
5
|
+
* each producing its own mixin descriptor via a direct `css()` call.
|
|
6
|
+
*
|
|
7
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
8
|
+
* @copyright Sergio Xalambrí 2026
|
|
9
|
+
*/
|
|
10
|
+
export * from "./chart-palette.js";
|
|
11
|
+
export * from "./field-stack-layout.js";
|
|
12
|
+
export * from "./floating-surface.js";
|
|
13
|
+
export * from "./graphic-host.js";
|
|
14
|
+
export * from "./interactive-transition.js";
|
|
15
|
+
export * from "./legend-toggle.js";
|
|
16
|
+
export * from "./output-caption-text.js";
|
|
17
|
+
export * from "./panel-chrome.js";
|
|
18
|
+
export * from "./range-thumb-appearance.js";
|
|
19
|
+
export * from "./rtl-aware-gradient-direction.js";
|
|
20
|
+
export * from "./semantic-color-panel.js";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Barrel for the style-mixin layer: `css()` mixin factories a component
|
|
3
|
+
* composes directly in its own `mix` array for a recurring border, focus
|
|
4
|
+
* ring, panel chrome, or gradient recipe shared across several components,
|
|
5
|
+
* each producing its own mixin descriptor via a direct `css()` call.
|
|
6
|
+
*
|
|
7
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
8
|
+
* @copyright Sergio Xalambrí 2026
|
|
9
|
+
*/
|
|
10
|
+
export * from "./chart-palette.js";
|
|
11
|
+
export * from "./field-stack-layout.js";
|
|
12
|
+
export * from "./floating-surface.js";
|
|
13
|
+
export * from "./graphic-host.js";
|
|
14
|
+
export * from "./interactive-transition.js";
|
|
15
|
+
export * from "./legend-toggle.js";
|
|
16
|
+
export * from "./output-caption-text.js";
|
|
17
|
+
export * from "./panel-chrome.js";
|
|
18
|
+
export * from "./range-thumb-appearance.js";
|
|
19
|
+
export * from "./rtl-aware-gradient-direction.js";
|
|
20
|
+
export * from "./semantic-color-panel.js";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `interactiveTransition()` style-mixin factory: the shared
|
|
3
|
+
* `transition-property`/`transition-timing-function`/`transition-duration`
|
|
4
|
+
* triplet composed into an interactive control's `mix` array, animating a
|
|
5
|
+
* hover, focus, press, selection, or validity change instead of snapping
|
|
6
|
+
* between states, sourced from the animation layer's shared tokens.
|
|
7
|
+
*
|
|
8
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
9
|
+
* @copyright Sergio Xalambrí 2026
|
|
10
|
+
*/
|
|
11
|
+
import type { ElementProps, MixinDescriptor } from "remix/ui";
|
|
12
|
+
import type { CSSStyles } from "../utils/css-styles.js";
|
|
13
|
+
/**
|
|
14
|
+
* Composes the transition-property/timing-function/duration triplet shared
|
|
15
|
+
* by every interactive control's hover, focus, press, selection, and
|
|
16
|
+
* validity-state changes, for use alongside a host's own `css()` styling.
|
|
17
|
+
*
|
|
18
|
+
* @returns A `css()` mixin ready for a host element's `mix` prop.
|
|
19
|
+
* @example
|
|
20
|
+
* <input
|
|
21
|
+
* mix={[
|
|
22
|
+
* interactiveTransition(),
|
|
23
|
+
* css({
|
|
24
|
+
* borderColor: "var(--ui-neutral-border)",
|
|
25
|
+
* "&:hover": { borderColor: "var(--ui-neutral-border-strong)" },
|
|
26
|
+
* }),
|
|
27
|
+
* ]}
|
|
28
|
+
* />;
|
|
29
|
+
*/
|
|
30
|
+
export declare function interactiveTransition<Node extends Element = Element>(): MixinDescriptor<Node, [
|
|
31
|
+
styles: CSSStyles
|
|
32
|
+
], ElementProps>;
|