@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.
- package/README.md +141 -1
- package/dist/DatePicker.utils-ytCEcs6T.js.map +1 -1
- package/dist/{RadioGroup-BL2bdmZx.js → RadioGroup-DCJBoZc-.js} +30 -29
- package/dist/RadioGroup-DCJBoZc-.js.map +1 -0
- package/dist/{RadioGroup.context-BdRgENJJ.js → RadioGroup.context-QNk2hW_4.js} +4 -4
- package/dist/RadioGroup.context-QNk2hW_4.js.map +1 -0
- package/dist/{Switch-BS8iwAJ5.js → Switch-JF9P9VJf.js} +464 -447
- package/dist/Switch-JF9P9VJf.js.map +1 -0
- package/dist/{ThemeProvider-JlN3U_r2.js → ThemeProvider-Q2Hjezbt.js} +2 -2
- package/dist/{ThemeProvider-JlN3U_r2.js.map → ThemeProvider-Q2Hjezbt.js.map} +1 -1
- package/dist/atoms.mjs +2 -2
- package/dist/components/atoms/Button/Button.interface.d.ts +6 -2
- package/dist/components/atoms/Button/index.d.ts +1 -1
- package/dist/components/atoms/Checkbox/Checkbox.d.ts +4 -1
- package/dist/components/atoms/Checkbox/Checkbox.interface.d.ts +1 -1
- package/dist/components/atoms/DatePicker/DatePicker.interface.d.ts +4 -0
- package/dist/components/atoms/DatePicker/DatePickerMenu/DatePickerMenu.d.ts +0 -2
- package/dist/components/atoms/DatePicker/index.d.ts +1 -1
- package/dist/components/atoms/IconButton/IconButton.interface.d.ts +6 -2
- package/dist/components/atoms/IconButton/index.d.ts +1 -1
- package/dist/components/atoms/Input/Input.d.ts +6 -7
- package/dist/components/atoms/Input/Input.interface.d.ts +66 -13
- package/dist/components/atoms/Input/index.d.ts +1 -1
- package/dist/components/atoms/Pagination/Pagination.d.ts +12 -0
- package/dist/components/atoms/Pagination/Pagination.emotion.d.ts +2 -0
- package/dist/components/atoms/Pagination/Pagination.interface.d.ts +32 -0
- package/dist/components/atoms/Pagination/PaginationMenu/PaginationMenu.d.ts +9 -0
- package/dist/components/atoms/Pagination/PaginationMenu/PaginationMenu.emotion.d.ts +2 -0
- package/dist/components/atoms/Pagination/PaginationMenu/PaginationMenu.interface.d.ts +23 -0
- package/dist/components/atoms/Pagination/PaginationMenu/index.d.ts +4 -0
- package/dist/components/atoms/Pagination/index.d.ts +4 -0
- package/dist/components/atoms/Radio/Radio.d.ts +4 -0
- package/dist/components/atoms/Radio/Radio.interface.d.ts +4 -0
- package/dist/components/atoms/Radio/RadioGroup.context.d.ts +2 -0
- package/dist/components/atoms/Radio/index.d.ts +1 -1
- package/dist/components/atoms/Select/Select.interface.d.ts +4 -0
- package/dist/components/atoms/Select/SelectMenu/SelectMenu.d.ts +1 -2
- package/dist/components/atoms/Select/index.d.ts +1 -1
- package/dist/components/atoms/Skeleton/Skeleton.d.ts +10 -0
- package/dist/components/atoms/Skeleton/Skeleton.emotion.d.ts +2 -0
- package/dist/components/atoms/Skeleton/Skeleton.interface.d.ts +14 -0
- package/dist/components/atoms/Skeleton/index.d.ts +2 -0
- package/dist/components/atoms/Slider/Slider.interface.d.ts +4 -0
- package/dist/components/atoms/Slider/index.d.ts +1 -1
- package/dist/components/atoms/Switch/Switch.interface.d.ts +5 -1
- package/dist/components/atoms/Switch/index.d.ts +1 -1
- package/dist/components/molecules/CheckboxGroup/CheckboxGroup.interface.d.ts +4 -0
- package/dist/components/molecules/CheckboxGroup/index.d.ts +1 -1
- package/dist/components/molecules/CheckboxTree/CheckboxTree.interface.d.ts +4 -0
- package/dist/components/molecules/CheckboxTree/index.d.ts +1 -1
- package/dist/components/molecules/Modal/Modal.d.ts +14 -0
- package/dist/components/molecules/Modal/Modal.emotion.d.ts +2 -0
- package/dist/components/molecules/Modal/Modal.interface.d.ts +42 -0
- package/dist/components/molecules/Modal/index.d.ts +5 -0
- package/dist/components/molecules/RadioGroup/RadioGroup.interface.d.ts +4 -0
- package/dist/components/molecules/RadioGroup/index.d.ts +1 -1
- package/dist/components/organisms/DataGrid/DataGrid.d.ts +19 -0
- package/dist/components/organisms/DataGrid/DataGrid.emotion.d.ts +2 -0
- package/dist/components/organisms/DataGrid/DataGrid.interface.d.ts +124 -0
- package/dist/components/organisms/DataGrid/DataGridMenu/DataGridMenu.d.ts +14 -0
- package/dist/components/organisms/DataGrid/DataGridMenu/DataGridMenu.emotion.d.ts +2 -0
- package/dist/components/organisms/DataGrid/DataGridMenu/DataGridMenu.interface.d.ts +54 -0
- package/dist/components/organisms/DataGrid/DataGridMenu/components/DataGridMenuMultiSelect.d.ts +12 -0
- package/dist/components/organisms/DataGrid/DataGridMenu/components/DataGridMenuSearch.d.ts +8 -0
- package/dist/components/organisms/DataGrid/DataGridMenu/index.d.ts +3 -0
- package/dist/components/organisms/DataGrid/DataGridSkeleton/DataGridSkeleton.d.ts +7 -0
- package/dist/components/organisms/DataGrid/DataGridSkeleton/index.d.ts +1 -0
- package/dist/components/organisms/DataGrid/index.d.ts +4 -0
- package/dist/{emotion-react-jsx-runtime.browser.esm-ClrpcFMG.js → emotion-react-jsx-runtime.browser.esm-C4rLUMui.js} +9 -8
- package/dist/emotion-react-jsx-runtime.browser.esm-C4rLUMui.js.map +1 -0
- package/dist/hocs/ThemeProvider/components/DataGrid.d.ts +20 -0
- package/dist/hocs/ThemeProvider/components/DataGridMenu.d.ts +18 -0
- package/dist/hocs/ThemeProvider/components/Modal.d.ts +16 -0
- package/dist/hocs/ThemeProvider/components/Pagination.d.ts +13 -0
- package/dist/hocs/ThemeProvider/components/PaginationMenu.d.ts +24 -0
- package/dist/hocs/ThemeProvider/components/index.d.ts +5 -1
- package/dist/hocs/ThemeProvider/interfaces/Components.interface.d.ts +6 -1
- package/dist/hocs.mjs +1 -1
- package/dist/hooks/useOnClickOutside.d.ts +2 -3
- package/dist/hooks.mjs +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.mjs +918 -6
- package/dist/index.mjs.map +1 -0
- package/dist/molecules.mjs +1 -1
- package/dist/theme/dark/colors.d.ts +1 -8
- package/dist/theme/dark/components/Button.d.ts +37 -0
- package/dist/theme/dark/components/DataGrid.d.ts +26 -0
- package/dist/theme/dark/components/DataGridMenu.d.ts +20 -0
- package/dist/theme/dark/components/Modal.d.ts +20 -0
- package/dist/theme/dark/components/Pagination.d.ts +12 -0
- package/dist/theme/dark/components/PaginationMenu.d.ts +32 -0
- package/dist/theme/dark/components/index.d.ts +132 -0
- package/dist/theme/dark/index.d.ts +132 -0
- package/dist/theme/index.d.ts +132 -0
- package/dist/{theme-D18AZjTt.js → theme-Cxg9jdmX.js} +126 -29
- package/dist/theme-Cxg9jdmX.js.map +1 -0
- package/dist/theme.mjs +1 -1
- package/dist/useStateCallback-B4O93zzK.js +32 -0
- package/dist/useStateCallback-B4O93zzK.js.map +1 -0
- package/dist/utilities.mjs +4 -5
- package/dist/utilities.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/RadioGroup-BL2bdmZx.js.map +0 -1
- package/dist/RadioGroup.context-BdRgENJJ.js.map +0 -1
- package/dist/Switch-BS8iwAJ5.js.map +0 -1
- package/dist/emotion-react-jsx-runtime.browser.esm-ClrpcFMG.js.map +0 -1
- package/dist/theme-D18AZjTt.js.map +0 -1
- package/dist/useStateCallback-D9fqdxiO.js +0 -26
- 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
|
-
│
|
|
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
|