@erxes/ui 4.0.0-v2.2 → 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/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 +1 -1
- package/dist/components/sidebar/panel.js +1 -1
- package/dist/index.d.ts +4 -5
- package/dist/index.js +4 -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/navigation-menu/components/NavigationMenu.d.ts +3 -3
- package/dist/modules/navigation-menu/components/NavigationMenu.js +6 -7
- 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.js +7 -2
- package/dist/state/themeState.d.ts +8 -2
- package/dist/state/themeState.js +13 -4
- package/package.json +2 -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
|
@@ -2,9 +2,8 @@ import { Badge } from "../../../components/badge.js";
|
|
|
2
2
|
import { Button, buttonVariants } from "../../../components/button.js";
|
|
3
3
|
import { Popover } from "../../../components/popover.js";
|
|
4
4
|
import { cn } from "../../../lib/utils.js";
|
|
5
|
-
import { CellColumnHead } from "./RecordTableCell.js";
|
|
5
|
+
import { CellColumnHead, useCellLabel } from "./RecordTableCell.js";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
|
-
import { use, useId } from "react";
|
|
8
7
|
import { cva } from "class-variance-authority";
|
|
9
8
|
// src/modules/record-table/components/RecordTableCellInline.tsx
|
|
10
9
|
const cellTriggerVariants = cva("h-8 px-2 w-full justify-start text-left focus-visible:relative focus-visible:z-10 focus-visible:outline-none focus-visible:shadow-subtle overflow-hidden", {
|
|
@@ -20,13 +19,10 @@ const cellTriggerVariants = cva("h-8 px-2 w-full justify-start text-left focus-v
|
|
|
20
19
|
defaultVariants: { variant: "cell" }
|
|
21
20
|
});
|
|
22
21
|
const RecordTableCellTrigger = ({ ref, children, className, id, variant, empty, ...props }) => {
|
|
23
|
-
const
|
|
24
|
-
const triggerId = id ?? ownId;
|
|
25
|
-
const columnHead = use(CellColumnHead);
|
|
22
|
+
const label = useCellLabel(id);
|
|
26
23
|
return /* @__PURE__ */ jsx(Popover.Trigger, {
|
|
27
24
|
render: /* @__PURE__ */ jsx(Button, {
|
|
28
|
-
|
|
29
|
-
"aria-labelledby": columnHead ? `${columnHead} ${triggerId}` : void 0,
|
|
25
|
+
...label,
|
|
30
26
|
variant: "ghost",
|
|
31
27
|
className: cn(cellTriggerVariants({
|
|
32
28
|
variant,
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { ScrollArea } from "../../../components/scroll-area.js";
|
|
2
2
|
import { mergeRefs } from "../../../lib/utils.js";
|
|
3
3
|
import { useCursorScroll } from "../hooks/useCursorScroll.js";
|
|
4
|
+
import { tablePositionState } from "../states/RecordTableCursorState.js";
|
|
4
5
|
import "../types/RecordTableCursorTypes.js";
|
|
5
6
|
import { RecordTableRowSkeleton } from "./RecordTableRowSkeleton.js";
|
|
6
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
8
|
import { createContext, useContext, useEffect, useState } from "react";
|
|
9
|
+
import { useStore } from "jotai";
|
|
8
10
|
import { useDebouncedCallback } from "use-debounce";
|
|
9
11
|
// src/modules/record-table/components/RecordTableCursor.tsx
|
|
10
12
|
const RecordTableCursorContext = createContext(null);
|
|
@@ -13,19 +15,6 @@ const useRecordTableCursorContext = () => {
|
|
|
13
15
|
if (!context) throw new Error("Cursor skeletons must be used within a RecordTableCursorProvider");
|
|
14
16
|
return context;
|
|
15
17
|
};
|
|
16
|
-
/** Session storage is best effort: when it is blocked the position is simply not restored. */
|
|
17
|
-
const remember = (key, value) => {
|
|
18
|
-
try {
|
|
19
|
-
sessionStorage.setItem(key, value);
|
|
20
|
-
} catch {}
|
|
21
|
-
};
|
|
22
|
-
const recall = (key) => {
|
|
23
|
-
try {
|
|
24
|
-
return sessionStorage.getItem(key);
|
|
25
|
-
} catch {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
18
|
/**
|
|
30
19
|
* Scrolls a cursor-paged table. With a `sessionKey` it remembers the first visible row and the
|
|
31
20
|
* scroll position for the session, and restores the position when the rows come back.
|
|
@@ -37,25 +26,31 @@ const RecordTableCursorProvider = ({ children, hasPreviousPage, loading, dataLen
|
|
|
37
26
|
offset
|
|
38
27
|
});
|
|
39
28
|
const [viewport, setViewport] = useState(null);
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
29
|
+
const store = useStore();
|
|
30
|
+
const remember = (part) => {
|
|
31
|
+
if (sessionKey) store.set(tablePositionState(sessionKey), (saved) => ({
|
|
32
|
+
...saved,
|
|
33
|
+
...part
|
|
34
|
+
}));
|
|
35
|
+
};
|
|
36
|
+
const rememberScrollTop = useDebouncedCallback((scroll) => remember({ scroll }), 150);
|
|
43
37
|
const handleScroll = (event) => {
|
|
44
38
|
const scroll = event.currentTarget;
|
|
45
39
|
const firstVisibleRow = scroll.querySelector(".in-view");
|
|
46
|
-
if (
|
|
40
|
+
if (firstVisibleRow) remember({ row: firstVisibleRow.id });
|
|
47
41
|
rememberScrollTop(scroll.scrollTop);
|
|
48
42
|
};
|
|
49
43
|
useEffect(() => {
|
|
50
44
|
const scroll = scrollRef.current;
|
|
51
45
|
if (!dataLength || loading || !scroll || !sessionKey) return;
|
|
52
|
-
const saved =
|
|
53
|
-
if (saved) scroll.scrollTop =
|
|
46
|
+
const saved = store.get(tablePositionState(sessionKey)).scroll;
|
|
47
|
+
if (saved) scroll.scrollTop = saved;
|
|
54
48
|
}, [
|
|
55
49
|
loading,
|
|
56
50
|
dataLength,
|
|
57
51
|
scrollRef,
|
|
58
|
-
sessionKey
|
|
52
|
+
sessionKey,
|
|
53
|
+
store
|
|
59
54
|
]);
|
|
60
55
|
return /* @__PURE__ */ jsx(RecordTableCursorContext.Provider, {
|
|
61
56
|
value: {
|
|
@@ -10,7 +10,7 @@ declare const tablePrefsSchema: z.ZodObject<{
|
|
|
10
10
|
stickyColumns: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
11
11
|
}, z.core.$strip>;
|
|
12
12
|
type TablePrefs = z.infer<typeof tablePrefsSchema>;
|
|
13
|
-
/** A table's column layout, kept in
|
|
13
|
+
/** A table's column layout, kept in this browser per `tableId`; without one nothing is kept. */
|
|
14
14
|
export declare const useTablePreferences: (tableId: string | undefined) => {
|
|
15
15
|
prefs: {
|
|
16
16
|
columnOrder?: string[] | undefined;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useCallback
|
|
1
|
+
import { storedFamily } from "../../../lib/stored.js";
|
|
2
|
+
import { useCallback } from "react";
|
|
3
|
+
import { useAtom } from "jotai";
|
|
3
4
|
import { z } from "zod";
|
|
4
5
|
// src/modules/record-table/hooks/useTablePreferences.ts
|
|
5
6
|
const ids = z.array(z.string());
|
|
@@ -14,37 +15,23 @@ const tablePrefsSchema = z.object({
|
|
|
14
15
|
/** The columns meant to stick when the pinning was saved (a newly sticky column is pinned once). */
|
|
15
16
|
stickyColumns: ids.optional()
|
|
16
17
|
});
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
} catch {
|
|
24
|
-
return {};
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
const writePrefs = (tableId, prefs) => {
|
|
28
|
-
try {
|
|
29
|
-
localStorage.setItem(storageKey(tableId), JSON.stringify(prefs));
|
|
30
|
-
} catch {}
|
|
31
|
-
};
|
|
32
|
-
/** A table's column layout, kept in localStorage per `tableId`; without one nothing is kept. */
|
|
18
|
+
const tablePrefsState = storedFamily({
|
|
19
|
+
key: "erxes:table:prefs",
|
|
20
|
+
schema: tablePrefsSchema,
|
|
21
|
+
initial: {}
|
|
22
|
+
});
|
|
23
|
+
/** A table's column layout, kept in this browser per `tableId`; without one nothing is kept. */
|
|
33
24
|
const useTablePreferences = (tableId) => {
|
|
34
|
-
const [prefs, setPrefs] =
|
|
25
|
+
const [prefs, setPrefs] = useAtom(tablePrefsState(tableId ?? ""));
|
|
26
|
+
const savePrefs = useCallback((updates) => {
|
|
27
|
+
if (tableId) setPrefs((current) => ({
|
|
28
|
+
...current,
|
|
29
|
+
...updates
|
|
30
|
+
}));
|
|
31
|
+
}, [tableId, setPrefs]);
|
|
35
32
|
return {
|
|
36
|
-
prefs,
|
|
37
|
-
savePrefs
|
|
38
|
-
if (!tableId) return;
|
|
39
|
-
setPrefs((current) => {
|
|
40
|
-
const merged = {
|
|
41
|
-
...current,
|
|
42
|
-
...updates
|
|
43
|
-
};
|
|
44
|
-
writePrefs(tableId, merged);
|
|
45
|
-
return merged;
|
|
46
|
-
});
|
|
47
|
-
}, [tableId])
|
|
33
|
+
prefs: tableId ? prefs : {},
|
|
34
|
+
savePrefs
|
|
48
35
|
};
|
|
49
36
|
};
|
|
50
37
|
export { useTablePreferences };
|
|
@@ -1 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Where a cursor-paged list was for this tab, per `sessionKey`: the first row in view and the
|
|
3
|
+
* scroll offset, both under the `filters` they were seen with.
|
|
4
|
+
*/
|
|
5
|
+
export declare const tablePositionState: import("jotai-family").AtomFamily<string, import("jotai").WritableAtom<{
|
|
6
|
+
filters: string;
|
|
7
|
+
row: string;
|
|
8
|
+
scroll: number;
|
|
9
|
+
}, [typeof import("jotai/utils").RESET | {
|
|
10
|
+
filters: string;
|
|
11
|
+
row: string;
|
|
12
|
+
scroll: number;
|
|
13
|
+
} | ((prev: {
|
|
14
|
+
filters: string;
|
|
15
|
+
row: string;
|
|
16
|
+
scroll: number;
|
|
17
|
+
}) => typeof import("jotai/utils").RESET | {
|
|
18
|
+
filters: string;
|
|
19
|
+
row: string;
|
|
20
|
+
scroll: number;
|
|
21
|
+
})], void>>;
|
|
@@ -1,4 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { storedFamily } from "../../../lib/stored.js";
|
|
2
|
+
import { z } from "zod";
|
|
2
3
|
// src/modules/record-table/states/RecordTableCursorState.ts
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Where a cursor-paged list was for this tab, per `sessionKey`: the first row in view and the
|
|
6
|
+
* scroll offset, both under the `filters` they were seen with.
|
|
7
|
+
*/
|
|
8
|
+
const tablePositionState = storedFamily({
|
|
9
|
+
key: "erxes:table:position",
|
|
10
|
+
session: true,
|
|
11
|
+
schema: z.object({
|
|
12
|
+
filters: z.string(),
|
|
13
|
+
row: z.string(),
|
|
14
|
+
scroll: z.number()
|
|
15
|
+
}),
|
|
16
|
+
initial: {
|
|
17
|
+
filters: "",
|
|
18
|
+
row: "",
|
|
19
|
+
scroll: 0
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
export { tablePositionState };
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { stored } from "../lib/stored.js";
|
|
2
2
|
import { atom } from "jotai";
|
|
3
|
+
import { z } from "zod";
|
|
3
4
|
// src/state/sidebarPanelState.ts
|
|
4
|
-
const sidebarPanelOpenState =
|
|
5
|
+
const sidebarPanelOpenState = stored({
|
|
6
|
+
key: "erxes:ui:sidebar-open",
|
|
7
|
+
schema: z.boolean(),
|
|
8
|
+
initial: true
|
|
9
|
+
});
|
|
5
10
|
/** On a phone, the path the panel was opened on: it covers the page, so it closes when you leave. */
|
|
6
11
|
const sidebarPanelOpenedAtState = atom(null);
|
|
7
12
|
export { sidebarPanelOpenState, sidebarPanelOpenedAtState };
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const ThemeOption: z.ZodEnum<{
|
|
3
|
+
dark: "dark";
|
|
4
|
+
light: "light";
|
|
5
|
+
system: "system";
|
|
6
|
+
}>;
|
|
7
|
+
export type ThemeOption = z.infer<typeof ThemeOption>;
|
|
8
|
+
export declare const themeState: import("jotai").WritableAtom<"dark" | "light" | "system", ["dark" | "light" | "system" | typeof import("jotai/utils").RESET | ((prev: "dark" | "light" | "system") => "dark" | "light" | "system" | typeof import("jotai/utils").RESET)], void>;
|
package/dist/state/themeState.js
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
1
|
+
import { stored } from "../lib/stored.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
const ThemeOption = z.enum([
|
|
4
|
+
"light",
|
|
5
|
+
"dark",
|
|
6
|
+
"system"
|
|
7
|
+
]);
|
|
8
|
+
const themeState = stored({
|
|
9
|
+
key: "erxes:ui:theme",
|
|
10
|
+
schema: ThemeOption,
|
|
11
|
+
initial: "system"
|
|
12
|
+
});
|
|
13
|
+
export { ThemeOption, themeState };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@erxes/ui",
|
|
3
|
-
"version": "4.0.0-v2.
|
|
3
|
+
"version": "4.0.0-v2.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "erxes design system: UI primitives, layout, hooks and shared frontend state",
|
|
6
6
|
"license": "AGPL-3.0-only",
|
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
"date-fns": "4.1.0",
|
|
57
57
|
"jotai-family": "1.1.0",
|
|
58
58
|
"libphonenumber-js": "1.12.6",
|
|
59
|
+
"nuqs": "^2.10.3",
|
|
59
60
|
"react-day-picker": "10.0.2",
|
|
60
61
|
"react-hook-form": "7.55.0",
|
|
61
62
|
"react-hotkeys-hook": "5.4.0",
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
export declare const INTL_LANGUAGES: {
|
|
2
|
-
English: string;
|
|
3
|
-
'English (UK)': string;
|
|
4
|
-
Spanish: string;
|
|
5
|
-
'Spanish (Mexico)': string;
|
|
6
|
-
French: string;
|
|
7
|
-
'French (Canada)': string;
|
|
8
|
-
German: string;
|
|
9
|
-
Italian: string;
|
|
10
|
-
Portuguese: string;
|
|
11
|
-
'Portuguese (Brazil)': string;
|
|
12
|
-
Russian: string;
|
|
13
|
-
'Chinese (Simplified)': string;
|
|
14
|
-
'Chinese (Traditional)': string;
|
|
15
|
-
Japanese: string;
|
|
16
|
-
Korean: string;
|
|
17
|
-
Arabic: string;
|
|
18
|
-
Hindi: string;
|
|
19
|
-
Dutch: string;
|
|
20
|
-
Swedish: string;
|
|
21
|
-
Norwegian: string;
|
|
22
|
-
Danish: string;
|
|
23
|
-
Finnish: string;
|
|
24
|
-
Polish: string;
|
|
25
|
-
Czech: string;
|
|
26
|
-
Hungarian: string;
|
|
27
|
-
Romanian: string;
|
|
28
|
-
Bulgarian: string;
|
|
29
|
-
Croatian: string;
|
|
30
|
-
Serbian: string;
|
|
31
|
-
Slovak: string;
|
|
32
|
-
Slovenian: string;
|
|
33
|
-
Estonian: string;
|
|
34
|
-
Latvian: string;
|
|
35
|
-
Lithuanian: string;
|
|
36
|
-
Greek: string;
|
|
37
|
-
Turkish: string;
|
|
38
|
-
Hebrew: string;
|
|
39
|
-
Thai: string;
|
|
40
|
-
Vietnamese: string;
|
|
41
|
-
Indonesian: string;
|
|
42
|
-
Malay: string;
|
|
43
|
-
Filipino: string;
|
|
44
|
-
Ukrainian: string;
|
|
45
|
-
Belarusian: string;
|
|
46
|
-
Kazakh: string;
|
|
47
|
-
Uzbek: string;
|
|
48
|
-
Georgian: string;
|
|
49
|
-
Armenian: string;
|
|
50
|
-
Azerbaijani: string;
|
|
51
|
-
Persian: string;
|
|
52
|
-
Urdu: string;
|
|
53
|
-
Bengali: string;
|
|
54
|
-
Tamil: string;
|
|
55
|
-
Telugu: string;
|
|
56
|
-
Marathi: string;
|
|
57
|
-
Gujarati: string;
|
|
58
|
-
Kannada: string;
|
|
59
|
-
Malayalam: string;
|
|
60
|
-
Punjabi: string;
|
|
61
|
-
Nepali: string;
|
|
62
|
-
Sinhala: string;
|
|
63
|
-
Burmese: string;
|
|
64
|
-
Khmer: string;
|
|
65
|
-
Lao: string;
|
|
66
|
-
Mongolian: string;
|
|
67
|
-
Tibetan: string;
|
|
68
|
-
Swahili: string;
|
|
69
|
-
Afrikaans: string;
|
|
70
|
-
Amharic: string;
|
|
71
|
-
Yoruba: string;
|
|
72
|
-
Igbo: string;
|
|
73
|
-
Hausa: string;
|
|
74
|
-
};
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
// src/constants/IntlLanguages.ts
|
|
2
|
-
const INTL_LANGUAGES = {
|
|
3
|
-
English: "en-US",
|
|
4
|
-
"English (UK)": "en-GB",
|
|
5
|
-
Spanish: "es-ES",
|
|
6
|
-
"Spanish (Mexico)": "es-MX",
|
|
7
|
-
French: "fr-FR",
|
|
8
|
-
"French (Canada)": "fr-CA",
|
|
9
|
-
German: "de-DE",
|
|
10
|
-
Italian: "it-IT",
|
|
11
|
-
Portuguese: "pt-PT",
|
|
12
|
-
"Portuguese (Brazil)": "pt-BR",
|
|
13
|
-
Russian: "ru-RU",
|
|
14
|
-
"Chinese (Simplified)": "zh-CN",
|
|
15
|
-
"Chinese (Traditional)": "zh-TW",
|
|
16
|
-
Japanese: "ja-JP",
|
|
17
|
-
Korean: "ko-KR",
|
|
18
|
-
Arabic: "ar-SA",
|
|
19
|
-
Hindi: "hi-IN",
|
|
20
|
-
Dutch: "nl-NL",
|
|
21
|
-
Swedish: "sv-SE",
|
|
22
|
-
Norwegian: "no-NO",
|
|
23
|
-
Danish: "da-DK",
|
|
24
|
-
Finnish: "fi-FI",
|
|
25
|
-
Polish: "pl-PL",
|
|
26
|
-
Czech: "cs-CZ",
|
|
27
|
-
Hungarian: "hu-HU",
|
|
28
|
-
Romanian: "ro-RO",
|
|
29
|
-
Bulgarian: "bg-BG",
|
|
30
|
-
Croatian: "hr-HR",
|
|
31
|
-
Serbian: "sr-RS",
|
|
32
|
-
Slovak: "sk-SK",
|
|
33
|
-
Slovenian: "sl-SI",
|
|
34
|
-
Estonian: "et-EE",
|
|
35
|
-
Latvian: "lv-LV",
|
|
36
|
-
Lithuanian: "lt-LT",
|
|
37
|
-
Greek: "el-GR",
|
|
38
|
-
Turkish: "tr-TR",
|
|
39
|
-
Hebrew: "he-IL",
|
|
40
|
-
Thai: "th-TH",
|
|
41
|
-
Vietnamese: "vi-VN",
|
|
42
|
-
Indonesian: "id-ID",
|
|
43
|
-
Malay: "ms-MY",
|
|
44
|
-
Filipino: "fil-PH",
|
|
45
|
-
Ukrainian: "uk-UA",
|
|
46
|
-
Belarusian: "be-BY",
|
|
47
|
-
Kazakh: "kk-KZ",
|
|
48
|
-
Uzbek: "uz-UZ",
|
|
49
|
-
Georgian: "ka-GE",
|
|
50
|
-
Armenian: "hy-AM",
|
|
51
|
-
Azerbaijani: "az-AZ",
|
|
52
|
-
Persian: "fa-IR",
|
|
53
|
-
Urdu: "ur-PK",
|
|
54
|
-
Bengali: "bn-BD",
|
|
55
|
-
Tamil: "ta-IN",
|
|
56
|
-
Telugu: "te-IN",
|
|
57
|
-
Marathi: "mr-IN",
|
|
58
|
-
Gujarati: "gu-IN",
|
|
59
|
-
Kannada: "kn-IN",
|
|
60
|
-
Malayalam: "ml-IN",
|
|
61
|
-
Punjabi: "pa-IN",
|
|
62
|
-
Nepali: "ne-NP",
|
|
63
|
-
Sinhala: "si-LK",
|
|
64
|
-
Burmese: "my-MM",
|
|
65
|
-
Khmer: "km-KH",
|
|
66
|
-
Lao: "lo-LA",
|
|
67
|
-
Mongolian: "mn-MN",
|
|
68
|
-
Tibetan: "bo-CN",
|
|
69
|
-
Swahili: "sw-KE",
|
|
70
|
-
Afrikaans: "af-ZA",
|
|
71
|
-
Amharic: "am-ET",
|
|
72
|
-
Yoruba: "yo-NG",
|
|
73
|
-
Igbo: "ig-NG",
|
|
74
|
-
Hausa: "ha-NG"
|
|
75
|
-
};
|
|
76
|
-
export { INTL_LANGUAGES };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { NavigateOptions } from "react-router-dom";
|
|
3
|
-
type QuerySchemas = Record<string, z.ZodType>;
|
|
4
|
-
/** Values to write; null removes the key, a missing key stays as it is. */
|
|
5
|
-
type QueryValues<S extends QuerySchemas> = { [K in keyof S]?: z.output<S[K]> | null; };
|
|
6
|
-
export type QueryState<T> = [T | null, (value: T | null, navigationOptions?: NavigateOptions) => void];
|
|
7
|
-
/** Reads and updates one URL query value while preserving concurrent query changes. */
|
|
8
|
-
export declare function useQueryState<S extends z.ZodType>(queryKey: string, schema: S): QueryState<z.output<S>>;
|
|
9
|
-
/**
|
|
10
|
-
* Reads and updates several query values through one shared navigation draft.
|
|
11
|
-
* Each key's value is checked against its schema; absent and invalid ones are undefined.
|
|
12
|
-
*/
|
|
13
|
-
export declare function useMultiQueryState<S extends QuerySchemas>(schemas: S): readonly [z.core.$InferObjectOutput<{ -readonly [k in keyof { -readonly [P in keyof S]: S[P]; }]: z.ZodOptional<{ -readonly [P in keyof S]: S[P]; }[k]>; }, {}>, (values: QueryValues<S>, navigationOptions?: NavigateOptions) => void];
|
|
14
|
-
/** Creates a remover that preserves the remaining query values and router state. */
|
|
15
|
-
export declare function useRemoveQueryStateByKey(): (key: string) => void;
|
|
16
|
-
export {};
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { jsonOf } from "../utils/json.js";
|
|
2
|
-
import { useLayoutEffect, useRef } from "react";
|
|
3
|
-
import { z } from "zod";
|
|
4
|
-
import { useLocation, useSearchParams } from "react-router-dom";
|
|
5
|
-
// src/hooks/use-query-state.tsx
|
|
6
|
-
let searchParamsDraft = null;
|
|
7
|
-
const getSearchParamsDraft = (location) => {
|
|
8
|
-
if (!searchParamsDraft || searchParamsDraft.location !== location) {
|
|
9
|
-
const draft = {
|
|
10
|
-
location,
|
|
11
|
-
params: new URLSearchParams(location.search),
|
|
12
|
-
state: location.state
|
|
13
|
-
};
|
|
14
|
-
searchParamsDraft = draft;
|
|
15
|
-
queueMicrotask(() => {
|
|
16
|
-
if (searchParamsDraft === draft) searchParamsDraft = null;
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
return searchParamsDraft;
|
|
20
|
-
};
|
|
21
|
-
/** Returns a reader for pending query changes at the latest router location. */
|
|
22
|
-
const useSearchParamsDraft = () => {
|
|
23
|
-
const location = useLocation();
|
|
24
|
-
const latestLocation = useRef(location);
|
|
25
|
-
useLayoutEffect(() => {
|
|
26
|
-
latestLocation.current = location;
|
|
27
|
-
});
|
|
28
|
-
return () => getSearchParamsDraft(latestLocation.current);
|
|
29
|
-
};
|
|
30
|
-
/** Preserves pending query values and explicit navigation state for the next setter. */
|
|
31
|
-
const updateSearchParamsDraft = (draft, nextParams, navigationOptions) => {
|
|
32
|
-
draft.params = new URLSearchParams(nextParams);
|
|
33
|
-
if (navigationOptions && "state" in navigationOptions) draft.state = navigationOptions.state;
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* The query value in the form its schema takes: as written (strings), else as
|
|
37
|
-
* JSON (numbers, booleans, arrays, objects). Anyone can edit a URL, so a value
|
|
38
|
-
* that fits neither is undefined, read as absent.
|
|
39
|
-
*/
|
|
40
|
-
const queryInput = (schema, value) => {
|
|
41
|
-
if (!value) return void 0;
|
|
42
|
-
if (schema.safeParse(value).success) return value;
|
|
43
|
-
const decoded = jsonOf(z.json()).safeParse(value);
|
|
44
|
-
return decoded.success && schema.safeParse(decoded.data).success ? decoded.data : void 0;
|
|
45
|
-
};
|
|
46
|
-
/** Strings as written, everything else (numbers, booleans, objects) as JSON. */
|
|
47
|
-
const toQueryString = (value) => typeof value === "string" ? value : JSON.stringify(value);
|
|
48
|
-
/** Reads and updates one URL query value while preserving concurrent query changes. */
|
|
49
|
-
function useQueryState(queryKey, schema) {
|
|
50
|
-
const [searchParams, setSearchParams] = useSearchParams();
|
|
51
|
-
const getDraft = useSearchParamsDraft();
|
|
52
|
-
const value = schema.safeParse(queryInput(schema, searchParams.get(queryKey))).data ?? null;
|
|
53
|
-
/** Updates the requested query key without discarding other pending query changes. */
|
|
54
|
-
const setQuery = (next, navigationOptions) => {
|
|
55
|
-
const draft = getDraft();
|
|
56
|
-
const nextParams = new URLSearchParams(draft.params);
|
|
57
|
-
if (next !== null) {
|
|
58
|
-
const stringValue = toQueryString(next);
|
|
59
|
-
if (nextParams.get(queryKey) === stringValue && !navigationOptions) return;
|
|
60
|
-
if (!nextParams.has(queryKey) && next === value && !navigationOptions) return;
|
|
61
|
-
nextParams.set(queryKey, stringValue);
|
|
62
|
-
} else if (nextParams.has(queryKey)) nextParams.delete(queryKey);
|
|
63
|
-
else if (!navigationOptions) return;
|
|
64
|
-
updateSearchParamsDraft(draft, nextParams, navigationOptions);
|
|
65
|
-
setSearchParams(nextParams, {
|
|
66
|
-
...navigationOptions,
|
|
67
|
-
state: draft.state
|
|
68
|
-
});
|
|
69
|
-
};
|
|
70
|
-
return [value, setQuery];
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Reads and updates several query values through one shared navigation draft.
|
|
74
|
-
* Each key's value is checked against its schema; absent and invalid ones are undefined.
|
|
75
|
-
*/
|
|
76
|
-
function useMultiQueryState(schemas) {
|
|
77
|
-
const [searchParams, setSearchParams] = useSearchParams();
|
|
78
|
-
const getDraft = useSearchParamsDraft();
|
|
79
|
-
const queries = z.object(schemas).partial().parse(Object.fromEntries(Object.entries(schemas).map(([key, schema]) => [key, queryInput(schema, searchParams.get(key))])));
|
|
80
|
-
/** Applies a batch without discarding other query changes from the same event. */
|
|
81
|
-
const setQueries = (values, navigationOptions) => {
|
|
82
|
-
const draft = getDraft();
|
|
83
|
-
const nextParams = new URLSearchParams(draft.params);
|
|
84
|
-
let hasChanges = false;
|
|
85
|
-
for (const [key, value] of Object.entries(values)) {
|
|
86
|
-
if (value === void 0) continue;
|
|
87
|
-
if (value !== null) {
|
|
88
|
-
const stringValue = toQueryString(value);
|
|
89
|
-
if (nextParams.get(key) === stringValue) continue;
|
|
90
|
-
nextParams.set(key, stringValue);
|
|
91
|
-
hasChanges = true;
|
|
92
|
-
} else if (nextParams.has(key)) {
|
|
93
|
-
nextParams.delete(key);
|
|
94
|
-
hasChanges = true;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
if (!hasChanges && !navigationOptions) return;
|
|
98
|
-
updateSearchParamsDraft(draft, nextParams, navigationOptions);
|
|
99
|
-
setSearchParams(nextParams, {
|
|
100
|
-
replace: true,
|
|
101
|
-
...navigationOptions,
|
|
102
|
-
state: draft.state
|
|
103
|
-
});
|
|
104
|
-
};
|
|
105
|
-
return [queries, setQueries];
|
|
106
|
-
}
|
|
107
|
-
/** Creates a remover that preserves the remaining query values and router state. */
|
|
108
|
-
function useRemoveQueryStateByKey() {
|
|
109
|
-
const [, setSearchParams] = useSearchParams();
|
|
110
|
-
const getDraft = useSearchParamsDraft();
|
|
111
|
-
/** Removes one query key when present and preserves other pending changes. */
|
|
112
|
-
const removeQuery = (key) => {
|
|
113
|
-
const draft = getDraft();
|
|
114
|
-
const nextParams = new URLSearchParams(draft.params);
|
|
115
|
-
if (!nextParams.has(key)) return;
|
|
116
|
-
nextParams.delete(key);
|
|
117
|
-
updateSearchParamsDraft(draft, nextParams);
|
|
118
|
-
setSearchParams(nextParams, { state: draft.state });
|
|
119
|
-
};
|
|
120
|
-
return removeQuery;
|
|
121
|
-
}
|
|
122
|
-
export { useMultiQueryState, useQueryState, useRemoveQueryStateByKey };
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { QueryState } from "../../../hooks/use-query-state.js";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
/** A filter's query value; changing it sends the table back to its first page. */
|
|
4
|
-
export declare function useFilterQueryState<S extends z.ZodType>(queryKey: string, schema: S, cursorKey?: string): QueryState<z.output<S>>;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { useQueryState } from "../../../hooks/use-query-state.js";
|
|
2
|
-
import { recordTableCursorAtomFamily } from "../../record-table/states/RecordTableCursorState.js";
|
|
3
|
-
import { useSetAtom } from "jotai";
|
|
4
|
-
// src/modules/filter/hooks/useFilterQueryState.tsx
|
|
5
|
-
/** A filter's query value; changing it sends the table back to its first page. */
|
|
6
|
-
function useFilterQueryState(queryKey, schema, cursorKey) {
|
|
7
|
-
const [query, setQuery] = useQueryState(queryKey, schema);
|
|
8
|
-
const setCursor = useSetAtom(recordTableCursorAtomFamily(cursorKey ?? ""));
|
|
9
|
-
return [query, (value) => {
|
|
10
|
-
setQuery(value);
|
|
11
|
-
if (cursorKey) setCursor("");
|
|
12
|
-
}];
|
|
13
|
-
}
|
|
14
|
-
export { useFilterQueryState };
|
package/dist/types/Theme.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type ThemeOption = 'light' | 'dark' | 'system';
|
package/dist/types/Theme.js
DELETED
|
File without changes
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { differenceInDays, formatDistance, formatDistanceStrict, isToday, startOfDay } from "date-fns";
|
|
2
|
-
// src/utils/localization/formatDateISOStringToRelativeDate.ts
|
|
3
|
-
const formatDateISOStringToRelativeDate = (isoDate, isDayMaximumPrecision = false) => {
|
|
4
|
-
const now = /* @__PURE__ */ new Date();
|
|
5
|
-
const targetDate = new Date(isoDate);
|
|
6
|
-
if (isDayMaximumPrecision && isToday(targetDate)) return "Today";
|
|
7
|
-
const isWithin24h = Math.abs(differenceInDays(targetDate, now)) < 1;
|
|
8
|
-
if (isDayMaximumPrecision || !isWithin24h) return formatDistance(startOfDay(targetDate), startOfDay(now), { addSuffix: true });
|
|
9
|
-
return formatDistance(targetDate, now, { addSuffix: true });
|
|
10
|
-
};
|
|
11
|
-
const formatDateISOStringToRelativeDateShort = (isoDate) => {
|
|
12
|
-
const now = /* @__PURE__ */ new Date();
|
|
13
|
-
const targetDate = new Date(isoDate);
|
|
14
|
-
return formatDistanceStrict(targetDate, now, { addSuffix: false }).replace(/\s*years?/g, "y").replace(/\s*months?/g, "mo").replace(/\s*days?/g, "d").replace(/\s*hours?/g, "h").replace(/\s*minutes?/g, "m").replace(/\s*seconds?/g, "s");
|
|
15
|
-
};
|
|
16
|
-
export { formatDateISOStringToRelativeDate, formatDateISOStringToRelativeDateShort };
|