@phpsoftbox/react-softbox 0.3.0 → 0.4.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 (41) hide show
  1. package/README.md +81 -1
  2. package/dist/components/Input/ErrorTooltip/ErrorTooltip.d.ts +12 -0
  3. package/dist/components/Input/ErrorTooltip/ErrorTooltip.js +25 -0
  4. package/dist/components/Input/ErrorTooltip/ErrorTooltip.js.map +1 -0
  5. package/dist/components/Input/ErrorTooltip/ErrorTooltip.module.css +31 -0
  6. package/dist/components/Input/Field.js +8 -1
  7. package/dist/components/Input/Field.js.map +1 -1
  8. package/dist/components/Input/FloatLabel/FloatLabel.module.css +5 -3
  9. package/dist/components/Input/FormField/FormField.d.ts +2 -0
  10. package/dist/components/Input/FormField/FormField.js +12 -1
  11. package/dist/components/Input/FormField/FormField.js.map +1 -1
  12. package/dist/components/Input/FormField/FormField.module.css +1 -0
  13. package/dist/components/Input/Input.d.ts +2 -0
  14. package/dist/components/Input/Input.js +2 -0
  15. package/dist/components/Input/Input.js.map +1 -1
  16. package/dist/components/Input/Input.module.css +8 -1
  17. package/dist/components/Input/Select/Select.d.ts +10 -5
  18. package/dist/components/Input/Select/Select.js +62 -16
  19. package/dist/components/Input/Select/Select.js.map +1 -1
  20. package/dist/components/Input/Select/Select.module.css +65 -23
  21. package/dist/components/Modal/Modal.d.ts +2 -1
  22. package/dist/components/Modal/Modal.js +18 -1
  23. package/dist/components/Modal/Modal.js.map +1 -1
  24. package/dist/components/Table/Table.d.ts +25 -0
  25. package/dist/components/Table/Table.js +132 -91
  26. package/dist/components/Table/Table.js.map +1 -1
  27. package/dist/components/Table/Table.module.css +33 -0
  28. package/dist/components/Tooltip/Tooltip.d.ts +33 -0
  29. package/dist/components/Tooltip/Tooltip.js +294 -0
  30. package/dist/components/Tooltip/Tooltip.js.map +1 -0
  31. package/dist/components/Tooltip/Tooltip.module.css +124 -0
  32. package/dist/foundations/tokens.css +6 -0
  33. package/dist/index.d.ts +3 -1
  34. package/dist/index.js +1 -0
  35. package/dist/index.js.map +1 -1
  36. package/docs/README.md +2 -0
  37. package/docs/forms.md +33 -0
  38. package/docs/overlays.md +2 -2
  39. package/docs/table.md +114 -0
  40. package/docs/tooltip.md +68 -0
  41. package/package.json +1 -1
package/docs/table.md ADDED
@@ -0,0 +1,114 @@
1
+ # Table
2
+
3
+ `Table` — табличный компонент с декларативными колонками, сортировкой и футером.
4
+
5
+ ## Базовый пример
6
+
7
+ ```tsx
8
+ const columns = [
9
+ { id: 'name', header: 'Название', accessor: 'name' },
10
+ { id: 'status', header: 'Статус', accessor: 'status' },
11
+ { id: 'amount', header: 'Сумма', accessor: (row) => `${row.amount} ₽`, align: 'right' },
12
+ ];
13
+
14
+ <Table columns={columns} data={rows} />;
15
+ ```
16
+
17
+ ## Колонки из бэкенда
18
+
19
+ ```tsx
20
+ const backendColumns = [
21
+ { id: 'client', title: 'Клиент', field: 'client', sortable: true },
22
+ { id: 'project', title: 'Проект', field: 'project' },
23
+ { id: 'amount', title: 'Сумма', field: 'amount', sortable: true, align: 'right' },
24
+ ];
25
+
26
+ <Table columns={backendColumns} data={rows} />;
27
+ ```
28
+
29
+ `header`, `label`, `title`, `field` используются по цепочке как заголовок. `accessor` может быть ключом или функцией.
30
+
31
+ ## Сортировка с обновлением query‑параметров
32
+
33
+ ```tsx
34
+ const [sort, setSort] = useState({ key: 'amount', direction: 'asc' });
35
+
36
+ <Table
37
+ columns={[
38
+ { id: 'client', header: 'Клиент', accessor: 'client', sortable: true },
39
+ { id: 'amount', header: 'Сумма', accessor: 'amount', sortable: true, align: 'right' },
40
+ ]}
41
+ data={rows}
42
+ sort={{
43
+ key: sort.key,
44
+ direction: sort.direction,
45
+ param: 'sort',
46
+ orderParam: 'order',
47
+ onChange: (next, url) => {
48
+ setSort(next);
49
+ window.history.replaceState(null, '', url);
50
+ },
51
+ }}
52
+ />;
53
+ ```
54
+
55
+ ## Футер
56
+
57
+ ```tsx
58
+ const columns = [
59
+ { id: 'name', header: 'Товар', accessor: 'name', footer: 'Итого' },
60
+ {
61
+ id: 'amount',
62
+ header: 'Сумма',
63
+ accessor: 'amount',
64
+ align: 'right',
65
+ footer: (rows) => rows.reduce((sum, row) => sum + row.amount, 0),
66
+ },
67
+ ];
68
+
69
+ <Table columns={columns} data={rows} showFooter />;
70
+ ```
71
+
72
+ ### Футер только в нужных колонках
73
+
74
+ ```tsx
75
+ const columns = [
76
+ { id: 'a', header: 'A', accessor: 'a' },
77
+ { id: 'b', header: 'B', accessor: 'b' },
78
+ { id: 'c', header: 'C', accessor: 'c' },
79
+ { id: 'd', header: 'D', accessor: 'd', footer: 'Итого' },
80
+ { id: 'e', header: 'E', accessor: 'e', footer: (rows) => rows.reduce((sum, row) => sum + row.e, 0) },
81
+ ];
82
+
83
+ <Table columns={columns} data={rows} showFooter />;
84
+ ```
85
+
86
+ ## Выбор строк + renderBulkAction
87
+
88
+ ```tsx
89
+ const [selected, setSelected] = useState<React.Key[]>([]);
90
+
91
+ <Table
92
+ columns={columns}
93
+ data={rows}
94
+ selection={{
95
+ selectedIds: selected,
96
+ onToggle: (id) => setSelected((prev) => prev.includes(id) ? prev.filter((key) => key !== id) : [...prev, id]),
97
+ onToggleAll: (ids) => setSelected((prev) => ids.length > 0 && ids.every((id) => prev.includes(id)) ? [] : ids),
98
+ }}
99
+ renderBulkAction={(ids) => (
100
+ <div>
101
+ Выбрано: {ids.length}
102
+ </div>
103
+ )}
104
+ />;
105
+ ```
106
+
107
+ ## Полезные поля колонки
108
+
109
+ - `field` / `accessor` / `cell` — источник данных
110
+ - `sortable`, `sortKey` — сортировка для колонки
111
+ - `footer` — значение в футере (node или функция)
112
+ - `hideOn` — скрыть колонку на `sm`/`md`/`lg`
113
+ - `width` / `minWidth` — размеры колонки
114
+ - `align` — `left` | `center` | `right`
@@ -0,0 +1,68 @@
1
+ # Tooltip
2
+
3
+ `Tooltip` — всплывающая подсказка для элементов интерфейса.
4
+
5
+ ## Базовый пример
6
+
7
+ ```tsx
8
+ <Tooltip content="Подсказка">
9
+ <Button>Наведи</Button>
10
+ </Tooltip>
11
+ ```
12
+
13
+ ## Направление
14
+
15
+ `placement`: `auto` | `top` | `bottom` | `left` | `right`.
16
+
17
+ ```tsx
18
+ <Tooltip content="Справа" placement="right">
19
+ <span>Help</span>
20
+ </Tooltip>
21
+ ```
22
+
23
+ ## Интерактивный контент
24
+
25
+ Если нужно, чтобы подсказка не исчезала при наведении мышью на сам tooltip (например, есть ссылки), включите `interactive`.
26
+
27
+ ```tsx
28
+ <Tooltip
29
+ interactive
30
+ content={
31
+ <>
32
+ <Tooltip.Header>Подробности</Tooltip.Header>
33
+ <Tooltip.Body>
34
+ Перейдите в <a href="/docs">документацию</a>.
35
+ </Tooltip.Body>
36
+ <Tooltip.Footer>Последнее обновление: сегодня</Tooltip.Footer>
37
+ </>
38
+ }
39
+ >
40
+ <Button>Подробнее</Button>
41
+ </Tooltip>
42
+ ```
43
+
44
+ ## Варианты
45
+
46
+ `variant`: `default` | `info` | `success` | `warning` | `danger`.
47
+
48
+ ```tsx
49
+ <Tooltip content="Важно" variant="warning">
50
+ <span>!</span>
51
+ </Tooltip>
52
+ ```
53
+
54
+ ## Header / Body / Footer
55
+
56
+ ```tsx
57
+ <Tooltip
58
+ content={
59
+ <>
60
+ <Tooltip.Header>Заголовок</Tooltip.Header>
61
+ <Tooltip.Body>Подробности и описание.</Tooltip.Body>
62
+ <Tooltip.Footer>Доп. инфо</Tooltip.Footer>
63
+ </>
64
+ }
65
+ >
66
+ <Button>Подробнее</Button>
67
+ </Tooltip>
68
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phpsoftbox/react-softbox",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",