@luscii-healthtech/web-ui 2.9.0 → 2.10.2
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/components/Avatar/Avatar.d.ts +11 -11
- package/dist/components/CenteredHero/CenteredHero.d.ts +1 -1
- package/dist/components/Container/types/FlexContainerProps.type.d.ts +3 -2
- package/dist/components/Datepicker/Datepicker.d.ts +12 -11
- package/dist/components/Dropdown/Dropdown.d.ts +17 -7
- package/dist/components/ErrorBlock/ErrorBlock.d.ts +3 -3
- package/dist/components/Form/form.transformer.d.ts +3 -20
- package/dist/components/Form/form.types.d.ts +5 -5
- package/dist/components/InfoBlock/InfoBlock.d.ts +4 -4
- package/dist/components/Input/SearchInput.d.ts +1 -1
- package/dist/components/Line/Line.d.ts +4 -4
- package/dist/components/Menu/Menu.d.ts +6 -0
- package/dist/components/MultiSelect/MultiSelect.d.ts +7 -7
- package/dist/components/Page/CRUDPage.d.ts +13 -13
- package/dist/components/Page/Page.d.ts +13 -13
- package/dist/components/PaginationMenu/PaginationMenu.utils.d.ts +1 -1
- package/dist/components/Radio/Radio.d.ts +5 -1
- package/dist/components/RadioGroup/RadioGroup.d.ts +9 -10
- package/dist/components/Select/LegacySelect.d.ts +8 -9
- package/dist/components/Select/SelectV2.d.ts +1 -1
- package/dist/components/Switcher/Switcher.d.ts +6 -6
- package/dist/components/Switcher/SwitcherItem.d.ts +7 -7
- package/dist/components/Text/LegacyText.d.ts +18 -18
- package/dist/components/TextEditor/TextEditor.d.ts +4 -4
- package/dist/components/Textarea/Textarea.d.ts +16 -16
- package/dist/components/Title/LegacyTitle.d.ts +10 -10
- package/dist/web-ui-tailwind.css +8 -0
- package/dist/web-ui.cjs.development.js +81 -74
- package/dist/web-ui.cjs.development.js.map +1 -1
- package/dist/web-ui.cjs.production.min.js +1 -1
- package/dist/web-ui.cjs.production.min.js.map +1 -1
- package/dist/web-ui.esm.js +81 -74
- package/dist/web-ui.esm.js.map +1 -1
- package/package.json +7 -3
- package/src/assets/add.svg +0 -5
- package/src/assets/add_hover.svg +0 -4
- package/src/assets/arrow-down-icon.svg +0 -3
- package/src/assets/big-menu-icon-hover.svg +0 -6
- package/src/assets/big-menu-icon.svg +0 -6
- package/src/assets/check-cross-icon.svg +0 -7
- package/src/assets/check-icon-primary.svg +0 -5
- package/src/assets/check-icon.svg +0 -3
- package/src/assets/chevron-double.svg +0 -3
- package/src/assets/close.svg +0 -3
- package/src/assets/color-variant-cross.svg +0 -3
- package/src/assets/cross-dark.svg +0 -3
- package/src/assets/delete.svg +0 -4
- package/src/assets/delete_hover.svg +0 -4
- package/src/assets/edit.svg +0 -6
- package/src/assets/edit_hover.svg +0 -6
- package/src/assets/error-icon.svg +0 -7
- package/src/assets/grid-view-icon-active.svg +0 -6
- package/src/assets/grid-view-icon.svg +0 -6
- package/src/assets/groups.svg +0 -3
- package/src/assets/hamburger.svg +0 -5
- package/src/assets/happy-star.svg +0 -9
- package/src/assets/hcps.svg +0 -3
- package/src/assets/indeterminate-icon.svg +0 -3
- package/src/assets/info-icon.svg +0 -6
- package/src/assets/left-arrow-blue.svg +0 -3
- package/src/assets/left-arrow-grey.svg +0 -3
- package/src/assets/list-view-icon-active.svg +0 -3
- package/src/assets/list-view-icon.svg +0 -3
- package/src/assets/loading.svg +0 -16
- package/src/assets/modal-close-icon-active.svg +0 -9
- package/src/assets/modal-close-icon.svg +0 -9
- package/src/assets/no-open-alerts.svg +0 -19
- package/src/assets/patients.svg +0 -3
- package/src/assets/phone-mockup.svg +0 -9
- package/src/assets/programs.svg +0 -3
- package/src/assets/right-arrow-blue.svg +0 -3
- package/src/assets/right-arrow-grey.svg +0 -3
- package/src/assets/search-cancel.svg +0 -3
- package/src/assets/search-not-found.svg +0 -70
- package/src/assets/search.svg +0 -3
- package/src/assets/spinner-gray.svg +0 -6
- package/src/assets/spinner.svg +0 -5
- package/src/assets/starIcon.svg +0 -3
- package/src/assets/success-icon.svg +0 -6
- package/src/components/Accordion/Accordion.tsx +0 -33
- package/src/components/Accordion/AccordionItem.tsx +0 -50
- package/src/components/Avatar/Avatar.js +0 -81
- package/src/components/Avatar/Avatar.scss +0 -153
- package/src/components/Badge/Badge.tsx +0 -23
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +0 -46
- package/src/components/Button/Button.examples.md +0 -46
- package/src/components/Button/Button.tsx +0 -200
- package/src/components/Button/Button.types.ts +0 -41
- package/src/components/Button/ButtonIcon.tsx +0 -42
- package/src/components/ButtonV2/ButtonProps.type.ts +0 -44
- package/src/components/ButtonV2/ButtonV2.tsx +0 -97
- package/src/components/ButtonV2/PrimaryButton.tsx +0 -25
- package/src/components/ButtonV2/SecondaryButton.tsx +0 -26
- package/src/components/ButtonV2/TertiaryButton.tsx +0 -26
- package/src/components/Carousel/Carousel.tsx +0 -52
- package/src/components/Carousel/GliderContainer.scss +0 -13
- package/src/components/Carousel/GliderContainer.tsx +0 -22
- package/src/components/CenteredHero/CenteredHero.tsx +0 -63
- package/src/components/CheckBoxListModal/CheckboxListModal.tsx +0 -180
- package/src/components/Checkbox/Checkbox.scss +0 -125
- package/src/components/Checkbox/Checkbox.tsx +0 -147
- package/src/components/CheckboxList/CheckboxGroup.tsx +0 -120
- package/src/components/CheckboxList/CheckboxList.tsx +0 -46
- package/src/components/CheckboxList/CheckboxList.types.ts +0 -47
- package/src/components/CheckboxList/CheckboxListItem.tsx +0 -54
- package/src/components/ConfirmationDialog/ConfirmationDialog.scss +0 -15
- package/src/components/ConfirmationDialog/ConfirmationDialog.tsx +0 -84
- package/src/components/Container/FlexColumn.tsx +0 -18
- package/src/components/Container/FlexContainer.tsx +0 -46
- package/src/components/Container/FlexRow.tsx +0 -18
- package/src/components/Container/types/FlexContainerProps.type.ts +0 -18
- package/src/components/Datepicker/Datepicker.js +0 -96
- package/src/components/Datepicker/Datepicker.scss +0 -332
- package/src/components/Dropdown/Dropdown.js +0 -416
- package/src/components/Dropdown/Dropdown.scss +0 -83
- package/src/components/EmptyListMessage/EmptyListMessage.tsx +0 -34
- package/src/components/ErrorBlock/ErrorBlock.js +0 -24
- package/src/components/ErrorBlock/ErrorBlock.scss +0 -20
- package/src/components/Form/Form.tsx +0 -138
- package/src/components/Form/FormFieldDecorator.tsx +0 -66
- package/src/components/Form/FormInput.tsx +0 -47
- package/src/components/Form/FormRadioGroup.tsx +0 -23
- package/src/components/Form/FormSelect.tsx +0 -32
- package/src/components/Form/form.transformer.ts +0 -9
- package/src/components/Form/form.types.ts +0 -139
- package/src/components/Icons/AddIcon.tsx +0 -29
- package/src/components/Icons/AlertsIcon.tsx +0 -39
- package/src/components/Icons/BellIcon.tsx +0 -39
- package/src/components/Icons/ChartIcon.tsx +0 -22
- package/src/components/Icons/ChatBoxIcon.tsx +0 -23
- package/src/components/Icons/CheckIcon.tsx +0 -26
- package/src/components/Icons/ChevronDoubleIcon.tsx +0 -25
- package/src/components/Icons/ChevronDownIcon.tsx +0 -20
- package/src/components/Icons/ChevronRightIcon.tsx +0 -20
- package/src/components/Icons/CrossIcon.tsx +0 -24
- package/src/components/Icons/DeleteIcon.tsx +0 -23
- package/src/components/Icons/DownArrowIcon.tsx +0 -23
- package/src/components/Icons/DragIcon.tsx +0 -25
- package/src/components/Icons/DynamicIcon.tsx +0 -25
- package/src/components/Icons/EditIcon.tsx +0 -23
- package/src/components/Icons/EmptyIcon.tsx +0 -29
- package/src/components/Icons/EmptyStateDashboardIcon.tsx +0 -130
- package/src/components/Icons/ExclamationMarkIcon.tsx +0 -23
- package/src/components/Icons/EyeIcon.tsx +0 -23
- package/src/components/Icons/GearIcon.tsx +0 -23
- package/src/components/Icons/GroupIcon.tsx +0 -23
- package/src/components/Icons/HamburgerIcon.tsx +0 -31
- package/src/components/Icons/HeartIcon.tsx +0 -23
- package/src/components/Icons/ImageIcon.tsx +0 -23
- package/src/components/Icons/LeftArrowIcon.tsx +0 -23
- package/src/components/Icons/LightBulbIcon.tsx +0 -31
- package/src/components/Icons/LockIcon.tsx +0 -23
- package/src/components/Icons/MessagesIcon.tsx +0 -23
- package/src/components/Icons/NotesIcon.tsx +0 -23
- package/src/components/Icons/PinIcon.tsx +0 -23
- package/src/components/Icons/PrintIcon.tsx +0 -22
- package/src/components/Icons/RightArrowIcon.tsx +0 -23
- package/src/components/Icons/SearchCancelIcon.tsx +0 -23
- package/src/components/Icons/SearchIcon.tsx +0 -23
- package/src/components/Icons/SmallCircleIcon.tsx +0 -21
- package/src/components/Icons/SmallDiamondIcon.tsx +0 -31
- package/src/components/Icons/SmallSquareIcon.tsx +0 -21
- package/src/components/Icons/SpaceRocketIcon.tsx +0 -23
- package/src/components/Icons/StarIcon.tsx +0 -23
- package/src/components/Icons/WarningIcon.tsx +0 -24
- package/src/components/Icons/types/IconProps.type.ts +0 -5
- package/src/components/InfoBlock/InfoBlock.js +0 -24
- package/src/components/InfoBlock/InfoBlock.scss +0 -20
- package/src/components/InfoField/InfoField.tsx +0 -94
- package/src/components/Input/Input.css +0 -3
- package/src/components/Input/Input.tsx +0 -211
- package/src/components/Input/SearchInput.tsx +0 -24
- package/src/components/Line/Line.js +0 -38
- package/src/components/List/List.scss +0 -23
- package/src/components/List/List.tsx +0 -138
- package/src/components/List/List.types.ts +0 -41
- package/src/components/List/ListItem.tsx +0 -89
- package/src/components/List/ListItemSkeleton.tsx +0 -26
- package/src/components/List/ListSkeleton.scss +0 -5
- package/src/components/List/ListSkeleton.tsx +0 -30
- package/src/components/LoadingIndicator/LoadingIndicator.scss +0 -50
- package/src/components/LoadingIndicator/LoadingIndicator.tsx +0 -46
- package/src/components/Menu/Menu.js +0 -74
- package/src/components/Menu/Menu.scss +0 -27
- package/src/components/Modal/Modal.scss +0 -117
- package/src/components/Modal/Modal.tsx +0 -104
- package/src/components/Modal/ModalWithButtons.tsx +0 -34
- package/src/components/MultiSelect/MultiSelect.js +0 -117
- package/src/components/MultiSelect/MultiSelect.scss +0 -29
- package/src/components/MultiSelect/MultiSelectUtils.js +0 -23
- package/src/components/NavMenu/NavLayout.tsx +0 -40
- package/src/components/NavMenu/NavMenu.tsx +0 -39
- package/src/components/NavMenu/NavMenu.utils.ts +0 -6
- package/src/components/NavMenu/NavMenuContent.tsx +0 -23
- package/src/components/NavMenu/NavMenuItem.tsx +0 -102
- package/src/components/NotificationBanner/NotificationBanner.tsx +0 -104
- package/src/components/Page/CRUDPage.js +0 -123
- package/src/components/Page/CRUDPage.scss +0 -32
- package/src/components/Page/Page.js +0 -102
- package/src/components/Page/Page.scss +0 -59
- package/src/components/PageHeader/PageHeader.tsx +0 -51
- package/src/components/PaginationMenu/PaginationMenu.tsx +0 -47
- package/src/components/PaginationMenu/PaginationMenu.types.ts +0 -46
- package/src/components/PaginationMenu/PaginationMenu.utils.ts +0 -49
- package/src/components/PaginationMenu/PaginationMenuLarge.tsx +0 -96
- package/src/components/PaginationMenu/PaginationMenuSmall.tsx +0 -43
- package/src/components/PreviewPhone/PreviewPhone.tsx +0 -52
- package/src/components/PreviewPhone/useWindowDimensions.js +0 -26
- package/src/components/Radio/Radio.js +0 -102
- package/src/components/Radio/Radio.scss +0 -58
- package/src/components/Radio/RadioV2.css +0 -15
- package/src/components/Radio/RadioV2.tsx +0 -87
- package/src/components/RadioGroup/RadioGroup.js +0 -66
- package/src/components/RadioGroup/RadioGroup.scss +0 -37
- package/src/components/RadioGroup/RadioGroupV2.tsx +0 -35
- package/src/components/Section/Section.scss +0 -74
- package/src/components/Section/Section.tsx +0 -68
- package/src/components/Section/SectionItem.scss +0 -20
- package/src/components/Section/SectionItem.tsx +0 -26
- package/src/components/Section/SectionItemWithContent.tsx +0 -30
- package/src/components/Select/LegacySelect.js +0 -114
- package/src/components/Select/Select.scss +0 -29
- package/src/components/Select/Select.tsx +0 -151
- package/src/components/Select/SelectV2.tsx +0 -171
- package/src/components/Select/options.transformer.ts +0 -36
- package/src/components/Select/select.utils.spec.ts +0 -63
- package/src/components/Select/select.utils.ts +0 -45
- package/src/components/SettingsMenuButton/SettingsMenuButton.tsx +0 -111
- package/src/components/Spinner/Spinner.tsx +0 -23
- package/src/components/Steps/Step.tsx +0 -31
- package/src/components/Steps/Steps.tsx +0 -24
- package/src/components/Switcher/Switcher.js +0 -58
- package/src/components/Switcher/SwitcherItem.js +0 -61
- package/src/components/Switcher/SwitcherItem.scss +0 -67
- package/src/components/TabLinks/TabLinks.tsx +0 -63
- package/src/components/Tabbar/Tabbar.tsx +0 -60
- package/src/components/Tabbar/TabbarItem.tsx +0 -66
- package/src/components/Table/Table.tsx +0 -91
- package/src/components/Table/Table.types.ts +0 -28
- package/src/components/Table/Table.utils.ts +0 -23
- package/src/components/Table/TableBody.tsx +0 -57
- package/src/components/Table/TableBodyRow.tsx +0 -47
- package/src/components/Table/TableBodyRowDataCell.tsx +0 -76
- package/src/components/Table/TableFooter.tsx +0 -21
- package/src/components/Table/TableHeader.tsx +0 -28
- package/src/components/Tag/Tag.tsx +0 -58
- package/src/components/Tag/Tag.utils.ts +0 -4
- package/src/components/Tag/TagGroup.tsx +0 -29
- package/src/components/Text/LegacyText.js +0 -78
- package/src/components/Text/Text.scss +0 -67
- package/src/components/Text/Text.tsx +0 -131
- package/src/components/TextEditor/TextEditor.js +0 -61
- package/src/components/TextEditor/TextEditor.scss +0 -14
- package/src/components/TextEditorV2/TextEditorV2.js +0 -52
- package/src/components/TextEditorV2/TextEditorV2.scss +0 -110
- package/src/components/TextLink/TextLink.tsx +0 -42
- package/src/components/Textarea/Textarea.js +0 -108
- package/src/components/Textarea/Textarea.scss +0 -56
- package/src/components/Timeline/Timeline.tsx +0 -28
- package/src/components/Timeline/TimelineStep.tsx +0 -36
- package/src/components/Title/LegacyTitle.js +0 -64
- package/src/components/Title/Title.scss +0 -6
- package/src/components/Title/Title.tsx +0 -62
- package/src/components/Toaster/Toaster.scss +0 -57
- package/src/components/Toaster/Toaster.tsx +0 -100
- package/src/components/Toaster/toast-elements-getter.ts +0 -72
- package/src/components/Toaster/toast-progress-animator.ts +0 -53
- package/src/components/Toaster/toast.ts +0 -112
- package/src/components/ViewItem/ViewItem.tsx +0 -85
- package/src/custom.d.ts +0 -4
- package/src/index.tsx +0 -170
- package/src/styles/_colors.scss +0 -59
- package/src/styles/_layout.scss +0 -64
- package/src/styles/_shadows.scss +0 -19
- package/src/styles/_skeleton.scss +0 -63
- package/src/styles/_typography.scss +0 -8
- package/src/styles/_utils.scss +0 -45
- package/src/styles/fonts/avenir/3A0AF8_0_0.eot +0 -0
- package/src/styles/fonts/avenir/3A0AF8_0_0.ttf +0 -0
- package/src/styles/fonts/avenir/3A0AF8_0_0.woff +0 -0
- package/src/styles/fonts/avenir/3A0AF8_0_0.woff2 +0 -0
- package/src/styles/fonts/avenir/3A0AF8_1_0.eot +0 -0
- package/src/styles/fonts/avenir/3A0AF8_1_0.ttf +0 -0
- package/src/styles/fonts/avenir/3A0AF8_1_0.woff +0 -0
- package/src/styles/fonts/avenir/3A0AF8_1_0.woff2 +0 -0
- package/src/types/general.types.ts +0 -11
- package/src/utils/useOutsideClick.js +0 -19
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState } from "react";
|
|
2
|
-
import classNames from "classnames";
|
|
3
|
-
|
|
4
|
-
import { Text } from "../Text/Text";
|
|
5
|
-
|
|
6
|
-
import "./Checkbox.scss";
|
|
7
|
-
|
|
8
|
-
export interface CheckboxProps {
|
|
9
|
-
id?: string;
|
|
10
|
-
// The label that will be presented as a Text
|
|
11
|
-
text?: string;
|
|
12
|
-
// The explanation that will be presented below it
|
|
13
|
-
explanation?: string;
|
|
14
|
-
type?: "regular" | "switch";
|
|
15
|
-
// Set the value
|
|
16
|
-
isChecked?: boolean;
|
|
17
|
-
//Value for when it is not clear if state is checked or not (for hierarchical checkboxes)
|
|
18
|
-
isIndeterminate?: boolean;
|
|
19
|
-
// Allow the user to change the input
|
|
20
|
-
isDisabled?: boolean;
|
|
21
|
-
name?: string;
|
|
22
|
-
// This can be used to retrieve the value it is referring to through onChange
|
|
23
|
-
value?: string;
|
|
24
|
-
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
25
|
-
className?: string;
|
|
26
|
-
error?: boolean;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export const Checkbox = ({
|
|
30
|
-
id,
|
|
31
|
-
text,
|
|
32
|
-
explanation,
|
|
33
|
-
type = "regular",
|
|
34
|
-
isChecked = false,
|
|
35
|
-
isIndeterminate = false,
|
|
36
|
-
isDisabled,
|
|
37
|
-
name,
|
|
38
|
-
value,
|
|
39
|
-
onChange,
|
|
40
|
-
className,
|
|
41
|
-
error,
|
|
42
|
-
}: CheckboxProps): JSX.Element => {
|
|
43
|
-
const [checked, setChecked] = useState(false);
|
|
44
|
-
const [indeterminate, setIndeterminate] = useState(false);
|
|
45
|
-
const [isFocused, setIsFocused] = useState(false);
|
|
46
|
-
const checkboxRef = React.useRef<HTMLInputElement>(null);
|
|
47
|
-
|
|
48
|
-
const containerClassName = classNames("cweb-checkbox", className, {
|
|
49
|
-
"is-focused": isFocused,
|
|
50
|
-
"is-checked": checked && !indeterminate,
|
|
51
|
-
"is-indeterminate": indeterminate,
|
|
52
|
-
"opacity-50 cursor-not-allowed is-disabled": isDisabled,
|
|
53
|
-
"type-regular": type === "regular",
|
|
54
|
-
"type-switch": type === "switch",
|
|
55
|
-
hasError: error,
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
useEffect(() => {
|
|
59
|
-
setChecked(isChecked);
|
|
60
|
-
setIndeterminate(false);
|
|
61
|
-
}, [isChecked]);
|
|
62
|
-
|
|
63
|
-
useEffect(() => {
|
|
64
|
-
setIndeterminate(isIndeterminate);
|
|
65
|
-
}, [isIndeterminate]);
|
|
66
|
-
|
|
67
|
-
useEffect(() => {
|
|
68
|
-
if (checkboxRef?.current) {
|
|
69
|
-
checkboxRef.current.indeterminate = !indeterminate;
|
|
70
|
-
}
|
|
71
|
-
}, [indeterminate]);
|
|
72
|
-
|
|
73
|
-
const handleChange = event => {
|
|
74
|
-
event.stopPropagation();
|
|
75
|
-
setIndeterminate(false);
|
|
76
|
-
if (onChange) {
|
|
77
|
-
onChange(event);
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
const handleFocus = () => setIsFocused(true);
|
|
82
|
-
|
|
83
|
-
const handleBlur = () => setIsFocused(false);
|
|
84
|
-
|
|
85
|
-
return (
|
|
86
|
-
<div className={containerClassName} data-test-id="checkbox">
|
|
87
|
-
<label
|
|
88
|
-
className="cweb-checkbox-label"
|
|
89
|
-
data-test-id="checkbox-label"
|
|
90
|
-
onClick={e => e.stopPropagation()}
|
|
91
|
-
>
|
|
92
|
-
<input
|
|
93
|
-
id={id}
|
|
94
|
-
ref={checkboxRef}
|
|
95
|
-
data-test-id={`checkbox-${name}`}
|
|
96
|
-
className="cweb-checkbox-input"
|
|
97
|
-
name={name}
|
|
98
|
-
type="checkbox"
|
|
99
|
-
checked={checked}
|
|
100
|
-
disabled={isDisabled}
|
|
101
|
-
value={value}
|
|
102
|
-
onBlur={handleBlur}
|
|
103
|
-
onFocus={handleFocus}
|
|
104
|
-
onChange={handleChange}
|
|
105
|
-
/>
|
|
106
|
-
|
|
107
|
-
<span
|
|
108
|
-
className={classNames(
|
|
109
|
-
"cweb-checkbox-icon-container",
|
|
110
|
-
"transition-colors duration-300",
|
|
111
|
-
{
|
|
112
|
-
"bg-primary": checked || indeterminate,
|
|
113
|
-
"bg-white": !checked && !indeterminate,
|
|
114
|
-
"hover:bg-primary-dark": checked || indeterminate,
|
|
115
|
-
"outline-primary": isFocused,
|
|
116
|
-
"cursor-not-allowed": isDisabled,
|
|
117
|
-
"cursor-pointer": !isDisabled,
|
|
118
|
-
}
|
|
119
|
-
)}
|
|
120
|
-
data-test-id="checkbox-span"
|
|
121
|
-
>
|
|
122
|
-
<span className="cweb-checkbox-icon" />
|
|
123
|
-
</span>
|
|
124
|
-
|
|
125
|
-
<div className="flex flex-col">
|
|
126
|
-
{text && (
|
|
127
|
-
<Text
|
|
128
|
-
className="ml-2 text-left select-none"
|
|
129
|
-
text={text}
|
|
130
|
-
data-test-id="checkbox-text"
|
|
131
|
-
/>
|
|
132
|
-
)}
|
|
133
|
-
{explanation && (
|
|
134
|
-
<Text
|
|
135
|
-
className="ml-2 text-left select-none"
|
|
136
|
-
text={explanation}
|
|
137
|
-
color={"slate-500"}
|
|
138
|
-
data-test-id="checkbox-explanation"
|
|
139
|
-
/>
|
|
140
|
-
)}
|
|
141
|
-
</div>
|
|
142
|
-
</label>
|
|
143
|
-
</div>
|
|
144
|
-
);
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
export default Checkbox;
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState } from "react";
|
|
2
|
-
import classNames from "classnames";
|
|
3
|
-
|
|
4
|
-
import { Text } from "../Text/Text";
|
|
5
|
-
import { Checkbox } from "../..";
|
|
6
|
-
import { ChevronRightIcon } from "../Icons/ChevronRightIcon";
|
|
7
|
-
import { ChevronDownIcon } from "../Icons/ChevronDownIcon";
|
|
8
|
-
|
|
9
|
-
import { CheckboxGroupProps, CheckboxState } from "./CheckboxList.types";
|
|
10
|
-
import { CheckboxListItem } from "./CheckboxListItem";
|
|
11
|
-
|
|
12
|
-
export const CheckboxGroup = ({
|
|
13
|
-
title,
|
|
14
|
-
items,
|
|
15
|
-
onChange,
|
|
16
|
-
className,
|
|
17
|
-
isCollapsed = true,
|
|
18
|
-
}: CheckboxGroupProps): JSX.Element => {
|
|
19
|
-
const [groupCheckboxState, setGroupCheckboxState] = useState<CheckboxState>(
|
|
20
|
-
CheckboxState.UNCHECKED
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
const [collapsed, setCollapsed] = useState(isCollapsed);
|
|
24
|
-
|
|
25
|
-
useEffect(() => {
|
|
26
|
-
if (items?.length > 0) {
|
|
27
|
-
const indeterminate = items.some(
|
|
28
|
-
(item) => item.isChecked !== items[0].isChecked
|
|
29
|
-
);
|
|
30
|
-
if (!indeterminate && items[0].isChecked) {
|
|
31
|
-
setGroupCheckboxState(CheckboxState.CHECKED);
|
|
32
|
-
} else if (!indeterminate && !items[0].isChecked) {
|
|
33
|
-
setGroupCheckboxState(CheckboxState.UNCHECKED);
|
|
34
|
-
} else {
|
|
35
|
-
setGroupCheckboxState(CheckboxState.INDETERMINATE);
|
|
36
|
-
}
|
|
37
|
-
} else {
|
|
38
|
-
setGroupCheckboxState(CheckboxState.UNCHECKED);
|
|
39
|
-
}
|
|
40
|
-
}, [items]);
|
|
41
|
-
|
|
42
|
-
const handleGroupClick = (
|
|
43
|
-
event:
|
|
44
|
-
| React.MouseEvent<HTMLDivElement>
|
|
45
|
-
| React.ChangeEvent<HTMLInputElement>
|
|
46
|
-
) => {
|
|
47
|
-
event.stopPropagation();
|
|
48
|
-
|
|
49
|
-
if (
|
|
50
|
-
(groupCheckboxState === CheckboxState.CHECKED ||
|
|
51
|
-
groupCheckboxState === CheckboxState.INDETERMINATE) &&
|
|
52
|
-
onChange
|
|
53
|
-
) {
|
|
54
|
-
//if checked or indeterminate >> make all items unchecked
|
|
55
|
-
items.forEach((item) =>
|
|
56
|
-
onChange({ id: item.id, newCheckedValue: false })
|
|
57
|
-
);
|
|
58
|
-
} else if (onChange) {
|
|
59
|
-
// else if unchecked >> make all items checked
|
|
60
|
-
items.forEach((item) => onChange({ id: item.id, newCheckedValue: true }));
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const handleGroupCollapse = (
|
|
65
|
-
event:
|
|
66
|
-
| React.MouseEvent<HTMLDivElement>
|
|
67
|
-
| React.MouseEvent<SVGSVGElement>
|
|
68
|
-
| undefined
|
|
69
|
-
) => {
|
|
70
|
-
if (event) {
|
|
71
|
-
event.stopPropagation();
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
setCollapsed(!collapsed);
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
const checkedItemsCount = items?.filter((item) => item?.isChecked).length;
|
|
78
|
-
const groupTitle =
|
|
79
|
-
checkedItemsCount > 0 ? `${title} (${checkedItemsCount})` : title;
|
|
80
|
-
|
|
81
|
-
return (
|
|
82
|
-
<div className={classNames("flex flex-col", className)}>
|
|
83
|
-
{title && (
|
|
84
|
-
<div className={"flex flex-row my-1 items-center w-full space-between"}>
|
|
85
|
-
<div
|
|
86
|
-
className={
|
|
87
|
-
"h-6 cursor-pointer mr-auto flex flex-row items-center text-slate-300 hover:text-slate-500 transition duration-300"
|
|
88
|
-
}
|
|
89
|
-
onClick={handleGroupCollapse}
|
|
90
|
-
>
|
|
91
|
-
{collapsed ? (
|
|
92
|
-
<ChevronRightIcon onClick={handleGroupCollapse} />
|
|
93
|
-
) : (
|
|
94
|
-
<ChevronDownIcon onClick={handleGroupCollapse} />
|
|
95
|
-
)}
|
|
96
|
-
<Text type={"strong"} text={groupTitle || ""} className={" ml-4"} />{" "}
|
|
97
|
-
</div>
|
|
98
|
-
<Checkbox
|
|
99
|
-
onChange={handleGroupClick}
|
|
100
|
-
className={"ml-auto"}
|
|
101
|
-
isChecked={groupCheckboxState === CheckboxState.CHECKED}
|
|
102
|
-
isIndeterminate={groupCheckboxState === CheckboxState.INDETERMINATE}
|
|
103
|
-
/>
|
|
104
|
-
</div>
|
|
105
|
-
)}
|
|
106
|
-
|
|
107
|
-
{!collapsed &&
|
|
108
|
-
items.map((item) => (
|
|
109
|
-
<CheckboxListItem
|
|
110
|
-
key={item.id}
|
|
111
|
-
id={item.id}
|
|
112
|
-
label={item.label}
|
|
113
|
-
onChange={onChange}
|
|
114
|
-
isChecked={item.isChecked}
|
|
115
|
-
className={"ml-10 my-1"}
|
|
116
|
-
/>
|
|
117
|
-
))}
|
|
118
|
-
</div>
|
|
119
|
-
);
|
|
120
|
-
};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import classNames from "classnames";
|
|
3
|
-
|
|
4
|
-
import { CheckboxListItem } from "./CheckboxListItem";
|
|
5
|
-
import { CheckboxListProps } from "./CheckboxList.types";
|
|
6
|
-
import { CheckboxGroup } from "./CheckboxGroup";
|
|
7
|
-
|
|
8
|
-
export { CheckboxListProps };
|
|
9
|
-
|
|
10
|
-
export const CheckboxList = ({
|
|
11
|
-
groups,
|
|
12
|
-
onChange,
|
|
13
|
-
className,
|
|
14
|
-
}: CheckboxListProps): JSX.Element => {
|
|
15
|
-
return (
|
|
16
|
-
<div className={classNames("flex flex-col", className)}>
|
|
17
|
-
{groups?.length > 0 &&
|
|
18
|
-
groups.map((group) => {
|
|
19
|
-
if (group.title) {
|
|
20
|
-
return (
|
|
21
|
-
<CheckboxGroup
|
|
22
|
-
key={group.title}
|
|
23
|
-
items={group.items}
|
|
24
|
-
title={group.title}
|
|
25
|
-
isCollapsed={group.isCollapsed}
|
|
26
|
-
onChange={onChange}
|
|
27
|
-
/>
|
|
28
|
-
);
|
|
29
|
-
} else {
|
|
30
|
-
return group.items.map((item) => (
|
|
31
|
-
<CheckboxListItem
|
|
32
|
-
key={item.id}
|
|
33
|
-
id={item.id}
|
|
34
|
-
label={item.label}
|
|
35
|
-
onChange={onChange}
|
|
36
|
-
isChecked={item.isChecked}
|
|
37
|
-
className={"my-1"}
|
|
38
|
-
/>
|
|
39
|
-
));
|
|
40
|
-
}
|
|
41
|
-
})}
|
|
42
|
-
</div>
|
|
43
|
-
);
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export default CheckboxList;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
export enum CheckboxState {
|
|
2
|
-
CHECKED = "checked",
|
|
3
|
-
INDETERMINATE = "indeterminate",
|
|
4
|
-
UNCHECKED = "unchecked",
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export interface CheckboxListProps {
|
|
8
|
-
groups: CheckboxGroup[];
|
|
9
|
-
onChange: (event: CheckboxChangeEvent) => void;
|
|
10
|
-
className?: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface CheckboxGroupProps {
|
|
14
|
-
//If you don't specify a title than it will just be a non-collapsible list
|
|
15
|
-
title?: string;
|
|
16
|
-
items: CheckboxListItem[];
|
|
17
|
-
onChange: (event: CheckboxChangeEvent) => void;
|
|
18
|
-
className?: string;
|
|
19
|
-
isCollapsed?: boolean;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface CheckboxGroupItemProps {
|
|
23
|
-
id: string;
|
|
24
|
-
label: string;
|
|
25
|
-
isChecked?: boolean;
|
|
26
|
-
onChange: (event: CheckboxChangeEvent) => void;
|
|
27
|
-
className?: string;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface CheckboxListItem {
|
|
31
|
-
id: string;
|
|
32
|
-
label: string;
|
|
33
|
-
isChecked?: boolean;
|
|
34
|
-
className?: string;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface CheckboxGroup {
|
|
38
|
-
//If you don't specify a title than it will just be a non-collapsible list
|
|
39
|
-
title?: string;
|
|
40
|
-
items: CheckboxListItem[];
|
|
41
|
-
isCollapsed?: boolean;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export interface CheckboxChangeEvent {
|
|
45
|
-
id: string;
|
|
46
|
-
newCheckedValue: boolean;
|
|
47
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState } from "react";
|
|
2
|
-
import classNames from "classnames";
|
|
3
|
-
|
|
4
|
-
import { Text } from "../Text/Text";
|
|
5
|
-
import { Checkbox } from "../Checkbox/Checkbox";
|
|
6
|
-
|
|
7
|
-
import { CheckboxGroupItemProps } from "./CheckboxList.types";
|
|
8
|
-
|
|
9
|
-
export const CheckboxListItem = ({
|
|
10
|
-
id,
|
|
11
|
-
label,
|
|
12
|
-
isChecked,
|
|
13
|
-
onChange,
|
|
14
|
-
className,
|
|
15
|
-
}: CheckboxGroupItemProps): JSX.Element => {
|
|
16
|
-
const [checked, setChecked] = useState(isChecked || false);
|
|
17
|
-
|
|
18
|
-
useEffect(() => {
|
|
19
|
-
setChecked(isChecked || false);
|
|
20
|
-
}, [isChecked]);
|
|
21
|
-
|
|
22
|
-
const handleItemClick = (event: React.MouseEvent<HTMLDivElement>) => {
|
|
23
|
-
event.stopPropagation();
|
|
24
|
-
|
|
25
|
-
if (onChange) {
|
|
26
|
-
onChange({ id, newCheckedValue: !checked });
|
|
27
|
-
}
|
|
28
|
-
setChecked(!checked);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const handleCheckboxClick = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
32
|
-
event.stopPropagation();
|
|
33
|
-
const targetId = event.target.id;
|
|
34
|
-
const newCheckedValue = event.target.checked;
|
|
35
|
-
|
|
36
|
-
if (onChange) {
|
|
37
|
-
onChange({ id: targetId, newCheckedValue });
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
return (
|
|
42
|
-
<div
|
|
43
|
-
className={classNames(
|
|
44
|
-
"flex flex-row space-between cursor-pointer",
|
|
45
|
-
className
|
|
46
|
-
)}
|
|
47
|
-
item-id={id}
|
|
48
|
-
onClick={handleItemClick}
|
|
49
|
-
>
|
|
50
|
-
<Text text={label} className={"mr-auto"} />
|
|
51
|
-
<Checkbox isChecked={checked} onChange={handleCheckboxClick} id={id} />
|
|
52
|
-
</div>
|
|
53
|
-
);
|
|
54
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
@import "../../styles/layout";
|
|
2
|
-
|
|
3
|
-
.vitals-confirmation-dialog {
|
|
4
|
-
margin-top: 4rem !important;
|
|
5
|
-
|
|
6
|
-
.vitals-confirmation-dialog-content {
|
|
7
|
-
padding: 24px;
|
|
8
|
-
|
|
9
|
-
.vitals-confirmation-dialog-action-container {
|
|
10
|
-
@include flexbox-horizontal(center, space-between);
|
|
11
|
-
width: 100%;
|
|
12
|
-
margin-top: 16px;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import classNames from "classnames";
|
|
3
|
-
|
|
4
|
-
import Button, { BUTTON_ROLES } from "../Button/Button";
|
|
5
|
-
import "./ConfirmationDialog.scss";
|
|
6
|
-
import { ModalWithButtons } from "../Modal/ModalWithButtons";
|
|
7
|
-
import { MODAL_SIZES, MODAL_SIZES_VALUES } from "../Modal/Modal";
|
|
8
|
-
import Text from "../Text/Text";
|
|
9
|
-
import { BUTTON_TYPE } from "../Button/Button.types";
|
|
10
|
-
|
|
11
|
-
interface ConfirmationDialogTexts {
|
|
12
|
-
message: string;
|
|
13
|
-
confirmLabel: string;
|
|
14
|
-
cancelLabel: string;
|
|
15
|
-
title?: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
interface ConfirmationDialogProps {
|
|
19
|
-
texts: ConfirmationDialogTexts;
|
|
20
|
-
isOpen: boolean;
|
|
21
|
-
onCancel: () => void;
|
|
22
|
-
onConfirm: () => void;
|
|
23
|
-
isProcessing: boolean;
|
|
24
|
-
cancelButtonRole: BUTTON_TYPE;
|
|
25
|
-
confirmButtonRole: BUTTON_TYPE;
|
|
26
|
-
size: MODAL_SIZES_VALUES;
|
|
27
|
-
showHeader: boolean;
|
|
28
|
-
className?: string;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export const ConfirmationDialog = (props: ConfirmationDialogProps): JSX.Element => {
|
|
32
|
-
const calculatedClassNames = classNames("vitals-confirmation-dialog", props.className);
|
|
33
|
-
|
|
34
|
-
const handleOnCloseClick = () => {
|
|
35
|
-
if (!props.isProcessing) {
|
|
36
|
-
props.onCancel();
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const modalButtons: [JSX.Element, JSX.Element?] = [
|
|
41
|
-
<Button
|
|
42
|
-
key="confirmation-dialog-button-cancel"
|
|
43
|
-
data-test-id="button-cancel"
|
|
44
|
-
text={props.texts.cancelLabel}
|
|
45
|
-
onClick={props.onCancel}
|
|
46
|
-
isDisabled={props.isProcessing}
|
|
47
|
-
role={props.cancelButtonRole}
|
|
48
|
-
/>,
|
|
49
|
-
<Button
|
|
50
|
-
key="confirmation-dialog-button-confirm"
|
|
51
|
-
className="ml-2.5"
|
|
52
|
-
data-test-id="button-confirm"
|
|
53
|
-
text={props.texts.confirmLabel}
|
|
54
|
-
onClick={props.onConfirm}
|
|
55
|
-
isPending={props.isProcessing}
|
|
56
|
-
/>,
|
|
57
|
-
];
|
|
58
|
-
|
|
59
|
-
return (
|
|
60
|
-
<ModalWithButtons
|
|
61
|
-
type={props.size}
|
|
62
|
-
className={calculatedClassNames}
|
|
63
|
-
isOpen={props.isOpen}
|
|
64
|
-
title={props.texts.title}
|
|
65
|
-
onCloseClick={handleOnCloseClick}
|
|
66
|
-
shouldCloseOnOverlayClick={!props.isProcessing}
|
|
67
|
-
showHeader={props.showHeader}
|
|
68
|
-
buttons={modalButtons}
|
|
69
|
-
buttonsAlignment="justify-end"
|
|
70
|
-
>
|
|
71
|
-
<div className="vitals-confirmation-dialog-content">
|
|
72
|
-
<Text text={props.texts.message} containsDangerousHtml={true} />
|
|
73
|
-
</div>
|
|
74
|
-
</ModalWithButtons>
|
|
75
|
-
);
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
ConfirmationDialog.defaultProps = {
|
|
79
|
-
isProcessing: false,
|
|
80
|
-
cancelButtonRole: BUTTON_ROLES.SECONDARY,
|
|
81
|
-
confirmButtonRole: BUTTON_ROLES.PRIMARY,
|
|
82
|
-
size: MODAL_SIZES.DEFAULT,
|
|
83
|
-
showHeader: true,
|
|
84
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
import { FlexContainer } from "./FlexContainer";
|
|
4
|
-
import { FlexContainerProps } from "./types/FlexContainerProps.type";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Container to be used for layouting instead of divs around the project.
|
|
8
|
-
* The spacing here has been coded according to our guidelines.
|
|
9
|
-
*/
|
|
10
|
-
export const FlexColumn: React.FC<FlexContainerProps> = (props) => {
|
|
11
|
-
const { children, spaced = true, ...rest } = props;
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
<FlexContainer {...rest} type="column" verticallySpaced={spaced}>
|
|
15
|
-
{children}
|
|
16
|
-
</FlexContainer>
|
|
17
|
-
);
|
|
18
|
-
};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import classNames from "classnames";
|
|
2
|
-
import React from "react";
|
|
3
|
-
|
|
4
|
-
import { FlexContainerBaseProps } from "./types/FlexContainerProps.type";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Container to be used for layouting instead of divs around the project.
|
|
8
|
-
* The spacing here has been coded according to our guidelines.
|
|
9
|
-
*/
|
|
10
|
-
export const FlexContainer: React.FC<
|
|
11
|
-
FlexContainerBaseProps & { type: "column" | "row" }
|
|
12
|
-
> = (props) => {
|
|
13
|
-
const {
|
|
14
|
-
children,
|
|
15
|
-
alignItems,
|
|
16
|
-
verticallySpaced,
|
|
17
|
-
horitontallySpaced,
|
|
18
|
-
justifyContent,
|
|
19
|
-
hasPadding,
|
|
20
|
-
type,
|
|
21
|
-
} = props;
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<div
|
|
25
|
-
className={classNames("flex w-full", {
|
|
26
|
-
"flex-row": type === "row",
|
|
27
|
-
"flex-col": type === "column",
|
|
28
|
-
|
|
29
|
-
"justify-center": justifyContent === "center",
|
|
30
|
-
"justify-start": justifyContent === "start",
|
|
31
|
-
"justify-end": justifyContent === "end",
|
|
32
|
-
"justify-between": justifyContent === "between",
|
|
33
|
-
|
|
34
|
-
"items-start": alignItems === "start",
|
|
35
|
-
"items-center": alignItems === "center",
|
|
36
|
-
"items-end": alignItems === "end",
|
|
37
|
-
|
|
38
|
-
"space-x-4": horitontallySpaced,
|
|
39
|
-
"space-y-4": verticallySpaced,
|
|
40
|
-
"p-4": hasPadding,
|
|
41
|
-
})}
|
|
42
|
-
>
|
|
43
|
-
{children}
|
|
44
|
-
</div>
|
|
45
|
-
);
|
|
46
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
import { FlexContainer } from "./FlexContainer";
|
|
4
|
-
import { FlexContainerProps } from "./types/FlexContainerProps.type";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Container to be used for layouting instead of divs around the project.
|
|
8
|
-
* The spacing here has been coded according to our guidelines.
|
|
9
|
-
*/
|
|
10
|
-
export const FlexRow: React.FC<FlexContainerProps> = (props) => {
|
|
11
|
-
const { children, spaced = true, ...rest } = props;
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
<FlexContainer {...rest} type="row" horitontallySpaced={spaced}>
|
|
15
|
-
{children}
|
|
16
|
-
</FlexContainer>
|
|
17
|
-
);
|
|
18
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
type FlexContainerBase = {
|
|
4
|
-
alignItems?: "center" | "start" | "end";
|
|
5
|
-
justifyContent?: "center" | "start" | "end" | "between";
|
|
6
|
-
verticallySpaced?: boolean;
|
|
7
|
-
horitontallySpaced?: boolean;
|
|
8
|
-
hasPadding?: boolean;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export type FlexContainerBaseProps = FlexContainerBase & {
|
|
12
|
-
children: React.ReactNode;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export type FlexContainerProps = Omit<
|
|
16
|
-
FlexContainerBaseProps,
|
|
17
|
-
"verticallySpaced" | "horitontallySpaced"
|
|
18
|
-
> & { spaced?: boolean };
|