@clicktap/ui 0.14.19 → 0.14.26

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 (205) hide show
  1. package/components/Avatar/Avatar.d.ts +5 -1
  2. package/components/Avatar/Avatar.js +1 -1
  3. package/components/Avatar/Avatar.types.d.ts +28 -2
  4. package/components/Avatar/AvatarGroup/AvatarGroup.d.ts +5 -1
  5. package/components/Avatar/AvatarGroup/AvatarGroup.js +1 -1
  6. package/components/Avatar/AvatarGroup/AvatarGroup.types.d.ts +7 -2
  7. package/components/Avatar/index.js +1 -1
  8. package/components/ContextMenu/ContextMenu.js +1 -1
  9. package/components/Dialog/Dialog.js +1 -1
  10. package/components/DialogTrigger/DialogTrigger.js +1 -1
  11. package/components/Drawer/Drawer.js +1 -1
  12. package/components/ModalOverlay/ModalOverlay.js +1 -1
  13. package/components/PinInput/PinInput.js +1 -1
  14. package/components/Select/Select.js +1 -1
  15. package/components/Tabs/Tabs.context.d.ts +3 -0
  16. package/package.json +1 -2
  17. package/components/Accordion/Accordion.tsx +0 -82
  18. package/components/Accordion/index.ts +0 -3
  19. package/components/Avatar/Avatar.stories.tsx +0 -99
  20. package/components/Avatar/Avatar.tsx +0 -120
  21. package/components/Avatar/Avatar.types.ts +0 -3
  22. package/components/Avatar/AvatarGroup/AvatarGroup.tsx +0 -32
  23. package/components/Avatar/AvatarGroup/AvatarGroup.types.ts +0 -8
  24. package/components/Avatar/index.ts +0 -4
  25. package/components/Badge/Badge.stories.tsx +0 -72
  26. package/components/Badge/Badge.tsx +0 -169
  27. package/components/Badge/Badge.types.ts +0 -3
  28. package/components/Badge/index.ts +0 -2
  29. package/components/Breadcrumbs/BreadcrumbEllipsis.tsx +0 -47
  30. package/components/Breadcrumbs/BreadcrumbEllipsis.types.ts +0 -5
  31. package/components/Breadcrumbs/BreadcrumbItem.tsx +0 -23
  32. package/components/Breadcrumbs/BreadcrumbItem.types.ts +0 -3
  33. package/components/Breadcrumbs/BreadcrumbLink.tsx +0 -30
  34. package/components/Breadcrumbs/BreadcrumbLink.types.ts +0 -3
  35. package/components/Breadcrumbs/BreadcrumbSeparator.tsx +0 -41
  36. package/components/Breadcrumbs/BreadcrumbSeparator.types.ts +0 -9
  37. package/components/Breadcrumbs/Breadcrumbs.tsx +0 -28
  38. package/components/Breadcrumbs/Breadcrumbs.types.ts +0 -6
  39. package/components/Breadcrumbs/index.ts +0 -10
  40. package/components/Button/Button.tsx +0 -72
  41. package/components/Button/Button.types.ts +0 -7
  42. package/components/Button/index.ts +0 -2
  43. package/components/Card/Card.tsx +0 -15
  44. package/components/Card/Card.types.ts +0 -3
  45. package/components/Card/index.ts +0 -2
  46. package/components/Checkbox/Checkbox.tsx +0 -122
  47. package/components/Checkbox/Checkbox.types.ts +0 -15
  48. package/components/Checkbox/index.ts +0 -2
  49. package/components/Collapsible/Collapsible.tsx +0 -34
  50. package/components/Collapsible/Collapsible.types.ts +0 -5
  51. package/components/Collapsible/CollapsibleTrigger.tsx +0 -57
  52. package/components/Collapsible/CollapsibleTrigger.types.ts +0 -14
  53. package/components/Collapsible/index.ts +0 -10
  54. package/components/Container/Container.tsx +0 -26
  55. package/components/Container/Container.types.ts +0 -3
  56. package/components/Container/index.ts +0 -2
  57. package/components/ContextMenu/ContextMenu.tsx +0 -74
  58. package/components/ContextMenu/ContextMenu.types.ts +0 -17
  59. package/components/ContextMenu/index.ts +0 -2
  60. package/components/CreditCardExpirationInput/CreditCardExpirationInput.tsx +0 -115
  61. package/components/CreditCardExpirationInput/CreditCardExpirationInput.types.ts +0 -10
  62. package/components/CreditCardExpirationInput/index.ts +0 -2
  63. package/components/CreditCardInput/CreditCardInput.tsx +0 -147
  64. package/components/CreditCardInput/CreditCardInput.types.ts +0 -12
  65. package/components/CreditCardInput/index.ts +0 -2
  66. package/components/DateInput/DateInput.tsx +0 -81
  67. package/components/DateInput/DateInput.types.ts +0 -15
  68. package/components/DateInput/index.ts +0 -2
  69. package/components/DateTimeFormat/DateTimeFormat.tsx +0 -16
  70. package/components/DateTimeFormat/DateTimeFormat.types.ts +0 -7
  71. package/components/DateTimeFormat/index.ts +0 -2
  72. package/components/Dialog/Dialog.tsx +0 -65
  73. package/components/Dialog/Dialog.types.ts +0 -9
  74. package/components/Dialog/index.ts +0 -2
  75. package/components/DialogTrigger/DialogTrigger.tsx +0 -45
  76. package/components/DialogTrigger/DialogTrigger.types.ts +0 -6
  77. package/components/DialogTrigger/index.ts +0 -5
  78. package/components/Divider/Divider.stories.tsx +0 -37
  79. package/components/Divider/Divider.tsx +0 -34
  80. package/components/Divider/Divider.types.ts +0 -5
  81. package/components/Divider/index.ts +0 -2
  82. package/components/DobInput/DobInput.tsx +0 -120
  83. package/components/DobInput/index.ts +0 -2
  84. package/components/Drawer/Drawer.tsx +0 -126
  85. package/components/Drawer/Drawer.types.ts +0 -11
  86. package/components/Drawer/index.ts +0 -2
  87. package/components/Icon/Account.tsx +0 -50
  88. package/components/Icon/Cart.tsx +0 -43
  89. package/components/Icon/Checkmark.tsx +0 -34
  90. package/components/Icon/Cross.tsx +0 -36
  91. package/components/Icon/DownArrow.tsx +0 -23
  92. package/components/Icon/Hamburger.tsx +0 -23
  93. package/components/Icon/Icon.types.ts +0 -8
  94. package/components/Icon/LinkArrow.tsx +0 -32
  95. package/components/Icon/Minus.tsx +0 -20
  96. package/components/Icon/Plus.tsx +0 -20
  97. package/components/Icon/Search.tsx +0 -36
  98. package/components/Icon/Trash.tsx +0 -27
  99. package/components/Icon/Verified.tsx +0 -20
  100. package/components/Icon/index.ts +0 -14
  101. package/components/Image/Image.tsx +0 -32
  102. package/components/Image/index.ts +0 -2
  103. package/components/Input/Input.tsx +0 -109
  104. package/components/Input/Input.types.ts +0 -17
  105. package/components/Input/index.ts +0 -2
  106. package/components/Link/Link.stories.tsx +0 -96
  107. package/components/Link/Link.tsx +0 -39
  108. package/components/Link/Link.types.ts +0 -3
  109. package/components/Link/index.ts +0 -2
  110. package/components/Loader/CircularEasing.tsx +0 -66
  111. package/components/Loader/CircularEasing.types.ts +0 -8
  112. package/components/Loader/Pulse.tsx +0 -45
  113. package/components/Loader/Pulse.types.ts +0 -5
  114. package/components/Loader/index.ts +0 -4
  115. package/components/Menu/ContextMenu.tsx +0 -83
  116. package/components/Menu/Menu.tsx +0 -143
  117. package/components/Menu/Menu.types.ts +0 -44
  118. package/components/Menu/index.ts +0 -4
  119. package/components/Meter/Meter.stories.tsx +0 -111
  120. package/components/Meter/Meter.tsx +0 -68
  121. package/components/Meter/Meter.types.ts +0 -10
  122. package/components/Meter/index.ts +0 -2
  123. package/components/Modal/Modal.tsx +0 -16
  124. package/components/Modal/Modal.types.ts +0 -6
  125. package/components/Modal/index.ts +0 -2
  126. package/components/ModalOverlay/ModalOverlay.tsx +0 -121
  127. package/components/ModalOverlay/ModalOverlay.types.ts +0 -18
  128. package/components/ModalOverlay/index.ts +0 -2
  129. package/components/NumberFormat/NumberFormat.tsx +0 -19
  130. package/components/NumberFormat/NumberFormat.types.ts +0 -8
  131. package/components/NumberFormat/index.ts +0 -2
  132. package/components/NumberInput/NumberInput.tsx +0 -164
  133. package/components/NumberInput/NumberInput.types.ts +0 -22
  134. package/components/NumberInput/index.ts +0 -2
  135. package/components/NumberTicker/DigitResolver.tsx +0 -119
  136. package/components/NumberTicker/DigitResolver.types.ts +0 -18
  137. package/components/NumberTicker/NumberTicker.tsx +0 -56
  138. package/components/NumberTicker/NumberTicker.types.ts +0 -96
  139. package/components/NumberTicker/hooks/useColumnTransition.ts +0 -36
  140. package/components/NumberTicker/hooks/useNumberDelta.ts +0 -19
  141. package/components/NumberTicker/hooks/useNumberTicker.ts +0 -36
  142. package/components/NumberTicker/index.ts +0 -10
  143. package/components/Pagination/Pagination.tsx +0 -44
  144. package/components/Pagination/index.ts +0 -2
  145. package/components/PasswordCheck/PasswordCheck.tsx +0 -59
  146. package/components/PasswordCheck/PasswordCheck.types.ts +0 -4
  147. package/components/PasswordCheck/PasswordCheck.utils.ts +0 -47
  148. package/components/PasswordCheck/index.ts +0 -2
  149. package/components/PhoneInput/PhoneInput.tsx +0 -191
  150. package/components/PhoneInput/index.ts +0 -2
  151. package/components/PinInput/PinInput.tsx +0 -318
  152. package/components/PinInput/PinInput.types.ts +0 -21
  153. package/components/PinInput/index.ts +0 -2
  154. package/components/Progressbar/CircularProgressbar.tsx +0 -71
  155. package/components/Progressbar/CircularProgressbar.types.ts +0 -10
  156. package/components/Progressbar/LinearProgressbar.tsx +0 -75
  157. package/components/Progressbar/LinearProgressbar.types.ts +0 -11
  158. package/components/Progressbar/index.ts +0 -4
  159. package/components/Radio/Radio.tsx +0 -88
  160. package/components/Radio/Radio.types.ts +0 -16
  161. package/components/Radio/index.ts +0 -2
  162. package/components/RadioGroup/RadioGroup.tsx +0 -49
  163. package/components/RadioGroup/RadioGroup.types.ts +0 -7
  164. package/components/RadioGroup/index.ts +0 -2
  165. package/components/Select/Option.tsx +0 -32
  166. package/components/Select/Option.types.ts +0 -3
  167. package/components/Select/Select.tsx +0 -272
  168. package/components/Select/Select.types.ts +0 -48
  169. package/components/Select/index.ts +0 -8
  170. package/components/Skeleton/Skeleton.tsx +0 -15
  171. package/components/Skeleton/Skeleton.types.ts +0 -3
  172. package/components/Skeleton/index.ts +0 -2
  173. package/components/Slider/Slider.tsx +0 -110
  174. package/components/Slider/Slider.types.ts +0 -11
  175. package/components/Slider/index.ts +0 -2
  176. package/components/Switch/Switch.tsx +0 -63
  177. package/components/Switch/Switch.types.ts +0 -8
  178. package/components/Switch/index.ts +0 -2
  179. package/components/Table/Table.tsx +0 -52
  180. package/components/Table/Table.types.ts +0 -22
  181. package/components/Table/index.ts +0 -2
  182. package/components/Tabs/Tab.tsx +0 -118
  183. package/components/Tabs/Tab.types.ts +0 -10
  184. package/components/Tabs/TabList.tsx +0 -51
  185. package/components/Tabs/TabList.types.ts +0 -12
  186. package/components/Tabs/TabPanel.tsx +0 -19
  187. package/components/Tabs/TabPanel.types.ts +0 -3
  188. package/components/Tabs/Tabs.context.tsx +0 -9
  189. package/components/Tabs/Tabs.tsx +0 -39
  190. package/components/Tabs/Tabs.types.ts +0 -3
  191. package/components/Tabs/index.ts +0 -9
  192. package/components/TimeInput/TimeInput.stories.tsx +0 -125
  193. package/components/TimeInput/TimeInput.tsx +0 -81
  194. package/components/TimeInput/TimeInput.types.ts +0 -15
  195. package/components/TimeInput/index.ts +0 -2
  196. package/components/ToggleButton/ToggleButton.stories.tsx +0 -89
  197. package/components/ToggleButton/ToggleButton.tsx +0 -69
  198. package/components/ToggleButton/ToggleButton.types.ts +0 -6
  199. package/components/ToggleButton/index.ts +0 -2
  200. package/components/Tooltip/Tooltip.tsx +0 -59
  201. package/components/Tooltip/Tooltip.types.ts +0 -3
  202. package/components/Tooltip/index.ts +0 -2
  203. package/components/UploadImage/UploadImage.tsx +0 -206
  204. package/components/UploadImage/UploadImage.types.ts +0 -15
  205. package/components/UploadImage/index.ts +0 -2
@@ -1,318 +0,0 @@
1
- 'use client';
2
-
3
- import { useEffect, useRef, useState } from 'react';
4
- import type { ChangeEvent, ClipboardEvent, KeyboardEvent } from 'react';
5
- import {
6
- FieldError,
7
- Group,
8
- Input,
9
- Label,
10
- Text,
11
- TextField,
12
- } from 'react-aria-components';
13
- import { cn } from '../../utils/cn';
14
- import type { PinInputProps } from './PinInput.types';
15
-
16
- /** based on https://github.com/chakra-ui/chakra-ui/blob/main/packages/components/src/pin-input/use-pin-input.ts */
17
- export function PinInput({
18
- description,
19
- errorMessage,
20
- isDisabled = false,
21
- isInvalid = false,
22
- isMasked = false,
23
- isRequired = true,
24
- label,
25
- length = 6,
26
- name,
27
- onChange: controlledOnChange,
28
- value = '',
29
- type = 'numeric',
30
- validationBehavior = 'native',
31
- className,
32
- classNames,
33
- ...props
34
- }: PinInputProps) {
35
- // const [focusedIndex, setFocusedIndex] = useState(-1);
36
- const [joinedValue, setJoinedValue] = useState(value);
37
- const [values, setValues] = useState<string[]>(Array(length).fill(''));
38
- const inputRefs = useRef<HTMLInputElement[]>([]);
39
-
40
- useEffect(() => {
41
- inputRefs.current = inputRefs.current.slice(0, length);
42
- }, [length]);
43
-
44
- useEffect(() => {
45
- const updatedValue = values.join('');
46
- setJoinedValue(updatedValue);
47
- if (controlledOnChange) controlledOnChange(updatedValue);
48
- }, [controlledOnChange, values]);
49
-
50
- // const onChange = (event: React.ChangeEvent<HTMLInputElement>) => {
51
- // const eventValue = event.target.value;
52
- // const currentValue = values[index];
53
- // const nextValue = getNextValue(currentValue, eventValue);
54
- // const allItems = getAllItems(containerRef.current);
55
-
56
- // // if the value was removed using backspace
57
- // if (nextValue === '') {
58
- // setValue('', index);
59
- // return;
60
- // }
61
-
62
- // // in the case of an autocomplete or copy and paste
63
- // if (eventValue.length > 2) {
64
- // // see if we can use the string to fill out our values
65
- // if (validate(eventValue, type)) {
66
- // // Ensure the value matches the number of inputs
67
- // const nextValue = eventValue
68
- // .split('')
69
- // .filter((_, index) => index < allItems.length);
70
-
71
- // setValues(nextValue);
72
- // // if pasting fills the entire input fields, trigger `onComplete`
73
- // if (nextValue.length === allItems.length) {
74
- // onComplete?.(nextValue.join(''));
75
- // }
76
- // }
77
- // } else {
78
- // // only set if the new value is a number
79
- // if (validate(nextValue, type)) {
80
- // setValue(nextValue, index);
81
- // }
82
-
83
- // setMoveFocus(true);
84
- // }
85
- // };
86
- const onChange = (event: ChangeEvent<HTMLInputElement>) => {
87
- const inputValue = event.target.value;
88
- const inputIndex = Number(
89
- event.target.getAttribute('data-pin-input-index')
90
- );
91
-
92
- if (inputValue !== '' && inputIndex < values.length - 1) {
93
- inputRefs.current?.[inputIndex + 1]?.focus();
94
- }
95
-
96
- const updatedValues = values.map((v, i) =>
97
- i === inputIndex ? inputValue : v
98
- );
99
- setValues(updatedValues);
100
-
101
- // return setValues(updatedValues);
102
- };
103
-
104
- const onKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {
105
- // const inputValue = event.currentTarget.value;
106
- const inputIndex = Number(
107
- event.currentTarget.getAttribute('data-pin-input-index')
108
- );
109
-
110
- // Allow standard keyboard shortcuts
111
- if (event.ctrlKey || event.metaKey) {
112
- return;
113
- }
114
-
115
- /** @todo is there a better way to pass through control keys? */
116
- const allowedKeys = [
117
- 'Backspace',
118
- 'Delete',
119
- 'ArrowLeft',
120
- 'ArrowRight',
121
- 'ArrowUp',
122
- 'ArrowDown',
123
- 'Control',
124
- 'Alt',
125
- 'Meta',
126
- 'Shift',
127
- 'Tab',
128
- 'Enter',
129
- 'Escape',
130
- ];
131
-
132
- const regex = {
133
- alpha: /^[a-z]$/i,
134
- alphanumeric: /^[a-z0-9]$/i,
135
- numeric: /^[0-9]$/i,
136
- };
137
-
138
- if (!event.key.match(regex[type]) && !allowedKeys.includes(event.key)) {
139
- event.preventDefault();
140
- }
141
-
142
- if (
143
- values[inputIndex] === '' &&
144
- inputIndex > 0 &&
145
- event.key === 'Backspace'
146
- ) {
147
- const updatedValues = values.map((v, i) =>
148
- i === inputIndex - 1 ? '' : v
149
- );
150
- setValues(updatedValues);
151
- inputRefs.current?.[inputIndex - 1]?.focus();
152
- event.preventDefault();
153
- }
154
-
155
- if (
156
- values[inputIndex] === '' &&
157
- inputIndex < values.length - 1 &&
158
- event.key === 'Delete'
159
- ) {
160
- const updatedValues = values.map((v, i) =>
161
- i === inputIndex + 1 ? '' : v
162
- );
163
- setValues(updatedValues);
164
- inputRefs.current?.[inputIndex + 1]?.focus();
165
- event.preventDefault();
166
- }
167
-
168
- // const prevValues = value;
169
- // prevValues[inputIndex] += inputValue;
170
- // setValue(prevValues);
171
- };
172
-
173
- const onPaste = (event: ClipboardEvent<HTMLInputElement>) => {
174
- const inputIndex = Number(
175
- event.currentTarget.getAttribute('data-pin-input-index')
176
- );
177
-
178
- event.preventDefault();
179
-
180
- const pasteData = event.clipboardData?.getData('text');
181
- if (!pasteData) return;
182
-
183
- /** @todo update to fail paste if contains invalid chars? */
184
- const splitValue = pasteData.split('').filter((char) => {
185
- switch (type) {
186
- case 'alpha':
187
- return /^[a-zA-Z]$/.test(char);
188
- case 'alphanumeric':
189
- return /^[a-z0-9]$/i.test(char);
190
- case 'numeric':
191
- default:
192
- return /^[0-9]$/.test(char);
193
- }
194
- });
195
-
196
- if (splitValue.length === 0) {
197
- return;
198
- }
199
-
200
- const updatedValues = [...values];
201
-
202
- let focusIndex = inputIndex;
203
-
204
- // eslint-disable-next-line no-plusplus
205
- for (let i = 0; i < splitValue.length && inputIndex + i < length; i++) {
206
- updatedValues[inputIndex + i] = splitValue[i];
207
- focusIndex = inputIndex + i;
208
- }
209
-
210
- setValues(updatedValues);
211
-
212
- const nextInputIndex =
213
- focusIndex + 1 < length ? focusIndex + 1 : length - 1;
214
- inputRefs.current[nextInputIndex]?.focus();
215
- };
216
-
217
- return (
218
- <Group
219
- className={cn('flex flex-wrap gap-2', className)}
220
- aria-label={label}
221
- // eslint-disable-next-line react/jsx-props-no-spreading
222
- {...props}
223
- >
224
- <Label
225
- className={cn(
226
- 'flex text-slate-500 text-sm grow shrink-0 basis-full',
227
- classNames?.label
228
- )}
229
- >
230
- {label}
231
- </Label>
232
-
233
- {values.map((v, i) => (
234
- <TextField
235
- className={cn(
236
- 'flex flex-col w-full flex-1 text-slate-900',
237
- classNames?.inputWrap
238
- )}
239
- // eslint-disable-next-line react/no-array-index-key
240
- key={`pin-input-${i}`}
241
- aria-label={`Pin Input Digit ${i + 1}`}
242
- isDisabled={isDisabled}
243
- isInvalid={isInvalid}
244
- isRequired={isRequired}
245
- validationBehavior={validationBehavior}
246
- >
247
- <Input
248
- className={cn(
249
- 'border-solid border border-slate-300 rounded-md',
250
- 'text-sm text-slate-900 placeholder-slate-400 text-center',
251
- 'h-10 px-2 py-0 m-0 w-full',
252
- 'bg-white',
253
- 'transition-all duration-200 ease-in-out',
254
- 'hover:border-slate-400',
255
- 'focus:outline-2 focus:outline focus:outline-slate-200 focus:border-slate-400',
256
- 'disabled:border-slate-200 disabled:bg-slate-100',
257
- 'invalid:border-red-500 invalid:bg-red-100 invalid:text-red-600',
258
- 'invalid:hover:border-red-600 invalid:focus:border-red-600 invalid:focus:outline-red-200',
259
- classNames?.input
260
- )}
261
- onChange={onChange}
262
- onKeyDown={onKeyDown}
263
- onPaste={onPaste}
264
- type={isMasked ? 'password' : 'text'}
265
- // eslint-disable-next-line no-return-assign
266
- ref={(el) => {
267
- if (el) {
268
- inputRefs.current[i] = el;
269
- }
270
- }}
271
- value={v}
272
- maxLength={1}
273
- name={name && `${name}-${i}`}
274
- // pattern="[0-9]*"
275
- data-pin-input-index={i}
276
- />
277
- {/* {description && (
278
- <StyledText slot="description">{description}</StyledText>
279
- )} */}
280
- </TextField>
281
- ))}
282
- <TextField
283
- className={cn(
284
- 'flex flex-row flex-wrap grow shrink-0 basis-full',
285
- classNames?.textWrap
286
- )}
287
- aria-label="Pin Input"
288
- isDisabled={isDisabled}
289
- isInvalid={isInvalid}
290
- isRequired={isRequired}
291
- validationBehavior={validationBehavior}
292
- >
293
- {name && <Input type="hidden" name={name} value={joinedValue} />}
294
- {description && (
295
- <Text
296
- className={cn(
297
- 'flex text-slate-500 text-sm grow shrink-0 basis-full',
298
- classNames?.description
299
- )}
300
- slot="description"
301
- >
302
- {description}
303
- </Text>
304
- )}
305
- <FieldError
306
- className={cn(
307
- 'flex text-red-500 text-sm grow shrink-0 basis-full',
308
- classNames?.error
309
- )}
310
- >
311
- {errorMessage}
312
- </FieldError>
313
- </TextField>
314
- </Group>
315
- );
316
- }
317
-
318
- export default PinInput;
@@ -1,21 +0,0 @@
1
- import type { GroupProps, ValidationResult } from 'react-aria-components';
2
- import type { SlotsToClasses } from '../../types/SlotsToClasses';
3
-
4
- /** @todo extend certain textfield props like name, validationBehavior and isRequired */
5
- export interface PinInputProps extends GroupProps {
6
- description?: string;
7
- errorMessage?: string | ((validation: ValidationResult) => string);
8
- label?: string;
9
- length?: number;
10
- name?: string;
11
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
- onChange?: (...event: any[]) => void;
13
- value?: string;
14
- isMasked?: boolean;
15
- isRequired?: boolean;
16
- type?: 'alpha' | 'alphanumeric' | 'numeric';
17
- validationBehavior?: 'native' | 'aria';
18
- classNames?: SlotsToClasses<
19
- 'label' | 'input' | 'description' | 'error' | 'inputWrap' | 'textWrap'
20
- >;
21
- }
@@ -1,2 +0,0 @@
1
- export { PinInput } from './PinInput';
2
- export type { PinInputProps } from './PinInput.types';
@@ -1,71 +0,0 @@
1
- 'use client';
2
-
3
- import { ProgressBar, Label } from 'react-aria-components';
4
- import { cn } from '../../utils/cn';
5
- import type { CircularProgressbarProps } from './CircularProgressbar.types';
6
-
7
- export function CircularProgressbar({
8
- label,
9
- value = 0,
10
- showValue = true,
11
- size = 60,
12
- strokeWidth = 6,
13
- className,
14
- classNames,
15
- ...props
16
- }: CircularProgressbarProps) {
17
- const center = size / 2;
18
- const radius = center - strokeWidth;
19
- const circumference = 2 * Math.PI * radius;
20
-
21
- return (
22
- <ProgressBar
23
- aria-label="Loading..."
24
- className={cn('flex', className)}
25
- // eslint-disable-next-line react/jsx-props-no-spreading
26
- {...props}
27
- value={value}
28
- >
29
- {({ percentage = 0 }) => (
30
- <div className={cn('flex items-center flex-col', classNames?.base)}>
31
- <Label className={cn('text-sm', classNames?.label)}>{label}</Label>
32
- <svg width={size} height={size} fill="none">
33
- <circle
34
- className={cn('stroke-slate-300')}
35
- cx={center}
36
- cy={center}
37
- r={radius}
38
- strokeWidth={strokeWidth}
39
- />
40
- <circle
41
- className={cn(
42
- 'stroke-slate-800 transition-stroke-dashoffset duration-500 ease-in-out'
43
- )}
44
- cx={center}
45
- cy={center}
46
- r={radius}
47
- strokeWidth={strokeWidth}
48
- strokeDasharray={`${circumference} ${circumference}`}
49
- strokeDashoffset={((100 - percentage) / 100) * circumference}
50
- strokeLinecap="round"
51
- transform={`rotate(-90 ${center} ${center})`}
52
- />
53
- {showValue && (
54
- <text
55
- className={cn('text-sm fill-slate-800', classNames?.value)}
56
- x="50%"
57
- y="50%"
58
- alignmentBaseline="middle"
59
- textAnchor="middle"
60
- >
61
- {percentage}%
62
- </text>
63
- )}
64
- </svg>
65
- </div>
66
- )}
67
- </ProgressBar>
68
- );
69
- }
70
-
71
- export default CircularProgressbar;
@@ -1,10 +0,0 @@
1
- import type { ProgressBarProps } from 'react-aria-components';
2
- import type { SlotsToClasses } from '../../types/SlotsToClasses';
3
-
4
- export interface CircularProgressbarProps extends ProgressBarProps {
5
- label?: string;
6
- showValue?: boolean;
7
- size?: number;
8
- strokeWidth?: number;
9
- classNames?: SlotsToClasses<'label' | 'base' | 'value'>;
10
- }
@@ -1,75 +0,0 @@
1
- 'use client';
2
-
3
- import { ProgressBar, Label } from 'react-aria-components';
4
- import { motion } from 'framer-motion';
5
- import { cn } from '../../utils/cn';
6
- import type { LinearProgressbarProps } from './LinearProgressbar.types';
7
-
8
- export function LinearProgressbar({
9
- label,
10
- isIndeterminate,
11
- showValue = true,
12
- width,
13
- className,
14
- classNames,
15
- ...props
16
- }: LinearProgressbarProps) {
17
- return (
18
- <ProgressBar
19
- style={{ width: width || '100%' }}
20
- className={cn('overflow-hidden', className)}
21
- // eslint-disable-next-line react/jsx-props-no-spreading
22
- {...props}
23
- >
24
- {({ percentage, valueText }) => (
25
- <>
26
- <div
27
- className={cn(
28
- 'flex items-center justify-between gap-2 mb-1',
29
- classNames?.labelWrapper
30
- )}
31
- >
32
- <Label className={cn('text-sm', classNames?.label)}>{label}</Label>
33
- {showValue && (
34
- <span className={cn('text-sm', classNames?.value)}>
35
- {valueText}
36
- </span>
37
- )}
38
- </div>
39
- <div
40
- className={cn(
41
- 'overflow-hidden forced-color-adjust-none h-2.5 rounded will-change-transform bg-slate-300',
42
- classNames?.trackWrapper
43
- )}
44
- >
45
- <motion.div
46
- style={{
47
- width:
48
- !isIndeterminate && typeof percentage === 'number'
49
- ? `${percentage}%`
50
- : '',
51
- }}
52
- // eslint-disable-next-line react/jsx-props-no-spreading
53
- {...(isIndeterminate && {
54
- animate: {
55
- x: ['-100%', '250px'],
56
- },
57
- transition: { repeat: Infinity, duration: 1.5 },
58
- })}
59
- className={cn(
60
- 'h-full bg-slate-800 rounded transition-width duration-500 ease-in-out',
61
- {
62
- 'w-1/2': isIndeterminate,
63
- 'transition-none': isIndeterminate,
64
- },
65
- classNames?.track
66
- )}
67
- />
68
- </div>
69
- </>
70
- )}
71
- </ProgressBar>
72
- );
73
- }
74
-
75
- export default LinearProgressbar;
@@ -1,11 +0,0 @@
1
- import type { ProgressBarProps } from 'react-aria-components';
2
- import type { SlotsToClasses } from '../../types/SlotsToClasses';
3
-
4
- export interface LinearProgressbarProps extends ProgressBarProps {
5
- label?: string;
6
- width?: string;
7
- showValue?: boolean;
8
- classNames?: SlotsToClasses<
9
- 'label' | 'value' | 'labelWrapper' | 'track' | 'trackWrapper'
10
- >;
11
- }
@@ -1,4 +0,0 @@
1
- export { CircularProgressbar } from './CircularProgressbar';
2
- export { LinearProgressbar } from './LinearProgressbar';
3
- export type { CircularProgressbarProps } from './CircularProgressbar.types';
4
- export type { LinearProgressbarProps } from './LinearProgressbar.types';
@@ -1,88 +0,0 @@
1
- 'use client';
2
-
3
- import { Radio as AriaRadio } from 'react-aria-components';
4
- import type { RadioRenderProps } from 'react-aria-components';
5
- import { cn } from '../../utils/cn';
6
- import type { RadioProps, RadioSlots } from './Radio.types';
7
-
8
- function ControlSlot({
9
- control,
10
- classNames,
11
- ...props
12
- }: RadioRenderProps &
13
- Pick<RadioSlots, 'control'> &
14
- Pick<RadioProps, 'classNames'>) {
15
- if (!control) {
16
- return (
17
- <div
18
- data-hovered={props?.isHovered}
19
- data-focused={props?.isFocused}
20
- data-disabled={props?.isDisabled}
21
- data-invalid={props?.isInvalid}
22
- data-selected={props?.isSelected}
23
- data-pressed={props?.isPressed}
24
- className={cn(
25
- 'flex items-center justify-center w-6 h-6 border-solid border border-slate-300 ransition-all duration-300 ease rounded-full',
26
- 'data-[hovered="true"]:border-slate-400',
27
- 'data-[focused="true"]:border-slate-400 data-[focused="true"]:outline-2 data-[focused="true"]:outline data-[focused="true"]:outline-slate-200',
28
- 'data-[disabled="true"]:border-slate-200 data-[disabled="true"]:bg-slate-100',
29
- 'data-[invalid="true"]:bg-red-100 data-[invalid="true"]:text-red-600 data-[invalid="true"]:border-red-500',
30
- 'data-[invalid="true"]:data-[disabled="true"]:border-red-200 data-[invalid="true"]:data-[disabled="true"]:bg-red-100',
31
- 'data-[invalid="true"]:data-[hovered="true"]:border-red-600',
32
- 'data-[invalid="true"]:data-[focused="true"]:border-red-600 data-[invalid="true"]:data-[focused="true"]:outline-red-200',
33
- 'data-[invalid="true"]:data-[selected="true"]:bg-red-100 data-[invalid="true"]:data-[selected="true"]:border-red-500',
34
- 'data-[invalid="true"]:data-[pressed="true"]:bg-red-600 data-[invalid="true"]:data-[pressed="true"]:border-red-600',
35
- classNames?.control
36
- )}
37
- // eslint-disable-next-line react/jsx-props-no-spreading
38
- {...props}
39
- >
40
- <div
41
- data-invalid={props?.isInvalid}
42
- className={cn(
43
- 'w-3 h-3 rounded-full bg-slate-900 opacity-0 transition-all duration-300 ease data-[invalid="true"]:bg-red-500',
44
- {
45
- 'opacity-100': props?.isSelected,
46
- }
47
- )}
48
- />
49
- </div>
50
- );
51
- }
52
- return typeof control === 'function' ? control(props) : control;
53
- }
54
-
55
- export function Radio({
56
- children,
57
- slots,
58
- className,
59
- classNames,
60
- ...props
61
- }: RadioProps) {
62
- return (
63
- <AriaRadio
64
- className={cn(
65
- 'flex items-center gap-2 group',
66
- 'invalid:text-red-500 invalid:disabled:text-red-300',
67
- 'disabled:text-slate-400',
68
- className
69
- )}
70
- // eslint-disable-next-line react/jsx-props-no-spreading
71
- {...props}
72
- >
73
- {(renderProps) => (
74
- <>
75
- <ControlSlot
76
- control={slots?.control}
77
- classNames={classNames}
78
- // eslint-disable-next-line react/jsx-props-no-spreading
79
- {...renderProps}
80
- />
81
- {typeof children === 'function' ? children(renderProps) : children}
82
- </>
83
- )}
84
- </AriaRadio>
85
- );
86
- }
87
-
88
- export default Radio;
@@ -1,16 +0,0 @@
1
- import type { ReactNode } from 'react';
2
- import type {
3
- RadioRenderProps,
4
- RadioProps as UiRadioProps,
5
- } from 'react-aria-components';
6
- import type { SlotsToClasses } from '../../types/SlotsToClasses';
7
-
8
- export interface RadioSlots {
9
- control?: ReactNode | ((values: RadioRenderProps) => ReactNode);
10
- }
11
-
12
- export interface RadioProps extends UiRadioProps {
13
- children?: ReactNode | ((values: RadioRenderProps) => ReactNode);
14
- slots?: RadioSlots;
15
- classNames?: SlotsToClasses<'control'>;
16
- }
@@ -1,2 +0,0 @@
1
- export { Radio } from './Radio';
2
- export type { RadioProps, RadioSlots } from './Radio.types';
@@ -1,49 +0,0 @@
1
- import { Label, RadioGroup as AriaRadioGroup } from 'react-aria-components';
2
- import { cn } from '../../utils/cn';
3
- import { RadioGroupProps } from './RadioGroup.types';
4
-
5
- export function RadioGroup({
6
- label,
7
- errorMessage,
8
- description,
9
- orientation,
10
- children,
11
- className,
12
- ...props
13
- }: RadioGroupProps) {
14
- return (
15
- <AriaRadioGroup
16
- className={cn('flex flex-col gap-4', className)}
17
- orientation={orientation}
18
- // eslint-disable-next-line react/jsx-props-no-spreading
19
- {...props}
20
- >
21
- {typeof children === 'function' ? (
22
- children
23
- ) : (
24
- <>
25
- {label && (
26
- <Label className="flex text-slate-500 text-xs">{label}</Label>
27
- )}
28
- <div
29
- className={cn(
30
- 'flex flex-col gap-2',
31
- orientation === 'horizontal' && 'flex-row items-center gap-4'
32
- )}
33
- >
34
- {children}
35
- </div>
36
- {description && (
37
- <p className="flex mt-1 text-slate-500 text-sm">{description}</p>
38
- )}
39
-
40
- {errorMessage && (
41
- <p className="flex pl-6 text-red-500 text-sm">{errorMessage}</p>
42
- )}
43
- </>
44
- )}
45
- </AriaRadioGroup>
46
- );
47
- }
48
-
49
- export default RadioGroup;
@@ -1,7 +0,0 @@
1
- import type { RadioGroupProps as AriaRadioGroupProps } from 'react-aria-components';
2
-
3
- export interface RadioGroupProps extends AriaRadioGroupProps {
4
- label?: string;
5
- description?: string;
6
- errorMessage?: string;
7
- }
@@ -1,2 +0,0 @@
1
- export { RadioGroup } from './RadioGroup';
2
- export type { RadioGroupProps } from './RadioGroup.types';