@douglasneuroinformatics/libui 3.8.6 → 3.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-M5H3G5VE.js → chunk-IYOZHDZL.js} +27 -10
- package/dist/chunk-IYOZHDZL.js.map +1 -0
- package/dist/{chunk-GLOKPJGE.js → chunk-JTEI2ZYI.js} +2 -2
- package/dist/components.d.ts +61 -61
- package/dist/components.js +46 -10
- package/dist/components.js.map +1 -1
- package/dist/hooks.d.ts +1 -1
- package/dist/hooks.js +2 -2
- package/dist/i18n.d.ts +11 -3
- package/dist/i18n.js +1 -1
- package/dist/{types-DTkK8l-q.d.ts → types-CU3FS63U.d.ts} +12 -4
- package/package.json +5 -7
- package/src/components/ArrowToggle/ArrowToggle.tsx +2 -2
- package/src/components/Breadcrumb/BreadcrumbLink.tsx +2 -2
- package/src/components/Breadcrumb/BreadcrumbRoot.tsx +2 -2
- package/src/components/Button/Button.tsx +6 -6
- package/src/components/Chart/ChartContainer.tsx +2 -2
- package/src/components/Chart/ChartLegendContent.tsx +5 -5
- package/src/components/Chart/ChartTooltipContent.tsx +8 -8
- package/src/components/ClientTable/ClientTable.spec.tsx +87 -0
- package/src/components/ClientTable/ClientTable.tsx +2 -1
- package/src/components/ClientTable/ClientTablePagination.tsx +28 -1
- package/src/components/ContextMenu/ContextMenuItem.tsx +2 -2
- package/src/components/ContextMenu/ContextMenuLabel.tsx +2 -2
- package/src/components/ContextMenu/ContextMenuSubTrigger.tsx +2 -2
- package/src/components/DropdownMenu/DropdownMenuContent.tsx +2 -2
- package/src/components/DropdownMenu/DropdownMenuItem.tsx +2 -2
- package/src/components/DropdownMenu/DropdownMenuLabel.tsx +2 -2
- package/src/components/DropdownMenu/DropdownMenuSubTrigger.tsx +2 -2
- package/src/components/Form/BaseRadioField.tsx +2 -2
- package/src/components/Form/Form.stories.tsx +0 -1
- package/src/components/Form/Form.tsx +0 -1
- package/src/components/Form/ScalarField.tsx +8 -8
- package/src/components/Form/SetField/SetFieldListbox.tsx +2 -2
- package/src/components/Form/SetField/SetFieldSelect.tsx +2 -2
- package/src/components/LineGraph/LineGraph.tsx +5 -2
- package/src/components/MenuBar/MenuBarItem.tsx +2 -2
- package/src/components/MenuBar/MenuBarLabel.tsx +2 -2
- package/src/components/MenuBar/MenuBarSubTrigger.tsx +2 -2
- package/src/components/Pagination/PaginationLink.tsx +4 -4
- package/src/components/Resizable/Resizable.tsx +2 -2
- package/src/components/Resizable/ResizableHandle.tsx +2 -2
- package/src/components/SearchBar/SearchBar.tsx +4 -4
- package/src/i18n/store.ts +18 -9
- package/src/i18n/translations/libui.json +8 -0
- package/src/i18n/types.ts +4 -4
- package/dist/chunk-M5H3G5VE.js.map +0 -1
- package/dist/douglasneuroinformatics-libui-3.8.6.tgz +0 -0
- /package/dist/{chunk-GLOKPJGE.js.map → chunk-JTEI2ZYI.js.map} +0 -0
|
@@ -7,9 +7,9 @@ import { cn } from '@/utils';
|
|
|
7
7
|
|
|
8
8
|
export const MenuBarSubTrigger = forwardRef<
|
|
9
9
|
React.ElementRef<typeof SubTrigger>,
|
|
10
|
-
{
|
|
10
|
+
React.ComponentPropsWithoutRef<typeof SubTrigger> & {
|
|
11
11
|
inset?: boolean;
|
|
12
|
-
}
|
|
12
|
+
}
|
|
13
13
|
>(function MenuBarSubTrigger({ children, className, inset, ...props }, ref) {
|
|
14
14
|
return (
|
|
15
15
|
<SubTrigger
|
|
@@ -7,10 +7,10 @@ import { cn } from '@/utils';
|
|
|
7
7
|
import { type ButtonProps, buttonVariants } from '../Button';
|
|
8
8
|
|
|
9
9
|
export type PaginationLinkProps = Simplify<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
Pick<ButtonProps, 'size'> &
|
|
11
|
+
React.ComponentProps<'a'> & {
|
|
12
|
+
isActive?: boolean;
|
|
13
|
+
}
|
|
14
14
|
>;
|
|
15
15
|
|
|
16
16
|
export const PaginationLink = ({ children, className, isActive, size = 'icon', ...props }: PaginationLinkProps) => (
|
|
@@ -6,11 +6,11 @@ import { ResizableHandle, type ResizableHandleProps } from './ResizableHandle';
|
|
|
6
6
|
import { ResizablePanelGroup, type ResizablePanelGroupProps } from './ResizablePanelGroup';
|
|
7
7
|
|
|
8
8
|
type ResizableRootType = React.FC<{ children: React.ReactNode }>;
|
|
9
|
-
type ResizableType = {
|
|
9
|
+
type ResizableType = ResizableRootType & {
|
|
10
10
|
Handle: React.FC<ResizableHandleProps>;
|
|
11
11
|
Panel: React.FC<PanelProps>;
|
|
12
12
|
PanelGroup: React.FC<ResizablePanelGroupProps>;
|
|
13
|
-
}
|
|
13
|
+
};
|
|
14
14
|
|
|
15
15
|
// This is only for storybook and is unnecessary for real-world use
|
|
16
16
|
const ResizableRoot: ResizableRootType = ({ children }) => <>{children}</>;
|
|
@@ -5,9 +5,9 @@ import { PanelResizeHandle } from 'react-resizable-panels';
|
|
|
5
5
|
|
|
6
6
|
import { cn } from '@/utils';
|
|
7
7
|
|
|
8
|
-
export type ResizableHandleProps = {
|
|
8
|
+
export type ResizableHandleProps = React.ComponentProps<typeof PanelResizeHandle> & {
|
|
9
9
|
withHandle?: boolean;
|
|
10
|
-
}
|
|
10
|
+
};
|
|
11
11
|
|
|
12
12
|
export const ResizableHandle = ({ className, withHandle, ...props }: ResizableHandleProps) => (
|
|
13
13
|
<PanelResizeHandle
|
|
@@ -19,17 +19,17 @@ export type BaseSearchBarProps = {
|
|
|
19
19
|
readOnly?: boolean;
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
type ControlledSearchBarProps = {
|
|
22
|
+
type ControlledSearchBarProps = BaseSearchBarProps & {
|
|
23
23
|
/** Event handler called when the value changes */
|
|
24
24
|
onValueChange: (value: string) => void;
|
|
25
25
|
/** The controlled value of the search bar, which should be used in conjunction with onValueChange */
|
|
26
26
|
value: string;
|
|
27
|
-
}
|
|
27
|
+
};
|
|
28
28
|
|
|
29
|
-
type UncontrolledSearchBarProps = {
|
|
29
|
+
type UncontrolledSearchBarProps = BaseSearchBarProps & {
|
|
30
30
|
onValueChange?: never;
|
|
31
31
|
value?: never;
|
|
32
|
-
}
|
|
32
|
+
};
|
|
33
33
|
|
|
34
34
|
export type SearchBarProps = ControlledSearchBarProps | UncontrolledSearchBarProps;
|
|
35
35
|
|
package/src/i18n/store.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { SetOptional } from 'type-fest';
|
|
2
|
+
import { subscribeWithSelector } from 'zustand/middleware';
|
|
2
3
|
import { createStore } from 'zustand/vanilla';
|
|
3
4
|
|
|
4
5
|
import libui from '@/i18n/translations/libui.json';
|
|
@@ -26,15 +27,17 @@ export type TranslationStore = {
|
|
|
26
27
|
translations: Translations;
|
|
27
28
|
};
|
|
28
29
|
|
|
29
|
-
export const translationStore = createStore
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
30
|
+
export const translationStore = createStore(
|
|
31
|
+
subscribeWithSelector<TranslationStore>((set) => ({
|
|
32
|
+
changeLanguage(language) {
|
|
33
|
+
set({ resolvedLanguage: language });
|
|
34
|
+
},
|
|
35
|
+
fallbackLanguage: 'en',
|
|
36
|
+
isInitialized: false,
|
|
37
|
+
resolvedLanguage: 'en',
|
|
38
|
+
translations: { libui }
|
|
39
|
+
}))
|
|
40
|
+
);
|
|
38
41
|
|
|
39
42
|
export const i18n: I18N = {
|
|
40
43
|
init: ({ defaultLanguage, fallbackLanguage, translations }: InitOptions = {}) => {
|
|
@@ -43,6 +46,12 @@ export const i18n: I18N = {
|
|
|
43
46
|
console.error('Cannot reinitialize translations store');
|
|
44
47
|
return;
|
|
45
48
|
}
|
|
49
|
+
translationStore.subscribe(
|
|
50
|
+
(state) => state.resolvedLanguage,
|
|
51
|
+
(resolvedLanguage) => {
|
|
52
|
+
document.documentElement.lang = resolvedLanguage;
|
|
53
|
+
}
|
|
54
|
+
);
|
|
46
55
|
translationStore.setState({
|
|
47
56
|
fallbackLanguage: fallbackLanguage ?? state.fallbackLanguage,
|
|
48
57
|
isInitialized: true,
|
package/src/i18n/types.ts
CHANGED
|
@@ -18,17 +18,17 @@ export declare namespace UserConfig {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
export type LanguageOptions = {
|
|
21
|
+
export type LanguageOptions = UserConfig.LanguageOptions & {
|
|
22
22
|
en: true;
|
|
23
23
|
fr: true;
|
|
24
|
-
}
|
|
24
|
+
};
|
|
25
25
|
|
|
26
26
|
export type Language = keyof { [L in keyof LanguageOptions as LanguageOptions[L] extends true ? L : never]: any };
|
|
27
27
|
|
|
28
28
|
export type Translations = Simplify<
|
|
29
|
-
{
|
|
29
|
+
OmitIndexSignature<UserConfig.Translations> & {
|
|
30
30
|
libui: typeof libuiTranslations;
|
|
31
|
-
}
|
|
31
|
+
}
|
|
32
32
|
>;
|
|
33
33
|
|
|
34
34
|
export type ExtractTranslationKey<T extends { [key: string]: any }, Key = keyof T> = Key extends string
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/i18n/store.ts","../src/i18n/translations/libui.json","../src/i18n/internal.ts"],"sourcesContent":["import type { SetOptional } from 'type-fest';\nimport { createStore } from 'zustand/vanilla';\n\nimport libui from '@/i18n/translations/libui.json';\n\nimport { getTranslation } from './internal';\n\nimport type { Language, TranslateFunction, Translations } from './types';\n\ntype InitOptions = {\n defaultLanguage?: Language;\n fallbackLanguage?: Language;\n translations?: SetOptional<Translations, 'libui'>;\n};\n\ntype I18N = {\n init: (options?: InitOptions) => void;\n t: TranslateFunction;\n};\n\nexport type TranslationStore = {\n changeLanguage: (language: Language) => void;\n fallbackLanguage: Language;\n isInitialized: boolean;\n resolvedLanguage: Language;\n translations: Translations;\n};\n\nexport const translationStore = createStore<TranslationStore>((set) => ({\n changeLanguage(language) {\n set({ resolvedLanguage: language });\n },\n fallbackLanguage: 'en',\n isInitialized: false,\n resolvedLanguage: 'en',\n translations: { libui }\n}));\n\nexport const i18n: I18N = {\n init: ({ defaultLanguage, fallbackLanguage, translations }: InitOptions = {}) => {\n const state = translationStore.getState();\n if (state.isInitialized) {\n console.error('Cannot reinitialize translations store');\n return;\n }\n translationStore.setState({\n fallbackLanguage: fallbackLanguage ?? state.fallbackLanguage,\n isInitialized: true,\n resolvedLanguage: defaultLanguage ?? state.resolvedLanguage,\n translations: {\n ...state.translations,\n ...translations\n }\n });\n },\n t: (target, ...args) => {\n const state = translationStore.getState();\n return getTranslation(target, state, ...args);\n }\n};\n","{\n \"days\": {\n \"friday\": {\n \"en\": \"Friday\",\n \"fr\": \"Vendredi\"\n },\n \"monday\": {\n \"en\": \"Monday\",\n \"fr\": \"Lundi\"\n },\n \"saturday\": {\n \"en\": \"Saturday\",\n \"fr\": \"Samedi\"\n },\n \"sunday\": {\n \"en\": \"Sunday\",\n \"fr\": \"Dimanche\"\n },\n \"thursday\": {\n \"en\": \"Thursday\",\n \"fr\": \"Jeudi\"\n },\n \"tuesday\": {\n \"en\": \"Tuesday\",\n \"fr\": \"Mardi\"\n },\n \"wednesday\": {\n \"en\": \"Wednesday\",\n \"fr\": \"Mercredi\"\n }\n },\n \"form\": {\n \"append\": {\n \"en\": \"Append\",\n \"fr\": \"Ajouter\"\n },\n \"radioLabels\": {\n \"false\": {\n \"en\": \"False\",\n \"fr\": \"Faux\"\n },\n \"true\": {\n \"en\": \"True\",\n \"fr\": \"Vrai\"\n }\n },\n \"remove\": {\n \"en\": \"Remove\",\n \"fr\": \"Supprimer\"\n },\n \"required\": {\n \"en\": \"This field is required\",\n \"fr\": \"Ce champ est obligatoire\"\n },\n \"reset\": {\n \"en\": \"Reset\",\n \"fr\": \"Réinitialiser\"\n },\n \"submit\": {\n \"en\": \"Submit\",\n \"fr\": \"Soumettre\"\n }\n },\n \"months\": {\n \"april\": {\n \"en\": \"April\",\n \"fr\": \"Avril\"\n },\n \"august\": {\n \"en\": \"August\",\n \"fr\": \"Août\"\n },\n \"december\": {\n \"en\": \"December\",\n \"fr\": \"Décembre\"\n },\n \"february\": {\n \"en\": \"February\",\n \"fr\": \"Février\"\n },\n \"january\": {\n \"en\": \"January\",\n \"fr\": \"Janvier\"\n },\n \"july\": {\n \"en\": \"July\",\n \"fr\": \"Juillet\"\n },\n \"june\": {\n \"en\": \"June\",\n \"fr\": \"Juin\"\n },\n \"march\": {\n \"en\": \"March\",\n \"fr\": \"Mars\"\n },\n \"may\": {\n \"en\": \"May\",\n \"fr\": \"Mai\"\n },\n \"november\": {\n \"en\": \"November\",\n \"fr\": \"Novembre\"\n },\n \"october\": {\n \"en\": \"October\",\n \"fr\": \"Octobre\"\n },\n \"september\": {\n \"en\": \"September\",\n \"fr\": \"Septembre\"\n }\n },\n \"notifications\": {\n \"types\": {\n \"error\": {\n \"en\": \"Error\",\n \"fr\": \"Erreur\"\n },\n \"info\": {\n \"en\": \"Info\",\n \"fr\": \"Attention\"\n },\n \"success\": {\n \"en\": \"Success\",\n \"fr\": \"Succès\"\n },\n \"warning\": {\n \"en\": \"Warning\",\n \"fr\": \"Avertissement\"\n }\n }\n },\n \"pagination\": {\n \"info\": {\n \"en\": \"Showing {{first}} to {{last}} of {{total}} results\",\n \"fr\": \"Affichage de {{first}} à {{last}} sur {{total}} résultats\"\n },\n \"next\": {\n \"en\": \"Next\",\n \"fr\": \"Suivant\"\n },\n \"previous\": {\n \"en\": \"Previous\",\n \"fr\": \"Précédent\"\n }\n },\n \"searchBar\": {\n \"placeholder\": {\n \"en\": \"Search...\",\n \"fr\": \"Rechercher...\"\n }\n }\n}\n","import { format } from '@douglasneuroinformatics/libjs';\nimport { get } from 'lodash-es';\nimport type { Primitive } from 'type-fest';\n\nimport type { Language } from './types';\n\nexport function getTranslation(\n target: { [L in Language]?: string } | string,\n state: {\n fallbackLanguage: Language;\n resolvedLanguage: Language;\n translations: { [key: string]: any };\n },\n ...args: Exclude<Primitive, symbol>[]\n) {\n let value: { [key: string]: string };\n if (typeof target === 'string') {\n value = get(state.translations, target) as { [key: string]: string };\n } else {\n value = target;\n }\n return format((value[state.resolvedLanguage] ?? value[state.fallbackLanguage])!, ...args);\n}\n"],"mappings":";;;AACA,SAAS,mBAAmB;;;ACD5B;AAAA,EACE,MAAQ;AAAA,IACN,QAAU;AAAA,MACR,IAAM;AAAA,MACN,IAAM;AAAA,IACR;AAAA,IACA,QAAU;AAAA,MACR,IAAM;AAAA,MACN,IAAM;AAAA,IACR;AAAA,IACA,UAAY;AAAA,MACV,IAAM;AAAA,MACN,IAAM;AAAA,IACR;AAAA,IACA,QAAU;AAAA,MACR,IAAM;AAAA,MACN,IAAM;AAAA,IACR;AAAA,IACA,UAAY;AAAA,MACV,IAAM;AAAA,MACN,IAAM;AAAA,IACR;AAAA,IACA,SAAW;AAAA,MACT,IAAM;AAAA,MACN,IAAM;AAAA,IACR;AAAA,IACA,WAAa;AAAA,MACX,IAAM;AAAA,MACN,IAAM;AAAA,IACR;AAAA,EACF;AAAA,EACA,MAAQ;AAAA,IACN,QAAU;AAAA,MACR,IAAM;AAAA,MACN,IAAM;AAAA,IACR;AAAA,IACA,aAAe;AAAA,MACb,OAAS;AAAA,QACP,IAAM;AAAA,QACN,IAAM;AAAA,MACR;AAAA,MACA,MAAQ;AAAA,QACN,IAAM;AAAA,QACN,IAAM;AAAA,MACR;AAAA,IACF;AAAA,IACA,QAAU;AAAA,MACR,IAAM;AAAA,MACN,IAAM;AAAA,IACR;AAAA,IACA,UAAY;AAAA,MACV,IAAM;AAAA,MACN,IAAM;AAAA,IACR;AAAA,IACA,OAAS;AAAA,MACP,IAAM;AAAA,MACN,IAAM;AAAA,IACR;AAAA,IACA,QAAU;AAAA,MACR,IAAM;AAAA,MACN,IAAM;AAAA,IACR;AAAA,EACF;AAAA,EACA,QAAU;AAAA,IACR,OAAS;AAAA,MACP,IAAM;AAAA,MACN,IAAM;AAAA,IACR;AAAA,IACA,QAAU;AAAA,MACR,IAAM;AAAA,MACN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