@erxes/ui 4.0.0-v2.1 → 4.0.0-v2.10
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/AGENTS.md +58 -0
- package/CATALOG.md +251 -0
- package/README.md +25 -2
- package/dist/components/accordion.d.ts +1 -0
- package/dist/components/accordion.js +1 -0
- package/dist/components/alert-dialog.d.ts +4 -0
- package/dist/components/alert-dialog.js +4 -0
- package/dist/components/alert.d.ts +1 -0
- package/dist/components/alert.js +1 -0
- package/dist/components/avatar.d.ts +2 -0
- package/dist/components/avatar.js +1 -0
- package/dist/components/background-gradient-animation.d.ts +4 -1
- package/dist/components/background-gradient-animation.js +4 -1
- package/dist/components/badge.d.ts +3 -0
- package/dist/components/badge.js +2 -0
- package/dist/components/breadcrumb.d.ts +1 -0
- package/dist/components/breadcrumb.js +1 -0
- package/dist/components/button.d.ts +6 -1
- package/dist/components/button.js +5 -1
- package/dist/components/calendar.d.ts +5 -0
- package/dist/components/calendar.js +4 -0
- package/dist/components/card.d.ts +1 -0
- package/dist/components/card.js +1 -0
- package/dist/components/chart-config.d.ts +4 -1
- package/dist/components/charts.d.ts +6 -0
- package/dist/components/charts.js +12 -3
- package/dist/components/checkbox.d.ts +1 -0
- package/dist/components/checkbox.js +1 -0
- package/dist/components/choicebox-group.d.ts +1 -0
- package/dist/components/choicebox-group.js +1 -0
- package/dist/components/collapsible.d.ts +1 -0
- package/dist/components/collapsible.js +1 -0
- package/dist/components/color-picker.d.ts +1 -0
- package/dist/components/color-picker.js +13 -6
- package/dist/components/combobox.d.ts +6 -1
- package/dist/components/combobox.js +9 -1
- package/dist/components/command-bar.d.ts +4 -0
- package/dist/components/command-bar.js +4 -0
- package/dist/components/command.d.ts +4 -0
- package/dist/components/command.js +4 -0
- package/dist/components/context-menu.d.ts +1 -0
- package/dist/components/context-menu.js +1 -0
- package/dist/components/copy-text.d.ts +1 -0
- package/dist/components/copy-text.js +1 -0
- package/dist/components/date-picker-value.d.ts +5 -9
- package/dist/components/date-picker-value.js +15 -34
- package/dist/components/date-picker.d.ts +4 -4
- package/dist/components/date-picker.js +9 -7
- package/dist/components/date-text-input.d.ts +2 -4
- package/dist/components/date-text-input.js +11 -9
- package/dist/components/dialog.d.ts +4 -0
- package/dist/components/dialog.js +5 -1
- package/dist/components/drag-handle.d.ts +1 -0
- package/dist/components/drag-handle.js +1 -0
- package/dist/components/dropdown-menu.d.ts +1 -0
- package/dist/components/dropdown-menu.js +1 -0
- package/dist/components/empty.d.ts +6 -1
- package/dist/components/empty.js +25 -2
- package/dist/components/form.d.ts +6 -2
- package/dist/components/form.js +8 -2
- package/dist/components/hover-card.d.ts +1 -0
- package/dist/components/hover-card.js +1 -0
- package/dist/components/icon-tip.d.ts +7 -0
- package/dist/components/icon-tip.js +16 -0
- package/dist/components/info-card.d.ts +4 -0
- package/dist/components/info-card.js +4 -0
- package/dist/components/input-group.d.ts +5 -4
- package/dist/components/input-group.js +5 -4
- package/dist/components/input.d.ts +1 -0
- package/dist/components/input.js +1 -0
- package/dist/components/kbd.d.ts +2 -1
- package/dist/components/kbd.js +2 -1
- package/dist/components/label.d.ts +1 -1
- package/dist/components/label.js +1 -1
- package/dist/components/multiselect.d.ts +1 -0
- package/dist/components/multiselect.js +3 -2
- package/dist/components/on-demand.d.ts +6 -0
- package/dist/components/on-demand.js +6 -0
- package/dist/components/popover.d.ts +4 -0
- package/dist/components/popover.js +4 -0
- package/dist/components/radio-group.d.ts +1 -0
- package/dist/components/radio-group.js +1 -0
- package/dist/components/scroll-area.d.ts +1 -0
- package/dist/components/scroll-area.js +1 -0
- package/dist/components/select.d.ts +5 -1
- package/dist/components/select.js +7 -1
- package/dist/components/separator.d.ts +4 -0
- package/dist/components/separator.js +4 -0
- package/dist/components/sheet.d.ts +4 -0
- package/dist/components/sheet.js +8 -4
- package/dist/components/sidebar/panel.js +29 -7
- package/dist/components/sidebar.d.ts +1 -0
- package/dist/components/sidebar.js +1 -0
- package/dist/components/skeleton.d.ts +1 -0
- package/dist/components/skeleton.js +1 -0
- package/dist/components/spinner.d.ts +1 -0
- package/dist/components/spinner.js +1 -0
- package/dist/components/string-array.js +1 -0
- package/dist/components/switch.d.ts +1 -0
- package/dist/components/switch.js +1 -0
- package/dist/components/table.d.ts +4 -0
- package/dist/components/table.js +4 -0
- package/dist/components/tabs.d.ts +8 -1
- package/dist/components/tabs.js +8 -1
- package/dist/components/text-overflow.d.ts +4 -1
- package/dist/components/text-overflow.js +4 -1
- package/dist/components/textarea.d.ts +1 -0
- package/dist/components/textarea.js +1 -0
- package/dist/components/toaster.d.ts +4 -1
- package/dist/components/toaster.js +5 -2
- package/dist/components/toggle-group.d.ts +5 -0
- package/dist/components/toggle-group.js +19 -11
- package/dist/components/toggle.d.ts +1 -0
- package/dist/components/toggle.js +1 -0
- package/dist/components/tooltip.d.ts +4 -0
- package/dist/components/tooltip.js +4 -0
- package/dist/components/upload.d.ts +4 -0
- package/dist/components/upload.js +20 -11
- package/dist/federation.d.ts +8 -1
- package/dist/federation.js +12 -2
- package/dist/hooks/use-item-keys.d.ts +11 -0
- package/dist/hooks/use-item-keys.js +24 -0
- package/dist/hooks/use-page-hotkey.d.ts +12 -0
- package/dist/hooks/use-page-hotkey.js +22 -0
- package/dist/hooks/use-toast.d.ts +5 -0
- package/dist/hooks/use-toast.js +5 -0
- package/dist/index.d.ts +33 -6
- package/dist/index.js +31 -4
- package/dist/lib/format.d.ts +60 -0
- package/dist/lib/format.js +86 -0
- package/dist/lib/money.d.ts +13 -0
- package/dist/lib/money.js +21 -0
- package/dist/lib/stored.d.ts +13 -0
- package/dist/lib/stored.js +41 -0
- package/dist/lib/text.d.ts +11 -0
- package/dist/lib/text.js +18 -0
- package/dist/modules/attachments/use-carousel.js +5 -10
- package/dist/modules/blocks/hooks/useBarcodeSizeForm.d.ts +1 -1
- package/dist/modules/blocks/utils/parseBlocks.d.ts +1 -1
- package/dist/modules/blocks/utils/parseBlocks.js +1 -1
- package/dist/modules/conditions/ConditionValueInput.d.ts +10 -0
- package/dist/modules/conditions/ConditionValueInput.js +166 -0
- package/dist/modules/conditions/ConditionsEditor.d.ts +11 -0
- package/dist/modules/conditions/ConditionsEditor.js +209 -0
- package/dist/modules/conditions/LazyConditionsEditor.d.ts +10 -0
- package/dist/modules/conditions/LazyConditionsEditor.js +11 -0
- package/dist/modules/conditions/PathPicker.d.ts +8 -0
- package/dist/modules/conditions/PathPicker.js +51 -0
- package/dist/modules/conditions/conditions.d.ts +66 -0
- package/dist/modules/conditions/conditions.js +136 -0
- package/dist/modules/display/components/EmailDisplay.d.ts +4 -0
- package/dist/modules/display/components/EmailDisplay.js +6 -3
- package/dist/modules/display/components/PhoneDisplay.d.ts +4 -0
- package/dist/modules/display/components/PhoneDisplay.js +4 -0
- package/dist/modules/display/components/RelativeDateDisplay.d.ts +7 -5
- package/dist/modules/display/components/RelativeDateDisplay.js +10 -8
- package/dist/modules/display/components/SexDisplay.d.ts +1 -0
- package/dist/modules/display/components/SexDisplay.js +1 -0
- package/dist/modules/filter/components/Filter.d.ts +4 -0
- package/dist/modules/filter/components/Filter.js +4 -0
- package/dist/modules/filter/components/FilterBar.js +5 -7
- package/dist/modules/filter/components/FilterDialog.js +4 -5
- package/dist/modules/filter/components/FilterPopover.js +1 -1
- package/dist/modules/filter/components/FilterProvider.d.ts +1 -2
- package/dist/modules/filter/components/FilterProvider.js +22 -16
- package/dist/modules/filter/hooks/useFilterContext.d.ts +1 -0
- package/dist/modules/filter/hooks/useFilterContext.js +1 -0
- package/dist/modules/filter/types/filter.d.ts +0 -1
- package/dist/modules/hotkey/components/PopoverScoped.d.ts +5 -0
- package/dist/modules/hotkey/components/PopoverScoped.js +5 -0
- package/dist/modules/hotkey/hooks/usePreviousHotkeyScope.d.ts +1 -0
- package/dist/modules/hotkey/hooks/usePreviousHotkeyScope.js +1 -0
- package/dist/modules/hotkey/hooks/useScopedHotkeys.d.ts +5 -1
- package/dist/modules/hotkey/hooks/useScopedHotkeys.js +5 -1
- package/dist/modules/icons/components/IconComponent.d.ts +4 -0
- package/dist/modules/icons/components/IconComponent.js +4 -0
- package/dist/modules/icons/components/IconPicker.d.ts +4 -0
- package/dist/modules/icons/components/IconPicker.js +7 -5
- package/dist/modules/icons/providers/IconsProvider.d.ts +1 -0
- package/dist/modules/icons/providers/IconsProvider.js +1 -0
- package/dist/modules/inputs/components/EmailField.d.ts +4 -1
- package/dist/modules/inputs/components/EmailField.js +4 -1
- package/dist/modules/inputs/components/FullNameField.d.ts +6 -0
- package/dist/modules/inputs/components/FullNameField.js +20 -8
- package/dist/modules/inputs/components/PhoneField.d.ts +4 -1
- package/dist/modules/inputs/components/PhoneField.js +4 -1
- package/dist/modules/inputs/components/SexField.d.ts +1 -0
- package/dist/modules/inputs/components/SexField.js +1 -0
- package/dist/modules/layout/components/AppLayout.d.ts +6 -6
- package/dist/modules/layout/components/AppLayout.js +12 -13
- package/dist/modules/layout/components/AppLayoutResizeHandle.d.ts +5 -12
- package/dist/modules/layout/components/AppLayoutResizeHandle.js +15 -18
- package/dist/modules/layout/components/Page.d.ts +5 -0
- package/dist/modules/layout/components/Page.js +5 -0
- package/dist/modules/layout/components/PageHeader.d.ts +4 -1
- package/dist/modules/layout/components/PageHeader.js +9 -3
- package/dist/modules/list/DisplayMenu.d.ts +24 -0
- package/dist/modules/list/DisplayMenu.js +87 -0
- package/dist/modules/list/ListFilter.d.ts +63 -0
- package/dist/modules/list/ListFilter.js +44 -0
- package/dist/modules/list/ViewBar.d.ts +13 -0
- package/dist/modules/list/ViewBar.js +30 -0
- package/dist/modules/list/filter/AdvancedFilterDialog.d.ts +5 -0
- package/dist/modules/list/filter/AdvancedFilterDialog.js +52 -0
- package/dist/modules/list/filter/FieldMenus.d.ts +5 -0
- package/dist/modules/list/filter/FieldMenus.js +184 -0
- package/dist/modules/list/filter/ListFilterBar.d.ts +6 -0
- package/dist/modules/list/filter/ListFilterBar.js +246 -0
- package/dist/modules/list/filter/RecordCount.d.ts +7 -0
- package/dist/modules/list/filter/RecordCount.js +22 -0
- package/dist/modules/list/filter/RuleChips.d.ts +2 -0
- package/dist/modules/list/filter/RuleChips.js +157 -0
- package/dist/modules/list/filter/fieldIcons.d.ts +7 -0
- package/dist/modules/list/filter/fieldIcons.js +16 -0
- package/dist/modules/list/filter/filterRules.d.ts +46 -0
- package/dist/modules/list/filter/filterRules.js +166 -0
- package/dist/modules/list/filter/listFilterContext.d.ts +29 -0
- package/dist/modules/list/filter/listFilterContext.js +34 -0
- package/dist/modules/list/filter/listFilterQuery.d.ts +16 -0
- package/dist/modules/list/filter/listFilterQuery.js +22 -0
- package/dist/modules/navigation-menu/components/NavigationMenu.d.ts +4 -3
- package/dist/modules/navigation-menu/components/NavigationMenu.js +7 -7
- package/dist/modules/pickers/EntityPicker.d.ts +37 -0
- package/dist/modules/pickers/EntityPicker.js +67 -0
- package/dist/modules/pickers/LookupPicker.d.ts +51 -0
- package/dist/modules/pickers/LookupPicker.js +84 -0
- package/dist/modules/pickers/SelectMember.d.ts +41 -0
- package/dist/modules/pickers/SelectMember.js +122 -0
- package/dist/modules/pickers/members.d.ts +30 -0
- package/dist/modules/pickers/members.js +18 -0
- package/dist/modules/record-field/components/NumberField.d.ts +5 -0
- package/dist/modules/record-field/components/NumberField.js +14 -7
- package/dist/modules/record-field/components/TextField.d.ts +4 -0
- package/dist/modules/record-field/components/TextField.js +14 -3
- package/dist/modules/record-field/meta-inputs/components/PhoneInput.d.ts +5 -0
- package/dist/modules/record-field/meta-inputs/components/PhoneInput.js +5 -0
- package/dist/modules/record-list/RecordList.d.ts +18 -0
- package/dist/modules/record-list/RecordList.js +23 -0
- package/dist/modules/record-list/RecordListProvider.d.ts +30 -0
- package/dist/modules/record-list/RecordListProvider.js +57 -0
- package/dist/modules/record-list/RecordListRoot.d.ts +28 -0
- package/dist/modules/record-list/RecordListRoot.js +124 -0
- package/dist/modules/record-list/selection.d.ts +22 -0
- package/dist/modules/record-list/selection.js +54 -0
- package/dist/modules/record-panel/PanelDescriptionEditor.d.ts +9 -0
- package/dist/modules/record-panel/PanelDescriptionEditor.js +39 -0
- package/dist/modules/record-panel/PanelDescriptionField.d.ts +13 -0
- package/dist/modules/record-panel/PanelDescriptionField.js +39 -0
- package/dist/modules/record-panel/PanelField.d.ts +17 -0
- package/dist/modules/record-panel/PanelField.js +47 -0
- package/dist/modules/record-panel/PanelForm.d.ts +22 -0
- package/dist/modules/record-panel/PanelForm.js +81 -0
- package/dist/modules/record-panel/PanelLabel.d.ts +10 -0
- package/dist/modules/record-panel/PanelLabel.js +55 -0
- package/dist/modules/record-panel/PanelSection.d.ts +12 -0
- package/dist/modules/record-panel/PanelSection.js +24 -0
- package/dist/modules/record-panel/panelExpansion.d.ts +10 -0
- package/dist/modules/record-panel/panelExpansion.js +7 -0
- package/dist/modules/record-panel/useSaveOnLeave.d.ts +14 -0
- package/dist/modules/record-panel/useSaveOnLeave.js +42 -0
- package/dist/modules/record-table/components/RecordTable.d.ts +6 -0
- package/dist/modules/record-table/components/RecordTable.js +6 -0
- package/dist/modules/record-table/components/RecordTableCell.d.ts +9 -0
- package/dist/modules/record-table/components/RecordTableCell.js +16 -2
- package/dist/modules/record-table/components/RecordTableCellInline.d.ts +5 -0
- package/dist/modules/record-table/components/RecordTableCellInline.js +8 -7
- package/dist/modules/record-table/components/RecordTableCursor.js +30 -28
- package/dist/modules/record-table/components/RecordTableProvider.js +12 -7
- package/dist/modules/record-table/hooks/useTablePreferences.d.ts +1 -1
- package/dist/modules/record-table/hooks/useTablePreferences.js +18 -31
- package/dist/modules/record-table/states/RecordTableCursorState.d.ts +21 -1
- package/dist/modules/record-table/states/RecordTableCursorState.js +21 -3
- package/dist/modules/record-table/types/RecordTableCursorTypes.d.ts +1 -0
- package/dist/modules/record-table/types/RecordTableCursorTypes.js +1 -0
- package/dist/modules/records/ContactLink.d.ts +13 -0
- package/dist/modules/records/ContactLink.js +77 -0
- package/dist/modules/records/contacts.d.ts +35 -0
- package/dist/modules/records/contacts.js +10 -0
- package/dist/modules/records/openRecord.d.ts +44 -0
- package/dist/modules/records/openRecord.js +48 -0
- package/dist/state/sidebarPanelState.d.ts +5 -1
- package/dist/state/sidebarPanelState.js +11 -3
- package/dist/state/themeState.d.ts +13 -2
- package/dist/state/themeState.js +18 -4
- package/dist/theme.css +5 -2
- package/dist/types/SexCode.d.ts +1 -0
- package/dist/types/SexCode.js +1 -0
- package/dist/types/UIConfig.d.ts +131 -3
- package/dist/utils/IsUndefinedOrNull.d.ts +1 -0
- package/dist/utils/IsUndefinedOrNull.js +1 -0
- package/dist/utils/file-storage.d.ts +1 -0
- package/dist/utils/file-storage.js +1 -0
- package/dist/utils/format/formatPhoneNumber.d.ts +4 -0
- package/dist/utils/format/formatPhoneNumber.js +4 -0
- package/dist/utils/getPluginAssetsUrl.d.ts +5 -0
- package/dist/utils/getPluginAssetsUrl.js +5 -0
- package/dist/utils/host-component.d.ts +10 -0
- package/dist/utils/host-component.js +34 -0
- package/dist/utils/json.d.ts +3 -2
- package/dist/utils/json.js +3 -2
- package/dist/utils/plugin-runtime.d.ts +21 -17
- package/dist/utils/plugin-runtime.js +59 -12
- package/dist/utils/plugin-styles.d.ts +7 -0
- package/dist/utils/plugin-styles.js +54 -0
- package/dist/utils/record-timeline.d.ts +10 -9
- package/dist/utils/record-timeline.js +12 -17
- package/exports.txt +226 -0
- package/package.json +13 -3
- package/dist/constants/IntlLanguages.d.ts +0 -74
- package/dist/constants/IntlLanguages.js +0 -76
- package/dist/hooks/use-query-state.d.ts +0 -16
- package/dist/hooks/use-query-state.js +0 -122
- package/dist/modules/filter/hooks/useFilterQueryState.d.ts +0 -4
- package/dist/modules/filter/hooks/useFilterQueryState.js +0 -14
- package/dist/types/Theme.d.ts +0 -1
- package/dist/types/Theme.js +0 -0
- package/dist/utils/localization/formatDateISOStringToRelativeDate.d.ts +0 -2
- package/dist/utils/localization/formatDateISOStringToRelativeDate.js +0 -16
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { useFormat } from "../lib/format.js";
|
|
1
2
|
import { cn } from "../lib/utils.js";
|
|
2
3
|
import { ChartContext, configFor, fillOf, keyOf, useChart } from "./chart-config.js";
|
|
3
4
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
-
import "react";
|
|
5
|
+
import React from "react";
|
|
5
6
|
import * as RechartsPrimitive from "recharts";
|
|
6
7
|
// src/components/charts.tsx
|
|
7
8
|
/** The series colours as `--color-<key>` variables. */
|
|
@@ -10,10 +11,15 @@ const colorVariables = (config) => {
|
|
|
10
11
|
for (const [key, { color }] of Object.entries(config)) if (color) variables[`--color-${key}`] = color;
|
|
11
12
|
return variables;
|
|
12
13
|
};
|
|
14
|
+
/**
|
|
15
|
+
* The frame for a recharts chart: size, theme and series colours.
|
|
16
|
+
* Each `config` colour becomes a `--color-<key>` variable the chart's parts can use.
|
|
17
|
+
*/
|
|
13
18
|
const ChartContainer = ({ ref, className, children, config, style, ...props }) => {
|
|
14
19
|
const cssVariables = colorVariables(config);
|
|
20
|
+
const chart = React.useMemo(() => ({ config }), [config]);
|
|
15
21
|
return /* @__PURE__ */ jsx(ChartContext.Provider, {
|
|
16
|
-
value:
|
|
22
|
+
value: chart,
|
|
17
23
|
children: /* @__PURE__ */ jsx("div", {
|
|
18
24
|
ref,
|
|
19
25
|
style: {
|
|
@@ -48,6 +54,7 @@ const TooltipIndicator = ({ indicator, color, nested }) => /* @__PURE__ */ jsx("
|
|
|
48
54
|
});
|
|
49
55
|
const TooltipRow = ({ item, index, payload, props, label }) => {
|
|
50
56
|
const { config } = useChart();
|
|
57
|
+
const fmt = useFormat();
|
|
51
58
|
const { indicator = "dot", formatter } = props;
|
|
52
59
|
const nested = label !== null;
|
|
53
60
|
const itemConfig = configFor(config, item, keyOf(props.nameKey, item.name, item.dataKey));
|
|
@@ -66,10 +73,11 @@ const TooltipRow = ({ item, index, payload, props, label }) => {
|
|
|
66
73
|
})]
|
|
67
74
|
}), item.value !== void 0 && /* @__PURE__ */ jsx("span", {
|
|
68
75
|
className: "font-mono font-medium tabular-nums text-foreground",
|
|
69
|
-
children: item.value.
|
|
76
|
+
children: typeof item.value === "number" ? fmt.number(item.value) : String(item.value)
|
|
70
77
|
})]
|
|
71
78
|
})] });
|
|
72
79
|
};
|
|
80
|
+
/** The themed body for a recharts `Tooltip`, labelled from the config. */
|
|
73
81
|
const ChartTooltipContent = ({ ref, ...props }) => {
|
|
74
82
|
const { active, payload, className, indicator = "dot", hideLabel = false } = props;
|
|
75
83
|
if (!active || !payload?.length) return null;
|
|
@@ -96,6 +104,7 @@ const ChartTooltipContent = ({ ref, ...props }) => {
|
|
|
96
104
|
})]
|
|
97
105
|
});
|
|
98
106
|
};
|
|
107
|
+
/** The themed body for a recharts `Legend`: each series' icon and label. */
|
|
99
108
|
const ChartLegendContent = ({ ref, className, hideIcon = false, payload, verticalAlign = "bottom", nameKey }) => {
|
|
100
109
|
const { config } = useChart();
|
|
101
110
|
if (!payload?.length) return null;
|
|
@@ -2,6 +2,7 @@ import { cn } from "../lib/utils.js";
|
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
import { Checkbox as Checkbox$1 } from "@base-ui/react/checkbox";
|
|
4
4
|
// src/components/checkbox.tsx
|
|
5
|
+
/** A themed checkbox; pass `indeterminate` for a partial selection. */
|
|
5
6
|
const Checkbox = ({ className, ...props }) => /* @__PURE__ */ jsx(Checkbox$1.Root, {
|
|
6
7
|
className: cn("peer inline-flex items-center justify-center size-4 shrink-0 rounded border border-scroll outline-offset-2 focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-ring/70 data-disabled:cursor-not-allowed data-disabled:opacity-50 data-checked:border-primary data-indeterminate:border-primary data-checked:bg-primary data-indeterminate:bg-primary data-checked:text-primary-foreground data-indeterminate:text-primary-foreground bg-background", className),
|
|
7
8
|
...props,
|
|
@@ -13,6 +13,7 @@ interface ChoiceboxItemProps extends Omit<ComponentPropsWithoutRef<'div'>, 'titl
|
|
|
13
13
|
children: ReactNode;
|
|
14
14
|
}
|
|
15
15
|
declare const ChoiceboxItem: ({ ref, className, value, title, disabled, children }: ChoiceboxItemProps & React.RefAttributes<HTMLLabelElement>) => import("react").JSX.Element;
|
|
16
|
+
/** Radio choices drawn as large tiles with a title and text. */
|
|
16
17
|
export declare const ChoiceboxGroup: typeof ChoiceboxGroupRoot & {
|
|
17
18
|
Item: typeof ChoiceboxItem;
|
|
18
19
|
};
|
|
@@ -38,5 +38,6 @@ const ChoiceboxItem = ({ ref, className, value, title, disabled, children }) =>
|
|
|
38
38
|
})]
|
|
39
39
|
}, `${id}-${value}`);
|
|
40
40
|
};
|
|
41
|
+
/** Radio choices drawn as large tiles with a title and text. */
|
|
41
42
|
const ChoiceboxGroup = Object.assign(ChoiceboxGroupRoot, { Item: ChoiceboxItem });
|
|
42
43
|
export { ChoiceboxGroup };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { IconCaretDownFilled } from "@tabler/icons-react";
|
|
2
2
|
import React from "react";
|
|
3
3
|
declare const TriggerIcon: ({ className, ...props }: React.ComponentProps<typeof IconCaretDownFilled>) => React.JSX.Element;
|
|
4
|
+
/** One section that folds open and shut, with a caret icon for its trigger. */
|
|
4
5
|
export declare const Collapsible: React.ForwardRefExoticComponent<Omit<import("@base-ui/react").CollapsibleRootProps, "ref"> & React.RefAttributes<HTMLDivElement>> & {
|
|
5
6
|
Trigger: React.ForwardRefExoticComponent<Omit<import("@base-ui/react").CollapsibleTriggerProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
6
7
|
TriggerIcon: typeof TriggerIcon;
|
|
@@ -8,6 +8,7 @@ const TriggerIcon = ({ className, ...props }) => /* @__PURE__ */ jsx(IconCaretDo
|
|
|
8
8
|
className: cn("transition-transform duration-100 group-data-closed:-rotate-90", className),
|
|
9
9
|
...props
|
|
10
10
|
});
|
|
11
|
+
/** One section that folds open and shut, with a caret icon for its trigger. */
|
|
11
12
|
const Collapsible = Object.assign(Collapsible$1.Root, {
|
|
12
13
|
Trigger: Collapsible$1.Trigger,
|
|
13
14
|
TriggerIcon,
|
|
@@ -19,6 +19,7 @@ declare const ColorPickerRoot: ({ ref, value, onValueChange, colors, scope, clas
|
|
|
19
19
|
colors?: Record<string, string>;
|
|
20
20
|
scope?: string;
|
|
21
21
|
} & React.RefAttributes<React.ComponentRef<typeof Combobox.TriggerBase>>) => React.JSX.Element;
|
|
22
|
+
/** A swatch button that opens preset colours and a hex input in a popover. */
|
|
22
23
|
export declare const ColorPicker: typeof ColorPickerRoot & {
|
|
23
24
|
Provider: typeof ColorPickerProvider;
|
|
24
25
|
Trigger: typeof ColorPickerTrigger;
|
|
@@ -5,7 +5,7 @@ import { cn } from "../lib/utils.js";
|
|
|
5
5
|
import { PopoverScoped } from "../modules/hotkey/components/PopoverScoped.js";
|
|
6
6
|
import { IconCheck, IconChevronDown } from "@tabler/icons-react";
|
|
7
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
-
import { createContext, useContext, useState } from "react";
|
|
8
|
+
import { createContext, useContext, useMemo, useState } from "react";
|
|
9
9
|
import { IMaskInput } from "react-imask";
|
|
10
10
|
// src/components/color-picker.tsx
|
|
11
11
|
const DEFAULT_COLORS = {
|
|
@@ -33,12 +33,17 @@ const useColorPickerContext = () => {
|
|
|
33
33
|
return context;
|
|
34
34
|
};
|
|
35
35
|
const ColorPickerProvider = ({ children, value, onValueChange, colors = DEFAULT_COLORS, open, onOpenChange, scope }) => {
|
|
36
|
+
const picker = useMemo(() => ({
|
|
37
|
+
value,
|
|
38
|
+
onValueChange,
|
|
39
|
+
colors
|
|
40
|
+
}), [
|
|
41
|
+
value,
|
|
42
|
+
onValueChange,
|
|
43
|
+
colors
|
|
44
|
+
]);
|
|
36
45
|
return /* @__PURE__ */ jsx(ColorPickerContext.Provider, {
|
|
37
|
-
value:
|
|
38
|
-
value,
|
|
39
|
-
onValueChange,
|
|
40
|
-
colors
|
|
41
|
-
},
|
|
46
|
+
value: picker,
|
|
42
47
|
children: /* @__PURE__ */ jsx(PopoverScoped, {
|
|
43
48
|
scope,
|
|
44
49
|
open,
|
|
@@ -83,6 +88,7 @@ const ColorPickerContent = ({ setOpen }) => {
|
|
|
83
88
|
style: { "--swatch": value },
|
|
84
89
|
children: [/* @__PURE__ */ jsx("input", {
|
|
85
90
|
type: "color",
|
|
91
|
+
"aria-label": "Custom color",
|
|
86
92
|
value: value || "#000000",
|
|
87
93
|
className: "absolute inset-0 w-full h-full opacity-0 cursor-pointer",
|
|
88
94
|
onChange: (e) => onValueChange?.(e.target.value)
|
|
@@ -122,6 +128,7 @@ const ColorPickerRoot = ({ ref, value, onValueChange, colors, scope, className,
|
|
|
122
128
|
}), /* @__PURE__ */ jsx(ColorPickerContent, { setOpen })]
|
|
123
129
|
});
|
|
124
130
|
};
|
|
131
|
+
/** A swatch button that opens preset colours and a hex input in a popover. */
|
|
125
132
|
const ColorPicker = Object.assign(ColorPickerRoot, {
|
|
126
133
|
Provider: ColorPickerProvider,
|
|
127
134
|
Trigger: ColorPickerTrigger,
|
|
@@ -7,7 +7,7 @@ type ComboboxTriggerProps = Omit<React.ComponentProps<typeof Button>, 'variant'>
|
|
|
7
7
|
variant?: React.ComponentProps<typeof Button>['variant'] | 'bordered';
|
|
8
8
|
hideChevron?: boolean;
|
|
9
9
|
};
|
|
10
|
-
declare const ComboboxTriggerBase: ({ ref, className, children, hideChevron, variant, ...props }: ComboboxTriggerProps) => React.JSX.Element;
|
|
10
|
+
declare const ComboboxTriggerBase: ({ ref, className, children, hideChevron, variant, id, ...props }: ComboboxTriggerProps) => React.JSX.Element;
|
|
11
11
|
declare const ComboboxTrigger: ({ ref, children, hideChevron, ...props }: ComboboxTriggerProps) => React.JSX.Element;
|
|
12
12
|
declare const ComboboxValue: ({ ref, value, className, placeholder, loading, ...props }: React.HTMLAttributes<HTMLSpanElement> & {
|
|
13
13
|
placeholder?: string;
|
|
@@ -35,6 +35,11 @@ declare const ComboboxEmpty: ({ ref, className, loading, error, ...props }: Reac
|
|
|
35
35
|
loading?: boolean;
|
|
36
36
|
error?: Pick<Error, 'message'> | null;
|
|
37
37
|
}) => React.JSX.Element;
|
|
38
|
+
/**
|
|
39
|
+
* Parts of a popover picker: trigger, value, content, check, load-more.
|
|
40
|
+
* Put a `Command` inside `Combobox.Content` for the searchable list. `ChipTrigger` is the
|
|
41
|
+
* labelled chip a filter bar uses.
|
|
42
|
+
*/
|
|
38
43
|
export declare const Combobox: {
|
|
39
44
|
TriggerBase: typeof ComboboxTriggerBase;
|
|
40
45
|
Trigger: typeof ComboboxTrigger;
|
|
@@ -4,14 +4,17 @@ import { Popover } from "./popover.js";
|
|
|
4
4
|
import { Command } from "./command.js";
|
|
5
5
|
import { Skeleton } from "./skeleton.js";
|
|
6
6
|
import { Spinner } from "./spinner.js";
|
|
7
|
+
import { useCellLabel } from "../modules/record-table/components/RecordTableCell.js";
|
|
7
8
|
import { IconCheck, IconChevronDown, IconX } from "@tabler/icons-react";
|
|
8
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
10
|
import "react";
|
|
10
11
|
import { useOnInView } from "react-intersection-observer";
|
|
11
12
|
// src/components/combobox.tsx
|
|
12
|
-
const ComboboxTriggerBase = ({ ref, className, children, hideChevron = false, variant = "outline", ...props }) => {
|
|
13
|
+
const ComboboxTriggerBase = ({ ref, className, children, hideChevron = false, variant = "outline", id, ...props }) => {
|
|
14
|
+
const label = useCellLabel(id);
|
|
13
15
|
return /* @__PURE__ */ jsx(Popover.Trigger, {
|
|
14
16
|
render: /* @__PURE__ */ jsx(Button, {
|
|
17
|
+
...label,
|
|
15
18
|
ref,
|
|
16
19
|
variant: variant === "bordered" ? "outline" : variant,
|
|
17
20
|
...props,
|
|
@@ -128,6 +131,11 @@ const ComboboxEmpty = ({ ref, className, loading, error, ...props }) => {
|
|
|
128
131
|
})
|
|
129
132
|
});
|
|
130
133
|
};
|
|
134
|
+
/**
|
|
135
|
+
* Parts of a popover picker: trigger, value, content, check, load-more.
|
|
136
|
+
* Put a `Command` inside `Combobox.Content` for the searchable list. `ChipTrigger` is the
|
|
137
|
+
* labelled chip a filter bar uses.
|
|
138
|
+
*/
|
|
131
139
|
const Combobox = {
|
|
132
140
|
TriggerBase: ComboboxTriggerBase,
|
|
133
141
|
Trigger: ComboboxTrigger,
|
|
@@ -10,6 +10,10 @@ declare const Value: ({ ref, className, onClose, children, ...props }: React.Com
|
|
|
10
10
|
onClose?: () => void;
|
|
11
11
|
}) => React.JSX.Element;
|
|
12
12
|
declare const Bar: ({ ref, className, ...props }: React.ComponentProps<'div'>) => React.JSX.Element;
|
|
13
|
+
/**
|
|
14
|
+
* A bar floating at the page bottom with bulk actions for a selection.
|
|
15
|
+
* The page opens it through `open`, so it has no trigger.
|
|
16
|
+
*/
|
|
13
17
|
export declare const CommandBar: typeof Root & {
|
|
14
18
|
Value: typeof Value;
|
|
15
19
|
Bar: typeof Bar;
|
|
@@ -52,6 +52,10 @@ const Bar = ({ ref, className, ...props }) => {
|
|
|
52
52
|
...props
|
|
53
53
|
});
|
|
54
54
|
};
|
|
55
|
+
/**
|
|
56
|
+
* A bar floating at the page bottom with bulk actions for a selection.
|
|
57
|
+
* The page opens it through `open`, so it has no trigger.
|
|
58
|
+
*/
|
|
55
59
|
const CommandBar = Object.assign(Root, {
|
|
56
60
|
Value,
|
|
57
61
|
Bar
|
|
@@ -37,6 +37,10 @@ declare const CommandActionItem: ({ icon: Icon, label, onSelect, disabled, trail
|
|
|
37
37
|
className?: string;
|
|
38
38
|
}) => React.JSX.Element;
|
|
39
39
|
declare const CommandShortcut: ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => React.JSX.Element;
|
|
40
|
+
/**
|
|
41
|
+
* A searchable list of items to pick or run, built on cmdk.
|
|
42
|
+
* `Command.Dialog` puts it in a palette; inside `Combobox.Content` it is a picker's list.
|
|
43
|
+
*/
|
|
40
44
|
export declare const Command: typeof CommandRoot & {
|
|
41
45
|
Dialog: typeof CommandDialog;
|
|
42
46
|
Input: typeof CommandInput;
|
|
@@ -131,6 +131,10 @@ const CommandShortcut = ({ className, ...props }) => {
|
|
|
131
131
|
...props
|
|
132
132
|
});
|
|
133
133
|
};
|
|
134
|
+
/**
|
|
135
|
+
* A searchable list of items to pick or run, built on cmdk.
|
|
136
|
+
* `Command.Dialog` puts it in a palette; inside `Combobox.Content` it is a picker's list.
|
|
137
|
+
*/
|
|
134
138
|
const Command = Object.assign(CommandRoot, {
|
|
135
139
|
Dialog: CommandDialog,
|
|
136
140
|
Input: CommandInput,
|
|
@@ -8,6 +8,7 @@ declare const ContextMenuContent: ({ className, side, sideOffset, align, ...prop
|
|
|
8
8
|
declare const ContextMenuItem: ({ className, inset, ...props }: Menu.Item.Props & {
|
|
9
9
|
inset?: boolean;
|
|
10
10
|
}) => import("react").JSX.Element;
|
|
11
|
+
/** A menu that opens on right-click, beside the pointer. */
|
|
11
12
|
export declare const ContextMenu: typeof ContextMenuRoot & {
|
|
12
13
|
Trigger: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react").ContextMenuTriggerProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
13
14
|
Content: typeof ContextMenuContent;
|
|
@@ -21,6 +21,7 @@ const ContextMenuItem = ({ className, inset, ...props }) => /* @__PURE__ */ jsx(
|
|
|
21
21
|
className: cn("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 font-medium text-sm outline-hidden transition-colors data-highlighted:bg-accent data-disabled:pointer-events-none data-disabled:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0", inset && "pl-8", className),
|
|
22
22
|
...props
|
|
23
23
|
});
|
|
24
|
+
/** A menu that opens on right-click, beside the pointer. */
|
|
24
25
|
const ContextMenu = Object.assign(ContextMenuRoot, {
|
|
25
26
|
Trigger: ContextMenu$1.Trigger,
|
|
26
27
|
Content: ContextMenuContent,
|
|
@@ -3,5 +3,6 @@ interface CopyTextProps {
|
|
|
3
3
|
children: React.ReactNode;
|
|
4
4
|
className?: string;
|
|
5
5
|
}
|
|
6
|
+
/** Text that copies `value` to the clipboard on click and shows "Copied!". */
|
|
6
7
|
export declare const CopyText: ({ value, children, className }: CopyTextProps) => import("react").JSX.Element;
|
|
7
8
|
export {};
|
|
@@ -4,6 +4,7 @@ import { IconCheck } from "@tabler/icons-react";
|
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import { useState } from "react";
|
|
6
6
|
// src/components/copy-text.tsx
|
|
7
|
+
/** Text that copies `value` to the clipboard on click and shows "Copied!". */
|
|
7
8
|
const CopyText = ({ value, children, className }) => {
|
|
8
9
|
const [copied, setCopied] = useState(false);
|
|
9
10
|
const handleCopy = async (e) => {
|
|
@@ -6,27 +6,23 @@ export type DatePickerValue = DateInput | DateInput[] | DateRange | {
|
|
|
6
6
|
} | null | undefined;
|
|
7
7
|
export type DatePickerMode = 'single' | 'multiple' | 'range';
|
|
8
8
|
export type NormalizedValue = Date | Date[] | DateRange | undefined;
|
|
9
|
-
/** Formats are written with Day.js tokens (`YYYY-MM-DD`, `MMM D, YYYY`), the picker's public API. */
|
|
10
|
-
export declare const DEFAULT_FORMAT = "YYYY-MM-DD";
|
|
11
|
-
export declare const DEFAULT_DISPLAY_FORMAT = "MMM D, YYYY";
|
|
12
|
-
export declare const formatWith: (date: Date, dayjsFormat: string) => string;
|
|
13
9
|
/** ISO strings without an offset are local time, like the Day.js parser this replaced. */
|
|
14
10
|
export declare const toDate: (value: unknown) => Date | undefined;
|
|
15
11
|
export declare const normalizeValue: (value: DatePickerValue, mode: DatePickerMode) => NormalizedValue;
|
|
16
12
|
export declare const getAnchorDate: (value: NormalizedValue) => Date | undefined;
|
|
17
|
-
/** Masks typed text as `
|
|
18
|
-
export declare const maskInputText: (
|
|
13
|
+
/** Masks typed text as `yyyy-MM-dd`, clamping the month and day. */
|
|
14
|
+
export declare const maskInputText: (value: string) => string;
|
|
19
15
|
export declare const getDateBounds: (withPresent: boolean, minDate?: Date, maxDate?: Date) => {
|
|
20
16
|
minBound: Date | undefined;
|
|
21
17
|
maxBound: Date | undefined;
|
|
22
18
|
};
|
|
23
19
|
export declare const getCalendarDisabled: (disabled: Matcher | Matcher[] | undefined, minBound?: Date, maxBound?: Date) => Matcher[];
|
|
24
|
-
/** Parses typed text strictly;
|
|
25
|
-
export declare const parseInputDate: (text: string,
|
|
20
|
+
/** Parses typed text strictly; `loose` also accepts unpadded months and days. */
|
|
21
|
+
export declare const parseInputDate: (text: string, { minBound, maxBound, loose }: {
|
|
26
22
|
minBound?: Date;
|
|
27
23
|
maxBound?: Date;
|
|
28
24
|
loose?: boolean;
|
|
29
25
|
}) => Date | undefined;
|
|
30
26
|
export declare const isDateRange: (value: NormalizedValue) => value is DateRange;
|
|
31
|
-
export declare const describeValue: (value: NormalizedValue,
|
|
27
|
+
export declare const describeValue: (value: NormalizedValue, formatDay: (date: Date) => string, formatMultiple: (count: number) => string) => string | undefined;
|
|
32
28
|
export {};
|
|
@@ -1,30 +1,12 @@
|
|
|
1
1
|
import { endOfDay, format, getDaysInMonth, isAfter, isBefore, isValid, parse, parseISO, startOfDay } from "date-fns";
|
|
2
2
|
// src/components/date-picker-value.ts
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
"YYYY-MM-D",
|
|
10
|
-
"YYYY-M-DD"
|
|
3
|
+
const INPUT_PATTERN = "yyyy-MM-dd";
|
|
4
|
+
const LOOSE_INPUT_PATTERNS = [
|
|
5
|
+
INPUT_PATTERN,
|
|
6
|
+
"yyyy-M-d",
|
|
7
|
+
"yyyy-MM-d",
|
|
8
|
+
"yyyy-M-dd"
|
|
11
9
|
];
|
|
12
|
-
const DAYJS_TOKEN = /\[([^\]]*)]|YYYY|YY|DD|D|dddd|ddd|A|a|ZZ|Z/g;
|
|
13
|
-
const DATE_FNS_TOKEN = {
|
|
14
|
-
YYYY: "yyyy",
|
|
15
|
-
YY: "yy",
|
|
16
|
-
DD: "dd",
|
|
17
|
-
D: "d",
|
|
18
|
-
dddd: "EEEE",
|
|
19
|
-
ddd: "EEE",
|
|
20
|
-
A: "a",
|
|
21
|
-
a: "aaa",
|
|
22
|
-
ZZ: "xx",
|
|
23
|
-
Z: "xxx"
|
|
24
|
-
};
|
|
25
|
-
/** Turns a Day.js format string into the date-fns pattern with the same output. */
|
|
26
|
-
const toDateFnsPattern = (dayjsFormat) => dayjsFormat.replace(DAYJS_TOKEN, (token, escaped) => escaped === void 0 ? DATE_FNS_TOKEN[token] ?? token : `'${escaped.replaceAll("'", "''")}'`);
|
|
27
|
-
const formatWith = (date, dayjsFormat) => format(date, toDateFnsPattern(dayjsFormat));
|
|
28
10
|
const isDateInput = (value) => value instanceof Date || typeof value === "string" || typeof value === "number";
|
|
29
11
|
/** ISO strings without an offset are local time, like the Day.js parser this replaced. */
|
|
30
12
|
const toDate = (value) => {
|
|
@@ -80,7 +62,8 @@ const daysInMonth = (year, month) => {
|
|
|
80
62
|
if (year?.length !== 4 || !(monthNumber >= 1 && monthNumber <= 12)) return void 0;
|
|
81
63
|
return getDaysInMonth(new Date(Number(year), monthNumber - 1, 1));
|
|
82
64
|
};
|
|
83
|
-
|
|
65
|
+
/** Masks typed text as `yyyy-MM-dd`, clamping the month and day. */
|
|
66
|
+
const maskInputText = (value) => {
|
|
84
67
|
const [year, month, day] = splitDateSegments(value);
|
|
85
68
|
const normalizedMonth = month?.length === 2 ? String(Math.min(Number(month), 12)).padStart(2, "0") : month;
|
|
86
69
|
const maxDay = daysInMonth(year, normalizedMonth);
|
|
@@ -90,8 +73,6 @@ const formatDateMask = (value) => {
|
|
|
90
73
|
day?.length === 2 && maxDay ? String(Math.min(Number(day), maxDay)).padStart(2, "0") : day
|
|
91
74
|
].filter((segment) => segment !== void 0).join("-");
|
|
92
75
|
};
|
|
93
|
-
/** Masks typed text as `YYYY-MM-DD` when the picker uses the default format. */
|
|
94
|
-
const maskInputText = (rawValue, format) => format === "YYYY-MM-DD" ? formatDateMask(rawValue) : rawValue;
|
|
95
76
|
const getDateBounds = (withPresent, minDate, maxDate) => ({
|
|
96
77
|
minBound: minDate ?? (withPresent ? /* @__PURE__ */ new Date("1900-01-01") : void 0),
|
|
97
78
|
maxBound: maxDate ?? (withPresent ? /* @__PURE__ */ new Date() : void 0)
|
|
@@ -102,19 +83,19 @@ const getCalendarDisabled = (disabled, minBound, maxBound) => [
|
|
|
102
83
|
...maxBound ? [{ after: maxBound }] : []
|
|
103
84
|
];
|
|
104
85
|
const isWithinBounds = (date, minBound, maxBound) => !(minBound && isBefore(date, startOfDay(minBound))) && !(maxBound && isAfter(date, endOfDay(maxBound)));
|
|
105
|
-
/** Parses typed text strictly;
|
|
106
|
-
const parseInputDate = (text,
|
|
107
|
-
const parsed = (loose
|
|
86
|
+
/** Parses typed text strictly; `loose` also accepts unpadded months and days. */
|
|
87
|
+
const parseInputDate = (text, { minBound, maxBound, loose }) => {
|
|
88
|
+
const parsed = (loose ? LOOSE_INPUT_PATTERNS : [INPUT_PATTERN]).map((pattern) => ({
|
|
108
89
|
pattern,
|
|
109
90
|
date: parse(text, pattern, /* @__PURE__ */ new Date())
|
|
110
91
|
})).find(({ pattern, date }) => isValid(date) && format(date, pattern) === text)?.date;
|
|
111
92
|
return parsed && isWithinBounds(parsed, minBound, maxBound) ? parsed : void 0;
|
|
112
93
|
};
|
|
113
94
|
const isDateRange = (value) => value !== void 0 && !(value instanceof Date) && !Array.isArray(value);
|
|
114
|
-
const describeValue = (value,
|
|
95
|
+
const describeValue = (value, formatDay, formatMultiple) => {
|
|
115
96
|
if (Array.isArray(value)) return value.length ? formatMultiple(value.length) : void 0;
|
|
116
97
|
if (!isDateRange(value) || !value.from) return void 0;
|
|
117
|
-
const from =
|
|
118
|
-
return value.to ?
|
|
98
|
+
const from = formatDay(value.from);
|
|
99
|
+
return value.to ? [from, formatDay(value.to)].join(" - ") : from;
|
|
119
100
|
};
|
|
120
|
-
export {
|
|
101
|
+
export { describeValue, getAnchorDate, getCalendarDisabled, getDateBounds, isDateRange, maskInputText, normalizeValue, parseInputDate, toDate };
|
|
@@ -11,10 +11,6 @@ export type DatePickerProps = {
|
|
|
11
11
|
minDate?: Date;
|
|
12
12
|
maxDate?: Date;
|
|
13
13
|
mode?: DatePickerMode;
|
|
14
|
-
/** Day.js tokens, e.g. `YYYY-MM-DD`. */
|
|
15
|
-
format?: string;
|
|
16
|
-
/** Day.js tokens, e.g. `DD.MM.YYYY`. */
|
|
17
|
-
displayFormat?: string;
|
|
18
14
|
formatMultiple?: (count: number) => string;
|
|
19
15
|
variant?: 'outline' | 'default' | 'ghost';
|
|
20
16
|
allowNull?: boolean;
|
|
@@ -25,5 +21,9 @@ export type DatePickerProps = {
|
|
|
25
21
|
inline?: boolean;
|
|
26
22
|
disabled?: Matcher | Matcher[];
|
|
27
23
|
} & Omit<PropsBase, 'mode' | 'required' | 'disabled'>;
|
|
24
|
+
/**
|
|
25
|
+
* A date field with a calendar popover, for one day, several or a range.
|
|
26
|
+
* `mode` picks which; `inline` shows the calendar without the popover.
|
|
27
|
+
*/
|
|
28
28
|
export declare const DatePicker: (props: DatePickerProps) => import("react").JSX.Element;
|
|
29
29
|
export {};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Calendar } from "./calendar.js";
|
|
2
2
|
import { Button } from "./button.js";
|
|
3
3
|
import { Popover } from "./popover.js";
|
|
4
|
+
import { useFormat } from "../lib/format.js";
|
|
4
5
|
import { cn } from "../lib/utils.js";
|
|
5
|
-
import {
|
|
6
|
+
import { describeValue, getAnchorDate, getCalendarDisabled, getDateBounds, isDateRange, normalizeValue, toDate } from "./date-picker-value.js";
|
|
6
7
|
import { DateTextInput } from "./date-text-input.js";
|
|
7
8
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
9
|
import { useRef, useState } from "react";
|
|
@@ -88,7 +89,7 @@ const useDatePicker = ({ value, onChange, mode, withPresent, minDate, maxDate, d
|
|
|
88
89
|
};
|
|
89
90
|
};
|
|
90
91
|
/** The props with their defaults; what is left goes to the calendar. */
|
|
91
|
-
const resolveProps = ({ value, onChange, placeholder = "Pick a date", withPresent = false, minDate, maxDate, disabled, className, mode = "single",
|
|
92
|
+
const resolveProps = ({ value, onChange, placeholder = "Pick a date", withPresent = false, minDate, maxDate, disabled, className, mode = "single", formatMultiple = defaultFormatMultiple, variant = "outline", allowNull, clearable = allowNull ?? true, clearLabel = "Clear", calendarClassName, popoverContentProps, inline = false, defaultMonth, ...calendarProps }) => ({
|
|
92
93
|
value,
|
|
93
94
|
onChange,
|
|
94
95
|
placeholder,
|
|
@@ -98,8 +99,6 @@ const resolveProps = ({ value, onChange, placeholder = "Pick a date", withPresen
|
|
|
98
99
|
disabled,
|
|
99
100
|
className,
|
|
100
101
|
mode,
|
|
101
|
-
format,
|
|
102
|
-
displayFormat,
|
|
103
102
|
formatMultiple,
|
|
104
103
|
variant,
|
|
105
104
|
clearable,
|
|
@@ -110,15 +109,18 @@ const resolveProps = ({ value, onChange, placeholder = "Pick a date", withPresen
|
|
|
110
109
|
defaultMonth,
|
|
111
110
|
calendarProps
|
|
112
111
|
});
|
|
112
|
+
/**
|
|
113
|
+
* A date field with a calendar popover, for one day, several or a range.
|
|
114
|
+
* `mode` picks which; `inline` shows the calendar without the popover.
|
|
115
|
+
*/
|
|
113
116
|
const DatePicker = (props) => {
|
|
114
117
|
const { calendarProps, ...o } = resolveProps(props);
|
|
115
118
|
const picker = useDatePicker(o);
|
|
119
|
+
const fmt = useFormat();
|
|
116
120
|
const { normalizedValue, isDisabled, hasValue, setIsOpen } = picker;
|
|
117
121
|
const singleInput = /* @__PURE__ */ jsx(DateTextInput, {
|
|
118
122
|
singleDate: normalizedValue instanceof Date ? normalizedValue : void 0,
|
|
119
123
|
onChange: o.onChange,
|
|
120
|
-
format: o.format,
|
|
121
|
-
displayFormat: o.displayFormat,
|
|
122
124
|
bounds: picker.bounds,
|
|
123
125
|
calendarDisabled: picker.calendarDisabled,
|
|
124
126
|
clearable: o.clearable,
|
|
@@ -158,7 +160,7 @@ const DatePicker = (props) => {
|
|
|
158
160
|
render: /* @__PURE__ */ jsx(Button, { variant: o.variant }),
|
|
159
161
|
disabled: isDisabled,
|
|
160
162
|
className: cn("w-full justify-start text-left font-normal", o.className),
|
|
161
|
-
children: describeValue(normalizedValue,
|
|
163
|
+
children: describeValue(normalizedValue, fmt.date, o.formatMultiple) ?? o.placeholder
|
|
162
164
|
}),
|
|
163
165
|
contentProps: o.popoverContentProps,
|
|
164
166
|
children: calendar
|
|
@@ -3,7 +3,6 @@ import { Matcher } from "react-day-picker";
|
|
|
3
3
|
type DateDraftOptions = {
|
|
4
4
|
singleDate?: Date;
|
|
5
5
|
onChange: (date: Date | null) => void;
|
|
6
|
-
format: string;
|
|
7
6
|
bounds: {
|
|
8
7
|
minBound?: Date;
|
|
9
8
|
maxBound?: Date;
|
|
@@ -13,7 +12,6 @@ type DateDraftOptions = {
|
|
|
13
12
|
onOpen?: () => void;
|
|
14
13
|
};
|
|
15
14
|
type DateTextInputProps = DateDraftOptions & {
|
|
16
|
-
displayFormat: string;
|
|
17
15
|
clearLabel: string;
|
|
18
16
|
isDisabled: boolean;
|
|
19
17
|
placeholder: string;
|
|
@@ -21,6 +19,6 @@ type DateTextInputProps = DateDraftOptions & {
|
|
|
21
19
|
inputRef: RefObject<HTMLInputElement | null>;
|
|
22
20
|
onClear: () => void;
|
|
23
21
|
};
|
|
24
|
-
/** Typed date entry for single mode: the
|
|
25
|
-
export declare const DateTextInput: ({
|
|
22
|
+
/** Typed date entry for single mode: the date in the UI's language at rest, `yyyy-MM-dd` while typing. */
|
|
23
|
+
export declare const DateTextInput: ({ clearLabel, isDisabled, placeholder, className, inputRef, onClear, ...options }: DateTextInputProps) => import("react").JSX.Element;
|
|
26
24
|
export {};
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { cn } from "../lib/utils.js";
|
|
2
|
-
import {
|
|
2
|
+
import { toIsoDay, useFormat } from "../lib/format.js";
|
|
3
|
+
import { maskInputText, parseInputDate } from "./date-picker-value.js";
|
|
3
4
|
import { IconCalendar, IconX } from "@tabler/icons-react";
|
|
4
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
6
|
import { useState } from "react";
|
|
6
7
|
import { dateMatchModifiers } from "react-day-picker";
|
|
7
8
|
// src/components/date-text-input.tsx
|
|
8
9
|
/** The text being typed (null while not editing, so the text follows the value) and its handlers. */
|
|
9
|
-
const useDateDraft = ({ singleDate, onChange,
|
|
10
|
+
const useDateDraft = ({ singleDate, onChange, bounds, calendarDisabled, clearable, onOpen }) => {
|
|
10
11
|
const [draft, setDraft] = useState(null);
|
|
11
12
|
const singleTime = singleDate?.getTime();
|
|
12
13
|
const parseDraft = (text, loose) => {
|
|
13
|
-
const date = text ? parseInputDate(text,
|
|
14
|
+
const date = text ? parseInputDate(text, {
|
|
14
15
|
...bounds,
|
|
15
16
|
loose
|
|
16
17
|
}) : void 0;
|
|
@@ -20,7 +21,7 @@ const useDateDraft = ({ singleDate, onChange, format, bounds, calendarDisabled,
|
|
|
20
21
|
if (date && date.getTime() !== singleTime) onChange(date);
|
|
21
22
|
};
|
|
22
23
|
const handleChange = (text) => {
|
|
23
|
-
const masked = maskInputText(text
|
|
24
|
+
const masked = maskInputText(text);
|
|
24
25
|
setDraft(masked);
|
|
25
26
|
if (masked) {
|
|
26
27
|
const parsed = parseDraft(masked, false);
|
|
@@ -34,7 +35,7 @@ const useDateDraft = ({ singleDate, onChange, format, bounds, calendarDisabled,
|
|
|
34
35
|
e.stopPropagation();
|
|
35
36
|
const typed = e.key === "Enter" ? parseDraft(draft, true) : void 0;
|
|
36
37
|
if (typed && typed.getTime() !== singleTime) {
|
|
37
|
-
setDraft(
|
|
38
|
+
setDraft(toIsoDay(typed));
|
|
38
39
|
onChange(typed);
|
|
39
40
|
} else if (opensPopover) onOpen?.();
|
|
40
41
|
};
|
|
@@ -43,18 +44,19 @@ const useDateDraft = ({ singleDate, onChange, format, bounds, calendarDisabled,
|
|
|
43
44
|
setDraft,
|
|
44
45
|
handleChange,
|
|
45
46
|
handleKeyDown,
|
|
46
|
-
handleFocus: () => setDraft((current) => current ?? (singleDate ?
|
|
47
|
+
handleFocus: () => setDraft((current) => current ?? (singleDate ? toIsoDay(singleDate) : "")),
|
|
47
48
|
handleBlur: () => {
|
|
48
49
|
changeTo(parseDraft(draft, true));
|
|
49
50
|
setDraft(null);
|
|
50
51
|
}
|
|
51
52
|
};
|
|
52
53
|
};
|
|
53
|
-
/** Typed date entry for single mode: the
|
|
54
|
-
const DateTextInput = ({
|
|
54
|
+
/** Typed date entry for single mode: the date in the UI's language at rest, `yyyy-MM-dd` while typing. */
|
|
55
|
+
const DateTextInput = ({ clearLabel, isDisabled, placeholder, className, inputRef, onClear, ...options }) => {
|
|
55
56
|
const { draft, setDraft, handleChange, handleKeyDown, handleFocus, handleBlur } = useDateDraft(options);
|
|
57
|
+
const fmt = useFormat();
|
|
56
58
|
const { singleDate } = options;
|
|
57
|
-
const inputText = draft ?? (singleDate ?
|
|
59
|
+
const inputText = draft ?? (singleDate ? fmt.date(singleDate) : "");
|
|
58
60
|
return /* @__PURE__ */ jsxs("div", {
|
|
59
61
|
"aria-disabled": isDisabled,
|
|
60
62
|
className: cn("flex h-7 w-full items-center gap-1 rounded-sm bg-background px-3 text-sm text-foreground shadow-xs transition focus-within:shadow-focus", isDisabled && "cursor-not-allowed opacity-50", className),
|
|
@@ -18,6 +18,10 @@ declare const DialogHeader: ({ className, ...props }: React.HTMLAttributes<HTMLD
|
|
|
18
18
|
declare const DialogFooter: ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => React.JSX.Element;
|
|
19
19
|
declare const DialogTitle: ({ className, ...props }: Dialog$1.Title.Props) => React.JSX.Element;
|
|
20
20
|
declare const DialogDescription: ({ className, ...props }: Dialog$1.Description.Props) => React.JSX.Element;
|
|
21
|
+
/**
|
|
22
|
+
* A centered modal over a dimmed page, such as an image lightbox.
|
|
23
|
+
* Never a form: forms go in core's record side panel. To confirm an action, call `useConfirm`.
|
|
24
|
+
*/
|
|
21
25
|
export declare const Dialog: (<Payload>(props: Dialog$1.Root.Props<Payload>) => React.JSX.Element) & {
|
|
22
26
|
Trigger: Dialog$1.Trigger;
|
|
23
27
|
Close: React.ForwardRefExoticComponent<Omit<import("@base-ui/react").DialogCloseProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -4,8 +4,8 @@ import { IconX } from "@tabler/icons-react";
|
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import "react";
|
|
6
6
|
import { cva } from "class-variance-authority";
|
|
7
|
-
import { Dialog as Dialog$1 } from "@base-ui/react/dialog";
|
|
8
7
|
import { useTranslation } from "react-i18next";
|
|
8
|
+
import { Dialog as Dialog$1 } from "@base-ui/react/dialog";
|
|
9
9
|
// src/components/dialog.tsx
|
|
10
10
|
/** Dims the page under a dialog. Content renders one; a hand-built popup in `Dialog.Portal` uses this. */
|
|
11
11
|
const DialogBackdrop = ({ className, ...props }) => /* @__PURE__ */ jsx(Dialog$1.Backdrop, {
|
|
@@ -72,6 +72,10 @@ const DialogDescription = ({ className, ...props }) => /* @__PURE__ */ jsx(Dialo
|
|
|
72
72
|
className: cn("text-sm text-accent-foreground", className),
|
|
73
73
|
...props
|
|
74
74
|
});
|
|
75
|
+
/**
|
|
76
|
+
* A centered modal over a dimmed page, such as an image lightbox.
|
|
77
|
+
* Never a form: forms go in core's record side panel. To confirm an action, call `useConfirm`.
|
|
78
|
+
*/
|
|
75
79
|
const Dialog = Object.assign(Dialog$1.Root, {
|
|
76
80
|
Trigger: Dialog$1.Trigger,
|
|
77
81
|
Close: Dialog$1.Close,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ButtonProps } from "./button.js";
|
|
2
2
|
type DragHandleProps = Omit<ButtonProps, 'render' | 'children' | 'size'>;
|
|
3
|
+
/** A small grip button to drag a row or card by, for a sortable list. */
|
|
3
4
|
export declare const DragHandle: ({ ref, className, variant, ...props }: DragHandleProps) => import("react").JSX.Element;
|
|
4
5
|
export {};
|
|
@@ -3,6 +3,7 @@ import { cn } from "../lib/utils.js";
|
|
|
3
3
|
import { IconGripVertical } from "@tabler/icons-react";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
// src/components/drag-handle.tsx
|
|
6
|
+
/** A small grip button to drag a row or card by, for a sortable list. */
|
|
6
7
|
const DragHandle = ({ ref, className, variant = "ghost", ...props }) => /* @__PURE__ */ jsx(Button, {
|
|
7
8
|
className: cn("size-5 flex-none cursor-grab px-0 text-accent-foreground active:cursor-grabbing", className),
|
|
8
9
|
ref,
|