@ttoss/ui 3.1.2 → 3.1.3
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/dist/esm/index.js +69 -19
- package/dist/index.d.mts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +69 -19
- package/package.json +2 -2
- package/src/components/Select.tsx +88 -29
package/dist/esm/index.js
CHANGED
|
@@ -261,43 +261,67 @@ import { Fragment as Fragment2, jsx as jsx7, jsxs as jsxs6 } from "react/jsx-run
|
|
|
261
261
|
var Select = /*#__PURE__*/React4.forwardRef(({
|
|
262
262
|
arrow,
|
|
263
263
|
sx,
|
|
264
|
+
leadingIcon,
|
|
265
|
+
trailingIcon,
|
|
264
266
|
...props
|
|
265
267
|
}, ref) => {
|
|
268
|
+
const hasError = props["aria-invalid"] === "true";
|
|
266
269
|
return /* @__PURE__ */jsx7(SelectUi, {
|
|
267
270
|
arrow: /* @__PURE__ */jsxs6(Fragment2, {
|
|
268
|
-
children: [
|
|
271
|
+
children: [leadingIcon && /* @__PURE__ */jsx7(Text, {
|
|
269
272
|
sx: {
|
|
270
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
271
|
-
marginLeft: ({
|
|
272
|
-
space
|
|
273
|
-
}) => {
|
|
274
|
-
return space?.["2xl"] ? "-2xl" : "-28px";
|
|
275
|
-
},
|
|
276
273
|
alignSelf: "center",
|
|
277
274
|
pointerEvents: "none",
|
|
278
275
|
lineHeight: 0,
|
|
279
|
-
fontSize: "base"
|
|
276
|
+
fontSize: "base",
|
|
277
|
+
position: "absolute",
|
|
278
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
279
|
+
left: ({
|
|
280
|
+
space
|
|
281
|
+
}) => {
|
|
282
|
+
const defaultLeftValue = "16px";
|
|
283
|
+
const leftSpaceValue = space?.["xl"] || "16px";
|
|
284
|
+
return `calc(${leftSpaceValue} + ${defaultLeftValue})`;
|
|
285
|
+
}
|
|
280
286
|
},
|
|
281
287
|
children: /* @__PURE__ */jsx7(Icon5, {
|
|
282
|
-
icon:
|
|
288
|
+
icon: leadingIcon
|
|
283
289
|
})
|
|
284
|
-
}),
|
|
285
|
-
className: "error-icon",
|
|
290
|
+
}), /* @__PURE__ */jsxs6(Flex, {
|
|
286
291
|
sx: {
|
|
292
|
+
gap: "lg",
|
|
293
|
+
position: "absolute",
|
|
287
294
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
288
|
-
|
|
295
|
+
right: ({
|
|
289
296
|
space
|
|
290
297
|
}) => {
|
|
291
|
-
|
|
298
|
+
const defaultRightValue = "16px";
|
|
299
|
+
const xlSpace = space?.["xl"] || "16px";
|
|
300
|
+
return `calc(${xlSpace} + ${defaultRightValue})`;
|
|
292
301
|
},
|
|
293
302
|
alignSelf: "center",
|
|
294
|
-
pointerEvents: "none"
|
|
295
|
-
lineHeight: 0,
|
|
296
|
-
fontSize: "base"
|
|
303
|
+
pointerEvents: "none"
|
|
297
304
|
},
|
|
298
|
-
children: /* @__PURE__ */jsx7(
|
|
299
|
-
|
|
300
|
-
|
|
305
|
+
children: [(trailingIcon || hasError) && /* @__PURE__ */jsx7(Text, {
|
|
306
|
+
className: hasError ? "error-icon" : "",
|
|
307
|
+
sx: {
|
|
308
|
+
alignSelf: "center",
|
|
309
|
+
pointerEvents: "none",
|
|
310
|
+
lineHeight: 0,
|
|
311
|
+
fontSize: "base"
|
|
312
|
+
},
|
|
313
|
+
children: /* @__PURE__ */jsx7(Icon5, {
|
|
314
|
+
icon: hasError ? "warning-alt" : trailingIcon
|
|
315
|
+
})
|
|
316
|
+
}), arrow ?? /* @__PURE__ */jsx7(Text, {
|
|
317
|
+
sx: {
|
|
318
|
+
lineHeight: 0,
|
|
319
|
+
fontSize: "base"
|
|
320
|
+
},
|
|
321
|
+
children: /* @__PURE__ */jsx7(Icon5, {
|
|
322
|
+
icon: "picker-down"
|
|
323
|
+
})
|
|
324
|
+
})]
|
|
301
325
|
})]
|
|
302
326
|
}),
|
|
303
327
|
sx: {
|
|
@@ -305,6 +329,32 @@ var Select = /*#__PURE__*/React4.forwardRef(({
|
|
|
305
329
|
width: "100%",
|
|
306
330
|
paddingY: "lg",
|
|
307
331
|
paddingX: "xl",
|
|
332
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
333
|
+
paddingLeft: ({
|
|
334
|
+
space,
|
|
335
|
+
fontSizes
|
|
336
|
+
}) => {
|
|
337
|
+
const xlSpace = space?.["xl"] || "16px";
|
|
338
|
+
const iconSize = fontSizes?.["base"] || "16px";
|
|
339
|
+
const lgSpace = space?.["lg"] || "16px";
|
|
340
|
+
if (leadingIcon) {
|
|
341
|
+
return `calc(${xlSpace} + ${iconSize} + ${lgSpace})`;
|
|
342
|
+
}
|
|
343
|
+
return xlSpace;
|
|
344
|
+
},
|
|
345
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
346
|
+
paddingRight: ({
|
|
347
|
+
space,
|
|
348
|
+
fontSizes
|
|
349
|
+
}) => {
|
|
350
|
+
const xlSpace = space?.["xl"] || "16px";
|
|
351
|
+
const iconSize = fontSizes?.["base"] || "16px";
|
|
352
|
+
const lgSpace = space?.["lg"] || "16px";
|
|
353
|
+
if (trailingIcon || hasError) {
|
|
354
|
+
return `calc(${lgSpace} + ${iconSize} + ${lgSpace} + ${iconSize} + ${xlSpace})`;
|
|
355
|
+
}
|
|
356
|
+
return `calc(${lgSpace} + ${iconSize} + ${xlSpace})`;
|
|
357
|
+
},
|
|
308
358
|
...sx
|
|
309
359
|
},
|
|
310
360
|
ref,
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as theme_ui from 'theme-ui';
|
|
2
|
-
import { Theme, BadgeProps as BadgeProps$1, ButtonProps as ButtonProps$1, InputProps as InputProps$1, LabelProps as LabelProps$1, LinkProps as LinkProps$1, SelectProps, IconButtonProps, TextareaProps as TextareaProps$1, TextProps, FlexProps } from 'theme-ui';
|
|
3
|
-
export { BaseStyles, Box, BoxProps, Card, CardProps, Checkbox, CheckboxProps, ContainerProps, Divider, DividerProps, Flex, FlexProps, Global, Grid, GridProps, Heading, HeadingProps, IconButtonProps, Image, ImageProps, Progress as LinearProgress, ProgressProps as LinearProgressProps, Paragraph, ParagraphProps, Radio, RadioProps,
|
|
2
|
+
import { Theme, BadgeProps as BadgeProps$1, ButtonProps as ButtonProps$1, InputProps as InputProps$1, LabelProps as LabelProps$1, LinkProps as LinkProps$1, SelectProps as SelectProps$1, IconButtonProps, TextareaProps as TextareaProps$1, TextProps, FlexProps } from 'theme-ui';
|
|
3
|
+
export { BaseStyles, Box, BoxProps, Card, CardProps, Checkbox, CheckboxProps, ContainerProps, Divider, DividerProps, Flex, FlexProps, Global, Grid, GridProps, Heading, HeadingProps, IconButtonProps, Image, ImageProps, Progress as LinearProgress, ProgressProps as LinearProgressProps, Paragraph, ParagraphProps, Radio, RadioProps, Slider, SliderProps, Spinner, SpinnerProps, SxProp, Text, TextProps, Theme } from 'theme-ui';
|
|
4
4
|
export { useBreakpointIndex, useResponsiveValue } from '@theme-ui/match-media';
|
|
5
5
|
export { Keyframes, keyframes } from '@emotion/react';
|
|
6
6
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
@@ -50,6 +50,10 @@ type LinkProps = LinkProps$1 & {
|
|
|
50
50
|
};
|
|
51
51
|
declare const Link: React.ForwardRefExoticComponent<Omit<LinkProps, "ref"> & React.RefAttributes<HTMLAnchorElement>>;
|
|
52
52
|
|
|
53
|
+
type SelectProps = SelectProps$1 & {
|
|
54
|
+
leadingIcon?: IconType;
|
|
55
|
+
trailingIcon?: IconType;
|
|
56
|
+
};
|
|
53
57
|
declare const Select: React.ForwardRefExoticComponent<Omit<SelectProps, "ref"> & React.RefAttributes<HTMLSelectElement>>;
|
|
54
58
|
|
|
55
59
|
declare const IconButton: React.ForwardRefExoticComponent<Omit<IconButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -100,4 +104,4 @@ type ActionButtonProps = Omit<ButtonProps, 'rightIcon' | 'leftIcon' | 'variant'>
|
|
|
100
104
|
};
|
|
101
105
|
declare const ActionButton: ({ icon, variant, sx, ...props }: ActionButtonProps) => react_jsx_runtime.JSX.Element;
|
|
102
106
|
|
|
103
|
-
export { ActionButton, ActionButtonProps, Badge, BadgeProps, Button, ButtonProps, CloseButton, CloseButtonProps, Container, HelpText, HelpTextProps, IconButton, InfiniteLinearProgress, Input, InputNumber, InputNumberProps, InputPassword, InputPasswordProps, InputProps, Label, LabelProps, Link, LinkProps, Select, Stack, StackProps, Textarea, TextareaProps, ThemeProvider, ThemeProviderProps, useTheme };
|
|
107
|
+
export { ActionButton, ActionButtonProps, Badge, BadgeProps, Button, ButtonProps, CloseButton, CloseButtonProps, Container, HelpText, HelpTextProps, IconButton, InfiniteLinearProgress, Input, InputNumber, InputNumberProps, InputPassword, InputPasswordProps, InputProps, Label, LabelProps, Link, LinkProps, Select, SelectProps, Stack, StackProps, Textarea, TextareaProps, ThemeProvider, ThemeProviderProps, useTheme };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as theme_ui from 'theme-ui';
|
|
2
|
-
import { Theme, BadgeProps as BadgeProps$1, ButtonProps as ButtonProps$1, InputProps as InputProps$1, LabelProps as LabelProps$1, LinkProps as LinkProps$1, SelectProps, IconButtonProps, TextareaProps as TextareaProps$1, TextProps, FlexProps } from 'theme-ui';
|
|
3
|
-
export { BaseStyles, Box, BoxProps, Card, CardProps, Checkbox, CheckboxProps, ContainerProps, Divider, DividerProps, Flex, FlexProps, Global, Grid, GridProps, Heading, HeadingProps, IconButtonProps, Image, ImageProps, Progress as LinearProgress, ProgressProps as LinearProgressProps, Paragraph, ParagraphProps, Radio, RadioProps,
|
|
2
|
+
import { Theme, BadgeProps as BadgeProps$1, ButtonProps as ButtonProps$1, InputProps as InputProps$1, LabelProps as LabelProps$1, LinkProps as LinkProps$1, SelectProps as SelectProps$1, IconButtonProps, TextareaProps as TextareaProps$1, TextProps, FlexProps } from 'theme-ui';
|
|
3
|
+
export { BaseStyles, Box, BoxProps, Card, CardProps, Checkbox, CheckboxProps, ContainerProps, Divider, DividerProps, Flex, FlexProps, Global, Grid, GridProps, Heading, HeadingProps, IconButtonProps, Image, ImageProps, Progress as LinearProgress, ProgressProps as LinearProgressProps, Paragraph, ParagraphProps, Radio, RadioProps, Slider, SliderProps, Spinner, SpinnerProps, SxProp, Text, TextProps, Theme } from 'theme-ui';
|
|
4
4
|
export { useBreakpointIndex, useResponsiveValue } from '@theme-ui/match-media';
|
|
5
5
|
export { Keyframes, keyframes } from '@emotion/react';
|
|
6
6
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
@@ -50,6 +50,10 @@ type LinkProps = LinkProps$1 & {
|
|
|
50
50
|
};
|
|
51
51
|
declare const Link: React.ForwardRefExoticComponent<Omit<LinkProps, "ref"> & React.RefAttributes<HTMLAnchorElement>>;
|
|
52
52
|
|
|
53
|
+
type SelectProps = SelectProps$1 & {
|
|
54
|
+
leadingIcon?: IconType;
|
|
55
|
+
trailingIcon?: IconType;
|
|
56
|
+
};
|
|
53
57
|
declare const Select: React.ForwardRefExoticComponent<Omit<SelectProps, "ref"> & React.RefAttributes<HTMLSelectElement>>;
|
|
54
58
|
|
|
55
59
|
declare const IconButton: React.ForwardRefExoticComponent<Omit<IconButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -100,4 +104,4 @@ type ActionButtonProps = Omit<ButtonProps, 'rightIcon' | 'leftIcon' | 'variant'>
|
|
|
100
104
|
};
|
|
101
105
|
declare const ActionButton: ({ icon, variant, sx, ...props }: ActionButtonProps) => react_jsx_runtime.JSX.Element;
|
|
102
106
|
|
|
103
|
-
export { ActionButton, ActionButtonProps, Badge, BadgeProps, Button, ButtonProps, CloseButton, CloseButtonProps, Container, HelpText, HelpTextProps, IconButton, InfiniteLinearProgress, Input, InputNumber, InputNumberProps, InputPassword, InputPasswordProps, InputProps, Label, LabelProps, Link, LinkProps, Select, Stack, StackProps, Textarea, TextareaProps, ThemeProvider, ThemeProviderProps, useTheme };
|
|
107
|
+
export { ActionButton, ActionButtonProps, Badge, BadgeProps, Button, ButtonProps, CloseButton, CloseButtonProps, Container, HelpText, HelpTextProps, IconButton, InfiniteLinearProgress, Input, InputNumber, InputNumberProps, InputPassword, InputPasswordProps, InputProps, Label, LabelProps, Link, LinkProps, Select, SelectProps, Stack, StackProps, Textarea, TextareaProps, ThemeProvider, ThemeProviderProps, useTheme };
|
package/dist/index.js
CHANGED
|
@@ -337,43 +337,67 @@ var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
|
337
337
|
var Select = React4.forwardRef(({
|
|
338
338
|
arrow,
|
|
339
339
|
sx,
|
|
340
|
+
leadingIcon,
|
|
341
|
+
trailingIcon,
|
|
340
342
|
...props
|
|
341
343
|
}, ref) => {
|
|
344
|
+
const hasError = props["aria-invalid"] === "true";
|
|
342
345
|
return /* @__PURE__ */(0, import_jsx_runtime7.jsx)(import_theme_ui17.Select, {
|
|
343
346
|
arrow: /* @__PURE__ */(0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, {
|
|
344
|
-
children: [
|
|
347
|
+
children: [leadingIcon && /* @__PURE__ */(0, import_jsx_runtime7.jsx)(import_theme_ui16.Text, {
|
|
345
348
|
sx: {
|
|
346
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
347
|
-
marginLeft: ({
|
|
348
|
-
space
|
|
349
|
-
}) => {
|
|
350
|
-
return space?.["2xl"] ? "-2xl" : "-28px";
|
|
351
|
-
},
|
|
352
349
|
alignSelf: "center",
|
|
353
350
|
pointerEvents: "none",
|
|
354
351
|
lineHeight: 0,
|
|
355
|
-
fontSize: "base"
|
|
352
|
+
fontSize: "base",
|
|
353
|
+
position: "absolute",
|
|
354
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
355
|
+
left: ({
|
|
356
|
+
space
|
|
357
|
+
}) => {
|
|
358
|
+
const defaultLeftValue = "16px";
|
|
359
|
+
const leftSpaceValue = space?.["xl"] || "16px";
|
|
360
|
+
return `calc(${leftSpaceValue} + ${defaultLeftValue})`;
|
|
361
|
+
}
|
|
356
362
|
},
|
|
357
363
|
children: /* @__PURE__ */(0, import_jsx_runtime7.jsx)(import_react_icons5.Icon, {
|
|
358
|
-
icon:
|
|
364
|
+
icon: leadingIcon
|
|
359
365
|
})
|
|
360
|
-
}),
|
|
361
|
-
className: "error-icon",
|
|
366
|
+
}), /* @__PURE__ */(0, import_jsx_runtime7.jsxs)(import_theme_ui8.Flex, {
|
|
362
367
|
sx: {
|
|
368
|
+
gap: "lg",
|
|
369
|
+
position: "absolute",
|
|
363
370
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
364
|
-
|
|
371
|
+
right: ({
|
|
365
372
|
space
|
|
366
373
|
}) => {
|
|
367
|
-
|
|
374
|
+
const defaultRightValue = "16px";
|
|
375
|
+
const xlSpace = space?.["xl"] || "16px";
|
|
376
|
+
return `calc(${xlSpace} + ${defaultRightValue})`;
|
|
368
377
|
},
|
|
369
378
|
alignSelf: "center",
|
|
370
|
-
pointerEvents: "none"
|
|
371
|
-
lineHeight: 0,
|
|
372
|
-
fontSize: "base"
|
|
379
|
+
pointerEvents: "none"
|
|
373
380
|
},
|
|
374
|
-
children: /* @__PURE__ */(0, import_jsx_runtime7.jsx)(
|
|
375
|
-
|
|
376
|
-
|
|
381
|
+
children: [(trailingIcon || hasError) && /* @__PURE__ */(0, import_jsx_runtime7.jsx)(import_theme_ui16.Text, {
|
|
382
|
+
className: hasError ? "error-icon" : "",
|
|
383
|
+
sx: {
|
|
384
|
+
alignSelf: "center",
|
|
385
|
+
pointerEvents: "none",
|
|
386
|
+
lineHeight: 0,
|
|
387
|
+
fontSize: "base"
|
|
388
|
+
},
|
|
389
|
+
children: /* @__PURE__ */(0, import_jsx_runtime7.jsx)(import_react_icons5.Icon, {
|
|
390
|
+
icon: hasError ? "warning-alt" : trailingIcon
|
|
391
|
+
})
|
|
392
|
+
}), arrow ?? /* @__PURE__ */(0, import_jsx_runtime7.jsx)(import_theme_ui16.Text, {
|
|
393
|
+
sx: {
|
|
394
|
+
lineHeight: 0,
|
|
395
|
+
fontSize: "base"
|
|
396
|
+
},
|
|
397
|
+
children: /* @__PURE__ */(0, import_jsx_runtime7.jsx)(import_react_icons5.Icon, {
|
|
398
|
+
icon: "picker-down"
|
|
399
|
+
})
|
|
400
|
+
})]
|
|
377
401
|
})]
|
|
378
402
|
}),
|
|
379
403
|
sx: {
|
|
@@ -381,6 +405,32 @@ var Select = React4.forwardRef(({
|
|
|
381
405
|
width: "100%",
|
|
382
406
|
paddingY: "lg",
|
|
383
407
|
paddingX: "xl",
|
|
408
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
409
|
+
paddingLeft: ({
|
|
410
|
+
space,
|
|
411
|
+
fontSizes
|
|
412
|
+
}) => {
|
|
413
|
+
const xlSpace = space?.["xl"] || "16px";
|
|
414
|
+
const iconSize = fontSizes?.["base"] || "16px";
|
|
415
|
+
const lgSpace = space?.["lg"] || "16px";
|
|
416
|
+
if (leadingIcon) {
|
|
417
|
+
return `calc(${xlSpace} + ${iconSize} + ${lgSpace})`;
|
|
418
|
+
}
|
|
419
|
+
return xlSpace;
|
|
420
|
+
},
|
|
421
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
422
|
+
paddingRight: ({
|
|
423
|
+
space,
|
|
424
|
+
fontSizes
|
|
425
|
+
}) => {
|
|
426
|
+
const xlSpace = space?.["xl"] || "16px";
|
|
427
|
+
const iconSize = fontSizes?.["base"] || "16px";
|
|
428
|
+
const lgSpace = space?.["lg"] || "16px";
|
|
429
|
+
if (trailingIcon || hasError) {
|
|
430
|
+
return `calc(${lgSpace} + ${iconSize} + ${lgSpace} + ${iconSize} + ${xlSpace})`;
|
|
431
|
+
}
|
|
432
|
+
return `calc(${lgSpace} + ${iconSize} + ${xlSpace})`;
|
|
433
|
+
},
|
|
384
434
|
...sx
|
|
385
435
|
},
|
|
386
436
|
ref,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/ui",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.3",
|
|
4
4
|
"description": "Primitive layout, typographic, and other components for styling applications.",
|
|
5
5
|
"author": "ttoss",
|
|
6
6
|
"contributors": [
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@theme-ui/match-media": "^0.16.0",
|
|
24
24
|
"theme-ui": "^0.16.0",
|
|
25
|
-
"@ttoss/theme": "^1.6.
|
|
25
|
+
"@ttoss/theme": "^1.6.3"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"@emotion/react": "^11",
|
|
@@ -1,53 +1,88 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { Flex, Text } from '..';
|
|
3
|
+
import { Icon, IconType } from '@ttoss/react-icons';
|
|
4
|
+
import {
|
|
5
|
+
type SelectProps as SelectPropsUi,
|
|
6
|
+
Select as SelectUi,
|
|
7
|
+
} from 'theme-ui';
|
|
5
8
|
|
|
6
|
-
export
|
|
9
|
+
export type SelectProps = SelectPropsUi & {
|
|
10
|
+
leadingIcon?: IconType;
|
|
11
|
+
trailingIcon?: IconType;
|
|
12
|
+
};
|
|
7
13
|
|
|
8
14
|
export const Select = React.forwardRef<HTMLSelectElement, SelectProps>(
|
|
9
|
-
({ arrow, sx, ...props }, ref) => {
|
|
15
|
+
({ arrow, sx, leadingIcon, trailingIcon, ...props }, ref) => {
|
|
16
|
+
const hasError = props['aria-invalid'] === 'true';
|
|
17
|
+
|
|
10
18
|
return (
|
|
11
19
|
<SelectUi
|
|
12
20
|
// https://theme-ui.com/components/select#custom-arrow-icon
|
|
13
21
|
arrow={
|
|
14
22
|
<>
|
|
15
|
-
{
|
|
23
|
+
{leadingIcon && (
|
|
16
24
|
<Text
|
|
17
25
|
sx={{
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
|
-
marginLeft: ({ space }: any) => {
|
|
20
|
-
return space?.['2xl'] ? '-2xl' : '-28px';
|
|
21
|
-
},
|
|
22
26
|
alignSelf: 'center',
|
|
23
27
|
pointerEvents: 'none',
|
|
24
28
|
lineHeight: 0,
|
|
25
29
|
fontSize: 'base',
|
|
26
|
-
|
|
27
|
-
>
|
|
28
|
-
<Icon icon="picker-down" />
|
|
29
|
-
</Text>
|
|
30
|
-
)}
|
|
31
|
-
|
|
32
|
-
{props['aria-invalid'] === 'true' && (
|
|
33
|
-
<Text
|
|
34
|
-
className="error-icon"
|
|
35
|
-
sx={{
|
|
30
|
+
position: 'absolute',
|
|
36
31
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
left: ({ space }: any) => {
|
|
33
|
+
const defaultLeftValue = '16px';
|
|
34
|
+
const leftSpaceValue = space?.['xl'] || '16px';
|
|
35
|
+
|
|
36
|
+
return `calc(${leftSpaceValue} + ${defaultLeftValue})`;
|
|
41
37
|
},
|
|
42
|
-
alignSelf: 'center',
|
|
43
|
-
pointerEvents: 'none',
|
|
44
|
-
lineHeight: 0,
|
|
45
|
-
fontSize: 'base',
|
|
46
38
|
}}
|
|
47
39
|
>
|
|
48
|
-
<Icon icon=
|
|
40
|
+
<Icon icon={leadingIcon} />
|
|
49
41
|
</Text>
|
|
50
42
|
)}
|
|
43
|
+
|
|
44
|
+
<Flex
|
|
45
|
+
sx={{
|
|
46
|
+
gap: 'lg',
|
|
47
|
+
position: 'absolute',
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
49
|
+
right: ({ space }: any) => {
|
|
50
|
+
const defaultRightValue = '16px';
|
|
51
|
+
const xlSpace = space?.['xl'] || '16px';
|
|
52
|
+
|
|
53
|
+
return `calc(${xlSpace} + ${defaultRightValue})`;
|
|
54
|
+
},
|
|
55
|
+
alignSelf: 'center',
|
|
56
|
+
pointerEvents: 'none',
|
|
57
|
+
}}
|
|
58
|
+
>
|
|
59
|
+
{(trailingIcon || hasError) && (
|
|
60
|
+
<Text
|
|
61
|
+
className={hasError ? 'error-icon' : ''}
|
|
62
|
+
sx={{
|
|
63
|
+
alignSelf: 'center',
|
|
64
|
+
pointerEvents: 'none',
|
|
65
|
+
lineHeight: 0,
|
|
66
|
+
fontSize: 'base',
|
|
67
|
+
}}
|
|
68
|
+
>
|
|
69
|
+
<Icon
|
|
70
|
+
icon={hasError ? 'warning-alt' : (trailingIcon as IconType)}
|
|
71
|
+
/>
|
|
72
|
+
</Text>
|
|
73
|
+
)}
|
|
74
|
+
|
|
75
|
+
{arrow ?? (
|
|
76
|
+
<Text
|
|
77
|
+
sx={{
|
|
78
|
+
lineHeight: 0,
|
|
79
|
+
fontSize: 'base',
|
|
80
|
+
}}
|
|
81
|
+
>
|
|
82
|
+
<Icon icon="picker-down" />
|
|
83
|
+
</Text>
|
|
84
|
+
)}
|
|
85
|
+
</Flex>
|
|
51
86
|
</>
|
|
52
87
|
}
|
|
53
88
|
sx={{
|
|
@@ -55,6 +90,30 @@ export const Select = React.forwardRef<HTMLSelectElement, SelectProps>(
|
|
|
55
90
|
width: '100%',
|
|
56
91
|
paddingY: 'lg',
|
|
57
92
|
paddingX: 'xl',
|
|
93
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
94
|
+
paddingLeft: ({ space, fontSizes }: any) => {
|
|
95
|
+
const xlSpace = space?.['xl'] || '16px';
|
|
96
|
+
const iconSize = fontSizes?.['base'] || '16px';
|
|
97
|
+
const lgSpace = space?.['lg'] || '16px';
|
|
98
|
+
|
|
99
|
+
if (leadingIcon) {
|
|
100
|
+
return `calc(${xlSpace} + ${iconSize} + ${lgSpace})`;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return xlSpace;
|
|
104
|
+
},
|
|
105
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
106
|
+
paddingRight: ({ space, fontSizes }: any) => {
|
|
107
|
+
const xlSpace = space?.['xl'] || '16px';
|
|
108
|
+
const iconSize = fontSizes?.['base'] || '16px';
|
|
109
|
+
const lgSpace = space?.['lg'] || '16px';
|
|
110
|
+
|
|
111
|
+
if (trailingIcon || hasError) {
|
|
112
|
+
return `calc(${lgSpace} + ${iconSize} + ${lgSpace} + ${iconSize} + ${xlSpace})`;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return `calc(${lgSpace} + ${iconSize} + ${xlSpace})`;
|
|
116
|
+
},
|
|
58
117
|
...sx,
|
|
59
118
|
}}
|
|
60
119
|
ref={ref}
|