@terraware/web-components 3.5.12-rc.7 → 3.5.12
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/components/AntSwitch/index.js +27 -0
- package/components/AntSwitch/styles.scss +66 -0
- package/components/Autocomplete/Autocomplete.js +131 -0
- package/components/Autocomplete/styles.scss +155 -0
- package/components/Badge/index.js +32 -0
- package/components/BusySpinner/index.js +49 -0
- package/components/Button/Button.js +51 -0
- package/components/Button/button.test.js +25 -0
- package/components/Button/styles.scss +453 -0
- package/components/Checkbox.js +70 -0
- package/components/Confirm/index.js +94 -0
- package/components/DatePicker/DatePicker.js +150 -0
- package/components/DatePicker/styles.scss +95 -0
- package/components/DialogBox/DialogBox.js +91 -0
- package/components/DialogBox/styles.scss +165 -0
- package/components/Divisor.js +21 -0
- package/components/Dropdown.js +102 -0
- package/components/ErrorBox/ErrorBox.js +47 -0
- package/components/ErrorBox/styles.scss +63 -0
- package/components/FileChooser/index.js +137 -0
- package/components/FormBottomBar/index.js +90 -0
- package/components/Icon/Icon.js +25 -0
- package/components/Icon/icons/index.js +241 -0
- package/components/Icon/styles.scss +41 -0
- package/components/IconTooltip/index.js +61 -0
- package/components/Map/MapBox.d.ts.map +1 -1
- package/components/Map/MapBox.js +479 -0
- package/components/Map/MapContainer.js +30 -0
- package/components/Map/MapDateSliderControl.js +66 -0
- package/components/Map/MapDrawer.js +45 -0
- package/components/Map/MapLegend.js +172 -0
- package/components/Map/MapViewStyleControl.js +74 -0
- package/components/Map/ReactMapboxWrapper.d.ts +3 -0
- package/components/Map/ReactMapboxWrapper.d.ts.map +1 -0
- package/components/Map/ReactMapboxWrapper.js +9 -0
- package/components/Map/index.js +190 -0
- package/components/Map/styles.scss +130 -0
- package/components/Map/types.js +24 -0
- package/components/Map/useMaintainLayerOrder.js +32 -0
- package/components/Message/Message.js +67 -0
- package/components/Message/styles.scss +202 -0
- package/components/MultiSelect/MultiSelect.test.js +75 -0
- package/components/MultiSelect/index.js +120 -0
- package/components/MultiSelect/styles.scss +180 -0
- package/components/Navbar/NavFooter.js +17 -0
- package/components/Navbar/NavItem.js +73 -0
- package/components/Navbar/NavSection.js +22 -0
- package/components/Navbar/Navbar.js +46 -0
- package/components/Navbar/SubNavbar.js +17 -0
- package/components/Navbar/styles.scss +155 -0
- package/components/Note.js +25 -0
- package/components/PageForm/index.js +43 -0
- package/components/PhotoChooser/index.js +137 -0
- package/components/Pill/index.js +46 -0
- package/components/Pill/styles.scss +50 -0
- package/components/PillList/index.js +29 -0
- package/components/PillList/styles.scss +12 -0
- package/components/PlacementWrapper/index.js +63 -0
- package/components/PopoverMenu/Popover.js +88 -0
- package/components/PopoverMenu/index.js +59 -0
- package/components/PopoverMultiSelect/index.js +62 -0
- package/components/PopoverMultiSelect/styles.scss +10 -0
- package/components/ProgressCircle/ProgressCircle.js +34 -0
- package/components/ProgressCircle/styles.scss +87 -0
- package/components/RadioButton.js +25 -0
- package/components/Select/Select.js +19 -0
- package/components/Select/SelectT.js +245 -0
- package/components/Select/styles.scss +307 -0
- package/components/Separator/index.js +21 -0
- package/components/Size.js +5 -0
- package/components/Slider/index.js +60 -0
- package/components/SummaryBox.js +73 -0
- package/components/Tabs/index.js +111 -0
- package/components/TextTruncated/index.js +146 -0
- package/components/Textfield/Textfield.js +172 -0
- package/components/Textfield/TruncatedTextArea.js +71 -0
- package/components/Textfield/styles.scss +271 -0
- package/components/Tooltip/Tooltip.js +54 -0
- package/components/ViewPhotosDialog/index.js +136 -0
- package/components/ViewPhotosDialog/styles.scss +18 -0
- package/components/svg/BlobbyGrayIconImage.js +39 -0
- package/components/svg/BlobbyGrayIconImport.js +39 -0
- package/components/svg/BlobbyGrayIconUploadToTheCloud.js +39 -0
- package/components/svg/BlobbyIconCloudChecked.js +156 -0
- package/components/svg/BlobbyIconExportOrUploadPhoto.js +156 -0
- package/components/svg/BlobbyIconFolder.js +156 -0
- package/components/svg/BlobbyIconGraphReport.js +156 -0
- package/components/svg/BlobbyIconHappy.js +156 -0
- package/components/svg/BlobbyIconHeartMonitor.js +156 -0
- package/components/svg/BlobbyIconLeaf.js +156 -0
- package/components/svg/BlobbyIconLibrary.js +156 -0
- package/components/svg/BlobbyIconNursery.js +158 -0
- package/components/svg/BlobbyIconOrganization.js +156 -0
- package/components/svg/BlobbyIconParchment.js +156 -0
- package/components/svg/BlobbyIconPeople.js +156 -0
- package/components/svg/BlobbyIconSeedBank.js +156 -0
- package/components/svg/BlobbyIconSeedling.js +156 -0
- package/components/svg/BlobbyIconSeeds.js +156 -0
- package/components/svg/BlobbyIconSite.js +159 -0
- package/components/svg/BlobbyIconSparkles.js +156 -0
- package/components/svg/BlobbyIconWrench.js +156 -0
- package/components/svg/Bug.js +25 -0
- package/components/svg/Calendar.js +25 -0
- package/components/svg/CaretDown.js +25 -0
- package/components/svg/CaretLeft.js +25 -0
- package/components/svg/CaretRight.js +25 -0
- package/components/svg/CaretUp.js +25 -0
- package/components/svg/ChevronDown.js +25 -0
- package/components/svg/ChevronUp.js +25 -0
- package/components/svg/Close.js +25 -0
- package/components/svg/Critical.js +25 -0
- package/components/svg/Edit.js +156 -0
- package/components/svg/Error.js +25 -0
- package/components/svg/Filter.js +25 -0
- package/components/svg/Folder.js +25 -0
- package/components/svg/Help.js +25 -0
- package/components/svg/Home.js +25 -0
- package/components/svg/IconAdd.js +25 -0
- package/components/svg/IconArrowRight.js +27 -0
- package/components/svg/IconBusinessNetwork.js +25 -0
- package/components/svg/IconCancel.js +25 -0
- package/components/svg/IconChargingBattery.js +25 -0
- package/components/svg/IconCheckmark.js +25 -0
- package/components/svg/IconCoinInHand.js +25 -0
- package/components/svg/IconColumns.js +25 -0
- package/components/svg/IconComment.js +26 -0
- package/components/svg/IconDashboard.js +25 -0
- package/components/svg/IconDataMigration.js +25 -0
- package/components/svg/IconEdit.js +27 -0
- package/components/svg/IconExport.js +25 -0
- package/components/svg/IconExternalLink.js +25 -0
- package/components/svg/IconEye.js +25 -0
- package/components/svg/IconEyeOff.js +25 -0
- package/components/svg/IconFile.js +25 -0
- package/components/svg/IconFolder.js +25 -0
- package/components/svg/IconFullScreen.js +26 -0
- package/components/svg/IconFutures.js +25 -0
- package/components/svg/IconGraphReport.js +25 -0
- package/components/svg/IconHeartMonitor.js +25 -0
- package/components/svg/IconHelp.js +27 -0
- package/components/svg/IconHistory.js +25 -0
- package/components/svg/IconImport.js +25 -0
- package/components/svg/IconIndex.js +25 -0
- package/components/svg/IconLayers.js +25 -0
- package/components/svg/IconLibrary.js +26 -0
- package/components/svg/IconList.js +25 -0
- package/components/svg/IconLivePlant.js +25 -0
- package/components/svg/IconLocations.js +25 -0
- package/components/svg/IconMail.js +25 -0
- package/components/svg/IconManager.js +25 -0
- package/components/svg/IconMarker.js +25 -0
- package/components/svg/IconMenu.js +25 -0
- package/components/svg/IconMenuHorizontal.js +25 -0
- package/components/svg/IconModule.js +25 -0
- package/components/svg/IconMyLocation.js +25 -0
- package/components/svg/IconNote.js +27 -0
- package/components/svg/IconNursery.js +27 -0
- package/components/svg/IconOrg.js +25 -0
- package/components/svg/IconParchment.js +25 -0
- package/components/svg/IconPhoto.js +25 -0
- package/components/svg/IconRedo.js +25 -0
- package/components/svg/IconRestorationSite.js +25 -0
- package/components/svg/IconSeedBank.js +25 -0
- package/components/svg/IconSeedling.js +25 -0
- package/components/svg/IconSettings.js +25 -0
- package/components/svg/IconSlice.js +25 -0
- package/components/svg/IconSubmit.js +25 -0
- package/components/svg/IconSubtract.js +27 -0
- package/components/svg/IconSynced.js +25 -0
- package/components/svg/IconTrashCan.js +25 -0
- package/components/svg/IconTreasureMap.js +25 -0
- package/components/svg/IconUndo.js +25 -0
- package/components/svg/IconVariable.js +25 -0
- package/components/svg/IconWifi.js +25 -0
- package/components/svg/Info.js +25 -0
- package/components/svg/Key.js +25 -0
- package/components/svg/Leaf.js +25 -0
- package/components/svg/Lock.js +25 -0
- package/components/svg/Logo.js +43 -0
- package/components/svg/MenuVertical.js +25 -0
- package/components/svg/Notification.js +25 -0
- package/components/svg/Person.js +25 -0
- package/components/svg/Plus.js +25 -0
- package/components/svg/RestorationSite.js +25 -0
- package/components/svg/Search.js +25 -0
- package/components/svg/Seeds.js +25 -0
- package/components/svg/Site.js +25 -0
- package/components/svg/Sparkles.js +25 -0
- package/components/svg/Species.js +25 -0
- package/components/svg/Species2.js +156 -0
- package/components/svg/Spinner.js +52 -0
- package/components/svg/Success.js +25 -0
- package/components/svg/SuccessFilled.js +25 -0
- package/components/svg/TerrawareLogoDesktop.js +49 -0
- package/components/svg/TerrawareLogoMobile.js +30 -0
- package/components/svg/Touchscreen.js +25 -0
- package/components/svg/UploadCloud.js +156 -0
- package/components/svg/Warning.js +25 -0
- package/components/svg/WelcomeClipboard.js +133 -0
- package/components/svg/index.js +832 -0
- package/components/table/EnhancedTableToolbar.js +76 -0
- package/components/table/EnhancedTableToolbarV2.js +49 -0
- package/components/table/TableCellRenderer.js +244 -0
- package/components/table/TableHeader.js +75 -0
- package/components/table/TableHeaderItem.js +100 -0
- package/components/table/density.js +28 -0
- package/components/table/index.js +346 -0
- package/components/table/sort.js +72 -0
- package/components/table/sort.test.js +37 -0
- package/components/table/types.js +5 -0
- package/components/types/index.js +5 -0
- package/fonts/Inter.ttf +0 -0
- package/index.css +11 -0
- package/index.js +377 -0
- package/package.json +2 -5
- package/setupTests.js +5 -0
- package/style-dictionary-dist/TerrawareTheme.js +193 -0
- package/style-dictionary-dist/terraware.scss +414 -0
- package/theme.js +86 -0
- package/utils/date.js +124 -0
- package/utils/date.test.js +87 -0
- package/utils/index.js +53 -0
- package/utils/preventDefaultEvent.js +8 -0
- package/utils/text.js +17 -0
- package/utils/text.test.js +23 -0
- package/utils/useDeviceInfo.js +85 -0
- package/index.cjs.js +0 -88606
- package/index.cjs.js.map +0 -1
- package/index.esm.js +0 -88533
- package/index.esm.js.map +0 -1
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = Message;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _utils = require("../../utils");
|
|
10
|
+
var _Icon = _interopRequireDefault(require("../Icon/Icon"));
|
|
11
|
+
require("./styles.scss");
|
|
12
|
+
function Message(props) {
|
|
13
|
+
const {
|
|
14
|
+
type,
|
|
15
|
+
priority,
|
|
16
|
+
title,
|
|
17
|
+
body,
|
|
18
|
+
actionText,
|
|
19
|
+
actionHandler,
|
|
20
|
+
pageButtons,
|
|
21
|
+
showCloseButton,
|
|
22
|
+
onClose
|
|
23
|
+
} = props;
|
|
24
|
+
const {
|
|
25
|
+
isMobile
|
|
26
|
+
} = (0, _utils.useDeviceInfo)();
|
|
27
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
28
|
+
className: "tw-message tw-message--".concat(type, " tw-message--").concat(priority, " ").concat(isMobile ? 'tw-message--mobile' : '')
|
|
29
|
+
}, type === 'toast' && /*#__PURE__*/_react.default.createElement("div", {
|
|
30
|
+
className: "tw-message--left-side"
|
|
31
|
+
}, /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
32
|
+
name: priority,
|
|
33
|
+
className: "left-side--icon"
|
|
34
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
35
|
+
className: "tw-message--container"
|
|
36
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
37
|
+
className: "tw-message--main-content"
|
|
38
|
+
}, type === 'page' && /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
39
|
+
name: priority,
|
|
40
|
+
className: "main-content--icon"
|
|
41
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
42
|
+
className: "tw-message--main-body"
|
|
43
|
+
}, title && /*#__PURE__*/_react.default.createElement("div", {
|
|
44
|
+
className: "tw-message--title-container"
|
|
45
|
+
}, /*#__PURE__*/_react.default.createElement("h4", null, title)), typeof body === 'string' ? /*#__PURE__*/_react.default.createElement("p", null, body) : body, type === 'page' && pageButtons && pageButtons.length > 0 ? /*#__PURE__*/_react.default.createElement("div", {
|
|
46
|
+
className: "tw-message--actions-container"
|
|
47
|
+
}, pageButtons === null || pageButtons === void 0 ? void 0 : pageButtons.map((pageButton, index) => {
|
|
48
|
+
const pageButtonWithKey = {
|
|
49
|
+
...pageButton,
|
|
50
|
+
key: "page-button-".concat(index),
|
|
51
|
+
props: {
|
|
52
|
+
...pageButton.props,
|
|
53
|
+
size: pageButton.props.size || 'medium'
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
return pageButtonWithKey;
|
|
57
|
+
})) : null)), type === 'toast' && actionText ? /*#__PURE__*/_react.default.createElement("button", {
|
|
58
|
+
onClick: actionHandler,
|
|
59
|
+
className: "tw-message--action-text"
|
|
60
|
+
}, actionText) : showCloseButton ? /*#__PURE__*/_react.default.createElement("button", {
|
|
61
|
+
onClick: onClose,
|
|
62
|
+
className: "icon-container"
|
|
63
|
+
}, /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
64
|
+
name: "close",
|
|
65
|
+
className: "page-message--close-icon"
|
|
66
|
+
})) : null));
|
|
67
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
@import '../../style-dictionary-dist/terraware.scss';
|
|
2
|
+
|
|
3
|
+
@font-face {
|
|
4
|
+
font-family: 'Inter';
|
|
5
|
+
src: local('Inter'), url(../../fonts/Inter.ttf) format('truetype');
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.tw-message {
|
|
9
|
+
&.tw-message--page {
|
|
10
|
+
width: 100%;
|
|
11
|
+
&.tw-message--container {
|
|
12
|
+
margin: $tw-spc-base-small 0;
|
|
13
|
+
}
|
|
14
|
+
&.tw-message--title-container {
|
|
15
|
+
display: flex;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
border-radius: $tw-sz-base-small;
|
|
20
|
+
display: flex;
|
|
21
|
+
width: 480px;
|
|
22
|
+
|
|
23
|
+
&.tw-message--mobile {
|
|
24
|
+
width: 100%;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&.tw-message--toast {
|
|
28
|
+
box-shadow: 0 $tw-sz-base-x-small $tw-sz-base-small 0 rgba($tw-clr-base-gray-800, $tw-opcty-base-020);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&--container {
|
|
32
|
+
margin: $tw-spc-base-small;
|
|
33
|
+
display: flex;
|
|
34
|
+
justify-content: space-between;
|
|
35
|
+
width: 100%;
|
|
36
|
+
}
|
|
37
|
+
&--title-container {
|
|
38
|
+
h4 {
|
|
39
|
+
font-family: $tw-fnt-mssg-title-font-family;
|
|
40
|
+
font-size: $tw-fnt-mssg-title-font-size;
|
|
41
|
+
font-weight: $tw-fnt-mssg-title-font-weight;
|
|
42
|
+
line-height: $tw-fnt-mssg-title-line-height;
|
|
43
|
+
color: $tw-clr-txt;
|
|
44
|
+
padding: 0;
|
|
45
|
+
margin: 0 0 $tw-spc-base-x-small;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&--main-content {
|
|
50
|
+
display: flex;
|
|
51
|
+
width: 100%;
|
|
52
|
+
|
|
53
|
+
p {
|
|
54
|
+
font-family: $tw-fnt-mssg-body-font-family;
|
|
55
|
+
font-size: $tw-fnt-mssg-body-font-size;
|
|
56
|
+
font-weight: $tw-fnt-mssg-body-font-weight;
|
|
57
|
+
line-height: $tw-fnt-mssg-body-line-height;
|
|
58
|
+
color: $tw-clr-txt;
|
|
59
|
+
padding: 0;
|
|
60
|
+
margin: 0;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.main-content--icon {
|
|
64
|
+
width: $tw-sz-base-medium;
|
|
65
|
+
height: $tw-sz-base-medium;
|
|
66
|
+
margin-right: $tw-spc-base-small;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
&--main-body {
|
|
71
|
+
width: 100%;
|
|
72
|
+
display: flex;
|
|
73
|
+
flex-direction: column;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
&--actions-container {
|
|
77
|
+
align-self: end;
|
|
78
|
+
|
|
79
|
+
button:first-child {
|
|
80
|
+
margin-right: $tw-spc-base-x-small;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
&--action-text {
|
|
85
|
+
font-family: $tw-fnt-mssg-body-font-family;
|
|
86
|
+
font-size: $tw-fnt-mssg-body-font-size;
|
|
87
|
+
font-weight: $tw-fnt-mssg-body-font-weight;
|
|
88
|
+
line-height: $tw-fnt-mssg-body-line-height;
|
|
89
|
+
color: $tw-clr-txt-brand;
|
|
90
|
+
margin-left: $tw-spc-base-x-small;
|
|
91
|
+
background: none;
|
|
92
|
+
border: 0;
|
|
93
|
+
cursor: pointer;
|
|
94
|
+
height: fit-content;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
&--left-side {
|
|
98
|
+
border-radius: ($tw-sz-base-small - 1) 0 0 ($tw-sz-base-small - 1);
|
|
99
|
+
padding: $tw-spc-base-small $tw-spc-base-small 0 $tw-spc-base-small;
|
|
100
|
+
.left-side--icon {
|
|
101
|
+
fill: $tw-clr-icn-inverse;
|
|
102
|
+
width: $tw-sz-base-medium;
|
|
103
|
+
height: $tw-sz-base-medium;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.toast-message--close-icon {
|
|
108
|
+
margin-left: $tw-spc-base-x-small;
|
|
109
|
+
fill: $tw-clr-icn-secondary;
|
|
110
|
+
width: $tw-sz-base-medium;
|
|
111
|
+
height: $tw-sz-base-medium;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.page-message--close-icon {
|
|
115
|
+
margin-left: $tw-spc-base-x-small;
|
|
116
|
+
fill: $tw-clr-icn-secondary;
|
|
117
|
+
width: $tw-sz-base-medium;
|
|
118
|
+
height: $tw-sz-base-medium;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.icon-container {
|
|
122
|
+
background: none;
|
|
123
|
+
border: 0;
|
|
124
|
+
cursor: pointer;
|
|
125
|
+
height: fit-content;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
&--info {
|
|
129
|
+
border: 1px solid $tw-clr-brdr-info;
|
|
130
|
+
background-color: $tw-clr-bg-info-tertiary;
|
|
131
|
+
|
|
132
|
+
&.tw-message--page {
|
|
133
|
+
border: 1px solid $tw-clr-brdr-info;
|
|
134
|
+
.main-content--icon {
|
|
135
|
+
fill: $tw-clr-icn-info;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
.tw-message--left-side {
|
|
139
|
+
background-color: $tw-clr-bg-info;
|
|
140
|
+
}
|
|
141
|
+
.left-side--icon {
|
|
142
|
+
fill: $tw-clr-icn-on-info;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
&--critical {
|
|
147
|
+
border: 1px solid $tw-clr-brdr-danger;
|
|
148
|
+
background-color: $tw-clr-bg-danger-tertiary;
|
|
149
|
+
|
|
150
|
+
&.tw-message--page {
|
|
151
|
+
border: 1px solid $tw-clr-brdr-danger;
|
|
152
|
+
|
|
153
|
+
.main-content--icon {
|
|
154
|
+
fill: $tw-clr-icn-danger;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
.tw-message--left-side {
|
|
158
|
+
background-color: $tw-clr-bg-danger;
|
|
159
|
+
}
|
|
160
|
+
.left-side--icon {
|
|
161
|
+
fill: $tw-clr-icn-on-danger;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
&--warning {
|
|
166
|
+
border: 1px solid $tw-clr-brdr-warning;
|
|
167
|
+
background-color: $tw-clr-bg-warning-tertiary;
|
|
168
|
+
|
|
169
|
+
&.tw-message--page {
|
|
170
|
+
border: 1px solid $tw-clr-brdr-warning;
|
|
171
|
+
|
|
172
|
+
.main-content--icon {
|
|
173
|
+
fill: $tw-clr-icn-warning;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
.tw-message--left-side {
|
|
177
|
+
background-color: $tw-clr-bg-warning;
|
|
178
|
+
}
|
|
179
|
+
.left-side--icon {
|
|
180
|
+
fill: $tw-clr-icn-on-warning;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
&--success {
|
|
185
|
+
border: 1px solid $tw-clr-brdr-success;
|
|
186
|
+
background-color: $tw-clr-bg-success-tertiary;
|
|
187
|
+
|
|
188
|
+
&.tw-message--page {
|
|
189
|
+
border: 1px solid $tw-clr-brdr-success;
|
|
190
|
+
|
|
191
|
+
.main-content--icon {
|
|
192
|
+
fill: $tw-clr-icn-success;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
.tw-message--left-side {
|
|
196
|
+
background-color: $tw-clr-bg-success;
|
|
197
|
+
}
|
|
198
|
+
.left-side--icon {
|
|
199
|
+
fill: $tw-clr-icn-on-success;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _react = _interopRequireDefault(require("react"));
|
|
5
|
+
var _react2 = require("@testing-library/react");
|
|
6
|
+
var _ = _interopRequireDefault(require("."));
|
|
7
|
+
test('show options when placeholder is clicked', () => {
|
|
8
|
+
(0, _react2.render)( /*#__PURE__*/_react.default.createElement(_.default, {
|
|
9
|
+
onAdd: () => undefined,
|
|
10
|
+
onRemove: () => undefined,
|
|
11
|
+
options: new Map([[1, 'foo'], [2, 'bar'], [3, 'baz']]),
|
|
12
|
+
valueRenderer: v => v,
|
|
13
|
+
selectedOptions: [],
|
|
14
|
+
placeHolder: "Select..."
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
// we should find the placeholder text
|
|
18
|
+
const placeHolder = _react2.screen.getByText('Select...');
|
|
19
|
+
expect(placeHolder).toBeInTheDocument();
|
|
20
|
+
|
|
21
|
+
// we should not find the options yet
|
|
22
|
+
expect(_react2.screen.queryByText('foo')).not.toBeInTheDocument();
|
|
23
|
+
expect(_react2.screen.queryByText('bar')).not.toBeInTheDocument();
|
|
24
|
+
expect(_react2.screen.queryByText('baz')).not.toBeInTheDocument();
|
|
25
|
+
|
|
26
|
+
// click the placeholder
|
|
27
|
+
_react2.fireEvent.click(placeHolder);
|
|
28
|
+
|
|
29
|
+
// now the options should be visible
|
|
30
|
+
expect(_react2.screen.queryByText('foo')).toBeInTheDocument();
|
|
31
|
+
expect(_react2.screen.queryByText('bar')).toBeInTheDocument();
|
|
32
|
+
expect(_react2.screen.queryByText('baz')).toBeInTheDocument();
|
|
33
|
+
});
|
|
34
|
+
test('clicking an option calls the onAdd handler', () => {
|
|
35
|
+
const handleAdd = jest.fn();
|
|
36
|
+
(0, _react2.render)( /*#__PURE__*/_react.default.createElement(_.default, {
|
|
37
|
+
onAdd: handleAdd,
|
|
38
|
+
onRemove: () => undefined,
|
|
39
|
+
options: new Map([[1, 'foo'], [2, 'bar'], [3, 'baz']]),
|
|
40
|
+
valueRenderer: v => v,
|
|
41
|
+
selectedOptions: [],
|
|
42
|
+
placeHolder: "Select..."
|
|
43
|
+
}));
|
|
44
|
+
|
|
45
|
+
// click the dropdown chevron
|
|
46
|
+
const dropdown = _react2.screen.getByLabelText('show-options');
|
|
47
|
+
_react2.fireEvent.click(dropdown);
|
|
48
|
+
|
|
49
|
+
// click one of the options
|
|
50
|
+
const option = _react2.screen.getByText('bar');
|
|
51
|
+
_react2.fireEvent.click(option);
|
|
52
|
+
|
|
53
|
+
// addHandler should have been called with id 2
|
|
54
|
+
expect(handleAdd).toBeCalledWith(2);
|
|
55
|
+
});
|
|
56
|
+
test('clicking the pill remove button calls the onRemove handler', () => {
|
|
57
|
+
const handleRemove = jest.fn();
|
|
58
|
+
(0, _react2.render)( /*#__PURE__*/_react.default.createElement(_.default, {
|
|
59
|
+
onAdd: () => undefined,
|
|
60
|
+
onRemove: handleRemove,
|
|
61
|
+
options: new Map([[1, 'foo']]),
|
|
62
|
+
valueRenderer: v => v,
|
|
63
|
+
selectedOptions: [1]
|
|
64
|
+
}));
|
|
65
|
+
|
|
66
|
+
// find a pill with the 'foo' text
|
|
67
|
+
expect(_react2.screen.queryByText('foo')).toBeInTheDocument();
|
|
68
|
+
|
|
69
|
+
// click the remove button
|
|
70
|
+
const removeButton = _react2.screen.getByLabelText('remove');
|
|
71
|
+
_react2.fireEvent.click(removeButton);
|
|
72
|
+
|
|
73
|
+
// handleRemove should have been called with id 1
|
|
74
|
+
expect(handleRemove).toBeCalledWith(1);
|
|
75
|
+
});
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = MultiSelect;
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _material = require("@mui/material");
|
|
11
|
+
var _Icon = _interopRequireDefault(require("../Icon/Icon"));
|
|
12
|
+
var _IconTooltip = _interopRequireDefault(require("../IconTooltip"));
|
|
13
|
+
var _PillList = _interopRequireDefault(require("../PillList"));
|
|
14
|
+
require("./styles.scss");
|
|
15
|
+
function MultiSelect(props) {
|
|
16
|
+
const {
|
|
17
|
+
className,
|
|
18
|
+
disabled,
|
|
19
|
+
fullWidth,
|
|
20
|
+
helperText,
|
|
21
|
+
errorText,
|
|
22
|
+
id,
|
|
23
|
+
label,
|
|
24
|
+
missingValuePlaceholder,
|
|
25
|
+
onAdd,
|
|
26
|
+
onRemove,
|
|
27
|
+
onPillClick,
|
|
28
|
+
options,
|
|
29
|
+
optionsVisible,
|
|
30
|
+
pillListClassName,
|
|
31
|
+
placeHolder,
|
|
32
|
+
selectedOptions,
|
|
33
|
+
sx,
|
|
34
|
+
tooltipTitle,
|
|
35
|
+
valueRenderer
|
|
36
|
+
} = props;
|
|
37
|
+
const [openedOptions, setOpenedOptions] = (0, _react.useState)(false);
|
|
38
|
+
const toggleOptions = () => {
|
|
39
|
+
setOpenedOptions(isOpen => !isOpen && !disabled);
|
|
40
|
+
if (props.onFocus) {
|
|
41
|
+
props.onFocus();
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
(0, _react.useEffect)(() => {
|
|
45
|
+
if (optionsVisible !== undefined) {
|
|
46
|
+
setOpenedOptions(optionsVisible);
|
|
47
|
+
}
|
|
48
|
+
}, [optionsVisible]);
|
|
49
|
+
const onBlurHandler = event => {
|
|
50
|
+
// In Chrome > 126, the onBlur event will fire even if you are clicking _within_ the focused element
|
|
51
|
+
// If this is the case, we do not actually want to blur
|
|
52
|
+
if (event.currentTarget.contains(event.relatedTarget)) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
setOpenedOptions(false);
|
|
56
|
+
if (props.onBlur) {
|
|
57
|
+
props.onBlur();
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
const unselectedOptions = Array.from(options.keys()).filter(key => !selectedOptions.includes(key));
|
|
61
|
+
const valuesPillData = selectedOptions.map(item => {
|
|
62
|
+
const value = options.get(item);
|
|
63
|
+
return {
|
|
64
|
+
id: item,
|
|
65
|
+
value: value ? valueRenderer(value) : missingValuePlaceholder || ''
|
|
66
|
+
};
|
|
67
|
+
}).filter(data => data.value);
|
|
68
|
+
return /*#__PURE__*/_react.default.createElement(_material.Box, {
|
|
69
|
+
className: "multi-select ".concat(className),
|
|
70
|
+
sx: sx
|
|
71
|
+
}, label && /*#__PURE__*/_react.default.createElement("label", {
|
|
72
|
+
htmlFor: id,
|
|
73
|
+
className: "multi-select__label"
|
|
74
|
+
}, label, " ", tooltipTitle && /*#__PURE__*/_react.default.createElement(_IconTooltip.default, {
|
|
75
|
+
title: tooltipTitle
|
|
76
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
77
|
+
className: "multi-select__container ".concat(fullWidth ? 'multi-select__container--fullWidth' : ''),
|
|
78
|
+
onBlur: onBlurHandler,
|
|
79
|
+
tabIndex: 0
|
|
80
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
81
|
+
id: id,
|
|
82
|
+
className: "multi-select__values".concat(disabled ? '--disabled' : '').concat(openedOptions ? ' open' : '').concat(errorText ? ' error' : ''),
|
|
83
|
+
onClick: toggleOptions
|
|
84
|
+
}, selectedOptions.length > 0 ? /*#__PURE__*/_react.default.createElement(_PillList.default, {
|
|
85
|
+
data: valuesPillData,
|
|
86
|
+
onRemove: onRemove,
|
|
87
|
+
onClick: onPillClick,
|
|
88
|
+
className: pillListClassName
|
|
89
|
+
}) : /*#__PURE__*/_react.default.createElement("p", {
|
|
90
|
+
className: "multi-select__placeholder-text"
|
|
91
|
+
}, placeHolder), /*#__PURE__*/_react.default.createElement("div", {
|
|
92
|
+
className: 'multi-select__values__icon-button',
|
|
93
|
+
"aria-label": "show-options"
|
|
94
|
+
}, /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
95
|
+
name: openedOptions ? 'chevronUp' : 'chevronDown',
|
|
96
|
+
className: "multi-select__values__icon-right".concat(disabled ? '--disabled' : '')
|
|
97
|
+
}))), options && unselectedOptions.length > 0 && openedOptions && /*#__PURE__*/_react.default.createElement("div", {
|
|
98
|
+
className: "multi-select__options-container"
|
|
99
|
+
}, /*#__PURE__*/_react.default.createElement("ul", {
|
|
100
|
+
className: 'multi-select__options'
|
|
101
|
+
}, unselectedOptions.map((optionKey, index) => {
|
|
102
|
+
const optionValue = options.get(optionKey);
|
|
103
|
+
return /*#__PURE__*/_react.default.createElement("li", {
|
|
104
|
+
key: index,
|
|
105
|
+
className: "select-value",
|
|
106
|
+
onClick: () => onAdd(optionKey)
|
|
107
|
+
}, optionValue ? valueRenderer(optionValue) : missingValuePlaceholder || '');
|
|
108
|
+
})))), helperText && /*#__PURE__*/_react.default.createElement("label", {
|
|
109
|
+
htmlFor: id,
|
|
110
|
+
className: "multi-select__help-text"
|
|
111
|
+
}, helperText), errorText && /*#__PURE__*/_react.default.createElement("div", {
|
|
112
|
+
className: "multi-select__error"
|
|
113
|
+
}, /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
114
|
+
name: "error",
|
|
115
|
+
className: "multi-select__error-icon"
|
|
116
|
+
}), /*#__PURE__*/_react.default.createElement("label", {
|
|
117
|
+
htmlFor: id,
|
|
118
|
+
className: "multi-select__error-text"
|
|
119
|
+
}, errorText)));
|
|
120
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
@import '../../style-dictionary-dist/terraware.scss';
|
|
2
|
+
|
|
3
|
+
@font-face {
|
|
4
|
+
font-family: 'Inter';
|
|
5
|
+
src: local('Inter'), url(../../fonts/Inter.ttf) format('truetype');
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.multi-select {
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-direction: column;
|
|
11
|
+
|
|
12
|
+
.multi-select__container {
|
|
13
|
+
position: relative;
|
|
14
|
+
width: 228px;
|
|
15
|
+
cursor: pointer;
|
|
16
|
+
|
|
17
|
+
&--fullWidth {
|
|
18
|
+
position: relative;
|
|
19
|
+
width: 100%;
|
|
20
|
+
cursor: pointer;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.multi-select__label {
|
|
25
|
+
font-family: $tw-fnt-frm-fld-label-font-family;
|
|
26
|
+
font-size: $tw-fnt-frm-fld-label-font-size;
|
|
27
|
+
font-weight: $tw-fnt-frm-fld-label-font-weight;
|
|
28
|
+
line-height: $tw-fnt-frm-fld-label-line-height;
|
|
29
|
+
color: $tw-clr-txt-secondary;
|
|
30
|
+
margin-bottom: $tw-spc-base-xx-small;
|
|
31
|
+
display: block;
|
|
32
|
+
width: 100%;
|
|
33
|
+
max-width: 100%;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.multi-select__error {
|
|
37
|
+
display: flex;
|
|
38
|
+
width: 100%;
|
|
39
|
+
margin-top: $tw-spc-base-xx-small;
|
|
40
|
+
|
|
41
|
+
&-text {
|
|
42
|
+
font-family: $tw-fnt-frm-fld-error-text-font-family;
|
|
43
|
+
font-size: $tw-fnt-frm-fld-error-text-font-size;
|
|
44
|
+
font-weight: $tw-fnt-frm-fld-error-text-font-weight;
|
|
45
|
+
line-height: $tw-fnt-frm-fld-error-text-line-height;
|
|
46
|
+
color: $tw-clr-txt-danger;
|
|
47
|
+
display: block;
|
|
48
|
+
width: 100%;
|
|
49
|
+
max-width: 100%;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
&-icon {
|
|
53
|
+
fill: $tw-clr-icn-danger;
|
|
54
|
+
width: $tw-fnt-frm-fld-error-text-line-height;
|
|
55
|
+
height: $tw-fnt-frm-fld-error-text-line-height;
|
|
56
|
+
margin-right: $tw-spc-base-x-small;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.multi-select__help-text {
|
|
61
|
+
font-family: $tw-fnt-frm-fld-help-text-font-family;
|
|
62
|
+
font-size: $tw-fnt-frm-fld-help-text-font-size;
|
|
63
|
+
font-weight: $tw-fnt-frm-fld-help-text-font-weight;
|
|
64
|
+
line-height: $tw-fnt-frm-fld-help-text-line-height;
|
|
65
|
+
color: $tw-clr-txt-secondary;
|
|
66
|
+
display: block;
|
|
67
|
+
width: 100%;
|
|
68
|
+
max-width: 100%;
|
|
69
|
+
margin-top: $tw-spc-base-xx-small;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.multi-select__placeholder-text {
|
|
73
|
+
font-family: $tw-fnt-frm-fld-text-value-font-family;
|
|
74
|
+
font-size: $tw-fnt-frm-fld-text-value-font-size;
|
|
75
|
+
font-weight: $tw-fnt-frm-fld-text-value-font-weight;
|
|
76
|
+
line-height: $tw-fnt-frm-fld-text-value-line-height;
|
|
77
|
+
color: $tw-clr-txt-tertiary;
|
|
78
|
+
margin: 0;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.multi-select__values {
|
|
82
|
+
background-color: $tw-clr-bg;
|
|
83
|
+
border: $tw-sz-frm-fld-text-input-stroke solid $tw-clr-brdr-secondary;
|
|
84
|
+
padding: #{$tw-spc-base-x-small - $tw-sz-frm-fld-text-input-stroke};
|
|
85
|
+
border-radius: $tw-sz-base-x-small;
|
|
86
|
+
border-width: $tw-sz-frm-fld-text-input-stroke;
|
|
87
|
+
display: flex;
|
|
88
|
+
align-items: flex-start;
|
|
89
|
+
justify-content: space-between;
|
|
90
|
+
|
|
91
|
+
&:hover {
|
|
92
|
+
border: $tw-sz-frm-fld-text-input-stroke solid $tw-clr-brdr-hover;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
&.open {
|
|
96
|
+
border: $tw-sz-frm-fld-text-input-stroke solid $tw-clr-brdr-active;
|
|
97
|
+
outline: $tw-sz-frm-fld-text-input-stroke-active solid $tw-clr-brdr-active;
|
|
98
|
+
outline-offset: -$tw-sz-frm-fld-text-input-stroke;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
&.error {
|
|
102
|
+
border: $tw-sz-frm-fld-text-input-stroke solid $tw-clr-brdr-danger;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
&--disabled {
|
|
106
|
+
background-color: $tw-clr-bg;
|
|
107
|
+
border: $tw-sz-frm-fld-text-input-stroke solid $tw-clr-brdr-tertiary;
|
|
108
|
+
padding: #{$tw-spc-base-x-small - $tw-sz-frm-fld-text-input-stroke};
|
|
109
|
+
border-radius: $tw-sz-base-x-small;
|
|
110
|
+
border-width: $tw-sz-frm-fld-text-input-stroke;
|
|
111
|
+
display: flex;
|
|
112
|
+
align-items: flex-start;
|
|
113
|
+
justify-content: space-between;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
&__icon-button {
|
|
117
|
+
width: $tw-fnt-frm-fld-text-value-line-height;
|
|
118
|
+
height: $tw-fnt-frm-fld-text-value-line-height;
|
|
119
|
+
padding: 0;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
&__icon-right {
|
|
123
|
+
width: $tw-fnt-frm-fld-text-value-line-height;
|
|
124
|
+
height: $tw-fnt-frm-fld-text-value-line-height;
|
|
125
|
+
fill: $tw-clr-icn;
|
|
126
|
+
flex-shrink: 0;
|
|
127
|
+
|
|
128
|
+
&--disabled {
|
|
129
|
+
width: $tw-fnt-frm-fld-text-value-line-height;
|
|
130
|
+
height: $tw-fnt-frm-fld-text-value-line-height;
|
|
131
|
+
fill: $tw-clr-icn-secondary;
|
|
132
|
+
flex-shrink: 0;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.multi-select__options-container {
|
|
138
|
+
position: relative;
|
|
139
|
+
height: 0;
|
|
140
|
+
width: 100%;
|
|
141
|
+
|
|
142
|
+
.multi-select__options {
|
|
143
|
+
z-index: 3;
|
|
144
|
+
width: calc(100% - 2px);
|
|
145
|
+
position: absolute;
|
|
146
|
+
top: 0px;
|
|
147
|
+
list-style-type: none;
|
|
148
|
+
padding: $tw-spc-base-x-small 0;
|
|
149
|
+
background: $tw-clr-bg;
|
|
150
|
+
border: 1px solid $tw-clr-brdr-secondary;
|
|
151
|
+
margin: $tw-spc-base-xx-small 0 0;
|
|
152
|
+
border-radius: $tw-sz-base-x-small;
|
|
153
|
+
max-height: 140px;
|
|
154
|
+
overflow-y: auto;
|
|
155
|
+
|
|
156
|
+
.select-value {
|
|
157
|
+
font-family: $tw-fnt-frm-fld-select-value-font-family;
|
|
158
|
+
font-size: $tw-fnt-frm-fld-select-value-font-size;
|
|
159
|
+
font-weight: $tw-fnt-frm-fld-select-value-font-weight;
|
|
160
|
+
line-height: $tw-fnt-frm-fld-select-value-line-height;
|
|
161
|
+
padding: $tw-spc-base-x-small $tw-spc-base-small;
|
|
162
|
+
cursor: pointer;
|
|
163
|
+
|
|
164
|
+
&:hover {
|
|
165
|
+
background-color: $tw-clr-bg-selected-ghost-hover;
|
|
166
|
+
color: $tw-clr-txt;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
&:active {
|
|
170
|
+
background-color: $tw-clr-bg-selected-ghost-active;
|
|
171
|
+
color: $tw-clr-txt;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
&--disabled {
|
|
175
|
+
opacity: $tw-opcty-semantic-off;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = NavFooter;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
require("./styles.scss");
|
|
10
|
+
function NavFooter(props) {
|
|
11
|
+
const {
|
|
12
|
+
children
|
|
13
|
+
} = props;
|
|
14
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
15
|
+
className: "nav-footer"
|
|
16
|
+
}, children);
|
|
17
|
+
}
|