@geotab/zenith 3.5.0 → 3.5.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.
Files changed (57) hide show
  1. package/README.md +4 -0
  2. package/dist/index.css +57 -0
  3. package/dist/index.d.ts +1 -0
  4. package/dist/index.js +5 -3
  5. package/dist/list/hooks/useDragAndDrop.d.ts +19 -1
  6. package/dist/list/hooks/useDragAndDrop.js +65 -26
  7. package/dist/list/utils/findElement.d.ts +1 -0
  8. package/dist/list/utils/findElement.js +13 -0
  9. package/dist/list/utils/findItemPosition.d.ts +1 -1
  10. package/dist/list/utils/findItemPosition.js +2 -2
  11. package/dist/list/utils/isDragNotClick.d.ts +6 -0
  12. package/dist/list/utils/isDragNotClick.js +9 -0
  13. package/dist/nav/context/nav.context.d.ts +2 -0
  14. package/dist/nav/context/nav.context.js +3 -1
  15. package/dist/nav/nav.js +20 -8
  16. package/dist/nav/navEditList/navEditList.d.ts +7 -0
  17. package/dist/nav/navEditList/navEditList.js +22 -0
  18. package/dist/nav/navEditList/navEditListUtils.d.ts +3 -0
  19. package/dist/nav/navEditList/navEditListUtils.js +14 -0
  20. package/dist/nav/navEditSection/navEditSection.d.ts +3 -0
  21. package/dist/nav/navEditSection/navEditSection.js +7 -0
  22. package/dist/nav/navFooter/navEditFooter/navEditFooter.d.ts +11 -0
  23. package/dist/nav/navFooter/navEditFooter/navEditFooter.js +110 -0
  24. package/dist/nav/navFooter/navFooter.d.ts +2 -7
  25. package/dist/nav/navFooter/navFooter.js +4 -4
  26. package/dist/nav/navItem/navActionItem.d.ts +14 -0
  27. package/dist/nav/navItem/navActionItem.js +15 -0
  28. package/esm/index.d.ts +1 -0
  29. package/esm/index.js +1 -0
  30. package/esm/list/hooks/useDragAndDrop.d.ts +19 -1
  31. package/esm/list/hooks/useDragAndDrop.js +65 -26
  32. package/esm/list/utils/findElement.d.ts +1 -0
  33. package/esm/list/utils/findElement.js +9 -0
  34. package/esm/list/utils/findItemPosition.d.ts +1 -1
  35. package/esm/list/utils/findItemPosition.js +2 -2
  36. package/esm/list/utils/isDragNotClick.d.ts +6 -0
  37. package/esm/list/utils/isDragNotClick.js +5 -0
  38. package/esm/nav/context/nav.context.d.ts +2 -0
  39. package/esm/nav/context/nav.context.js +3 -1
  40. package/esm/nav/nav.js +21 -9
  41. package/esm/nav/navEditList/navEditList.d.ts +7 -0
  42. package/esm/nav/navEditList/navEditList.js +18 -0
  43. package/esm/nav/navEditList/navEditListUtils.d.ts +3 -0
  44. package/esm/nav/navEditList/navEditListUtils.js +10 -0
  45. package/esm/nav/navEditSection/navEditSection.d.ts +3 -0
  46. package/esm/nav/navEditSection/navEditSection.js +3 -0
  47. package/esm/nav/navFooter/navEditFooter/navEditFooter.d.ts +11 -0
  48. package/esm/nav/navFooter/navEditFooter/navEditFooter.js +101 -0
  49. package/esm/nav/navFooter/navFooter.d.ts +2 -7
  50. package/esm/nav/navFooter/navFooter.js +4 -4
  51. package/esm/nav/navItem/navActionItem.d.ts +14 -0
  52. package/esm/nav/navItem/navActionItem.js +11 -0
  53. package/package.json +4 -4
  54. package/dist/list/utils/findListElement.d.ts +0 -1
  55. package/dist/list/utils/findListElement.js +0 -13
  56. package/esm/list/utils/findListElement.d.ts +0 -1
  57. package/esm/list/utils/findListElement.js +0 -9
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ import "./navEditFooter.less";
3
+ import { IZenComponentProps } from "../../../commonHelpers/zenComponent";
4
+ /**
5
+ * @beta This component is not fully ready yet and may change in future releases.
6
+ */
7
+ export interface INavEditFooter extends IZenComponentProps {
8
+ handleSaveClick: () => void;
9
+ handleCancelClick: () => void;
10
+ }
11
+ export declare const NavEditFooter: React.FC<INavEditFooter>;
@@ -0,0 +1,101 @@
1
+ import { injectString } from "../../../utils/localization/translationsDictionary";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Button } from "../../../button/button";
4
+ import { classNames } from "../../../commonHelpers/classNames/classNames";
5
+ import { useLanguage } from "../../../utils/localization/useLanguage";
6
+ import { useNavContext } from "../../context/nav.context";
7
+ import { useCallback } from "react";
8
+ import { useMobile } from "../../../commonHelpers/hooks/useMobile";
9
+ injectString("cs", "Save", "Ulo\u017Eit");
10
+ injectString("da-DK", "Save", "Spare");
11
+ injectString("de", "Save", "Speichern");
12
+ injectString("en", "Save", "Save");
13
+ injectString("es", "Save", "Guardar");
14
+ injectString("fi-FI", "Save", "S\xE4\xE4st\xE4\xE4");
15
+ injectString("fr", "Save", "Enregistrer");
16
+ injectString("fr-FR", "Save", "Enregistrer");
17
+ injectString("hu-HU", "Save", "Ment\xE9s");
18
+ injectString("id", "Save", "Simpan");
19
+ injectString("it", "Save", "Salvare");
20
+ injectString("ja", "Save", "\u4FDD\u5B58");
21
+ injectString("ko-KR", "Save", "\uC800\uC7A5");
22
+ injectString("ms", "Save", "Simpan");
23
+ injectString("nb-NO", "Save", "Lagre");
24
+ injectString("nl", "Save", "Opslaan");
25
+ injectString("pl", "Save", "Zapisz");
26
+ injectString("pt-BR", "Save", "Salvar");
27
+ injectString("pt-PT", "Save", "Guardar");
28
+ injectString("sk-SK", "Save", "Ulo\u017Ei\u0165");
29
+ injectString("sv", "Save", "Spara");
30
+ injectString("th", "Save", "\u0E1A\u0E31\u0E19\u0E17\u0E36\u0E01");
31
+ injectString("tr", "Save", "Kaydet");
32
+ injectString("zh-Hans", "Save", "\u4FDD\u5B58");
33
+ injectString("zh-TW", "Save", "\u5132\u5B58");
34
+ injectString("ro-RO", "Save", "Salva\u021Bi");
35
+ injectString("cs", "Cancel", "Zru\u0161it");
36
+ injectString("da-DK", "Cancel", "Annuller");
37
+ injectString("de", "Cancel", "Abbrechen");
38
+ injectString("en", "Cancel", "Cancel");
39
+ injectString("es", "Cancel", "Cancelar");
40
+ injectString("fi-FI", "Cancel", "Peruuta");
41
+ injectString("fr", "Cancel", "Annuler");
42
+ injectString("fr-FR", "Cancel", "Annuler");
43
+ injectString("hu-HU", "Cancel", "M\xE9gse");
44
+ injectString("id", "Cancel", "Batalkan");
45
+ injectString("it", "Cancel", "Annullare");
46
+ injectString("ja", "Cancel", "\u30AD\u30E3\u30F3\u30BB\u30EB");
47
+ injectString("ko-KR", "Cancel", "\uCDE8\uC18C");
48
+ injectString("ms", "Cancel", "Batal");
49
+ injectString("nb-NO", "Cancel", "Avbryt");
50
+ injectString("nl", "Cancel", "Annuleren");
51
+ injectString("pl", "Cancel", "Anuluj");
52
+ injectString("pt-BR", "Cancel", "Cancelar");
53
+ injectString("pt-PT", "Cancel", "Cancelar");
54
+ injectString("sk-SK", "Cancel", "Zru\u0161.");
55
+ injectString("sv", "Cancel", "Avbryt");
56
+ injectString("th", "Cancel", "\u0E22\u0E01\u0E40\u0E25\u0E34\u0E01");
57
+ injectString("tr", "Cancel", "\u0130ptal");
58
+ injectString("zh-Hans", "Cancel", "\u53D6\u6D88");
59
+ injectString("zh-TW", "Cancel", "\u53D6\u6D88");
60
+ injectString("ro-RO", "Cancel", "Anula\u021Bi");
61
+ export const NavEditFooter = ({
62
+ className,
63
+ handleSaveClick,
64
+ handleCancelClick
65
+ }) => {
66
+ const {
67
+ onEditStateToggle
68
+ } = useNavContext();
69
+ const isMobile = useMobile();
70
+ const {
71
+ translate
72
+ } = useLanguage();
73
+ const onSaveClick = useCallback(() => {
74
+ onEditStateToggle === null || onEditStateToggle === void 0 ? void 0 : onEditStateToggle(false);
75
+ handleSaveClick();
76
+ }, [onEditStateToggle, handleSaveClick]);
77
+ const onCancelClick = useCallback(() => {
78
+ onEditStateToggle === null || onEditStateToggle === void 0 ? void 0 : onEditStateToggle(false);
79
+ handleCancelClick();
80
+ }, [onEditStateToggle, handleCancelClick]);
81
+ const navEditFooterClassNames = classNames(["zen-nav-edit-footer", isMobile ? "zen-nav-edit-footer--mobile" : "", className !== null && className !== void 0 ? className : ""]);
82
+ // needed to change buttons order between mobile and desktop modes
83
+ const saveButtonClassNames = classNames(["zen-nav-edit-footer__button", isMobile ? "zen-nav-edit-footer__button--with-margin" : ""]);
84
+ const saveButton = _jsx(Button, {
85
+ onClick: onSaveClick,
86
+ className: saveButtonClassNames,
87
+ type: "primary",
88
+ children: translate("Save")
89
+ });
90
+ const cancelButton = _jsx(Button, {
91
+ onClick: onCancelClick,
92
+ className: "zen-nav-edit-footer__button",
93
+ type: "secondary",
94
+ children: translate("Cancel")
95
+ });
96
+ return _jsxs("div", {
97
+ className: navEditFooterClassNames,
98
+ children: [isMobile ? saveButton : cancelButton, isMobile ? cancelButton : saveButton]
99
+ });
100
+ };
101
+ NavEditFooter.displayName = "NavEditFooter";
@@ -3,11 +3,6 @@ import { IZenComponentProps } from "../../commonHelpers/zenComponent";
3
3
  import { FC } from "react";
4
4
  export interface INavFooter extends IZenComponentProps {
5
5
  }
6
- export interface INavFooterBottom extends IZenComponentProps {
7
- }
8
- export interface INavFooterEditButton extends IZenComponentProps {
9
- onClick?: () => void;
10
- }
11
6
  /**
12
7
  * @beta This component is not fully ready yet and may change in future releases.
13
8
  */
@@ -16,6 +11,6 @@ export declare const NavFooter: FC<INavFooter> & {
16
11
  ({ children }: import("./navFooterAction/navFooterAction").INavFooterActionProps): import("react/jsx-runtime").JSX.Element | null;
17
12
  displayName: string;
18
13
  };
19
- Bottom: FC<INavFooterBottom>;
20
- EditButton: FC<INavFooterEditButton>;
14
+ Bottom: FC<IZenComponentProps>;
15
+ EditButton: FC<IZenComponentProps>;
21
16
  };
@@ -65,14 +65,14 @@ const NavFooterBottom = ({
65
65
  };
66
66
  NavFooterBottom.displayName = "NavFooterBottom";
67
67
  const NavFooterEditButton = ({
68
- className,
69
- onClick
68
+ className
70
69
  }) => {
71
70
  const {
72
71
  translate
73
72
  } = useLanguage();
74
73
  const {
75
- collapsed
74
+ collapsed,
75
+ onEditStateToggle
76
76
  } = useNavContext();
77
77
  const isMobile = useMobile();
78
78
  return _jsx(NavItem, {
@@ -80,7 +80,7 @@ const NavFooterEditButton = ({
80
80
  title: translate("Edit Navigation"),
81
81
  collapsed: !isMobile,
82
82
  primaryIcon: IconEdit,
83
- onClick: () => onClick && onClick(),
83
+ onClick: () => onEditStateToggle === null || onEditStateToggle === void 0 ? void 0 : onEditStateToggle(true),
84
84
  menuAlignment: "right-bottom",
85
85
  tooltipAlignment: collapsed ? "right" : "top"
86
86
  }, "edit-button");
@@ -0,0 +1,14 @@
1
+ import { FC, MouseEvent, ReactNode } from "react";
2
+ import { IZenComponentProps } from "../../commonHelpers/zenComponent";
3
+ import { IIcon } from "../../icons/icon";
4
+ import "./navItem.less";
5
+ export interface INavActionItem extends IZenComponentProps {
6
+ title: string;
7
+ id?: string;
8
+ icon?: FC<IIcon>;
9
+ startNode?: ReactNode;
10
+ endButtonIcon?: FC<IIcon>;
11
+ endButtonTitle?: string;
12
+ onEndButtonClick?: (e: MouseEvent) => void;
13
+ }
14
+ export declare const NavActionItem: FC<INavActionItem>;
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { classNames } from "../../commonHelpers/classNames/classNames";
3
+ export const NavActionItem = ({ title, id, icon, className, startNode, endButtonIcon, endButtonTitle, onEndButtonClick }) => {
4
+ const PrimaryIconComponent = typeof icon === "function" ? icon : null;
5
+ const EndButtonIconComponent = typeof endButtonIcon === "function" ? endButtonIcon : null;
6
+ const itemClasses = classNames(["zen-nav-item", className || ""]);
7
+ return (_jsxs("div", { className: itemClasses, id: id, children: [_jsx("div", { className: "zen-nav-item__main", children: _jsxs("div", { className: "zen-nav-item__content-left", children: [startNode ? _jsx("span", { className: "zen-nav-item__icon", children: startNode }) : null, PrimaryIconComponent ? _jsx(PrimaryIconComponent, { size: "huge" }) : null, _jsx("span", { className: "zen-nav-item__title", children: _jsx("span", { className: "zen-nav-item__title-text", children: title }) })] }) }), EndButtonIconComponent && endButtonTitle && onEndButtonClick
8
+ ? _jsx("button", { type: "button", className: "zen-nav-item__action", "aria-label": endButtonTitle, title: endButtonTitle, onClick: onEndButtonClick, children: _jsx(EndButtonIconComponent, { size: "huge" }) })
9
+ : null] }));
10
+ };
11
+ NavActionItem.displayName = "NavActionItem";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geotab/zenith",
3
- "version": "3.5.0",
3
+ "version": "3.5.1",
4
4
  "description": "Zenith components library on React",
5
5
  "main": "dist/index.js",
6
6
  "types": "esm/index.d.ts",
@@ -11,6 +11,9 @@
11
11
  "**/react-chartjs/dateAdapter.ts",
12
12
  "**/react-chartjs/dateAdapter.js"
13
13
  ],
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
14
17
  "scripts": {
15
18
  "test": "npm run clean && npm run test-build && node build-utils/translations/inject-translations.js && jest --clearCache && jest",
16
19
  "start": "npm run storybook --loglevel verbose",
@@ -111,8 +114,5 @@
111
114
  "last 1 firefox version",
112
115
  "last 1 safari version"
113
116
  ]
114
- },
115
- "publishConfig": {
116
- "access": "public"
117
117
  }
118
118
  }
@@ -1 +0,0 @@
1
- export declare const findListElement: (element: HTMLElement) => HTMLElement | null;
@@ -1,13 +0,0 @@
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;
@@ -1 +0,0 @@
1
- export declare const findListElement: (element: HTMLElement) => HTMLElement | null;
@@ -1,9 +0,0 @@
1
- export const findListElement = (element) => {
2
- if (element.classList.contains("zen-list-item")) {
3
- return element;
4
- }
5
- if (element.parentElement) {
6
- return findListElement(element.parentElement);
7
- }
8
- return null;
9
- };