@geotab/zenith 1.22.2-beta.0 → 1.22.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/README.md +7 -0
  2. package/dist/card/card.d.ts +1 -8
  3. package/dist/card/card.js +29 -53
  4. package/dist/card/components/cardButton/cardButton.d.ts +0 -1
  5. package/dist/card/components/title.d.ts +1 -5
  6. package/dist/card/components/title.js +5 -9
  7. package/dist/commonStyles/common.less +1 -0
  8. package/dist/dateInput/dateInput.js +1 -1
  9. package/dist/dropdown/dropdown.js +2 -1
  10. package/dist/groupsFilter/groupsFilter.js +1 -0
  11. package/dist/groupsFilter/stateReducer/stateReducer.js +1 -1
  12. package/dist/index.css +762 -178
  13. package/dist/index.d.ts +7 -2
  14. package/dist/index.js +24 -16
  15. package/dist/list/hooks/useContainerScroll.d.ts +4 -0
  16. package/dist/list/hooks/useContainerScroll.js +38 -0
  17. package/dist/list/hooks/useDragAndDrop.d.ts +4 -0
  18. package/dist/list/hooks/useDragAndDrop.js +134 -0
  19. package/dist/list/hooks/useLazyLoading.d.ts +1 -0
  20. package/dist/list/hooks/useLazyLoading.js +52 -0
  21. package/dist/list/hooks/useVirtualScroll.d.ts +4 -0
  22. package/dist/list/hooks/useVirtualScroll.js +104 -0
  23. package/dist/list/interfaces.d.ts +16 -0
  24. package/dist/list/interfaces.js +5 -0
  25. package/dist/list/itemCompact/itemCompact.d.ts +18 -0
  26. package/dist/list/itemCompact/itemCompact.js +24 -0
  27. package/dist/list/itemCompact/itemCompactWaiting.d.ts +6 -0
  28. package/dist/list/itemCompact/itemCompactWaiting.js +14 -0
  29. package/dist/list/itemData/itemData.d.ts +30 -0
  30. package/dist/list/itemData/itemData.js +25 -0
  31. package/dist/list/itemData/itemDataInternal.d.ts +29 -0
  32. package/dist/list/itemData/itemDataInternal.js +66 -0
  33. package/dist/list/itemData/itemDataWaiting.d.ts +5 -0
  34. package/dist/list/itemData/itemDataWaiting.js +8 -0
  35. package/dist/list/list.d.ts +13 -0
  36. package/dist/list/list.js +54 -0
  37. package/dist/list/listItem/listItem.d.ts +16 -0
  38. package/dist/list/listItem/listItem.js +72 -0
  39. package/dist/list/listItem/listItemWaiting.d.ts +8 -0
  40. package/dist/list/listItem/listItemWaiting.js +14 -0
  41. package/dist/list/utils/changeOrder.d.ts +1 -0
  42. package/dist/list/utils/changeOrder.js +10 -0
  43. package/dist/list/utils/findItemPosition.d.ts +1 -0
  44. package/dist/list/utils/findItemPosition.js +19 -0
  45. package/dist/list/utils/findListElement.d.ts +1 -0
  46. package/dist/list/utils/findListElement.js +13 -0
  47. package/dist/list/utils/findVisibleListItems.d.ts +1 -0
  48. package/dist/list/utils/findVisibleListItems.js +60 -0
  49. package/dist/list/utils/getLoadingItems.d.ts +2 -0
  50. package/dist/list/utils/getLoadingItems.js +18 -0
  51. package/dist/list/utils/isActiveElement.d.ts +1 -0
  52. package/dist/list/utils/isActiveElement.js +14 -0
  53. package/dist/list/utils/isDataListitem.d.ts +3 -0
  54. package/dist/list/utils/isDataListitem.js +11 -0
  55. package/dist/list/viewportProvider/viewportContext.d.ts +6 -0
  56. package/dist/list/viewportProvider/viewportContext.js +5 -0
  57. package/dist/list/viewportProvider/viewportProvider.d.ts +6 -0
  58. package/dist/list/viewportProvider/viewportProvider.js +7 -0
  59. package/dist/selectList/selectList.js +3 -3
  60. package/dist/selectList/selectListItem.js +1 -1
  61. package/dist/selectRaw/selectRaw.js +1 -1
  62. package/dist/utils/localization/translations/cs-json.d.ts +1 -0
  63. package/dist/utils/localization/translations/cs-json.js +2 -1
  64. package/dist/utils/localization/translations/de-json.d.ts +1 -0
  65. package/dist/utils/localization/translations/de-json.js +2 -1
  66. package/dist/utils/localization/translations/en-json.d.ts +1 -1
  67. package/dist/utils/localization/translations/en-json.js +1 -1
  68. package/dist/utils/localization/translations/es-json.d.ts +1 -0
  69. package/dist/utils/localization/translations/es-json.js +2 -1
  70. package/dist/utils/localization/translations/fr-FR-json.d.ts +1 -0
  71. package/dist/utils/localization/translations/fr-FR-json.js +2 -1
  72. package/dist/utils/localization/translations/fr-json.d.ts +1 -0
  73. package/dist/utils/localization/translations/fr-json.js +2 -1
  74. package/dist/utils/localization/translations/id-json.d.ts +1 -0
  75. package/dist/utils/localization/translations/id-json.js +2 -1
  76. package/dist/utils/localization/translations/it-json.d.ts +1 -0
  77. package/dist/utils/localization/translations/it-json.js +2 -1
  78. package/dist/utils/localization/translations/ja-json.d.ts +1 -0
  79. package/dist/utils/localization/translations/ja-json.js +2 -1
  80. package/dist/utils/localization/translations/ko-KR-json.d.ts +1 -0
  81. package/dist/utils/localization/translations/ko-KR-json.js +2 -1
  82. package/dist/utils/localization/translations/ms-json.d.ts +1 -0
  83. package/dist/utils/localization/translations/ms-json.js +2 -1
  84. package/dist/utils/localization/translations/nl-json.d.ts +1 -0
  85. package/dist/utils/localization/translations/nl-json.js +2 -1
  86. package/dist/utils/localization/translations/pl-json.d.ts +1 -0
  87. package/dist/utils/localization/translations/pl-json.js +2 -1
  88. package/dist/utils/localization/translations/pt-BR-json.d.ts +1 -0
  89. package/dist/utils/localization/translations/pt-BR-json.js +2 -1
  90. package/dist/utils/localization/translations/sv-json.d.ts +1 -0
  91. package/dist/utils/localization/translations/sv-json.js +2 -1
  92. package/dist/utils/localization/translations/th-json.d.ts +1 -0
  93. package/dist/utils/localization/translations/th-json.js +2 -1
  94. package/dist/utils/localization/translations/tr-json.d.ts +1 -0
  95. package/dist/utils/localization/translations/tr-json.js +2 -1
  96. package/dist/utils/localization/translations/zh-Hans-json.d.ts +1 -0
  97. package/dist/utils/localization/translations/zh-Hans-json.js +2 -1
  98. package/dist/utils/theme/useIconSize.d.ts +2 -0
  99. package/dist/utils/theme/useIconSize.js +9 -0
  100. package/package.json +4 -4
  101. package/dist/card/card.js.map +0 -1
  102. package/dist/card/components/cardButton/cardButton.js.map +0 -1
  103. package/dist/card/components/cardFavorite.d.ts +0 -0
  104. package/dist/card/components/cardFavorite.js +0 -1
  105. package/dist/card/components/title.js.map +0 -1
  106. package/dist/favoriteButton/favoriteButton.d.ts +0 -7
  107. package/dist/favoriteButton/favoriteButton.js +0 -16
  108. package/dist/favoriteButton/favoriteButton.js.map +0 -1
  109. package/dist/icons/iconStarFilled.js.map +0 -1
  110. package/dist/index.js.map +0 -1
  111. package/dist/utils/localization/translations/en-json.js.map +0 -1
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.ItemData = void 0;
15
+ const jsx_runtime_1 = require("react/jsx-runtime");
16
+ const react_1 = require("react");
17
+ const viewportContext_1 = require("../viewportProvider/viewportContext");
18
+ const itemDataInternal_1 = require("./itemDataInternal");
19
+ const ItemDataInner = (_a) => {
20
+ var { id } = _a, rest = __rest(_a, ["id"]);
21
+ const { isInViewport } = (0, react_1.useContext)(viewportContext_1.viewportContext);
22
+ const visible = (0, react_1.useMemo)(() => isInViewport(id), [id, isInViewport]);
23
+ return (0, jsx_runtime_1.jsx)(itemDataInternal_1.ItemDataInternal, Object.assign({ id: id, visible: visible }, rest), id);
24
+ };
25
+ exports.ItemData = (0, react_1.memo)(ItemDataInner);
@@ -0,0 +1,29 @@
1
+ import { FunctionComponent, ReactNode } from "react";
2
+ import { IIcon } from "../../icons/icon";
3
+ import { TListItemAction } from "../interfaces";
4
+ interface IItemDataData {
5
+ label?: string;
6
+ value: string | number | React.ReactNode;
7
+ link?: string;
8
+ icon?: FunctionComponent<IIcon> | ReactNode;
9
+ iconClassName?: string;
10
+ }
11
+ export interface IItemData {
12
+ id: string;
13
+ visible?: boolean;
14
+ icon?: FunctionComponent<IIcon> | ReactNode;
15
+ iconClassName?: string;
16
+ name: string;
17
+ link?: string;
18
+ secondary?: string;
19
+ status?: React.ReactNode;
20
+ actions?: TListItemAction[];
21
+ data?: IItemDataData[];
22
+ onClick?: () => void;
23
+ checked?: boolean;
24
+ onCheck?: (checked: boolean) => void;
25
+ isMobile?: boolean;
26
+ isDrive?: boolean;
27
+ }
28
+ export declare const ItemDataInternal: ({ id, visible, icon, iconClassName, name, link, secondary, status, actions, data, onClick, checked, onCheck, isDrive, isMobile }: IItemData) => import("react/jsx-runtime").JSX.Element;
29
+ export {};
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ItemDataInternal = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const interfaces_1 = require("../interfaces");
7
+ const useLanguage_1 = require("../../utils/localization/useLanguage");
8
+ const button_1 = require("../../button/button");
9
+ const classNames_1 = require("../../commonHelpers/classNames/classNames");
10
+ const iconChevronRight_1 = require("../../icons/iconChevronRight");
11
+ const iconDotVertical_1 = require("../../icons/iconDotVertical");
12
+ const menu_1 = require("../../menu/menu");
13
+ const isActiveElement_1 = require("../utils/isActiveElement");
14
+ const checkbox_1 = require("../../checkbox/checkbox");
15
+ const ItemDataInternalInner = ({ id, visible, icon, iconClassName, name, link, secondary, status, actions, data, onClick, checked, onCheck, isDrive, isMobile }) => {
16
+ const { translate } = (0, useLanguage_1.useLanguage)();
17
+ const driveClassName = (0, react_1.useMemo)(() => isDrive
18
+ ? isMobile ? "zen-item-data-drive" : "zen-item-data-drive-tablet"
19
+ : "", [isDrive, isMobile]);
20
+ const renderActions = (0, react_1.useCallback)(() => {
21
+ if (!actions || actions.length === 0) {
22
+ return null;
23
+ }
24
+ return (0, jsx_runtime_1.jsx)(menu_1.Menu, { alignment: "bottom-right", title: translate("More"), trigger: (0, jsx_runtime_1.jsx)(button_1.Button, { type: "tertiary-black", className: "zen-item-data__more-button", "aria-label": translate("More"), title: translate("More"), children: (0, jsx_runtime_1.jsx)(iconDotVertical_1.IconDotVertical, { size: "large" }) }), children: actions.map((action) => (0, jsx_runtime_1.jsx)(menu_1.Menu.Item, { id: action.name, name: action.name, onClick: (0, interfaces_1.isButtonAction)(action) ? action.onClick : undefined, link: !(0, interfaces_1.isButtonAction)(action) ? action.link : undefined }, action.name)) });
25
+ }, [actions, translate]);
26
+ const renderIcon = (0, react_1.useCallback)((iconComponent, iClassName, className) => {
27
+ if (typeof iconComponent === "function") {
28
+ return (0, react_1.createElement)(iconComponent, { size: "large", className: (0, classNames_1.classNames)([className || "", iClassName || ""]) });
29
+ }
30
+ return iconComponent;
31
+ }, []);
32
+ const handleClick = (0, react_1.useCallback)((e) => {
33
+ if (!onClick) {
34
+ return;
35
+ }
36
+ if (e.target instanceof HTMLElement && (0, isActiveElement_1.isActiveElement)(e.target)) {
37
+ return;
38
+ }
39
+ onClick();
40
+ }, [onClick]);
41
+ const handleCheck = (0, react_1.useCallback)((e) => {
42
+ if (onCheck) {
43
+ onCheck(e.target.checked);
44
+ }
45
+ }, [onCheck]);
46
+ const hasCheckbox = (0, react_1.useMemo)(() => checked !== undefined && onCheck, [checked, onCheck]);
47
+ const placeholderHeight = (0, react_1.useMemo)(() => {
48
+ let plHeight = secondary ? 32 : (icon ? 24 : 16);
49
+ if (data) {
50
+ plHeight += 4 + data.length * 16 + (data.length - 1) * 4;
51
+ }
52
+ return { height: `${plHeight + 12 * 2 + 1}px` };
53
+ }, [data, icon, secondary]);
54
+ const classNamesList = (0, react_1.useMemo)(() => (0, classNames_1.classNames)(["zen-item-data", driveClassName || ""]), [driveClassName]);
55
+ if (!visible) {
56
+ return (0, jsx_runtime_1.jsx)("li", { style: placeholderHeight, className: classNamesList, "data-list-item-id": id }, id);
57
+ }
58
+ return (0, jsx_runtime_1.jsxs)("li", { className: (0, classNames_1.classNames)(["zen-item-data", driveClassName || ""]), "data-list-item-id": id, onClick: handleClick, children: [(0, jsx_runtime_1.jsxs)("div", { className: "zen-item-data__main", children: [hasCheckbox && (0, jsx_runtime_1.jsx)(checkbox_1.Checkbox, { className: "zen-item-data__checkbox", checked: checked, onChange: handleCheck, title: name }), icon ? (0, jsx_runtime_1.jsx)("div", { className: (0, classNames_1.classNames)(["zen-item-data__icon", iconClassName || ""]), children: renderIcon(icon) }) : null, (0, jsx_runtime_1.jsxs)("div", { className: "zen-item-data__main-data", children: [(0, jsx_runtime_1.jsxs)("div", { className: "zen-item-data__identifier", children: [link
59
+ ? (0, jsx_runtime_1.jsx)("a", { href: link, className: "zen-item-data__link zen-link zen-link--light zen-link--inline", children: name })
60
+ : (0, jsx_runtime_1.jsx)("div", { className: "zen-item-data__name", children: name }), secondary ? (0, jsx_runtime_1.jsx)("div", { className: "zen-item-data__secondary", children: secondary }) : null] }), status ? (0, jsx_runtime_1.jsx)("div", { className: "zen-item-data__status", children: status }) : null, renderActions(), onClick ? (0, jsx_runtime_1.jsx)(button_1.Button, { type: "tertiary-black", className: "zen-item-data__click", onClick: onClick, title: translate("Open"), "aria-label": translate("Open"), children: (0, jsx_runtime_1.jsx)(iconChevronRight_1.IconChevronRight, { size: "large", className: "zen-item-data__click-icon" }) }) : null] })] }), data && data.length > 0
61
+ ? (0, jsx_runtime_1.jsxs)("div", { className: "zen-item-data__secondary-data", children: [hasCheckbox ? (0, jsx_runtime_1.jsx)("div", { className: "zen-item-data__checkbox-placeholder" }) : null, icon ? (0, jsx_runtime_1.jsx)("div", { className: "zen-item-data__icon-placeholder" }) : null, (0, jsx_runtime_1.jsx)("div", { className: "zen-item-data__data", children: data.map((item, index) => ((0, jsx_runtime_1.jsxs)("div", { className: "zen-item-data__data-row", children: [item.label ? (0, jsx_runtime_1.jsx)("span", { className: "zen-item-data__data-label", children: item.label }) : null, (0, jsx_runtime_1.jsxs)("span", { className: "zen-item-data__data-value", children: [item.icon ? renderIcon(item.icon, item.iconClassName, "zen-item-data__data-value-icon") : null, item.link
62
+ ? (0, jsx_runtime_1.jsx)("a", { className: "zen-link zen-link--inline zen-link--light", href: item.link, children: item.value })
63
+ : (0, jsx_runtime_1.jsx)("span", { className: "zen-item-data__data-value-text", children: item.value })] })] }, index))) })] })
64
+ : null] }, id);
65
+ };
66
+ exports.ItemDataInternal = (0, react_1.memo)(ItemDataInternalInner);
@@ -0,0 +1,5 @@
1
+ import "./itemData.less";
2
+ export interface IItemDataWaiting {
3
+ id: string;
4
+ }
5
+ export declare const ItemDataWaiting: ({ id }: IItemDataWaiting) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ItemDataWaiting = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const classNames_1 = require("../../commonHelpers/classNames/classNames");
6
+ const skeleton_1 = require("../../skeleton/skeleton");
7
+ const ItemDataWaiting = ({ id }) => (0, jsx_runtime_1.jsxs)("li", { className: (0, classNames_1.classNames)(["zen-item-data"]), "data-list-item-id": id, children: [(0, jsx_runtime_1.jsx)(skeleton_1.Skeleton, { className: "zen-item-data__waiting" }), (0, jsx_runtime_1.jsx)(skeleton_1.Skeleton, { className: "zen-item-data__waiting" }), (0, jsx_runtime_1.jsx)(skeleton_1.Skeleton, { className: "zen-item-data__waiting" })] }, id);
8
+ exports.ItemDataWaiting = ItemDataWaiting;
@@ -0,0 +1,13 @@
1
+ import { IZenComponentProps } from "../commonHelpers/zenComponent";
2
+ import "./list.less";
3
+ import { TListType } from "./interfaces";
4
+ export interface IList extends IZenComponentProps {
5
+ type?: TListType;
6
+ onChangeOrder?: (startPosition: number, endPosition: number) => void;
7
+ checked?: string[];
8
+ onCheck?: (checked: string[]) => void;
9
+ onListEnd?: () => void;
10
+ isLoading?: boolean;
11
+ waitingItems?: number;
12
+ }
13
+ export declare const List: ({ type, children, onChangeOrder, checked, onCheck, onListEnd, isLoading, waitingItems }: IList) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.List = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const useDragAndDrop_1 = require("./hooks/useDragAndDrop");
7
+ const isDataListitem_1 = require("./utils/isDataListitem");
8
+ const useDrive_1 = require("../utils/theme/useDrive");
9
+ const useMobile_1 = require("../commonHelpers/hooks/useMobile");
10
+ const viewportProvider_1 = require("./viewportProvider/viewportProvider");
11
+ const useVirtualScroll_1 = require("./hooks/useVirtualScroll");
12
+ const useLazyLoading_1 = require("./hooks/useLazyLoading");
13
+ const getLoadingItems_1 = require("./utils/getLoadingItems");
14
+ const List = ({ type, children, onChangeOrder, checked, onCheck, onListEnd, isLoading, waitingItems }) => {
15
+ const listId = (0, react_1.useId)();
16
+ const listRef = (0, react_1.useRef)(null);
17
+ const onChangeOrderCallback = (0, react_1.useCallback)((startPosition, endPosition) => {
18
+ if (onChangeOrder) {
19
+ onChangeOrder(startPosition, endPosition);
20
+ }
21
+ }, [onChangeOrder]);
22
+ const { onDragStart } = (0, useDragAndDrop_1.useDragAndDrop)(listRef, onChangeOrderCallback);
23
+ const isDrive = (0, useDrive_1.useDrive)();
24
+ const isMobile = (0, useMobile_1.useMobile)();
25
+ const { isInViewport } = (0, useVirtualScroll_1.useVirtualScroll)(listRef, children);
26
+ (0, useLazyLoading_1.useLazyLoading)(listRef, isLoading, onListEnd);
27
+ const childrenArray = (0, react_1.useMemo)(() => react_1.Children.map(children, (child) => {
28
+ const props = {
29
+ isDrive: isDrive,
30
+ isMobile: isMobile
31
+ };
32
+ if (onChangeOrder) {
33
+ props.onDragStart = onDragStart;
34
+ }
35
+ if (onCheck && checked && (0, isDataListitem_1.isDataListItem)(child)) {
36
+ const id = child.props.id;
37
+ props.checked = checked.indexOf(id) > -1;
38
+ props.onCheck = (itemChecked) => onCheck(itemChecked ? [...checked, id] : checked.filter((c) => c !== id));
39
+ }
40
+ if (Object.keys(props).length > 0) {
41
+ return (0, react_1.cloneElement)(child, props);
42
+ }
43
+ return child;
44
+ }), [checked, children, isDrive, isMobile, onChangeOrder, onCheck, onDragStart]);
45
+ const loadingChildren = (0, react_1.useMemo)(() => {
46
+ if (!isLoading) {
47
+ return null;
48
+ }
49
+ const defaultWaitingItems = type === "data" ? 50 : 10;
50
+ return (0, getLoadingItems_1.getLoadingItems)(type || "standard", waitingItems || defaultWaitingItems, listId, isDrive, isMobile);
51
+ }, [isDrive, isLoading, isMobile, listId, type, waitingItems]);
52
+ return (0, jsx_runtime_1.jsx)(viewportProvider_1.ViewportProvider, { isInViewport: isInViewport, children: (0, jsx_runtime_1.jsxs)("ul", { className: "zen-list", ref: listRef, children: [childrenArray, loadingChildren] }) });
53
+ };
54
+ exports.List = List;
@@ -0,0 +1,16 @@
1
+ import { ReactNode } from "react";
2
+ import { IZenComponentProps } from "../../commonHelpers/zenComponent";
3
+ import "./listItem.less";
4
+ import { TListItemAction } from "../interfaces";
5
+ export interface IListItem extends IZenComponentProps {
6
+ id: string;
7
+ image?: ReactNode;
8
+ name: string;
9
+ secondary?: string;
10
+ status?: ReactNode;
11
+ actions?: TListItemAction[];
12
+ onClick?: () => void;
13
+ link?: string;
14
+ onDragStart?: (e: React.PointerEvent<HTMLElement>) => void;
15
+ }
16
+ export declare const ListItem: ({ id, className, image, name, secondary, status, actions, onClick, link, onDragStart }: IListItem) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ListItem = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const iconGrab_1 = require("../../icons/iconGrab");
7
+ const button_1 = require("../../button/button");
8
+ const useMobile_1 = require("../../commonHelpers/hooks/useMobile");
9
+ const menu_1 = require("../../menu/menu");
10
+ const useLanguage_1 = require("../../utils/localization/useLanguage");
11
+ const iconDotVertical_1 = require("../../icons/iconDotVertical");
12
+ const interfaces_1 = require("../interfaces");
13
+ const useDriveClassName_1 = require("../../utils/theme/useDriveClassName");
14
+ const classNames_1 = require("../../commonHelpers/classNames/classNames");
15
+ const useIconSize_1 = require("../../utils/theme/useIconSize");
16
+ const iconChevronRight_1 = require("../../icons/iconChevronRight");
17
+ const isActiveElement_1 = require("../utils/isActiveElement");
18
+ const ListItem = ({ id, className, image, name, secondary, status, actions, onClick, link, onDragStart }) => {
19
+ const isMobile = (0, useMobile_1.useMobile)();
20
+ const driveClassName = (0, useDriveClassName_1.useDriveClassName)("zen-list-item");
21
+ const iconSize = (0, useIconSize_1.useIconSize)();
22
+ const { translate } = (0, useLanguage_1.useLanguage)();
23
+ const itemRef = (0, react_1.useRef)(null);
24
+ const renderActions = (0, react_1.useCallback)(() => {
25
+ if (!actions || actions.length === 0) {
26
+ return null;
27
+ }
28
+ const { primaryActions, secondaryActions } = actions.reduce((acc, action) => {
29
+ if (!isMobile && action.hasOwnProperty("icon")) {
30
+ acc.primaryActions.push(action);
31
+ }
32
+ else {
33
+ acc.secondaryActions.push(action);
34
+ }
35
+ return acc;
36
+ }, { primaryActions: [], secondaryActions: [] });
37
+ const buttons = (0, jsx_runtime_1.jsx)("div", { className: "zen-list-item__actions", children: primaryActions.map((action) => (0, jsx_runtime_1.jsx)(button_1.Button, { type: "tertiary-black", className: "zen-list-item__action-button", onClick: (0, interfaces_1.isButtonAction)(action) ? action.onClick : undefined, link: !(0, interfaces_1.isButtonAction)(action) ? action.link : undefined, children: action.icon ? (0, react_1.createElement)(action.icon, { size: iconSize }) : null }, action.name)) });
38
+ const menu = secondaryActions.length > 0
39
+ ? (0, jsx_runtime_1.jsx)(menu_1.Menu, { alignment: "bottom-right", title: translate("More"), trigger: (0, jsx_runtime_1.jsx)(button_1.Button, { type: "tertiary-black", className: "zen-list-item__more-button", children: (0, jsx_runtime_1.jsx)(iconDotVertical_1.IconDotVertical, { size: "large" }) }), children: secondaryActions.map((action) => (0, jsx_runtime_1.jsx)(menu_1.Menu.Item, { id: action.name, name: action.name, onClick: (0, interfaces_1.isButtonAction)(action) ? action.onClick : undefined, link: !(0, interfaces_1.isButtonAction)(action) ? action.link : undefined }, action.name)) })
40
+ : null;
41
+ return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [buttons, menu] });
42
+ }, [actions, iconSize, isMobile, translate]);
43
+ const isDndElement = (0, react_1.useCallback)((el) => {
44
+ if (!el) {
45
+ return false;
46
+ }
47
+ if (typeof el.className !== "string") {
48
+ return false;
49
+ }
50
+ return el.className.indexOf("zen-list-item__dnd") !== -1;
51
+ }, []);
52
+ const handleClick = (0, react_1.useCallback)((e) => {
53
+ if (!onClick && !link) {
54
+ return;
55
+ }
56
+ if (e.target instanceof HTMLElement && (0, isActiveElement_1.isActiveElement)(e.target) || isDndElement(e.target)) {
57
+ return;
58
+ }
59
+ if (onClick) {
60
+ onClick();
61
+ return;
62
+ }
63
+ if (itemRef.current) {
64
+ const linkEl = itemRef.current.querySelector(".zen-list-item__click");
65
+ linkEl === null || linkEl === void 0 ? void 0 : linkEl.click();
66
+ }
67
+ }, [isDndElement, link, onClick]);
68
+ const clickableClassName = (0, react_1.useMemo)(() => onClick || link ? "zen-list-item--clickable" : "", [link, onClick]);
69
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
70
+ return (0, jsx_runtime_1.jsxs)("li", { id: id, className: (0, classNames_1.classNames)(["zen-list-item", driveClassName || "", clickableClassName, className || ""]), onClick: handleClick, ref: itemRef, children: [onDragStart ? (0, jsx_runtime_1.jsx)("div", { className: "zen-list-item__dnd", onPointerDown: onDragStart, children: (0, jsx_runtime_1.jsx)(iconGrab_1.IconGrab, { size: "large" }) }) : null, image ? (0, jsx_runtime_1.jsx)("div", { className: "zen-list-item__image", children: image }) : null, (0, jsx_runtime_1.jsxs)("div", { className: "zen-list-item__identifier", children: [(0, jsx_runtime_1.jsx)("div", { className: "zen-list-item__name", children: name }), (0, jsx_runtime_1.jsx)("div", { className: "zen-list-item__secondary", children: secondary })] }), status ? (0, jsx_runtime_1.jsx)("div", { className: "zen-list-item__status", children: status }) : null, renderActions(), onClick || link ? (0, jsx_runtime_1.jsx)(button_1.Button, { type: "tertiary-black", className: "zen-list-item__click", onClick: onClick, link: link, children: (0, jsx_runtime_1.jsx)(iconChevronRight_1.IconChevronRight, { size: "large", className: "zen-list-item__click-icon" }) }) : null] });
71
+ };
72
+ exports.ListItem = ListItem;
@@ -0,0 +1,8 @@
1
+ import "./listItem.less";
2
+ interface IListItemWaiting {
3
+ id: string;
4
+ isDrive?: boolean;
5
+ isMobile?: boolean;
6
+ }
7
+ export declare const ListItemWaiting: ({ id, isDrive, isMobile }: IListItemWaiting) => import("react/jsx-runtime").JSX.Element;
8
+ export {};
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ListItemWaiting = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const skeleton_1 = require("../../skeleton/skeleton");
7
+ const classNames_1 = require("../../commonHelpers/classNames/classNames");
8
+ const ListItemWaiting = ({ id, isDrive, isMobile }) => {
9
+ const driveClassName = (0, react_1.useMemo)(() => isDrive
10
+ ? isMobile ? "zen-list-item--drive" : "zen-list-item--drive-tablet"
11
+ : "", [isDrive, isMobile]);
12
+ return (0, jsx_runtime_1.jsx)("li", { id: id, className: (0, classNames_1.classNames)(["zen-list-item", driveClassName]), children: (0, jsx_runtime_1.jsx)(skeleton_1.Skeleton, { className: "zen-list-item__waiting" }) });
13
+ };
14
+ exports.ListItemWaiting = ListItemWaiting;
@@ -0,0 +1 @@
1
+ export declare function changeOrder<T>(data: T[], startPosition: number, endPosition: number): T[];
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.changeOrder = void 0;
4
+ function changeOrder(data, startPosition, endPosition) {
5
+ const newData = [...data];
6
+ const [movedElement] = newData.splice(startPosition, 1);
7
+ newData.splice(endPosition, 0, movedElement);
8
+ return newData;
9
+ }
10
+ exports.changeOrder = changeOrder;
@@ -0,0 +1 @@
1
+ export declare const findItemPosition: (element: HTMLElement) => number;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findItemPosition = void 0;
4
+ const findItemPosition = (element) => {
5
+ const parent = element.parentElement;
6
+ if (!parent) {
7
+ return -1;
8
+ }
9
+ let ignoreOriginalElement = false;
10
+ for (let i = 0; i < parent.children.length; i++) {
11
+ const currentChild = parent.children[i];
12
+ ignoreOriginalElement = ignoreOriginalElement || currentChild.classList.contains("zen-list-item--dragging");
13
+ if (currentChild === element) {
14
+ return i - (ignoreOriginalElement ? 1 : 0);
15
+ }
16
+ }
17
+ return -1;
18
+ };
19
+ exports.findItemPosition = findItemPosition;
@@ -0,0 +1 @@
1
+ export declare const findListElement: (element: HTMLElement) => HTMLElement | null;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findListElement = void 0;
4
+ const findListElement = (element) => {
5
+ if (element.classList.contains("zen-list-item")) {
6
+ return element;
7
+ }
8
+ if (element.parentElement) {
9
+ return (0, exports.findListElement)(element.parentElement);
10
+ }
11
+ return null;
12
+ };
13
+ exports.findListElement = findListElement;
@@ -0,0 +1 @@
1
+ export declare const findVisibleListItems: (rows: Element[], top: number, bottom: number) => HTMLElement[];
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findVisibleListItems = void 0;
4
+ const findFirstVisible = (rows, top, rangeStart, rangeEnd) => {
5
+ const middle = Math.floor((rangeStart + rangeEnd) / 2);
6
+ const row = rows[middle];
7
+ const rowTop = row.getBoundingClientRect().top;
8
+ if (rowTop >= top) {
9
+ if (middle - rangeStart <= 1) {
10
+ return middle;
11
+ }
12
+ return findFirstVisible(rows, top, rangeStart, middle);
13
+ }
14
+ if (rangeEnd - middle <= 1) {
15
+ return middle;
16
+ }
17
+ return findFirstVisible(rows, top, middle, rangeEnd);
18
+ };
19
+ const findVisibleListItems = (rows, top, bottom) => {
20
+ if (rows.length === 0) {
21
+ return [];
22
+ }
23
+ let foundVisible = false;
24
+ let from = 0;
25
+ let to = 0;
26
+ const rowsLength = rows.length;
27
+ const firstVisible = findFirstVisible(rows, top, 0, rowsLength - 1);
28
+ const startIndex = Math.max(0, firstVisible - 1);
29
+ for (let i = startIndex; i < rowsLength; i++) {
30
+ const row = rows[i];
31
+ const { top: rowTop, bottom: rowBottom } = row.getBoundingClientRect();
32
+ if (rowTop >= top && rowBottom <= bottom) {
33
+ if (!foundVisible) {
34
+ from = i - 1;
35
+ }
36
+ foundVisible = true;
37
+ continue;
38
+ }
39
+ // if we found visible rows, then we can stop searching
40
+ if (foundVisible) {
41
+ // add last row if it is partially visible and next one for correct keyboard navigation with lazy loading
42
+ to = i + 1;
43
+ break;
44
+ }
45
+ }
46
+ // if we found visible rows, but the last row is not visible, then we need to add it
47
+ if (foundVisible && to === 0) {
48
+ to = rowsLength - 1;
49
+ }
50
+ const visibleRows = [];
51
+ if (from <= to) {
52
+ from = Math.max(0, from);
53
+ to = Math.min(rows.length - 1, to);
54
+ for (let i = from; i <= to; ++i) {
55
+ visibleRows.push(rows[i]);
56
+ }
57
+ }
58
+ return visibleRows;
59
+ };
60
+ exports.findVisibleListItems = findVisibleListItems;
@@ -0,0 +1,2 @@
1
+ import { TListType } from "../interfaces";
2
+ export declare const getLoadingItems: (type: TListType, count: number, listId: string, isDrive: boolean, isMobile: boolean) => import("react/jsx-runtime").JSX.Element[];
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getLoadingItems = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const itemDataWaiting_1 = require("../itemData/itemDataWaiting");
6
+ const itemCompactWaiting_1 = require("../itemCompact/itemCompactWaiting");
7
+ const listItemWaiting_1 = require("../listItem/listItemWaiting");
8
+ const getLoadingItems = (type, count, listId, isDrive, isMobile) => Array.from({ length: count }).map((_, index) => {
9
+ const id = `${listId}-${index}`;
10
+ if (type === "data") {
11
+ return (0, jsx_runtime_1.jsx)(itemDataWaiting_1.ItemDataWaiting, { id: id }, id);
12
+ }
13
+ if (type === "compact") {
14
+ return (0, jsx_runtime_1.jsx)(itemCompactWaiting_1.ItemCompactWaiting, { isDrive: isDrive, isMobile: isMobile }, id);
15
+ }
16
+ return (0, jsx_runtime_1.jsx)(listItemWaiting_1.ListItemWaiting, { id: id, isDrive: isDrive, isMobile: isMobile }, id);
17
+ });
18
+ exports.getLoadingItems = getLoadingItems;
@@ -0,0 +1 @@
1
+ export declare const isActiveElement: (element: HTMLElement, level?: number) => boolean;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isActiveElement = void 0;
4
+ const activeElements = ["A", "BUTTON", "INPUT", "SELECT", "TEXTAREA", "LABEL"];
5
+ const isActiveElement = (element, level = 0) => {
6
+ if (activeElements.indexOf(element.nodeName) > -1) {
7
+ return true;
8
+ }
9
+ if (level < 4 && element.parentElement) {
10
+ return (0, exports.isActiveElement)(element.parentElement, level + 1);
11
+ }
12
+ return false;
13
+ };
14
+ exports.isActiveElement = isActiveElement;
@@ -0,0 +1,3 @@
1
+ import { ReactElement, ReactNode } from "react";
2
+ import { IItemData } from "../itemData/itemData";
3
+ export declare const isDataListItem: (item: ReactNode) => item is ReactElement<IItemData, string | import("react").JSXElementConstructor<any>>;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isDataListItem = void 0;
4
+ const react_1 = require("react");
5
+ const isDataListItem = (item) => {
6
+ if (!(0, react_1.isValidElement)(item)) {
7
+ return false;
8
+ }
9
+ return "id" in item.props && "name" in item.props;
10
+ };
11
+ exports.isDataListItem = isDataListItem;
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ interface IViewportContext {
3
+ isInViewport: (id: string) => boolean;
4
+ }
5
+ export declare const viewportContext: import("react").Context<IViewportContext>;
6
+ export {};
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.viewportContext = void 0;
4
+ const react_1 = require("react");
5
+ exports.viewportContext = (0, react_1.createContext)({ isInViewport: () => true });
@@ -0,0 +1,6 @@
1
+ import { FC, PropsWithChildren } from "react";
2
+ interface IViewportProviderProps extends PropsWithChildren {
3
+ isInViewport: (id: string) => boolean;
4
+ }
5
+ export declare const ViewportProvider: FC<IViewportProviderProps>;
6
+ export {};
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ViewportProvider = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const viewportContext_1 = require("./viewportContext");
6
+ const ViewportProvider = ({ isInViewport, children }) => ((0, jsx_runtime_1.jsx)(viewportContext_1.viewportContext.Provider, { value: { isInViewport }, children: children }));
7
+ exports.ViewportProvider = ViewportProvider;
@@ -29,10 +29,10 @@ exports.defaultListItemHeight = 40;
29
29
  const MemoizedSelectListItem = (0, react_2.memo)(selectListItem_1.SelectListItem);
30
30
  const SelectListInnerComp = (0, react_2.forwardRef)(({ id, items, value, disabled, activeIndex = -1, title, multiselect = false, showCheckbox = false, standalone, className = "", onClickItem, onChangeItem, onKeyDown, onFocus, onBlur, style = {} }, listRef) => {
31
31
  var _a;
32
- const driveComponentClass = (0, useDriveClassName_1.useDriveClassName)("zen-list");
32
+ const driveComponentClass = (0, useDriveClassName_1.useDriveClassName)("zen-select-list");
33
33
  const state = (0, selectList_helpers_1.getInitialState)({ items, value, multiselect });
34
34
  state.activeIndex = activeIndex;
35
- return (0, jsx_runtime_1.jsx)("ul", { id: id, ref: listRef, className: (0, classNames_1.classNames)(["zen-list", driveComponentClass || "", className]), role: "listbox", "aria-multiselectable": multiselect, "aria-activedescendant": standalone ? ((0, selectList_helpers_1.getItemIdByIndex)(state.itemsState, state.activeIndex) || ((_a = items.find(el => !el.disabled)) === null || _a === void 0 ? void 0 : _a.id)) : undefined, "aria-label": title, "aria-disabled": disabled, tabIndex: standalone && !disabled ? 0 : -1, onKeyDown: onKeyDown, onFocus: onFocus, onBlur: onBlur, style: style, children: items.map((item, index) => (0, react_1.createElement)(MemoizedSelectListItem, Object.assign({}, item, { className: (0, classNames_1.classNames)(["zen-list__item", item.className || ""]), key: item.id, showCheckbox: showCheckbox, state: state.itemsState.get(item.id), focused: state.activeIndex === index, onChange: onChangeItem, onClick: onClickItem }), item.children)) });
35
+ return (0, jsx_runtime_1.jsx)("ul", { id: id, ref: listRef, className: (0, classNames_1.classNames)(["zen-select-list", driveComponentClass || "", className]), role: "listbox", "aria-multiselectable": multiselect, "aria-activedescendant": standalone ? ((0, selectList_helpers_1.getItemIdByIndex)(state.itemsState, state.activeIndex) || ((_a = items.find(el => !el.disabled)) === null || _a === void 0 ? void 0 : _a.id)) : undefined, "aria-label": title, "aria-disabled": disabled, tabIndex: standalone && !disabled ? 0 : -1, onKeyDown: onKeyDown, onFocus: onFocus, onBlur: onBlur, style: style, children: items.map((item, index) => (0, react_1.createElement)(MemoizedSelectListItem, Object.assign({}, item, { className: (0, classNames_1.classNames)(["zen-select-list__item", item.className || ""]), key: item.id, showCheckbox: showCheckbox, state: state.itemsState.get(item.id), focused: state.activeIndex === index, onChange: onChangeItem, onClick: onClickItem }), item.children)) });
36
36
  });
37
37
  SelectListInnerComp.displayName = "SelectListInnerComp";
38
38
  const SelectListInner = (0, react_2.memo)(SelectListInnerComp);
@@ -60,7 +60,7 @@ const SelectList = (_a) => {
60
60
  }, [multiselect]);
61
61
  (0, react_2.useEffect)(() => {
62
62
  if (state.activeIndex >= 0 && document.activeElement && listRef.current && (0, isChildOf_1.isChildOf)(document.activeElement, listRef.current)) {
63
- const itemEl = listRef.current.querySelector(`.zen-list__item:nth-child(${state.activeIndex + 1})`);
63
+ const itemEl = listRef.current.querySelector(`.zen-select-list__item:nth-child(${state.activeIndex + 1})`);
64
64
  itemEl === null || itemEl === void 0 ? void 0 : itemEl.scrollIntoView({ block: "nearest" });
65
65
  }
66
66
  }, [state.activeIndex]);
@@ -26,7 +26,7 @@ const SelectListItem = ({ id, disabled = false, state = checkboxState_1.Checkbox
26
26
  driveClassName || "",
27
27
  className
28
28
  ]), role: "option", "aria-selected": state === checkboxState_1.CheckboxState.On, "aria-disabled": disabled, onClick: onClickFunc, id: id, children: (0, jsx_runtime_1.jsxs)("div", { className: (0, classNames_1.classNames)([
29
- "zen-list__item-content",
29
+ "zen-select-list__item-content",
30
30
  "zen-select-item__wrapper",
31
31
  "zen-ellipsis",
32
32
  multiLevel ? "zen-select-item__wrapper--with-arrow" : ""
@@ -91,7 +91,7 @@ exports.SelectRaw = react_1.default.forwardRef((props, selectRef) => {
91
91
  }, [outerValue, items]);
92
92
  react_1.default.useEffect(() => {
93
93
  if (state.activeIndex >= 0 && document.activeElement && ref.current && (0, isChildOf_1.isChildOf)(document.activeElement, ref.current)) {
94
- const itemEl = ref.current.querySelector(`.zen-list__item:nth-child(${state.activeIndex + 1})`);
94
+ const itemEl = ref.current.querySelector(`.zen-select-list__item:nth-child(${state.activeIndex + 1})`);
95
95
  itemEl === null || itemEl === void 0 ? void 0 : itemEl.scrollIntoView({ block: "nearest" });
96
96
  }
97
97
  }, [state.activeIndex]);
@@ -215,4 +215,5 @@ export declare const translations: {
215
215
  Ma: string;
216
216
  Next: string;
217
217
  Previous: string;
218
+ Open: string;
218
219
  };
@@ -217,5 +217,6 @@ exports.translations = {
217
217
  "Filters": "Filtry",
218
218
  "Ma": "Kvě",
219
219
  "Next": "Další",
220
- "Previous": "Předchozí"
220
+ "Previous": "Předchozí",
221
+ "Open": "Otevřít"
221
222
  };
@@ -215,4 +215,5 @@ export declare const translations: {
215
215
  Ma: string;
216
216
  Next: string;
217
217
  Previous: string;
218
+ Open: string;
218
219
  };
@@ -217,5 +217,6 @@ exports.translations = {
217
217
  "Filters": "Filter",
218
218
  "Ma": "Mai",
219
219
  "Next": "Nächstes",
220
- "Previous": "Vorherige"
220
+ "Previous": "Vorherige",
221
+ "Open": "Offen"
221
222
  };