astralis-ui 0.1.0
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 +21 -0
- package/README.md +89 -0
- package/dist/components/buttons/button/button.js +83 -0
- package/dist/components/buttons/button/button.styles.js +69 -0
- package/dist/components/buttons/button-group/button-group.context.js +10 -0
- package/dist/components/buttons/button-group/button-group.js +42 -0
- package/dist/components/buttons/button-group/button-group.styles.js +39 -0
- package/dist/components/buttons/theme-toggle/theme-toggle.js +53 -0
- package/dist/components/data-display/avatar/avatar.context.js +10 -0
- package/dist/components/data-display/avatar/avatar.styles.js +40 -0
- package/dist/components/data-display/avatar/components/avatar-badge.js +24 -0
- package/dist/components/data-display/avatar/components/avatar-group.js +30 -0
- package/dist/components/data-display/avatar/components/avatar-root.js +57 -0
- package/dist/components/data-display/avatar/index.js +13 -0
- package/dist/components/data-display/badge/badge.js +12 -0
- package/dist/components/data-display/badge/badge.styles.js +25 -0
- package/dist/components/data-display/calendar/calendar.context.js +13 -0
- package/dist/components/data-display/calendar/components/calendar-cell.js +60 -0
- package/dist/components/data-display/calendar/components/calendar-grid.js +106 -0
- package/dist/components/data-display/calendar/components/calendar-header.js +23 -0
- package/dist/components/data-display/calendar/components/calendar-next-trigger.js +34 -0
- package/dist/components/data-display/calendar/components/calendar-prev-trigger.js +34 -0
- package/dist/components/data-display/calendar/components/calendar-root.js +154 -0
- package/dist/components/data-display/calendar/components/calendar-view-trigger.js +28 -0
- package/dist/components/data-display/calendar/components/calendar-weekdays.js +43 -0
- package/dist/components/data-display/calendar/index.js +30 -0
- package/dist/components/data-display/card/card.context.js +10 -0
- package/dist/components/data-display/card/card.styles.js +30 -0
- package/dist/components/data-display/card/components/card-body.js +19 -0
- package/dist/components/data-display/card/components/card-description.js +25 -0
- package/dist/components/data-display/card/components/card-footer.js +32 -0
- package/dist/components/data-display/card/components/card-header.js +37 -0
- package/dist/components/data-display/card/components/card-root.js +30 -0
- package/dist/components/data-display/card/components/card-title.js +25 -0
- package/dist/components/data-display/card/index.js +24 -0
- package/dist/components/data-display/data-list/components/data-list-item.js +20 -0
- package/dist/components/data-display/data-list/components/data-list-label.js +23 -0
- package/dist/components/data-display/data-list/components/data-list-root.js +11 -0
- package/dist/components/data-display/data-list/components/data-list-value.js +12 -0
- package/dist/components/data-display/data-list/data-list.context.js +12 -0
- package/dist/components/data-display/data-list/index.js +16 -0
- package/dist/components/data-display/image/components/image-group.js +79 -0
- package/dist/components/data-display/image/components/image-lightbox.js +188 -0
- package/dist/components/data-display/image/components/image-root.js +98 -0
- package/dist/components/data-display/image/components/image.constants.js +28 -0
- package/dist/components/data-display/image/index.js +11 -0
- package/dist/components/data-display/marquee/components/marquee-item.js +27 -0
- package/dist/components/data-display/marquee/components/marquee-root.js +130 -0
- package/dist/components/data-display/marquee/index.js +11 -0
- package/dist/components/data-display/qr-code/index.js +7 -0
- package/dist/components/data-display/qr-code/qr-code.js +203 -0
- package/dist/components/data-display/stat/components/stat-help-text.js +9 -0
- package/dist/components/data-display/stat/components/stat-indicator.js +23 -0
- package/dist/components/data-display/stat/components/stat-label.js +9 -0
- package/dist/components/data-display/stat/components/stat-root.js +10 -0
- package/dist/components/data-display/stat/components/stat-value.js +9 -0
- package/dist/components/data-display/stat/index.js +19 -0
- package/dist/components/data-display/stat/stat.context.js +6 -0
- package/dist/components/data-display/table/components/table-body.js +9 -0
- package/dist/components/data-display/table/components/table-caption.js +26 -0
- package/dist/components/data-display/table/components/table-cell.js +12 -0
- package/dist/components/data-display/table/components/table-footer.js +9 -0
- package/dist/components/data-display/table/components/table-head.js +20 -0
- package/dist/components/data-display/table/components/table-header.js +22 -0
- package/dist/components/data-display/table/components/table-root.js +20 -0
- package/dist/components/data-display/table/components/table-row.js +23 -0
- package/dist/components/data-display/table/index.js +28 -0
- package/dist/components/data-display/table/table.context.js +12 -0
- package/dist/components/data-display/table/table.styles.js +9 -0
- package/dist/components/data-display/tag/components/checkable-tag-group.js +37 -0
- package/dist/components/data-display/tag/components/checkable-tag.js +45 -0
- package/dist/components/data-display/tag/components/tag-root.js +52 -0
- package/dist/components/data-display/tag/index.js +14 -0
- package/dist/components/data-display/tag/tag.styles.js +27 -0
- package/dist/components/data-display/timeline/components/timeline-content.js +23 -0
- package/dist/components/data-display/timeline/components/timeline-indicator.js +21 -0
- package/dist/components/data-display/timeline/components/timeline-item.js +23 -0
- package/dist/components/data-display/timeline/components/timeline-root.js +12 -0
- package/dist/components/data-display/timeline/index.js +20 -0
- package/dist/components/data-display/timeline/timeline.context.js +18 -0
- package/dist/components/data-display/timeline/timeline.styles.js +33 -0
- package/dist/components/data-entry/checkbox/checkbox.context.js +12 -0
- package/dist/components/data-entry/checkbox/checkbox.styles.js +14 -0
- package/dist/components/data-entry/checkbox/components/checkbox-group.js +38 -0
- package/dist/components/data-entry/checkbox/components/checkbox.js +86 -0
- package/dist/components/data-entry/checkbox/index.js +11 -0
- package/dist/components/data-entry/combobox/combobox.js +178 -0
- package/dist/components/data-entry/field/components/field-error-text.js +47 -0
- package/dist/components/data-entry/field/components/field-help-text.js +30 -0
- package/dist/components/data-entry/field/components/field-label.js +35 -0
- package/dist/components/data-entry/field/components/field-root.js +45 -0
- package/dist/components/data-entry/field/field.context.js +10 -0
- package/dist/components/data-entry/field/index.js +17 -0
- package/dist/components/data-entry/input/components/input-group.js +15 -0
- package/dist/components/data-entry/input/components/input-password.js +42 -0
- package/dist/components/data-entry/input/components/input-search.js +48 -0
- package/dist/components/data-entry/input/components/input-textarea.js +53 -0
- package/dist/components/data-entry/input/components/input.js +44 -0
- package/dist/components/data-entry/input/index.js +18 -0
- package/dist/components/data-entry/input/input.context.js +13 -0
- package/dist/components/data-entry/input/input.styles.js +48 -0
- package/dist/components/data-entry/multi-select/components/multi-select.js +301 -0
- package/dist/components/data-entry/multi-select/multi-select.styles.js +47 -0
- package/dist/components/data-entry/number-input/number-input.js +97 -0
- package/dist/components/data-entry/pin-input/components/pin-input.js +127 -0
- package/dist/components/data-entry/pin-input/pin-input.styles.js +35 -0
- package/dist/components/data-entry/radio/components/radio-group.js +38 -0
- package/dist/components/data-entry/radio/components/radio.js +80 -0
- package/dist/components/data-entry/radio/index.js +11 -0
- package/dist/components/data-entry/radio/radio.context.js +10 -0
- package/dist/components/data-entry/radio/radio.styles.js +14 -0
- package/dist/components/data-entry/select/components/select.js +208 -0
- package/dist/components/data-entry/select/select.styles.js +35 -0
- package/dist/components/data-entry/shared/options.js +49 -0
- package/dist/components/data-entry/slider/components/slider.js +395 -0
- package/dist/components/data-entry/slider/slider.styles.js +15 -0
- package/dist/components/data-entry/switch/components/switch.js +86 -0
- package/dist/components/data-entry/switch/switch.styles.js +14 -0
- package/dist/components/disclosure/accordion/accordion.context.js +20 -0
- package/dist/components/disclosure/accordion/accordion.styles.js +84 -0
- package/dist/components/disclosure/accordion/components/accordion-content.js +26 -0
- package/dist/components/disclosure/accordion/components/accordion-item.js +30 -0
- package/dist/components/disclosure/accordion/components/accordion-root.js +80 -0
- package/dist/components/disclosure/accordion/components/accordion-trigger.js +49 -0
- package/dist/components/disclosure/accordion/index.js +16 -0
- package/dist/components/disclosure/carousel/carousel.context.js +18 -0
- package/dist/components/disclosure/carousel/carousel.styles.js +77 -0
- package/dist/components/disclosure/carousel/components/carousel-autoplay-trigger.js +25 -0
- package/dist/components/disclosure/carousel/components/carousel-control.js +12 -0
- package/dist/components/disclosure/carousel/components/carousel-indicator.js +22 -0
- package/dist/components/disclosure/carousel/components/carousel-indicators.js +32 -0
- package/dist/components/disclosure/carousel/components/carousel-next.js +24 -0
- package/dist/components/disclosure/carousel/components/carousel-prev.js +24 -0
- package/dist/components/disclosure/carousel/components/carousel-progress-text.js +21 -0
- package/dist/components/disclosure/carousel/components/carousel-root.js +129 -0
- package/dist/components/disclosure/carousel/components/carousel-slide.js +49 -0
- package/dist/components/disclosure/carousel/components/carousel-track.js +74 -0
- package/dist/components/disclosure/carousel/index.js +34 -0
- package/dist/components/disclosure/pagination/components/pagination-controls.js +79 -0
- package/dist/components/disclosure/pagination/components/pagination-ellipsis.js +11 -0
- package/dist/components/disclosure/pagination/components/pagination-item.js +24 -0
- package/dist/components/disclosure/pagination/components/pagination-jumper.js +35 -0
- package/dist/components/disclosure/pagination/components/pagination-list.js +9 -0
- package/dist/components/disclosure/pagination/components/pagination-page-text.js +18 -0
- package/dist/components/disclosure/pagination/components/pagination-pages.js +24 -0
- package/dist/components/disclosure/pagination/components/pagination-root.js +44 -0
- package/dist/components/disclosure/pagination/index.js +34 -0
- package/dist/components/disclosure/pagination/pagination.context.js +12 -0
- package/dist/components/disclosure/pagination/pagination.styles.js +84 -0
- package/dist/components/feedback/alert/alert.js +55 -0
- package/dist/components/feedback/alert/alert.styles.js +23 -0
- package/dist/components/feedback/progress/progress.js +112 -0
- package/dist/components/feedback/progress/progress.styles.js +25 -0
- package/dist/components/feedback/skeleton/skeleton.js +27 -0
- package/dist/components/feedback/skeleton/skeleton.styles.js +20 -0
- package/dist/components/feedback/spinner/spinner.js +32 -0
- package/dist/components/feedback/spinner/spinner.styles.js +17 -0
- package/dist/components/feedback/status.js +18 -0
- package/dist/components/feedback/toast/toast-store.js +35 -0
- package/dist/components/feedback/toast/toast.styles.js +20 -0
- package/dist/components/feedback/toast/toaster.js +65 -0
- package/dist/components/icon/icon.js +47 -0
- package/dist/components/icon/icon.styles.js +20 -0
- package/dist/components/icon/internal-icons.js +143 -0
- package/dist/components/layout/aspect-ratio/aspect-ratio.js +32 -0
- package/dist/components/layout/aspect-ratio/aspect-ratio.styles.js +18 -0
- package/dist/components/layout/box/box.js +30 -0
- package/dist/components/layout/box/box.styles.js +76 -0
- package/dist/components/layout/center/center.js +31 -0
- package/dist/components/layout/container/container.js +40 -0
- package/dist/components/layout/flex/flex-item.js +35 -0
- package/dist/components/layout/flex/flex.js +32 -0
- package/dist/components/layout/flex/flex.style.js +42 -0
- package/dist/components/layout/flex/index.js +11 -0
- package/dist/components/layout/float/float.js +32 -0
- package/dist/components/layout/float/float.styles.js +29 -0
- package/dist/components/layout/grid/grid-item.js +36 -0
- package/dist/components/layout/grid/grid.js +47 -0
- package/dist/components/layout/grid/grid.styles.js +43 -0
- package/dist/components/layout/grid/index.js +10 -0
- package/dist/components/layout/separator/separator.js +33 -0
- package/dist/components/layout/separator/separator.styles.js +29 -0
- package/dist/components/layout/stack/stack.js +24 -0
- package/dist/components/menu/components/menu-content.js +62 -0
- package/dist/components/menu/components/menu-parts.js +81 -0
- package/dist/components/menu/components/menu-root.js +36 -0
- package/dist/components/menu/index.js +15 -0
- package/dist/components/menu/menu.context.js +12 -0
- package/dist/components/menu/menu.styles.js +12 -0
- package/dist/components/navigation/breadcrumb/breadcrumb.js +50 -0
- package/dist/components/navigation/steps/components/steps-completed.js +12 -0
- package/dist/components/navigation/steps/components/steps-content.js +12 -0
- package/dist/components/navigation/steps/components/steps-description.js +13 -0
- package/dist/components/navigation/steps/components/steps-indicator.js +34 -0
- package/dist/components/navigation/steps/components/steps-item.js +112 -0
- package/dist/components/navigation/steps/components/steps-list.js +21 -0
- package/dist/components/navigation/steps/components/steps-next.js +25 -0
- package/dist/components/navigation/steps/components/steps-prev.js +25 -0
- package/dist/components/navigation/steps/components/steps-root.js +61 -0
- package/dist/components/navigation/steps/components/steps-title.js +13 -0
- package/dist/components/navigation/steps/index.js +34 -0
- package/dist/components/navigation/steps/steps.context.js +20 -0
- package/dist/components/navigation/steps/steps.styles.js +97 -0
- package/dist/components/navigation/tabs/components/tabs-content.js +26 -0
- package/dist/components/navigation/tabs/components/tabs-list.js +45 -0
- package/dist/components/navigation/tabs/components/tabs-root.js +54 -0
- package/dist/components/navigation/tabs/components/tabs-trigger.js +54 -0
- package/dist/components/navigation/tabs/index.js +16 -0
- package/dist/components/navigation/tabs/tabs.context.js +12 -0
- package/dist/components/navigation/tabs/tabs.styles.js +80 -0
- package/dist/components/overlay/drawer/components/drawer-content.js +48 -0
- package/dist/components/overlay/drawer/components/drawer-parts.js +48 -0
- package/dist/components/overlay/drawer/components/drawer-root.js +58 -0
- package/dist/components/overlay/drawer/drawer.context.js +12 -0
- package/dist/components/overlay/drawer/drawer.styles.js +32 -0
- package/dist/components/overlay/drawer/index.js +27 -0
- package/dist/components/overlay/modal/components/modal-content.js +48 -0
- package/dist/components/overlay/modal/components/modal-parts.js +48 -0
- package/dist/components/overlay/modal/components/modal-root.js +58 -0
- package/dist/components/overlay/modal/index.js +27 -0
- package/dist/components/overlay/modal/modal.context.js +12 -0
- package/dist/components/overlay/modal/modal.styles.js +31 -0
- package/dist/components/overlay/popover/components/popover-content.js +76 -0
- package/dist/components/overlay/popover/components/popover-parts.js +17 -0
- package/dist/components/overlay/popover/components/popover-root.js +71 -0
- package/dist/components/overlay/popover/index.js +19 -0
- package/dist/components/overlay/popover/popover.context.js +12 -0
- package/dist/components/overlay/popover/popover.styles.js +6 -0
- package/dist/components/overlay/portal.js +10 -0
- package/dist/components/overlay/tooltip/components/tooltip-content.js +52 -0
- package/dist/components/overlay/tooltip/components/tooltip-root.js +53 -0
- package/dist/components/overlay/tooltip/index.js +12 -0
- package/dist/components/overlay/tooltip/tooltip.context.js +12 -0
- package/dist/components/overlay/tooltip/tooltip.styles.js +6 -0
- package/dist/components/typography/blockquote/blockquote.js +39 -0
- package/dist/components/typography/blockquote/blockquote.styles.js +21 -0
- package/dist/components/typography/code/code.js +35 -0
- package/dist/components/typography/code/code.styles.js +26 -0
- package/dist/components/typography/code-block/code-block.js +57 -0
- package/dist/components/typography/code-block/code-block.styles.js +36 -0
- package/dist/components/typography/heading/heading.js +21 -0
- package/dist/components/typography/highlight/highlight.js +30 -0
- package/dist/components/typography/highlight/highlight.styles.js +18 -0
- package/dist/components/typography/kbd/kbd.js +26 -0
- package/dist/components/typography/link/link.js +48 -0
- package/dist/components/typography/list/index.js +10 -0
- package/dist/components/typography/list/list-item.js +37 -0
- package/dist/components/typography/list/list.js +35 -0
- package/dist/components/typography/list/list.styles.js +35 -0
- package/dist/components/typography/text/text.js +80 -0
- package/dist/components/typography/text/text.styles.js +110 -0
- package/dist/const/color-mappings.js +541 -0
- package/dist/const/color-schemes.js +5 -0
- package/dist/const/common-mappings.js +127 -0
- package/dist/const/layout-mappings.js +446 -0
- package/dist/const/positioning-mappings.js +164 -0
- package/dist/const/rounded-mappings.js +121 -0
- package/dist/const/sizing-mappings.js +1113 -0
- package/dist/const/spacing-mappings.js +508 -0
- package/dist/hooks/use-anchor-position.js +39 -0
- package/dist/hooks/use-controllable-state.js +18 -0
- package/dist/hooks/use-dismiss.js +23 -0
- package/dist/hooks/use-overlay-behavior.js +42 -0
- package/dist/hooks/use-prefers-reduced-motion.js +15 -0
- package/dist/hooks/use-presence.js +18 -0
- package/dist/hooks/use-roving-focus.js +51 -0
- package/dist/index.d.ts +3533 -0
- package/dist/index.js +359 -0
- package/dist/styles.css +2 -0
- package/dist/theme/provider.js +130 -0
- package/dist/utils/astralis-merge.js +31 -0
- package/dist/utils/overlay-stack.js +27 -0
- package/dist/utils/responsive.js +32 -0
- package/dist/utils/split-variant-props.js +13 -0
- package/package.json +107 -0
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs as c, jsx as l, Fragment as he } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef as xe, useState as v, useMemo as k, useRef as T, useImperativeHandle as ge, useCallback as we, useLayoutEffect as ye, useEffect as X } from "react";
|
|
4
|
+
import { createPortal as Ne } from "react-dom";
|
|
5
|
+
import { useFieldContext as ke } from "../../field/field.context.js";
|
|
6
|
+
import { msContainer as Ie, msTagSizes as Ce, msOptionClasses as De, msInputText as Se, msFocusRing as Le } from "../multi-select.styles.js";
|
|
7
|
+
import { astralisMerge as f } from "../../../../utils/astralis-merge.js";
|
|
8
|
+
import { flattenOptions as $, isGroup as J } from "../../shared/options.js";
|
|
9
|
+
import { accentClass as Q } from "../../../../const/color-schemes.js";
|
|
10
|
+
import { SpinnerIcon as Me, XIcon as Z, ChevronDownIcon as Oe, CheckIcon as Re } from "../../../icon/internal-icons.js";
|
|
11
|
+
function W(r) {
|
|
12
|
+
return r.searchLabel ?? String(r.label);
|
|
13
|
+
}
|
|
14
|
+
function Ee({
|
|
15
|
+
label: r,
|
|
16
|
+
onRemove: m,
|
|
17
|
+
disabled: d,
|
|
18
|
+
size: u
|
|
19
|
+
}) {
|
|
20
|
+
return /* @__PURE__ */ c(
|
|
21
|
+
"span",
|
|
22
|
+
{
|
|
23
|
+
className: f(
|
|
24
|
+
Ce[u],
|
|
25
|
+
"astralis:inline-flex astralis:items-center astralis:gap-1 astralis:rounded-sm astralis:font-medium astralis:bg-accent-subtle astralis:text-accent-label astralis:transition-colors"
|
|
26
|
+
),
|
|
27
|
+
children: [
|
|
28
|
+
/* @__PURE__ */ l("span", { className: "astralis:truncate astralis:max-w-32", children: r }),
|
|
29
|
+
!d && /* @__PURE__ */ l(
|
|
30
|
+
"button",
|
|
31
|
+
{
|
|
32
|
+
type: "button",
|
|
33
|
+
tabIndex: -1,
|
|
34
|
+
"aria-label": "Remove",
|
|
35
|
+
onMouseDown: (h) => {
|
|
36
|
+
h.preventDefault(), m();
|
|
37
|
+
},
|
|
38
|
+
className: "astralis:flex astralis:items-center astralis:shrink-0 astralis:transition-colors astralis:hover:text-accent-emphasized",
|
|
39
|
+
children: /* @__PURE__ */ l(Z, { className: "astralis:h-2.5 astralis:w-2.5" })
|
|
40
|
+
}
|
|
41
|
+
)
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
function Y({
|
|
47
|
+
option: r,
|
|
48
|
+
isActive: m,
|
|
49
|
+
isSelected: d,
|
|
50
|
+
onToggle: u
|
|
51
|
+
}) {
|
|
52
|
+
return /* @__PURE__ */ c(
|
|
53
|
+
"div",
|
|
54
|
+
{
|
|
55
|
+
role: "option",
|
|
56
|
+
"aria-selected": d,
|
|
57
|
+
"aria-disabled": r.disabled,
|
|
58
|
+
onMouseDown: (h) => {
|
|
59
|
+
h.preventDefault(), r.disabled || u(r.value);
|
|
60
|
+
},
|
|
61
|
+
className: f(
|
|
62
|
+
"astralis:flex astralis:items-center astralis:justify-between astralis:gap-2",
|
|
63
|
+
"astralis:px-3 astralis:py-2 astralis:rounded-lg astralis:text-sm astralis:cursor-pointer astralis:transition-colors",
|
|
64
|
+
De(m, !!r.disabled),
|
|
65
|
+
d && "astralis:font-medium"
|
|
66
|
+
),
|
|
67
|
+
children: [
|
|
68
|
+
/* @__PURE__ */ l("span", { className: "astralis:truncate", children: r.label }),
|
|
69
|
+
d && /* @__PURE__ */ l(Re, { className: "astralis:h-3.5 astralis:w-3.5 astralis:shrink-0 astralis:text-accent-solid" })
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
const Ae = xe(
|
|
75
|
+
({
|
|
76
|
+
options: r = [],
|
|
77
|
+
value: m,
|
|
78
|
+
defaultValue: d = [],
|
|
79
|
+
onChange: u,
|
|
80
|
+
placeholder: h = "Select options…",
|
|
81
|
+
size: M = "md",
|
|
82
|
+
variant: B = "outline",
|
|
83
|
+
colorScheme: V = "brand",
|
|
84
|
+
disabled: _,
|
|
85
|
+
invalid: ee,
|
|
86
|
+
readOnly: se,
|
|
87
|
+
clearable: ae = !1,
|
|
88
|
+
max: I,
|
|
89
|
+
emptyText: te = "No options",
|
|
90
|
+
loading: le = !1,
|
|
91
|
+
name: P,
|
|
92
|
+
className: re = "",
|
|
93
|
+
id: ie
|
|
94
|
+
}, ne) => {
|
|
95
|
+
const x = ke(), b = _ ?? x?.disabled, O = ee ?? x?.invalid, i = se ?? x?.readOnly, oe = ie ?? x?.id, [n, o] = v(!1), [C, j] = v(""), [g, w] = v(-1), [ce, z] = v(!1), D = m !== void 0, [de, R] = v(d), a = D ? m ?? [] : de, q = k(() => $(r), [r]), ue = k(
|
|
96
|
+
() => q.filter((e) => a.includes(e.value)),
|
|
97
|
+
[q, a]
|
|
98
|
+
), S = k(() => {
|
|
99
|
+
const e = C.toLowerCase().trim();
|
|
100
|
+
return e ? r.map((s) => {
|
|
101
|
+
if (J(s)) {
|
|
102
|
+
const t = s.options.filter((F) => W(F).toLowerCase().includes(e));
|
|
103
|
+
return t.length ? { ...s, options: t } : null;
|
|
104
|
+
}
|
|
105
|
+
return W(s).toLowerCase().includes(e) ? s : null;
|
|
106
|
+
}).filter((s) => s !== null) : r;
|
|
107
|
+
}, [r, C]), K = k(() => $(S), [S]), y = k(() => K.filter((e) => !e.disabled), [K]), L = I != null && a.length >= I, N = T(null), G = T(null), H = T(null);
|
|
108
|
+
ge(ne, () => N.current, []);
|
|
109
|
+
const [E, fe] = v({ top: 0, left: 0, width: 0 }), p = we(() => {
|
|
110
|
+
if (!N.current) return;
|
|
111
|
+
const e = N.current.getBoundingClientRect();
|
|
112
|
+
fe({ top: e.bottom + 4, left: e.left, width: e.width });
|
|
113
|
+
}, []);
|
|
114
|
+
ye(() => {
|
|
115
|
+
if (n)
|
|
116
|
+
return p(), window.addEventListener("scroll", p, !0), window.addEventListener("resize", p), () => {
|
|
117
|
+
window.removeEventListener("scroll", p, !0), window.removeEventListener("resize", p);
|
|
118
|
+
};
|
|
119
|
+
}, [n, p]), X(() => {
|
|
120
|
+
n ? (w(-1), requestAnimationFrame(() => H.current?.focus())) : (j(""), w(-1));
|
|
121
|
+
}, [n]), X(() => {
|
|
122
|
+
if (!n) return;
|
|
123
|
+
const e = (s) => {
|
|
124
|
+
const t = s.target;
|
|
125
|
+
!N.current?.contains(t) && !G.current?.contains(t) && o(!1);
|
|
126
|
+
};
|
|
127
|
+
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
128
|
+
}, [n]);
|
|
129
|
+
const A = (e) => {
|
|
130
|
+
if (i) return;
|
|
131
|
+
const s = a.includes(e) ? a.filter((t) => t !== e) : L ? a : [...a, e];
|
|
132
|
+
D || R(s), u?.(s);
|
|
133
|
+
}, U = (e) => {
|
|
134
|
+
if (i) return;
|
|
135
|
+
const s = a.filter((t) => t !== e);
|
|
136
|
+
D || R(s), u?.(s);
|
|
137
|
+
}, me = (e) => {
|
|
138
|
+
e.stopPropagation(), !i && (D || R([]), u?.([]));
|
|
139
|
+
}, be = () => {
|
|
140
|
+
!b && !i && o((e) => !e);
|
|
141
|
+
}, pe = (e) => {
|
|
142
|
+
if (i) {
|
|
143
|
+
e.key === "Tab" ? o(!1) : e.preventDefault();
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
switch (e.key) {
|
|
147
|
+
case "Backspace":
|
|
148
|
+
!C && a.length > 0 && U(a[a.length - 1]);
|
|
149
|
+
break;
|
|
150
|
+
case "Escape":
|
|
151
|
+
o(!1);
|
|
152
|
+
break;
|
|
153
|
+
case "ArrowDown":
|
|
154
|
+
e.preventDefault(), n ? w((s) => Math.min(s + 1, y.length - 1)) : o(!0);
|
|
155
|
+
break;
|
|
156
|
+
case "ArrowUp":
|
|
157
|
+
e.preventDefault(), w((s) => Math.max(s - 1, 0));
|
|
158
|
+
break;
|
|
159
|
+
case "Enter":
|
|
160
|
+
e.preventDefault(), n ? g >= 0 && y[g] && A(y[g].value) : o(!0);
|
|
161
|
+
break;
|
|
162
|
+
case "Tab":
|
|
163
|
+
o(!1);
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
}, ve = ae && a.length > 0 && !b && !i;
|
|
167
|
+
return /* @__PURE__ */ c("div", { className: f("astralis:relative astralis:w-full", Q(V), re), children: [
|
|
168
|
+
P != null && a.map((e) => /* @__PURE__ */ l("input", { type: "hidden", name: P, value: e, disabled: !!b }, String(e))),
|
|
169
|
+
/* @__PURE__ */ c(
|
|
170
|
+
"div",
|
|
171
|
+
{
|
|
172
|
+
ref: N,
|
|
173
|
+
id: oe,
|
|
174
|
+
role: "combobox",
|
|
175
|
+
"aria-haspopup": "listbox",
|
|
176
|
+
"aria-expanded": n,
|
|
177
|
+
"aria-invalid": O || void 0,
|
|
178
|
+
"aria-describedby": x?.describedBy,
|
|
179
|
+
"aria-readonly": i || void 0,
|
|
180
|
+
onClick: be,
|
|
181
|
+
className: f(
|
|
182
|
+
Ie({ size: M, variant: B, invalid: !!O }),
|
|
183
|
+
ce && !i && Le(B, !!O),
|
|
184
|
+
b && "astralis:cursor-not-allowed astralis:opacity-moderate astralis:pointer-events-none",
|
|
185
|
+
i && "astralis:cursor-default astralis:bg-surface-muted"
|
|
186
|
+
),
|
|
187
|
+
children: [
|
|
188
|
+
ue.map((e) => /* @__PURE__ */ l(
|
|
189
|
+
Ee,
|
|
190
|
+
{
|
|
191
|
+
label: e.label,
|
|
192
|
+
size: M,
|
|
193
|
+
disabled: !!b || !!i,
|
|
194
|
+
onRemove: () => U(e.value)
|
|
195
|
+
},
|
|
196
|
+
String(e.value)
|
|
197
|
+
)),
|
|
198
|
+
/* @__PURE__ */ l(
|
|
199
|
+
"input",
|
|
200
|
+
{
|
|
201
|
+
ref: H,
|
|
202
|
+
"aria-label": "Search options",
|
|
203
|
+
type: "text",
|
|
204
|
+
placeholder: a.length === 0 ? h : "",
|
|
205
|
+
value: C,
|
|
206
|
+
onChange: (e) => {
|
|
207
|
+
i || (j(e.target.value), w(-1), n || o(!0));
|
|
208
|
+
},
|
|
209
|
+
onKeyDown: pe,
|
|
210
|
+
onFocus: () => {
|
|
211
|
+
z(!0), i || o(!0);
|
|
212
|
+
},
|
|
213
|
+
onBlur: () => z(!1),
|
|
214
|
+
disabled: !!b,
|
|
215
|
+
readOnly: i,
|
|
216
|
+
"aria-readonly": i || void 0,
|
|
217
|
+
className: f(
|
|
218
|
+
"astralis:flex-1 astralis:min-w-16 astralis:bg-transparent astralis:outline-none astralis:text-label-base astralis:placeholder:text-label-subtle",
|
|
219
|
+
Se[M]
|
|
220
|
+
)
|
|
221
|
+
}
|
|
222
|
+
),
|
|
223
|
+
/* @__PURE__ */ l("span", { className: "astralis:flex astralis:items-center astralis:gap-1 astralis:shrink-0 astralis:ml-auto astralis:text-label-subtle", children: le ? /* @__PURE__ */ l(Me, {}) : /* @__PURE__ */ c(he, { children: [
|
|
224
|
+
ve && /* @__PURE__ */ l(
|
|
225
|
+
"button",
|
|
226
|
+
{
|
|
227
|
+
type: "button",
|
|
228
|
+
tabIndex: -1,
|
|
229
|
+
"aria-label": "Clear all",
|
|
230
|
+
onMouseDown: me,
|
|
231
|
+
className: "astralis:flex astralis:items-center astralis:rounded-sm astralis:p-0.5 astralis:transition-colors astralis:hover:text-label-base",
|
|
232
|
+
children: /* @__PURE__ */ l(Z, { className: "astralis:h-3.5 astralis:w-3.5" })
|
|
233
|
+
}
|
|
234
|
+
),
|
|
235
|
+
/* @__PURE__ */ l(
|
|
236
|
+
Oe,
|
|
237
|
+
{
|
|
238
|
+
className: f(
|
|
239
|
+
"astralis:h-4 astralis:w-4 astralis:shrink-0 astralis:transition-transform",
|
|
240
|
+
n && "astralis:rotate-180"
|
|
241
|
+
)
|
|
242
|
+
}
|
|
243
|
+
)
|
|
244
|
+
] }) })
|
|
245
|
+
]
|
|
246
|
+
}
|
|
247
|
+
),
|
|
248
|
+
n && Ne(
|
|
249
|
+
/* @__PURE__ */ c(
|
|
250
|
+
"div",
|
|
251
|
+
{
|
|
252
|
+
ref: G,
|
|
253
|
+
role: "listbox",
|
|
254
|
+
"aria-multiselectable": "true",
|
|
255
|
+
style: { position: "fixed", top: E.top, left: E.left, width: E.width, zIndex: 9999 },
|
|
256
|
+
className: f(
|
|
257
|
+
"astralis:bg-surface-base astralis:border-normal astralis:border-stroke-subtle astralis:rounded-xl astralis:shadow-lg astralis:overflow-hidden",
|
|
258
|
+
Q(V)
|
|
259
|
+
),
|
|
260
|
+
children: [
|
|
261
|
+
L && /* @__PURE__ */ c("div", { className: "astralis:px-3 astralis:py-1.5 astralis:text-xs astralis:text-label-subtle astralis:border-b astralis:border-stroke-subtle astralis:bg-surface-muted", children: [
|
|
262
|
+
"Maximum ",
|
|
263
|
+
I,
|
|
264
|
+
" item",
|
|
265
|
+
I !== 1 ? "s" : "",
|
|
266
|
+
" selected"
|
|
267
|
+
] }),
|
|
268
|
+
/* @__PURE__ */ l("div", { className: "astralis:max-h-60 astralis:overflow-y-auto astralis:p-1.5", children: S.length === 0 ? /* @__PURE__ */ l("div", { className: "astralis:px-3 astralis:py-4 astralis:text-sm astralis:text-label-subtle astralis:text-center", children: te }) : S.map((e, s) => J(e) ? /* @__PURE__ */ c("div", { children: [
|
|
269
|
+
/* @__PURE__ */ l("div", { className: "astralis:px-2 astralis:pt-2 astralis:pb-1 astralis:text-xs astralis:font-semibold astralis:uppercase astralis:tracking-wider astralis:text-label-subtle", children: e.group }),
|
|
270
|
+
e.options.map((t) => /* @__PURE__ */ l(
|
|
271
|
+
Y,
|
|
272
|
+
{
|
|
273
|
+
option: L && !a.includes(t.value) ? { ...t, disabled: !0 } : t,
|
|
274
|
+
isActive: y.findIndex((F) => F.value === t.value) === g,
|
|
275
|
+
isSelected: a.includes(t.value),
|
|
276
|
+
onToggle: A
|
|
277
|
+
},
|
|
278
|
+
String(t.value)
|
|
279
|
+
))
|
|
280
|
+
] }, `g-${s}`) : /* @__PURE__ */ l(
|
|
281
|
+
Y,
|
|
282
|
+
{
|
|
283
|
+
option: L && !a.includes(e.value) ? { ...e, disabled: !0 } : e,
|
|
284
|
+
isActive: y.findIndex((t) => t.value === e.value) === g,
|
|
285
|
+
isSelected: a.includes(e.value),
|
|
286
|
+
onToggle: A
|
|
287
|
+
},
|
|
288
|
+
String(e.value)
|
|
289
|
+
)) })
|
|
290
|
+
]
|
|
291
|
+
}
|
|
292
|
+
),
|
|
293
|
+
document.body
|
|
294
|
+
)
|
|
295
|
+
] });
|
|
296
|
+
}
|
|
297
|
+
);
|
|
298
|
+
Ae.displayName = "MultiSelect";
|
|
299
|
+
export {
|
|
300
|
+
Ae as MultiSelectBase
|
|
301
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cva as t } from "class-variance-authority";
|
|
3
|
+
const l = t(
|
|
4
|
+
"astralis:w-full astralis:flex astralis:items-center astralis:flex-wrap astralis:gap-1.5 astralis:cursor-text astralis:transition-colors",
|
|
5
|
+
{
|
|
6
|
+
variants: {
|
|
7
|
+
size: {
|
|
8
|
+
sm: "astralis:min-h-8 astralis:px-2 astralis:py-1",
|
|
9
|
+
md: "astralis:min-h-10 astralis:px-3 astralis:py-1.5",
|
|
10
|
+
lg: "astralis:min-h-12 astralis:px-3 astralis:py-2"
|
|
11
|
+
},
|
|
12
|
+
variant: {
|
|
13
|
+
outline: "astralis:border-normal astralis:border-stroke-base astralis:bg-surface-base astralis:rounded-lg astralis:hover:border-stroke-emphasized",
|
|
14
|
+
filled: "astralis:border-normal astralis:border-transparent astralis:bg-surface-muted astralis:rounded-lg astralis:hover:bg-surface-subtle"
|
|
15
|
+
},
|
|
16
|
+
invalid: { true: "", false: "" }
|
|
17
|
+
},
|
|
18
|
+
compoundVariants: [
|
|
19
|
+
{ invalid: !0, variant: "outline", className: "astralis:border-red-solid astralis:hover:border-red-solid" },
|
|
20
|
+
{ invalid: !0, variant: "filled", className: "astralis:border-red-solid astralis:hover:border-red-solid" }
|
|
21
|
+
],
|
|
22
|
+
defaultVariants: { size: "md", variant: "outline", invalid: !1 }
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
function e(s, a) {
|
|
26
|
+
const r = s === "filled" ? "astralis:bg-surface-base " : "";
|
|
27
|
+
return a ? r + "astralis:border-red-solid astralis:ring-2 astralis:ring-red-muted" : r + "astralis:border-accent-stroke astralis:ring-2 astralis:ring-accent-ring";
|
|
28
|
+
}
|
|
29
|
+
const n = {
|
|
30
|
+
sm: "astralis:text-xs astralis:h-5 astralis:px-1.5",
|
|
31
|
+
md: "astralis:text-xs astralis:h-6 astralis:px-2",
|
|
32
|
+
lg: "astralis:text-sm astralis:h-7 astralis:px-2.5"
|
|
33
|
+
}, o = {
|
|
34
|
+
sm: "astralis:text-xs",
|
|
35
|
+
md: "astralis:text-sm",
|
|
36
|
+
lg: "astralis:text-base"
|
|
37
|
+
};
|
|
38
|
+
function d(s, a) {
|
|
39
|
+
return a ? "astralis:cursor-not-allowed astralis:opacity-moderate astralis:text-label-subtle" : s ? "astralis:bg-accent-subtle astralis:text-accent-label" : "astralis:text-label-base astralis:hover:bg-surface-muted";
|
|
40
|
+
}
|
|
41
|
+
export {
|
|
42
|
+
l as msContainer,
|
|
43
|
+
e as msFocusRing,
|
|
44
|
+
o as msInputText,
|
|
45
|
+
d as msOptionClasses,
|
|
46
|
+
n as msTagSizes
|
|
47
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs as w, jsx as o } from "react/jsx-runtime";
|
|
3
|
+
import { useState as x, useRef as G, useEffect as J } from "react";
|
|
4
|
+
import { inputVariants as L } from "../input/input.styles.js";
|
|
5
|
+
import { useFieldContext as Q } from "../field/field.context.js";
|
|
6
|
+
import { astralisMerge as g } from "../../../utils/astralis-merge.js";
|
|
7
|
+
import { ChevronUpIcon as W, ChevronDownIcon as X } from "../../icon/internal-icons.js";
|
|
8
|
+
const k = "astralis:flex astralis:flex-1 astralis:items-center astralis:justify-center astralis:cursor-pointer astralis:text-label-subtle astralis:transition-colors astralis:hover:text-label-base astralis:hover:bg-surface-subtle astralis:disabled:opacity-moderate astralis:disabled:pointer-events-none astralis:outline-none astralis:focus-visible:outline-2 astralis:focus-visible:outline-offset-[-2px] astralis:focus-visible:outline-accent-ring";
|
|
9
|
+
function Y({
|
|
10
|
+
value: v,
|
|
11
|
+
defaultValue: C = null,
|
|
12
|
+
onChange: D,
|
|
13
|
+
min: l,
|
|
14
|
+
max: a,
|
|
15
|
+
step: f = 1,
|
|
16
|
+
precision: p,
|
|
17
|
+
size: I = "md",
|
|
18
|
+
variant: M = "outline",
|
|
19
|
+
invalid: O,
|
|
20
|
+
disabled: j,
|
|
21
|
+
readOnly: E,
|
|
22
|
+
hideSteppers: y = !1,
|
|
23
|
+
className: R = "",
|
|
24
|
+
id: S,
|
|
25
|
+
onKeyDown: q,
|
|
26
|
+
onBlur: A,
|
|
27
|
+
ref: B,
|
|
28
|
+
...F
|
|
29
|
+
}) {
|
|
30
|
+
const r = Q(), h = O ?? r?.invalid, u = j ?? r?.disabled, d = E ?? r?.readOnly, K = S ?? r?.id, N = v !== void 0, [U, V] = x(C), s = N ? v ?? null : U, b = G(s);
|
|
31
|
+
b.current = s;
|
|
32
|
+
const [i, m] = x(s == null ? "" : String(s));
|
|
33
|
+
J(() => {
|
|
34
|
+
m(s == null ? "" : String(s));
|
|
35
|
+
}, [s]);
|
|
36
|
+
const H = (e) => {
|
|
37
|
+
let t = e;
|
|
38
|
+
return l != null && (t = Math.max(l, t)), a != null && (t = Math.min(a, t)), p != null && (t = Number(t.toFixed(p))), t;
|
|
39
|
+
}, n = (e) => {
|
|
40
|
+
const t = e == null || Number.isNaN(e) ? null : H(e);
|
|
41
|
+
N || V(t), b.current = t, m(t == null ? "" : String(t)), D?.(t);
|
|
42
|
+
}, c = (e) => {
|
|
43
|
+
if (u || d) return;
|
|
44
|
+
const z = b.current ?? (e === 1 ? (l ?? 0) - f : (a ?? 0) + f);
|
|
45
|
+
n(z + e * f);
|
|
46
|
+
}, T = (e) => {
|
|
47
|
+
q?.(e), e.key === "ArrowUp" ? (e.preventDefault(), c(1)) : e.key === "ArrowDown" ? (e.preventDefault(), c(-1)) : e.key === "Home" && l != null ? (e.preventDefault(), n(l)) : e.key === "End" && a != null ? (e.preventDefault(), n(a)) : e.key === "Enter" && n(i.trim() === "" ? null : Number(i));
|
|
48
|
+
};
|
|
49
|
+
return /* @__PURE__ */ w("div", { className: "astralis:relative astralis:w-full", children: [
|
|
50
|
+
/* @__PURE__ */ o(
|
|
51
|
+
"input",
|
|
52
|
+
{
|
|
53
|
+
ref: B,
|
|
54
|
+
id: K,
|
|
55
|
+
type: "text",
|
|
56
|
+
inputMode: "decimal",
|
|
57
|
+
autoComplete: "off",
|
|
58
|
+
role: "spinbutton",
|
|
59
|
+
"aria-valuemin": l,
|
|
60
|
+
"aria-valuemax": a,
|
|
61
|
+
"aria-valuenow": s ?? void 0,
|
|
62
|
+
"aria-invalid": h || void 0,
|
|
63
|
+
"aria-describedby": r?.describedBy,
|
|
64
|
+
disabled: u,
|
|
65
|
+
readOnly: d,
|
|
66
|
+
required: r?.required,
|
|
67
|
+
value: i,
|
|
68
|
+
onChange: (e) => m(e.target.value),
|
|
69
|
+
onKeyDown: T,
|
|
70
|
+
onBlur: (e) => {
|
|
71
|
+
A?.(e), n(i.trim() === "" ? null : Number(i));
|
|
72
|
+
},
|
|
73
|
+
className: g(
|
|
74
|
+
L({ size: I, variant: M, invalid: !!h }),
|
|
75
|
+
!y && "astralis:pr-8",
|
|
76
|
+
R
|
|
77
|
+
),
|
|
78
|
+
...F
|
|
79
|
+
}
|
|
80
|
+
),
|
|
81
|
+
!y && /* @__PURE__ */ w(
|
|
82
|
+
"div",
|
|
83
|
+
{
|
|
84
|
+
"aria-hidden": "true",
|
|
85
|
+
className: "astralis:absolute astralis:inset-y-1 astralis:right-1 astralis:flex astralis:w-6 astralis:flex-col astralis:overflow-hidden astralis:rounded-md astralis:border-normal astralis:border-stroke-subtle",
|
|
86
|
+
children: [
|
|
87
|
+
/* @__PURE__ */ o("button", { type: "button", tabIndex: -1, disabled: u || d, onClick: () => c(1), className: k, children: /* @__PURE__ */ o(W, { className: "astralis:h-3 astralis:w-3" }) }),
|
|
88
|
+
/* @__PURE__ */ o("button", { type: "button", tabIndex: -1, disabled: u || d, onClick: () => c(-1), className: g(k, "astralis:border-t astralis:border-stroke-subtle"), children: /* @__PURE__ */ o(X, { className: "astralis:h-3 astralis:w-3" }) })
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
)
|
|
92
|
+
] });
|
|
93
|
+
}
|
|
94
|
+
Y.displayName = "NumberInput";
|
|
95
|
+
export {
|
|
96
|
+
Y as NumberInput
|
|
97
|
+
};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as y } from "react/jsx-runtime";
|
|
3
|
+
import { useState as Z, useRef as _, useEffect as E } from "react";
|
|
4
|
+
import { useFieldContext as S } from "../../field/field.context.js";
|
|
5
|
+
import { pinCell as q } from "../pin-input.styles.js";
|
|
6
|
+
import { astralisMerge as C } from "../../../../utils/astralis-merge.js";
|
|
7
|
+
function p(a, n) {
|
|
8
|
+
return Array.from({ length: n }, (v, m) => a[m] ?? "");
|
|
9
|
+
}
|
|
10
|
+
function G(a, n) {
|
|
11
|
+
return a ? n === "numeric" ? /^\d$/.test(a) : n === "alpha" ? /^[a-zA-Z]$/.test(a) : !0 : !0;
|
|
12
|
+
}
|
|
13
|
+
function H({
|
|
14
|
+
length: a = 4,
|
|
15
|
+
value: n,
|
|
16
|
+
defaultValue: v = "",
|
|
17
|
+
onChange: m,
|
|
18
|
+
onComplete: g,
|
|
19
|
+
type: c = "numeric",
|
|
20
|
+
mask: w = !1,
|
|
21
|
+
size: k = "md",
|
|
22
|
+
variant: x = "outline",
|
|
23
|
+
disabled: A,
|
|
24
|
+
invalid: I,
|
|
25
|
+
readOnly: P,
|
|
26
|
+
placeholder: B = "○",
|
|
27
|
+
autoFocus: b = !1,
|
|
28
|
+
className: N = "",
|
|
29
|
+
id: O
|
|
30
|
+
}) {
|
|
31
|
+
const l = S(), R = A ?? l?.disabled, D = I ?? l?.invalid, o = P ?? l?.readOnly, $ = O ?? l?.id, h = n !== void 0, [M, j] = Z(
|
|
32
|
+
() => p(v, a)
|
|
33
|
+
), s = h ? p(n ?? "", a) : M, i = _([]);
|
|
34
|
+
E(() => {
|
|
35
|
+
b && i.current[0]?.focus();
|
|
36
|
+
}, [b]);
|
|
37
|
+
const u = (t) => {
|
|
38
|
+
h || j(t);
|
|
39
|
+
const e = t.join("");
|
|
40
|
+
m?.(e), t.every((r) => r !== "") && g?.(e);
|
|
41
|
+
}, z = (t, e) => {
|
|
42
|
+
if (o) return;
|
|
43
|
+
const f = e.target.value.slice(-1);
|
|
44
|
+
if (!G(f, c)) return;
|
|
45
|
+
const d = [...s];
|
|
46
|
+
d[t] = f, u(d), f && t < a - 1 && i.current[t + 1]?.focus();
|
|
47
|
+
}, F = (t, e) => {
|
|
48
|
+
if (o) {
|
|
49
|
+
(e.key === "Backspace" || e.key === "Delete") && e.preventDefault();
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
switch (e.key) {
|
|
53
|
+
case "Backspace":
|
|
54
|
+
if (s[t]) {
|
|
55
|
+
const r = [...s];
|
|
56
|
+
r[t] = "", u(r);
|
|
57
|
+
} else if (t > 0) {
|
|
58
|
+
const r = [...s];
|
|
59
|
+
r[t - 1] = "", u(r), i.current[t - 1]?.focus();
|
|
60
|
+
}
|
|
61
|
+
e.preventDefault();
|
|
62
|
+
break;
|
|
63
|
+
case "Delete":
|
|
64
|
+
if (s[t]) {
|
|
65
|
+
const r = [...s];
|
|
66
|
+
r[t] = "", u(r), e.preventDefault();
|
|
67
|
+
}
|
|
68
|
+
break;
|
|
69
|
+
case "ArrowLeft":
|
|
70
|
+
t > 0 && (i.current[t - 1]?.focus(), e.preventDefault());
|
|
71
|
+
break;
|
|
72
|
+
case "ArrowRight":
|
|
73
|
+
t < a - 1 && (i.current[t + 1]?.focus(), e.preventDefault());
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
}, K = (t) => {
|
|
77
|
+
if (t.preventDefault(), o) return;
|
|
78
|
+
const e = t.clipboardData.getData("text"), r = c === "numeric" ? e.replace(/\D/g, "") : c === "alpha" ? e.replace(/[^a-zA-Z]/g, "") : e, f = p(r, a);
|
|
79
|
+
u(f);
|
|
80
|
+
const d = Math.min(r.length, a - 1);
|
|
81
|
+
i.current[d]?.focus();
|
|
82
|
+
}, L = (t) => {
|
|
83
|
+
t.target.select();
|
|
84
|
+
}, T = w ? "password" : c === "numeric" ? "tel" : "text";
|
|
85
|
+
return /* @__PURE__ */ y(
|
|
86
|
+
"div",
|
|
87
|
+
{
|
|
88
|
+
role: "group",
|
|
89
|
+
"aria-label": "PIN input",
|
|
90
|
+
className: C("astralis:flex astralis:items-center astralis:gap-2", N),
|
|
91
|
+
children: Array.from({ length: a }, (t, e) => /* @__PURE__ */ y(
|
|
92
|
+
"input",
|
|
93
|
+
{
|
|
94
|
+
ref: (r) => {
|
|
95
|
+
i.current[e] = r;
|
|
96
|
+
},
|
|
97
|
+
id: e === 0 ? $ : void 0,
|
|
98
|
+
type: T,
|
|
99
|
+
inputMode: c === "numeric" ? "numeric" : "text",
|
|
100
|
+
autoComplete: e === 0 ? "one-time-code" : "off",
|
|
101
|
+
maxLength: 2,
|
|
102
|
+
value: s[e],
|
|
103
|
+
placeholder: B,
|
|
104
|
+
disabled: !!R,
|
|
105
|
+
readOnly: o,
|
|
106
|
+
"aria-label": `Digit ${e + 1} of ${a}`,
|
|
107
|
+
"aria-invalid": D || void 0,
|
|
108
|
+
"aria-describedby": l?.describedBy,
|
|
109
|
+
"aria-readonly": o || void 0,
|
|
110
|
+
onChange: (r) => z(e, r),
|
|
111
|
+
onKeyDown: (r) => F(e, r),
|
|
112
|
+
onPaste: K,
|
|
113
|
+
onFocus: L,
|
|
114
|
+
className: C(
|
|
115
|
+
q({ size: k, variant: x, invalid: !!D }),
|
|
116
|
+
o && "astralis:bg-surface-muted astralis:cursor-default"
|
|
117
|
+
)
|
|
118
|
+
},
|
|
119
|
+
e
|
|
120
|
+
))
|
|
121
|
+
}
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
H.displayName = "PinInput";
|
|
125
|
+
export {
|
|
126
|
+
H as PinInputBase
|
|
127
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cva as s } from "class-variance-authority";
|
|
3
|
+
const r = s(
|
|
4
|
+
"astralis:text-center astralis:text-label-base astralis:font-mono astralis:font-semibold astralis:transition-colors astralis:outline-none astralis:placeholder:text-label-subtle astralis:placeholder:font-normal astralis:disabled:cursor-not-allowed astralis:disabled:opacity-moderate",
|
|
5
|
+
{
|
|
6
|
+
variants: {
|
|
7
|
+
size: {
|
|
8
|
+
sm: "astralis:h-8 astralis:w-8 astralis:text-sm",
|
|
9
|
+
md: "astralis:h-10 astralis:w-10 astralis:text-base",
|
|
10
|
+
lg: "astralis:h-12 astralis:w-12 astralis:text-lg"
|
|
11
|
+
},
|
|
12
|
+
variant: {
|
|
13
|
+
outline: "astralis:border-normal astralis:border-stroke-base astralis:bg-surface-base astralis:rounded-lg astralis:hover:border-stroke-emphasized astralis:focus-visible:border-accent-stroke astralis:focus-visible:ring-2 astralis:focus-visible:ring-accent-ring",
|
|
14
|
+
filled: "astralis:border-normal astralis:border-transparent astralis:bg-surface-muted astralis:rounded-lg astralis:hover:bg-surface-subtle astralis:focus-visible:bg-surface-base astralis:focus-visible:border-accent-stroke astralis:focus-visible:ring-2 astralis:focus-visible:ring-accent-ring"
|
|
15
|
+
},
|
|
16
|
+
invalid: { true: "", false: "" }
|
|
17
|
+
},
|
|
18
|
+
compoundVariants: [
|
|
19
|
+
{
|
|
20
|
+
invalid: !0,
|
|
21
|
+
variant: "outline",
|
|
22
|
+
className: "astralis:border-red-solid astralis:hover:border-red-solid astralis:focus-visible:border-red-solid astralis:focus-visible:ring-red-muted"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
invalid: !0,
|
|
26
|
+
variant: "filled",
|
|
27
|
+
className: "astralis:border-red-solid astralis:hover:border-red-solid astralis:focus-visible:border-red-solid astralis:focus-visible:ring-red-muted"
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
defaultVariants: { size: "md", variant: "outline", invalid: !1 }
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
export {
|
|
34
|
+
r as pinCell
|
|
35
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
3
|
+
import { useId as v, useState as G } from "react";
|
|
4
|
+
import N from "../radio.context.js";
|
|
5
|
+
import { astralisMerge as R } from "../../../../utils/astralis-merge.js";
|
|
6
|
+
function h({
|
|
7
|
+
value: e,
|
|
8
|
+
defaultValue: t = "",
|
|
9
|
+
onChange: o,
|
|
10
|
+
name: s,
|
|
11
|
+
disabled: l,
|
|
12
|
+
colorScheme: i,
|
|
13
|
+
orientation: n = "vertical",
|
|
14
|
+
children: p,
|
|
15
|
+
className: u,
|
|
16
|
+
...m
|
|
17
|
+
}) {
|
|
18
|
+
const c = v(), d = s ?? c, [f, x] = G(t), g = e ?? f, V = (a) => {
|
|
19
|
+
x(a), o?.(a);
|
|
20
|
+
};
|
|
21
|
+
return /* @__PURE__ */ r(N.Provider, { value: { groupValue: g, selectValue: V, name: d, disabled: l, colorScheme: i }, children: /* @__PURE__ */ r(
|
|
22
|
+
"div",
|
|
23
|
+
{
|
|
24
|
+
role: "radiogroup",
|
|
25
|
+
className: R(
|
|
26
|
+
"astralis:flex",
|
|
27
|
+
n === "horizontal" ? "astralis:flex-row astralis:flex-wrap astralis:gap-x-6 astralis:gap-y-2" : "astralis:flex-col astralis:gap-2.5",
|
|
28
|
+
u
|
|
29
|
+
),
|
|
30
|
+
...m,
|
|
31
|
+
children: p
|
|
32
|
+
}
|
|
33
|
+
) });
|
|
34
|
+
}
|
|
35
|
+
h.displayName = "Radio.Group";
|
|
36
|
+
export {
|
|
37
|
+
h as RadioGroup
|
|
38
|
+
};
|