@moda/om 16.2.1 → 16.3.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 +7 -0
- package/dist/index.cjs.js +34 -20
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +34 -20
- package/dist/index.esm.js.map +1 -1
- package/dist/src/components/Select/Select.d.ts +1 -0
- package/dist/src/components/Select/SelectOption.d.ts +1 -0
- package/dist/src/components/Select/SelectOptions.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/Select/Select.tsx +4 -0
- package/src/components/Select/SelectOption.tsx +4 -1
- package/src/components/Select/SelectOptions.tsx +3 -0
|
@@ -6,5 +6,6 @@ export declare type SelectOptionProps = Omit<React.HTMLAttributes<HTMLLIElement>
|
|
|
6
6
|
selected: boolean;
|
|
7
7
|
option: SelectableOption;
|
|
8
8
|
onClick: (option: SelectableOption) => void;
|
|
9
|
+
dataTestId?: string;
|
|
9
10
|
};
|
|
10
11
|
export declare const SelectOption: React.FC<SelectOptionProps>;
|
|
@@ -9,5 +9,6 @@ export declare type SelectOptionsProps = Omit<React.HTMLAttributes<HTMLUListElem
|
|
|
9
9
|
selectedOption?: SelectableOption | undefined;
|
|
10
10
|
onFocus?(option: SelectableOption): void;
|
|
11
11
|
onSelect(option: SelectableOption): void;
|
|
12
|
+
dataTestId?: string;
|
|
12
13
|
};
|
|
13
14
|
export declare const SelectOptions: React.FC<SelectOptionsProps>;
|
package/package.json
CHANGED
|
@@ -29,6 +29,7 @@ export type SelectProps = Omit<
|
|
|
29
29
|
searchable?: boolean;
|
|
30
30
|
shiftIconLeftwards?: boolean;
|
|
31
31
|
value?: string | undefined;
|
|
32
|
+
dataTestId?: string;
|
|
32
33
|
};
|
|
33
34
|
|
|
34
35
|
export const Select: React.FC<SelectProps> = ({
|
|
@@ -48,6 +49,7 @@ export const Select: React.FC<SelectProps> = ({
|
|
|
48
49
|
searchable,
|
|
49
50
|
shiftIconLeftwards = false,
|
|
50
51
|
value,
|
|
52
|
+
dataTestId,
|
|
51
53
|
...rest
|
|
52
54
|
}) => {
|
|
53
55
|
const { state, dispatch, Mode, selectRef } = useSelect({ value, defaultValue });
|
|
@@ -111,6 +113,7 @@ export const Select: React.FC<SelectProps> = ({
|
|
|
111
113
|
className="Select__value"
|
|
112
114
|
disabled={disabled}
|
|
113
115
|
onClick={handleToggle}
|
|
116
|
+
data-test-id={dataTestId}
|
|
114
117
|
aria-haspopup="listbox"
|
|
115
118
|
aria-expanded={state.mode === Mode.Open}
|
|
116
119
|
aria-labelledby={`Select__label--${idRef} Select__value--${idRef}`}
|
|
@@ -139,6 +142,7 @@ export const Select: React.FC<SelectProps> = ({
|
|
|
139
142
|
'Select__options--up': dropDirection === 'up',
|
|
140
143
|
'Select__options--down': dropDirection === 'down'
|
|
141
144
|
})}
|
|
145
|
+
dataTestId={dataTestId}
|
|
142
146
|
searchable={searchable}
|
|
143
147
|
options={options}
|
|
144
148
|
onSelect={handleSelect}
|
|
@@ -9,6 +9,7 @@ export type SelectOptionProps = Omit<React.HTMLAttributes<HTMLLIElement>, 'onCli
|
|
|
9
9
|
selected: boolean;
|
|
10
10
|
option: SelectableOption;
|
|
11
11
|
onClick: (option: SelectableOption) => void;
|
|
12
|
+
dataTestId?: string;
|
|
12
13
|
};
|
|
13
14
|
|
|
14
15
|
export const SelectOption: React.FC<SelectOptionProps> = ({
|
|
@@ -16,7 +17,8 @@ export const SelectOption: React.FC<SelectOptionProps> = ({
|
|
|
16
17
|
selected,
|
|
17
18
|
option,
|
|
18
19
|
onClick,
|
|
19
|
-
className
|
|
20
|
+
className,
|
|
21
|
+
dataTestId
|
|
20
22
|
}) => {
|
|
21
23
|
const ref = useRef<HTMLLIElement>(null);
|
|
22
24
|
|
|
@@ -43,6 +45,7 @@ export const SelectOption: React.FC<SelectOptionProps> = ({
|
|
|
43
45
|
'SelectOption--disabled': option.disabled
|
|
44
46
|
})}
|
|
45
47
|
onClick={handleClick}
|
|
48
|
+
data-test-id={dataTestId ? `${dataTestId}--${option.label.replace(' ', '-')}` : undefined}
|
|
46
49
|
aria-label={option.label}
|
|
47
50
|
aria-selected={selected}
|
|
48
51
|
role="option"
|
|
@@ -19,6 +19,7 @@ export type SelectOptionsProps = Omit<
|
|
|
19
19
|
selectedOption?: SelectableOption | undefined;
|
|
20
20
|
onFocus?(option: SelectableOption): void;
|
|
21
21
|
onSelect(option: SelectableOption): void;
|
|
22
|
+
dataTestId?: string;
|
|
22
23
|
};
|
|
23
24
|
|
|
24
25
|
export const SelectOptions: React.FC<SelectOptionsProps> = ({
|
|
@@ -30,6 +31,7 @@ export const SelectOptions: React.FC<SelectOptionsProps> = ({
|
|
|
30
31
|
onSelect,
|
|
31
32
|
onFocus,
|
|
32
33
|
className,
|
|
34
|
+
dataTestId,
|
|
33
35
|
...rest
|
|
34
36
|
}) => {
|
|
35
37
|
const [searchPhrase, setSearchPhrase] = useState('');
|
|
@@ -82,6 +84,7 @@ export const SelectOptions: React.FC<SelectOptionsProps> = ({
|
|
|
82
84
|
id={`SelectOption--${option.value}-${idRef}`}
|
|
83
85
|
key={option.value}
|
|
84
86
|
option={option}
|
|
87
|
+
dataTestId={dataTestId}
|
|
85
88
|
active={activeOption?.value === option.value}
|
|
86
89
|
selected={selectedOption?.value === option.value}
|
|
87
90
|
onClick={onSelect}
|