@sats-group/ui-lib 79.2.0 → 80.1.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/package.json
CHANGED
package/react/select/select.scss
CHANGED
|
@@ -4,18 +4,20 @@
|
|
|
4
4
|
@use '../../tokens/font-sizes';
|
|
5
5
|
|
|
6
6
|
.select {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
&__content {
|
|
8
|
+
&--position-inline {
|
|
9
|
+
align-items: center;
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-direction: row;
|
|
12
|
+
gap: spacing.$xs;
|
|
13
|
+
flex-wrap: wrap;
|
|
14
|
+
}
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
&--position-stacked {
|
|
17
|
+
display: grid;
|
|
18
|
+
gap: spacing.$xxs;
|
|
19
|
+
justify-items: start;
|
|
20
|
+
}
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
// NOTE: Specificity hack
|
|
@@ -53,7 +55,6 @@
|
|
|
53
55
|
border: 1px solid light.$ge-border-default;
|
|
54
56
|
display: block;
|
|
55
57
|
position: relative;
|
|
56
|
-
width: 100%;
|
|
57
58
|
border-radius: corner-radius.$s;
|
|
58
59
|
padding-right: 36px; // NOTE: custom spacing to offset chevron overlap
|
|
59
60
|
|
|
@@ -109,7 +110,7 @@
|
|
|
109
110
|
margin-left: spacing.$xs;
|
|
110
111
|
}
|
|
111
112
|
|
|
112
|
-
&__label {
|
|
113
|
+
&__label-text {
|
|
113
114
|
display: flex;
|
|
114
115
|
flex-direction: row;
|
|
115
116
|
}
|
package/react/select/select.tsx
CHANGED
|
@@ -18,6 +18,7 @@ const RefSelect = React.forwardRef<
|
|
|
18
18
|
{
|
|
19
19
|
children,
|
|
20
20
|
className,
|
|
21
|
+
id,
|
|
21
22
|
isLabelVisible = true,
|
|
22
23
|
label,
|
|
23
24
|
labelPosition = labelPositions.stacked,
|
|
@@ -39,66 +40,71 @@ const RefSelect = React.forwardRef<
|
|
|
39
40
|
validationOnChange(e);
|
|
40
41
|
};
|
|
41
42
|
|
|
43
|
+
const asterix = required ? (
|
|
44
|
+
<span className="select__asterisk">*</span>
|
|
45
|
+
) : null;
|
|
46
|
+
|
|
42
47
|
return (
|
|
43
|
-
<
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
48
|
+
<div className={cn('select', className, { 'select--error': error })}>
|
|
49
|
+
<div
|
|
50
|
+
className={`select__content select__content--position-${labelPosition}`}
|
|
51
|
+
>
|
|
52
|
+
{isLabelVisible ? (
|
|
53
|
+
<label className="select__label" htmlFor={id}>
|
|
54
|
+
{label || children ? (
|
|
55
|
+
<div className="select__label-text">
|
|
56
|
+
<Text
|
|
57
|
+
size={
|
|
58
|
+
variant === variants.small
|
|
59
|
+
? Text.sizes.small
|
|
60
|
+
: Text.sizes.basic
|
|
61
|
+
}
|
|
62
|
+
theme={Text.themes.emphasis}
|
|
63
|
+
>
|
|
64
|
+
{label}
|
|
65
|
+
</Text>
|
|
66
|
+
{asterix}
|
|
67
|
+
{children}
|
|
68
|
+
</div>
|
|
69
|
+
) : required ? (
|
|
70
|
+
asterix
|
|
71
|
+
) : null}
|
|
72
|
+
</label>
|
|
73
|
+
) : null}
|
|
74
|
+
|
|
75
|
+
<div className="select__native-wrapper">
|
|
76
|
+
<select
|
|
77
|
+
aria-label={isLabelVisible ? undefined : label}
|
|
78
|
+
className={`select__select select__select--variant-${variant}`}
|
|
79
|
+
id={id}
|
|
80
|
+
name={name}
|
|
81
|
+
onChange={onInputChange}
|
|
82
|
+
onInvalid={e => {
|
|
83
|
+
// NOTE: To not break compatibility
|
|
84
|
+
if (restProps.onInvalid) restProps.onInvalid(e);
|
|
85
|
+
onInvalid(e);
|
|
86
|
+
}}
|
|
87
|
+
ref={ref}
|
|
88
|
+
required={required}
|
|
89
|
+
{...restProps}
|
|
58
90
|
>
|
|
59
|
-
{
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
91
|
+
{options.map(option => (
|
|
92
|
+
<Option key={option.value} {...option} />
|
|
93
|
+
))}
|
|
94
|
+
</select>
|
|
95
|
+
<span className="select__chevron">
|
|
96
|
+
<SvgArrowDown />
|
|
97
|
+
</span>
|
|
63
98
|
</div>
|
|
64
|
-
) : required ? (
|
|
65
|
-
<span className="select__asterisk">*</span>
|
|
66
|
-
) : null}
|
|
67
99
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
className=
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
name={name}
|
|
75
|
-
ref={ref}
|
|
76
|
-
onChange={onInputChange}
|
|
77
|
-
required={required}
|
|
78
|
-
onInvalid={e => {
|
|
79
|
-
// NOTE: To not break compatibility
|
|
80
|
-
if (restProps.onInvalid) restProps.onInvalid(e);
|
|
81
|
-
onInvalid(e);
|
|
82
|
-
}}
|
|
83
|
-
aria-label={isLabelVisible ? undefined : label}
|
|
84
|
-
{...restProps}
|
|
85
|
-
>
|
|
86
|
-
{options.map(option => (
|
|
87
|
-
<Option key={option.value} {...option} />
|
|
88
|
-
))}
|
|
89
|
-
</select>
|
|
90
|
-
<span className="select__chevron">
|
|
91
|
-
<SvgArrowDown />
|
|
92
|
-
</span>
|
|
100
|
+
{/* NOTE: This is aria-hidden because reporting of validation errors is handled by the browser */}
|
|
101
|
+
{error ? (
|
|
102
|
+
<div aria-hidden="true" className="select__error">
|
|
103
|
+
{error}
|
|
104
|
+
</div>
|
|
105
|
+
) : null}
|
|
93
106
|
</div>
|
|
94
|
-
|
|
95
|
-
{/* NOTE: This is aria-hidden because reporting of validation errors is handled by the browser */}
|
|
96
|
-
{error && (
|
|
97
|
-
<div aria-hidden="true" className="select__error">
|
|
98
|
-
{error}
|
|
99
|
-
</div>
|
|
100
|
-
)}
|
|
101
|
-
</label>
|
|
107
|
+
</div>
|
|
102
108
|
);
|
|
103
109
|
},
|
|
104
110
|
);
|
|
@@ -114,7 +120,8 @@ const SelectComponent = RefSelect as <OptionExtra>(
|
|
|
114
120
|
) => React.ReactElement;
|
|
115
121
|
|
|
116
122
|
const Select: typeof SelectComponent & {
|
|
123
|
+
labelPositions: typeof labelPositions;
|
|
117
124
|
variants: typeof variants;
|
|
118
|
-
} = Object.assign(SelectComponent, { variants });
|
|
125
|
+
} = Object.assign(SelectComponent, { labelPositions, variants });
|
|
119
126
|
|
|
120
127
|
export default Select;
|
|
@@ -10,10 +10,11 @@ export const labelPositions = {
|
|
|
10
10
|
export const variants = {
|
|
11
11
|
small: 'small',
|
|
12
12
|
large: 'large',
|
|
13
|
-
};
|
|
13
|
+
} as const;
|
|
14
14
|
|
|
15
15
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
16
|
export type Select<OptionExtra = any> = {
|
|
17
|
+
id: string;
|
|
17
18
|
isLabelVisible?: boolean;
|
|
18
19
|
label?: string;
|
|
19
20
|
labelPosition?: ObjectValues<typeof labelPositions>;
|