aidos-ui 4.0.0 → 4.0.1

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 (93) hide show
  1. package/.claude/settings.local.json +14 -1
  2. package/CLAUDE.md +72 -0
  3. package/dist/BaseButton.js.map +1 -1
  4. package/dist/BaseLink.js.map +1 -1
  5. package/dist/BaseListItem.d.ts +1 -1
  6. package/dist/Calendar.d.ts +2 -2
  7. package/dist/DarkMode.js.map +1 -1
  8. package/dist/DatePicker.js.map +1 -1
  9. package/dist/Dialog.d.ts +3 -3
  10. package/dist/Dialog.js.map +1 -1
  11. package/dist/Dropdown.js.map +1 -1
  12. package/dist/Icon.d.ts +3 -3
  13. package/dist/Icon.js +2 -21
  14. package/dist/Icon.js.map +1 -1
  15. package/dist/Interactable.js.map +1 -1
  16. package/dist/NextJSRouterState.js.map +1 -1
  17. package/dist/OnVisible.d.ts +1 -1
  18. package/dist/OnVisible.js.map +1 -1
  19. package/dist/Popover.d.ts +3 -3
  20. package/dist/Popover.js.map +1 -1
  21. package/dist/Providers.d.ts +2 -2
  22. package/dist/RangeInput.d.ts +1 -1
  23. package/dist/RootView.js.map +1 -1
  24. package/dist/Select.d.ts +0 -1
  25. package/dist/Storage.d.ts +2 -1
  26. package/dist/Storage.js.map +1 -1
  27. package/dist/Stream.js.map +1 -1
  28. package/dist/Text.js.map +1 -1
  29. package/dist/TextInput.d.ts +3 -2
  30. package/dist/TextInput.js +13 -4
  31. package/dist/TextInput.js.map +1 -1
  32. package/dist/TextPairing.js.map +1 -1
  33. package/dist/Tooltip.d.ts +2 -2
  34. package/dist/Tooltip.js.map +1 -1
  35. package/dist/aria.js.map +1 -1
  36. package/dist/hash.js.map +1 -1
  37. package/dist/jss.d.ts +6 -6
  38. package/dist/jss.js +2 -2
  39. package/dist/jss.js.map +1 -1
  40. package/dist/numberToBase.js.map +1 -1
  41. package/dist/stateMachineContextFactory.js.map +1 -1
  42. package/dist/useCookie.js.map +1 -1
  43. package/dist/useKeyboard.js.map +1 -1
  44. package/dist/useNavigation.js.map +1 -1
  45. package/dist/useRefEffect.js.map +1 -1
  46. package/next-env.d.ts +2 -1
  47. package/next.config.js +2 -1
  48. package/package.json +27 -20
  49. package/src/BaseListItem.tsx +1 -1
  50. package/src/Calendar.tsx +2 -2
  51. package/src/Dialog.tsx +3 -3
  52. package/src/Icon.tsx +4 -30
  53. package/src/Popover.tsx +3 -3
  54. package/src/Providers.tsx +1 -1
  55. package/src/RangeInput.tsx +1 -1
  56. package/src/Storage.tsx +1 -1
  57. package/src/TextInput.tsx +17 -5
  58. package/src/Tooltip.tsx +2 -2
  59. package/src/docs/mdx.tsx +40 -0
  60. package/src/docs/searchIndex.ts +1 -1
  61. package/src/jss.tsx +3 -3
  62. package/src/pages/Badge.mdx +136 -14
  63. package/src/pages/Button.mdx +121 -63
  64. package/src/pages/Calendar.mdx +196 -2
  65. package/src/pages/Card.mdx +123 -47
  66. package/src/pages/Checkbox.mdx +103 -28
  67. package/src/pages/Dialog.mdx +172 -7
  68. package/src/pages/FlexLayout.mdx +185 -51
  69. package/src/pages/Hashing.mdx +199 -8
  70. package/src/pages/Icon.mdx +150 -42
  71. package/src/pages/IconButton.mdx +127 -116
  72. package/src/pages/Link.mdx +118 -47
  73. package/src/pages/List.mdx +167 -283
  74. package/src/pages/ListHeader.mdx +157 -27
  75. package/src/pages/Popover.mdx +177 -55
  76. package/src/pages/ProgressBar.mdx +186 -6
  77. package/src/pages/ProgressCircle.mdx +196 -13
  78. package/src/pages/RangeInput.mdx +189 -61
  79. package/src/pages/Tabs.mdx +202 -346
  80. package/src/pages/Text.mdx +102 -81
  81. package/src/pages/TextInput.mdx +169 -44
  82. package/src/pages/TextPairing.mdx +164 -115
  83. package/src/pages/TimeInput.mdx +142 -37
  84. package/src/pages/Tooltip.mdx +99 -12
  85. package/src/pages/_app.tsx +13 -3
  86. package/src/pages/css-in-js.mdx +196 -83
  87. package/src/pages/navigation.mdx +122 -20
  88. package/src/pages/useCookie.mdx +168 -7
  89. package/src/pages/useKeyboard.mdx +242 -5
  90. package/src/pages/useNavigation.mdx +244 -16
  91. package/src/pages/usePromise.mdx +271 -6
  92. package/src/pages/useRefEffect.mdx +230 -28
  93. package/tsconfig.json +13 -4
@@ -1,71 +1,147 @@
1
1
  import { Card } from "../Card";
2
2
  import { Button } from "../Button";
3
3
  import { TextInput } from "../TextInput";
4
- import { TextArea } from "../TextArea";
5
- import { H2, P } from "../Text";
4
+ import { Column } from "../Column";
5
+ import { Row } from "../Row";
6
+ import { H2, H3, P, Span } from "../Text";
7
+ import { Icon } from "../Icon";
6
8
 
7
9
  # Card
8
10
 
9
- Cards can be used to make give cohesion to some UI elements, grouping them visually in a distinct way.
11
+ A container component that groups related content with a distinct visual treatment. Cards provide elevation, background, and rounded corners to create visual hierarchy.
12
+
13
+ ---
14
+
15
+ ## Props
16
+
17
+ Card extends all FlexLayout props:
18
+
19
+ | Prop | Type | Default | Description |
20
+ |------|------|---------|-------------|
21
+ | `padding` | `Padding` | `"large"` | Internal padding |
22
+ | `gap` | `Gap` | `"large"` | Space between children |
23
+ | `direction` | `"row"` \| `"column"` | `"column"` | Flex direction |
24
+ | `align` | `Align` | - | Cross-axis alignment |
25
+ | `justify` | `Justify` | - | Main-axis alignment |
26
+ | `grow` | `boolean` | - | Allow card to grow |
27
+
28
+ ---
29
+
30
+ ## Basic card
31
+
32
+ <Card>
33
+ <H3>Card title</H3>
34
+ <P>Cards group related content together with visual distinction from the surrounding interface.</P>
35
+ </Card>
36
+
37
+ ```js
38
+ <Card>
39
+ <H3>Card title</H3>
40
+ <P>Card content goes here...</P>
41
+ </Card>
42
+ ```
43
+
44
+ ---
45
+
46
+ ## Contact form example
10
47
 
11
48
  <Card>
12
- <H2>Contact Us</H2>
13
- <P>If you have any questions or inquiries, please feel free to contact us.</P>
49
+ <H3>Contact Us</H3>
50
+ <P>Send us a message and we'll get back to you soon.</P>
14
51
  <TextInput
15
- name="email"
16
- placeholder="Email"
17
- value={null}
18
- padding={"medium"}
52
+ placeholder="Your email"
53
+ value=""
19
54
  type="email"
20
55
  onValueChange={() => {}}
21
56
  />
22
- <TextArea
23
- jss={{
24
- resize: "vertical",
25
- }}
26
- name="message"
27
- placeholder="Type your query here..."
28
- value={null}
29
- type="text"
57
+ <TextInput
58
+ placeholder="Your message"
59
+ value=""
30
60
  onValueChange={() => {}}
31
61
  />
32
- <Button
33
- jss={{ animation: "all 1s ease-out" }}
34
- onClick={() => {}}
35
- type="submit"
36
- label="Subscribe"
37
- color="positive"
38
- />
62
+ <Button color="positive" onClick={() => {}}>
63
+ Send Message
64
+ </Button>
39
65
  </Card>
40
66
 
41
67
  ```js
42
68
  <Card>
43
- <H2>Contact Us</H2>
44
- <P>If you have any questions or inquiries, please feel free to contact us.</P>
69
+ <H3>Contact Us</H3>
70
+ <P>Send us a message and we'll get back to you soon.</P>
45
71
  <TextInput
46
- name="email"
47
- placeholder="Email"
48
- value={null}
49
- padding={"medium"}
72
+ placeholder="Your email"
73
+ value={email}
50
74
  type="email"
51
- onValueChange={() => {}}
75
+ onValueChange={setEmail}
52
76
  />
53
- <TextArea
54
- jss={{
55
- resize: "vertical",
56
- }}
57
- name="message"
58
- placeholder="Type your query here..."
59
- value={null}
60
- type="text"
61
- onValueChange={() => {}}
62
- />
63
- <Button
64
- jss={{ animation: "all 1s ease-out" }}
65
- onClick={() => {}}
66
- type="submit"
67
- label="Subscribe"
68
- color="positive"
77
+ <TextInput
78
+ placeholder="Your message"
79
+ value={message}
80
+ onValueChange={setMessage}
69
81
  />
82
+ <Button color="positive" onClick={handleSubmit}>
83
+ Send Message
84
+ </Button>
70
85
  </Card>
71
86
  ```
87
+
88
+ ---
89
+
90
+ ## Custom padding and gap
91
+
92
+ <Row gap="medium">
93
+ <Card padding="small" gap="small">
94
+ <Span>Small padding</Span>
95
+ <Span color="secondary">Compact layout</Span>
96
+ </Card>
97
+ <Card padding="xlarge" gap="medium">
98
+ <Span>Large padding</Span>
99
+ <Span color="secondary">Spacious layout</Span>
100
+ </Card>
101
+ </Row>
102
+
103
+ ```js
104
+ <Card padding="small" gap="small">
105
+ <Span>Compact card</Span>
106
+ </Card>
107
+
108
+ <Card padding="xlarge" gap="large">
109
+ <Span>Spacious card</Span>
110
+ </Card>
111
+ ```
112
+
113
+ ---
114
+
115
+ ## Horizontal card
116
+
117
+ Use `direction="row"` for horizontal layouts:
118
+
119
+ <Card direction="row" align="center" gap="medium">
120
+ <Icon icon="fa-user" color="highlight" size="xlarge" />
121
+ <Column gap="none">
122
+ <Span bold>John Doe</Span>
123
+ <Span color="secondary" size="small">Software Engineer</Span>
124
+ </Column>
125
+ </Card>
126
+
127
+ ```js
128
+ <Card direction="row" align="center" gap="medium">
129
+ <Icon icon="fa-user" color="highlight" size="xlarge" />
130
+ <Column gap="none">
131
+ <Span bold>John Doe</Span>
132
+ <Span color="secondary" size="small">Software Engineer</Span>
133
+ </Column>
134
+ </Card>
135
+ ```
136
+
137
+ ---
138
+
139
+ ## Use cases
140
+
141
+ Cards are useful for:
142
+
143
+ - **Forms** - Group related inputs together
144
+ - **Profiles** - Display user or item information
145
+ - **Summaries** - Highlight key metrics or stats
146
+ - **Actions** - Group related actions with context
147
+ - **Content sections** - Separate distinct content areas
@@ -2,55 +2,130 @@ import { Checkbox } from "../Checkbox";
2
2
  import { StaticCheckbox } from "../StaticCheckbox";
3
3
  import { Column } from "../Column";
4
4
  import { Row } from "../Row";
5
+ import { Span } from "../Text";
5
6
 
6
7
  # Checkbox
7
8
 
8
- The `Checkbox` component is an input of type checkbox with the visual style of a checkbox.
9
+ A styled checkbox input with custom visual appearance. Built on native HTML checkbox for full accessibility support.
9
10
 
10
- <Column>
11
- <Row padding="medium" gap="medium" justify="center" align="center">
11
+ ---
12
+
13
+ ## Props
14
+
15
+ ### Checkbox
16
+
17
+ | Prop | Type | Required | Default | Description |
18
+ |------|------|----------|---------|-------------|
19
+ | `checked` | `boolean` | Yes | - | Whether the checkbox is checked |
20
+ | `onClick` | `() => void` | Yes | - | Called when checkbox is toggled |
21
+ | `size` | `Size` | Yes | - | `"small"` (16px), `"medium"` (20px), `"large"` (24px) |
22
+
23
+ Also accepts standard HTML input attributes.
24
+
25
+ ### StaticCheckbox
26
+
27
+ | Prop | Type | Required | Default | Description |
28
+ |------|------|----------|---------|-------------|
29
+ | `checked` | `boolean` | Yes | - | Whether the checkbox appears checked |
30
+ | `size` | `Size` | Yes | - | `"small"`, `"medium"`, `"large"` |
31
+
32
+ ---
33
+
34
+ ## Sizes
35
+
36
+ <Row padding="medium" gap="xlarge" justify="center" align="center">
37
+ <Column gap="small" align="center">
12
38
  <Checkbox size="small" checked={true} onClick={() => {}} />
39
+ <Span size="small" color="secondary">small</Span>
40
+ </Column>
41
+ <Column gap="small" align="center">
13
42
  <Checkbox size="medium" checked={true} onClick={() => {}} />
43
+ <Span size="small" color="secondary">medium</Span>
44
+ </Column>
45
+ <Column gap="small" align="center">
14
46
  <Checkbox size="large" checked={true} onClick={() => {}} />
15
- </Row>
16
- <Row padding="medium" gap="medium" justify="center" align="center">
17
- <Checkbox size="small" checked={false} onClick={() => {}} />
18
- <Checkbox size="medium" checked={false} onClick={() => {}} />
19
- <Checkbox size="large" checked={false} onClick={() => {}} />
20
- </Row>
21
- </Column>
47
+ <Span size="small" color="secondary">large</Span>
48
+ </Column>
49
+ </Row>
22
50
 
23
51
  ```js
24
- <Column>
25
- <Row padding="medium" gap="medium" justify="center" align="center">
26
- <Checkbox size="small" checked={true} onClick={() => {}} />
27
- <Checkbox size="medium" checked={true} onClick={() => {}} />
28
- <Checkbox size="large" checked={true} onClick={() => {}} />
29
- </Row>
30
- <Row padding="medium" gap="medium" justify="center" align="center">
31
- <Checkbox size="small" checked={false} onClick={() => {}} />
52
+ <Checkbox size="small" checked={checked} onClick={toggle} />
53
+ <Checkbox size="medium" checked={checked} onClick={toggle} />
54
+ <Checkbox size="large" checked={checked} onClick={toggle} />
55
+ ```
56
+
57
+ ---
58
+
59
+ ## States
60
+
61
+ <Row padding="medium" gap="xlarge" justify="center" align="center">
62
+ <Column gap="small" align="center">
32
63
  <Checkbox size="medium" checked={false} onClick={() => {}} />
33
- <Checkbox size="large" checked={false} onClick={() => {}} />
34
- </Row>
35
- </Column>
64
+ <Span size="small" color="secondary">unchecked</Span>
65
+ </Column>
66
+ <Column gap="small" align="center">
67
+ <Checkbox size="medium" checked={true} onClick={() => {}} />
68
+ <Span size="small" color="secondary">checked</Span>
69
+ </Column>
70
+ </Row>
71
+
72
+ ```js
73
+ const [checked, setChecked] = useState(false);
74
+
75
+ <Checkbox
76
+ size="medium"
77
+ checked={checked}
78
+ onClick={() => setChecked(!checked)}
79
+ />
36
80
  ```
37
81
 
38
82
  ---
39
83
 
40
- ## Static checkbox
84
+ ## StaticCheckbox
41
85
 
42
- The variant `StaticCheckbox` can be used when one only needs the visual representation of a checkbox but the `<input type="checkbox" />` does not make sense.
86
+ Use `StaticCheckbox` when you need just the visual appearance without the underlying `<input>` element. Useful when the checkbox is part of a larger interactive component.
43
87
 
44
- <Row padding="medium" gap="medium" justify="center" align="center">
88
+ <Row padding="medium" gap="large" justify="center" align="center">
45
89
  <StaticCheckbox size="small" checked={true} />
46
90
  <StaticCheckbox size="medium" checked={true} />
47
91
  <StaticCheckbox size="large" checked={true} />
48
92
  </Row>
49
93
 
50
94
  ```js
51
- <Row padding="medium" gap="medium" justify="center" align="center">
52
- <StaticCheckbox size="small" checked={true} />
53
- <StaticCheckbox size="medium" checked={true} />
54
- <StaticCheckbox size="large" checked={true} />
95
+ // Visual only - no input element
96
+ <StaticCheckbox size="medium" checked={isSelected} />
97
+
98
+ // Used within a custom list item
99
+ <ListButtonItem
100
+ headline="Option"
101
+ addOn={<StaticCheckbox size="medium" checked={selected} />}
102
+ onClick={toggleSelection}
103
+ />
104
+ ```
105
+
106
+ ---
107
+
108
+ ## With label
109
+
110
+ Checkboxes are typically paired with labels for better UX:
111
+
112
+ ```js
113
+ <Row gap="small" align="center">
114
+ <Checkbox
115
+ size="medium"
116
+ checked={agreed}
117
+ onClick={() => setAgreed(!agreed)}
118
+ />
119
+ <Span>I agree to the terms and conditions</Span>
55
120
  </Row>
56
121
  ```
122
+
123
+ ---
124
+
125
+ ## Accessibility
126
+
127
+ - Uses native `<input type="checkbox">` for full keyboard and screen reader support
128
+ - Visual checkbox is layered over the hidden input
129
+ - Focus ring appears on keyboard navigation
130
+ - Press animation provides tactile feedback
131
+ - `aria-checked` attribute reflects current state
@@ -1,15 +1,47 @@
1
1
  import { DialogTrigger } from "../examples/ExampleDialog.tsx";
2
+ import { Button } from "../Button";
2
3
 
3
4
  # Dialog
4
5
 
5
- The `Dialog` component can be used to show a modal window on top of the main UI. When visible, it will trap focus and clicks to the underlying UI, which is the required behaviour for acceessibility.
6
+ A modal dialog component that overlays the main UI. Dialogs trap focus and prevent interaction with the underlying content, following accessibility best practices.
7
+
8
+ ---
9
+
10
+ ## Props
11
+
12
+ ### Dialog component
13
+
14
+ | Prop | Type | Required | Description |
15
+ |------|------|----------|-------------|
16
+ | `label` | `string` | Yes | Dialog title displayed in the header |
17
+ | `children` | `ReactNode` | Yes | Dialog content |
18
+ | `close` | `() => void` | Yes | Function to close the dialog |
19
+
20
+ ### useDialog hook
21
+
22
+ | Parameter | Type | Description |
23
+ |-----------|------|-------------|
24
+ | `DialogComponent` | `(props: { close: () => void } & Input) => JSX.Element` | Component to render inside the dialog |
25
+ | `options.closeOnOutsideClick` | `boolean` | Whether clicking outside closes the dialog |
26
+
27
+ Returns:
28
+ - `open(input?: Input)` - Function to open the dialog with optional input data
29
+ - `close()` - Function to close the dialog programmatically
30
+
31
+ ---
32
+
33
+ ## Basic usage
34
+
35
+ Click the button to open a dialog:
6
36
 
7
37
  <DialogTrigger />
8
38
 
9
39
  ```js
10
- function ExampleDialog({ close }) {
40
+ import { Dialog, useDialog } from "aidos-ui";
41
+
42
+ function MyDialog({ close }) {
11
43
  return (
12
- <Dialog close={close} label="Example">
44
+ <Dialog close={close} label="Settings">
13
45
  <Row padding="medium" align="center" justify="space-between">
14
46
  <Span>Dark mode</Span>
15
47
  <DarkModeToggle />
@@ -18,15 +50,148 @@ function ExampleDialog({ close }) {
18
50
  );
19
51
  }
20
52
 
21
- export function DialogTrigger() {
22
- const { open } = useDialog<void>(
23
- ({ close }) => <ExampleDialog close={close} />,
53
+ function App() {
54
+ const { open } = useDialog(
55
+ ({ close }) => <MyDialog close={close} />,
24
56
  { closeOnOutsideClick: true }
25
57
  );
26
58
 
27
- return <Button label="Show dialog" color={"positive"} onClick={() => open()} />;
59
+ return (
60
+ <Button color="positive" onClick={() => open()}>
61
+ Open Settings
62
+ </Button>
63
+ );
64
+ }
65
+ ```
66
+
67
+ ---
68
+
69
+ ## Passing data to dialog
70
+
71
+ Use TypeScript generics to pass data when opening the dialog:
72
+
73
+ ```js
74
+ interface UserData {
75
+ name: string;
76
+ email: string;
28
77
  }
29
78
 
79
+ function EditUserDialog({ close, name, email }: { close: () => void } & UserData) {
80
+ return (
81
+ <Dialog close={close} label="Edit User">
82
+ <Column padding="medium" gap="medium">
83
+ <TextInput value={name} onValueChange={() => {}} />
84
+ <TextInput value={email} onValueChange={() => {}} />
85
+ <Button color="positive" onClick={close}>
86
+ Save
87
+ </Button>
88
+ </Column>
89
+ </Dialog>
90
+ );
91
+ }
92
+
93
+ function App() {
94
+ const { open } = useDialog<UserData>(
95
+ ({ close, name, email }) => (
96
+ <EditUserDialog close={close} name={name} email={email} />
97
+ ),
98
+ { closeOnOutsideClick: false }
99
+ );
100
+
101
+ return (
102
+ <Button
103
+ color="primary"
104
+ onClick={() => open({ name: "John", email: "john@example.com" })}
105
+ >
106
+ Edit User
107
+ </Button>
108
+ );
109
+ }
30
110
  ```
31
111
 
32
112
  ---
113
+
114
+ ## Dialog options
115
+
116
+ ### Close on outside click
117
+
118
+ Control whether clicking the backdrop closes the dialog:
119
+
120
+ ```js
121
+ // Dialog closes when clicking outside
122
+ const { open } = useDialog(
123
+ ({ close }) => <MyDialog close={close} />,
124
+ { closeOnOutsideClick: true }
125
+ );
126
+
127
+ // Dialog stays open until explicitly closed
128
+ const { open } = useDialog(
129
+ ({ close }) => <MyDialog close={close} />,
130
+ { closeOnOutsideClick: false }
131
+ );
132
+ ```
133
+
134
+ ---
135
+
136
+ ## Closing the dialog
137
+
138
+ Dialogs can be closed in several ways:
139
+
140
+ 1. **Close button** - Built into the Dialog header
141
+ 2. **Escape key** - Native dialog behavior
142
+ 3. **Outside click** - When `closeOnOutsideClick: true`
143
+ 4. **Programmatically** - Using the `close` function
144
+
145
+ ```js
146
+ function ConfirmDialog({ close, onConfirm }) {
147
+ return (
148
+ <Dialog close={close} label="Confirm">
149
+ <Column padding="medium" gap="medium">
150
+ <P>Are you sure you want to proceed?</P>
151
+ <Row gap="medium" justify="end">
152
+ <Button bare color="primary" onClick={close}>
153
+ Cancel
154
+ </Button>
155
+ <Button
156
+ color="positive"
157
+ onClick={() => {
158
+ onConfirm();
159
+ close();
160
+ }}
161
+ >
162
+ Confirm
163
+ </Button>
164
+ </Row>
165
+ </Column>
166
+ </Dialog>
167
+ );
168
+ }
169
+ ```
170
+
171
+ ---
172
+
173
+ ## Setup
174
+
175
+ The `DialogProvider` must wrap your app to enable dialogs. This is typically included in the `Providers` component:
176
+
177
+ ```js
178
+ import { Providers } from "aidos-ui";
179
+
180
+ function App() {
181
+ return (
182
+ <Providers>
183
+ {/* Your app content */}
184
+ </Providers>
185
+ );
186
+ }
187
+ ```
188
+
189
+ ---
190
+
191
+ ## Accessibility
192
+
193
+ - Uses native `<dialog>` element with `showModal()` for proper modal behavior
194
+ - Focus is trapped within the dialog
195
+ - Escape key closes the dialog
196
+ - Focus returns to the triggering element when closed
197
+ - Backdrop prevents interaction with underlying content