@geotab/zenith 3.10.0-beta.7 → 3.11.0-beta.0
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 +33 -0
- package/dist/calendar/calendar.js +7 -4
- package/dist/card/components/title.js +4 -1
- package/dist/card/components/titleLink.js +5 -2
- package/dist/chart/barChart/getDefaultOptions.d.ts +2 -1
- package/dist/chart/barChart/getDefaultOptions.js +5 -2
- package/dist/chart/barChart.js +6 -4
- package/dist/chart/lineChart/getDefaultOptions.d.ts +2 -1
- package/dist/chart/lineChart/getDefaultOptions.js +5 -2
- package/dist/chart/lineChart.js +4 -2
- package/dist/checkboxListWithAction/checkboxListWithAction.js +4 -1
- package/dist/commonHelpers/arrowNavigation/components/arrowButton/arrowButton.js +4 -1
- package/dist/commonStyles/pillStyles/pillContent.less +13 -14
- package/dist/commonStyles/pillStyles/pillStyles.less +4 -5
- package/dist/commonStyles/pillStyles/pillTextContent.less +2 -2
- package/dist/commonStyles/typography/typography.less +579 -19
- package/dist/controlledPopup/controlledPopup.d.ts +1 -0
- package/dist/controlledPopup/controlledPopup.js +3 -1
- package/dist/dataGrid/cell/cell.d.ts +2 -1
- package/dist/dataGrid/cell/cell.js +2 -2
- package/dist/dataGrid/dataGrid.js +7 -4
- package/dist/dataGrid/listColumn.d.ts +2 -0
- package/dist/dataGrid/row/row.d.ts +2 -1
- package/dist/dataGrid/row/row.js +13 -9
- package/dist/dataGrid/withFlexibleColumns/components/columnSettingsList.js +2 -1
- package/dist/dataGrid/withSelectableRows/components/bulkActions/bulkActions.d.ts +4 -0
- package/dist/dateRangeInner/dateRangeInner.js +5 -2
- package/dist/dateRangeRaw/dateRangeRaw.js +5 -2
- package/dist/dateRangeRaw/utils/parseLabel.js +1 -1
- package/dist/dropdownRaw/dropdownRaw.js +12 -6
- package/dist/fileUpload/components/dropZoneContent.js +100 -100
- package/dist/fileUpload/fileUpload.js +100 -100
- package/dist/filters/components/filtersSearchList.js +4 -1
- package/dist/filtersBar/filtersContainer/filtersContainer.js +62 -61
- package/dist/formStepperButtons/formStepperButtons.js +4 -1
- package/dist/groupsFilterRaw/groupsFilterAdjustmentState.js +4 -1
- package/dist/groupsFilterRaw/groupsFilterInitialState.js +4 -1
- package/dist/header/headerBack.js +4 -1
- package/dist/icons/iconAlignLeft.js +1 -3
- package/dist/icons/iconAlignmentLeft.js +1 -3
- package/dist/icons/iconAlignmentRight.js +1 -3
- package/dist/icons/iconArrowBottomLeft.js +1 -3
- package/dist/icons/iconArrowBottomRight.js +1 -3
- package/dist/icons/iconArrowLeftPath.js +1 -3
- package/dist/icons/iconArrowRight.js +1 -3
- package/dist/icons/iconArrowRightCircle.js +1 -3
- package/dist/icons/iconArrowRightPath.js +1 -3
- package/dist/icons/iconArrowTopLeft.js +1 -3
- package/dist/icons/iconArrowTopRight.js +1 -3
- package/dist/icons/iconChevronDoubleRight.js +1 -3
- package/dist/icons/iconChevronRight.js +1 -3
- package/dist/icons/iconChevronRightSmall.js +1 -3
- package/dist/icons/iconCornerDownLeft.js +1 -3
- package/dist/icons/iconCornerDownRight.js +1 -3
- package/dist/icons/iconCornerLeftDown.js +1 -3
- package/dist/icons/iconCornerLeftUp.js +1 -3
- package/dist/icons/iconCornerRightDown.js +1 -3
- package/dist/icons/iconCornerRightUp.js +1 -3
- package/dist/icons/iconCornerUpLeft.js +1 -3
- package/dist/icons/iconCornerUpRight.js +1 -3
- package/dist/index.css +3257 -2925
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/lineChartMini/lineChartMini.js +15 -3
- package/dist/list/itemData/itemDataInternal.js +4 -1
- package/dist/list/list.d.ts +1 -0
- package/dist/list/list.js +2 -2
- package/dist/list/listItem/listItem.d.ts +1 -3
- package/dist/list/listItem/listItem.js +6 -5
- package/dist/menu/components/controlledMenuList/controlledMenuList.d.ts +27 -0
- package/dist/menu/components/controlledMenuList/controlledMenuList.js +126 -0
- package/dist/menu/components/createControlledMenuList.d.ts +37 -0
- package/dist/menu/components/createControlledMenuList.js +55 -0
- package/dist/menu/components/createMenuItem.d.ts +67 -0
- package/dist/menu/components/createMenuItem.js +97 -0
- package/dist/menu/components/menuButton.js +12 -3
- package/dist/menu/components/menuItem.d.ts +1 -2
- package/dist/menu/components/menuItem.js +20 -74
- package/dist/menu/contexts/usePathContext.d.ts +2 -0
- package/dist/menu/contexts/usePathContext.js +9 -0
- package/dist/menu/controlledMenu.js +8 -175
- package/dist/menu/utils/buildMenuContent.d.ts +2 -0
- package/dist/menu/utils/buildMenuContent.js +38 -0
- package/dist/menu/utils/findContent.d.ts +2 -2
- package/dist/menu/utils/findContent.js +4 -3
- package/dist/menu/utils/getItemLabel.d.ts +2 -0
- package/dist/menu/utils/getItemLabel.js +8 -0
- package/dist/menu/utils/getSafeRel.d.ts +1 -0
- package/dist/menu/utils/getSafeRel.js +14 -0
- package/dist/menu/utils/isMenuItem.d.ts +2 -0
- package/dist/menu/utils/isMenuItem.js +13 -0
- package/dist/menu/utils/isSafeHref.d.ts +1 -0
- package/dist/menu/utils/isSafeHref.js +10 -0
- package/dist/menu/utils/normalizeSeparators.d.ts +2 -0
- package/dist/menu/utils/normalizeSeparators.js +23 -0
- package/dist/menu/utils/resolveKeys.d.ts +12 -0
- package/dist/menu/utils/resolveKeys.js +22 -0
- package/dist/menu/utils/useLastValidSheet.d.ts +7 -0
- package/dist/menu/utils/useLastValidSheet.js +30 -0
- package/dist/menu/utils/useMenuItemCore.d.ts +31 -0
- package/dist/menu/utils/useMenuItemCore.js +54 -0
- package/dist/menu/utils/useMenuItemKeyboardNav.d.ts +2 -0
- package/dist/menu/utils/useMenuItemKeyboardNav.js +15 -0
- package/dist/menu/utils/useMenuListKeyboardNav.d.ts +12 -0
- package/dist/menu/utils/useMenuListKeyboardNav.js +77 -0
- package/dist/menu/utils/useMenuPath.d.ts +6 -0
- package/dist/menu/utils/useMenuPath.js +35 -0
- package/dist/nav/navItem/navItem.js +10 -5
- package/dist/nav/navSection/navSection.js +7 -5
- package/dist/pagination/paginationArrow.js +10 -3
- package/dist/radioGroupRaw/radioGroupRaw.js +2 -1
- package/dist/rangeRaw/rangeRaw.js +0 -1
- package/dist/selectList/selectList.helpers.d.ts +1 -1
- package/dist/selectList/selectList.helpers.js +29 -4
- package/dist/selectList/selectList.js +3 -1
- package/dist/selectList/selectList.reducer.js +1 -2
- package/dist/selectList/selectListItem.js +4 -1
- package/dist/sortControl/sortControl.js +59 -4
- package/dist/table/children/useTableChildren.d.ts +1 -1
- package/dist/table/children/useTableChildren.js +3 -3
- package/dist/table/flexible/columnsList.js +4 -2
- package/dist/table/selectable/useSelectableRows.d.ts +8 -0
- package/dist/table/selectable/useSelectableRows.js +14 -6
- package/dist/table/table.js +1 -7
- package/dist/tabs/tabs.js +60 -58
- package/dist/tabs/tabsTestHelper.js +2 -2
- package/dist/timePickerRaw/timePickerRaw.js +1 -1
- package/dist/toggleButtonRaw/toggleButtonRaw.js +5 -2
- package/dist/utils/localization/translations/ar.json +3 -1
- package/dist/utils/localization/translations/cs.json +9 -5
- package/dist/utils/localization/translations/da-DK.json +9 -5
- package/dist/utils/localization/translations/de.json +9 -5
- package/dist/utils/localization/translations/en.json +5 -1
- package/dist/utils/localization/translations/es.json +9 -5
- package/dist/utils/localization/translations/fi-FI.json +9 -5
- package/dist/utils/localization/translations/fr-FR.json +9 -5
- package/dist/utils/localization/translations/fr.json +9 -5
- package/dist/utils/localization/translations/hu-HU.json +9 -5
- package/dist/utils/localization/translations/id.json +9 -5
- package/dist/utils/localization/translations/it.json +9 -5
- package/dist/utils/localization/translations/ja.json +9 -5
- package/dist/utils/localization/translations/ko-KR.json +9 -5
- package/dist/utils/localization/translations/ms.json +9 -5
- package/dist/utils/localization/translations/nb-NO.json +9 -5
- package/dist/utils/localization/translations/nl.json +9 -5
- package/dist/utils/localization/translations/pl.json +9 -5
- package/dist/utils/localization/translations/pt-BR.json +9 -5
- package/dist/utils/localization/translations/pt-PT.json +9 -5
- package/dist/utils/localization/translations/ro-RO.json +9 -5
- package/dist/utils/localization/translations/sk-SK.json +9 -5
- package/dist/utils/localization/translations/sv.json +9 -5
- package/dist/utils/localization/translations/th.json +9 -5
- package/dist/utils/localization/translations/tr.json +9 -5
- package/dist/utils/localization/translations/zh-Hans.json +9 -5
- package/dist/utils/localization/translations/zh-TW.json +9 -5
- package/dist/utils/localization/useDirectionalIcon.d.ts +3 -0
- package/dist/utils/localization/useDirectionalIcon.js +9 -0
- package/dist/utils/positioningUtils/alignments.d.ts +2 -2
- package/dist/utils/positioningUtils/alignments.js +2 -2
- package/dist/utils/positioningUtils/calculatePosition.js +4 -6
- package/esm/calendar/calendar.js +7 -4
- package/esm/card/components/title.js +4 -1
- package/esm/card/components/titleLink.js +5 -2
- package/esm/chart/barChart/getDefaultOptions.d.ts +2 -1
- package/esm/chart/barChart/getDefaultOptions.js +5 -2
- package/esm/chart/barChart.js +6 -4
- package/esm/chart/lineChart/getDefaultOptions.d.ts +2 -1
- package/esm/chart/lineChart/getDefaultOptions.js +5 -2
- package/esm/chart/lineChart.js +4 -2
- package/esm/checkboxListWithAction/checkboxListWithAction.js +4 -1
- package/esm/commonHelpers/arrowNavigation/components/arrowButton/arrowButton.js +4 -1
- package/esm/controlledPopup/controlledPopup.d.ts +1 -0
- package/esm/controlledPopup/controlledPopup.js +3 -1
- package/esm/dataGrid/cell/cell.d.ts +2 -1
- package/esm/dataGrid/cell/cell.js +2 -2
- package/esm/dataGrid/dataGrid.js +7 -4
- package/esm/dataGrid/listColumn.d.ts +2 -0
- package/esm/dataGrid/row/row.d.ts +2 -1
- package/esm/dataGrid/row/row.js +13 -9
- package/esm/dataGrid/withFlexibleColumns/components/columnSettingsList.js +2 -1
- package/esm/dataGrid/withSelectableRows/components/bulkActions/bulkActions.d.ts +4 -0
- package/esm/dateRangeInner/dateRangeInner.js +5 -2
- package/esm/dateRangeRaw/dateRangeRaw.js +5 -2
- package/esm/dateRangeRaw/utils/parseLabel.js +1 -1
- package/esm/dropdownRaw/dropdownRaw.js +12 -6
- package/esm/fileUpload/components/dropZoneContent.js +100 -100
- package/esm/fileUpload/fileUpload.js +100 -100
- package/esm/filters/components/filtersSearchList.js +4 -1
- package/esm/filtersBar/filtersContainer/filtersContainer.js +62 -61
- package/esm/formStepperButtons/formStepperButtons.js +4 -1
- package/esm/groupsFilterRaw/groupsFilterAdjustmentState.js +4 -1
- package/esm/groupsFilterRaw/groupsFilterInitialState.js +4 -1
- package/esm/header/headerBack.js +4 -1
- package/esm/icons/iconAlignLeft.js +1 -3
- package/esm/icons/iconAlignmentLeft.js +1 -3
- package/esm/icons/iconAlignmentRight.js +1 -3
- package/esm/icons/iconArrowBottomLeft.js +1 -3
- package/esm/icons/iconArrowBottomRight.js +1 -3
- package/esm/icons/iconArrowLeftPath.js +1 -3
- package/esm/icons/iconArrowRight.js +1 -3
- package/esm/icons/iconArrowRightCircle.js +1 -3
- package/esm/icons/iconArrowRightPath.js +1 -3
- package/esm/icons/iconArrowTopLeft.js +1 -3
- package/esm/icons/iconArrowTopRight.js +1 -3
- package/esm/icons/iconChevronDoubleRight.js +1 -3
- package/esm/icons/iconChevronRight.js +1 -3
- package/esm/icons/iconChevronRightSmall.js +1 -3
- package/esm/icons/iconCornerDownLeft.js +1 -3
- package/esm/icons/iconCornerDownRight.js +1 -3
- package/esm/icons/iconCornerLeftDown.js +1 -3
- package/esm/icons/iconCornerLeftUp.js +1 -3
- package/esm/icons/iconCornerRightDown.js +1 -3
- package/esm/icons/iconCornerRightUp.js +1 -3
- package/esm/icons/iconCornerUpLeft.js +1 -3
- package/esm/icons/iconCornerUpRight.js +1 -3
- package/esm/index.d.ts +1 -0
- package/esm/index.js +1 -0
- package/esm/lineChartMini/lineChartMini.js +15 -3
- package/esm/list/itemData/itemDataInternal.js +4 -1
- package/esm/list/list.d.ts +1 -0
- package/esm/list/list.js +2 -2
- package/esm/list/listItem/listItem.d.ts +1 -3
- package/esm/list/listItem/listItem.js +6 -5
- package/esm/menu/components/controlledMenuList/controlledMenuList.d.ts +27 -0
- package/esm/menu/components/controlledMenuList/controlledMenuList.js +123 -0
- package/esm/menu/components/createControlledMenuList.d.ts +37 -0
- package/esm/menu/components/createControlledMenuList.js +51 -0
- package/esm/menu/components/createMenuItem.d.ts +67 -0
- package/esm/menu/components/createMenuItem.js +93 -0
- package/esm/menu/components/menuButton.js +12 -3
- package/esm/menu/components/menuItem.d.ts +1 -2
- package/esm/menu/components/menuItem.js +20 -74
- package/esm/menu/contexts/usePathContext.d.ts +2 -0
- package/esm/menu/contexts/usePathContext.js +5 -0
- package/esm/menu/controlledMenu.js +10 -177
- package/esm/menu/utils/buildMenuContent.d.ts +2 -0
- package/esm/menu/utils/buildMenuContent.js +34 -0
- package/esm/menu/utils/findContent.d.ts +2 -2
- package/esm/menu/utils/findContent.js +4 -3
- package/esm/menu/utils/getItemLabel.d.ts +2 -0
- package/esm/menu/utils/getItemLabel.js +4 -0
- package/esm/menu/utils/getSafeRel.d.ts +1 -0
- package/esm/menu/utils/getSafeRel.js +10 -0
- package/esm/menu/utils/isMenuItem.d.ts +2 -0
- package/esm/menu/utils/isMenuItem.js +9 -0
- package/esm/menu/utils/isSafeHref.d.ts +1 -0
- package/esm/menu/utils/isSafeHref.js +6 -0
- package/esm/menu/utils/normalizeSeparators.d.ts +2 -0
- package/esm/menu/utils/normalizeSeparators.js +19 -0
- package/esm/menu/utils/resolveKeys.d.ts +12 -0
- package/esm/menu/utils/resolveKeys.js +18 -0
- package/esm/menu/utils/useLastValidSheet.d.ts +7 -0
- package/esm/menu/utils/useLastValidSheet.js +26 -0
- package/esm/menu/utils/useMenuItemCore.d.ts +31 -0
- package/esm/menu/utils/useMenuItemCore.js +50 -0
- package/esm/menu/utils/useMenuItemKeyboardNav.d.ts +2 -0
- package/esm/menu/utils/useMenuItemKeyboardNav.js +11 -0
- package/esm/menu/utils/useMenuListKeyboardNav.d.ts +12 -0
- package/esm/menu/utils/useMenuListKeyboardNav.js +73 -0
- package/esm/menu/utils/useMenuPath.d.ts +6 -0
- package/esm/menu/utils/useMenuPath.js +31 -0
- package/esm/nav/navItem/navItem.js +10 -5
- package/esm/nav/navSection/navSection.js +7 -5
- package/esm/pagination/paginationArrow.js +10 -3
- package/esm/radioGroupRaw/radioGroupRaw.js +2 -1
- package/esm/rangeRaw/rangeRaw.js +0 -1
- package/esm/selectList/selectList.helpers.d.ts +1 -1
- package/esm/selectList/selectList.helpers.js +29 -4
- package/esm/selectList/selectList.js +3 -1
- package/esm/selectList/selectList.reducer.js +1 -2
- package/esm/selectList/selectListItem.js +4 -1
- package/esm/sortControl/sortControl.js +59 -4
- package/esm/table/children/useTableChildren.d.ts +1 -1
- package/esm/table/children/useTableChildren.js +3 -3
- package/esm/table/flexible/columnsList.js +4 -2
- package/esm/table/selectable/useSelectableRows.d.ts +8 -0
- package/esm/table/selectable/useSelectableRows.js +14 -6
- package/esm/table/table.js +1 -7
- package/esm/tabs/tabs.js +60 -58
- package/esm/tabs/tabsTestHelper.js +2 -2
- package/esm/testHelpers/mockAbsoluteAlignment.d.ts +1 -0
- package/esm/testHelpers/mockAbsoluteAlignment.js +10 -0
- package/esm/timePickerRaw/timePickerRaw.js +1 -1
- package/esm/toggleButtonRaw/toggleButtonRaw.js +5 -2
- package/esm/utils/localization/translations/ar.json +3 -1
- package/esm/utils/localization/translations/cs.json +9 -5
- package/esm/utils/localization/translations/da-DK.json +9 -5
- package/esm/utils/localization/translations/de.json +9 -5
- package/esm/utils/localization/translations/en.json +5 -1
- package/esm/utils/localization/translations/es.json +9 -5
- package/esm/utils/localization/translations/fi-FI.json +9 -5
- package/esm/utils/localization/translations/fr-FR.json +9 -5
- package/esm/utils/localization/translations/fr.json +9 -5
- package/esm/utils/localization/translations/hu-HU.json +9 -5
- package/esm/utils/localization/translations/id.json +9 -5
- package/esm/utils/localization/translations/it.json +9 -5
- package/esm/utils/localization/translations/ja.json +9 -5
- package/esm/utils/localization/translations/ko-KR.json +9 -5
- package/esm/utils/localization/translations/ms.json +9 -5
- package/esm/utils/localization/translations/nb-NO.json +9 -5
- package/esm/utils/localization/translations/nl.json +9 -5
- package/esm/utils/localization/translations/pl.json +9 -5
- package/esm/utils/localization/translations/pt-BR.json +9 -5
- package/esm/utils/localization/translations/pt-PT.json +9 -5
- package/esm/utils/localization/translations/ro-RO.json +9 -5
- package/esm/utils/localization/translations/sk-SK.json +9 -5
- package/esm/utils/localization/translations/sv.json +9 -5
- package/esm/utils/localization/translations/th.json +9 -5
- package/esm/utils/localization/translations/tr.json +9 -5
- package/esm/utils/localization/translations/zh-Hans.json +9 -5
- package/esm/utils/localization/translations/zh-TW.json +9 -5
- package/esm/utils/localization/useDirectionalIcon.d.ts +3 -0
- package/esm/utils/localization/useDirectionalIcon.js +5 -0
- package/esm/utils/positioningUtils/alignments.d.ts +2 -2
- package/esm/utils/positioningUtils/alignments.js +2 -2
- package/esm/utils/positioningUtils/calculatePosition.js +4 -6
- package/package.json +123 -122
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useId, useMemo } from "react";
|
|
3
3
|
import { classNames } from "../commonHelpers/classNames/classNames";
|
|
4
|
-
import { useIsRTL } from "../utils/localization/useIsRTL";
|
|
5
4
|
export const IconCornerUpRight = ({ className, size, title, description, focusable = false }) => {
|
|
6
5
|
const uniqueId = useId();
|
|
7
|
-
const
|
|
8
|
-
const classes = useMemo(() => classNames(["zen-icon", size ? `zen-icon--${size}` : "", isRTL ? "zen-icon--rtl" : "", className !== null && className !== void 0 ? className : ""]), [size, isRTL, className]);
|
|
6
|
+
const classes = useMemo(() => classNames(["zen-icon", size ? `zen-icon--${size}` : "", className !== null && className !== void 0 ? className : ""]), [size, className]);
|
|
9
7
|
return (_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 25", focusable: focusable ? "true" : undefined, tabIndex: focusable ? 0 : undefined, role: focusable || title || description ? undefined : "presentation", className: classes, "aria-labelledby": title && focusable ? uniqueId : undefined, "data-name": "IconCornerUpRight", children: [title ? _jsx("title", { id: uniqueId, children: title }) : null, description ? _jsx("desc", { children: description }) : null, _jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M4 20.87a1 1 0 001-1v-9h12.586l-2.293 2.293a1 1 0 001.414 1.414l4-4a1 1 0 000-1.414l-4-4a1 1 0 10-1.414 1.414l2.293 2.293H4a1 1 0 00-1 1v10a1 1 0 001 1z" })] }));
|
|
10
8
|
};
|
package/esm/index.d.ts
CHANGED
|
@@ -775,6 +775,7 @@ export { getNewFocusableItem, getFirstFocusableItem } from "./utils/keyboardHelp
|
|
|
775
775
|
export { LanguageProvider } from "./utils/localization/languageProvider";
|
|
776
776
|
export { dictionaries, injectString } from "./utils/localization/translationsDictionary";
|
|
777
777
|
export { useDirection } from "./utils/localization/useDirection";
|
|
778
|
+
export { useDirectionalIcon } from "./utils/localization/useDirectionalIcon";
|
|
778
779
|
export { useLanguage } from "./utils/localization/useLanguage";
|
|
779
780
|
export { ThemeDark } from "./utils/theme/themeDark";
|
|
780
781
|
export { ThemeDrive } from "./utils/theme/themeDrive";
|
package/esm/index.js
CHANGED
|
@@ -759,6 +759,7 @@ export { getNewFocusableItem, getFirstFocusableItem } from "./utils/keyboardHelp
|
|
|
759
759
|
export { LanguageProvider } from "./utils/localization/languageProvider";
|
|
760
760
|
export { dictionaries, injectString } from "./utils/localization/translationsDictionary";
|
|
761
761
|
export { useDirection } from "./utils/localization/useDirection";
|
|
762
|
+
export { useDirectionalIcon } from "./utils/localization/useDirectionalIcon";
|
|
762
763
|
export { useLanguage } from "./utils/localization/useLanguage";
|
|
763
764
|
export { ThemeDark } from "./utils/theme/themeDark";
|
|
764
765
|
export { ThemeDrive } from "./utils/theme/themeDrive";
|
|
@@ -18,6 +18,7 @@ import { getDefaultDatasetStyle } from "../lineChart/utils";
|
|
|
18
18
|
import { useDrive } from "../utils/theme/useDrive";
|
|
19
19
|
import { useMobile } from "../commonHelpers/hooks/useMobile";
|
|
20
20
|
import { themeContext } from "../utils/theme/themeContext";
|
|
21
|
+
import { useIsRTL } from "../utils/localization/useIsRTL";
|
|
21
22
|
import { AccessibleChart } from "../chart/accessibleChart/accessibleChart";
|
|
22
23
|
ChartJS.defaults.font = {
|
|
23
24
|
family: "Roboto",
|
|
@@ -30,17 +31,26 @@ const defaultGridStyle = {
|
|
|
30
31
|
const defaultGridBorderStyle = {
|
|
31
32
|
display: false
|
|
32
33
|
};
|
|
33
|
-
const
|
|
34
|
+
const getDefaultOptions = (isRtl) => ({
|
|
34
35
|
responsive: true,
|
|
35
36
|
maintainAspectRatio: false,
|
|
37
|
+
layout: {
|
|
38
|
+
padding: {
|
|
39
|
+
left: isRtl ? 16 : 0,
|
|
40
|
+
right: isRtl ? 0 : 16
|
|
41
|
+
}
|
|
42
|
+
},
|
|
36
43
|
scales: {
|
|
37
44
|
x: {
|
|
38
45
|
grid: defaultGridStyle,
|
|
39
|
-
border: defaultGridBorderStyle
|
|
46
|
+
border: defaultGridBorderStyle,
|
|
47
|
+
reverse: isRtl,
|
|
48
|
+
offset: false
|
|
40
49
|
},
|
|
41
50
|
y: {
|
|
42
51
|
grid: defaultGridStyle,
|
|
43
52
|
border: defaultGridBorderStyle,
|
|
53
|
+
position: isRtl ? "right" : "left",
|
|
44
54
|
ticks: {
|
|
45
55
|
display: false
|
|
46
56
|
}
|
|
@@ -54,7 +64,7 @@ const defaultOptions = {
|
|
|
54
64
|
enabled: false
|
|
55
65
|
}
|
|
56
66
|
}
|
|
57
|
-
};
|
|
67
|
+
});
|
|
58
68
|
export const LineChartMini = (_a) => {
|
|
59
69
|
var _b, _c;
|
|
60
70
|
var { data, options = {} } = _a, rest = __rest(_a, ["data", "options"]);
|
|
@@ -62,6 +72,7 @@ export const LineChartMini = (_a) => {
|
|
|
62
72
|
const isMobile = useMobile();
|
|
63
73
|
const memoizedFontSize = useMemo(() => (isDrive ? (isMobile ? 14 : 16) : 12), [isDrive, isMobile]);
|
|
64
74
|
const { dark } = useContext(themeContext);
|
|
75
|
+
const isRtl = useIsRTL();
|
|
65
76
|
useEffect(() => {
|
|
66
77
|
ChartJS.defaults.font = {
|
|
67
78
|
family: "Roboto",
|
|
@@ -70,6 +81,7 @@ export const LineChartMini = (_a) => {
|
|
|
70
81
|
ChartJS.defaults.color = dark ? "#FFFFFF" : "#1F2833";
|
|
71
82
|
}, [memoizedFontSize, dark]);
|
|
72
83
|
const adaptedData = Object.assign({}, data);
|
|
84
|
+
const defaultOptions = useMemo(() => getDefaultOptions(isRtl), [isRtl]);
|
|
73
85
|
const adaptedOptions = deepMerge(defaultOptions, options);
|
|
74
86
|
if (((_b = adaptedData.labels) === null || _b === void 0 ? void 0 : _b.length) === 2) {
|
|
75
87
|
const maxLabelsCount = Math.max(...data.datasets.map(ds => ds.data.length));
|
|
@@ -6,6 +6,8 @@ import { useLanguage } from "../../utils/localization/useLanguage";
|
|
|
6
6
|
import { Button } from "../../button/button";
|
|
7
7
|
import { classNames } from "../../commonHelpers/classNames/classNames";
|
|
8
8
|
import { IconChevronRight } from "../../icons/iconChevronRight";
|
|
9
|
+
import { IconChevronLeft } from "../../icons/iconChevronLeft";
|
|
10
|
+
import { useDirectionalIcon } from "../../utils/localization/useDirectionalIcon";
|
|
9
11
|
import { IconDotVertical } from "../../icons/iconDotVertical";
|
|
10
12
|
import { Menu } from "../../menu/menu";
|
|
11
13
|
import { isActiveElement } from "../utils/isActiveElement";
|
|
@@ -87,6 +89,7 @@ const ItemDataInternalInner = ({
|
|
|
87
89
|
const {
|
|
88
90
|
translate
|
|
89
91
|
} = useLanguage();
|
|
92
|
+
const ChevronIcon = useDirectionalIcon(IconChevronRight, IconChevronLeft);
|
|
90
93
|
const driveClassName = useMemo(() => isDrive ? isMobile ? "zen-item-data-drive" : "zen-item-data-drive-tablet" : "", [isDrive, isMobile]);
|
|
91
94
|
const mobileClassName = useMobileClassName("zen-item-data");
|
|
92
95
|
const aceClassName = useMemo(() => isTall ? "zen-item-data--tall" : "", [isTall]);
|
|
@@ -194,7 +197,7 @@ const ItemDataInternalInner = ({
|
|
|
194
197
|
onClick: onClick,
|
|
195
198
|
title: translate("Open"),
|
|
196
199
|
"aria-label": translate("Open"),
|
|
197
|
-
children: _jsx(
|
|
200
|
+
children: _jsx(ChevronIcon, {
|
|
198
201
|
size: "large",
|
|
199
202
|
className: "zen-item-data__click-icon"
|
|
200
203
|
})
|
package/esm/list/list.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ type IListBase = {
|
|
|
10
10
|
isLoading?: boolean;
|
|
11
11
|
waitingItems?: number;
|
|
12
12
|
onKeyDown?: (event: React.KeyboardEvent<HTMLUListElement>) => void;
|
|
13
|
+
vertical?: boolean;
|
|
13
14
|
} & IZenComponentProps;
|
|
14
15
|
type IListStandard = IListBase & {
|
|
15
16
|
type?: Omit<TListType, "data">;
|
package/esm/list/list.js
CHANGED
|
@@ -10,7 +10,7 @@ import { useLazyLoading } from "./hooks/useLazyLoading";
|
|
|
10
10
|
import { getLoadingItems } from "./utils/getLoadingItems";
|
|
11
11
|
import { classNames } from "../commonHelpers/classNames/classNames";
|
|
12
12
|
export const List = (props) => {
|
|
13
|
-
const { type, children, onChangeOrder, checked, onCheck, onListEnd, onKeyDown, isLoading, waitingItems, className } = props;
|
|
13
|
+
const { type, children, onChangeOrder, checked, onCheck, onListEnd, onKeyDown, isLoading, waitingItems, vertical, className } = props;
|
|
14
14
|
const isTall = type === "data" && "variant" in props ? props.variant === "tall" : undefined;
|
|
15
15
|
const listId = useId();
|
|
16
16
|
const listRef = useRef(null);
|
|
@@ -53,5 +53,5 @@ export const List = (props) => {
|
|
|
53
53
|
const defaultWaitingItems = type === "data" ? 50 : 10;
|
|
54
54
|
return getLoadingItems(type || "standard", waitingItems || defaultWaitingItems, listId, isDrive, isMobile, isTall);
|
|
55
55
|
}, [isDrive, isTall, isLoading, isMobile, listId, type, waitingItems]);
|
|
56
|
-
return (_jsx(ViewportProvider, { isInViewport: isInViewport, children: _jsxs("ul", { className: classNames(["zen-list", className || ""]), onKeyDown: onKeyDown, ref: listRef, children: [childrenArray, loadingChildren] }) }));
|
|
56
|
+
return (_jsx(ViewportProvider, { isInViewport: isInViewport, children: _jsxs("ul", { className: classNames(["zen-list", vertical ? "zen-list--vertical" : "", className || ""]), onKeyDown: onKeyDown, ref: listRef, children: [childrenArray, loadingChildren] }) }));
|
|
57
57
|
};
|
|
@@ -13,7 +13,5 @@ export interface IListItem extends IZenComponentProps {
|
|
|
13
13
|
link?: string;
|
|
14
14
|
target?: React.HTMLAttributeAnchorTarget;
|
|
15
15
|
onDragStart?: (e: React.PointerEvent<HTMLElement>) => void;
|
|
16
|
-
wrap?: boolean;
|
|
17
|
-
vertical?: boolean;
|
|
18
16
|
}
|
|
19
|
-
export declare const ListItem: ({ id, className, image, name, secondary, status, actions, onClick, link, target, onDragStart
|
|
17
|
+
export declare const ListItem: ({ id, className, image, name, secondary, status, actions, onClick, link, target, onDragStart }: IListItem) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -12,6 +12,8 @@ import { useDriveClassName } from "../../utils/theme/useDriveClassName";
|
|
|
12
12
|
import { classNames } from "../../commonHelpers/classNames/classNames";
|
|
13
13
|
import { useIconSize } from "../../utils/theme/useIconSize";
|
|
14
14
|
import { IconChevronRight } from "../../icons/iconChevronRight";
|
|
15
|
+
import { IconChevronLeft } from "../../icons/iconChevronLeft";
|
|
16
|
+
import { useDirectionalIcon } from "../../utils/localization/useDirectionalIcon";
|
|
15
17
|
import { isActiveElement } from "../utils/isActiveElement";
|
|
16
18
|
import { useMobileClassName } from "../../utils/theme/useMobileClassName";
|
|
17
19
|
injectString("cs", "More", "V\xEDce");
|
|
@@ -79,9 +81,7 @@ export const ListItem = ({
|
|
|
79
81
|
onClick,
|
|
80
82
|
link,
|
|
81
83
|
target,
|
|
82
|
-
onDragStart
|
|
83
|
-
wrap,
|
|
84
|
-
vertical
|
|
84
|
+
onDragStart
|
|
85
85
|
}) => {
|
|
86
86
|
const isMobile = useMobile();
|
|
87
87
|
const driveClassName = useDriveClassName("zen-list-item");
|
|
@@ -91,6 +91,7 @@ export const ListItem = ({
|
|
|
91
91
|
translate
|
|
92
92
|
} = useLanguage();
|
|
93
93
|
const itemRef = useRef(null);
|
|
94
|
+
const ChevronIcon = useDirectionalIcon(IconChevronRight, IconChevronLeft);
|
|
94
95
|
const renderActions = useCallback(() => {
|
|
95
96
|
if (!actions || actions.length === 0) {
|
|
96
97
|
return null;
|
|
@@ -171,7 +172,7 @@ export const ListItem = ({
|
|
|
171
172
|
const clickableClassName = useMemo(() => onClick || link ? "zen-list-item--clickable" : "", [link, onClick]);
|
|
172
173
|
return _jsxs("li", {
|
|
173
174
|
id: id,
|
|
174
|
-
className: classNames(["zen-list-item", mobileClassName || driveClassName || "", clickableClassName,
|
|
175
|
+
className: classNames(["zen-list-item", mobileClassName || driveClassName || "", clickableClassName, className || ""]),
|
|
175
176
|
onClick: handleClick,
|
|
176
177
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
177
178
|
ref: itemRef,
|
|
@@ -203,7 +204,7 @@ export const ListItem = ({
|
|
|
203
204
|
link: link,
|
|
204
205
|
target: target,
|
|
205
206
|
title: translate("View details"),
|
|
206
|
-
children: _jsx(
|
|
207
|
+
children: _jsx(ChevronIcon, {
|
|
207
208
|
size: isMobile ? "huge" : "large",
|
|
208
209
|
className: "zen-list-item__click-icon"
|
|
209
210
|
})
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { FC, ForwardRefExoticComponent, RefAttributes, ReactNode } from "react";
|
|
2
|
+
import { IMenuControlledItem } from "../menuItem";
|
|
3
|
+
import { IZenComponentProps } from "../../../commonHelpers/zenComponent";
|
|
4
|
+
import { IMenuSeparator } from "../menuSeparator";
|
|
5
|
+
import { TAlignment } from "../../../absolute/absolute";
|
|
6
|
+
export type TMenuListDirection = "vertical" | "horizontal";
|
|
7
|
+
export interface IControlledMenuList extends IZenComponentProps {
|
|
8
|
+
listClassName?: string;
|
|
9
|
+
ariaLabel?: string;
|
|
10
|
+
/** Default tooltip alignment injected into MenuItem children that don't specify their own. */
|
|
11
|
+
defaultTooltipAlignment?: TAlignment;
|
|
12
|
+
/** Default submenu alignment injected into MenuItem children that don't specify their own. */
|
|
13
|
+
defaultAlignment?: TAlignment;
|
|
14
|
+
/** Layout direction of the menu list. Defaults to "vertical". */
|
|
15
|
+
direction?: TMenuListDirection;
|
|
16
|
+
}
|
|
17
|
+
/** Internal props injected by ControlledMenu — not part of the public API. */
|
|
18
|
+
export interface IControlledMenuListInternal extends IControlledMenuList {
|
|
19
|
+
isOpen?: boolean;
|
|
20
|
+
setIsOpen?: (v: boolean) => void;
|
|
21
|
+
}
|
|
22
|
+
export declare const ControlledMenuList: ForwardRefExoticComponent<IControlledMenuList & {
|
|
23
|
+
children?: ReactNode;
|
|
24
|
+
} & RefAttributes<HTMLDivElement>> & {
|
|
25
|
+
Item: FC<IMenuControlledItem>;
|
|
26
|
+
Separator: FC<IMenuSeparator>;
|
|
27
|
+
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
3
|
+
import { Children, cloneElement, isValidElement, useState, useMemo, useCallback, useRef, forwardRef, Fragment } from "react";
|
|
4
|
+
import { MenuItem, isMenuItem } from "../menuItem";
|
|
5
|
+
import { classNames } from "../../../commonHelpers/classNames/classNames";
|
|
6
|
+
import { findContent } from "../../utils/findContent";
|
|
7
|
+
import { getItemLabel } from "../../utils/getItemLabel";
|
|
8
|
+
import { normalizeSeparators } from "../../utils/normalizeSeparators";
|
|
9
|
+
import { useMenuPath } from "../../utils/useMenuPath";
|
|
10
|
+
import { useLastValidSheet } from "../../utils/useLastValidSheet";
|
|
11
|
+
import { useMenuListKeyboardNav } from "../../utils/useMenuListKeyboardNav";
|
|
12
|
+
import { MenuButton } from "../menuButton";
|
|
13
|
+
import { IconArrowLeft } from "../../../icons/iconArrowLeft";
|
|
14
|
+
import { DeviceType } from "../../../commonHelpers/hooks/deviceType";
|
|
15
|
+
import { useDeviceType } from "../../../commonHelpers/hooks/useDeviceType";
|
|
16
|
+
import { generateId } from "../../../commonHelpers/generateId";
|
|
17
|
+
import { PathProvider } from "../../contexts/pathProvider";
|
|
18
|
+
import { MobileSheet } from "../../../mobileSheet/mobileSheet";
|
|
19
|
+
import { isSeparator, MenuSeparator } from "../menuSeparator";
|
|
20
|
+
import { IconArrowRight } from "../../../icons/iconArrowRight";
|
|
21
|
+
import { useDirectionalIcon } from "../../../utils/localization/useDirectionalIcon";
|
|
22
|
+
const ControlledMenuListBase = forwardRef(({ children, setIsOpen, isOpen, className = "", listClassName = "", ariaLabel, defaultTooltipAlignment, defaultAlignment, direction = "vertical" }, ref) => {
|
|
23
|
+
const [deviceType, setDeviceType] = useState(DeviceType.Desktop);
|
|
24
|
+
const isMobile = deviceType === DeviceType.Mobile;
|
|
25
|
+
const BackArrowIcon = useDirectionalIcon(IconArrowLeft, IconArrowRight);
|
|
26
|
+
useDeviceType(setDeviceType);
|
|
27
|
+
// True when mounted inside ControlledMenu, which injects setIsOpen and isOpen.
|
|
28
|
+
// Standalone usage leaves both undefined.
|
|
29
|
+
const isEmbedded = setIsOpen !== undefined;
|
|
30
|
+
const { path, onOpenBranch, closeBranch, closeAll } = useMenuPath(isOpen);
|
|
31
|
+
const navigatedViaKeyboardRef = useRef(false);
|
|
32
|
+
const keyboardActiveRef = useRef(false);
|
|
33
|
+
const internalRef = useRef(null);
|
|
34
|
+
const divRefCallback = useCallback((node) => {
|
|
35
|
+
internalRef.current = node;
|
|
36
|
+
if (typeof ref === "function") {
|
|
37
|
+
ref(node);
|
|
38
|
+
}
|
|
39
|
+
else if (ref) {
|
|
40
|
+
ref.current = node;
|
|
41
|
+
}
|
|
42
|
+
}, [ref]);
|
|
43
|
+
const effectiveSetIsOpen = useCallback((v) => {
|
|
44
|
+
setIsOpen === null || setIsOpen === void 0 ? void 0 : setIsOpen(v);
|
|
45
|
+
if (!v && !isEmbedded) {
|
|
46
|
+
closeAll();
|
|
47
|
+
}
|
|
48
|
+
}, [setIsOpen, closeAll, isEmbedded]);
|
|
49
|
+
const buildListItems = useCallback((childrenToProcess) => {
|
|
50
|
+
var _a;
|
|
51
|
+
const cont = [];
|
|
52
|
+
// If children is a Fragment, extract its children
|
|
53
|
+
let actualChildren = childrenToProcess;
|
|
54
|
+
if (isValidElement(childrenToProcess) && childrenToProcess.type === Fragment) {
|
|
55
|
+
actualChildren = (_a = childrenToProcess.props.children) !== null && _a !== void 0 ? _a : [];
|
|
56
|
+
}
|
|
57
|
+
Children.map(actualChildren, (child) => {
|
|
58
|
+
var _a, _b;
|
|
59
|
+
if (!child)
|
|
60
|
+
return;
|
|
61
|
+
if (typeof child === "string") {
|
|
62
|
+
cont.push(_jsx("li", { role: "presentation", className: classNames(["zen-menu-item__content"]), children: child }, generateId()));
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (isValidElement(child) && isSeparator(child)) {
|
|
66
|
+
cont.push(cloneElement(child, { key: (_a = child.key) !== null && _a !== void 0 ? _a : generateId() }));
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (isValidElement(child) && isMenuItem(child)) {
|
|
70
|
+
const childProps = child.props;
|
|
71
|
+
cont.push(cloneElement(child, {
|
|
72
|
+
isMobile,
|
|
73
|
+
key: (_b = childProps.id) !== null && _b !== void 0 ? _b : generateId(),
|
|
74
|
+
setIsOpen: effectiveSetIsOpen,
|
|
75
|
+
onClick: childProps.onClick,
|
|
76
|
+
tooltipAlignment: childProps.tooltipAlignment || defaultTooltipAlignment || undefined,
|
|
77
|
+
alignment: childProps.alignment || defaultAlignment || undefined
|
|
78
|
+
}));
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const childProps = child.props;
|
|
82
|
+
cont.push(_jsx("li", { className: classNames(["zen-menu-item__content"]), role: "presentation", children: child }, childProps.id || childProps["data-id"] || generateId()));
|
|
83
|
+
});
|
|
84
|
+
return normalizeSeparators(cont);
|
|
85
|
+
}, [isMobile, effectiveSetIsOpen, defaultTooltipAlignment, defaultAlignment]);
|
|
86
|
+
// Embedded (ControlledMenu): switch content based on path so the outer MobileSheet
|
|
87
|
+
// shows nested items with the back button as a list row.
|
|
88
|
+
// Standalone: always show top-level content; nested navigation uses its own MobileSheet.
|
|
89
|
+
const [content, parent] = useMemo(() => {
|
|
90
|
+
if (isEmbedded && isMobile && path.length > 0) {
|
|
91
|
+
const el = findContent(children, isMenuItem, path[path.length - 1]);
|
|
92
|
+
if (el && isValidElement(el)) {
|
|
93
|
+
return [buildListItems(el.props.children), el];
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return [buildListItems(children), null];
|
|
97
|
+
}, [children, isMobile, path, isEmbedded, buildListItems]);
|
|
98
|
+
// Standalone mobile only: compute nested content for the inline MobileSheet.
|
|
99
|
+
const [nestedContent, nestedParent] = useMemo(() => {
|
|
100
|
+
if (isEmbedded || !isMobile || path.length === 0) {
|
|
101
|
+
return [null, null];
|
|
102
|
+
}
|
|
103
|
+
const el = findContent(children, isMenuItem, path[path.length - 1]);
|
|
104
|
+
if (!el || !isValidElement(el)) {
|
|
105
|
+
return [null, null];
|
|
106
|
+
}
|
|
107
|
+
return [buildListItems(el.props.children), el];
|
|
108
|
+
}, [children, isMobile, path, isEmbedded, buildListItems]);
|
|
109
|
+
const isHorizontal = direction === "horizontal";
|
|
110
|
+
const { onKeyDown, onKeyDownVertical, onMouseDown } = useMenuListKeyboardNav(keyboardActiveRef, navigatedViaKeyboardRef, isHorizontal);
|
|
111
|
+
const renderList = (listContent, backParent, listRef, applyDirection = true, keyDownHandler = onKeyDown) => (_jsx("div", { ref: listRef, tabIndex: -1, onKeyDown: keyDownHandler, onMouseDown: onMouseDown, className: classNames(["zen-action-list", className]), children: _jsxs("ul", { role: "menu", "aria-label": ariaLabel, className: classNames([
|
|
112
|
+
"zen-menu-item",
|
|
113
|
+
className,
|
|
114
|
+
listClassName,
|
|
115
|
+
applyDirection && direction === "horizontal" ? "zen-menu-item--horizontal" : ""
|
|
116
|
+
]), children: [backParent ? (_jsx(MenuButton, { id: "root", name: getItemLabel(backParent), icon: BackArrowIcon, onClick: closeBranch, hasChildren: false, disabled: false }, "root")) : null, listContent] }) }));
|
|
117
|
+
const { sheetContent, sheetParent, sheetPathLength, sheetParentName } = useLastValidSheet(nestedContent, nestedParent, path, children);
|
|
118
|
+
return (_jsxs(PathProvider, { path: path, onOpenBranch: onOpenBranch, closeBranch: closeBranch, navigatedViaKeyboardRef: navigatedViaKeyboardRef, keyboardActiveRef: keyboardActiveRef, children: [renderList(content, parent, divRefCallback), !isEmbedded && isMobile && (_jsxs(MobileSheet, { label: sheetParentName, isOpen: path.length > 0, triggerRef: internalRef, onHidePanel: closeAll, onCloseClick: closeAll, children: [_jsx(MobileSheet.Title, { children: sheetParentName }), _jsx(MobileSheet.Content, { children: renderList(sheetContent, sheetPathLength > 1 ? sheetParent : null, undefined, false, onKeyDownVertical) })] }))] }));
|
|
119
|
+
});
|
|
120
|
+
ControlledMenuListBase.displayName = "ControlledMenuList";
|
|
121
|
+
export const ControlledMenuList = ControlledMenuListBase;
|
|
122
|
+
ControlledMenuList.Item = MenuItem;
|
|
123
|
+
ControlledMenuList.Separator = MenuSeparator;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { FC, ReactNode } from "react";
|
|
2
|
+
import { IControlledMenuListInternal } from "./controlledMenuList/controlledMenuList";
|
|
3
|
+
import { IMenuControlledItem } from "./menuItem";
|
|
4
|
+
import { IMenuSeparator } from "./menuSeparator";
|
|
5
|
+
export interface ICreateControlledMenuListRenderProps {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
type CreatedListComponent<T> = FC<T & IControlledMenuListInternal & {
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
}> & {
|
|
11
|
+
Item: FC<IMenuControlledItem>;
|
|
12
|
+
Separator: FC<IMenuSeparator>;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Factory that creates a typed ControlledMenuList component with custom props.
|
|
16
|
+
*
|
|
17
|
+
* The `renderContent` function receives all consumer props plus `children` (the built ControlledMenuList element),
|
|
18
|
+
* allowing the consumer to wrap the list with custom markup.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* interface INavSection { sectionTitle: string }
|
|
22
|
+
*
|
|
23
|
+
* const NavSection = createControlledMenuList<INavSection>(({ sectionTitle, children }) => (
|
|
24
|
+
* <div>
|
|
25
|
+
* <div className="section-header">{sectionTitle}</div>
|
|
26
|
+
* {children}
|
|
27
|
+
* </div>
|
|
28
|
+
* ));
|
|
29
|
+
*
|
|
30
|
+
* // Usage — accepts INavSection + IControlledMenuList props:
|
|
31
|
+
* <NavSection sectionTitle="Reports" setIsOpen={setIsOpen} isOpen={isOpen}>
|
|
32
|
+
* <NavSection.Item id="daily" name="Daily Reports" />
|
|
33
|
+
* <NavSection.Item id="weekly" name="Weekly Reports" />
|
|
34
|
+
* </NavSection>
|
|
35
|
+
*/
|
|
36
|
+
export declare function createControlledMenuList<T extends object>(renderContent: (props: T & ICreateControlledMenuListRenderProps) => ReactNode): CreatedListComponent<T>;
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { ControlledMenuList } from "./controlledMenuList/controlledMenuList";
|
|
14
|
+
import { MenuItem } from "./menuItem";
|
|
15
|
+
import { MenuSeparator } from "./menuSeparator";
|
|
16
|
+
/**
|
|
17
|
+
* Factory that creates a typed ControlledMenuList component with custom props.
|
|
18
|
+
*
|
|
19
|
+
* The `renderContent` function receives all consumer props plus `children` (the built ControlledMenuList element),
|
|
20
|
+
* allowing the consumer to wrap the list with custom markup.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* interface INavSection { sectionTitle: string }
|
|
24
|
+
*
|
|
25
|
+
* const NavSection = createControlledMenuList<INavSection>(({ sectionTitle, children }) => (
|
|
26
|
+
* <div>
|
|
27
|
+
* <div className="section-header">{sectionTitle}</div>
|
|
28
|
+
* {children}
|
|
29
|
+
* </div>
|
|
30
|
+
* ));
|
|
31
|
+
*
|
|
32
|
+
* // Usage — accepts INavSection + IControlledMenuList props:
|
|
33
|
+
* <NavSection sectionTitle="Reports" setIsOpen={setIsOpen} isOpen={isOpen}>
|
|
34
|
+
* <NavSection.Item id="daily" name="Daily Reports" />
|
|
35
|
+
* <NavSection.Item id="weekly" name="Weekly Reports" />
|
|
36
|
+
* </NavSection>
|
|
37
|
+
*/
|
|
38
|
+
export function createControlledMenuList(renderContent) {
|
|
39
|
+
const CreatedList = allProps => {
|
|
40
|
+
const { setIsOpen, listClassName, isOpen, defaultTooltipAlignment, defaultAlignment, direction, className, children } = allProps, rest = __rest(allProps, ["setIsOpen", "listClassName", "isOpen", "defaultTooltipAlignment", "defaultAlignment", "direction", "className", "children"]);
|
|
41
|
+
// Cast required to pass internal props (isOpen, setIsOpen) not in the public interface.
|
|
42
|
+
const InternalList = ControlledMenuList;
|
|
43
|
+
const list = (_jsx(InternalList, { setIsOpen: setIsOpen, listClassName: listClassName, isOpen: isOpen, defaultTooltipAlignment: defaultTooltipAlignment, defaultAlignment: defaultAlignment, direction: direction, className: className, children: children }));
|
|
44
|
+
return renderContent(Object.assign(Object.assign({}, rest), { children: list }));
|
|
45
|
+
};
|
|
46
|
+
CreatedList.displayName = "ControlledMenuList";
|
|
47
|
+
const result = CreatedList;
|
|
48
|
+
result.Item = MenuItem;
|
|
49
|
+
result.Separator = MenuSeparator;
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { ReactNode, ForwardRefExoticComponent, RefAttributes, ForwardedRef } from "react";
|
|
2
|
+
import { TAlignment } from "../../absolute/absolute";
|
|
3
|
+
import { IMenuItem } from "./menuItem";
|
|
4
|
+
import "./menuButton.less";
|
|
5
|
+
export interface ICreateMenuItemRenderProps {
|
|
6
|
+
hasChildren: boolean;
|
|
7
|
+
isOpen: boolean;
|
|
8
|
+
isMobile: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface ICreateMenuItemWrapperProps {
|
|
11
|
+
role: "presentation";
|
|
12
|
+
className: string;
|
|
13
|
+
tabIndex?: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Factory that creates a typed Menu item component with full MenuItem functionality
|
|
17
|
+
* (nested submenus, keyboard navigation, mobile sheet support), but with a
|
|
18
|
+
* consumer-defined typed interface instead of the fixed MenuItem props.
|
|
19
|
+
*
|
|
20
|
+
* The `renderTrigger` function receives all consumer props plus `hasChildren` and
|
|
21
|
+
* `isOpen` so the trigger content can reflect submenu state.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* interface INavItem { label: string; count?: number }
|
|
25
|
+
*
|
|
26
|
+
* const NavMenuItem = createMenuItem<INavItem>(({ label, count, hasChildren, isOpen }) => (
|
|
27
|
+
* <>
|
|
28
|
+
* <span>{label}</span>
|
|
29
|
+
* {count !== undefined && <Badge>{count}</Badge>}
|
|
30
|
+
* {hasChildren && <ChevronRight rotated={isOpen} />}
|
|
31
|
+
* </>
|
|
32
|
+
* ));
|
|
33
|
+
*
|
|
34
|
+
* // Usage — supports nesting exactly like Menu.Item:
|
|
35
|
+
* <Menu title="Nav">
|
|
36
|
+
* <NavMenuItem id="reports" label="Reports" count={3}>
|
|
37
|
+
* <Menu.Item id="charts" name="Charts" />
|
|
38
|
+
* <Menu.Item id="tables" name="Tables" />
|
|
39
|
+
* </NavMenuItem>
|
|
40
|
+
* </Menu>
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* // renderWrapper: replace the default <li> with a custom host element
|
|
44
|
+
* <NavMenuItem
|
|
45
|
+
* id="settings"
|
|
46
|
+
* label="Settings"
|
|
47
|
+
* renderWrapper={(children, ref, defaultProps) => (
|
|
48
|
+
* <li ref={ref} {...defaultProps} data-testid="nav-settings">
|
|
49
|
+
* {children}
|
|
50
|
+
* </li>
|
|
51
|
+
* )}
|
|
52
|
+
* />
|
|
53
|
+
*/
|
|
54
|
+
type PublicMenuItemProps<T> = T & Pick<IMenuItem, "id" | "children" | "className" | "alignment" | "disabled" | "onClick" | "link" | "target" | "rel"> & {
|
|
55
|
+
ariaLabel?: string;
|
|
56
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
57
|
+
renderWrapper?: (children: ReactNode, ref: ForwardedRef<HTMLLIElement>, defaultProps: ICreateMenuItemWrapperProps) => ReactNode;
|
|
58
|
+
tabIndex?: number;
|
|
59
|
+
tooltip?: ReactNode;
|
|
60
|
+
tooltipAlignment?: TAlignment;
|
|
61
|
+
};
|
|
62
|
+
export interface ICreateMenuItemOptions<T> {
|
|
63
|
+
/** Hook-compatible function called during render to derive a default tooltip from item props. Can call useContext. */
|
|
64
|
+
renderTooltip?: (props: T) => ReactNode | undefined;
|
|
65
|
+
}
|
|
66
|
+
export declare function createMenuItem<T extends object>(renderTrigger: (props: T & ICreateMenuItemRenderProps) => ReactNode, options?: ICreateMenuItemOptions<T>): ForwardRefExoticComponent<PublicMenuItemProps<T> & RefAttributes<HTMLLIElement>>;
|
|
67
|
+
export {};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { Fragment, forwardRef, useMemo } from "react";
|
|
14
|
+
import { ControlledPopup } from "../../controlledPopup/controlledPopup";
|
|
15
|
+
import { classNames } from "../../commonHelpers/classNames/classNames";
|
|
16
|
+
import { useMenuItemCore } from "../utils/useMenuItemCore";
|
|
17
|
+
import { Tooltip } from "../../tooltip/tooltip";
|
|
18
|
+
import { isSafeHref } from "../utils/isSafeHref";
|
|
19
|
+
import { getSafeRel } from "../utils/getSafeRel";
|
|
20
|
+
import { useDriveClassName } from "../../utils/theme/useDriveClassName";
|
|
21
|
+
export function createMenuItem(renderTrigger, options) {
|
|
22
|
+
var _a;
|
|
23
|
+
// Defined at factory level so it is always the same function reference —
|
|
24
|
+
// safe to call unconditionally inside the component (rules of hooks).
|
|
25
|
+
const resolveDefaultTooltip = (_a = options === null || options === void 0 ? void 0 : options.renderTooltip) !== null && _a !== void 0 ? _a : (() => undefined);
|
|
26
|
+
const CreatedItem = forwardRef((allProps, containerRef) => {
|
|
27
|
+
const { id, children, className, alignment, disabled, isMobile = false, setIsOpen, ariaLabel, onClick, onOpenChange, link, target, rel, renderWrapper, tabIndex, tooltip, tooltipAlignment } = allProps, rest = __rest(allProps, ["id", "children", "className", "alignment", "disabled", "isMobile", "setIsOpen", "ariaLabel", "onClick", "onOpenChange", "link", "target", "rel", "renderWrapper", "tabIndex", "tooltip", "tooltipAlignment"]);
|
|
28
|
+
const linkEvents = useMemo(() => ({
|
|
29
|
+
onKeyDown: (e) => {
|
|
30
|
+
if (e.key === " ") {
|
|
31
|
+
e.preventDefault();
|
|
32
|
+
const linkEl = e.currentTarget;
|
|
33
|
+
linkEl.dataset.spaceDown = "1";
|
|
34
|
+
linkEl.classList.add("zen-menu-button__action--active");
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
onKeyUp: (e) => {
|
|
38
|
+
if (e.key === " ") {
|
|
39
|
+
e.preventDefault();
|
|
40
|
+
const linkEl = e.currentTarget;
|
|
41
|
+
linkEl.classList.remove("zen-menu-button__action--active");
|
|
42
|
+
if (linkEl.dataset.spaceDown) {
|
|
43
|
+
delete linkEl.dataset.spaceDown;
|
|
44
|
+
linkEl.click();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}), []);
|
|
49
|
+
const { ref, isOpen, hasChildren, content, openedViaKeyboard, contentAlignment, path, handleDesktopActionClick, handleTriggerClick, handleOpenChange } = useMenuItemCore({ id, children, className, alignment, isMobile, setIsOpen, onClick, onOpenChange });
|
|
50
|
+
const driveClass = useDriveClassName("zen-menu-button__action");
|
|
51
|
+
const liDefaultProps = Object.assign({ role: "presentation", className: classNames(["zen-menu-button", className !== null && className !== void 0 ? className : ""]) }, (tabIndex !== undefined && { tabIndex }));
|
|
52
|
+
// Resolved at component top level so renderTooltip can safely call hooks (e.g. useContext).
|
|
53
|
+
const defaultTooltip = resolveDefaultTooltip(Object.assign(Object.assign({}, rest), { isMobile }));
|
|
54
|
+
const effectiveTooltip = tooltip !== null && tooltip !== void 0 ? tooltip : defaultTooltip;
|
|
55
|
+
const effectiveTooltipAlignment = tooltipAlignment;
|
|
56
|
+
const wrapButton = (button) => {
|
|
57
|
+
// On mobile, tooltip wraps the <li> instead of the button so Tooltip doesn't
|
|
58
|
+
// intercept the button's onClick and shows on tap instead.
|
|
59
|
+
// Items with children are excluded — wrapping <li> would fire both the tooltip and
|
|
60
|
+
// the submenu drill-in on the same tap.
|
|
61
|
+
const isMobileTooltip = isMobile && !!effectiveTooltip && !hasChildren;
|
|
62
|
+
const wrappedButton = effectiveTooltip && !isMobileTooltip ? (_jsx(Tooltip, { trigger: button, alignment: effectiveTooltipAlignment, children: effectiveTooltip })) : (button);
|
|
63
|
+
const liElement = renderWrapper ? (renderWrapper(wrappedButton, containerRef, liDefaultProps)) : (_jsx("li", Object.assign({ ref: containerRef }, liDefaultProps, { tabIndex: tabIndex, children: wrappedButton })));
|
|
64
|
+
// Wrap li with Tooltip on mobile
|
|
65
|
+
return isMobileTooltip ? (_jsx(Tooltip, { trigger: liElement, alignment: effectiveTooltipAlignment, children: effectiveTooltip })) : (liElement);
|
|
66
|
+
};
|
|
67
|
+
// Leaf node — no submenu
|
|
68
|
+
if (!hasChildren) {
|
|
69
|
+
const triggerContent = renderTrigger(Object.assign(Object.assign({}, rest), { hasChildren: false, isOpen: false, isMobile }));
|
|
70
|
+
return wrapButton(link ? (_jsx("a", Object.assign({ role: "menuitem", "aria-label": ariaLabel, "aria-disabled": disabled, href: disabled || !isSafeHref(link) ? undefined : link, target: target, rel: getSafeRel(rel, target), className: classNames(["zen-menu-button__action", "zen-caption", driveClass !== null && driveClass !== void 0 ? driveClass : ""]), onClick: handleDesktopActionClick }, linkEvents, { children: triggerContent }))) : (_jsx("button", { ref: ref, type: "button", role: "menuitem", "aria-label": ariaLabel, disabled: !!disabled, className: classNames(["zen-menu-button__action", "zen-button", "zen-caption", driveClass !== null && driveClass !== void 0 ? driveClass : ""]), onClick: handleDesktopActionClick, children: triggerContent })));
|
|
71
|
+
}
|
|
72
|
+
// Mobile — button drills into sub-level via PathContext
|
|
73
|
+
if (isMobile) {
|
|
74
|
+
return wrapButton(_jsx("button", { ref: ref, type: "button", role: "menuitem", "aria-label": ariaLabel, disabled: !!disabled, className: classNames([
|
|
75
|
+
"zen-menu-button__action",
|
|
76
|
+
"zen-button",
|
|
77
|
+
"zen-caption",
|
|
78
|
+
"zen-menu-button__action--has-children",
|
|
79
|
+
driveClass !== null && driveClass !== void 0 ? driveClass : ""
|
|
80
|
+
]), onClick: handleTriggerClick, children: renderTrigger(Object.assign(Object.assign({}, rest), { hasChildren: true, isOpen, isMobile })) }));
|
|
81
|
+
}
|
|
82
|
+
// Desktop with submenu
|
|
83
|
+
return (_jsxs(Fragment, { children: [wrapButton(_jsx("button", { ref: ref, type: "button", role: "menuitem", "aria-label": ariaLabel, disabled: !!disabled, "aria-haspopup": "menu", "aria-expanded": isOpen, className: classNames([
|
|
84
|
+
"zen-menu-button__action",
|
|
85
|
+
"zen-button",
|
|
86
|
+
"zen-caption",
|
|
87
|
+
"zen-menu-button__action--has-children",
|
|
88
|
+
driveClass !== null && driveClass !== void 0 ? driveClass : ""
|
|
89
|
+
]), onClick: handleTriggerClick, children: renderTrigger(Object.assign(Object.assign({}, rest), { hasChildren: true, isOpen, isMobile: false })) })), _jsx(ControlledPopup, { className: classNames([`zen-controlled-menu-submenu--${path.length}`]), useTrapFocusWithTrigger: openedViaKeyboard ? "on" : "withTrigger", alignment: contentAlignment, triggerRef: ref, isOpen: isOpen, onOpenChange: handleOpenChange, ariaLabel: ariaLabel, recalculateOnScroll: true, children: _jsx("ul", { role: "menu", className: "zen-menu-item", children: content }) })] }));
|
|
90
|
+
});
|
|
91
|
+
CreatedItem.displayName = "MenuItem";
|
|
92
|
+
return CreatedItem;
|
|
93
|
+
}
|