@geotab/zenith 3.16.0 → 3.17.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -1
- package/README.md.baseline +1 -0
- package/dist/absolute/absolute.js +5 -1
- package/dist/button/button.d.ts +2 -1
- package/dist/button/button.js +22 -5
- package/dist/checkboxListWithAction/checkboxListWithAction.d.ts +2 -0
- package/dist/checkboxListWithAction/checkboxListWithAction.js +1 -1
- package/dist/commonHelpers/ShowMoreCell.d.ts +5 -0
- package/dist/commonHelpers/ShowMoreCell.js +66 -0
- package/dist/commonHelpers/getAriaAttributes.js +6 -9
- package/dist/commonHelpers/getNonAriaProps.d.ts +11 -0
- package/dist/commonHelpers/getNonAriaProps.js +19 -0
- package/dist/commonHelpers/hooks/useScroll.d.ts +1 -1
- package/dist/commonHelpers/hooks/useScroll.js +6 -6
- package/dist/commonHelpers/isAriaProp.d.ts +9 -0
- package/dist/commonHelpers/isAriaProp.js +13 -0
- package/dist/commonHelpers/showMoreRow.d.ts +28 -0
- package/dist/commonHelpers/showMoreRow.js +29 -0
- package/dist/commonHelpers/tabsKeyboard.d.ts +1 -1
- package/dist/commonHelpers/tabsKeyboard.js +15 -1
- package/dist/commonStyles/colors/colors.less +18 -0
- package/dist/dataFeed/dataFeedColumnsItems.js +3 -1
- package/dist/dataGrid/columns/checkboxColumn/checkboxCell.d.ts +2 -1
- package/dist/dataGrid/columns/checkboxColumn/checkboxCell.js +1 -1
- package/dist/dataGrid/columns/checkboxColumn/checkboxColumnWrapper.d.ts +4 -2
- package/dist/dataGrid/columns/checkboxColumn/checkboxColumnWrapper.js +10 -1
- package/dist/dataGrid/dataGrid.d.ts +5 -1
- package/dist/dataGrid/dataGrid.js +39 -2
- package/dist/dataGrid/lazyLoadingEnd/lazyLoadingEnd.d.ts +3 -0
- package/dist/dataGrid/lazyLoadingEnd/lazyLoadingEnd.js +54 -0
- package/dist/dataGrid/row/row.js +20 -2
- package/dist/dataGrid/withSelectableRows/components/bulkActions/bulkActions.d.ts +3 -1
- package/dist/dataGrid/withSelectableRows/components/bulkActions/bulkActions.js +39 -4
- package/dist/dataGrid/withSelectableRows/withSelectableRows.js +73 -12
- package/dist/dropdown/dropdownTrigger.d.ts +1 -1
- package/dist/dropdownRaw/dropdownHelper.d.ts +12 -0
- package/dist/dropdownRaw/dropdownHelper.js +32 -11
- package/dist/dropdownRaw/dropdownRaw.js +36 -8
- package/dist/dropdownRaw/dropdownSearchableTrigger.d.ts +2 -1
- package/dist/dropdownRaw/dropdownSearchableTrigger.js +13 -6
- package/dist/dropdownRaw/dropdownTrigger.d.ts +2 -1
- package/dist/dropdownRaw/dropdownTrigger.js +2 -2
- package/dist/dropdownRaw/stateReducer/stateReducer.d.ts +8 -0
- package/dist/dropdownRaw/stateReducer/stateReducer.js +5 -2
- package/dist/dropdownRaw/types.d.ts +36 -0
- package/dist/filterButton/filterButton.d.ts +1 -1
- package/dist/formGroup/hooks/rowHooks/useLabelClasses.js +8 -2
- package/dist/formLayout/utils/applyLayoutPosition/applyLayoutPosition.d.ts +2 -1
- package/dist/formLayout/utils/applyLayoutPosition/applyLayoutPosition.js +37 -90
- package/dist/header/components/collapsedItemsControl/collapsedItemsControl.d.ts +1 -1
- package/dist/header/components/collapsedItemsControl/collapsedItemsControl.js +6 -2
- package/dist/header/headerButton.d.ts +3 -1
- package/dist/header/headerButton.js +4 -2
- package/dist/header/headerMenu.d.ts +2 -0
- package/dist/header/headerMenu.js +1 -1
- package/dist/index.css +319 -68
- package/dist/index.d.ts +3 -1
- package/dist/index.js +9 -3
- package/dist/menu/components/menuButton.d.ts +3 -1
- package/dist/menu/components/menuButton.js +66 -47
- package/dist/menu/components/menuItem.js +4 -4
- package/dist/miniTabs/miniTabs.js +4 -2
- package/dist/pageHeader/pageHeaderButton.d.ts +1 -1
- package/dist/pageHeader/pageHeaderButton.js +4 -2
- package/dist/pagination/pagination.d.ts +19 -4
- package/dist/pagination/pagination.js +21 -1
- package/dist/pagination/paginationText/paginationText.d.ts +7 -1
- package/dist/pagination/paginationText/paginationText.js +6 -3
- package/dist/pillExpandable/pillContent.d.ts +3 -2
- package/dist/pillExpandable/pillContent.js +2 -2
- package/dist/pillExpandable/pillExpandable.js +20 -5
- package/dist/pillExpandable/pillExpandablePopoverContent.d.ts +3 -2
- package/dist/pillExpandable/pillExpandablePopoverContent.js +1 -1
- package/dist/pillExpandable/pillExpandableSimple.d.ts +3 -1
- package/dist/pillExpandable/pillExpandableSimple.js +19 -9
- package/dist/selectList/selectList.js +1 -0
- package/dist/selectList/selectListItem.d.ts +10 -1
- package/dist/selectList/selectListItem.js +12 -9
- package/dist/table/children/tablePagination.d.ts +1 -1
- package/dist/table/children/useTableChildren.d.ts +4 -2
- package/dist/table/children/useTableChildren.js +64 -16
- package/dist/table/nested/nestedData.d.ts +29 -1
- package/dist/table/nested/nestedData.js +45 -4
- package/dist/table/nested/useNestedRows.js +18 -22
- package/dist/table/nested/useShowMore.d.ts +41 -0
- package/dist/table/nested/useShowMore.js +56 -0
- package/dist/table/selectable/interfaces.d.ts +17 -0
- package/dist/table/selectable/useDragSelection.d.ts +10 -0
- package/dist/table/selectable/useDragSelection.js +145 -0
- package/dist/table/selectable/useSelectableRows.d.ts +5 -2
- package/dist/table/selectable/useSelectableRows.js +131 -36
- package/dist/table/selectable/utils/calculateSelectionState.d.ts +1 -1
- package/dist/table/selectable/utils/calculateSelectionState.js +43 -7
- package/dist/table/selectable/utils/checkRow.js +4 -2
- package/dist/table/selectable/utils/getCurrentPageSelection.js +9 -5
- package/dist/table/selectable/utils/getDragSelectionRows.d.ts +15 -0
- package/dist/table/selectable/utils/getDragSelectionRows.js +28 -0
- package/dist/table/selectable/utils/getRangeIds.d.ts +2 -0
- package/dist/table/selectable/utils/getRangeIds.js +21 -0
- package/dist/table/selectable/utils/isRowChecked.d.ts +1 -1
- package/dist/table/selectable/utils/isRowChecked.js +40 -7
- package/dist/table/table.d.ts +1 -2
- package/dist/table/table.js +58 -31
- package/dist/tabs/tabs.d.ts +1 -0
- package/dist/tabs/tabs.js +50 -17
- package/dist/textInputRaw/textInputRaw.js +3 -2
- package/dist/tooltip/tooltip.d.ts +2 -0
- package/dist/tooltip/tooltip.js +19 -7
- package/dist/utils/localization/translations/ar-001.json +1 -0
- package/dist/utils/localization/translations/bg-BG.json +1 -0
- package/dist/utils/localization/translations/cs.json +1 -0
- package/dist/utils/localization/translations/da-DK.json +1 -0
- package/dist/utils/localization/translations/de.json +1 -0
- package/dist/utils/localization/translations/el-GR.json +1 -0
- package/dist/utils/localization/translations/en.json +4 -0
- package/dist/utils/localization/translations/es.json +1 -0
- package/dist/utils/localization/translations/et-EE.json +1 -0
- package/dist/utils/localization/translations/fi-FI.json +1 -0
- package/dist/utils/localization/translations/fr-FR.json +1 -0
- package/dist/utils/localization/translations/fr.json +1 -0
- package/dist/utils/localization/translations/hu-HU.json +1 -0
- package/dist/utils/localization/translations/id.json +1 -0
- package/dist/utils/localization/translations/it.json +1 -0
- package/dist/utils/localization/translations/ja.json +1 -0
- package/dist/utils/localization/translations/ka-GE.json +1 -0
- package/dist/utils/localization/translations/ko-KR.json +1 -0
- package/dist/utils/localization/translations/lt-LT.json +1 -0
- package/dist/utils/localization/translations/lv-LV.json +1 -0
- package/dist/utils/localization/translations/ms.json +1 -0
- package/dist/utils/localization/translations/nb-NO.json +1 -0
- package/dist/utils/localization/translations/nl.json +1 -0
- package/dist/utils/localization/translations/pl.json +1 -0
- package/dist/utils/localization/translations/pt-BR.json +1 -0
- package/dist/utils/localization/translations/pt-PT.json +1 -0
- package/dist/utils/localization/translations/ro-RO.json +1 -0
- package/dist/utils/localization/translations/sk-SK.json +1 -0
- package/dist/utils/localization/translations/sv.json +1 -0
- package/dist/utils/localization/translations/th.json +1 -0
- package/dist/utils/localization/translations/tr.json +1 -0
- package/dist/utils/localization/translations/zh-Hans.json +1 -0
- package/dist/utils/localization/translations/zh-TW.json +1 -0
- package/dist/waiting/waiting.js +97 -1
- package/esm/absolute/absolute.js +5 -1
- package/esm/button/button.d.ts +2 -1
- package/esm/button/button.js +22 -5
- package/esm/checkboxListWithAction/checkboxListWithAction.d.ts +2 -0
- package/esm/checkboxListWithAction/checkboxListWithAction.js +1 -1
- package/esm/commonHelpers/ShowMoreCell.d.ts +5 -0
- package/esm/commonHelpers/ShowMoreCell.js +57 -0
- package/esm/commonHelpers/getAriaAttributes.js +6 -9
- package/esm/commonHelpers/getNonAriaProps.d.ts +11 -0
- package/esm/commonHelpers/getNonAriaProps.js +15 -0
- package/esm/commonHelpers/hooks/useScroll.d.ts +1 -1
- package/esm/commonHelpers/hooks/useScroll.js +6 -6
- package/esm/commonHelpers/isAriaProp.d.ts +9 -0
- package/esm/commonHelpers/isAriaProp.js +9 -0
- package/esm/commonHelpers/showMoreRow.d.ts +28 -0
- package/esm/commonHelpers/showMoreRow.js +22 -0
- package/esm/commonHelpers/tabsKeyboard.d.ts +1 -1
- package/esm/commonHelpers/tabsKeyboard.js +15 -1
- package/esm/commonStyles/colors/colorsConstant.js +11 -11
- package/esm/dataFeed/dataFeedColumnsItems.js +3 -1
- package/esm/dataGrid/columns/checkboxColumn/checkboxCell.d.ts +2 -1
- package/esm/dataGrid/columns/checkboxColumn/checkboxCell.js +1 -1
- package/esm/dataGrid/columns/checkboxColumn/checkboxColumnWrapper.d.ts +4 -2
- package/esm/dataGrid/columns/checkboxColumn/checkboxColumnWrapper.js +10 -1
- package/esm/dataGrid/dataGrid.d.ts +5 -1
- package/esm/dataGrid/dataGrid.js +38 -2
- package/esm/dataGrid/lazyLoadingEnd/lazyLoadingEnd.d.ts +3 -0
- package/esm/dataGrid/lazyLoadingEnd/lazyLoadingEnd.js +45 -0
- package/esm/dataGrid/row/row.js +20 -2
- package/esm/dataGrid/withSelectableRows/components/bulkActions/bulkActions.d.ts +3 -1
- package/esm/dataGrid/withSelectableRows/components/bulkActions/bulkActions.js +39 -4
- package/esm/dataGrid/withSelectableRows/withSelectableRows.js +73 -12
- package/esm/dropdown/dropdownTrigger.d.ts +1 -1
- package/esm/dropdownRaw/dropdownHelper.d.ts +12 -0
- package/esm/dropdownRaw/dropdownHelper.js +30 -10
- package/esm/dropdownRaw/dropdownRaw.js +37 -9
- package/esm/dropdownRaw/dropdownSearchableTrigger.d.ts +2 -1
- package/esm/dropdownRaw/dropdownSearchableTrigger.js +13 -6
- package/esm/dropdownRaw/dropdownTrigger.d.ts +2 -1
- package/esm/dropdownRaw/dropdownTrigger.js +2 -2
- package/esm/dropdownRaw/stateReducer/stateReducer.d.ts +8 -0
- package/esm/dropdownRaw/stateReducer/stateReducer.js +5 -2
- package/esm/dropdownRaw/types.d.ts +36 -0
- package/esm/filterButton/filterButton.d.ts +1 -1
- package/esm/formGroup/hooks/rowHooks/useLabelClasses.js +8 -2
- package/esm/formLayout/utils/applyLayoutPosition/applyLayoutPosition.d.ts +2 -1
- package/esm/formLayout/utils/applyLayoutPosition/applyLayoutPosition.js +37 -90
- package/esm/header/components/collapsedItemsControl/collapsedItemsControl.d.ts +1 -1
- package/esm/header/components/collapsedItemsControl/collapsedItemsControl.js +6 -2
- package/esm/header/headerButton.d.ts +3 -1
- package/esm/header/headerButton.js +4 -2
- package/esm/header/headerMenu.d.ts +2 -0
- package/esm/header/headerMenu.js +1 -1
- package/esm/index.d.ts +3 -1
- package/esm/index.js +3 -1
- package/esm/menu/components/menuButton.d.ts +3 -1
- package/esm/menu/components/menuButton.js +66 -47
- package/esm/menu/components/menuItem.js +4 -4
- package/esm/miniTabs/miniTabs.js +4 -2
- package/esm/pageHeader/pageHeaderButton.d.ts +1 -1
- package/esm/pageHeader/pageHeaderButton.js +4 -2
- package/esm/pagination/pagination.d.ts +19 -4
- package/esm/pagination/pagination.js +21 -1
- package/esm/pagination/paginationText/paginationText.d.ts +7 -1
- package/esm/pagination/paginationText/paginationText.js +6 -3
- package/esm/pillExpandable/pillContent.d.ts +3 -2
- package/esm/pillExpandable/pillContent.js +2 -2
- package/esm/pillExpandable/pillExpandable.js +20 -5
- package/esm/pillExpandable/pillExpandablePopoverContent.d.ts +3 -2
- package/esm/pillExpandable/pillExpandablePopoverContent.js +1 -1
- package/esm/pillExpandable/pillExpandableSimple.d.ts +3 -1
- package/esm/pillExpandable/pillExpandableSimple.js +20 -10
- package/esm/selectList/selectList.js +1 -0
- package/esm/selectList/selectListItem.d.ts +10 -1
- package/esm/selectList/selectListItem.js +12 -9
- package/esm/table/children/tablePagination.d.ts +1 -1
- package/esm/table/children/useTableChildren.d.ts +4 -2
- package/esm/table/children/useTableChildren.js +64 -16
- package/esm/table/nested/nestedData.d.ts +29 -1
- package/esm/table/nested/nestedData.js +44 -3
- package/esm/table/nested/useNestedRows.js +18 -22
- package/esm/table/nested/useShowMore.d.ts +41 -0
- package/esm/table/nested/useShowMore.js +52 -0
- package/esm/table/selectable/interfaces.d.ts +17 -0
- package/esm/table/selectable/useDragSelection.d.ts +10 -0
- package/esm/table/selectable/useDragSelection.js +141 -0
- package/esm/table/selectable/useSelectableRows.d.ts +5 -2
- package/esm/table/selectable/useSelectableRows.js +129 -35
- package/esm/table/selectable/utils/calculateSelectionState.d.ts +1 -1
- package/esm/table/selectable/utils/calculateSelectionState.js +43 -7
- package/esm/table/selectable/utils/checkRow.js +4 -2
- package/esm/table/selectable/utils/getCurrentPageSelection.js +9 -5
- package/esm/table/selectable/utils/getDragSelectionRows.d.ts +15 -0
- package/esm/table/selectable/utils/getDragSelectionRows.js +24 -0
- package/esm/table/selectable/utils/getRangeIds.d.ts +2 -0
- package/esm/table/selectable/utils/getRangeIds.js +17 -0
- package/esm/table/selectable/utils/isRowChecked.d.ts +1 -1
- package/esm/table/selectable/utils/isRowChecked.js +40 -7
- package/esm/table/table.d.ts +1 -2
- package/esm/table/table.js +43 -16
- package/esm/tabs/tabs.d.ts +1 -0
- package/esm/tabs/tabs.js +50 -17
- package/esm/textInputRaw/textInputRaw.js +3 -2
- package/esm/tooltip/tooltip.d.ts +2 -0
- package/esm/tooltip/tooltip.js +19 -7
- package/esm/utils/localization/translations/ar-001.json +1 -0
- package/esm/utils/localization/translations/bg-BG.json +1 -0
- package/esm/utils/localization/translations/cs.json +1 -0
- package/esm/utils/localization/translations/da-DK.json +1 -0
- package/esm/utils/localization/translations/de.json +1 -0
- package/esm/utils/localization/translations/el-GR.json +1 -0
- package/esm/utils/localization/translations/en.json +4 -0
- package/esm/utils/localization/translations/es.json +1 -0
- package/esm/utils/localization/translations/et-EE.json +1 -0
- package/esm/utils/localization/translations/fi-FI.json +1 -0
- package/esm/utils/localization/translations/fr-FR.json +1 -0
- package/esm/utils/localization/translations/fr.json +1 -0
- package/esm/utils/localization/translations/hu-HU.json +1 -0
- package/esm/utils/localization/translations/id.json +1 -0
- package/esm/utils/localization/translations/it.json +1 -0
- package/esm/utils/localization/translations/ja.json +1 -0
- package/esm/utils/localization/translations/ka-GE.json +1 -0
- package/esm/utils/localization/translations/ko-KR.json +1 -0
- package/esm/utils/localization/translations/lt-LT.json +1 -0
- package/esm/utils/localization/translations/lv-LV.json +1 -0
- package/esm/utils/localization/translations/ms.json +1 -0
- package/esm/utils/localization/translations/nb-NO.json +1 -0
- package/esm/utils/localization/translations/nl.json +1 -0
- package/esm/utils/localization/translations/pl.json +1 -0
- package/esm/utils/localization/translations/pt-BR.json +1 -0
- package/esm/utils/localization/translations/pt-PT.json +1 -0
- package/esm/utils/localization/translations/ro-RO.json +1 -0
- package/esm/utils/localization/translations/sk-SK.json +1 -0
- package/esm/utils/localization/translations/sv.json +1 -0
- package/esm/utils/localization/translations/th.json +1 -0
- package/esm/utils/localization/translations/tr.json +1 -0
- package/esm/utils/localization/translations/zh-Hans.json +1 -0
- package/esm/utils/localization/translations/zh-TW.json +1 -0
- package/esm/waiting/waiting.js +98 -2
- package/package.json +15 -3
|
@@ -8,7 +8,7 @@ const iconChevronTop_1 = require("../icons/iconChevronTop");
|
|
|
8
8
|
const iconChevronBottom_1 = require("../icons/iconChevronBottom");
|
|
9
9
|
const iconException_1 = require("../icons/iconException");
|
|
10
10
|
const classNames_1 = require("../commonHelpers/classNames/classNames");
|
|
11
|
-
const PillExpandableSimple = ({ onExpand, text, expanded, includeExpandIcon = true, type = "warning", icon = iconException_1.IconException, isBeta, isMobile, ref, className, descriptionId, dataAnalyticsId
|
|
11
|
+
const PillExpandableSimple = ({ onExpand, text, expanded, includeExpandIcon = true, type = "warning", icon = iconException_1.IconException, isBeta, isMobile, ref, className, descriptionId, ariaHasPopup, isDecorative, dataAnalyticsId
|
|
12
12
|
// eslint-disable-next-line complexity
|
|
13
13
|
}) => {
|
|
14
14
|
const iconDriveClassName = (0, useDriveClassName_1.useDriveClassName)("icon");
|
|
@@ -21,13 +21,7 @@ const PillExpandableSimple = ({ onExpand, text, expanded, includeExpandIcon = tr
|
|
|
21
21
|
const iconSize = isBeta ? "big" : isLargeIcon ? "large" : "big";
|
|
22
22
|
const hasText = (text || "").trim().length > 0;
|
|
23
23
|
const isTextCentered = icon === false && !includeExpandIcon;
|
|
24
|
-
|
|
25
|
-
"zen-status-pill__container",
|
|
26
|
-
`zen-status-pill__container--${type}`,
|
|
27
|
-
containerDriveClassName || "",
|
|
28
|
-
className || "",
|
|
29
|
-
"zen-ellipsis"
|
|
30
|
-
]), ref: ref, onClick: onExpandHandler, tabIndex: !includeExpandIcon ? -1 : undefined, "aria-expanded": includeExpandIcon ? (expanded !== null && expanded !== void 0 ? expanded : false) : undefined, "aria-describedby": descriptionId }, (dataAnalyticsId ? { "data-analytics-id": dataAnalyticsId } : {}), { children: [icon !== false && ((0, jsx_runtime_1.jsx)("div", { className: (0, classNames_1.classNames)([
|
|
24
|
+
const content = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [icon !== false && ((0, jsx_runtime_1.jsx)("div", { className: (0, classNames_1.classNames)([
|
|
31
25
|
"zen-status-pill__icon",
|
|
32
26
|
`zen-status-pill__icon--${type}`,
|
|
33
27
|
isLargeIcon ? "zen-status-pill__icon--large" : "",
|
|
@@ -41,7 +35,23 @@ const PillExpandableSimple = ({ onExpand, text, expanded, includeExpandIcon = tr
|
|
|
41
35
|
isTextCentered ? "zen-status-pill__text--centered" : ""
|
|
42
36
|
]), children: text })), includeExpandIcon && ((0, jsx_runtime_1.jsx)("div", { className: `zen-status-pill__expand-button zen-status-pill__expand-button--${type}`, children: (0, jsx_runtime_1.jsx)("div", { className: "zen-status-pill__icon", children: (0, react_1.createElement)(ChevronIcon, {
|
|
43
37
|
size: iconSize
|
|
44
|
-
}) }) }))] }))
|
|
38
|
+
}) }) }))] }));
|
|
39
|
+
if (isDecorative) {
|
|
40
|
+
return ((0, jsx_runtime_1.jsx)("span", { className: (0, classNames_1.classNames)([
|
|
41
|
+
"zen-status-pill__container",
|
|
42
|
+
`zen-status-pill__container--${type}`,
|
|
43
|
+
containerDriveClassName || "",
|
|
44
|
+
className || "",
|
|
45
|
+
"zen-ellipsis"
|
|
46
|
+
]), "aria-hidden": "true", children: content }));
|
|
47
|
+
}
|
|
48
|
+
return ((0, jsx_runtime_1.jsx)("button", Object.assign({ type: "button", className: (0, classNames_1.classNames)([
|
|
49
|
+
"zen-status-pill__container",
|
|
50
|
+
`zen-status-pill__container--${type}`,
|
|
51
|
+
containerDriveClassName || "",
|
|
52
|
+
className || "",
|
|
53
|
+
"zen-ellipsis"
|
|
54
|
+
]), ref: ref, onClick: onExpandHandler, tabIndex: !includeExpandIcon ? -1 : undefined, "aria-expanded": includeExpandIcon ? (expanded !== null && expanded !== void 0 ? expanded : false) : undefined, "aria-describedby": descriptionId, "aria-haspopup": ariaHasPopup, "data-role": ariaHasPopup }, (dataAnalyticsId ? { "data-analytics-id": dataAnalyticsId } : {}), { children: content })));
|
|
45
55
|
};
|
|
46
56
|
exports.PillExpandableSimple = PillExpandableSimple;
|
|
47
57
|
exports.PillExpandableSimple.displayName = "PillExpandableSimple";
|
|
@@ -147,6 +147,7 @@ const SelectListInnerComp = ({
|
|
|
147
147
|
showCheckbox: showCheckbox,
|
|
148
148
|
state: state.itemsState.get(item.id),
|
|
149
149
|
focused: state.activeIndex === index,
|
|
150
|
+
divider: index < items.length - 1 ? item.divider : undefined,
|
|
150
151
|
onChange: onChangeItem,
|
|
151
152
|
onClick: onClickItem,
|
|
152
153
|
onFocusItem: onFocusItem
|
|
@@ -10,5 +10,14 @@ export interface ISelectListItem extends IZenIdComponentProps {
|
|
|
10
10
|
onClick?: (id: string) => void;
|
|
11
11
|
onFocusItem?: (id: string) => void;
|
|
12
12
|
multiLevel?: boolean;
|
|
13
|
+
/** When true, renders a 1px separator line below this item. */
|
|
14
|
+
divider?: boolean;
|
|
15
|
+
title?: string;
|
|
16
|
+
/**
|
|
17
|
+
* When true, renders the item label in `--text-error-message` red. Visual signal only — does not prevent selection.
|
|
18
|
+
* Only applies in single-select (SelectList) mode; ignored in multiselect (CheckboxListWithAction).
|
|
19
|
+
* Disabled+destructive renders with `--accents-error--main` (#ffeceb) on a transparent background, no hover feedback.
|
|
20
|
+
*/
|
|
21
|
+
destructive?: boolean;
|
|
13
22
|
}
|
|
14
|
-
export declare const SelectListItem: ({ id, disabled, state, showCheckbox, focused, onChange, onClick, onFocusItem, multiLevel, className, children }: ISelectListItem) => import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export declare const SelectListItem: ({ id, disabled, state, showCheckbox, focused, onChange, onClick, onFocusItem, multiLevel, divider, title, destructive, className, children }: ISelectListItem) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -26,7 +26,16 @@ const getTabIndex = (showCheckbox, focused, disabled) => {
|
|
|
26
26
|
return -1;
|
|
27
27
|
return focused ? 0 : -1;
|
|
28
28
|
};
|
|
29
|
-
const
|
|
29
|
+
const getItemClassName = (showCheckbox, focused, destructive, driveClassName, className, divider) => (0, classNames_1.classNames)([
|
|
30
|
+
"zen-select-item",
|
|
31
|
+
showCheckbox ? "zen-select-item--with-checkbox" : "",
|
|
32
|
+
focused ? "zen-select-item--focused" : "",
|
|
33
|
+
destructive ? "zen-select-item--destructive" : "",
|
|
34
|
+
driveClassName || "",
|
|
35
|
+
className,
|
|
36
|
+
divider ? "zen-select-item--divider" : ""
|
|
37
|
+
]);
|
|
38
|
+
const SelectListItem = ({ id, disabled = false, state = checkboxState_1.CheckboxState.Off, showCheckbox = false, focused = false, onChange, onClick, onFocusItem, multiLevel, divider, title, destructive, className = "", children }) => {
|
|
30
39
|
const driveClassName = (0, useDriveClassName_1.useDriveClassName)("zen-select-item");
|
|
31
40
|
const ChevronIcon = (0, useDirectionalIcon_1.useDirectionalIcon)(iconChevronRight_1.IconChevronRight, iconChevronLeft_1.IconChevronLeft);
|
|
32
41
|
const onClickFunc = () => {
|
|
@@ -39,17 +48,11 @@ const SelectListItem = ({ id, disabled = false, state = checkboxState_1.Checkbox
|
|
|
39
48
|
}
|
|
40
49
|
onChange && onChange(id, newState);
|
|
41
50
|
};
|
|
42
|
-
return ((0, jsx_runtime_1.jsx)("li", { "data-id": id, className: (0, classNames_1.classNames)([
|
|
43
|
-
"zen-select-item",
|
|
44
|
-
showCheckbox ? "zen-select-item--with-checkbox" : "",
|
|
45
|
-
focused ? "zen-select-item--focused" : "",
|
|
46
|
-
driveClassName || "",
|
|
47
|
-
className
|
|
48
|
-
]), role: showCheckbox ? "menuitemcheckbox" : "option", "aria-selected": showCheckbox ? undefined : state === checkboxState_1.CheckboxState.On, "aria-checked": getAriaChecked(showCheckbox, state), "aria-disabled": disabled, tabIndex: getTabIndex(showCheckbox, focused, disabled), onFocus: !showCheckbox && !disabled && onFocusItem ? () => onFocusItem(id) : undefined, onClick: onClickFunc, id: id, children: (0, jsx_runtime_1.jsxs)("div", { className: (0, classNames_1.classNames)([
|
|
51
|
+
return ((0, jsx_runtime_1.jsx)("li", { "data-id": id, className: getItemClassName(showCheckbox, focused, destructive, driveClassName, className, divider), role: showCheckbox ? "menuitemcheckbox" : "option", "aria-selected": showCheckbox ? undefined : state === checkboxState_1.CheckboxState.On, "aria-checked": getAriaChecked(showCheckbox, state), "aria-disabled": disabled, tabIndex: getTabIndex(showCheckbox, focused, disabled), onFocus: !showCheckbox && !disabled && onFocusItem ? () => onFocusItem(id) : undefined, onClick: onClickFunc, id: id, children: (0, jsx_runtime_1.jsxs)("div", { className: (0, classNames_1.classNames)([
|
|
49
52
|
"zen-select-list__item-content",
|
|
50
53
|
"zen-select-item__wrapper",
|
|
51
54
|
"zen-ellipsis",
|
|
52
55
|
multiLevel ? "zen-select-item__wrapper--with-arrow" : ""
|
|
53
|
-
]), children: [showCheckbox ? ((0, jsx_runtime_1.jsx)(checkboxNonInteractive_1.CheckboxNonInteractive, { className: "zen-select-item__control-view", checked: state === checkboxState_1.CheckboxState.On, indeterminate: state === checkboxState_1.CheckboxState.Indeterminate, disabled: disabled, children: children })) : (children), multiLevel && !showCheckbox ? (0, jsx_runtime_1.jsx)(ChevronIcon, { size: "large" }) : null] }) }));
|
|
56
|
+
]), title: title || undefined, children: [showCheckbox ? ((0, jsx_runtime_1.jsx)(checkboxNonInteractive_1.CheckboxNonInteractive, { className: "zen-select-item__control-view", checked: state === checkboxState_1.CheckboxState.On, indeterminate: state === checkboxState_1.CheckboxState.Indeterminate, disabled: disabled, children: children })) : (children), multiLevel && !showCheckbox ? (0, jsx_runtime_1.jsx)(ChevronIcon, { size: "large" }) : null] }) }));
|
|
54
57
|
};
|
|
55
58
|
exports.SelectListItem = SelectListItem;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IPagination } from "../../pagination/pagination";
|
|
2
|
-
export interface ITablePagination extends Pick<IPagination, "
|
|
2
|
+
export interface ITablePagination extends Pick<IPagination, "total">, Partial<Pick<IPagination, "activePage" | "perPage" | "onChange" | "disabled">> {
|
|
3
3
|
}
|
|
4
4
|
export declare const TablePagination: {
|
|
5
5
|
(_: ITablePagination): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { ReactElement, ReactNode, RefObject } from "react";
|
|
2
|
-
export declare const useTableChildren: (children: ReactNode, isMobile: boolean, selected: number, allSelected: boolean, clearSelection: () => void, activeId?: string, gridRef?: RefObject<HTMLElement | null>, onCloseDetailPanel?: () => void) => {
|
|
3
|
-
bulkActions:
|
|
2
|
+
export declare const useTableChildren: (children: ReactNode, isMobile: boolean, selected: number, allSelected: boolean, clearSelection: () => void, activeId?: string, gridRef?: RefObject<HTMLElement | null>, onCloseDetailPanel?: () => void, isInfinite?: boolean, loadedCount?: number, excludedCount?: number, canUsePaginationTotal?: boolean, hasMoreRows?: boolean) => {
|
|
3
|
+
bulkActions: import("react/jsx-runtime").JSX.Element | undefined;
|
|
4
|
+
hasSelection: boolean;
|
|
4
5
|
pagination: ReactElement | undefined;
|
|
6
|
+
paginationTotal: number | undefined;
|
|
5
7
|
activePage: undefined;
|
|
6
8
|
fullscreenButton: ReactElement | undefined;
|
|
7
9
|
emptyList: ReactElement | undefined;
|
|
@@ -27,35 +27,58 @@ const isChildElement = function (child, expectedType) {
|
|
|
27
27
|
}
|
|
28
28
|
return false;
|
|
29
29
|
};
|
|
30
|
-
const useTableChildren = (children, isMobile, selected, allSelected, clearSelection, activeId, gridRef, onCloseDetailPanel
|
|
31
|
-
|
|
30
|
+
const useTableChildren = (children, isMobile, selected, allSelected, clearSelection, activeId, gridRef, onCloseDetailPanel,
|
|
31
|
+
// Desktop infinite scroll (Table's `onScrollEnd`): when true, a `Table.Pagination` child is
|
|
32
|
+
// rendered as the chevron-less "loaded" variant (see `pagination.tsx`) instead of the normal
|
|
33
|
+
// paged controls, driven by `loadedCount` (the number of rows currently rendered).
|
|
34
|
+
isInfinite = false, loadedCount = 0, excludedCount = 0, canUsePaginationTotal = true, hasMoreRows = false) => (0, react_1.useMemo)(() => {
|
|
35
|
+
let bulkActionButtons;
|
|
32
36
|
let tablePagination = undefined;
|
|
33
37
|
let activePage = undefined;
|
|
38
|
+
// A plain `let` reassigned only inside the `Children.forEach` callback below would be seen
|
|
39
|
+
// by TS as always `undefined` at the return statement (its pre-callback narrowed type) —
|
|
40
|
+
// see the `as ReactElement | undefined` casts used for the other fields above/below for the
|
|
41
|
+
// same reason. A property on a mutable object sidesteps that: property reads aren't narrowed
|
|
42
|
+
// the same way, so `paginationMeta.total` correctly types as `number | undefined` below.
|
|
43
|
+
const paginationMeta = {};
|
|
34
44
|
let tableFullscreen = undefined;
|
|
35
45
|
let emptyList = undefined;
|
|
36
46
|
let footer = undefined;
|
|
37
47
|
let detailPanel = undefined;
|
|
38
48
|
const other = [];
|
|
39
49
|
react_1.Children.forEach(children, child => {
|
|
50
|
+
var _a, _b;
|
|
40
51
|
if (!child) {
|
|
41
52
|
return;
|
|
42
53
|
}
|
|
43
54
|
if (isChildElement(child, tableBulkActions_1.TableBulkActions.displayName)) {
|
|
44
|
-
|
|
45
|
-
bulkActions = ((0, jsx_runtime_1.jsx)(bulkActions_1.BulkActions, { gridType: isMobile ? deviceType_1.DeviceType.Mobile : deviceType_1.DeviceType.Desktop, selected: selected, allSelected: allSelected, onClearSelection: clearSelection, children: bulkActionButtons }));
|
|
55
|
+
bulkActionButtons = child.props.children || [];
|
|
46
56
|
return;
|
|
47
57
|
}
|
|
48
58
|
if (isChildElement(child, tablePagination_1.TablePagination.displayName)) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
paginationMeta.present = true;
|
|
60
|
+
const total = child.props.total || 0;
|
|
61
|
+
tablePagination = isInfinite
|
|
62
|
+
? (0, react_1.createElement)(pagination_1.Pagination, {
|
|
63
|
+
// activePage/perPage/onChange/gridRef/disabled are all paged-only (see
|
|
64
|
+
// Pagination's `variant` dispatch) and optional on IPagination for exactly
|
|
65
|
+
// this reason — intentionally omitted here rather than passed for no effect.
|
|
66
|
+
total,
|
|
67
|
+
variant: "loaded",
|
|
68
|
+
loadedCount,
|
|
69
|
+
includeText: true
|
|
70
|
+
})
|
|
71
|
+
: (0, react_1.createElement)(pagination_1.Pagination, {
|
|
72
|
+
activePage: (_a = child.props.activePage) !== null && _a !== void 0 ? _a : 0,
|
|
73
|
+
total,
|
|
74
|
+
perPage: child.props.perPage || 10,
|
|
75
|
+
onChange: (_b = child.props.onChange) !== null && _b !== void 0 ? _b : (() => undefined),
|
|
76
|
+
type: paginationType_1.PaginationType.Compact,
|
|
77
|
+
includeText: true,
|
|
78
|
+
gridRef: gridRef,
|
|
79
|
+
disabled: child.props.disabled
|
|
80
|
+
});
|
|
81
|
+
paginationMeta.total = child.props.total;
|
|
59
82
|
activePage = child.props.activePage;
|
|
60
83
|
return;
|
|
61
84
|
}
|
|
@@ -93,9 +116,20 @@ const useTableChildren = (children, isMobile, selected, allSelected, clearSelect
|
|
|
93
116
|
}
|
|
94
117
|
other.push(child);
|
|
95
118
|
});
|
|
119
|
+
const allRowsLoaded = (!paginationMeta.present && !hasMoreRows) || (paginationMeta.total !== undefined && loadedCount >= paginationMeta.total);
|
|
120
|
+
const hasExclusions = allSelected && excludedCount > 0;
|
|
121
|
+
const selectedCount = allSelected && !allRowsLoaded
|
|
122
|
+
? canUsePaginationTotal && paginationMeta.total !== undefined
|
|
123
|
+
? Math.max(0, paginationMeta.total - excludedCount)
|
|
124
|
+
: undefined
|
|
125
|
+
: selected;
|
|
126
|
+
const hasSelection = selectedCount === undefined || selectedCount > 0;
|
|
127
|
+
const bulkActions = bulkActionButtons !== undefined ? ((0, jsx_runtime_1.jsx)(bulkActions_1.BulkActions, { gridType: isMobile ? deviceType_1.DeviceType.Mobile : deviceType_1.DeviceType.Desktop, selected: selectedCount !== null && selectedCount !== void 0 ? selectedCount : selected, allSelected: allSelected && !hasExclusions && hasSelection, selectionCountUnknown: hasExclusions && selectedCount === undefined, onClearSelection: clearSelection, children: bulkActionButtons })) : undefined;
|
|
96
128
|
return {
|
|
97
|
-
bulkActions
|
|
129
|
+
bulkActions,
|
|
130
|
+
hasSelection,
|
|
98
131
|
pagination: tablePagination,
|
|
132
|
+
paginationTotal: paginationMeta.total,
|
|
99
133
|
activePage: activePage,
|
|
100
134
|
fullscreenButton: tableFullscreen,
|
|
101
135
|
emptyList: emptyList,
|
|
@@ -103,5 +137,19 @@ const useTableChildren = (children, isMobile, selected, allSelected, clearSelect
|
|
|
103
137
|
detailPanel: detailPanel,
|
|
104
138
|
other: other
|
|
105
139
|
};
|
|
106
|
-
}, [
|
|
140
|
+
}, [
|
|
141
|
+
children,
|
|
142
|
+
clearSelection,
|
|
143
|
+
isMobile,
|
|
144
|
+
selected,
|
|
145
|
+
gridRef,
|
|
146
|
+
allSelected,
|
|
147
|
+
activeId,
|
|
148
|
+
onCloseDetailPanel,
|
|
149
|
+
isInfinite,
|
|
150
|
+
loadedCount,
|
|
151
|
+
excludedCount,
|
|
152
|
+
canUsePaginationTotal,
|
|
153
|
+
hasMoreRows
|
|
154
|
+
]);
|
|
107
155
|
exports.useTableChildren = useTableChildren;
|
|
@@ -1,5 +1,26 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
1
2
|
import { IEntityWithId } from "../../commonHelpers/entity";
|
|
2
|
-
declare const
|
|
3
|
+
export declare const DEFAULT_SHOW_MORE_CAP = 10;
|
|
4
|
+
/**
|
|
5
|
+
* Caps how many child rows render per parent, appending a "+N more" affordance.
|
|
6
|
+
* Desktop only: on mobile an expanded parent always renders its full child list, uncapped and
|
|
7
|
+
* with no "+N more" row, because the feed has no comparable density constraint.
|
|
8
|
+
* Memoize the object you pass — a new reference each render re-derives the entity tree.
|
|
9
|
+
*/
|
|
10
|
+
export type IShowMoreOptions<TParent> = {
|
|
11
|
+
/** Defaults to 10. */
|
|
12
|
+
cap?: number;
|
|
13
|
+
label?: (remaining: number) => ReactNode;
|
|
14
|
+
/** When true for a parent, all its children render with no cap and no "+N more" row. */
|
|
15
|
+
isUncapped?: (parent: TParent) => boolean;
|
|
16
|
+
} & ({
|
|
17
|
+
onClick: (parent: TParent) => void;
|
|
18
|
+
href?: never;
|
|
19
|
+
} | {
|
|
20
|
+
href: (parent: TParent) => string;
|
|
21
|
+
onClick?: never;
|
|
22
|
+
});
|
|
23
|
+
declare const NestedDataInt: <TParent extends IEntityWithId, TChild extends IEntityWithId>({ entities, children, expandedRows, useChildrenDataHook, maxHooks, showMore, hideChildrenOnMobile }: {
|
|
3
24
|
entities: TParent[];
|
|
4
25
|
expandedRows: string[];
|
|
5
26
|
useChildrenDataHook: (parentId: string, enabled: boolean) => {
|
|
@@ -10,6 +31,13 @@ declare const NestedDataInt: <TParent extends IEntityWithId, TChild extends IEnt
|
|
|
10
31
|
};
|
|
11
32
|
children: React.ReactNode;
|
|
12
33
|
maxHooks?: number;
|
|
34
|
+
showMore?: IShowMoreOptions<TParent>;
|
|
35
|
+
/**
|
|
36
|
+
* Mobile only. When true, parents render as plain rows on the feed: no children and no
|
|
37
|
+
* expand control. Pair it with a column renderer (e.g. `MainColumn`'s `mainText.createLink`)
|
|
38
|
+
* to send the user to a view that owns the full child list. Desktop is unaffected.
|
|
39
|
+
*/
|
|
40
|
+
hideChildrenOnMobile?: boolean;
|
|
13
41
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
14
42
|
export declare const NestedData: typeof NestedDataInt;
|
|
15
43
|
export {};
|
|
@@ -1,9 +1,24 @@
|
|
|
1
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
|
+
};
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NestedData = void 0;
|
|
14
|
+
exports.NestedData = exports.DEFAULT_SHOW_MORE_CAP = void 0;
|
|
4
15
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
16
|
const react_1 = require("react");
|
|
6
|
-
const
|
|
17
|
+
const showMoreRow_1 = require("../../commonHelpers/showMoreRow");
|
|
18
|
+
const useMobile_1 = require("../../commonHelpers/hooks/useMobile");
|
|
19
|
+
exports.DEFAULT_SHOW_MORE_CAP = 10;
|
|
20
|
+
const NestedDataInt = ({ entities, children, expandedRows, useChildrenDataHook, maxHooks = 100, showMore, hideChildrenOnMobile }) => {
|
|
21
|
+
const isMobile = (0, useMobile_1.useMobile)();
|
|
7
22
|
// Call hooks in a consistent order - this MUST be at the top level and cannot be wrapped in useEffect
|
|
8
23
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
9
24
|
const hookResults = [];
|
|
@@ -18,23 +33,49 @@ const NestedDataInt = ({ entities, children, expandedRows, useChildrenDataHook,
|
|
|
18
33
|
}
|
|
19
34
|
// Memoize the entities with children calculation to avoid unnecessary re-renders
|
|
20
35
|
const entitiesWithChildren = (0, react_1.useMemo)(() => entities.map((entity, index) => {
|
|
36
|
+
var _a, _b;
|
|
21
37
|
const isExpanded = expandedRows.includes(entity.id);
|
|
22
38
|
if (index < maxHooks) {
|
|
23
39
|
const { data: childrenData, isLoading, error, isError } = hookResults[index];
|
|
40
|
+
// Must come before the skeleton branch below: that one attaches placeholder
|
|
41
|
+
// children to every collapsed parent, which is what makes the feed render an
|
|
42
|
+
// expand control. Dropping `children` entirely is what removes it.
|
|
43
|
+
if (isMobile && hideChildrenOnMobile) {
|
|
44
|
+
// `children` is destructured off rather than spread over, so a
|
|
45
|
+
// consumer-supplied array cannot survive and re-add the control.
|
|
46
|
+
const _c = entity, { children: _hidden } = _c, rest = __rest(_c, ["children"]);
|
|
47
|
+
const withoutChildren = rest;
|
|
48
|
+
// Selection still covers every real child (ticket decision #4) even though
|
|
49
|
+
// none of them render.
|
|
50
|
+
return childrenData ? (0, showMoreRow_1.withFullChildren)(withoutChildren, childrenData) : withoutChildren;
|
|
51
|
+
}
|
|
24
52
|
if (isLoading || !isExpanded) {
|
|
25
|
-
|
|
53
|
+
const placeholderEntity = Object.assign(Object.assign({}, entity), { children: new Array(3)
|
|
26
54
|
.fill("")
|
|
27
55
|
.map((_1, j) => ({ id: `loading-${entity.id}-${j}`, isLoading: true })) });
|
|
56
|
+
// Skeletons render, but already-fetched children stay available so selecting
|
|
57
|
+
// the parent covers every child rather than the placeholders.
|
|
58
|
+
return childrenData ? (0, showMoreRow_1.withFullChildren)(placeholderEntity, childrenData) : placeholderEntity;
|
|
28
59
|
}
|
|
29
60
|
if (isError && error) {
|
|
30
61
|
return Object.assign(Object.assign({}, entity), { children: [] });
|
|
31
62
|
}
|
|
32
63
|
if (childrenData) {
|
|
64
|
+
const cap = (_a = showMore === null || showMore === void 0 ? void 0 : showMore.cap) !== null && _a !== void 0 ? _a : exports.DEFAULT_SHOW_MORE_CAP;
|
|
65
|
+
// The cap is a desktop density affordance; the mobile feed renders every child.
|
|
66
|
+
if (showMore && !isMobile && childrenData.length > cap && !((_b = showMore.isUncapped) === null || _b === void 0 ? void 0 : _b.call(showMore, entity))) {
|
|
67
|
+
const remaining = childrenData.length - cap;
|
|
68
|
+
const showMoreActivation = "href" in showMore && showMore.href
|
|
69
|
+
? { href: showMore.href(entity) }
|
|
70
|
+
: { onActivate: () => showMore.onClick(entity) };
|
|
71
|
+
const showMoreRow = (0, showMoreRow_1.createShowMoreRow)(Object.assign({ parentId: entity.id, remaining, label: showMore.label }, showMoreActivation));
|
|
72
|
+
return (0, showMoreRow_1.withFullChildren)(Object.assign(Object.assign({}, entity), { children: [...childrenData.slice(0, cap), showMoreRow] }), childrenData);
|
|
73
|
+
}
|
|
33
74
|
return Object.assign(Object.assign({}, entity), { children: childrenData });
|
|
34
75
|
}
|
|
35
76
|
}
|
|
36
77
|
return entity;
|
|
37
|
-
}), [entities, expandedRows, maxHooks, hookResults]);
|
|
78
|
+
}), [entities, expandedRows, maxHooks, hookResults, showMore, isMobile, hideChildrenOnMobile]);
|
|
38
79
|
/* eslint-disable @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-explicit-any */
|
|
39
80
|
const table = (0, react_1.useMemo)(() => (0, react_1.cloneElement)(children, {
|
|
40
81
|
entities: entitiesWithChildren
|
|
@@ -102,6 +102,20 @@ const useNestedRows = (expandedRows, onExpand, columns, isMobile) => {
|
|
|
102
102
|
}
|
|
103
103
|
}, [intExpanded, onExpand]);
|
|
104
104
|
const firstColumnId = (0, react_1.useMemo)(() => columns.length > 0 ? columns[0].id : null, [columns]);
|
|
105
|
+
// `announceState` adds aria-expanded to the button itself. Only the feed needs it: the desktop
|
|
106
|
+
// grid is a treegrid whose <tr> already carries aria-expanded (see dataGrid/row/row.tsx), and
|
|
107
|
+
// repeating it on the control inside that row would announce the state twice.
|
|
108
|
+
const renderExpandButton = (0, react_1.useCallback)((isExpanded, onExpandCallback, announceState = false) => (0, jsx_runtime_1.jsx)("button", {
|
|
109
|
+
className: "zen-nested-button__button",
|
|
110
|
+
onClick: onExpandCallback,
|
|
111
|
+
"aria-expanded": announceState ? isExpanded : undefined,
|
|
112
|
+
"aria-label": isExpanded ? translate("Collapse") : translate("Expand"),
|
|
113
|
+
children: isExpanded ? (0, jsx_runtime_1.jsx)(iconChevronTop_1.IconChevronTop, {
|
|
114
|
+
size: "large"
|
|
115
|
+
}) : (0, jsx_runtime_1.jsx)(iconChevronBottom_1.IconChevronBottom, {
|
|
116
|
+
size: "large"
|
|
117
|
+
})
|
|
118
|
+
}), [translate]);
|
|
105
119
|
const wrapper = (0, react_1.useMemo)(() => ({
|
|
106
120
|
name: exports.NestedWrapperName,
|
|
107
121
|
render(value, entity, isNested) {
|
|
@@ -121,16 +135,7 @@ const useNestedRows = (expandedRows, onExpand, columns, isMobile) => {
|
|
|
121
135
|
if ("children" in entity) {
|
|
122
136
|
return (0, jsx_runtime_1.jsxs)("div", {
|
|
123
137
|
className: "zen-nested-button",
|
|
124
|
-
children: [(0, jsx_runtime_1.jsx)("
|
|
125
|
-
className: "zen-nested-button__button",
|
|
126
|
-
onClick: onExpandCallback,
|
|
127
|
-
"aria-label": isExpanded ? translate("Collapse") : translate("Expand"),
|
|
128
|
-
children: isExpanded ? (0, jsx_runtime_1.jsx)(iconChevronTop_1.IconChevronTop, {
|
|
129
|
-
size: "large"
|
|
130
|
-
}) : (0, jsx_runtime_1.jsx)(iconChevronBottom_1.IconChevronBottom, {
|
|
131
|
-
size: "large"
|
|
132
|
-
})
|
|
133
|
-
}), (0, jsx_runtime_1.jsx)("div", {
|
|
138
|
+
children: [renderExpandButton(isExpanded, onExpandCallback), (0, jsx_runtime_1.jsx)("div", {
|
|
134
139
|
className: "zen-nested-button__content",
|
|
135
140
|
children: value
|
|
136
141
|
})]
|
|
@@ -141,7 +146,7 @@ const useNestedRows = (expandedRows, onExpand, columns, isMobile) => {
|
|
|
141
146
|
renderHeader(title) {
|
|
142
147
|
return title;
|
|
143
148
|
}
|
|
144
|
-
}), [expanded, onExpandedChange, isMobile,
|
|
149
|
+
}), [expanded, onExpandedChange, isMobile, renderExpandButton]);
|
|
145
150
|
const nestedColumns = (0, react_1.useMemo)(() => {
|
|
146
151
|
const newColumns = columns.map(c => Object.assign({}, c));
|
|
147
152
|
// Add nested wrapper to the first column
|
|
@@ -167,16 +172,7 @@ const useNestedRows = (expandedRows, onExpand, columns, isMobile) => {
|
|
|
167
172
|
};
|
|
168
173
|
return [(0, jsx_runtime_1.jsxs)("div", {
|
|
169
174
|
className: "zen-nested-button",
|
|
170
|
-
children: [(0, jsx_runtime_1.jsx)("
|
|
171
|
-
className: "zen-nested-button__button",
|
|
172
|
-
onClick: onExpandCallback,
|
|
173
|
-
"aria-label": isExpanded ? translate("Collapse") : translate("Expand"),
|
|
174
|
-
children: isExpanded ? (0, jsx_runtime_1.jsx)(iconChevronTop_1.IconChevronTop, {
|
|
175
|
-
size: "large"
|
|
176
|
-
}) : (0, jsx_runtime_1.jsx)(iconChevronBottom_1.IconChevronBottom, {
|
|
177
|
-
size: "large"
|
|
178
|
-
})
|
|
179
|
-
}), (0, jsx_runtime_1.jsx)("div", {
|
|
175
|
+
children: [renderExpandButton(isExpanded, onExpandCallback, true), (0, jsx_runtime_1.jsx)("div", {
|
|
180
176
|
className: "zen-nested-button__content",
|
|
181
177
|
children: primaryData
|
|
182
178
|
})]
|
|
@@ -184,7 +180,7 @@ const useNestedRows = (expandedRows, onExpand, columns, isMobile) => {
|
|
|
184
180
|
className: "zen-nested-button__padding",
|
|
185
181
|
children: secondaryData
|
|
186
182
|
}, "nested-value")];
|
|
187
|
-
}, [expanded, onExpandedChange, isMobile,
|
|
183
|
+
}, [expanded, onExpandedChange, isMobile, renderExpandButton]);
|
|
188
184
|
return {
|
|
189
185
|
nestedColumns,
|
|
190
186
|
nestedFeedWrapper,
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { IEntityWithId } from "../../commonHelpers/entity";
|
|
3
|
+
import { IShowMoreOptions } from "./nestedData";
|
|
4
|
+
export type IUseShowMoreConfig<TParent> = {
|
|
5
|
+
/** Passed through to `IShowMoreOptions.cap`. Defaults to 10. */
|
|
6
|
+
cap?: number;
|
|
7
|
+
/** Passed through to `IShowMoreOptions.label`. */
|
|
8
|
+
label?: (remaining: number) => ReactNode;
|
|
9
|
+
} & ({
|
|
10
|
+
/**
|
|
11
|
+
* Runs in addition to the reveal, not instead of it - the hook marks the parent revealed
|
|
12
|
+
* either way. Use it for side effects such as analytics.
|
|
13
|
+
*/
|
|
14
|
+
onClick?: (parent: TParent) => void;
|
|
15
|
+
href?: never;
|
|
16
|
+
} | {
|
|
17
|
+
/**
|
|
18
|
+
* Passed straight through to `IShowMoreOptions.href`. In this mode "+N more" navigates
|
|
19
|
+
* instead of revealing in place, so the hook keeps no reveal state and `onCollapse`
|
|
20
|
+
* does nothing.
|
|
21
|
+
*/
|
|
22
|
+
href: (parent: TParent) => string;
|
|
23
|
+
onClick?: never;
|
|
24
|
+
});
|
|
25
|
+
/**
|
|
26
|
+
* Builds `NestedData`'s `showMore` option so consumers don't hand-roll the reveal state.
|
|
27
|
+
*
|
|
28
|
+
* Without `href`, this owns the "click +N more to reveal the rest in place" pattern: it tracks
|
|
29
|
+
* which parents have been revealed and derives `isUncapped` and `onClick` from that. Call the
|
|
30
|
+
* returned `onCollapse(parentId)` from your own `onExpand` when a parent collapses, so
|
|
31
|
+
* re-expanding it shows the capped view again instead of staying revealed.
|
|
32
|
+
*
|
|
33
|
+
* With `href`, the config is passed straight through and no reveal state exists.
|
|
34
|
+
*
|
|
35
|
+
* The returned `showMore` is referentially stable across renders - config callbacks are read
|
|
36
|
+
* through a ref, so passing an inline config object does not produce a new `showMore` each render.
|
|
37
|
+
*/
|
|
38
|
+
export declare const useShowMore: <TParent extends IEntityWithId>(config?: IUseShowMoreConfig<TParent>) => {
|
|
39
|
+
showMore: IShowMoreOptions<TParent>;
|
|
40
|
+
onCollapse: (parentId: string) => void;
|
|
41
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useShowMore = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
/**
|
|
6
|
+
* Builds `NestedData`'s `showMore` option so consumers don't hand-roll the reveal state.
|
|
7
|
+
*
|
|
8
|
+
* Without `href`, this owns the "click +N more to reveal the rest in place" pattern: it tracks
|
|
9
|
+
* which parents have been revealed and derives `isUncapped` and `onClick` from that. Call the
|
|
10
|
+
* returned `onCollapse(parentId)` from your own `onExpand` when a parent collapses, so
|
|
11
|
+
* re-expanding it shows the capped view again instead of staying revealed.
|
|
12
|
+
*
|
|
13
|
+
* With `href`, the config is passed straight through and no reveal state exists.
|
|
14
|
+
*
|
|
15
|
+
* The returned `showMore` is referentially stable across renders - config callbacks are read
|
|
16
|
+
* through a ref, so passing an inline config object does not produce a new `showMore` each render.
|
|
17
|
+
*/
|
|
18
|
+
const useShowMore = (config) => {
|
|
19
|
+
const [revealedParents, setRevealedParents] = (0, react_1.useState)(new Set());
|
|
20
|
+
// Latest-ref so an inline config object - the common call shape - doesn't change `showMore`'s
|
|
21
|
+
// identity every render. Written during render because `href` is read while NestedData
|
|
22
|
+
// renders, so an effect-updated ref would be a render stale on first paint.
|
|
23
|
+
const configRef = (0, react_1.useRef)(config);
|
|
24
|
+
configRef.current = config;
|
|
25
|
+
const cap = config === null || config === void 0 ? void 0 : config.cap;
|
|
26
|
+
const hasLabel = !!(config === null || config === void 0 ? void 0 : config.label);
|
|
27
|
+
const hasHref = !!(config && "href" in config && config.href);
|
|
28
|
+
const showMore = (0, react_1.useMemo)(() => {
|
|
29
|
+
const label = hasLabel ? (remaining) => { var _a, _b; return (_b = (_a = configRef.current) === null || _a === void 0 ? void 0 : _a.label) === null || _b === void 0 ? void 0 : _b.call(_a, remaining); } : undefined;
|
|
30
|
+
if (hasHref) {
|
|
31
|
+
return { cap, label, href: (parent) => configRef.current.href(parent) };
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
cap,
|
|
35
|
+
label,
|
|
36
|
+
isUncapped: (parent) => revealedParents.has(parent.id),
|
|
37
|
+
onClick: (parent) => {
|
|
38
|
+
var _a, _b;
|
|
39
|
+
setRevealedParents(prev => (prev.has(parent.id) ? prev : new Set(prev).add(parent.id)));
|
|
40
|
+
(_b = (_a = configRef.current) === null || _a === void 0 ? void 0 : _a.onClick) === null || _b === void 0 ? void 0 : _b.call(_a, parent);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}, [revealedParents, cap, hasLabel, hasHref]);
|
|
44
|
+
const onCollapse = (0, react_1.useCallback)((parentId) => {
|
|
45
|
+
setRevealedParents(prev => {
|
|
46
|
+
if (!prev.has(parentId)) {
|
|
47
|
+
return prev;
|
|
48
|
+
}
|
|
49
|
+
const next = new Set(prev);
|
|
50
|
+
next.delete(parentId);
|
|
51
|
+
return next;
|
|
52
|
+
});
|
|
53
|
+
}, []);
|
|
54
|
+
return { showMore, onCollapse };
|
|
55
|
+
};
|
|
56
|
+
exports.useShowMore = useShowMore;
|
|
@@ -5,6 +5,23 @@ export declare enum SelectionState {
|
|
|
5
5
|
None = "none"
|
|
6
6
|
}
|
|
7
7
|
export interface ISelectionValue {
|
|
8
|
+
/**
|
|
9
|
+
* Whether every selectable row across every page is selected.
|
|
10
|
+
*/
|
|
8
11
|
all: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Included IDs by default. With `ISelectableRowsOptions.allowExclusions: true`,
|
|
14
|
+
* these are excluded IDs while `all` is true, and included IDs while `all` is false.
|
|
15
|
+
* Consumers opting in must resolve the effective selection before running bulk actions.
|
|
16
|
+
*/
|
|
9
17
|
selected: string[];
|
|
10
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* One checkbox row in the order it is rendered. Expanded nested rows are part of this list,
|
|
21
|
+
* directly after their parent, so a drag or shift-click range can span nesting levels the
|
|
22
|
+
* same way it spans sibling rows.
|
|
23
|
+
*/
|
|
24
|
+
export interface IDragSelectionRow {
|
|
25
|
+
id: string;
|
|
26
|
+
isNested: boolean;
|
|
27
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MouseEvent as ReactMouseEvent, RefObject } from "react";
|
|
2
|
+
import { IDragSelectionRow } from "./interfaces";
|
|
3
|
+
/**
|
|
4
|
+
* @param rows every checkbox row in render order, expanded nested rows included, so ranges can
|
|
5
|
+
* span nesting levels.
|
|
6
|
+
*/
|
|
7
|
+
export declare const useDragSelection: (rows: IDragSelectionRow[], gridRef: RefObject<HTMLElement | null> | undefined, onBatchSelect: (rangeIds: string[], select: boolean, base: Set<string>) => void, getBaseSelection: () => Set<string>, isSelectable: (row: IDragSelectionRow) => boolean, isEnabled: boolean) => {
|
|
8
|
+
onCheckboxMouseDown: (id: string, checked: boolean, e: ReactMouseEvent) => void;
|
|
9
|
+
suppressNextChangeRef: RefObject<boolean>;
|
|
10
|
+
};
|