@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,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A convenience wrapper composing a two-control confirmation prompt in one
|
|
3
|
+
* call: an {@link AlertDialog} panel prefilled with a heading, an optional
|
|
4
|
+
* supporting passage, and a cancel/confirm control pair, so a single
|
|
5
|
+
* consequential decision needs no compound assembly of its own. The
|
|
6
|
+
* confirming control defaults to the semantic danger tone, keeping an
|
|
7
|
+
* irreversible action behind an explicit confirmation step in that tone.
|
|
8
|
+
*
|
|
9
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
10
|
+
* @copyright Sergio Xalambrí 2026
|
|
11
|
+
*/
|
|
12
|
+
import type { Handle, Props as TagProps, RemixNode } from "remix/ui";
|
|
13
|
+
import type { Button } from "./button.js";
|
|
14
|
+
import { AlertDialog } from "./alert-dialog.js";
|
|
15
|
+
/**
|
|
16
|
+
* Prop types for {@link Confirm}.
|
|
17
|
+
*/
|
|
18
|
+
export declare namespace Confirm {
|
|
19
|
+
/**
|
|
20
|
+
* Per-part styling for the elements this convenience wrapper composes in
|
|
21
|
+
* one call, layered after each part's own built-in styling.
|
|
22
|
+
*/
|
|
23
|
+
interface PartsProps {
|
|
24
|
+
/** Styling for the header slot wrapping the title and description, rendered through {@link AlertDialog.Header}. */
|
|
25
|
+
header?: TagProps<"div">["mix"];
|
|
26
|
+
/** Styling for the heading, rendered through {@link AlertDialog.Title}, whichever heading tag its ambient level resolves to. */
|
|
27
|
+
title?: TagProps<"h1" | "h2" | "h3" | "h4" | "h5" | "h6">["mix"];
|
|
28
|
+
/** Styling for the supporting description, rendered through {@link AlertDialog.Description} only when `description` is set. */
|
|
29
|
+
description?: TagProps<"p">["mix"];
|
|
30
|
+
/** Styling for the action row wrapping the cancel and confirm controls, rendered through {@link AlertDialog.Footer}. */
|
|
31
|
+
footer?: TagProps<"div">["mix"];
|
|
32
|
+
/** Styling for the control that backs out without confirming, rendered through {@link AlertDialog.Cancel}. */
|
|
33
|
+
cancel?: TagProps<"button">["mix"];
|
|
34
|
+
/** Styling for the confirming control, rendered through {@link AlertDialog.Action}. */
|
|
35
|
+
action?: TagProps<"button">["mix"];
|
|
36
|
+
/** Styling for the `<form>` wrapping the panel's content, rendered only in submit mode. */
|
|
37
|
+
form?: TagProps<"form">["mix"];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The submission a confirming control performs instead of merely closing
|
|
41
|
+
* the panel. Passing this switches {@link Confirm} into submit mode, where
|
|
42
|
+
* the form's response is what ends the interruption.
|
|
43
|
+
*/
|
|
44
|
+
interface FormProps {
|
|
45
|
+
/** URL the confirmation submits to. Omit to submit to the current URL, as a native `<form>` with no `action` does. */
|
|
46
|
+
action?: string;
|
|
47
|
+
/** HTTP method the confirmation submits with. Defaults to {@link DEFAULT_METHOD}, since a confirmed action changes state. */
|
|
48
|
+
method?: "get" | "post";
|
|
49
|
+
/**
|
|
50
|
+
* Hidden inputs submitted along with the confirmation — a CSRF token,
|
|
51
|
+
* an intent discriminator, the id of the record being acted on. They
|
|
52
|
+
* render first inside the form, before the panel's own content.
|
|
53
|
+
*/
|
|
54
|
+
fields?: RemixNode;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Props accepted by {@link Confirm}. `mix` styles the underlying
|
|
58
|
+
* {@link AlertDialog} host directly; style the composed header, title,
|
|
59
|
+
* description, footer, and controls individually through `parts` instead.
|
|
60
|
+
*/
|
|
61
|
+
interface Props extends Omit<AlertDialog.Props, "id" | "children" | "title"> {
|
|
62
|
+
/**
|
|
63
|
+
* Stable identifier the panel renders as its own `id`; a trigger
|
|
64
|
+
* elsewhere on the page targets it via `commandfor`/`command="show-modal"`,
|
|
65
|
+
* and the cancel and confirm controls point back at it automatically.
|
|
66
|
+
*/
|
|
67
|
+
id: string;
|
|
68
|
+
/** The panel's heading, rendered through {@link AlertDialog.Title}. */
|
|
69
|
+
title: RemixNode;
|
|
70
|
+
/**
|
|
71
|
+
* Supporting copy rendered through {@link AlertDialog.Description}
|
|
72
|
+
* beneath the title. Omit to render no description.
|
|
73
|
+
*/
|
|
74
|
+
description?: RemixNode;
|
|
75
|
+
/** Label for the confirming control, rendered through {@link AlertDialog.Action}. */
|
|
76
|
+
confirmLabel: RemixNode;
|
|
77
|
+
/** Label for the control that backs out without confirming, rendered through {@link AlertDialog.Cancel}. */
|
|
78
|
+
cancelLabel: RemixNode;
|
|
79
|
+
/** Semantic color for the confirming control. Defaults to {@link DEFAULT_COLOR}. */
|
|
80
|
+
color?: Button.Color;
|
|
81
|
+
/**
|
|
82
|
+
* Submission the confirming control performs. Omitting it leaves
|
|
83
|
+
* confirming as a close-only action for the page to react to; setting it
|
|
84
|
+
* submits a real form instead.
|
|
85
|
+
*/
|
|
86
|
+
form?: FormProps;
|
|
87
|
+
/** Per-part styling for this wrapper's internally composed elements. */
|
|
88
|
+
parts?: PartsProps;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Composes {@link AlertDialog} into a confirmation prompt, wiring title and
|
|
93
|
+
* description ids to `aria-labelledby`/`aria-describedby`. Omit
|
|
94
|
+
* {@link Confirm.Props.form} to close on confirm, or pass it to submit a real `<form>` instead.
|
|
95
|
+
*
|
|
96
|
+
* @param handle Runtime handle carrying the panel's props and this instance's stable identifier.
|
|
97
|
+
* @returns The render function producing the confirmation prompt's markup.
|
|
98
|
+
* @example
|
|
99
|
+
* <Button commandfor="confirm-delete" command="show-modal" color="danger">{t("project.delete")}</Button>
|
|
100
|
+
* <Confirm
|
|
101
|
+
* id="confirm-delete"
|
|
102
|
+
* title={t("project.deleteTitle")}
|
|
103
|
+
* description={t("project.deleteDescription")}
|
|
104
|
+
* confirmLabel={t("actions.delete")}
|
|
105
|
+
* cancelLabel={t("actions.cancel")}
|
|
106
|
+
* />
|
|
107
|
+
* @example
|
|
108
|
+
* <Confirm
|
|
109
|
+
* id="publish-post"
|
|
110
|
+
* title={t("post.publishTitle")}
|
|
111
|
+
* confirmLabel={t("actions.publish")}
|
|
112
|
+
* cancelLabel={t("actions.cancel")}
|
|
113
|
+
* color="brand"
|
|
114
|
+
* />
|
|
115
|
+
* @example
|
|
116
|
+
* <Confirm
|
|
117
|
+
* id="revoke-session"
|
|
118
|
+
* title={t("session.revokeTitle")}
|
|
119
|
+
* confirmLabel={t("actions.revoke")}
|
|
120
|
+
* cancelLabel={t("actions.cancel")}
|
|
121
|
+
* form={{ action: revokeUrl, fields: <input type="hidden" name="csrf" value={token} /> }}
|
|
122
|
+
* />
|
|
123
|
+
*/
|
|
124
|
+
export declare function Confirm(handle: Handle<Confirm.Props>): () => import("remix/ui").RemixElement;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { flex, flexCol, gap } from "@sdxc/u/layout";
|
|
3
|
+
import { AlertDialog } from "./alert-dialog.js";
|
|
4
|
+
/** Semantic color role {@link Confirm} falls back to when `color` is omitted. */
|
|
5
|
+
const DEFAULT_COLOR = "danger";
|
|
6
|
+
/** HTTP method a submitting {@link Confirm} falls back to when `form.method` is omitted. */
|
|
7
|
+
const DEFAULT_METHOD = "post";
|
|
8
|
+
/**
|
|
9
|
+
* Column gap the wrapping `<form>` re-declares in submit mode, matching the
|
|
10
|
+
* panel's own child gap — the form becomes the panel's single child, so
|
|
11
|
+
* without this the header and footer would lose their spacing.
|
|
12
|
+
*/
|
|
13
|
+
const PANEL_GAP = 6;
|
|
14
|
+
/**
|
|
15
|
+
* Composes {@link AlertDialog} into a confirmation prompt, wiring title and
|
|
16
|
+
* description ids to `aria-labelledby`/`aria-describedby`. Omit
|
|
17
|
+
* {@link Confirm.Props.form} to close on confirm, or pass it to submit a real `<form>` instead.
|
|
18
|
+
*
|
|
19
|
+
* @param handle Runtime handle carrying the panel's props and this instance's stable identifier.
|
|
20
|
+
* @returns The render function producing the confirmation prompt's markup.
|
|
21
|
+
* @example
|
|
22
|
+
* <Button commandfor="confirm-delete" command="show-modal" color="danger">{t("project.delete")}</Button>
|
|
23
|
+
* <Confirm
|
|
24
|
+
* id="confirm-delete"
|
|
25
|
+
* title={t("project.deleteTitle")}
|
|
26
|
+
* description={t("project.deleteDescription")}
|
|
27
|
+
* confirmLabel={t("actions.delete")}
|
|
28
|
+
* cancelLabel={t("actions.cancel")}
|
|
29
|
+
* />
|
|
30
|
+
* @example
|
|
31
|
+
* <Confirm
|
|
32
|
+
* id="publish-post"
|
|
33
|
+
* title={t("post.publishTitle")}
|
|
34
|
+
* confirmLabel={t("actions.publish")}
|
|
35
|
+
* cancelLabel={t("actions.cancel")}
|
|
36
|
+
* color="brand"
|
|
37
|
+
* />
|
|
38
|
+
* @example
|
|
39
|
+
* <Confirm
|
|
40
|
+
* id="revoke-session"
|
|
41
|
+
* title={t("session.revokeTitle")}
|
|
42
|
+
* confirmLabel={t("actions.revoke")}
|
|
43
|
+
* cancelLabel={t("actions.cancel")}
|
|
44
|
+
* form={{ action: revokeUrl, fields: <input type="hidden" name="csrf" value={token} /> }}
|
|
45
|
+
* />
|
|
46
|
+
*/
|
|
47
|
+
export function Confirm(handle) {
|
|
48
|
+
return () => {
|
|
49
|
+
let { id, title, description, confirmLabel, cancelLabel, color, form, "aria-labelledby": ariaLabelledByProp, "aria-describedby": ariaDescribedByProp, parts, mix, ...rest } = handle.props;
|
|
50
|
+
let resolvedColor = color ?? DEFAULT_COLOR;
|
|
51
|
+
let titleId = `${handle.id}-title`;
|
|
52
|
+
let descriptionId = description ? `${handle.id}-description` : undefined;
|
|
53
|
+
let content = (_jsxs(_Fragment, { children: [_jsxs(AlertDialog.Header, { mix: parts?.header, children: [_jsx(AlertDialog.Title, { id: titleId, mix: parts?.title, children: title }), description ? (_jsx(AlertDialog.Description, { id: descriptionId, mix: parts?.description, children: description })) : null] }), _jsxs(AlertDialog.Footer, { mix: parts?.footer, children: [_jsx(AlertDialog.Cancel, { commandfor: id, mix: parts?.cancel, children: cancelLabel }), _jsx(AlertDialog.Action, { type: form ? "submit" : undefined, commandfor: form ? undefined : id, color: resolvedColor, mix: parts?.action, children: confirmLabel })] })] }));
|
|
54
|
+
return (_jsx(AlertDialog, { ...rest, id: id, "aria-labelledby": ariaLabelledByProp ?? titleId, "aria-describedby": ariaDescribedByProp ?? descriptionId, mix: mix, children: form ? (_jsxs("form", { action: form.action, method: form.method ?? DEFAULT_METHOD, mix: [flex(), flexCol(), gap(PANEL_GAP), parts?.form], children: [form.fields, content] })) : (content) }));
|
|
55
|
+
};
|
|
56
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A menu surface that opens at a right-click's pointer position, composing
|
|
3
|
+
* {@link Menu}'s popover styling and `role="menu"` wiring directly so its
|
|
4
|
+
* rows read and behave exactly like a standard menu's. Adds the
|
|
5
|
+
* {@link ContextMenu.Trigger} wrapper a pointer gesture opens the surface
|
|
6
|
+
* against, plus the grouped-row parts — {@link ContextMenu.Group},
|
|
7
|
+
* {@link ContextMenu.Label}, and {@link ContextMenu.Shortcut} — a context
|
|
8
|
+
* menu's denser row layout tends to need.
|
|
9
|
+
*
|
|
10
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
11
|
+
* @copyright Sergio Xalambrí 2026
|
|
12
|
+
*/
|
|
13
|
+
import type { Handle, Props as TagProps, RemixNode } from "remix/ui";
|
|
14
|
+
import { Menu } from "./menu.js";
|
|
15
|
+
import { Section } from "./section.js";
|
|
16
|
+
/**
|
|
17
|
+
* Prop types for {@link ContextMenu} and its compound parts.
|
|
18
|
+
*/
|
|
19
|
+
export declare namespace ContextMenu {
|
|
20
|
+
/**
|
|
21
|
+
* Every prop {@link Menu.Props} accepts, unchanged, since {@link
|
|
22
|
+
* ContextMenu} renders one directly as its host.
|
|
23
|
+
*/
|
|
24
|
+
interface Props extends Menu.Props {
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Every native `<div>` attribute, plus the `mix` passthrough. The area a
|
|
28
|
+
* consumer wraps around content that should open {@link ContextMenu} at the
|
|
29
|
+
* pointer's position — a table row, a card, a canvas region.
|
|
30
|
+
*/
|
|
31
|
+
interface TriggerProps extends TagProps<"div"> {
|
|
32
|
+
/** The content the pointer gesture opens {@link ContextMenu} against. */
|
|
33
|
+
children: RemixNode;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Every prop {@link Menu.ItemProps} accepts, unchanged, since {@link
|
|
37
|
+
* ContextMenu.Item} renders one directly.
|
|
38
|
+
*/
|
|
39
|
+
interface ItemProps extends Menu.ItemProps {
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Every prop {@link Section.Props} accepts, since {@link
|
|
43
|
+
* ContextMenu.Group} renders one directly as its host.
|
|
44
|
+
*/
|
|
45
|
+
interface GroupProps extends Section.Props {
|
|
46
|
+
/** The group's rows, typically a {@link ContextMenu.Label} followed by a run of {@link ContextMenu.Item}s. */
|
|
47
|
+
children: RemixNode;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Every native `<header>` attribute, plus the `mix` passthrough.
|
|
51
|
+
*/
|
|
52
|
+
interface LabelProps extends TagProps<"header"> {
|
|
53
|
+
/** The group's visible label text. */
|
|
54
|
+
children: RemixNode;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Every prop {@link Menu.SeparatorProps} accepts, unchanged, since {@link
|
|
58
|
+
* ContextMenu.Separator} renders one directly.
|
|
59
|
+
*/
|
|
60
|
+
interface SeparatorProps extends Menu.SeparatorProps {
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Every prop {@link ContextMenu.Props} accepts, unchanged, since {@link
|
|
64
|
+
* ContextMenu.SubContent} renders {@link ContextMenu} directly with a
|
|
65
|
+
* different default `placement`.
|
|
66
|
+
*/
|
|
67
|
+
interface SubContentProps extends Props {
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Every native `<span>` attribute, plus the `mix` passthrough.
|
|
71
|
+
*/
|
|
72
|
+
interface ShortcutProps extends TagProps<"span"> {
|
|
73
|
+
/** The shortcut hint text, typically a key combination like "⌘⇧D". */
|
|
74
|
+
children: RemixNode;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Renders {@link Menu} unchanged; positioning against the pointer is handled
|
|
79
|
+
* entirely by the `contextMenu()` mixin a consuming island applies to
|
|
80
|
+
* {@link ContextMenu.Trigger}, while every nested row stays a real, tab-reachable `<a>` or `<button>`.
|
|
81
|
+
*
|
|
82
|
+
* @param handle Runtime handle carrying the host's {@link Menu} props.
|
|
83
|
+
* @returns The render function producing the surface's markup.
|
|
84
|
+
* @example
|
|
85
|
+
* <ContextMenu.Trigger mix={[contextMenu("row-menu")]}>
|
|
86
|
+
* <TableRow />
|
|
87
|
+
* </ContextMenu.Trigger>
|
|
88
|
+
* <ContextMenu id="row-menu" aria-label={t("table.rowActions")}>
|
|
89
|
+
* <ContextMenu.Item href={viewUrl}>{t("actions.view")}</ContextMenu.Item>
|
|
90
|
+
* <ContextMenu.Item href={editUrl}>{t("actions.edit")}</ContextMenu.Item>
|
|
91
|
+
* <ContextMenu.Separator />
|
|
92
|
+
* <ContextMenu.Item danger commandfor="confirm-delete" command="show-modal">{t("actions.delete")}</ContextMenu.Item>
|
|
93
|
+
* </ContextMenu>
|
|
94
|
+
*/
|
|
95
|
+
export declare function ContextMenu(handle: Handle<ContextMenu.Props>): () => import("remix/ui").RemixElement;
|
|
96
|
+
export declare namespace ContextMenu {
|
|
97
|
+
var Trigger: (handle: Handle<ContextMenu.TriggerProps>) => () => import("remix/ui").RemixElement;
|
|
98
|
+
var Item: (handle: Handle<Menu.ItemProps>) => () => import("remix/ui").RemixElement;
|
|
99
|
+
var Group: (handle: Handle<ContextMenu.GroupProps>) => () => import("remix/ui").RemixElement;
|
|
100
|
+
var Label: (handle: Handle<ContextMenu.LabelProps>) => () => import("remix/ui").RemixElement;
|
|
101
|
+
var Separator: (handle: Handle<Menu.SeparatorProps>) => () => import("remix/ui").RemixElement;
|
|
102
|
+
var SubTrigger: (handle: Handle<ContextMenu.ItemProps>) => () => import("remix/ui").RemixElement;
|
|
103
|
+
var SubContent: (handle: Handle<ContextMenu.SubContentProps>) => () => import("remix/ui").RemixElement;
|
|
104
|
+
var CheckboxItem: (handle: Handle<Menu.ItemProps>) => () => import("remix/ui").RemixElement;
|
|
105
|
+
var RadioItem: (handle: Handle<Menu.ItemProps>) => () => import("remix/ui").RemixElement;
|
|
106
|
+
var RadioGroup: (handle: Handle<ContextMenu.GroupProps>) => () => import("remix/ui").RemixElement;
|
|
107
|
+
var Shortcut: (handle: Handle<ContextMenu.ShortcutProps>) => () => import("remix/ui").RemixElement;
|
|
108
|
+
}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { jsx as _jsx } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { borderEdge, fg, outline } from "@sdxc/u/color";
|
|
3
|
+
import { mis, pb, pi, pie } from "@sdxc/u/size";
|
|
4
|
+
import { not } from "@sdxc/u/state";
|
|
5
|
+
import { text, weight } from "@sdxc/u/typography";
|
|
6
|
+
import { Menu } from "./menu.js";
|
|
7
|
+
import { Section } from "./section.js";
|
|
8
|
+
/**
|
|
9
|
+
* Side {@link ContextMenu.SubContent} renders against relative to its
|
|
10
|
+
* {@link ContextMenu.SubTrigger} row when a consumer leaves `placement`
|
|
11
|
+
* unset — the direction a nested row conventionally flies outward toward.
|
|
12
|
+
*/
|
|
13
|
+
const DEFAULT_SUB_PLACEMENT = "right-start";
|
|
14
|
+
/**
|
|
15
|
+
* Renders {@link Menu} unchanged; positioning against the pointer is handled
|
|
16
|
+
* entirely by the `contextMenu()` mixin a consuming island applies to
|
|
17
|
+
* {@link ContextMenu.Trigger}, while every nested row stays a real, tab-reachable `<a>` or `<button>`.
|
|
18
|
+
*
|
|
19
|
+
* @param handle Runtime handle carrying the host's {@link Menu} props.
|
|
20
|
+
* @returns The render function producing the surface's markup.
|
|
21
|
+
* @example
|
|
22
|
+
* <ContextMenu.Trigger mix={[contextMenu("row-menu")]}>
|
|
23
|
+
* <TableRow />
|
|
24
|
+
* </ContextMenu.Trigger>
|
|
25
|
+
* <ContextMenu id="row-menu" aria-label={t("table.rowActions")}>
|
|
26
|
+
* <ContextMenu.Item href={viewUrl}>{t("actions.view")}</ContextMenu.Item>
|
|
27
|
+
* <ContextMenu.Item href={editUrl}>{t("actions.edit")}</ContextMenu.Item>
|
|
28
|
+
* <ContextMenu.Separator />
|
|
29
|
+
* <ContextMenu.Item danger commandfor="confirm-delete" command="show-modal">{t("actions.delete")}</ContextMenu.Item>
|
|
30
|
+
* </ContextMenu>
|
|
31
|
+
*/
|
|
32
|
+
export function ContextMenu(handle) {
|
|
33
|
+
return () => _jsx(Menu, { ...handle.props });
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Renders {@link ContextMenu.TriggerProps.children} inside a plain `<div>`,
|
|
37
|
+
* the area a pointer gesture opens the paired {@link ContextMenu} against.
|
|
38
|
+
* Pair it with the `contextMenu()` mixin via `mix`; outline is suppressed since that mixin's own focus handling takes over once the surface opens.
|
|
39
|
+
*
|
|
40
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
41
|
+
* @returns The render function producing the trigger area's markup.
|
|
42
|
+
* @example
|
|
43
|
+
* <ContextMenu.Trigger mix={[contextMenu("row-menu")]}>
|
|
44
|
+
* <TableRow />
|
|
45
|
+
* </ContextMenu.Trigger>
|
|
46
|
+
*/
|
|
47
|
+
ContextMenu.Trigger = function ContextMenuTrigger(handle) {
|
|
48
|
+
return () => {
|
|
49
|
+
let { children, mix, ...rest } = handle.props;
|
|
50
|
+
return (_jsx("div", { ...rest, mix: [outline("none"), mix], children: children }));
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Renders a single row: {@link Menu.Item} unchanged, since a context menu's
|
|
55
|
+
* row shares every look and state — hover, pressed, focus-visible,
|
|
56
|
+
* `aria-selected`, `danger` — with a standard menu's row.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* <ContextMenu.Item href="/settings/profile">{t("nav.profile")}</ContextMenu.Item>
|
|
60
|
+
* @example
|
|
61
|
+
* <ContextMenu.Item danger>{t("actions.delete")}</ContextMenu.Item>
|
|
62
|
+
*/
|
|
63
|
+
ContextMenu.Item = Menu.Item;
|
|
64
|
+
/**
|
|
65
|
+
* Renders {@link ContextMenu.GroupProps.children} as one labeled run of rows:
|
|
66
|
+
* {@link Section} restyled with a divider above every group but the first.
|
|
67
|
+
* Pair a {@link ContextMenu.Label} first child with `aria-labelledby` pointing at its `id` for assistive technology.
|
|
68
|
+
*
|
|
69
|
+
* @param handle Runtime handle carrying the host `<section>`'s props.
|
|
70
|
+
* @returns The render function producing the group's markup.
|
|
71
|
+
* @example
|
|
72
|
+
* <ContextMenu.Group aria-labelledby="row-menu-view-heading">
|
|
73
|
+
* <ContextMenu.Label id="row-menu-view-heading">{t("menu.view")}</ContextMenu.Label>
|
|
74
|
+
* <ContextMenu.Item href={viewUrl}>{t("actions.view")}</ContextMenu.Item>
|
|
75
|
+
* <ContextMenu.Item href={editUrl}>{t("actions.edit")}</ContextMenu.Item>
|
|
76
|
+
* </ContextMenu.Group>
|
|
77
|
+
*/
|
|
78
|
+
ContextMenu.Group = function ContextMenuGroup(handle) {
|
|
79
|
+
return () => {
|
|
80
|
+
let { mix, ...rest } = handle.props;
|
|
81
|
+
return (_jsx(Section, { ...rest, mix: [not(":first-child", borderEdge("block-start", { color: "neutral", width: 1 })), mix] }));
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Renders {@link ContextMenu.LabelProps.children} as a
|
|
86
|
+
* {@link ContextMenu.Group}'s small, muted heading, sized and spaced to sit
|
|
87
|
+
* directly above the group's first row for a dense row of actions.
|
|
88
|
+
*
|
|
89
|
+
* @param handle Runtime handle carrying the host `<header>`'s props.
|
|
90
|
+
* @returns The render function producing the label's markup.
|
|
91
|
+
* @example
|
|
92
|
+
* <ContextMenu.Label id="row-menu-view-heading">{t("menu.view")}</ContextMenu.Label>
|
|
93
|
+
*/
|
|
94
|
+
ContextMenu.Label = function ContextMenuLabel(handle) {
|
|
95
|
+
return () => {
|
|
96
|
+
let { children, mix, ...rest } = handle.props;
|
|
97
|
+
return (_jsx("header", { ...rest, mix: [pi(2), pb(1), weight("semibold"), fg("neutral.muted"), text("xs"), mix], children: children }));
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Renders a hairline divider between two runs of {@link ContextMenu.Item}s:
|
|
102
|
+
* {@link Menu.Separator} unchanged.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* <ContextMenu.Item href="/settings/profile">{t("nav.profile")}</ContextMenu.Item>
|
|
106
|
+
* <ContextMenu.Separator />
|
|
107
|
+
* <ContextMenu.Item danger>{t("actions.signOut")}</ContextMenu.Item>
|
|
108
|
+
*/
|
|
109
|
+
ContextMenu.Separator = Menu.Separator;
|
|
110
|
+
/**
|
|
111
|
+
* Renders a row that opens a nested {@link ContextMenu.SubContent} surface:
|
|
112
|
+
* {@link Menu.Item} restyled with inline-end padding for a trailing chevron
|
|
113
|
+
* icon; point `commandfor` at the nested surface's `id` with `command="toggle-popover"`.
|
|
114
|
+
*
|
|
115
|
+
* @param handle Runtime handle carrying the host row's props.
|
|
116
|
+
* @returns The render function producing the row's markup.
|
|
117
|
+
* @example
|
|
118
|
+
* <ContextMenu.SubTrigger commandfor="row-menu-share" command="toggle-popover">
|
|
119
|
+
* {t("actions.share")}
|
|
120
|
+
* <ChevronRightIcon data-slot="icon" aria-hidden />
|
|
121
|
+
* </ContextMenu.SubTrigger>
|
|
122
|
+
* <ContextMenu.SubContent id="row-menu-share" aria-label={t("actions.share")}>
|
|
123
|
+
* <ContextMenu.Item>{t("share.email")}</ContextMenu.Item>
|
|
124
|
+
* <ContextMenu.Item>{t("share.link")}</ContextMenu.Item>
|
|
125
|
+
* </ContextMenu.SubContent>
|
|
126
|
+
*/
|
|
127
|
+
ContextMenu.SubTrigger = function ContextMenuSubTrigger(handle) {
|
|
128
|
+
return () => {
|
|
129
|
+
let { mix, ...rest } = handle.props;
|
|
130
|
+
return _jsx(Menu.Item, { ...rest, mix: [pie(8), mix] });
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Renders a nested surface opened by a {@link ContextMenu.SubTrigger} row:
|
|
135
|
+
* {@link ContextMenu} itself, defaulting `placement` to
|
|
136
|
+
* {@link DEFAULT_SUB_PLACEMENT} since a nested row conventionally opens beside itself.
|
|
137
|
+
*
|
|
138
|
+
* @param handle Runtime handle carrying the host's {@link Menu} props.
|
|
139
|
+
* @returns The render function producing the nested surface's markup.
|
|
140
|
+
* @example
|
|
141
|
+
* <ContextMenu.SubContent id="row-menu-share" aria-label={t("actions.share")}>
|
|
142
|
+
* <ContextMenu.Item>{t("share.email")}</ContextMenu.Item>
|
|
143
|
+
* <ContextMenu.Item>{t("share.link")}</ContextMenu.Item>
|
|
144
|
+
* </ContextMenu.SubContent>
|
|
145
|
+
*/
|
|
146
|
+
ContextMenu.SubContent = function ContextMenuSubContent(handle) {
|
|
147
|
+
return () => {
|
|
148
|
+
let { placement, ...rest } = handle.props;
|
|
149
|
+
return _jsx(ContextMenu, { ...rest, placement: placement ?? DEFAULT_SUB_PLACEMENT });
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* Renders a row that toggles a checked state: {@link ContextMenu.Item}
|
|
154
|
+
* unchanged — set `aria-selected="true"` directly to mark it checked, the
|
|
155
|
+
* same contract {@link Menu.Item} documents.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* <ContextMenu.CheckboxItem aria-selected={showHidden ? "true" : undefined}>{t("view.showHidden")}</ContextMenu.CheckboxItem>
|
|
159
|
+
*/
|
|
160
|
+
ContextMenu.CheckboxItem = ContextMenu.Item;
|
|
161
|
+
/**
|
|
162
|
+
* Renders a row belonging to a mutually exclusive set: {@link
|
|
163
|
+
* ContextMenu.Item} unchanged — set `aria-selected="true"` directly on
|
|
164
|
+
* whichever row is the current pick.
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* <ContextMenu.RadioItem aria-selected={sort === "name" ? "true" : undefined}>{t("sort.name")}</ContextMenu.RadioItem>
|
|
168
|
+
*/
|
|
169
|
+
ContextMenu.RadioItem = ContextMenu.Item;
|
|
170
|
+
/**
|
|
171
|
+
* Renders a mutually exclusive set of {@link ContextMenu.RadioItem} rows:
|
|
172
|
+
* {@link ContextMenu.Group} unchanged.
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* <ContextMenu.RadioGroup aria-labelledby="row-menu-sort-heading">
|
|
176
|
+
* <ContextMenu.Label id="row-menu-sort-heading">{t("menu.sortBy")}</ContextMenu.Label>
|
|
177
|
+
* <ContextMenu.RadioItem aria-selected="true">{t("sort.name")}</ContextMenu.RadioItem>
|
|
178
|
+
* <ContextMenu.RadioItem>{t("sort.date")}</ContextMenu.RadioItem>
|
|
179
|
+
* </ContextMenu.RadioGroup>
|
|
180
|
+
*/
|
|
181
|
+
ContextMenu.RadioGroup = ContextMenu.Group;
|
|
182
|
+
/**
|
|
183
|
+
* Renders {@link ContextMenu.ShortcutProps.children} as a row's trailing
|
|
184
|
+
* keyboard-shortcut hint: pushed to the row's inline end and muted, reading
|
|
185
|
+
* as supplementary detail alongside the row's primary label.
|
|
186
|
+
*
|
|
187
|
+
* @param handle Runtime handle carrying the host `<span>`'s props.
|
|
188
|
+
* @returns The render function producing the shortcut hint's markup.
|
|
189
|
+
* @example
|
|
190
|
+
* <ContextMenu.Item>
|
|
191
|
+
* {t("actions.duplicate")}
|
|
192
|
+
* <ContextMenu.Shortcut>⌘D</ContextMenu.Shortcut>
|
|
193
|
+
* </ContextMenu.Item>
|
|
194
|
+
*/
|
|
195
|
+
ContextMenu.Shortcut = function ContextMenuShortcut(handle) {
|
|
196
|
+
return () => {
|
|
197
|
+
let { children, mix, ...rest } = handle.props;
|
|
198
|
+
return (_jsx("span", { ...rest, mix: [mis("auto"), fg("neutral.muted"), text("xs"), mix], children: children }));
|
|
199
|
+
};
|
|
200
|
+
};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A convenience wrapper composing a labeled, described, and validated date
|
|
3
|
+
* field in one call: a caption through {@link Label}, a native
|
|
4
|
+
* `<input type="date">` styled through {@link Input}, an optional supporting
|
|
5
|
+
* passage through {@link Description}, and an optional validation message
|
|
6
|
+
* through {@link FieldError}. Every id and `aria-describedby` relationship
|
|
7
|
+
* between the parts is computed from this instance's own stable identifier,
|
|
8
|
+
* leaving no id bookkeeping to the consumer.
|
|
9
|
+
*
|
|
10
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
11
|
+
* @copyright Sergio Xalambrí 2026
|
|
12
|
+
*/
|
|
13
|
+
import type { Handle, Props as TagProps, RemixNode } from "remix/ui";
|
|
14
|
+
import type { FieldPartsProps } from "../utils/field-parts.js";
|
|
15
|
+
/**
|
|
16
|
+
* Prop types for {@link DateField}.
|
|
17
|
+
*/
|
|
18
|
+
export declare namespace DateField {
|
|
19
|
+
/**
|
|
20
|
+
* Semantic color role for the control's keyboard focus ring, each mapped
|
|
21
|
+
* to its matching `--ui-*` variables.
|
|
22
|
+
*/
|
|
23
|
+
type Color = "brand" | "neutral" | "success" | "warning" | "danger";
|
|
24
|
+
/**
|
|
25
|
+
* Per-part styling for the elements this convenience wrapper composes in
|
|
26
|
+
* one call, layered after each part's own built-in styling.
|
|
27
|
+
*/
|
|
28
|
+
type PartsProps = FieldPartsProps;
|
|
29
|
+
/**
|
|
30
|
+
* Props accepted by {@link DateField}. `mix` styles the root element
|
|
31
|
+
* grouping the field's parts; style the composed label, control,
|
|
32
|
+
* description, and error individually through `parts` instead.
|
|
33
|
+
*/
|
|
34
|
+
interface Props extends Omit<TagProps<"div">, "children"> {
|
|
35
|
+
/** Semantic color role for the control's focus ring. Defaults to `"neutral"` when omitted. */
|
|
36
|
+
color?: Color;
|
|
37
|
+
/**
|
|
38
|
+
* The field's caption, rendered through {@link Label} and associated
|
|
39
|
+
* with the control through a native `for`/`id` relationship computed
|
|
40
|
+
* from this instance's own identifier.
|
|
41
|
+
*/
|
|
42
|
+
label: RemixNode;
|
|
43
|
+
/**
|
|
44
|
+
* Supporting copy rendered through {@link Description} beneath the
|
|
45
|
+
* control and referenced by the control's `aria-describedby`. Omit to
|
|
46
|
+
* render no description.
|
|
47
|
+
*/
|
|
48
|
+
description?: RemixNode;
|
|
49
|
+
/**
|
|
50
|
+
* Validation message rendered through {@link FieldError} beneath the
|
|
51
|
+
* control; its presence alone marks `aria-invalid` unless set
|
|
52
|
+
* explicitly. Inside a {@link Form} carrying `issues`, an explicit value still wins over the field's own by-`name` lookup.
|
|
53
|
+
*/
|
|
54
|
+
errorMessage?: RemixNode;
|
|
55
|
+
/**
|
|
56
|
+
* Native `autofocus`. Defaults to `true` for the first invalid field of an
|
|
57
|
+
* enclosing {@link Form}'s `issues`, landing keyboard focus on the problem
|
|
58
|
+
* after a server round-trip; pass it explicitly to override for this field.
|
|
59
|
+
*/
|
|
60
|
+
autoFocus?: boolean;
|
|
61
|
+
/** Native `name` submitted with an enclosing form. */
|
|
62
|
+
name?: string;
|
|
63
|
+
/** Current value, in `YYYY-MM-DD` form, for a control a consumer tracks itself. */
|
|
64
|
+
value?: string;
|
|
65
|
+
/** Initial value, in `YYYY-MM-DD` form, for a control left to the platform's own uncontrolled state. */
|
|
66
|
+
defaultValue?: string;
|
|
67
|
+
/** Earliest accepted date, in `YYYY-MM-DD` form. */
|
|
68
|
+
min?: string;
|
|
69
|
+
/** Latest accepted date, in `YYYY-MM-DD` form. */
|
|
70
|
+
max?: string;
|
|
71
|
+
/** Granularity, in days, the control's value must fall on. */
|
|
72
|
+
step?: number;
|
|
73
|
+
/** Marks the control required for its enclosing form. */
|
|
74
|
+
required?: boolean;
|
|
75
|
+
/** Marks the control inert and excluded from the tab order. */
|
|
76
|
+
disabled?: boolean;
|
|
77
|
+
/** Marks the control's value fixed, while keeping it focusable and included in form submission. */
|
|
78
|
+
readOnly?: boolean;
|
|
79
|
+
/** Native autofill hint, e.g. `"bday"`. */
|
|
80
|
+
autoComplete?: string;
|
|
81
|
+
/** Per-part styling for this wrapper's internally composed elements. */
|
|
82
|
+
parts?: PartsProps;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Renders a complete date field in one call, stacking {@link Label},
|
|
87
|
+
* {@link Input}, and, when supplied, {@link Description} and {@link FieldError}.
|
|
88
|
+
* An invalid state — from `errorMessage` or an explicit `aria-invalid` override — recolors the border and ring to the semantic danger tone regardless of `color`.
|
|
89
|
+
*
|
|
90
|
+
* @param handle Runtime handle carrying the root element's props and this instance's stable identifier.
|
|
91
|
+
* @returns The render function producing the field's markup.
|
|
92
|
+
* @example
|
|
93
|
+
* <DateField label={t("form.birthday.label")} name="birthday" autoComplete="bday" />
|
|
94
|
+
* @example
|
|
95
|
+
* <DateField
|
|
96
|
+
* label={t("form.startDate.label")}
|
|
97
|
+
* name="startDate"
|
|
98
|
+
* min="2026-01-01"
|
|
99
|
+
* max="2026-12-31"
|
|
100
|
+
* description={t("form.startDate.hint")}
|
|
101
|
+
* />
|
|
102
|
+
* @example
|
|
103
|
+
* <DateField
|
|
104
|
+
* label={t("form.dueDate.label")}
|
|
105
|
+
* name="dueDate"
|
|
106
|
+
* defaultValue="2026-07-20"
|
|
107
|
+
* errorMessage={t("form.dueDate.pastDate")}
|
|
108
|
+
* />
|
|
109
|
+
*/
|
|
110
|
+
export declare function DateField(handle: Handle<DateField.Props>): () => import("remix/ui").RemixElement;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { fieldStackLayout } from "../styles/field-stack-layout.js";
|
|
3
|
+
import { resolveFieldWiring } from "../utils/resolve-field-wiring.js";
|
|
4
|
+
import { Description } from "./description.js";
|
|
5
|
+
import { FieldError } from "./field-error.js";
|
|
6
|
+
import { resolveFieldIssue } from "./form.js";
|
|
7
|
+
import { Input } from "./input.js";
|
|
8
|
+
import { Label } from "./label.js";
|
|
9
|
+
/**
|
|
10
|
+
* Renders a complete date field in one call, stacking {@link Label},
|
|
11
|
+
* {@link Input}, and, when supplied, {@link Description} and {@link FieldError}.
|
|
12
|
+
* An invalid state — from `errorMessage` or an explicit `aria-invalid` override — recolors the border and ring to the semantic danger tone regardless of `color`.
|
|
13
|
+
*
|
|
14
|
+
* @param handle Runtime handle carrying the root element's props and this instance's stable identifier.
|
|
15
|
+
* @returns The render function producing the field's markup.
|
|
16
|
+
* @example
|
|
17
|
+
* <DateField label={t("form.birthday.label")} name="birthday" autoComplete="bday" />
|
|
18
|
+
* @example
|
|
19
|
+
* <DateField
|
|
20
|
+
* label={t("form.startDate.label")}
|
|
21
|
+
* name="startDate"
|
|
22
|
+
* min="2026-01-01"
|
|
23
|
+
* max="2026-12-31"
|
|
24
|
+
* description={t("form.startDate.hint")}
|
|
25
|
+
* />
|
|
26
|
+
* @example
|
|
27
|
+
* <DateField
|
|
28
|
+
* label={t("form.dueDate.label")}
|
|
29
|
+
* name="dueDate"
|
|
30
|
+
* defaultValue="2026-07-20"
|
|
31
|
+
* errorMessage={t("form.dueDate.pastDate")}
|
|
32
|
+
* />
|
|
33
|
+
*/
|
|
34
|
+
export function DateField(handle) {
|
|
35
|
+
return () => {
|
|
36
|
+
let { color, label, description, errorMessage: errorMessageProp, autoFocus, name, value, defaultValue, min, max, step, required, disabled, readOnly, autoComplete, "aria-invalid": ariaInvalidProp, parts, mix, ...rest } = handle.props;
|
|
37
|
+
let { errorMessage, isFirstInvalid } = resolveFieldIssue(handle, name, errorMessageProp);
|
|
38
|
+
let resolvedAutoFocus = autoFocus ?? (isFirstInvalid || undefined);
|
|
39
|
+
let { resolvedColor, resolvedInvalid, descriptionId, errorId, describedBy } = resolveFieldWiring(handle.id, {
|
|
40
|
+
color,
|
|
41
|
+
errorMessage,
|
|
42
|
+
description,
|
|
43
|
+
ariaInvalid: ariaInvalidProp,
|
|
44
|
+
});
|
|
45
|
+
return (_jsxs("div", { ...rest, "data-slot": "date-field", mix: [fieldStackLayout(), mix], children: [_jsx(Label, { htmlFor: handle.id, mix: parts?.label, children: label }), _jsx(Input, { id: handle.id, type: "date", name: name, value: value, defaultValue: defaultValue, min: min, max: max, step: step, required: required, disabled: disabled, readOnly: readOnly, autoComplete: autoComplete,
|
|
46
|
+
// oxlint-disable-next-line jsx-a11y/no-autofocus -- Not a focus grab on page load: this only ever resolves true for the first field an enclosing Form reports as invalid, so a failed submit lands the user on the problem instead of leaving them to hunt for it.
|
|
47
|
+
autoFocus: resolvedAutoFocus, "aria-invalid": resolvedInvalid, "aria-describedby": describedBy, color: resolvedColor, mix: parts?.input }), description ? (_jsx(Description, { id: descriptionId, mix: parts?.description, children: description })) : null, errorMessage ? (_jsx(FieldError, { id: errorId, mix: parts?.error, children: errorMessage })) : null] }));
|
|
48
|
+
};
|
|
49
|
+
}
|