paris 0.17.9 → 0.18.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/CHANGELOG.md +16 -0
- package/package.json +139 -150
- package/src/helpers/renderEnhancer.tsx +4 -5
- package/src/helpers/useResizeObserver.ts +17 -23
- package/src/pages/_document.tsx +1 -3
- package/src/pages/index.tsx +8 -24
- package/src/stories/Pagination.mdx +1 -1
- package/src/stories/Tokens.mdx +1 -1
- package/src/stories/Welcome.mdx +1 -1
- package/src/stories/accordion/Accordion.stories.ts +1 -1
- package/src/stories/accordion/Accordion.tsx +14 -35
- package/src/stories/accordionselect/AccordionSelect.stories.ts +2 -5
- package/src/stories/accordionselect/AccordionSelect.tsx +26 -50
- package/src/stories/avatar/Avatar.stories.ts +1 -1
- package/src/stories/avatar/Avatar.tsx +14 -13
- package/src/stories/button/Button.stories.ts +18 -15
- package/src/stories/button/Button.tsx +44 -48
- package/src/stories/callout/Callout.stories.ts +3 -7
- package/src/stories/callout/Callout.tsx +4 -8
- package/src/stories/card/Card.stories.ts +1 -1
- package/src/stories/card/Card.tsx +4 -11
- package/src/stories/cardbutton/CardButton.stories.tsx +1 -1
- package/src/stories/cardbutton/CardButton.tsx +16 -18
- package/src/stories/checkbox/Checkbox.stories.ts +1 -1
- package/src/stories/checkbox/Checkbox.tsx +37 -49
- package/src/stories/combobox/Combobox.stories.ts +65 -71
- package/src/stories/combobox/Combobox.tsx +80 -89
- package/src/stories/dialog/Dialog.stories.tsx +2 -2
- package/src/stories/dialog/Dialog.tsx +45 -68
- package/src/stories/drawer/Drawer.stories.tsx +63 -105
- package/src/stories/drawer/Drawer.tsx +93 -90
- package/src/stories/field/Field.stories.ts +1 -1
- package/src/stories/field/Field.tsx +25 -30
- package/src/stories/icon/Ellipsis.tsx +4 -1
- package/src/stories/icon/Icon.stories.ts +2 -2
- package/src/stories/icon/Icon.tsx +16 -26
- package/src/stories/icon/Info.tsx +4 -1
- package/src/stories/icon/Spinner.tsx +4 -2
- package/src/stories/icon/index.ts +6 -6
- package/src/stories/informationaltooltip/InformationalTooltip.stories.tsx +12 -11
- package/src/stories/informationaltooltip/InformationalTooltip.tsx +23 -28
- package/src/stories/input/Input.stories.ts +14 -15
- package/src/stories/input/Input.tsx +119 -95
- package/src/stories/markdown/Markdown.module.scss +384 -0
- package/src/stories/markdown/Markdown.stories.ts +203 -0
- package/src/stories/markdown/Markdown.tsx +293 -0
- package/src/stories/markdown/index.ts +1 -0
- package/src/stories/menu/Menu.module.scss +9 -0
- package/src/stories/menu/Menu.stories.tsx +4 -10
- package/src/stories/menu/Menu.tsx +27 -29
- package/src/stories/pagination/usePagination.ts +8 -8
- package/src/stories/popover/Popover.stories.ts +2 -2
- package/src/stories/popover/Popover.tsx +4 -10
- package/src/stories/select/Select.stories.ts +10 -10
- package/src/stories/select/Select.tsx +268 -240
- package/src/stories/styledlink/StyledLink.stories.ts +1 -1
- package/src/stories/styledlink/StyledLink.tsx +11 -17
- package/src/stories/table/Table.stories.ts +1 -1
- package/src/stories/table/Table.tsx +55 -65
- package/src/stories/tabs/Tabs.stories.tsx +2 -2
- package/src/stories/tabs/Tabs.tsx +15 -21
- package/src/stories/tag/Tag.stories.ts +1 -4
- package/src/stories/tag/Tag.tsx +9 -17
- package/src/stories/text/Text.stories.ts +1 -1
- package/src/stories/text/Text.tsx +49 -31
- package/src/stories/text/Typography.module.css +120 -120
- package/src/stories/textarea/TextArea.stories.ts +2 -5
- package/src/stories/textarea/TextArea.tsx +91 -84
- package/src/stories/theme/index.ts +1 -1
- package/src/stories/theme/themes.ts +423 -424
- package/src/stories/theme/tokens.ts +3 -3
- package/src/stories/theme/tw-preflight.css +4 -3
- package/src/stories/tilt/Tilt.stories.tsx +3 -6
- package/src/stories/tilt/Tilt.tsx +160 -126
- package/src/stories/toast/Toast.stories.tsx +2 -2
- package/src/stories/toast/Toast.tsx +3 -6
- package/src/stories/utility/RemoveFromDOM.tsx +9 -13
- package/src/stories/utility/TextWhenString.tsx +3 -16
- package/src/stories/utility/VisuallyHidden.tsx +10 -17
- package/src/styles/Home.module.css +185 -195
- package/src/styles/globals.css +0 -2
|
@@ -1,33 +1,37 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
} from 'react';
|
|
6
|
-
import { forwardRef, useId } from 'react';
|
|
3
|
+
import { faChevronDown } from '@fortawesome/free-solid-svg-icons';
|
|
4
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
7
5
|
import {
|
|
8
|
-
Listbox,
|
|
6
|
+
Listbox,
|
|
7
|
+
ListboxButton,
|
|
8
|
+
ListboxOption,
|
|
9
|
+
ListboxOptions,
|
|
10
|
+
Radio,
|
|
11
|
+
RadioGroup,
|
|
12
|
+
Transition,
|
|
9
13
|
} from '@headlessui/react';
|
|
10
14
|
import { clsx } from 'clsx';
|
|
11
|
-
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
12
|
-
import { faChevronDown } from '@fortawesome/free-solid-svg-icons';
|
|
13
15
|
import { motion } from 'framer-motion';
|
|
16
|
+
import type { ComponentPropsWithoutRef, CSSProperties, ForwardedRef, ReactNode } from 'react';
|
|
17
|
+
import { forwardRef, useId } from 'react';
|
|
18
|
+
import { MemoizedEnhancer } from '../../helpers/renderEnhancer';
|
|
19
|
+
import { Field } from '../field';
|
|
20
|
+
import { Check, Icon } from '../icon';
|
|
21
|
+
import type { InputProps } from '../input';
|
|
14
22
|
import inputStyles from '../input/Input.module.scss';
|
|
15
|
-
import dropdownStyles from '../utility/Dropdown.module.scss';
|
|
16
|
-
import styles from './Select.module.scss';
|
|
17
23
|
import type { TextProps } from '../text';
|
|
18
24
|
import { Text } from '../text';
|
|
19
|
-
import type { InputProps } from '../input';
|
|
20
|
-
import { MemoizedEnhancer } from '../../helpers/renderEnhancer';
|
|
21
25
|
import { pget, theme } from '../theme';
|
|
22
|
-
import { Field } from '../field';
|
|
23
26
|
import { TextWhenString } from '../utility';
|
|
24
|
-
import
|
|
27
|
+
import dropdownStyles from '../utility/Dropdown.module.scss';
|
|
28
|
+
import styles from './Select.module.scss';
|
|
25
29
|
|
|
26
30
|
export type Option<T = Record<string, any>> = {
|
|
27
|
-
id: string
|
|
28
|
-
node: ReactNode
|
|
29
|
-
disabled?: boolean
|
|
30
|
-
metadata?: T
|
|
31
|
+
id: string;
|
|
32
|
+
node: ReactNode;
|
|
33
|
+
disabled?: boolean;
|
|
34
|
+
metadata?: T;
|
|
31
35
|
};
|
|
32
36
|
export type CommonSelectProps<T = Record<string, any>> = {
|
|
33
37
|
/**
|
|
@@ -64,7 +68,7 @@ export type CommonSelectProps<T = Record<string, any>> = {
|
|
|
64
68
|
description?: TextProps<'p'>;
|
|
65
69
|
startEnhancerContainer?: ComponentPropsWithoutRef<'div'>;
|
|
66
70
|
endEnhancerContainer?: ComponentPropsWithoutRef<'div'>;
|
|
67
|
-
}
|
|
71
|
+
};
|
|
68
72
|
} & Omit<InputProps, 'type' | 'overrides'>;
|
|
69
73
|
|
|
70
74
|
export type SingleSelectProps<T = Record<string, any>> = {
|
|
@@ -97,7 +101,7 @@ export type MultiSelectProps<T = Record<string, any>> = {
|
|
|
97
101
|
* The visual variant of the Select. For multiselect, only `listbox` is supported.
|
|
98
102
|
* @default listbox
|
|
99
103
|
*/
|
|
100
|
-
kind?: 'listbox'
|
|
104
|
+
kind?: 'listbox';
|
|
101
105
|
/**
|
|
102
106
|
* Converts the single select into a multiselect.
|
|
103
107
|
*/
|
|
@@ -112,8 +116,7 @@ export type MultiSelectProps<T = Record<string, any>> = {
|
|
|
112
116
|
onChange?: (value: Option<T>['id'][] | null) => void | Promise<void>;
|
|
113
117
|
} & CommonSelectProps;
|
|
114
118
|
|
|
115
|
-
type SelectProps<T = Record<string, any>> = |
|
|
116
|
-
| (MultiSelectProps<T>);
|
|
119
|
+
type SelectProps<T = Record<string, any>> = SingleSelectProps<T> | MultiSelectProps<T>;
|
|
117
120
|
|
|
118
121
|
/**
|
|
119
122
|
* A Select component is used to render a `select` box.
|
|
@@ -127,233 +130,258 @@ type SelectProps<T = Record<string, any>> = | (SingleSelectProps<T>)
|
|
|
127
130
|
* ```
|
|
128
131
|
* @constructor
|
|
129
132
|
*/
|
|
130
|
-
export const Select = forwardRef(
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
133
|
+
export const Select = forwardRef(
|
|
134
|
+
<T = Record<string, any>>(
|
|
135
|
+
{
|
|
136
|
+
options,
|
|
137
|
+
value,
|
|
138
|
+
onChange,
|
|
139
|
+
label,
|
|
140
|
+
status,
|
|
141
|
+
hideLabel,
|
|
142
|
+
description,
|
|
143
|
+
hideDescription,
|
|
144
|
+
descriptionPosition,
|
|
145
|
+
placeholder,
|
|
146
|
+
startEnhancer,
|
|
147
|
+
endEnhancer,
|
|
148
|
+
disabled,
|
|
149
|
+
kind = 'listbox',
|
|
150
|
+
maxHeight = 320,
|
|
151
|
+
hasOptionBorder = false,
|
|
152
|
+
multiple = false,
|
|
153
|
+
multipleItemsName,
|
|
154
|
+
segmentedHeight = 'compact',
|
|
155
|
+
overrides,
|
|
156
|
+
}: SelectProps<T>,
|
|
157
|
+
ref: ForwardedRef<any>,
|
|
158
|
+
) => {
|
|
159
|
+
const inputID = useId();
|
|
160
|
+
const multiItems = multipleItemsName || 'items';
|
|
154
161
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
value={listboxValue}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
{...overrides?.selectInput}
|
|
200
|
-
aria-disabled={disabled}
|
|
201
|
-
data-status={disabled ? 'disabled' : (status || 'default')}
|
|
202
|
-
className={clsx(
|
|
203
|
-
overrides?.selectInput?.className,
|
|
204
|
-
inputStyles.inputContainer,
|
|
205
|
-
styles.listboxButton,
|
|
206
|
-
styles.field,
|
|
207
|
-
)}
|
|
208
|
-
>
|
|
209
|
-
{!!startEnhancer && (
|
|
210
|
-
<div
|
|
211
|
-
{...overrides?.startEnhancerContainer}
|
|
212
|
-
className={clsx(inputStyles.enhancer, overrides?.startEnhancerContainer?.className)}
|
|
213
|
-
data-status={disabled ? 'disabled' : (status || 'default')}
|
|
214
|
-
>
|
|
215
|
-
{!!startEnhancer && (
|
|
216
|
-
<MemoizedEnhancer
|
|
217
|
-
enhancer={startEnhancer}
|
|
218
|
-
size={parseInt(pget('typography.styles.paragraphSmall.fontSize') || theme.typography.styles.paragraphSmall.fontSize, 10)}
|
|
219
|
-
/>
|
|
220
|
-
)}
|
|
221
|
-
</div>
|
|
222
|
-
)}
|
|
223
|
-
{buttonText()}
|
|
224
|
-
{endEnhancer ? (
|
|
225
|
-
<div
|
|
226
|
-
{...overrides?.endEnhancerContainer}
|
|
227
|
-
className={clsx(inputStyles.enhancer, overrides?.endEnhancerContainer?.className)}
|
|
228
|
-
data-status={disabled ? 'disabled' : (status || 'default')}
|
|
229
|
-
>
|
|
230
|
-
{!!endEnhancer && (
|
|
231
|
-
<MemoizedEnhancer
|
|
232
|
-
enhancer={endEnhancer}
|
|
233
|
-
size={parseInt(pget('typography.styles.paragraphSmall.fontSize') || theme.typography.styles.paragraphSmall.fontSize, 10)}
|
|
234
|
-
/>
|
|
235
|
-
)}
|
|
236
|
-
</div>
|
|
237
|
-
) : (
|
|
238
|
-
<FontAwesomeIcon className={clsx(inputStyles.enhancer, styles.chevron)} data-status={disabled ? 'disabled' : (status || 'default')} width="10px" icon={faChevronDown} />
|
|
239
|
-
)}
|
|
240
|
-
</ListboxButton>
|
|
241
|
-
<Transition
|
|
242
|
-
as="div"
|
|
243
|
-
className={dropdownStyles.transitionContainer}
|
|
244
|
-
enter={dropdownStyles.transition}
|
|
245
|
-
enterFrom={dropdownStyles.enterFrom}
|
|
246
|
-
enterTo={dropdownStyles.enterTo}
|
|
247
|
-
leave={dropdownStyles.transition}
|
|
248
|
-
leaveFrom={dropdownStyles.leaveFrom}
|
|
249
|
-
leaveTo={dropdownStyles.leaveTo}
|
|
250
|
-
>
|
|
251
|
-
<ListboxOptions
|
|
162
|
+
// TypeScript can't track discriminated union correlation through destructuring and JSX conditionals.
|
|
163
|
+
// For Listbox: supports both single and multi via overloads, needs explicit union types
|
|
164
|
+
// For RadioGroup: only supports single-select, needs narrowed types
|
|
165
|
+
const listboxValue = value as string | string[] | null | undefined;
|
|
166
|
+
const listboxOnChange = onChange as ((value: string | string[] | null) => void) | undefined;
|
|
167
|
+
const singleValue = value as string | null | undefined;
|
|
168
|
+
const singleOnChange = onChange as ((value: string | null) => void) | undefined;
|
|
169
|
+
const buttonText = () => {
|
|
170
|
+
if (!value || value.length === 0) {
|
|
171
|
+
return placeholder || 'Select an option';
|
|
172
|
+
}
|
|
173
|
+
if (!multiple) {
|
|
174
|
+
return options?.find((o) => o.id === value)?.node;
|
|
175
|
+
}
|
|
176
|
+
if (value && value.length === 1) {
|
|
177
|
+
return options?.find((o) => o.id === value[0])?.node;
|
|
178
|
+
}
|
|
179
|
+
if (value.length === options.length) {
|
|
180
|
+
return `All ${multiItems}`;
|
|
181
|
+
}
|
|
182
|
+
return `${value.length} ${multiItems}`;
|
|
183
|
+
};
|
|
184
|
+
return (
|
|
185
|
+
<Field
|
|
186
|
+
htmlFor={inputID}
|
|
187
|
+
label={label}
|
|
188
|
+
hideLabel={hideLabel}
|
|
189
|
+
description={description}
|
|
190
|
+
hideDescription={hideDescription}
|
|
191
|
+
descriptionPosition={descriptionPosition}
|
|
192
|
+
disabled={disabled}
|
|
193
|
+
overrides={{
|
|
194
|
+
container: overrides?.container,
|
|
195
|
+
label: overrides?.label,
|
|
196
|
+
description: overrides?.description,
|
|
197
|
+
}}
|
|
198
|
+
>
|
|
199
|
+
{kind === 'listbox' && (
|
|
200
|
+
<Listbox as="div" ref={ref} value={listboxValue} onChange={listboxOnChange} multiple={multiple}>
|
|
201
|
+
<ListboxButton
|
|
202
|
+
id={inputID}
|
|
203
|
+
{...overrides?.selectInput}
|
|
204
|
+
aria-disabled={disabled}
|
|
205
|
+
data-status={disabled ? 'disabled' : status || 'default'}
|
|
252
206
|
className={clsx(
|
|
253
|
-
overrides?.
|
|
254
|
-
|
|
207
|
+
overrides?.selectInput?.className,
|
|
208
|
+
inputStyles.inputContainer,
|
|
209
|
+
styles.listboxButton,
|
|
210
|
+
styles.field,
|
|
255
211
|
)}
|
|
256
|
-
style={{
|
|
257
|
-
'--options-maxHeight': `${maxHeight}px`,
|
|
258
|
-
} as CSSProperties}
|
|
259
212
|
>
|
|
260
|
-
{
|
|
261
|
-
<
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
213
|
+
{!!startEnhancer && (
|
|
214
|
+
<div
|
|
215
|
+
{...overrides?.startEnhancerContainer}
|
|
216
|
+
className={clsx(inputStyles.enhancer, overrides?.startEnhancerContainer?.className)}
|
|
217
|
+
data-status={disabled ? 'disabled' : status || 'default'}
|
|
218
|
+
>
|
|
219
|
+
{!!startEnhancer && (
|
|
220
|
+
<MemoizedEnhancer
|
|
221
|
+
enhancer={startEnhancer}
|
|
222
|
+
size={parseInt(
|
|
223
|
+
pget('typography.styles.paragraphSmall.fontSize') ||
|
|
224
|
+
theme.typography.styles.paragraphSmall.fontSize,
|
|
225
|
+
10,
|
|
226
|
+
)}
|
|
227
|
+
/>
|
|
268
228
|
)}
|
|
269
|
-
|
|
229
|
+
</div>
|
|
230
|
+
)}
|
|
231
|
+
{buttonText()}
|
|
232
|
+
{endEnhancer ? (
|
|
233
|
+
<div
|
|
234
|
+
{...overrides?.endEnhancerContainer}
|
|
235
|
+
className={clsx(inputStyles.enhancer, overrides?.endEnhancerContainer?.className)}
|
|
236
|
+
data-status={disabled ? 'disabled' : status || 'default'}
|
|
270
237
|
>
|
|
271
|
-
{
|
|
272
|
-
<
|
|
273
|
-
{
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
styles.radioOption,
|
|
238
|
+
{!!endEnhancer && (
|
|
239
|
+
<MemoizedEnhancer
|
|
240
|
+
enhancer={endEnhancer}
|
|
241
|
+
size={parseInt(
|
|
242
|
+
pget('typography.styles.paragraphSmall.fontSize') ||
|
|
243
|
+
theme.typography.styles.paragraphSmall.fontSize,
|
|
244
|
+
10,
|
|
245
|
+
)}
|
|
246
|
+
/>
|
|
247
|
+
)}
|
|
248
|
+
</div>
|
|
249
|
+
) : (
|
|
250
|
+
<FontAwesomeIcon
|
|
251
|
+
className={clsx(inputStyles.enhancer, styles.chevron)}
|
|
252
|
+
data-status={disabled ? 'disabled' : status || 'default'}
|
|
253
|
+
width="10px"
|
|
254
|
+
icon={faChevronDown}
|
|
255
|
+
/>
|
|
290
256
|
)}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
disabled={option.disabled || false}
|
|
294
|
-
data-status={disabled ? 'disabled' : (status || 'default')}
|
|
295
|
-
>
|
|
296
|
-
<div className={styles.radioCircle} />
|
|
297
|
-
<TextWhenString kind="paragraphXSmall">
|
|
298
|
-
{option.node}
|
|
299
|
-
</TextWhenString>
|
|
300
|
-
</Radio>
|
|
301
|
-
))}
|
|
302
|
-
</RadioGroup>
|
|
303
|
-
)}
|
|
304
|
-
{kind === 'card' && (
|
|
305
|
-
<RadioGroup ref={ref} as="div" className={styles.cardContainer} value={singleValue} onChange={singleOnChange}>
|
|
306
|
-
{options.map((option) => (
|
|
307
|
-
<Radio
|
|
257
|
+
</ListboxButton>
|
|
258
|
+
<Transition
|
|
308
259
|
as="div"
|
|
309
|
-
className={
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
260
|
+
className={dropdownStyles.transitionContainer}
|
|
261
|
+
enter={dropdownStyles.transition}
|
|
262
|
+
enterFrom={dropdownStyles.enterFrom}
|
|
263
|
+
enterTo={dropdownStyles.enterTo}
|
|
264
|
+
leave={dropdownStyles.transition}
|
|
265
|
+
leaveFrom={dropdownStyles.leaveFrom}
|
|
266
|
+
leaveTo={dropdownStyles.leaveTo}
|
|
316
267
|
>
|
|
317
|
-
<
|
|
318
|
-
|
|
268
|
+
<ListboxOptions
|
|
269
|
+
className={clsx(overrides?.optionsContainer, styles.options)}
|
|
270
|
+
style={
|
|
271
|
+
{
|
|
272
|
+
'--options-maxHeight': `${maxHeight}px`,
|
|
273
|
+
} as CSSProperties
|
|
274
|
+
}
|
|
275
|
+
>
|
|
276
|
+
{(options || []).map((option) => (
|
|
277
|
+
<ListboxOption
|
|
278
|
+
key={option.id}
|
|
279
|
+
value={option.id}
|
|
280
|
+
className={clsx(
|
|
281
|
+
overrides?.option,
|
|
282
|
+
styles.option,
|
|
283
|
+
hasOptionBorder && styles.optionBorder,
|
|
284
|
+
)}
|
|
285
|
+
disabled={option.disabled || false}
|
|
286
|
+
>
|
|
287
|
+
{typeof option.node === 'string' ? (
|
|
288
|
+
<Text as="span" kind="paragraphSmall">
|
|
289
|
+
{option.node}
|
|
290
|
+
</Text>
|
|
291
|
+
) : (
|
|
292
|
+
option.node
|
|
293
|
+
)}
|
|
294
|
+
<Icon icon={Check} size={12} className={styles.check} />
|
|
295
|
+
</ListboxOption>
|
|
296
|
+
))}
|
|
297
|
+
</ListboxOptions>
|
|
298
|
+
</Transition>
|
|
299
|
+
</Listbox>
|
|
300
|
+
)}
|
|
301
|
+
{kind === 'radio' && (
|
|
302
|
+
<RadioGroup
|
|
303
|
+
ref={ref}
|
|
304
|
+
as="div"
|
|
305
|
+
className={styles.radioContainer}
|
|
306
|
+
value={singleValue}
|
|
307
|
+
onChange={singleOnChange}
|
|
308
|
+
>
|
|
309
|
+
{options.map((option) => (
|
|
310
|
+
<Radio
|
|
311
|
+
as="div"
|
|
312
|
+
className={clsx(styles.radioOption)}
|
|
313
|
+
key={option.id}
|
|
314
|
+
value={option.id}
|
|
315
|
+
disabled={option.disabled || false}
|
|
316
|
+
data-status={disabled ? 'disabled' : status || 'default'}
|
|
317
|
+
>
|
|
318
|
+
<div className={styles.radioCircle} />
|
|
319
|
+
<TextWhenString kind="paragraphXSmall">{option.node}</TextWhenString>
|
|
320
|
+
</Radio>
|
|
321
|
+
))}
|
|
322
|
+
</RadioGroup>
|
|
323
|
+
)}
|
|
324
|
+
{kind === 'card' && (
|
|
325
|
+
<RadioGroup
|
|
326
|
+
ref={ref}
|
|
327
|
+
as="div"
|
|
328
|
+
className={styles.cardContainer}
|
|
329
|
+
value={singleValue}
|
|
330
|
+
onChange={singleOnChange}
|
|
331
|
+
>
|
|
332
|
+
{options.map((option) => (
|
|
333
|
+
<Radio
|
|
334
|
+
as="div"
|
|
335
|
+
className={clsx(styles.cardOption)}
|
|
336
|
+
key={option.id}
|
|
337
|
+
value={option.id}
|
|
338
|
+
disabled={option.disabled || false}
|
|
339
|
+
data-status={disabled ? 'disabled' : status || 'default'}
|
|
340
|
+
>
|
|
341
|
+
<div
|
|
342
|
+
className={clsx(styles.cardSurface, typeof option.node === 'string' && styles.text)}
|
|
343
|
+
>
|
|
344
|
+
<TextWhenString kind="paragraphSmall">{option.node}</TextWhenString>
|
|
345
|
+
</div>
|
|
346
|
+
</Radio>
|
|
347
|
+
))}
|
|
348
|
+
</RadioGroup>
|
|
349
|
+
)}
|
|
350
|
+
{kind === 'segmented' && (
|
|
351
|
+
<RadioGroup
|
|
352
|
+
ref={ref}
|
|
353
|
+
as="div"
|
|
354
|
+
className={styles.segmentedContainer}
|
|
355
|
+
value={singleValue || options[0].id}
|
|
356
|
+
onChange={singleOnChange}
|
|
357
|
+
>
|
|
358
|
+
{options.map((option) => (
|
|
359
|
+
<Radio
|
|
360
|
+
as="div"
|
|
361
|
+
className={clsx(styles.segmentedOption, styles[segmentedHeight])}
|
|
362
|
+
key={option.id}
|
|
363
|
+
value={option.id}
|
|
364
|
+
disabled={option.disabled || false}
|
|
365
|
+
data-status={disabled ? 'disabled' : status || 'default'}
|
|
366
|
+
>
|
|
367
|
+
{(option.id === value || (!value && option.id === options[0].id)) && (
|
|
368
|
+
<motion.div
|
|
369
|
+
className={styles.segmentedBackground}
|
|
370
|
+
layoutId={`${inputID}-segmented-selected`}
|
|
371
|
+
transition={{
|
|
372
|
+
ease: [0.42, 0.0, 0.58, 1.0],
|
|
373
|
+
duration: 0.25,
|
|
374
|
+
}}
|
|
375
|
+
/>
|
|
376
|
+
)}
|
|
377
|
+
<TextWhenString kind="paragraphXSmall" weight="medium" className={styles.segmentedText}>
|
|
319
378
|
{option.node}
|
|
320
379
|
</TextWhenString>
|
|
321
|
-
</
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
<Radio
|
|
330
|
-
as="div"
|
|
331
|
-
className={clsx(
|
|
332
|
-
styles.segmentedOption,
|
|
333
|
-
styles[segmentedHeight],
|
|
334
|
-
)}
|
|
335
|
-
key={option.id}
|
|
336
|
-
value={option.id}
|
|
337
|
-
disabled={option.disabled || false}
|
|
338
|
-
data-status={disabled ? 'disabled' : (status || 'default')}
|
|
339
|
-
>
|
|
340
|
-
{(option.id === value || (!value && option.id === options[0].id)) && (
|
|
341
|
-
<motion.div
|
|
342
|
-
className={styles.segmentedBackground}
|
|
343
|
-
layoutId={`${inputID}-segmented-selected`}
|
|
344
|
-
transition={{
|
|
345
|
-
ease: [0.42, 0.0, 0.58, 1.0],
|
|
346
|
-
duration: 0.25,
|
|
347
|
-
}}
|
|
348
|
-
/>
|
|
349
|
-
)}
|
|
350
|
-
<TextWhenString kind="paragraphXSmall" weight="medium" className={styles.segmentedText}>
|
|
351
|
-
{option.node}
|
|
352
|
-
</TextWhenString>
|
|
353
|
-
</Radio>
|
|
354
|
-
))}
|
|
355
|
-
</RadioGroup>
|
|
356
|
-
)}
|
|
357
|
-
</Field>
|
|
358
|
-
);
|
|
359
|
-
});
|
|
380
|
+
</Radio>
|
|
381
|
+
))}
|
|
382
|
+
</RadioGroup>
|
|
383
|
+
)}
|
|
384
|
+
</Field>
|
|
385
|
+
);
|
|
386
|
+
},
|
|
387
|
+
);
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ComponentPropsWithoutRef, ElementType, FC, ReactNode,
|
|
3
|
-
} from 'react';
|
|
4
|
-
import { createElement } from 'react';
|
|
5
1
|
import { clsx } from 'clsx';
|
|
2
|
+
import type { ComponentPropsWithoutRef, ElementType, FC, ReactNode } from 'react';
|
|
3
|
+
import { createElement } from 'react';
|
|
6
4
|
import styles from './StyledLink.module.scss';
|
|
7
5
|
|
|
8
6
|
export type StyledLinkProps<T extends ElementType = 'a'> = {
|
|
@@ -24,16 +22,12 @@ export type StyledLinkProps<T extends ElementType = 'a'> = {
|
|
|
24
22
|
* ```
|
|
25
23
|
* @constructor
|
|
26
24
|
*/
|
|
27
|
-
export const StyledLink: FC<StyledLinkProps<ElementType>> = ({
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
className: clsx(className, styles.link),
|
|
37
|
-
},
|
|
38
|
-
children,
|
|
39
|
-
);
|
|
25
|
+
export const StyledLink: FC<StyledLinkProps<ElementType>> = ({ as = 'a', children, className, ...props }) =>
|
|
26
|
+
createElement(
|
|
27
|
+
as,
|
|
28
|
+
{
|
|
29
|
+
...props,
|
|
30
|
+
className: clsx(className, styles.link),
|
|
31
|
+
},
|
|
32
|
+
children,
|
|
33
|
+
);
|