@wickermoney/ui-kit 0.6.0-rc.1 → 0.6.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.
- package/README.md +44 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -34,7 +34,9 @@ export function Summary({ net }: { net: string }) {
|
|
|
34
34
|
|
|
35
35
|
The package entry imports its stylesheets (`tokens.css` and `components.css`)
|
|
36
36
|
as a side effect, so your bundler must handle CSS imports. Vite and most modern
|
|
37
|
-
bundlers do by default.
|
|
37
|
+
bundlers do by default. `package.json` declares `./dist/index.js` and `./dist/*.css` as the
|
|
38
|
+
only files with side effects (`sideEffects`), so a bundler can still drop the
|
|
39
|
+
components you never import.
|
|
38
40
|
|
|
39
41
|
**Inside a Wicker Money plugin:** the host already loads these styles, so
|
|
40
42
|
components in your widgets are styled with no extra setup. For your plugin's
|
|
@@ -48,9 +50,11 @@ A federated remote's emitted stylesheet is never requested.
|
|
|
48
50
|
|---|---|
|
|
49
51
|
| `Surface` | Card/panel with an optional title and header action |
|
|
50
52
|
| `Button` | `variant`: `default`, `primary` or `danger` |
|
|
53
|
+
| `IconButton` | Square icon-only button for table rows. `icon` is one of `edit`, `delete`, `disable`, `enable`, `archive`, `history`, `end` or `balance`; `label` is required and is both the accessible name and the hover tooltip; `variant`: `default` or `danger`. Takes any other native `<button>` attribute |
|
|
54
|
+
| `Dialog` | Modal built on the native `<dialog>` (`showModal()`): a side drawer on a desktop window, a full-screen sheet on a phone. `title` is the heading and the accessible name; `onClose` is called on Escape, the close button or a click on the backdrop. The page behind is inert, Tab stays inside, the first input in the body gets focus, and focus returns to what opened it when it unmounts. Render it only while it is wanted |
|
|
51
55
|
| `Field`, `SelectField` | Labelled form inputs; optional `hint` and `error` (wires `aria-invalid` and `aria-describedby`) |
|
|
52
56
|
| `FormError` | A form-level error, shown beside the form's submit button |
|
|
53
|
-
| `Table` | Typed table: `columns`, `rows`, `rowKey`; `numeric` columns right-align |
|
|
57
|
+
| `Table` | Typed table: `columns`, `rows`, `rowKey`; `numeric` columns right-align. `empty` is rendered instead of the table when `rows` is empty; `className` adds a class to the table's scroller. Optional `caption` names the table: it is rendered as a visually hidden `<caption>` that a screen reader announces. Header cells carry `scope="col"`, and a column whose `header` is an empty string (a column of row buttons) gets a visually hidden "Actions" label in its header cell, so no header cell is empty |
|
|
54
58
|
| `Stat` | Label + value; `tone="auto"` colours by sign |
|
|
55
59
|
| `CategoryOptions`, `orderByParent` | Category `<option>` list grouped under parents |
|
|
56
60
|
| `Alert` | Inline error or notice (`role="alert"`) |
|
|
@@ -67,7 +71,44 @@ names and returns anything left over as one form-level message;
|
|
|
67
71
|
and `hasFormErrors` cover the empty case.
|
|
68
72
|
|
|
69
73
|
Every component's props type is exported alongside it (`SurfaceProps`,
|
|
70
|
-
`TableProps<T>`, ...).
|
|
74
|
+
`TableProps<T>`, ...). The other exported types are `Column<T>` (a `Table` column),
|
|
75
|
+
`IconName`, `FieldCommon`, `GroupableCategory`, and the form-error types
|
|
76
|
+
`FormErrors`, `FormErrorState`, `FieldMatcher` and `ValidationIssue`.
|
|
77
|
+
|
|
78
|
+
### Focus trap
|
|
79
|
+
|
|
80
|
+
`useFocusTrap(ref, active, options?)` keeps Tab and Shift+Tab inside the element
|
|
81
|
+
`ref` points at while `active` is true: Tab from the last tabbable element wraps
|
|
82
|
+
to the first, Shift+Tab from the first wraps to the last, and if focus is outside
|
|
83
|
+
the container the next Tab pulls it in. Disabled, `inert`, hidden and
|
|
84
|
+
`tabindex="-1"` elements are skipped. It does not move focus when it turns on
|
|
85
|
+
(you know what should be focused first) and it does not handle Escape. The
|
|
86
|
+
container must be mounted whenever `active` is true.
|
|
87
|
+
|
|
88
|
+
By default, when the trap turns off, focus goes back to whatever had it when the
|
|
89
|
+
trap turned on. Pass `{ restoreFocus: false }` (the `restoreFocus` field of
|
|
90
|
+
`FocusTrapOptions`, default `true`) when you return focus somewhere more specific
|
|
91
|
+
yourself.
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
import { useRef } from 'react'
|
|
95
|
+
import { useFocusTrap } from '@wickermoney/ui-kit'
|
|
96
|
+
|
|
97
|
+
export function Menu({ onClose }: { onClose: () => void }) {
|
|
98
|
+
const ref = useRef<HTMLDivElement>(null)
|
|
99
|
+
useFocusTrap(ref, true)
|
|
100
|
+
return (
|
|
101
|
+
<div ref={ref} role="dialog" aria-modal="true" aria-label="Menu" tabIndex={-1}
|
|
102
|
+
onKeyDown={(e) => { if (e.key === 'Escape') onClose() }}>
|
|
103
|
+
<button type="button" onClick={onClose}>Close</button>
|
|
104
|
+
</div>
|
|
105
|
+
)
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
It is for hand-rolled modals that are not a native `<dialog>`. A native `<dialog>`
|
|
110
|
+
opened with `showModal()` already keeps focus inside, and the kit's own `Dialog`
|
|
111
|
+
is one.
|
|
71
112
|
|
|
72
113
|
## Design tokens
|
|
73
114
|
|