@douglasneuroinformatics/libui 4.4.1 → 4.5.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-5B62SIBQ.js +60 -0
- package/dist/chunk-5B62SIBQ.js.map +1 -0
- package/dist/chunk-GT5NL2RJ.js +306 -0
- package/dist/chunk-GT5NL2RJ.js.map +1 -0
- package/dist/{chunk-LSGD4EQY.js → chunk-SGSRBDMT.js} +30 -24
- package/dist/{chunk-LSGD4EQY.js.map → chunk-SGSRBDMT.js.map} +1 -1
- package/dist/components.d.ts +13 -17
- package/dist/components.js +10 -4
- package/dist/components.js.map +1 -1
- package/dist/hooks.d.ts +3 -6
- package/dist/hooks.js +3 -2
- package/dist/i18n.d.ts +25 -28
- package/dist/i18n.js +4 -5
- package/dist/{types-DDyMlEuL.d.ts → types-CxoDu4Em.d.ts} +18 -6
- package/dist/utils.js +1 -0
- package/package.json +9 -15
- package/src/components/Accordion/Accordion.stories.tsx +1 -1
- package/src/components/ActionDropdown/ActionDropdown.stories.tsx +1 -1
- package/src/components/AlertDialog/AlertDialog.stories.tsx +1 -1
- package/src/components/ArrowToggle/ArrowToggle.stories.tsx +1 -1
- package/src/components/Avatar/Avatar.stories.tsx +1 -1
- package/src/components/Badge/Badge.stories.tsx +1 -1
- package/src/components/Breadcrumb/Breadcrumb.stories.tsx +1 -1
- package/src/components/Button/Button.stories.tsx +1 -1
- package/src/components/Card/Card.stories.tsx +1 -1
- package/src/components/Chart/Chart.stories.tsx +1 -1
- package/src/components/Checkbox/Checkbox.stories.tsx +2 -2
- package/src/components/ClientTable/ClientTable.stories.tsx +1 -1
- package/src/components/Collapsible/Collapsible.stories.tsx +1 -1
- package/src/components/Command/Command.stories.tsx +1 -1
- package/src/components/ContextMenu/ContextMenu.stories.tsx +1 -1
- package/src/components/CopyButton/CopyButton.stories.tsx +1 -1
- package/src/components/DataTable/DataTable.stories.tsx +1 -1
- package/src/components/DatePicker/DatePicker.stories.tsx +1 -1
- package/src/components/Dialog/Dialog.stories.tsx +1 -1
- package/src/components/Drawer/Drawer.stories.tsx +1 -1
- package/src/components/DropdownButton/DropdownButton.stories.tsx +1 -1
- package/src/components/DropdownMenu/DropdownMenu.stories.tsx +1 -1
- package/src/components/ErrorFallback/ErrorFallback.stories.tsx +1 -1
- package/src/components/FileDropzone/FileDropzone.stories.tsx +1 -1
- package/src/components/Form/BooleanField/BooleanField.stories.tsx +1 -1
- package/src/components/Form/DateField/DateField.stories.tsx +1 -1
- package/src/components/Form/Form.stories.tsx +1 -1
- package/src/components/Form/Form.tsx +13 -6
- package/src/components/Form/NumberField/NumberField.stories.tsx +1 -1
- package/src/components/Form/SetField/SetField.stories.tsx +1 -1
- package/src/components/Form/StringField/StringField.stories.tsx +1 -1
- package/src/components/Heading/Heading.stories.tsx +1 -1
- package/src/components/HoverCard/HoverCard.stories.tsx +2 -2
- package/src/components/Input/Input.stories.tsx +1 -1
- package/src/components/Label/Label.stories.tsx +1 -1
- package/src/components/LanguageToggle/LanguageToggle.stories.tsx +22 -2
- package/src/components/LineGraph/LineGraph.stories.tsx +1 -1
- package/src/components/ListboxDropdown/ListboxDropdown.stories.tsx +1 -1
- package/src/components/MenuBar/MenuBar.stories.tsx +1 -1
- package/src/components/NotificationHub/NotificationHub.stories.tsx +1 -1
- package/src/components/OneTimePasswordInput/OneTimePasswordInput.stories.tsx +1 -1
- package/src/components/Pagination/Pagination.stories.tsx +1 -1
- package/src/components/Popover/Popover.stories.tsx +4 -4
- package/src/components/Progress/Progress.stories.tsx +1 -1
- package/src/components/RadioGroup/RadioGroup.stories.tsx +1 -1
- package/src/components/Resizable/Resizable.stories.tsx +1 -1
- package/src/components/ScrollArea/ScrollArea.stories.tsx +1 -1
- package/src/components/SearchBar/SearchBar.stories.tsx +1 -1
- package/src/components/Select/Select.stories.tsx +1 -1
- package/src/components/Separator/Separator.stories.tsx +3 -3
- package/src/components/Sheet/Sheet.stories.tsx +1 -1
- package/src/components/Slider/Slider.stories.tsx +1 -1
- package/src/components/Spinner/Spinner.stories.tsx +1 -1
- package/src/components/SpinnerIcon/SpinnerIcon.stories.tsx +1 -1
- package/src/components/StatisticCard/StatisticCard.stories.tsx +1 -1
- package/src/components/Switch/Switch.stories.tsx +1 -1
- package/src/components/Table/Table.stories.tsx +1 -1
- package/src/components/Tabs/Tabs.stories.tsx +1 -1
- package/src/components/TextArea/TextArea.stories.tsx +1 -1
- package/src/components/ThemeToggle/ThemeToggle.stories.tsx +1 -1
- package/src/components/Tooltip/Tooltip.stories.tsx +1 -1
- package/src/hooks/useTranslation/useTranslation.ts +39 -24
- package/src/i18n/__tests__/translator.test.ts +91 -0
- package/src/i18n/index.ts +4 -1
- package/src/i18n/translator.ts +129 -0
- package/src/i18n/types.ts +23 -6
- package/src/testing/mocks.ts +0 -9
- package/src/testing/setup-tests.ts +3 -2
- package/dist/chunk-VFVO337W.js +0 -252
- package/dist/chunk-VFVO337W.js.map +0 -1
- package/src/i18n/internal.ts +0 -23
- package/src/i18n/store.ts +0 -69
package/dist/hooks.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { D as DEFAULT_THEME, a as SYS_DARK_MEDIA_QUERY, S as StorageName, b as T
|
|
|
3
3
|
import { Promisable } from 'type-fest';
|
|
4
4
|
import { RefObject, useEffect, Dispatch, SetStateAction } from 'react';
|
|
5
5
|
import * as zustand from 'zustand';
|
|
6
|
-
import { T as
|
|
6
|
+
import { T as TranslatorType, a as TranslationKey, b as TranslationNamespace, c as TranslationKeyForNamespace } from './types-CxoDu4Em.js';
|
|
7
7
|
|
|
8
8
|
declare function useChart(): {
|
|
9
9
|
config: ChartConfig;
|
|
@@ -72,11 +72,8 @@ declare function useLocalStorage<T>(key: string, initialValue: (() => T) | T, op
|
|
|
72
72
|
/** Custom hook that uses session storage to persist state across page reloads */
|
|
73
73
|
declare function useSessionStorage<T>(key: string, initialValue: (() => T) | T, options?: UseStorageOptions<T>): [T, Dispatch<SetStateAction<T>>];
|
|
74
74
|
|
|
75
|
-
declare function useTranslation
|
|
76
|
-
|
|
77
|
-
resolvedLanguage: "fr" | "en";
|
|
78
|
-
t: TranslateFunction<TNamespace>;
|
|
79
|
-
};
|
|
75
|
+
declare function useTranslation(): TranslatorType<TranslationKey>;
|
|
76
|
+
declare function useTranslation<TNamespace extends TranslationNamespace>(namespace: TNamespace): TranslatorType<TranslationKeyForNamespace<TNamespace>>;
|
|
80
77
|
|
|
81
78
|
type WindowSize = {
|
|
82
79
|
height: number;
|
package/dist/hooks.js
CHANGED
|
@@ -19,9 +19,10 @@ import {
|
|
|
19
19
|
useTheme,
|
|
20
20
|
useTranslation,
|
|
21
21
|
useWindowSize
|
|
22
|
-
} from "./chunk-
|
|
23
|
-
import "./chunk-
|
|
22
|
+
} from "./chunk-SGSRBDMT.js";
|
|
23
|
+
import "./chunk-GT5NL2RJ.js";
|
|
24
24
|
import "./chunk-HCQE34RL.js";
|
|
25
|
+
import "./chunk-5B62SIBQ.js";
|
|
25
26
|
export {
|
|
26
27
|
DEFAULT_THEME,
|
|
27
28
|
SYS_DARK_MEDIA_QUERY,
|
package/dist/i18n.d.ts
CHANGED
|
@@ -1,33 +1,30 @@
|
|
|
1
|
-
import * as zustand from 'zustand';
|
|
2
1
|
import { SetOptional } from 'type-fest';
|
|
3
|
-
import { L as Language,
|
|
4
|
-
export { E as ExtractTranslationKey,
|
|
2
|
+
import { T as TranslatorType, a as TranslationKey, L as Language, d as Translations, e as TranslateOptions } from './types-CxoDu4Em.js';
|
|
3
|
+
export { E as ExtractTranslationKey, f as LanguageOptions, g as TranslateFormatArgs, h as TranslateFunction, c as TranslationKeyForNamespace, b as TranslationNamespace, U as UserConfig } from './types-CxoDu4Em.js';
|
|
5
4
|
|
|
6
|
-
type
|
|
7
|
-
|
|
8
|
-
fallbackLanguage?: Language;
|
|
9
|
-
translations?: SetOptional<Translations, 'libui'>;
|
|
10
|
-
};
|
|
11
|
-
type I18N = {
|
|
12
|
-
init: (options?: InitOptions) => void;
|
|
13
|
-
t: TranslateFunction;
|
|
14
|
-
};
|
|
15
|
-
type TranslationStore = {
|
|
16
|
-
changeLanguage: (language: Language) => void;
|
|
17
|
-
fallbackLanguage: Language;
|
|
18
|
-
isInitialized: boolean;
|
|
19
|
-
resolvedLanguage: Language;
|
|
20
|
-
translations: Translations;
|
|
5
|
+
type TranslatorEventMap = {
|
|
6
|
+
languageChange: (...args: [language: Language]) => void;
|
|
21
7
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
<U>(selector: (state: TranslationStore) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
|
|
26
|
-
equalityFn?: ((a: U, b: U) => boolean) | undefined;
|
|
27
|
-
fireImmediately?: boolean;
|
|
28
|
-
} | undefined): () => void;
|
|
29
|
-
};
|
|
8
|
+
type TranslatorConfig = {
|
|
9
|
+
defaultLanguage?: Language;
|
|
10
|
+
translations: SetOptional<Translations, 'libui'>;
|
|
30
11
|
};
|
|
31
|
-
declare
|
|
12
|
+
declare class Translator implements TranslatorType<TranslationKey> {
|
|
13
|
+
#private;
|
|
14
|
+
constructor();
|
|
15
|
+
get isInitialized(): boolean;
|
|
16
|
+
get resolvedLanguage(): "fr" | "en";
|
|
17
|
+
addEventListener<TKey extends keyof TranslatorEventMap>(key: TKey, handler: TranslatorEventMap[TKey]): void;
|
|
18
|
+
changeLanguage(language: Language): void;
|
|
19
|
+
init({ defaultLanguage, translations }: TranslatorConfig): void;
|
|
20
|
+
removeEventListener<TKey extends keyof TranslatorEventMap>(key: TKey, handler: TranslatorEventMap[TKey]): boolean;
|
|
21
|
+
t(target: TranslationKey | {
|
|
22
|
+
[L in Language]?: string;
|
|
23
|
+
}, { args }?: TranslateOptions): string;
|
|
24
|
+
private emitEvent;
|
|
25
|
+
private getFormatArgs;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
declare const i18n: Translator;
|
|
32
29
|
|
|
33
|
-
export { Language,
|
|
30
|
+
export { Language, TranslateOptions, TranslationKey, Translations, TranslatorType, i18n };
|
package/dist/i18n.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Simplify, OmitIndexSignature
|
|
1
|
+
import { Primitive, Simplify, OmitIndexSignature } from 'type-fest';
|
|
2
2
|
|
|
3
3
|
var days = {
|
|
4
4
|
friday: {
|
|
@@ -222,12 +222,24 @@ type ExtractTranslationKey<T extends {
|
|
|
222
222
|
[K in Language]?: string;
|
|
223
223
|
} ? Key : `${Key}.${ExtractTranslationKey<T[Key]>}` : `${Key}` : never;
|
|
224
224
|
type TranslationNamespace = Extract<keyof Translations, string>;
|
|
225
|
-
type TranslationKey
|
|
226
|
-
|
|
227
|
-
|
|
225
|
+
type TranslationKey = ExtractTranslationKey<Translations>;
|
|
226
|
+
type TranslationKeyForNamespace<TNamespace extends TranslationNamespace> = TranslationKey extends `${TNamespace}.${infer TKey}` ? TKey : never;
|
|
227
|
+
type TranslateFormatArgs = Exclude<Primitive, symbol>[] | {
|
|
228
|
+
[L in Language]?: Exclude<Primitive, symbol>[];
|
|
229
|
+
};
|
|
230
|
+
type TranslateOptions = {
|
|
231
|
+
args?: TranslateFormatArgs;
|
|
232
|
+
};
|
|
233
|
+
interface TranslateFunction<TKey extends string> {
|
|
234
|
+
(key: TKey, options?: TranslateOptions): string;
|
|
228
235
|
(translations: {
|
|
229
236
|
[L in Language]?: string;
|
|
230
|
-
},
|
|
237
|
+
}, options?: TranslateOptions): string;
|
|
231
238
|
}
|
|
239
|
+
type TranslatorType<TKey extends string> = {
|
|
240
|
+
changeLanguage: (language: Language) => void;
|
|
241
|
+
resolvedLanguage: Language;
|
|
242
|
+
t: TranslateFunction<TKey>;
|
|
243
|
+
};
|
|
232
244
|
|
|
233
|
-
export { type ExtractTranslationKey as E, type Language as L, type
|
|
245
|
+
export { type ExtractTranslationKey as E, type Language as L, type TranslatorType as T, UserConfig as U, type TranslationKey as a, type TranslationNamespace as b, type TranslationKeyForNamespace as c, type Translations as d, type TranslateOptions as e, type LanguageOptions as f, type TranslateFormatArgs as g, type TranslateFunction as h };
|
package/dist/utils.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douglasneuroinformatics/libui",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.5.0",
|
|
5
5
|
"packageManager": "pnpm@10.7.1",
|
|
6
6
|
"description": "Generic UI components for DNP projects, built using React and Tailwind CSS",
|
|
7
7
|
"author": "Joshua Unrau",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"zod": "^3.25.x"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@douglasneuroinformatics/libjs": "^3.0.
|
|
71
|
+
"@douglasneuroinformatics/libjs": "^3.0.2",
|
|
72
72
|
"@douglasneuroinformatics/libui-form-types": "^0.11.0",
|
|
73
73
|
"@radix-ui/react-accordion": "^1.2.3",
|
|
74
74
|
"@radix-ui/react-alert-dialog": "^1.1.6",
|
|
@@ -116,17 +116,10 @@
|
|
|
116
116
|
"@douglasneuroinformatics/semantic-release": "^0.2.1",
|
|
117
117
|
"@douglasneuroinformatics/tsconfig": "^1.0.3",
|
|
118
118
|
"@faker-js/faker": "^9.6.0",
|
|
119
|
-
"@storybook/addon-docs": "^
|
|
120
|
-
"@storybook/addon-
|
|
121
|
-
"@storybook/addon-interactions": "^8.6.11",
|
|
122
|
-
"@storybook/addon-links": "^8.6.11",
|
|
123
|
-
"@storybook/blocks": "^8.6.11",
|
|
124
|
-
"@storybook/components": "^8.6.11",
|
|
119
|
+
"@storybook/addon-docs": "^9.0.6",
|
|
120
|
+
"@storybook/addon-links": "^9.0.6",
|
|
125
121
|
"@storybook/icons": "^1.4.0",
|
|
126
|
-
"@storybook/
|
|
127
|
-
"@storybook/react": "^8.6.11",
|
|
128
|
-
"@storybook/react-vite": "^8.6.11",
|
|
129
|
-
"@storybook/theming": "^8.6.11",
|
|
122
|
+
"@storybook/react-vite": "^9.0.6",
|
|
130
123
|
"@tailwindcss/vite": "^4.1.0",
|
|
131
124
|
"@testing-library/dom": "^10.4.0",
|
|
132
125
|
"@testing-library/jest-dom": "^6.6.3",
|
|
@@ -137,7 +130,7 @@
|
|
|
137
130
|
"@types/node": "22.x",
|
|
138
131
|
"@types/react": "^19.0.12",
|
|
139
132
|
"@types/react-dom": "^19.0.4",
|
|
140
|
-
"@vitejs/plugin-react-swc": "^3.
|
|
133
|
+
"@vitejs/plugin-react-swc": "^3.10.1",
|
|
141
134
|
"@vitest/coverage-v8": "^3.1.1",
|
|
142
135
|
"culori": "^4.0.1",
|
|
143
136
|
"eslint": "^9.23.0",
|
|
@@ -147,10 +140,10 @@
|
|
|
147
140
|
"prettier": "^3.5.3",
|
|
148
141
|
"prettier-plugin-tailwindcss": "^0.6.11",
|
|
149
142
|
"sort-json": "^2.0.1",
|
|
150
|
-
"storybook": "^
|
|
143
|
+
"storybook": "^9.0.6",
|
|
151
144
|
"tsup": "^8.4.0",
|
|
152
145
|
"typescript": "5.6.x",
|
|
153
|
-
"vite": "6.
|
|
146
|
+
"vite": "^6.3.5",
|
|
154
147
|
"vitest": "^3.1.1"
|
|
155
148
|
},
|
|
156
149
|
"commitlint": {
|
|
@@ -166,6 +159,7 @@
|
|
|
166
159
|
"pnpm": {
|
|
167
160
|
"onlyBuiltDependencies": [
|
|
168
161
|
"@swc/core",
|
|
162
|
+
"@tailwindcss/oxide",
|
|
169
163
|
"esbuild"
|
|
170
164
|
]
|
|
171
165
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
2
|
|
|
3
3
|
import { Checkbox } from './Checkbox';
|
|
4
4
|
|
|
@@ -20,7 +20,7 @@ export const Default: Story = {
|
|
|
20
20
|
id="terms"
|
|
21
21
|
/>
|
|
22
22
|
<label
|
|
23
|
-
className="text-sm font-medium
|
|
23
|
+
className="text-sm leading-none font-medium peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
24
24
|
htmlFor="terms"
|
|
25
25
|
>
|
|
26
26
|
Accept terms and conditions
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
2
|
import { CalculatorIcon, CalendarIcon, CreditCardIcon, SettingsIcon, SmileIcon, UserIcon } from 'lucide-react';
|
|
3
3
|
|
|
4
4
|
import { Command } from './Command';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { range, toBasicISOString, unwrap } from '@douglasneuroinformatics/libjs';
|
|
2
2
|
import { faker } from '@faker-js/faker';
|
|
3
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
4
4
|
|
|
5
5
|
import { DataTable } from './DataTable';
|
|
6
6
|
|
|
@@ -6,7 +6,7 @@ import { sleep } from '@douglasneuroinformatics/libjs';
|
|
|
6
6
|
import type { ZodTypeLike } from '@douglasneuroinformatics/libjs';
|
|
7
7
|
import type { FormFields } from '@douglasneuroinformatics/libui-form-types';
|
|
8
8
|
import type FormTypes from '@douglasneuroinformatics/libui-form-types';
|
|
9
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
9
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
10
10
|
import type { IntRange } from 'type-fest';
|
|
11
11
|
import { z } from 'zod/v4';
|
|
12
12
|
|
|
@@ -24,6 +24,10 @@ import { getInitialValues } from './utils';
|
|
|
24
24
|
|
|
25
25
|
import type { FormErrors } from './types';
|
|
26
26
|
|
|
27
|
+
type FormSubmitResult = { errorMessage: string; success: false } | { success: true };
|
|
28
|
+
|
|
29
|
+
type FormSubmitHandler<TData> = (data: NoInfer<TData>) => Promisable<FormSubmitResult | void>;
|
|
30
|
+
|
|
27
31
|
type FormProps<TSchema extends ZodTypeLike<FormDataType>, TData extends TSchema['_output'] = TSchema['_output']> = {
|
|
28
32
|
[key: `data-${string}`]: unknown;
|
|
29
33
|
additionalButtons?: {
|
|
@@ -39,11 +43,9 @@ type FormProps<TSchema extends ZodTypeLike<FormDataType>, TData extends TSchema[
|
|
|
39
43
|
fieldsFooter?: React.ReactNode;
|
|
40
44
|
id?: string;
|
|
41
45
|
initialValues?: PartialNullableFormDataType<NoInfer<TData>>;
|
|
42
|
-
onBeforeSubmit?:
|
|
43
|
-
| ((data: NoInfer<TData>) => Promisable<{ errorMessage: string; success: false } | { success: true }>)
|
|
44
|
-
| null;
|
|
46
|
+
onBeforeSubmit?: FormSubmitHandler<NoInfer<TData>> | null;
|
|
45
47
|
onError?: (error: ZodErrorLike) => void;
|
|
46
|
-
onSubmit:
|
|
48
|
+
onSubmit: FormSubmitHandler<NoInfer<TData>>;
|
|
47
49
|
preventResetValuesOnReset?: boolean;
|
|
48
50
|
readOnly?: boolean;
|
|
49
51
|
resetBtn?: boolean;
|
|
@@ -121,7 +123,7 @@ const Form = <TSchema extends ZodTypeLike<FormDataType>, TData extends TSchema['
|
|
|
121
123
|
}
|
|
122
124
|
if (onBeforeSubmit) {
|
|
123
125
|
const beforeSubmitResult = await onBeforeSubmit(result.data);
|
|
124
|
-
if (!beforeSubmitResult.success) {
|
|
126
|
+
if (beforeSubmitResult && !beforeSubmitResult.success) {
|
|
125
127
|
setErrors({});
|
|
126
128
|
setRootErrors([beforeSubmitResult.errorMessage]);
|
|
127
129
|
return;
|
|
@@ -130,12 +132,17 @@ const Form = <TSchema extends ZodTypeLike<FormDataType>, TData extends TSchema['
|
|
|
130
132
|
|
|
131
133
|
try {
|
|
132
134
|
setIsSubmitting(true);
|
|
133
|
-
await Promise.all([
|
|
135
|
+
const [formSubmitResult] = await Promise.all([
|
|
134
136
|
onSubmit(result.data),
|
|
135
137
|
new Promise<void>((resolve) => {
|
|
136
138
|
return suspendWhileSubmitting ? setTimeout(resolve, 500) : resolve();
|
|
137
139
|
})
|
|
138
140
|
]);
|
|
141
|
+
if (formSubmitResult && !formSubmitResult.success) {
|
|
142
|
+
setErrors({});
|
|
143
|
+
setRootErrors([formSubmitResult.errorMessage]);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
139
146
|
reset();
|
|
140
147
|
} finally {
|
|
141
148
|
setIsSubmitting(false);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
2
|
import { CalendarDays } from 'lucide-react';
|
|
3
3
|
|
|
4
4
|
import { Avatar } from '../Avatar';
|
|
@@ -27,7 +27,7 @@ export const Default: Story = {
|
|
|
27
27
|
<p className="text-sm">The React Framework - created and maintained by @vercel.</p>
|
|
28
28
|
<div className="flex items-center pt-2">
|
|
29
29
|
<CalendarDays className="mr-2 h-4 w-4 opacity-70" />
|
|
30
|
-
<span className="text-
|
|
30
|
+
<span className="text-muted-foreground text-xs">Joined December 2021</span>
|
|
31
31
|
</div>
|
|
32
32
|
</div>
|
|
33
33
|
</div>
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
2
|
|
|
3
|
+
import { useTranslation } from '@/hooks';
|
|
4
|
+
|
|
5
|
+
import { Separator } from '../Separator';
|
|
3
6
|
import { LanguageToggle } from './LanguageToggle';
|
|
4
7
|
|
|
5
8
|
type Story = StoryObj<typeof LanguageToggle>;
|
|
@@ -13,5 +16,22 @@ export const Default: Story = {
|
|
|
13
16
|
en: 'English',
|
|
14
17
|
fr: 'Français'
|
|
15
18
|
}
|
|
16
|
-
}
|
|
19
|
+
},
|
|
20
|
+
decorators: [
|
|
21
|
+
(Story) => {
|
|
22
|
+
const i18n = useTranslation();
|
|
23
|
+
return (
|
|
24
|
+
<div className="flex items-center gap-6">
|
|
25
|
+
<Story />
|
|
26
|
+
<Separator className="h-6" orientation="vertical" />
|
|
27
|
+
<h3 className="font-medium">
|
|
28
|
+
{i18n.t({
|
|
29
|
+
en: 'Hello',
|
|
30
|
+
fr: 'Bonjour'
|
|
31
|
+
})}
|
|
32
|
+
</h3>
|
|
33
|
+
</div>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
]
|
|
17
37
|
};
|