@atomic-ui/ui-react 0.2.0 → 0.5.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 CHANGED
@@ -1,13 +1,70 @@
1
1
  # @atomic-ui/ui-react
2
2
 
3
- React components for the `@atomic-ui/ui` custom elements. Each one has typed props and typed events, and sets properties on the element where React 18 would otherwise only set attributes.
3
+ React components for every `@atomic-ui/ui` custom element, and for every `@atomic-ui/strata` block in its `strata` entry, with typed props and typed events, and JSX types for the tags themselves. It works with React 18 and React 19.
4
+
5
+ ```sh
6
+ pnpm add @atomic-ui/ui @atomic-ui/ui-react
7
+ ```
8
+
9
+ ```tsx
10
+ import { Table, Pagination, TextInput, Tabs } from '@atomic-ui/ui-react';
11
+
12
+ export function Cases({ rows, page, pages }: Props) {
13
+ return (
14
+ <>
15
+ <TextInput label="Search cases" type="search" onChange={(e) => setQuery(e.detail.value)} />
16
+ <Table
17
+ caption="Open cases"
18
+ columns={[{ key: 'ref', label: 'Reference', sortable: true }, { key: 'fee', label: 'Fee', numeric: true }]}
19
+ rows={rows}
20
+ stack
21
+ selectable
22
+ emptyText="No cases match your search."
23
+ onSort={(e) => sortBy(e.detail.key, e.detail.direction)}
24
+ onSelection={(e) => setSelected(e.detail.selected)}
25
+ />
26
+ <Pagination page={page} pages={pages} onPage={(e) => setPage(e.detail.page)} />
27
+ </>
28
+ );
29
+ }
30
+ ```
31
+
32
+ Importing this package defines the elements, so nothing else needs importing first.
33
+
34
+ ## The Strata blocks
35
+
36
+ The blocks Strata builds sites from are in `@atomic-ui/strata`, and their components are in this package's `strata` entry. An app that uses them installs that package too:
37
+
38
+ ```sh
39
+ pnpm add @atomic-ui/ui @atomic-ui/strata @atomic-ui/ui-react
40
+ ```
4
41
 
5
42
  ```tsx
6
- import '@atomic-ui/ui';
7
- import { Button, TextInput } from '@atomic-ui/ui-react';
43
+ import { Hero, CardGrid, SiteHeader, MortgageCalculator } from '@atomic-ui/ui-react/strata';
8
44
 
9
- <TextInput label="Postcode" onChange={(e) => setPostcode(e.detail.value)} />
10
- <Button variant="primary">Continue</Button>
45
+ <SiteHeader brand="Larkfield" links={links} actionText="Book a visit" onAction={book} />
46
+ <Hero heading="Homes made for the way you live" />
47
+ <CardGrid items={developments} columns="three" />
11
48
  ```
12
49
 
13
- Import `@atomic-ui/ui` once, so the custom elements are defined before React renders them.
50
+ They are generated from `@atomic-ui/strata`'s manifest by the same script and named the same way, and importing the entry types the blocks' tags for JSX, as `ImpaktStrataIntrinsicElements`. The main entry holds the product components only, so an app that uses no blocks never loads them. `@atomic-ui/strata` is an optional peer dependency.
51
+
52
+ ## Names
53
+
54
+ Every element has a component named after its tag without `impakt-`: `impakt-table` is `Table`, `impakt-text-input` is `TextInput` and `impakt-error-summary` is `ErrorSummary`. Its props are the element's own properties, typed from the element. Each event is a prop named `on` and the rest of the event's name: `impakt-change` is `onChange`, `impakt-sort` is `onSort` and `impakt-close` is `onClose`, and the handler receives the event with its typed `detail`. `Button` keeps `onClick`.
55
+
56
+ The components are generated from the component manifest when the package builds, by `scripts/generate.mjs`, so they always match the elements. The twelve components 0.2.0 had keep their names, props and events.
57
+
58
+ ## Writing the tags in React 19
59
+
60
+ React 19 sets properties on custom elements and listens for their events, so an app can also write the tags. Importing this package, or `@atomic-ui/ui-react/jsx` on its own, types every tag: its properties, its attributes by their HTML names, and each event as `on` and the event's own name.
61
+
62
+ ```tsx
63
+ <impakt-table caption="Open cases" columns={columns} rows={rows} sort-key="opened" onimpakt-sort={(e) => sortBy(e.detail)} />
64
+ ```
65
+
66
+ A child given `slot` puts richer content in a component, such as a badge in a table cell (`slot="cell:c1:status"`) or a panel in a tab (`slot="files"`).
67
+
68
+ ## Next.js
69
+
70
+ The package starts with `'use client'`, so its components can be used from a server component's tree and render in the browser. The elements need the browser to draw, so a page shows their content once the client has loaded.
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=chunk-NSAHEL6V.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,190 @@
1
+ import { type EventName } from '@lit/react';
2
+ import { ImpaktAccordion, ImpaktAddressLookup, ImpaktAlert, ImpaktAvatar, ImpaktAvatarGroup, ImpaktBadge, ImpaktBreadcrumbs, ImpaktButton, ImpaktCard, ImpaktCheckbox, ImpaktCheckboxGroup, ImpaktChip, ImpaktDateInput, ImpaktDialog, ImpaktDivider, ImpaktDocumentLink, ImpaktDrawer, ImpaktEmptyState, ImpaktErrorSummary, ImpaktFieldset, ImpaktFileUpload, ImpaktGrid, ImpaktHeading, ImpaktHelp, ImpaktIcon, ImpaktImage, ImpaktLink, ImpaktList, ImpaktLogo, ImpaktMenu, ImpaktMoneyInput, ImpaktNav, ImpaktPage, ImpaktPagination, ImpaktPrice, ImpaktProgress, ImpaktRadioGroup, ImpaktRangeInput, ImpaktSection, ImpaktSelect, ImpaktSlotPicker, ImpaktSpacer, ImpaktStack, ImpaktSummaryList, ImpaktTable, ImpaktTabs, ImpaktTaskList, ImpaktText, ImpaktTextInput, ImpaktTextarea, ImpaktToast, ImpaktVisuallyHidden } from '@atomic-ui/ui';
3
+ import type { SortDirection } from '@atomic-ui/ui';
4
+ /** `<impakt-accordion>` */
5
+ export declare const Accordion: import("@lit/react").ReactWebComponent<ImpaktAccordion, {}>;
6
+ /** `<impakt-address-lookup>` */
7
+ export declare const AddressLookup: import("@lit/react").ReactWebComponent<ImpaktAddressLookup, {
8
+ onLookup: EventName<CustomEvent<{
9
+ postcode: string;
10
+ }>>;
11
+ onChange: EventName<CustomEvent<{
12
+ value: string;
13
+ }>>;
14
+ }>;
15
+ /** `<impakt-alert>` */
16
+ export declare const Alert: import("@lit/react").ReactWebComponent<ImpaktAlert, {}>;
17
+ /** `<impakt-avatar>` */
18
+ export declare const Avatar: import("@lit/react").ReactWebComponent<ImpaktAvatar, {}>;
19
+ /** `<impakt-avatar-group>` */
20
+ export declare const AvatarGroup: import("@lit/react").ReactWebComponent<ImpaktAvatarGroup, {}>;
21
+ /** `<impakt-badge>` */
22
+ export declare const Badge: import("@lit/react").ReactWebComponent<ImpaktBadge, {}>;
23
+ /** `<impakt-breadcrumbs>` */
24
+ export declare const Breadcrumbs: import("@lit/react").ReactWebComponent<ImpaktBreadcrumbs, {}>;
25
+ /** `<impakt-button>` */
26
+ export declare const Button: import("@lit/react").ReactWebComponent<ImpaktButton, {
27
+ onClick: EventName<MouseEvent>;
28
+ }>;
29
+ /** `<impakt-card>` */
30
+ export declare const Card: import("@lit/react").ReactWebComponent<ImpaktCard, {}>;
31
+ /** `<impakt-checkbox>` */
32
+ export declare const Checkbox: import("@lit/react").ReactWebComponent<ImpaktCheckbox, {
33
+ onChange: EventName<CustomEvent<{
34
+ value: string;
35
+ }>>;
36
+ }>;
37
+ /** `<impakt-checkbox-group>` */
38
+ export declare const CheckboxGroup: import("@lit/react").ReactWebComponent<ImpaktCheckboxGroup, {
39
+ onChange: EventName<CustomEvent<{
40
+ value: string;
41
+ }>>;
42
+ }>;
43
+ /** `<impakt-chip>` */
44
+ export declare const Chip: import("@lit/react").ReactWebComponent<ImpaktChip, {}>;
45
+ /** `<impakt-date-input>` */
46
+ export declare const DateInput: import("@lit/react").ReactWebComponent<ImpaktDateInput, {
47
+ onChange: EventName<CustomEvent<{
48
+ value: string;
49
+ }>>;
50
+ }>;
51
+ /** `<impakt-dialog>` */
52
+ export declare const Dialog: import("@lit/react").ReactWebComponent<ImpaktDialog, {
53
+ onClose: EventName<CustomEvent<null>>;
54
+ }>;
55
+ /** `<impakt-divider>` */
56
+ export declare const Divider: import("@lit/react").ReactWebComponent<ImpaktDivider, {}>;
57
+ /** `<impakt-document-link>` */
58
+ export declare const DocumentLink: import("@lit/react").ReactWebComponent<ImpaktDocumentLink, {}>;
59
+ /** `<impakt-drawer>` */
60
+ export declare const Drawer: import("@lit/react").ReactWebComponent<ImpaktDrawer, {
61
+ onClose: EventName<CustomEvent<null>>;
62
+ }>;
63
+ /** `<impakt-empty-state>` */
64
+ export declare const EmptyState: import("@lit/react").ReactWebComponent<ImpaktEmptyState, {}>;
65
+ /** `<impakt-error-summary>` */
66
+ export declare const ErrorSummary: import("@lit/react").ReactWebComponent<ImpaktErrorSummary, {}>;
67
+ /** `<impakt-fieldset>` */
68
+ export declare const Fieldset: import("@lit/react").ReactWebComponent<ImpaktFieldset, {}>;
69
+ /** `<impakt-file-upload>` */
70
+ export declare const FileUpload: import("@lit/react").ReactWebComponent<ImpaktFileUpload, {
71
+ onFiles: EventName<CustomEvent<{
72
+ files: File[];
73
+ }>>;
74
+ onChange: EventName<CustomEvent<{
75
+ value: string;
76
+ }>>;
77
+ }>;
78
+ /** `<impakt-grid>` */
79
+ export declare const Grid: import("@lit/react").ReactWebComponent<ImpaktGrid, {}>;
80
+ /** `<impakt-heading>` */
81
+ export declare const Heading: import("@lit/react").ReactWebComponent<ImpaktHeading, {}>;
82
+ /** `<impakt-help>` */
83
+ export declare const Help: import("@lit/react").ReactWebComponent<ImpaktHelp, {}>;
84
+ /** `<impakt-icon>` */
85
+ export declare const Icon: import("@lit/react").ReactWebComponent<ImpaktIcon, {}>;
86
+ /** `<impakt-image>` */
87
+ export declare const Image: import("@lit/react").ReactWebComponent<ImpaktImage, {}>;
88
+ /** `<impakt-link>` */
89
+ export declare const Link: import("@lit/react").ReactWebComponent<ImpaktLink, {}>;
90
+ /** `<impakt-list>` */
91
+ export declare const List: import("@lit/react").ReactWebComponent<ImpaktList, {}>;
92
+ /** `<impakt-logo>` */
93
+ export declare const Logo: import("@lit/react").ReactWebComponent<ImpaktLogo, {}>;
94
+ /** `<impakt-menu>` */
95
+ export declare const Menu: import("@lit/react").ReactWebComponent<ImpaktMenu, {
96
+ onSelect: EventName<CustomEvent<{
97
+ value: string;
98
+ }>>;
99
+ }>;
100
+ /** `<impakt-money-input>` */
101
+ export declare const MoneyInput: import("@lit/react").ReactWebComponent<ImpaktMoneyInput, {
102
+ onChange: EventName<CustomEvent<{
103
+ value: string;
104
+ }>>;
105
+ }>;
106
+ /** `<impakt-nav>` */
107
+ export declare const Nav: import("@lit/react").ReactWebComponent<ImpaktNav, {}>;
108
+ /** `<impakt-page>` */
109
+ export declare const Page: import("@lit/react").ReactWebComponent<ImpaktPage, {}>;
110
+ /** `<impakt-pagination>` */
111
+ export declare const Pagination: import("@lit/react").ReactWebComponent<ImpaktPagination, {
112
+ onPage: EventName<CustomEvent<{
113
+ page: number;
114
+ }>>;
115
+ }>;
116
+ /** `<impakt-price>` */
117
+ export declare const Price: import("@lit/react").ReactWebComponent<ImpaktPrice, {}>;
118
+ /** `<impakt-progress>` */
119
+ export declare const Progress: import("@lit/react").ReactWebComponent<ImpaktProgress, {}>;
120
+ /** `<impakt-radio-group>` */
121
+ export declare const RadioGroup: import("@lit/react").ReactWebComponent<ImpaktRadioGroup, {
122
+ onChange: EventName<CustomEvent<{
123
+ value: string;
124
+ }>>;
125
+ }>;
126
+ /** `<impakt-range-input>` */
127
+ export declare const RangeInput: import("@lit/react").ReactWebComponent<ImpaktRangeInput, {
128
+ onChange: EventName<CustomEvent<{
129
+ value: string;
130
+ }>>;
131
+ }>;
132
+ /** `<impakt-section>` */
133
+ export declare const Section: import("@lit/react").ReactWebComponent<ImpaktSection, {}>;
134
+ /** `<impakt-select>` */
135
+ export declare const Select: import("@lit/react").ReactWebComponent<ImpaktSelect, {
136
+ onChange: EventName<CustomEvent<{
137
+ value: string;
138
+ }>>;
139
+ }>;
140
+ /** `<impakt-slot-picker>` */
141
+ export declare const SlotPicker: import("@lit/react").ReactWebComponent<ImpaktSlotPicker, {
142
+ onChange: EventName<CustomEvent<{
143
+ value: string;
144
+ }>>;
145
+ }>;
146
+ /** `<impakt-spacer>` */
147
+ export declare const Spacer: import("@lit/react").ReactWebComponent<ImpaktSpacer, {}>;
148
+ /** `<impakt-stack>` */
149
+ export declare const Stack: import("@lit/react").ReactWebComponent<ImpaktStack, {}>;
150
+ /** `<impakt-summary-list>` */
151
+ export declare const SummaryList: import("@lit/react").ReactWebComponent<ImpaktSummaryList, {}>;
152
+ /** `<impakt-table>` */
153
+ export declare const Table: import("@lit/react").ReactWebComponent<ImpaktTable, {
154
+ onSort: EventName<CustomEvent<{
155
+ key: string;
156
+ direction: SortDirection;
157
+ }>>;
158
+ onSelection: EventName<CustomEvent<{
159
+ selected: string[];
160
+ }>>;
161
+ }>;
162
+ /** `<impakt-tabs>` */
163
+ export declare const Tabs: import("@lit/react").ReactWebComponent<ImpaktTabs, {
164
+ onChange: EventName<CustomEvent<{
165
+ value: string;
166
+ }>>;
167
+ }>;
168
+ /** `<impakt-task-list>` */
169
+ export declare const TaskList: import("@lit/react").ReactWebComponent<ImpaktTaskList, {}>;
170
+ /** `<impakt-text>` */
171
+ export declare const Text: import("@lit/react").ReactWebComponent<ImpaktText, {}>;
172
+ /** `<impakt-text-input>` */
173
+ export declare const TextInput: import("@lit/react").ReactWebComponent<ImpaktTextInput, {
174
+ onChange: EventName<CustomEvent<{
175
+ value: string;
176
+ }>>;
177
+ }>;
178
+ /** `<impakt-textarea>` */
179
+ export declare const Textarea: import("@lit/react").ReactWebComponent<ImpaktTextarea, {
180
+ onChange: EventName<CustomEvent<{
181
+ value: string;
182
+ }>>;
183
+ }>;
184
+ /** `<impakt-toast>` */
185
+ export declare const Toast: import("@lit/react").ReactWebComponent<ImpaktToast, {
186
+ onClose: EventName<CustomEvent<null>>;
187
+ onAction: EventName<CustomEvent<null>>;
188
+ }>;
189
+ /** `<impakt-visually-hidden>` */
190
+ export declare const VisuallyHidden: import("@lit/react").ReactWebComponent<ImpaktVisuallyHidden, {}>;
package/dist/index.d.ts CHANGED
@@ -1,29 +1,38 @@
1
- import { type EventName } from '@lit/react';
2
- import { ImpktButton, ImpktTextInput, ImpktSelect, ImpktCheckbox, ImpktRadioGroup, ImpktAlert, ImpktStack, ImpktCard, ImpktHeading, ImpktText, ImpktGrid, ImpktHelp } from '@atomic-ui/ui';
1
+ /**
2
+ * React bindings for `@atomic-ui/ui`.
3
+ *
4
+ * ## Why a wrapper exists at all
5
+ *
6
+ * React 18 sets everything it does not recognise as an HTML *attribute*, which
7
+ * means a prop holding an array or an object arrives at a custom element as
8
+ * the string `[object Object]`. `impakt-radio-group`'s options are an array, so
9
+ * without this the component that most needs structured data is the one that
10
+ * cannot receive it. React 19 fixed that, and the wrapper stays regardless for
11
+ * the second reason: custom events. `@lit/react` maps `impakt-change` onto an
12
+ * `onChange` prop with a type, rather than leaving every consumer to reach for
13
+ * a ref and `addEventListener`.
14
+ *
15
+ * ## Generated from the manifest
16
+ *
17
+ * Every element has a wrapper, written by `scripts/generate.mjs` from the
18
+ * Custom Elements Manifest that `@atomic-ui/ui` builds from its own source, so a
19
+ * wrapper cannot drift from its component. The same script writes the JSX types
20
+ * in `./jsx`, which this module brings in, so a React 19 app can also write the
21
+ * tags themselves, such as `<impakt-table columns={columns}>`, with types.
22
+ *
23
+ * The blocks Strata builds sites from are in `@atomic-ui/strata`, and their
24
+ * wrappers are in this package's `./strata` entry, generated the same way from
25
+ * that package's manifest.
26
+ *
27
+ * Each wrapper is the tag's name without `impakt-`, so `impakt-text-input` is
28
+ * `TextInput`. Each `impakt-` event is a prop named `on` and the rest of the
29
+ * event's name, so `impakt-change` is `onChange` and `impakt-sort` is `onSort`.
30
+ */
31
+ import './jsx';
32
+ export * from './components';
33
+ export type { ImpaktElementProps, ImpaktIntrinsicElements } from './jsx';
3
34
  /** What a control reports when its value changes. */
4
- export type ImpktChangeEvent = CustomEvent<{
35
+ export type ImpaktChangeEvent = CustomEvent<{
5
36
  value: string;
6
37
  }>;
7
- export declare const Button: import("@lit/react").ReactWebComponent<ImpktButton, {
8
- onClick: EventName<MouseEvent>;
9
- }>;
10
- export declare const TextInput: import("@lit/react").ReactWebComponent<ImpktTextInput, {
11
- onChange: EventName<ImpktChangeEvent>;
12
- }>;
13
- export declare const Select: import("@lit/react").ReactWebComponent<ImpktSelect, {
14
- onChange: EventName<ImpktChangeEvent>;
15
- }>;
16
- export declare const Checkbox: import("@lit/react").ReactWebComponent<ImpktCheckbox, {
17
- onChange: EventName<ImpktChangeEvent>;
18
- }>;
19
- export declare const RadioGroup: import("@lit/react").ReactWebComponent<ImpktRadioGroup, {
20
- onChange: EventName<ImpktChangeEvent>;
21
- }>;
22
- export declare const Alert: import("@lit/react").ReactWebComponent<ImpktAlert, {}>;
23
- export declare const Stack: import("@lit/react").ReactWebComponent<ImpktStack, {}>;
24
- export declare const Card: import("@lit/react").ReactWebComponent<ImpktCard, {}>;
25
- export declare const Heading: import("@lit/react").ReactWebComponent<ImpktHeading, {}>;
26
- export declare const Text: import("@lit/react").ReactWebComponent<ImpktText, {}>;
27
- export type { RadioOption, SelectOption, AlertTone, HelpKind } from '@atomic-ui/ui';
28
- export declare const Grid: import("@lit/react").ReactWebComponent<ImpktGrid, {}>;
29
- export declare const Help: import("@lit/react").ReactWebComponent<ImpktHelp, {}>;
38
+ export type { RadioOption, SelectOption, CheckboxOption, AlertTone, HelpKind, TableColumn, SortDirection, TabItem, SummaryRow, TaskItem, ErrorItem, MenuItem, ProgressStep, AccordionItem, AvatarItem, NavLink, Tone, } from '@atomic-ui/ui';