@alepha/ui 0.33.0 → 0.34.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/dist/admin/analytics/AdvancedSection.d.ts.map +1 -1
- package/dist/admin/analytics/AdvancedSection.js +7 -3
- package/dist/admin/analytics/AdvancedSection.js.map +1 -1
- package/dist/admin/analytics/AnalyticsChart.d.ts +1 -0
- package/dist/admin/analytics/AnalyticsChart.d.ts.map +1 -1
- package/dist/admin/analytics/AnalyticsChart.js +3 -1
- package/dist/admin/analytics/AnalyticsChart.js.map +1 -1
- package/dist/admin/analytics/AnalyticsChartHeader.d.ts +5 -0
- package/dist/admin/analytics/AnalyticsChartHeader.d.ts.map +1 -1
- package/dist/admin/analytics/AnalyticsChartHeader.js +7 -2
- package/dist/admin/analytics/AnalyticsChartHeader.js.map +1 -1
- package/dist/admin/analytics/AnalyticsChartLine.d.ts +5 -0
- package/dist/admin/analytics/AnalyticsChartLine.d.ts.map +1 -1
- package/dist/admin/analytics/AnalyticsChartLine.js +6 -2
- package/dist/admin/analytics/AnalyticsChartLine.js.map +1 -1
- package/dist/admin/analytics/CoarsenedBadge.d.ts +15 -0
- package/dist/admin/analytics/CoarsenedBadge.d.ts.map +1 -0
- package/dist/admin/analytics/CoarsenedBadge.js +30 -0
- package/dist/admin/analytics/CoarsenedBadge.js.map +1 -0
- package/dist/admin/analytics/CompareNote.d.ts +5 -0
- package/dist/admin/analytics/CompareNote.d.ts.map +1 -1
- package/dist/admin/analytics/CompareNote.js +5 -1
- package/dist/admin/analytics/CompareNote.js.map +1 -1
- package/dist/admin/analytics/FilterEditor.d.ts +1 -0
- package/dist/admin/analytics/FilterEditor.d.ts.map +1 -1
- package/dist/admin/analytics/FilterEditor.js +1 -0
- package/dist/admin/analytics/FilterEditor.js.map +1 -1
- package/dist/admin/analytics/GroupByChips.d.ts +17 -11
- package/dist/admin/analytics/GroupByChips.d.ts.map +1 -1
- package/dist/admin/analytics/GroupByChips.js +21 -20
- package/dist/admin/analytics/GroupByChips.js.map +1 -1
- package/dist/admin/analytics/MeasureChips.d.ts +11 -6
- package/dist/admin/analytics/MeasureChips.d.ts.map +1 -1
- package/dist/admin/analytics/MeasureChips.js +13 -16
- package/dist/admin/analytics/MeasureChips.js.map +1 -1
- package/dist/admin/analytics/QueryPanel.d.ts.map +1 -1
- package/dist/admin/analytics/QueryPanel.js +9 -5
- package/dist/admin/analytics/QueryPanel.js.map +1 -1
- package/dist/admin/analytics/RangeControl.d.ts +11 -7
- package/dist/admin/analytics/RangeControl.d.ts.map +1 -1
- package/dist/admin/analytics/RangeControl.js +83 -30
- package/dist/admin/analytics/RangeControl.js.map +1 -1
- package/dist/admin/analytics/ResultsPane.d.ts.map +1 -1
- package/dist/admin/analytics/ResultsPane.js +13 -9
- package/dist/admin/analytics/ResultsPane.js.map +1 -1
- package/dist/admin/analytics/ResultsTable.d.ts.map +1 -1
- package/dist/admin/analytics/ResultsTable.js +3 -3
- package/dist/admin/analytics/ResultsTable.js.map +1 -1
- package/dist/admin/analytics/TotalsCards.d.ts +2 -1
- package/dist/admin/analytics/TotalsCards.d.ts.map +1 -1
- package/dist/admin/analytics/TotalsCards.js +9 -10
- package/dist/admin/analytics/TotalsCards.js.map +1 -1
- package/dist/admin/analytics/analyticsModel.d.ts +126 -17
- package/dist/admin/analytics/analyticsModel.d.ts.map +1 -1
- package/dist/admin/analytics/analyticsModel.js +283 -48
- package/dist/admin/analytics/analyticsModel.js.map +1 -1
- package/dist/admin/analytics/analyticsTypes.d.ts +55 -4
- package/dist/admin/analytics/analyticsTypes.d.ts.map +1 -1
- package/dist/admin/analytics/chartModel.d.ts +38 -3
- package/dist/admin/analytics/chartModel.d.ts.map +1 -1
- package/dist/admin/analytics/chartModel.js +86 -16
- package/dist/admin/analytics/chartModel.js.map +1 -1
- package/dist/admin/analytics/instantRangeSchema.d.ts +8 -0
- package/dist/admin/analytics/instantRangeSchema.d.ts.map +1 -0
- package/dist/admin/analytics/instantRangeSchema.js +13 -0
- package/dist/admin/analytics/instantRangeSchema.js.map +1 -0
- package/dist/admin/analytics/useAnalyticsQuery.d.ts +13 -3
- package/dist/admin/analytics/useAnalyticsQuery.d.ts.map +1 -1
- package/dist/admin/analytics/useAnalyticsQuery.js +60 -21
- package/dist/admin/analytics/useAnalyticsQuery.js.map +1 -1
- package/dist/admin/analytics/useFilterValues.d.ts +4 -0
- package/dist/admin/analytics/useFilterValues.d.ts.map +1 -1
- package/dist/admin/analytics/useFilterValues.js +6 -6
- package/dist/admin/analytics/useFilterValues.js.map +1 -1
- package/dist/ai/AiChat.d.ts +30 -0
- package/dist/ai/AiChat.d.ts.map +1 -0
- package/dist/ai/AiChat.js +116 -0
- package/dist/ai/AiChat.js.map +1 -0
- package/dist/ai/AiChatConfirmCard.d.ts +17 -0
- package/dist/ai/AiChatConfirmCard.d.ts.map +1 -0
- package/dist/ai/AiChatConfirmCard.js +47 -0
- package/dist/ai/AiChatConfirmCard.js.map +1 -0
- package/dist/ai/AiChatHistory.d.ts +14 -0
- package/dist/ai/AiChatHistory.d.ts.map +1 -0
- package/dist/ai/AiChatHistory.js +40 -0
- package/dist/ai/AiChatHistory.js.map +1 -0
- package/dist/ai/AiChatMessage.d.ts +10 -0
- package/dist/ai/AiChatMessage.d.ts.map +1 -0
- package/dist/ai/AiChatMessage.js +38 -0
- package/dist/ai/AiChatMessage.js.map +1 -0
- package/dist/ai/AiFormRegistry.d.ts +37 -0
- package/dist/ai/AiFormRegistry.d.ts.map +1 -0
- package/dist/ai/AiFormRegistry.js +59 -0
- package/dist/ai/AiFormRegistry.js.map +1 -0
- package/dist/ai/aiChatMessageFormSchema.d.ts +7 -0
- package/dist/ai/aiChatMessageFormSchema.d.ts.map +1 -0
- package/dist/ai/aiChatMessageFormSchema.js +13 -0
- package/dist/ai/aiChatMessageFormSchema.js.map +1 -0
- package/dist/ai/aiContextAtom.d.ts +16 -0
- package/dist/ai/aiContextAtom.d.ts.map +1 -0
- package/dist/ai/aiContextAtom.js +25 -0
- package/dist/ai/aiContextAtom.js.map +1 -0
- package/dist/ai/index.d.ts +18 -0
- package/dist/ai/index.d.ts.map +1 -0
- package/dist/ai/index.js +10 -0
- package/dist/ai/useAiChat.d.ts +82 -0
- package/dist/ai/useAiChat.d.ts.map +1 -0
- package/dist/ai/useAiChat.js +256 -0
- package/dist/ai/useAiChat.js.map +1 -0
- package/dist/ai/useAiContext.d.ts +33 -0
- package/dist/ai/useAiContext.d.ts.map +1 -0
- package/dist/ai/useAiContext.js +52 -0
- package/dist/ai/useAiContext.js.map +1 -0
- package/dist/core/Breadcrumb.js +1 -1
- package/dist/core/Breadcrumb.js.map +1 -1
- package/dist/core/Sheet.d.ts +6 -1
- package/dist/core/Sheet.d.ts.map +1 -1
- package/dist/core/Sheet.js +2 -2
- package/dist/core/Sheet.js.map +1 -1
- package/dist/core/Sidebar.d.ts +7 -1
- package/dist/core/Sidebar.d.ts.map +1 -1
- package/dist/core/Sidebar.js +22 -17
- package/dist/core/Sidebar.js.map +1 -1
- package/dist/core/index.js +2 -2
- package/dist/form/Control.d.ts +14 -0
- package/dist/form/Control.d.ts.map +1 -1
- package/dist/form/Control.js +9 -3
- package/dist/form/Control.js.map +1 -1
- package/dist/form/ControlDate.d.ts +11 -0
- package/dist/form/ControlDate.d.ts.map +1 -1
- package/dist/form/ControlDate.js +20 -2
- package/dist/form/ControlDate.js.map +1 -1
- package/dist/form/ControlDatePopover.d.ts +3 -0
- package/dist/form/ControlDatePopover.d.ts.map +1 -1
- package/dist/form/ControlDatePopover.js +1 -0
- package/dist/form/ControlDatePopover.js.map +1 -1
- package/dist/form/ControlMonthPopover.d.ts +25 -0
- package/dist/form/ControlMonthPopover.d.ts.map +1 -0
- package/dist/form/ControlMonthPopover.js +112 -0
- package/dist/form/ControlMonthPopover.js.map +1 -0
- package/dist/form/ControlSelect.d.ts +7 -0
- package/dist/form/ControlSelect.d.ts.map +1 -1
- package/dist/form/ControlSelect.js +37 -0
- package/dist/form/ControlSelect.js.map +1 -1
- package/dist/i18n/fr/uiFr.d.ts.map +1 -1
- package/dist/i18n/fr/uiFr.js +31 -1
- package/dist/i18n/fr/uiFr.js.map +1 -1
- package/dist/shell/AppShellNavCollapse.d.ts +4 -0
- package/dist/shell/AppShellNavCollapse.d.ts.map +1 -1
- package/dist/shell/AppShellNavCollapse.js +1 -0
- package/dist/shell/AppShellNavCollapse.js.map +1 -1
- package/dist/shell/AppShellSidebarNavItem.d.ts.map +1 -1
- package/dist/shell/AppShellSidebarNavItem.js +13 -9
- package/dist/shell/AppShellSidebarNavItem.js.map +1 -1
- package/dist/shell/AppShellStatefulSidebarTrigger.d.ts.map +1 -1
- package/dist/shell/AppShellStatefulSidebarTrigger.js +5 -2
- package/dist/shell/AppShellStatefulSidebarTrigger.js.map +1 -1
- package/dist/table/DataTable.d.ts.map +1 -1
- package/dist/table/DataTable.js +2 -1
- package/dist/table/DataTable.js.map +1 -1
- package/dist/table/DataTableToolbar.d.ts +7 -3
- package/dist/table/DataTableToolbar.d.ts.map +1 -1
- package/dist/table/DataTableToolbar.js +7 -3
- package/dist/table/DataTableToolbar.js.map +1 -1
- package/dist/table/dataTableBaseProps.d.ts +17 -0
- package/dist/table/dataTableBaseProps.d.ts.map +1 -1
- package/docs/packages-alepha-ui-account.md +29 -0
- package/docs/packages-alepha-ui-admin.md +35 -0
- package/docs/packages-alepha-ui-ai.md +29 -0
- package/docs/packages-alepha-ui-auth.md +23 -0
- package/docs/packages-alepha-ui-calendar.md +24 -0
- package/docs/packages-alepha-ui-chart.md +23 -0
- package/docs/packages-alepha-ui-command.md +24 -0
- package/docs/packages-alepha-ui-core.md +40 -0
- package/docs/packages-alepha-ui-form.md +29 -0
- package/docs/packages-alepha-ui-i18n-fr.md +31 -0
- package/docs/packages-alepha-ui-markdown.md +27 -0
- package/docs/packages-alepha-ui-organizations.md +20 -0
- package/docs/packages-alepha-ui-otp.md +22 -0
- package/docs/packages-alepha-ui-overview.md +337 -0
- package/docs/packages-alepha-ui-resizable.md +22 -0
- package/docs/packages-alepha-ui-settings.md +23 -0
- package/docs/packages-alepha-ui-shell.md +41 -0
- package/docs/packages-alepha-ui-table.md +37 -0
- package/docs/packages-alepha-ui-tree.md +31 -0
- package/package.json +15 -5
- package/src/admin/analytics/AdvancedSection.tsx +39 -30
- package/src/admin/analytics/AnalyticsChart.tsx +7 -1
- package/src/admin/analytics/AnalyticsChartHeader.tsx +22 -7
- package/src/admin/analytics/AnalyticsChartLine.tsx +15 -2
- package/src/admin/analytics/CoarsenedBadge.tsx +38 -0
- package/src/admin/analytics/CompareNote.tsx +16 -5
- package/src/admin/analytics/FilterEditor.tsx +2 -0
- package/src/admin/analytics/GroupByChips.tsx +40 -27
- package/src/admin/analytics/MeasureChips.tsx +19 -11
- package/src/admin/analytics/QueryPanel.tsx +10 -5
- package/src/admin/analytics/RangeControl.tsx +91 -27
- package/src/admin/analytics/ResultsPane.tsx +20 -6
- package/src/admin/analytics/ResultsTable.tsx +9 -5
- package/src/admin/analytics/TotalsCards.tsx +24 -11
- package/src/admin/analytics/analyticsModel.spec.ts +167 -36
- package/src/admin/analytics/analyticsModel.ts +358 -49
- package/src/admin/analytics/analyticsTypes.ts +56 -4
- package/src/admin/analytics/chartModel.ts +139 -20
- package/src/admin/analytics/instantRangeSchema.ts +9 -0
- package/src/admin/analytics/useAnalyticsQuery.ts +98 -35
- package/src/admin/analytics/useFilterValues.ts +16 -5
- package/src/ai/AiChat.tsx +151 -0
- package/src/ai/AiChatConfirmCard.tsx +64 -0
- package/src/ai/AiChatHistory.tsx +60 -0
- package/src/ai/AiChatMessage.tsx +57 -0
- package/src/ai/AiFormRegistry.ts +78 -0
- package/src/ai/__tests__/AiChat.browser.spec.tsx +391 -0
- package/src/ai/aiChatMessageFormSchema.ts +8 -0
- package/src/ai/aiContextAtom.ts +23 -0
- package/src/ai/index.ts +18 -0
- package/src/ai/useAiChat.ts +343 -0
- package/src/ai/useAiContext.ts +74 -0
- package/src/core/Breadcrumb.tsx +1 -1
- package/src/core/Sheet.tsx +9 -2
- package/src/core/Sidebar.tsx +45 -22
- package/src/form/Control.tsx +26 -1
- package/src/form/ControlDate.tsx +37 -2
- package/src/form/ControlDatePopover.tsx +4 -1
- package/src/form/ControlMonthPopover.tsx +169 -0
- package/src/form/ControlSelect.tsx +62 -0
- package/src/form/__tests__/ControlChoices.browser.spec.tsx +130 -0
- package/src/i18n/fr/uiFr.ts +36 -2
- package/src/shell/AppShellNavCollapse.tsx +5 -0
- package/src/shell/AppShellSidebarNavItem.tsx +23 -10
- package/src/shell/AppShellStatefulSidebarTrigger.tsx +10 -2
- package/src/shell/__tests__/AppShellDirection.browser.spec.tsx +95 -0
- package/src/table/DataTable.tsx +2 -0
- package/src/table/DataTableToolbar.tsx +18 -3
- package/src/table/__tests__/DataTableLeading.browser.spec.tsx +130 -0
- package/src/table/dataTableBaseProps.ts +17 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { cn } from "../core/utils.js";
|
|
2
|
+
import { Button } from "../core/Button.js";
|
|
3
|
+
import { Popover, PopoverContent, PopoverTrigger } from "../core/Popover.js";
|
|
4
|
+
import { ControlClearButton, TRIGGER_CLASSES, TRIGGER_SIZES, TRIGGER_WRAPPER_CLASSES } from "./fieldTrigger.js";
|
|
5
|
+
import { useI18n } from "alepha/react/i18n";
|
|
6
|
+
import { CalendarDays, ChevronDown, ChevronLeft, ChevronRight } from "lucide-react";
|
|
7
|
+
import { useState } from "react";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
//#region src/form/ControlMonthPopover.tsx
|
|
10
|
+
/**
|
|
11
|
+
* A month as a form holds it: `YYYY-MM`, the value of `<input type="month">`.
|
|
12
|
+
*/
|
|
13
|
+
const MONTH = /^(\d{4})-(\d{2})$/;
|
|
14
|
+
/**
|
|
15
|
+
* The month picker: the kit's field trigger, then a year with its twelve
|
|
16
|
+
* months. For a period that is a whole month (a report, an invoice), where a
|
|
17
|
+
* day picker would ask for a day nobody means.
|
|
18
|
+
*
|
|
19
|
+
* The value is `YYYY-MM`, so a schema reads it as a plain string and a
|
|
20
|
+
* server parses it without a time zone.
|
|
21
|
+
*/
|
|
22
|
+
const ControlMonthPopover = (props) => {
|
|
23
|
+
const { tr, l, lang } = useI18n();
|
|
24
|
+
const [open, setOpen] = useState(false);
|
|
25
|
+
const match = props.value ? MONTH.exec(props.value) : null;
|
|
26
|
+
const year = match ? Number(match[1]) : void 0;
|
|
27
|
+
const month = match ? Number(match[2]) : void 0;
|
|
28
|
+
const [shownYear, setShownYear] = useState(() => year ?? (/* @__PURE__ */ new Date()).getFullYear());
|
|
29
|
+
const key = (y, m) => `${String(y).padStart(4, "0")}-${String(m).padStart(2, "0")}`;
|
|
30
|
+
const outOfRange = (value) => props.min !== void 0 && value < props.min || props.max !== void 0 && value > props.max;
|
|
31
|
+
const formatted = year !== void 0 && month !== void 0 ? l(new Date(year, month - 1, 1), { date: {
|
|
32
|
+
year: "numeric",
|
|
33
|
+
month: "long"
|
|
34
|
+
} }) : "";
|
|
35
|
+
const monthName = (m) => new Date(2e3, m - 1, 1).toLocaleString(lang, { month: "short" });
|
|
36
|
+
const showClear = Boolean(props.clearable && match && !props.disabled);
|
|
37
|
+
const size = TRIGGER_SIZES.default;
|
|
38
|
+
return /* @__PURE__ */ jsxs(Popover, {
|
|
39
|
+
open,
|
|
40
|
+
onOpenChange: (next) => {
|
|
41
|
+
if (next && year !== void 0) setShownYear(year);
|
|
42
|
+
setOpen(next);
|
|
43
|
+
},
|
|
44
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
45
|
+
className: TRIGGER_WRAPPER_CLASSES,
|
|
46
|
+
children: [/* @__PURE__ */ jsxs(PopoverTrigger, {
|
|
47
|
+
...props.triggerProps,
|
|
48
|
+
id: props.id,
|
|
49
|
+
"data-slot": "date-trigger",
|
|
50
|
+
disabled: props.disabled,
|
|
51
|
+
className: cn(TRIGGER_CLASSES, size.trigger, size.chevron, !match && "text-muted-foreground"),
|
|
52
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
53
|
+
"data-slot": "trigger-label",
|
|
54
|
+
className: cn("flex min-w-0 items-center gap-2", showClear && size.clearGap),
|
|
55
|
+
children: [/* @__PURE__ */ jsx(CalendarDays, { className: cn("text-muted-foreground shrink-0", size.icon) }), /* @__PURE__ */ jsx("span", {
|
|
56
|
+
className: "truncate",
|
|
57
|
+
children: formatted || tr("controlMonth.placeholder", { default: "Pick a month" })
|
|
58
|
+
})]
|
|
59
|
+
}), /* @__PURE__ */ jsx(ChevronDown, { className: "text-muted-foreground pointer-events-none size-4 shrink-0" })]
|
|
60
|
+
}), showClear && /* @__PURE__ */ jsx(ControlClearButton, { onClick: () => props.onChange(void 0) })]
|
|
61
|
+
}), /* @__PURE__ */ jsxs(PopoverContent, {
|
|
62
|
+
className: "w-64 p-2",
|
|
63
|
+
align: "start",
|
|
64
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
65
|
+
className: "mb-2 flex items-center justify-between",
|
|
66
|
+
children: [
|
|
67
|
+
/* @__PURE__ */ jsx(Button, {
|
|
68
|
+
variant: "minimal",
|
|
69
|
+
size: "icon-sm",
|
|
70
|
+
"aria-label": tr("controlMonth.previousYear", { default: "Previous year" }),
|
|
71
|
+
onClick: () => setShownYear((it) => it - 1),
|
|
72
|
+
children: /* @__PURE__ */ jsx(ChevronLeft, { className: "rtl:-scale-x-100" })
|
|
73
|
+
}),
|
|
74
|
+
/* @__PURE__ */ jsx("span", {
|
|
75
|
+
className: "text-sm font-medium tabular-nums",
|
|
76
|
+
children: shownYear
|
|
77
|
+
}),
|
|
78
|
+
/* @__PURE__ */ jsx(Button, {
|
|
79
|
+
variant: "minimal",
|
|
80
|
+
size: "icon-sm",
|
|
81
|
+
"aria-label": tr("controlMonth.nextYear", { default: "Next year" }),
|
|
82
|
+
onClick: () => setShownYear((it) => it + 1),
|
|
83
|
+
children: /* @__PURE__ */ jsx(ChevronRight, { className: "rtl:-scale-x-100" })
|
|
84
|
+
})
|
|
85
|
+
]
|
|
86
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
87
|
+
className: "grid grid-cols-3 gap-1",
|
|
88
|
+
children: Array.from({ length: 12 }, (_, i) => i + 1).map((m) => {
|
|
89
|
+
const value = key(shownYear, m);
|
|
90
|
+
const selected = year === shownYear && month === m;
|
|
91
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
92
|
+
variant: selected ? "solid" : "minimal",
|
|
93
|
+
intent: selected ? "primary" : "none",
|
|
94
|
+
size: "sm",
|
|
95
|
+
"data-value": value,
|
|
96
|
+
"aria-pressed": selected,
|
|
97
|
+
disabled: outOfRange(value),
|
|
98
|
+
onClick: () => {
|
|
99
|
+
props.onChange(value);
|
|
100
|
+
setOpen(false);
|
|
101
|
+
},
|
|
102
|
+
children: monthName(m)
|
|
103
|
+
}, m);
|
|
104
|
+
})
|
|
105
|
+
})]
|
|
106
|
+
})]
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
//#endregion
|
|
110
|
+
export { ControlMonthPopover };
|
|
111
|
+
|
|
112
|
+
//# sourceMappingURL=ControlMonthPopover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ControlMonthPopover.js","names":["CalendarIcon","ChevronDownIcon"],"sources":["../../src/form/ControlMonthPopover.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport { useI18n } from \"alepha/react/i18n\";\nimport {\n CalendarDays as CalendarIcon,\n ChevronDown as ChevronDownIcon,\n ChevronLeft,\n ChevronRight,\n} from \"lucide-react\";\nimport { type HTMLAttributes, useState } from \"react\";\n\nimport { Button } from \"../core/Button.tsx\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"../core/Popover.tsx\";\nimport { cn } from \"../core/utils.ts\";\nimport {\n ControlClearButton,\n TRIGGER_CLASSES,\n TRIGGER_SIZES,\n TRIGGER_WRAPPER_CLASSES,\n} from \"./fieldTrigger.tsx\";\n\n/**\n * A month as a form holds it: `YYYY-MM`, the value of `<input type=\"month\">`.\n */\nconst MONTH = /^(\\d{4})-(\\d{2})$/;\n\nexport interface ControlMonthPopoverProps {\n id?: string;\n value?: string;\n disabled?: boolean;\n clearable?: boolean;\n /** First selectable month, `YYYY-MM`. */\n min?: string;\n /** Last selectable month, `YYYY-MM`. */\n max?: string;\n /** Forwarded to the trigger: an `aria-label`, a `data-testid`. */\n triggerProps?: HTMLAttributes<HTMLElement>;\n onChange: (value: string | undefined) => void;\n}\n\n/**\n * The month picker: the kit's field trigger, then a year with its twelve\n * months. For a period that is a whole month (a report, an invoice), where a\n * day picker would ask for a day nobody means.\n *\n * The value is `YYYY-MM`, so a schema reads it as a plain string and a\n * server parses it without a time zone.\n */\nexport const ControlMonthPopover = (props: ControlMonthPopoverProps) => {\n const { tr, l, lang } = useI18n();\n const [open, setOpen] = useState(false);\n const match = props.value ? MONTH.exec(props.value) : null;\n const year = match ? Number(match[1]) : undefined;\n const month = match ? Number(match[2]) : undefined;\n const [shownYear, setShownYear] = useState(\n () => year ?? new Date().getFullYear(),\n );\n\n const key = (y: number, m: number) =>\n `${String(y).padStart(4, \"0\")}-${String(m).padStart(2, \"0\")}`;\n const outOfRange = (value: string) =>\n (props.min !== undefined && value < props.min) ||\n (props.max !== undefined && value > props.max);\n\n const formatted =\n year !== undefined && month !== undefined\n ? l(new Date(year, month - 1, 1), {\n date: { year: \"numeric\", month: \"long\" },\n })\n : \"\";\n const monthName = (m: number) =>\n new Date(2000, m - 1, 1).toLocaleString(lang, { month: \"short\" });\n\n const showClear = Boolean(props.clearable && match && !props.disabled);\n const size = TRIGGER_SIZES.default;\n\n return (\n <Popover\n open={open}\n onOpenChange={(next) => {\n if (next && year !== undefined) setShownYear(year);\n setOpen(next);\n }}\n >\n <div className={TRIGGER_WRAPPER_CLASSES}>\n <PopoverTrigger\n {...props.triggerProps}\n id={props.id}\n data-slot=\"date-trigger\"\n disabled={props.disabled}\n className={cn(\n TRIGGER_CLASSES,\n size.trigger,\n size.chevron,\n !match && \"text-muted-foreground\",\n )}\n >\n <span\n data-slot=\"trigger-label\"\n className={cn(\n \"flex min-w-0 items-center gap-2\",\n showClear && size.clearGap,\n )}\n >\n <CalendarIcon\n className={cn(\"text-muted-foreground shrink-0\", size.icon)}\n />\n <span className=\"truncate\">\n {formatted ||\n tr(\"controlMonth.placeholder\", { default: \"Pick a month\" })}\n </span>\n </span>\n <ChevronDownIcon className=\"text-muted-foreground pointer-events-none size-4 shrink-0\" />\n </PopoverTrigger>\n {showClear && (\n <ControlClearButton onClick={() => props.onChange(undefined)} />\n )}\n </div>\n <PopoverContent className=\"w-64 p-2\" align=\"start\">\n <div className=\"mb-2 flex items-center justify-between\">\n <Button\n variant=\"minimal\"\n size=\"icon-sm\"\n aria-label={tr(\"controlMonth.previousYear\", {\n default: \"Previous year\",\n })}\n onClick={() => setShownYear((it) => it - 1)}\n >\n <ChevronLeft className=\"rtl:-scale-x-100\" />\n </Button>\n <span className=\"text-sm font-medium tabular-nums\">{shownYear}</span>\n <Button\n variant=\"minimal\"\n size=\"icon-sm\"\n aria-label={tr(\"controlMonth.nextYear\", { default: \"Next year\" })}\n onClick={() => setShownYear((it) => it + 1)}\n >\n <ChevronRight className=\"rtl:-scale-x-100\" />\n </Button>\n </div>\n <div className=\"grid grid-cols-3 gap-1\">\n {Array.from({ length: 12 }, (_, i) => i + 1).map((m) => {\n const value = key(shownYear, m);\n const selected = year === shownYear && month === m;\n return (\n <Button\n key={m}\n variant={selected ? \"solid\" : \"minimal\"}\n intent={selected ? \"primary\" : \"none\"}\n size=\"sm\"\n data-value={value}\n aria-pressed={selected}\n disabled={outOfRange(value)}\n onClick={() => {\n props.onChange(value);\n setOpen(false);\n }}\n >\n {monthName(m)}\n </Button>\n );\n })}\n </div>\n </PopoverContent>\n </Popover>\n );\n};\n"],"mappings":";;;;;;;;;;;;AA0BA,MAAM,QAAQ;;;;;;;;;AAwBd,MAAa,uBAAuB,UAAoC;CACtE,MAAM,EAAE,IAAI,GAAG,SAAS,Q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UAAU;MAC9B,QAAQ,WAAW,YAAY;MAC/B,MAAK;MACL,cAAY;MACZ,gBAAc;MACd,UAAU,WAAW,KAAK;MAC1B,eAAe;OACb,MAAM,SAAS,KAAK;OACpB,QAAQ,KAAK;MACf;MAEC,UAAA,UAAU,CAAC;KACN,GAbD,CAaC;IAEZ,CAAC;GACE,CAAA,CACS;EACT,CAAA,CAAA;;AAEb"}
|
|
@@ -22,6 +22,13 @@ export interface ControlSelectProps {
|
|
|
22
22
|
* Render as a `<Segmented>` control (best for 2–4 options).
|
|
23
23
|
*/
|
|
24
24
|
segmented?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Render a multi-choice field (an array schema) as a group of checkboxes,
|
|
27
|
+
* every option visible: for a handful of fixed choices (days of the week,
|
|
28
|
+
* device types), where a select would hide what is ticked. Each checkbox
|
|
29
|
+
* is named by its option's label and carries `data-value`.
|
|
30
|
+
*/
|
|
31
|
+
checkboxes?: boolean;
|
|
25
32
|
/**
|
|
26
33
|
* Force the search input on. Kept as the historical name for
|
|
27
34
|
* `searchable: true` — every select is a combobox now, the flag only
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ControlSelect.d.ts","sourceRoot":"","sources":["../../src/form/ControlSelect.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAEpC,OAAO,EACL,KAAK,cAAc,EAIpB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,KAAK,SAAS,EAA6B,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ControlSelect.d.ts","sourceRoot":"","sources":["../../src/form/ControlSelect.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,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
|
+
import { Checkbox } from "../core/Checkbox.js";
|
|
1
2
|
import { FormField } from "./FormField.js";
|
|
2
3
|
import { Segmented } from "../core/Segmented.js";
|
|
3
4
|
import { optValue } from "./controlSelectOptions.js";
|
|
@@ -82,6 +83,42 @@ const ControlSelect = (props) => {
|
|
|
82
83
|
fullWidth: true
|
|
83
84
|
})
|
|
84
85
|
});
|
|
86
|
+
if (props.checkboxes && isArray) {
|
|
87
|
+
const ticked = Array.isArray(value) ? value.map(String) : [];
|
|
88
|
+
return /* @__PURE__ */ jsx(FormField, {
|
|
89
|
+
id: meta.id,
|
|
90
|
+
label: meta.label,
|
|
91
|
+
description: meta.description,
|
|
92
|
+
error: meta.error,
|
|
93
|
+
required: meta.required,
|
|
94
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
95
|
+
role: "group",
|
|
96
|
+
"aria-label": meta.label || void 0,
|
|
97
|
+
...props.triggerProps,
|
|
98
|
+
id: meta.id,
|
|
99
|
+
className: "flex flex-wrap gap-x-4 gap-y-2 py-1",
|
|
100
|
+
children: data.map((o) => {
|
|
101
|
+
const optionValue = optValue(o);
|
|
102
|
+
const optionId = `${meta.id}-${optionValue}`;
|
|
103
|
+
return /* @__PURE__ */ jsxs("label", {
|
|
104
|
+
htmlFor: optionId,
|
|
105
|
+
className: "flex items-center gap-2 text-sm",
|
|
106
|
+
children: [/* @__PURE__ */ jsx(Checkbox, {
|
|
107
|
+
id: optionId,
|
|
108
|
+
"data-value": optionValue,
|
|
109
|
+
disabled: props.disabled || typeof o !== "string" && o.disabled,
|
|
110
|
+
checked: ticked.includes(optionValue),
|
|
111
|
+
onCheckedChange: (checked) => {
|
|
112
|
+
const next = checked ? [...ticked, optionValue] : ticked.filter((it) => it !== optionValue);
|
|
113
|
+
const ordered = data.map(optValue).filter((it) => next.includes(it));
|
|
114
|
+
setValue(ordered.map(coerce));
|
|
115
|
+
}
|
|
116
|
+
}), segmentedLabel(o)]
|
|
117
|
+
}, optionValue);
|
|
118
|
+
})
|
|
119
|
+
})
|
|
120
|
+
});
|
|
121
|
+
}
|
|
85
122
|
const clearLabel = props.clearLabel ?? tr("controlSelect.none", { default: "None" });
|
|
86
123
|
const searchable = props.searchable ?? (props.combobox || mode === "long" || Boolean(props.createNewEntry) || data.length > SEARCH_THRESHOLD);
|
|
87
124
|
return /* @__PURE__ */ jsx(FormField, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ControlSelect.js","names":[],"sources":["../../src/form/ControlSelect.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport type { Async } from \"alepha\";\nimport { useAction } from \"alepha/react\";\nimport {\n type BaseInputField,\n parseField,\n useFieldValue,\n useFormState,\n} from \"alepha/react/form\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport type { HTMLAttributes } from \"react\";\nimport { type ReactNode, useMemo, useRef, useState } from \"react\";\n\nimport { Segmented } from \"../core/Segmented.tsx\";\nimport { ControlSelectCombobox } from \"./ControlSelectCombobox.tsx\";\nimport { optValue } from \"./controlSelectOptions.ts\";\nimport type { ControlTriggerSize } from \"./fieldTrigger.tsx\";\nimport { FormField } from \"./FormField.tsx\";\nimport type { IconComponent } from \"./iconHint.tsx\";\n\nexport interface ControlSelectProps {\n /**\n * Bound `InputField` from `useForm`. Single or multi value depending on schema.\n */\n input: BaseInputField;\n /**\n * Field label. Falls back to schema `title`.\n */\n label?: string;\n /**\n * Helper text shown below the input.\n */\n description?: string;\n /**\n * Render as a `<Segmented>` control (best for 2–4 options).\n */\n segmented?: boolean;\n /**\n * Force the search input on. Kept as the historical name for\n * `searchable: true` — every select is a combobox now, the flag only\n * decides whether it carries a search field.\n */\n combobox?: boolean;\n /**\n * Whether the dropdown carries a search input. Defaults to \"auto\": on for a\n * long-mode `loader` (the rows are not all here), when `createNewEntry` is\n * set (typing IS how an entry is made), and for lists longer than\n * `SEARCH_THRESHOLD`. Set explicitly to search a short list or to drop the\n * search field from a long one.\n *\n * Multi-select obeys the same rule as everything else; it used to force the\n * field on because its chips box doubled as the search input.\n */\n searchable?: boolean;\n /**\n * Async option loader. Triggers long-mode (server-side search) above `loaderThreshold` options.\n */\n loader?: (search: string, resolve?: string[]) => Async<SelectOption[]>;\n /**\n * Option count above which `loader` is invoked on every search instead of once. Defaults to 100.\n */\n loaderThreshold?: number;\n /**\n * Debounce in ms applied to search queries when calling `loader` in long mode.\n */\n loaderDebounce?: number;\n /**\n * Disable the control.\n */\n disabled?: boolean;\n /**\n * Inline option list (overrides schema `enum`). Accepts either a static\n * array or an async function `(query) => SelectOption[]`. The async form\n * is mapped to a long-mode loader.\n */\n items?:\n | SelectOption[]\n | ((query: string) => SelectOption[] | Promise<SelectOption[]>);\n /**\n * Allow the user to add a new option by typing. When `true`, the typed\n * query becomes the value (and label) of a freshly created entry. When a\n * function, the function builds the option from the query.\n *\n * - For multi-select fields: each entry is appended to the value array.\n * - For single fields: behaves like a regular text input with a dropdown\n * suggesting existing options.\n */\n createNewEntry?: boolean | ((query: string) => Exclude<SelectOption, string>);\n /**\n * When true, the dropdown gets a synthetic \"none\" row at the top that\n * resets the field to `undefined`. Useful for optional filter chips\n * (e.g. an admin-table status filter) where the user needs an explicit\n * \"no filter\" option — Base UI's `Select` reserves empty-string values\n * as its internal no-selection sentinel, so a regular `<SelectItem\n * value=\"\">` can't be picked. With `clearable`, ControlSelect uses an\n * internal sentinel and translates it to `undefined` in `onChange`.\n *\n * Currently honored by the static-short `Select` and the searchable\n * Combobox render paths. Ignored by `segmented` (use a real segment\n * for \"all\" there).\n */\n clearable?: boolean;\n /**\n * Label rendered for the \"clear\" row injected by `clearable`. Also\n * used as the trigger placeholder when the field is empty. Defaults to\n * `\"None\"`. Localize at the call site (e.g. `\"All types\"`,\n * `\"All status\"`).\n */\n clearLabel?: string;\n /**\n * Trigger text for a multi-select whose selection is too long to name, e.g.\n * `(n) => \\`${n} status\\``. One selection always shows the value itself, so\n * this is only ever asked for two or more past `maxTriggerLength`. Defaults\n * to `\"{n} values\"`.\n */\n countLabel?: (count: number) => string;\n /**\n * The longest joined text, in characters, a multi-select trigger names its\n * selection with (\"Draft, Ready\") before it collapses to `countLabel`.\n * Defaults to 20, which suits a filter chip; a full-width form field has\n * room for more.\n */\n maxTriggerLength?: number;\n /**\n * Trigger text when nothing is selected, e.g. \"Pick an epic…\". Defaults to\n * the `clearLabel` on a `clearable` or multi field (where empty IS a\n * meaningful state to name), and to \"Select…\" otherwise.\n *\n * Set it when the empty trigger has a job to do - a picker whose whole\n * purpose is the choice it prompts for reads as a dead \"Select…\" without\n * it, which is why the surfaces that needed one stayed on the raw `Select`.\n */\n placeholder?: string;\n /**\n * Extra className applied to the visible trigger: the combobox button or\n * the segmented control, whichever this field renders. Useful for sizing\n * filter chips (`\"w-40\"`, `\"w-72\"`, etc.) without wrapping the whole\n * `FormField` in an extra div.\n */\n triggerClassName?: string;\n /**\n * Trigger height and type scale. Defaults to `default`.\n */\n size?: ControlSelectSize;\n /**\n * Render the trigger borderless and transparent, so it reads as the row it\n * sits on rather than as a form field.\n */\n minimal?: boolean;\n /**\n * Extra attributes for whichever trigger this field renders, forwarded from\n * `Control`'s `inputProps`.\n *\n * The accessible name usually lives here, because a filter is routinely\n * rendered with `label=\"\"` next to its own heading: with no `<label>` to\n * borrow a name from, a `role=combobox` button or a radiogroup has no name\n * at all. That is both an a11y hole and unaddressable from a\n * test, and it was silent, since `Control` accepted `inputProps` and then\n * dropped it on every select-shaped branch.\n */\n triggerProps?: HTMLAttributes<HTMLElement>;\n /**\n * Leading icon rendered on the left of the trigger, matching the\n * text-input controls. Resolved by the parent `Control` from its `icon`\n * prop, falling back to the list glyph like a text input falls back to\n * its schema hint; `icon={null}` on the `Control` removes it, and a\n * `minimal` trigger gets none by default.\n */\n icon?: IconComponent;\n /**\n * Drawn at the top of the popup, above the options - for a setting that\n * changes what the choice MEANS rather than what is chosen, such as a\n * filter's \"is / is not\".\n *\n * ⚠️ Only the combobox shape has a popup, so a segmented or radio rendering\n * of the same field draws nothing for it.\n */\n popupHeader?: ReactNode;\n /**\n * Drawn on the trigger just before the selected label, after the icon: the\n * short word that keeps a qualified value from reading as a plain one\n * (\"not Active\"). Absent while nothing is selected, because a qualifier on\n * a placeholder has nothing to qualify.\n */\n triggerPrefix?: ReactNode;\n /**\n * Extra className on the popup, merged over its own.\n *\n * The popup is sized from its trigger by default (`--anchor-width`), and it\n * keeps following that width while open. A trigger whose text changes as\n * the reader picks - a `triggerPrefix` appearing, \"2 values\" replacing a\n * name - therefore resizes the popup under their cursor. `w-max` with a\n * floor (`w-max min-w-48`) sizes it from its own content instead.\n */\n popupClassName?: string;\n}\n\nexport const ControlSelect = (props: ControlSelectProps) => {\n const { tr } = useI18n();\n const form = useFormState(props.input, [\"error\"]);\n const [value, setValue] = useFieldValue(props.input);\n\n const meta = parseField(props.input, {\n label: props.label,\n description: props.description,\n error: form.error,\n });\n\n const isArray = meta.isArray;\n const isNumeric = meta.type === \"number\" || meta.type === \"integer\";\n const isBoolean = meta.type === \"boolean\";\n\n // Normalize items prop: array → static; function → loader\n const itemsArray = Array.isArray(props.items)\n ? (props.items as SelectOption[])\n : undefined;\n const itemsLoader =\n typeof props.items === \"function\"\n ? (props.items as (q: string) => Async<SelectOption[]>)\n : undefined;\n\n const enumValues =\n itemsArray ?? (meta.enum as SelectOption[] | undefined) ?? [];\n\n const effectiveLoader = props.loader ?? itemsLoader;\n\n const {\n data: asyncData,\n loading,\n mode,\n search,\n } = useAsyncLoader(\n effectiveLoader,\n props.loaderThreshold ?? 100,\n props.loaderDebounce ?? 300,\n props.input.initialValue,\n );\n\n // Labels and `disabled` flags are part of the identity: keying on the\n // joined values alone collided (`[\"ab\",\"c\"]` vs `[\"a\",\"bc\"]`) and kept a\n // stale list when only the labels changed.\n //\n // ⚠️ `icon` is EXCLUDED, and it has to be. It is a `ReactNode`, and a\n // rendered element holds a fiber that points back at its DOM node, so\n // `JSON.stringify` on the raw option threw \"Converting circular structure\n // to JSON\" - a documented prop that crashed the component the first time\n // anyone used it (#Q2049). Two lists that differ only by icon share a key,\n // which is right: the key exists to notice a changed VALUE or LABEL.\n const enumKey = JSON.stringify(\n enumValues.map((option) =>\n typeof option === \"string\"\n ? option\n : {\n value: option.value,\n label: option.label,\n description: option.description,\n tag: option.tag,\n disabled: option.disabled,\n },\n ),\n );\n const min = meta.constraints.minimum;\n const max = meta.constraints.maximum;\n // Derived, not stored: this is a pure function of the schema. As state\n // filled in by an effect, the first paint of every boolean or ranged select\n // was an EMPTY list, corrected one render later.\n const staticData = useMemo<SelectOption[]>(() => {\n if (effectiveLoader) return [];\n if (isBoolean && enumValues.length === 0) {\n return [\n { value: \"true\", label: tr(\"controlSelect.yes\", { default: \"Yes\" }) },\n { value: \"false\", label: tr(\"controlSelect.no\", { default: \"No\" }) },\n ];\n }\n if (\n isNumeric &&\n enumValues.length === 0 &&\n typeof min === \"number\" &&\n typeof max === \"number\" &&\n max - min <= 20\n ) {\n const range: SelectOption[] = [];\n for (let i = min; i <= max; i++) range.push(String(i));\n return range;\n }\n return enumValues;\n }, [effectiveLoader, enumKey, isBoolean, isNumeric, min, max, tr]);\n\n const data = effectiveLoader ? asyncData : staticData;\n\n if (!props.input?.props) return null;\n\n const coerce = (raw: string): unknown => {\n if (isNumeric) return Number(raw);\n if (isBoolean) return raw === \"true\";\n return raw;\n };\n\n if (props.segmented) {\n return (\n <FormField\n id={meta.id}\n label={meta.label}\n description={meta.description}\n error={meta.error}\n required={meta.required}\n >\n {/* `triggerProps` is deliberately NOT spread here. `Segmented`\n redeclares two attributes that `HTMLAttributes` also has, with\n narrower types (`defaultValue` is string-only, `onChange` takes a\n value rather than an event), so a blanket spread neither typechecks\n nor is safe. A segmented field also renders every option as visible\n text, so it is the one branch that is not nameless without a label.\n Name it with `label` if it needs one. */}\n <Segmented\n value={value != null ? String(value) : undefined}\n onChange={(v) => setValue(coerce(v))}\n disabled={props.disabled}\n options={data.slice(0, 10).map((o) => ({\n value: optValue(o),\n label: segmentedLabel(o),\n }))}\n fullWidth\n />\n </FormField>\n );\n }\n\n const clearLabel =\n props.clearLabel ?? tr(\"controlSelect.none\", { default: \"None\" });\n\n // One control for every list. The option count decides whether the popup\n // carries a search field — it no longer decides which primitive renders.\n // The native `Select` path this replaced silently dropped `description`,\n // `tag`, per-option `disabled` and `deselectable`, and styled its trigger\n // differently, purely because a list happened to be short.\n // A search field is offered only when scanning the list by eye stops being\n // realistic: a server-driven list (whose rows are not all here), one past\n // `SEARCH_THRESHOLD`, or one where typing is how a new entry is made.\n //\n // Multi-select used to force it on unconditionally, because the chips box\n // WAS the search input and there was no other way to open the popup. The\n // trigger is a button now, so multi obeys the same rule as everything else\n // and a four-row status filter no longer opens onto a search field.\n const searchable =\n props.searchable ??\n (props.combobox ||\n mode === \"long\" ||\n Boolean(props.createNewEntry) ||\n data.length > SEARCH_THRESHOLD);\n\n return (\n <FormField\n id={meta.id}\n label={meta.label}\n description={meta.description}\n error={meta.error}\n required={meta.required}\n >\n <ControlSelectCombobox\n id={meta.id}\n data={data}\n loading={loading}\n multi={isArray}\n searchable={searchable}\n disabled={props.disabled}\n value={value}\n onChange={(v) => setValue(v)}\n coerce={coerce}\n onSearch={mode === \"long\" ? (text) => search.run(text) : undefined}\n createNewEntry={props.createNewEntry}\n icon={props.icon}\n // Used to be dropped on this path, so a filter chip sized `w-40` lost\n // its width as soon as its list crossed the threshold.\n triggerClassName={props.triggerClassName}\n triggerProps={props.triggerProps}\n size={props.size}\n minimal={props.minimal}\n // `clearable` used to reach this path as a placeholder and nothing\n // else, so a filter chip that had switched to the combobox (>20\n // options) could be set but never put back to \"All …\".\n clearable={props.clearable}\n clearLabel={clearLabel}\n countLabel={props.countLabel}\n maxTriggerLength={props.maxTriggerLength}\n popupHeader={props.popupHeader}\n triggerPrefix={props.triggerPrefix}\n popupClassName={props.popupClassName}\n // An optional field must also be able to go back to empty without a\n // dedicated row: Base UI never emits `null`, so re-pressing the\n // selected row deselects (see `handleSingle` in\n // `ControlSelectCombobox.tsx`). A required field keeps its value —\n // clearing it would only produce a validation error the user cannot\n // see yet.\n deselectable={props.clearable || !meta.required}\n // Multi shows this muted when nothing is picked, so it reaches the\n // trigger whether or not the field is `clearable` — a multi-select\n // has no clear ROW (it clears by deselecting), and without this its\n // empty trigger fell back to a bare \"Select…\".\n placeholder={\n props.placeholder ??\n (props.clearable || isArray ? clearLabel : undefined)\n }\n />\n </FormField>\n );\n};\n\nexport type SelectOption =\n | string\n | {\n value: string;\n label: string;\n /**\n * Optional secondary line shown under the label in the dropdown.\n */\n description?: string;\n /**\n * Optional small badge rendered next to the label.\n */\n tag?: string;\n /**\n * Optional icon/element rendered before the label, in both the\n * dropdown row and (for single-select) the trigger when selected.\n */\n icon?: ReactNode;\n /**\n * When true, the row is non-interactive — can't be selected if\n * not selected, can't be deselected if selected. Useful for\n * default/mandatory entries (e.g. the base \"user\" role).\n */\n disabled?: boolean;\n };\n\ntype LoaderMode = \"static\" | \"short\" | \"long\";\n\n/**\n * How tall and how loud a select trigger is.\n *\n * The kit's own scale, kept under this name because `Control` and a long tail\n * of callers already spell it `size=\"xs\"` on a select. The table behind it,\n * and the trigger box it sizes, are `control-base/field-trigger`'s - shared\n * with the two calendar controls, which used to draw a button instead.\n */\nexport type ControlSelectSize = ControlTriggerSize;\n\n/**\n * Static option count above which the dropdown grows a search input. Below it\n * the very same combobox renders without one — the threshold decides whether\n * you can type, never which control you get.\n */\n// Past this many rows, scanning by eye stops being realistic and the popup\n// grows a search field. Raised 20 -> 50 with the multi-select rework: the old\n// value put a search box on lists a reader takes in at a glance.\nconst SEARCH_THRESHOLD = 50;\n\n/**\n * Friendly label for plain string options: \"optional\" → \"Optional\",\n * \"in_progress\" → \"In Progress\". Custom `{ value, label }` items pass through\n * untouched.\n */\nconst titlecase = (s: string) =>\n s.replace(/[_-]+/g, \" \").replace(/\\b\\w/g, (c) => c.toUpperCase());\n/**\n * What one segment shows.\n *\n * ⚠️ The option's `icon` is rendered HERE rather than dropped, which is what\n * this path did until #Q2049. `SegmentedOption.label` is a `ReactNode`, so\n * there was never a reason for it: an option list carrying icons for the\n * dropdown carried them for the segments too, and dropping them silently\n * made a caller choose between two shapes for one list.\n */\nconst segmentedLabel = (o: SelectOption): ReactNode => {\n if (typeof o === \"string\") {\n return titlecase(o);\n }\n if (!o.icon) {\n return o.label;\n }\n return (\n <span className=\"inline-flex items-center gap-1.5\">\n {o.icon}\n {o.label}\n </span>\n );\n};\n\nconst useAsyncLoader = (\n loader: ControlSelectProps[\"loader\"],\n threshold: number,\n debounceMs: number,\n defaultValue: unknown,\n) => {\n const [data, setData] = useState<SelectOption[]>([]);\n const [loading, setLoading] = useState(false);\n const [mode, setMode] = useState<LoaderMode>(\"static\");\n const cache = useRef(new Map<string, SelectOption[]>());\n\n useAction(\n {\n // `id`, not `name`: `id` is what useAction threads into its\n // react:action:* events. `name` was accepted and never read, so this\n // identifier reached nothing.\n id: \"select:loader:init\",\n runOnInit: true,\n handler: async () => {\n if (!loader) {\n setMode(\"static\");\n return;\n }\n setLoading(true);\n try {\n const result = await loader(\"\");\n const isShort = result.length <= threshold;\n setMode(isShort ? \"short\" : \"long\");\n cache.current.set(\"\", result);\n setData(result);\n\n // Coercion at a boundary: the value is a form/route/chart primitive whose\n // declared type is wider than what can reach here.\n // oxlint-disable-next-line typescript/no-base-to-string -- a coercion at a boundary, see the comment above\n if (!isShort && defaultValue != null && String(defaultValue) !== \"\") {\n // Coercion at a boundary: the value is a form/route/chart primitive whose\n // declared type is wider than what can reach here.\n // oxlint-disable-next-line typescript/no-base-to-string -- a coercion at a boundary, see the comment above\n const resolved = await loader(\"\", [String(defaultValue)]);\n if (resolved.length > 0) {\n setData((prev) => {\n const existing = new Set(prev.map(optValue));\n const fresh = resolved.filter(\n (r) => !existing.has(optValue(r)),\n );\n return [...prev, ...fresh];\n });\n }\n }\n } finally {\n setLoading(false);\n }\n },\n },\n [loader, threshold],\n );\n\n const search = useAction<[string]>(\n {\n debounce: debounceMs,\n handler: async (_ctx, text) => {\n if (!loader || mode !== \"long\") return;\n if (cache.current.has(text)) {\n setData(cache.current.get(text)!);\n return;\n }\n setLoading(true);\n try {\n const result = await loader(text);\n cache.current.set(text, result);\n setData(result);\n } finally {\n setLoading(false);\n }\n },\n },\n [loader, mode, debounceMs],\n );\n\n return { data, loading, mode, search };\n};\n"],"mappings":";;;;;;;;;;AAwMA,MAAa,iBAAiB,UAA8B;CAC1D,MAAM,EAAE,OAAO,QAAQ;CACvB,MAAM,OAAO,aAAa,MAAM,OAAO,CAAC,OAAO,CAAC;CAChD,MAAM,CAAC,OAAO,YAAY,cAAc,MAAM,KAAK;CAEnD,MAAM,OAAO,WAAW,MAAM,OAAO;EACnC,OAAO,MAAM;EACb,aAAa,MAAM;EACnB,OAAO,KAAK;CACd,CAAC;CAED,MAAM,UAAU,KAAK;CACrB,MAAM,YAAY,KAAK,SAAS,YAAY,KAAK,SAAS;CAC1D,MAAM,YAAY,KAAK,SAAS;CAGhC,MAAM,aAAa,MAAM,QAAQ,MAAM,KAAK,IACvC,MAAM,QACP,KAAA;CACJ,MAAM,cACJ,OAAO,MAAM,UAAU,aAClB,MAAM,QACP,KAAA;CAEN,MAAM,aACJ,cAAe,KAAK,QAAuC,CAAC;CAE9D,MAAM,kBAAkB,MAAM,UAAU;CAExC,MAAM,EACJ,MAAM,WACN,SACA,MACA,WACE,eACF,iBACA,MAAM,mBAAmB,KACzB,MAAM,kBAAkB,KACxB,MAAM,MAAM,YACd;CAYA,MAAM,UAAU,KAAK,UACnB,WAAW,KAAK,WACd,OAAO,WAAW,WACd,SACA;EACE,OAAO,OAAO;EACd,OAAO,OAAO;EACd,aAAa,OAAO;EACpB,KAAK,OAAO;EACZ,UAAU,OAAO;CACnB,CACN,CACF;CACA,MAAM,MAAM,KAAK,YAAY;CAC7B,MAAM,MAAM,KAAK,YAAY;CAI7B,MAAM,aAAa,cAA8B;EAC/C,IAAI,iBAAiB,OAAO,CAAC;EAC7B,IAAI,aAAa,WAAW,WAAW,GACrC,OAAO,CACL;GAAE,OAAO;GAAQ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C,QAAQ;IACX,QAAQ,QAAQ;IAChB;GACF;GACA,WAAW,IAAI;GACf,IAAI;IACF,MAAM,SAAS,MAAM,OAAO,EAAE;IAC9B,MAAM,UAAU,OAAO,UAAU;IACjC,QAAQ,UAAU,UAAU,MAAM;IAClC,MAAM,QAAQ,IAAI,IAAI,MAAM;IAC5B,QAAQ,MAAM;IAKd,IAAI,CAAC,WAAW,gBAAgB,QAAQ,OAAO,YAAY,MAAM,IAAI;KAInE,MAAM,WAAW,MAAM,OAAO,IAAI,CAAC,OAAO,YAAY,CAAC,CAAC;KACxD,IAAI,SAAS,SAAS,GACpB,SAAS,SAAS;MAChB,MAAM,WAAW,IAAI,IAAI,KAAK,IAAI,QAAQ,CAAC;MAC3C,MAAM,QAAQ,SAAS,QACpB,MAAM,CAAC,SAAS,IAAI,SAAS,CAAC,CAAC,CAClC;MACA,OAAO,CAAC,GAAG,MAAM,GAAG,KAAK;KAC3B,CAAC;IAEL;GACF,UAAU;IACR,WAAW,KAAK;GAClB;EACF;CACF,GACA,CAAC,QAAQ,SAAS,CACpB;CAwBA,OAAO;EAAE;EAAM;EAAS;EAAM,QAtBf,UACb;GACE,UAAU;GACV,SAAS,OAAO,MAAM,SAAS;IAC7B,IAAI,CAAC,UAAU,SAAS,QAAQ;IAChC,IAAI,MAAM,QAAQ,IAAI,IAAI,GAAG;KAC3B,QAAQ,MAAM,QAAQ,IAAI,IAAI,CAAE;KAChC;IACF;IACA,WAAW,IAAI;IACf,IAAI;KACF,MAAM,SAAS,MAAM,OAAO,IAAI;KAChC,MAAM,QAAQ,IAAI,MAAM,MAAM;KAC9B,QAAQ,MAAM;IAChB,UAAU;KACR,WAAW,KAAK;IAClB;GACF;EACF,GACA;GAAC;GAAQ;GAAM;EAAU,CAGQ;CAAE;AACvC"}
|
|
1
|
+
{"version":3,"file":"ControlSelect.js","names":[],"sources":["../../src/form/ControlSelect.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport type { Async } from \"alepha\";\nimport { useAction } from \"alepha/react\";\nimport {\n type BaseInputField,\n parseField,\n useFieldValue,\n useFormState,\n} from \"alepha/react/form\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport type { HTMLAttributes } from \"react\";\nimport { type ReactNode, useMemo, useRef, useState } from \"react\";\n\nimport { Checkbox } from \"../core/Checkbox.tsx\";\nimport { Segmented } from \"../core/Segmented.tsx\";\nimport { ControlSelectCombobox } from \"./ControlSelectCombobox.tsx\";\nimport { optValue } from \"./controlSelectOptions.ts\";\nimport type { ControlTriggerSize } from \"./fieldTrigger.tsx\";\nimport { FormField } from \"./FormField.tsx\";\nimport type { IconComponent } from \"./iconHint.tsx\";\n\nexport interface ControlSelectProps {\n /**\n * Bound `InputField` from `useForm`. Single or multi value depending on schema.\n */\n input: BaseInputField;\n /**\n * Field label. Falls back to schema `title`.\n */\n label?: string;\n /**\n * Helper text shown below the input.\n */\n description?: string;\n /**\n * Render as a `<Segmented>` control (best for 2–4 options).\n */\n segmented?: boolean;\n /**\n * Render a multi-choice field (an array schema) as a group of checkboxes,\n * every option visible: for a handful of fixed choices (days of the week,\n * device types), where a select would hide what is ticked. Each checkbox\n * is named by its option's label and carries `data-value`.\n */\n checkboxes?: boolean;\n /**\n * Force the search input on. Kept as the historical name for\n * `searchable: true` — every select is a combobox now, the flag only\n * decides whether it carries a search field.\n */\n combobox?: boolean;\n /**\n * Whether the dropdown carries a search input. Defaults to \"auto\": on for a\n * long-mode `loader` (the rows are not all here), when `createNewEntry` is\n * set (typing IS how an entry is made), and for lists longer than\n * `SEARCH_THRESHOLD`. Set explicitly to search a short list or to drop the\n * search field from a long one.\n *\n * Multi-select obeys the same rule as everything else; it used to force the\n * field on because its chips box doubled as the search input.\n */\n searchable?: boolean;\n /**\n * Async option loader. Triggers long-mode (server-side search) above `loaderThreshold` options.\n */\n loader?: (search: string, resolve?: string[]) => Async<SelectOption[]>;\n /**\n * Option count above which `loader` is invoked on every search instead of once. Defaults to 100.\n */\n loaderThreshold?: number;\n /**\n * Debounce in ms applied to search queries when calling `loader` in long mode.\n */\n loaderDebounce?: number;\n /**\n * Disable the control.\n */\n disabled?: boolean;\n /**\n * Inline option list (overrides schema `enum`). Accepts either a static\n * array or an async function `(query) => SelectOption[]`. The async form\n * is mapped to a long-mode loader.\n */\n items?:\n | SelectOption[]\n | ((query: string) => SelectOption[] | Promise<SelectOption[]>);\n /**\n * Allow the user to add a new option by typing. When `true`, the typed\n * query becomes the value (and label) of a freshly created entry. When a\n * function, the function builds the option from the query.\n *\n * - For multi-select fields: each entry is appended to the value array.\n * - For single fields: behaves like a regular text input with a dropdown\n * suggesting existing options.\n */\n createNewEntry?: boolean | ((query: string) => Exclude<SelectOption, string>);\n /**\n * When true, the dropdown gets a synthetic \"none\" row at the top that\n * resets the field to `undefined`. Useful for optional filter chips\n * (e.g. an admin-table status filter) where the user needs an explicit\n * \"no filter\" option — Base UI's `Select` reserves empty-string values\n * as its internal no-selection sentinel, so a regular `<SelectItem\n * value=\"\">` can't be picked. With `clearable`, ControlSelect uses an\n * internal sentinel and translates it to `undefined` in `onChange`.\n *\n * Currently honored by the static-short `Select` and the searchable\n * Combobox render paths. Ignored by `segmented` (use a real segment\n * for \"all\" there).\n */\n clearable?: boolean;\n /**\n * Label rendered for the \"clear\" row injected by `clearable`. Also\n * used as the trigger placeholder when the field is empty. Defaults to\n * `\"None\"`. Localize at the call site (e.g. `\"All types\"`,\n * `\"All status\"`).\n */\n clearLabel?: string;\n /**\n * Trigger text for a multi-select whose selection is too long to name, e.g.\n * `(n) => \\`${n} status\\``. One selection always shows the value itself, so\n * this is only ever asked for two or more past `maxTriggerLength`. Defaults\n * to `\"{n} values\"`.\n */\n countLabel?: (count: number) => string;\n /**\n * The longest joined text, in characters, a multi-select trigger names its\n * selection with (\"Draft, Ready\") before it collapses to `countLabel`.\n * Defaults to 20, which suits a filter chip; a full-width form field has\n * room for more.\n */\n maxTriggerLength?: number;\n /**\n * Trigger text when nothing is selected, e.g. \"Pick an epic…\". Defaults to\n * the `clearLabel` on a `clearable` or multi field (where empty IS a\n * meaningful state to name), and to \"Select…\" otherwise.\n *\n * Set it when the empty trigger has a job to do - a picker whose whole\n * purpose is the choice it prompts for reads as a dead \"Select…\" without\n * it, which is why the surfaces that needed one stayed on the raw `Select`.\n */\n placeholder?: string;\n /**\n * Extra className applied to the visible trigger: the combobox button or\n * the segmented control, whichever this field renders. Useful for sizing\n * filter chips (`\"w-40\"`, `\"w-72\"`, etc.) without wrapping the whole\n * `FormField` in an extra div.\n */\n triggerClassName?: string;\n /**\n * Trigger height and type scale. Defaults to `default`.\n */\n size?: ControlSelectSize;\n /**\n * Render the trigger borderless and transparent, so it reads as the row it\n * sits on rather than as a form field.\n */\n minimal?: boolean;\n /**\n * Extra attributes for whichever trigger this field renders, forwarded from\n * `Control`'s `inputProps`.\n *\n * The accessible name usually lives here, because a filter is routinely\n * rendered with `label=\"\"` next to its own heading: with no `<label>` to\n * borrow a name from, a `role=combobox` button or a radiogroup has no name\n * at all. That is both an a11y hole and unaddressable from a\n * test, and it was silent, since `Control` accepted `inputProps` and then\n * dropped it on every select-shaped branch.\n */\n triggerProps?: HTMLAttributes<HTMLElement>;\n /**\n * Leading icon rendered on the left of the trigger, matching the\n * text-input controls. Resolved by the parent `Control` from its `icon`\n * prop, falling back to the list glyph like a text input falls back to\n * its schema hint; `icon={null}` on the `Control` removes it, and a\n * `minimal` trigger gets none by default.\n */\n icon?: IconComponent;\n /**\n * Drawn at the top of the popup, above the options - for a setting that\n * changes what the choice MEANS rather than what is chosen, such as a\n * filter's \"is / is not\".\n *\n * ⚠️ Only the combobox shape has a popup, so a segmented or radio rendering\n * of the same field draws nothing for it.\n */\n popupHeader?: ReactNode;\n /**\n * Drawn on the trigger just before the selected label, after the icon: the\n * short word that keeps a qualified value from reading as a plain one\n * (\"not Active\"). Absent while nothing is selected, because a qualifier on\n * a placeholder has nothing to qualify.\n */\n triggerPrefix?: ReactNode;\n /**\n * Extra className on the popup, merged over its own.\n *\n * The popup is sized from its trigger by default (`--anchor-width`), and it\n * keeps following that width while open. A trigger whose text changes as\n * the reader picks - a `triggerPrefix` appearing, \"2 values\" replacing a\n * name - therefore resizes the popup under their cursor. `w-max` with a\n * floor (`w-max min-w-48`) sizes it from its own content instead.\n */\n popupClassName?: string;\n}\n\nexport const ControlSelect = (props: ControlSelectProps) => {\n const { tr } = useI18n();\n const form = useFormState(props.input, [\"error\"]);\n const [value, setValue] = useFieldValue(props.input);\n\n const meta = parseField(props.input, {\n label: props.label,\n description: props.description,\n error: form.error,\n });\n\n const isArray = meta.isArray;\n const isNumeric = meta.type === \"number\" || meta.type === \"integer\";\n const isBoolean = meta.type === \"boolean\";\n\n // Normalize items prop: array → static; function → loader\n const itemsArray = Array.isArray(props.items)\n ? (props.items as SelectOption[])\n : undefined;\n const itemsLoader =\n typeof props.items === \"function\"\n ? (props.items as (q: string) => Async<SelectOption[]>)\n : undefined;\n\n const enumValues =\n itemsArray ?? (meta.enum as SelectOption[] | undefined) ?? [];\n\n const effectiveLoader = props.loader ?? itemsLoader;\n\n const {\n data: asyncData,\n loading,\n mode,\n search,\n } = useAsyncLoader(\n effectiveLoader,\n props.loaderThreshold ?? 100,\n props.loaderDebounce ?? 300,\n props.input.initialValue,\n );\n\n // Labels and `disabled` flags are part of the identity: keying on the\n // joined values alone collided (`[\"ab\",\"c\"]` vs `[\"a\",\"bc\"]`) and kept a\n // stale list when only the labels changed.\n //\n // ⚠️ `icon` is EXCLUDED, and it has to be. It is a `ReactNode`, and a\n // rendered element holds a fiber that points back at its DOM node, so\n // `JSON.stringify` on the raw option threw \"Converting circular structure\n // to JSON\" - a documented prop that crashed the component the first time\n // anyone used it (#Q2049). Two lists that differ only by icon share a key,\n // which is right: the key exists to notice a changed VALUE or LABEL.\n const enumKey = JSON.stringify(\n enumValues.map((option) =>\n typeof option === \"string\"\n ? option\n : {\n value: option.value,\n label: option.label,\n description: option.description,\n tag: option.tag,\n disabled: option.disabled,\n },\n ),\n );\n const min = meta.constraints.minimum;\n const max = meta.constraints.maximum;\n // Derived, not stored: this is a pure function of the schema. As state\n // filled in by an effect, the first paint of every boolean or ranged select\n // was an EMPTY list, corrected one render later.\n const staticData = useMemo<SelectOption[]>(() => {\n if (effectiveLoader) return [];\n if (isBoolean && enumValues.length === 0) {\n return [\n { value: \"true\", label: tr(\"controlSelect.yes\", { default: \"Yes\" }) },\n { value: \"false\", label: tr(\"controlSelect.no\", { default: \"No\" }) },\n ];\n }\n if (\n isNumeric &&\n enumValues.length === 0 &&\n typeof min === \"number\" &&\n typeof max === \"number\" &&\n max - min <= 20\n ) {\n const range: SelectOption[] = [];\n for (let i = min; i <= max; i++) range.push(String(i));\n return range;\n }\n return enumValues;\n }, [effectiveLoader, enumKey, isBoolean, isNumeric, min, max, tr]);\n\n const data = effectiveLoader ? asyncData : staticData;\n\n if (!props.input?.props) return null;\n\n const coerce = (raw: string): unknown => {\n if (isNumeric) return Number(raw);\n if (isBoolean) return raw === \"true\";\n return raw;\n };\n\n if (props.segmented) {\n return (\n <FormField\n id={meta.id}\n label={meta.label}\n description={meta.description}\n error={meta.error}\n required={meta.required}\n >\n {/* `triggerProps` is deliberately NOT spread here. `Segmented`\n redeclares two attributes that `HTMLAttributes` also has, with\n narrower types (`defaultValue` is string-only, `onChange` takes a\n value rather than an event), so a blanket spread neither typechecks\n nor is safe. A segmented field also renders every option as visible\n text, so it is the one branch that is not nameless without a label.\n Name it with `label` if it needs one. */}\n <Segmented\n value={value != null ? String(value) : undefined}\n onChange={(v) => setValue(coerce(v))}\n disabled={props.disabled}\n options={data.slice(0, 10).map((o) => ({\n value: optValue(o),\n label: segmentedLabel(o),\n }))}\n fullWidth\n />\n </FormField>\n );\n }\n\n if (props.checkboxes && isArray) {\n const ticked = Array.isArray(value) ? (value as unknown[]).map(String) : [];\n return (\n <FormField\n id={meta.id}\n label={meta.label}\n description={meta.description}\n error={meta.error}\n required={meta.required}\n >\n <div\n role=\"group\"\n aria-label={meta.label || undefined}\n {...props.triggerProps}\n id={meta.id}\n className=\"flex flex-wrap gap-x-4 gap-y-2 py-1\"\n >\n {data.map((o) => {\n const optionValue = optValue(o);\n const optionId = `${meta.id}-${optionValue}`;\n return (\n <label\n key={optionValue}\n htmlFor={optionId}\n className=\"flex items-center gap-2 text-sm\"\n >\n <Checkbox\n // An explicit id: Base UI would mint one with `useId`.\n id={optionId}\n data-value={optionValue}\n disabled={\n props.disabled || (typeof o !== \"string\" && o.disabled)\n }\n checked={ticked.includes(optionValue)}\n onCheckedChange={(checked) => {\n const next = checked\n ? [...ticked, optionValue]\n : ticked.filter((it) => it !== optionValue);\n // In the options' order, whatever order they were ticked.\n const ordered = data\n .map(optValue)\n .filter((it) => next.includes(it));\n setValue(ordered.map(coerce));\n }}\n />\n {segmentedLabel(o)}\n </label>\n );\n })}\n </div>\n </FormField>\n );\n }\n\n const clearLabel =\n props.clearLabel ?? tr(\"controlSelect.none\", { default: \"None\" });\n\n // One control for every list. The option count decides whether the popup\n // carries a search field — it no longer decides which primitive renders.\n // The native `Select` path this replaced silently dropped `description`,\n // `tag`, per-option `disabled` and `deselectable`, and styled its trigger\n // differently, purely because a list happened to be short.\n // A search field is offered only when scanning the list by eye stops being\n // realistic: a server-driven list (whose rows are not all here), one past\n // `SEARCH_THRESHOLD`, or one where typing is how a new entry is made.\n //\n // Multi-select used to force it on unconditionally, because the chips box\n // WAS the search input and there was no other way to open the popup. The\n // trigger is a button now, so multi obeys the same rule as everything else\n // and a four-row status filter no longer opens onto a search field.\n const searchable =\n props.searchable ??\n (props.combobox ||\n mode === \"long\" ||\n Boolean(props.createNewEntry) ||\n data.length > SEARCH_THRESHOLD);\n\n return (\n <FormField\n id={meta.id}\n label={meta.label}\n description={meta.description}\n error={meta.error}\n required={meta.required}\n >\n <ControlSelectCombobox\n id={meta.id}\n data={data}\n loading={loading}\n multi={isArray}\n searchable={searchable}\n disabled={props.disabled}\n value={value}\n onChange={(v) => setValue(v)}\n coerce={coerce}\n onSearch={mode === \"long\" ? (text) => search.run(text) : undefined}\n createNewEntry={props.createNewEntry}\n icon={props.icon}\n // Used to be dropped on this path, so a filter chip sized `w-40` lost\n // its width as soon as its list crossed the threshold.\n triggerClassName={props.triggerClassName}\n triggerProps={props.triggerProps}\n size={props.size}\n minimal={props.minimal}\n // `clearable` used to reach this path as a placeholder and nothing\n // else, so a filter chip that had switched to the combobox (>20\n // options) could be set but never put back to \"All …\".\n clearable={props.clearable}\n clearLabel={clearLabel}\n countLabel={props.countLabel}\n maxTriggerLength={props.maxTriggerLength}\n popupHeader={props.popupHeader}\n triggerPrefix={props.triggerPrefix}\n popupClassName={props.popupClassName}\n // An optional field must also be able to go back to empty without a\n // dedicated row: Base UI never emits `null`, so re-pressing the\n // selected row deselects (see `handleSingle` in\n // `ControlSelectCombobox.tsx`). A required field keeps its value —\n // clearing it would only produce a validation error the user cannot\n // see yet.\n deselectable={props.clearable || !meta.required}\n // Multi shows this muted when nothing is picked, so it reaches the\n // trigger whether or not the field is `clearable` — a multi-select\n // has no clear ROW (it clears by deselecting), and without this its\n // empty trigger fell back to a bare \"Select…\".\n placeholder={\n props.placeholder ??\n (props.clearable || isArray ? clearLabel : undefined)\n }\n />\n </FormField>\n );\n};\n\nexport type SelectOption =\n | string\n | {\n value: string;\n label: string;\n /**\n * Optional secondary line shown under the label in the dropdown.\n */\n description?: string;\n /**\n * Optional small badge rendered next to the label.\n */\n tag?: string;\n /**\n * Optional icon/element rendered before the label, in both the\n * dropdown row and (for single-select) the trigger when selected.\n */\n icon?: ReactNode;\n /**\n * When true, the row is non-interactive — can't be selected if\n * not selected, can't be deselected if selected. Useful for\n * default/mandatory entries (e.g. the base \"user\" role).\n */\n disabled?: boolean;\n };\n\ntype LoaderMode = \"static\" | \"short\" | \"long\";\n\n/**\n * How tall and how loud a select trigger is.\n *\n * The kit's own scale, kept under this name because `Control` and a long tail\n * of callers already spell it `size=\"xs\"` on a select. The table behind it,\n * and the trigger box it sizes, are `control-base/field-trigger`'s - shared\n * with the two calendar controls, which used to draw a button instead.\n */\nexport type ControlSelectSize = ControlTriggerSize;\n\n/**\n * Static option count above which the dropdown grows a search input. Below it\n * the very same combobox renders without one — the threshold decides whether\n * you can type, never which control you get.\n */\n// Past this many rows, scanning by eye stops being realistic and the popup\n// grows a search field. Raised 20 -> 50 with the multi-select rework: the old\n// value put a search box on lists a reader takes in at a glance.\nconst SEARCH_THRESHOLD = 50;\n\n/**\n * Friendly label for plain string options: \"optional\" → \"Optional\",\n * \"in_progress\" → \"In Progress\". Custom `{ value, label }` items pass through\n * untouched.\n */\nconst titlecase = (s: string) =>\n s.replace(/[_-]+/g, \" \").replace(/\\b\\w/g, (c) => c.toUpperCase());\n/**\n * What one segment shows.\n *\n * ⚠️ The option's `icon` is rendered HERE rather than dropped, which is what\n * this path did until #Q2049. `SegmentedOption.label` is a `ReactNode`, so\n * there was never a reason for it: an option list carrying icons for the\n * dropdown carried them for the segments too, and dropping them silently\n * made a caller choose between two shapes for one list.\n */\nconst segmentedLabel = (o: SelectOption): ReactNode => {\n if (typeof o === \"string\") {\n return titlecase(o);\n }\n if (!o.icon) {\n return o.label;\n }\n return (\n <span className=\"inline-flex items-center gap-1.5\">\n {o.icon}\n {o.label}\n </span>\n );\n};\n\nconst useAsyncLoader = (\n loader: ControlSelectProps[\"loader\"],\n threshold: number,\n debounceMs: number,\n defaultValue: unknown,\n) => {\n const [data, setData] = useState<SelectOption[]>([]);\n const [loading, setLoading] = useState(false);\n const [mode, setMode] = useState<LoaderMode>(\"static\");\n const cache = useRef(new Map<string, SelectOption[]>());\n\n useAction(\n {\n // `id`, not `name`: `id` is what useAction threads into its\n // react:action:* events. `name` was accepted and never read, so this\n // identifier reached nothing.\n id: \"select:loader:init\",\n runOnInit: true,\n handler: async () => {\n if (!loader) {\n setMode(\"static\");\n return;\n }\n setLoading(true);\n try {\n const result = await loader(\"\");\n const isShort = result.length <= threshold;\n setMode(isShort ? \"short\" : \"long\");\n cache.current.set(\"\", result);\n setData(result);\n\n // Coercion at a boundary: the value is a form/route/chart primitive whose\n // declared type is wider than what can reach here.\n // oxlint-disable-next-line typescript/no-base-to-string -- a coercion at a boundary, see the comment above\n if (!isShort && defaultValue != null && String(defaultValue) !== \"\") {\n // Coercion at a boundary: the value is a form/route/chart primitive whose\n // declared type is wider than what can reach here.\n // oxlint-disable-next-line typescript/no-base-to-string -- a coercion at a boundary, see the comment above\n const resolved = await loader(\"\", [String(defaultValue)]);\n if (resolved.length > 0) {\n setData((prev) => {\n const existing = new Set(prev.map(optValue));\n const fresh = resolved.filter(\n (r) => !existing.has(optValue(r)),\n );\n return [...prev, ...fresh];\n });\n }\n }\n } finally {\n setLoading(false);\n }\n },\n },\n [loader, threshold],\n );\n\n const search = useAction<[string]>(\n {\n debounce: debounceMs,\n handler: async (_ctx, text) => {\n if (!loader || mode !== \"long\") return;\n if (cache.current.has(text)) {\n setData(cache.current.get(text)!);\n return;\n }\n setLoading(true);\n try {\n const result = await loader(text);\n cache.current.set(text, result);\n setData(result);\n } finally {\n setLoading(false);\n }\n },\n },\n [loader, mode, debounceMs],\n );\n\n return { data, loading, mode, search };\n};\n"],"mappings":";;;;;;;;;;;AAgNA,MAAa,iBAAiB,UAA8B;CAC1D,MAAM,EAAE,OAAO,QAAQ;CACvB,MAAM,OAAO,aAAa,MAAM,OAAO,CAAC,OAAO,CAAC;CAChD,MAAM,CAAC,OAAO,YAAY,cAAc,MAAM,KAAK;CAEnD,MAAM,OAAO,WAAW,MAAM,OAAO;EACnC,OAAO,MAAM;EACb,aAAa,MAAM;EACnB,OAAO,KAAK;CACd,CAAC;CAED,MAAM,UAAU,KAAK;CACrB,MAAM,YAAY,KAAK,SAAS,YAAY,KAAK,SAAS;CAC1D,MAAM,YAAY,KAAK,SAAS;CAGhC,MAAM,aAAa,MAAM,QAAQ,MAAM,KAAK,IACvC,MAAM,QACP,KAAA;CACJ,MAAM,cACJ,OAAO,MAAM,UAAU,aAClB,MAAM,QACP,KAAA;CAEN,MAAM,aACJ,cAAe,KAAK,QAAuC,CA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IAChB,UAAU;KACR,WAAW,KAAK;IAClB;GACF;EACF,GACA;GAAC;GAAQ;GAAM;EAAU,CAGQ;CAAE;AACvC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uiFr.d.ts","sourceRoot":"","sources":["../../../src/i18n/fr/uiFr.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,eAAO,MAAM,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"uiFr.d.ts","sourceRoot":"","sources":["../../../src/i18n/fr/uiFr.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,eAAO,MAAM,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAutCvC,CAAC"}
|
package/dist/i18n/fr/uiFr.js
CHANGED
|
@@ -44,6 +44,19 @@
|
|
|
44
44
|
* the components already default to English.
|
|
45
45
|
*/
|
|
46
46
|
const uiFr = {
|
|
47
|
+
"ai.chat.approve": "Approuver",
|
|
48
|
+
"ai.chat.confirmTitle": "Exécuter $1 ?",
|
|
49
|
+
"ai.chat.deny": "Refuser",
|
|
50
|
+
"ai.chat.empty": "Posez une question sur cette page.",
|
|
51
|
+
"ai.chat.message": "Message",
|
|
52
|
+
"ai.chat.new": "Nouvelle conversation",
|
|
53
|
+
"ai.chat.placeholder": "Demandez à l'assistant",
|
|
54
|
+
"ai.chat.running": "Exécution de $1",
|
|
55
|
+
"ai.chat.send": "Envoyer",
|
|
56
|
+
"ai.chat.title": "Assistant",
|
|
57
|
+
"ai.chat.toolDone": "$1 exécuté",
|
|
58
|
+
"ai.chat.toolFailed": "Échec de $1",
|
|
59
|
+
"ai.chat.untitled": "Conversation sans titre",
|
|
47
60
|
"useDialog.cancel": "Annuler",
|
|
48
61
|
"useDialog.confirm": "Confirmer",
|
|
49
62
|
"useDialog.ok": "OK",
|
|
@@ -125,6 +138,9 @@ const uiFr = {
|
|
|
125
138
|
"controlArray.moveUp": "Monter",
|
|
126
139
|
"controlArray.remove": "Retirer",
|
|
127
140
|
"controlDate.placeholder": "Choisir une date",
|
|
141
|
+
"controlMonth.nextYear": "Année suivante",
|
|
142
|
+
"controlMonth.placeholder": "Choisir un mois",
|
|
143
|
+
"controlMonth.previousYear": "Année précédente",
|
|
128
144
|
"controlDateRange.placeholder": "Choisir une période",
|
|
129
145
|
"controlObject.clear": "Vider",
|
|
130
146
|
"controlObject.collapse": "Replier",
|
|
@@ -237,6 +253,11 @@ const uiFr = {
|
|
|
237
253
|
"nav.spotlight.empty": "Aucun résultat.",
|
|
238
254
|
"nav.spotlight.search": "Rechercher…",
|
|
239
255
|
"nav.spotlight.title": "Rechercher",
|
|
256
|
+
"nav.sidebar.collapse": "Replier la barre latérale",
|
|
257
|
+
"nav.sidebar.description": "Affiche la barre latérale mobile.",
|
|
258
|
+
"nav.sidebar.expand": "Déplier la barre latérale",
|
|
259
|
+
"nav.sidebar.title": "Barre latérale",
|
|
260
|
+
"nav.sidebar.toggle": "Afficher ou masquer la barre latérale",
|
|
240
261
|
"admin.analytics.addFilter": "filtre",
|
|
241
262
|
"admin.analytics.apply": "Appliquer",
|
|
242
263
|
"admin.analytics.axis": "axe",
|
|
@@ -247,9 +268,12 @@ const uiFr = {
|
|
|
247
268
|
"admin.analytics.changeValues": "Modifier les valeurs",
|
|
248
269
|
"admin.analytics.clear": "Effacer",
|
|
249
270
|
"admin.analytics.close": "Fermer",
|
|
271
|
+
"admin.analytics.coarsened": "Bords élargis",
|
|
272
|
+
"admin.analytics.coarsenedHint": "Un seau au bord de cette fenêtre la dépasse et a été lu en entier : des lectures juste hors de la fenêtre sont comptées. Les données plus anciennes sont dans des paliers plus grossiers.",
|
|
250
273
|
"admin.analytics.compareLastYearNote": "vs même fenêtre l'an dernier ($1)",
|
|
251
274
|
"admin.analytics.compareOffNote": "Aucune référence, les écarts sont masqués.",
|
|
252
275
|
"admin.analytics.comparePreviousNote": "vs $1 j précédents ($2)",
|
|
276
|
+
"admin.analytics.comparePreviousSpanNote": "vs les $1 précédents ($2)",
|
|
253
277
|
"admin.analytics.copied": "Copié",
|
|
254
278
|
"admin.analytics.copy": "Copier",
|
|
255
279
|
"admin.analytics.csv": "Télécharger le CSV",
|
|
@@ -257,11 +281,12 @@ const uiFr = {
|
|
|
257
281
|
"admin.analytics.empty": "Aucune donnée pour cette requête.",
|
|
258
282
|
"admin.analytics.emptyFiltered": "Assouplissez un filtre, ou élargissez la fenêtre.",
|
|
259
283
|
"admin.analytics.emptyHint": "Élargissez la fenêtre.",
|
|
284
|
+
"admin.analytics.grainLockedPoints": "$1 est verrouillé. Cette plage dessinerait plus de $2 seaux $1.",
|
|
285
|
+
"admin.analytics.grainLockedRetention": "$1 est verrouillé. $2 conserve ses seaux $1 moins longtemps que cette plage, et les lectures plus anciennes sont dans des seaux plus grossiers, qui ne fusionneraient pas.",
|
|
260
286
|
"admin.analytics.groupByKey": "grouper par $1",
|
|
261
287
|
"admin.analytics.hintEquality": "1 valeur, envoyée en égalité",
|
|
262
288
|
"admin.analytics.hintInArray": "$1 valeurs, envoyées en inArray",
|
|
263
289
|
"admin.analytics.hintPick": "choisissez-en une ou plusieurs",
|
|
264
|
-
"admin.analytics.hourLocked": "hour est verrouillé. $1 conserve les seaux horaires bruts pendant $2 jours, et une plage de $3 jours atteint le palier journalier agrégé. Ce sont des clés différentes, elles ne fusionneraient pas.",
|
|
265
290
|
"admin.analytics.labelBars": "barres",
|
|
266
291
|
"admin.analytics.labelDonut": "anneau",
|
|
267
292
|
"admin.analytics.labelHeat": "carte de chaleur",
|
|
@@ -275,6 +300,7 @@ const uiFr = {
|
|
|
275
300
|
"admin.analytics.noDatasets": "Aucun jeu de données analytics n'est déclaré dans cette application.",
|
|
276
301
|
"admin.analytics.noteDays": "$1 jours",
|
|
277
302
|
"admin.analytics.noteHeat": "$1 jours × 24 heures",
|
|
303
|
+
"admin.analytics.noteBuckets": "$1 seaux",
|
|
278
304
|
"admin.analytics.noteColumns": "$1 colonnes",
|
|
279
305
|
"admin.analytics.noteColumns.one": "1 colonne",
|
|
280
306
|
"admin.analytics.noteGroups": "$1 groupes",
|
|
@@ -289,6 +315,8 @@ const uiFr = {
|
|
|
289
315
|
"admin.analytics.pickDataset": "Choisir un jeu de données",
|
|
290
316
|
"admin.analytics.pickDimension": "Filtrer sur une dimension",
|
|
291
317
|
"admin.analytics.raiseLimit": "Monter à $1",
|
|
318
|
+
"admin.analytics.rangeFrom": "de",
|
|
319
|
+
"admin.analytics.rangeTo": "à",
|
|
292
320
|
"admin.analytics.removeFilter": "Retirer",
|
|
293
321
|
"admin.analytics.requestHonesty": "Chaque clé ici figure dans le schéma publié du jeu de données.",
|
|
294
322
|
"admin.analytics.requestItem": "Requête…",
|
|
@@ -309,6 +337,7 @@ const uiFr = {
|
|
|
309
337
|
"admin.analytics.shapeRank": "Classement",
|
|
310
338
|
"admin.analytics.shapeShare": "Part 100 %",
|
|
311
339
|
"admin.analytics.summaryDefaults": "jusqu'à hier · vs $1 j précédents · limite $2",
|
|
340
|
+
"admin.analytics.summaryInstant": "vs les $1 précédents · limite $2",
|
|
312
341
|
"admin.analytics.summaryLastYear": "vs l'an dernier",
|
|
313
342
|
"admin.analytics.summaryLimit": "limite $1",
|
|
314
343
|
"admin.analytics.summaryNoBaseline": "aucune référence",
|
|
@@ -321,6 +350,7 @@ const uiFr = {
|
|
|
321
350
|
"admin.analytics.valuesInWindow": "$1 dans la fenêtre",
|
|
322
351
|
"admin.analytics.vsLastYear": "vs l'an dernier",
|
|
323
352
|
"admin.analytics.vsPrevious": "vs $1 j précédents",
|
|
353
|
+
"admin.analytics.vsPreviousSpan": "vs les $1 précédents",
|
|
324
354
|
"admin.audits.actionAll": "Toutes les actions",
|
|
325
355
|
"admin.audits.bulkDelete": "Supprimer la sélection",
|
|
326
356
|
"admin.audits.bulkDeleteConfirm": "Supprimer $1 entrée(s) d'audit ? Ces journaux sont généralement conservés pour des raisons de conformité. L'opération est irréversible.",
|