@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,416 +0,0 @@
|
|
|
1
|
-
import React, { PureComponent } from "react";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
|
-
import classNames from "classnames";
|
|
4
|
-
|
|
5
|
-
import chevronDouble from "../../assets/chevron-double.svg";
|
|
6
|
-
import checkmark from "../../assets/check-icon-primary.svg";
|
|
7
|
-
import { Text } from "../Text/Text";
|
|
8
|
-
|
|
9
|
-
import "./Dropdown.scss";
|
|
10
|
-
|
|
11
|
-
const ITEM_QUERY_FIELD_NAMES = {
|
|
12
|
-
ID: "id",
|
|
13
|
-
HIGHLIGHT_INDEX: "highlightIndex",
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const keyCodes = {
|
|
17
|
-
ARROW_DOWN: 40,
|
|
18
|
-
ARROW_UP: 38,
|
|
19
|
-
ENTER: 13,
|
|
20
|
-
TAB: 9,
|
|
21
|
-
SHIFT: 16,
|
|
22
|
-
ESC: 27,
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
class Dropdown extends PureComponent {
|
|
26
|
-
static addHighlightIndexToItems = items => {
|
|
27
|
-
let index = 0;
|
|
28
|
-
|
|
29
|
-
return items.map(item => {
|
|
30
|
-
if (!item.subItems) {
|
|
31
|
-
const currentIndex = index;
|
|
32
|
-
index = index + 1;
|
|
33
|
-
|
|
34
|
-
return {
|
|
35
|
-
...item,
|
|
36
|
-
highlightIndex: currentIndex,
|
|
37
|
-
};
|
|
38
|
-
} else {
|
|
39
|
-
return {
|
|
40
|
-
...item,
|
|
41
|
-
subItems: item.subItems.map(subItem => {
|
|
42
|
-
const currentIndex = index;
|
|
43
|
-
index = index + 1;
|
|
44
|
-
|
|
45
|
-
return {
|
|
46
|
-
...subItem,
|
|
47
|
-
highlightIndex: currentIndex,
|
|
48
|
-
};
|
|
49
|
-
}),
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
static getTotalItemCount = items => {
|
|
56
|
-
return items.reduce((acc, item) => {
|
|
57
|
-
if (!item.subItems) {
|
|
58
|
-
return acc + 1;
|
|
59
|
-
} else {
|
|
60
|
-
return acc + item.subItems.length;
|
|
61
|
-
}
|
|
62
|
-
}, 0);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
constructor(props) {
|
|
66
|
-
super(props);
|
|
67
|
-
|
|
68
|
-
const items = Dropdown.addHighlightIndexToItems(props.items);
|
|
69
|
-
const selectedItem = props.initialSelectedItemId
|
|
70
|
-
? this.findItem(
|
|
71
|
-
items,
|
|
72
|
-
ITEM_QUERY_FIELD_NAMES.ID,
|
|
73
|
-
props.initialSelectedItemId
|
|
74
|
-
)
|
|
75
|
-
: null;
|
|
76
|
-
|
|
77
|
-
this.state = {
|
|
78
|
-
totalItemCount: Dropdown.getTotalItemCount(items),
|
|
79
|
-
isDropdownOpen: false,
|
|
80
|
-
highlightIndex: null,
|
|
81
|
-
selectedItem,
|
|
82
|
-
items,
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
static getDerivedStateFromProps(nextProps, prevState) {
|
|
87
|
-
const items = Dropdown.addHighlightIndexToItems(nextProps.items);
|
|
88
|
-
|
|
89
|
-
return {
|
|
90
|
-
...prevState,
|
|
91
|
-
items: items,
|
|
92
|
-
totalItemCount: Dropdown.getTotalItemCount(items),
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
componentDidMount() {
|
|
97
|
-
document.addEventListener("mousedown", this.handleClickOutside);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
componentWillUnmount() {
|
|
101
|
-
document.removeEventListener("mousedown", this.handleClickOutside);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
handleClickOutside = event => {
|
|
105
|
-
if (this.rootRef && !this.rootRef.contains(event.target)) {
|
|
106
|
-
this.closeDropdown();
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
handleKeyDown = event => {
|
|
111
|
-
const { items, isDropdownOpen, highlightIndex } = this.state;
|
|
112
|
-
|
|
113
|
-
if (event.keyCode === keyCodes.ENTER) {
|
|
114
|
-
event.preventDefault();
|
|
115
|
-
|
|
116
|
-
if (isDropdownOpen) {
|
|
117
|
-
this.closeDropdown();
|
|
118
|
-
this.setSelectedItem(
|
|
119
|
-
this.findItem(
|
|
120
|
-
items,
|
|
121
|
-
ITEM_QUERY_FIELD_NAMES.HIGHLIGHT_INDEX,
|
|
122
|
-
highlightIndex
|
|
123
|
-
)
|
|
124
|
-
);
|
|
125
|
-
this.rootRef.blur();
|
|
126
|
-
} else {
|
|
127
|
-
this.openDropdown();
|
|
128
|
-
}
|
|
129
|
-
} else if (event.keyCode === keyCodes.TAB) {
|
|
130
|
-
if (event.shiftKey) {
|
|
131
|
-
this.decreaseHighlightIndexIfPossible();
|
|
132
|
-
} else {
|
|
133
|
-
this.increaseHighlightIndexIfPossible();
|
|
134
|
-
}
|
|
135
|
-
} else if (event.keyCode === keyCodes.ARROW_UP) {
|
|
136
|
-
event.preventDefault();
|
|
137
|
-
|
|
138
|
-
this.decreaseHighlightIndexIfPossible();
|
|
139
|
-
} else if (event.keyCode === keyCodes.ARROW_DOWN) {
|
|
140
|
-
event.preventDefault();
|
|
141
|
-
|
|
142
|
-
if (isDropdownOpen) {
|
|
143
|
-
this.increaseHighlightIndexIfPossible();
|
|
144
|
-
} else {
|
|
145
|
-
this.openDropdown();
|
|
146
|
-
}
|
|
147
|
-
} else if (event.keyCode === keyCodes.ESC) {
|
|
148
|
-
this.closeDropdown();
|
|
149
|
-
this.rootRef.blur();
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
findItem = (items, fieldName, fieldValue) => {
|
|
154
|
-
let selectedItem;
|
|
155
|
-
|
|
156
|
-
for (let i = 0; i < items.length; i++) {
|
|
157
|
-
const item = items[i];
|
|
158
|
-
|
|
159
|
-
if (item[fieldName] === fieldValue) {
|
|
160
|
-
selectedItem = item;
|
|
161
|
-
} else if (item.subItems) {
|
|
162
|
-
for (let j = 0; j < item.subItems.length; j++) {
|
|
163
|
-
const subItem = item.subItems[j];
|
|
164
|
-
|
|
165
|
-
if (
|
|
166
|
-
(fieldName === ITEM_QUERY_FIELD_NAMES.ID &&
|
|
167
|
-
subItem.key === fieldValue) ||
|
|
168
|
-
subItem[fieldName] === fieldValue
|
|
169
|
-
) {
|
|
170
|
-
selectedItem = subItem;
|
|
171
|
-
break;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
if (selectedItem) {
|
|
177
|
-
break;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
return selectedItem;
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
openDropdown = () => {
|
|
185
|
-
this.setState(prevState => {
|
|
186
|
-
return {
|
|
187
|
-
isDropdownOpen: true,
|
|
188
|
-
highlightIndex: prevState.selectedItem
|
|
189
|
-
? prevState.selectedItem.highlightIndex
|
|
190
|
-
: 0,
|
|
191
|
-
};
|
|
192
|
-
});
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
closeDropdown = () => {
|
|
196
|
-
this.setState({
|
|
197
|
-
isDropdownOpen: false,
|
|
198
|
-
highlightIndex: null,
|
|
199
|
-
});
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
setSelectedItem = item => {
|
|
203
|
-
this.setState({
|
|
204
|
-
selectedItem: item,
|
|
205
|
-
});
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
findSelectedItem = selectedIndex => {
|
|
209
|
-
return this.rootRef.querySelectorAll(".dropdown-list-item")[selectedIndex];
|
|
210
|
-
};
|
|
211
|
-
|
|
212
|
-
scrollToHighlightedItem = selectedIndex => {
|
|
213
|
-
const selectedItem = this.findSelectedItem(selectedIndex);
|
|
214
|
-
if (this.dropdownListRef.scrollTo) {
|
|
215
|
-
this.dropdownListRef.scrollTo(0, selectedItem.offsetTop);
|
|
216
|
-
}
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
increaseHighlightIndexIfPossible = () => {
|
|
220
|
-
this.setState(prevState => {
|
|
221
|
-
const newHighlightIndex =
|
|
222
|
-
prevState.highlightIndex < prevState.totalItemCount - 1
|
|
223
|
-
? prevState.highlightIndex + 1
|
|
224
|
-
: prevState.highlightIndex;
|
|
225
|
-
|
|
226
|
-
if (newHighlightIndex !== prevState.highlightIndex) {
|
|
227
|
-
this.scrollToHighlightedItem(newHighlightIndex);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
return {
|
|
231
|
-
highlightIndex: newHighlightIndex,
|
|
232
|
-
};
|
|
233
|
-
});
|
|
234
|
-
};
|
|
235
|
-
|
|
236
|
-
decreaseHighlightIndexIfPossible = () => {
|
|
237
|
-
this.setState(prevState => {
|
|
238
|
-
const newHighlightIndex =
|
|
239
|
-
prevState.highlightIndex > 0
|
|
240
|
-
? prevState.highlightIndex - 1
|
|
241
|
-
: prevState.highlightIndex;
|
|
242
|
-
|
|
243
|
-
if (newHighlightIndex !== prevState.highlightIndex) {
|
|
244
|
-
this.scrollToHighlightedItem(newHighlightIndex);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
return {
|
|
248
|
-
highlightIndex: newHighlightIndex,
|
|
249
|
-
};
|
|
250
|
-
});
|
|
251
|
-
};
|
|
252
|
-
|
|
253
|
-
selectItem = item => {
|
|
254
|
-
const { onItemSelect } = this.props;
|
|
255
|
-
|
|
256
|
-
this.closeDropdown();
|
|
257
|
-
this.setSelectedItem(item);
|
|
258
|
-
|
|
259
|
-
onItemSelect(item);
|
|
260
|
-
};
|
|
261
|
-
|
|
262
|
-
renderIndividualItem = item => {
|
|
263
|
-
const { highlightIndex } = this.state;
|
|
264
|
-
const isItemSelected = item.highlightIndex === highlightIndex;
|
|
265
|
-
|
|
266
|
-
const itemClassName = classNames("dropdown-list-item p-3", {
|
|
267
|
-
"is-selected": isItemSelected,
|
|
268
|
-
"flex flex-row justify-between space-x-2": isItemSelected,
|
|
269
|
-
});
|
|
270
|
-
const textType = isItemSelected ? "strong" : "base";
|
|
271
|
-
|
|
272
|
-
return (
|
|
273
|
-
<div
|
|
274
|
-
className={itemClassName}
|
|
275
|
-
key={item.id}
|
|
276
|
-
tabIndex="0"
|
|
277
|
-
onClick={() => this.selectItem(item)}
|
|
278
|
-
>
|
|
279
|
-
<Text
|
|
280
|
-
data-test-id={item.text}
|
|
281
|
-
text={item.text}
|
|
282
|
-
type={textType}
|
|
283
|
-
truncate
|
|
284
|
-
/>
|
|
285
|
-
<img
|
|
286
|
-
className={classNames({ hidden: !isItemSelected })}
|
|
287
|
-
src={checkmark}
|
|
288
|
-
alt="checked"
|
|
289
|
-
/>
|
|
290
|
-
</div>
|
|
291
|
-
);
|
|
292
|
-
};
|
|
293
|
-
|
|
294
|
-
renderGroupedItems = item => {
|
|
295
|
-
return (
|
|
296
|
-
<div className="dropdown-list-item-group" key={item.groupKey}>
|
|
297
|
-
{item.title && (
|
|
298
|
-
<div className="p-3 bg-main-background" tabIndex="-1">
|
|
299
|
-
<Text
|
|
300
|
-
className="uppercase"
|
|
301
|
-
data-test-id={item.text}
|
|
302
|
-
text={item.title}
|
|
303
|
-
type="sm"
|
|
304
|
-
color="slate-500"
|
|
305
|
-
truncate
|
|
306
|
-
/>
|
|
307
|
-
</div>
|
|
308
|
-
)}
|
|
309
|
-
{item.subItems.map(subItem => this.renderIndividualItem(subItem))}
|
|
310
|
-
</div>
|
|
311
|
-
);
|
|
312
|
-
};
|
|
313
|
-
|
|
314
|
-
renderItems = () => {
|
|
315
|
-
const { items } = this.state;
|
|
316
|
-
|
|
317
|
-
return (
|
|
318
|
-
<div
|
|
319
|
-
className={classNames("dropdown-list", { wider: this.props.wider })}
|
|
320
|
-
ref={element => (this.dropdownListRef = element)}
|
|
321
|
-
>
|
|
322
|
-
{items.map(item =>
|
|
323
|
-
item.subItems
|
|
324
|
-
? this.renderGroupedItems(item)
|
|
325
|
-
: this.renderIndividualItem(item)
|
|
326
|
-
)}
|
|
327
|
-
</div>
|
|
328
|
-
);
|
|
329
|
-
};
|
|
330
|
-
|
|
331
|
-
render() {
|
|
332
|
-
// eslint-disable-next-line no-unused-vars
|
|
333
|
-
const {
|
|
334
|
-
placeholder = "",
|
|
335
|
-
className,
|
|
336
|
-
initialSelectedItemId,
|
|
337
|
-
onItemSelect,
|
|
338
|
-
items,
|
|
339
|
-
wider,
|
|
340
|
-
...otherProps
|
|
341
|
-
} = this.props;
|
|
342
|
-
const { selectedItem, isDropdownOpen } = this.state;
|
|
343
|
-
const containerClassName = classNames("cweb-dropdown", className, {
|
|
344
|
-
"is-open": isDropdownOpen,
|
|
345
|
-
});
|
|
346
|
-
const onDropdownClick = isDropdownOpen
|
|
347
|
-
? this.closeDropdown
|
|
348
|
-
: this.openDropdown;
|
|
349
|
-
|
|
350
|
-
return (
|
|
351
|
-
<div
|
|
352
|
-
className={classNames(containerClassName)}
|
|
353
|
-
tabIndex="0"
|
|
354
|
-
ref={element => (this.rootRef = element)}
|
|
355
|
-
onKeyDown={this.handleKeyDown}
|
|
356
|
-
>
|
|
357
|
-
<div
|
|
358
|
-
{...otherProps}
|
|
359
|
-
className={classNames(
|
|
360
|
-
"dropdown-header space-x-2 border border-solid p-3 cursor-pointer",
|
|
361
|
-
{
|
|
362
|
-
"border-primary-dark": isDropdownOpen,
|
|
363
|
-
"border-input-border hover:border-input-border-dark": !isDropdownOpen,
|
|
364
|
-
}
|
|
365
|
-
)}
|
|
366
|
-
onClick={onDropdownClick}
|
|
367
|
-
>
|
|
368
|
-
<Text
|
|
369
|
-
className="dropdown-header-title"
|
|
370
|
-
text={selectedItem ? selectedItem.text : placeholder}
|
|
371
|
-
truncate
|
|
372
|
-
/>
|
|
373
|
-
<img
|
|
374
|
-
className="dropdown-header-icon"
|
|
375
|
-
src={chevronDouble}
|
|
376
|
-
alt="browse icon"
|
|
377
|
-
/>
|
|
378
|
-
</div>
|
|
379
|
-
{this.renderItems()}
|
|
380
|
-
</div>
|
|
381
|
-
);
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
Dropdown.propTypes = {
|
|
386
|
-
items: PropTypes.arrayOf(
|
|
387
|
-
PropTypes.oneOfType([
|
|
388
|
-
PropTypes.shape({
|
|
389
|
-
id: PropTypes.string.isRequired,
|
|
390
|
-
text: PropTypes.string.isRequired,
|
|
391
|
-
key: PropTypes.string.isRequired,
|
|
392
|
-
}),
|
|
393
|
-
PropTypes.shape({
|
|
394
|
-
subItems: PropTypes.arrayOf(
|
|
395
|
-
PropTypes.shape({
|
|
396
|
-
id: PropTypes.string.isRequired,
|
|
397
|
-
text: PropTypes.string.isRequired,
|
|
398
|
-
key: PropTypes.string.isRequired,
|
|
399
|
-
})
|
|
400
|
-
).isRequired,
|
|
401
|
-
title: PropTypes.string,
|
|
402
|
-
groupKey: PropTypes.string.isRequired,
|
|
403
|
-
}),
|
|
404
|
-
])
|
|
405
|
-
).isRequired,
|
|
406
|
-
initialSelectedItemId: PropTypes.oneOfType([
|
|
407
|
-
PropTypes.number,
|
|
408
|
-
PropTypes.string,
|
|
409
|
-
]),
|
|
410
|
-
placeholder: PropTypes.string,
|
|
411
|
-
className: PropTypes.string,
|
|
412
|
-
onItemSelect: PropTypes.func.isRequired,
|
|
413
|
-
wider: PropTypes.bool,
|
|
414
|
-
};
|
|
415
|
-
|
|
416
|
-
export default Dropdown;
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
@import "../../styles/colors";
|
|
2
|
-
@import "../../styles/typography";
|
|
3
|
-
@import "../../styles/layout";
|
|
4
|
-
@import "../../styles/utils";
|
|
5
|
-
|
|
6
|
-
.cweb-dropdown {
|
|
7
|
-
$list-item-title-padding: 15px 12px;
|
|
8
|
-
|
|
9
|
-
@mixin dropdown-list-item() {
|
|
10
|
-
cursor: pointer;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
@include flexbox-vertical();
|
|
14
|
-
position: relative;
|
|
15
|
-
|
|
16
|
-
outline: none;
|
|
17
|
-
border-radius: 4px;
|
|
18
|
-
|
|
19
|
-
&:focus {
|
|
20
|
-
outline: 4px solid rgba(0, 159, 227, 0.3);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
> .dropdown-header {
|
|
24
|
-
@include flexbox-horizontal(center, space-between);
|
|
25
|
-
|
|
26
|
-
align-self: stretch;
|
|
27
|
-
height: $default-height;
|
|
28
|
-
border-radius: $default-border-radius;
|
|
29
|
-
transition: all 0.4s ease;
|
|
30
|
-
|
|
31
|
-
> .dropdown-header-icon {
|
|
32
|
-
opacity: 0.5;
|
|
33
|
-
transition: opacity 0.3s ease-in-out;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
&:hover {
|
|
37
|
-
> .dropdown-header-icon {
|
|
38
|
-
opacity: 1;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
> .dropdown-list {
|
|
44
|
-
box-shadow: 0px 2px 4px -2px rgba(0, 0, 0, 0.56);
|
|
45
|
-
|
|
46
|
-
display: none;
|
|
47
|
-
position: absolute;
|
|
48
|
-
top: 100%;
|
|
49
|
-
z-index: 1;
|
|
50
|
-
width: 100%;
|
|
51
|
-
max-height: 360px;
|
|
52
|
-
overflow-y: auto;
|
|
53
|
-
align-self: stretch;
|
|
54
|
-
margin-top: 8px;
|
|
55
|
-
padding: 0;
|
|
56
|
-
background-color: #ffffff;
|
|
57
|
-
list-style: none;
|
|
58
|
-
|
|
59
|
-
border: 1px solid $input-border;
|
|
60
|
-
border-radius: 4px;
|
|
61
|
-
|
|
62
|
-
> .dropdown-list-item {
|
|
63
|
-
@include dropdown-list-item();
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
> .dropdown-list-item-group {
|
|
67
|
-
> .dropdown-list-item {
|
|
68
|
-
@include dropdown-list-item();
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
&.is-open {
|
|
74
|
-
> .dropdown-list {
|
|
75
|
-
display: block;
|
|
76
|
-
margin-bottom: 32px;
|
|
77
|
-
|
|
78
|
-
&.wider {
|
|
79
|
-
width: 200%;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import classNames from "classnames";
|
|
3
|
-
|
|
4
|
-
import NoOpenAlertsImage from "../../assets/no-open-alerts.svg";
|
|
5
|
-
import SearchNotFoundImage from "../../assets/search-not-found.svg";
|
|
6
|
-
import HappyStarImage from "../../assets/happy-star.svg";
|
|
7
|
-
import { Text } from "../Text/Text";
|
|
8
|
-
|
|
9
|
-
const imageSrc = {
|
|
10
|
-
"no-open-alerts": NoOpenAlertsImage,
|
|
11
|
-
"search-not-found": SearchNotFoundImage,
|
|
12
|
-
"no-notes-found": HappyStarImage,
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
interface EmptyListMessageProps {
|
|
16
|
-
text: string;
|
|
17
|
-
imageName?: keyof typeof imageSrc;
|
|
18
|
-
dataTestId?: string;
|
|
19
|
-
className?: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const EmptyListMessage = ({
|
|
23
|
-
text,
|
|
24
|
-
imageName,
|
|
25
|
-
dataTestId = "empty-list-message",
|
|
26
|
-
className,
|
|
27
|
-
}: EmptyListMessageProps): JSX.Element => {
|
|
28
|
-
return (
|
|
29
|
-
<div className={classNames("flex flex-col items-center", className)} data-test-id={dataTestId}>
|
|
30
|
-
{imageName && <img className="mb-2.5" alt="" src={imageSrc[imageName]} />}
|
|
31
|
-
<Text className="text-center" text={text} />
|
|
32
|
-
</div>
|
|
33
|
-
);
|
|
34
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
|
-
import classNames from "classnames";
|
|
4
|
-
|
|
5
|
-
import Text from "../Text/Text";
|
|
6
|
-
|
|
7
|
-
import "./ErrorBlock.scss";
|
|
8
|
-
|
|
9
|
-
ErrorBlock.propTypes = {
|
|
10
|
-
message: PropTypes.string.isRequired,
|
|
11
|
-
className: PropTypes.string,
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
function ErrorBlock({ message, className = "", ...otherProps }) {
|
|
15
|
-
const containerClassName = classNames("cweb-error-block", className);
|
|
16
|
-
|
|
17
|
-
return (
|
|
18
|
-
<div className={containerClassName}>
|
|
19
|
-
<Text {...otherProps} className="cweb-error-block-message" text={message} />
|
|
20
|
-
</div>
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export default ErrorBlock;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
@import '../../styles/colors';
|
|
2
|
-
|
|
3
|
-
.cweb-error-block {
|
|
4
|
-
position: relative;
|
|
5
|
-
padding: 16px 16px 16px 56px;
|
|
6
|
-
background-color: $color-negative-support;
|
|
7
|
-
border-radius: 8px;
|
|
8
|
-
|
|
9
|
-
&:before {
|
|
10
|
-
content: "";
|
|
11
|
-
position: absolute;
|
|
12
|
-
left: 16px;
|
|
13
|
-
top: 14px;
|
|
14
|
-
z-index: 1;
|
|
15
|
-
width: 24px;
|
|
16
|
-
height: 23px;
|
|
17
|
-
background: url("../../assets/error-icon.svg") no-repeat center;
|
|
18
|
-
background-size: contain;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Control, useForm, UseFormReturn } from "react-hook-form";
|
|
3
|
-
|
|
4
|
-
import { PrimaryButton } from "../ButtonV2/PrimaryButton";
|
|
5
|
-
import { InputProps } from "../Input/Input";
|
|
6
|
-
import { RadioGroupProps } from "../RadioGroup/RadioGroupV2";
|
|
7
|
-
import { SelectProps } from "../Select/SelectV2";
|
|
8
|
-
|
|
9
|
-
import { FormInput } from "./FormInput";
|
|
10
|
-
import {
|
|
11
|
-
FormFieldProps,
|
|
12
|
-
FormFieldRowProps,
|
|
13
|
-
FormProps,
|
|
14
|
-
GenericFormProps,
|
|
15
|
-
} from "./form.types";
|
|
16
|
-
import { isRequired } from "./form.transformer";
|
|
17
|
-
import { FormRadioGroup } from "./FormRadioGroup";
|
|
18
|
-
import { FormSelect } from "./FormSelect";
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Create a straight forward Form, which takes away the 'overhead' of react-hook-form.
|
|
22
|
-
*
|
|
23
|
-
* You will probably don't want to use this component for now, given that the button is hardcoded.
|
|
24
|
-
* This is an example for the Form for now, though it could be improved to enforce further unification.
|
|
25
|
-
*
|
|
26
|
-
* TODO: make the buttons configurable.
|
|
27
|
-
*/
|
|
28
|
-
export function GenericForm<TFieldValues>({
|
|
29
|
-
fields,
|
|
30
|
-
onValid,
|
|
31
|
-
onError,
|
|
32
|
-
defaultValues,
|
|
33
|
-
}: GenericFormProps<TFieldValues>): JSX.Element {
|
|
34
|
-
const useFormReturn = useForm<TFieldValues>({
|
|
35
|
-
criteriaMode: "all",
|
|
36
|
-
defaultValues: defaultValues,
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
const { handleSubmit } = useFormReturn;
|
|
40
|
-
|
|
41
|
-
return (
|
|
42
|
-
<div className="space-y-4">
|
|
43
|
-
<Form fields={fields} useFormReturn={useFormReturn} />
|
|
44
|
-
<PrimaryButton onClick={handleSubmit(onValid, onError)} text={"submit"} />
|
|
45
|
-
</div>
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Creates a Form based on the fields input.
|
|
51
|
-
*
|
|
52
|
-
* Expects the results of the useForm hook to be injected into the useFormReturn parameter.
|
|
53
|
-
*
|
|
54
|
-
* This allows you to use and modify the useFormReturn before injecting it here.
|
|
55
|
-
*/
|
|
56
|
-
export function Form<TFieldValues, TContext>({
|
|
57
|
-
fields,
|
|
58
|
-
useFormReturn,
|
|
59
|
-
}: FormProps<TFieldValues, TContext>): JSX.Element {
|
|
60
|
-
return (
|
|
61
|
-
<div className="space-y-4">
|
|
62
|
-
{fields.map((props) => {
|
|
63
|
-
if (props.type === "row") {
|
|
64
|
-
const { fields: rowFields, key } =
|
|
65
|
-
props as FormFieldRowProps<TFieldValues>;
|
|
66
|
-
return (
|
|
67
|
-
<div className={"flex flex-row space-x-4"} key={key}>
|
|
68
|
-
{rowFields.map((field) => FormFieldMapper(field, useFormReturn))}
|
|
69
|
-
</div>
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
return FormFieldMapper(props, useFormReturn);
|
|
73
|
-
})}
|
|
74
|
-
</div>
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function FormFieldMapper<TFieldValues, TContext>(
|
|
79
|
-
formFieldProps: FormFieldProps<TFieldValues>,
|
|
80
|
-
useFormReturn: UseFormReturn<TFieldValues, TContext>
|
|
81
|
-
): JSX.Element {
|
|
82
|
-
const {
|
|
83
|
-
type,
|
|
84
|
-
name,
|
|
85
|
-
options,
|
|
86
|
-
fieldProps = {},
|
|
87
|
-
...decoratorProps
|
|
88
|
-
} = formFieldProps;
|
|
89
|
-
const {
|
|
90
|
-
register,
|
|
91
|
-
control,
|
|
92
|
-
formState: { errors },
|
|
93
|
-
} = useFormReturn;
|
|
94
|
-
|
|
95
|
-
switch (type) {
|
|
96
|
-
case "text":
|
|
97
|
-
case "number":
|
|
98
|
-
case "email":
|
|
99
|
-
case "password":
|
|
100
|
-
return (
|
|
101
|
-
<FormInput
|
|
102
|
-
key={name}
|
|
103
|
-
{...decoratorProps}
|
|
104
|
-
fieldRequired={isRequired(options)}
|
|
105
|
-
fieldErrors={errors}
|
|
106
|
-
{...(fieldProps as InputProps)}
|
|
107
|
-
{...register(name, options)}
|
|
108
|
-
type={type || "text"}
|
|
109
|
-
/>
|
|
110
|
-
);
|
|
111
|
-
case "select":
|
|
112
|
-
return (
|
|
113
|
-
<FormSelect
|
|
114
|
-
key={name}
|
|
115
|
-
{...decoratorProps}
|
|
116
|
-
fieldRequired={isRequired(options)}
|
|
117
|
-
fieldErrors={errors}
|
|
118
|
-
{...(fieldProps as SelectProps)}
|
|
119
|
-
control={control as Control}
|
|
120
|
-
rules={options}
|
|
121
|
-
name={name}
|
|
122
|
-
/>
|
|
123
|
-
);
|
|
124
|
-
case "radioGroup":
|
|
125
|
-
return (
|
|
126
|
-
<FormRadioGroup
|
|
127
|
-
key={name}
|
|
128
|
-
{...decoratorProps}
|
|
129
|
-
fieldRequired={isRequired(options)}
|
|
130
|
-
fieldErrors={errors}
|
|
131
|
-
{...(fieldProps as RadioGroupProps)}
|
|
132
|
-
{...register(name, options)}
|
|
133
|
-
/>
|
|
134
|
-
);
|
|
135
|
-
default:
|
|
136
|
-
return <></>;
|
|
137
|
-
}
|
|
138
|
-
}
|