@erxes/ui 4.0.0-v2.1 → 4.0.0-v2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/dist/components/charts.js +3 -1
- package/dist/components/combobox.d.ts +1 -1
- package/dist/components/combobox.js +4 -1
- 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 +0 -4
- package/dist/components/date-picker.js +5 -7
- package/dist/components/date-text-input.d.ts +2 -4
- package/dist/components/date-text-input.js +11 -9
- package/dist/components/dialog.js +1 -1
- package/dist/components/empty.d.ts +5 -1
- package/dist/components/empty.js +24 -2
- package/dist/components/select.d.ts +1 -1
- package/dist/components/select.js +3 -1
- package/dist/components/sheet.js +4 -4
- package/dist/components/sidebar/panel.js +29 -7
- package/dist/federation.d.ts +4 -1
- package/dist/federation.js +6 -2
- package/dist/index.d.ts +8 -5
- package/dist/index.js +8 -4
- package/dist/lib/format.d.ts +52 -0
- package/dist/lib/format.js +75 -0
- package/dist/lib/stored.d.ts +13 -0
- package/dist/lib/stored.js +41 -0
- package/dist/modules/attachments/use-carousel.js +5 -10
- package/dist/modules/display/components/RelativeDateDisplay.d.ts +4 -5
- package/dist/modules/display/components/RelativeDateDisplay.js +7 -8
- 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 +1 -2
- package/dist/modules/filter/types/filter.d.ts +0 -1
- package/dist/modules/layout/components/AppLayout.d.ts +2 -2
- package/dist/modules/layout/components/AppLayout.js +8 -9
- package/dist/modules/layout/components/AppLayoutResizeHandle.d.ts +5 -12
- package/dist/modules/layout/components/AppLayoutResizeHandle.js +15 -18
- package/dist/modules/layout/components/PageHeader.js +5 -2
- package/dist/modules/navigation-menu/components/NavigationMenu.d.ts +3 -3
- package/dist/modules/navigation-menu/components/NavigationMenu.js +6 -7
- package/dist/modules/pickers/EntityPicker.d.ts +30 -0
- package/dist/modules/pickers/EntityPicker.js +60 -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.js +4 -2
- package/dist/modules/record-field/components/TextField.js +9 -2
- 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.js +3 -7
- package/dist/modules/record-table/components/RecordTableCursor.js +15 -20
- 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/state/sidebarPanelState.d.ts +5 -1
- package/dist/state/sidebarPanelState.js +11 -3
- package/dist/state/themeState.d.ts +8 -2
- package/dist/state/themeState.js +13 -4
- package/dist/theme.css +3 -2
- package/dist/utils/plugin-styles.d.ts +6 -0
- package/dist/utils/plugin-styles.js +53 -0
- package/package.json +4 -1
- 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
package/README.md
CHANGED
|
@@ -24,9 +24,12 @@ Only what something uses:
|
|
|
24
24
|
- what web imports,
|
|
25
25
|
- what plugin UIs import (the HR plugin is the first consumer),
|
|
26
26
|
- the plugin API in the plugin skills: `getPluginRuntime`, `pluginFetch`, `pluginJson`,
|
|
27
|
-
`useLiveSignal`, `RecordTimeline`, `getPluginAssetsUrl` and the `IUIConfig` types,
|
|
27
|
+
`useLiveSignal`, `RecordTimeline`, `getPluginAssetsUrl`, `addPluginStyles` and the `IUIConfig` types,
|
|
28
28
|
- the design-system primitives in `src/components` (Accordion, Card, Slider …), even unused,
|
|
29
|
-
because plugins build on them
|
|
29
|
+
because plugins build on them,
|
|
30
|
+
- the pickers in `src/modules/pickers`: `EntityPicker`, and `SelectMember`, `MemberInline` and
|
|
31
|
+
`useMembersById`, which take `memberQueries` from `@erxes/core-contract/client`. They read
|
|
32
|
+
through TanStack query options, so erxes-ui imports nothing from core.
|
|
30
33
|
|
|
31
34
|
Anything else is removed, not kept "in case". Before you remove an export, check the HR plugin
|
|
32
35
|
UI and `.agents/skills/plugin-contract/SKILL.md`.
|
|
@@ -1,3 +1,4 @@
|
|
|
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";
|
|
@@ -48,6 +49,7 @@ const TooltipIndicator = ({ indicator, color, nested }) => /* @__PURE__ */ jsx("
|
|
|
48
49
|
});
|
|
49
50
|
const TooltipRow = ({ item, index, payload, props, label }) => {
|
|
50
51
|
const { config } = useChart();
|
|
52
|
+
const fmt = useFormat();
|
|
51
53
|
const { indicator = "dot", formatter } = props;
|
|
52
54
|
const nested = label !== null;
|
|
53
55
|
const itemConfig = configFor(config, item, keyOf(props.nameKey, item.name, item.dataKey));
|
|
@@ -66,7 +68,7 @@ const TooltipRow = ({ item, index, payload, props, label }) => {
|
|
|
66
68
|
})]
|
|
67
69
|
}), item.value !== void 0 && /* @__PURE__ */ jsx("span", {
|
|
68
70
|
className: "font-mono font-medium tabular-nums text-foreground",
|
|
69
|
-
children: item.value.
|
|
71
|
+
children: typeof item.value === "number" ? fmt.number(item.value) : String(item.value)
|
|
70
72
|
})]
|
|
71
73
|
})] });
|
|
72
74
|
};
|
|
@@ -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;
|
|
@@ -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,
|
|
@@ -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;
|
|
@@ -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,
|
|
@@ -113,12 +112,11 @@ const resolveProps = ({ value, onChange, placeholder = "Pick a date", withPresen
|
|
|
113
112
|
const DatePicker = (props) => {
|
|
114
113
|
const { calendarProps, ...o } = resolveProps(props);
|
|
115
114
|
const picker = useDatePicker(o);
|
|
115
|
+
const fmt = useFormat();
|
|
116
116
|
const { normalizedValue, isDisabled, hasValue, setIsOpen } = picker;
|
|
117
117
|
const singleInput = /* @__PURE__ */ jsx(DateTextInput, {
|
|
118
118
|
singleDate: normalizedValue instanceof Date ? normalizedValue : void 0,
|
|
119
119
|
onChange: o.onChange,
|
|
120
|
-
format: o.format,
|
|
121
|
-
displayFormat: o.displayFormat,
|
|
122
120
|
bounds: picker.bounds,
|
|
123
121
|
calendarDisabled: picker.calendarDisabled,
|
|
124
122
|
clearable: o.clearable,
|
|
@@ -158,7 +156,7 @@ const DatePicker = (props) => {
|
|
|
158
156
|
render: /* @__PURE__ */ jsx(Button, { variant: o.variant }),
|
|
159
157
|
disabled: isDisabled,
|
|
160
158
|
className: cn("w-full justify-start text-left font-normal", o.className),
|
|
161
|
-
children: describeValue(normalizedValue,
|
|
159
|
+
children: describeValue(normalizedValue, fmt.date, o.formatMultiple) ?? o.placeholder
|
|
162
160
|
}),
|
|
163
161
|
contentProps: o.popoverContentProps,
|
|
164
162
|
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),
|
|
@@ -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, {
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { VariantProps } from "class-variance-authority";
|
|
2
|
-
declare
|
|
2
|
+
declare const emptyVariants: (props?: ({
|
|
3
|
+
variant?: "default" | "outline" | null | undefined;
|
|
4
|
+
size?: "default" | "sm" | null | undefined;
|
|
5
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
|
+
declare function EmptyRoot({ className, variant, size, ...props }: React.ComponentProps<'div'> & VariantProps<typeof emptyVariants>): import("react").JSX.Element;
|
|
3
7
|
declare function EmptyHeader({ className, ...props }: React.ComponentProps<'div'>): import("react").JSX.Element;
|
|
4
8
|
declare const emptyMediaVariants: (props?: ({
|
|
5
9
|
variant?: "default" | "icon" | null | undefined;
|
package/dist/components/empty.js
CHANGED
|
@@ -2,10 +2,32 @@ import { cn } from "../lib/utils.js";
|
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
import { cva } from "class-variance-authority";
|
|
4
4
|
// src/components/empty.tsx
|
|
5
|
-
|
|
5
|
+
const emptyVariants = cva("flex min-w-0 flex-1 flex-col items-center justify-center gap-6 rounded-lg border-dashed text-center text-balance", {
|
|
6
|
+
variants: {
|
|
7
|
+
variant: {
|
|
8
|
+
default: "",
|
|
9
|
+
/** A dashed outline on the page background, standing in for missing content. */
|
|
10
|
+
outline: "border bg-background"
|
|
11
|
+
},
|
|
12
|
+
size: {
|
|
13
|
+
default: "px-6 py-12 md:px-12",
|
|
14
|
+
/** Inside a card or a widget, where a page's spacing would crowd it. */
|
|
15
|
+
sm: "p-6"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
defaultVariants: {
|
|
19
|
+
variant: "default",
|
|
20
|
+
size: "default"
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
function EmptyRoot({ className, variant, size, ...props }) {
|
|
6
24
|
return /* @__PURE__ */ jsx("div", {
|
|
7
25
|
"data-slot": "empty",
|
|
8
|
-
className: cn(
|
|
26
|
+
className: cn(emptyVariants({
|
|
27
|
+
variant,
|
|
28
|
+
size,
|
|
29
|
+
className
|
|
30
|
+
})),
|
|
9
31
|
...props
|
|
10
32
|
});
|
|
11
33
|
}
|
|
@@ -11,7 +11,7 @@ declare const SelectGroup: (props: Select$1.Group.Props) => string | number | bi
|
|
|
11
11
|
declare const selectTriggerVariants: (props?: ({
|
|
12
12
|
variant?: "bordered" | "default" | "flush" | null | undefined;
|
|
13
13
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
14
|
-
declare const SelectTrigger: ({ className, children, variant, ...props }: Select$1.Trigger.Props & VariantProps<typeof selectTriggerVariants>) => React.JSX.Element;
|
|
14
|
+
declare const SelectTrigger: ({ className, children, variant, id, ...props }: Select$1.Trigger.Props & VariantProps<typeof selectTriggerVariants>) => React.JSX.Element;
|
|
15
15
|
declare const SelectContent: ({ className, children, side, align, ...props }: Select$1.Popup.Props & Pick<Select$1.Positioner.Props, 'side' | 'align'>) => React.JSX.Element;
|
|
16
16
|
declare const SelectLabel: ({ className, ...props }: Select$1.GroupLabel.Props) => React.JSX.Element | null;
|
|
17
17
|
declare const SelectItem: ({ className, children, value, ...props }: Omit<Select$1.Item.Props, 'value'> & {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { cn } from "../lib/utils.js";
|
|
2
|
+
import { useCellLabel } from "../modules/record-table/components/RecordTableCell.js";
|
|
2
3
|
import { IconCheck, IconChevronDown, IconChevronUp } from "@tabler/icons-react";
|
|
3
4
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
5
|
import { createContext, use, useCallback, useLayoutEffect, useState } from "react";
|
|
@@ -38,7 +39,8 @@ const selectTriggerVariants = cva("flex h-7 w-full items-center font-medium just
|
|
|
38
39
|
} },
|
|
39
40
|
defaultVariants: { variant: "default" }
|
|
40
41
|
});
|
|
41
|
-
const SelectTrigger = ({ className, children, variant, ...props }) => /* @__PURE__ */ jsxs(Select$1.Trigger, {
|
|
42
|
+
const SelectTrigger = ({ className, children, variant, id, ...props }) => /* @__PURE__ */ jsxs(Select$1.Trigger, {
|
|
43
|
+
...useCellLabel(id),
|
|
42
44
|
className: cn(selectTriggerVariants({ variant }), className),
|
|
43
45
|
...props,
|
|
44
46
|
children: [children, /* @__PURE__ */ jsx(IconChevronDown, {
|
package/dist/components/sheet.js
CHANGED
|
@@ -4,8 +4,8 @@ import { IconX } from "@tabler/icons-react";
|
|
|
4
4
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import React from "react";
|
|
6
6
|
import { cva } from "class-variance-authority";
|
|
7
|
-
import { Dialog } from "@base-ui/react/dialog";
|
|
8
7
|
import { useTranslation } from "react-i18next";
|
|
8
|
+
import { Dialog } from "@base-ui/react/dialog";
|
|
9
9
|
// src/components/sheet.tsx
|
|
10
10
|
const SheetHeaderActionsContext = React.createContext(null);
|
|
11
11
|
const SheetRoot = ({ headerActions = null, ...props }) => /* @__PURE__ */ jsx(SheetHeaderActionsContext, {
|
|
@@ -80,7 +80,7 @@ const SheetHeader = ({ className, children, ...props }) => {
|
|
|
80
80
|
const items = React.Children.toArray(children);
|
|
81
81
|
const close = actions ? items.find((child) => React.isValidElement(child) && child.type === SheetClose) : void 0;
|
|
82
82
|
return /* @__PURE__ */ jsx("div", {
|
|
83
|
-
className: cn("flex px-5 h-10
|
|
83
|
+
className: cn("flex flex-wrap items-center gap-x-2 gap-y-1 px-5 py-2 min-h-10 bg-background border-b flex-none", className),
|
|
84
84
|
...props,
|
|
85
85
|
children: actions ? /* @__PURE__ */ jsxs(Fragment, { children: [items.filter((child) => child !== close), /* @__PURE__ */ jsxs("div", {
|
|
86
86
|
className: "ml-auto flex shrink-0 items-center gap-1 [&>button]:ml-0",
|
|
@@ -97,11 +97,11 @@ const SheetFooter = ({ className, ...props }) => /* @__PURE__ */ jsx("div", {
|
|
|
97
97
|
...props
|
|
98
98
|
});
|
|
99
99
|
const SheetTitle = ({ className, ...props }) => /* @__PURE__ */ jsx(Dialog.Title, {
|
|
100
|
-
className: cn("text-lg font-semibold text-foreground leading-
|
|
100
|
+
className: cn("min-w-0 flex-1 text-lg font-semibold text-foreground leading-tight", className),
|
|
101
101
|
...props
|
|
102
102
|
});
|
|
103
103
|
const SheetDescription = ({ className, ...props }) => /* @__PURE__ */ jsx(Dialog.Description, {
|
|
104
|
-
className: cn("text-sm leading-
|
|
104
|
+
className: cn("order-last basis-full text-sm leading-snug text-muted-foreground", className),
|
|
105
105
|
...props
|
|
106
106
|
});
|
|
107
107
|
const Sheet = Object.assign(SheetRoot, {
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { Button } from "../button.js";
|
|
2
2
|
import { Separator } from "../separator.js";
|
|
3
|
+
import { useIsMobile } from "../../hooks/use-mobile.js";
|
|
3
4
|
import { cn, mergeRefs } from "../../lib/utils.js";
|
|
4
|
-
import { sidebarPanelOpenState } from "../../state/sidebarPanelState.js";
|
|
5
|
+
import { sidebarPanelOpenState, sidebarPanelOpenedAtState } from "../../state/sidebarPanelState.js";
|
|
5
6
|
import { IconLayoutSidebarLeftCollapse, IconLayoutSidebarLeftExpand } from "@tabler/icons-react";
|
|
6
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
8
|
import React from "react";
|
|
9
|
+
import { useAtom } from "jotai";
|
|
8
10
|
import { useTranslation } from "react-i18next";
|
|
9
|
-
import { useAtom, useAtomValue } from "jotai";
|
|
10
11
|
import { createPortal } from "react-dom";
|
|
12
|
+
import { useLocation } from "react-router-dom";
|
|
11
13
|
// src/components/sidebar/panel.tsx
|
|
12
14
|
const SIDEBAR_PANEL_SLOT = "[data-sidebar-panel-slot]";
|
|
13
15
|
const findSidebarPanelSlot = (panel) => {
|
|
@@ -20,6 +22,26 @@ const findSidebarPanelSlot = (panel) => {
|
|
|
20
22
|
return null;
|
|
21
23
|
};
|
|
22
24
|
const SidebarPanelInnerTriggerHiddenContext = React.createContext(false);
|
|
25
|
+
/**
|
|
26
|
+
* Whether the panel is open. On a desktop it stays as the member left it. On a phone it covers
|
|
27
|
+
* the page, so it starts closed and closes once you pick a page in it.
|
|
28
|
+
*/
|
|
29
|
+
const useSidebarPanelOpen = () => {
|
|
30
|
+
const isMobile = useIsMobile();
|
|
31
|
+
const { pathname } = useLocation();
|
|
32
|
+
const [desktopOpen, setDesktopOpen] = useAtom(sidebarPanelOpenState);
|
|
33
|
+
const [openedAt, setOpenedAt] = useAtom(sidebarPanelOpenedAtState);
|
|
34
|
+
if (!isMobile) return {
|
|
35
|
+
isMobile,
|
|
36
|
+
open: desktopOpen,
|
|
37
|
+
setOpen: setDesktopOpen
|
|
38
|
+
};
|
|
39
|
+
return {
|
|
40
|
+
isMobile,
|
|
41
|
+
open: openedAt === pathname,
|
|
42
|
+
setOpen: (open) => setOpenedAt(open ? pathname : null)
|
|
43
|
+
};
|
|
44
|
+
};
|
|
23
45
|
const isSlotAbovePanel = (slot, panel) => Boolean(panel && slot.compareDocumentPosition(panel) & Node.DOCUMENT_POSITION_FOLLOWING);
|
|
24
46
|
const useSidebarPanelSlot = (panelRef, open) => {
|
|
25
47
|
const [slot, setSlot] = React.useState(null);
|
|
@@ -46,7 +68,7 @@ const useSidebarPanelSlot = (panelRef, open) => {
|
|
|
46
68
|
};
|
|
47
69
|
const SidebarPanelTrigger = ({ ref, className, onClick, ...props }) => {
|
|
48
70
|
const hidden = React.useContext(SidebarPanelInnerTriggerHiddenContext);
|
|
49
|
-
const
|
|
71
|
+
const { open, setOpen } = useSidebarPanelOpen();
|
|
50
72
|
const { t } = useTranslation("common", { keyPrefix: "navigation" });
|
|
51
73
|
const toggleLabel = open ? t("collapse-sidebar", "Collapse sidebar") : t("expand-sidebar", "Expand sidebar");
|
|
52
74
|
if (hidden) return null;
|
|
@@ -67,7 +89,7 @@ const SidebarPanelTrigger = ({ ref, className, onClick, ...props }) => {
|
|
|
67
89
|
});
|
|
68
90
|
};
|
|
69
91
|
const SidebarPanel = ({ ref, className, children, label, actions, ...props }) => {
|
|
70
|
-
const open =
|
|
92
|
+
const { isMobile, open } = useSidebarPanelOpen();
|
|
71
93
|
const panelRef = React.useRef(null);
|
|
72
94
|
const { slot, claimed } = useSidebarPanelSlot(panelRef, open);
|
|
73
95
|
const triggerInSlot = Boolean(slot && claimed);
|
|
@@ -75,7 +97,7 @@ const SidebarPanel = ({ ref, className, children, label, actions, ...props }) =>
|
|
|
75
97
|
ref: mergeRefs(panelRef, ref),
|
|
76
98
|
"data-sidebar": "panel",
|
|
77
99
|
"data-state": open ? "expanded" : "collapsed",
|
|
78
|
-
className: cn("relative flex h-full w-60 flex-col overflow-hidden border-r bg-sidebar text-foreground transition-layout duration-300 ease-out-quint motion-reduce:transition-none", className, !open && "w-0! overflow-visible border-0!"),
|
|
100
|
+
className: cn("relative flex h-full w-60 flex-col overflow-hidden border-r bg-sidebar text-foreground transition-layout duration-300 ease-out-quint motion-reduce:transition-none", className, isMobile && "absolute inset-y-0 left-0 z-20 shadow-lg", !open && "w-0! overflow-visible border-0! shadow-none"),
|
|
79
101
|
...props,
|
|
80
102
|
children: [
|
|
81
103
|
slot && claimed && createPortal(/* @__PURE__ */ jsxs("span", {
|
|
@@ -83,13 +105,13 @@ const SidebarPanel = ({ ref, className, children, label, actions, ...props }) =>
|
|
|
83
105
|
children: [/* @__PURE__ */ jsx(SidebarPanelTrigger, { className: "size-7" }), /* @__PURE__ */ jsx(Separator.Inline, {})]
|
|
84
106
|
}), slot),
|
|
85
107
|
!open && !slot && /* @__PURE__ */ jsx("div", {
|
|
86
|
-
className: "absolute top-2.5 left-2 z-20",
|
|
108
|
+
className: "absolute top-2.5 left-2 z-20 navigation-collapsed:left-12",
|
|
87
109
|
children: /* @__PURE__ */ jsx(SidebarPanelTrigger, { className: "size-7 border bg-background shadow-xs" })
|
|
88
110
|
}),
|
|
89
111
|
/* @__PURE__ */ jsxs(SidebarPanelInnerTriggerHiddenContext.Provider, {
|
|
90
112
|
value: triggerInSlot,
|
|
91
113
|
children: [open && label && /* @__PURE__ */ jsxs("div", {
|
|
92
|
-
className: "flex h-10 shrink-0 items-center gap-1 px-2",
|
|
114
|
+
className: "flex h-10 shrink-0 items-center gap-1 px-2 navigation-collapsed:pl-12",
|
|
93
115
|
children: [
|
|
94
116
|
/* @__PURE__ */ jsx("span", {
|
|
95
117
|
className: "min-w-0 flex-1 truncate px-2 text-sm font-medium",
|
package/dist/federation.d.ts
CHANGED
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
* it never bundles a second React, router, query client or erxes-ui. A shared
|
|
6
6
|
* name matches only that exact import, so React's entry points are listed one
|
|
7
7
|
* by one: a remote that bundles its own `react/jsx-runtime` breaks as soon as
|
|
8
|
-
* its React differs from the host's.
|
|
8
|
+
* its React differs from the host's. `@tanstack/query-core` is listed with
|
|
9
|
+
* `@tanstack/react-query` because `@orpc/tanstack-query` imports it directly: a
|
|
10
|
+
* plugin's own copy would hold a different `skipToken`, so `input: skipToken`
|
|
11
|
+
* (from the host's `@tanstack/react-query`) would run the query, not disable it.
|
|
9
12
|
*/
|
|
10
13
|
export declare const SHARED: string[];
|
package/dist/federation.js
CHANGED
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
* it never bundles a second React, router, query client or erxes-ui. A shared
|
|
7
7
|
* name matches only that exact import, so React's entry points are listed one
|
|
8
8
|
* by one: a remote that bundles its own `react/jsx-runtime` breaks as soon as
|
|
9
|
-
* its React differs from the host's.
|
|
9
|
+
* its React differs from the host's. `@tanstack/query-core` is listed with
|
|
10
|
+
* `@tanstack/react-query` because `@orpc/tanstack-query` imports it directly: a
|
|
11
|
+
* plugin's own copy would hold a different `skipToken`, so `input: skipToken`
|
|
12
|
+
* (from the host's `@tanstack/react-query`) would run the query, not disable it.
|
|
10
13
|
*/
|
|
11
14
|
const SHARED = [
|
|
12
15
|
"react",
|
|
@@ -19,6 +22,7 @@ const SHARED = [
|
|
|
19
22
|
"erxes-ui",
|
|
20
23
|
"jotai",
|
|
21
24
|
"react-i18next",
|
|
22
|
-
"@tanstack/react-query"
|
|
25
|
+
"@tanstack/react-query",
|
|
26
|
+
"@tanstack/query-core"
|
|
23
27
|
];
|
|
24
28
|
export { SHARED };
|