@foi/design-system 0.0.10 → 0.0.12

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 (83) hide show
  1. package/README.md +104 -51
  2. package/dist/DatePicker.utils-ytCEcs6T.js.map +1 -1
  3. package/dist/{RadioGroup-BGdJ2fTN.js → RadioGroup-CdW6yS38.js} +16 -16
  4. package/dist/RadioGroup-CdW6yS38.js.map +1 -0
  5. package/dist/{RadioGroup.context-DJLdImVO.js → RadioGroup.context-BdRgENJJ.js} +7 -7
  6. package/dist/{RadioGroup.context-DJLdImVO.js.map → RadioGroup.context-BdRgENJJ.js.map} +1 -1
  7. package/dist/{Switch-BBGFtWQt.js → Switch-C7wjcrjU.js} +36 -36
  8. package/dist/Switch-C7wjcrjU.js.map +1 -0
  9. package/dist/{ThemeProvider-DtW2BY15.js → ThemeProvider-JlN3U_r2.js} +2 -2
  10. package/dist/{ThemeProvider-DtW2BY15.js.map → ThemeProvider-JlN3U_r2.js.map} +1 -1
  11. package/dist/atoms.mjs +2 -2
  12. package/dist/components/atoms/Button/Button.interface.d.ts +5 -1
  13. package/dist/components/atoms/Button/index.d.ts +1 -1
  14. package/dist/components/atoms/Checkbox/Checkbox.interface.d.ts +5 -1
  15. package/dist/components/atoms/Checkbox/index.d.ts +1 -1
  16. package/dist/components/atoms/DatePicker/DatePicker.interface.d.ts +4 -0
  17. package/dist/components/atoms/DatePicker/index.d.ts +1 -1
  18. package/dist/components/atoms/IconButton/IconButton.interface.d.ts +5 -1
  19. package/dist/components/atoms/IconButton/index.d.ts +1 -1
  20. package/dist/components/atoms/Input/Input.interface.d.ts +5 -1
  21. package/dist/components/atoms/Input/index.d.ts +1 -1
  22. package/dist/components/atoms/Radio/Radio.interface.d.ts +4 -0
  23. package/dist/components/atoms/Radio/index.d.ts +1 -1
  24. package/dist/components/atoms/Select/Select.interface.d.ts +4 -0
  25. package/dist/components/atoms/Select/index.d.ts +1 -1
  26. package/dist/components/atoms/Slider/Slider.interface.d.ts +4 -0
  27. package/dist/components/atoms/Slider/index.d.ts +1 -1
  28. package/dist/components/atoms/Switch/Switch.interface.d.ts +5 -1
  29. package/dist/components/atoms/Switch/index.d.ts +1 -1
  30. package/dist/components/molecules/CheckboxGroup/CheckboxGroup.interface.d.ts +4 -0
  31. package/dist/components/molecules/CheckboxGroup/index.d.ts +1 -1
  32. package/dist/components/molecules/CheckboxTree/CheckboxTree.interface.d.ts +4 -0
  33. package/dist/components/molecules/CheckboxTree/index.d.ts +1 -1
  34. package/dist/components/molecules/RadioGroup/RadioGroup.interface.d.ts +4 -0
  35. package/dist/components/molecules/RadioGroup/index.d.ts +1 -1
  36. package/dist/{emotion-react-jsx-runtime.browser.esm-BFNmScj4.js → emotion-react-jsx-runtime.browser.esm-ClrpcFMG.js} +169 -167
  37. package/dist/emotion-react-jsx-runtime.browser.esm-ClrpcFMG.js.map +1 -0
  38. package/dist/hocs/ThemeProvider/ThemeProvider.interface.d.ts +2 -2
  39. package/dist/hocs/ThemeProvider/components/Button.d.ts +17 -27
  40. package/dist/hocs/ThemeProvider/components/Checkbox.d.ts +23 -45
  41. package/dist/hocs/ThemeProvider/components/CheckboxGroup.d.ts +11 -14
  42. package/dist/hocs/ThemeProvider/components/CheckboxTree.d.ts +11 -14
  43. package/dist/hocs/ThemeProvider/components/DatePicker.d.ts +23 -45
  44. package/dist/hocs/ThemeProvider/components/DatePickerMenu.d.ts +17 -27
  45. package/dist/hocs/ThemeProvider/components/IconButton.d.ts +20 -28
  46. package/dist/hocs/ThemeProvider/components/Input.d.ts +23 -45
  47. package/dist/hocs/ThemeProvider/components/Radio.d.ts +23 -45
  48. package/dist/hocs/ThemeProvider/components/RadioGroup.d.ts +11 -14
  49. package/dist/hocs/ThemeProvider/components/Select.d.ts +23 -45
  50. package/dist/hocs/ThemeProvider/components/SelectMenu.d.ts +16 -24
  51. package/dist/hocs/ThemeProvider/components/Slider.d.ts +15 -26
  52. package/dist/hocs/ThemeProvider/components/Switch.d.ts +18 -30
  53. package/dist/hocs/ThemeProvider/createComponentStyles.d.ts +2 -1
  54. package/dist/hocs/ThemeProvider/useThemeProvider.hook.d.ts +1 -1
  55. package/dist/hocs.mjs +1 -1
  56. package/dist/index.mjs +5 -5
  57. package/dist/molecules.mjs +1 -1
  58. package/dist/theme/dark/colors.d.ts +0 -8
  59. package/dist/theme/dark/components/Button.d.ts +29 -27
  60. package/dist/theme/dark/components/Checkbox.d.ts +117 -54
  61. package/dist/theme/dark/components/CheckboxGroup.d.ts +13 -11
  62. package/dist/theme/dark/components/CheckboxTree.d.ts +12 -10
  63. package/dist/theme/dark/components/DatePicker.d.ts +53 -51
  64. package/dist/theme/dark/components/DatePickerMenu.d.ts +24 -22
  65. package/dist/theme/dark/components/IconButton.d.ts +24 -22
  66. package/dist/theme/dark/components/Input.d.ts +53 -51
  67. package/dist/theme/dark/components/Radio.d.ts +56 -54
  68. package/dist/theme/dark/components/RadioGroup.d.ts +13 -11
  69. package/dist/theme/dark/components/Select.d.ts +53 -51
  70. package/dist/theme/dark/components/SelectMenu.d.ts +23 -21
  71. package/dist/theme/dark/components/Slider.d.ts +41 -39
  72. package/dist/theme/dark/components/Switch.d.ts +49 -47
  73. package/dist/theme/dark/components/index.d.ts +567 -478
  74. package/dist/theme/dark/index.d.ts +567 -478
  75. package/dist/theme/index.d.ts +567 -478
  76. package/dist/{theme-DEqiATmv.js → theme-D18AZjTt.js} +112 -61
  77. package/dist/theme-D18AZjTt.js.map +1 -0
  78. package/dist/theme.mjs +1 -1
  79. package/package.json +1 -1
  80. package/dist/RadioGroup-BGdJ2fTN.js.map +0 -1
  81. package/dist/Switch-BBGFtWQt.js.map +0 -1
  82. package/dist/emotion-react-jsx-runtime.browser.esm-BFNmScj4.js.map +0 -1
  83. package/dist/theme-DEqiATmv.js.map +0 -1
package/README.md CHANGED
@@ -4,17 +4,16 @@ A component library built with React 19 and TypeScript. Components are designed
4
4
 
5
5
  ## Tech stack
6
6
 
7
- | Tool | Version | Purpose |
8
- |---|---|---|
9
- | React | 19 | UI runtime |
10
- | TypeScript | 6 | Type safety |
11
- | Vite | 8 | Dev server & bundler |
12
- | Emotion | 11 | CSS-in-JS styling |
13
- | React Hook Form | 7 | Form state & validation |
14
- | Zod | 4 | Schema validation |
15
- | MUI Icons | 9 | Default icon set |
16
- | Storybook | 10 | Component explorer |
17
- | Vitest | 4 | Unit tests |
7
+ | Tool | Version | Purpose |
8
+ | --------------- | ------- | ----------------------- |
9
+ | React | 19 | UI runtime |
10
+ | TypeScript | 6 | Type safety |
11
+ | Vite | 8 | Dev server & bundler |
12
+ | Emotion | 11 | CSS-in-JS styling |
13
+ | React Hook Form | 7 | Form state & validation |
14
+ | Zod | 4 | Schema validation |
15
+ | Storybook | 10 | Component explorer |
16
+ | Vitest | 4 | Unit tests |
18
17
 
19
18
  ## Commands
20
19
 
@@ -43,25 +42,26 @@ npm publish --access public
43
42
 
44
43
  ### Atoms
45
44
 
46
- | Component | Description |
47
- |---|---|
48
- | `Button` | Primary action button with variant/size/color support |
49
- | `Checkbox` | Single checkbox — standalone, RHF, or inside a group |
50
- | `DatePicker` | Date input with calendar menu, integrates with RHF |
51
- | `IconButton` | Clickable icon with button semantics |
52
- | `Input` | Text input field with label, helper text, and error state |
53
- | `Radio` | Single radio button used inside `RadioGroup` |
54
- | `Select` | Dropdown select with RHF integration |
55
- | `Slider` | Range slider with RHF integration |
56
- | `Switch` | Toggle switch boolean RHF field |
45
+ | Component | Description |
46
+ | ------------ | ------------------------------------------------------------------- |
47
+ | `Button` | Primary action button with variant/size/color support |
48
+ | `Checkbox` | Single checkbox — standalone, RHF, or inside a group |
49
+ | `DatePicker` | Date input with calendar menu, integrates with RHF |
50
+ | `Icon` | Font-based icon using Material Symbols Rounded — pass a `name` prop |
51
+ | `IconButton` | Clickable icon with button semantics |
52
+ | `Input` | Text input field with label, helper text, and error state |
53
+ | `Radio` | Single radio button used inside `RadioGroup` |
54
+ | `Select` | Dropdown select with RHF integration |
55
+ | `Slider` | Range slider with RHF integration |
56
+ | `Switch` | Toggle switch — boolean RHF field |
57
57
 
58
58
  ### Molecules
59
59
 
60
- | Component | Description |
61
- |---|---|
60
+ | Component | Description |
61
+ | --------------- | -------------------------------------------------------------- |
62
62
  | `CheckboxGroup` | Manages a set of `Checkbox` children as a `string[]` RHF field |
63
- | `CheckboxTree` | Hierarchical checkbox group with parent/child selection logic |
64
- | `RadioGroup` | Manages a set of `Radio` children as a single RHF field |
63
+ | `CheckboxTree` | Hierarchical checkbox group with parent/child selection logic |
64
+ | `RadioGroup` | Manages a set of `Radio` children as a single RHF field |
65
65
 
66
66
  ## Usage with React Hook Form
67
67
 
@@ -76,7 +76,7 @@ import Button from '@components/atoms/Button';
76
76
 
77
77
  const schema = z.object({
78
78
  email: z.string().email('Invalid email'),
79
- age: z.number().min(18, 'Must be 18 or older'),
79
+ age: z.number().min(18, 'Must be 18 or older'),
80
80
  });
81
81
 
82
82
  type FormValues = z.infer<typeof schema>;
@@ -88,9 +88,9 @@ const MyForm = () => {
88
88
 
89
89
  return (
90
90
  <form onSubmit={handleSubmit(console.log)}>
91
- <Input name="email" control={control} label="Email" />
92
- <Input name="age" control={control} label="Age" type="number" />
93
- <Button type="submit" label="Submit" />
91
+ <Input name='email' control={control} label='Email' />
92
+ <Input name='age' control={control} label='Age' type='number' />
93
+ <Button type='submit' label='Submit' />
94
94
  </form>
95
95
  );
96
96
  };
@@ -105,11 +105,11 @@ const schema = z.object({
105
105
  skills: z.array(z.string()).min(1, 'Select at least one'),
106
106
  });
107
107
 
108
- <CheckboxGroup name="skills" control={control} label="Skills">
109
- <Checkbox value="react" label="React" />
110
- <Checkbox value="vue" label="Vue" />
111
- <Checkbox value="svelte" label="Svelte" />
112
- </CheckboxGroup>
108
+ <CheckboxGroup name='skills' control={control} label='Skills'>
109
+ <Checkbox value='react' label='React' />
110
+ <Checkbox value='vue' label='Vue' />
111
+ <Checkbox value='svelte' label='Svelte' />
112
+ </CheckboxGroup>;
113
113
  ```
114
114
 
115
115
  ### Controlled mode (no RHF)
@@ -119,39 +119,92 @@ Pass `checked` + `onChecked` instead of `name`/`control`.
119
119
  ```tsx
120
120
  const [agreed, setAgreed] = useState(false);
121
121
 
122
- <Checkbox checked={agreed} onChecked={setAgreed} label="I agree to the terms" />
122
+ <Checkbox checked={agreed} onChecked={setAgreed} label='I agree to the terms' />;
123
123
  ```
124
124
 
125
125
  ## Theming
126
126
 
127
- Wrap your app in `ThemeProvider` and define one or more themes. Each theme maps component tokens to CSS custom properties that components consume at render time.
127
+ Wrap your app in `ThemeProvider` and pass one or more named themes. The active theme is selected by the `theme` prop and its tokens are injected as CSS custom properties that every component consumes.
128
128
 
129
129
  ```tsx
130
130
  import ThemeProvider from '@hocs/ThemeProvider';
131
- import { lightTheme, darkTheme } from './themes';
131
+ import darkTheme from './themes/dark';
132
132
 
133
- <ThemeProvider themes={[lightTheme, darkTheme] as const} theme="light">
133
+ <ThemeProvider themes={[darkTheme]} theme='dark'>
134
134
  <App />
135
- </ThemeProvider>
135
+ </ThemeProvider>;
136
136
  ```
137
137
 
138
- A theme is a plain object with a `name`, a `fonts` map, and a `components` map:
138
+ ### Theme structure
139
+
140
+ A theme is a plain object with a `name`, an optional `fonts` map, and a `components` map. Each component key holds one or more **variants**. Every component must define at least a `DEFAULT` variant; additional variants are optional.
141
+
142
+ Each variant contains:
143
+
144
+ - `ROOT` — static styles applied unconditionally (e.g. `border-radius`)
145
+ - `EVENTS` — styles scoped to interaction states (`ENABLED`, `HOVER`, `FOCUS`, `ERROR`, `DISABLED`, etc.)
139
146
 
140
147
  ```ts
141
- const lightTheme = {
142
- name: 'light',
143
- fonts: { FONT_FAMILY: 'Inter, sans-serif' },
144
- components: {
145
- BUTTON: {
146
- ROOT: { 'background-color': '#0070f3', color: '#fff' },
147
- HOVER: { 'background-color': '#005bb5' },
148
+ import type { BUTTON } from '@hocs/ThemeProvider/components/Button';
149
+
150
+ const component = {
151
+ BUTTON: {
152
+ DEFAULT: {
153
+ ROOT: {
154
+ 'border-radius': '8px',
155
+ },
156
+ EVENTS: {
157
+ ENABLED: {
158
+ 'background-color': '#0070f3',
159
+ 'color-primary': '#ffffff',
160
+ },
161
+ HOVER: {
162
+ 'background-color': '#005bb5',
163
+ },
164
+ FOCUS: {
165
+ 'outline-color': '#93c5fd',
166
+ 'outline-width': '2px',
167
+ 'outline-style': 'solid',
168
+ 'outline-offset': '2px',
169
+ },
170
+ DISABLED: {
171
+ 'background-color': '#e5e7eb',
172
+ 'color-primary': '#9ca3af',
173
+ },
174
+ },
175
+ },
176
+ DANGER: {
177
+ EVENTS: {
178
+ ENABLED: {
179
+ 'background-color': '#dc2626',
180
+ 'color-primary': '#ffffff',
181
+ },
182
+ HOVER: {
183
+ 'background-color': '#b91c1c',
184
+ },
185
+ },
148
186
  },
149
- // ...other components
150
187
  },
151
- } satisfies Theme;
188
+ } as const satisfies BUTTON;
189
+ ```
190
+
191
+ The `satisfies BUTTON` check enforces that `DEFAULT` is present and that every token key is valid for that component. TypeScript reports an error at the theme file if a token is misspelled or if `DEFAULT` is missing.
192
+
193
+ ### Selecting a variant
194
+
195
+ Pass the `variant` prop to a component to switch between the variants you defined in the theme. The default is always `'default'`.
196
+
197
+ ```tsx
198
+ <Button label='Delete' variant='danger' />
152
199
  ```
153
200
 
154
- Individual components also accept a `theme` prop for one-off overrides without changing the global theme.
201
+ ### One-off theme override
202
+
203
+ Any component also accepts a `theme` prop — a partial `EVENTS` object — to override tokens for that single instance without touching the global theme.
204
+
205
+ ```tsx
206
+ <Button label='Special' theme={{ ENABLED: { 'background-color': '#7c3aed' } }} />
207
+ ```
155
208
 
156
209
  ## Project structure
157
210