@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,23 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
TableFieldText,
|
|
3
|
-
TableFieldAction,
|
|
4
|
-
TableFieldContent,
|
|
5
|
-
} from "./Table.types";
|
|
6
|
-
|
|
7
|
-
export function isTableFieldText<Item>(
|
|
8
|
-
content: TableFieldContent<Item>
|
|
9
|
-
): content is TableFieldText {
|
|
10
|
-
return "text" in content || "tag" in content;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function isTableFieldAction<Item>(
|
|
14
|
-
content: TableFieldContent<Item>
|
|
15
|
-
): content is [TableFieldAction<Item>?, TableFieldAction<Item>?] {
|
|
16
|
-
return (
|
|
17
|
-
Array.isArray(content) &&
|
|
18
|
-
content.some(
|
|
19
|
-
action =>
|
|
20
|
-
action && "key" in action && "icon" in action && "handleClick" in action
|
|
21
|
-
)
|
|
22
|
-
);
|
|
23
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import classNames from "classnames";
|
|
2
|
-
import React from "react";
|
|
3
|
-
|
|
4
|
-
import { EmptyListMessage } from "../EmptyListMessage/EmptyListMessage";
|
|
5
|
-
import LoadingIndicator from "../LoadingIndicator/LoadingIndicator";
|
|
6
|
-
|
|
7
|
-
import { TableFieldConfig } from "./Table.types";
|
|
8
|
-
import { TableBodyRow } from "./TableBodyRow";
|
|
9
|
-
|
|
10
|
-
export interface TableBody<Item> {
|
|
11
|
-
items?: Item[];
|
|
12
|
-
fieldConfigurations: TableFieldConfig<Item>[];
|
|
13
|
-
emptyItemsText: string;
|
|
14
|
-
emptyFieldContentText?: string;
|
|
15
|
-
isLoading: boolean;
|
|
16
|
-
showEmptyView: boolean;
|
|
17
|
-
onRowClick?: (item: Item) => void;
|
|
18
|
-
className?: string;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function TableBody<Item>(props: TableBody<Item>): JSX.Element {
|
|
22
|
-
return (
|
|
23
|
-
<tbody className={props.className}>
|
|
24
|
-
{!props.isLoading &&
|
|
25
|
-
props.items?.map(item => (
|
|
26
|
-
<TableBodyRow
|
|
27
|
-
className={classNames("border-b last:border-none border-slate-100")}
|
|
28
|
-
key={JSON.stringify(item)}
|
|
29
|
-
item={item}
|
|
30
|
-
fieldConfigurations={props.fieldConfigurations}
|
|
31
|
-
emptyFieldContentText={props.emptyFieldContentText}
|
|
32
|
-
onClick={props.onRowClick}
|
|
33
|
-
/>
|
|
34
|
-
))}
|
|
35
|
-
|
|
36
|
-
{props.isLoading && (
|
|
37
|
-
<tr>
|
|
38
|
-
<td colSpan={props.fieldConfigurations.length}>
|
|
39
|
-
<LoadingIndicator className="py-0 px-3" asModal={false} />
|
|
40
|
-
</td>
|
|
41
|
-
</tr>
|
|
42
|
-
)}
|
|
43
|
-
|
|
44
|
-
{props.showEmptyView && (
|
|
45
|
-
<tr>
|
|
46
|
-
<td colSpan={props.fieldConfigurations.length}>
|
|
47
|
-
<EmptyListMessage
|
|
48
|
-
className="py-6"
|
|
49
|
-
text={props.emptyItemsText}
|
|
50
|
-
imageName={"search-not-found"}
|
|
51
|
-
/>
|
|
52
|
-
</td>
|
|
53
|
-
</tr>
|
|
54
|
-
)}
|
|
55
|
-
</tbody>
|
|
56
|
-
);
|
|
57
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import classNames from "classnames";
|
|
3
|
-
|
|
4
|
-
import { TableFieldConfig } from "./Table.types";
|
|
5
|
-
import { TableBodyRowDataCell } from "./TableBodyRowDataCell";
|
|
6
|
-
|
|
7
|
-
export interface TableBodyRowProps<Item> {
|
|
8
|
-
item: Item;
|
|
9
|
-
fieldConfigurations: TableFieldConfig<Item>[];
|
|
10
|
-
emptyFieldContentText?: string;
|
|
11
|
-
onClick?: (item: Item) => void;
|
|
12
|
-
className?: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function TableBodyRow<Item>(
|
|
16
|
-
props: TableBodyRowProps<Item>
|
|
17
|
-
): JSX.Element {
|
|
18
|
-
const handleRowClick = (event: React.MouseEvent) => {
|
|
19
|
-
event.stopPropagation();
|
|
20
|
-
props.onClick?.(props.item);
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<tr
|
|
25
|
-
tabIndex={0}
|
|
26
|
-
className={classNames(
|
|
27
|
-
"group",
|
|
28
|
-
{
|
|
29
|
-
"hover:bg-blue-50 transition-colors ease-in-out duration-300 cursor-pointer focus:outline-primary":
|
|
30
|
-
props.onClick,
|
|
31
|
-
"hover:bg-white cursor-default": !props.onClick,
|
|
32
|
-
},
|
|
33
|
-
props.className
|
|
34
|
-
)}
|
|
35
|
-
onClick={handleRowClick}
|
|
36
|
-
>
|
|
37
|
-
{props.fieldConfigurations.map(fieldConfig => (
|
|
38
|
-
<TableBodyRowDataCell
|
|
39
|
-
key={fieldConfig.key}
|
|
40
|
-
item={props.item}
|
|
41
|
-
fieldConfig={fieldConfig}
|
|
42
|
-
emptyFieldContentText={props.emptyFieldContentText}
|
|
43
|
-
/>
|
|
44
|
-
))}
|
|
45
|
-
</tr>
|
|
46
|
-
);
|
|
47
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import classNames from "classnames";
|
|
3
|
-
|
|
4
|
-
import Tag from "../Tag/Tag";
|
|
5
|
-
import Text from "../Text/Text";
|
|
6
|
-
import { TertiaryButton } from "../ButtonV2/TertiaryButton";
|
|
7
|
-
|
|
8
|
-
import { TableFieldConfig } from "./Table.types";
|
|
9
|
-
import { isTableFieldAction, isTableFieldText } from "./Table.utils";
|
|
10
|
-
|
|
11
|
-
export interface TableBodyRowDataCellProps<Item> {
|
|
12
|
-
item: Item;
|
|
13
|
-
fieldConfig: TableFieldConfig<Item>;
|
|
14
|
-
emptyFieldContentText?: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function TableBodyRowDataCell<Item>(
|
|
18
|
-
props: TableBodyRowDataCellProps<Item>
|
|
19
|
-
): JSX.Element {
|
|
20
|
-
const content = props.fieldConfig.content(props.item);
|
|
21
|
-
const emptyFieldContentText = props.emptyFieldContentText ?? "";
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<td
|
|
25
|
-
className={classNames("px-2 first:pl-6 last:pr-6", {
|
|
26
|
-
"align-top": !isTableFieldAction(content),
|
|
27
|
-
})}
|
|
28
|
-
>
|
|
29
|
-
{isTableFieldText(content) && (
|
|
30
|
-
<div className="flex flex-row">
|
|
31
|
-
{content.tag && (
|
|
32
|
-
<div className="mt-3 mr-2">
|
|
33
|
-
<Tag text={content.tag.text} colorTheme={content.tag.color} />
|
|
34
|
-
</div>
|
|
35
|
-
)}
|
|
36
|
-
<Text
|
|
37
|
-
className={classNames("py-4 text-left leading-5", {
|
|
38
|
-
"break-all": content.breakAllWord,
|
|
39
|
-
"break-words": !content.breakAllWord,
|
|
40
|
-
})}
|
|
41
|
-
text={content.text === "" ? emptyFieldContentText : content.text}
|
|
42
|
-
type="base"
|
|
43
|
-
/>
|
|
44
|
-
</div>
|
|
45
|
-
)}
|
|
46
|
-
|
|
47
|
-
{isTableFieldAction(content) && (
|
|
48
|
-
<div
|
|
49
|
-
className={classNames(
|
|
50
|
-
"flex flex-row justify-end",
|
|
51
|
-
"transition-opacity ease-in-out duration-300",
|
|
52
|
-
{
|
|
53
|
-
"opacity-0": props.fieldConfig.onlyShowContentOnHovering,
|
|
54
|
-
"group-hover:opacity-100":
|
|
55
|
-
props.fieldConfig.onlyShowContentOnHovering,
|
|
56
|
-
}
|
|
57
|
-
)}
|
|
58
|
-
>
|
|
59
|
-
{content.map(
|
|
60
|
-
action =>
|
|
61
|
-
action && (
|
|
62
|
-
<TertiaryButton
|
|
63
|
-
className="ml-2 first:ml-0"
|
|
64
|
-
key={action.key}
|
|
65
|
-
icon={action.icon}
|
|
66
|
-
onClick={() => {
|
|
67
|
-
action.handleClick(props.item);
|
|
68
|
-
}}
|
|
69
|
-
/>
|
|
70
|
-
)
|
|
71
|
-
)}
|
|
72
|
-
</div>
|
|
73
|
-
)}
|
|
74
|
-
</td>
|
|
75
|
-
);
|
|
76
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
import { PaginationMenu } from "../PaginationMenu/PaginationMenu";
|
|
4
|
-
import { PaginationMenuProps } from "../PaginationMenu/PaginationMenu.types";
|
|
5
|
-
|
|
6
|
-
interface TableFooterProps {
|
|
7
|
-
colSpan: number;
|
|
8
|
-
paginationMenuProps: PaginationMenuProps;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const TableFooter = (props: TableFooterProps): JSX.Element => {
|
|
12
|
-
return (
|
|
13
|
-
<tfoot>
|
|
14
|
-
<tr>
|
|
15
|
-
<td colSpan={props.colSpan}>
|
|
16
|
-
<PaginationMenu className="p-6" {...props.paginationMenuProps} />
|
|
17
|
-
</td>
|
|
18
|
-
</tr>
|
|
19
|
-
</tfoot>
|
|
20
|
-
);
|
|
21
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
import Text from "../Text/Text";
|
|
4
|
-
|
|
5
|
-
import { TableFieldConfig } from "./Table.types";
|
|
6
|
-
|
|
7
|
-
export interface TableHeaderProps<Item> {
|
|
8
|
-
fieldConfigurations: TableFieldConfig<Item>[];
|
|
9
|
-
className?: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function TableHeader<Item>(props: TableHeaderProps<Item>): JSX.Element {
|
|
13
|
-
return (
|
|
14
|
-
<thead className={props.className}>
|
|
15
|
-
<tr>
|
|
16
|
-
{props.fieldConfigurations.map(fieldConfig => (
|
|
17
|
-
<th className="px-2 first:pl-6 last:pr-6" key={fieldConfig.key}>
|
|
18
|
-
<Text
|
|
19
|
-
text={fieldConfig.headerText ?? ""}
|
|
20
|
-
type="strong"
|
|
21
|
-
className="py-4 text-left leading-5 truncate uppercase"
|
|
22
|
-
/>
|
|
23
|
-
</th>
|
|
24
|
-
))}
|
|
25
|
-
</tr>
|
|
26
|
-
</thead>
|
|
27
|
-
);
|
|
28
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import classNames from "classnames";
|
|
3
|
-
|
|
4
|
-
import { Text, TextColor } from "../Text/Text";
|
|
5
|
-
|
|
6
|
-
import { TagSize } from "./Tag.utils";
|
|
7
|
-
|
|
8
|
-
export enum TagColorTheme {
|
|
9
|
-
Red = "red",
|
|
10
|
-
Amber = "amber",
|
|
11
|
-
Green = "green",
|
|
12
|
-
Gray = "gray",
|
|
13
|
-
Blue = "blue",
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface TagProps {
|
|
17
|
-
text: string;
|
|
18
|
-
colorTheme?: TagColorTheme;
|
|
19
|
-
size?: TagSize;
|
|
20
|
-
className?: string;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const Tag = ({
|
|
24
|
-
text,
|
|
25
|
-
colorTheme = TagColorTheme.Gray,
|
|
26
|
-
className,
|
|
27
|
-
size = TagSize.base,
|
|
28
|
-
}: TagProps): JSX.Element => {
|
|
29
|
-
const textColor: Record<TagColorTheme, TextColor> = {
|
|
30
|
-
[TagColorTheme.Red]: "red",
|
|
31
|
-
[TagColorTheme.Amber]: "amber",
|
|
32
|
-
[TagColorTheme.Green]: "green",
|
|
33
|
-
[TagColorTheme.Gray]: "base",
|
|
34
|
-
// Blue must be 800 here to pass the contrast test
|
|
35
|
-
[TagColorTheme.Blue]: "blue-800",
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
return (
|
|
39
|
-
<div
|
|
40
|
-
className={classNames("py-1 px-2 inline-block rounded-lg", className, {
|
|
41
|
-
"bg-red-50": colorTheme === TagColorTheme.Red,
|
|
42
|
-
"bg-orange-50": colorTheme === TagColorTheme.Amber,
|
|
43
|
-
"bg-green-50": colorTheme === TagColorTheme.Green,
|
|
44
|
-
"bg-slate-50": colorTheme === TagColorTheme.Gray,
|
|
45
|
-
"bg-blue-50": colorTheme === TagColorTheme.Blue,
|
|
46
|
-
})}
|
|
47
|
-
>
|
|
48
|
-
<Text
|
|
49
|
-
className="leading-5"
|
|
50
|
-
color={textColor[colorTheme]}
|
|
51
|
-
text={text}
|
|
52
|
-
type={size === TagSize.small ? "sm" : "base"}
|
|
53
|
-
/>
|
|
54
|
-
</div>
|
|
55
|
-
);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export default Tag;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import classNames from "classnames";
|
|
3
|
-
|
|
4
|
-
import Tag, { TagProps } from "./Tag";
|
|
5
|
-
import { TagSize } from "./Tag.utils";
|
|
6
|
-
|
|
7
|
-
interface TagGroupProps {
|
|
8
|
-
tags: TagProps[];
|
|
9
|
-
tagSize?: TagSize;
|
|
10
|
-
className?: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const TagGroup = ({
|
|
14
|
-
tags,
|
|
15
|
-
tagSize = TagSize.base,
|
|
16
|
-
className,
|
|
17
|
-
}: TagGroupProps): JSX.Element => (
|
|
18
|
-
<div className={classNames("flex flex-row flex-wrap", className)}>
|
|
19
|
-
{tags.map(tag => (
|
|
20
|
-
<Tag
|
|
21
|
-
size={tagSize}
|
|
22
|
-
{...tag}
|
|
23
|
-
className={classNames("mr-2 last:mr-0 mb-2")}
|
|
24
|
-
/>
|
|
25
|
-
))}
|
|
26
|
-
</div>
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
export default TagGroup;
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
|
-
import classNames from "classnames";
|
|
4
|
-
|
|
5
|
-
import "./Text.scss";
|
|
6
|
-
|
|
7
|
-
const TEXT_TYPE_OPTIONS = {
|
|
8
|
-
DEFAULT: "default",
|
|
9
|
-
STRONG: "strong",
|
|
10
|
-
EMPHASIZED: "emphasized",
|
|
11
|
-
FINEPRINT: "fineprint",
|
|
12
|
-
SMALL: "small",
|
|
13
|
-
SMALL_DARK: "small-dark",
|
|
14
|
-
SMALL_FINEPRINT: "small-fineprint",
|
|
15
|
-
MICRO: "micro",
|
|
16
|
-
ERROR: "error",
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const TEXT_LEVEL_OPTIONS = {
|
|
20
|
-
INLINE: "inline",
|
|
21
|
-
BLOCK: "block",
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
LegacyText.propTypes = {
|
|
25
|
-
text: PropTypes.string.isRequired,
|
|
26
|
-
level: PropTypes.oneOf([TEXT_LEVEL_OPTIONS.INLINE, TEXT_LEVEL_OPTIONS.BLOCK]),
|
|
27
|
-
type: PropTypes.oneOf([
|
|
28
|
-
TEXT_TYPE_OPTIONS.DEFAULT,
|
|
29
|
-
TEXT_TYPE_OPTIONS.STRONG,
|
|
30
|
-
TEXT_TYPE_OPTIONS.EMPHASIZED,
|
|
31
|
-
TEXT_TYPE_OPTIONS.FINEPRINT,
|
|
32
|
-
TEXT_TYPE_OPTIONS.SMALL,
|
|
33
|
-
TEXT_TYPE_OPTIONS.SMALL_DARK,
|
|
34
|
-
TEXT_TYPE_OPTIONS.SMALL_FINEPRINT,
|
|
35
|
-
TEXT_TYPE_OPTIONS.MICRO,
|
|
36
|
-
TEXT_TYPE_OPTIONS.ERROR,
|
|
37
|
-
]),
|
|
38
|
-
className: PropTypes.string,
|
|
39
|
-
containsDangerousHtml: PropTypes.bool,
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* @deprecated use TextV2
|
|
44
|
-
*/
|
|
45
|
-
function LegacyText({
|
|
46
|
-
text,
|
|
47
|
-
type = TEXT_TYPE_OPTIONS.DEFAULT,
|
|
48
|
-
level = TEXT_LEVEL_OPTIONS.BLOCK,
|
|
49
|
-
className = "",
|
|
50
|
-
containsDangerousHtml = false,
|
|
51
|
-
...otherProps
|
|
52
|
-
}) {
|
|
53
|
-
const containerClassName = classNames("cweb-text", className, {
|
|
54
|
-
"type-default": type === TEXT_TYPE_OPTIONS.DEFAULT,
|
|
55
|
-
"type-strong": type === TEXT_TYPE_OPTIONS.STRONG,
|
|
56
|
-
"type-emphasized": type === TEXT_TYPE_OPTIONS.EMPHASIZED,
|
|
57
|
-
"type-small": type === TEXT_TYPE_OPTIONS.SMALL,
|
|
58
|
-
"type-fineprint": type === TEXT_TYPE_OPTIONS.FINEPRINT,
|
|
59
|
-
"type-small-fineprint": type === TEXT_TYPE_OPTIONS.SMALL_FINEPRINT,
|
|
60
|
-
"level-inline": level === TEXT_LEVEL_OPTIONS.INLINE,
|
|
61
|
-
"level-block": level === TEXT_LEVEL_OPTIONS.BLOCK,
|
|
62
|
-
"type-small-dark": type === TEXT_LEVEL_OPTIONS.SMALL_DARK,
|
|
63
|
-
"type-error": type === TEXT_TYPE_OPTIONS.ERROR,
|
|
64
|
-
"text-xs": type === TEXT_TYPE_OPTIONS.MICRO,
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
return containsDangerousHtml ? (
|
|
68
|
-
<p className={containerClassName} dangerouslySetInnerHTML={{ __html: text }} {...otherProps} />
|
|
69
|
-
) : (
|
|
70
|
-
<p className={containerClassName} {...otherProps}>
|
|
71
|
-
{text}
|
|
72
|
-
</p>
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export default LegacyText;
|
|
77
|
-
|
|
78
|
-
export { TEXT_TYPE_OPTIONS, TEXT_LEVEL_OPTIONS };
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
@import "../../styles/colors";
|
|
2
|
-
@import "../../styles/typography";
|
|
3
|
-
|
|
4
|
-
.cweb-text {
|
|
5
|
-
$color: $color-body;
|
|
6
|
-
$color-fineprint: $color-text-lighter;
|
|
7
|
-
$color-small: $color-text-secondary;
|
|
8
|
-
|
|
9
|
-
$font-size: 1rem;
|
|
10
|
-
$font-size-small: 0.875rem;
|
|
11
|
-
|
|
12
|
-
$line-height: 1.31em;
|
|
13
|
-
$line-height-small: 1.25em;
|
|
14
|
-
|
|
15
|
-
@include text($font-size, $line-height, $color);
|
|
16
|
-
|
|
17
|
-
&.type-emphasized {
|
|
18
|
-
font-weight: bold;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
&.type-error {
|
|
22
|
-
color: $color-negative-alt-emphasis;
|
|
23
|
-
font-size: $font-size-small;
|
|
24
|
-
line-height: $line-height-small;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
&.type-strong {
|
|
28
|
-
font-weight: bold;
|
|
29
|
-
color: $color-text-emphasis;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
&.type-small-dark {
|
|
33
|
-
font-size: $font-size-small;
|
|
34
|
-
line-height: $line-height-small;
|
|
35
|
-
color: $color-body;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
&.type-small {
|
|
39
|
-
font-size: $font-size-small;
|
|
40
|
-
line-height: $line-height-small;
|
|
41
|
-
color: $color-small;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
&.type-small-fineprint {
|
|
45
|
-
font-size: $font-size-small;
|
|
46
|
-
line-height: $line-height-small;
|
|
47
|
-
color: $color-fineprint;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
&.type-fineprint {
|
|
51
|
-
color: $color-fineprint;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
&.level-inline {
|
|
55
|
-
display: inline;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
&.level-block {
|
|
59
|
-
display: block;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.in-html-link {
|
|
64
|
-
a:hover {
|
|
65
|
-
text-decoration: underline;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import classNames from "classnames";
|
|
2
|
-
import React from "react";
|
|
3
|
-
|
|
4
|
-
import { RestPropped } from "../../types/general.types";
|
|
5
|
-
|
|
6
|
-
import "./Text.scss";
|
|
7
|
-
|
|
8
|
-
export type TextStyle =
|
|
9
|
-
| "sm"
|
|
10
|
-
| "sm-strong"
|
|
11
|
-
| "base"
|
|
12
|
-
| "strong"
|
|
13
|
-
| "lg"
|
|
14
|
-
| "lg-strong"
|
|
15
|
-
| "xl"
|
|
16
|
-
| "xl-strong";
|
|
17
|
-
|
|
18
|
-
//Extend with other colors that we want to enable for text
|
|
19
|
-
export type TextColor =
|
|
20
|
-
| "base"
|
|
21
|
-
| "slate-500"
|
|
22
|
-
| "slate-200"
|
|
23
|
-
| "white"
|
|
24
|
-
| "blue-800"
|
|
25
|
-
| "red"
|
|
26
|
-
| "green"
|
|
27
|
-
| "amber";
|
|
28
|
-
|
|
29
|
-
export type TextHoverColor = "blue-900" | "white";
|
|
30
|
-
|
|
31
|
-
export interface TextProps extends RestPropped {
|
|
32
|
-
text: string;
|
|
33
|
-
type?: TextStyle; //defaults to "base"
|
|
34
|
-
inline?: boolean; //defaults to false
|
|
35
|
-
color?: TextColor; //defaults to "base"
|
|
36
|
-
hoverColor?: TextHoverColor; //defaults to "base"
|
|
37
|
-
hoverInGroup?: boolean;
|
|
38
|
-
className?: string;
|
|
39
|
-
containsDangerousHtml?: boolean; //defaults to false
|
|
40
|
-
truncate?: boolean; //defaults to false
|
|
41
|
-
"data-test-id"?: string;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export const Text = (props: TextProps): JSX.Element => {
|
|
45
|
-
/**
|
|
46
|
-
* One might argue that we're duplicating strings in this file.
|
|
47
|
-
* That's how tailwind expects to detect used classes, so please do not make
|
|
48
|
-
* anything dynamic or try to string concat class names.
|
|
49
|
-
* https://v1.tailwindcss.com/docs/controlling-file-size
|
|
50
|
-
*/
|
|
51
|
-
|
|
52
|
-
const allowedColors: Record<TextColor, string> = {
|
|
53
|
-
base: "text-slate-700",
|
|
54
|
-
"slate-500": "text-slate-500",
|
|
55
|
-
"slate-200": "text-slate-200",
|
|
56
|
-
red: "text-red-700",
|
|
57
|
-
green: "text-green-700",
|
|
58
|
-
amber: "text-yellow-700",
|
|
59
|
-
white: "text-white",
|
|
60
|
-
"blue-800": "text-blue-800",
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const allowedHoverColors: Record<TextHoverColor, string> = {
|
|
64
|
-
"blue-900": "hover:text-blue-900",
|
|
65
|
-
white: "hover:text-white",
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
// What is a group hover? https://v1.tailwindcss.com/docs/pseudo-class-variants#group-hover
|
|
69
|
-
const allowedGroupHoverColors: Record<TextHoverColor, string> = {
|
|
70
|
-
"blue-900": "group-hover:text-blue-900",
|
|
71
|
-
white: "group-hover:text-white",
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const selectedHoverColor =
|
|
75
|
-
props.hoverColor &&
|
|
76
|
-
!props.hoverInGroup &&
|
|
77
|
-
allowedHoverColors[props.hoverColor];
|
|
78
|
-
|
|
79
|
-
const selectedGroupHoverColor =
|
|
80
|
-
props.hoverColor &&
|
|
81
|
-
props.hoverInGroup &&
|
|
82
|
-
allowedGroupHoverColors[props.hoverColor];
|
|
83
|
-
|
|
84
|
-
const containerProps = {
|
|
85
|
-
"data-test-id": props["data-test-id"],
|
|
86
|
-
className: classNames(
|
|
87
|
-
// apply different style classes
|
|
88
|
-
// for now we stick with font-size 16px on the body
|
|
89
|
-
// so I am adjusting our styles accordingly (one step down)
|
|
90
|
-
{
|
|
91
|
-
"text-xs font-medium": props.type === "sm",
|
|
92
|
-
"text-xs font-semibold": props.type === "sm-strong",
|
|
93
|
-
"text-sm": props.type === "base",
|
|
94
|
-
"text-sm font-semibold": props.type === "strong",
|
|
95
|
-
"": props.type === "lg",
|
|
96
|
-
"font-semibold": props.type === "lg-strong",
|
|
97
|
-
"text-lg": props.type === "xl",
|
|
98
|
-
"font-semibold text-lg": props.type === "xl-strong",
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
inline: props.inline,
|
|
102
|
-
// FIXME: this class doesn't do anything without a max-width
|
|
103
|
-
truncate: props.truncate,
|
|
104
|
-
},
|
|
105
|
-
allowedColors[props.color || "base"],
|
|
106
|
-
selectedHoverColor,
|
|
107
|
-
selectedGroupHoverColor,
|
|
108
|
-
{
|
|
109
|
-
"in-html-link": props.containsDangerousHtml,
|
|
110
|
-
},
|
|
111
|
-
//can be used to overwrite other classes like the color
|
|
112
|
-
props.className
|
|
113
|
-
),
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
return props.containsDangerousHtml ? (
|
|
117
|
-
<p {...containerProps} dangerouslySetInnerHTML={{ __html: props.text }} />
|
|
118
|
-
) : (
|
|
119
|
-
<p {...containerProps}>{props.text}</p>
|
|
120
|
-
);
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
export default Text;
|
|
124
|
-
|
|
125
|
-
Text.defaultProps = {
|
|
126
|
-
type: "base",
|
|
127
|
-
inline: false,
|
|
128
|
-
color: "base",
|
|
129
|
-
containsDangerousHtml: false,
|
|
130
|
-
truncate: false,
|
|
131
|
-
};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useMemo, useRef } from "react";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
|
-
import ReactQuill from "react-quill";
|
|
4
|
-
|
|
5
|
-
import "react-quill/dist/quill.snow.css";
|
|
6
|
-
import "./TextEditor.scss";
|
|
7
|
-
|
|
8
|
-
export default function TextEditor({ defaultValue, onValueChange, placeholder }) {
|
|
9
|
-
const formats = ["bold", "italic", "underline", "strike", "list", "bullet", "link"];
|
|
10
|
-
const toolbarLastGroup = ["link", "video"];
|
|
11
|
-
const quillRef = useRef();
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
if (quillRef.current) {
|
|
16
|
-
const quillInstance = quillRef.current;
|
|
17
|
-
const tooltipSave = quillInstance.editor.theme.tooltip.save;
|
|
18
|
-
|
|
19
|
-
quillInstance.editor.theme.tooltip.save = function () {
|
|
20
|
-
// overwrite save link functionality
|
|
21
|
-
let url = this.textbox.value;
|
|
22
|
-
|
|
23
|
-
if (url.indexOf("http") === -1 || url.indexOf("https") === -1) {
|
|
24
|
-
url = `https://${url}`;
|
|
25
|
-
this.textbox.value = url;
|
|
26
|
-
}
|
|
27
|
-
tooltipSave.call(this);
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
}, []);
|
|
31
|
-
|
|
32
|
-
const modules = useMemo(() => {
|
|
33
|
-
return {
|
|
34
|
-
toolbar: {
|
|
35
|
-
container: [
|
|
36
|
-
["bold", "italic", "underline", "strike"],
|
|
37
|
-
[{ list: "ordered" }, { list: "bullet" }],
|
|
38
|
-
toolbarLastGroup,
|
|
39
|
-
],
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
}, []);
|
|
43
|
-
|
|
44
|
-
return (
|
|
45
|
-
<ReactQuill
|
|
46
|
-
ref={quillRef}
|
|
47
|
-
theme="snow"
|
|
48
|
-
modules={modules}
|
|
49
|
-
placeholder={placeholder}
|
|
50
|
-
formats={formats}
|
|
51
|
-
value={defaultValue}
|
|
52
|
-
onChange={onValueChange}
|
|
53
|
-
/>
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
TextEditor.propTypes = {
|
|
58
|
-
defaultValue: PropTypes.string,
|
|
59
|
-
placeholder: PropTypes.string,
|
|
60
|
-
onValueChange: PropTypes.func.isRequired,
|
|
61
|
-
};
|