@salesforce/design-system-react 11.0.0-alpha.7 → 11.0.0-alpha.9
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/dist/cjs/components/accordion/index.cjs +1 -1
- package/dist/cjs/components/accordion/index.cjs.map +1 -1
- package/dist/cjs/components/alert/container.cjs +1 -1
- package/dist/cjs/components/alert/container.cjs.map +1 -1
- package/dist/cjs/components/avatar/index.cjs +1 -1
- package/dist/cjs/components/avatar/index.cjs.map +1 -1
- package/dist/cjs/components/button-stateful/check-props.cjs +2 -0
- package/dist/cjs/components/button-stateful/check-props.cjs.map +1 -0
- package/dist/cjs/components/button-stateful/component.cjs +2 -0
- package/dist/cjs/components/button-stateful/component.cjs.map +1 -0
- package/dist/cjs/components/button-stateful/index.cjs +1 -1
- package/dist/cjs/components/button-stateful/index.cjs.map +1 -1
- package/dist/cjs/components/carousel/index.cjs +1 -1
- package/dist/cjs/components/carousel/index.cjs.map +1 -1
- package/dist/cjs/components/checkbox/check-props.cjs +1 -1
- package/dist/cjs/components/checkbox/check-props.cjs.map +1 -1
- package/dist/cjs/components/checkbox/index.cjs +1 -1
- package/dist/cjs/components/checkbox/index.cjs.map +1 -1
- package/dist/cjs/components/color-picker/check-props.cjs +1 -1
- package/dist/cjs/components/color-picker/check-props.cjs.map +1 -1
- package/dist/cjs/components/color-picker/color-picker.cjs +1 -1
- package/dist/cjs/components/color-picker/color-picker.cjs.map +1 -1
- package/dist/cjs/components/color-picker/private/color-picker-tabs.cjs +2 -0
- package/dist/cjs/components/color-picker/private/color-picker-tabs.cjs.map +1 -0
- package/dist/cjs/components/color-picker/private/hsv-color.cjs +1 -1
- package/dist/cjs/components/color-picker/private/hsv-color.cjs.map +1 -1
- package/dist/cjs/components/combobox/check-props.cjs +1 -1
- package/dist/cjs/components/combobox/check-props.cjs.map +1 -1
- package/dist/cjs/components/combobox/combobox.cjs +1 -1
- package/dist/cjs/components/combobox/combobox.cjs.map +1 -1
- package/dist/cjs/components/combobox/index.cjs +1 -1
- package/dist/cjs/components/date-picker/check-props.cjs +1 -1
- package/dist/cjs/components/date-picker/check-props.cjs.map +1 -1
- package/dist/cjs/components/date-picker/date-picker.cjs +1 -1
- package/dist/cjs/components/date-picker/date-picker.cjs.map +1 -1
- package/dist/cjs/components/date-picker/index.cjs.map +1 -1
- package/dist/cjs/components/date-picker/private/calendar-wrapper.cjs.map +1 -1
- package/dist/cjs/components/expandable-section/index.cjs +1 -1
- package/dist/cjs/components/expandable-section/index.cjs.map +1 -1
- package/dist/cjs/components/filter/filter.cjs +1 -1
- package/dist/cjs/components/filter/filter.cjs.map +1 -1
- package/dist/cjs/components/icon/input-icon/index.cjs +1 -1
- package/dist/cjs/components/icon/input-icon/index.cjs.map +1 -1
- package/dist/cjs/components/index.cjs +1 -1
- package/dist/cjs/components/input/check-props.cjs +1 -1
- package/dist/cjs/components/input/check-props.cjs.map +1 -1
- package/dist/cjs/components/input/index.cjs +1 -1
- package/dist/cjs/components/input/index.cjs.map +1 -1
- package/dist/cjs/components/input/private/inner-input.cjs +1 -1
- package/dist/cjs/components/input/private/inner-input.cjs.map +1 -1
- package/dist/cjs/components/menu-dropdown/button-trigger.cjs +1 -1
- package/dist/cjs/components/menu-dropdown/button-trigger.cjs.map +1 -1
- package/dist/cjs/components/menu-dropdown/index.cjs.map +1 -1
- package/dist/cjs/components/menu-dropdown/menu-dropdown.cjs +1 -1
- package/dist/cjs/components/menu-dropdown/menu-dropdown.cjs.map +1 -1
- package/dist/cjs/components/modal/check-props.cjs +2 -0
- package/dist/cjs/components/modal/check-props.cjs.map +1 -0
- package/dist/cjs/components/modal/component.cjs +2 -0
- package/dist/cjs/components/modal/component.cjs.map +1 -0
- package/dist/cjs/components/modal/index.cjs +1 -1
- package/dist/cjs/components/modal/index.cjs.map +1 -1
- package/dist/cjs/components/popover/component.cjs +2 -0
- package/dist/cjs/components/popover/component.cjs.map +1 -0
- package/dist/cjs/components/popover/edit-dialog.cjs +1 -1
- package/dist/cjs/components/popover/edit-dialog.cjs.map +1 -1
- package/dist/cjs/components/popover/index.cjs.map +1 -1
- package/dist/cjs/components/popover/popover.cjs +1 -1
- package/dist/cjs/components/popover/popover.cjs.map +1 -1
- package/dist/cjs/components/radio/check-props.cjs +1 -1
- package/dist/cjs/components/radio/check-props.cjs.map +1 -1
- package/dist/cjs/components/radio/index.cjs +1 -1
- package/dist/cjs/components/radio/index.cjs.map +1 -1
- package/dist/cjs/components/radio-button-group/index.cjs.map +1 -1
- package/dist/cjs/components/radio-button-group/radio.cjs.map +1 -1
- package/dist/cjs/components/radio-group/check-props.cjs +2 -0
- package/dist/cjs/components/radio-group/check-props.cjs.map +1 -0
- package/dist/cjs/components/radio-group/component.cjs +2 -0
- package/dist/cjs/components/radio-group/component.cjs.map +1 -0
- package/dist/cjs/components/radio-group/index.cjs +1 -1
- package/dist/cjs/components/radio-group/index.cjs.map +1 -1
- package/dist/cjs/components/setup-assistant/step.cjs +1 -1
- package/dist/cjs/components/setup-assistant/step.cjs.map +1 -1
- package/dist/cjs/components/simple-data-table/check-props.cjs +1 -1
- package/dist/cjs/components/simple-data-table/check-props.cjs.map +1 -1
- package/dist/cjs/components/simple-data-table/column.cjs.map +1 -1
- package/dist/cjs/components/simple-data-table/index.cjs +1 -1
- package/dist/cjs/components/simple-data-table/index.cjs.map +1 -1
- package/dist/cjs/components/simple-data-table/private/head.cjs +1 -1
- package/dist/cjs/components/simple-data-table/private/head.cjs.map +1 -1
- package/dist/cjs/components/simple-data-table/private/header-cell.cjs +1 -1
- package/dist/cjs/components/simple-data-table/private/header-cell.cjs.map +1 -1
- package/dist/cjs/components/simple-data-table/private/row.cjs +1 -1
- package/dist/cjs/components/simple-data-table/private/row.cjs.map +1 -1
- package/dist/cjs/components/slider/check-props.cjs +1 -1
- package/dist/cjs/components/slider/check-props.cjs.map +1 -1
- package/dist/cjs/components/slider/index.cjs +1 -1
- package/dist/cjs/components/slider/index.cjs.map +1 -1
- package/dist/cjs/components/spinner/check-props.cjs +2 -0
- package/dist/cjs/components/spinner/check-props.cjs.map +1 -0
- package/dist/cjs/components/spinner/component.cjs +2 -0
- package/dist/cjs/components/spinner/component.cjs.map +1 -0
- package/dist/cjs/components/spinner/index.cjs +1 -1
- package/dist/cjs/components/spinner/index.cjs.map +1 -1
- package/dist/cjs/components/split-view/index.cjs +1 -1
- package/dist/cjs/components/split-view/index.cjs.map +1 -1
- package/dist/cjs/components/split-view/listbox-check-props.cjs +1 -1
- package/dist/cjs/components/split-view/listbox-check-props.cjs.map +1 -1
- package/dist/cjs/components/split-view/listbox.cjs +1 -1
- package/dist/cjs/components/split-view/listbox.cjs.map +1 -1
- package/dist/cjs/components/tabs/check-props.cjs +2 -0
- package/dist/cjs/components/tabs/check-props.cjs.map +1 -0
- package/dist/cjs/components/tabs/component.cjs +2 -0
- package/dist/cjs/components/tabs/component.cjs.map +1 -0
- package/dist/cjs/components/tabs/index.cjs +1 -1
- package/dist/cjs/components/tabs/index.cjs.map +1 -1
- package/dist/cjs/components/tabs/panel.cjs.map +1 -1
- package/dist/cjs/components/textarea/check-props.cjs +1 -1
- package/dist/cjs/components/textarea/check-props.cjs.map +1 -1
- package/dist/cjs/components/textarea/index.cjs +1 -1
- package/dist/cjs/components/textarea/index.cjs.map +1 -1
- package/dist/cjs/components/toast/container.cjs +1 -1
- package/dist/cjs/components/toast/container.cjs.map +1 -1
- package/dist/cjs/components/tooltip/index.cjs +2 -2
- package/dist/cjs/components/tooltip/index.cjs.map +1 -1
- package/dist/cjs/components/tree/check-props.cjs +1 -1
- package/dist/cjs/components/tree/check-props.cjs.map +1 -1
- package/dist/cjs/components/tree/private/branch.cjs +1 -1
- package/dist/cjs/components/tree/private/branch.cjs.map +1 -1
- package/dist/cjs/components/tree/private/item.cjs +1 -1
- package/dist/cjs/components/tree/private/item.cjs.map +1 -1
- package/dist/cjs/components/tree/private/render-branch.cjs +1 -1
- package/dist/cjs/components/tree/private/render-branch.cjs.map +1 -1
- package/dist/cjs/components/tree/tree.cjs +1 -1
- package/dist/cjs/components/tree/tree.cjs.map +1 -1
- package/dist/cjs/components/vertical-navigation/check-props.cjs +2 -0
- package/dist/cjs/components/vertical-navigation/check-props.cjs.map +1 -0
- package/dist/cjs/components/vertical-navigation/component.cjs +2 -0
- package/dist/cjs/components/vertical-navigation/component.cjs.map +1 -0
- package/dist/cjs/components/vertical-navigation/index.cjs +1 -1
- package/dist/cjs/components/vertical-navigation/index.cjs.map +1 -1
- package/dist/cjs/components/welcome-mat/index.cjs +1 -1
- package/dist/cjs/components/welcome-mat/index.cjs.map +1 -1
- package/dist/cjs/components/welcome-mat/info-badge.cjs +1 -1
- package/dist/cjs/components/welcome-mat/info-badge.cjs.map +1 -1
- package/dist/cjs/utilities/hooks/index.cjs +1 -1
- package/dist/cjs/utilities/hooks/use-controllable-state.cjs +2 -0
- package/dist/cjs/utilities/hooks/use-controllable-state.cjs.map +1 -0
- package/dist/cjs/utilities/warning/required-property.cjs +2 -0
- package/dist/cjs/utilities/warning/required-property.cjs.map +1 -0
- package/dist/es/components/accordion/index.js +10 -8
- package/dist/es/components/accordion/index.js.map +1 -1
- package/dist/es/components/alert/container.js +1 -1
- package/dist/es/components/alert/container.js.map +1 -1
- package/dist/es/components/avatar/index.js +2 -1
- package/dist/es/components/avatar/index.js.map +1 -1
- package/dist/es/components/button-stateful/check-props.js +14 -0
- package/dist/es/components/button-stateful/check-props.js.map +1 -0
- package/dist/es/components/button-stateful/component.js +20 -0
- package/dist/es/components/button-stateful/component.js.map +1 -0
- package/dist/es/components/button-stateful/index.js +102 -94
- package/dist/es/components/button-stateful/index.js.map +1 -1
- package/dist/es/components/carousel/index.js +112 -130
- package/dist/es/components/carousel/index.js.map +1 -1
- package/dist/es/components/checkbox/check-props.js +14 -8
- package/dist/es/components/checkbox/check-props.js.map +1 -1
- package/dist/es/components/checkbox/index.js +40 -33
- package/dist/es/components/checkbox/index.js.map +1 -1
- package/dist/es/components/color-picker/check-props.js +16 -11
- package/dist/es/components/color-picker/check-props.js.map +1 -1
- package/dist/es/components/color-picker/color-picker.js +185 -169
- package/dist/es/components/color-picker/color-picker.js.map +1 -1
- package/dist/es/components/color-picker/private/color-picker-tabs.js +17 -0
- package/dist/es/components/color-picker/private/color-picker-tabs.js.map +1 -0
- package/dist/es/components/color-picker/private/hsv-color.js +1 -0
- package/dist/es/components/color-picker/private/hsv-color.js.map +1 -1
- package/dist/es/components/combobox/check-props.js +15 -14
- package/dist/es/components/combobox/check-props.js.map +1 -1
- package/dist/es/components/combobox/combobox.js +401 -401
- package/dist/es/components/combobox/combobox.js.map +1 -1
- package/dist/es/components/combobox/index.js +4 -4
- package/dist/es/components/date-picker/check-props.js +15 -9
- package/dist/es/components/date-picker/check-props.js.map +1 -1
- package/dist/es/components/date-picker/date-picker.js +144 -138
- package/dist/es/components/date-picker/date-picker.js.map +1 -1
- package/dist/es/components/date-picker/index.js.map +1 -1
- package/dist/es/components/date-picker/private/calendar-wrapper.js.map +1 -1
- package/dist/es/components/expandable-section/index.js +32 -26
- package/dist/es/components/expandable-section/index.js.map +1 -1
- package/dist/es/components/filter/filter.js +1 -1
- package/dist/es/components/filter/filter.js.map +1 -1
- package/dist/es/components/icon/input-icon/index.js +7 -2
- package/dist/es/components/icon/input-icon/index.js.map +1 -1
- package/dist/es/components/index.js +3 -3
- package/dist/es/components/input/check-props.js +19 -17
- package/dist/es/components/input/check-props.js.map +1 -1
- package/dist/es/components/input/index.js +153 -156
- package/dist/es/components/input/index.js.map +1 -1
- package/dist/es/components/input/private/inner-input.js +18 -18
- package/dist/es/components/input/private/inner-input.js.map +1 -1
- package/dist/es/components/menu-dropdown/button-trigger.js +7 -1
- package/dist/es/components/menu-dropdown/button-trigger.js.map +1 -1
- package/dist/es/components/menu-dropdown/index.js.map +1 -1
- package/dist/es/components/menu-dropdown/menu-dropdown.js +294 -269
- package/dist/es/components/menu-dropdown/menu-dropdown.js.map +1 -1
- package/dist/es/components/modal/check-props.js +22 -0
- package/dist/es/components/modal/check-props.js.map +1 -0
- package/dist/es/components/modal/component.js +35 -0
- package/dist/es/components/modal/component.js.map +1 -0
- package/dist/es/components/modal/index.js +118 -104
- package/dist/es/components/modal/index.js.map +1 -1
- package/dist/es/components/popover/component.js +59 -0
- package/dist/es/components/popover/component.js.map +1 -0
- package/dist/es/components/popover/edit-dialog.js +1 -1
- package/dist/es/components/popover/edit-dialog.js.map +1 -1
- package/dist/es/components/popover/index.js.map +1 -1
- package/dist/es/components/popover/popover.js +241 -193
- package/dist/es/components/popover/popover.js.map +1 -1
- package/dist/es/components/radio/check-props.js +8 -8
- package/dist/es/components/radio/check-props.js.map +1 -1
- package/dist/es/components/radio/index.js +15 -13
- package/dist/es/components/radio/index.js.map +1 -1
- package/dist/es/components/radio-button-group/index.js.map +1 -1
- package/dist/es/components/radio-button-group/radio.js.map +1 -1
- package/dist/es/components/radio-group/check-props.js +14 -0
- package/dist/es/components/radio-group/check-props.js.map +1 -0
- package/dist/es/components/radio-group/component.js +21 -0
- package/dist/es/components/radio-group/component.js.map +1 -0
- package/dist/es/components/radio-group/index.js +62 -38
- package/dist/es/components/radio-group/index.js.map +1 -1
- package/dist/es/components/setup-assistant/step.js +5 -4
- package/dist/es/components/setup-assistant/step.js.map +1 -1
- package/dist/es/components/simple-data-table/check-props.js +7 -6
- package/dist/es/components/simple-data-table/check-props.js.map +1 -1
- package/dist/es/components/simple-data-table/column.js.map +1 -1
- package/dist/es/components/simple-data-table/index.js +67 -49
- package/dist/es/components/simple-data-table/index.js.map +1 -1
- package/dist/es/components/simple-data-table/private/head.js +1 -1
- package/dist/es/components/simple-data-table/private/head.js.map +1 -1
- package/dist/es/components/simple-data-table/private/header-cell.js +50 -52
- package/dist/es/components/simple-data-table/private/header-cell.js.map +1 -1
- package/dist/es/components/simple-data-table/private/row.js +43 -57
- package/dist/es/components/simple-data-table/private/row.js.map +1 -1
- package/dist/es/components/slider/check-props.js +14 -12
- package/dist/es/components/slider/check-props.js.map +1 -1
- package/dist/es/components/slider/index.js +71 -62
- package/dist/es/components/slider/index.js.map +1 -1
- package/dist/es/components/spinner/check-props.js +13 -0
- package/dist/es/components/spinner/check-props.js.map +1 -0
- package/dist/es/components/spinner/component.js +17 -0
- package/dist/es/components/spinner/component.js.map +1 -0
- package/dist/es/components/spinner/index.js +43 -29
- package/dist/es/components/spinner/index.js.map +1 -1
- package/dist/es/components/split-view/index.js +23 -22
- package/dist/es/components/split-view/index.js.map +1 -1
- package/dist/es/components/split-view/listbox-check-props.js +10 -2
- package/dist/es/components/split-view/listbox-check-props.js.map +1 -1
- package/dist/es/components/split-view/listbox.js +67 -50
- package/dist/es/components/split-view/listbox.js.map +1 -1
- package/dist/es/components/tabs/check-props.js +15 -0
- package/dist/es/components/tabs/check-props.js.map +1 -0
- package/dist/es/components/tabs/component.js +28 -0
- package/dist/es/components/tabs/component.js.map +1 -0
- package/dist/es/components/tabs/index.js +84 -69
- package/dist/es/components/tabs/index.js.map +1 -1
- package/dist/es/components/tabs/panel.js.map +1 -1
- package/dist/es/components/textarea/check-props.js +1 -1
- package/dist/es/components/textarea/check-props.js.map +1 -1
- package/dist/es/components/textarea/index.js +3 -2
- package/dist/es/components/textarea/index.js.map +1 -1
- package/dist/es/components/toast/container.js +1 -1
- package/dist/es/components/toast/container.js.map +1 -1
- package/dist/es/components/tooltip/index.js +120 -109
- package/dist/es/components/tooltip/index.js.map +1 -1
- package/dist/es/components/tree/check-props.js +14 -9
- package/dist/es/components/tree/check-props.js.map +1 -1
- package/dist/es/components/tree/private/branch.js +38 -35
- package/dist/es/components/tree/private/branch.js.map +1 -1
- package/dist/es/components/tree/private/item.js +6 -8
- package/dist/es/components/tree/private/item.js.map +1 -1
- package/dist/es/components/tree/private/render-branch.js +9 -10
- package/dist/es/components/tree/private/render-branch.js.map +1 -1
- package/dist/es/components/tree/tree.js +128 -93
- package/dist/es/components/tree/tree.js.map +1 -1
- package/dist/es/components/vertical-navigation/check-props.js +13 -0
- package/dist/es/components/vertical-navigation/check-props.js.map +1 -0
- package/dist/es/components/vertical-navigation/component.js +27 -0
- package/dist/es/components/vertical-navigation/component.js.map +1 -0
- package/dist/es/components/vertical-navigation/index.js +28 -26
- package/dist/es/components/vertical-navigation/index.js.map +1 -1
- package/dist/es/components/welcome-mat/index.js +51 -50
- package/dist/es/components/welcome-mat/index.js.map +1 -1
- package/dist/es/components/welcome-mat/info-badge.js +14 -4
- package/dist/es/components/welcome-mat/info-badge.js.map +1 -1
- package/dist/es/utilities/hooks/index.js +2 -1
- package/dist/es/utilities/hooks/use-controllable-state.js +20 -0
- package/dist/es/utilities/hooks/use-controllable-state.js.map +1 -0
- package/dist/es/utilities/warning/required-property.js +15 -0
- package/dist/es/utilities/warning/required-property.js.map +1 -0
- package/dist/types/components/accordion/index.d.ts.map +1 -1
- package/dist/types/components/avatar/index.d.ts.map +1 -1
- package/dist/types/components/button-stateful/check-props.d.ts +3 -0
- package/dist/types/components/button-stateful/check-props.d.ts.map +1 -0
- package/dist/types/components/button-stateful/index.d.ts +34 -6
- package/dist/types/components/button-stateful/index.d.ts.map +1 -1
- package/dist/types/components/carousel/index.d.ts +26 -7
- package/dist/types/components/carousel/index.d.ts.map +1 -1
- package/dist/types/components/checkbox/check-props.d.ts +1 -0
- package/dist/types/components/checkbox/check-props.d.ts.map +1 -1
- package/dist/types/components/checkbox/index.d.ts +38 -9
- package/dist/types/components/checkbox/index.d.ts.map +1 -1
- package/dist/types/components/color-picker/check-props.d.ts.map +1 -1
- package/dist/types/components/color-picker/color-picker.d.ts +50 -11
- package/dist/types/components/color-picker/color-picker.d.ts.map +1 -1
- package/dist/types/components/color-picker/index.d.ts +2 -2
- package/dist/types/components/color-picker/index.d.ts.map +1 -1
- package/dist/types/components/color-picker/private/color-picker-tabs.d.ts +14 -0
- package/dist/types/components/color-picker/private/color-picker-tabs.d.ts.map +1 -0
- package/dist/types/components/color-picker/private/hsv-color.d.ts.map +1 -1
- package/dist/types/components/color-picker/types.d.ts +9 -5
- package/dist/types/components/color-picker/types.d.ts.map +1 -1
- package/dist/types/components/combobox/check-props.d.ts.map +1 -1
- package/dist/types/components/combobox/combobox.d.ts +41 -6
- package/dist/types/components/combobox/combobox.d.ts.map +1 -1
- package/dist/types/components/date-picker/check-props.d.ts.map +1 -1
- package/dist/types/components/date-picker/date-picker.d.ts +52 -17
- package/dist/types/components/date-picker/date-picker.d.ts.map +1 -1
- package/dist/types/components/date-picker/index.d.ts +1 -1
- package/dist/types/components/date-picker/index.d.ts.map +1 -1
- package/dist/types/components/date-picker/private/calendar-wrapper.d.ts +3 -1
- package/dist/types/components/date-picker/private/calendar-wrapper.d.ts.map +1 -1
- package/dist/types/components/expandable-section/index.d.ts +15 -3
- package/dist/types/components/expandable-section/index.d.ts.map +1 -1
- package/dist/types/components/icon/input-icon/index.d.ts.map +1 -1
- package/dist/types/components/input/check-props.d.ts.map +1 -1
- package/dist/types/components/input/index.d.ts +10 -4
- package/dist/types/components/input/index.d.ts.map +1 -1
- package/dist/types/components/input/private/inner-input.d.ts +2 -4
- package/dist/types/components/input/private/inner-input.d.ts.map +1 -1
- package/dist/types/components/menu-dropdown/button-trigger.d.ts.map +1 -1
- package/dist/types/components/menu-dropdown/index.d.ts +1 -1
- package/dist/types/components/menu-dropdown/index.d.ts.map +1 -1
- package/dist/types/components/menu-dropdown/menu-dropdown.d.ts +78 -15
- package/dist/types/components/menu-dropdown/menu-dropdown.d.ts.map +1 -1
- package/dist/types/components/modal/check-props.d.ts +3 -0
- package/dist/types/components/modal/check-props.d.ts.map +1 -0
- package/dist/types/components/modal/index.d.ts +21 -13
- package/dist/types/components/modal/index.d.ts.map +1 -1
- package/dist/types/components/popover/index.d.ts +1 -1
- package/dist/types/components/popover/index.d.ts.map +1 -1
- package/dist/types/components/popover/popover.d.ts +54 -17
- package/dist/types/components/popover/popover.d.ts.map +1 -1
- package/dist/types/components/radio/check-props.d.ts.map +1 -1
- package/dist/types/components/radio/index.d.ts +42 -9
- package/dist/types/components/radio/index.d.ts.map +1 -1
- package/dist/types/components/radio-button-group/index.d.ts +20 -10
- package/dist/types/components/radio-button-group/index.d.ts.map +1 -1
- package/dist/types/components/radio-button-group/radio.d.ts +7 -2
- package/dist/types/components/radio-button-group/radio.d.ts.map +1 -1
- package/dist/types/components/radio-group/check-props.d.ts +3 -0
- package/dist/types/components/radio-group/check-props.d.ts.map +1 -0
- package/dist/types/components/radio-group/index.d.ts +51 -8
- package/dist/types/components/radio-group/index.d.ts.map +1 -1
- package/dist/types/components/radio-group/radio.d.ts +7 -2
- package/dist/types/components/radio-group/radio.d.ts.map +1 -1
- package/dist/types/components/setup-assistant/step.d.ts +10 -2
- package/dist/types/components/setup-assistant/step.d.ts.map +1 -1
- package/dist/types/components/simple-data-table/check-props.d.ts.map +1 -1
- package/dist/types/components/simple-data-table/column.d.ts +4 -1
- package/dist/types/components/simple-data-table/column.d.ts.map +1 -1
- package/dist/types/components/simple-data-table/index.d.ts +10 -2
- package/dist/types/components/simple-data-table/index.d.ts.map +1 -1
- package/dist/types/components/simple-data-table/private/header-cell.d.ts.map +1 -1
- package/dist/types/components/simple-data-table/private/row.d.ts +4 -2
- package/dist/types/components/simple-data-table/private/row.d.ts.map +1 -1
- package/dist/types/components/simple-data-table/types.d.ts +40 -13
- package/dist/types/components/simple-data-table/types.d.ts.map +1 -1
- package/dist/types/components/slider/check-props.d.ts.map +1 -1
- package/dist/types/components/slider/index.d.ts +32 -17
- package/dist/types/components/slider/index.d.ts.map +1 -1
- package/dist/types/components/spinner/check-props.d.ts +3 -0
- package/dist/types/components/spinner/check-props.d.ts.map +1 -0
- package/dist/types/components/spinner/index.d.ts +18 -9
- package/dist/types/components/spinner/index.d.ts.map +1 -1
- package/dist/types/components/split-view/index.d.ts +12 -3
- package/dist/types/components/split-view/index.d.ts.map +1 -1
- package/dist/types/components/split-view/listbox-check-props.d.ts +1 -0
- package/dist/types/components/split-view/listbox-check-props.d.ts.map +1 -1
- package/dist/types/components/split-view/listbox.d.ts +41 -10
- package/dist/types/components/split-view/listbox.d.ts.map +1 -1
- package/dist/types/components/tabs/check-props.d.ts +3 -0
- package/dist/types/components/tabs/check-props.d.ts.map +1 -0
- package/dist/types/components/tabs/index.d.ts +46 -12
- package/dist/types/components/tabs/index.d.ts.map +1 -1
- package/dist/types/components/tabs/panel.d.ts +4 -0
- package/dist/types/components/tabs/panel.d.ts.map +1 -1
- package/dist/types/components/textarea/check-props.d.ts.map +1 -1
- package/dist/types/components/textarea/index.d.ts +14 -6
- package/dist/types/components/textarea/index.d.ts.map +1 -1
- package/dist/types/components/toast/container.d.ts +1 -1
- package/dist/types/components/tooltip/index.d.ts +49 -3
- package/dist/types/components/tooltip/index.d.ts.map +1 -1
- package/dist/types/components/tree/check-props.d.ts +1 -0
- package/dist/types/components/tree/check-props.d.ts.map +1 -1
- package/dist/types/components/tree/private/branch.d.ts +6 -1
- package/dist/types/components/tree/private/branch.d.ts.map +1 -1
- package/dist/types/components/tree/private/item.d.ts +3 -1
- package/dist/types/components/tree/private/item.d.ts.map +1 -1
- package/dist/types/components/tree/private/render-branch.d.ts +3 -1
- package/dist/types/components/tree/private/render-branch.d.ts.map +1 -1
- package/dist/types/components/tree/tree.d.ts +41 -10
- package/dist/types/components/tree/tree.d.ts.map +1 -1
- package/dist/types/components/tree/types.d.ts +23 -4
- package/dist/types/components/tree/types.d.ts.map +1 -1
- package/dist/types/components/vertical-navigation/check-props.d.ts +1 -0
- package/dist/types/components/vertical-navigation/check-props.d.ts.map +1 -1
- package/dist/types/components/vertical-navigation/index.d.ts +16 -11
- package/dist/types/components/vertical-navigation/index.d.ts.map +1 -1
- package/dist/types/components/welcome-mat/index.d.ts +5 -6
- package/dist/types/components/welcome-mat/index.d.ts.map +1 -1
- package/dist/types/components/welcome-mat/info-badge.d.ts.map +1 -1
- package/dist/types/types/components.d.ts +0 -2
- package/dist/types/types/components.d.ts.map +1 -1
- package/dist/types/utilities/hooks/index.d.ts +1 -0
- package/dist/types/utilities/hooks/index.d.ts.map +1 -1
- package/dist/types/utilities/hooks/use-controllable-state.d.ts +23 -0
- package/dist/types/utilities/hooks/use-controllable-state.d.ts.map +1 -0
- package/dist/types/utilities/warning/required-property.d.ts +3 -0
- package/dist/types/utilities/warning/required-property.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -15,7 +15,7 @@ var d = ({ event: e, props: n, fromFocus: r }) => {
|
|
|
15
15
|
event: e,
|
|
16
16
|
data: {
|
|
17
17
|
node: n.node,
|
|
18
|
-
select: !n.node
|
|
18
|
+
select: !n.isNodeSelected(n.node),
|
|
19
19
|
treeIndex: n.treeIndex
|
|
20
20
|
},
|
|
21
21
|
fromFocus: r
|
|
@@ -59,7 +59,7 @@ var d = ({ event: e, props: n, fromFocus: r }) => {
|
|
|
59
59
|
data: {
|
|
60
60
|
node: r,
|
|
61
61
|
select: !0,
|
|
62
|
-
expand: !r
|
|
62
|
+
expand: !t.isNodeExpanded(r),
|
|
63
63
|
treeIndex: t.flattenedNodes[i].treeIndex
|
|
64
64
|
}
|
|
65
65
|
});
|
|
@@ -80,11 +80,8 @@ var d = ({ event: e, props: n, fromFocus: r }) => {
|
|
|
80
80
|
event: e,
|
|
81
81
|
props: t
|
|
82
82
|
});
|
|
83
|
-
}, b = (e) => {
|
|
84
|
-
let t = e.
|
|
85
|
-
return e.treeIndex === e.focusedNodeIndex || t ? 0 : -1;
|
|
86
|
-
}, x = (e) => {
|
|
87
|
-
let t = e.node.selected, n = e.treeIndex === e.focusedNodeIndex;
|
|
83
|
+
}, b = (e) => e.treeIndex === e.tabStopIndex ? 0 : -1, x = (e) => {
|
|
84
|
+
let t = e.isNodeSelected(e.node), n = e.treeIndex === e.focusedNodeIndex;
|
|
88
85
|
return /* @__PURE__ */ s("li", {
|
|
89
86
|
id: `${e.treeId}-${e.node.id}`,
|
|
90
87
|
role: "treeitem",
|
|
@@ -104,13 +101,14 @@ var d = ({ event: e, props: n, fromFocus: r }) => {
|
|
|
104
101
|
props: e
|
|
105
102
|
}),
|
|
106
103
|
children: [/* @__PURE__ */ s(r, {
|
|
104
|
+
"aria-hidden": !0,
|
|
107
105
|
tabIndex: -1,
|
|
108
106
|
assistiveText: { icon: "" },
|
|
109
107
|
iconCategory: "utility",
|
|
110
108
|
iconName: "chevronright",
|
|
111
109
|
iconSize: "small",
|
|
112
110
|
variant: "icon",
|
|
113
|
-
className: "slds-m-right_small slds-is-disabled",
|
|
111
|
+
className: "slds-m-right_small slds-is-disabled slds-hidden",
|
|
114
112
|
disabled: !0
|
|
115
113
|
}), /* @__PURE__ */ s("span", {
|
|
116
114
|
className: "slds-size_1-of-1",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item.js","names":[],"sources":["../../../../../components/tree/private/item.tsx"],"sourcesContent":["/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\nimport React, { ReactNode } from 'react';\nimport classNames from 'classnames';\nimport findIndex from 'lodash.findindex';\nimport isFunction from 'lodash.isfunction';\n\nimport Button from '../../button';\nimport Highlighter from '../../utilities/highlighter';\n\nimport EventUtil from '../../../utilities/event';\nimport KEYS from '../../../utilities/key-code';\nimport mapKeyEventCallbacks from '../../../utilities/key-callbacks';\nimport { TREE_ITEM } from '../../../utilities/constants';\nimport { TreeNode, FlattenedNode } from '../types';\n\nexport interface ItemProps {\n\thtmlId: string;\n\tlabel: ReactNode | string;\n\tlevel: number;\n\tnode: TreeNode;\n\tonExpand: (params: {\n\t\tevent: React.SyntheticEvent;\n\t\tdata: {\n\t\t\tnode: TreeNode;\n\t\t\tselect?: boolean;\n\t\t\texpand: boolean;\n\t\t\ttreeIndex: string;\n\t\t};\n\t}) => void;\n\tonSelect?: (params: {\n\t\tevent: React.SyntheticEvent;\n\t\tdata: {\n\t\t\tnode: TreeNode;\n\t\t\tselect: boolean;\n\t\t\ttreeIndex: string;\n\t\t};\n\t\tfromFocus?: boolean;\n\t\tclearSelectedNodes?: boolean;\n\t}) => void;\n\tsearchTerm?: string;\n\ttreeId?: string;\n\ttreeIndex: string;\n\tflattenedNodes: FlattenedNode[];\n\
|
|
1
|
+
{"version":3,"file":"item.js","names":[],"sources":["../../../../../components/tree/private/item.tsx"],"sourcesContent":["/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\nimport React, { ReactNode } from 'react';\nimport classNames from 'classnames';\nimport findIndex from 'lodash.findindex';\nimport isFunction from 'lodash.isfunction';\n\nimport Button from '../../button';\nimport Highlighter from '../../utilities/highlighter';\n\nimport EventUtil from '../../../utilities/event';\nimport KEYS from '../../../utilities/key-code';\nimport mapKeyEventCallbacks from '../../../utilities/key-callbacks';\nimport { TREE_ITEM } from '../../../utilities/constants';\nimport { TreeNode, FlattenedNode } from '../types';\n\nexport interface ItemProps {\n\thtmlId: string;\n\tlabel: ReactNode | string;\n\tlevel: number;\n\tnode: TreeNode;\n\tonExpand: (params: {\n\t\tevent: React.SyntheticEvent;\n\t\tdata: {\n\t\t\tnode: TreeNode;\n\t\t\tselect?: boolean;\n\t\t\texpand: boolean;\n\t\t\ttreeIndex: string;\n\t\t};\n\t}) => void;\n\tonSelect?: (params: {\n\t\tevent: React.SyntheticEvent;\n\t\tdata: {\n\t\t\tnode: TreeNode;\n\t\t\tselect: boolean;\n\t\t\ttreeIndex: string;\n\t\t};\n\t\tfromFocus?: boolean;\n\t\tclearSelectedNodes?: boolean;\n\t}) => void;\n\tsearchTerm?: string;\n\ttreeId?: string;\n\ttreeIndex: string;\n\tflattenedNodes: FlattenedNode[];\n\tisNodeSelected: (node: TreeNode) => boolean;\n\tisNodeExpanded: (node: TreeNode) => boolean;\n\ttabStopIndex?: string;\n\tfocusedNodeIndex?: string;\n\tonNodeBlur?: () => void;\n\ttreeHasFocus?: boolean;\n\tparent?: TreeNode | { nodes?: TreeNode[] };\n}\n\nconst handleSelect = ({\n\tevent,\n\tprops,\n\tfromFocus,\n}: {\n\tevent: React.SyntheticEvent;\n\tprops: ItemProps;\n\tfromFocus?: boolean;\n}) => {\n\tEventUtil.trap(event);\n\tif (isFunction(props.onSelect)) {\n\t\tprops.onSelect({\n\t\t\tevent,\n\t\t\tdata: {\n\t\t\t\tnode: props.node,\n\t\t\t\tselect: !props.isNodeSelected(props.node),\n\t\t\t\ttreeIndex: props.treeIndex,\n\t\t\t},\n\t\t\tfromFocus,\n\t\t});\n\t}\n};\n\nconst findNextNode = (flattenedNodes: FlattenedNode[], node: TreeNode) => {\n\tconst nodes = flattenedNodes.map((flattenedNode) => flattenedNode.node);\n\tconst index = findIndex(nodes, { id: node.id });\n\treturn flattenedNodes[(index + 1) % flattenedNodes.length];\n};\n\nconst findPreviousNode = (flattenedNodes: FlattenedNode[], node: TreeNode) => {\n\tconst nodes = flattenedNodes.map((flattenedNode) => flattenedNode.node);\n\tlet index = findIndex(nodes, { id: node.id }) - 1;\n\tif (index < 0) {\n\t\tindex += flattenedNodes.length;\n\t}\n\treturn flattenedNodes[index];\n};\n\nconst handleKeyDownDown = (event: React.KeyboardEvent, props: ItemProps) => {\n\tif (props.focusedNodeIndex === props.treeIndex) {\n\t\tconst flattenedNode = findNextNode(props.flattenedNodes, props.node);\n\t\tprops.onSelect?.({\n\t\t\tevent,\n\t\t\tdata: {\n\t\t\t\tnode: flattenedNode.node,\n\t\t\t\tselect: true,\n\t\t\t\ttreeIndex: flattenedNode.treeIndex,\n\t\t\t},\n\t\t\tclearSelectedNodes: true,\n\t\t});\n\t}\n};\n\nconst handleKeyDownUp = (event: React.KeyboardEvent, props: ItemProps) => {\n\tif (props.focusedNodeIndex === props.treeIndex) {\n\t\tconst flattenedNode = findPreviousNode(props.flattenedNodes, props.node);\n\t\tprops.onSelect?.({\n\t\t\tevent,\n\t\t\tdata: {\n\t\t\t\tnode: flattenedNode.node,\n\t\t\t\tselect: true,\n\t\t\t\ttreeIndex: flattenedNode.treeIndex,\n\t\t\t},\n\t\t\tclearSelectedNodes: true,\n\t\t});\n\t}\n};\n\nconst handleKeyDownLeft = (event: React.KeyboardEvent, props: ItemProps) => {\n\tconst nodes = props.flattenedNodes.map((flattenedNode) => flattenedNode.node);\n\tconst parent = props.parent as TreeNode;\n\tconst index = findIndex(nodes, { id: parent?.id });\n\tif (index !== -1) {\n\t\t// `select: true` marks a move to the parent node, not an expand/collapse request.\n\t\t// Tree routes it to `onSelect` (or to the deprecated `onExpandClick`).\n\t\tprops.onExpand({\n\t\t\tevent,\n\t\t\tdata: {\n\t\t\t\tnode: parent,\n\t\t\t\tselect: true,\n\t\t\t\texpand: !props.isNodeExpanded(parent),\n\t\t\t\ttreeIndex: props.flattenedNodes[index].treeIndex,\n\t\t\t},\n\t\t});\n\t}\n};\n\nconst handleKeyDownEnter = (event: React.KeyboardEvent, props: ItemProps) => {\n\thandleSelect({ event, props });\n};\n\nconst handleKeyDown = (event: React.KeyboardEvent, props: ItemProps) => {\n\tmapKeyEventCallbacks(event, {\n\t\tcallbacks: {\n\t\t\t[KEYS.DOWN]: {\n\t\t\t\tcallback: (evt: React.KeyboardEvent) => handleKeyDownDown(evt, props),\n\t\t\t},\n\t\t\t[KEYS.UP]: {\n\t\t\t\tcallback: (evt: React.KeyboardEvent) => handleKeyDownUp(evt, props),\n\t\t\t},\n\t\t\t[KEYS.LEFT]: {\n\t\t\t\tcallback: (evt: React.KeyboardEvent) => handleKeyDownLeft(evt, props),\n\t\t\t},\n\t\t\t[KEYS.ENTER]: {\n\t\t\t\tcallback: (evt: React.KeyboardEvent) => handleKeyDownEnter(evt, props),\n\t\t\t},\n\t\t},\n\t});\n};\n\nconst handleFocus = (event: React.FocusEvent, props: ItemProps) => {\n\tif (\n\t\t!props.treeHasFocus &&\n\t\t!props.focusedNodeIndex &&\n\t\tevent.target === event.currentTarget\n\t) {\n\t\thandleSelect({ event, props });\n\t}\n};\n\nconst getTabIndex = (props: ItemProps): number =>\n\tprops.treeIndex === props.tabStopIndex ? 0 : -1;\n\n/**\n * A Tree Item is a non-branching node in a hierarchical list.\n */\nconst Item: React.FC<ItemProps> = (props) => {\n\tconst isSelected = props.isNodeSelected(props.node);\n\tconst isFocused = props.treeIndex === props.focusedNodeIndex;\n\n\treturn (\n\t\t<li\n\t\t\tid={`${props.treeId}-${props.node.id}`}\n\t\t\trole=\"treeitem\"\n\t\t\taria-level={props.level}\n\t\t\taria-selected={isSelected ? 'true' : 'false'}\n\t\t\ttabIndex={getTabIndex(props)}\n\t\t\tonKeyDown={(event) => handleKeyDown(event, props)}\n\t\t\tonFocus={(event) => handleFocus(event, props)}\n\t\t\tonBlur={props.onNodeBlur}\n\t\t\tref={(component) => {\n\t\t\t\tif (props.treeHasFocus && component && isFocused) {\n\t\t\t\t\tcomponent.focus();\n\t\t\t\t}\n\t\t\t}}\n\t\t>\n\t\t\t<div\n\t\t\t\tclassName={classNames('slds-tree__item', {\n\t\t\t\t\t'slds-is-selected': isSelected,\n\t\t\t\t})}\n\t\t\t\tonClick={(event) => handleSelect({ event, props })}\n\t\t\t>\n\t\t\t\t<Button\n\t\t\t\t\taria-hidden\n\t\t\t\t\ttabIndex={-1}\n\t\t\t\t\tassistiveText={{ icon: '' }}\n\t\t\t\t\ticonCategory=\"utility\"\n\t\t\t\t\ticonName=\"chevronright\"\n\t\t\t\t\ticonSize=\"small\"\n\t\t\t\t\tvariant=\"icon\"\n\t\t\t\t\t// `slds-hidden` keeps the chevron's space so leaf labels align with\n\t\t\t\t\t// branch labels; SLDS 2 no longer hides `.slds-is-disabled` here.\n\t\t\t\t\tclassName=\"slds-m-right_small slds-is-disabled slds-hidden\"\n\t\t\t\t\tdisabled\n\t\t\t\t/>\n\t\t\t\t<span className=\"slds-size_1-of-1\">\n\t\t\t\t\t<Highlighter\n\t\t\t\t\t\tsearch={props.searchTerm}\n\t\t\t\t\t\tclassName=\"slds-tree__item-label slds-truncate\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{props.label}\n\t\t\t\t\t</Highlighter>\n\t\t\t\t</span>\n\t\t\t</div>\n\t\t</li>\n\t);\n};\n\nItem.displayName = TRE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AA,kBAAC,OAAD;GACC,WAAW,EAAW,mBAAmB,EACxC,oBAAoB,EACrB,CAAC;GACD,UAAU,MAAU,EAAa;IAAE;IAAO;GAAM,CAAC;GAJlD,UAAA,CAMC,kBAAC,GAAD;IACC,eAAA;IACA,UAAU;IACV,eAAe,EAAE,MAAM,GAAG;IAC1B,cAAa;IACb,UAAS;IACT,UAAS;IACT,SAAQ;IAGR,WAAU;IACV,UAAA;GACA,CAAA,GACD,kBAAC,QAAD;IAAM,WAAU;IACf,UAAA,kBAAC,GAAD;KACC,QAAQ,EAAM;KACd,WAAU;KAET,UAAA,EAAM;IACK,CAAA;GACR,CAAA,CACF;;CACF,CAAA;AAEN;AAEA,EAAK,cAAc"}
|
|
@@ -14,7 +14,7 @@ var u = (t, n) => {
|
|
|
14
14
|
event: t,
|
|
15
15
|
data: {
|
|
16
16
|
node: n.node,
|
|
17
|
-
expand: !n.node
|
|
17
|
+
expand: !n.isNodeExpanded(n.node),
|
|
18
18
|
treeIndex: n.treeIndex
|
|
19
19
|
}
|
|
20
20
|
});
|
|
@@ -23,7 +23,7 @@ var u = (t, n) => {
|
|
|
23
23
|
event: t,
|
|
24
24
|
data: {
|
|
25
25
|
node: n.node,
|
|
26
|
-
select: !n.node
|
|
26
|
+
select: !n.isNodeSelected(n.node),
|
|
27
27
|
treeIndex: n.treeIndex
|
|
28
28
|
},
|
|
29
29
|
fromFocus: r
|
|
@@ -61,12 +61,12 @@ var u = (t, n) => {
|
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
63
|
}, g = (e, t) => {
|
|
64
|
-
if (t.node
|
|
64
|
+
if (t.isNodeExpanded(t.node)) {
|
|
65
65
|
let n = t.getNodes?.(t.node);
|
|
66
66
|
n && n.length > 0 && m(e, t);
|
|
67
67
|
} else u(e, t);
|
|
68
68
|
}, _ = (e, t) => {
|
|
69
|
-
if (t.node
|
|
69
|
+
if (t.isNodeExpanded(t.node)) u(e, t);
|
|
70
70
|
else {
|
|
71
71
|
let n = t.flattenedNodes.map((e) => e.node), r = t.parent, i = l(n, { id: r?.id });
|
|
72
72
|
i !== -1 && t.onExpand({
|
|
@@ -74,7 +74,7 @@ var u = (t, n) => {
|
|
|
74
74
|
data: {
|
|
75
75
|
node: r,
|
|
76
76
|
select: !0,
|
|
77
|
-
expand: !r
|
|
77
|
+
expand: !t.isNodeExpanded(r),
|
|
78
78
|
treeIndex: t.flattenedNodes[i].treeIndex
|
|
79
79
|
}
|
|
80
80
|
});
|
|
@@ -98,11 +98,8 @@ var u = (t, n) => {
|
|
|
98
98
|
props: t,
|
|
99
99
|
fromFocus: !0
|
|
100
100
|
});
|
|
101
|
-
}, x = (e) => {
|
|
102
|
-
let t =
|
|
103
|
-
return e.treeIndex === e.focusedNodeIndex || t ? 0 : -1;
|
|
104
|
-
}, S = (e, t) => {
|
|
105
|
-
let r = t.node.expanded, c = t.node.selected, l = t.treeIndex === t.focusedNodeIndex, f = t.node.loading, p = /* @__PURE__ */ s("div", {
|
|
101
|
+
}, x = (e) => e.treeIndex === e.tabStopIndex ? 0 : -1, S = (e, t) => {
|
|
102
|
+
let r = t.isNodeExpanded(t.node), c = t.isNodeSelected(t.node), l = t.treeIndex === t.focusedNodeIndex, f = t.node.loading, p = /* @__PURE__ */ s("div", {
|
|
106
103
|
style: {
|
|
107
104
|
display: "block",
|
|
108
105
|
paddingLeft: `${1.5 * t.level + 1.5}rem`,
|
|
@@ -158,6 +155,8 @@ var u = (t, n) => {
|
|
|
158
155
|
props: t
|
|
159
156
|
}),
|
|
160
157
|
children: [/* @__PURE__ */ o(n, {
|
|
158
|
+
"aria-controls": String(t.htmlId),
|
|
159
|
+
"aria-hidden": !0,
|
|
161
160
|
assistiveText: { icon: "Expand Tree Branch" },
|
|
162
161
|
iconCategory: "utility",
|
|
163
162
|
iconName: "chevronright",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-branch.js","names":[],"sources":["../../../../../components/tree/private/render-branch.tsx"],"sourcesContent":["/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\nimport React, { ReactNode } from 'react';\nimport findIndex from 'lodash.findindex';\nimport isFunction from 'lodash.isfunction';\nimport classNames from 'classnames';\n\nimport Button from '../../button';\nimport Highlighter from '../../utilities/highlighter';\n\nimport EventUtil from '../../../utilities/event';\nimport KEYS from '../../../utilities/key-code';\nimport mapKeyEventCallbacks from '../../../utilities/key-callbacks';\nimport { TreeNode, FlattenedNode } from '../types';\n\nexport interface RenderBranchProps {\n\thtmlId: string | number;\n\tlabel?: ReactNode | string;\n\tlevel: number;\n\tnode: TreeNode;\n\tonExpand: (params: {\n\t\tevent: React.SyntheticEvent;\n\t\tdata: {\n\t\t\tnode: TreeNode;\n\t\t\texpand: boolean;\n\t\t\ttreeIndex: string;\n\t\t\tselect?: boolean;\n\t\t};\n\t}) => void;\n\tonSelect?: (params: {\n\t\tevent: React.SyntheticEvent;\n\t\tdata: {\n\t\t\tnode: TreeNode;\n\t\t\tselect: boolean;\n\t\t\ttreeIndex: string;\n\t\t};\n\t\tfromFocus?: boolean;\n\t\tclearSelectedNodes?: boolean;\n\t}) => void;\n\tsearchTerm?: string;\n\ttreeIndex: string;\n\tflattenedNodes: FlattenedNode[];\n\tselectedNodeIndexes: string[];\n\tfocusedNodeIndex?: string;\n\tonNodeBlur?: () => void;\n\ttreeHasFocus?: boolean;\n\tparent?: TreeNode | { nodes?: TreeNode[] };\n\tgetNodes?: (node: { nodes?: TreeNode[] }) => TreeNode[] | undefined;\n}\n\nconst handleExpand = (\n\tevent: React.SyntheticEvent,\n\tprops: RenderBranchProps\n) => {\n\tEventUtil.trap(event);\n\tif (isFunction(props.onExpand)) {\n\t\tprops.onExpand({\n\t\t\tevent,\n\t\t\tdata: {\n\t\t\t\tnode: props.node,\n\t\t\t\texpand: !props.node.expanded,\n\t\t\t\ttreeIndex: props.treeIndex,\n\t\t\t},\n\t\t});\n\t}\n};\n\nconst handleSelect = ({\n\tevent,\n\tprops,\n\tfromFocus,\n}: {\n\tevent: React.SyntheticEvent;\n\tprops: RenderBranchProps;\n\tfromFocus?: boolean;\n}) => {\n\tEventUtil.trap(event);\n\tif (isFunction(props.onSelect)) {\n\t\tprops.onSelect({\n\t\t\tevent,\n\t\t\tdata: {\n\t\t\t\tnode: props.node,\n\t\t\t\tselect: !props.node.selected,\n\t\t\t\ttreeIndex: props.treeIndex,\n\t\t\t},\n\t\t\tfromFocus,\n\t\t});\n\t}\n};\n\nconst findNextNode = (flattenedNodes: FlattenedNode[], node: TreeNode) => {\n\tconst nodes = flattenedNodes.map((flattenedNode) => flattenedNode.node);\n\tconst index = findIndex(nodes, { id: node.id });\n\treturn flattenedNodes[(index + 1) % flattenedNodes.length];\n};\n\nconst findPreviousNode = (flattenedNodes: FlattenedNode[], node: TreeNode) => {\n\tconst nodes = flattenedNodes.map((flattenedNode) => flattenedNode.node);\n\tlet index = findIndex(nodes, { id: node.id }) - 1;\n\tif (index < 0) {\n\t\tindex += flattenedNodes.length;\n\t}\n\treturn flattenedNodes[index];\n};\n\nconst handleKeyDownDown = (\n\tevent: React.KeyboardEvent,\n\tprops: RenderBranchProps\n) => {\n\tif (props.focusedNodeIndex === props.treeIndex) {\n\t\tconst flattenedNode = findNextNode(props.flattenedNodes, props.node);\n\t\tprops.onSelect?.({\n\t\t\tevent,\n\t\t\tdata: {\n\t\t\t\tnode: flattenedNode.node,\n\t\t\t\tselect: true,\n\t\t\t\ttreeIndex: flattenedNode.treeIndex,\n\t\t\t},\n\t\t\tclearSelectedNodes: true,\n\t\t});\n\t}\n};\n\nconst handleKeyDownUp = (\n\tevent: React.KeyboardEvent,\n\tprops: RenderBranchProps\n) => {\n\tif (props.focusedNodeIndex === props.treeIndex) {\n\t\tconst flattenedNode = findPreviousNode(props.flattenedNodes, props.node);\n\t\tprops.onSelect?.({\n\t\t\tevent,\n\t\t\tdata: {\n\t\t\t\tnode: flattenedNode.node,\n\t\t\t\tselect: true,\n\t\t\t\ttreeIndex: flattenedNode.treeIndex,\n\t\t\t},\n\t\t\tclearSelectedNodes: true,\n\t\t});\n\t}\n};\n\nconst handleKeyDownRight = (\n\tevent: React.KeyboardEvent,\n\tprops: RenderBranchProps\n) => {\n\tif (props.node.expanded) {\n\t\tconst childNodes = props.getNodes?.(props.node);\n\t\tif (childNodes && childNodes.length > 0) {\n\t\t\thandleKeyDownDown(event, props);\n\t\t}\n\t} else {\n\t\thandleExpand(event, props);\n\t}\n};\n\nconst handleKeyDownLeft = (\n\tevent: React.KeyboardEvent,\n\tprops: RenderBranchProps\n) => {\n\tif (props.node.expanded) {\n\t\thandleExpand(event, props);\n\t} else {\n\t\tconst nodes = props.flattenedNodes.map(\n\t\t\t(flattenedNode) => flattenedNode.node\n\t\t);\n\t\tconst parent = props.parent as TreeNode;\n\t\tconst index = findIndex(nodes, { id: parent?.id });\n\t\tif (index !== -1) {\n\t\t\t// `select: true` marks a move to the parent node, not an expand/collapse request.\n\t\t\t// Tree routes it to `onSelect` (or to the deprecated `onExpandClick`).\n\t\t\tprops.onExpand({\n\t\t\t\tevent,\n\t\t\t\tdata: {\n\t\t\t\t\tnode: parent,\n\t\t\t\t\tselect: true,\n\t\t\t\t\texpand: !parent.expanded,\n\t\t\t\t\ttreeIndex: props.flattenedNodes[index].treeIndex,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t}\n};\n\nconst handleKeyDownEnter = (\n\tevent: React.KeyboardEvent,\n\tprops: RenderBranchProps\n) => {\n\thandleSelect({ event, props });\n};\n\nconst handleKeyDown = (\n\tevent: React.KeyboardEvent,\n\tprops: RenderBranchProps\n) => {\n\tmapKeyEventCallbacks(event, {\n\t\tcallbacks: {\n\t\t\t[KEYS.DOWN]: {\n\t\t\t\tcallback: (evt: React.KeyboardEvent) => handleKeyDownDown(evt, props),\n\t\t\t},\n\t\t\t[KEYS.UP]: {\n\t\t\t\tcallback: (evt: React.KeyboardEvent) => handleKeyDownUp(evt, props),\n\t\t\t},\n\t\t\t[KEYS.RIGHT]: {\n\t\t\t\tcallback: (evt: React.KeyboardEvent) => handleKeyDownRight(evt, props),\n\t\t\t},\n\t\t\t[KEYS.LEFT]: {\n\t\t\t\tcallback: (evt: React.KeyboardEvent) => handleKeyDownLeft(evt, props),\n\t\t\t},\n\t\t\t[KEYS.ENTER]: {\n\t\t\t\tcallback: (evt: React.KeyboardEvent) => handleKeyDownEnter(evt, props),\n\t\t\t},\n\t\t},\n\t});\n};\n\nconst handleFocus = (event: React.FocusEvent, props: RenderBranchProps) => {\n\tif (\n\t\t!props.treeHasFocus &&\n\t\t!props.focusedNodeIndex &&\n\t\tevent.target === event.currentTarget\n\t) {\n\t\thandleSelect({ event, props, fromFocus: true });\n\t}\n};\n\nconst getTabIndex = (props: RenderBranchProps): number => {\n\tconst initialFocus =\n\t\tprops.selectedNodeIndexes.length === 0 &&\n\t\tprops.treeIndex === props.flattenedNodes[0]?.treeIndex;\n\treturn props.treeIndex === props.focusedNodeIndex || initialFocus ? 0 : -1;\n};\n\n/**\n * Renders a branch node in the tree.\n */\nconst RenderBranch = (\n\tchildren: ReactNode,\n\tprops: RenderBranchProps\n): React.ReactElement => {\n\tconst isExpanded = props.node.expanded;\n\tconst isSelected = props.node.selected;\n\tconst isFocused = props.treeIndex === props.focusedNodeIndex;\n\tconst isLoading = props.node.loading;\n\n\tconst loader = (\n\t\t<div\n\t\t\tstyle={{\n\t\t\t\tdisplay: 'block',\n\t\t\t\tpaddingLeft: `${1.5 * props.level + 1.5}rem`,\n\t\t\t\tmarginTop: '.5rem',\n\t\t\t}}\n\t\t>\n\t\t\t<div\n\t\t\t\tstyle={{\n\t\t\t\t\tborderRadius: '15rem',\n\t\t\t\t\tdisplay: 'block',\n\t\t\t\t\tmarginBottom: '.75rem',\n\t\t\t\t\theight: '.5rem',\n\t\t\t\t\tbackgroundColor: 'rgb(224, 229, 238)',\n\t\t\t\t\twidth: '40%',\n\t\t\t\t}}\n\t\t\t/>\n\t\t\t<div\n\t\t\t\tstyle={{\n\t\t\t\t\tborderRadius: '15rem',\n\t\t\t\t\tdisplay: 'block',\n\t\t\t\t\tmarginBottom: '.75rem',\n\t\t\t\t\theight: '.5rem',\n\t\t\t\t\tbackgroundColor: 'rgb(224, 229, 238)',\n\t\t\t\t\twidth: '80%',\n\t\t\t\t}}\n\t\t\t/>\n\t\t\t<div\n\t\t\t\tstyle={{\n\t\t\t\t\tborderRadius: '15rem',\n\t\t\t\t\tdisplay: 'block',\n\t\t\t\t\tmarginBottom: '.75rem',\n\t\t\t\t\theight: '.5rem',\n\t\t\t\t\tbackgroundColor: 'rgb(224, 229, 238)',\n\t\t\t\t\twidth: '60%',\n\t\t\t\t}}\n\t\t\t/>\n\t\t</div>\n\t);\n\n\tconst label =\n\t\tprops.node.assistiveText ||\n\t\t(typeof props.node.label === 'string' ? props.node.label : null);\n\n\t// aria-level and aria-expanded are valid for elements with role=\"treeitem\"\n\tconst ariaProps = {\n\t\t'aria-level': props.level,\n\t\t'aria-expanded': isExpanded ? ('true' as const) : ('false' as const),\n\t\t'aria-label':\n\t\t\tprops.node.nodes && props.node.nodes.length > 0 ? label : undefined,\n\t};\n\n\treturn (\n\t\t// @ts-expect-error - aria-level is valid for treeitem role but not in React types\n\t\t<li\n\t\t\tid={String(props.htmlId)}\n\t\t\trole=\"treeitem\"\n\t\t\t{...ariaProps}\n\t\t\ttabIndex={getTabIndex(props)}\n\t\t\tonKeyDown={(event) => handleKeyDown(event, props)}\n\t\t\tonFocus={(event) => handleFocus(event, props)}\n\t\t\tonBlur={props.onNodeBlur}\n\t\t\tref={(component) => {\n\t\t\t\tif (props.treeHasFocus && component && isFocused) {\n\t\t\t\t\tcomponent.focus();\n\t\t\t\t}\n\t\t\t}}\n\t\t>\n\t\t\t<div\n\t\t\t\tclassName={classNames('slds-tree__item', {\n\t\t\t\t\t'slds-is-selected': isSelected,\n\t\t\t\t})}\n\t\t\t\tonClick={(event) => handleSelect({ event, props })}\n\t\t\t>\n\t\t\t\t<Button\n\t\t\t\t\tassistiveText={{ icon: 'Expand Tree Branch' }}\n\t\t\t\t\ticonCategory=\"utility\"\n\t\t\t\t\ticonName=\"chevronright\"\n\t\t\t\t\ticonSize=\"small\"\n\t\t\t\t\tvariant=\"icon\"\n\t\t\t\t\tclassName=\"slds-m-right_small\"\n\t\t\t\t\tonClick={(event) => handleExpand(event, props)}\n\t\t\t\t\ttabIndex={-1}\n\t\t\t\t/>\n\t\t\t\t<span className=\"slds-size_1-of-1\" id={`${props.htmlId}__label`}>\n\t\t\t\t\t<Highlighter\n\t\t\t\t\t\tsearch={props.searchTerm}\n\t\t\t\t\t\tclassName=\"slds-tree__item-label slds-truncate\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{props.label}\n\t\t\t\t\t</Highlighter>\n\t\t\t\t</span>\n\t\t\t</div>\n\t\t\t{isLoading ? loader : null}\n\t\t\t<ul\n\t\t\t\tclassName={classNames({\n\t\t\t\t\t'slds-is-expanded': isExpanded,\n\t\t\t\t\t'slds-is-collapsed': !isExpanded,\n\t\t\t\t})}\n\t\t\t\trole=\"group\"\n\t\t\t\taria-labelledby={`${props.htmlId}__label`}\n\t\t\t>\n\t\t\t\t{isExpanded && !isLoading ? children : null}\n\t\t\t</ul>\n\t\t</li>\n\t);\n};\n\nRenderBranch.displayName = 'Branch';\n\nexport default RenderBranch;\n"],"mappings":";;;;;;;;;;;AAmDA,IAAM,KACL,GACA,MACI;CAEJ,AADA,EAAU,KAAK,CAAK,GAChB,EAAW,EAAM,QAAQ,KAC5B,EAAM,SAAS;EACd;EACA,MAAM;GACL,MAAM,EAAM;GACZ,QAAQ,CAAC,EAAM,KAAK;GACpB,WAAW,EAAM;EAClB;CACD,CAAC;AAEH,GAEM,KAAgB,EACrB,UACA,UACA,mBAKK;CAEL,AADA,EAAU,KAAK,CAAK,GAChB,EAAW,EAAM,QAAQ,KAC5B,EAAM,SAAS;EACd;EACA,MAAM;GACL,MAAM,EAAM;GACZ,QAAQ,CAAC,EAAM,KAAK;GACpB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M;KACK,CAAA;IACR,CAAA,CACF;;GACJ,IAAY,IAAS;GACtB,kBAAC,MAAD;IACC,WAAW,EAAW;KACrB,oBAAoB;KACpB,qBAAqB,CAAC;IACvB,CAAC;IACD,MAAK;IACL,mBAAiB,GAAG,EAAM,OAAO;IAEhC,UAAA,KAAc,CAAC,IAAY,IAAW;GACpC,CAAA;EACD;;AAEN;AAEA,EAAa,cAAc"}
|
|
1
|
+
{"version":3,"file":"render-branch.js","names":[],"sources":["../../../../../components/tree/private/render-branch.tsx"],"sourcesContent":["/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\nimport React, { ReactNode } from 'react';\nimport findIndex from 'lodash.findindex';\nimport isFunction from 'lodash.isfunction';\nimport classNames from 'classnames';\n\nimport Button from '../../button';\nimport Highlighter from '../../utilities/highlighter';\n\nimport EventUtil from '../../../utilities/event';\nimport KEYS from '../../../utilities/key-code';\nimport mapKeyEventCallbacks from '../../../utilities/key-callbacks';\nimport { TreeNode, FlattenedNode } from '../types';\n\nexport interface RenderBranchProps {\n\thtmlId: string | number;\n\tlabel?: ReactNode | string;\n\tlevel: number;\n\tnode: TreeNode;\n\tonExpand: (params: {\n\t\tevent: React.SyntheticEvent;\n\t\tdata: {\n\t\t\tnode: TreeNode;\n\t\t\texpand: boolean;\n\t\t\ttreeIndex: string;\n\t\t\tselect?: boolean;\n\t\t};\n\t}) => void;\n\tonSelect?: (params: {\n\t\tevent: React.SyntheticEvent;\n\t\tdata: {\n\t\t\tnode: TreeNode;\n\t\t\tselect: boolean;\n\t\t\ttreeIndex: string;\n\t\t};\n\t\tfromFocus?: boolean;\n\t\tclearSelectedNodes?: boolean;\n\t}) => void;\n\tsearchTerm?: string;\n\ttreeIndex: string;\n\tflattenedNodes: FlattenedNode[];\n\tisNodeSelected: (node: TreeNode) => boolean;\n\tisNodeExpanded: (node: TreeNode) => boolean;\n\ttabStopIndex?: string;\n\tfocusedNodeIndex?: string;\n\tonNodeBlur?: () => void;\n\ttreeHasFocus?: boolean;\n\tparent?: TreeNode | { nodes?: TreeNode[] };\n\tgetNodes?: (node: { nodes?: TreeNode[] }) => TreeNode[] | undefined;\n}\n\nconst handleExpand = (\n\tevent: React.SyntheticEvent,\n\tprops: RenderBranchProps\n) => {\n\tEventUtil.trap(event);\n\tif (isFunction(props.onExpand)) {\n\t\tprops.onExpand({\n\t\t\tevent,\n\t\t\tdata: {\n\t\t\t\tnode: props.node,\n\t\t\t\texpand: !props.isNodeExpanded(props.node),\n\t\t\t\ttreeIndex: props.treeIndex,\n\t\t\t},\n\t\t});\n\t}\n};\n\nconst handleSelect = ({\n\tevent,\n\tprops,\n\tfromFocus,\n}: {\n\tevent: React.SyntheticEvent;\n\tprops: RenderBranchProps;\n\tfromFocus?: boolean;\n}) => {\n\tEventUtil.trap(event);\n\tif (isFunction(props.onSelect)) {\n\t\tprops.onSelect({\n\t\t\tevent,\n\t\t\tdata: {\n\t\t\t\tnode: props.node,\n\t\t\t\tselect: !props.isNodeSelected(props.node),\n\t\t\t\ttreeIndex: props.treeIndex,\n\t\t\t},\n\t\t\tfromFocus,\n\t\t});\n\t}\n};\n\nconst findNextNode = (flattenedNodes: FlattenedNode[], node: TreeNode) => {\n\tconst nodes = flattenedNodes.map((flattenedNode) => flattenedNode.node);\n\tconst index = findIndex(nodes, { id: node.id });\n\treturn flattenedNodes[(index + 1) % flattenedNodes.length];\n};\n\nconst findPreviousNode = (flattenedNodes: FlattenedNode[], node: TreeNode) => {\n\tconst nodes = flattenedNodes.map((flattenedNode) => flattenedNode.node);\n\tlet index = findIndex(nodes, { id: node.id }) - 1;\n\tif (index < 0) {\n\t\tindex += flattenedNodes.length;\n\t}\n\treturn flattenedNodes[index];\n};\n\nconst handleKeyDownDown = (\n\tevent: React.KeyboardEvent,\n\tprops: RenderBranchProps\n) => {\n\tif (props.focusedNodeIndex === props.treeIndex) {\n\t\tconst flattenedNode = findNextNode(props.flattenedNodes, props.node);\n\t\tprops.onSelect?.({\n\t\t\tevent,\n\t\t\tdata: {\n\t\t\t\tnode: flattenedNode.node,\n\t\t\t\tselect: true,\n\t\t\t\ttreeIndex: flattenedNode.treeIndex,\n\t\t\t},\n\t\t\tclearSelectedNodes: true,\n\t\t});\n\t}\n};\n\nconst handleKeyDownUp = (\n\tevent: React.KeyboardEvent,\n\tprops: RenderBranchProps\n) => {\n\tif (props.focusedNodeIndex === props.treeIndex) {\n\t\tconst flattenedNode = findPreviousNode(props.flattenedNodes, props.node);\n\t\tprops.onSelect?.({\n\t\t\tevent,\n\t\t\tdata: {\n\t\t\t\tnode: flattenedNode.node,\n\t\t\t\tselect: true,\n\t\t\t\ttreeIndex: flattenedNode.treeIndex,\n\t\t\t},\n\t\t\tclearSelectedNodes: true,\n\t\t});\n\t}\n};\n\nconst handleKeyDownRight = (\n\tevent: React.KeyboardEvent,\n\tprops: RenderBranchProps\n) => {\n\tif (props.isNodeExpanded(props.node)) {\n\t\tconst childNodes = props.getNodes?.(props.node);\n\t\tif (childNodes && childNodes.length > 0) {\n\t\t\thandleKeyDownDown(event, props);\n\t\t}\n\t} else {\n\t\thandleExpand(event, props);\n\t}\n};\n\nconst handleKeyDownLeft = (\n\tevent: React.KeyboardEvent,\n\tprops: RenderBranchProps\n) => {\n\tif (props.isNodeExpanded(props.node)) {\n\t\thandleExpand(event, props);\n\t} else {\n\t\tconst nodes = props.flattenedNodes.map(\n\t\t\t(flattenedNode) => flattenedNode.node\n\t\t);\n\t\tconst parent = props.parent as TreeNode;\n\t\tconst index = findIndex(nodes, { id: parent?.id });\n\t\tif (index !== -1) {\n\t\t\t// `select: true` marks a move to the parent node, not an expand/collapse request.\n\t\t\t// Tree routes it to `onSelect` (or to the deprecated `onExpandClick`).\n\t\t\tprops.onExpand({\n\t\t\t\tevent,\n\t\t\t\tdata: {\n\t\t\t\t\tnode: parent,\n\t\t\t\t\tselect: true,\n\t\t\t\t\texpand: !props.isNodeExpanded(parent),\n\t\t\t\t\ttreeIndex: props.flattenedNodes[index].treeIndex,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t}\n};\n\nconst handleKeyDownEnter = (\n\tevent: React.KeyboardEvent,\n\tprops: RenderBranchProps\n) => {\n\thandleSelect({ event, props });\n};\n\nconst handleKeyDown = (\n\tevent: React.KeyboardEvent,\n\tprops: RenderBranchProps\n) => {\n\tmapKeyEventCallbacks(event, {\n\t\tcallbacks: {\n\t\t\t[KEYS.DOWN]: {\n\t\t\t\tcallback: (evt: React.KeyboardEvent) => handleKeyDownDown(evt, props),\n\t\t\t},\n\t\t\t[KEYS.UP]: {\n\t\t\t\tcallback: (evt: React.KeyboardEvent) => handleKeyDownUp(evt, props),\n\t\t\t},\n\t\t\t[KEYS.RIGHT]: {\n\t\t\t\tcallback: (evt: React.KeyboardEvent) => handleKeyDownRight(evt, props),\n\t\t\t},\n\t\t\t[KEYS.LEFT]: {\n\t\t\t\tcallback: (evt: React.KeyboardEvent) => handleKeyDownLeft(evt, props),\n\t\t\t},\n\t\t\t[KEYS.ENTER]: {\n\t\t\t\tcallback: (evt: React.KeyboardEvent) => handleKeyDownEnter(evt, props),\n\t\t\t},\n\t\t},\n\t});\n};\n\nconst handleFocus = (event: React.FocusEvent, props: RenderBranchProps) => {\n\tif (\n\t\t!props.treeHasFocus &&\n\t\t!props.focusedNodeIndex &&\n\t\tevent.target === event.currentTarget\n\t) {\n\t\thandleSelect({ event, props, fromFocus: true });\n\t}\n};\n\nconst getTabIndex = (props: RenderBranchProps): number =>\n\tprops.treeIndex === props.tabStopIndex ? 0 : -1;\n\n/**\n * Renders a branch node in the tree.\n */\nconst RenderBranch = (\n\tchildren: ReactNode,\n\tprops: RenderBranchProps\n): React.ReactElement => {\n\tconst isExpanded = props.isNodeExpanded(props.node);\n\tconst isSelected = props.isNodeSelected(props.node);\n\tconst isFocused = props.treeIndex === props.focusedNodeIndex;\n\tconst isLoading = props.node.loading;\n\n\tconst loader = (\n\t\t<div\n\t\t\tstyle={{\n\t\t\t\tdisplay: 'block',\n\t\t\t\tpaddingLeft: `${1.5 * props.level + 1.5}rem`,\n\t\t\t\tmarginTop: '.5rem',\n\t\t\t}}\n\t\t>\n\t\t\t<div\n\t\t\t\tstyle={{\n\t\t\t\t\tborderRadius: '15rem',\n\t\t\t\t\tdisplay: 'block',\n\t\t\t\t\tmarginBottom: '.75rem',\n\t\t\t\t\theight: '.5rem',\n\t\t\t\t\tbackgroundColor: 'rgb(224, 229, 238)',\n\t\t\t\t\twidth: '40%',\n\t\t\t\t}}\n\t\t\t/>\n\t\t\t<div\n\t\t\t\tstyle={{\n\t\t\t\t\tborderRadius: '15rem',\n\t\t\t\t\tdisplay: 'block',\n\t\t\t\t\tmarginBottom: '.75rem',\n\t\t\t\t\theight: '.5rem',\n\t\t\t\t\tbackgroundColor: 'rgb(224, 229, 238)',\n\t\t\t\t\twidth: '80%',\n\t\t\t\t}}\n\t\t\t/>\n\t\t\t<div\n\t\t\t\tstyle={{\n\t\t\t\t\tborderRadius: '15rem',\n\t\t\t\t\tdisplay: 'block',\n\t\t\t\t\tmarginBottom: '.75rem',\n\t\t\t\t\theight: '.5rem',\n\t\t\t\t\tbackgroundColor: 'rgb(224, 229, 238)',\n\t\t\t\t\twidth: '60%',\n\t\t\t\t}}\n\t\t\t/>\n\t\t</div>\n\t);\n\n\tconst label =\n\t\tprops.node.assistiveText ||\n\t\t(typeof props.node.label === 'string' ? props.node.label : null);\n\n\t// aria-level and aria-expanded are valid for elements with role=\"treeitem\"\n\tconst ariaProps = {\n\t\t'aria-level': props.level,\n\t\t'aria-expanded': isExpanded ? ('true' as const) : ('false' as const),\n\t\t'aria-label':\n\t\t\tprops.node.nodes && props.node.nodes.length > 0 ? label : undefined,\n\t};\n\n\treturn (\n\t\t// @ts-expect-error - aria-level is valid for treeitem role but not in React types\n\t\t<li\n\t\t\tid={String(props.htmlId)}\n\t\t\trole=\"treeitem\"\n\t\t\t{...ariaProps}\n\t\t\ttabIndex={getTabIndex(props)}\n\t\t\tonKeyDown={(event) => handleKeyDown(event, props)}\n\t\t\tonFocus={(event) => handleFocus(event, props)}\n\t\t\tonBlur={props.onNodeBlur}\n\t\t\tref={(component) => {\n\t\t\t\tif (props.treeHasFocus && component && isFocused) {\n\t\t\t\t\tcomponent.focus();\n\t\t\t\t}\n\t\t\t}}\n\t\t>\n\t\t\t<div\n\t\t\t\tclassName={classNames('slds-tree__item', {\n\t\t\t\t\t'slds-is-selected': isSelected,\n\t\t\t\t})}\n\t\t\t\tonClick={(event) => handleSelect({ event, props })}\n\t\t\t>\n\t\t\t\t<Button\n\t\t\t\t\t// SLDS 1 only rotates the chevron when `aria-controls` is set.\n\t\t\t\t\taria-controls={String(props.htmlId)}\n\t\t\t\t\taria-hidden\n\t\t\t\t\tassistiveText={{ icon: 'Expand Tree Branch' }}\n\t\t\t\t\ticonCategory=\"utility\"\n\t\t\t\t\ticonName=\"chevronright\"\n\t\t\t\t\ticonSize=\"small\"\n\t\t\t\t\tvariant=\"icon\"\n\t\t\t\t\tclassName=\"slds-m-right_small\"\n\t\t\t\t\tonClick={(event) => handleExpand(event, props)}\n\t\t\t\t\ttabIndex={-1}\n\t\t\t\t/>\n\t\t\t\t<span className=\"slds-size_1-of-1\" id={`${props.htmlId}__label`}>\n\t\t\t\t\t<Highlighter\n\t\t\t\t\t\tsearch={props.searchTerm}\n\t\t\t\t\t\tclassName=\"slds-tree__item-label slds-truncate\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{props.label}\n\t\t\t\t\t</Highlighter>\n\t\t\t\t</span>\n\t\t\t</div>\n\t\t\t{isLoading ? loader : null}\n\t\t\t<ul\n\t\t\t\tclassName={classNames({\n\t\t\t\t\t'slds-is-expanded': isExpanded,\n\t\t\t\t\t'slds-is-collapsed': !isExpanded,\n\t\t\t\t})}\n\t\t\t\trole=\"group\"\n\t\t\t\taria-labelledby={`${props.htmlId}__label`}\n\t\t\t>\n\t\t\t\t{isExpanded && !isLoading ? children : null}\n\t\t\t</ul>\n\t\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EAElB;EAZD,UAAA;GAcC,kBAAC,OAAD;IACC,WAAW,EAAW,mBAAmB,EACxC,oBAAoB,EACrB,CAAC;IACD,UAAU,MAAU,EAAa;KAAE;KAAO;IAAM,CAAC;IAJlD,UAAA,CAMC,kBAAC,GAAD;KAEC,iBAAe,OAAO,EAAM,MAAM;KAClC,eAAA;KACA,eAAe,EAAE,MAAM,qBAAqB;KAC5C,cAAa;KACb,UAAS;KACT,UAAS;KACT,SAAQ;KACR,WAAU;KACV,UAAU,MAAU,EAAa,GAAO,CAAK;KAC7C,UAAU;IACV,CAAA,GACD,kBAAC,QAAD;KAAM,WAAU;KAAmB,IAAI,GAAG,EAAM,OAAO;KACtD,UAAA,kBAAC,GAAD;MACC,QAAQ,EAAM;MACd,WAAU;MAET,UAAA,EAAM;KACK,CAAA;IACR,CAAA,CACF;;GACJ,IAAY,IAAS;GACtB,kBAAC,MAAD;IACC,WAAW,EAAW;KACrB,oBAAoB;KACpB,qBAAqB,CAAC;IACvB,CAAC;IACD,MAAK;IACL,mBAAiB,GAAG,EAAM,OAAO;IAEhC,UAAA,KAAc,CAAC,IAAY,IAAW;GACpC,CAAA;EACD;;AAEN;AAEA,EAAa,cAAc"}
|
|
@@ -1,73 +1,97 @@
|
|
|
1
1
|
import { TREE as e } from "../../utilities/constants.js";
|
|
2
|
-
import t from "
|
|
3
|
-
import n from "./
|
|
4
|
-
import r from "./
|
|
5
|
-
import
|
|
6
|
-
import c from "
|
|
7
|
-
import
|
|
2
|
+
import { useControllableState as t } from "../../utilities/hooks/use-controllable-state.js";
|
|
3
|
+
import n from "./private/branch.js";
|
|
4
|
+
import r, { checkLegacyNodeFields as i } from "./check-props.js";
|
|
5
|
+
import a from "./component.js";
|
|
6
|
+
import { forwardRef as o, useCallback as s, useEffect as c, useMemo as l, useRef as u, useState as ee } from "react";
|
|
7
|
+
import d from "classnames";
|
|
8
|
+
import { jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
8
9
|
//#region components/tree/tree.tsx
|
|
9
|
-
var
|
|
10
|
+
var m = [], h = (e, t, n, r = "", i = !0) => {
|
|
10
11
|
if (!e.nodes) return [{
|
|
11
12
|
node: e,
|
|
12
|
-
treeIndex:
|
|
13
|
+
treeIndex: r
|
|
13
14
|
}];
|
|
14
|
-
let
|
|
15
|
+
let a = [{
|
|
15
16
|
node: e,
|
|
16
|
-
treeIndex:
|
|
17
|
+
treeIndex: r
|
|
17
18
|
}];
|
|
18
|
-
if (e
|
|
19
|
-
let
|
|
20
|
-
|
|
19
|
+
if (i || n(e)) for (let o = 0; o < e.nodes.length; o += 1) {
|
|
20
|
+
let s = i ? e.nodes[o] : t(e)?.[o];
|
|
21
|
+
s && (a = a.concat(h(s, t, n, r ? `${r}-${o}` : `${o}`, !1)));
|
|
21
22
|
}
|
|
22
|
-
return
|
|
23
|
-
},
|
|
24
|
-
let
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
23
|
+
return a;
|
|
24
|
+
}, g = (e, t, n) => {
|
|
25
|
+
let r = [], i = /* @__PURE__ */ new Set(), a = (e) => {
|
|
26
|
+
e?.forEach((e) => {
|
|
27
|
+
e && !i.has(e) && (i.add(e), n(e) && r.push(e.id), a(t(e)));
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
return a(t({ nodes: e })), r;
|
|
31
|
+
}, te = (e) => e.nodes, _ = o(({ assistiveText: o, className: _, classNameList: v, listClassName: y, getNodes: b = te, heading: x, id: S, labels: C, nodes: w, selectedIds: T, expandedIds: E, defaultExpandedIds: D, onSelect: O, onClick: k, onRequestToggle: A, onExpandClick: j, onScroll: M, searchTerm: N, styleList: P, listStyle: F }, I) => {
|
|
32
|
+
let L = o?.heading ?? o?.label, R = C?.heading ?? x, z = T === void 0, B = E === void 0 && D === void 0, [V, H] = t(E, D ?? m), U = l(() => new Set(T ?? m), [T]), W = l(() => new Set(V), [V]), G = s((e) => z ? !!e.selected : U.has(e.id), [z, U]), K = s((e) => B && e.expanded !== void 0 ? !!e.expanded : W.has(e.id), [B, W]), q = u(!1), J = l(() => h({ nodes: b({ nodes: w }) }, b, K).slice(1), [
|
|
33
|
+
b,
|
|
34
|
+
w,
|
|
35
|
+
K
|
|
36
|
+
]), [ne, Y] = ee(void 0), X = ne ?? J.find((e) => G(e.node))?.treeIndex, re = X ?? J[0]?.treeIndex;
|
|
37
|
+
c(() => {
|
|
38
|
+
r(e, {
|
|
39
|
+
assistiveText: o,
|
|
40
|
+
className: _,
|
|
41
|
+
classNameList: v,
|
|
42
|
+
listClassName: y,
|
|
43
|
+
getNodes: b,
|
|
44
|
+
heading: x,
|
|
45
|
+
id: S,
|
|
46
|
+
labels: C,
|
|
47
|
+
nodes: w,
|
|
48
|
+
selectedIds: T,
|
|
49
|
+
expandedIds: E,
|
|
50
|
+
defaultExpandedIds: D,
|
|
51
|
+
onSelect: O,
|
|
52
|
+
onClick: k,
|
|
53
|
+
onRequestToggle: A,
|
|
54
|
+
onExpandClick: j,
|
|
55
|
+
onScroll: M,
|
|
56
|
+
searchTerm: N,
|
|
57
|
+
styleList: P,
|
|
58
|
+
listStyle: F
|
|
59
|
+
}, a);
|
|
60
|
+
}, []), c(() => {
|
|
61
|
+
process.env.NODE_ENV !== "production" && B && i(e, { hasExpandedField: J.some((e) => e.node.expanded !== void 0) });
|
|
62
|
+
}, [B, J]);
|
|
63
|
+
let Z = s(() => z ? g(w, b, (e) => !!e.selected) : T, [
|
|
64
|
+
z,
|
|
65
|
+
w,
|
|
66
|
+
b,
|
|
67
|
+
T
|
|
68
|
+
]), Q = s(() => B ? g(w, b, (e) => e.type === "branch" && K(e)) : V, [
|
|
69
|
+
B,
|
|
70
|
+
w,
|
|
71
|
+
b,
|
|
72
|
+
K,
|
|
73
|
+
V
|
|
74
|
+
]), $ = s(({ event: e, data: t, clearSelectedNodes: n, fromFocus: r }) => {
|
|
75
|
+
if (!r) {
|
|
76
|
+
if (O) {
|
|
77
|
+
let r = n ? [] : Z().filter((e) => e !== t.node.id);
|
|
78
|
+
O(e, {
|
|
79
|
+
node: t.node,
|
|
80
|
+
isSelected: t.select,
|
|
81
|
+
selectedIds: t.select ? [...r, t.node.id] : r
|
|
82
|
+
});
|
|
83
|
+
} else k && k(e, t);
|
|
84
|
+
}
|
|
85
|
+
q.current = !0, Y(t.treeIndex);
|
|
61
86
|
}, [
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}, []), B = i(({ event: e, data: t }) => {
|
|
87
|
+
Z,
|
|
88
|
+
O,
|
|
89
|
+
k
|
|
90
|
+
]), ie = s(() => {
|
|
91
|
+
q.current = !1;
|
|
92
|
+
}, []), ae = s(({ event: e, data: t }) => {
|
|
69
93
|
if (t.select) {
|
|
70
|
-
!
|
|
94
|
+
!A && j ? (q.current = !0, j(e, t), Y(t.treeIndex)) : $({
|
|
71
95
|
event: e,
|
|
72
96
|
data: {
|
|
73
97
|
node: t.node,
|
|
@@ -78,44 +102,55 @@ var d = (e, t, n = "", r = !0) => {
|
|
|
78
102
|
});
|
|
79
103
|
return;
|
|
80
104
|
}
|
|
81
|
-
|
|
105
|
+
q.current = !0;
|
|
106
|
+
let n = Q().filter((e) => e !== t.node.id), r = t.expand ? [...n, t.node.id] : n;
|
|
107
|
+
H(r), A ? A(e, {
|
|
82
108
|
node: t.node,
|
|
83
|
-
isExpanded: t.expand
|
|
84
|
-
|
|
109
|
+
isExpanded: t.expand,
|
|
110
|
+
expandedIds: r
|
|
111
|
+
}) : j && j(e, t);
|
|
85
112
|
}, [
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
113
|
+
$,
|
|
114
|
+
Q,
|
|
115
|
+
H,
|
|
116
|
+
A,
|
|
117
|
+
j
|
|
118
|
+
]), oe = L || R;
|
|
119
|
+
return /* @__PURE__ */ p("div", {
|
|
120
|
+
id: S,
|
|
121
|
+
className: d("slds-tree_container", _),
|
|
122
|
+
ref: I,
|
|
123
|
+
children: [/* @__PURE__ */ f("h4", {
|
|
124
|
+
className: d("slds-tree__group-header", { "slds-assistive-text": !!L }),
|
|
125
|
+
id: `${S}__heading`,
|
|
126
|
+
children: oe
|
|
127
|
+
}), /* @__PURE__ */ f(n, {
|
|
128
|
+
getNodes: b,
|
|
129
|
+
initalClassName: d(y, v),
|
|
130
|
+
htmlId: S,
|
|
131
|
+
initialStyle: F || P ? {
|
|
132
|
+
...F,
|
|
133
|
+
...P
|
|
134
|
+
} : void 0,
|
|
102
135
|
level: 0,
|
|
103
|
-
node: { nodes:
|
|
104
|
-
flattenedNodes:
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
136
|
+
node: { nodes: w },
|
|
137
|
+
flattenedNodes: J,
|
|
138
|
+
isNodeSelected: G,
|
|
139
|
+
isNodeExpanded: K,
|
|
140
|
+
tabStopIndex: re,
|
|
141
|
+
focusedNodeIndex: X,
|
|
142
|
+
treeHasFocus: q.current,
|
|
143
|
+
onNodeBlur: ie,
|
|
144
|
+
onSelect: $,
|
|
145
|
+
onExpand: ae,
|
|
146
|
+
onScroll: M,
|
|
147
|
+
searchTerm: N,
|
|
148
|
+
treeId: S
|
|
114
149
|
})]
|
|
115
150
|
});
|
|
116
|
-
};
|
|
117
|
-
|
|
151
|
+
});
|
|
152
|
+
_.displayName = e;
|
|
118
153
|
//#endregion
|
|
119
|
-
export {
|
|
154
|
+
export { _ as default };
|
|
120
155
|
|
|
121
156
|
//# sourceMappingURL=tree.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree.js","names":[],"sources":["../../../../components/tree/tree.tsx"],"sourcesContent":["/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\nimport React, { useState, useCallback, useEffect, useRef } from 'react';\nimport classNames from 'classnames';\n// Using native Array.find instead of lodash for better TypeScript support\n\n// Child components\nimport Branch from './private/branch';\n\n// Similar to React's PropTypes check\nimport checkProps from './check-props';\n\n// Constants\nimport { TREE } from '../../utilities/constants';\nimport componentDoc from './component.json';\n\nimport {\n\tTreeNode,\n\tFlattenedNode,\n\tTreeAssistiveText,\n\tTreeLabels,\n\tTreeNodeSelectData,\n\tTreeRequestToggleData,\n\tTreeSelectData,\n\tTreeExpandData,\n\tTreeScrollData,\n} from './types';\n\nexport interface TreeProps {\n\t/**\n\t * **Assistive text for accessibility**\n\t * * `heading`: Visually hidden tree heading. Set this or `labels.heading`.\n\t */\n\tassistiveText?: TreeAssistiveText;\n\t/** Class names for the container element */\n\tclassName?: string | string[] | Record<string, boolean>;\n\t/** Class names for the top-level ul element */\n\tlistClassName?: string | string[] | Record<string, boolean>;\n\t/** Function to get child nodes from a parent node */\n\tgetNodes?: (node: { nodes?: TreeNode[] }) => TreeNode[] | undefined;\n\t/** @deprecated Use `labels.heading` instead. */\n\theading?: ReactNode;\n\t/** HTML id of the tree container (required) */\n\tid: string;\n\t/**\n\t * **Text labels for internationalization**\n\t * * `heading`: Visible tree heading that describes its contents. Set this or `assistiveText.heading`.\n\t */\n\tlabels?: TreeLabels;\n\t/** Array of tree nodes */\n\tnodes: TreeNode[];\n\t/**\n\t * Called when an item or branch is selected or deselected: by click, by focus, or by keyboard\n\t * (Enter, Up/Down arrows, Right arrow into an expanded branch, Left arrow to the parent node).\n\t * `data.isSelected` is the requested selection state. Update `node.selected` in `nodes` to apply it.\n\t */\n\tonSelect?: (event: React.SyntheticEvent, data: TreeNodeSelectData) => void;\n\t/**\n\t * Called when an item or branch is selected.\n\t * @deprecated Use `onSelect`, which receives `{ node, isSelected }`. Ignored when `onSelect` is passed.\n\t */\n\tonClick?: (event: React.SyntheticEvent, data: TreeSelectData) => void;\n\t/**\n\t * Called when a branch is asked to expand or collapse: by clicking its toggle button, by Right\n\t * arrow on a collapsed branch, or by Left arrow on an expanded branch. `data.isExpanded` is the\n\t * requested expansion state. Update `node.expanded` in `nodes` to apply it.\n\t */\n\tonRequestToggle?: (\n\t\tevent: React.SyntheticEvent,\n\t\tdata: TreeRequestToggleData\n\t) => void;\n\t/**\n\t * Called when a branch's expand/collapse button is clicked, or when the Left arrow is pressed\n\t * on a collapsed branch or item (with `data.select: true` and `data.node` set to the parent).\n\t * @deprecated Use `onRequestToggle`, which receives `{ node, isExpanded }`. With\n\t * `onRequestToggle`, Left arrow on a collapsed branch or item selects the parent via\n\t * `onSelect` instead. Ignored when `onRequestToggle` is passed.\n\t */\n\tonExpandClick?: (event: React.SyntheticEvent, data: TreeExpandData) => void;\n\t/** Callback when the tree list scrolls. `data.ratio` is the scroll position from `0` to `1`. */\n\tonScroll?: (\n\t\tevent: React.UIEvent<HTMLUListElement>,\n\t\tdata: TreeScrollData\n\t) => void;\n\t/** Search term to highlight in node labels */\n\tsearchTerm?: string;\n\t/** Styles for the top-level ul element */\n\tlistStyle?: React.CSSProperties;\n}\n\ntype ReactNode = React.ReactNode;\n\n/**\n * Flattens hierarchical tree structure into a flat array.\n * The first item is the whole tree and should be removed with slice(1).\n */\nconst flattenTree = (\n\troot: { nodes?: TreeNode[]; expanded?: boolean },\n\tgetNodes: (node: { nodes?: TreeNode[] }) => TreeNode[] | undefined,\n\ttreeIndex = '',\n\tfirstLevel = true\n): FlattenedNode[] => {\n\tif (!root.nodes) {\n\t\treturn [{ node: root as TreeNode, treeIndex }];\n\t}\n\tlet nodes: FlattenedNode[] = [{ node: root as TreeNode, treeIndex }];\n\tif (root.expanded) {\n\t\tfor (let index = 0; index < root.nodes.length; index += 1) {\n\t\t\tconst curNode = firstLevel ? root.nodes[index] : getNodes(root)?.[index];\n\t\t\tif (curNode) {\n\t\t\t\tnodes = nodes.concat(\n\t\t\t\t\tflattenTree(\n\t\t\t\t\t\tcurNode,\n\t\t\t\t\t\tgetNodes,\n\t\t\t\t\t\ttreeIndex ? `${treeIndex}-${index}` : `${index}`,\n\t\t\t\t\t\tfalse\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\treturn nodes;\n};\n\nconst defaultGetNodes = (node: { nodes?: TreeNode[] }) => node.nodes;\n\n/**\n * A tree is visualization of a structure hierarchy.\n * A branch can be expanded or collapsed.\n * This is a controlled component, since visual state is present in the nodes data.\n */\nconst Tree: React.FC<TreeProps> = ({\n\tassistiveText: assistiveTextProp,\n\tclassName,\n\tlistClassName,\n\tgetNodes = defaultGetNodes,\n\theading: headingProp,\n\tid,\n\tlabels,\n\tnodes,\n\tonSelect,\n\tonClick,\n\tonRequestToggle,\n\tonExpandClick,\n\tonScroll,\n\tsearchTerm,\n\tlistStyle,\n}) => {\n\t// `assistiveText.label` is deprecated\n\tconst assistiveHeading =\n\t\tassistiveTextProp?.heading ?? assistiveTextProp?.label;\n\t// `heading` is deprecated\n\tconst visibleHeading = labels?.heading ?? headingProp;\n\n\t// Track if tree has focus\n\tconst treeHasFocusRef = useRef(false);\n\n\t// Compute flattened nodes\n\tconst computeFlattenedNodes = useCallback(() => {\n\t\treturn flattenTree(\n\t\t\t{\n\t\t\t\tnodes: getNodes({ nodes }),\n\t\t\t\texpanded: true,\n\t\t\t},\n\t\t\tgetNodes\n\t\t).slice(1);\n\t}, [getNodes, nodes]);\n\n\t// Initialize state\n\tconst [flattenedNodes, setFlattenedNodes] = useState<FlattenedNode[]>(\n\t\tcomputeFlattenedNodes\n\t);\n\tconst [selectedNodeIndexes, setSelectedNodeIndexes] = useState<string[]>(\n\t\t() => {\n\t\t\tconst flattened = computeFlattenedNodes();\n\t\t\tconst selectedNode = flattened.find((curNode) => curNode.node.selected);\n\t\t\treturn selectedNode ? [selectedNode.treeIndex] : [];\n\t\t}\n\t);\n\tconst [focusedNodeIndex, setFocusedNodeIndex] = useState<string | undefined>(\n\t\t() => {\n\t\t\tconst flattened = computeFlattenedNodes();\n\t\t\tconst selectedNode = flattened.find((curNode) => curNode.node.selected);\n\t\t\treturn selectedNode?.treeIndex;\n\t\t}\n\t);\n\n\t// Check props on mount\n\tuseEffect(() => {\n\t\tcheckProps(\n\t\t\tTREE,\n\t\t\t{\n\t\t\t\tassistiveText: assistiveTextProp,\n\t\t\t\tclassName,\n\t\t\t\tlistClassName,\n\t\t\t\tgetNodes,\n\t\t\t\theading: headingProp,\n\t\t\t\tid,\n\t\t\t\tlabels,\n\t\t\t\tnodes,\n\t\t\t\tonSelect,\n\t\t\t\tonClick,\n\t\t\t\tonRequestToggle,\n\t\t\t\tonExpandClick,\n\t\t\t\tonScroll,\n\t\t\t\tsearchTerm,\n\t\t\t\tlistStyle,\n\t\t\t},\n\t\t\tcomponentDoc\n\t\t);\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, []);\n\n\t// Update flattened nodes when nodes prop changes\n\tuseEffect(() => {\n\t\tsetFlattenedNodes(computeFlattenedNodes());\n\t}, [computeFlattenedNodes, nodes]);\n\n\t// Handle node selection\n\tconst handleSelect = useCallback(\n\t\t({\n\t\t\tevent,\n\t\t\tdata,\n\t\t\tclearSelectedNodes,\n\t\t\tfromFocus,\n\t\t}: {\n\t\t\tevent: React.SyntheticEvent;\n\t\t\tdata: TreeSelectData;\n\t\t\tclearSelectedNodes?: boolean;\n\t\t\tfromFocus?: boolean;\n\t\t}) => {\n\t\t\t// When triggered by a key event, other nodes should be deselected\n\t\t\tif (clearSelectedNodes) {\n\t\t\t\tflattenedNodes.forEach((flattenedNode) => {\n\t\t\t\t\tif (flattenedNode.node.selected) {\n\t\t\t\t\t\tflattenedNode.node.selected = false;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Prevent firing twice on first click due to focus event\n\t\t\tif (!fromFocus) {\n\t\t\t\tif (onSelect) {\n\t\t\t\t\tonSelect(event, { node: data.node, isSelected: data.select });\n\t\t\t\t} else if (onClick) {\n\t\t\t\t\tonClick(event, data);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Update selected and focused nodes\n\t\t\tlet newSelectedNodeIndexes: string[];\n\t\t\tif (data.select) {\n\t\t\t\tnewSelectedNodeIndexes = [...selectedNodeIndexes, data.treeIndex];\n\t\t\t} else {\n\t\t\t\tnewSelectedNodeIndexes = selectedNodeIndexes.filter(\n\t\t\t\t\t(treeIndex) => treeIndex !== data.treeIndex\n\t\t\t\t);\n\t\t\t}\n\n\t\t\ttreeHasFocusRef.current = true;\n\t\t\tsetFocusedNodeIndex(data.treeIndex);\n\t\t\tsetSelectedNodeIndexes(newSelectedNodeIndexes);\n\t\t},\n\t\t[flattenedNodes, onSelect, onClick, selectedNodeIndexes]\n\t);\n\n\t// Handle node blur\n\tconst handleNodeBlur = useCallback(() => {\n\t\ttreeHasFocusRef.current = false;\n\t}, []);\n\n\t// Handle expand/collapse\n\tconst handleExpand = useCallback(\n\t\t({\n\t\t\tevent,\n\t\t\tdata,\n\t\t}: {\n\t\t\tevent: React.SyntheticEvent;\n\t\t\tdata: TreeExpandData;\n\t\t}) => {\n\t\t\t// `data.select` marks Left arrow on a collapsed branch or item: move to the parent node.\n\t\t\tif (data.select) {\n\t\t\t\tif (!onRequestToggle && onExpandClick) {\n\t\t\t\t\t// Deprecated behavior: report it to `onExpandClick` with the parent node\n\t\t\t\t\ttreeHasFocusRef.current = true;\n\t\t\t\t\tonExpandClick(event, data);\n\t\t\t\t\tsetFocusedNodeIndex(data.treeIndex);\n\t\t\t\t} else {\n\t\t\t\t\t// Not an expand/collapse request: select the parent, like Up/Down arrows do\n\t\t\t\t\thandleSelect({\n\t\t\t\t\t\tevent,\n\t\t\t\t\t\tdata: { node: data.node, select: true, treeIndex: data.treeIndex },\n\t\t\t\t\t\tclearSelectedNodes: true,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\ttreeHasFocusRef.current = true;\n\t\t\tif (onRequestToggle) {\n\t\t\t\tonRequestToggle(event, { node: data.node, isExpanded: data.expand });\n\t\t\t} else if (onExpandClick) {\n\t\t\t\tonExpandClick(event, data);\n\t\t\t}\n\t\t},\n\t\t[handleSelect, onRequestToggle, onExpandClick]\n\t);\n\n\t// Determine heading text\n\tconst headingText = assistiveHeading || visibleHeading;\n\n\treturn (\n\t\t<div id={id} className={classNames('slds-tree_container', className)}>\n\t\t\t<h4\n\t\t\t\tclassName={classNames('slds-tree__group-header', {\n\t\t\t\t\t'slds-assistive-text': !!assistiveHeading,\n\t\t\t\t})}\n\t\t\t\tid={`${id}__heading`}\n\t\t\t>\n\t\t\t\t{headingText}\n\t\t\t</h4>\n\t\t\t<Branch\n\t\t\t\tgetNodes={getNodes}\n\t\t\t\tinitalClassName={listClassName}\n\t\t\t\thtmlId={id}\n\t\t\t\tinitialStyle={listStyle}\n\t\t\t\tlevel={0}\n\t\t\t\tnode={{ nodes }}\n\t\t\t\tflattenedNodes={flattenedNodes}\n\t\t\t\tselectedNodeIndexes={selectedNodeIndexes}\n\t\t\t\tfocusedNodeIndex={focusedNodeIndex}\n\t\t\t\ttreeHasFocus={treeHasFocusRef.current}\n\t\t\t\tonNodeBlur={handleNodeBlur}\n\t\t\t\tonSelect={handleSelect}\n\t\t\t\tonExpand={handleExpand}\n\t\t\t\tonScroll={onScroll}\n\t\t\t\tsearchTerm={searchTerm}\n\t\t\t\ttreeId={id}\n\t\t\t/>\n\t\t</div>\n\t);\n};\n\nTree.displayName = TREE;\n\nexport default Tree;\n"],"mappings":";;;;;;;;AAiGA,IAAM,KACL,GACA,GACA,IAAY,IACZ,IAAa,OACQ;CACrB,IAAI,CAAC,EAAK,OACT,OAAO,CAAC;EAAE,MAAM;EAAkB;CAAU,CAAC;CAE9C,IAAI,IAAyB,CAAC;EAAE,MAAM;EAAkB;CAAU,CAAC;CACnE,IAAI,EAAK,UACR,KAAK,IAAI,IAAQ,GAAG,IAAQ,EAAK,MAAM,QAAQ,KAAS,GAAG;EAC1D,IAAM,IAAU,IAAa,EAAK,MAAM,KAAS,EAAS,CAAI,CAAC,GAAG;EAClE,AAAI,MACH,IAAQ,EAAM,OACb,EACC,GACA,GACA,IAAY,GAAG,EAAU,GAAG,MAAU,GAAG,KACzC,EACD,CACD;CAEF;CAED,OAAO;AACR,GAEM,KAAmB,MAAiC,EAAK,OAOzD,KAA6B,EAClC,eAAe,GACf,cACA,kBACA,cAAW,GACX,SAAS,GACT,OACA,WACA,UACA,aACA,YACA,oBACA,kBACA,aACA,eACA,mBACK;CAEL,IAAM,IACL,GAAmB,WAAW,GAAmB,OAE5C,IAAiB,GAAQ,WAAW,GAGpC,IAAkB,EAAO,EAAK,GAG9B,IAAwB,QACtB,EACN;EACC,OAAO,EAAS,EAAE,SAAM,CAAC;EACzB,UAAU;CACX,GACA,CACD,CAAC,CAAC,MAAM,CAAC,GACP,CAAC,GAAU,CAAK,CAAC,GAGd,CAAC,GAAgB,KAAqB,EAC3C,CACD,GACM,CAAC,GAAqB,KAA0B,QAC/C;EAEL,IAAM,IADY,EACG,CAAA,CAAU,MAAM,MAAY,EAAQ,KAAK,QAAQ;EACtE,OAAO,IAAe,CAAC,EAAa,SAAS,IAAI,CAAC;CACnD,CACD,GACM,CAAC,GAAkB,KAAuB,QAE5B,EACG,CAAA,CAAU,MAAM,M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,GAAO,CAAI;CAE3B,GACA;EAAC;EAAc;EAAiB;CAAa,CAC9C,GAGM,IAAc,KAAoB;CAExC,OACC,kBAAC,OAAD;EAAS;EAAI,WAAW,EAAW,uBAAuB,CAAS;EAAnE,UAAA,CACC,kBAAC,MAAD;GACC,WAAW,EAAW,2BAA2B,EAChD,uBAAuB,CAAC,CAAC,EAC1B,CAAC;GACD,IAAI,GAAG,EAAG;GAET,UAAA;EACE,CAAA,GACJ,kBAAC,GAAD;GACW;GACV,iBAAiB;GACjB,QAAQ;GACR,cAAc;GACd,OAAO;GACP,MAAM,EAAE,SAAM;GACE;GACK;GACH;GAClB,cAAc,EAAgB;GAC9B,YAAY;GACZ,UAAU;GACV,UAAU;GACA;GACE;GACZ,QAAQ;EACR,CAAA,CACG;;AAEP;AAEA,EAAK,cAAc"}
|
|
1
|
+
{"version":3,"file":"tree.js","names":[],"sources":["../../../../components/tree/tree.tsx"],"sourcesContent":["/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\nimport React, {\n\tforwardRef,\n\tuseState,\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n} from 'react';\nimport classNames from 'classnames';\n// Using native Array.find instead of lodash for better TypeScript support\n\n// Child components\nimport Branch from './private/branch';\n\n// Similar to React's PropTypes check\nimport checkProps, { checkLegacyNodeFields } from './check-props';\nimport { useControllableState } from '../../utilities/hooks';\n\n// Constants\nimport { TREE } from '../../utilities/constants';\nimport componentDoc from './component.json';\n\nimport {\n\tTreeNode,\n\tTreeNodeId,\n\tFlattenedNode,\n\tTreeAssistiveText,\n\tTreeLabels,\n\tTreeNodeSelectData,\n\tTreeRequestToggleData,\n\tTreeSelectData,\n\tTreeExpandData,\n\tTreeScrollData,\n} from './types';\n\nexport interface TreeProps {\n\t/**\n\t * **Assistive text for accessibility**\n\t * * `heading`: Visually hidden tree heading. Set this or `labels.heading`.\n\t */\n\tassistiveText?: TreeAssistiveText;\n\t/** Class names for the root `.slds-tree_container` div */\n\tclassName?: string | string[] | Record<string, boolean>;\n\t/** Class names for the top-level `ul.slds-tree` element */\n\tclassNameList?: string | string[] | Record<string, boolean>;\n\t/** @deprecated Use `classNameList`. */\n\tlistClassName?: string | string[] | Record<string, boolean>;\n\t/** Function to get child nodes from a parent node */\n\tgetNodes?: (node: { nodes?: TreeNode[] }) => TreeNode[] | undefined;\n\t/** @deprecated Use `labels.heading` instead. */\n\theading?: ReactNode;\n\t/** HTML id of the tree container (required) */\n\tid: string;\n\t/**\n\t * **Text labels for internationalization**\n\t * * `heading`: Visible tree heading that describes its contents. Set this or `assistiveText.heading`.\n\t */\n\tlabels?: TreeLabels;\n\t/**\n\t * Array of tree nodes. The tree never modifies them: selection comes from `selectedIds` and\n\t * expansion from `expandedIds` / `defaultExpandedIds`.\n\t */\n\tnodes: TreeNode[];\n\t/**\n\t * Ids of the selected nodes (`[]` for none). The tree is controlled: it renders this selection and\n\t * reports changes through `onSelect`, where `data.selectedIds` is the requested selection.\n\t *\n\t * When omitted, the tree falls back to the deprecated `node.selected` fields (read-only) and warns.\n\t */\n\tselectedIds: TreeNodeId[];\n\t/**\n\t * Ids of the expanded branches. Pass it to control expansion and update it from\n\t * `onRequestToggle` (`data.expandedIds` is the requested set). Leave it `undefined` to let the\n\t * tree manage expansion itself, starting from `defaultExpandedIds`.\n\t */\n\texpandedIds?: TreeNodeId[];\n\t/**\n\t * Ids of the branches expanded on first render when `expandedIds` is not passed. Defaults to `[]`.\n\t *\n\t * When neither `expandedIds` nor `defaultExpandedIds` is passed, a branch's deprecated\n\t * `node.expanded` field (read-only) still decides whether it is expanded, and the tree warns.\n\t */\n\tdefaultExpandedIds?: TreeNodeId[];\n\t/**\n\t * Called when an item or branch is selected or deselected: by click, by focus, or by keyboard\n\t * (Enter, Up/Down arrows, Right arrow into an expanded branch, Left arrow to the parent node).\n\t * `data.isSelected` is the requested selection state of `data.node` and `data.selectedIds` the\n\t * requested selection. Update `selectedIds` to apply it. Required: without it, selecting a\n\t * node does nothing.\n\t */\n\tonSelect: (event: React.SyntheticEvent, data: TreeNodeSelectData) => void;\n\t/**\n\t * Called when an item or branch is selected.\n\t * @deprecated Use `onSelect`, which receives `{ node, isSelected }`. Ignored when `onSelect` is passed.\n\t */\n\tonClick?: (event: React.SyntheticEvent, data: TreeSelectData) => void;\n\t/**\n\t * Called when a branch is asked to expand or collapse: by clicking its toggle button, by Right\n\t * arrow on a collapsed branch, or by Left arrow on an expanded branch. `data.isExpanded` is the\n\t * requested expansion state of `data.node` and `data.expandedIds` the requested set. Called\n\t * whether or not expansion is controlled; when `expandedIds` is passed, update it to apply the change.\n\t */\n\tonRequestToggle?: (\n\t\tevent: React.SyntheticEvent,\n\t\tdata: TreeRequestToggleData\n\t) => void;\n\t/**\n\t * Called when a branch's expand/collapse button is clicked, or when the Left arrow is pressed\n\t * on a collapsed branch or item (with `data.select: true` and `data.node` set to the parent).\n\t * @deprecated Use `onRequestToggle`, which receives `{ node, isExpanded }`. With\n\t * `onRequestToggle`, Left arrow on a collapsed branch or item selects the parent via\n\t * `onSelect` instead. Ignored when `onRequestToggle` is passed.\n\t */\n\tonExpandClick?: (event: React.SyntheticEvent, data: TreeExpandData) => void;\n\t/** Callback when the tree list scrolls. `data.ratio` is the scroll position from `0` to `1`. */\n\tonScroll?: (\n\t\tevent: React.UIEvent<HTMLUListElement>,\n\t\tdata: TreeScrollData\n\t) => void;\n\t/** Search term to highlight in node labels */\n\tsearchTerm?: string;\n\t/** Styles for the top-level `ul.slds-tree` element */\n\tstyleList?: React.CSSProperties;\n\t/** @deprecated Use `styleList`. */\n\tlistStyle?: React.CSSProperties;\n}\n\ntype ReactNode = React.ReactNode;\n\ntype GetNodes = (node: { nodes?: TreeNode[] }) => TreeNode[] | undefined;\n\nconst EMPTY_IDS: TreeNodeId[] = [];\n\n/**\n * Flattens the visible part of the tree (expanded branches only) into a flat array.\n * The first item is the root and should be removed with slice(1).\n */\nconst flattenTree = (\n\troot: { nodes?: TreeNode[] },\n\tgetNodes: GetNodes,\n\tisExpanded: (node: TreeNode) => boolean,\n\ttreeIndex = '',\n\tfirstLevel = true\n): FlattenedNode[] => {\n\tif (!root.nodes) {\n\t\treturn [{ node: root as TreeNode, treeIndex }];\n\t}\n\tlet nodes: FlattenedNode[] = [{ node: root as TreeNode, treeIndex }];\n\tif (firstLevel || isExpanded(root as TreeNode)) {\n\t\tfor (let index = 0; index < root.nodes.length; index += 1) {\n\t\t\tconst curNode = firstLevel ? root.nodes[index] : getNodes(root)?.[index];\n\t\t\tif (curNode) {\n\t\t\t\tnodes = nodes.concat(\n\t\t\t\t\tflattenTree(\n\t\t\t\t\t\tcurNode,\n\t\t\t\t\t\tgetNodes,\n\t\t\t\t\t\tisExpanded,\n\t\t\t\t\t\ttreeIndex ? `${treeIndex}-${index}` : `${index}`,\n\t\t\t\t\t\tfalse\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\treturn nodes;\n};\n\n/**\n * Ids of every node in the tree (visible or not) that matches `predicate`.\n * Used only for the deprecated `node.selected` / `node.expanded` fallback.\n */\nconst collectNodeIds = (\n\tnodes: TreeNode[],\n\tgetNodes: GetNodes,\n\tpredicate: (node: TreeNode) => boolean\n): TreeNodeId[] => {\n\tconst ids: TreeNodeId[] = [];\n\tconst visited = new Set<TreeNode>();\n\tconst visit = (list: TreeNode[] | undefined) => {\n\t\tlist?.forEach((node) => {\n\t\t\tif (node && !visited.has(node)) {\n\t\t\t\tvisited.add(node);\n\t\t\t\tif (predicate(node)) {\n\t\t\t\t\tids.push(node.id);\n\t\t\t\t}\n\t\t\t\tvisit(getNodes(node));\n\t\t\t}\n\t\t});\n\t};\n\tvisit(getNodes({ nodes }));\n\treturn ids;\n};\n\nconst defaultGetNodes = (node: { nodes?: TreeNode[] }) => node.nodes;\n\n/**\n * A tree is visualization of a structure hierarchy.\n * A branch can be expanded or collapsed.\n * Selection is controlled through `selectedIds`. Expansion is controlled through `expandedIds`, or\n * managed by the tree (starting from `defaultExpandedIds`) when `expandedIds` is not passed.\n */\nconst Tree = forwardRef<HTMLDivElement, TreeProps>(\n\t(\n\t\t{\n\t\t\tassistiveText: assistiveTextProp,\n\t\t\tclassName,\n\t\t\tclassNameList,\n\t\t\tlistClassName,\n\t\t\tgetNodes = defaultGetNodes,\n\t\t\theading: headingProp,\n\t\t\tid,\n\t\t\tlabels,\n\t\t\tnodes,\n\t\t\tselectedIds,\n\t\t\texpandedIds,\n\t\t\tdefaultExpandedIds,\n\t\t\tonSelect,\n\t\t\tonClick,\n\t\t\tonRequestToggle,\n\t\t\tonExpandClick,\n\t\t\tonScroll,\n\t\t\tsearchTerm,\n\t\t\tstyleList,\n\t\t\tlistStyle,\n\t\t},\n\t\tref\n\t) => {\n\t\t// `assistiveText.label` is deprecated\n\t\tconst assistiveHeading =\n\t\t\tassistiveTextProp?.heading ?? assistiveTextProp?.label;\n\t\t// `heading` is deprecated\n\t\tconst visibleHeading = labels?.heading ?? headingProp;\n\n\t\t// Without `selectedIds`, selection is read from the deprecated `node.selected` fields\n\t\tconst isLegacySelection = selectedIds === undefined;\n\t\t// Without `expandedIds` and `defaultExpandedIds`, the deprecated `node.expanded` fields win\n\t\tconst isLegacyExpansion =\n\t\t\texpandedIds === undefined && defaultExpandedIds === undefined;\n\n\t\t// Expansion is ephemeral UI state: controlled when `expandedIds` is passed\n\t\tconst [currentExpandedIds, setExpandedIds] = useControllableState(\n\t\t\texpandedIds,\n\t\t\tdefaultExpandedIds ?? EMPTY_IDS\n\t\t);\n\n\t\tconst selectedIdSet = useMemo(\n\t\t\t() => new Set<TreeNodeId>(selectedIds ?? EMPTY_IDS),\n\t\t\t[selectedIds]\n\t\t);\n\t\tconst expandedIdSet = useMemo(\n\t\t\t() => new Set<TreeNodeId>(currentExpandedIds),\n\t\t\t[currentExpandedIds]\n\t\t);\n\n\t\tconst isNodeSelected = useCallback(\n\t\t\t(node: TreeNode) =>\n\t\t\t\tisLegacySelection ? !!node.selected : selectedIdSet.has(node.id),\n\t\t\t[isLegacySelection, selectedIdSet]\n\t\t);\n\n\t\tconst isNodeExpanded = useCallback(\n\t\t\t(node: TreeNode) =>\n\t\t\t\tisLegacyExpansion && node.expanded !== undefined\n\t\t\t\t\t? !!node.expanded\n\t\t\t\t\t: expandedIdSet.has(node.id),\n\t\t\t[isLegacyExpansion, expandedIdSet]\n\t\t);\n\n\t\t// Track if tree has focus\n\t\tconst treeHasFocusRef = useRef(false);\n\n\t\t// Visible nodes in display order\n\t\tconst flattenedNodes = useMemo(\n\t\t\t() =>\n\t\t\t\tflattenTree(\n\t\t\t\t\t{ nodes: getNodes({ nodes }) },\n\t\t\t\t\tgetNodes,\n\t\t\t\t\tisNodeExpanded\n\t\t\t\t).slice(1),\n\t\t\t[getNodes, nodes, isNodeExpanded]\n\t\t);\n\n\t\t// Roving focus is ephemeral and internal. Until a node has been focused, the first visible\n\t\t// selected node is the tab stop.\n\t\tconst [focusedNodeIndex, setFocusedNodeIndex] = useState<\n\t\t\tstring | undefined\n\t\t>(undefined);\n\t\tconst effectiveFocusedNodeIndex =\n\t\t\tfocusedNodeIndex ??\n\t\t\tflattenedNodes.find((flattenedNode) => isNodeSelected(flattenedNode.node))\n\t\t\t\t?.treeIndex;\n\t\tconst tabStopIndex =\n\t\t\teffectiveFocusedNodeIndex ?? flattenedNodes[0]?.treeIndex;\n\n\t\t// Check props on mount\n\t\tuseEffect(() => {\n\t\t\tcheckProps(\n\t\t\t\tTREE,\n\t\t\t\t{\n\t\t\t\t\tassistiveText: assistiveTextProp,\n\t\t\t\t\tclassName,\n\t\t\t\t\tclassNameList,\n\t\t\t\t\tlistClassName,\n\t\t\t\t\tgetNodes,\n\t\t\t\t\theading: headingProp,\n\t\t\t\t\tid,\n\t\t\t\t\tlabels,\n\t\t\t\t\tnodes,\n\t\t\t\t\tselectedIds,\n\t\t\t\t\texpandedIds,\n\t\t\t\t\tdefaultExpandedIds,\n\t\t\t\t\tonSelect,\n\t\t\t\t\tonClick,\n\t\t\t\t\tonRequestToggle,\n\t\t\t\t\tonExpandClick,\n\t\t\t\t\tonScroll,\n\t\t\t\t\tsearchTerm,\n\t\t\t\t\tstyleList,\n\t\t\t\t\tlistStyle,\n\t\t\t\t},\n\t\t\t\tcomponentDoc\n\t\t\t);\n\t\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t}, []);\n\n\t\t// Warn about the deprecated `node.expanded` fallback whenever visible nodes use it\n\t\tuseEffect(() => {\n\t\t\tif (process.env.NODE_ENV !== 'production' && isLegacyExpansion) {\n\t\t\t\tcheckLegacyNodeFields(TREE, {\n\t\t\t\t\thasExpandedField: flattenedNodes.some(\n\t\t\t\t\t\t(flattenedNode) => flattenedNode.node.expanded !== undefined\n\t\t\t\t\t),\n\t\t\t\t});\n\t\t\t}\n\t\t}, [isLegacyExpansion, flattenedNodes]);\n\n\t\tconst getSelectedIds = useCallback(\n\t\t\t() =>\n\t\t\t\tisLegacySelection\n\t\t\t\t\t? collectNodeIds(nodes, getNodes, (node) => !!node.selected)\n\t\t\t\t\t: (selectedIds as TreeNodeId[]),\n\t\t\t[isLegacySelection, nodes, getNodes, selectedIds]\n\t\t);\n\n\t\tconst getExpandedIds = useCallback(\n\t\t\t() =>\n\t\t\t\tisLegacyExpansion\n\t\t\t\t\t? collectNodeIds(\n\t\t\t\t\t\t\tnodes,\n\t\t\t\t\t\t\tgetNodes,\n\t\t\t\t\t\t\t(node) => node.type === 'branch' && isNodeExpanded(node)\n\t\t\t\t\t\t)\n\t\t\t\t\t: currentExpandedIds,\n\t\t\t[isLegacyExpansion, nodes, getNodes, isNodeExpanded, currentExpandedIds]\n\t\t);\n\n\t\t// Handle node selection. Never writes to `nodes`: it reports the requested selection.\n\t\tconst handleSelect = useCallback(\n\t\t\t({\n\t\t\t\tevent,\n\t\t\t\tdata,\n\t\t\t\tclearSelectedNodes,\n\t\t\t\tfromFocus,\n\t\t\t}: {\n\t\t\t\tevent: React.SyntheticEvent;\n\t\t\t\tdata: TreeSelectData;\n\t\t\t\tclearSelectedNodes?: boolean;\n\t\t\t\tfromFocus?: boolean;\n\t\t\t}) => {\n\t\t\t\t// Prevent firing twice on first click due to focus event\n\t\t\t\tif (!fromFocus) {\n\t\t\t\t\tif (onSelect) {\n\t\t\t\t\t\t// Keyboard navigation moves the selection to the node; click and Enter toggle it\n\t\t\t\t\t\tconst others = clearSelectedNodes\n\t\t\t\t\t\t\t? []\n\t\t\t\t\t\t\t: getSelectedIds().filter((nodeId) => nodeId !== data.node.id);\n\t\t\t\t\t\tonSelect(event, {\n\t\t\t\t\t\t\tnode: data.node,\n\t\t\t\t\t\t\tisSelected: data.select,\n\t\t\t\t\t\t\tselectedIds: data.select ? [...others, data.node.id] : others,\n\t\t\t\t\t\t});\n\t\t\t\t\t} else if (onClick) {\n\t\t\t\t\t\tonClick(event, data);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\ttreeHasFocusRef.current = true;\n\t\t\t\tsetFocusedNodeIndex(data.treeIndex);\n\t\t\t},\n\t\t\t[getSelectedIds, onSelect, onClick]\n\t\t);\n\n\t\t// Handle node blur\n\t\tconst handleNodeBlur = useCallback(() => {\n\t\t\ttreeHasFocusRef.current = false;\n\t\t}, []);\n\n\t\t// Handle expand/collapse\n\t\tconst handleExpand = useCallback(\n\t\t\t({\n\t\t\t\tevent,\n\t\t\t\tdata,\n\t\t\t}: {\n\t\t\t\tevent: React.SyntheticEvent;\n\t\t\t\tdata: TreeExpandData;\n\t\t\t}) => {\n\t\t\t\t// `data.select` marks Left arrow on a collapsed branch or item: move to the parent node.\n\t\t\t\tif (data.select) {\n\t\t\t\t\tif (!onRequestToggle && onExpandClick) {\n\t\t\t\t\t\t// Deprecated behavior: report it to `onExpandClick` with the parent node\n\t\t\t\t\t\ttreeHasFocusRef.current = true;\n\t\t\t\t\t\tonExpandClick(event, data);\n\t\t\t\t\t\tsetFocusedNodeIndex(data.treeIndex);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Not an expand/collapse request: select the parent, like Up/Down arrows do\n\t\t\t\t\t\thandleSelect({\n\t\t\t\t\t\t\tevent,\n\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\tnode: data.node,\n\t\t\t\t\t\t\t\tselect: true,\n\t\t\t\t\t\t\t\ttreeIndex: data.treeIndex,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tclearSelectedNodes: true,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\ttreeHasFocusRef.current = true;\n\t\t\t\tconst others = getExpandedIds().filter(\n\t\t\t\t\t(nodeId) => nodeId !== data.node.id\n\t\t\t\t);\n\t\t\t\tconst nextExpandedIds = data.expand\n\t\t\t\t\t? [...others, data.node.id]\n\t\t\t\t\t: others;\n\t\t\t\t// No-op when `expandedIds` is controlled\n\t\t\t\tsetExpandedIds(nextExpandedIds);\n\t\t\t\tif (onRequestToggle) {\n\t\t\t\t\tonRequestToggle(event, {\n\t\t\t\t\t\tnode: data.node,\n\t\t\t\t\t\tisExpanded: data.expand,\n\t\t\t\t\t\texpandedIds: nextExpandedIds,\n\t\t\t\t\t});\n\t\t\t\t} else if (onExpandClick) {\n\t\t\t\t\tonExpandClick(event, data);\n\t\t\t\t}\n\t\t\t},\n\t\t\t[\n\t\t\t\thandleSelect,\n\t\t\t\tgetExpandedIds,\n\t\t\t\tsetExpandedIds,\n\t\t\t\tonRequestToggle,\n\t\t\t\tonExpandClick,\n\t\t\t]\n\t\t);\n\n\t\t// Determine heading text\n\t\tconst headingText = assistiveHeading || visibleHeading;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tid={id}\n\t\t\t\tclassName={classNames('slds-tree_container', className)}\n\t\t\t\tref={ref}\n\t\t\t>\n\t\t\t\t<h4\n\t\t\t\t\tclassName={classNames('slds-tree__group-header', {\n\t\t\t\t\t\t'slds-assistive-text': !!assistiveHeading,\n\t\t\t\t\t})}\n\t\t\t\t\tid={`${id}__heading`}\n\t\t\t\t>\n\t\t\t\t\t{headingText}\n\t\t\t\t</h4>\n\t\t\t\t<Branch\n\t\t\t\t\tgetNodes={getNodes}\n\t\t\t\t\tinitalClassName={classNames(listClassName, classNameList)}\n\t\t\t\t\thtmlId={id}\n\t\t\t\t\tinitialStyle={\n\t\t\t\t\t\tlistStyle || styleList ? { ...listStyle, ...styleList } : undefined\n\t\t\t\t\t}\n\t\t\t\t\tlevel={0}\n\t\t\t\t\tnode={{ nodes }}\n\t\t\t\t\tflattenedNodes={flattenedNodes}\n\t\t\t\t\tisNodeSelected={isNodeSelected}\n\t\t\t\t\tisNodeExpanded={isNodeExpanded}\n\t\t\t\t\ttabStopIndex={tabStopIndex}\n\t\t\t\t\tfocusedNodeIndex={effectiveFocusedNodeIndex}\n\t\t\t\t\ttreeHasFocus={treeHasFocusRef.current}\n\t\t\t\t\tonNodeBlur={handleNodeBlur}\n\t\t\t\t\tonSelect={handleSelect}\n\t\t\t\t\tonExpand={handleExpand}\n\t\t\t\t\tonScroll={onScroll}\n\t\t\t\t\tsearchTerm={searchTerm}\n\t\t\t\t\ttreeId={id}\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n);\n\nTree.displayName = TREE;\n\nexport default Tree;\n"],"mappings":";;;;;;;;;AAsIA,IAAM,IAA0B,CAAC,GAM3B,KACL,GACA,GACA,GACA,IAAY,IACZ,IAAa,OACQ;CACrB,IAAI,CAAC,EAAK,OACT,OAAO,CAAC;EAAE,MAAM;EAAkB;CAAU,CAAC;CAE9C,IAAI,IAAyB,CAAC;EAAE,MAAM;EAAkB;CAAU,CAAC;CACnE,IAAI,KAAc,EAAW,CAAgB,GAC5C,KAAK,IAAI,IAAQ,GAAG,IAAQ,EAAK,MAAM,QAAQ,KAAS,GAAG;EAC1D,IAAM,IAAU,IAAa,EAAK,MAAM,KAAS,EAAS,CAAI,CAAC,GAAG;EAClE,AAAI,MACH,IAAQ,EAAM,OACb,EACC,GACA,G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Ac,EAAgB;GAC9B,YAAY;GACZ,UAAU;GACV,UAAU;GACA;GACE;GACZ,QAAQ;EACR,CAAA,CACG;;AAEP,CACD;AAEA,EAAK,cAAc"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import e from "../../utilities/get-component-doc.js";
|
|
2
|
+
import "../../utilities/warning/deprecated-property.js";
|
|
3
|
+
import t from "../../utilities/warning/required-property.js";
|
|
4
|
+
process.env.NODE_ENV;
|
|
5
|
+
var n = function() {};
|
|
6
|
+
process.env.NODE_ENV !== "production" && (n = function(n, r, i) {
|
|
7
|
+
let a = e(i);
|
|
8
|
+
t(n, r.selectedId !== void 0, "selectedId", `VerticalNavigation is controlled and no longer selects the first item by default: pass \`selectedId\` (or \`null\` for no selection) and update it in \`onSelect\`. ${a("selectedId")}`);
|
|
9
|
+
});
|
|
10
|
+
//#endregion
|
|
11
|
+
export { n as checkRequiredProps };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=check-props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-props.js","names":[],"sources":["../../../../components/vertical-navigation/check-props.js"],"sourcesContent":["/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n/* eslint-disable import/no-mutable-exports */\n\nimport deprecatedProperty from '../../utilities/warning/deprecated-property';\nimport requiredProperty from '../../utilities/warning/required-property';\nimport getComponentDocFn from '../../utilities/get-component-doc';\n\nlet checkProps = function checkPropsFunction() {};\n\nif (process.env.NODE_ENV !== 'production') {\n\tcheckProps = function checkPropsFunction(COMPONENT, props) {\n\t\tdeprecatedProperty(\n\t\t\tCOMPONENT,\n\t\t\tprops.variant,\n\t\t\t'variant',\n\t\t\tundefined,\n\t\t\t'Shade variant is deprecated as there is no background supported currently. Vertical Navigation now uses a default shade.'\n\t\t);\n\t};\n}\n\n// Controlled-selection checks. Exported separately so the component can run\n// them without enabling the pre-existing `checkProps` warnings.\nexport let checkRequiredProps = function checkRequiredPropsFunction() {};\n\nif (process.env.NODE_ENV !== 'production') {\n\tcheckRequiredProps = function checkRequiredPropsFunction(\n\t\tCOMPONENT,\n\t\tprops,\n\t\tjsonDoc\n\t) {\n\t\tconst createDocUrl = getComponentDocFn(jsonDoc);\n\n\t\trequiredProperty(\n\t\t\tCOMPONENT,\n\t\t\tprops.selectedId !== undefined,\n\t\t\t'selectedId',\n\t\t\t`VerticalNavigation is controlled and no longer selects the first item by default: pass \\`selectedId\\` (or \\`null\\` for no selection) and update it in \\`onSelect\\`. ${createDocUrl('selectedId')}`\n\t\t);\n\t};\n}\n\nexport default checkProps;\n"],"mappings":";;;AAUA,QAAA,IAAA;AAcA,IAAW,IAAqB,WAAsC,CAAC;AAEvE,QAAA,IAAA,aAA6B,iBAC5B,IAAqB,SACpB,GACA,GACA,GACC;CACD,IAAM,IAAe,EAAkB,CAAO;CAE9C,EACC,GACA,EAAM,eAAe,KAAA,GACrB,cACA,uKAAuK,EAAa,YAAY,GACjM;AACD"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//#region components/vertical-navigation/component.json
|
|
2
|
+
var e = "vertical-navigation", t = "prod", n = "VerticalNavigation", r = {
|
|
3
|
+
component: e,
|
|
4
|
+
status: t,
|
|
5
|
+
"display-name": "Vertical Navigation",
|
|
6
|
+
classKey: n,
|
|
7
|
+
"SLDS-component-path": "/components/vertical-navigation",
|
|
8
|
+
"site-stories": [
|
|
9
|
+
{
|
|
10
|
+
heading: "Default",
|
|
11
|
+
path: "/__examples__/default.jsx"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
heading: "Items with Icons",
|
|
15
|
+
path: "/__examples__/icons.jsx"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
heading: "Items with Notifications",
|
|
19
|
+
path: "/__examples__/notifications.jsx"
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
"url-slug": "vertical-navigation"
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
export { n as classKey, e as component, r as default, t as status };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.js","names":[],"sources":["../../../../components/vertical-navigation/component.json"],"sourcesContent":["{\n\t\"component\": \"vertical-navigation\",\n\t\"status\": \"prod\",\n\t\"display-name\": \"Vertical Navigation\",\n\t\"classKey\": \"VerticalNavigation\",\n\t\"SLDS-component-path\": \"/components/vertical-navigation\",\n\t\"site-stories\": [\n\t\t{\n\t\t\t\"heading\": \"Default\",\n\t\t\t\"path\": \"/__examples__/default.jsx\"\n\t\t},\n\t\t{\n\t\t\t\"heading\": \"Items with Icons\",\n\t\t\t\"path\": \"/__examples__/icons.jsx\"\n\t\t},\n\t\t{\n\t\t\t\"heading\": \"Items with Notifications\",\n\t\t\t\"path\": \"/__examples__/notifications.jsx\"\n\t\t}\n\t],\n\t\"url-slug\": \"vertical-navigation\"\n}\n"],"mappings":""}
|