@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.
Files changed (88) hide show
  1. package/dist/chunk-5B62SIBQ.js +60 -0
  2. package/dist/chunk-5B62SIBQ.js.map +1 -0
  3. package/dist/chunk-GT5NL2RJ.js +306 -0
  4. package/dist/chunk-GT5NL2RJ.js.map +1 -0
  5. package/dist/{chunk-LSGD4EQY.js → chunk-SGSRBDMT.js} +30 -24
  6. package/dist/{chunk-LSGD4EQY.js.map → chunk-SGSRBDMT.js.map} +1 -1
  7. package/dist/components.d.ts +13 -17
  8. package/dist/components.js +10 -4
  9. package/dist/components.js.map +1 -1
  10. package/dist/hooks.d.ts +3 -6
  11. package/dist/hooks.js +3 -2
  12. package/dist/i18n.d.ts +25 -28
  13. package/dist/i18n.js +4 -5
  14. package/dist/{types-DDyMlEuL.d.ts → types-CxoDu4Em.d.ts} +18 -6
  15. package/dist/utils.js +1 -0
  16. package/package.json +9 -15
  17. package/src/components/Accordion/Accordion.stories.tsx +1 -1
  18. package/src/components/ActionDropdown/ActionDropdown.stories.tsx +1 -1
  19. package/src/components/AlertDialog/AlertDialog.stories.tsx +1 -1
  20. package/src/components/ArrowToggle/ArrowToggle.stories.tsx +1 -1
  21. package/src/components/Avatar/Avatar.stories.tsx +1 -1
  22. package/src/components/Badge/Badge.stories.tsx +1 -1
  23. package/src/components/Breadcrumb/Breadcrumb.stories.tsx +1 -1
  24. package/src/components/Button/Button.stories.tsx +1 -1
  25. package/src/components/Card/Card.stories.tsx +1 -1
  26. package/src/components/Chart/Chart.stories.tsx +1 -1
  27. package/src/components/Checkbox/Checkbox.stories.tsx +2 -2
  28. package/src/components/ClientTable/ClientTable.stories.tsx +1 -1
  29. package/src/components/Collapsible/Collapsible.stories.tsx +1 -1
  30. package/src/components/Command/Command.stories.tsx +1 -1
  31. package/src/components/ContextMenu/ContextMenu.stories.tsx +1 -1
  32. package/src/components/CopyButton/CopyButton.stories.tsx +1 -1
  33. package/src/components/DataTable/DataTable.stories.tsx +1 -1
  34. package/src/components/DatePicker/DatePicker.stories.tsx +1 -1
  35. package/src/components/Dialog/Dialog.stories.tsx +1 -1
  36. package/src/components/Drawer/Drawer.stories.tsx +1 -1
  37. package/src/components/DropdownButton/DropdownButton.stories.tsx +1 -1
  38. package/src/components/DropdownMenu/DropdownMenu.stories.tsx +1 -1
  39. package/src/components/ErrorFallback/ErrorFallback.stories.tsx +1 -1
  40. package/src/components/FileDropzone/FileDropzone.stories.tsx +1 -1
  41. package/src/components/Form/BooleanField/BooleanField.stories.tsx +1 -1
  42. package/src/components/Form/DateField/DateField.stories.tsx +1 -1
  43. package/src/components/Form/Form.stories.tsx +1 -1
  44. package/src/components/Form/Form.tsx +13 -6
  45. package/src/components/Form/NumberField/NumberField.stories.tsx +1 -1
  46. package/src/components/Form/SetField/SetField.stories.tsx +1 -1
  47. package/src/components/Form/StringField/StringField.stories.tsx +1 -1
  48. package/src/components/Heading/Heading.stories.tsx +1 -1
  49. package/src/components/HoverCard/HoverCard.stories.tsx +2 -2
  50. package/src/components/Input/Input.stories.tsx +1 -1
  51. package/src/components/Label/Label.stories.tsx +1 -1
  52. package/src/components/LanguageToggle/LanguageToggle.stories.tsx +22 -2
  53. package/src/components/LineGraph/LineGraph.stories.tsx +1 -1
  54. package/src/components/ListboxDropdown/ListboxDropdown.stories.tsx +1 -1
  55. package/src/components/MenuBar/MenuBar.stories.tsx +1 -1
  56. package/src/components/NotificationHub/NotificationHub.stories.tsx +1 -1
  57. package/src/components/OneTimePasswordInput/OneTimePasswordInput.stories.tsx +1 -1
  58. package/src/components/Pagination/Pagination.stories.tsx +1 -1
  59. package/src/components/Popover/Popover.stories.tsx +4 -4
  60. package/src/components/Progress/Progress.stories.tsx +1 -1
  61. package/src/components/RadioGroup/RadioGroup.stories.tsx +1 -1
  62. package/src/components/Resizable/Resizable.stories.tsx +1 -1
  63. package/src/components/ScrollArea/ScrollArea.stories.tsx +1 -1
  64. package/src/components/SearchBar/SearchBar.stories.tsx +1 -1
  65. package/src/components/Select/Select.stories.tsx +1 -1
  66. package/src/components/Separator/Separator.stories.tsx +3 -3
  67. package/src/components/Sheet/Sheet.stories.tsx +1 -1
  68. package/src/components/Slider/Slider.stories.tsx +1 -1
  69. package/src/components/Spinner/Spinner.stories.tsx +1 -1
  70. package/src/components/SpinnerIcon/SpinnerIcon.stories.tsx +1 -1
  71. package/src/components/StatisticCard/StatisticCard.stories.tsx +1 -1
  72. package/src/components/Switch/Switch.stories.tsx +1 -1
  73. package/src/components/Table/Table.stories.tsx +1 -1
  74. package/src/components/Tabs/Tabs.stories.tsx +1 -1
  75. package/src/components/TextArea/TextArea.stories.tsx +1 -1
  76. package/src/components/ThemeToggle/ThemeToggle.stories.tsx +1 -1
  77. package/src/components/Tooltip/Tooltip.stories.tsx +1 -1
  78. package/src/hooks/useTranslation/useTranslation.ts +39 -24
  79. package/src/i18n/__tests__/translator.test.ts +91 -0
  80. package/src/i18n/index.ts +4 -1
  81. package/src/i18n/translator.ts +129 -0
  82. package/src/i18n/types.ts +23 -6
  83. package/src/testing/mocks.ts +0 -9
  84. package/src/testing/setup-tests.ts +3 -2
  85. package/dist/chunk-VFVO337W.js +0 -252
  86. package/dist/chunk-VFVO337W.js.map +0 -1
  87. package/src/i18n/internal.ts +0 -23
  88. 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 TranslationNamespace, L as Language, a as TranslateFunction } from './types-DDyMlEuL.js';
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<TNamespace extends TranslationNamespace | undefined = undefined>(namespace?: TNamespace): {
76
- changeLanguage: (language: Language) => void;
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-LSGD4EQY.js";
23
- import "./chunk-VFVO337W.js";
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, b as Translations, a as TranslateFunction } from './types-DDyMlEuL.js';
4
- export { E as ExtractTranslationKey, c as LanguageOptions, d as TranslationKey, T as TranslationNamespace, U as UserConfig } from './types-DDyMlEuL.js';
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 InitOptions = {
7
- defaultLanguage?: Language;
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
- declare const translationStore: Omit<zustand.StoreApi<TranslationStore>, "subscribe"> & {
23
- subscribe: {
24
- (listener: (selectedState: TranslationStore, previousSelectedState: TranslationStore) => void): () => void;
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 const i18n: I18N;
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, TranslateFunction, type TranslationStore, Translations, i18n, translationStore };
30
+ export { Language, TranslateOptions, TranslationKey, Translations, TranslatorType, i18n };
package/dist/i18n.js CHANGED
@@ -1,10 +1,9 @@
1
1
  "use client"
2
2
  import {
3
- i18n,
4
- translationStore
5
- } from "./chunk-VFVO337W.js";
3
+ i18n
4
+ } from "./chunk-GT5NL2RJ.js";
5
+ import "./chunk-5B62SIBQ.js";
6
6
  export {
7
- i18n,
8
- translationStore
7
+ i18n
9
8
  };
10
9
  //# sourceMappingURL=i18n.js.map
@@ -1,4 +1,4 @@
1
- import { Simplify, OmitIndexSignature, Primitive } from 'type-fest';
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<TNamespace> = TNamespace extends TranslationNamespace ? ExtractTranslationKey<Translations[TNamespace]> : ExtractTranslationKey<Translations>;
226
- interface TranslateFunction<TNamespace = undefined> {
227
- (key: TranslationKey<TNamespace>, ...args: Exclude<Primitive, symbol>[]): string;
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
- }, ...args: Exclude<Primitive, symbol>[]): string;
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 TranslationNamespace as T, UserConfig as U, type TranslateFunction as a, type Translations as b, type LanguageOptions as c, type TranslationKey as d };
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
@@ -3,6 +3,7 @@ import {
3
3
  cn,
4
4
  isBrowser
5
5
  } from "./chunk-HCQE34RL.js";
6
+ import "./chunk-5B62SIBQ.js";
6
7
  export {
7
8
  cn,
8
9
  isBrowser
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@douglasneuroinformatics/libui",
3
3
  "type": "module",
4
- "version": "4.4.1",
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.1",
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": "^8.6.11",
120
- "@storybook/addon-essentials": "^8.6.11",
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/manager-api": "^8.6.11",
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.8.1",
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": "^8.6.11",
143
+ "storybook": "^9.0.6",
151
144
  "tsup": "^8.4.0",
152
145
  "typescript": "5.6.x",
153
- "vite": "6.2.4",
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 { Accordion } from './Accordion';
4
4
 
@@ -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 { ActionDropdown } from './ActionDropdown';
4
4
 
@@ -1,6 +1,6 @@
1
1
  import { Fragment } from 'react';
2
2
 
3
- import type { Meta, StoryObj } from '@storybook/react';
3
+ import type { Meta, StoryObj } from '@storybook/react-vite';
4
4
 
5
5
  import { Button } from '../Button';
6
6
  import { AlertDialog } from './AlertDialog';
@@ -1,6 +1,6 @@
1
1
  import { useState } from 'react';
2
2
 
3
- import type { Meta, StoryObj } from '@storybook/react';
3
+ import type { Meta, StoryObj } from '@storybook/react-vite';
4
4
 
5
5
  import { ArrowToggle } from './ArrowToggle';
6
6
 
@@ -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 { Avatar } from './Avatar';
4
4
 
@@ -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 { Badge } from './Badge';
4
4
 
@@ -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 { DropdownMenu } from '../DropdownMenu';
4
4
  import { Breadcrumb } from './Breadcrumb';
@@ -1,4 +1,4 @@
1
- import type { Meta, StoryObj } from '@storybook/react';
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
2
  import { DownloadIcon } from 'lucide-react';
3
3
 
4
4
  import { Button } from './Button';
@@ -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 { Button } from '../Button';
4
4
  import { Input } from '../Input';
@@ -1,4 +1,4 @@
1
- import type { Meta, StoryObj } from '@storybook/react';
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
2
  import { Bar, BarChart, CartesianGrid, XAxis } from 'recharts';
3
3
 
4
4
  import { Chart } from './Chart';
@@ -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 leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
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,5 +1,5 @@
1
1
  import { randomInt, range } from '@douglasneuroinformatics/libjs';
2
- import type { Meta, StoryObj } from '@storybook/react';
2
+ import type { Meta, StoryObj } from '@storybook/react-vite';
3
3
 
4
4
  import { ClientTable } from './ClientTable';
5
5
 
@@ -1,6 +1,6 @@
1
1
  import { Fragment, useState } from 'react';
2
2
 
3
- import type { Meta, StoryObj } from '@storybook/react';
3
+ import type { Meta, StoryObj } from '@storybook/react-vite';
4
4
  import { ChevronsUpDownIcon } from 'lucide-react';
5
5
 
6
6
  import { Button } from '../Button';
@@ -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,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 { ContextMenu } from './ContextMenu';
4
4
 
@@ -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 { CopyButton } from './CopyButton';
4
4
 
@@ -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
 
@@ -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 { DatePicker } from './DatePicker';
4
4
 
@@ -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 { Button } from '../Button';
4
4
  import { Input } from '../Input';
@@ -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 { Button } from '../Button';
4
4
  import { Drawer } from './Drawer';
@@ -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 { DropdownButton } from './DropdownButton';
4
4
 
@@ -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 { Button } from '../Button';
4
4
  import { DropdownMenu } from './DropdownMenu';
@@ -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 { ErrorFallback } from './ErrorFallback';
4
4
 
@@ -1,6 +1,6 @@
1
1
  import { useState } from 'react';
2
2
 
3
- import type { Meta, StoryObj } from '@storybook/react';
3
+ import type { Meta, StoryObj } from '@storybook/react-vite';
4
4
 
5
5
  import { FileDropzone } from './FileDropzone.js';
6
6
 
@@ -1,6 +1,6 @@
1
1
  import { useState } from 'react';
2
2
 
3
- import type { Meta, StoryObj } from '@storybook/react';
3
+ import type { Meta, StoryObj } from '@storybook/react-vite';
4
4
 
5
5
  import { BooleanField } from './BooleanField';
6
6
 
@@ -1,6 +1,6 @@
1
1
  import { useState } from 'react';
2
2
 
3
- import type { Meta, StoryObj } from '@storybook/react';
3
+ import type { Meta, StoryObj } from '@storybook/react-vite';
4
4
 
5
5
  import { DateField } from './DateField';
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: (data: NoInfer<TData>) => Promisable<void>;
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,6 +1,6 @@
1
1
  import { useState } from 'react';
2
2
 
3
- import type { Meta, StoryObj } from '@storybook/react';
3
+ import type { Meta, StoryObj } from '@storybook/react-vite';
4
4
 
5
5
  import { NumberField } from './NumberField';
6
6
 
@@ -1,6 +1,6 @@
1
1
  import { useState } from 'react';
2
2
 
3
- import type { Meta, StoryObj } from '@storybook/react';
3
+ import type { Meta, StoryObj } from '@storybook/react-vite';
4
4
 
5
5
  import { SetField } from './SetField';
6
6
 
@@ -1,6 +1,6 @@
1
1
  import { useState } from 'react';
2
2
 
3
- import type { Meta, StoryObj } from '@storybook/react';
3
+ import type { Meta, StoryObj } from '@storybook/react-vite';
4
4
 
5
5
  import { StringField } from './StringField';
6
6
 
@@ -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 { Heading } from './Heading';
4
4
 
@@ -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-xs text-muted-foreground">Joined December 2021</span>
30
+ <span className="text-muted-foreground text-xs">Joined December 2021</span>
31
31
  </div>
32
32
  </div>
33
33
  </div>
@@ -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 { Input } from './Input';
4
4
 
@@ -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 { Label } from './Label';
4
4
 
@@ -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
  };
@@ -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 { LineGraph } from './LineGraph';
4
4
 
@@ -1,6 +1,6 @@
1
1
  import { useState } from 'react';
2
2
 
3
- import type { Meta, StoryObj } from '@storybook/react';
3
+ import type { Meta, StoryObj } from '@storybook/react-vite';
4
4
 
5
5
  import { ListboxDropdown } from './ListboxDropdown';
6
6
 
@@ -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 { MenuBar } from './MenuBar';
4
4
 
@@ -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 { useNotificationsStore } from '@/hooks/useNotificationsStore';
4
4