@foi/design-system 0.0.11 → 0.0.13

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 (109) hide show
  1. package/README.md +141 -1
  2. package/dist/DatePicker.utils-ytCEcs6T.js.map +1 -1
  3. package/dist/{RadioGroup-BL2bdmZx.js → RadioGroup-DCJBoZc-.js} +30 -29
  4. package/dist/RadioGroup-DCJBoZc-.js.map +1 -0
  5. package/dist/{RadioGroup.context-BdRgENJJ.js → RadioGroup.context-QNk2hW_4.js} +4 -4
  6. package/dist/RadioGroup.context-QNk2hW_4.js.map +1 -0
  7. package/dist/{Switch-BS8iwAJ5.js → Switch-JF9P9VJf.js} +464 -447
  8. package/dist/Switch-JF9P9VJf.js.map +1 -0
  9. package/dist/{ThemeProvider-JlN3U_r2.js → ThemeProvider-Q2Hjezbt.js} +2 -2
  10. package/dist/{ThemeProvider-JlN3U_r2.js.map → ThemeProvider-Q2Hjezbt.js.map} +1 -1
  11. package/dist/atoms.mjs +2 -2
  12. package/dist/components/atoms/Button/Button.interface.d.ts +6 -2
  13. package/dist/components/atoms/Button/index.d.ts +1 -1
  14. package/dist/components/atoms/Checkbox/Checkbox.d.ts +4 -1
  15. package/dist/components/atoms/Checkbox/Checkbox.interface.d.ts +1 -1
  16. package/dist/components/atoms/DatePicker/DatePicker.interface.d.ts +4 -0
  17. package/dist/components/atoms/DatePicker/DatePickerMenu/DatePickerMenu.d.ts +0 -2
  18. package/dist/components/atoms/DatePicker/index.d.ts +1 -1
  19. package/dist/components/atoms/IconButton/IconButton.interface.d.ts +6 -2
  20. package/dist/components/atoms/IconButton/index.d.ts +1 -1
  21. package/dist/components/atoms/Input/Input.d.ts +6 -7
  22. package/dist/components/atoms/Input/Input.interface.d.ts +66 -13
  23. package/dist/components/atoms/Input/index.d.ts +1 -1
  24. package/dist/components/atoms/Pagination/Pagination.d.ts +12 -0
  25. package/dist/components/atoms/Pagination/Pagination.emotion.d.ts +2 -0
  26. package/dist/components/atoms/Pagination/Pagination.interface.d.ts +32 -0
  27. package/dist/components/atoms/Pagination/PaginationMenu/PaginationMenu.d.ts +9 -0
  28. package/dist/components/atoms/Pagination/PaginationMenu/PaginationMenu.emotion.d.ts +2 -0
  29. package/dist/components/atoms/Pagination/PaginationMenu/PaginationMenu.interface.d.ts +23 -0
  30. package/dist/components/atoms/Pagination/PaginationMenu/index.d.ts +4 -0
  31. package/dist/components/atoms/Pagination/index.d.ts +4 -0
  32. package/dist/components/atoms/Radio/Radio.d.ts +4 -0
  33. package/dist/components/atoms/Radio/Radio.interface.d.ts +4 -0
  34. package/dist/components/atoms/Radio/RadioGroup.context.d.ts +2 -0
  35. package/dist/components/atoms/Radio/index.d.ts +1 -1
  36. package/dist/components/atoms/Select/Select.interface.d.ts +4 -0
  37. package/dist/components/atoms/Select/SelectMenu/SelectMenu.d.ts +1 -2
  38. package/dist/components/atoms/Select/index.d.ts +1 -1
  39. package/dist/components/atoms/Skeleton/Skeleton.d.ts +10 -0
  40. package/dist/components/atoms/Skeleton/Skeleton.emotion.d.ts +2 -0
  41. package/dist/components/atoms/Skeleton/Skeleton.interface.d.ts +14 -0
  42. package/dist/components/atoms/Skeleton/index.d.ts +2 -0
  43. package/dist/components/atoms/Slider/Slider.interface.d.ts +4 -0
  44. package/dist/components/atoms/Slider/index.d.ts +1 -1
  45. package/dist/components/atoms/Switch/Switch.interface.d.ts +5 -1
  46. package/dist/components/atoms/Switch/index.d.ts +1 -1
  47. package/dist/components/molecules/CheckboxGroup/CheckboxGroup.interface.d.ts +4 -0
  48. package/dist/components/molecules/CheckboxGroup/index.d.ts +1 -1
  49. package/dist/components/molecules/CheckboxTree/CheckboxTree.interface.d.ts +4 -0
  50. package/dist/components/molecules/CheckboxTree/index.d.ts +1 -1
  51. package/dist/components/molecules/Modal/Modal.d.ts +14 -0
  52. package/dist/components/molecules/Modal/Modal.emotion.d.ts +2 -0
  53. package/dist/components/molecules/Modal/Modal.interface.d.ts +42 -0
  54. package/dist/components/molecules/Modal/index.d.ts +5 -0
  55. package/dist/components/molecules/RadioGroup/RadioGroup.interface.d.ts +4 -0
  56. package/dist/components/molecules/RadioGroup/index.d.ts +1 -1
  57. package/dist/components/organisms/DataGrid/DataGrid.d.ts +19 -0
  58. package/dist/components/organisms/DataGrid/DataGrid.emotion.d.ts +2 -0
  59. package/dist/components/organisms/DataGrid/DataGrid.interface.d.ts +124 -0
  60. package/dist/components/organisms/DataGrid/DataGridMenu/DataGridMenu.d.ts +14 -0
  61. package/dist/components/organisms/DataGrid/DataGridMenu/DataGridMenu.emotion.d.ts +2 -0
  62. package/dist/components/organisms/DataGrid/DataGridMenu/DataGridMenu.interface.d.ts +54 -0
  63. package/dist/components/organisms/DataGrid/DataGridMenu/components/DataGridMenuMultiSelect.d.ts +12 -0
  64. package/dist/components/organisms/DataGrid/DataGridMenu/components/DataGridMenuSearch.d.ts +8 -0
  65. package/dist/components/organisms/DataGrid/DataGridMenu/index.d.ts +3 -0
  66. package/dist/components/organisms/DataGrid/DataGridSkeleton/DataGridSkeleton.d.ts +7 -0
  67. package/dist/components/organisms/DataGrid/DataGridSkeleton/index.d.ts +1 -0
  68. package/dist/components/organisms/DataGrid/index.d.ts +4 -0
  69. package/dist/{emotion-react-jsx-runtime.browser.esm-ClrpcFMG.js → emotion-react-jsx-runtime.browser.esm-C4rLUMui.js} +9 -8
  70. package/dist/emotion-react-jsx-runtime.browser.esm-C4rLUMui.js.map +1 -0
  71. package/dist/hocs/ThemeProvider/components/DataGrid.d.ts +20 -0
  72. package/dist/hocs/ThemeProvider/components/DataGridMenu.d.ts +18 -0
  73. package/dist/hocs/ThemeProvider/components/Modal.d.ts +16 -0
  74. package/dist/hocs/ThemeProvider/components/Pagination.d.ts +13 -0
  75. package/dist/hocs/ThemeProvider/components/PaginationMenu.d.ts +24 -0
  76. package/dist/hocs/ThemeProvider/components/index.d.ts +5 -1
  77. package/dist/hocs/ThemeProvider/interfaces/Components.interface.d.ts +6 -1
  78. package/dist/hocs.mjs +1 -1
  79. package/dist/hooks/useOnClickOutside.d.ts +2 -3
  80. package/dist/hooks.mjs +1 -1
  81. package/dist/index.d.ts +6 -0
  82. package/dist/index.mjs +918 -6
  83. package/dist/index.mjs.map +1 -0
  84. package/dist/molecules.mjs +1 -1
  85. package/dist/theme/dark/colors.d.ts +1 -8
  86. package/dist/theme/dark/components/Button.d.ts +37 -0
  87. package/dist/theme/dark/components/DataGrid.d.ts +26 -0
  88. package/dist/theme/dark/components/DataGridMenu.d.ts +20 -0
  89. package/dist/theme/dark/components/Modal.d.ts +20 -0
  90. package/dist/theme/dark/components/Pagination.d.ts +12 -0
  91. package/dist/theme/dark/components/PaginationMenu.d.ts +32 -0
  92. package/dist/theme/dark/components/index.d.ts +132 -0
  93. package/dist/theme/dark/index.d.ts +132 -0
  94. package/dist/theme/index.d.ts +132 -0
  95. package/dist/{theme-D18AZjTt.js → theme-Cxg9jdmX.js} +126 -29
  96. package/dist/theme-Cxg9jdmX.js.map +1 -0
  97. package/dist/theme.mjs +1 -1
  98. package/dist/useStateCallback-B4O93zzK.js +32 -0
  99. package/dist/useStateCallback-B4O93zzK.js.map +1 -0
  100. package/dist/utilities.mjs +4 -5
  101. package/dist/utilities.mjs.map +1 -1
  102. package/package.json +1 -1
  103. package/dist/RadioGroup-BL2bdmZx.js.map +0 -1
  104. package/dist/RadioGroup.context-BdRgENJJ.js.map +0 -1
  105. package/dist/Switch-BS8iwAJ5.js.map +0 -1
  106. package/dist/emotion-react-jsx-runtime.browser.esm-ClrpcFMG.js.map +0 -1
  107. package/dist/theme-D18AZjTt.js.map +0 -1
  108. package/dist/useStateCallback-D9fqdxiO.js +0 -26
  109. package/dist/useStateCallback-D9fqdxiO.js.map +0 -1
package/README.md CHANGED
@@ -50,8 +50,10 @@ npm publish --access public
50
50
  | `Icon` | Font-based icon using Material Symbols Rounded — pass a `name` prop |
51
51
  | `IconButton` | Clickable icon with button semantics |
52
52
  | `Input` | Text input field with label, helper text, and error state |
53
+ | `Pagination` | Page navigation bar with first/prev/next/last buttons and optional rows-per-page selector |
53
54
  | `Radio` | Single radio button — used inside `RadioGroup` |
54
55
  | `Select` | Dropdown select with RHF integration |
56
+ | `Skeleton` | Animated placeholder shown while content is loading — rectangular or circular |
55
57
  | `Slider` | Range slider with RHF integration |
56
58
  | `Switch` | Toggle switch — boolean RHF field |
57
59
 
@@ -61,8 +63,15 @@ npm publish --access public
61
63
  | --------------- | -------------------------------------------------------------- |
62
64
  | `CheckboxGroup` | Manages a set of `Checkbox` children as a `string[]` RHF field |
63
65
  | `CheckboxTree` | Hierarchical checkbox group with parent/child selection logic |
66
+ | `Modal` | Overlay dialog rendered via React portal — closes on ×, backdrop click, or Escape |
64
67
  | `RadioGroup` | Manages a set of `Radio` children as a single RHF field |
65
68
 
69
+ ### Organisms
70
+
71
+ | Component | Description |
72
+ | ---------- | -------------------------------------------------------------------------------------------------------- |
73
+ | `DataGrid` | Async data table with server-side sorting, filtering (search / multiselect), pagination or infinite scroll, skeleton loading state, and custom action columns via `render` |
74
+
66
75
  ## Usage with React Hook Form
67
76
 
68
77
  All field components share the same integration pattern. Define a Zod schema, pass `control` down, and let the component handle registration, value sync, and error display.
@@ -206,13 +215,144 @@ Any component also accepts a `theme` prop — a partial `EVENTS` object — to o
206
215
  <Button label='Special' theme={{ ENABLED: { 'background-color': '#7c3aed' } }} />
207
216
  ```
208
217
 
218
+ ## DataGrid
219
+
220
+ An async data table that delegates all data operations to the server via `onFetch`.
221
+
222
+ ### Defining columns
223
+
224
+ ```tsx
225
+ import DataGrid from '@components/organisms/DataGrid';
226
+ import type { DataGridColumn } from '@components/organisms/DataGrid';
227
+
228
+ interface Product { id: number; name: string; price: number; }
229
+
230
+ const columns: DataGridColumn<Product>[] = [
231
+ {
232
+ key: 'name',
233
+ label: 'Product',
234
+ type: 'text',
235
+ filter: { type: 'search' },
236
+ },
237
+ {
238
+ key: 'price',
239
+ label: 'Price',
240
+ type: 'number',
241
+ render: value => `$${Number(value).toLocaleString('es-CL')}`,
242
+ },
243
+ ];
244
+ ```
245
+
246
+ ### The `onFetch` contract
247
+
248
+ `onFetch` receives `{ page, pageSize, sort?, filters? }` and must return `{ data, total }`. It is called automatically whenever the page, sort, or any filter changes.
249
+
250
+ ```tsx
251
+ const onFetch = async ({ page, pageSize, sort, filters }) => {
252
+ const response = await api.getProducts({ page, pageSize, sort, filters });
253
+ return { data: response.items, total: response.total };
254
+ };
255
+
256
+ <DataGrid<Product> columns={columns} onFetch={onFetch} />
257
+ ```
258
+
259
+ ### Action columns
260
+
261
+ Add a column with `type: 'options'` and a `render` prop to define row-level actions. The `render` receives `(value, row)` — use `row` to call your handlers or control Modal state.
262
+
263
+ ```tsx
264
+ const [pendingDelete, setPendingDelete] = useState<Product | null>(null);
265
+
266
+ const columnsWithActions: DataGridColumn<Product>[] = [
267
+ ...columns,
268
+ {
269
+ key: 'actions',
270
+ label: '',
271
+ type: 'options',
272
+ sortable: false,
273
+ render: (_value, row) => (
274
+ <>
275
+ <IconButton icon={<Icon name='edit' size='sm' />} onClick={() => onEdit(row)} aria-label='Edit' />
276
+ <IconButton icon={<Icon name='delete' size='sm' />} onClick={() => setPendingDelete(row)} aria-label='Delete' />
277
+ </>
278
+ ),
279
+ },
280
+ ];
281
+ ```
282
+
283
+ ### Pagination modes
284
+
285
+ | Prop | Value | Behaviour |
286
+ | ----------------- | -------------- | ---------------------------------------------- |
287
+ | `paginationType` | `'pagination'` | Renders a `<Pagination>` bar below the table (default) |
288
+ | `paginationType` | `'scroll'` | Appends rows as the user scrolls down |
289
+ | `pageSizeOptions` | `number[]` | Shows a rows-per-page selector in the bar |
290
+
291
+ ## Modal
292
+
293
+ A portal-based overlay dialog. Renders into `document.body` so it sits above all other content regardless of DOM nesting.
294
+
295
+ ### Basic usage
296
+
297
+ ```tsx
298
+ import Modal from '@components/molecules/Modal';
299
+ import Button from '@components/atoms/Button';
300
+ import Icon from '@components/atoms/Icon';
301
+
302
+ const [open, setOpen] = useState(false);
303
+
304
+ <Modal
305
+ open={open}
306
+ onClose={() => setOpen(false)}
307
+ header={
308
+ <>
309
+ <Icon name='info' />
310
+ <span className='--MODAL-title'>Información</span>
311
+ </>
312
+ }
313
+ footer={
314
+ <>
315
+ <Button onClick={() => setOpen(false)} variant='ghost'>Cancelar</Button>
316
+ <Button onClick={() => setOpen(false)}>Aceptar</Button>
317
+ </>
318
+ }
319
+ >
320
+ Contenido del modal.
321
+ </Modal>
322
+ ```
323
+
324
+ Apply `--MODAL-title` to the title element inside `header` to receive the themed font and colour styles.
325
+
326
+ ### Props
327
+
328
+ | Prop | Type | Default | Description |
329
+ | ---------------- | ------------- | ------- | ------------------------------------------------- |
330
+ | `open` | `boolean` | — | Controls visibility |
331
+ | `onClose` | `() => void` | — | Called when the modal requests to close |
332
+ | `header` | `ReactNode` | — | Full header bar content (rendered before ×) |
333
+ | `showCloseButton`| `boolean` | `true` | Whether to render the × icon button |
334
+ | `size` | `'md' \| 'lg'`| `'md'` | `'md'` = 480 px, `'lg'` = 720 px |
335
+ | `children` | `ReactNode` | — | Main body content |
336
+ | `footer` | `ReactNode` | — | Footer row content (typically action buttons) |
337
+ | `staticBackdrop` | `boolean` | `false` | When `true`, backdrop click and Escape do nothing |
338
+ | `className` | `string` | — | Extra CSS class on the modal panel |
339
+
340
+ ### Close triggers
341
+
342
+ | Trigger | `staticBackdrop=false` | `staticBackdrop=true` |
343
+ | ---------------- | ---------------------- | --------------------- |
344
+ | × button | ✓ | ✓ |
345
+ | Backdrop click | ✓ | — |
346
+ | Escape key | ✓ | — |
347
+
209
348
  ## Project structure
210
349
 
211
350
  ```
212
351
  src/
213
352
  ├── components/
214
353
  │ ├── atoms/ # Primitive UI components
215
- └── molecules/ # Composed components built from atoms
354
+ ├── molecules/ # Composed components built from atoms
355
+ │ └── organisms/ # Complex components composed from molecules and atoms
216
356
  ├── hocs/
217
357
  │ ├── ThemeProvider/ # Global theme context and CSS-variable injection
218
358
  │ ├── MarginPage/ # Page layout wrapper