@utilitywarehouse/hearth-react 0.28.6 → 0.29.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 (104) hide show
  1. package/README.md +34 -20
  2. package/SKILL.md +355 -0
  3. package/dist/{chunk-O7RBVBMN.cjs → chunk-LWHIBSW2.cjs} +2 -2
  4. package/dist/{chunk-O7RBVBMN.cjs.map → chunk-LWHIBSW2.cjs.map} +1 -1
  5. package/dist/{chunk-JRVYOIXR.js → chunk-MIVYZGEV.js} +2 -2
  6. package/dist/components/CardAccordion/CardAccordion.context.d.ts.map +1 -1
  7. package/dist/components/Combobox/Combobox.cjs +1 -1
  8. package/dist/components/Combobox/Combobox.js +1 -1
  9. package/dist/components/ExpandableCard/ExpandableCard.cjs +1 -1
  10. package/dist/components/ExpandableCard/ExpandableCard.js +1 -1
  11. package/dist/helpers/get-classname-styles.d.ts.map +1 -1
  12. package/dist/helpers/logger.d.ts.map +1 -1
  13. package/dist/helpers/merge-ids.d.ts.map +1 -1
  14. package/dist/hooks/use-ids.d.ts.map +1 -1
  15. package/dist/index.cjs +1 -1
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.js +1 -1
  18. package/package.json +18 -12
  19. package/public/llms/components/accordion.md +321 -0
  20. package/public/llms/components/alert.md +217 -0
  21. package/public/llms/components/avatar.md +112 -0
  22. package/public/llms/components/badge.md +158 -0
  23. package/public/llms/components/body-text.md +200 -0
  24. package/public/llms/components/box.md +148 -0
  25. package/public/llms/components/breadcrumbs.md +97 -0
  26. package/public/llms/components/button.md +595 -0
  27. package/public/llms/components/card-accordion.md +277 -0
  28. package/public/llms/components/card.md +985 -0
  29. package/public/llms/components/checkbox-group.md +193 -0
  30. package/public/llms/components/checkbox-tile.md +116 -0
  31. package/public/llms/components/checkbox.md +108 -0
  32. package/public/llms/components/combobox.md +360 -0
  33. package/public/llms/components/container.md +162 -0
  34. package/public/llms/components/currency-input.md +85 -0
  35. package/public/llms/components/date-input.md +90 -0
  36. package/public/llms/components/date-picker.md +159 -0
  37. package/public/llms/components/description-list.md +149 -0
  38. package/public/llms/components/detail-text.md +89 -0
  39. package/public/llms/components/divider.md +88 -0
  40. package/public/llms/components/em.md +43 -0
  41. package/public/llms/components/expandable-card.md +231 -0
  42. package/public/llms/components/flex.md +197 -0
  43. package/public/llms/components/grid.md +244 -0
  44. package/public/llms/components/heading.md +65 -0
  45. package/public/llms/components/helper-text.md +27 -0
  46. package/public/llms/components/highlight-banner.md +94 -0
  47. package/public/llms/components/icon-button.md +516 -0
  48. package/public/llms/components/icon-container.md +247 -0
  49. package/public/llms/components/inline-link.md +190 -0
  50. package/public/llms/components/label.md +28 -0
  51. package/public/llms/components/link.md +236 -0
  52. package/public/llms/components/list.md +715 -0
  53. package/public/llms/components/menu.md +270 -0
  54. package/public/llms/components/modal.md +328 -0
  55. package/public/llms/components/pagination.md +138 -0
  56. package/public/llms/components/password-input.md +93 -0
  57. package/public/llms/components/progress-bar.md +139 -0
  58. package/public/llms/components/progress-stepper.md +147 -0
  59. package/public/llms/components/radio-group.md +487 -0
  60. package/public/llms/components/search-input.md +132 -0
  61. package/public/llms/components/section-header.md +82 -0
  62. package/public/llms/components/select.md +148 -0
  63. package/public/llms/components/skeleton.md +282 -0
  64. package/public/llms/components/spinner.md +59 -0
  65. package/public/llms/components/strong.md +49 -0
  66. package/public/llms/components/switch.md +106 -0
  67. package/public/llms/components/table.md +230 -0
  68. package/public/llms/components/tabs.md +320 -0
  69. package/public/llms/components/text-area.md +141 -0
  70. package/public/llms/components/text-input.md +228 -0
  71. package/public/llms/components/toast.md +323 -0
  72. package/public/llms/components/toggle-button-card.md +513 -0
  73. package/public/llms/components/tooltip.md +188 -0
  74. package/public/llms/components/unstyled-icon-button.md +175 -0
  75. package/public/llms/components/validation-text.md +29 -0
  76. package/public/llms/components/verification-input.md +96 -0
  77. package/public/llms/docs/changelog.md +1430 -0
  78. package/public/llms/docs/common-props/align-self.md +90 -0
  79. package/public/llms/docs/common-props/border.md +308 -0
  80. package/public/llms/docs/common-props/colour.md +221 -0
  81. package/public/llms/docs/common-props/flex-items.md +91 -0
  82. package/public/llms/docs/common-props/gap.md +111 -0
  83. package/public/llms/docs/common-props/grid-items.md +96 -0
  84. package/public/llms/docs/common-props/margin.md +105 -0
  85. package/public/llms/docs/common-props/opacity.md +100 -0
  86. package/public/llms/docs/common-props/order.md +90 -0
  87. package/public/llms/docs/common-props/overflow.md +89 -0
  88. package/public/llms/docs/common-props/padding.md +102 -0
  89. package/public/llms/docs/common-props/position.md +92 -0
  90. package/public/llms/docs/common-props/size.md +93 -0
  91. package/public/llms/docs/common-props/spacing.md +97 -0
  92. package/public/llms/docs/common-props/text.md +35 -0
  93. package/public/llms/docs/common-props/z-index.md +88 -0
  94. package/public/llms/docs/design-tokens.md +72 -0
  95. package/public/llms/docs/getting-started.md +117 -0
  96. package/public/llms/docs/layout.md +135 -0
  97. package/public/llms/docs/migrating.md +302 -0
  98. package/public/llms/docs/responsive-design/breakpoints.md +119 -0
  99. package/public/llms/docs/responsive-design/media-queries.md +89 -0
  100. package/public/llms/docs/responsive-design/responsive-props.md +37 -0
  101. package/public/llms.txt +97 -0
  102. package/scripts/init-ai.js +142 -0
  103. package/styles.css +2 -2
  104. /package/dist/{chunk-JRVYOIXR.js.map → chunk-MIVYZGEV.js.map} +0 -0
@@ -0,0 +1,188 @@
1
+ # Tooltip
2
+
3
+ Use `Tooltip` to temporarily display short, contextual text, that
4
+ is not critical information, related to an element when
5
+ the element receives keyboard focus or the mouse hovers over it.
6
+
7
+ - [Setup](#setup)
8
+ - [Usage](#usage)
9
+ - [Alignment](#alignment)
10
+ - [Heading](#heading)
11
+ - [Accessibility](#accessibility)
12
+ - [Keyboard interactions](#keyboard-interactions)
13
+ - [API](#api)
14
+
15
+ ```tsx
16
+ <Flex justifyContent="center" padding="800">
17
+ <Tooltip {...args}>
18
+ <UnstyledIconButton label="further information">
19
+ <InfoSmallIcon />
20
+ </UnstyledIconButton>
21
+ </Tooltip>
22
+ </Flex>
23
+ ```
24
+
25
+ ## Setup
26
+
27
+ `Tooltip` requires a provider to be present in the component tree. You can use
28
+ either the global `HearthProvider` or the more specific `TooltipProvider`
29
+ depending on your needs.
30
+
31
+ ### HearthProvider
32
+
33
+ When setting up your application, wrap it with `HearthProvider`. This is the
34
+ preferred approach as it includes all necessary providers for Hearth
35
+ components, including tooltip support.
36
+
37
+ ```tsx
38
+ import { HearthProvider } from '@utilitywarehouse/hearth-react';
39
+
40
+ function App({ children }) {
41
+ return <HearthProvider>{children}</HearthProvider>;
42
+ }
43
+ ```
44
+
45
+ ### TooltipProvider
46
+
47
+ If you only need tooltip functionality in a specific part of your application,
48
+ you can use `TooltipProvider` directly.
49
+
50
+ ```tsx
51
+ import { TooltipProvider } from '@utilitywarehouse/hearth-react';
52
+
53
+ function MyFeature({ children }) {
54
+ return <TooltipProvider>{children}</TooltipProvider>;
55
+ }
56
+ ```
57
+
58
+ ## Usage
59
+
60
+ The `Tooltip` component accepts any single child element as the trigger, and
61
+ displays the tooltip content on hover or focus.
62
+
63
+ ```tsx
64
+ import { Tooltip } from '@utilitywarehouse/hearth-react';
65
+ import { InfoSmallIcon } from '@utilitywarehouse/hearth-react-icons';
66
+
67
+ <Tooltip description="Helpful information">
68
+ <UnstyledIconButton label="further information">
69
+ <InfoSmallIcon />
70
+ </UnstyledIconButton>
71
+ </Tooltip>;
72
+ ```
73
+
74
+ You can also use it with other interactive elements, such as buttons:
75
+
76
+ ```tsx
77
+ <Flex justifyContent="center" padding="800">
78
+ <Tooltip {...args}>
79
+ <Button variant="outline" colorScheme="functional" size="sm">
80
+ Tooltip
81
+ </Button>
82
+ </Tooltip>
83
+ </Flex>
84
+ ```
85
+
86
+ ## Alignment
87
+
88
+ Use the `align` prop to control the position of the tooltip relative to the
89
+ trigger. The available options are: `topLeft`, `topCenter`, `topRight`,
90
+ `bottomLeft`, `bottomCenter`, `bottomRight`, `leftCenter`, and `rightCenter`.
91
+
92
+ The default alignment is `topCenter`.
93
+
94
+ ```tsx
95
+ <Flex direction="column" alignItems="center" gap="400" padding="800">
96
+ <Flex direction="row" gap="400" alignItems="center">
97
+ <Tooltip description="Left Center align" align="leftCenter">
98
+ <UnstyledIconButton label="further information">
99
+ <InfoSmallIcon />
100
+ </UnstyledIconButton>
101
+ </Tooltip>
102
+ <Tooltip description="Right Center align" align="rightCenter">
103
+ <UnstyledIconButton label="further information">
104
+ <InfoSmallIcon />
105
+ </UnstyledIconButton>
106
+ </Tooltip>
107
+ </Flex>
108
+ <Flex direction="row" gap="400">
109
+ <Tooltip description="Bottom Left align" align="bottomLeft">
110
+ <UnstyledIconButton label="further information">
111
+ <InfoSmallIcon />
112
+ </UnstyledIconButton>
113
+ </Tooltip>
114
+ <Tooltip description="Bottom Center align" align="bottomCenter">
115
+ <UnstyledIconButton label="further information">
116
+ <InfoSmallIcon />
117
+ </UnstyledIconButton>
118
+ </Tooltip>
119
+ <Tooltip description="Bottom Right align" align="bottomRight">
120
+ <UnstyledIconButton label="further information">
121
+ <InfoSmallIcon />
122
+ </UnstyledIconButton>
123
+ </Tooltip>
124
+ </Flex>
125
+ <Flex direction="row" gap="400">
126
+ <Tooltip description="Top Left align" align="topLeft">
127
+ <UnstyledIconButton label="further information">
128
+ <InfoSmallIcon />
129
+ </UnstyledIconButton>
130
+ </Tooltip>
131
+ <Tooltip description="Top Center align" align="topCenter">
132
+ <UnstyledIconButton label="further information">
133
+ <InfoSmallIcon />
134
+ </UnstyledIconButton>
135
+ </Tooltip>
136
+ <Tooltip description="Top Right align" align="topRight">
137
+ <UnstyledIconButton label="further information">
138
+ <InfoSmallIcon />
139
+ </UnstyledIconButton>
140
+ </Tooltip>
141
+ </Flex>
142
+ </Flex>
143
+ ```
144
+
145
+ ## Heading
146
+
147
+ You can optionally include a `heading` alongside the `description` to provide
148
+ more structured tooltip content.
149
+
150
+ ```tsx
151
+ <Flex justifyContent="center" padding="800">
152
+ <Tooltip {...args}>
153
+ <UnstyledIconButton label="further information">
154
+ <InfoSmallIcon />
155
+ </UnstyledIconButton>
156
+ </Tooltip>
157
+ </Flex>
158
+ ```
159
+
160
+ ## Accessibility
161
+
162
+ Adheres to the [WAI-ARIA Tooltip](https://www.w3.org/WAI/ARIA/apg/patterns/tooltip/) pattern.
163
+
164
+ ### Keyboard interactions
165
+
166
+ | Key | Description |
167
+ | -------- | ------------------------------------------ |
168
+ | `Tab` | Opens/closes the tooltip without delay. |
169
+ | `Space` | If open, closes the tooltip without delay. |
170
+ | `Enter` | If open, closes the tooltip without delay. |
171
+ | `Escape` | If open, closes the tooltip without delay. |
172
+
173
+ ## API
174
+
175
+ | Prop | Type | Default | Description |
176
+ | ------------------------ | ---------------------------------------------------------------------------------------------------------------------------- | ----------- | --------------------------------------------------------------------------------------------------------------------- |
177
+ | `align` | `"rightCenter" \| "leftCenter" \| "bottomLeft" \| "bottomCenter" \| "bottomRight" \| "topLeft" \| "topCenter" \| "topRight"` | `topCenter` | |
178
+ | `aria-label` | `string` | — | A more descriptive label for accessibility purpose |
179
+ | `heading` | `string` | — | |
180
+ | `hideWhenDetached` | `boolean` | — | |
181
+ | `updatePositionStrategy` | `"optimized" \| "always"` | — | |
182
+ | `forceMount` | `true` | — | Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries. |
183
+ | `onEscapeKeyDown` | `((event: KeyboardEvent) => void)` | — | Event handler called when the escape key is down. Can be prevented. |
184
+ | `onPointerDownOutside` | `((event: PointerDownOutsideEvent) => void)` | — | Event handler called when the a `pointerdown` event happens outside of the `Tooltip`. Can be prevented. |
185
+ | `open` | `boolean` | — | |
186
+ | `defaultOpen` | `boolean` | — | |
187
+ | `onOpenChange` | `((open: boolean) => void)` | — | |
188
+ | `description` | `ReactNode` | — | |
@@ -0,0 +1,175 @@
1
+ # UnstyledIconButton
2
+
3
+ - [Icons](#icons)
4
+ - [Accessibility](#accessibility)
5
+ - [Disabled buttons](#disabled-buttons)
6
+ - [Size](#size)
7
+ - [Responsive icon sizes](#responsive-icon-sizes)
8
+ - [Semantic HTML](#semantic-html)
9
+ - [API](#api)
10
+
11
+ ```tsx
12
+ <Flex direction="column">
13
+ <Box padding="200">
14
+ <UnstyledIconButton {...args}>
15
+ {args.size === 'sm' ? <CloseSmallIcon /> : <CloseMediumIcon />}
16
+ </UnstyledIconButton>
17
+ </Box>
18
+ <Box padding="200" backgroundColor="brand">
19
+ <UnstyledIconButton {...args} inverted>
20
+ {args.size === 'sm' ? <CloseSmallIcon /> : <CloseMediumIcon />}
21
+ </UnstyledIconButton>
22
+ </Box>
23
+ </Flex>
24
+ ```
25
+
26
+ ## Icons
27
+
28
+ This button is intended to be used with the Hearth Icons packages (to be released). If you do use
29
+ another icon, please add the `data-icon` attribute to your icon so that it
30
+ renders the appropriate styles.
31
+
32
+ ```tsx
33
+ <UnstyledIconButton>
34
+ <AddMediumIcon />
35
+ </UnstyledIconButton>
36
+
37
+ [...]
38
+
39
+ <UnstyledIconButton>
40
+ <MyFontIcon aria-hidden="true" data-icon />
41
+ </UnstyledIconButton>
42
+ ```
43
+
44
+ ## Accessibility
45
+
46
+ Follows the [WAI-ARIA Button Pattern](https://www.w3.org/WAI/ARIA/apg/patterns/button/).
47
+
48
+ Given the button contains only an icon (i.e. no text content), it is required
49
+ that a label be provided. This will be announced to a screen reader, and should
50
+ reflect the visual icon being used with the button.
51
+
52
+ Icons from the UW icons packages have `aria-hidden="true"` set by default. If
53
+ you are using an icon from outside these packages, and for purely decorative
54
+ reasons, please ensure it has this attribute set so that the icon is hidden
55
+ from screen readers.
56
+
57
+ ### Disabled buttons
58
+
59
+ Disabled buttons use `aria-disabled`, rather than `disabled`, so that they are
60
+ still focusable when using the keyboard. This means that screen readers are
61
+ still able to find the button, with the insight that it is disabled and that
62
+ there is perhaps an action which needs to be taken, rather than not knowing
63
+ there is a button there at all. The `onClick` handler will be disabled, however
64
+ you will need to make sure you disable any other expected actions, including
65
+ when using `type="submit"`.
66
+
67
+ ## Size
68
+
69
+ The size prop controls the size of the `UnstyledIconButton`. This is a responsive prop and
70
+ can be used to display different sizes at different breakpoints.
71
+
72
+ ```tsx
73
+ <UnstyledIconButton
74
+ size={{
75
+ mobile: 'md',
76
+ tablet: 'sm',
77
+ desktop: 'md',
78
+ wide: 'sm',
79
+ }}
80
+ />
81
+ ```
82
+
83
+ ### Responsive icon sizes
84
+
85
+ If you need to render different sized icons in conjunction with the responsive
86
+ size prop, there are a couple of ways you can do this.
87
+
88
+ 1. Using JS, with the `useMediaQuery` hook.
89
+
90
+ ```tsx
91
+ import { AddMediumIcon, AddSmallIcon } from '@utilitywarehouse/hearth-react-icons';
92
+ import { UnstyledIconButton, useMediaQuery, media } from '@utilitywarehouse/hearth-react';
93
+
94
+ const MyComponent = () => {
95
+ const showDesktopIcon = useMediaQuery(media.above('desktop'));
96
+
97
+ return (
98
+ <UnstyledIconButton size={{ mobile: 'sm', desktop: 'md' }}>
99
+ {showDesktopIcon ? <AddMediumIcon /> : <AddSmallIcon />}
100
+ </UnstyledIconButton>
101
+ );
102
+ };
103
+ ```
104
+
105
+ 2. Using CSS, with `Box` and style props.
106
+
107
+ ```tsx
108
+ import { AddMediumIcon, AddSmallIcon } from '@utilitywarehouse/hearth-react-icons';
109
+ import { UnstyledIconButton, Box } from '@utilitywarehouse/hearth-react';
110
+
111
+ const MyComponent = () => (
112
+ <UnstyledIconButton size={{ mobile: 'sm', desktop: 'md' }} label="add">
113
+ <Box asChild display={{ mobile: 'none', desktop: 'block' }}>
114
+ <AddMediumIcon />
115
+ </Box>
116
+ <Box asChild display={{ desktop: 'none' }}>
117
+ <AddSmallIcon />
118
+ </Box>
119
+ </UnstyledIconButton>
120
+ );
121
+ ```
122
+
123
+ ## Semantic HTML
124
+
125
+ > If it goes somewhere it's a link, if it does something it's a button.
126
+
127
+ A semantic HTML button is rendered by default, however you can change the
128
+ underlying HTML element by using the `asChild` prop.
129
+
130
+ **NOTE:** Be aware that you cannot currently use `asChild` with the `emphasis` variant.
131
+
132
+ When `asChild` is set to true, the button will not render a default DOM element,
133
+ instead cloning the child and passing it the props and behaviour required to
134
+ make it functional.
135
+
136
+ Read more about this idea in the [Radix UI composition docs](https://www.radix-ui.com/primitives/docs/guides/composition).
137
+
138
+ ```tsx
139
+ <Flex gap="200">
140
+ <UnstyledIconButton {...args} asChild>
141
+ {/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
142
+ <a href={args.disabled ? undefined : 'https://uw.co.uk/services'}>
143
+ <AddMediumIcon />
144
+ </a>
145
+ </UnstyledIconButton>
146
+ <UnstyledIconButton {...args} asChild loading>
147
+ {/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
148
+ <a href={args.disabled ? undefined : 'https://uw.co.uk/services'}>
149
+ <AddMediumIcon />
150
+ </a>
151
+ </UnstyledIconButton>
152
+ </Flex>
153
+ ```
154
+
155
+ ```tsx
156
+ <UnstyledIconButton asChild>
157
+ <a href="https://uw.co.uk/services">
158
+ <AddMediumIcon />
159
+ </a>
160
+ </UnstyledIconButton>
161
+ ```
162
+
163
+ ## API
164
+
165
+ This component is based on the `button` element and supports the following common props:
166
+
167
+ - Margin
168
+
169
+ | Prop | Type | Default | Description |
170
+ | ---------- | -------------------------- | ------- | ---------------------------------------------------------------------------------------------------- |
171
+ | `label` | `string` | — | |
172
+ | `loading` | `boolean` | — | Indicate when the button is in a loading state, will also disable the button. |
173
+ | `asChild` | `boolean` | — | Change the default rendered element for the one passed as a child, merging their props and behavior. |
174
+ | `size` | `Responsive<"sm" \| "md">` | `md` | Sets the button height. |
175
+ | `inverted` | `boolean` | — | Inverts the component colours, for use on darker surface colours. |
@@ -0,0 +1,29 @@
1
+ # ValidationText
2
+
3
+ `ValidationText` should be used with form field components to display validation messages.
4
+
5
+ ```tsx
6
+ <ValidationText status="valid">Hearth validation text</ValidationText>
7
+ ```
8
+
9
+ ## API
10
+
11
+ This component is based on the `span` element and supports the following common props:
12
+
13
+ - Margin
14
+ - Text transform
15
+ - Text align
16
+
17
+ | Prop | Type | Default | Description |
18
+ | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- | ------------------------------------------------------------------------ |
19
+ | `status` | `"valid" \| "invalid"` | `'valid'` | The validation status |
20
+ | `disableUserSelect` | `boolean` | — | Make the text unselectable, for use when associated with input elements. |
21
+ | `margin` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
22
+ | `marginTop` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
23
+ | `marginRight` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
24
+ | `marginBottom` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
25
+ | `marginLeft` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
26
+ | `marginX` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
27
+ | `marginY` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
28
+ | `textAlign` | `Responsive<"center" \| "left" \| "right">` | — | |
29
+ | `textTransform` | `"none" \| "uppercase" \| "lowercase" \| "capitalize"` | — | Set the text-transform on the component. |
@@ -0,0 +1,96 @@
1
+ # VerificationInput
2
+
3
+ `VerificationInput` allows users to enter a one-time password (OTP) sent via
4
+ SMS, email, or authenticator apps.
5
+
6
+ ```tsx
7
+ <VerificationInput label="Label" helperText="Helper text" validationText="Validation text" />
8
+ ```
9
+
10
+ ## Alternatives
11
+
12
+ - TextInput - For text
13
+ - PasswordInput - For entering
14
+ passwords
15
+ - SearchInput - For search
16
+ - CurrencyInput - For money
17
+ - DateInput - For entering dates
18
+
19
+ ## Controlled
20
+
21
+ Use `value` in conjunction with `onValueChange` for a controlled input.
22
+
23
+ ```tsx
24
+ const [value, setValue] = React.useState("");
25
+
26
+ [...]
27
+
28
+ <VerificationInput
29
+ label="Controlled"
30
+ value={value}
31
+ onValueChange={setValue}
32
+ />
33
+ ```
34
+
35
+ ## Input type
36
+
37
+ By default `VerificationInput` renders a text input where the value is visible.
38
+ You can set `type="password"` if you need to visually hide the value being
39
+ entered.
40
+
41
+ ## Validation type
42
+
43
+ The `VerificationInput` only accepts numeric values by default. To change this,
44
+ use the `validationType` prop.
45
+
46
+ If you set this to `"none"` you can use the `sanitizeValue` prop for custom
47
+ sanitization. This function will be called before updating values in response
48
+ to user interactions.
49
+
50
+ ## Auto submit
51
+
52
+ Use the `autoSubmit` and `onAutoSubmit` props to define whether the component
53
+ should attempt to automatically submit when all fields are filled. If the field
54
+ is associated with an HTML form element, the form's `requestSubmit` method will
55
+ be called. The `onAutoSubmit` callback will be called when `autoSubmit` is
56
+ `true`, before attempting to submit the associated form.
57
+
58
+ ## API
59
+
60
+ This component is based on the `input` element and supports the following common props:
61
+
62
+ - Margin
63
+
64
+ | Prop | Type | Default | Description |
65
+ | ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
66
+ | `form` | `string` | — | A string specifying the `form` element with which the input is associated. This string's value, if present, must match the id of a `form` element in the same document. @see https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#form |
67
+ | `label` | `string` | — | The label for the form field, describing its purpose. |
68
+ | `autoComplete` | `"off" \| "one-time-code"` | — | Specifies what—if any—permission the user agent has to provide automated assistance in filling out form field values, as well as guidance to the browser as to the type of information expected in the field. Allows `"one-time-code"` or `"off"`. @defaultValue `"one-time-code"` @see https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/autocomplete |
69
+ | `autoFocus` | `boolean` | — | Whether or not the first fillable input should be focused on page-load. @defaultValue `false` @see https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/autofocus |
70
+ | `autoSubmit` | `boolean` | — | Whether or not the component should attempt to automatically submit when all fields are filled. If the field is associated with an HTML `form` element, the form's `requestSubmit` method will be called. @defaultValue `false` |
71
+ | `defaultValue` | `string` | — | The initial value of the uncontrolled field. |
72
+ | `disabled` | `boolean` | — | Whether or not the the field's input elements are disabled. |
73
+ | `name` | `string` | — | A string specifying a name for the input control. This name is submitted along with the control's value when the form data is submitted. @see https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#name |
74
+ | `onAutoSubmit` | `((value: string) => void)` | — | When the `autoSubmit` prop is set to `true`, this callback will be fired before attempting to submit the associated form. It will be called whether or not a form is located, or if submission is not allowed. |
75
+ | `onValueChange` | `((value: string) => void)` | — | A callback fired when the field's value changes. When the component is controlled, this should update the state passed to the `value` prop. |
76
+ | `placeholder` | `string` | — | Defines the text displayed in a form control when the control has no value. @see https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/placeholder |
77
+ | `readOnly` | `boolean` | — | Whether or not the input elements can be updated by the user. @see https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/readonly |
78
+ | `sanitizeValue` | `((value: string) => string)` | — | Function for custom sanitization when `validationType` is set to `"none"`. This function will be called before updating values in response to user interactions. |
79
+ | `type` | `"text" \| "password"` | — | The input type of the field's input elements. Can be `"password"` or `"text"`. |
80
+ | `validationType` | `"none" \| "numeric" \| "alpha" \| "alphanumeric"` | — | Specifies the type of input validation to be used. Can be `"alpha"`, `"numeric"`, `"alphanumeric"` or `"none"`. @defaultValue `"numeric"` |
81
+ | `value` | `string` | — | The controlled value of the field. |
82
+ | `labelId` | `string` | — | |
83
+ | `helperTextId` | `string` | — | |
84
+ | `validationTextId` | `string` | — | |
85
+ | `required` | `boolean` | — | |
86
+ | `labelVariant` | `"body" \| "heading"` | — | Change the label variant |
87
+ | `helperText` | `string` | — | Optional helper text to provide additional context or instructions. |
88
+ | `validationText` | `string` | — | Text to display when the `validationStatus` is set. |
89
+ | `validationStatus` | `"valid" \| "invalid"` | — | Indicates the validation status. |
90
+ | `margin` | `Responsive<"0" \| "auto" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
91
+ | `marginTop` | `Responsive<"0" \| "auto" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
92
+ | `marginRight` | `Responsive<"0" \| "auto" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
93
+ | `marginBottom` | `Responsive<"0" \| "auto" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
94
+ | `marginLeft` | `Responsive<"0" \| "auto" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
95
+ | `marginX` | `Responsive<"0" \| "auto" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
96
+ | `marginY` | `Responsive<"0" \| "auto" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |