@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
|
@@ -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 +1,5 @@
|
|
|
1
|
-
export declare const sidebarPanelOpenState: import("jotai").WritableAtom<boolean, [boolean | typeof import("jotai/utils").RESET | ((prev: boolean) => boolean | typeof import("jotai/utils").RESET)], void>;
|
|
1
|
+
export declare const sidebarPanelOpenState: import("jotai").WritableAtom<boolean, [boolean | typeof import("jotai/utils").RESET | ((prev: boolean) => boolean | typeof import("jotai/utils").RESET)], void>;
|
|
2
|
+
/** On a phone, the path the panel was opened on: it covers the page, so it closes when you leave. */
|
|
3
|
+
export declare const sidebarPanelOpenedAtState: import("jotai").PrimitiveAtom<string | null> & {
|
|
4
|
+
init: string | null;
|
|
5
|
+
};
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { stored } from "../lib/stored.js";
|
|
2
|
+
import { atom } from "jotai";
|
|
3
|
+
import { z } from "zod";
|
|
2
4
|
// src/state/sidebarPanelState.ts
|
|
3
|
-
const sidebarPanelOpenState =
|
|
4
|
-
|
|
5
|
+
const sidebarPanelOpenState = stored({
|
|
6
|
+
key: "erxes:ui:sidebar-open",
|
|
7
|
+
schema: z.boolean(),
|
|
8
|
+
initial: true
|
|
9
|
+
});
|
|
10
|
+
/** On a phone, the path the panel was opened on: it covers the page, so it closes when you leave. */
|
|
11
|
+
const sidebarPanelOpenedAtState = atom(null);
|
|
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/dist/theme.css
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
Maps utilities to design tokens. Token values live on the host's :root and
|
|
5
5
|
.dark (base.css, imported once by the host page), so this file must not
|
|
6
|
-
declare them. A plugin imports it
|
|
7
|
-
utilities
|
|
6
|
+
declare them. A plugin UI imports it with theme(inline) to build its own
|
|
7
|
+
utilities (create-erxes's ui/src/styles.css), and addPluginStyles adds the
|
|
8
|
+
ones web lacks; see apps/web/src/styles.css for the host.
|
|
8
9
|
*/
|
|
9
10
|
@custom-variant dark (&:is(.dark *));
|
|
10
11
|
/* Inside an app layout whose navigation panel is closed, where its toggle button floats at the
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adds `css`, the plugin's compiled Tailwind (`import css from './styles.css?inline'`), to the
|
|
3
|
+
* page: its utilities layer without the classes the page already has, and its `@property` and
|
|
4
|
+
* `@keyframes` rules. Calling it again for the same plugin replaces its sheet.
|
|
5
|
+
*/
|
|
6
|
+
export declare const addPluginStyles: (plugin: string, css: string) => void;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// src/utils/plugin-styles.ts
|
|
2
|
+
const sheets = /* @__PURE__ */ new Map();
|
|
3
|
+
/** The class a rule is for: `md\:flex` in `.md\:flex`, `space-y-2` in `:where(.space-y-2 > …)`. */
|
|
4
|
+
const CLASS = /\.((?:\\[\da-f]{1,6} ?|\\.|[\w-])+)/i;
|
|
5
|
+
const classOf = (rule) => rule instanceof CSSStyleRule ? CLASS.exec(rule.selectorText)?.[1] : void 0;
|
|
6
|
+
const collectClasses = (rules, into) => {
|
|
7
|
+
for (const rule of rules) {
|
|
8
|
+
const name = classOf(rule);
|
|
9
|
+
if (name) into.add(name);
|
|
10
|
+
else if (rule instanceof CSSGroupingRule) collectClasses(rule.cssRules, into);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
/** Another origin's sheet can't be read; web's own and inline ones can. */
|
|
14
|
+
const sameOrigin = (sheet) => !sheet.href || new URL(sheet.href).origin === window.location.origin;
|
|
15
|
+
/** Every class the page's other style sheets style. */
|
|
16
|
+
const pageClasses = (except) => {
|
|
17
|
+
const classes = /* @__PURE__ */ new Set();
|
|
18
|
+
for (const sheet of [...document.styleSheets, ...document.adoptedStyleSheets]) if (sheet !== except && sameOrigin(sheet)) collectClasses(sheet.cssRules, classes);
|
|
19
|
+
return classes;
|
|
20
|
+
};
|
|
21
|
+
/** Deletes the rules for classes the page has, and the groups that leave empty. */
|
|
22
|
+
const dropKnown = (group, known) => {
|
|
23
|
+
for (let index = group.cssRules.length - 1; index >= 0; index--) {
|
|
24
|
+
const rule = group.cssRules[index];
|
|
25
|
+
const name = rule && classOf(rule);
|
|
26
|
+
if (name !== void 0 && known.has(name)) group.deleteRule(index);
|
|
27
|
+
else if (rule instanceof CSSGroupingRule && !(rule instanceof CSSStyleRule)) {
|
|
28
|
+
dropKnown(rule, known);
|
|
29
|
+
if (rule.cssRules.length === 0) group.deleteRule(index);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
/** What a plugin sheet keeps besides its utilities: the custom properties and keyframes they use. */
|
|
34
|
+
const isSupport = (rule) => rule instanceof CSSPropertyRule || rule instanceof CSSKeyframesRule || rule instanceof CSSLayerStatementRule || rule instanceof CSSLayerBlockRule && rule.name === "properties";
|
|
35
|
+
/**
|
|
36
|
+
* Adds `css`, the plugin's compiled Tailwind (`import css from './styles.css?inline'`), to the
|
|
37
|
+
* page: its utilities layer without the classes the page already has, and its `@property` and
|
|
38
|
+
* `@keyframes` rules. Calling it again for the same plugin replaces its sheet.
|
|
39
|
+
*/
|
|
40
|
+
const addPluginStyles = (plugin, css) => {
|
|
41
|
+
const previous = sheets.get(plugin);
|
|
42
|
+
const sheet = new CSSStyleSheet();
|
|
43
|
+
sheet.replaceSync(css);
|
|
44
|
+
for (let index = sheet.cssRules.length - 1; index >= 0; index--) {
|
|
45
|
+
const rule = sheet.cssRules[index];
|
|
46
|
+
const utilities = rule instanceof CSSLayerBlockRule && rule.name === "utilities";
|
|
47
|
+
if (rule && !utilities && !isSupport(rule)) sheet.deleteRule(index);
|
|
48
|
+
}
|
|
49
|
+
dropKnown(sheet, pageClasses(previous));
|
|
50
|
+
sheets.set(plugin, sheet);
|
|
51
|
+
document.adoptedStyleSheets = [...document.adoptedStyleSheets.filter((adopted) => adopted !== previous), sheet];
|
|
52
|
+
};
|
|
53
|
+
export { addPluginStyles };
|
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",
|
|
@@ -70,6 +71,7 @@
|
|
|
70
71
|
"zod": "4.6.7"
|
|
71
72
|
},
|
|
72
73
|
"devDependencies": {
|
|
74
|
+
"@tanstack/react-query": "^5.107.1",
|
|
73
75
|
"@types/node": "^26.6.6",
|
|
74
76
|
"@types/react": "19.3.0",
|
|
75
77
|
"@types/react-dom": "19.3.0",
|
|
@@ -79,6 +81,7 @@
|
|
|
79
81
|
"react-i18next": "^18.0.1"
|
|
80
82
|
},
|
|
81
83
|
"peerDependencies": {
|
|
84
|
+
"@tanstack/react-query": "^5.107.1",
|
|
82
85
|
"jotai": "^3.0.2",
|
|
83
86
|
"react": "^19.3.1",
|
|
84
87
|
"react-dom": "^19.3.1",
|
|
@@ -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 };
|