@geotab/zenith 1.19.1 → 1.20.0-beta.1
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/README.md +11 -0
- package/dist/banner/bannerMultipLine.js +2 -1
- package/dist/banner/bannerSingleLine.js +2 -1
- package/dist/banner/typeIcon.js +1 -1
- package/dist/chart/lineChart.js +1 -1
- package/dist/dataGrid/withSortableColumns/columns/sortableColumnWrapper.js +28 -8
- package/dist/dateRange/dateRange.d.ts +3 -3
- package/dist/dateRange/dateRange.js +15 -10
- package/dist/dateRange/dateRangeUtils.d.ts +3 -0
- package/dist/filtersBar/components/filtersBarPeriodPicker/filtersBarPeriodPicker.d.ts +10 -4
- package/dist/filtersBar/components/filtersBarPeriodPicker/filtersBarPeriodPicker.js +14 -10
- package/dist/filtersBar/components/filtersBarPeriodPicker/getRangeOption.d.ts +7 -1
- package/dist/filtersBar/components/filtersBarPeriodPicker/getRangeOption.js +59 -1
- package/dist/icons/iconAddPeople2.d.ts +4 -0
- package/dist/icons/iconAddPeople2.js +4 -0
- package/dist/icons/iconLaptop.d.ts +4 -0
- package/dist/icons/iconLaptop.js +17 -0
- package/dist/icons/iconRemovePeople.d.ts +4 -0
- package/dist/icons/iconRemovePeople.js +17 -0
- package/dist/index.css +150 -117
- package/dist/index.d.ts +3 -1
- package/dist/index.js +12 -8
- package/dist/lineChart/lineChart.d.ts +3 -0
- package/dist/lineChart/lineChart.js +3 -0
- package/dist/modal/modal.js +3 -2
- package/dist/selectRaw/selectRaw.d.ts +1 -0
- package/dist/selectRaw/selectRaw.js +6 -2
- package/dist/table/selectable/useSelectableRows.js +1 -1
- package/dist/table/sortable/sortableHeader.js +30 -8
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -40,6 +40,17 @@ Zenith library provides components defined in Zenith Design System. It includes
|
|
|
40
40
|
|
|
41
41
|
## Change log
|
|
42
42
|
|
|
43
|
+
## 1.20.0
|
|
44
|
+
|
|
45
|
+
* Add documentation for Charts
|
|
46
|
+
* Add feature to detect range value in DateRange
|
|
47
|
+
* Add possibility to prevent unchecking selection in SelectField
|
|
48
|
+
* Add icon IconLaptop and deprecated duplicated
|
|
49
|
+
* Audit: Feedback (Modal and Banner)
|
|
50
|
+
* Fix GroupsButton positioning
|
|
51
|
+
* Fix sort indicator in Table
|
|
52
|
+
* Collect all Zenith documentation in one file
|
|
53
|
+
|
|
43
54
|
## 1.19.1
|
|
44
55
|
|
|
45
56
|
* Fix stepper issue with decimal values
|
|
@@ -20,6 +20,7 @@ const BannerMultiline = ({ children, header, type = "warning", icon, action, onC
|
|
|
20
20
|
const { translate } = (0, useLanguage_1.useLanguage)();
|
|
21
21
|
const bannerHeaderClassName = (0, useDriveClassName_1.useDriveClassName)("zen-banner__header");
|
|
22
22
|
const bannerMessageClassName = (0, useDriveClassName_1.useDriveClassName)("zen-banner__message");
|
|
23
|
+
const closeButtonClassName = (0, useDriveClassName_1.useDriveClassName)("zen-banner__close-button");
|
|
23
24
|
const contentRef = (0, react_1.useRef)(null);
|
|
24
25
|
const text = (0, useNodeText_1.useNodeText)(contentRef);
|
|
25
26
|
const linkClasses = (0, classNames_1.classNames)(["zen-banner__link", "zen-banner__link--" + type]);
|
|
@@ -30,6 +31,6 @@ const BannerMultiline = ({ children, header, type = "warning", icon, action, onC
|
|
|
30
31
|
"zen-banner__block--multiline",
|
|
31
32
|
"zen-banner__block--" + size
|
|
32
33
|
]);
|
|
33
|
-
return (0, jsx_runtime_1.jsx)("div", { className: blockClassNames, role: role, "aria-atomic": ariaAtomic, "aria-live": ariaLive, children: (0, jsx_runtime_1.jsxs)("div", { className: (0, classNames_1.classNames)(["zen-banner__content", "zen-banner__content--multiline", `zen-banner__content--${size}`]), children: [header && (0, jsx_runtime_1.jsxs)("div", { className: "zen-banner__multiline-container", children: [(0, jsx_runtime_1.jsxs)("div", { className: "zen-banner__header-container", children: [icon && header && (0, jsx_runtime_1.jsx)(typeIcon_1.default, { type: type }), header && (0, jsx_runtime_1.jsx)("div", { className: (0, classNames_1.classNames)(["zen-banner__header", bannerHeaderClassName || ""]), children: header })] }), onClose && (0, jsx_runtime_1.jsx)("button", { type: "button", className: "zen-banner__close-button", onClick: onClose, title: translate("Close"), "aria-label": translate("Close"), children: (0, jsx_runtime_1.jsx)(iconClose_1.IconClose, { size: bannerHeaderClassName ? "huge" : "large" }) })] }), (0, jsx_runtime_1.jsxs)("div", { className: "zen-banner__message-container", children: [icon && !header && (0, jsx_runtime_1.jsx)(typeIcon_1.default, { className: "zen-banner__icon-block--top-gap", type: type }), (0, jsx_runtime_1.jsx)("div", { ref: contentRef, title: text, className: (0, classNames_1.classNames)(["zen-banner__message", "zen-banner__message--multiline", bannerMessageClassName || ""]), children: children }), onClose && !header && (0, jsx_runtime_1.jsx)("button", { type: "button", className: "zen-banner__close-button zen-banner__close-button--top-gap", onClick: onClose, title: translate("Close"), "aria-label": translate("Close"), children: (0, jsx_runtime_1.jsx)(iconClose_1.IconClose, { size: bannerHeaderClassName ? "huge" : "large" }) })
|
|
34
|
+
return (0, jsx_runtime_1.jsx)("div", { className: blockClassNames, role: role, "aria-atomic": ariaAtomic, "aria-live": ariaLive, children: (0, jsx_runtime_1.jsxs)("div", { className: (0, classNames_1.classNames)(["zen-banner__content", "zen-banner__content--multiline", `zen-banner__content--${size}`]), children: [header && (0, jsx_runtime_1.jsxs)("div", { className: "zen-banner__multiline-container", children: [(0, jsx_runtime_1.jsxs)("div", { className: "zen-banner__header-container", children: [icon && header && (0, jsx_runtime_1.jsx)(typeIcon_1.default, { type: type }), header && (0, jsx_runtime_1.jsx)("div", { className: (0, classNames_1.classNames)(["zen-banner__header", bannerHeaderClassName || ""]), children: header })] }), onClose && (0, jsx_runtime_1.jsx)("button", { type: "button", className: (0, classNames_1.classNames)(["zen-banner__close-button", closeButtonClassName || ""]), onClick: onClose, title: translate("Close"), "aria-label": translate("Close"), children: (0, jsx_runtime_1.jsx)(iconClose_1.IconClose, { size: bannerHeaderClassName ? "huge" : "large" }) })] }), (0, jsx_runtime_1.jsxs)("div", { className: "zen-banner__message-container", children: [icon && !header && (0, jsx_runtime_1.jsx)(typeIcon_1.default, { className: "zen-banner__icon-block--top-gap", type: type }), (0, jsx_runtime_1.jsx)("div", { ref: contentRef, title: text, className: (0, classNames_1.classNames)(["zen-banner__message", "zen-banner__message--multiline", bannerMessageClassName || ""]), children: children }), onClose && !header && (0, jsx_runtime_1.jsx)("button", { type: "button", className: "zen-banner__close-button zen-banner__close-button--top-gap", onClick: onClose, title: translate("Close"), "aria-label": translate("Close"), children: (0, jsx_runtime_1.jsx)(iconClose_1.IconClose, { size: bannerHeaderClassName ? "huge" : "large" }) }), action && (0, jsx_runtime_1.jsx)("div", { className: "zen-banner__action zen-banner__action--multiline", children: (0, jsx_runtime_1.jsx)(button_1.Button, { className: linkClasses, type: buttonType_1.ButtonType.Tertiary, link: action.link, onClick: action.onClick, children: action.text }) })] })] }) });
|
|
34
35
|
};
|
|
35
36
|
exports.BannerMultiline = BannerMultiline;
|
|
@@ -21,11 +21,12 @@ const BannerSingleLine = ({ children, header, type = "warning", icon, action, on
|
|
|
21
21
|
const { translate } = (0, useLanguage_1.useLanguage)();
|
|
22
22
|
const bannerHeaderClassName = (0, useDriveClassName_1.useDriveClassName)("zen-banner__header");
|
|
23
23
|
const bannerMessageClassName = (0, useDriveClassName_1.useDriveClassName)("zen-banner__message");
|
|
24
|
+
const closeButtonClassName = (0, useDriveClassName_1.useDriveClassName)("zen-banner__close-button");
|
|
24
25
|
const isMobile = (0, useMobile_1.useMobile)();
|
|
25
26
|
const contentRef = (0, react_1.useRef)(null);
|
|
26
27
|
const text = (0, useNodeText_1.useNodeText)(contentRef);
|
|
27
28
|
const linkClasses = (0, classNames_1.classNames)(["zen-banner__link", "zen-banner__link--" + type]);
|
|
28
29
|
const blockClassNames = (0, classNames_1.classNames)(["zen-banner", "zen-banner__block", bannerOptions.blockClassName, className || "", "zen-banner__block--" + size]);
|
|
29
|
-
return (0, jsx_runtime_1.
|
|
30
|
+
return (0, jsx_runtime_1.jsxs)("div", { className: blockClassNames, role: role, "aria-atomic": ariaAtomic, "aria-live": ariaLive, children: [(0, jsx_runtime_1.jsxs)("div", { className: (0, classNames_1.classNames)(["zen-banner__content", `zen-banner__content--${size}`]), children: [icon && (0, jsx_runtime_1.jsx)(typeIcon_1.default, { type: type }), header && (0, jsx_runtime_1.jsx)("div", { className: (0, classNames_1.classNames)(["zen-banner__header", bannerHeaderClassName || ""]), children: header }), (0, jsx_runtime_1.jsx)("div", { className: (0, classNames_1.classNames)(["zen-banner__message", bannerMessageClassName || "", isMobile ? "zen-banner__message--mobile" : ""]), ref: contentRef, title: text, children: children }), action && (0, jsx_runtime_1.jsx)("div", { className: "zen-banner__action", children: (0, jsx_runtime_1.jsx)(button_1.Button, { className: linkClasses, type: buttonType_1.ButtonType.Tertiary, link: action.link, onClick: action.onClick, children: action.text }) })] }), onClose && (0, jsx_runtime_1.jsx)("button", { type: "button", className: (0, classNames_1.classNames)(["zen-banner__close-button", closeButtonClassName || ""]), onClick: onClose, title: translate("Close"), "aria-label": translate("Close"), children: (0, jsx_runtime_1.jsx)(iconClose_1.IconClose, { size: bannerHeaderClassName ? "huge" : "large" }) })] });
|
|
30
31
|
};
|
|
31
32
|
exports.BannerSingleLine = BannerSingleLine;
|
package/dist/banner/typeIcon.js
CHANGED
|
@@ -17,7 +17,7 @@ const TypeIcon = ({ type, className }) => {
|
|
|
17
17
|
}), []);
|
|
18
18
|
const bannerDriveClassName = (0, useDriveClassName_1.useDriveClassName)("zen-banner__icon-block");
|
|
19
19
|
return (0, jsx_runtime_1.jsx)("div", { className: (0, classNames_1.classNames)(["zen-banner__icon-block", className || ""]), children: (0, react_1.createElement)(iconsByType[type], {
|
|
20
|
-
size: bannerDriveClassName ? "
|
|
20
|
+
size: bannerDriveClassName ? "huge" : "large",
|
|
21
21
|
className: `zen-push__icon--${type}`
|
|
22
22
|
}) });
|
|
23
23
|
};
|
package/dist/chart/lineChart.js
CHANGED
|
@@ -59,6 +59,7 @@ const LineChart = (_a) => {
|
|
|
59
59
|
const tooltipId = (0, react_1.useMemo)(() => (0, generateId_1.generateId)(), []);
|
|
60
60
|
const { isHidden, toggleHidden } = (0, useHidden_1.useHidden)();
|
|
61
61
|
const { toLocalDateTime } = (0, react_1.useContext)(userFormatContext_1.userFormatContext);
|
|
62
|
+
const isTimedData = (0, react_1.useMemo)(() => (0, isDateRange_1.isDateRange)(data, true), [data]);
|
|
62
63
|
const chartData = (0, react_1.useMemo)(() => {
|
|
63
64
|
const chData = Object.assign({}, data);
|
|
64
65
|
chData.datasets = chData.datasets.map((ds, i) => (0, getDefaultDatasetStyle_1.getDefaultDatasetStyle)(ds, i));
|
|
@@ -72,7 +73,6 @@ const LineChart = (_a) => {
|
|
|
72
73
|
chData.datasets = chData.datasets.map((ds, i) => isHidden(ds.parentIndex !== undefined ? ds.parentIndex : i) ? Object.assign(Object.assign({}, ds), { hidden: true }) : ds);
|
|
73
74
|
return (0, convertDates_1.convertDates)(chData, toLocalDateTime);
|
|
74
75
|
}, [data, isHidden, toLocalDateTime]);
|
|
75
|
-
const isTimedData = (0, react_1.useMemo)(() => (0, isDateRange_1.isDateRange)(chartData, true), [chartData]);
|
|
76
76
|
const yAxisMeta = (0, react_1.useMemo)(() => (0, getYAxisMeta_1.getYAxisMeta)(chartData), [chartData]);
|
|
77
77
|
const xAxisMeta = (0, react_1.useMemo)(() => (0, getXAxisMeta_1.getXAxisMeta)(chartData, isTimedData), [chartData, isTimedData]);
|
|
78
78
|
const { chartRef, ticks } = (0, useChartTicks_1.useChartTicks)();
|
|
@@ -16,25 +16,45 @@ const getSortButtonTitle = (sortDirection, title, translate) => {
|
|
|
16
16
|
};
|
|
17
17
|
const SortableHeaderCell = ({ columnName, isSortedBy, sortDirection, title, tooltip, onSortChange, isMobile = false }) => {
|
|
18
18
|
const { translate } = (0, useLanguage_1.useLanguage)();
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
|
|
19
|
+
const [isHovered, setIsHovered] = (0, react_1.useState)(false);
|
|
20
|
+
const [isFocused, setIsFocused] = (0, react_1.useState)(false);
|
|
21
|
+
const isActive = isHovered || isFocused;
|
|
22
|
+
const iconTitle = getSortButtonTitle(isActive
|
|
23
|
+
? sortDirection
|
|
24
|
+
: sortDirection === columnSortDirection_1.ColumnSortDirection.Ascending
|
|
25
|
+
? columnSortDirection_1.ColumnSortDirection.Descending
|
|
26
|
+
: columnSortDirection_1.ColumnSortDirection.Ascending, tooltip, translate);
|
|
27
|
+
const icon = (0, react_1.useMemo)(() => {
|
|
28
|
+
if (isActive) {
|
|
29
|
+
return sortDirection === columnSortDirection_1.ColumnSortDirection.Ascending
|
|
30
|
+
? iconFilter3Desc_1.IconFilter3Desc
|
|
31
|
+
: iconFilter3Asc_1.IconFilter3Asc;
|
|
32
|
+
}
|
|
33
|
+
return sortDirection === columnSortDirection_1.ColumnSortDirection.Ascending
|
|
34
|
+
? iconFilter3Asc_1.IconFilter3Asc
|
|
35
|
+
: iconFilter3Desc_1.IconFilter3Desc;
|
|
36
|
+
}, [sortDirection, isActive]);
|
|
37
|
+
const iconButton = ((0, jsx_runtime_1.jsx)(textIconButton_1.TextIconButton, { className: "zen-sortable-column-button__dir-icon zen-caption__post-icon", icon: icon, iconPosition: isMobile ? textIconButton_1.ButtonIconPosition.Start : textIconButton_1.ButtonIconPosition.End, type: buttonType_1.ButtonType.Light, title: iconTitle }));
|
|
38
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: (0, classNames_1.classNames)([
|
|
23
39
|
"zen-sortable-column",
|
|
24
40
|
isSortedBy ? `zen-sortable-column--active` : "",
|
|
25
41
|
isMobile ? `zen-sortable-column--mobile` : ""
|
|
26
|
-
]), children: (0, jsx_runtime_1.jsx)("div", { className: (0, classNames_1.classNames)([
|
|
42
|
+
]), onMouseEnter: () => setIsHovered(true), onMouseLeave: () => setIsHovered(false), onFocus: () => setIsFocused(true), onBlur: () => setIsFocused(false), children: (0, jsx_runtime_1.jsx)("div", { className: (0, classNames_1.classNames)([
|
|
27
43
|
"zen-caption",
|
|
28
44
|
"zen-sortable-column__button",
|
|
29
45
|
"zen-sortable-column-button",
|
|
30
46
|
isSortedBy ? `zen-sortable-column-button--active` : "",
|
|
31
|
-
sortDirection === columnSortDirection_1.ColumnSortDirection.Ascending
|
|
47
|
+
sortDirection === columnSortDirection_1.ColumnSortDirection.Ascending
|
|
48
|
+
? "zen-sortable-column-button--dir-asc"
|
|
49
|
+
: "zen-sortable-column-button--dir-desc"
|
|
32
50
|
]), title: iconTitle, "aria-label": iconTitle, onClick: () => {
|
|
33
51
|
onSortChange({
|
|
34
52
|
sortColumn: columnName,
|
|
35
|
-
sortDirection: sortDirection === columnSortDirection_1.ColumnSortDirection.Ascending
|
|
53
|
+
sortDirection: sortDirection === columnSortDirection_1.ColumnSortDirection.Ascending
|
|
54
|
+
? columnSortDirection_1.ColumnSortDirection.Descending
|
|
55
|
+
: columnSortDirection_1.ColumnSortDirection.Ascending
|
|
36
56
|
});
|
|
37
|
-
}, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [isMobile ? iconButton : null, (0, jsx_runtime_1.jsx)("div", { className: "zen-sortable-column-button__content zen-caption__content", children: title }), isMobile ? null : iconButton] }) }) });
|
|
57
|
+
}, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [isMobile ? iconButton : null, (0, jsx_runtime_1.jsx)("div", { className: "zen-sortable-column-button__content zen-caption__content", children: title }), isMobile ? null : iconButton] }) }) }));
|
|
38
58
|
};
|
|
39
59
|
exports.SortableHeaderCell = SortableHeaderCell;
|
|
40
60
|
class SortableColumnWrapper {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import "./dateRange.less";
|
|
3
3
|
import { IZenComponentProps } from "./../commonHelpers/zenComponent";
|
|
4
|
-
import { IDateRangeValue, TDateRangeOption } from "./dateRangeUtils";
|
|
4
|
+
import { IDateRangeValue, IDateRangeValueOptionalLabel, TDateRangeOption } from "./dateRangeUtils";
|
|
5
5
|
import { TButton } from "../button/buttonType";
|
|
6
6
|
interface IDateRangeBase extends IZenComponentProps {
|
|
7
7
|
options: TDateRangeOption[];
|
|
@@ -24,13 +24,13 @@ interface IDateRangeBase extends IZenComponentProps {
|
|
|
24
24
|
}
|
|
25
25
|
export interface IDateRange extends IDateRangeBase {
|
|
26
26
|
defaultValue: IDateRangeValue;
|
|
27
|
-
value:
|
|
27
|
+
value: IDateRangeValueOptionalLabel;
|
|
28
28
|
onChange: (value: IDateRangeValue) => void;
|
|
29
29
|
allowUnsetValue?: false;
|
|
30
30
|
}
|
|
31
31
|
export interface IDateRangeUnsetValue extends IDateRangeBase {
|
|
32
32
|
defaultValue?: IDateRangeValue;
|
|
33
|
-
value:
|
|
33
|
+
value: IDateRangeValueOptionalLabel | undefined;
|
|
34
34
|
onChange: (value: IDateRangeValue | undefined) => void;
|
|
35
35
|
allowUnsetValue: true;
|
|
36
36
|
}
|
|
@@ -33,30 +33,33 @@ const parseLabel = (option, dateFormat, translate, toLacalFn) => {
|
|
|
33
33
|
};
|
|
34
34
|
exports.parseLabel = parseLabel;
|
|
35
35
|
const DateRange = ({ className, classNamePopup, defaultValue, value, onChange, options: optionsArg, type, id, disabled, dropDownTitle, hasApplyButton, disableFutureDates, disablePastDates, disableDatesBefore, disableDatesAfter, withCalendar, lockStartDate, lockEndDate, timeSelect, error, allowUnsetValue = false }) => {
|
|
36
|
+
var _a;
|
|
36
37
|
const { translate } = (0, useLanguage_1.useLanguage)();
|
|
37
38
|
const isMobile = (0, useMobile_1.useMobile)();
|
|
38
39
|
const drivePopupClassName = (0, useDriveClassName_1.useDriveClassName)("zen-date-range-popup");
|
|
39
40
|
const driveWrapperClassName = (0, useDriveClassName_1.useDriveClassName)("zen-date-range-popup-wrapper");
|
|
40
41
|
const [showMobileCalendar, setShowMobileCalendar] = (0, react_1.useState)(false);
|
|
41
42
|
const { dateFormat, toLocalDateTime, toReverseOffsetDateTime, weekStartsOnSunday } = (0, react_1.useContext)(userFormatContext_1.userFormatContext);
|
|
42
|
-
const
|
|
43
|
+
const optionsMap = (0, react_1.useMemo)(() => (0, getRangeOption_1.getOptionsPeriodMap)(optionsArg, translate, toLocalDateTime, weekStartsOnSunday ? "Sunday" : "Monday", toReverseOffsetDateTime), [optionsArg, toLocalDateTime, toReverseOffsetDateTime, translate, weekStartsOnSunday]);
|
|
44
|
+
const [selectedRange, setSelectedRange] = (0, react_1.useState)((0, getRangeOption_1.getSelectedRangeFromValue)(optionsMap, value));
|
|
43
45
|
const isDefaultState = !defaultValue && !selectedRange || (defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.label) === (selectedRange === null || selectedRange === void 0 ? void 0 : selectedRange.label);
|
|
44
46
|
const isCustomDateOption = (selectedRange === null || selectedRange === void 0 ? void 0 : selectedRange.label) === dateRangeInner_1.CUSTOM_CALENDAR_ID;
|
|
45
47
|
const [isOpen, setIsOpen] = (0, react_1.useState)(false);
|
|
46
48
|
const prevIsOpenRef = (0, react_1.useRef)(false);
|
|
47
49
|
const [customDate, setCustomDate] = (0, react_1.useState)((0, normalizeDates_1.normalizeDates)(value === null || value === void 0 ? void 0 : value.from.toISOString(), value === null || value === void 0 ? void 0 : value.to.toISOString(), disableFutureDates, disablePastDates, disableDatesBefore, disableDatesAfter));
|
|
48
50
|
const triggerRef = (0, react_1.useRef)(null);
|
|
49
|
-
const [prevSelection, setPrevSelection] = (0, react_1.useState)(value);
|
|
51
|
+
const [prevSelection, setPrevSelection] = (0, react_1.useState)((0, getRangeOption_1.getSelectedRangeFromValue)(optionsMap, value));
|
|
50
52
|
const componentId = (0, useUniqueId_1.useUniqueId)();
|
|
51
53
|
const calendarLabel = translate(dateRangeInner_1.CUSTOM_CALENDAR_ID);
|
|
52
54
|
const getCustomRange = (0, react_1.useCallback)(() => ({ from: (prevSelection === null || prevSelection === void 0 ? void 0 : prevSelection.from) || new Date(), to: (prevSelection === null || prevSelection === void 0 ? void 0 : prevSelection.to) || new Date() }), [prevSelection]);
|
|
53
55
|
const options = (0, react_1.useMemo)(() => (0, getRangeOption_1.getRangeOptionsArray)(optionsArg, translate, toLocalDateTime, weekStartsOnSunday ? "Sunday" : "Monday", toReverseOffsetDateTime, withCalendar || false, prevSelection && prevSelection.label === dateRangeInner_1.CUSTOM_CALENDAR_ID, prevSelection ? getCustomRange : undefined), [optionsArg, translate, toLocalDateTime, weekStartsOnSunday, toReverseOffsetDateTime, withCalendar, prevSelection, getCustomRange]);
|
|
54
56
|
const hasCustomOption = (0, react_1.useMemo)(() => options.find(option => option.id === dateRangeInner_1.CUSTOM_CALENDAR_ID) !== undefined, [options]);
|
|
57
|
+
const currentLabel = (_a = (0, getRangeOption_1.getSelectedRangeFromValue)(optionsMap, value)) === null || _a === void 0 ? void 0 : _a.label;
|
|
55
58
|
const cssClass = (0, classNames_1.classNames)([
|
|
56
59
|
"zen-date-range",
|
|
57
60
|
error ? "zen-date-range--error" : "",
|
|
58
61
|
className !== null && className !== void 0 ? className : "",
|
|
59
|
-
!defaultValue && !value || (defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.label) ===
|
|
62
|
+
!defaultValue && !value || (defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.label) === currentLabel || type && type !== buttonType_1.ButtonType.Secondary ? "" : "zen-date-range--active"
|
|
60
63
|
]);
|
|
61
64
|
const title = (0, react_1.useMemo)(() => dropDownTitle || translate("Date range"), [dropDownTitle, translate]);
|
|
62
65
|
const toggleVisibility = (0, react_1.useCallback)(() => setIsOpen(currentIsOpen => !currentIsOpen), []);
|
|
@@ -72,11 +75,12 @@ const DateRange = ({ className, classNamePopup, defaultValue, value, onChange, o
|
|
|
72
75
|
return (0, exports.parseLabel)(rangeValue, dateFormat, translate, toLocalDateTime);
|
|
73
76
|
}, [dateFormat, options, translate, toLocalDateTime]);
|
|
74
77
|
(0, react_1.useEffect)(() => {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
+
const currentValue = (0, getRangeOption_1.getSelectedRangeFromValue)(optionsMap, value);
|
|
79
|
+
if ((prevSelection === null || prevSelection === void 0 ? void 0 : prevSelection.label) !== (currentValue === null || currentValue === void 0 ? void 0 : currentValue.label)) {
|
|
80
|
+
setSelectedRange(currentValue);
|
|
81
|
+
setPrevSelection(currentValue);
|
|
78
82
|
}
|
|
79
|
-
}, [prevSelection === null || prevSelection === void 0 ? void 0 : prevSelection.label, value]);
|
|
83
|
+
}, [optionsMap, prevSelection === null || prevSelection === void 0 ? void 0 : prevSelection.label, value]);
|
|
80
84
|
const handleDateRangeSelection = (0, react_1.useCallback)((newVal) => {
|
|
81
85
|
var _a, _b;
|
|
82
86
|
const selection = options.find(option => option.id === newVal);
|
|
@@ -144,8 +148,9 @@ const DateRange = ({ className, classNamePopup, defaultValue, value, onChange, o
|
|
|
144
148
|
}, []);
|
|
145
149
|
(0, react_1.useEffect)(() => {
|
|
146
150
|
setCustomDate({ from: value === null || value === void 0 ? void 0 : value.from.toISOString(), to: value === null || value === void 0 ? void 0 : value.to.toISOString() });
|
|
147
|
-
|
|
148
|
-
|
|
151
|
+
const currentValue = (0, getRangeOption_1.getSelectedRangeFromValue)(optionsMap, value);
|
|
152
|
+
setPrevSelection(currentValue);
|
|
153
|
+
}, [optionsMap, value]);
|
|
149
154
|
const range = (0, react_1.useMemo)(() => ({ from: customDate.from, to: customDate.to }), [customDate.from, customDate.to]);
|
|
150
155
|
const component = (0, react_1.useMemo)(() => (0, jsx_runtime_1.jsx)(dateRangeInner_1.DateRangeInner, { id: id || componentId, options: options, onOptionSelect: handleDateRangeSelection, onCalendarSelect: hasCustomOption ? (val) => {
|
|
151
156
|
setCustomDate({ from: lockStartDate || val.from, to: lockEndDate || (lockStartDate ? val.to || val.from : val.to) });
|
|
@@ -183,7 +188,7 @@ const DateRange = ({ className, classNamePopup, defaultValue, value, onChange, o
|
|
|
183
188
|
}
|
|
184
189
|
prevIsOpenRef.current = isOpen;
|
|
185
190
|
}, [isOpen]);
|
|
186
|
-
return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(textIconButton_1.TextIconButton, { htmlType: "button", icon: iconCalendar_1.IconCalendar, iconPosition: textIconButton_1.ButtonIconPosition.Start, className: cssClass, type: type, disabled: disabled, onClick: toggleVisibility, ref: triggerRef, children: getButtonLabel(value) }), isMobile ? memoizedMobileView : memoizedDesktopView, (0, jsx_runtime_1.jsx)(formFieldError_1.FormFieldError, { error: error })] });
|
|
191
|
+
return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(textIconButton_1.TextIconButton, { htmlType: "button", icon: iconCalendar_1.IconCalendar, iconPosition: textIconButton_1.ButtonIconPosition.Start, className: cssClass, type: type, disabled: disabled, onClick: toggleVisibility, ref: triggerRef, children: getButtonLabel((0, getRangeOption_1.getSelectedRangeFromValue)(optionsMap, value)) }), isMobile ? memoizedMobileView : memoizedDesktopView, (0, jsx_runtime_1.jsx)(formFieldError_1.FormFieldError, { error: error })] });
|
|
187
192
|
};
|
|
188
193
|
exports.DateRange = DateRange;
|
|
189
194
|
exports.TRANSLATIONS = [
|
|
@@ -7,6 +7,9 @@ interface IDateRange {
|
|
|
7
7
|
export interface IDateRangeValue extends IDateRange {
|
|
8
8
|
label: string;
|
|
9
9
|
}
|
|
10
|
+
export interface IDateRangeValueOptionalLabel extends IDateRange {
|
|
11
|
+
label?: string;
|
|
12
|
+
}
|
|
10
13
|
export interface IDateRangeOption {
|
|
11
14
|
label: string;
|
|
12
15
|
getRange: () => IDateRange;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import "./filtersBarPeriodPicker.less";
|
|
3
3
|
import { IFiltersBarItem } from "../interfaces";
|
|
4
|
-
import { IDateRangeValue, TDateRangeOption } from "../../../dateRange/dateRangeUtils";
|
|
4
|
+
import { IDateRangeValue, IDateRangeValueOptionalLabel, TDateRangeOption } from "../../../dateRange/dateRangeUtils";
|
|
5
5
|
import { IButton } from "../../../button/button";
|
|
6
6
|
import { TDateDeformatter, TDateFormatter } from "../../../dateInputInner/dateInputInner";
|
|
7
7
|
interface IFiltersBarDateRangePickerBase extends Pick<IButton, "type" | "disabled"> {
|
|
@@ -32,7 +32,7 @@ interface IFiltersBarDateRangePicker extends IFiltersBarDateRangePickerBase {
|
|
|
32
32
|
interface IFiltersBarDateRangePickerUnsetValue extends IFiltersBarDateRangePickerBase {
|
|
33
33
|
allowUnsetValue: true;
|
|
34
34
|
}
|
|
35
|
-
|
|
35
|
+
interface IFiltersBarPeriodPickerImp extends IFiltersBarItem<IDateRangeValueOptionalLabel | IDateRangeValue, IFiltersBarDateRangePicker> {
|
|
36
36
|
props: IFiltersBarDateRangePicker;
|
|
37
37
|
defaultState: IDateRangeValue;
|
|
38
38
|
className?: string;
|
|
@@ -43,8 +43,11 @@ export interface IFiltersBarPeriodPicker extends IFiltersBarItem<IDateRangeValue
|
|
|
43
43
|
*/
|
|
44
44
|
hasApplyButton?: boolean;
|
|
45
45
|
}
|
|
46
|
-
export
|
|
47
|
-
|
|
46
|
+
export interface IFiltersBarPeriodPicker extends Omit<IFiltersBarPeriodPickerImp, "onChange"> {
|
|
47
|
+
onChange: (state: IDateRangeValue) => void;
|
|
48
|
+
}
|
|
49
|
+
export type IPeriodPickerUnsetValue = IDateRangeValueOptionalLabel | IDateRangeValue | undefined;
|
|
50
|
+
interface IFiltersBarPeriodPickerUnsetValueImp extends IFiltersBarItem<IPeriodPickerUnsetValue, IFiltersBarDateRangePickerUnsetValue> {
|
|
48
51
|
props: IFiltersBarDateRangePickerUnsetValue;
|
|
49
52
|
defaultState: IPeriodPickerUnsetValue;
|
|
50
53
|
className?: string;
|
|
@@ -55,6 +58,9 @@ export interface IFiltersBarPeriodPickerUnsetValue extends IFiltersBarItem<IPeri
|
|
|
55
58
|
*/
|
|
56
59
|
hasApplyButton?: boolean;
|
|
57
60
|
}
|
|
61
|
+
export interface IFiltersBarPeriodPickerUnsetValue extends Omit<IFiltersBarPeriodPickerUnsetValueImp, "onChange"> {
|
|
62
|
+
onChange: (state: IDateRangeValue | undefined) => void;
|
|
63
|
+
}
|
|
58
64
|
export declare const FiltersBarPeriodPicker: React.FC<IFiltersBarPeriodPicker | IFiltersBarPeriodPickerUnsetValue>;
|
|
59
65
|
export declare const TRANSLATIONS: string[];
|
|
60
66
|
export {};
|
|
@@ -18,9 +18,10 @@ const FiltersBarPeriodPicker = ({ props, hasApplyButton, className, useSidePanel
|
|
|
18
18
|
const { translate } = (0, useLanguage_1.useLanguage)();
|
|
19
19
|
const { toLocalDateTime, toReverseOffsetDateTime, weekStartsOnSunday } = (0, react_1.useContext)(userFormatContext_1.userFormatContext);
|
|
20
20
|
const id = (0, useUniqueId_1.useUniqueId)();
|
|
21
|
-
const
|
|
21
|
+
const optionsMap = (0, react_1.useMemo)(() => (0, getRangeOption_1.getOptionsPeriodMap)(optionsArg, translate, toLocalDateTime, weekStartsOnSunday ? "Sunday" : "Monday", toReverseOffsetDateTime), [optionsArg, toLocalDateTime, toReverseOffsetDateTime, translate, weekStartsOnSunday]);
|
|
22
|
+
const [selectedRange, setSelectedRange] = (0, react_1.useState)((0, getRangeOption_1.getSelectedRangeFromValue)(optionsMap, state));
|
|
22
23
|
const filterBarLabelledId = (0, useUniqueId_1.useUniqueId)();
|
|
23
|
-
const [prevSelection, setPrevSelection] = (0, react_1.useState)(state);
|
|
24
|
+
const [prevSelection, setPrevSelection] = (0, react_1.useState)((0, getRangeOption_1.getSelectedRangeFromValue)(optionsMap, state));
|
|
24
25
|
const getCustomRange = (0, react_1.useCallback)(() => ({ from: (prevSelection === null || prevSelection === void 0 ? void 0 : prevSelection.from) || new Date(), to: (prevSelection === null || prevSelection === void 0 ? void 0 : prevSelection.to) || new Date() }), [prevSelection]);
|
|
25
26
|
const options = (0, react_1.useMemo)(() => (0, getRangeOption_1.getRangeOptionsArray)(optionsArg, translate, toLocalDateTime, weekStartsOnSunday ? "Sunday" : "Monday", toReverseOffsetDateTime, withCalendar || false, prevSelection && prevSelection.label === dateRangeInner_1.CUSTOM_CALENDAR_ID, prevSelection ? getCustomRange : undefined), [optionsArg, translate, toLocalDateTime, weekStartsOnSunday, toReverseOffsetDateTime, withCalendar, prevSelection, getCustomRange]);
|
|
26
27
|
const hasCustomOption = (0, react_1.useMemo)(() => options.find(option => option.id === dateRangeInner_1.CUSTOM_CALENDAR_ID) !== undefined, [options]);
|
|
@@ -54,13 +55,14 @@ const FiltersBarPeriodPicker = ({ props, hasApplyButton, className, useSidePanel
|
|
|
54
55
|
}
|
|
55
56
|
}, [options, disableFutureDates, disablePastDates, disableDatesBefore, disableDatesAfter, checkError, onChange, selectedRange === null || selectedRange === void 0 ? void 0 : selectedRange.label, state === null || state === void 0 ? void 0 : state.from, state === null || state === void 0 ? void 0 : state.to]);
|
|
56
57
|
(0, react_1.useEffect)(() => {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
const currentState = (0, getRangeOption_1.getSelectedRangeFromValue)(optionsMap, state);
|
|
59
|
+
if ((prevSelection === null || prevSelection === void 0 ? void 0 : prevSelection.label) !== (currentState === null || currentState === void 0 ? void 0 : currentState.label)) {
|
|
60
|
+
setSelectedRange(currentState);
|
|
61
|
+
setPrevSelection(currentState);
|
|
60
62
|
}
|
|
61
|
-
if (useSidePanelView && (defaultState === null || defaultState === void 0 ? void 0 : defaultState.label) === dateRangeInner_1.CUSTOM_CALENDAR_ID && (
|
|
63
|
+
if (useSidePanelView && (defaultState === null || defaultState === void 0 ? void 0 : defaultState.label) === dateRangeInner_1.CUSTOM_CALENDAR_ID && (currentState === null || currentState === void 0 ? void 0 : currentState.label) === dateRangeInner_1.CUSTOM_CALENDAR_ID &&
|
|
62
64
|
(prevSelection === null || prevSelection === void 0 ? void 0 : prevSelection.label) === dateRangeInner_1.CUSTOM_CALENDAR_ID &&
|
|
63
|
-
defaultState.from.toISOString() ===
|
|
65
|
+
defaultState.from.toISOString() === currentState.from.toISOString() && defaultState.to.toISOString() === currentState.to.toISOString()
|
|
64
66
|
&& customDate.from && customDate.to && (customDate.from !== defaultState.from.toISOString() || customDate.to !== defaultState.to.toISOString())) {
|
|
65
67
|
const normalizedDates = (0, normalizeDates_1.normalizeDates)(defaultState.from.toISOString(), defaultState.to.toISOString(), disableFutureDates, disablePastDates, disableDatesBefore, disableDatesAfter);
|
|
66
68
|
const newRange = { from: new Date(normalizedDates.from), to: new Date(normalizedDates.to) };
|
|
@@ -69,21 +71,23 @@ const FiltersBarPeriodPicker = ({ props, hasApplyButton, className, useSidePanel
|
|
|
69
71
|
setPrevSelection(updatedState);
|
|
70
72
|
setCustomDate({ from: newRange.from.toISOString(), to: newRange.to.toISOString() });
|
|
71
73
|
}
|
|
72
|
-
}, [prevSelection === null || prevSelection === void 0 ? void 0 : prevSelection.label, state,
|
|
74
|
+
}, [prevSelection === null || prevSelection === void 0 ? void 0 : prevSelection.label, state, defaultState, useSidePanelView, customDate.from, customDate.to,
|
|
75
|
+
disableFutureDates, disablePastDates, disableDatesBefore, disableDatesAfter, optionsMap]);
|
|
73
76
|
const handleCustomDate = (0, react_1.useCallback)((value) => {
|
|
74
77
|
const isHasError = !value.from || !value.to;
|
|
75
78
|
checkError && checkError(isHasError);
|
|
76
79
|
setSelectedRange({ label: dateRangeInner_1.CUSTOM_CALENDAR_ID, from: lockStartDate || value.from, to: lockEndDate || (lockStartDate ? value.to || value.from : value.to) });
|
|
77
80
|
setCustomDate({ from: lockStartDate || value.from, to: lockEndDate || (lockStartDate ? value.to || value.from : value.to) });
|
|
78
81
|
!isHasError && onChange({
|
|
79
|
-
label: dateRangeInner_1.CUSTOM_CALENDAR_ID,
|
|
82
|
+
label: dateRangeInner_1.CUSTOM_CALENDAR_ID,
|
|
83
|
+
from: new Date((lockStartDate || value.from)),
|
|
84
|
+
to: new Date((lockEndDate || (lockStartDate ? value.to || value.from : value.to)))
|
|
80
85
|
});
|
|
81
86
|
}, [checkError, lockEndDate, lockStartDate, onChange]);
|
|
82
87
|
const range = (0, react_1.useMemo)(() => ({ from: customDate.from, to: customDate.to }), [customDate.from, customDate.to]);
|
|
83
88
|
const component = (0, react_1.useMemo)(() => (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(DateRangeInnerMemo, { id: `${id}-daterange`, options: options, onOptionSelect: handleDateRangeSelection, onCalendarSelect: hasCustomOption ? handleCustomDate : undefined, selection: selectedRange === null || selectedRange === void 0 ? void 0 : selectedRange.label, range: range, timeSelect: timeSelect, disableFutureDates: disableFutureDates, disablePastDates: disablePastDates, disableDatesBefore: disableDatesBefore, disableDatesAfter: disableDatesAfter }) }), [id, options, handleDateRangeSelection, hasCustomOption, handleCustomDate, selectedRange === null || selectedRange === void 0 ? void 0 : selectedRange.label, range, timeSelect, disableFutureDates, disablePastDates, disableDatesBefore, disableDatesAfter]);
|
|
84
89
|
const popup = (0, react_1.useMemo)(() => {
|
|
85
90
|
const commonProps = Object.assign(Object.assign({}, props), { hasApplyButton: useSidePanelView ? false : props.hasApplyButton || hasApplyButton, id: id, className: (0, classNames_1.classNames)(["zen-filters-bar-period-picker", useSidePanelView ? "zen-filters-bar-period-picker--full-width" : "", className !== null && className !== void 0 ? className : ""]), classNamePopup: (0, classNames_1.classNames)(["zen-filters-bar-period-picker__popup", useSidePanelView ? "zen-filters-bar-period-picker__popup--full-width" : "", classNamePopup || ""]), options: optionsArg });
|
|
86
|
-
// @ts-expect-error: Let's ignore a compile error. if value undefined, and a value is passed to the function undefined, it can be passed because the interface is IDateRangeUnsetValue
|
|
87
91
|
return props.allowUnsetValue ? (0, jsx_runtime_1.jsx)(dateRange_1.DateRange, Object.assign({}, commonProps, { value: state, onChange: onChange, defaultValue: defaultState, allowUnsetValue: true })) : (0, jsx_runtime_1.jsx)(dateRange_1.DateRange, Object.assign({}, commonProps, { value: state, onChange: onChange, defaultValue: defaultState, allowUnsetValue: false }));
|
|
88
92
|
}, [props, useSidePanelView, id, className, classNamePopup, optionsArg, state, onChange, defaultState, hasApplyButton]);
|
|
89
93
|
if (!options.length && !hasCustomOption) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TDayName } from "../../../calendar/dateUtils";
|
|
2
|
-
import { IDateRangeOption, TDateRangeOption } from "../../../dateRange/dateRangeUtils";
|
|
2
|
+
import { IDateRangeOption, TDateRangeOption, IDateRangeValueOptionalLabel } from "../../../dateRange/dateRangeUtils";
|
|
3
3
|
export interface IDateRangeOptionId extends IDateRangeOption {
|
|
4
4
|
id: string;
|
|
5
5
|
}
|
|
@@ -34,4 +34,10 @@ export interface IDateRangeOptionsItem {
|
|
|
34
34
|
hasSecondaryLabel: boolean;
|
|
35
35
|
}
|
|
36
36
|
export declare const getRangeOptionsArray: (initialOptions: TDateRangeOption[], translate: (s: string) => string, toLocalDateTime: (date: Date | string) => Date, firstDayOfWeek?: TDayName, toReverseOffsetDateTime?: (date: Date | string) => Date, customLabel?: boolean, isPrevRangeCustom?: boolean, customGetRangeOptions?: () => IDateRange) => IDateRangeOptionsItem[];
|
|
37
|
+
export declare const getOptionsPeriodMap: (initialOptions: TDateRangeOption[], translate: (s: string) => string, toLocalDateTime: (date: Date | string) => Date, firstDayOfWeek?: TDayName, toReverseOffsetDateTime?: (date: Date | string) => Date) => Map<string, IDateRangeOptionId>;
|
|
38
|
+
export declare const getSelectedRangeFromValue: (optionsMap: Map<string, IDateRangeOptionId>, value?: IDateRangeValueOptionalLabel) => {
|
|
39
|
+
label: string;
|
|
40
|
+
from: Date;
|
|
41
|
+
to: Date;
|
|
42
|
+
} | undefined;
|
|
37
43
|
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getRangeOptionsArray = exports.getRangeOption = void 0;
|
|
3
|
+
exports.getSelectedRangeFromValue = exports.getOptionsPeriodMap = exports.getRangeOptionsArray = exports.getRangeOption = void 0;
|
|
4
4
|
const dateRangeUtils_1 = require("../../../dateRange/dateRangeUtils");
|
|
5
|
+
const dateRangeInner_1 = require("../../../dateRangeInner/dateRangeInner");
|
|
5
6
|
const options = {
|
|
6
7
|
"Today": (translate, toLocalDateTime, _firstDayOfWeek, toReverseOffsetDateTime) => (0, dateRangeUtils_1.GET_TODAY_OPTION)(toLocalDateTime, translate, toReverseOffsetDateTime),
|
|
7
8
|
"Yesterday": (translate, toLocalDateTime, _firstDayOfWeek, toReverseOffsetDateTime) => (0, dateRangeUtils_1.GET_YESTERDAY_OPTION)(toLocalDateTime, translate, toReverseOffsetDateTime),
|
|
@@ -55,3 +56,60 @@ const getRangeOptionsArray = (initialOptions, translate, toLocalDateTime, firstD
|
|
|
55
56
|
return preparedOptions;
|
|
56
57
|
};
|
|
57
58
|
exports.getRangeOptionsArray = getRangeOptionsArray;
|
|
59
|
+
const getOptionsPeriodMap = (initialOptions, translate, toLocalDateTime, firstDayOfWeek, toReverseOffsetDateTime) => {
|
|
60
|
+
const optionsArray = initialOptions.map(opt => getRangeOption(opt, translate, toLocalDateTime, firstDayOfWeek, toReverseOffsetDateTime))
|
|
61
|
+
.filter(option => !!option && option.id !== dateRangeInner_1.CUSTOM_CALENDAR_ID);
|
|
62
|
+
const optionsMap = new Map();
|
|
63
|
+
optionsArray.forEach(opt => {
|
|
64
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
65
|
+
if (opt.getRange) {
|
|
66
|
+
const range = opt.getRange();
|
|
67
|
+
const key = `${range.from.toISOString()}_${range.to.toISOString()}`;
|
|
68
|
+
if (optionsMap.has(key)) {
|
|
69
|
+
optionsMap.set(`${key}_${opt.id}`, Object.assign(Object.assign({}, opt), { getRange: () => range }));
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
optionsMap.set(`${key}`, Object.assign(Object.assign({}, opt), { getRange: () => range }));
|
|
73
|
+
}
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
return optionsMap;
|
|
78
|
+
};
|
|
79
|
+
exports.getOptionsPeriodMap = getOptionsPeriodMap;
|
|
80
|
+
const getSelectedRangeFromValue = (optionsMap, value) => {
|
|
81
|
+
if (!value) {
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
const currentOption = optionsMap.get(`${value.from.toISOString()}_${value.to.toISOString()}`);
|
|
85
|
+
if (!currentOption || value.label === dateRangeInner_1.CUSTOM_CALENDAR_ID) {
|
|
86
|
+
return {
|
|
87
|
+
label: dateRangeInner_1.CUSTOM_CALENDAR_ID,
|
|
88
|
+
from: value.from,
|
|
89
|
+
to: value.to
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function findValueByLabel(val) {
|
|
93
|
+
for (const [_, mapVal] of optionsMap.entries()) {
|
|
94
|
+
if (mapVal.id === val.label) {
|
|
95
|
+
const mapValRange = mapVal.getRange();
|
|
96
|
+
return mapValRange.from.getTime() === val.from.getTime() && mapValRange.to.getTime() === val.to.getTime() ? { id: mapVal.id, from: mapValRange.from, to: mapValRange.to } : undefined;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
const optionToReturn = value.label && currentOption.id && value.label !== currentOption.id ? findValueByLabel(value) : undefined;
|
|
102
|
+
if (optionToReturn) {
|
|
103
|
+
return {
|
|
104
|
+
label: optionToReturn.id,
|
|
105
|
+
from: value.from,
|
|
106
|
+
to: value.to
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
label: currentOption.id,
|
|
111
|
+
from: value.from,
|
|
112
|
+
to: value.to
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
exports.getSelectedRangeFromValue = getSelectedRangeFromValue;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import "./icon.less";
|
|
3
3
|
import { IIcon } from "./icon";
|
|
4
|
+
/**
|
|
5
|
+
@deprecated - will be removed in future releases
|
|
6
|
+
duplicate of **IconRemovePeople**, please use that instead
|
|
7
|
+
*/
|
|
4
8
|
export declare const IconAddPeople2: React.FC<IIcon>;
|
|
@@ -5,6 +5,10 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const classNames_1 = require("../commonHelpers/classNames/classNames");
|
|
7
7
|
const useUniqueId_1 = require("../commonHelpers/useUniqueId");
|
|
8
|
+
/**
|
|
9
|
+
@deprecated - will be removed in future releases
|
|
10
|
+
duplicate of **IconRemovePeople**, please use that instead
|
|
11
|
+
*/
|
|
8
12
|
const IconAddPeople2 = ({ className, size, title, description, focusable = false }) => {
|
|
9
13
|
const uniqueId = (0, useUniqueId_1.useUniqueId)();
|
|
10
14
|
const classes = (0, react_1.useMemo)(() => (0, classNames_1.classNames)([
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IconLaptop = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const classNames_1 = require("../commonHelpers/classNames/classNames");
|
|
7
|
+
const useUniqueId_1 = require("../commonHelpers/useUniqueId");
|
|
8
|
+
const IconLaptop = ({ className, size, title, description, focusable = false }) => {
|
|
9
|
+
const uniqueId = (0, useUniqueId_1.useUniqueId)();
|
|
10
|
+
const classes = (0, react_1.useMemo)(() => (0, classNames_1.classNames)([
|
|
11
|
+
"zen-icon",
|
|
12
|
+
(size ? `zen-icon--${size}` : ""),
|
|
13
|
+
className !== null && className !== void 0 ? className : ""
|
|
14
|
+
]), [size, className]);
|
|
15
|
+
return (0, jsx_runtime_1.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", focusable: focusable ? "true" : undefined, tabIndex: focusable ? 0 : undefined, role: focusable || title || description ? undefined : "presentation", className: classes, "aria-labelledby": title && focusable ? uniqueId : undefined, "data-name": "IconLaptop", children: [title ? (0, jsx_runtime_1.jsx)("title", { id: uniqueId, children: title }) : null, description ? (0, jsx_runtime_1.jsx)("desc", { children: description }) : null, (0, jsx_runtime_1.jsx)("path", { fillRule: "evenodd", d: "M3 4a1 1 0 0 1 1-1h16a1 1 0 0 1 1 1v11h1a1 1 0 0 1 1 1v4a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1v-4a1 1 0 0 1 1-1h1zm2 11h14V5H5zm-2 2v2h18v-2z", clipRule: "evenodd" }), (0, jsx_runtime_1.jsx)("path", { d: "M17.25 13.063c0 .517-.403.937-.9.937s-.9-.42-.9-.937V7.437c0-.517.403-.937.9-.937s.9.42.9.938zM14.25 13.063c0 .517-.403.937-.9.937s-.9-.42-.9-.937v-4.22c0-.517.403-.937.9-.937s.9.42.9.938zM11.25 13.063c0 .517-.403.937-.9.937s-.9-.42-.9-.937V10.25c0-.518.403-.937.9-.937s.9.42.9.937z" })] });
|
|
16
|
+
};
|
|
17
|
+
exports.IconLaptop = IconLaptop;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IconRemovePeople = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const classNames_1 = require("../commonHelpers/classNames/classNames");
|
|
7
|
+
const useUniqueId_1 = require("../commonHelpers/useUniqueId");
|
|
8
|
+
const IconRemovePeople = ({ className, size, title, description, focusable = false }) => {
|
|
9
|
+
const uniqueId = (0, useUniqueId_1.useUniqueId)();
|
|
10
|
+
const classes = (0, react_1.useMemo)(() => (0, classNames_1.classNames)([
|
|
11
|
+
"zen-icon",
|
|
12
|
+
(size ? `zen-icon--${size}` : ""),
|
|
13
|
+
className !== null && className !== void 0 ? className : ""
|
|
14
|
+
]), [size, className]);
|
|
15
|
+
return (0, jsx_runtime_1.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", focusable: focusable ? "true" : undefined, tabIndex: focusable ? 0 : undefined, role: focusable || title || description ? undefined : "presentation", className: classes, "aria-labelledby": title && focusable ? uniqueId : undefined, "data-name": "IconRemovePeople", children: [title ? (0, jsx_runtime_1.jsx)("title", { id: uniqueId, children: title }) : null, description ? (0, jsx_runtime_1.jsx)("desc", { children: description }) : null, (0, jsx_runtime_1.jsx)("path", { fillRule: "evenodd", d: "M12 4a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5M7.5 6.5a4.5 4.5 0 1 1 9 0 4.5 4.5 0 0 1-9 0M5.678 19c.71-2.909 3.092-5 6.322-5q.453 0 .879.053a1 1 0 0 0 .242-1.985A9 9 0 0 0 12 12c-4.758 0-8.083 3.521-8.496 7.906A1 1 0 0 0 4.5 21H12a1 1 0 1 0 0-2zm9.615-3.707a1 1 0 0 1 1.414 0L18 16.586l1.293-1.293a1 1 0 0 1 1.414 1.414L19.414 18l1.293 1.293a1 1 0 0 1-1.414 1.414L18 19.414l-1.293 1.293a1 1 0 0 1-1.414-1.414L16.586 18l-1.293-1.293a1 1 0 0 1 0-1.414", clipRule: "evenodd" })] });
|
|
16
|
+
};
|
|
17
|
+
exports.IconRemovePeople = IconRemovePeople;
|