@leonardaustin/ui 0.25.0 → 0.26.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/README.md +11 -0
- package/dist/components/app-shell/AppShell.d.ts +3 -3
- package/dist/components/app-shell/AppShell.js +82 -0
- package/dist/components/app-shell/AuthLayout.d.ts +3 -3
- package/dist/components/app-shell/AuthLayout.js +16 -0
- package/dist/components/app-shell/BackLink.d.ts +3 -3
- package/dist/components/app-shell/BackLink.js +19 -0
- package/dist/components/app-shell/BottomNav.d.ts +3 -2
- package/dist/components/app-shell/BottomNav.js +37 -0
- package/dist/components/app-shell/Breadcrumbs.d.ts +3 -2
- package/dist/components/app-shell/Breadcrumbs.js +46 -0
- package/dist/components/app-shell/CommandPalette.d.ts +3 -2
- package/dist/components/app-shell/CommandPalette.js +119 -0
- package/dist/components/app-shell/MobileDrawer.d.ts +3 -3
- package/dist/components/app-shell/MobileDrawer.js +128 -0
- package/dist/components/app-shell/Sidebar.d.ts +3 -3
- package/dist/components/app-shell/Sidebar.js +355 -0
- package/dist/components/app-shell/ThemeMenu.d.ts +3 -2
- package/dist/components/app-shell/ThemeMenu.js +273 -0
- package/dist/components/app-shell/TopBar.d.ts +3 -3
- package/dist/components/app-shell/TopBar.js +129 -0
- package/dist/components/app-shell/commandPaletteEvents.js +16 -0
- package/dist/components/app-shell/navigation.js +21 -0
- package/dist/components/app-shell/themeMenuEvents.js +7 -0
- package/dist/components/charts/AreaChart.d.ts +4 -3
- package/dist/components/charts/AreaChart.js +217 -0
- package/dist/components/charts/BarChart.d.ts +4 -3
- package/dist/components/charts/BarChart.js +91 -0
- package/dist/components/charts/DonutChart.d.ts +4 -3
- package/dist/components/charts/DonutChart.js +172 -0
- package/dist/components/charts/RadarChart.d.ts +4 -3
- package/dist/components/charts/RadarChart.js +142 -0
- package/dist/components/charts/RadialBarChart.d.ts +4 -3
- package/dist/components/charts/RadialBarChart.js +219 -0
- package/dist/components/charts/SparkLine.d.ts +4 -3
- package/dist/components/charts/SparkLine.js +39 -0
- package/dist/components/charts/StackedBarChart.d.ts +4 -3
- package/dist/components/charts/StackedBarChart.js +249 -0
- package/dist/components/charts/VerticalBarChart.d.ts +4 -3
- package/dist/components/charts/VerticalBarChart.js +143 -0
- package/dist/components/charts/chartUtils.js +68 -0
- package/dist/components/tables/ColumnPicker.d.ts +3 -3
- package/dist/components/tables/ColumnPicker.js +59 -0
- package/dist/components/tables/Pagination.d.ts +3 -3
- package/dist/components/tables/Pagination.js +56 -0
- package/dist/components/tables/ResourceTable.d.ts +3 -3
- package/dist/components/tables/ResourceTable.js +88 -0
- package/dist/components/tables/Table.js +95 -0
- package/dist/components/tables/sortRows.js +11 -0
- package/dist/components/ui/Accordion.d.ts +2 -1
- package/dist/components/ui/Accordion.js +35 -0
- package/dist/components/ui/Alert.d.ts +3 -2
- package/dist/components/ui/Alert.js +51 -0
- package/dist/components/ui/AttachmentList.d.ts +5 -5
- package/dist/components/ui/AttachmentList.js +90 -0
- package/dist/components/ui/AudioPlayer.d.ts +5 -2
- package/dist/components/ui/AudioPlayer.js +447 -0
- package/dist/components/ui/AuthCard.d.ts +3 -3
- package/dist/components/ui/AuthCard.js +39 -0
- package/dist/components/ui/AuthorByline.d.ts +3 -3
- package/dist/components/ui/AuthorByline.js +23 -0
- package/dist/components/ui/Avatar.d.ts +3 -2
- package/dist/components/ui/Avatar.js +36 -0
- package/dist/components/ui/Badge.d.ts +3 -2
- package/dist/components/ui/Badge.js +47 -0
- package/dist/components/ui/Button.d.ts +3 -3
- package/dist/components/ui/Button.js +83 -0
- package/dist/components/ui/Calendar.d.ts +3 -3
- package/dist/components/ui/Calendar.js +344 -0
- package/dist/components/ui/CalendarGrid.d.ts +3 -2
- package/dist/components/ui/CalendarGrid.js +136 -0
- package/dist/components/ui/Card.d.ts +6 -5
- package/dist/components/ui/Card.js +53 -0
- package/dist/components/ui/CharacterCount.d.ts +3 -3
- package/dist/components/ui/CharacterCount.js +27 -0
- package/dist/components/ui/Checkbox.d.ts +10 -8
- package/dist/components/ui/Checkbox.js +52 -0
- package/dist/components/ui/CodeInput.d.ts +7 -4
- package/dist/components/ui/CodeInput.js +96 -0
- package/dist/components/ui/Combobox.d.ts +8 -6
- package/dist/components/ui/Combobox.js +213 -0
- package/dist/components/ui/CopyButton.d.ts +1 -1
- package/dist/components/ui/CopyButton.js +57 -0
- package/dist/components/ui/DangerZone.d.ts +3 -3
- package/dist/components/ui/DangerZone.js +23 -0
- package/dist/components/ui/DatePartsInput.d.ts +6 -4
- package/dist/components/ui/DatePartsInput.js +138 -0
- package/dist/components/ui/DatePicker.d.ts +9 -4
- package/dist/components/ui/DatePicker.js +84 -0
- package/dist/components/ui/DateRangePicker.d.ts +7 -4
- package/dist/components/ui/DateRangePicker.js +143 -0
- package/dist/components/ui/DateTimePicker.d.ts +7 -4
- package/dist/components/ui/DateTimePicker.js +267 -0
- package/dist/components/ui/DetailPanel.d.ts +3 -3
- package/dist/components/ui/DetailPanel.js +183 -0
- package/dist/components/ui/Dialog.d.ts +3 -3
- package/dist/components/ui/Dialog.js +411 -0
- package/dist/components/ui/DialogActions.d.ts +3 -3
- package/dist/components/ui/DialogActions.js +35 -0
- package/dist/components/ui/Disclosure.d.ts +3 -3
- package/dist/components/ui/Disclosure.js +45 -0
- package/dist/components/ui/DividerLabel.d.ts +3 -3
- package/dist/components/ui/DividerLabel.js +20 -0
- package/dist/components/ui/DropdownMenu.d.ts +3 -3
- package/dist/components/ui/DropdownMenu.js +229 -0
- package/dist/components/ui/EmptyState.d.ts +3 -3
- package/dist/components/ui/EmptyState.js +31 -0
- package/dist/components/ui/ErrorBoundary.js +46 -0
- package/dist/components/ui/FieldContext.js +8 -0
- package/dist/components/ui/Fieldset.d.ts +2 -2
- package/dist/components/ui/Fieldset.js +39 -0
- package/dist/components/ui/FilterButton.d.ts +4 -7
- package/dist/components/ui/FilterButton.js +17 -0
- package/dist/components/ui/FilterDropdown.d.ts +4 -4
- package/dist/components/ui/FilterDropdown.js +18 -0
- package/dist/components/ui/FormField.d.ts +4 -4
- package/dist/components/ui/FormField.js +68 -0
- package/dist/components/ui/Grid.d.ts +1 -1
- package/dist/components/ui/Grid.js +19 -0
- package/dist/components/ui/GridItem.d.ts +1 -1
- package/dist/components/ui/GridItem.js +16 -0
- package/dist/components/ui/Inline.d.ts +1 -1
- package/dist/components/ui/Inline.js +24 -0
- package/dist/components/ui/Kbd.d.ts +3 -2
- package/dist/components/ui/Kbd.js +13 -0
- package/dist/components/ui/ListItemLink.d.ts +3 -3
- package/dist/components/ui/ListItemLink.js +44 -0
- package/dist/components/ui/LoadingSpinner.d.ts +3 -2
- package/dist/components/ui/LoadingSpinner.js +19 -0
- package/dist/components/ui/MessageBubble.d.ts +2 -2
- package/dist/components/ui/MessageBubble.js +41 -0
- package/dist/components/ui/MetadataGrid.d.ts +5 -3
- package/dist/components/ui/MetadataGrid.js +76 -0
- package/dist/components/ui/MetricCard.d.ts +3 -3
- package/dist/components/ui/MetricCard.js +51 -0
- package/dist/components/ui/NavTabs.d.ts +2 -2
- package/dist/components/ui/NavTabs.js +29 -0
- package/dist/components/ui/OAuthButton.d.ts +2 -2
- package/dist/components/ui/OAuthButton.js +55 -0
- package/dist/components/ui/OverlineLabel.d.ts +3 -3
- package/dist/components/ui/OverlineLabel.js +13 -0
- package/dist/components/ui/PageHeader.d.ts +3 -3
- package/dist/components/ui/PageHeader.js +33 -0
- package/dist/components/ui/PageSection.d.ts +3 -3
- package/dist/components/ui/PageSection.js +31 -0
- package/dist/components/ui/PaginationBar.d.ts +3 -3
- package/dist/components/ui/PaginationBar.js +62 -0
- package/dist/components/ui/PasswordInput.d.ts +3 -3
- package/dist/components/ui/PasswordInput.js +62 -0
- package/dist/components/ui/PasswordRequirements.d.ts +3 -2
- package/dist/components/ui/PasswordRequirements.js +34 -0
- package/dist/components/ui/Popover.d.ts +3 -3
- package/dist/components/ui/Popover.js +53 -0
- package/dist/components/ui/ProfileHeader.d.ts +3 -3
- package/dist/components/ui/ProfileHeader.js +54 -0
- package/dist/components/ui/ProgressBar.d.ts +3 -3
- package/dist/components/ui/ProgressBar.js +42 -0
- package/dist/components/ui/ProseContent.d.ts +3 -3
- package/dist/components/ui/ProseContent.js +13 -0
- package/dist/components/ui/QrCode.d.ts +3 -3
- package/dist/components/ui/QrCode.js +47 -0
- package/dist/components/ui/Radio.d.ts +9 -6
- package/dist/components/ui/Radio.js +58 -0
- package/dist/components/ui/RadioPill.d.ts +7 -4
- package/dist/components/ui/RadioPill.js +53 -0
- package/dist/components/ui/ReorderList.d.ts +3 -3
- package/dist/components/ui/ReorderList.js +123 -0
- package/dist/components/ui/SearchInput.d.ts +7 -5
- package/dist/components/ui/SearchInput.js +49 -0
- package/dist/components/ui/SectionHeader.d.ts +3 -3
- package/dist/components/ui/SectionHeader.js +13 -0
- package/dist/components/ui/Select.d.ts +4 -4
- package/dist/components/ui/Select.js +117 -0
- package/dist/components/ui/SelectDropdown.d.ts +8 -3
- package/dist/components/ui/SelectDropdown.js +206 -0
- package/dist/components/ui/SettingRow.d.ts +5 -5
- package/dist/components/ui/SettingRow.js +25 -0
- package/dist/components/ui/SideSheet.d.ts +3 -3
- package/dist/components/ui/SideSheet.js +164 -0
- package/dist/components/ui/Skeleton.d.ts +3 -3
- package/dist/components/ui/Skeleton.js +18 -0
- package/dist/components/ui/Slider.d.ts +11 -6
- package/dist/components/ui/Slider.js +58 -0
- package/dist/components/ui/SplitPaneLayout.d.ts +5 -5
- package/dist/components/ui/SplitPaneLayout.js +22 -0
- package/dist/components/ui/Stack.d.ts +1 -1
- package/dist/components/ui/Stack.js +18 -0
- package/dist/components/ui/StatusDot.d.ts +3 -2
- package/dist/components/ui/StatusDot.js +24 -0
- package/dist/components/ui/StepProgress.d.ts +3 -2
- package/dist/components/ui/StepProgress.js +33 -0
- package/dist/components/ui/Tabs.d.ts +5 -5
- package/dist/components/ui/Tabs.js +63 -0
- package/dist/components/ui/TextInput.d.ts +3 -3
- package/dist/components/ui/TextInput.js +57 -0
- package/dist/components/ui/Textarea.d.ts +3 -3
- package/dist/components/ui/Textarea.js +59 -0
- package/dist/components/ui/ThemePreview.d.ts +3 -3
- package/dist/components/ui/ThemePreview.js +28 -0
- package/dist/components/ui/TimeInput.d.ts +7 -6
- package/dist/components/ui/TimeInput.js +22 -0
- package/dist/components/ui/Timeline.d.ts +3 -2
- package/dist/components/ui/Timeline.js +29 -0
- package/dist/components/ui/Toast.js +121 -0
- package/dist/components/ui/Toggle.d.ts +5 -3
- package/dist/components/ui/Toggle.js +34 -0
- package/dist/components/ui/Toolbar.d.ts +3 -3
- package/dist/components/ui/Toolbar.js +70 -0
- package/dist/components/ui/Tooltip.js +91 -0
- package/dist/components/ui/TranscriptLine.d.ts +3 -3
- package/dist/components/ui/TranscriptLine.js +40 -0
- package/dist/components/ui/UploadDropzone.d.ts +3 -5
- package/dist/components/ui/UploadDropzone.js +55 -0
- package/dist/components/ui/badgeColors.js +5 -0
- package/dist/components/ui/calendar/AgendaView.js +140 -0
- package/dist/components/ui/calendar/MonthView.js +321 -0
- package/dist/components/ui/calendar/TimeGrid.js +501 -0
- package/dist/components/ui/calendar/TimelineView.js +311 -0
- package/dist/components/ui/calendar/context.js +10 -0
- package/dist/components/ui/calendar/items.js +152 -0
- package/dist/components/ui/calendar/types.js +38 -0
- package/dist/components/ui/calendar/useGridInteraction.js +393 -0
- package/dist/components/ui/useFieldControl.d.ts +1 -1
- package/dist/components/ui/useFieldControl.js +17 -0
- package/dist/config/theme.js +219 -0
- package/dist/core.css +2933 -0
- package/dist/hooks/useAnchoredPopup.js +162 -0
- package/dist/hooks/useApplyTheme.js +16 -0
- package/dist/hooks/useControllableState.d.ts +14 -0
- package/dist/hooks/useControllableState.js +10 -0
- package/dist/hooks/useDismiss.js +24 -0
- package/dist/hooks/useFocusTrap.js +42 -0
- package/dist/hooks/useOverlayStack.js +23 -0
- package/dist/hooks/usePopover.js +47 -0
- package/dist/hooks/usePortalContainer.js +14 -0
- package/dist/hooks/useSettings.js +8 -0
- package/dist/hooks/useTheme.js +8 -0
- package/dist/hooks/useTypeahead.js +19 -0
- package/dist/index.js +133 -12884
- package/dist/lib/anchorPlacement.js +75 -0
- package/dist/lib/calendar.js +666 -0
- package/dist/lib/cn.js +228 -0
- package/dist/lib/codeInput.js +51 -0
- package/dist/lib/dateParts.js +31 -0
- package/dist/lib/dialogDrag.js +45 -0
- package/dist/lib/dialogResize.js +47 -0
- package/dist/lib/formatDate.js +29 -0
- package/dist/lib/formatMediaTime.js +7 -0
- package/dist/lib/layout.js +29 -0
- package/dist/lib/math.js +6 -0
- package/dist/lib/mergeRefs.d.ts +6 -0
- package/dist/lib/mergeRefs.js +17 -0
- package/dist/lib/months.js +30 -0
- package/dist/lib/overlayStack.js +47 -0
- package/dist/lib/panelResize.js +8 -0
- package/dist/lib/passwordRequirements.js +23 -0
- package/dist/lib/qrCode.js +570 -0
- package/dist/lib/tones.js +104 -0
- package/dist/lib/typeahead.js +31 -0
- package/dist/providers/ControlSizeContext.js +9 -0
- package/dist/providers/ControlSizeProvider.js +11 -0
- package/dist/providers/SettingsContext.js +53 -0
- package/dist/providers/SettingsProvider.js +249 -0
- package/dist/providers/ThemeContext.js +5 -0
- package/dist/providers/ThemeProvider.js +17 -0
- package/dist/providers/accentColors.js +75 -0
- package/dist/providers/themeClasses.d.ts +1 -0
- package/dist/providers/themeClasses.js +20 -0
- package/dist/styles.css +228 -176
- package/dist/themes/cyber-brutal-dark.css +53 -0
- package/dist/themes/cyber-brutal-light.css +75 -0
- package/dist/themes/glass-dark.css +217 -0
- package/dist/themes/glass-light.css +215 -0
- package/dist/themes/hashi.css +66 -0
- package/dist/themes/light-inverted.css +32 -0
- package/dist/themes/light.css +1 -0
- package/dist/themes/monokai.css +51 -0
- package/dist/themes/solarized.css +55 -0
- package/package.json +3 -1
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { cn as e } from "../../lib/cn.js";
|
|
2
|
+
import { SelectDropdown as t } from "./SelectDropdown.js";
|
|
3
|
+
import { Pagination as n } from "../tables/Pagination.js";
|
|
4
|
+
import { Fragment as r, jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/ui/PaginationBar.tsx
|
|
6
|
+
var o = [
|
|
7
|
+
{
|
|
8
|
+
value: "10",
|
|
9
|
+
label: "10 per page"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
value: "25",
|
|
13
|
+
label: "25 per page"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
value: "50",
|
|
17
|
+
label: "50 per page"
|
|
18
|
+
}
|
|
19
|
+
];
|
|
20
|
+
function s({ page: s, pageSize: c, total: l, summary: u, showTotal: d = !1, loading: f = !1, pageSizeOptions: p = o, onPageChange: m, onPageSizeChange: h, className: g, ref: _, ...v }) {
|
|
21
|
+
let y = Math.ceil(l / c), b = Math.min((s - 1) * c + 1, l), x = Math.min(s * c, l);
|
|
22
|
+
return /* @__PURE__ */ a("div", {
|
|
23
|
+
ref: _,
|
|
24
|
+
...v,
|
|
25
|
+
className: e("flex items-center justify-between", g),
|
|
26
|
+
children: [/* @__PURE__ */ a("div", {
|
|
27
|
+
className: "flex items-center gap-3",
|
|
28
|
+
children: [h && /* @__PURE__ */ i(t, {
|
|
29
|
+
size: "sm",
|
|
30
|
+
value: String(c),
|
|
31
|
+
onValueChange: (e) => {
|
|
32
|
+
f || h(Number(e));
|
|
33
|
+
},
|
|
34
|
+
options: p,
|
|
35
|
+
className: "w-28",
|
|
36
|
+
disabled: f
|
|
37
|
+
}), /* @__PURE__ */ a("span", {
|
|
38
|
+
role: "status",
|
|
39
|
+
className: e("text-text-tertiary text-xs", !f && "hidden sm:inline"),
|
|
40
|
+
children: [f ? "Loading results..." : u === void 0 ? /* @__PURE__ */ a(r, { children: [
|
|
41
|
+
b,
|
|
42
|
+
"–",
|
|
43
|
+
x,
|
|
44
|
+
" of ",
|
|
45
|
+
l
|
|
46
|
+
] }) : typeof u == "function" ? u(l) : u, !f && d && /* @__PURE__ */ a(r, { children: [
|
|
47
|
+
" · ",
|
|
48
|
+
l,
|
|
49
|
+
" in total"
|
|
50
|
+
] })]
|
|
51
|
+
})]
|
|
52
|
+
}), /* @__PURE__ */ i(n, {
|
|
53
|
+
page: s,
|
|
54
|
+
totalPages: y,
|
|
55
|
+
onPageChange: m,
|
|
56
|
+
loading: f,
|
|
57
|
+
summary: null
|
|
58
|
+
})]
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
export { s as PaginationBar };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ComponentPropsWithRef } from "react";
|
|
2
2
|
import { type ControlSize } from "../../providers/ControlSizeContext";
|
|
3
|
-
export interface PasswordInputProps extends
|
|
3
|
+
export interface PasswordInputProps extends ComponentPropsWithRef<"input"> {
|
|
4
4
|
/** Label shown above the input. */
|
|
5
5
|
label?: string;
|
|
6
6
|
/** Error message shown above the input; also marks the field invalid and turns the border red. */
|
|
@@ -10,4 +10,4 @@ export interface PasswordInputProps extends InputHTMLAttributes<HTMLInputElement
|
|
|
10
10
|
/** Opt-in larger control, or inherit ControlSizeProvider. */
|
|
11
11
|
controlSize?: ControlSize;
|
|
12
12
|
}
|
|
13
|
-
export declare
|
|
13
|
+
export declare function PasswordInput({ label, error, className, id, hint, controlSize, required, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, ref, ...props }: PasswordInputProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { cn as e } from "../../lib/cn.js";
|
|
2
|
+
import { useControlSize as t } from "../../providers/ControlSizeContext.js";
|
|
3
|
+
import { useFieldControl as n } from "./useFieldControl.js";
|
|
4
|
+
import { useState as r } from "react";
|
|
5
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
6
|
+
import { Eye as o, EyeOff as s } from "lucide-react";
|
|
7
|
+
//#region src/components/ui/PasswordInput.tsx
|
|
8
|
+
function c({ label: c, error: l, className: u, id: d, hint: f, controlSize: p, required: m, "aria-describedby": h, "aria-invalid": g, ref: _, ...v }) {
|
|
9
|
+
let y = n({
|
|
10
|
+
id: d,
|
|
11
|
+
error: l,
|
|
12
|
+
hint: f,
|
|
13
|
+
describedBy: h,
|
|
14
|
+
invalid: g,
|
|
15
|
+
required: m
|
|
16
|
+
}), { inputId: b, errorId: x, hintId: S } = y, C = t(p), [w, T] = r(!1);
|
|
17
|
+
return /* @__PURE__ */ a("div", {
|
|
18
|
+
className: "flex flex-col gap-1.5",
|
|
19
|
+
children: [
|
|
20
|
+
f && /* @__PURE__ */ i("p", {
|
|
21
|
+
id: S,
|
|
22
|
+
className: "text-text-secondary text-xs",
|
|
23
|
+
children: f
|
|
24
|
+
}),
|
|
25
|
+
(c || l) && /* @__PURE__ */ a("div", {
|
|
26
|
+
className: "flex items-center justify-between",
|
|
27
|
+
children: [c && /* @__PURE__ */ i("label", {
|
|
28
|
+
htmlFor: b,
|
|
29
|
+
className: "ui-field-label text-xs font-medium",
|
|
30
|
+
children: c
|
|
31
|
+
}), l && /* @__PURE__ */ i("p", {
|
|
32
|
+
id: x,
|
|
33
|
+
className: "text-2xs text-danger-fg",
|
|
34
|
+
children: l
|
|
35
|
+
})]
|
|
36
|
+
}),
|
|
37
|
+
/* @__PURE__ */ a("div", {
|
|
38
|
+
className: "relative",
|
|
39
|
+
children: [/* @__PURE__ */ i("input", {
|
|
40
|
+
ref: _,
|
|
41
|
+
"data-control-size": C,
|
|
42
|
+
required: y.required,
|
|
43
|
+
"aria-invalid": y.invalid,
|
|
44
|
+
"aria-describedby": y.describedBy,
|
|
45
|
+
id: b,
|
|
46
|
+
type: w ? "text" : "password",
|
|
47
|
+
className: e("ui-password-input ui-sized-control bg-bg-secondary text-text-primary h-7 w-full rounded-md border px-2 pr-8 text-xs", "placeholder:text-text-placeholder", "transition-colors duration-[100ms]", "focus:border-accent focus:outline-none", l ? "border-danger" : "border-border", u),
|
|
48
|
+
...v
|
|
49
|
+
}), /* @__PURE__ */ i("button", {
|
|
50
|
+
type: "button",
|
|
51
|
+
onClick: () => T(!w),
|
|
52
|
+
"data-control-size": C,
|
|
53
|
+
className: "ui-password-toggle text-text-tertiary hover:text-text-primary absolute top-1/2 right-2.5 -translate-y-1/2 cursor-pointer",
|
|
54
|
+
"aria-label": w ? "Hide password" : "Show password",
|
|
55
|
+
children: i(w ? s : o, { className: "h-3.5 w-3.5" })
|
|
56
|
+
})]
|
|
57
|
+
})
|
|
58
|
+
]
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
export { c as PasswordInput };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { ComponentPropsWithRef } from "react";
|
|
1
2
|
import { type PasswordRequirement } from "../../lib/passwordRequirements";
|
|
2
|
-
export interface PasswordRequirementsProps {
|
|
3
|
+
export interface PasswordRequirementsProps extends Omit<ComponentPropsWithRef<"ul">, "children"> {
|
|
3
4
|
/** The password to check against each rule. */
|
|
4
5
|
password: string;
|
|
5
6
|
/** Rules to list, each with a unique label. Defaults to `defaultPasswordRequirements`. */
|
|
@@ -10,4 +11,4 @@ export interface PasswordRequirementsProps {
|
|
|
10
11
|
className?: string;
|
|
11
12
|
}
|
|
12
13
|
/** A live checklist of password rules, ticked off as the user types. */
|
|
13
|
-
export declare function PasswordRequirements({ password, requirements, showWhenEmpty, className, }: PasswordRequirementsProps): import("react/jsx-runtime").JSX.Element | null;
|
|
14
|
+
export declare function PasswordRequirements({ password, requirements, showWhenEmpty, className, ref, ...rest }: PasswordRequirementsProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { cn as e } from "../../lib/cn.js";
|
|
2
|
+
import { defaultPasswordRequirements as t } from "../../lib/passwordRequirements.js";
|
|
3
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
4
|
+
import { Check as i, X as a } from "lucide-react";
|
|
5
|
+
//#region src/components/ui/PasswordRequirements.tsx
|
|
6
|
+
function o({ password: o, requirements: s = t, showWhenEmpty: c = !1, className: l, ref: u, ...d }) {
|
|
7
|
+
return !c && o.length === 0 ? null : /* @__PURE__ */ n("ul", {
|
|
8
|
+
ref: u,
|
|
9
|
+
...d,
|
|
10
|
+
"aria-label": "Password requirements",
|
|
11
|
+
className: e("space-y-1", l),
|
|
12
|
+
children: s.map((t) => {
|
|
13
|
+
let s = t.test(o);
|
|
14
|
+
return /* @__PURE__ */ r("li", {
|
|
15
|
+
className: "flex items-center gap-1.5",
|
|
16
|
+
children: [s ? /* @__PURE__ */ n(i, {
|
|
17
|
+
"aria-hidden": "true",
|
|
18
|
+
className: "text-success h-3 w-3"
|
|
19
|
+
}) : /* @__PURE__ */ n(a, {
|
|
20
|
+
"aria-hidden": "true",
|
|
21
|
+
className: "text-text-tertiary h-3 w-3"
|
|
22
|
+
}), /* @__PURE__ */ r("span", {
|
|
23
|
+
className: e("text-2xs", s ? "text-success-fg" : "text-text-tertiary"),
|
|
24
|
+
children: [t.label, /* @__PURE__ */ n("span", {
|
|
25
|
+
className: "sr-only",
|
|
26
|
+
children: s ? " (met)" : " (not met)"
|
|
27
|
+
})]
|
|
28
|
+
})]
|
|
29
|
+
}, t.label);
|
|
30
|
+
})
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { o as PasswordRequirements };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ComponentPropsWithRef, type ReactNode } from "react";
|
|
2
2
|
export type PopoverPlacement = "top" | "bottom" | "left" | "right";
|
|
3
3
|
export type PopoverTriggerProps = Pick<ComponentPropsWithRef<"button">, "ref" | "type" | "onClick" | "aria-haspopup" | "aria-expanded" | "aria-controls">;
|
|
4
|
-
export interface PopoverProps {
|
|
4
|
+
export interface PopoverProps extends Omit<ComponentPropsWithRef<"div">, "children"> {
|
|
5
5
|
/** Spread these props onto a focusable button, including its ref. */
|
|
6
6
|
trigger: (props: PopoverTriggerProps) => ReactNode;
|
|
7
7
|
/** Current visibility, controlled by the caller. */
|
|
@@ -11,10 +11,10 @@ export interface PopoverProps {
|
|
|
11
11
|
/** Preferred side, flipping when there is insufficient room. */
|
|
12
12
|
placement?: PopoverPlacement;
|
|
13
13
|
/** Accessible name of the non-modal dialog. */
|
|
14
|
-
|
|
14
|
+
"aria-label": string;
|
|
15
15
|
children: ReactNode;
|
|
16
16
|
/** Additional classes on the popup panel. */
|
|
17
17
|
className?: string;
|
|
18
18
|
}
|
|
19
19
|
/** An anchored non-modal dialog. Tab remains free to leave the popup. */
|
|
20
|
-
export declare function Popover({ trigger, open, onOpenChange, placement, ariaLabel, children, className, }: PopoverProps): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export declare function Popover({ trigger, open, onOpenChange, placement, "aria-label": ariaLabel, children, className, ref, id, ...rest }: PopoverProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { cn as e } from "../../lib/cn.js";
|
|
2
|
+
import { mergeRefs as t } from "../../lib/mergeRefs.js";
|
|
3
|
+
import { OverlayContext as n } from "../../hooks/useOverlayStack.js";
|
|
4
|
+
import { PortalContainerContext as r, usePortalContainerRef as i } from "../../hooks/usePortalContainer.js";
|
|
5
|
+
import { useAnchoredPopup as a } from "../../hooks/useAnchoredPopup.js";
|
|
6
|
+
import { useDismiss as o } from "../../hooks/useDismiss.js";
|
|
7
|
+
import "../../hooks/usePopover.js";
|
|
8
|
+
import { useCallback as s, useId as c, useLayoutEffect as l, useRef as u } from "react";
|
|
9
|
+
import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
10
|
+
//#region src/components/ui/Popover.tsx
|
|
11
|
+
function m({ trigger: m, open: h, onOpenChange: g, placement: _ = "bottom", "aria-label": v, children: y, className: b, ref: x, id: S, ...C }) {
|
|
12
|
+
let w = u(null), T = u(null), [E, D] = i(T), O = c(), k = S ?? O, A = (e) => {
|
|
13
|
+
g(!1), e === "escape" && w.current?.focus();
|
|
14
|
+
}, j = o(h, A, [T], [w]);
|
|
15
|
+
a(h, w, T, {
|
|
16
|
+
side: _,
|
|
17
|
+
onAnchorHidden: () => A()
|
|
18
|
+
});
|
|
19
|
+
let M = s((e) => {
|
|
20
|
+
if (D(e), e) return () => {
|
|
21
|
+
e.contains(e.ownerDocument.activeElement) && w.current?.focus({ preventScroll: !0 }), D(null);
|
|
22
|
+
};
|
|
23
|
+
}, [D]);
|
|
24
|
+
return l(() => {
|
|
25
|
+
if (E) return t(x)(E) ?? void 0;
|
|
26
|
+
}, [E, x]), l(() => {
|
|
27
|
+
h && T.current?.focus();
|
|
28
|
+
}, [h]), /* @__PURE__ */ p(d, { children: [m({
|
|
29
|
+
ref: w,
|
|
30
|
+
type: "button",
|
|
31
|
+
onClick: () => g(!h),
|
|
32
|
+
"aria-haspopup": "dialog",
|
|
33
|
+
"aria-expanded": h,
|
|
34
|
+
"aria-controls": h ? k : void 0
|
|
35
|
+
}), h && /* @__PURE__ */ f("div", {
|
|
36
|
+
...C,
|
|
37
|
+
ref: M,
|
|
38
|
+
id: k,
|
|
39
|
+
role: "dialog",
|
|
40
|
+
"aria-label": v,
|
|
41
|
+
tabIndex: -1,
|
|
42
|
+
className: e("ui-glass ui-glass-popover bg-bg-tertiary border-border-strong animate-scale-in fixed top-0 left-0 z-[100] rounded-md border shadow-lg", "text-text-primary p-3 text-xs focus:outline-none", b),
|
|
43
|
+
children: /* @__PURE__ */ f(n.Provider, {
|
|
44
|
+
value: j,
|
|
45
|
+
children: /* @__PURE__ */ f(r.Provider, {
|
|
46
|
+
value: E,
|
|
47
|
+
children: y
|
|
48
|
+
})
|
|
49
|
+
})
|
|
50
|
+
})] });
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
export { m as Popover };
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* />
|
|
24
24
|
* ```
|
|
25
25
|
*/
|
|
26
|
-
import type { ElementType, ReactNode } from "react";
|
|
26
|
+
import type { ComponentPropsWithRef, ElementType, ReactNode } from "react";
|
|
27
27
|
interface MetaItem {
|
|
28
28
|
/** A Lucide icon component rendered at 12px. */
|
|
29
29
|
icon: ElementType;
|
|
@@ -32,7 +32,7 @@ interface MetaItem {
|
|
|
32
32
|
/** Optional href — renders the item as a link instead of a span. */
|
|
33
33
|
href?: string;
|
|
34
34
|
}
|
|
35
|
-
export interface ProfileHeaderProps {
|
|
35
|
+
export interface ProfileHeaderProps extends Omit<ComponentPropsWithRef<"div">, "children"> {
|
|
36
36
|
/** User display name — rendered as an h1. */
|
|
37
37
|
name: string;
|
|
38
38
|
/** Secondary text below the name (e.g. job title). */
|
|
@@ -49,5 +49,5 @@ export interface ProfileHeaderProps {
|
|
|
49
49
|
/** Additional utility classes for the root container. */
|
|
50
50
|
className?: string;
|
|
51
51
|
}
|
|
52
|
-
export declare function ProfileHeader({ name, subtitle, badge, meta, action, className, }: ProfileHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
52
|
+
export declare function ProfileHeader({ name, subtitle, badge, meta, action, className, ref, ...rest }: ProfileHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
53
53
|
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { cn as e } from "../../lib/cn.js";
|
|
2
|
+
import { Avatar as t } from "./Avatar.js";
|
|
3
|
+
import { Fragment as n, jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/ui/ProfileHeader.tsx
|
|
5
|
+
function a({ name: a, subtitle: o, badge: s, meta: c, action: l, className: u, ref: d, ...f }) {
|
|
6
|
+
return /* @__PURE__ */ i("div", {
|
|
7
|
+
ref: d,
|
|
8
|
+
...f,
|
|
9
|
+
className: e("flex items-start gap-4", u),
|
|
10
|
+
children: [
|
|
11
|
+
/* @__PURE__ */ r(t, {
|
|
12
|
+
name: a,
|
|
13
|
+
size: "lg"
|
|
14
|
+
}),
|
|
15
|
+
/* @__PURE__ */ i("div", {
|
|
16
|
+
className: "min-w-0 flex-1",
|
|
17
|
+
children: [
|
|
18
|
+
/* @__PURE__ */ i("div", {
|
|
19
|
+
className: "mb-1 flex items-center gap-2",
|
|
20
|
+
children: [/* @__PURE__ */ r("h1", {
|
|
21
|
+
className: "text-text-primary text-base font-semibold",
|
|
22
|
+
children: a
|
|
23
|
+
}), s]
|
|
24
|
+
}),
|
|
25
|
+
o && /* @__PURE__ */ r("p", {
|
|
26
|
+
className: "text-text-tertiary text-xs",
|
|
27
|
+
children: o
|
|
28
|
+
}),
|
|
29
|
+
c && c.length > 0 && /* @__PURE__ */ r("div", {
|
|
30
|
+
className: "mt-2 flex flex-wrap gap-3",
|
|
31
|
+
children: c.map((e) => {
|
|
32
|
+
let t = e.icon, a = /* @__PURE__ */ i(n, { children: [
|
|
33
|
+
/* @__PURE__ */ r(t, { className: "h-3 w-3" }),
|
|
34
|
+
" ",
|
|
35
|
+
e.text
|
|
36
|
+
] });
|
|
37
|
+
return e.href ? /* @__PURE__ */ r("a", {
|
|
38
|
+
href: e.href,
|
|
39
|
+
className: "text-2xs-f text-accent-fg hover:underline flex cursor-pointer items-center gap-1",
|
|
40
|
+
children: a
|
|
41
|
+
}, e.text) : /* @__PURE__ */ r("span", {
|
|
42
|
+
className: "text-2xs-f text-text-tertiary flex items-center gap-1",
|
|
43
|
+
children: a
|
|
44
|
+
}, e.text);
|
|
45
|
+
})
|
|
46
|
+
})
|
|
47
|
+
]
|
|
48
|
+
}),
|
|
49
|
+
l
|
|
50
|
+
]
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
export { a as ProfileHeader };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ComponentPropsWithRef } from "react";
|
|
2
2
|
import type { ToneColor } from "../../lib/tones";
|
|
3
|
-
export interface ProgressBarProps extends Omit<
|
|
3
|
+
export interface ProgressBarProps extends Omit<ComponentPropsWithRef<"progress">, "value" | "max" | "children" | "aria-label" | "aria-labelledby"> {
|
|
4
4
|
/** Accessible label, also displayed above the progress indicator. */
|
|
5
5
|
label: string;
|
|
6
6
|
/** Omit for indeterminate progress. Values outside the range are clamped. */
|
|
@@ -17,4 +17,4 @@ export interface ProgressBarProps extends Omit<ProgressHTMLAttributes<HTMLProgre
|
|
|
17
17
|
animated?: boolean;
|
|
18
18
|
}
|
|
19
19
|
/** Native progress semantics. Announce workflow milestones separately rather than every percentage change. */
|
|
20
|
-
export declare
|
|
20
|
+
export declare function ProgressBar({ label, value, min, max, color, striped, animated, id, className, ref, ...props }: ProgressBarProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { cn as e } from "../../lib/cn.js";
|
|
2
|
+
import { useId as t } from "react";
|
|
3
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/ui/ProgressBar.tsx
|
|
5
|
+
function i({ label: i, value: a, min: o = 0, max: s = 100, color: c = "accent", striped: l = !1, animated: u = !1, id: d, className: f, ref: p, ...m }) {
|
|
6
|
+
let h = t(), g = d ?? h;
|
|
7
|
+
if (!Number.isFinite(o) || !Number.isFinite(s) || s <= o) throw RangeError("ProgressBar requires a finite max greater than min");
|
|
8
|
+
if (a !== void 0 && !Number.isFinite(a)) throw RangeError("ProgressBar value must be finite");
|
|
9
|
+
let _ = a === void 0 ? void 0 : Math.min(s, Math.max(o, a));
|
|
10
|
+
return /* @__PURE__ */ r("div", {
|
|
11
|
+
className: "space-y-1.5",
|
|
12
|
+
children: [/* @__PURE__ */ n("label", {
|
|
13
|
+
htmlFor: g,
|
|
14
|
+
className: "text-text-secondary text-xs",
|
|
15
|
+
children: i
|
|
16
|
+
}), /* @__PURE__ */ r("div", {
|
|
17
|
+
className: "ui-progress-track",
|
|
18
|
+
"data-color": c,
|
|
19
|
+
"data-striped": l || void 0,
|
|
20
|
+
"data-animated": u || void 0,
|
|
21
|
+
"data-indeterminate": _ === void 0 || void 0,
|
|
22
|
+
children: [/* @__PURE__ */ n("span", {
|
|
23
|
+
"aria-hidden": "true",
|
|
24
|
+
className: "ui-progress-fill",
|
|
25
|
+
style: { width: _ === void 0 ? "35%" : `${(_ - o) / (s - o) * 100}%` }
|
|
26
|
+
}), /* @__PURE__ */ n("progress", {
|
|
27
|
+
...m,
|
|
28
|
+
ref: p,
|
|
29
|
+
id: g,
|
|
30
|
+
className: e("ui-progress-bar", f),
|
|
31
|
+
max: s - o,
|
|
32
|
+
value: _ === void 0 ? void 0 : _ - o,
|
|
33
|
+
"aria-valuemin": o,
|
|
34
|
+
"aria-valuemax": s,
|
|
35
|
+
"aria-valuenow": _,
|
|
36
|
+
children: _ === void 0 ? "In progress" : `${Math.round((_ - o) / (s - o) * 100)}%`
|
|
37
|
+
})]
|
|
38
|
+
})]
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
export { i as ProgressBar };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { ReactNode } from "react";
|
|
2
|
-
export interface ProseContentProps {
|
|
1
|
+
import type { ComponentPropsWithRef, ReactNode } from "react";
|
|
2
|
+
export interface ProseContentProps extends Omit<ComponentPropsWithRef<"div">, "children"> {
|
|
3
3
|
/** Rich content (headings, paragraphs, lists) styled by the prose rules. */
|
|
4
4
|
children: ReactNode;
|
|
5
5
|
/** Additional utility classes appended to the root element. */
|
|
6
6
|
className?: string;
|
|
7
7
|
}
|
|
8
|
-
export declare function ProseContent({ children, className }: ProseContentProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare function ProseContent({ children, className, ref, ...rest }: ProseContentProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { cn as e } from "../../lib/cn.js";
|
|
2
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
3
|
+
//#region src/components/ui/ProseContent.tsx
|
|
4
|
+
function n({ children: n, className: r, ref: i, ...a }) {
|
|
5
|
+
return /* @__PURE__ */ t("div", {
|
|
6
|
+
ref: i,
|
|
7
|
+
...a,
|
|
8
|
+
className: e("ui-prose", r),
|
|
9
|
+
children: n
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { n as ProseContent };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type ReactNode } from "react";
|
|
1
|
+
import { type ComponentPropsWithRef, type ReactNode } from "react";
|
|
2
2
|
import { type QrErrorCorrection } from "../../lib/qrCode";
|
|
3
|
-
export interface QrCodeProps {
|
|
3
|
+
export interface QrCodeProps extends Omit<ComponentPropsWithRef<"svg">, "children" | "width" | "height" | "viewBox"> {
|
|
4
4
|
/**
|
|
5
5
|
* Text to encode, e.g. a URL or an `otpauth://` URI for authenticator apps.
|
|
6
6
|
* An empty string renders nothing.
|
|
@@ -30,4 +30,4 @@ export interface QrCodeProps {
|
|
|
30
30
|
* Colours come from `--qr-foreground` / `--qr-background` so it stays
|
|
31
31
|
* dark-on-light in every theme.
|
|
32
32
|
*/
|
|
33
|
-
export declare function QrCode({ value, errorCorrection, size, margin, "aria-label": ariaLabel, fallback, className, }: QrCodeProps): import("react/jsx-runtime").JSX.Element | null;
|
|
33
|
+
export declare function QrCode({ value, errorCorrection, size, margin, "aria-label": ariaLabel, fallback, className, ref, ...rest }: QrCodeProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { cn as e } from "../../lib/cn.js";
|
|
2
|
+
import { QrCapacityError as t, encodeQrCode as n } from "../../lib/qrCode.js";
|
|
3
|
+
import { useMemo as r } from "react";
|
|
4
|
+
import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/ui/QrCode.tsx
|
|
6
|
+
function s({ value: s, errorCorrection: c = "M", size: l = 160, margin: u = 4, "aria-label": d = "QR code", fallback: f = null, className: p, ref: m, ...h }) {
|
|
7
|
+
let g = r(() => {
|
|
8
|
+
if (!s) return null;
|
|
9
|
+
try {
|
|
10
|
+
return n(s, c);
|
|
11
|
+
} catch (e) {
|
|
12
|
+
if (e instanceof t) return "too-long";
|
|
13
|
+
throw e;
|
|
14
|
+
}
|
|
15
|
+
}, [s, c]);
|
|
16
|
+
if (!g) return null;
|
|
17
|
+
if (g === "too-long") return /* @__PURE__ */ a(i, { children: f });
|
|
18
|
+
let _ = Math.max(0, Math.floor(u)), v = g.size + _ * 2, y = "";
|
|
19
|
+
return g.modules.forEach((e, t) => {
|
|
20
|
+
for (let n = 0; n < g.size; n++) {
|
|
21
|
+
if (!e[n]) continue;
|
|
22
|
+
let r = n;
|
|
23
|
+
for (; n + 1 < g.size && e[n + 1];) n++;
|
|
24
|
+
y += `M${r + _} ${t + _}h${n - r + 1}v1h-${n - r + 1}z`;
|
|
25
|
+
}
|
|
26
|
+
}), /* @__PURE__ */ o("svg", {
|
|
27
|
+
ref: m,
|
|
28
|
+
...h,
|
|
29
|
+
role: "img",
|
|
30
|
+
"aria-label": d,
|
|
31
|
+
width: l,
|
|
32
|
+
height: l,
|
|
33
|
+
viewBox: `0 0 ${v} ${v}`,
|
|
34
|
+
shapeRendering: "crispEdges",
|
|
35
|
+
className: e("block", p),
|
|
36
|
+
children: [/* @__PURE__ */ a("rect", {
|
|
37
|
+
width: v,
|
|
38
|
+
height: v,
|
|
39
|
+
fill: "var(--qr-background)"
|
|
40
|
+
}), /* @__PURE__ */ a("path", {
|
|
41
|
+
d: y,
|
|
42
|
+
fill: "var(--qr-foreground)"
|
|
43
|
+
})]
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
export { s as QrCode };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ComponentPropsWithRef, type ReactNode } from "react";
|
|
2
2
|
import { type FieldsetProps } from "./Fieldset";
|
|
3
|
-
export interface RadioProps extends Omit<
|
|
3
|
+
export interface RadioProps extends Omit<ComponentPropsWithRef<"input">, "type" | "size"> {
|
|
4
4
|
/** Label shown next to the radio. */
|
|
5
5
|
label: ReactNode;
|
|
6
6
|
/** Muted help text below the label, linked via `aria-describedby`. */
|
|
@@ -8,6 +8,7 @@ export interface RadioProps extends Omit<InputHTMLAttributes<HTMLInputElement>,
|
|
|
8
8
|
/** Opt-in larger control, or inherit ControlSizeProvider. */
|
|
9
9
|
controlSize?: "compact" | "comfortable";
|
|
10
10
|
}
|
|
11
|
+
declare function RadioInput({ label, description, controlSize, className, id, "aria-describedby": describedBy, "aria-invalid": invalid, ref, ...props }: RadioProps): import("react/jsx-runtime").JSX.Element;
|
|
11
12
|
export interface RadioGroupOption {
|
|
12
13
|
/** Value submitted when this option is selected; also its React key. */
|
|
13
14
|
value: string;
|
|
@@ -24,16 +25,18 @@ export interface RadioGroupProps extends Omit<FieldsetProps, "onChange"> {
|
|
|
24
25
|
/** The options to render, in order. */
|
|
25
26
|
options: RadioGroupOption[];
|
|
26
27
|
/** Value of the currently selected option. */
|
|
27
|
-
value
|
|
28
|
+
value?: string;
|
|
29
|
+
/** Initially selected value when uncontrolled. */
|
|
30
|
+
defaultValue?: string;
|
|
28
31
|
/** Called with the option's value when the user selects it. */
|
|
29
|
-
|
|
32
|
+
onValueChange?: (value: string) => void;
|
|
30
33
|
/** Marks the radios as required. */
|
|
31
34
|
required?: boolean;
|
|
32
35
|
/** Opt-in larger control, or inherit ControlSizeProvider. */
|
|
33
36
|
controlSize?: "compact" | "comfortable";
|
|
34
37
|
}
|
|
35
|
-
declare function RadioGroup({ name, id, options, value,
|
|
36
|
-
export declare const Radio:
|
|
38
|
+
declare function RadioGroup({ name, id, options, value: valueProp, defaultValue, onValueChange, required, disabled, controlSize, ...props }: RadioGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
39
|
+
export declare const Radio: typeof RadioInput & {
|
|
37
40
|
Group: typeof RadioGroup;
|
|
38
41
|
};
|
|
39
42
|
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { cn as e } from "../../lib/cn.js";
|
|
2
|
+
import { useControlSize as t } from "../../providers/ControlSizeContext.js";
|
|
3
|
+
import { useControllableState as n } from "../../hooks/useControllableState.js";
|
|
4
|
+
import { FieldContext as r, describeField as i } from "./FieldContext.js";
|
|
5
|
+
import { Fieldset as a } from "./Fieldset.js";
|
|
6
|
+
import { useContext as o, useId as s } from "react";
|
|
7
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
8
|
+
//#region src/components/ui/Radio.tsx
|
|
9
|
+
function u({ label: n, description: a, controlSize: u, className: d, id: f, "aria-describedby": p, "aria-invalid": m, ref: h, ...g }) {
|
|
10
|
+
let _ = s(), v = t(u), y = o(r), b = f ?? y?.id ?? _, x = a ? `${b}-description` : void 0;
|
|
11
|
+
return /* @__PURE__ */ l("label", {
|
|
12
|
+
className: e("ui-choice flex items-start gap-2.5", d),
|
|
13
|
+
"data-control-size": v,
|
|
14
|
+
children: [/* @__PURE__ */ c("input", {
|
|
15
|
+
...g,
|
|
16
|
+
ref: h,
|
|
17
|
+
id: b,
|
|
18
|
+
type: "radio",
|
|
19
|
+
"aria-invalid": m ?? (y?.invalid || void 0),
|
|
20
|
+
"aria-describedby": i(p, y?.describedBy, x),
|
|
21
|
+
className: "ui-native-choice"
|
|
22
|
+
}), /* @__PURE__ */ l("span", {
|
|
23
|
+
className: "text-text-primary text-xs",
|
|
24
|
+
children: [/* @__PURE__ */ c("span", { children: n }), a && /* @__PURE__ */ c("span", {
|
|
25
|
+
id: x,
|
|
26
|
+
className: "text-text-secondary block text-xs",
|
|
27
|
+
children: a
|
|
28
|
+
})]
|
|
29
|
+
})]
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function d({ name: e, id: t, options: r, value: i, defaultValue: o, onValueChange: l, required: d, disabled: f, controlSize: p, ...m }) {
|
|
33
|
+
let h = s(), g = t ?? h, [_, v] = n({
|
|
34
|
+
value: i,
|
|
35
|
+
defaultValue: o,
|
|
36
|
+
onChange: (e) => l?.(e)
|
|
37
|
+
});
|
|
38
|
+
return /* @__PURE__ */ c(a, {
|
|
39
|
+
...m,
|
|
40
|
+
id: g,
|
|
41
|
+
disabled: f,
|
|
42
|
+
children: r.map((t, n) => /* @__PURE__ */ c(u, {
|
|
43
|
+
id: `${g}-${n}`,
|
|
44
|
+
name: e ?? g,
|
|
45
|
+
value: t.value,
|
|
46
|
+
checked: _ === t.value,
|
|
47
|
+
onChange: () => v(t.value),
|
|
48
|
+
label: t.label,
|
|
49
|
+
description: t.description,
|
|
50
|
+
disabled: f || t.disabled,
|
|
51
|
+
required: d,
|
|
52
|
+
controlSize: p
|
|
53
|
+
}, t.value))
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
var f = /*#__PURE__*/ Object.assign(u, { Group: d });
|
|
57
|
+
//#endregion
|
|
58
|
+
export { f as Radio };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ComponentPropsWithRef } from "react";
|
|
2
|
+
export interface RadioPillProps<T extends string> extends Omit<ComponentPropsWithRef<"div">, "defaultValue" | "children" | "onChange"> {
|
|
2
3
|
/** The segments to render, in order. Disabled segments are skipped by keyboard navigation. */
|
|
3
4
|
options: {
|
|
4
5
|
value: T;
|
|
@@ -6,9 +7,11 @@ export interface RadioPillProps<T extends string> {
|
|
|
6
7
|
disabled?: boolean;
|
|
7
8
|
}[];
|
|
8
9
|
/** Value of the currently selected option. */
|
|
9
|
-
value
|
|
10
|
+
value?: T;
|
|
11
|
+
/** Initially selected value when uncontrolled. */
|
|
12
|
+
defaultValue?: T;
|
|
10
13
|
/** Called with the option's value when a segment is selected. */
|
|
11
|
-
|
|
14
|
+
onValueChange?: (value: T) => void;
|
|
12
15
|
/** Disables all segments and dims the control. */
|
|
13
16
|
disabled?: boolean;
|
|
14
17
|
/** Additional utility classes appended to the radiogroup. */
|
|
@@ -16,4 +19,4 @@ export interface RadioPillProps<T extends string> {
|
|
|
16
19
|
/** Accessible name for the radiogroup. */
|
|
17
20
|
"aria-label"?: string;
|
|
18
21
|
}
|
|
19
|
-
export declare function RadioPill<T extends string>({ options, value,
|
|
22
|
+
export declare function RadioPill<T extends string>({ options, value: valueProp, defaultValue, onValueChange, disabled, className, "aria-label": ariaLabel, ref, ...rest }: RadioPillProps<T>): import("react/jsx-runtime").JSX.Element;
|