@sats-group/ui-lib 74.2.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/.nvmrc +1 -0
- package/README.md +35 -0
- package/catalog-info.yaml +14 -0
- package/eslint.config.mjs +94 -0
- package/fonts/Inter-BoldItalic.woff +0 -0
- package/fonts/Inter-BoldItalic.woff2 +0 -0
- package/fonts/Inter-ExtraBold.woff +0 -0
- package/fonts/Inter-ExtraBold.woff2 +0 -0
- package/fonts/Inter-Italic.woff +0 -0
- package/fonts/Inter-Italic.woff2 +0 -0
- package/fonts/Inter-Regular.woff +0 -0
- package/fonts/Inter-Regular.woff2 +0 -0
- package/fonts/Inter-SemiBold.woff +0 -0
- package/fonts/Inter-SemiBold.woff2 +0 -0
- package/fonts/LICENSE.txt +92 -0
- package/fonts/SATSHeadline-Bold.woff +0 -0
- package/fonts/SATSHeadline-BoldItalic.woff +0 -0
- package/fonts/SATSHeadline-RegularItalic.woff +0 -0
- package/fonts/SATSHeadline-SemiBoldItalic.woff +0 -0
- package/logos/e-avatar.svg +3 -0
- package/logos/elixia-letter.svg +3 -0
- package/logos/elixia-small.svg +8 -0
- package/logos/elixia.svg +8 -0
- package/logos/s-avatar.svg +3 -0
- package/logos/sats-letter.svg +3 -0
- package/logos/sats-small.svg +3 -0
- package/logos/sats.svg +4 -0
- package/package.json +58 -0
- package/react/add-bem-modifiers.ts +51 -0
- package/react/badge/badge.scss +53 -0
- package/react/badge/badge.tsx +28 -0
- package/react/badge/badge.types.ts +34 -0
- package/react/badge/index.ts +2 -0
- package/react/banner/banner.scss +118 -0
- package/react/banner/banner.tsx +92 -0
- package/react/banner/banner.types.ts +10 -0
- package/react/banner/index.ts +2 -0
- package/react/bomb/bomb.scss +33 -0
- package/react/bomb/bomb.tsx +19 -0
- package/react/bomb/bomb.types.ts +1 -0
- package/react/bomb/index.ts +2 -0
- package/react/button/button.tsx +19 -0
- package/react/button/button.types.ts +3 -0
- package/react/button/index.ts +2 -0
- package/react/checkbox/checkbox.scss +218 -0
- package/react/checkbox/checkbox.tsx +176 -0
- package/react/checkbox/checkbox.types.ts +19 -0
- package/react/checkbox/index.ts +2 -0
- package/react/chip/chip.scss +46 -0
- package/react/chip/chip.tsx +37 -0
- package/react/chip/chip.types.ts +18 -0
- package/react/chip/index.ts +2 -0
- package/react/chip/remove.tsx +14 -0
- package/react/chip-selected/chip-selected.scss +47 -0
- package/react/chip-selected/chip-selected.tsx +102 -0
- package/react/chip-selected/chip-selected.types.ts +11 -0
- package/react/chip-selected/index.ts +2 -0
- package/react/confirmation/confirmation.scss +60 -0
- package/react/confirmation/confirmation.tsx +85 -0
- package/react/confirmation/confirmation.types.ts +24 -0
- package/react/confirmation/index.ts +2 -0
- package/react/context-menu/context-menu.scss +183 -0
- package/react/context-menu/context-menu.tsx +200 -0
- package/react/context-menu/context-menu.types.ts +71 -0
- package/react/context-menu/index.ts +2 -0
- package/react/cropped-image/cropped-image.scss +48 -0
- package/react/cropped-image/cropped-image.tsx +36 -0
- package/react/cropped-image/cropped-image.types.ts +26 -0
- package/react/cropped-image/index.ts +2 -0
- package/react/dropdown-list/dropdown-list.scss +170 -0
- package/react/dropdown-list/dropdown-list.tsx +116 -0
- package/react/dropdown-list/dropdown-list.types.ts +17 -0
- package/react/dropdown-list/index.ts +2 -0
- package/react/expander/expander.scss +115 -0
- package/react/expander/expander.tsx +167 -0
- package/react/expander/expander.types.ts +26 -0
- package/react/expander/index.ts +2 -0
- package/react/filter/filter.scss +94 -0
- package/react/filter/filter.tsx +99 -0
- package/react/filter/filter.types.ts +8 -0
- package/react/filter/index.ts +2 -0
- package/react/filter-wrapper/filter-wrapper.scss +46 -0
- package/react/filter-wrapper/filter-wrapper.tsx +24 -0
- package/react/filter-wrapper/filter-wrapper.types.ts +10 -0
- package/react/filter-wrapper/index.ts +2 -0
- package/react/flag/flag.scss +26 -0
- package/react/flag/flag.tsx +27 -0
- package/react/flag/flag.types.ts +17 -0
- package/react/flag/index.ts +2 -0
- package/react/form-content/checkbox-category.tsx +183 -0
- package/react/form-content/form-content.checkbox-list.tsx +126 -0
- package/react/form-content/form-content.checkbox-list.types.ts +36 -0
- package/react/form-content/form-content.radio-list.tsx +58 -0
- package/react/form-content/form-content.range.tsx +20 -0
- package/react/form-content/form-content.range.types.ts +14 -0
- package/react/form-content/form-content.scss +234 -0
- package/react/form-content/form-content.search.tsx +47 -0
- package/react/form-content/form-content.tsx +95 -0
- package/react/form-content/form-content.types.ts +55 -0
- package/react/form-content/index.ts +2 -0
- package/react/form-content/types/index.d.ts +1 -0
- package/react/hidden-input/hidden-input.tsx +9 -0
- package/react/hidden-input/hidden-input.types.ts +6 -0
- package/react/hidden-input/index.ts +2 -0
- package/react/hooks/focus-previous-element.ts +30 -0
- package/react/hooks/is-running-on-client.ts +1 -0
- package/react/hooks/use-click-outside.ts +23 -0
- package/react/hooks/use-escape.ts +18 -0
- package/react/hooks/use-event.ts +29 -0
- package/react/hooks/use-is-mounted.ts +11 -0
- package/react/hooks/use-toggle.ts +19 -0
- package/react/icons/16/close.tsx +12 -0
- package/react/icons/18/close.tsx +18 -0
- package/react/icons/24/arrow-down.tsx +14 -0
- package/react/icons/24/arrow-right.tsx +14 -0
- package/react/icons/24/arrow-up.tsx +14 -0
- package/react/icons/24/close.tsx +12 -0
- package/react/icons/24/remove.tsx +12 -0
- package/react/icons/24/search.tsx +10 -0
- package/react/icons/icons.md +3 -0
- package/react/indexed-access-type.ts +1 -0
- package/react/link/index.ts +2 -0
- package/react/link/link.scss +44 -0
- package/react/link/link.tsx +62 -0
- package/react/link/link.types.ts +37 -0
- package/react/link-button/index.ts +2 -0
- package/react/link-button/link-button.tsx +17 -0
- package/react/link-button/link-button.types.ts +5 -0
- package/react/link-card/index.ts +2 -0
- package/react/link-card/link-card.scss +37 -0
- package/react/link-card/link-card.tsx +24 -0
- package/react/link-card/link-card.types.ts +5 -0
- package/react/logos/e-avatar.tsx +12 -0
- package/react/logos/elixia-letter.tsx +12 -0
- package/react/logos/elixia-small.tsx +12 -0
- package/react/logos/elixia.tsx +12 -0
- package/react/logos/index.ts +8 -0
- package/react/logos/s-avatar.tsx +12 -0
- package/react/logos/sats-letter.tsx +12 -0
- package/react/logos/sats-small.tsx +12 -0
- package/react/logos/sats.tsx +12 -0
- package/react/message/hook/use-message.ts +22 -0
- package/react/message/index.ts +2 -0
- package/react/message/message.scss +92 -0
- package/react/message/message.tsx +60 -0
- package/react/message/message.types.ts +39 -0
- package/react/message/publish.ts +19 -0
- package/react/message-field/index.ts +2 -0
- package/react/message-field/message-field.scss +21 -0
- package/react/message-field/message-field.tsx +70 -0
- package/react/message-field/message-field.types.ts +24 -0
- package/react/modal/index.ts +2 -0
- package/react/modal/modal.scss +162 -0
- package/react/modal/modal.tsx +130 -0
- package/react/modal/modal.types.ts +36 -0
- package/react/modal/tab-trapper.tsx +68 -0
- package/react/progress-bar/index.ts +2 -0
- package/react/progress-bar/progress-bar.scss +71 -0
- package/react/progress-bar/progress-bar.tsx +81 -0
- package/react/progress-bar/progress-bar.types.ts +35 -0
- package/react/radio/index.ts +2 -0
- package/react/radio/radio.scss +142 -0
- package/react/radio/radio.tsx +87 -0
- package/react/radio/radio.types.ts +15 -0
- package/react/scale-bar/index.ts +2 -0
- package/react/scale-bar/scale-bar.scss +22 -0
- package/react/scale-bar/scale-bar.tsx +29 -0
- package/react/scale-bar/scale-bar.types.ts +4 -0
- package/react/search/index.ts +2 -0
- package/react/search/search.scss +207 -0
- package/react/search/search.tsx +255 -0
- package/react/search/search.types.ts +43 -0
- package/react/select/chevron-down.tsx +24 -0
- package/react/select/index.ts +2 -0
- package/react/select/select.scss +135 -0
- package/react/select/select.tsx +105 -0
- package/react/select/select.types.ts +19 -0
- package/react/select-option/README.md +3 -0
- package/react/select-option/index.ts +2 -0
- package/react/select-option/select-option.tsx +16 -0
- package/react/select-option/select-option.types.ts +8 -0
- package/react/tag/index.ts +2 -0
- package/react/tag/tag.scss +107 -0
- package/react/tag/tag.tsx +26 -0
- package/react/tag/tag.types.ts +30 -0
- package/react/text/index.ts +2 -0
- package/react/text/text.scss +109 -0
- package/react/text/text.tsx +40 -0
- package/react/text/text.types.ts +29 -0
- package/react/text-area/index.ts +2 -0
- package/react/text-area/text-area.scss +180 -0
- package/react/text-area/text-area.tsx +153 -0
- package/react/text-area/text-area.types.ts +24 -0
- package/react/text-input/index.ts +2 -0
- package/react/text-input/text-input.scss +233 -0
- package/react/text-input/text-input.tsx +106 -0
- package/react/text-input/text-input.types.ts +19 -0
- package/react/toggle/index.ts +2 -0
- package/react/toggle/toggle.scss +69 -0
- package/react/toggle/toggle.tsx +83 -0
- package/react/toggle/toggle.types.ts +11 -0
- package/react/toolbox/index.ts +2 -0
- package/react/toolbox/toolbox.scss +68 -0
- package/react/toolbox/toolbox.tsx +43 -0
- package/react/toolbox/toolbox.types.ts +39 -0
- package/react/ts/debounce.ts +12 -0
- package/react/types.ts +38 -0
- package/react/use-input-validation.ts +47 -0
- package/react/use-input-validation.types.ts +12 -0
- package/react/visually-button/index.ts +2 -0
- package/react/visually-button/visually-button.scss +470 -0
- package/react/visually-button/visually-button.tsx +130 -0
- package/react/visually-button/visually-button.types.ts +71 -0
- package/react/visually-hidden/index.ts +2 -0
- package/react/visually-hidden/visually-hidden.scss +6 -0
- package/react/visually-hidden/visually-hidden.tsx +10 -0
- package/tokens/corner-radius.scss +5 -0
- package/tokens/dark.scss +392 -0
- package/tokens/darkmode.scss +131 -0
- package/tokens/elevation.scss +57 -0
- package/tokens/font-faces.scss +62 -0
- package/tokens/font-names.scss +2 -0
- package/tokens/font-sizes.scss +95 -0
- package/tokens/light.scss +392 -0
- package/tokens/lightmode.scss +131 -0
- package/tokens/primitives.scss +137 -0
- package/tokens/spacing.scss +12 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import Collapse from 'react-tiny-collapse';
|
|
3
|
+
import Text from '../text';
|
|
4
|
+
import Checkbox from '../checkbox';
|
|
5
|
+
|
|
6
|
+
import ChevronRight from '../icons/24/arrow-right';
|
|
7
|
+
import ChevronUp from '../icons/24/arrow-up';
|
|
8
|
+
|
|
9
|
+
import { CheckboxCategory as Props } from './form-content.checkbox-list.types';
|
|
10
|
+
import VisuallyHidden from '../visually-hidden';
|
|
11
|
+
import { mod } from '../add-bem-modifiers';
|
|
12
|
+
|
|
13
|
+
const CheckboxCategory: React.FC<React.PropsWithChildren<Props>> = ({
|
|
14
|
+
currentlySelectedValues = [],
|
|
15
|
+
id,
|
|
16
|
+
isSearching,
|
|
17
|
+
options,
|
|
18
|
+
searchResults = [],
|
|
19
|
+
selectAll,
|
|
20
|
+
selectAllLabel,
|
|
21
|
+
setMultipleSelectedValues = () => {},
|
|
22
|
+
setSelectedValue = () => {},
|
|
23
|
+
shouldShowItems = true,
|
|
24
|
+
removeAllValues = () => {},
|
|
25
|
+
}) => {
|
|
26
|
+
const isExpandable = React.useMemo(
|
|
27
|
+
() => (selectAll ? true : false),
|
|
28
|
+
[selectAll],
|
|
29
|
+
);
|
|
30
|
+
const [availableOptions] = React.useState(
|
|
31
|
+
options.filter(button => !button.disabled),
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const [isOpen, setIsOpen] = React.useState(isExpandable ? true : false);
|
|
35
|
+
|
|
36
|
+
const handleChange = (value: string) => {
|
|
37
|
+
setSelectedValue(id, value);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const handleSelectAll = () => {
|
|
41
|
+
if (currentlySelectedValues.length !== availableOptions.length) {
|
|
42
|
+
setMultipleSelectedValues(
|
|
43
|
+
id,
|
|
44
|
+
availableOptions.map(button => button.value),
|
|
45
|
+
);
|
|
46
|
+
} else {
|
|
47
|
+
removeAllValues(id);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
React.useEffect(
|
|
52
|
+
() =>
|
|
53
|
+
isSearching
|
|
54
|
+
? setIsOpen(true)
|
|
55
|
+
: isExpandable
|
|
56
|
+
? setIsOpen(false)
|
|
57
|
+
: setIsOpen(true),
|
|
58
|
+
[isExpandable, isSearching, searchResults],
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
const disableCategory = options.every(checkbox => checkbox.disabled);
|
|
62
|
+
|
|
63
|
+
const hasSelectedValues = currentlySelectedValues.length > 0;
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<fieldset className="form-content__fieldset">
|
|
67
|
+
{isExpandable && (
|
|
68
|
+
<div
|
|
69
|
+
className={mod('form-content__chevron-button-wrapper', {
|
|
70
|
+
hidden: isSearching,
|
|
71
|
+
})}
|
|
72
|
+
>
|
|
73
|
+
{selectAll ? (
|
|
74
|
+
<div className="form-content__select-all">
|
|
75
|
+
<Checkbox
|
|
76
|
+
{...selectAll}
|
|
77
|
+
isLabelVisible={false}
|
|
78
|
+
checked={
|
|
79
|
+
availableOptions.length > 0 &&
|
|
80
|
+
currentlySelectedValues.length === availableOptions.length
|
|
81
|
+
}
|
|
82
|
+
onChange={handleSelectAll}
|
|
83
|
+
data-test-select-all
|
|
84
|
+
disabled={disableCategory}
|
|
85
|
+
/>
|
|
86
|
+
</div>
|
|
87
|
+
) : null}
|
|
88
|
+
<button
|
|
89
|
+
className="form-content__chevron-button"
|
|
90
|
+
onClick={() => setIsOpen(currentState => !currentState)}
|
|
91
|
+
type="button"
|
|
92
|
+
>
|
|
93
|
+
<Text
|
|
94
|
+
elementName="span"
|
|
95
|
+
className={mod('form-content__select-all-label', {
|
|
96
|
+
disabled: disableCategory,
|
|
97
|
+
})}
|
|
98
|
+
size={Text.sizes.basic}
|
|
99
|
+
>
|
|
100
|
+
{selectAllLabel}
|
|
101
|
+
</Text>
|
|
102
|
+
<div className="form-content__checkbox-category-info-wrapper">
|
|
103
|
+
{hasSelectedValues ? (
|
|
104
|
+
<Text
|
|
105
|
+
className="form-content__checkbox-category-number"
|
|
106
|
+
size={Text.sizes.interface}
|
|
107
|
+
>
|
|
108
|
+
{currentlySelectedValues.length}
|
|
109
|
+
</Text>
|
|
110
|
+
) : undefined}
|
|
111
|
+
{isOpen ? (
|
|
112
|
+
<div className="form-content__checkbox-category-icon">
|
|
113
|
+
<ChevronUp />
|
|
114
|
+
</div>
|
|
115
|
+
) : (
|
|
116
|
+
<div className="form-content__checkbox-category-icon">
|
|
117
|
+
<ChevronRight />
|
|
118
|
+
</div>
|
|
119
|
+
)}
|
|
120
|
+
</div>
|
|
121
|
+
</button>
|
|
122
|
+
</div>
|
|
123
|
+
)}
|
|
124
|
+
|
|
125
|
+
<Collapse
|
|
126
|
+
duration={300}
|
|
127
|
+
animateChildren={isExpandable ? true : false}
|
|
128
|
+
isOpen={isOpen}
|
|
129
|
+
>
|
|
130
|
+
{
|
|
131
|
+
<fieldset className="form-content__fieldset">
|
|
132
|
+
{options.map(checkbox => {
|
|
133
|
+
const isInSearchResults = isSearching
|
|
134
|
+
? searchResults.find(
|
|
135
|
+
item =>
|
|
136
|
+
item.key.toLowerCase() === checkbox.value.toLowerCase(),
|
|
137
|
+
)
|
|
138
|
+
: undefined;
|
|
139
|
+
|
|
140
|
+
const isSelected = currentlySelectedValues.includes(
|
|
141
|
+
checkbox.value,
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
const node = (
|
|
145
|
+
<div
|
|
146
|
+
key={checkbox.value}
|
|
147
|
+
className={mod('form-content__checkbox-button', {
|
|
148
|
+
nested: !isSearching && isExpandable,
|
|
149
|
+
})}
|
|
150
|
+
>
|
|
151
|
+
<Checkbox
|
|
152
|
+
onChange={e => handleChange(e.target.value)}
|
|
153
|
+
checked={isSelected}
|
|
154
|
+
isUnderlined={true}
|
|
155
|
+
{...checkbox}
|
|
156
|
+
/>
|
|
157
|
+
</div>
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
if (!isSelected && !isInSearchResults && !shouldShowItems) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (isSelected && isSearching && !isInSearchResults) {
|
|
165
|
+
return (
|
|
166
|
+
<VisuallyHidden key={checkbox.value}>{node}</VisuallyHidden>
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (!isSelected && isSearching && !isInSearchResults) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return node;
|
|
175
|
+
})}
|
|
176
|
+
</fieldset>
|
|
177
|
+
}
|
|
178
|
+
</Collapse>
|
|
179
|
+
</fieldset>
|
|
180
|
+
);
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
export default CheckboxCategory;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import Text from '../text';
|
|
3
|
+
|
|
4
|
+
import CheckboxCategory from './checkbox-category';
|
|
5
|
+
|
|
6
|
+
import { CheckboxList as Props } from './form-content.checkbox-list.types';
|
|
7
|
+
import { SearchItem } from './form-content.types';
|
|
8
|
+
import { mod } from '../add-bem-modifiers';
|
|
9
|
+
import FormContentSearch from './form-content.search';
|
|
10
|
+
|
|
11
|
+
const CheckboxList: React.FC<React.PropsWithChildren<Props>> = props => {
|
|
12
|
+
const [currentlySelectedValues, setCurrentlySelectedValues] = React.useState<
|
|
13
|
+
Record<string, string[]>
|
|
14
|
+
>({});
|
|
15
|
+
const { content, emptySearchResultDescription, emptySearchResultText } =
|
|
16
|
+
props;
|
|
17
|
+
|
|
18
|
+
const [searchTerm, setSearchTerm] = React.useState('');
|
|
19
|
+
const [searchResult, setSearchResult] = React.useState<SearchItem[]>();
|
|
20
|
+
|
|
21
|
+
const updateCurrentlySelectedValues = (id: string, value: string) => {
|
|
22
|
+
if (currentlySelectedValues[id]?.includes(value)) {
|
|
23
|
+
setCurrentlySelectedValues(prevState => {
|
|
24
|
+
const updatedValues = Object.entries(prevState).map(([id, values]) => [
|
|
25
|
+
id,
|
|
26
|
+
values.filter(option => option !== value),
|
|
27
|
+
]);
|
|
28
|
+
return Object.fromEntries(updatedValues);
|
|
29
|
+
});
|
|
30
|
+
} else {
|
|
31
|
+
setCurrentlySelectedValues(prevState => {
|
|
32
|
+
const updatedValues = Object.entries(prevState).map(
|
|
33
|
+
([filterGroupId, values = []]) => {
|
|
34
|
+
if (id === filterGroupId) {
|
|
35
|
+
return [filterGroupId, [...values, value]];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return [filterGroupId, values];
|
|
39
|
+
},
|
|
40
|
+
);
|
|
41
|
+
return Object.fromEntries(updatedValues);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const updateMultipleSelectedValues = (id: string, values: string[]) => {
|
|
47
|
+
setCurrentlySelectedValues(prevState => ({
|
|
48
|
+
...prevState,
|
|
49
|
+
[id]: values,
|
|
50
|
+
}));
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const removeAllValuesById = (id: string) => {
|
|
54
|
+
setCurrentlySelectedValues(prevState => {
|
|
55
|
+
const selectedValues = prevState[id] || [];
|
|
56
|
+
const updatedValues = Object.entries(prevState).map(([id, values]) => [
|
|
57
|
+
id,
|
|
58
|
+
values.filter(option => !selectedValues.includes(option)),
|
|
59
|
+
]);
|
|
60
|
+
return Object.fromEntries(updatedValues);
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
React.useEffect(() => {
|
|
65
|
+
const selectedValues = content
|
|
66
|
+
.flatMap(({ categories }) => categories)
|
|
67
|
+
.filter(category => category?.id)
|
|
68
|
+
.map(category => [category?.id, category?.selectedValues]);
|
|
69
|
+
setCurrentlySelectedValues(Object.fromEntries(selectedValues));
|
|
70
|
+
}, [content]);
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<div>
|
|
74
|
+
{'searchProps' in props ? (
|
|
75
|
+
<FormContentSearch
|
|
76
|
+
{...props.searchProps}
|
|
77
|
+
searchResult={setSearchResult}
|
|
78
|
+
searchTerm={setSearchTerm}
|
|
79
|
+
/>
|
|
80
|
+
) : undefined}
|
|
81
|
+
|
|
82
|
+
{searchTerm.length > 0 && searchResult?.length === 0 && (
|
|
83
|
+
<div className="form-content__search-no-results">
|
|
84
|
+
<Text
|
|
85
|
+
className="form-content__search-no-results-text"
|
|
86
|
+
elementName="span"
|
|
87
|
+
theme={Text.themes.emphasis}
|
|
88
|
+
>
|
|
89
|
+
{emptySearchResultText}
|
|
90
|
+
</Text>
|
|
91
|
+
<span>{emptySearchResultDescription}</span>
|
|
92
|
+
</div>
|
|
93
|
+
)}
|
|
94
|
+
|
|
95
|
+
{content.map(({ categories = [], key, header }) => (
|
|
96
|
+
<React.Fragment key={key}>
|
|
97
|
+
{header && searchTerm.length === 0 ? (
|
|
98
|
+
<Text
|
|
99
|
+
className={mod('form-content__content-title', {
|
|
100
|
+
hidden: searchTerm.length > 0,
|
|
101
|
+
})}
|
|
102
|
+
theme={Text.themes.emphasis}
|
|
103
|
+
>
|
|
104
|
+
{header}
|
|
105
|
+
</Text>
|
|
106
|
+
) : undefined}
|
|
107
|
+
|
|
108
|
+
{categories.map(category => (
|
|
109
|
+
<CheckboxCategory
|
|
110
|
+
key={category.id}
|
|
111
|
+
searchResults={searchResult}
|
|
112
|
+
isSearching={searchTerm.length > 0}
|
|
113
|
+
currentlySelectedValues={currentlySelectedValues[category.id]}
|
|
114
|
+
setSelectedValue={updateCurrentlySelectedValues}
|
|
115
|
+
setMultipleSelectedValues={updateMultipleSelectedValues}
|
|
116
|
+
removeAllValues={removeAllValuesById}
|
|
117
|
+
{...category}
|
|
118
|
+
/>
|
|
119
|
+
))}
|
|
120
|
+
</React.Fragment>
|
|
121
|
+
))}
|
|
122
|
+
</div>
|
|
123
|
+
);
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
export default CheckboxList;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Checkbox } from '../checkbox/checkbox.types';
|
|
2
|
+
import { ContentKeys } from '../form-content/form-content.types';
|
|
3
|
+
import type { Search } from './form-content.types';
|
|
4
|
+
|
|
5
|
+
export type CheckboxCategory = {
|
|
6
|
+
currentlySelectedValues?: string[];
|
|
7
|
+
id: string;
|
|
8
|
+
isSearching?: boolean;
|
|
9
|
+
options: Checkbox[];
|
|
10
|
+
searchResults?: { key: string; label: string }[];
|
|
11
|
+
selectAll?: Checkbox;
|
|
12
|
+
selectAllLabel?: string;
|
|
13
|
+
selectedValues?: string[];
|
|
14
|
+
setMultipleSelectedValues?: (id: string, values: string[]) => void;
|
|
15
|
+
setSelectedValue?: (id: string, value: string) => void;
|
|
16
|
+
shouldShowItems?: boolean;
|
|
17
|
+
removeAllValues?: (id: string) => void;
|
|
18
|
+
queryName: string; // NOTE: This is used by some systems to avoid looping through all options to get the name. This should be refactored away in those systems.
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type CheckboxListBase = {
|
|
22
|
+
key: ContentKeys.Checkbox;
|
|
23
|
+
content: {
|
|
24
|
+
key: string;
|
|
25
|
+
header?: string;
|
|
26
|
+
categories?: CheckboxCategory[];
|
|
27
|
+
}[];
|
|
28
|
+
emptySearchResultText?: string;
|
|
29
|
+
emptySearchResultDescription?: string;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type CheckboxListSearch = CheckboxListBase & {
|
|
33
|
+
searchProps: Search;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export type CheckboxList = CheckboxListBase | CheckboxListSearch;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import Radio from '../radio';
|
|
3
|
+
import Text from '../text';
|
|
4
|
+
import FormContentSearch from './form-content.search';
|
|
5
|
+
|
|
6
|
+
import { RadioList as Props, SearchItem } from './form-content.types';
|
|
7
|
+
import classNames from 'classnames';
|
|
8
|
+
|
|
9
|
+
const RadioList: React.FC<Props> = props => {
|
|
10
|
+
const [searchTerm, setSearchTerm] = React.useState('');
|
|
11
|
+
const [searchResult, setSearchResult] = React.useState<SearchItem[]>();
|
|
12
|
+
return (
|
|
13
|
+
<div>
|
|
14
|
+
{'searchProps' in props ? (
|
|
15
|
+
<FormContentSearch
|
|
16
|
+
{...props.searchProps}
|
|
17
|
+
searchResult={setSearchResult}
|
|
18
|
+
searchTerm={setSearchTerm}
|
|
19
|
+
/>
|
|
20
|
+
) : undefined}
|
|
21
|
+
{props.categories.map((category, categoryIndex) => (
|
|
22
|
+
<div key={categoryIndex}>
|
|
23
|
+
{category.header &&
|
|
24
|
+
category.options.length > 0 &&
|
|
25
|
+
searchTerm.length === 0 ? (
|
|
26
|
+
<Text
|
|
27
|
+
className={classNames('form-content__group-title', {
|
|
28
|
+
hidden: searchTerm.length > 0,
|
|
29
|
+
})}
|
|
30
|
+
theme={Text.themes.emphasis}
|
|
31
|
+
>
|
|
32
|
+
{category.header}
|
|
33
|
+
</Text>
|
|
34
|
+
) : undefined}
|
|
35
|
+
{category.options.map((radio, i) => {
|
|
36
|
+
const isInSearchResults =
|
|
37
|
+
searchTerm.length > 0
|
|
38
|
+
? searchResult?.find(
|
|
39
|
+
item =>
|
|
40
|
+
item.key.toLowerCase() === radio.value.toLowerCase(),
|
|
41
|
+
)
|
|
42
|
+
: undefined;
|
|
43
|
+
|
|
44
|
+
if (searchTerm.length > 0 && !isInSearchResults) return;
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<div key={i} className="form-content__radio-button">
|
|
48
|
+
<Radio {...radio} isUnderline={true} />
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
})}
|
|
52
|
+
</div>
|
|
53
|
+
))}
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export default RadioList;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import TextInput from '../text-input';
|
|
3
|
+
|
|
4
|
+
import { Range as Props } from './form-content.range.types';
|
|
5
|
+
|
|
6
|
+
const Range: React.FC<React.PropsWithChildren<Props>> = ({ max, min }) => {
|
|
7
|
+
return (
|
|
8
|
+
<div className="form-content__range">
|
|
9
|
+
<div className="form-content__range-input">
|
|
10
|
+
<TextInput {...min} type="number" />
|
|
11
|
+
</div>
|
|
12
|
+
<div className="form-content__range-line"></div>
|
|
13
|
+
<div className="form-content__range-input">
|
|
14
|
+
<TextInput {...max} type="number" />
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
17
|
+
);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default Range;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ContentKeys } from './form-content.types';
|
|
2
|
+
import type { TextInput } from '../text-input/text-input.types';
|
|
3
|
+
|
|
4
|
+
interface RangeInput extends TextInput {
|
|
5
|
+
min: number;
|
|
6
|
+
max: number;
|
|
7
|
+
defaultValue: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type Range = {
|
|
11
|
+
key: ContentKeys.Range;
|
|
12
|
+
max: RangeInput;
|
|
13
|
+
min: RangeInput;
|
|
14
|
+
};
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
@use '../../tokens/corner-radius';
|
|
2
|
+
@use '../../tokens/elevation';
|
|
3
|
+
@use '../../tokens/light';
|
|
4
|
+
@use '../../tokens/spacing';
|
|
5
|
+
|
|
6
|
+
.form-content {
|
|
7
|
+
$breakpoint: 1100px;
|
|
8
|
+
|
|
9
|
+
&__background-overlay {
|
|
10
|
+
pointer-events: none;
|
|
11
|
+
@media (min-width: $breakpoint) {
|
|
12
|
+
position: fixed;
|
|
13
|
+
width: 100%;
|
|
14
|
+
height: 100%;
|
|
15
|
+
top: 0;
|
|
16
|
+
left: 0;
|
|
17
|
+
background: light.$fixed-background-primary-default;
|
|
18
|
+
opacity: 0.2;
|
|
19
|
+
z-index: 400;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&__modal {
|
|
24
|
+
display: none;
|
|
25
|
+
|
|
26
|
+
&--open {
|
|
27
|
+
display: grid;
|
|
28
|
+
grid-template-rows: auto 1fr auto;
|
|
29
|
+
|
|
30
|
+
position: fixed;
|
|
31
|
+
width: 100%;
|
|
32
|
+
top: 0;
|
|
33
|
+
left: 0;
|
|
34
|
+
bottom: 0;
|
|
35
|
+
right: 0;
|
|
36
|
+
|
|
37
|
+
background-color: light.$surface-primary-default;
|
|
38
|
+
z-index: 500;
|
|
39
|
+
|
|
40
|
+
border-radius: corner-radius.$s;
|
|
41
|
+
@include elevation.level(2);
|
|
42
|
+
|
|
43
|
+
@media (min-width: $breakpoint) {
|
|
44
|
+
top: 10%;
|
|
45
|
+
left: 50%;
|
|
46
|
+
bottom: unset;
|
|
47
|
+
transform: translateX(-50%);
|
|
48
|
+
max-width: 870px;
|
|
49
|
+
min-height: 40vh;
|
|
50
|
+
max-height: 80vh;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
&__modal-content {
|
|
56
|
+
overflow-y: auto;
|
|
57
|
+
height: 100%;
|
|
58
|
+
|
|
59
|
+
border-radius: corner-radius.$s corner-radius.$s 0 0;
|
|
60
|
+
|
|
61
|
+
background: linear-gradient(white 30%, white) center top,
|
|
62
|
+
linear-gradient(white, white 70%) center bottom,
|
|
63
|
+
linear-gradient(rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0)) center top,
|
|
64
|
+
linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.05)) center bottom;
|
|
65
|
+
|
|
66
|
+
background-repeat: no-repeat;
|
|
67
|
+
background-size: 100% 20px, 100% 20px, 100% 14px, 100% 14px;
|
|
68
|
+
background-attachment: local, local, scroll, scroll;
|
|
69
|
+
|
|
70
|
+
@media (max-width: $breakpoint) {
|
|
71
|
+
border-radius: 0;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
&__modal-header {
|
|
76
|
+
display: grid;
|
|
77
|
+
grid-template-columns: 1fr auto;
|
|
78
|
+
align-items: center;
|
|
79
|
+
border-bottom: 1px solid light.$ge-divider-default;
|
|
80
|
+
padding: spacing.$s;
|
|
81
|
+
|
|
82
|
+
@media (min-width: $breakpoint) {
|
|
83
|
+
grid-template-columns: 1fr;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
&__modal-close-small {
|
|
88
|
+
@media (min-width: $breakpoint) {
|
|
89
|
+
display: none;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
&__modal-close-large {
|
|
94
|
+
display: none;
|
|
95
|
+
|
|
96
|
+
@media (min-width: $breakpoint) {
|
|
97
|
+
display: block;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
&__modal-title {
|
|
102
|
+
text-align: center;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
&__modal-action-wrapper {
|
|
106
|
+
border-top: 1px solid light.$ge-divider-default;
|
|
107
|
+
padding: spacing.$s;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
&__modal-actions {
|
|
111
|
+
display: grid;
|
|
112
|
+
gap: spacing.$s;
|
|
113
|
+
grid-auto-flow: column;
|
|
114
|
+
margin: auto;
|
|
115
|
+
width: 100%;
|
|
116
|
+
|
|
117
|
+
@media (min-width: $breakpoint) {
|
|
118
|
+
width: fit-content;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
&__fieldset {
|
|
123
|
+
border: 0;
|
|
124
|
+
padding: 0;
|
|
125
|
+
margin: 0;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
&__checkbox-button,
|
|
129
|
+
&__content-title {
|
|
130
|
+
margin: spacing.$m spacing.$l 0;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
&__radio-button {
|
|
134
|
+
// NOTE: Purposefully different from `&__checkbox-button` and `&__content-title`,
|
|
135
|
+
// ref. https://hfnswedenab.atlassian.net/browse/IAT-3537
|
|
136
|
+
margin: spacing.$s spacing.$l 0;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
&__checkbox-button {
|
|
140
|
+
&--nested {
|
|
141
|
+
margin-left: spacing.$xxl;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
&__search {
|
|
146
|
+
padding: 0 spacing.$m;
|
|
147
|
+
padding-top: spacing.$m;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
&__chevron-button-wrapper {
|
|
151
|
+
position: relative;
|
|
152
|
+
display: flex;
|
|
153
|
+
align-items: center;
|
|
154
|
+
margin: 0 spacing.$l;
|
|
155
|
+
border-bottom: 1px solid light.$ge-divider-default;
|
|
156
|
+
line-height: 0;
|
|
157
|
+
|
|
158
|
+
&--hidden {
|
|
159
|
+
display: none;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
&__chevron-button {
|
|
164
|
+
display: flex;
|
|
165
|
+
justify-content: space-between;
|
|
166
|
+
align-items: center;
|
|
167
|
+
background: none;
|
|
168
|
+
width: 100%;
|
|
169
|
+
margin-left: spacing.$xs;
|
|
170
|
+
color: light.$on-surface-primary-default;
|
|
171
|
+
border: none;
|
|
172
|
+
padding: spacing.$s 0;
|
|
173
|
+
padding-top: calc(spacing.$s + 2px);
|
|
174
|
+
font: inherit;
|
|
175
|
+
cursor: pointer;
|
|
176
|
+
outline: inherit;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
&__select-all-label {
|
|
180
|
+
text-align: left;
|
|
181
|
+
|
|
182
|
+
&--disabled {
|
|
183
|
+
color: light.$on-surface-primary-default;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
&__checkbox-category-info-wrapper {
|
|
188
|
+
display: flex;
|
|
189
|
+
gap: spacing.$s;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
&__checkbox-category-icon {
|
|
193
|
+
margin-left: spacing.$xs;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
&__checkbox-category-number {
|
|
197
|
+
border-radius: 100%;
|
|
198
|
+
color: light.$on-ge-on-tags-primary-default;
|
|
199
|
+
background: light.$ge-tags-primary;
|
|
200
|
+
width: 24px;
|
|
201
|
+
display: flex;
|
|
202
|
+
justify-content: center;
|
|
203
|
+
align-items: center;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
&__search-no-results {
|
|
207
|
+
display: flex;
|
|
208
|
+
flex-direction: column;
|
|
209
|
+
justify-content: center;
|
|
210
|
+
text-align: center;
|
|
211
|
+
padding: spacing.$m;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
&__search-no-results-text {
|
|
215
|
+
margin-bottom: spacing.$xs;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
&__range {
|
|
219
|
+
display: flex;
|
|
220
|
+
justify-content: center;
|
|
221
|
+
align-items: center;
|
|
222
|
+
padding: spacing.$m;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
&__range-line {
|
|
226
|
+
width: 21px;
|
|
227
|
+
border-bottom: 1px solid light.$ge-divider-alternate;
|
|
228
|
+
margin: 0 spacing.$m;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
&__range-input {
|
|
232
|
+
flex-grow: 1;
|
|
233
|
+
}
|
|
234
|
+
}
|