@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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sats-group/ui-lib",
3
- "version": "79.2.0",
3
+ "version": "80.1.0",
4
4
  "description": "SATS web user interface library",
5
5
  "engines": {
6
6
  "node": "^18 || ^20",
@@ -23,7 +23,7 @@ const FormContentSearch: React.FC<Props> = ({
23
23
  }, [searchDataset]);
24
24
 
25
25
  const searchResults = React.useMemo(
26
- () => (term.length > 0 ? search(term).slice(0, 5) : []),
26
+ () => (term.length > 0 ? search(term) : []),
27
27
  [search, term],
28
28
  );
29
29
 
@@ -4,18 +4,20 @@
4
4
  @use '../../tokens/font-sizes';
5
5
 
6
6
  .select {
7
- display: flex;
8
-
9
- &--label-position-inline {
10
- flex-direction: row;
11
- gap: spacing.$xs;
12
- align-items: center;
13
- flex-wrap: wrap;
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
- &--label-position-stacked {
17
- flex-direction: column;
18
- gap: spacing.$xxs;
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
  }
@@ -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
- <label
44
- className={cn('select', className, {
45
- 'select--error': error,
46
- [`select--label-position-${labelPosition}`]: labelPosition
47
- ? labelPositions[labelPosition]
48
- : undefined,
49
- })}
50
- >
51
- {isLabelVisible && (label || children) ? (
52
- <div className="select__label">
53
- <Text
54
- size={
55
- variant === variants.small ? Text.sizes.small : Text.sizes.basic
56
- }
57
- theme={Text.themes.emphasis}
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
- {label}
60
- </Text>
61
- {required ? <span className="select__asterisk">*</span> : null}
62
- {children}
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
- <div className="select__native-wrapper">
69
- <select
70
- className={cn('select__select', {
71
- 'select__select--variant-small': variant === variants.small,
72
- 'select__select--variant-large': variant === variants.large,
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>;