@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,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = SummaryBox;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _iconsMaterial = require("@mui/icons-material");
|
|
10
|
+
var _material = require("@mui/material");
|
|
11
|
+
function SummaryBox(_ref) {
|
|
12
|
+
let {
|
|
13
|
+
title,
|
|
14
|
+
value,
|
|
15
|
+
variant = 'default',
|
|
16
|
+
id,
|
|
17
|
+
icon,
|
|
18
|
+
onIconClick
|
|
19
|
+
} = _ref;
|
|
20
|
+
const theme = (0, _material.useTheme)();
|
|
21
|
+
const summaryBoxStyles = (0, _react.useMemo)(() => {
|
|
22
|
+
switch (variant) {
|
|
23
|
+
case 'default':
|
|
24
|
+
return {
|
|
25
|
+
position: 'relative',
|
|
26
|
+
borderRadius: 8,
|
|
27
|
+
backgroundColor: theme.palette.neutral[200],
|
|
28
|
+
padding: theme.spacing(2)
|
|
29
|
+
};
|
|
30
|
+
case 'available':
|
|
31
|
+
return {
|
|
32
|
+
borderRadius: 8,
|
|
33
|
+
backgroundColor: theme.palette.neutral[700],
|
|
34
|
+
padding: theme.spacing(2),
|
|
35
|
+
color: theme.palette.common.white
|
|
36
|
+
};
|
|
37
|
+
case 'full':
|
|
38
|
+
return {
|
|
39
|
+
borderRadius: 8,
|
|
40
|
+
backgroundColor: theme.palette.neutral[200],
|
|
41
|
+
padding: theme.spacing(2),
|
|
42
|
+
height: '100%',
|
|
43
|
+
boxSizing: 'border-box'
|
|
44
|
+
};
|
|
45
|
+
default:
|
|
46
|
+
return {
|
|
47
|
+
borderRadius: 8,
|
|
48
|
+
backgroundColor: theme.palette.state[5],
|
|
49
|
+
padding: theme.spacing(2),
|
|
50
|
+
color: theme.palette.common.white
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}, [theme, variant]);
|
|
54
|
+
return /*#__PURE__*/_react.default.createElement(_material.Box, {
|
|
55
|
+
id: id,
|
|
56
|
+
sx: summaryBoxStyles
|
|
57
|
+
}, icon && /*#__PURE__*/_react.default.createElement(_material.IconButton, {
|
|
58
|
+
onClick: onIconClick,
|
|
59
|
+
sx: {
|
|
60
|
+
position: 'absolute',
|
|
61
|
+
right: theme.spacing(2)
|
|
62
|
+
}
|
|
63
|
+
}, /*#__PURE__*/_react.default.createElement(_iconsMaterial.Info, null)), /*#__PURE__*/_react.default.createElement(_material.Typography, {
|
|
64
|
+
component: "p"
|
|
65
|
+
}, title), /*#__PURE__*/_react.default.createElement(_material.Typography, {
|
|
66
|
+
component: "p",
|
|
67
|
+
variant: "h6",
|
|
68
|
+
sx: {
|
|
69
|
+
fontWeight: theme.typography.fontWeightBold,
|
|
70
|
+
whiteSpace: 'pre-line'
|
|
71
|
+
}
|
|
72
|
+
}, value));
|
|
73
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
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 = void 0;
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _lab = require("@mui/lab");
|
|
11
|
+
var _material = require("@mui/material");
|
|
12
|
+
var _utils = require("../../utils");
|
|
13
|
+
var _Icon = _interopRequireDefault(require("../Icon/Icon"));
|
|
14
|
+
const Tabs = _ref => {
|
|
15
|
+
var _ref2, _tabs$;
|
|
16
|
+
let {
|
|
17
|
+
activeTab,
|
|
18
|
+
onChangeTab,
|
|
19
|
+
tabs,
|
|
20
|
+
tabStyle,
|
|
21
|
+
headerBorder = false
|
|
22
|
+
} = _ref;
|
|
23
|
+
const [selectedTab, setSelectedTab] = (0, _react.useState)((_ref2 = activeTab !== null && activeTab !== void 0 ? activeTab : (_tabs$ = tabs[0]) === null || _tabs$ === void 0 ? void 0 : _tabs$.id) !== null && _ref2 !== void 0 ? _ref2 : '');
|
|
24
|
+
const theme = (0, _material.useTheme)();
|
|
25
|
+
const {
|
|
26
|
+
isMobile
|
|
27
|
+
} = (0, _utils.useDeviceInfo)();
|
|
28
|
+
const tabStyles = [{
|
|
29
|
+
color: theme.palette.TwClrTxtSecondary,
|
|
30
|
+
fontSize: '16px',
|
|
31
|
+
fontWeight: 600,
|
|
32
|
+
lineHeight: '24px',
|
|
33
|
+
minHeight: theme.spacing(4.5),
|
|
34
|
+
padding: theme.spacing(1, 2),
|
|
35
|
+
textTransform: 'capitalize',
|
|
36
|
+
'&:hover': {
|
|
37
|
+
backgroundColor: theme.palette.TwClrBgHover
|
|
38
|
+
},
|
|
39
|
+
'&.Mui-selected': {
|
|
40
|
+
color: theme.palette.TwClrTxtBrand
|
|
41
|
+
},
|
|
42
|
+
'&.MuiTab-labelIcon': {
|
|
43
|
+
alignItems: 'center',
|
|
44
|
+
display: 'flex',
|
|
45
|
+
flexDirection: 'row'
|
|
46
|
+
},
|
|
47
|
+
'& .MuiTab-iconWrapper': {
|
|
48
|
+
fill: theme.palette.TwClrIcnSecondary,
|
|
49
|
+
marginBottom: 0,
|
|
50
|
+
marginRight: theme.spacing(1)
|
|
51
|
+
},
|
|
52
|
+
'&.Mui-selected .MuiTab-iconWrapper': {
|
|
53
|
+
fill: theme.palette.TwClrIcnBrand
|
|
54
|
+
}
|
|
55
|
+
}, ...(Array.isArray(tabStyle) ? tabStyle : [tabStyle])];
|
|
56
|
+
const tabHeaderProps = {
|
|
57
|
+
borderBottom: headerBorder ? 1 : 0,
|
|
58
|
+
borderColor: 'divider',
|
|
59
|
+
margin: isMobile ? 0 : theme.spacing(0, 4)
|
|
60
|
+
};
|
|
61
|
+
const tabPanelStyles = {
|
|
62
|
+
padding: 0
|
|
63
|
+
};
|
|
64
|
+
const setTab = tab => {
|
|
65
|
+
if (onChangeTab) {
|
|
66
|
+
onChangeTab(tab);
|
|
67
|
+
} else {
|
|
68
|
+
setSelectedTab(tab);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
(0, _react.useEffect)(() => {
|
|
72
|
+
if (activeTab !== undefined) {
|
|
73
|
+
setSelectedTab(activeTab);
|
|
74
|
+
}
|
|
75
|
+
}, [activeTab]);
|
|
76
|
+
return /*#__PURE__*/_react.default.createElement(_material.Box, {
|
|
77
|
+
sx: {
|
|
78
|
+
width: '100%'
|
|
79
|
+
}
|
|
80
|
+
}, /*#__PURE__*/_react.default.createElement(_lab.TabContext, {
|
|
81
|
+
value: selectedTab
|
|
82
|
+
}, /*#__PURE__*/_react.default.createElement(_material.Box, {
|
|
83
|
+
sx: tabHeaderProps
|
|
84
|
+
}, /*#__PURE__*/_react.default.createElement(_lab.TabList, {
|
|
85
|
+
onChange: (unused, value) => setTab(value),
|
|
86
|
+
sx: {
|
|
87
|
+
minHeight: theme.spacing(4.5)
|
|
88
|
+
},
|
|
89
|
+
TabIndicatorProps: {
|
|
90
|
+
style: {
|
|
91
|
+
background: theme.palette.TwClrBgBrand,
|
|
92
|
+
height: '4px'
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
variant: 'scrollable'
|
|
96
|
+
}, tabs.map((tab, index) => /*#__PURE__*/_react.default.createElement(_material.Tab, {
|
|
97
|
+
disabled: tab.disabled,
|
|
98
|
+
icon: tab.icon ? /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
99
|
+
name: tab.icon
|
|
100
|
+
}) : undefined,
|
|
101
|
+
key: index,
|
|
102
|
+
label: tab.label,
|
|
103
|
+
sx: tabStyles,
|
|
104
|
+
value: tab.id
|
|
105
|
+
})))), tabs.map((tab, index) => /*#__PURE__*/_react.default.createElement(_lab.TabPanel, {
|
|
106
|
+
key: index,
|
|
107
|
+
sx: tabPanelStyles,
|
|
108
|
+
value: tab.id
|
|
109
|
+
}, tab.children))));
|
|
110
|
+
};
|
|
111
|
+
var _default = exports.default = Tabs;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = TextTruncated;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _material = require("@mui/material");
|
|
10
|
+
/**
|
|
11
|
+
* Represents the result of truncating the string list
|
|
12
|
+
* text: the text to display before the '...# more' link
|
|
13
|
+
* numberMore: the number to display in the '...# more' link
|
|
14
|
+
* has two special values
|
|
15
|
+
* 0: the full text can be displayed; do not show '...# more'
|
|
16
|
+
* -1: the list is of length one but the element cannot be fully
|
|
17
|
+
* displayed. show '...more' without a '#'
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Compute TextDisplay for a list of strings
|
|
22
|
+
* @param strings list of strings to process
|
|
23
|
+
* @param maxLength max displayable length
|
|
24
|
+
*/
|
|
25
|
+
function computeFromStringList(strings, maxLength, listSeparator) {
|
|
26
|
+
if (strings.length === 0) {
|
|
27
|
+
return {
|
|
28
|
+
text: '',
|
|
29
|
+
numberMore: 0
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
if (strings[0].length > maxLength) {
|
|
33
|
+
// case in which the first string is too long to fit by itself
|
|
34
|
+
return {
|
|
35
|
+
text: strings[0].substring(0, maxLength),
|
|
36
|
+
numberMore: strings.length === 1 ? -1 : strings.length - 1
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// concatenate strings with ', ' and stop before exceeding max
|
|
41
|
+
let stringsRemaining = strings.length - 1;
|
|
42
|
+
let result = strings[0];
|
|
43
|
+
for (let i = 1; i < strings.length; i++) {
|
|
44
|
+
const tempResult = [result, strings[i]].join(listSeparator);
|
|
45
|
+
if (tempResult.length > maxLength) {
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
stringsRemaining--;
|
|
49
|
+
result = tempResult;
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
text: result,
|
|
53
|
+
numberMore: stringsRemaining
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function TextTruncated(props) {
|
|
57
|
+
const {
|
|
58
|
+
stringList,
|
|
59
|
+
listSeparator,
|
|
60
|
+
maxLengthPx,
|
|
61
|
+
moreSeparator,
|
|
62
|
+
moreText,
|
|
63
|
+
textStyle,
|
|
64
|
+
showAllStyle,
|
|
65
|
+
placeHolder
|
|
66
|
+
} = props;
|
|
67
|
+
const [showAllOpen, setShowAllOpen] = (0, _react.useState)(false);
|
|
68
|
+
const [canvasContext, setCanvasContext] = (0, _react.useState)();
|
|
69
|
+
const theme = (0, _material.useTheme)();
|
|
70
|
+
(0, _react.useEffect)(() => {
|
|
71
|
+
var _canvas$getContext;
|
|
72
|
+
const canvas = document.createElement('canvas');
|
|
73
|
+
setCanvasContext((_canvas$getContext = canvas === null || canvas === void 0 ? void 0 : canvas.getContext('2d')) !== null && _canvas$getContext !== void 0 ? _canvas$getContext : undefined);
|
|
74
|
+
}, []);
|
|
75
|
+
const pixelsPerChar = (0, _react.useMemo)(() => {
|
|
76
|
+
// compute the pixels per character, averaged over the comma-separated joined stringList
|
|
77
|
+
const fullText = stringList.join(listSeparator);
|
|
78
|
+
let result = 0;
|
|
79
|
+
if (canvasContext) {
|
|
80
|
+
const fontSize = textStyle && textStyle.fontSize || theme.typography.fontSize;
|
|
81
|
+
const fontFamily = textStyle && textStyle.fontFamily || theme.typography.fontFamily;
|
|
82
|
+
canvasContext.font = "".concat(fontSize, "px ").concat(fontFamily);
|
|
83
|
+
result = canvasContext.measureText(fullText).width;
|
|
84
|
+
}
|
|
85
|
+
return result / fullText.length;
|
|
86
|
+
}, [stringList, textStyle, canvasContext, theme.typography.fontFamily, theme.typography.fontSize]);
|
|
87
|
+
let maxExcludingSuffix = stringList.join(listSeparator).length;
|
|
88
|
+
if (pixelsPerChar > 0) {
|
|
89
|
+
const maxChars = maxLengthPx / pixelsPerChar;
|
|
90
|
+
maxExcludingSuffix = maxChars - moreSeparator.length - (moreText ? moreText.length : 0) - 1 - Math.ceil(Math.log10(stringList.length));
|
|
91
|
+
}
|
|
92
|
+
const textToDisplay = computeFromStringList(stringList, maxExcludingSuffix, listSeparator);
|
|
93
|
+
const onClickHandler = e => {
|
|
94
|
+
e.stopPropagation();
|
|
95
|
+
setShowAllOpen(!showAllOpen);
|
|
96
|
+
};
|
|
97
|
+
return stringList.length > 0 ? /*#__PURE__*/_react.default.createElement(_material.Typography, {
|
|
98
|
+
sx: textStyle
|
|
99
|
+
}, textToDisplay.text, textToDisplay.numberMore !== 0 && moreText ? moreSeparator : '', textToDisplay.numberMore !== 0 ? /*#__PURE__*/_react.default.createElement(_material.Tooltip, {
|
|
100
|
+
arrow: true,
|
|
101
|
+
open: moreText ? showAllOpen : undefined,
|
|
102
|
+
enterDelay: moreText ? 0 : 400,
|
|
103
|
+
title: /*#__PURE__*/_react.default.createElement(_material.Typography, {
|
|
104
|
+
sx: showAllStyle,
|
|
105
|
+
fontSize: "14px"
|
|
106
|
+
}, stringList.join(listSeparator)),
|
|
107
|
+
sx: {
|
|
108
|
+
'& .MuiTooltip-arrow': {
|
|
109
|
+
color: "".concat(theme.palette.TwClrBg, " !important"),
|
|
110
|
+
'&:before': {
|
|
111
|
+
border: "1px solid ".concat(theme.palette.TwClrBrdrTertiary)
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
'& .MuiTooltip-popper': {
|
|
115
|
+
maxHeight: '200px',
|
|
116
|
+
overflow: 'auto'
|
|
117
|
+
},
|
|
118
|
+
'& .MuiTooltip-tooltip': {
|
|
119
|
+
backgroundColor: "".concat(theme.palette.TwClrBg, " !important"),
|
|
120
|
+
color: "".concat(theme.palette.TwClrTxt, " !important"),
|
|
121
|
+
border: "1px solid ".concat(theme.palette.TwClrBrdrTertiary, " !important"),
|
|
122
|
+
borderRadius: '8px !important',
|
|
123
|
+
boxShadow: "0px 3px 3px ".concat(theme.palette.TwClrBaseGray100),
|
|
124
|
+
padding: '8px'
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}, moreText ? /*#__PURE__*/_react.default.createElement(_material.Link, {
|
|
128
|
+
component: "button",
|
|
129
|
+
onClick: onClickHandler,
|
|
130
|
+
onBlur: () => setShowAllOpen(false),
|
|
131
|
+
sx: {
|
|
132
|
+
color: theme.palette.TwClrTxtBrand,
|
|
133
|
+
textDecorationColor: "".concat(theme.palette.TwClrTxtBrand, "80")
|
|
134
|
+
}
|
|
135
|
+
}, /*#__PURE__*/_react.default.createElement(_material.Typography, {
|
|
136
|
+
sx: {
|
|
137
|
+
...textStyle,
|
|
138
|
+
marginTop: '-3px'
|
|
139
|
+
}
|
|
140
|
+
}, (textToDisplay.numberMore > 0 ? textToDisplay.numberMore + ' ' : '') + moreText)) : /*#__PURE__*/_react.default.createElement(_material.Typography, {
|
|
141
|
+
sx: {
|
|
142
|
+
...textStyle,
|
|
143
|
+
display: 'inline'
|
|
144
|
+
}
|
|
145
|
+
}, moreSeparator)) : null) : placeHolder || null;
|
|
146
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
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 = TextField;
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _material = require("@mui/material");
|
|
11
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
12
|
+
var _utils = require("../../utils");
|
|
13
|
+
var _Icon = _interopRequireDefault(require("../Icon/Icon"));
|
|
14
|
+
var _IconTooltip = _interopRequireDefault(require("../IconTooltip"));
|
|
15
|
+
var _TruncatedTextArea = _interopRequireDefault(require("./TruncatedTextArea"));
|
|
16
|
+
require("./styles.scss");
|
|
17
|
+
function TextField(props) {
|
|
18
|
+
const {
|
|
19
|
+
autoFocus,
|
|
20
|
+
label,
|
|
21
|
+
className,
|
|
22
|
+
disabled,
|
|
23
|
+
disabledCharacters,
|
|
24
|
+
display,
|
|
25
|
+
errorText,
|
|
26
|
+
helperText,
|
|
27
|
+
iconLeft,
|
|
28
|
+
iconRight,
|
|
29
|
+
id,
|
|
30
|
+
min,
|
|
31
|
+
max,
|
|
32
|
+
maxLength,
|
|
33
|
+
onBlur,
|
|
34
|
+
onChange,
|
|
35
|
+
onClickRightIcon,
|
|
36
|
+
onFocus,
|
|
37
|
+
onKeyDown,
|
|
38
|
+
placeholder,
|
|
39
|
+
preserveNewlines,
|
|
40
|
+
readonly,
|
|
41
|
+
required,
|
|
42
|
+
styles,
|
|
43
|
+
sx,
|
|
44
|
+
tooltipTitle,
|
|
45
|
+
truncateConfig,
|
|
46
|
+
type,
|
|
47
|
+
value,
|
|
48
|
+
warningText
|
|
49
|
+
} = props;
|
|
50
|
+
const textfieldClass = (0, _classnames.default)({
|
|
51
|
+
'textfield-value': true,
|
|
52
|
+
'textfield-value--disabled': disabled,
|
|
53
|
+
'textfield-value--error': !!errorText,
|
|
54
|
+
'textfield-value--warning': !!warningText,
|
|
55
|
+
'textfield-value--readonly': readonly
|
|
56
|
+
});
|
|
57
|
+
const textfieldOnChange = event => {
|
|
58
|
+
const textValue = event.target.value;
|
|
59
|
+
if ((0, _utils.isWhitespaces)(textValue)) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (onChange) {
|
|
63
|
+
onChange(textValue);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const onKeyDownHandler = e => {
|
|
67
|
+
if (disabledCharacters && disabledCharacters.includes(e.key)) {
|
|
68
|
+
e === null || e === void 0 ? void 0 : e.preventDefault();
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (onKeyDown) {
|
|
72
|
+
onKeyDown(e.key);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const renderRightIcon = () => {
|
|
76
|
+
if (iconRight === 'cancel' && !value) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
return /*#__PURE__*/_react.default.createElement("button", {
|
|
80
|
+
onClick: onClickRightIcon,
|
|
81
|
+
className: "textfield-value--icon-container"
|
|
82
|
+
}, /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
83
|
+
name: iconRight,
|
|
84
|
+
className: "textfield-value--icon-right".concat(iconRight === 'cancel' ? '--cancel' : '')
|
|
85
|
+
}));
|
|
86
|
+
};
|
|
87
|
+
const typeProps = {
|
|
88
|
+
type
|
|
89
|
+
};
|
|
90
|
+
if (type === 'number') {
|
|
91
|
+
if (min !== undefined) {
|
|
92
|
+
typeProps.min = min;
|
|
93
|
+
}
|
|
94
|
+
if (max !== undefined) {
|
|
95
|
+
typeProps.max = max;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const displayComponent = (0, _react.useMemo)(() => {
|
|
99
|
+
if (!display) {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
if (type === 'textarea' && truncateConfig) {
|
|
103
|
+
return /*#__PURE__*/_react.default.createElement(_TruncatedTextArea.default, {
|
|
104
|
+
preserveNewlines: preserveNewlines,
|
|
105
|
+
truncateConfig: truncateConfig,
|
|
106
|
+
value: value
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
return /*#__PURE__*/_react.default.createElement("p", {
|
|
110
|
+
className: "textfield-value--display".concat(preserveNewlines ? ' preserve-newlines' : '')
|
|
111
|
+
}, value);
|
|
112
|
+
}, [display, preserveNewlines, truncateConfig, type, value]);
|
|
113
|
+
return /*#__PURE__*/_react.default.createElement(_material.Box, {
|
|
114
|
+
className: "textfield ".concat(className),
|
|
115
|
+
sx: sx
|
|
116
|
+
}, /*#__PURE__*/_react.default.createElement("label", {
|
|
117
|
+
htmlFor: id,
|
|
118
|
+
className: "textfield-label"
|
|
119
|
+
}, required && label ? "".concat(label, " *") : label, tooltipTitle && /*#__PURE__*/_react.default.createElement(_IconTooltip.default, {
|
|
120
|
+
placement: "top",
|
|
121
|
+
title: tooltipTitle
|
|
122
|
+
})), !display && (type === 'text' || type === 'number' ? /*#__PURE__*/_react.default.createElement("div", {
|
|
123
|
+
id: id,
|
|
124
|
+
className: textfieldClass
|
|
125
|
+
}, iconLeft && /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
126
|
+
name: iconLeft,
|
|
127
|
+
className: "textfield-value--icon-left"
|
|
128
|
+
}), /*#__PURE__*/_react.default.createElement("input", Object.assign({
|
|
129
|
+
autoFocus: autoFocus,
|
|
130
|
+
value: type === 'number' ? value : value || '',
|
|
131
|
+
disabled: readonly || disabled,
|
|
132
|
+
placeholder: placeholder,
|
|
133
|
+
onChange: textfieldOnChange,
|
|
134
|
+
onBlur: onBlur,
|
|
135
|
+
onFocus: onFocus,
|
|
136
|
+
onKeyDown: onKeyDownHandler,
|
|
137
|
+
onWheel: e => e.currentTarget.blur(),
|
|
138
|
+
required: required,
|
|
139
|
+
maxLength: maxLength
|
|
140
|
+
}, typeProps)), iconRight ? renderRightIcon() : null) : /*#__PURE__*/_react.default.createElement("textarea", {
|
|
141
|
+
autoFocus: autoFocus,
|
|
142
|
+
className: textfieldClass,
|
|
143
|
+
value: value,
|
|
144
|
+
disabled: readonly || disabled,
|
|
145
|
+
placeholder: placeholder,
|
|
146
|
+
onChange: textfieldOnChange,
|
|
147
|
+
onBlur: onBlur,
|
|
148
|
+
onFocus: onFocus,
|
|
149
|
+
required: required,
|
|
150
|
+
maxLength: maxLength,
|
|
151
|
+
style: (styles || {}).textarea
|
|
152
|
+
})), displayComponent, errorText && /*#__PURE__*/_react.default.createElement("div", {
|
|
153
|
+
className: "textfield-label-container"
|
|
154
|
+
}, /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
155
|
+
name: "error",
|
|
156
|
+
className: "textfield-error-text--icon"
|
|
157
|
+
}), /*#__PURE__*/_react.default.createElement("label", {
|
|
158
|
+
htmlFor: id,
|
|
159
|
+
className: "textfield-error-text"
|
|
160
|
+
}, errorText)), warningText && /*#__PURE__*/_react.default.createElement("div", {
|
|
161
|
+
className: "textfield-label-container"
|
|
162
|
+
}, /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
163
|
+
name: "warning",
|
|
164
|
+
className: "textfield-warning-text--icon"
|
|
165
|
+
}), /*#__PURE__*/_react.default.createElement("label", {
|
|
166
|
+
htmlFor: id,
|
|
167
|
+
className: "textfield-warning-text"
|
|
168
|
+
}, warningText)), helperText && /*#__PURE__*/_react.default.createElement("label", {
|
|
169
|
+
htmlFor: id,
|
|
170
|
+
className: "textfield-help-text"
|
|
171
|
+
}, helperText));
|
|
172
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _material = require("@mui/material");
|
|
10
|
+
const TruncatedTextArea = _ref => {
|
|
11
|
+
let {
|
|
12
|
+
preserveNewlines,
|
|
13
|
+
truncateConfig,
|
|
14
|
+
value
|
|
15
|
+
} = _ref;
|
|
16
|
+
const {
|
|
17
|
+
maxHeight,
|
|
18
|
+
showLessText,
|
|
19
|
+
showMoreText,
|
|
20
|
+
showTextStyle,
|
|
21
|
+
valueTextStyle,
|
|
22
|
+
alignment = 'left'
|
|
23
|
+
} = truncateConfig;
|
|
24
|
+
const theme = (0, _material.useTheme)();
|
|
25
|
+
const [showAll, setShowAll] = (0, _react.useState)(false);
|
|
26
|
+
const [needsTruncating, setNeedsTruncating] = (0, _react.useState)(false);
|
|
27
|
+
const [totalHeight, setTotalHeight] = (0, _react.useState)(0);
|
|
28
|
+
const ref = (0, _react.useRef)(null);
|
|
29
|
+
(0, _react.useEffect)(() => {
|
|
30
|
+
if (ref && ref.current && !totalHeight) {
|
|
31
|
+
const height = ref.current.clientHeight;
|
|
32
|
+
setTotalHeight(height);
|
|
33
|
+
setNeedsTruncating(height > maxHeight);
|
|
34
|
+
}
|
|
35
|
+
}, [maxHeight, ref, totalHeight]);
|
|
36
|
+
const toggleShowAll = () => setShowAll(prev => !prev);
|
|
37
|
+
const textStyle = {
|
|
38
|
+
...valueTextStyle,
|
|
39
|
+
margin: '8px 0',
|
|
40
|
+
padding: 0,
|
|
41
|
+
overflow: 'hidden',
|
|
42
|
+
width: '100%'
|
|
43
|
+
};
|
|
44
|
+
if (needsTruncating && !showAll) {
|
|
45
|
+
textStyle.maxHeight = "".concat(maxHeight, "px");
|
|
46
|
+
}
|
|
47
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("p", {
|
|
48
|
+
ref: ref,
|
|
49
|
+
className: "textfield-value--display".concat(preserveNewlines ? ' preserve-newlines' : ''),
|
|
50
|
+
style: textStyle
|
|
51
|
+
}, value), needsTruncating && /*#__PURE__*/_react.default.createElement("div", {
|
|
52
|
+
style: {
|
|
53
|
+
width: '100%',
|
|
54
|
+
textAlign: alignment
|
|
55
|
+
}
|
|
56
|
+
}, /*#__PURE__*/_react.default.createElement(_material.Link, {
|
|
57
|
+
component: "button",
|
|
58
|
+
onClick: toggleShowAll,
|
|
59
|
+
onBlur: () => setShowAll(false),
|
|
60
|
+
sx: {
|
|
61
|
+
color: theme.palette.TwClrTxtBrand,
|
|
62
|
+
textDecorationColor: "".concat(theme.palette.TwClrTxtBrand, "80")
|
|
63
|
+
}
|
|
64
|
+
}, /*#__PURE__*/_react.default.createElement(_material.Typography, {
|
|
65
|
+
sx: {
|
|
66
|
+
...showTextStyle,
|
|
67
|
+
marginTop: '-3px'
|
|
68
|
+
}
|
|
69
|
+
}, showAll ? showLessText : showMoreText))));
|
|
70
|
+
};
|
|
71
|
+
var _default = exports.default = TruncatedTextArea;
|