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,395 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as d, jsxs as G, Fragment as ie } from "react/jsx-runtime";
|
|
3
|
+
import { useState as q, useRef as D, useEffect as S, useCallback as Z, useMemo as ee } from "react";
|
|
4
|
+
import { useFieldContext as te } from "../../field/field.context.js";
|
|
5
|
+
import { CENTER_XY as se, sliderThumbSize as oe, sliderTrackH as ae } from "../slider.styles.js";
|
|
6
|
+
import { astralisMerge as k } from "../../../../utils/astralis-merge.js";
|
|
7
|
+
import { accentClass as re } from "../../../../const/color-schemes.js";
|
|
8
|
+
function z(t, e, a) {
|
|
9
|
+
return (t - e) / (a - e) * 100;
|
|
10
|
+
}
|
|
11
|
+
function Q(t, e, a, f, r) {
|
|
12
|
+
const { left: c, width: g } = e.getBoundingClientRect(), A = Math.max(0, Math.min(1, (t - c) / g)), E = a + A * (f - a), M = Math.round(E / r) * r, X = String(r).includes(".") ? String(r).split(".")[1].length : 0;
|
|
13
|
+
return parseFloat(Math.max(a, Math.min(f, M)).toFixed(X));
|
|
14
|
+
}
|
|
15
|
+
function ne(t, e, a, f) {
|
|
16
|
+
if (!t) return [];
|
|
17
|
+
if (t === !0) {
|
|
18
|
+
const r = Math.round((a - e) / f);
|
|
19
|
+
return r > 20 ? [{ value: e }, { value: a }] : Array.from({ length: r + 1 }, (c, g) => ({ value: e + g * f }));
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
}
|
|
23
|
+
function ce({ value: t, visible: e }) {
|
|
24
|
+
return e ? /* @__PURE__ */ d(
|
|
25
|
+
"div",
|
|
26
|
+
{
|
|
27
|
+
"aria-hidden": "true",
|
|
28
|
+
style: { bottom: "100%", left: "50%", transform: "translateX(-50%)" },
|
|
29
|
+
className: "astralis:absolute astralis:mb-2 astralis:pointer-events-none",
|
|
30
|
+
children: /* @__PURE__ */ G("div", { className: "astralis:relative astralis:rounded-sm astralis:bg-surface-inverted astralis:px-1.5 astralis:py-0.5 astralis:text-xs astralis:font-medium astralis:text-label-inverted astralis:whitespace-nowrap astralis:shadow-sm", children: [
|
|
31
|
+
t,
|
|
32
|
+
/* @__PURE__ */ d(
|
|
33
|
+
"div",
|
|
34
|
+
{
|
|
35
|
+
"aria-hidden": "true",
|
|
36
|
+
style: { top: "100%", left: "50%", transform: "translateX(-50%) rotate(45deg)", marginTop: "-3px" },
|
|
37
|
+
className: "astralis:absolute astralis:h-2 astralis:w-2 astralis:bg-surface-inverted"
|
|
38
|
+
}
|
|
39
|
+
)
|
|
40
|
+
] })
|
|
41
|
+
}
|
|
42
|
+
) : null;
|
|
43
|
+
}
|
|
44
|
+
function W({
|
|
45
|
+
percent: t,
|
|
46
|
+
value: e,
|
|
47
|
+
size: a,
|
|
48
|
+
isInvalid: f,
|
|
49
|
+
isDisabled: r,
|
|
50
|
+
isReadOnly: c,
|
|
51
|
+
showTooltip: g,
|
|
52
|
+
onMouseDown: A,
|
|
53
|
+
onKeyDown: E,
|
|
54
|
+
ariaMin: M,
|
|
55
|
+
ariaMax: X,
|
|
56
|
+
label: V
|
|
57
|
+
}) {
|
|
58
|
+
const [B, T] = q(!1), [H, L] = q(!1), u = (b) => {
|
|
59
|
+
if (r || c) return;
|
|
60
|
+
L(!0), A(b);
|
|
61
|
+
const v = () => L(!1);
|
|
62
|
+
document.addEventListener("mouseup", v, { once: !0 });
|
|
63
|
+
}, h = g && (B || H);
|
|
64
|
+
return /* @__PURE__ */ d(
|
|
65
|
+
"div",
|
|
66
|
+
{
|
|
67
|
+
role: "slider",
|
|
68
|
+
tabIndex: r ? -1 : 0,
|
|
69
|
+
"aria-valuemin": M,
|
|
70
|
+
"aria-valuemax": X,
|
|
71
|
+
"aria-valuenow": e,
|
|
72
|
+
"aria-label": V,
|
|
73
|
+
"aria-disabled": r,
|
|
74
|
+
"aria-readonly": c,
|
|
75
|
+
style: { left: `${t}%`, ...se },
|
|
76
|
+
className: k(
|
|
77
|
+
"astralis:absolute astralis:rounded-full astralis:border-moderate astralis:bg-surface-base astralis:shadow-md astralis:transition-shadow",
|
|
78
|
+
"astralis:outline-none astralis:focus-visible:ring-2 astralis:focus-visible:ring-offset-1 astralis:focus-visible:ring-offset-surface-base",
|
|
79
|
+
oe[a],
|
|
80
|
+
f ? "astralis:border-red-solid astralis:focus-visible:ring-red-muted" : "astralis:border-accent-solid astralis:focus-visible:ring-accent-ring",
|
|
81
|
+
r ? "astralis:cursor-not-allowed astralis:border-stroke-emphasized" : c ? "astralis:cursor-default" : "astralis:cursor-grab astralis:active:cursor-grabbing astralis:hover:shadow-lg"
|
|
82
|
+
),
|
|
83
|
+
onMouseDown: u,
|
|
84
|
+
onKeyDown: E,
|
|
85
|
+
onMouseEnter: () => T(!0),
|
|
86
|
+
onMouseLeave: () => T(!1),
|
|
87
|
+
children: /* @__PURE__ */ d(ce, { value: e, visible: h })
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
function le({ marksArr: t, min: e, max: a, isActive: f }) {
|
|
92
|
+
return /* @__PURE__ */ d(ie, { children: t.map((r) => {
|
|
93
|
+
const c = z(r.value, e, a);
|
|
94
|
+
return /* @__PURE__ */ G("div", { "aria-hidden": "true", style: { left: `${c}%`, ...se }, className: "astralis:absolute", children: [
|
|
95
|
+
/* @__PURE__ */ d(
|
|
96
|
+
"div",
|
|
97
|
+
{
|
|
98
|
+
className: k(
|
|
99
|
+
"astralis:h-1.5 astralis:w-1.5 astralis:rounded-full astralis:border-normal",
|
|
100
|
+
f(r.value) ? "astralis:bg-accent-solid astralis:border-accent-solid" : "astralis:bg-surface-base astralis:border-stroke-emphasized"
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
),
|
|
104
|
+
r.label && /* @__PURE__ */ d(
|
|
105
|
+
"span",
|
|
106
|
+
{
|
|
107
|
+
style: { left: "50%", transform: "translateX(-50%)" },
|
|
108
|
+
className: "astralis:absolute astralis:top-3 astralis:text-xs astralis:text-label-muted astralis:whitespace-nowrap",
|
|
109
|
+
children: r.label
|
|
110
|
+
}
|
|
111
|
+
)
|
|
112
|
+
] }, r.value);
|
|
113
|
+
}) });
|
|
114
|
+
}
|
|
115
|
+
function ue({
|
|
116
|
+
min: t = 0,
|
|
117
|
+
max: e = 100,
|
|
118
|
+
step: a = 1,
|
|
119
|
+
value: f,
|
|
120
|
+
defaultValue: r = 0,
|
|
121
|
+
onChange: c,
|
|
122
|
+
size: g = "md",
|
|
123
|
+
colorScheme: A = "brand",
|
|
124
|
+
showTooltip: E = !0,
|
|
125
|
+
marks: M,
|
|
126
|
+
disabled: X,
|
|
127
|
+
invalid: V,
|
|
128
|
+
readOnly: B,
|
|
129
|
+
className: T = "",
|
|
130
|
+
id: H,
|
|
131
|
+
ref: L
|
|
132
|
+
}) {
|
|
133
|
+
const u = te(), h = X ?? u?.disabled, b = V ?? u?.invalid, v = B ?? u?.readOnly, J = H ?? u?.id, C = f !== void 0, [i, R] = q(r), w = C ? f : i, x = D(null), I = D(!1), y = D({ min: t, max: e, step: a, isControlled: C, isDisabled: h, isReadOnly: v });
|
|
134
|
+
S(() => {
|
|
135
|
+
y.current = { min: t, max: e, step: a, isControlled: C, isDisabled: h, isReadOnly: v };
|
|
136
|
+
});
|
|
137
|
+
const $ = D(c);
|
|
138
|
+
S(() => {
|
|
139
|
+
$.current = c;
|
|
140
|
+
});
|
|
141
|
+
const F = D(R), O = Z((s) => {
|
|
142
|
+
if (!x.current || y.current.isDisabled || y.current.isReadOnly) return;
|
|
143
|
+
const { min: l, max: m, step: N, isControlled: p } = y.current, U = Q(s, x.current, l, m, N);
|
|
144
|
+
p || F.current(U), $.current?.(U);
|
|
145
|
+
}, []);
|
|
146
|
+
S(() => {
|
|
147
|
+
const s = (m) => {
|
|
148
|
+
if (!I.current) return;
|
|
149
|
+
const N = "touches" in m ? m.touches[0].clientX : m.clientX;
|
|
150
|
+
O(N);
|
|
151
|
+
}, l = () => {
|
|
152
|
+
I.current = !1;
|
|
153
|
+
};
|
|
154
|
+
return document.addEventListener("mousemove", s), document.addEventListener("mouseup", l), document.addEventListener("touchmove", s, { passive: !0 }), document.addEventListener("touchend", l), () => {
|
|
155
|
+
document.removeEventListener("mousemove", s), document.removeEventListener("mouseup", l), document.removeEventListener("touchmove", s), document.removeEventListener("touchend", l);
|
|
156
|
+
};
|
|
157
|
+
}, [O]);
|
|
158
|
+
const K = (s) => {
|
|
159
|
+
h || v || (I.current = !0, O(s.clientX));
|
|
160
|
+
}, j = (s) => {
|
|
161
|
+
s.stopPropagation(), !(h || v) && (I.current = !0);
|
|
162
|
+
}, P = (s) => {
|
|
163
|
+
if (h || v) return;
|
|
164
|
+
const { min: l, max: m, step: N } = y.current;
|
|
165
|
+
let p = w;
|
|
166
|
+
switch (s.key) {
|
|
167
|
+
case "ArrowLeft":
|
|
168
|
+
case "ArrowDown":
|
|
169
|
+
p = Math.max(l, w - N);
|
|
170
|
+
break;
|
|
171
|
+
case "ArrowRight":
|
|
172
|
+
case "ArrowUp":
|
|
173
|
+
p = Math.min(m, w + N);
|
|
174
|
+
break;
|
|
175
|
+
case "Home":
|
|
176
|
+
p = l;
|
|
177
|
+
break;
|
|
178
|
+
case "End":
|
|
179
|
+
p = m;
|
|
180
|
+
break;
|
|
181
|
+
default:
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
s.preventDefault(), C || R(p), c?.(p);
|
|
185
|
+
}, _ = z(w, t, e), n = ee(() => ne(M, t, e, a), [M, t, e, a]), o = n.some((s) => s.label);
|
|
186
|
+
return /* @__PURE__ */ d(
|
|
187
|
+
"div",
|
|
188
|
+
{
|
|
189
|
+
ref: L,
|
|
190
|
+
id: J,
|
|
191
|
+
className: k(
|
|
192
|
+
"astralis:relative astralis:w-full astralis:select-none",
|
|
193
|
+
re(A),
|
|
194
|
+
o && "astralis:mb-6",
|
|
195
|
+
h && "astralis:opacity-moderate",
|
|
196
|
+
v && "astralis:opacity-high",
|
|
197
|
+
T
|
|
198
|
+
),
|
|
199
|
+
children: /* @__PURE__ */ G(
|
|
200
|
+
"div",
|
|
201
|
+
{
|
|
202
|
+
ref: x,
|
|
203
|
+
onMouseDown: K,
|
|
204
|
+
className: k(
|
|
205
|
+
"astralis:relative astralis:w-full astralis:rounded-full astralis:bg-surface-muted",
|
|
206
|
+
ae[g],
|
|
207
|
+
h ? "astralis:cursor-not-allowed" : v ? "astralis:cursor-default" : "astralis:cursor-pointer"
|
|
208
|
+
),
|
|
209
|
+
children: [
|
|
210
|
+
/* @__PURE__ */ d(
|
|
211
|
+
"div",
|
|
212
|
+
{
|
|
213
|
+
"aria-hidden": "true",
|
|
214
|
+
style: { top: 0, bottom: 0, left: 0, width: `${_}%` },
|
|
215
|
+
className: k("astralis:absolute astralis:rounded-full", b ? "astralis:bg-red-solid" : "astralis:bg-accent-solid")
|
|
216
|
+
}
|
|
217
|
+
),
|
|
218
|
+
/* @__PURE__ */ d(
|
|
219
|
+
W,
|
|
220
|
+
{
|
|
221
|
+
percent: _,
|
|
222
|
+
value: w,
|
|
223
|
+
size: g,
|
|
224
|
+
isInvalid: !!b,
|
|
225
|
+
isDisabled: !!h,
|
|
226
|
+
isReadOnly: !!v,
|
|
227
|
+
showTooltip: E,
|
|
228
|
+
onMouseDown: j,
|
|
229
|
+
onKeyDown: P,
|
|
230
|
+
ariaMin: t,
|
|
231
|
+
ariaMax: e
|
|
232
|
+
}
|
|
233
|
+
),
|
|
234
|
+
/* @__PURE__ */ d(le, { marksArr: n, min: t, max: e, isActive: (s) => s <= w })
|
|
235
|
+
]
|
|
236
|
+
}
|
|
237
|
+
)
|
|
238
|
+
}
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
ue.displayName = "Slider";
|
|
242
|
+
function de({
|
|
243
|
+
min: t = 0,
|
|
244
|
+
max: e = 100,
|
|
245
|
+
step: a = 1,
|
|
246
|
+
value: f,
|
|
247
|
+
defaultValue: r = [20, 80],
|
|
248
|
+
onChange: c,
|
|
249
|
+
size: g = "md",
|
|
250
|
+
colorScheme: A = "brand",
|
|
251
|
+
showTooltip: E = !0,
|
|
252
|
+
marks: M,
|
|
253
|
+
disabled: X,
|
|
254
|
+
invalid: V,
|
|
255
|
+
readOnly: B,
|
|
256
|
+
className: T = "",
|
|
257
|
+
ref: H
|
|
258
|
+
}) {
|
|
259
|
+
const L = te(), u = X ?? L?.disabled, h = V ?? L?.invalid, b = B ?? L?.readOnly, v = f !== void 0, [J, C] = q(r), i = v ? f : J, R = D(null), w = D(-1), x = D({ min: t, max: e, step: a, isControlled: v, isDisabled: u, isReadOnly: b, value: i });
|
|
260
|
+
S(() => {
|
|
261
|
+
x.current = { min: t, max: e, step: a, isControlled: v, isDisabled: u, isReadOnly: b, value: i };
|
|
262
|
+
});
|
|
263
|
+
const I = D(c);
|
|
264
|
+
S(() => {
|
|
265
|
+
I.current = c;
|
|
266
|
+
});
|
|
267
|
+
const y = Z((n) => {
|
|
268
|
+
if (!R.current || x.current.isDisabled || x.current.isReadOnly) return;
|
|
269
|
+
const o = w.current;
|
|
270
|
+
if (o === -1) return;
|
|
271
|
+
const { min: s, max: l, step: m, isControlled: N, value: p } = x.current, U = Q(n, R.current, s, l, m);
|
|
272
|
+
let Y;
|
|
273
|
+
o === 0 ? Y = [Math.min(U, p[1] - m), p[1]] : Y = [p[0], Math.max(U, p[0] + m)], N || C(Y), I.current?.(Y);
|
|
274
|
+
}, []);
|
|
275
|
+
S(() => {
|
|
276
|
+
const n = (s) => {
|
|
277
|
+
if (w.current === -1) return;
|
|
278
|
+
const l = "touches" in s ? s.touches[0].clientX : s.clientX;
|
|
279
|
+
y(l);
|
|
280
|
+
}, o = () => {
|
|
281
|
+
w.current = -1;
|
|
282
|
+
};
|
|
283
|
+
return document.addEventListener("mousemove", n), document.addEventListener("mouseup", o), document.addEventListener("touchmove", n, { passive: !0 }), document.addEventListener("touchend", o), () => {
|
|
284
|
+
document.removeEventListener("mousemove", n), document.removeEventListener("mouseup", o), document.removeEventListener("touchmove", n), document.removeEventListener("touchend", o);
|
|
285
|
+
};
|
|
286
|
+
}, [y]);
|
|
287
|
+
const $ = (n) => {
|
|
288
|
+
if (u || b || !R.current) return;
|
|
289
|
+
const o = Q(n.clientX, R.current, t, e, a), s = Math.abs(o - i[0]), l = Math.abs(o - i[1]);
|
|
290
|
+
w.current = s <= l ? 0 : 1, y(n.clientX);
|
|
291
|
+
}, F = (n) => (o) => {
|
|
292
|
+
o.stopPropagation(), !(u || b) && (w.current = n);
|
|
293
|
+
}, O = (n) => (o) => {
|
|
294
|
+
if (u || b) return;
|
|
295
|
+
const s = i[n];
|
|
296
|
+
let l = s;
|
|
297
|
+
switch (o.key) {
|
|
298
|
+
case "ArrowLeft":
|
|
299
|
+
case "ArrowDown":
|
|
300
|
+
l = Math.max(t, s - a);
|
|
301
|
+
break;
|
|
302
|
+
case "ArrowRight":
|
|
303
|
+
case "ArrowUp":
|
|
304
|
+
l = Math.min(e, s + a);
|
|
305
|
+
break;
|
|
306
|
+
case "Home":
|
|
307
|
+
l = t;
|
|
308
|
+
break;
|
|
309
|
+
case "End":
|
|
310
|
+
l = e;
|
|
311
|
+
break;
|
|
312
|
+
default:
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
o.preventDefault();
|
|
316
|
+
const m = n === 0 ? [Math.min(l, i[1] - a), i[1]] : [i[0], Math.max(l, i[0] + a)];
|
|
317
|
+
v || C(m), c?.(m);
|
|
318
|
+
}, K = z(i[0], t, e), j = z(i[1], t, e), P = ee(() => ne(M, t, e, a), [M, t, e, a]), _ = P.some((n) => n.label);
|
|
319
|
+
return /* @__PURE__ */ d(
|
|
320
|
+
"div",
|
|
321
|
+
{
|
|
322
|
+
ref: H,
|
|
323
|
+
className: k(
|
|
324
|
+
"astralis:relative astralis:w-full astralis:select-none",
|
|
325
|
+
re(A),
|
|
326
|
+
_ && "astralis:mb-6",
|
|
327
|
+
u && "astralis:opacity-moderate",
|
|
328
|
+
b && "astralis:opacity-high",
|
|
329
|
+
T
|
|
330
|
+
),
|
|
331
|
+
children: /* @__PURE__ */ G(
|
|
332
|
+
"div",
|
|
333
|
+
{
|
|
334
|
+
ref: R,
|
|
335
|
+
onMouseDown: $,
|
|
336
|
+
className: k(
|
|
337
|
+
"astralis:relative astralis:w-full astralis:rounded-full astralis:bg-surface-muted",
|
|
338
|
+
ae[g],
|
|
339
|
+
u ? "astralis:cursor-not-allowed" : b ? "astralis:cursor-default" : "astralis:cursor-pointer"
|
|
340
|
+
),
|
|
341
|
+
children: [
|
|
342
|
+
/* @__PURE__ */ d(
|
|
343
|
+
"div",
|
|
344
|
+
{
|
|
345
|
+
"aria-hidden": "true",
|
|
346
|
+
style: { top: 0, bottom: 0, left: `${K}%`, width: `${j - K}%` },
|
|
347
|
+
className: k("astralis:absolute astralis:rounded-full", h ? "astralis:bg-red-solid" : "astralis:bg-accent-solid")
|
|
348
|
+
}
|
|
349
|
+
),
|
|
350
|
+
/* @__PURE__ */ d(
|
|
351
|
+
W,
|
|
352
|
+
{
|
|
353
|
+
percent: K,
|
|
354
|
+
value: i[0],
|
|
355
|
+
size: g,
|
|
356
|
+
isInvalid: !!h,
|
|
357
|
+
isDisabled: !!u,
|
|
358
|
+
isReadOnly: !!b,
|
|
359
|
+
showTooltip: E,
|
|
360
|
+
onMouseDown: F(0),
|
|
361
|
+
onKeyDown: O(0),
|
|
362
|
+
ariaMin: t,
|
|
363
|
+
ariaMax: i[1],
|
|
364
|
+
label: "Start value"
|
|
365
|
+
}
|
|
366
|
+
),
|
|
367
|
+
/* @__PURE__ */ d(
|
|
368
|
+
W,
|
|
369
|
+
{
|
|
370
|
+
percent: j,
|
|
371
|
+
value: i[1],
|
|
372
|
+
size: g,
|
|
373
|
+
isInvalid: !!h,
|
|
374
|
+
isDisabled: !!u,
|
|
375
|
+
isReadOnly: !!b,
|
|
376
|
+
showTooltip: E,
|
|
377
|
+
onMouseDown: F(1),
|
|
378
|
+
onKeyDown: O(1),
|
|
379
|
+
ariaMin: i[0],
|
|
380
|
+
ariaMax: e,
|
|
381
|
+
label: "End value"
|
|
382
|
+
}
|
|
383
|
+
),
|
|
384
|
+
/* @__PURE__ */ d(le, { marksArr: P, min: t, max: e, isActive: (n) => n >= i[0] && n <= i[1] })
|
|
385
|
+
]
|
|
386
|
+
}
|
|
387
|
+
)
|
|
388
|
+
}
|
|
389
|
+
);
|
|
390
|
+
}
|
|
391
|
+
de.displayName = "RangeSlider";
|
|
392
|
+
export {
|
|
393
|
+
de as RangeSliderBase,
|
|
394
|
+
ue as SliderBase
|
|
395
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const s = {
|
|
3
|
+
sm: "astralis:h-1",
|
|
4
|
+
md: "astralis:h-1.5",
|
|
5
|
+
lg: "astralis:h-2"
|
|
6
|
+
}, a = {
|
|
7
|
+
sm: "astralis:h-3.5 astralis:w-3.5",
|
|
8
|
+
md: "astralis:h-5 astralis:w-5",
|
|
9
|
+
lg: "astralis:h-6 astralis:w-6"
|
|
10
|
+
}, t = { top: "50%", transform: "translate(-50%, -50%)" };
|
|
11
|
+
export {
|
|
12
|
+
t as CENTER_XY,
|
|
13
|
+
a as sliderThumbSize,
|
|
14
|
+
s as sliderTrackH
|
|
15
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs as j, jsx as l } from "react/jsx-runtime";
|
|
3
|
+
import { useState as z, useEffect as B } from "react";
|
|
4
|
+
import { useFieldContext as D } from "../../field/field.context.js";
|
|
5
|
+
import { switchSizes as T, switchTrackColor as E, switchTrack as F } from "../switch.styles.js";
|
|
6
|
+
import { astralisMerge as n } from "../../../../utils/astralis-merge.js";
|
|
7
|
+
import { accentClass as I } from "../../../../const/color-schemes.js";
|
|
8
|
+
function L({
|
|
9
|
+
size: f = "md",
|
|
10
|
+
children: d,
|
|
11
|
+
colorScheme: u = "brand",
|
|
12
|
+
invalid: b,
|
|
13
|
+
disabled: p,
|
|
14
|
+
checked: s,
|
|
15
|
+
defaultChecked: y = !1,
|
|
16
|
+
onChange: C,
|
|
17
|
+
readOnly: w,
|
|
18
|
+
className: k = "",
|
|
19
|
+
id: v,
|
|
20
|
+
ref: x,
|
|
21
|
+
...g
|
|
22
|
+
}) {
|
|
23
|
+
const a = D(), [N, c] = z(y), e = s !== void 0, i = e ? s : N, m = p ?? a?.disabled, h = b ?? a?.invalid, t = w ?? a?.readOnly, O = v ?? a?.id, S = (o) => {
|
|
24
|
+
if (t) {
|
|
25
|
+
o.preventDefault();
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
e || c(o.target.checked), C?.(o);
|
|
29
|
+
};
|
|
30
|
+
B(() => {
|
|
31
|
+
e && c(s);
|
|
32
|
+
}, [e, s]);
|
|
33
|
+
const r = T[f];
|
|
34
|
+
return /* @__PURE__ */ j(
|
|
35
|
+
"label",
|
|
36
|
+
{
|
|
37
|
+
className: n(
|
|
38
|
+
"astralis:inline-flex astralis:items-center astralis:gap-2.5",
|
|
39
|
+
I(u),
|
|
40
|
+
m ? "astralis:cursor-not-allowed astralis:opacity-moderate" : t ? "astralis:cursor-default" : "astralis:cursor-pointer",
|
|
41
|
+
k
|
|
42
|
+
),
|
|
43
|
+
children: [
|
|
44
|
+
/* @__PURE__ */ l(
|
|
45
|
+
"input",
|
|
46
|
+
{
|
|
47
|
+
ref: x,
|
|
48
|
+
type: "checkbox",
|
|
49
|
+
role: "switch",
|
|
50
|
+
id: O,
|
|
51
|
+
checked: i,
|
|
52
|
+
disabled: m,
|
|
53
|
+
readOnly: t,
|
|
54
|
+
"aria-invalid": h || void 0,
|
|
55
|
+
"aria-describedby": a?.describedBy,
|
|
56
|
+
"aria-readonly": t || void 0,
|
|
57
|
+
"aria-checked": i,
|
|
58
|
+
onChange: S,
|
|
59
|
+
className: "astralis:sr-only astralis:peer",
|
|
60
|
+
...g
|
|
61
|
+
}
|
|
62
|
+
),
|
|
63
|
+
/* @__PURE__ */ l("span", { "aria-hidden": "true", className: n(r.track, F, E(i, !!h)), children: /* @__PURE__ */ l(
|
|
64
|
+
"span",
|
|
65
|
+
{
|
|
66
|
+
"aria-hidden": "true",
|
|
67
|
+
className: n(
|
|
68
|
+
r.thumb,
|
|
69
|
+
// Deliberately white in BOTH themes (Chakra/Material convention):
|
|
70
|
+
// a theme-following thumb would go dark on the dark off-track and
|
|
71
|
+
// vanish. `bg-white` resolves var(--astralis-color-white), so it
|
|
72
|
+
// stays themable at the primitive layer.
|
|
73
|
+
"astralis:rounded-full astralis:bg-white astralis:shadow-sm astralis:transition-transform",
|
|
74
|
+
i ? r.on : "astralis:translate-x-0"
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
) }),
|
|
78
|
+
d && /* @__PURE__ */ l("span", { className: n(r.label, "astralis:text-label-base astralis:select-none"), children: d })
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
L.displayName = "Switch";
|
|
84
|
+
export {
|
|
85
|
+
L as SwitchBase
|
|
86
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const r = {
|
|
3
|
+
sm: { track: "astralis:h-4 astralis:w-7", thumb: "astralis:h-3 astralis:w-3", on: "astralis:translate-x-3", label: "astralis:text-xs" },
|
|
4
|
+
md: { track: "astralis:h-5 astralis:w-9", thumb: "astralis:h-4 astralis:w-4", on: "astralis:translate-x-4", label: "astralis:text-sm" },
|
|
5
|
+
lg: { track: "astralis:h-6 astralis:w-11", thumb: "astralis:h-5 astralis:w-5", on: "astralis:translate-x-5", label: "astralis:text-base" }
|
|
6
|
+
}, t = "astralis:inline-flex astralis:shrink-0 astralis:items-center astralis:px-0.5 astralis:rounded-full astralis:transition-colors astralis:peer-focus-visible:ring-2 astralis:peer-focus-visible:ring-accent-ring astralis:peer-focus-visible:ring-offset-2 astralis:peer-focus-visible:ring-offset-surface-base";
|
|
7
|
+
function i(s, a) {
|
|
8
|
+
return a ? s ? "astralis:bg-red-solid" : "astralis:bg-surface-muted astralis:border-normal astralis:border-red-solid" : s ? "astralis:bg-accent-solid" : "astralis:bg-surface-muted astralis:border-normal astralis:border-stroke-emphasized";
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
r as switchSizes,
|
|
12
|
+
t as switchTrack,
|
|
13
|
+
i as switchTrackColor
|
|
14
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useContext as n, createContext as t } from "react";
|
|
3
|
+
const c = t(null);
|
|
4
|
+
function i() {
|
|
5
|
+
const o = n(c);
|
|
6
|
+
if (!o) throw new Error("Accordion sub-components must be used within <Accordion>");
|
|
7
|
+
return o;
|
|
8
|
+
}
|
|
9
|
+
const r = t(null);
|
|
10
|
+
function u() {
|
|
11
|
+
const o = n(r);
|
|
12
|
+
if (!o) throw new Error("Accordion.Trigger / Accordion.Content must be used within <Accordion.Item>");
|
|
13
|
+
return o;
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
c as AccordionContext,
|
|
17
|
+
r as AccordionItemContext,
|
|
18
|
+
i as useAccordion,
|
|
19
|
+
u as useAccordionItem
|
|
20
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cva as a } from "class-variance-authority";
|
|
3
|
+
const t = a("astralis:w-full", {
|
|
4
|
+
variants: {
|
|
5
|
+
variant: {
|
|
6
|
+
// Shared outer border + rounded; items divided by inner borders.
|
|
7
|
+
enclosed: "astralis:border-normal astralis:border-stroke-base astralis:rounded-lg astralis:overflow-hidden",
|
|
8
|
+
// Divider lines only, no outer frame.
|
|
9
|
+
outline: "",
|
|
10
|
+
// Each item is its own card.
|
|
11
|
+
separated: "astralis:flex astralis:flex-col astralis:gap-3",
|
|
12
|
+
// Filled cards.
|
|
13
|
+
subtle: "astralis:flex astralis:flex-col astralis:gap-2",
|
|
14
|
+
// No chrome at all.
|
|
15
|
+
plain: ""
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
defaultVariants: { variant: "enclosed" }
|
|
19
|
+
}), r = a("astralis:transition-colors", {
|
|
20
|
+
variants: {
|
|
21
|
+
variant: {
|
|
22
|
+
enclosed: "astralis:border-b astralis:border-stroke-base astralis:last:border-b-0",
|
|
23
|
+
outline: "astralis:border-b astralis:border-stroke-base astralis:last:border-b-0",
|
|
24
|
+
separated: "astralis:border-normal astralis:border-stroke-base astralis:rounded-lg astralis:overflow-hidden astralis:bg-surface-base",
|
|
25
|
+
subtle: "astralis:rounded-lg astralis:overflow-hidden astralis:bg-surface-subtle",
|
|
26
|
+
plain: ""
|
|
27
|
+
},
|
|
28
|
+
disabled: {
|
|
29
|
+
true: "astralis:opacity-moderate astralis:pointer-events-none",
|
|
30
|
+
false: ""
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
defaultVariants: { variant: "enclosed", disabled: !1 }
|
|
34
|
+
}), l = a(
|
|
35
|
+
"astralis:w-full astralis:flex astralis:items-center astralis:gap-3 astralis:text-left astralis:font-medium astralis:text-label-base astralis:cursor-pointer astralis:transition-colors astralis:outline-none astralis:focus-visible:outline-2 astralis:focus-visible:outline-offset-[-2px] astralis:focus-visible:outline-accent-ring astralis:disabled:cursor-not-allowed astralis:disabled:opacity-moderate",
|
|
36
|
+
{
|
|
37
|
+
variants: {
|
|
38
|
+
size: {
|
|
39
|
+
sm: "astralis:px-3 astralis:py-2 astralis:text-sm",
|
|
40
|
+
md: "astralis:px-4 astralis:py-3 astralis:text-base",
|
|
41
|
+
lg: "astralis:px-5 astralis:py-4 astralis:text-lg"
|
|
42
|
+
},
|
|
43
|
+
variant: {
|
|
44
|
+
enclosed: "astralis:hover:bg-surface-subtle",
|
|
45
|
+
outline: "astralis:hover:bg-surface-subtle",
|
|
46
|
+
separated: "astralis:hover:bg-surface-subtle",
|
|
47
|
+
subtle: "astralis:hover:bg-accent-subtle",
|
|
48
|
+
plain: ""
|
|
49
|
+
},
|
|
50
|
+
open: { true: "", false: "" }
|
|
51
|
+
},
|
|
52
|
+
compoundVariants: [
|
|
53
|
+
// Only the `subtle` variant tints its open header with the accent hue.
|
|
54
|
+
{ variant: "subtle", open: !0, class: "astralis:bg-accent-subtle astralis:text-accent-label" }
|
|
55
|
+
],
|
|
56
|
+
defaultVariants: { size: "md", variant: "enclosed", open: !1 }
|
|
57
|
+
}
|
|
58
|
+
), e = a("astralis:text-label-muted", {
|
|
59
|
+
variants: {
|
|
60
|
+
size: {
|
|
61
|
+
// pt is set so (trigger pad-bottom + content pad-top) === content pad-bottom,
|
|
62
|
+
// making the gap above the body equal the gap below it.
|
|
63
|
+
sm: "astralis:px-3 astralis:pb-3 astralis:pt-2 astralis:text-sm",
|
|
64
|
+
md: "astralis:px-4 astralis:pb-4 astralis:pt-2 astralis:text-sm",
|
|
65
|
+
lg: "astralis:px-5 astralis:pb-5 astralis:pt-2 astralis:text-base"
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
defaultVariants: { size: "md" }
|
|
69
|
+
}), i = a(
|
|
70
|
+
"astralis:shrink-0 astralis:text-label-muted astralis:transition-transform astralis:duration-moderate",
|
|
71
|
+
{
|
|
72
|
+
variants: {
|
|
73
|
+
open: { true: "astralis:rotate-180", false: "astralis:rotate-0" }
|
|
74
|
+
},
|
|
75
|
+
defaultVariants: { open: !1 }
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
export {
|
|
79
|
+
e as accordionContentVariants,
|
|
80
|
+
i as accordionIndicatorVariants,
|
|
81
|
+
r as accordionItemVariants,
|
|
82
|
+
t as accordionRootVariants,
|
|
83
|
+
l as accordionTriggerVariants
|
|
84
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
3
|
+
import { useRef as c } from "react";
|
|
4
|
+
import { useAccordion as m, useAccordionItem as u } from "../accordion.context.js";
|
|
5
|
+
import { accordionContentVariants as f } from "../accordion.styles.js";
|
|
6
|
+
import { astralisMerge as p } from "../../../../utils/astralis-merge.js";
|
|
7
|
+
function N({ children: o, className: i = "" }) {
|
|
8
|
+
const { size: n, keepMounted: s } = m(), { open: e, triggerId: a, contentId: l } = u(), t = c(!1);
|
|
9
|
+
e && (t.current = !0);
|
|
10
|
+
const d = e || t.current || s;
|
|
11
|
+
return /* @__PURE__ */ r(
|
|
12
|
+
"div",
|
|
13
|
+
{
|
|
14
|
+
id: l,
|
|
15
|
+
role: "region",
|
|
16
|
+
"aria-labelledby": a,
|
|
17
|
+
"data-state": e ? "open" : "closed",
|
|
18
|
+
className: "astralis:grid astralis:transition-all astralis:duration-moderate",
|
|
19
|
+
style: { gridTemplateRows: e ? "1fr" : "0fr" },
|
|
20
|
+
children: /* @__PURE__ */ r("div", { className: "astralis:overflow-hidden astralis:min-h-0", inert: !e, children: /* @__PURE__ */ r("div", { className: p(f({ size: n }), i), children: d ? o : null }) })
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
N as AccordionContent
|
|
26
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo as p } from "react";
|
|
4
|
+
import { useAccordion as f, AccordionItemContext as b } from "../accordion.context.js";
|
|
5
|
+
import { accordionItemVariants as I } from "../accordion.styles.js";
|
|
6
|
+
import { astralisMerge as g } from "../../../../utils/astralis-merge.js";
|
|
7
|
+
function M({ children: d, value: o, disabled: n = !1, className: s = "" }) {
|
|
8
|
+
const { rootId: e, variant: c, isOpen: a, disabled: m } = f(), t = n || m, r = a(o), l = p(
|
|
9
|
+
() => ({
|
|
10
|
+
value: o,
|
|
11
|
+
open: r,
|
|
12
|
+
disabled: t,
|
|
13
|
+
triggerId: `${e}-trigger-${o}`,
|
|
14
|
+
contentId: `${e}-content-${o}`
|
|
15
|
+
}),
|
|
16
|
+
[o, r, t, e]
|
|
17
|
+
);
|
|
18
|
+
return /* @__PURE__ */ i(b.Provider, { value: l, children: /* @__PURE__ */ i(
|
|
19
|
+
"div",
|
|
20
|
+
{
|
|
21
|
+
"data-state": r ? "open" : "closed",
|
|
22
|
+
"data-disabled": t ? "" : void 0,
|
|
23
|
+
className: g(I({ variant: c, disabled: t }), s),
|
|
24
|
+
children: d
|
|
25
|
+
}
|
|
26
|
+
) });
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
M as AccordionItem
|
|
30
|
+
};
|