@salesforce/design-system-react 11.0.0-rc.0 → 11.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -1
- package/dist/cjs/components/accordion/index.cjs +1 -1
- package/dist/cjs/components/accordion/index.cjs.map +1 -1
- package/dist/cjs/components/accordion/panel.cjs.map +1 -1
- package/dist/cjs/components/alert/index.cjs +1 -1
- package/dist/cjs/components/alert/index.cjs.map +1 -1
- package/dist/cjs/components/builder-header/nav-dropdown.cjs.map +1 -1
- package/dist/cjs/components/builder-header/nav-link.cjs.map +1 -1
- package/dist/cjs/components/builder-header/toolbar.cjs.map +1 -1
- package/dist/cjs/components/button/check-props.cjs +1 -1
- package/dist/cjs/components/button/check-props.cjs.map +1 -1
- package/dist/cjs/components/button/index.cjs +1 -1
- package/dist/cjs/components/button/index.cjs.map +1 -1
- package/dist/cjs/components/button-stateful/check-props.cjs +1 -1
- package/dist/cjs/components/button-stateful/check-props.cjs.map +1 -1
- 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/carousel/private/carousel-indicators.cjs.map +1 -1
- package/dist/cjs/components/carousel/private/carousel-item.cjs +1 -1
- package/dist/cjs/components/carousel/private/carousel-item.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/color-picker.cjs +1 -1
- package/dist/cjs/components/color-picker/color-picker.cjs.map +1 -1
- package/dist/cjs/components/color-picker/private/custom-color.cjs.map +1 -1
- 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/color-picker/private/swatch-option.cjs +1 -1
- package/dist/cjs/components/color-picker/private/swatch-option.cjs.map +1 -1
- package/dist/cjs/components/color-picker/private/swatch.cjs +1 -1
- package/dist/cjs/components/color-picker/private/swatch.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/combobox/index.cjs.map +1 -1
- package/dist/cjs/components/combobox/private/menu.cjs +1 -1
- package/dist/cjs/components/combobox/private/menu.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.cjs.map +1 -1
- package/dist/cjs/components/date-picker/private/day.cjs +1 -1
- package/dist/cjs/components/date-picker/private/day.cjs.map +1 -1
- package/dist/cjs/components/files/file.cjs +1 -8
- package/dist/cjs/components/files/file.cjs.map +1 -1
- package/dist/cjs/components/files/private/file-actions.cjs +1 -1
- package/dist/cjs/components/files/private/file-actions.cjs.map +1 -1
- package/dist/cjs/components/files/private/file-figure.cjs +1 -1
- package/dist/cjs/components/files/private/file-figure.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/check-props.cjs +1 -1
- package/dist/cjs/components/icon/check-props.cjs.map +1 -1
- package/dist/cjs/components/icon/index.cjs +1 -1
- package/dist/cjs/components/icon/index.cjs.map +1 -1
- package/dist/cjs/components/icon/input-icon/index.cjs.map +1 -1
- package/dist/cjs/components/icon-settings/index.cjs.map +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.map +1 -1
- package/dist/cjs/components/input/private/inner-input.cjs.map +1 -1
- package/dist/cjs/components/input/search.cjs.map +1 -1
- package/dist/cjs/components/menu-dropdown/button-trigger.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/index.cjs +1 -1
- package/dist/cjs/components/modal/index.cjs.map +1 -1
- package/dist/cjs/components/panel/filtering/group.cjs.map +1 -1
- package/dist/cjs/components/pill/index.cjs.map +1 -1
- package/dist/cjs/components/pill-container/index.cjs +1 -1
- package/dist/cjs/components/pill-container/index.cjs.map +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/progress-indicator/index.cjs.map +1 -1
- package/dist/cjs/components/progress-indicator/private/step.cjs.map +1 -1
- package/dist/cjs/components/progress-ring/index.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-group/check-props.cjs.map +1 -1
- package/dist/cjs/components/radio-group/index.cjs.map +1 -1
- package/dist/cjs/components/scoped-notification/index.cjs.map +1 -1
- package/dist/cjs/components/setup-assistant/step.cjs.map +1 -1
- package/dist/cjs/components/simple-data-table/cell.cjs +1 -1
- package/dist/cjs/components/simple-data-table/cell.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/interactive-element.cjs +1 -1
- package/dist/cjs/components/simple-data-table/interactive-element.cjs.map +1 -1
- package/dist/cjs/components/simple-data-table/private/cell-context.cjs.map +1 -1
- package/dist/cjs/components/simple-data-table/private/corner-style.cjs +2 -0
- package/dist/cjs/components/simple-data-table/private/corner-style.cjs.map +1 -0
- 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/link.cjs +1 -1
- package/dist/cjs/components/simple-data-table/private/link.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/simple-data-table/row-actions.cjs +1 -1
- package/dist/cjs/components/simple-data-table/row-actions.cjs.map +1 -1
- package/dist/cjs/components/slider/index.cjs.map +1 -1
- package/dist/cjs/components/split-view/header.cjs.map +1 -1
- package/dist/cjs/components/split-view/listbox.cjs.map +1 -1
- package/dist/cjs/components/split-view/private/list-item-with-content.cjs.map +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/tabs/private/tab.cjs +1 -1
- package/dist/cjs/components/tabs/private/tab.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/index.cjs.map +1 -1
- package/dist/cjs/components/tooltip/index.cjs +1 -3
- package/dist/cjs/components/tooltip/index.cjs.map +1 -1
- package/dist/cjs/components/tree/private/branch.cjs.map +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.map +1 -1
- package/dist/cjs/components/trial-bar/button.cjs.map +1 -1
- package/dist/cjs/components/trial-bar/dropdown.cjs.map +1 -1
- package/dist/cjs/components/utilities/dialog/index.cjs +1 -1
- package/dist/cjs/components/utilities/dialog/index.cjs.map +1 -1
- package/dist/cjs/components/utilities/dialog/portal.cjs +1 -1
- package/dist/cjs/components/utilities/dialog/portal.cjs.map +1 -1
- package/dist/cjs/components/utilities/menu-list/index.cjs +1 -26
- package/dist/cjs/components/utilities/menu-list/index.cjs.map +1 -1
- package/dist/cjs/components/utilities/menu-list/item-label.cjs.map +1 -1
- package/dist/cjs/components/utilities/menu-list/item.cjs +1 -1
- package/dist/cjs/components/utilities/menu-list/item.cjs.map +1 -1
- package/dist/cjs/components/utilities/utility-icon/index.cjs +1 -1
- package/dist/cjs/components/utilities/utility-icon/index.cjs.map +1 -1
- package/dist/cjs/utilities/color.cjs +1 -1
- package/dist/cjs/utilities/color.cjs.map +1 -1
- package/dist/cjs/utilities/dom-element-focus.cjs.map +1 -1
- package/dist/cjs/utilities/execution-environment.cjs.map +1 -1
- package/dist/cjs/utilities/get-aria-props.cjs +1 -1
- package/dist/cjs/utilities/get-aria-props.cjs.map +1 -1
- package/dist/cjs/utilities/get-component-doc.cjs +1 -1
- package/dist/cjs/utilities/get-component-doc.cjs.map +1 -1
- package/dist/cjs/utilities/get-data-props.cjs +1 -1
- package/dist/cjs/utilities/get-data-props.cjs.map +1 -1
- package/dist/cjs/utilities/keyboard-navigable-dialog.cjs +1 -1
- package/dist/cjs/utilities/keyboard-navigable-dialog.cjs.map +1 -1
- package/dist/cjs/utilities/keyboard-navigate.cjs +1 -1
- package/dist/cjs/utilities/keyboard-navigate.cjs.map +1 -1
- package/dist/cjs/utilities/product-tokens/icon-backgrounds.cjs.map +1 -1
- package/dist/cjs/utilities/warning/children-as-trigger.cjs +1 -1
- package/dist/cjs/utilities/warning/children-as-trigger.cjs.map +1 -1
- package/dist/cjs/utilities/warning/deprecated-property-value.cjs +1 -1
- package/dist/cjs/utilities/warning/deprecated-property-value.cjs.map +1 -1
- package/dist/cjs/utilities/warning/deprecated-property.cjs +1 -1
- package/dist/cjs/utilities/warning/deprecated-property.cjs.map +1 -1
- package/dist/cjs/utilities/warning/has-children-without-display-name-of.cjs +1 -1
- package/dist/cjs/utilities/warning/has-children-without-display-name-of.cjs.map +1 -1
- package/dist/cjs/utilities/warning/if-one-then-both-required-property.cjs +1 -1
- package/dist/cjs/utilities/warning/if-one-then-both-required-property.cjs.map +1 -1
- package/dist/cjs/utilities/warning/is-trigger-tabbable.cjs +1 -1
- package/dist/cjs/utilities/warning/is-trigger-tabbable.cjs.map +1 -1
- package/dist/cjs/utilities/warning/low-priority-warning.cjs.map +1 -1
- package/dist/cjs/utilities/warning/one-of-required-property.cjs +1 -1
- package/dist/cjs/utilities/warning/one-of-required-property.cjs.map +1 -1
- package/dist/cjs/utilities/warning/only-one-of-properties.cjs +1 -1
- package/dist/cjs/utilities/warning/only-one-of-properties.cjs.map +1 -1
- package/dist/cjs/utilities/warning/removal-version.cjs +2 -0
- package/dist/cjs/utilities/warning/removal-version.cjs.map +1 -0
- package/dist/cjs/utilities/warning/render-function-return-contents-lack-display-name.cjs +1 -1
- package/dist/cjs/utilities/warning/render-function-return-contents-lack-display-name.cjs.map +1 -1
- package/dist/cjs/utilities/warning/required-property.cjs +1 -1
- package/dist/cjs/utilities/warning/required-property.cjs.map +1 -1
- package/dist/cjs/utilities/warning/sunset-property.cjs +1 -1
- package/dist/cjs/utilities/warning/sunset-property.cjs.map +1 -1
- package/dist/cjs/utilities/warning/warned-registry.cjs +2 -0
- package/dist/cjs/utilities/warning/warned-registry.cjs.map +1 -0
- package/dist/es/components/accordion/index.js +7 -3
- package/dist/es/components/accordion/index.js.map +1 -1
- package/dist/es/components/accordion/panel.js.map +1 -1
- package/dist/es/components/alert/index.js +4 -5
- package/dist/es/components/alert/index.js.map +1 -1
- package/dist/es/components/builder-header/nav-dropdown.js.map +1 -1
- package/dist/es/components/builder-header/nav-link.js.map +1 -1
- package/dist/es/components/builder-header/toolbar.js.map +1 -1
- package/dist/es/components/button/check-props.js +1 -1
- package/dist/es/components/button/check-props.js.map +1 -1
- package/dist/es/components/button/index.js +50 -50
- package/dist/es/components/button/index.js.map +1 -1
- package/dist/es/components/button-stateful/check-props.js +1 -1
- package/dist/es/components/button-stateful/check-props.js.map +1 -1
- package/dist/es/components/button-stateful/index.js +3 -2
- package/dist/es/components/button-stateful/index.js.map +1 -1
- package/dist/es/components/carousel/index.js +155 -129
- package/dist/es/components/carousel/index.js.map +1 -1
- package/dist/es/components/carousel/private/carousel-indicators.js.map +1 -1
- package/dist/es/components/carousel/private/carousel-item.js +1 -1
- package/dist/es/components/carousel/private/carousel-item.js.map +1 -1
- package/dist/es/components/checkbox/check-props.js +1 -1
- package/dist/es/components/checkbox/check-props.js.map +1 -1
- package/dist/es/components/checkbox/index.js +102 -100
- package/dist/es/components/checkbox/index.js.map +1 -1
- package/dist/es/components/color-picker/color-picker.js +150 -151
- package/dist/es/components/color-picker/color-picker.js.map +1 -1
- package/dist/es/components/color-picker/private/custom-color.js.map +1 -1
- package/dist/es/components/color-picker/private/hsv-color.js +16 -20
- package/dist/es/components/color-picker/private/hsv-color.js.map +1 -1
- package/dist/es/components/color-picker/private/swatch-option.js +2 -2
- package/dist/es/components/color-picker/private/swatch-option.js.map +1 -1
- package/dist/es/components/color-picker/private/swatch.js +1 -1
- package/dist/es/components/color-picker/private/swatch.js.map +1 -1
- package/dist/es/components/combobox/combobox.js +569 -582
- package/dist/es/components/combobox/combobox.js.map +1 -1
- package/dist/es/components/combobox/index.js +6 -19
- package/dist/es/components/combobox/index.js.map +1 -1
- package/dist/es/components/combobox/private/menu.js +3 -3
- package/dist/es/components/combobox/private/menu.js.map +1 -1
- package/dist/es/components/date-picker/date-picker.js +101 -102
- 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.js.map +1 -1
- package/dist/es/components/date-picker/private/day.js +1 -1
- package/dist/es/components/date-picker/private/day.js.map +1 -1
- package/dist/es/components/files/file.js +5 -6
- package/dist/es/components/files/file.js.map +1 -1
- package/dist/es/components/files/private/file-actions.js +2 -2
- package/dist/es/components/files/private/file-actions.js.map +1 -1
- package/dist/es/components/files/private/file-figure.js +1 -1
- package/dist/es/components/files/private/file-figure.js.map +1 -1
- package/dist/es/components/filter/filter.js +5 -1
- package/dist/es/components/filter/filter.js.map +1 -1
- package/dist/es/components/icon/check-props.js +9 -7
- package/dist/es/components/icon/check-props.js.map +1 -1
- package/dist/es/components/icon/index.js +13 -10
- package/dist/es/components/icon/index.js.map +1 -1
- package/dist/es/components/icon/input-icon/index.js.map +1 -1
- package/dist/es/components/icon-settings/index.js.map +1 -1
- package/dist/es/components/input/check-props.js +14 -13
- package/dist/es/components/input/check-props.js.map +1 -1
- package/dist/es/components/input/index.js.map +1 -1
- package/dist/es/components/input/private/inner-input.js.map +1 -1
- package/dist/es/components/input/search.js.map +1 -1
- package/dist/es/components/menu-dropdown/button-trigger.js.map +1 -1
- package/dist/es/components/menu-dropdown/menu-dropdown.js +202 -207
- package/dist/es/components/menu-dropdown/menu-dropdown.js.map +1 -1
- package/dist/es/components/modal/index.js +1 -2
- package/dist/es/components/modal/index.js.map +1 -1
- package/dist/es/components/panel/filtering/group.js.map +1 -1
- package/dist/es/components/pill/index.js.map +1 -1
- package/dist/es/components/pill-container/index.js +10 -6
- package/dist/es/components/pill-container/index.js.map +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 +181 -177
- package/dist/es/components/popover/popover.js.map +1 -1
- package/dist/es/components/progress-indicator/index.js.map +1 -1
- package/dist/es/components/progress-indicator/private/step.js.map +1 -1
- package/dist/es/components/progress-ring/index.js.map +1 -1
- package/dist/es/components/radio/index.js +1 -1
- package/dist/es/components/radio/index.js.map +1 -1
- package/dist/es/components/radio-group/check-props.js.map +1 -1
- package/dist/es/components/radio-group/index.js.map +1 -1
- package/dist/es/components/scoped-notification/index.js.map +1 -1
- package/dist/es/components/setup-assistant/step.js.map +1 -1
- package/dist/es/components/simple-data-table/cell.js +8 -5
- package/dist/es/components/simple-data-table/cell.js.map +1 -1
- package/dist/es/components/simple-data-table/index.js +97 -91
- package/dist/es/components/simple-data-table/index.js.map +1 -1
- package/dist/es/components/simple-data-table/interactive-element.js +31 -28
- package/dist/es/components/simple-data-table/interactive-element.js.map +1 -1
- package/dist/es/components/simple-data-table/private/cell-context.js.map +1 -1
- package/dist/es/components/simple-data-table/private/corner-style.js +9 -0
- package/dist/es/components/simple-data-table/private/corner-style.js.map +1 -0
- package/dist/es/components/simple-data-table/private/head.js +65 -42
- package/dist/es/components/simple-data-table/private/head.js.map +1 -1
- package/dist/es/components/simple-data-table/private/header-cell.js +2 -1
- package/dist/es/components/simple-data-table/private/header-cell.js.map +1 -1
- package/dist/es/components/simple-data-table/private/link.js.map +1 -1
- package/dist/es/components/simple-data-table/private/row.js +96 -60
- package/dist/es/components/simple-data-table/private/row.js.map +1 -1
- package/dist/es/components/simple-data-table/row-actions.js +4 -1
- package/dist/es/components/simple-data-table/row-actions.js.map +1 -1
- package/dist/es/components/slider/index.js.map +1 -1
- package/dist/es/components/split-view/header.js.map +1 -1
- package/dist/es/components/split-view/listbox.js.map +1 -1
- package/dist/es/components/split-view/private/list-item-with-content.js.map +1 -1
- package/dist/es/components/tabs/index.js.map +1 -1
- package/dist/es/components/tabs/panel.js.map +1 -1
- package/dist/es/components/tabs/private/tab.js +1 -1
- package/dist/es/components/tabs/private/tab.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 +29 -42
- package/dist/es/components/textarea/index.js.map +1 -1
- package/dist/es/components/toast/index.js.map +1 -1
- package/dist/es/components/tooltip/index.js +107 -88
- package/dist/es/components/tooltip/index.js.map +1 -1
- package/dist/es/components/tree/private/branch.js.map +1 -1
- package/dist/es/components/tree/private/item.js.map +1 -1
- package/dist/es/components/tree/private/render-branch.js +14 -19
- package/dist/es/components/tree/private/render-branch.js.map +1 -1
- package/dist/es/components/tree/tree.js.map +1 -1
- package/dist/es/components/trial-bar/button.js.map +1 -1
- package/dist/es/components/trial-bar/dropdown.js.map +1 -1
- package/dist/es/components/utilities/dialog/index.js +2 -1
- package/dist/es/components/utilities/dialog/index.js.map +1 -1
- package/dist/es/components/utilities/dialog/portal.js +5 -3
- package/dist/es/components/utilities/dialog/portal.js.map +1 -1
- package/dist/es/components/utilities/menu-list/index.js +6 -6
- package/dist/es/components/utilities/menu-list/index.js.map +1 -1
- package/dist/es/components/utilities/menu-list/item-label.js.map +1 -1
- package/dist/es/components/utilities/menu-list/item.js +42 -18
- package/dist/es/components/utilities/menu-list/item.js.map +1 -1
- package/dist/es/components/utilities/utility-icon/index.js +32 -52
- package/dist/es/components/utilities/utility-icon/index.js.map +1 -1
- package/dist/es/utilities/color.js +1 -1
- package/dist/es/utilities/color.js.map +1 -1
- package/dist/es/utilities/dom-element-focus.js.map +1 -1
- package/dist/es/utilities/execution-environment.js.map +1 -1
- package/dist/es/utilities/get-aria-props.js +1 -1
- package/dist/es/utilities/get-aria-props.js.map +1 -1
- package/dist/es/utilities/get-component-doc.js +6 -6
- package/dist/es/utilities/get-component-doc.js.map +1 -1
- package/dist/es/utilities/get-data-props.js +1 -1
- package/dist/es/utilities/get-data-props.js.map +1 -1
- package/dist/es/utilities/keyboard-navigable-dialog.js +7 -7
- package/dist/es/utilities/keyboard-navigable-dialog.js.map +1 -1
- package/dist/es/utilities/keyboard-navigate.js +1 -1
- package/dist/es/utilities/keyboard-navigate.js.map +1 -1
- package/dist/es/utilities/product-tokens/icon-backgrounds.js.map +1 -1
- package/dist/es/utilities/warning/children-as-trigger.js +10 -8
- package/dist/es/utilities/warning/children-as-trigger.js.map +1 -1
- package/dist/es/utilities/warning/deprecated-property-value.js +12 -10
- package/dist/es/utilities/warning/deprecated-property-value.js.map +1 -1
- package/dist/es/utilities/warning/deprecated-property.js +10 -8
- package/dist/es/utilities/warning/deprecated-property.js.map +1 -1
- package/dist/es/utilities/warning/has-children-without-display-name-of.js +11 -10
- package/dist/es/utilities/warning/has-children-without-display-name-of.js.map +1 -1
- package/dist/es/utilities/warning/if-one-then-both-required-property.js +10 -9
- package/dist/es/utilities/warning/if-one-then-both-required-property.js.map +1 -1
- package/dist/es/utilities/warning/is-trigger-tabbable.js +9 -8
- package/dist/es/utilities/warning/is-trigger-tabbable.js.map +1 -1
- package/dist/es/utilities/warning/low-priority-warning.js.map +1 -1
- package/dist/es/utilities/warning/one-of-required-property.js +11 -10
- package/dist/es/utilities/warning/one-of-required-property.js.map +1 -1
- package/dist/es/utilities/warning/only-one-of-properties.js +9 -8
- package/dist/es/utilities/warning/only-one-of-properties.js.map +1 -1
- package/dist/es/utilities/warning/removal-version.js +6 -0
- package/dist/es/utilities/warning/removal-version.js.map +1 -0
- package/dist/es/utilities/warning/render-function-return-contents-lack-display-name.js +14 -13
- package/dist/es/utilities/warning/render-function-return-contents-lack-display-name.js.map +1 -1
- package/dist/es/utilities/warning/required-property.js +8 -7
- package/dist/es/utilities/warning/required-property.js.map +1 -1
- package/dist/es/utilities/warning/sunset-property.js +8 -7
- package/dist/es/utilities/warning/sunset-property.js.map +1 -1
- package/dist/es/utilities/warning/warned-registry.js +10 -0
- package/dist/es/utilities/warning/warned-registry.js.map +1 -0
- package/dist/llms/components/accordion.md +267 -0
- package/dist/llms/components/alert.md +228 -0
- package/dist/llms/components/avatar.md +167 -0
- package/dist/llms/components/badge.md +153 -0
- package/dist/llms/components/breadcrumb.md +148 -0
- package/dist/llms/components/builder-header.examples.md +239 -0
- package/dist/llms/components/builder-header.md +736 -0
- package/dist/llms/components/button-group.md +167 -0
- package/dist/llms/components/button-stateful.md +246 -0
- package/dist/llms/components/button.md +661 -0
- package/dist/llms/components/card.md +368 -0
- package/dist/llms/components/carousel.md +365 -0
- package/dist/llms/components/checkbox.md +887 -0
- package/dist/llms/components/color-picker.md +591 -0
- package/dist/llms/components/combobox.examples.md +802 -0
- package/dist/llms/components/combobox.md +929 -0
- package/dist/llms/components/date-picker.md +546 -0
- package/dist/llms/components/docked-composer.md +173 -0
- package/dist/llms/components/dynamic-icon.md +226 -0
- package/dist/llms/components/expandable-section.md +198 -0
- package/dist/llms/components/files.md +337 -0
- package/dist/llms/components/filter.md +775 -0
- package/dist/llms/components/icon-settings.md +301 -0
- package/dist/llms/components/icon.md +1040 -0
- package/dist/llms/components/input.md +746 -0
- package/dist/llms/components/media-object.md +125 -0
- package/dist/llms/components/menu-dropdown.md +732 -0
- package/dist/llms/components/modal.md +504 -0
- package/dist/llms/components/page-header.md +282 -0
- package/dist/llms/components/panel.md +256 -0
- package/dist/llms/components/pill-container.md +218 -0
- package/dist/llms/components/pill.md +266 -0
- package/dist/llms/components/popover.md +600 -0
- package/dist/llms/components/portal-settings.md +371 -0
- package/dist/llms/components/progress-bar.md +175 -0
- package/dist/llms/components/progress-indicator.md +399 -0
- package/dist/llms/components/progress-ring.md +146 -0
- package/dist/llms/components/radio-button-group.md +285 -0
- package/dist/llms/components/radio-group.md +242 -0
- package/dist/llms/components/radio.md +269 -0
- package/dist/llms/components/scoped-notification.md +156 -0
- package/dist/llms/components/setup-assistant.md +398 -0
- package/dist/llms/components/simple-data-table.examples.md +2773 -0
- package/dist/llms/components/simple-data-table.md +919 -0
- package/dist/llms/components/slider.md +217 -0
- package/dist/llms/components/spinner.md +232 -0
- package/dist/llms/components/split-view.md +350 -0
- package/dist/llms/components/tabs.md +311 -0
- package/dist/llms/components/textarea.md +331 -0
- package/dist/llms/components/toast.md +267 -0
- package/dist/llms/components/tooltip.md +470 -0
- package/dist/llms/components/tree.md +1011 -0
- package/dist/llms/components/trial-bar.md +383 -0
- package/dist/llms/components/vertical-navigation.md +196 -0
- package/dist/llms/components/visual-picker.md +362 -0
- package/dist/llms/components/welcome-mat.md +885 -0
- package/dist/llms/docs/migration-v11.md +471 -0
- package/dist/llms/llms-full.txt +6874 -0
- package/dist/llms/llms.txt +133 -0
- package/dist/llms/rules.md +36 -0
- package/dist/types/components/accordion/index.d.ts.map +1 -1
- package/dist/types/components/accordion/panel.d.ts +7 -7
- package/dist/types/components/builder-header/nav-dropdown.d.ts +1 -0
- package/dist/types/components/builder-header/nav-dropdown.d.ts.map +1 -1
- package/dist/types/components/builder-header/nav-link.d.ts +0 -1
- package/dist/types/components/builder-header/nav-link.d.ts.map +1 -1
- package/dist/types/components/builder-header/toolbar.d.ts +0 -1
- package/dist/types/components/builder-header/toolbar.d.ts.map +1 -1
- package/dist/types/components/button/index.d.ts +19 -6
- package/dist/types/components/button/index.d.ts.map +1 -1
- package/dist/types/components/button-stateful/index.d.ts +8 -2
- package/dist/types/components/button-stateful/index.d.ts.map +1 -1
- package/dist/types/components/carousel/index.d.ts +7 -1
- package/dist/types/components/carousel/index.d.ts.map +1 -1
- package/dist/types/components/checkbox/index.d.ts +22 -5
- package/dist/types/components/checkbox/index.d.ts.map +1 -1
- package/dist/types/components/color-picker/color-picker.d.ts +6 -4
- package/dist/types/components/color-picker/color-picker.d.ts.map +1 -1
- package/dist/types/components/color-picker/types.d.ts +2 -2
- package/dist/types/components/combobox/combobox.d.ts +22 -0
- package/dist/types/components/combobox/combobox.d.ts.map +1 -1
- package/dist/types/components/combobox/index.d.ts +1 -1
- package/dist/types/components/combobox/index.d.ts.map +1 -1
- package/dist/types/components/date-picker/date-picker.d.ts +16 -4
- package/dist/types/components/date-picker/date-picker.d.ts.map +1 -1
- package/dist/types/components/date-picker/index.d.ts +2 -6
- package/dist/types/components/date-picker/index.d.ts.map +1 -1
- package/dist/types/components/files/file.d.ts +5 -0
- package/dist/types/components/files/file.d.ts.map +1 -1
- package/dist/types/components/icon/index.d.ts +8 -1
- package/dist/types/components/icon/index.d.ts.map +1 -1
- package/dist/types/components/icon/input-icon/index.d.ts +3 -0
- package/dist/types/components/icon/input-icon/index.d.ts.map +1 -1
- package/dist/types/components/icon-settings/index.d.ts.map +1 -1
- package/dist/types/components/input/index.d.ts +10 -6
- package/dist/types/components/input/index.d.ts.map +1 -1
- package/dist/types/components/input/search.d.ts.map +1 -1
- package/dist/types/components/menu-dropdown/button-trigger.d.ts +5 -0
- package/dist/types/components/menu-dropdown/button-trigger.d.ts.map +1 -1
- package/dist/types/components/menu-dropdown/menu-dropdown.d.ts +13 -3
- package/dist/types/components/menu-dropdown/menu-dropdown.d.ts.map +1 -1
- package/dist/types/components/modal/index.d.ts +5 -5
- package/dist/types/components/modal/index.d.ts.map +1 -1
- package/dist/types/components/page-header/types.d.ts +3 -0
- package/dist/types/components/page-header/types.d.ts.map +1 -1
- package/dist/types/components/panel/filtering/group.d.ts +2 -0
- package/dist/types/components/panel/filtering/group.d.ts.map +1 -1
- package/dist/types/components/pill/index.d.ts +1 -0
- package/dist/types/components/pill/index.d.ts.map +1 -1
- package/dist/types/components/popover/edit-dialog.d.ts +1 -3
- package/dist/types/components/popover/edit-dialog.d.ts.map +1 -1
- package/dist/types/components/popover/index.d.ts.map +1 -1
- package/dist/types/components/popover/popover.d.ts +1 -0
- package/dist/types/components/popover/popover.d.ts.map +1 -1
- package/dist/types/components/progress-indicator/index.d.ts +1 -0
- package/dist/types/components/progress-indicator/index.d.ts.map +1 -1
- package/dist/types/components/progress-ring/index.d.ts +1 -0
- package/dist/types/components/progress-ring/index.d.ts.map +1 -1
- package/dist/types/components/radio/index.d.ts +11 -4
- package/dist/types/components/radio/index.d.ts.map +1 -1
- package/dist/types/components/radio-group/index.d.ts +5 -3
- package/dist/types/components/radio-group/index.d.ts.map +1 -1
- package/dist/types/components/scoped-notification/index.d.ts +1 -0
- package/dist/types/components/scoped-notification/index.d.ts.map +1 -1
- package/dist/types/components/setup-assistant/step.d.ts +0 -1
- package/dist/types/components/setup-assistant/step.d.ts.map +1 -1
- package/dist/types/components/simple-data-table/cell.d.ts.map +1 -1
- package/dist/types/components/simple-data-table/index.d.ts.map +1 -1
- package/dist/types/components/simple-data-table/interactive-element.d.ts +8 -1
- package/dist/types/components/simple-data-table/interactive-element.d.ts.map +1 -1
- package/dist/types/components/simple-data-table/types.d.ts +11 -2
- package/dist/types/components/simple-data-table/types.d.ts.map +1 -1
- package/dist/types/components/slider/index.d.ts +6 -4
- package/dist/types/components/slider/index.d.ts.map +1 -1
- package/dist/types/components/split-view/listbox.d.ts.map +1 -1
- package/dist/types/components/split-view/private/list-item-with-content.d.ts.map +1 -1
- package/dist/types/components/tabs/index.d.ts +1 -0
- package/dist/types/components/tabs/index.d.ts.map +1 -1
- package/dist/types/components/tabs/panel.d.ts +2 -1
- package/dist/types/components/tabs/panel.d.ts.map +1 -1
- package/dist/types/components/textarea/index.d.ts +12 -40
- package/dist/types/components/textarea/index.d.ts.map +1 -1
- package/dist/types/components/toast/index.d.ts.map +1 -1
- package/dist/types/components/tooltip/index.d.ts +5 -0
- package/dist/types/components/tooltip/index.d.ts.map +1 -1
- package/dist/types/components/tree/tree.d.ts +5 -0
- package/dist/types/components/tree/tree.d.ts.map +1 -1
- package/dist/types/components/utilities/dialog/portal.d.ts.map +1 -1
- package/dist/types/components/utilities/menu-list/index.d.ts +2 -2
- package/dist/types/components/utilities/menu-list/index.d.ts.map +1 -1
- package/dist/types/components/utilities/menu-list/item-label.d.ts +12 -0
- package/dist/types/components/utilities/menu-list/item-label.d.ts.map +1 -1
- package/dist/types/components/utilities/menu-list/item.d.ts +14 -1
- package/dist/types/components/utilities/menu-list/item.d.ts.map +1 -1
- package/dist/types/components/utilities/truncate/index.d.ts.map +1 -1
- package/dist/types/components/utilities/utility-icon/index.d.ts +1 -1
- package/dist/types/components/utilities/utility-icon/index.d.ts.map +1 -1
- package/dist/types/types/common.d.ts.map +1 -1
- package/dist/types/types/components.d.ts.map +1 -1
- package/package.json +9 -7
- package/dist/cjs/icons/action/index.cjs +0 -2
- package/dist/cjs/icons/action/index.cjs.map +0 -1
- package/dist/cjs/icons/custom/index.cjs +0 -2
- package/dist/cjs/icons/custom/index.cjs.map +0 -1
- package/dist/cjs/icons/doctype/index.cjs +0 -2
- package/dist/cjs/icons/doctype/index.cjs.map +0 -1
- package/dist/cjs/icons/standard/index.cjs +0 -2
- package/dist/cjs/icons/standard/index.cjs.map +0 -1
- package/dist/cjs/icons/utility/index.cjs +0 -2
- package/dist/cjs/icons/utility/index.cjs.map +0 -1
- package/dist/es/icons/action/index.js +0 -6
- package/dist/es/icons/action/index.js.map +0 -1
- package/dist/es/icons/custom/index.js +0 -6
- package/dist/es/icons/custom/index.js.map +0 -1
- package/dist/es/icons/doctype/index.js +0 -6
- package/dist/es/icons/doctype/index.js.map +0 -1
- package/dist/es/icons/standard/index.js +0 -6
- package/dist/es/icons/standard/index.js.map +0 -1
- package/dist/es/icons/utility/index.js +0 -6
- package/dist/es/icons/utility/index.js.map +0 -1
- package/dist/types/icons/action/index.d.ts +0 -3
- package/dist/types/icons/action/index.d.ts.map +0 -1
- package/dist/types/icons/custom/index.d.ts +0 -3
- package/dist/types/icons/custom/index.d.ts.map +0 -1
- package/dist/types/icons/doctype/index.d.ts +0 -3
- package/dist/types/icons/doctype/index.d.ts.map +0 -1
- package/dist/types/icons/standard/index.d.ts +0 -3
- package/dist/types/icons/standard/index.d.ts.map +0 -1
- package/dist/types/icons/utility/index.d.ts +0 -3
- package/dist/types/icons/utility/index.d.ts.map +0 -1
|
@@ -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\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\t</li>\n\t);\n};\n\nRenderBranch.displayName = 'Branch';\n\nexport default RenderBranch;\n"],"mappings":";;;;;;;;;;;AAqDA,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,eAAe,EAAM,IAAI;GACxC,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,eAAe,EAAM,IAAI;GACxC,WAAW,EAAM;EAClB;EACA;CACD,CAAC;AAEH,GAEM,KAAgB,GAAiC,MAAmB;CACzE,IAAM,IAAQ,EAAe,KAAK,MAAkB,EAAc,IAAI;CAEtE,OAAO,GADO,EAAU,GAAO,EAAE,IAAI,EAAK,GAAG,CACtB,IAAQ,KAAK,EAAe;AACpD,GAEM,KAAoB,GAAiC,MA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;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// Loading skeleton bar. SLDS 2 ships no skeleton/stencil blueprint, so this\n// uses global styling hooks with the SLDS 1 values as fallbacks.\nconst skeletonBarStyle: React.CSSProperties = {\n\tborderRadius: 'var(--slds-g-radius-border-pill, 15rem)',\n\tdisplay: 'block',\n\tmarginBottom: 'var(--slds-g-spacing-3, .75rem)',\n\theight: 'var(--slds-g-sizing-3, .5rem)',\n\tbackgroundColor:\n\t\t'var(--slds-g-color-surface-container-3, rgb(224, 229, 238))',\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.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: 'var(--slds-g-spacing-2, .5rem)',\n\t\t\t}}\n\t\t>\n\t\t\t<div\n\t\t\t\tstyle={{\n\t\t\t\t\t...skeletonBarStyle,\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\t...skeletonBarStyle,\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\t...skeletonBarStyle,\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\taria-selected={isSelected ? 'true' : 'false'}\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{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions -- keyboard selection is handled on the treeitem */}\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\t</li>\n\t);\n};\n\nRenderBranch.displayName = 'Branch';\n\nexport default RenderBranch;\n"],"mappings":";;;;;;;;;;;AAqDA,IAAM,KACL,GACA,MACI;CAEJ,AADA,EAAU,KAAK,CAAK,GAChB,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,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 +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, {\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\ninterface TreeBaseProps {\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/**\n\t * Resolves a node's children, for trees that store child ids instead of `nodes`. Used at every level.\n\t */\n\tgetNodes?: (node: { nodes?: TreeNode[] }) => TreeNode[] | undefined;\n\t/** HTML id of the tree container (required) */\n\tid: string;\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\n/** A visible heading. A tree needs a heading, visible or not. */\ninterface TreeVisibleHeadingProps {\n\t/**\n\t * **Text labels for internationalization**\n\t * * `heading`: Visible tree heading that describes its contents.\n\t */\n\tlabels: TreeLabels & { heading: ReactNode };\n\tassistiveText?: TreeAssistiveText & { heading?: never; label?: never };\n\theading?: never;\n}\n\n/** A visually hidden heading, for screen readers only. */\ninterface TreeHiddenHeadingProps {\n\t/**\n\t * **Assistive text for accessibility**\n\t * * `heading`: Visually hidden tree heading.\n\t */\n\tassistiveText: TreeAssistiveText & { heading: string };\n\tlabels?: TreeLabels & { heading?: never };\n\theading?: never;\n}\n\n/** @deprecated Use `labels.heading`. */\ninterface TreeDeprecatedHeadingProps {\n\t/** @deprecated Use `labels.heading` instead. */\n\theading: ReactNode;\n\tassistiveText?: TreeAssistiveText & { heading?: never };\n\tlabels?: TreeLabels & { heading?: never };\n}\n\n/** @deprecated Use `assistiveText.heading`. */\ninterface TreeDeprecatedAssistiveLabelProps {\n\t/** **Assistive text for accessibility** */\n\tassistiveText: TreeAssistiveText & { label: string; heading?: never };\n\tlabels?: TreeLabels & { heading?: never };\n\theading?: never;\n}\n\n/**\n * Props for the Tree component. The heading is either visible (`labels.heading`) or\n * visually hidden (`assistiveText.heading`), not both.\n */\nexport type TreeProps = TreeBaseProps &\n\t(\n\t\t| TreeVisibleHeadingProps\n\t\t| TreeHiddenHeadingProps\n\t\t| TreeDeprecatedHeadingProps\n\t\t| TreeDeprecatedAssistiveLabelProps\n\t);\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":";;;;;;;;;AA8KA,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,GACA,GACA,IAAY,GAAG,EAAU,GAAG,MAAU,GAAG,KACzC,EACD,CACD;CAEF;CAED,OAAO;AACR,GAMM,KACL,GACA,GACA,MACkB;CAClB,IAAM,IAAoB,CAAC,GACrB,oBAAU,IAAI,IAAc,GAC5B,KAAS,MAAiC;EAC/C,GAAM,SAAS,MAAS;GACvB,AAAI,KAAQ,CAAC,EAAQ,IAAI,CAAI,MAC5B,EAAQ,IAAI,CAAI,GACZ,EAAU,CAAI,KACjB,EAAI,KAAK,EAAK,EAAE,GAEjB,EAAM,EAAS,CAAI,CAAC;EAEtB,CAAC;CACF;CAEA,OADA,EAAM,EAAS,EAAE,SAAM,CAAC,CAAC,GAClB;AACR,GAEM,MAAmB,MAA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;EACD;EAEA,EAAgB,UAAU;EAC1B,IAAM,IAAS,EAAe,CAAC,CAAC,QAC9B,MAAW,MAAW,EAAK,KAAK,EAClC,GACM,IAAkB,EAAK,SAC1B,CAAC,GAAG,GAAQ,EAAK,KAAK,EAAE,IACxB;EAGH,AADA,EAAe,CAAe,GAC1B,IACH,EAAgB,GAAO;GACtB,MAAM,EAAK;GACX,YAAY,EAAK;GACjB,aAAa;EACd,CAAC,IACS,KACV,EAAc,GAAO,CAAI;CAE3B,GACA;EACC;EACA;EACA;EACA;EACA;CACD,CACD,GAGM,KAAc,KAAoB;CAExC,OACC,kBAAC,OAAD;EACK;EACJ,WAAW,EAAW,uBAAuB,CAAS;EACjD;EAHN,UAAA,CAKC,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,EAAW,GAAe,CAAa;GACxD,QAAQ;GACR,cACC,KAAa,IAAY;IAAE,GAAG;IAAW,GAAG;GAAU,IAAI,KAAA;GAE3D,OAAO;GACP,MAAM,EAAE,SAAM;GACE;GACA;GACA;GACF;GACd,kBAAkB;GAClB,cAAc,EAAgB;GAC9B,YAAY;GACZ,UAAU;GACV,UAAU;GACA;GACE;GACZ,QAAQ;EACR,CAAA,CACG;;AAEP,CACD;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\ninterface TreeBaseProps {\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/**\n\t * Resolves a node's children, for trees that store child ids instead of `nodes`. Used at every level.\n\t */\n\tgetNodes?: (node: { nodes?: TreeNode[] }) => TreeNode[] | undefined;\n\t/** HTML id of the tree container (required) */\n\tid: string;\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\n/** A visible heading. A tree needs a heading, visible or not. */\ninterface TreeVisibleHeadingProps {\n\t/**\n\t * **Text labels for internationalization**\n\t * * `heading`: Visible tree heading that describes its contents.\n\t */\n\tlabels: TreeLabels & { heading: ReactNode };\n\t/** **Assistive text for accessibility**. Has no `heading` when `labels.heading` is set. */\n\tassistiveText?: TreeAssistiveText & { heading?: never; label?: never };\n\theading?: never;\n}\n\n/** A visually hidden heading, for screen readers only. */\ninterface TreeHiddenHeadingProps {\n\t/**\n\t * **Assistive text for accessibility**\n\t * * `heading`: Visually hidden tree heading.\n\t */\n\tassistiveText: TreeAssistiveText & { heading: string };\n\t/** **Text labels for internationalization**. Has no `heading` when `assistiveText.heading` is set. */\n\tlabels?: TreeLabels & { heading?: never };\n\theading?: never;\n}\n\n/** @deprecated Use `labels.heading`. */\ninterface TreeDeprecatedHeadingProps {\n\t/** @deprecated Use `labels.heading` instead. */\n\theading: ReactNode;\n\t/** **Assistive text for accessibility**. Has no `heading` when `heading` is set. */\n\tassistiveText?: TreeAssistiveText & { heading?: never };\n\t/** **Text labels for internationalization**. Has no `heading` when `heading` is set. */\n\tlabels?: TreeLabels & { heading?: never };\n}\n\n/** @deprecated Use `assistiveText.heading`. */\ninterface TreeDeprecatedAssistiveLabelProps {\n\t/** **Assistive text for accessibility** */\n\tassistiveText: TreeAssistiveText & { label: string; heading?: never };\n\t/** **Text labels for internationalization**. Has no `heading` when `assistiveText.label` is set. */\n\tlabels?: TreeLabels & { heading?: never };\n\theading?: never;\n}\n\n/**\n * Props for the Tree component. The heading is either visible (`labels.heading`) or\n * visually hidden (`assistiveText.heading`), not both.\n */\nexport type TreeProps = TreeBaseProps &\n\t(\n\t\t| TreeVisibleHeadingProps\n\t\t| TreeHiddenHeadingProps\n\t\t| TreeDeprecatedHeadingProps\n\t\t| TreeDeprecatedAssistiveLabelProps\n\t);\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":";;;;;;;;;AAmLA,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,I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AG;GAAU,IAAI,KAAA;GAE3D,OAAO;GACP,MAAM,EAAE,SAAM;GACE;GACA;GACA;GACF;GACd,kBAAkB;GAClB,cAAc,EAAgB;GAC9B,YAAY;GACZ,UAAU;GACV,UAAU;GACA;GACE;GACZ,QAAQ;EACR,CAAA,CACG;;AAEP,CACD;AAEA,EAAK,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.js","names":[],"sources":["../../../../components/trial-bar/button.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport Button, { type ButtonProps } from '../button';\nimport { TRIAL_BAR_BUTTON } from '../../utilities/constants';\n\n/**\n * A
|
|
1
|
+
{"version":3,"file":"button.js","names":[],"sources":["../../../../components/trial-bar/button.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport Button, { type ButtonProps } from '../button';\nimport { TRIAL_BAR_BUTTON } from '../../utilities/constants';\n\n/**\n * A `Button` within the Trial Bar.\n */\nconst TrialBarButton = ({ className, style, ...props }: ButtonProps) => (\n\t<Button\n\t\t{...props}\n\t\tinverse\n\t\tstyle={{ border: 0, padding: 0, ...style }}\n\t\tclassName={classNames(\n\t\t\t'slds-m-right_small',\n\t\t\tclassName as string | string[] | Record<string, boolean>\n\t\t)}\n\t/>\n);\n\nTrialBarButton.displayName = TRIAL_BAR_BUTTON;\n\nexport default TrialBarButton;\n"],"mappings":";;;;;AAOA,IAAM,KAAkB,EAAE,cAAW,UAAO,GAAG,QAC9C,kBAAC,GAAD;CACC,GAAI;CACJ,SAAA;CACA,OAAO;EAAE,QAAQ;EAAG,SAAS;EAAG,GAAG;CAAM;CACzC,WAAW,EACV,sBACA,CACD;AACA,CAAA;AAGF,EAAe,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropdown.js","names":[],"sources":["../../../../components/trial-bar/dropdown.tsx"],"sourcesContent":["import classNames from 'classnames';\n\nimport Dropdown from '../menu-dropdown';\nimport { type MenuDropdownBaseProps } from '../menu-dropdown/menu-dropdown';\nimport Button from '../button';\n\nimport { TRIAL_BAR_DROPDOWN } from '../../utilities/constants';\n\nexport interface TrialBarDropdownProps extends Omit<\n\tMenuDropdownBaseProps,\n\t'inverse' | 'label' | 'trigger'\n> {\n\t/**\n\t * Label rendered on the dropdown trigger button.\n\t */\n\tlabel?: string;\n}\n\n/**\n * A
|
|
1
|
+
{"version":3,"file":"dropdown.js","names":[],"sources":["../../../../components/trial-bar/dropdown.tsx"],"sourcesContent":["import classNames from 'classnames';\n\nimport Dropdown from '../menu-dropdown';\nimport { type MenuDropdownBaseProps } from '../menu-dropdown/menu-dropdown';\nimport Button from '../button';\n\nimport { TRIAL_BAR_DROPDOWN } from '../../utilities/constants';\n\nexport interface TrialBarDropdownProps extends Omit<\n\tMenuDropdownBaseProps,\n\t'inverse' | 'label' | 'trigger'\n> {\n\t/**\n\t * Label rendered on the dropdown trigger button.\n\t */\n\tlabel?: string;\n}\n\n/**\n * A `MenuDropdown` within the Trial Bar.\n */\nconst TrialBarDropdown = (props: TrialBarDropdownProps) => {\n\tconst { label, triggerClassName, ...rest } = props;\n\treturn (\n\t\t<Dropdown\n\t\t\t{...rest}\n\t\t\tinverse\n\t\t\ttriggerClassName={classNames('slds-grid', triggerClassName)}\n\t\t\ttrigger={\n\t\t\t\t<Button\n\t\t\t\t\tinverse\n\t\t\t\t\tstyle={{ border: 0, height: '100%', padding: 0 }}\n\t\t\t\t\ticonCategory=\"utility\"\n\t\t\t\t\ticonName=\"right\"\n\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\tlabel={label}\n\t\t\t\t/>\n\t\t\t}\n\t\t/>\n\t);\n};\n\nTrialBarDropdown.displayName = TRIAL_BAR_DROPDOWN;\nexport default TrialBarDropdown;\n"],"mappings":";;;;;;AAqBA,IAAM,KAAoB,MAAiC;CAC1D,IAAM,EAAE,UAAO,qBAAkB,GAAG,MAAS;CAC7C,OACC,kBAAC,GAAD;EACC,GAAI;EACJ,SAAA;EACA,kBAAkB,EAAW,aAAa,CAAgB;EAC1D,SACC,kBAAC,GAAD;GACC,SAAA;GACA,OAAO;IAAE,QAAQ;IAAG,QAAQ;IAAQ,SAAS;GAAE;GAC/C,cAAa;GACb,UAAS;GACT,cAAa;GACN;EACP,CAAA;CAEF,CAAA;AAEH;AAEA,EAAiB,cAAc"}
|
|
@@ -46,6 +46,7 @@ var S = class extends p.Component {
|
|
|
46
46
|
containerProps: g.object,
|
|
47
47
|
direction: g.oneOf([n.LTR, n.RTL]),
|
|
48
48
|
hasNubbin: g.bool,
|
|
49
|
+
isNubbinHidden: g.bool,
|
|
49
50
|
hasStaticAlignment: g.bool,
|
|
50
51
|
inheritWidthOf: g.oneOf([
|
|
51
52
|
"target",
|
|
@@ -189,7 +190,7 @@ var S = class extends p.Component {
|
|
|
189
190
|
"absolute-positioned": this.props.position === "absolute",
|
|
190
191
|
"portal-positioned": this.props.position === "overflowBoundaryElement",
|
|
191
192
|
[`${this.props.outsideClickIgnoreClass}`]: this.props.position === "overflowBoundaryElement"
|
|
192
|
-
}, this.props.hasNubbin && u(this.props.align, this.state.popperData), this.props.contentsClassName) || void 0,
|
|
193
|
+
}, this.props.hasNubbin && !this.props.isNubbinHidden && u(this.props.align, this.state.popperData), this.props.contentsClassName) || void 0,
|
|
193
194
|
style: e,
|
|
194
195
|
onMouseDown: this.props.onMouseDown,
|
|
195
196
|
onKeyDown: this.handleKeyDown,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../../components/utilities/dialog/index.jsx"],"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 */\nimport React from 'react';\n\nimport PropTypes from 'prop-types';\n\nimport { computePosition, autoUpdate, flip, shift } from '@floating-ui/dom';\nimport { dequal as isEqual } from 'dequal';\n\n// ### classNames\n// [github.com/JedWatson/classnames](https://github.com/JedWatson/classnames)\n// This project uses `classnames`, \"a simple javascript utility for conditionally\n// joining classNames together.\"\nimport classNames from 'classnames';\n\nimport Portal from './portal';\nimport EventUtil from '../../../utilities/event';\nimport KEYS from '../../../utilities/key-code';\nimport DOMElementFocus from '../../../utilities/dom-element-focus';\nimport {\n\tgetNubbinMargins,\n\tgetNubbinClassName,\n\tmapPropToPopperPlacement,\n} from '../../../utilities/dialog-helpers';\n\nimport { DIALOG } from '../../../utilities/constants';\n\n// #### Dialog doesn't pass down <IconSettings> context so repassing it here.\nimport IconSettings, { IconSettingsContext } from '../../icon-settings';\n// eslint-disable-next-line camelcase\nimport UNSAFE_DirectionSettings, { DIRECTIONS } from '../UNSAFE_direction';\nimport LanguageDirection from '../UNSAFE_direction/private/language-direction';\n\n/*\n * A Dialog is content that is separate from the typical flow of a page. It typically overlays other elements in the document flow. This is achieved with elevation (`z-index`) and one of the following: relative position, absolute position, or a new top-level React render tree (portal). A boundary element is a scrolling ancestor element or the edge of the browser (window/viewport). This element typically has an overflow (overflow-y/overflow-x) style that is scroll, hidden, or auto. Inverted placement is the flipping of the overlay element from top to bottom or left to right in order stay within a boundary element.\n *\n * * Dropdown menu (Combobox, DatePicker, et al.) placement is typically bottom-aligned and should be allowed to invert its placement when inside a boundary element this often happens within a modal. Dropdowns should not overflow boundary elements , since most boundary elements scroll vertically and have space for the menu.\n *\n * * If they are hidden, left and right placed overlay elements (such as Popover and Tooltip) should be placed within a portal element attached to the DOM <body>, but styled to align to its target/trigger. Since scrolling typically occurs on the vertical axis, this allows them to overflow boundary elements and still allow scrolling of content, yet still invert placement for the browser viewport. Portal elements are only necessary if an original ancestor boundary element exists. **No portals are created by default.**\n *\n * * Nubbins/arrows should be repositioned for any new placement/alignment.\n *\n * Allow Overflowing of Boundary Element: Allow applications to create a portal element attached to the DOM <body> to be outside of boundary elements if manual testing shows confusing alignment/poor usability/readability. This should be exception and not the default.\n *\n * Allow Inverted placement: Allow applications to prevent inverted placement if manual testing shows confusing alignment/poor usability/readability.\n *\n * ### How this new Dialog component works\n * * There is no longer an inline render within components. All overlays should go through `Dialog`. `position: relative` just passes on the markup with some additional event listeners. No positional library is used.\n * * The default `position: absolute` will run through three renders. It will first render the overlay at `0px/0px` offset of its parent. It will then store the target DOM node, once the DOM node is set, a state change will occur and tell a PopperJS instance to be created on update, once it is created, a third render is done to update the styles created by PopperJS.\n * * `position: overflowBoundaryElement` will do the same three renders as `absolute` except that the initial render will create a disconnected render tree (portal) on the `body`. Then, the position will change once the target is stored. The portal itself will be rendered multiple times. The first will result in `onOpen` executing. Each update will result in a re-render of the disconnected render-tree.\n *\n * This component is private.\n */\nclass Dialog extends React.Component {\n\tstatic displayName = DIALOG;\n\n\tstatic propTypes = {\n\t\t/**\n\t\t * Alignment of the dialog with respect to the target (assuming left-to-right language direction). For example,\n\t\t * a value of 'left bottom' indicates that the dialog will be rendered below and left-aligned with the target.\n\t\t * Note that setting the direction prop to \"rtl\" will flip the resulting dialog alignment.\n\t\t */\n\t\talign: PropTypes.oneOf([\n\t\t\t'top',\n\t\t\t'top left',\n\t\t\t'top right',\n\t\t\t'right',\n\t\t\t'right top',\n\t\t\t'right bottom',\n\t\t\t'bottom',\n\t\t\t'bottom left',\n\t\t\t'bottom right',\n\t\t\t'left',\n\t\t\t'left top',\n\t\t\t'left bottom',\n\t\t]),\n\t\t/**\n\t\t * CSS classes to be added to the absolutely positioned element.\n\t\t */\n\t\tclassName: PropTypes.oneOfType([\n\t\t\tPropTypes.array,\n\t\t\tPropTypes.object,\n\t\t\tPropTypes.string,\n\t\t]),\n\t\t/**\n\t\t * CSS classes to be added to the wrapping `div` of the contents of the dialog.\n\t\t */\n\t\tcontentsClassName: PropTypes.oneOfType([\n\t\t\tPropTypes.array,\n\t\t\tPropTypes.object,\n\t\t\tPropTypes.string,\n\t\t]),\n\t\t/**\n\t\t * Contents of dialog\n\t\t */\n\t\tchildren: PropTypes.node.isRequired,\n\t\t/**\n\t\t * Closes dialog when tab key is pressed\n\t\t */\n\t\tcloseOnTabKey: PropTypes.bool,\n\t\t/**\n\t\t * Props passed along to wrapping div. This allows one less wrapping `div` to be in the markup. dialog children are expected to be wrapper in a single `div`.\n\t\t */\n\t\tcontainerProps: PropTypes.object,\n\t\t/**\n\t\t * Establishes directional context for component. Defaults to left-to-right.\n\t\t */\n\t\tdirection: PropTypes.oneOf([DIRECTIONS.LTR, DIRECTIONS.RTL]),\n\t\t/**\n\t\t * Will show the nubbin pointing from the dialog to the reference element. Positioning and offsets will be handled.\n\t\t */\n\t\thasNubbin: PropTypes.bool,\n\t\t/**\n\t\t * By default, dialogs will flip their alignment (such as bottom to top) if they extend beyond a boundary element such as a scrolling parent or a window/viewpoint. `hasStaticAlignment` disables this behavior and allows this component to extend beyond boundary elements.\n\t\t */\n\t\thasStaticAlignment: PropTypes.bool,\n\t\t/**\n\t\t * Sets the dialog width to the width of either 'target' (Menus attached to `input` typically follow this UX pattern), 'menu' or 'none.\n\t\t */\n\t\tinheritWidthOf: PropTypes.oneOf(['target', 'menu', 'none']),\n\t\t/**\n\t\t * DEPRECATED - do not add checkProp deprecation message at this level. It is handled at higher level components.\n\t\t * TODO - to be removed.\n\t\t * Offset adds pixels to the absolutely positioned dropdown menu in the format: ([vertical]px [horizontal]px). SHOULD BE OBJECT -----------\n\t\t */\n\t\toffset: PropTypes.string,\n\t\t/**\n\t\t * Called when dialog closes and unmounts.\n\t\t */\n\t\tonClose: PropTypes.func,\n\t\t/**\n\t\t * Called when a key pressed.\n\t\t */\n\t\tonKeyDown: PropTypes.func,\n\t\t/**\n\t\t * Called when mouse hovers over the trigger button. This is only called if `this.props.openOn` is set to `hover`.\n\t\t */\n\t\tonMouseEnter: PropTypes.func,\n\t\t/**\n\t\t * Called when mouse hover leaves the trigger button. This is only called if `this.props.openOn` is set to `hover`.\n\t\t */\n\t\tonMouseLeave: PropTypes.func,\n\t\t/**\n\t\t * Called when dialog opens (that is mounts). The parameters are `undefined, { portal: this.portal }`.\n\t\t */\n\t\tonOpen: PropTypes.func,\n\t\t/**\n\t\t * React component to be aligned with. Function should return a DOM `ref` from the parent component.\n\t\t */\n\t\tonRequestTargetElement: PropTypes.func.isRequired,\n\t\t/**\n\t\t * Triggered when an item in the menu is clicked.\n\t\t */\n\t\toutsideClickIgnoreClass: PropTypes.string,\n\t\t/**\n\t\t * If a dialog is `positione=\"overflowBoundaryElement\"`, it will be rendered in a portal or separate render tree. This `portalMount` callback will be triggered instead of the the default `ReactDOM.unstable_renderSubtreeIntoContainer` and the function will mount the portal itself. Consider the following code that bypasses the internal mount and uses an Enzyme wrapper to mount the React root tree to the DOM.\n\t\t *\n\t\t * ```\n\t\t * <Popover\n\t\t * isOpen\n\t\t * portalMount={({ instance, reactElement, domContainerNode }) => {\n\t\t * portalWrapper = Enzyme.mount(reactElement, { attachTo: domContainerNode });\n\t\t * }}\n\t\t * onOpen={() => {\n\t\t * expect(portalWrapper.find(`#my-heading`)).to.exist;\n\t\t * done();\n\t\t * }}\n\t\t * />\n\t\t * ```\n\t\t */\n\t\tportalMount: PropTypes.func,\n\t\t/**\n\t\t * Please select one of the following:\n\t\t * * `absolute` - (default) The dialog will use `position: absolute` and style attributes to position itself. This allows inverted placement or flipping of the dialog.\n\t\t * * `overflowBoundaryElement` - The dialog will overflow scrolling parents. Use on elements that are aligned to the left or right of their target and don't care about the target being within a scrolling parent. Typically this is a popover or tooltip. Dropdown menus can usually open up and down if no room exists. In order to achieve this a portal element will be created and attached to `body`. This element will render into that detached render tree.\n\t\t * * `relative` - No styling or portals will be used. Menus will be positioned relative to their triggers. This is a great choice for HTML snapshot testing.\n\t\t */\n\t\tposition: PropTypes.oneOf([\n\t\t\t'absolute',\n\t\t\t'overflowBoundaryElement',\n\t\t\t'relative',\n\t\t]).isRequired,\n\t\t/**\n\t\t * An object of CSS styles that are applied to the immediate parent `div` of the contents. Use this instead of margin props.\n\t\t */\n\t\tstyle: PropTypes.object,\n\n\t\t/**\n\t\t * Sets which focus UX pattern to follow. For instance, popovers trap focus and must be exited to regain focus. Dropdowns and Tooltips never have focus.\n\t\t */\n\t\tvariant: PropTypes.oneOf(['dropdown', 'popover', 'tooltip']),\n\t};\n\n\tstatic defaultProps = {\n\t\talign: 'bottom left',\n\t\tdirection: DIRECTIONS.LTR,\n\t\toffset: '0px 0px',\n\t\toutsideClickIgnoreClass: 'ignore-react-onclickoutside',\n\t};\n\n\tstate = {\n\t\ttriggerPopperJS: false,\n\t\tisOpen: false,\n\t};\n\n\tcomponentDidMount() {\n\t\tif (\n\t\t\tthis.props.position === 'absolute' ||\n\t\t\tthis.props.position === 'relative'\n\t\t) {\n\t\t\tthis.handleOpen();\n\t\t}\n\t}\n\n\tcomponentDidUpdate(prevProps, prevState) {\n\t\t// Re-run positioning only when a prop that actually feeds the position\n\t\t// calculation changes. `autoUpdate` (set up in `createPopper`) already\n\t\t// re-runs on scroll/resize/layout shifts, so calling `floatingUpdate()`\n\t\t// on *every* render — including the re-renders our own `setState`\n\t\t// triggers — just recomputes the same position repeatedly. Under jsdom\n\t\t// (where each recompute is pure overhead) this multiplied menu-open cost\n\t\t// several-fold; in real browsers it was redundant work.\n\t\tif (\n\t\t\tthis.floatingUpdate &&\n\t\t\t(prevProps.align !== this.props.align ||\n\t\t\t\tprevProps.direction !== this.props.direction ||\n\t\t\t\tprevProps.hasStaticAlignment !== this.props.hasStaticAlignment)\n\t\t) {\n\t\t\tthis.floatingUpdate();\n\t\t}\n\t\tif (\n\t\t\tthis.state.triggerPopperJS === true &&\n\t\t\tprevState.triggerPopperJS === false &&\n\t\t\t(this.props.position === 'absolute' ||\n\t\t\t\tthis.props.position === 'overflowBoundaryElement') &&\n\t\t\tthis.dialogContent &&\n\t\t\tthis.props.onRequestTargetElement()\n\t\t) {\n\t\t\tthis.createPopper();\n\t\t}\n\t}\n\n\tcomponentWillUnmount() {\n\t\tif (this.props.variant === 'popover') {\n\t\t\tDOMElementFocus.teardownScopedFocus();\n\t\t\tDOMElementFocus.returnFocusToStoredElement();\n\t\t}\n\n\t\tif (\n\t\t\tthis.props.position === 'absolute' ||\n\t\t\tthis.props.position === 'overflowBoundaryElement'\n\t\t) {\n\t\t\tthis.destroyPopper();\n\t\t}\n\n\t\tthis.handleClose(undefined, { componentWillUnmount: true });\n\t}\n\n\tgetPropOffsetsInPixels = (offsetString) => {\n\t\tconst offsetArray = offsetString.split(' ');\n\t\treturn {\n\t\t\tvertical: parseInt(offsetArray[0], 10),\n\t\t\thorizontal: parseInt(offsetArray[1], 10),\n\t\t};\n\t};\n\n\tgetPopperStyles = () => {\n\t\tconst { popperData } = this.state;\n\t\tif (!this.floatingUpdate || !popperData) {\n\t\t\treturn {\n\t\t\t\tposition: 'absolute',\n\t\t\t\tpointerEvents: 'none',\n\t\t\t};\n\t\t}\n\n\t\tconst { position } = popperData.offsets.popper;\n\t\tconst propOffsets = this.getPropOffsetsInPixels(this.props.offset);\n\n\t\t// FIXME before merge - gotta rename from margin to offset\n\t\tconst nubbinOffsets = this.props.hasNubbin\n\t\t\t? getNubbinMargins(this.state.popperData)\n\t\t\t: { left: 0, top: 0 };\n\n\t\tconst left =\n\t\t\tpopperData.offsets.popper.left +\n\t\t\tnubbinOffsets.left +\n\t\t\tpropOffsets.horizontal;\n\t\tconst top =\n\t\t\tpopperData.offsets.popper.top + nubbinOffsets.top + propOffsets.vertical;\n\n\t\t// A Dropdown with overflowBoundaryElement position and 'align=right' uses max-width instead of inherited children width\n\t\tconst right = 'inherit';\n\n\t\treturn {\n\t\t\t...popperData.style,\n\t\t\tleft: isNaN(left) ? 0 : left,\n\t\t\ttop: isNaN(top) ? 0 : top,\n\t\t\tright,\n\t\t\tposition,\n\t\t};\n\t};\n\n\t// Render\n\tsetDialogContent = (component) => {\n\t\tthis.dialogContent = component;\n\t\tif (!this.state.triggerPopperJS) {\n\t\t\tthis.setState({ triggerPopperJS: true });\n\t\t}\n\t};\n\n\t/**\n\t * Events\n\t */\n\thandleClickOutside = () => {\n\t\tthis.handleClose();\n\t};\n\n\thandleClose = (event, data = {}) => {\n\t\tif (!data.componentWillUnmount) {\n\t\t\tthis.setState({ triggerPopperJS: true });\n\t\t}\n\t\tif (this.props.onClose) {\n\t\t\tthis.props.onClose(event, data);\n\t\t}\n\t};\n\n\thandleClick = (event) => {\n\t\tif (event.nativeEvent) {\n\t\t\tevent.nativeEvent.preventDefault();\n\t\t\tevent.nativeEvent.stopPropagation();\n\t\t}\n\t};\n\n\thandleKeyDown = (event) => {\n\t\tif (event.key === KEYS.TAB) {\n\t\t\tif (this.props.closeOnTabKey) {\n\t\t\t\tEventUtil.trap(event);\n\t\t\t\tthis.handleClose(event);\n\t\t\t}\n\t\t}\n\n\t\tif (this.props.onKeyDown) {\n\t\t\tthis.props.onKeyDown(event);\n\t\t}\n\t};\n\n\thandleOpen = () => {\n\t\tif (this.props.variant === 'popover' && this.dialogContent) {\n\t\t\tDOMElementFocus.storeActiveElement();\n\t\t\tDOMElementFocus.setupScopedFocus({\n\t\t\t\tancestorElement: this.dialogContent,\n\t\t\t}); // eslint-disable-line react/no-find-dom-node\n\t\t\t// Don't steal focus from inner elements\n\t\t\tif (!DOMElementFocus.hasOrAncestorHasFocus()) {\n\t\t\t\tDOMElementFocus.focusAncestor({\n\t\t\t\t\tisPortal: this.props.position === 'overflowBoundaryElement',\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tif (this.props.onOpen) {\n\t\t\tthis.props.onOpen(undefined, { portal: this.dialogContent });\n\t\t}\n\t};\n\n\t/**\n\t * Positioning API and helper functions\n\t *\n\t * Uses `@floating-ui/dom` for positioning. Floating UI shares popper v1's\n\t * placement vocabulary (`bottom-start`, etc.) and its offset-parent\n\t * positioning model, so `mapPropToPopperPlacement` and the nubbin/offset math\n\t * in `dialog-helpers` carry over unchanged. `computeFloatingData` reshapes\n\t * Floating UI's output into the `popperData` object the rest of this\n\t * component and the helpers already consume (`offsets.popper`,\n\t * `offsets.reference`, `placement`, `flipped`, `style`).\n\t */\n\n\tcomputeFloatingData = (reference, floating) => {\n\t\tconst requestedPlacement = mapPropToPopperPlacement(\n\t\t\tthis.props.align,\n\t\t\tthis.props.direction\n\t\t);\n\n\t\t// `strategy: 'absolute'` matches popper v1, which positioned relative to\n\t\t// the offset parent. Floating UI returns `x`/`y` in that same coordinate\n\t\t// space, so the downstream nubbin/offset math is unaffected.\n\t\treturn computePosition(reference, floating, {\n\t\t\tplacement: requestedPlacement,\n\t\t\tstrategy: 'absolute',\n\t\t\t// Flip (invert placement) and shift (nudge to stay in view) replace\n\t\t\t// popper v1's `flip` + `preventOverflow` modifiers. Both are disabled\n\t\t\t// when `hasStaticAlignment` is set, matching the prior behavior.\n\t\t\tmiddleware: this.props.hasStaticAlignment ? [] : [flip(), shift()],\n\t\t}).then(({ x, y, placement }) => {\n\t\t\tconst referenceRect = reference.getBoundingClientRect();\n\t\t\treturn {\n\t\t\t\tplacement,\n\t\t\t\t// Floating UI resolves flips into the final `placement`; a flip\n\t\t\t\t// occurred whenever it differs from what we requested. The nubbin\n\t\t\t\t// class helper keys off this.\n\t\t\t\tflipped: placement !== requestedPlacement,\n\t\t\t\toffsets: {\n\t\t\t\t\tpopper: { left: x, top: y, position: 'absolute' },\n\t\t\t\t\treference: {\n\t\t\t\t\t\twidth: referenceRect.width,\n\t\t\t\t\t\theight: referenceRect.height,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tstyle: {},\n\t\t\t};\n\t\t});\n\t};\n\n\tcreatePopper = () => {\n\t\tconst reference = this.props.onRequestTargetElement(); // eslint-disable-line react/no-find-dom-node\n\t\tconst floating = this.dialogContent;\n\n\t\tif (!reference) {\n\t\t\tconsole.error('Target node not found!', reference); // eslint-disable-line no-console\n\t\t}\n\t\tif (!floating) {\n\t\t\tconsole.error('Popper node not found!', floating); // eslint-disable-line no-console\n\t\t}\n\t\tif (!reference || !floating) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst update = () => {\n\t\t\tthis.computeFloatingData(reference, floating).then((popperData) => {\n\t\t\t\tif (\n\t\t\t\t\t!this.state.popperData ||\n\t\t\t\t\t!isEqual(popperData.offsets, this.state.popperData.offsets) ||\n\t\t\t\t\tpopperData.placement !== this.state.popperData.placement\n\t\t\t\t) {\n\t\t\t\t\tthis.setState({ popperData });\n\t\t\t\t}\n\t\t\t});\n\t\t};\n\n\t\t// `autoUpdate` re-runs positioning on scroll, resize, and layout shifts —\n\t\t// the equivalent of popper v1's `eventsEnabled`. It also invokes `update`\n\t\t// once synchronously to establish the initial position, so no separate\n\t\t// `update()` call is needed here (a manual call would just recompute the\n\t\t// same position a second time). It returns a cleanup function stored for\n\t\t// teardown.\n\t\tthis.cleanupFloating = autoUpdate(reference, floating, update);\n\t\tthis.floatingUpdate = update;\n\t};\n\n\tdestroyPopper = () => {\n\t\tif (this.cleanupFloating) {\n\t\t\tthis.cleanupFloating();\n\t\t\tthis.cleanupFloating = null;\n\t\t}\n\t\tthis.floatingUpdate = null;\n\t};\n\n\trender() {\n\t\tlet style = {};\n\t\tconst role =\n\t\t\tthis.props.variant === 'popover' ? 'dialog' : this.props.variant;\n\t\tif (\n\t\t\tthis.props.position === 'absolute' ||\n\t\t\tthis.props.position === 'overflowBoundaryElement'\n\t\t) {\n\t\t\tstyle = {\n\t\t\t\t...style,\n\t\t\t\toutline: 0,\n\t\t\t\t...this.getPopperStyles(),\n\t\t\t};\n\t\t}\n\n\t\tif (\n\t\t\tthis.props.inheritWidthOf === 'target' &&\n\t\t\tthis.props.onRequestTargetElement()\n\t\t) {\n\t\t\tstyle.width = this.props\n\t\t\t\t.onRequestTargetElement()\n\t\t\t\t.getBoundingClientRect().width;\n\t\t} else if (\n\t\t\tthis.props.inheritWidthOf === 'menu' &&\n\t\t\tthis.dialogContent &&\n\t\t\tthis.dialogContent.querySelector('.slds-listbox')\n\t\t) {\n\t\t\t// inherit menu renderer width\n\t\t\tstyle.width = this.dialogContent\n\t\t\t\t.querySelector('.slds-listbox')\n\t\t\t\t.getBoundingClientRect().width;\n\t\t}\n\n\t\tstyle = {\n\t\t\t...style,\n\t\t\t...this.props.style,\n\t\t};\n\n\t\tconst outerTag = this.props.variant === 'popover' ? 'section' : 'div';\n\n\t\tconst contents = React.createElement(\n\t\t\touterTag,\n\t\t\t{\n\t\t\t\tclassName:\n\t\t\t\t\tclassNames(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'absolute-positioned': this.props.position === 'absolute',\n\t\t\t\t\t\t\t'portal-positioned':\n\t\t\t\t\t\t\t\tthis.props.position === 'overflowBoundaryElement',\n\t\t\t\t\t\t\t[`${this.props.outsideClickIgnoreClass}`]:\n\t\t\t\t\t\t\t\tthis.props.position === 'overflowBoundaryElement',\n\t\t\t\t\t\t},\n\t\t\t\t\t\tthis.props.hasNubbin &&\n\t\t\t\t\t\t\tgetNubbinClassName(this.props.align, this.state.popperData),\n\t\t\t\t\t\tthis.props.contentsClassName\n\t\t\t\t\t) || undefined,\n\n\t\t\t\tstyle,\n\t\t\t\tonMouseDown: this.props.onMouseDown,\n\t\t\t\tonKeyDown: this.handleKeyDown,\n\t\t\t\tonMouseEnter: this.props.onMouseEnter,\n\t\t\t\tonMouseLeave: this.props.onMouseLeave,\n\t\t\t\tref: this.setDialogContent,\n\t\t\t\trole,\n\t\t\t\ttabIndex: this.props.variant === 'popover' ? '-1' : undefined,\n\t\t\t\t...this.props.containerProps,\n\t\t\t},\n\n\t\t\tthis.props.children\n\t\t);\n\n\t\tconst subRenders = {\n\t\t\tabsolute: () => contents,\n\t\t\trelative: () => contents,\n\t\t\toverflowBoundaryElement: () => {\n\t\t\t\t// Cycle through current context, create object of\n\t\t\t\t// truthy values, and pass into Portal's context.\n\n\t\t\t\t// TODO: Add test when switched to `ReactDOM.createPortal`\n\t\t\t\tconst truthyIconSettingsContext = Object.keys(this.context)\n\t\t\t\t\t.filter((key) => Boolean(this.context[key]))\n\t\t\t\t\t.reduce(\n\t\t\t\t\t\t(accumulatedContext, key) => ({\n\t\t\t\t\t\t\t...accumulatedContext,\n\t\t\t\t\t\t\t...{ [key]: this.context[key] },\n\t\t\t\t\t\t}),\n\t\t\t\t\t\t{}\n\t\t\t\t\t);\n\t\t\t\tconst wrapped = (\n\t\t\t\t\t// eslint-disable-next-line\n\t\t\t\t\t<UNSAFE_DirectionSettings.Provider value={this.props.direction}>\n\t\t\t\t\t\t<IconSettings {...truthyIconSettingsContext}>\n\t\t\t\t\t\t\t{contents}\n\t\t\t\t\t\t</IconSettings>\n\t\t\t\t\t</UNSAFE_DirectionSettings.Provider>\n\t\t\t\t);\n\t\t\t\treturn (\n\t\t\t\t\t<Portal onOpen={this.handleOpen} portalMount={this.props.portalMount}>\n\t\t\t\t\t\t{wrapped}\n\t\t\t\t\t</Portal>\n\t\t\t\t);\n\t\t\t},\n\t\t};\n\n\t\treturn subRenders[this.props.position] && subRenders[this.props.position]();\n\t}\n}\n\nDialog.contextType = IconSettingsContext;\n\nexport default LanguageDirection(Dialog);\n"],"mappings":";;;;;;;;;;;;;;;;AAqDA,IAAM,IAAN,cAAqB,EAAM,UAAU;CACpC,OAAO,cAAc;CAErB,OAAO,YAAY;EAMlB,OAAO,EAAU,MAAM;GACtB;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACD,CAAC;EAID,WAAW,EAAU,UAAU;GAC9B,EAAU;GACV,EAAU;GACV,EAAU;EACX,CAAC;EAID,mBAAmB,EAAU,UAAU;GACtC,EAAU;GACV,EAAU;GACV,EAAU;EACX,CAAC;EAID,UAAU,EAAU,KAAK;EAIzB,eAAe,EAAU;EAIzB,gBAAgB,EAAU;EAI1B,WAAW,EAAU,MAAM,CAAC,EAAW,KAAK,EAAW,GAAG,CAAC;EAI3D,WAAW,EAAU;EAIrB,oBAAoB,EAAU;EAI9B,gBAAgB,EAAU,MAAM;GAAC;GAAU;GAAQ;EAAM,CAAC;EAM1D,QAAQ,EAAU;EAIlB,SAAS,EAAU;EAInB,WAAW,EAAU;EAIrB,cAAc,EAAU;EAIxB,cAAc,EAAU;EAIxB,QAAQ,EAAU;EAIlB,wBAAwB,EAAU,KAAK;EAIvC,yBAAyB,EAAU;EAiBnC,aAA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,CAAC,CACF,GACK,IAEL,kBAAC,EAAyB,UAA1B;KAAmC,OAAO,KAAK,MAAM;KACpD,UAAA,kBAAC,GAAD;MAAc,GAAI;MAChB,UAAA;KACY,CAAA;IACoB,CAAA;IAEpC,OACC,kBAAC,GAAD;KAAQ,QAAQ,KAAK;KAAY,aAAa,KAAK,MAAM;KACvD,UAAA;IACM,CAAA;GAEV;EACD;EAEA,OAAO,EAAW,KAAK,MAAM,aAAa,EAAW,KAAK,MAAM,SAAS,CAAC;CAC3E;AACD;AAEA,EAAO,cAAc;AAErB,IAAA,IAAe,EAAkB,CAAM"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../../components/utilities/dialog/index.jsx"],"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 */\nimport React from 'react';\n\nimport PropTypes from 'prop-types';\n\nimport { computePosition, autoUpdate, flip, shift } from '@floating-ui/dom';\nimport { dequal as isEqual } from 'dequal';\n\n// ### classNames\n// [github.com/JedWatson/classnames](https://github.com/JedWatson/classnames)\n// This project uses `classnames`, \"a simple javascript utility for conditionally\n// joining classNames together.\"\nimport classNames from 'classnames';\n\nimport Portal from './portal';\nimport EventUtil from '../../../utilities/event';\nimport KEYS from '../../../utilities/key-code';\nimport DOMElementFocus from '../../../utilities/dom-element-focus';\nimport {\n\tgetNubbinMargins,\n\tgetNubbinClassName,\n\tmapPropToPopperPlacement,\n} from '../../../utilities/dialog-helpers';\n\nimport { DIALOG } from '../../../utilities/constants';\n\n// #### Dialog doesn't pass down <IconSettings> context so repassing it here.\nimport IconSettings, { IconSettingsContext } from '../../icon-settings';\n// eslint-disable-next-line camelcase\nimport UNSAFE_DirectionSettings, { DIRECTIONS } from '../UNSAFE_direction';\nimport LanguageDirection from '../UNSAFE_direction/private/language-direction';\n\n/*\n * A Dialog is content that is separate from the typical flow of a page. It typically overlays other elements in the document flow. This is achieved with elevation (`z-index`) and one of the following: relative position, absolute position, or a new top-level React render tree (portal). A boundary element is a scrolling ancestor element or the edge of the browser (window/viewport). This element typically has an overflow (overflow-y/overflow-x) style that is scroll, hidden, or auto. Inverted placement is the flipping of the overlay element from top to bottom or left to right in order stay within a boundary element.\n *\n * * Dropdown menu (Combobox, DatePicker, et al.) placement is typically bottom-aligned and should be allowed to invert its placement when inside a boundary element this often happens within a modal. Dropdowns should not overflow boundary elements , since most boundary elements scroll vertically and have space for the menu.\n *\n * * If they are hidden, left and right placed overlay elements (such as Popover and Tooltip) should be placed within a portal element attached to the DOM <body>, but styled to align to its target/trigger. Since scrolling typically occurs on the vertical axis, this allows them to overflow boundary elements and still allow scrolling of content, yet still invert placement for the browser viewport. Portal elements are only necessary if an original ancestor boundary element exists. **No portals are created by default.**\n *\n * * Nubbins/arrows should be repositioned for any new placement/alignment.\n *\n * Allow Overflowing of Boundary Element: Allow applications to create a portal element attached to the DOM <body> to be outside of boundary elements if manual testing shows confusing alignment/poor usability/readability. This should be exception and not the default.\n *\n * Allow Inverted placement: Allow applications to prevent inverted placement if manual testing shows confusing alignment/poor usability/readability.\n *\n * ### How this new Dialog component works\n * * There is no longer an inline render within components. All overlays should go through `Dialog`. `position: relative` just passes on the markup with some additional event listeners. No positional library is used.\n * * The default `position: absolute` will run through three renders. It will first render the overlay at `0px/0px` offset of its parent. It will then store the target DOM node, once the DOM node is set, a state change will occur and tell a PopperJS instance to be created on update, once it is created, a third render is done to update the styles created by PopperJS.\n * * `position: overflowBoundaryElement` will do the same three renders as `absolute` except that the initial render will create a disconnected render tree (portal) on the `body`. Then, the position will change once the target is stored. The portal itself will be rendered multiple times. The first will result in `onOpen` executing. Each update will result in a re-render of the disconnected render-tree.\n *\n * This component is private.\n */\nclass Dialog extends React.Component {\n\tstatic displayName = DIALOG;\n\n\tstatic propTypes = {\n\t\t/**\n\t\t * Alignment of the dialog with respect to the target (assuming left-to-right language direction). For example,\n\t\t * a value of 'left bottom' indicates that the dialog will be rendered below and left-aligned with the target.\n\t\t * Note that setting the direction prop to \"rtl\" will flip the resulting dialog alignment.\n\t\t */\n\t\talign: PropTypes.oneOf([\n\t\t\t'top',\n\t\t\t'top left',\n\t\t\t'top right',\n\t\t\t'right',\n\t\t\t'right top',\n\t\t\t'right bottom',\n\t\t\t'bottom',\n\t\t\t'bottom left',\n\t\t\t'bottom right',\n\t\t\t'left',\n\t\t\t'left top',\n\t\t\t'left bottom',\n\t\t]),\n\t\t/**\n\t\t * CSS classes to be added to the absolutely positioned element.\n\t\t */\n\t\tclassName: PropTypes.oneOfType([\n\t\t\tPropTypes.array,\n\t\t\tPropTypes.object,\n\t\t\tPropTypes.string,\n\t\t]),\n\t\t/**\n\t\t * CSS classes to be added to the wrapping `div` of the contents of the dialog.\n\t\t */\n\t\tcontentsClassName: PropTypes.oneOfType([\n\t\t\tPropTypes.array,\n\t\t\tPropTypes.object,\n\t\t\tPropTypes.string,\n\t\t]),\n\t\t/**\n\t\t * Contents of dialog\n\t\t */\n\t\tchildren: PropTypes.node.isRequired,\n\t\t/**\n\t\t * Closes dialog when tab key is pressed\n\t\t */\n\t\tcloseOnTabKey: PropTypes.bool,\n\t\t/**\n\t\t * Props passed along to wrapping div. This allows one less wrapping `div` to be in the markup. dialog children are expected to be wrapper in a single `div`.\n\t\t */\n\t\tcontainerProps: PropTypes.object,\n\t\t/**\n\t\t * Establishes directional context for component. Defaults to left-to-right.\n\t\t */\n\t\tdirection: PropTypes.oneOf([DIRECTIONS.LTR, DIRECTIONS.RTL]),\n\t\t/**\n\t\t * Will show the nubbin pointing from the dialog to the reference element. Positioning and offsets will be handled.\n\t\t */\n\t\thasNubbin: PropTypes.bool,\n\t\t/**\n\t\t * With `hasNubbin`, keeps the nubbin's offset but doesn't draw it, for a component that draws its own (Tooltip `hasAnchoredNubbin`).\n\t\t */\n\t\tisNubbinHidden: PropTypes.bool,\n\t\t/**\n\t\t * By default, dialogs will flip their alignment (such as bottom to top) if they extend beyond a boundary element such as a scrolling parent or a window/viewpoint. `hasStaticAlignment` disables this behavior and allows this component to extend beyond boundary elements.\n\t\t */\n\t\thasStaticAlignment: PropTypes.bool,\n\t\t/**\n\t\t * Sets the dialog width to the width of either 'target' (Menus attached to `input` typically follow this UX pattern), 'menu' or 'none.\n\t\t */\n\t\tinheritWidthOf: PropTypes.oneOf(['target', 'menu', 'none']),\n\t\t/**\n\t\t * DEPRECATED - do not add checkProp deprecation message at this level. It is handled at higher level components.\n\t\t * TODO - to be removed.\n\t\t * Offset adds pixels to the absolutely positioned dropdown menu in the format: ([vertical]px [horizontal]px). SHOULD BE OBJECT -----------\n\t\t */\n\t\toffset: PropTypes.string,\n\t\t/**\n\t\t * Called when dialog closes and unmounts.\n\t\t */\n\t\tonClose: PropTypes.func,\n\t\t/**\n\t\t * Called when a key pressed.\n\t\t */\n\t\tonKeyDown: PropTypes.func,\n\t\t/**\n\t\t * Called when mouse hovers over the trigger button. This is only called if `this.props.openOn` is set to `hover`.\n\t\t */\n\t\tonMouseEnter: PropTypes.func,\n\t\t/**\n\t\t * Called when mouse hover leaves the trigger button. This is only called if `this.props.openOn` is set to `hover`.\n\t\t */\n\t\tonMouseLeave: PropTypes.func,\n\t\t/**\n\t\t * Called when dialog opens (that is mounts). The parameters are `undefined, { portal: this.portal }`.\n\t\t */\n\t\tonOpen: PropTypes.func,\n\t\t/**\n\t\t * React component to be aligned with. Function should return a DOM `ref` from the parent component.\n\t\t */\n\t\tonRequestTargetElement: PropTypes.func.isRequired,\n\t\t/**\n\t\t * Triggered when an item in the menu is clicked.\n\t\t */\n\t\toutsideClickIgnoreClass: PropTypes.string,\n\t\t/**\n\t\t * If a dialog is `positione=\"overflowBoundaryElement\"`, it will be rendered in a portal or separate render tree. This `portalMount` callback will be triggered instead of the the default `ReactDOM.unstable_renderSubtreeIntoContainer` and the function will mount the portal itself. Consider the following code that bypasses the internal mount and uses an Enzyme wrapper to mount the React root tree to the DOM.\n\t\t *\n\t\t * ```\n\t\t * <Popover\n\t\t * isOpen\n\t\t * portalMount={({ instance, reactElement, domContainerNode }) => {\n\t\t * portalWrapper = Enzyme.mount(reactElement, { attachTo: domContainerNode });\n\t\t * }}\n\t\t * onOpen={() => {\n\t\t * expect(portalWrapper.find(`#my-heading`)).to.exist;\n\t\t * done();\n\t\t * }}\n\t\t * />\n\t\t * ```\n\t\t */\n\t\tportalMount: PropTypes.func,\n\t\t/**\n\t\t * Please select one of the following:\n\t\t * * `absolute` - (default) The dialog will use `position: absolute` and style attributes to position itself. This allows inverted placement or flipping of the dialog.\n\t\t * * `overflowBoundaryElement` - The dialog will overflow scrolling parents. Use on elements that are aligned to the left or right of their target and don't care about the target being within a scrolling parent. Typically this is a popover or tooltip. Dropdown menus can usually open up and down if no room exists. In order to achieve this a portal element will be created and attached to `body`. This element will render into that detached render tree.\n\t\t * * `relative` - No styling or portals will be used. Menus will be positioned relative to their triggers. This is a great choice for HTML snapshot testing.\n\t\t */\n\t\tposition: PropTypes.oneOf([\n\t\t\t'absolute',\n\t\t\t'overflowBoundaryElement',\n\t\t\t'relative',\n\t\t]).isRequired,\n\t\t/**\n\t\t * An object of CSS styles that are applied to the immediate parent `div` of the contents. Use this instead of margin props.\n\t\t */\n\t\tstyle: PropTypes.object,\n\n\t\t/**\n\t\t * Sets which focus UX pattern to follow. For instance, popovers trap focus and must be exited to regain focus. Dropdowns and Tooltips never have focus.\n\t\t */\n\t\tvariant: PropTypes.oneOf(['dropdown', 'popover', 'tooltip']),\n\t};\n\n\tstatic defaultProps = {\n\t\talign: 'bottom left',\n\t\tdirection: DIRECTIONS.LTR,\n\t\toffset: '0px 0px',\n\t\toutsideClickIgnoreClass: 'ignore-react-onclickoutside',\n\t};\n\n\tstate = {\n\t\ttriggerPopperJS: false,\n\t\tisOpen: false,\n\t};\n\n\tcomponentDidMount() {\n\t\tif (\n\t\t\tthis.props.position === 'absolute' ||\n\t\t\tthis.props.position === 'relative'\n\t\t) {\n\t\t\tthis.handleOpen();\n\t\t}\n\t}\n\n\tcomponentDidUpdate(prevProps, prevState) {\n\t\t// Re-run positioning only when a prop that actually feeds the position\n\t\t// calculation changes. `autoUpdate` (set up in `createPopper`) already\n\t\t// re-runs on scroll/resize/layout shifts, so calling `floatingUpdate()`\n\t\t// on *every* render — including the re-renders our own `setState`\n\t\t// triggers — just recomputes the same position repeatedly. Under jsdom\n\t\t// (where each recompute is pure overhead) this multiplied menu-open cost\n\t\t// several-fold; in real browsers it was redundant work.\n\t\tif (\n\t\t\tthis.floatingUpdate &&\n\t\t\t(prevProps.align !== this.props.align ||\n\t\t\t\tprevProps.direction !== this.props.direction ||\n\t\t\t\tprevProps.hasStaticAlignment !== this.props.hasStaticAlignment)\n\t\t) {\n\t\t\tthis.floatingUpdate();\n\t\t}\n\t\tif (\n\t\t\tthis.state.triggerPopperJS === true &&\n\t\t\tprevState.triggerPopperJS === false &&\n\t\t\t(this.props.position === 'absolute' ||\n\t\t\t\tthis.props.position === 'overflowBoundaryElement') &&\n\t\t\tthis.dialogContent &&\n\t\t\tthis.props.onRequestTargetElement()\n\t\t) {\n\t\t\tthis.createPopper();\n\t\t}\n\t}\n\n\tcomponentWillUnmount() {\n\t\tif (this.props.variant === 'popover') {\n\t\t\tDOMElementFocus.teardownScopedFocus();\n\t\t\tDOMElementFocus.returnFocusToStoredElement();\n\t\t}\n\n\t\tif (\n\t\t\tthis.props.position === 'absolute' ||\n\t\t\tthis.props.position === 'overflowBoundaryElement'\n\t\t) {\n\t\t\tthis.destroyPopper();\n\t\t}\n\n\t\tthis.handleClose(undefined, { componentWillUnmount: true });\n\t}\n\n\tgetPropOffsetsInPixels = (offsetString) => {\n\t\tconst offsetArray = offsetString.split(' ');\n\t\treturn {\n\t\t\tvertical: parseInt(offsetArray[0], 10),\n\t\t\thorizontal: parseInt(offsetArray[1], 10),\n\t\t};\n\t};\n\n\tgetPopperStyles = () => {\n\t\tconst { popperData } = this.state;\n\t\tif (!this.floatingUpdate || !popperData) {\n\t\t\treturn {\n\t\t\t\tposition: 'absolute',\n\t\t\t\tpointerEvents: 'none',\n\t\t\t};\n\t\t}\n\n\t\tconst { position } = popperData.offsets.popper;\n\t\tconst propOffsets = this.getPropOffsetsInPixels(this.props.offset);\n\n\t\t// FIXME before merge - gotta rename from margin to offset\n\t\tconst nubbinOffsets = this.props.hasNubbin\n\t\t\t? getNubbinMargins(this.state.popperData)\n\t\t\t: { left: 0, top: 0 };\n\n\t\tconst left =\n\t\t\tpopperData.offsets.popper.left +\n\t\t\tnubbinOffsets.left +\n\t\t\tpropOffsets.horizontal;\n\t\tconst top =\n\t\t\tpopperData.offsets.popper.top + nubbinOffsets.top + propOffsets.vertical;\n\n\t\t// A Dropdown with overflowBoundaryElement position and 'align=right' uses max-width instead of inherited children width\n\t\tconst right = 'inherit';\n\n\t\treturn {\n\t\t\t...popperData.style,\n\t\t\tleft: isNaN(left) ? 0 : left,\n\t\t\ttop: isNaN(top) ? 0 : top,\n\t\t\tright,\n\t\t\tposition,\n\t\t};\n\t};\n\n\t// Render\n\tsetDialogContent = (component) => {\n\t\tthis.dialogContent = component;\n\t\tif (!this.state.triggerPopperJS) {\n\t\t\tthis.setState({ triggerPopperJS: true });\n\t\t}\n\t};\n\n\t/**\n\t * Events\n\t */\n\thandleClickOutside = () => {\n\t\tthis.handleClose();\n\t};\n\n\thandleClose = (event, data = {}) => {\n\t\tif (!data.componentWillUnmount) {\n\t\t\tthis.setState({ triggerPopperJS: true });\n\t\t}\n\t\tif (this.props.onClose) {\n\t\t\tthis.props.onClose(event, data);\n\t\t}\n\t};\n\n\thandleClick = (event) => {\n\t\tif (event.nativeEvent) {\n\t\t\tevent.nativeEvent.preventDefault();\n\t\t\tevent.nativeEvent.stopPropagation();\n\t\t}\n\t};\n\n\thandleKeyDown = (event) => {\n\t\tif (event.key === KEYS.TAB) {\n\t\t\tif (this.props.closeOnTabKey) {\n\t\t\t\tEventUtil.trap(event);\n\t\t\t\tthis.handleClose(event);\n\t\t\t}\n\t\t}\n\n\t\tif (this.props.onKeyDown) {\n\t\t\tthis.props.onKeyDown(event);\n\t\t}\n\t};\n\n\thandleOpen = () => {\n\t\tif (this.props.variant === 'popover' && this.dialogContent) {\n\t\t\tDOMElementFocus.storeActiveElement();\n\t\t\tDOMElementFocus.setupScopedFocus({\n\t\t\t\tancestorElement: this.dialogContent,\n\t\t\t}); // eslint-disable-line react/no-find-dom-node\n\t\t\t// Don't steal focus from inner elements\n\t\t\tif (!DOMElementFocus.hasOrAncestorHasFocus()) {\n\t\t\t\tDOMElementFocus.focusAncestor({\n\t\t\t\t\tisPortal: this.props.position === 'overflowBoundaryElement',\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tif (this.props.onOpen) {\n\t\t\tthis.props.onOpen(undefined, { portal: this.dialogContent });\n\t\t}\n\t};\n\n\t/**\n\t * Positioning API and helper functions\n\t *\n\t * Uses `@floating-ui/dom` for positioning. Floating UI shares popper v1's\n\t * placement vocabulary (`bottom-start`, etc.) and its offset-parent\n\t * positioning model, so `mapPropToPopperPlacement` and the nubbin/offset math\n\t * in `dialog-helpers` carry over unchanged. `computeFloatingData` reshapes\n\t * Floating UI's output into the `popperData` object the rest of this\n\t * component and the helpers already consume (`offsets.popper`,\n\t * `offsets.reference`, `placement`, `flipped`, `style`).\n\t */\n\n\tcomputeFloatingData = (reference, floating) => {\n\t\tconst requestedPlacement = mapPropToPopperPlacement(\n\t\t\tthis.props.align,\n\t\t\tthis.props.direction\n\t\t);\n\n\t\t// `strategy: 'absolute'` matches popper v1, which positioned relative to\n\t\t// the offset parent. Floating UI returns `x`/`y` in that same coordinate\n\t\t// space, so the downstream nubbin/offset math is unaffected.\n\t\treturn computePosition(reference, floating, {\n\t\t\tplacement: requestedPlacement,\n\t\t\tstrategy: 'absolute',\n\t\t\t// Flip (invert placement) and shift (nudge to stay in view) replace\n\t\t\t// popper v1's `flip` + `preventOverflow` modifiers. Both are disabled\n\t\t\t// when `hasStaticAlignment` is set, matching the prior behavior.\n\t\t\tmiddleware: this.props.hasStaticAlignment ? [] : [flip(), shift()],\n\t\t}).then(({ x, y, placement }) => {\n\t\t\tconst referenceRect = reference.getBoundingClientRect();\n\t\t\treturn {\n\t\t\t\tplacement,\n\t\t\t\t// Floating UI resolves flips into the final `placement`; a flip\n\t\t\t\t// occurred whenever it differs from what we requested. The nubbin\n\t\t\t\t// class helper keys off this.\n\t\t\t\tflipped: placement !== requestedPlacement,\n\t\t\t\toffsets: {\n\t\t\t\t\tpopper: { left: x, top: y, position: 'absolute' },\n\t\t\t\t\treference: {\n\t\t\t\t\t\twidth: referenceRect.width,\n\t\t\t\t\t\theight: referenceRect.height,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tstyle: {},\n\t\t\t};\n\t\t});\n\t};\n\n\tcreatePopper = () => {\n\t\tconst reference = this.props.onRequestTargetElement(); // eslint-disable-line react/no-find-dom-node\n\t\tconst floating = this.dialogContent;\n\n\t\tif (!reference) {\n\t\t\tconsole.error('Target node not found!', reference); // eslint-disable-line no-console\n\t\t}\n\t\tif (!floating) {\n\t\t\tconsole.error('Popper node not found!', floating); // eslint-disable-line no-console\n\t\t}\n\t\tif (!reference || !floating) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst update = () => {\n\t\t\tthis.computeFloatingData(reference, floating).then((popperData) => {\n\t\t\t\tif (\n\t\t\t\t\t!this.state.popperData ||\n\t\t\t\t\t!isEqual(popperData.offsets, this.state.popperData.offsets) ||\n\t\t\t\t\tpopperData.placement !== this.state.popperData.placement\n\t\t\t\t) {\n\t\t\t\t\tthis.setState({ popperData });\n\t\t\t\t}\n\t\t\t});\n\t\t};\n\n\t\t// `autoUpdate` re-runs positioning on scroll, resize, and layout shifts —\n\t\t// the equivalent of popper v1's `eventsEnabled`. It also invokes `update`\n\t\t// once synchronously to establish the initial position, so no separate\n\t\t// `update()` call is needed here (a manual call would just recompute the\n\t\t// same position a second time). It returns a cleanup function stored for\n\t\t// teardown.\n\t\tthis.cleanupFloating = autoUpdate(reference, floating, update);\n\t\tthis.floatingUpdate = update;\n\t};\n\n\tdestroyPopper = () => {\n\t\tif (this.cleanupFloating) {\n\t\t\tthis.cleanupFloating();\n\t\t\tthis.cleanupFloating = null;\n\t\t}\n\t\tthis.floatingUpdate = null;\n\t};\n\n\trender() {\n\t\tlet style = {};\n\t\tconst role =\n\t\t\tthis.props.variant === 'popover' ? 'dialog' : this.props.variant;\n\t\tif (\n\t\t\tthis.props.position === 'absolute' ||\n\t\t\tthis.props.position === 'overflowBoundaryElement'\n\t\t) {\n\t\t\tstyle = {\n\t\t\t\t...style,\n\t\t\t\toutline: 0,\n\t\t\t\t...this.getPopperStyles(),\n\t\t\t};\n\t\t}\n\n\t\tif (\n\t\t\tthis.props.inheritWidthOf === 'target' &&\n\t\t\tthis.props.onRequestTargetElement()\n\t\t) {\n\t\t\tstyle.width = this.props\n\t\t\t\t.onRequestTargetElement()\n\t\t\t\t.getBoundingClientRect().width;\n\t\t} else if (\n\t\t\tthis.props.inheritWidthOf === 'menu' &&\n\t\t\tthis.dialogContent &&\n\t\t\tthis.dialogContent.querySelector('.slds-listbox')\n\t\t) {\n\t\t\t// inherit menu renderer width\n\t\t\tstyle.width = this.dialogContent\n\t\t\t\t.querySelector('.slds-listbox')\n\t\t\t\t.getBoundingClientRect().width;\n\t\t}\n\n\t\tstyle = {\n\t\t\t...style,\n\t\t\t...this.props.style,\n\t\t};\n\n\t\tconst outerTag = this.props.variant === 'popover' ? 'section' : 'div';\n\n\t\tconst contents = React.createElement(\n\t\t\touterTag,\n\t\t\t{\n\t\t\t\tclassName:\n\t\t\t\t\tclassNames(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'absolute-positioned': this.props.position === 'absolute',\n\t\t\t\t\t\t\t'portal-positioned':\n\t\t\t\t\t\t\t\tthis.props.position === 'overflowBoundaryElement',\n\t\t\t\t\t\t\t[`${this.props.outsideClickIgnoreClass}`]:\n\t\t\t\t\t\t\t\tthis.props.position === 'overflowBoundaryElement',\n\t\t\t\t\t\t},\n\t\t\t\t\t\tthis.props.hasNubbin &&\n\t\t\t\t\t\t\t!this.props.isNubbinHidden &&\n\t\t\t\t\t\t\tgetNubbinClassName(this.props.align, this.state.popperData),\n\t\t\t\t\t\tthis.props.contentsClassName\n\t\t\t\t\t) || undefined,\n\n\t\t\t\tstyle,\n\t\t\t\tonMouseDown: this.props.onMouseDown,\n\t\t\t\tonKeyDown: this.handleKeyDown,\n\t\t\t\tonMouseEnter: this.props.onMouseEnter,\n\t\t\t\tonMouseLeave: this.props.onMouseLeave,\n\t\t\t\tref: this.setDialogContent,\n\t\t\t\trole,\n\t\t\t\ttabIndex: this.props.variant === 'popover' ? '-1' : undefined,\n\t\t\t\t...this.props.containerProps,\n\t\t\t},\n\n\t\t\tthis.props.children\n\t\t);\n\n\t\tconst subRenders = {\n\t\t\tabsolute: () => contents,\n\t\t\trelative: () => contents,\n\t\t\toverflowBoundaryElement: () => {\n\t\t\t\t// Cycle through current context, create object of\n\t\t\t\t// truthy values, and pass into Portal's context.\n\n\t\t\t\t// TODO: Add test when switched to `ReactDOM.createPortal`\n\t\t\t\tconst truthyIconSettingsContext = Object.keys(this.context)\n\t\t\t\t\t.filter((key) => Boolean(this.context[key]))\n\t\t\t\t\t.reduce(\n\t\t\t\t\t\t(accumulatedContext, key) => ({\n\t\t\t\t\t\t\t...accumulatedContext,\n\t\t\t\t\t\t\t...{ [key]: this.context[key] },\n\t\t\t\t\t\t}),\n\t\t\t\t\t\t{}\n\t\t\t\t\t);\n\t\t\t\tconst wrapped = (\n\t\t\t\t\t// eslint-disable-next-line\n\t\t\t\t\t<UNSAFE_DirectionSettings.Provider value={this.props.direction}>\n\t\t\t\t\t\t<IconSettings {...truthyIconSettingsContext}>\n\t\t\t\t\t\t\t{contents}\n\t\t\t\t\t\t</IconSettings>\n\t\t\t\t\t</UNSAFE_DirectionSettings.Provider>\n\t\t\t\t);\n\t\t\t\treturn (\n\t\t\t\t\t<Portal onOpen={this.handleOpen} portalMount={this.props.portalMount}>\n\t\t\t\t\t\t{wrapped}\n\t\t\t\t\t</Portal>\n\t\t\t\t);\n\t\t\t},\n\t\t};\n\n\t\treturn subRenders[this.props.position] && subRenders[this.props.position]();\n\t}\n}\n\nDialog.contextType = IconSettingsContext;\n\nexport default LanguageDirection(Dialog);\n"],"mappings":";;;;;;;;;;;;;;;;AAqDA,IAAM,IAAN,cAAqB,EAAM,UAAU;CACpC,OAAO,cAAc;CAErB,OAAO,YAAY;EAMlB,OAAO,EAAU,MAAM;GACtB;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACD,CAAC;EAID,WAAW,EAAU,UAAU;GAC9B,EAAU;GACV,EAAU;GACV,EAAU;EACX,CAAC;EAID,mBAAmB,EAAU,UAAU;GACtC,EAAU;GACV,EAAU;GACV,EAAU;EACX,CAAC;EAID,UAAU,EAAU,KAAK;EAIzB,eAAe,EAAU;EAIzB,gBAAgB,EAAU;EAI1B,WAAW,EAAU,MAAM,CAAC,EAAW,KAAK,EAAW,GAAG,CAAC;EAI3D,WAAW,EAAU;EAIrB,gBAAgB,EAAU;EAI1B,oBAAoB,EAAU;EAI9B,gBAAgB,EAAU,MAAM;GAAC;GAAU;GAAQ;EAAM,CAAC;EAM1D,QAAQ,EAAU;EAIlB,SAAS,EAAU;EAInB,WAAW,EAAU;EAIrB,cAAc,EAAU;EAIxB,cAAc,EAAU;EAIxB,QAAQ,EAAU;EAIlB,wBAAwB,EAAU,KAAK;EAIvC,yBAAyB,EAAU;EAiBnC,aAAa,EAAU;EAOvB,UAAU,EAAU,MAAM;GACzB;GACA;GACA;EACD,CAAC,CAAC,CAAC;EAIH,OAAO,EAAU;EAKjB,SAAS,EAAU,MAAM;GAAC;GAAY;GAAW;EAAS,CAAC;CAC5D;CAEA,OAAO,eAAe;EACrB,OAAO;EACP,WAAW,EAAW;EACtB,QAAQ;EACR,yBAAyB;CAC1B;CAEA,QAAQ;EACP,iBAAiB;EACjB,QAAQ;CACT;CAEA,oBAAoB;EACnB,CACC,KAAK,MAAM,aAAa,cACx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SAAS,CAAC;CAC3E;AACD;AAEA,EAAO,cAAc;AAErB,IAAA,IAAe,EAAkB,CAAM"}
|
|
@@ -3,23 +3,25 @@ import { Children as t, useContext as n, useEffect as r, useRef as i, useState a
|
|
|
3
3
|
import { createPortal as o } from "react-dom";
|
|
4
4
|
//#region components/utilities/dialog/portal.tsx
|
|
5
5
|
var s = typeof document < "u", c = (c) => {
|
|
6
|
-
let { renderTag: l = "span", renderTo: u = null, id: d, className: f, style: p, onMount: m, onOpen: h, onUpdate: g, children: _ } = c, v = n(e), y = i(null), b = i(null), [x, S] = a(
|
|
6
|
+
let { renderTag: l = "span", renderTo: u = null, id: d, className: f, style: p, onMount: m, onOpen: h, onUpdate: g, children: _ } = c, v = n(e), y = i(null), b = i(null), [x, S] = a(null), C = () => typeof u == "string" ? document.querySelector(u) : v && typeof v.renderTo == "string" && document.querySelectorAll(v.renderTo)[0] ? document.querySelectorAll(v.renderTo)[0] : u || (s ? document.body : null);
|
|
7
7
|
r(() => {
|
|
8
8
|
if (!s) return;
|
|
9
9
|
let e = document.createElement(l);
|
|
10
10
|
e.setAttribute("style", "display: block; height: 0px; width: 0px;"), e.className = "design-system-react-portal";
|
|
11
11
|
let t = C();
|
|
12
|
-
return t && t.appendChild(e), y.current = e, b.current = m ? m(void 0, { portal: e }) : e, S(
|
|
12
|
+
return t && t.appendChild(e), y.current = e, b.current = m ? m(void 0, { portal: e }) : e, S(e), () => {
|
|
13
13
|
e.parentNode && e.parentNode.removeChild(e), y.current = null, b.current = null;
|
|
14
14
|
};
|
|
15
15
|
}, []), r(() => {
|
|
16
|
+
x && h && h(void 0, { portal: _ });
|
|
17
|
+
}, [x]), r(() => {
|
|
16
18
|
let e = y.current;
|
|
17
19
|
e && (d && (e.id = d), f && (e.className = f), p && Object.keys(p).forEach((t) => {
|
|
18
20
|
e.style[t] = p[t];
|
|
19
21
|
}), g && (b.current = g(b.current)));
|
|
20
22
|
});
|
|
21
23
|
let w = _ ? t.only(_) : null;
|
|
22
|
-
return !x || !
|
|
24
|
+
return !x || !w ? null : o(w, x);
|
|
23
25
|
};
|
|
24
26
|
c.displayName = "Portal";
|
|
25
27
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"portal.js","names":[],"sources":["../../../../../components/utilities/dialog/portal.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\tuseContext,\n\tuseEffect,\n\tuseRef,\n\tuseState,\n\tChildren,\n\ttype ReactNode,\n\ttype CSSProperties,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { PortalSettingsContext } from '../../portal-settings';\n\n/*\n * This component mounts its children within a disconnected render tree (portal).\n *\n * Reimplemented on top of React 18/19's `ReactDOM.createPortal`. The previous\n * implementation relied on `ReactDOM.unstable_renderSubtreeIntoContainer` and\n * `ReactDOM.unmountComponentAtNode`, both of which were removed in React 19.\n */\n\nexport interface PortalProps {\n\t/**\n\t * What tag to use for the portal, defaults to `span`.\n\t */\n\trenderTag?: string;\n\t/**\n\t * What node the portal is rendered to, defaults to `document.body`.\n\t */\n\trenderTo?: string | HTMLElement | null;\n\t/**\n\t * React id prop.\n\t */\n\tid?: string;\n\t/**\n\t * Accepts a _single_ element or component.\n\t */\n\tchildren?: ReactNode;\n\t/**\n\t * ClassName added to the portal node.\n\t */\n\tclassName?: string;\n\t/**\n\t * An object of styles that are applied to the portal.\n\t */\n\tstyle?: CSSProperties;\n\t/**\n\t * Triggers when Portal render tree mounts. Pass in an undefined event and `{ portal: [node] }`\n\t */\n\tonMount?: (event: undefined, data: { portal: HTMLElement }) => unknown;\n\t/**\n\t * Triggers when the portal is mounted.\n\t */\n\tonOpen?: (event: undefined, data: { portal: ReactNode }) => void;\n\t/**\n\t * Triggers when Portal re-renders its tree.\n\t */\n\tonUpdate?: (instance: unknown) => unknown;\n}\n\nconst documentDefined = typeof document !== 'undefined';\n\nconst Portal = (props: PortalProps): React.ReactPortal | null => {\n\tconst {\n\t\trenderTag = 'span',\n\t\trenderTo = null,\n\t\tid,\n\t\tclassName,\n\t\tstyle,\n\t\tonMount,\n\t\tonOpen,\n\t\tonUpdate,\n\t\tchildren,\n\t} = props;\n\n\tconst context = useContext(PortalSettingsContext);\n\tconst portalNodeRef = useRef<HTMLElement | null>(null);\n\tconst portalNodeInstanceRef = useRef<unknown>(null);\n\tconst [
|
|
1
|
+
{"version":3,"file":"portal.js","names":[],"sources":["../../../../../components/utilities/dialog/portal.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\tuseContext,\n\tuseEffect,\n\tuseRef,\n\tuseState,\n\tChildren,\n\ttype ReactNode,\n\ttype CSSProperties,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { PortalSettingsContext } from '../../portal-settings';\n\n/*\n * This component mounts its children within a disconnected render tree (portal).\n *\n * Reimplemented on top of React 18/19's `ReactDOM.createPortal`. The previous\n * implementation relied on `ReactDOM.unstable_renderSubtreeIntoContainer` and\n * `ReactDOM.unmountComponentAtNode`, both of which were removed in React 19.\n */\n\nexport interface PortalProps {\n\t/**\n\t * What tag to use for the portal, defaults to `span`.\n\t */\n\trenderTag?: string;\n\t/**\n\t * What node the portal is rendered to, defaults to `document.body`.\n\t */\n\trenderTo?: string | HTMLElement | null;\n\t/**\n\t * React id prop.\n\t */\n\tid?: string;\n\t/**\n\t * Accepts a _single_ element or component.\n\t */\n\tchildren?: ReactNode;\n\t/**\n\t * ClassName added to the portal node.\n\t */\n\tclassName?: string;\n\t/**\n\t * An object of styles that are applied to the portal.\n\t */\n\tstyle?: CSSProperties;\n\t/**\n\t * Triggers when Portal render tree mounts. Pass in an undefined event and `{ portal: [node] }`\n\t */\n\tonMount?: (event: undefined, data: { portal: HTMLElement }) => unknown;\n\t/**\n\t * Triggers when the portal is mounted.\n\t */\n\tonOpen?: (event: undefined, data: { portal: ReactNode }) => void;\n\t/**\n\t * Triggers when Portal re-renders its tree.\n\t */\n\tonUpdate?: (instance: unknown) => unknown;\n}\n\nconst documentDefined = typeof document !== 'undefined';\n\nconst Portal = (props: PortalProps): React.ReactPortal | null => {\n\tconst {\n\t\trenderTag = 'span',\n\t\trenderTo = null,\n\t\tid,\n\t\tclassName,\n\t\tstyle,\n\t\tonMount,\n\t\tonOpen,\n\t\tonUpdate,\n\t\tchildren,\n\t} = props;\n\n\tconst context = useContext(PortalSettingsContext);\n\tconst portalNodeRef = useRef<HTMLElement | null>(null);\n\tconst portalNodeInstanceRef = useRef<unknown>(null);\n\t// The attached container node, for render; the effects use `portalNodeRef`\n\tconst [portalNode, setPortalNode] = useState<HTMLElement | null>(null);\n\n\t// Resolve where the portal's DOM node should be appended. Precedence matches\n\t// the legacy implementation: explicit `renderTo` selector/node > context\n\t// `renderTo` selector > `document.body`.\n\tconst getPortalParentNode = (): Element | null => {\n\t\tif (typeof renderTo === 'string') {\n\t\t\treturn document.querySelector(renderTo);\n\t\t}\n\t\tif (\n\t\t\tcontext &&\n\t\t\ttypeof context.renderTo === 'string' &&\n\t\t\tdocument.querySelectorAll(context.renderTo)[0]\n\t\t) {\n\t\t\treturn document.querySelectorAll(context.renderTo)[0];\n\t\t}\n\t\treturn renderTo || (documentDefined ? document.body : null);\n\t};\n\n\t// Create the portal container node, append it to the parent, and tear it\n\t// down on unmount. Runs once (mount/unmount lifecycle).\n\tuseEffect(() => {\n\t\tif (!documentDefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst node = document.createElement(renderTag);\n\t\tnode.setAttribute('style', 'display: block; height: 0px; width: 0px;');\n\t\tnode.className = 'design-system-react-portal';\n\n\t\tconst parent = getPortalParentNode();\n\t\tif (parent) {\n\t\t\tparent.appendChild(node);\n\t\t}\n\n\t\tportalNodeRef.current = node;\n\t\tportalNodeInstanceRef.current = onMount\n\t\t\t? onMount(undefined, { portal: node })\n\t\t\t: node;\n\n\t\t// eslint-disable-next-line react-hooks/set-state-in-effect -- the node must be attached to the document before children mount, so it is created in an effect\n\t\tsetPortalNode(node);\n\n\t\treturn () => {\n\t\t\tif (node.parentNode) {\n\t\t\t\tnode.parentNode.removeChild(node);\n\t\t\t}\n\t\t\tportalNodeRef.current = null;\n\t\t\tportalNodeInstanceRef.current = null;\n\t\t};\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, []);\n\n\t// Fire `onOpen` once the children have mounted into the node (the render after\n\t// it is created), so a handler can reach them, for example to move focus inside\n\tuseEffect(() => {\n\t\tif (portalNode && onOpen) {\n\t\t\tonOpen(undefined, { portal: children });\n\t\t}\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [portalNode]);\n\n\t// Keep the container node's id/className/style in sync with props, and fire\n\t// `onUpdate` after each render (matches the legacy `updatePortal` behavior).\n\tuseEffect(() => {\n\t\tconst node = portalNodeRef.current;\n\t\tif (!node) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (id) {\n\t\t\tnode.id = id;\n\t\t}\n\t\tif (className) {\n\t\t\tnode.className = className;\n\t\t}\n\t\tif (style) {\n\t\t\t(Object.keys(style) as Array<keyof CSSProperties>).forEach((key) => {\n\t\t\t\t(node.style as unknown as Record<string, unknown>)[key as string] =\n\t\t\t\t\tstyle[key] as unknown as string;\n\t\t\t});\n\t\t}\n\t\tif (onUpdate) {\n\t\t\tportalNodeInstanceRef.current = onUpdate(portalNodeInstanceRef.current);\n\t\t}\n\t});\n\n\tconst child = children ? Children.only(children) : null;\n\n\tif (!portalNode || !child) {\n\t\treturn null;\n\t}\n\n\treturn createPortal(child, portalNode);\n};\n\nPortal.displayName = 'Portal';\n\nexport default Portal;\n"],"mappings":";;;;AA8DA,IAAM,IAAkB,OAAO,WAAa,KAEtC,KAAU,MAAiD;CAChE,IAAM,EACL,eAAY,QACZ,cAAW,MACX,OACA,cACA,UACA,YACA,WACA,aACA,gBACG,GAEE,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EAAO,cAAc"}
|
|
@@ -2,9 +2,9 @@ import { LIST as e } from "../../../utilities/constants.js";
|
|
|
2
2
|
import t from "./item.js";
|
|
3
3
|
import n, { createElement as r } from "react";
|
|
4
4
|
import i from "classnames";
|
|
5
|
-
import { jsx as a
|
|
5
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
6
6
|
//#region components/utilities/menu-list/index.tsx
|
|
7
|
-
var
|
|
7
|
+
var o = class extends n.Component {
|
|
8
8
|
static displayName = e;
|
|
9
9
|
static defaultProps = {
|
|
10
10
|
length: "5",
|
|
@@ -12,8 +12,8 @@ var s = class extends n.Component {
|
|
|
12
12
|
selectedIndex: -1
|
|
13
13
|
};
|
|
14
14
|
render() {
|
|
15
|
-
let e
|
|
16
|
-
return this.props.length && (e = `slds-dropdown_length-${this.props.length}`),
|
|
15
|
+
let e;
|
|
16
|
+
return this.props.length && (e = `slds-dropdown_length-${this.props.length}`), /* @__PURE__ */ a("ul", {
|
|
17
17
|
"aria-labelledby": this.props.triggerId,
|
|
18
18
|
className: i("dropdown__list", e, this.props.className),
|
|
19
19
|
role: "menu",
|
|
@@ -36,10 +36,10 @@ var s = class extends n.Component {
|
|
|
36
36
|
tooltipTemplate: this.props.tooltipMenuItem
|
|
37
37
|
});
|
|
38
38
|
})
|
|
39
|
-
})
|
|
39
|
+
});
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
42
|
//#endregion
|
|
43
|
-
export {
|
|
43
|
+
export { o as default };
|
|
44
44
|
|
|
45
45
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../../components/utilities/menu-list/index.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\n// # List Component\n\n// ## Dependencies\n\n// ### React\nimport React, {\n\ttype ComponentType,\n\ttype ReactElement,\n\ttype ReactNode,\n} from 'react';\n\n// ### classNames\nimport classNames from 'classnames';\n\n// ## Children\nimport ListItem, { type ListItemProps } from './item';\nimport { type ListItemLabelProps } from './item-label';\n\n// ## Constants\nimport { LIST } from '../../../utilities/constants';\n\ntype ListOption = { disabled?: boolean; value?: unknown } & Record<\n\tstring,\n\tunknown\n>;\n\nexport interface MenuListProps {\n\t/**\n\t * Determines whether or not to show a checkmark for selected items.\n\t */\n\tcheckmark?: boolean;\n\t/**\n\t * CSS classes to be added to `<ul />`.\n\t */\n\tclassName?: string;\n\t/**\n\t * Used internally to determine the id that will be used for list items.\n\t */\n\tgetListItemId?: (index: number) => string;\n\t/**\n\t * Used internally to pass references to the individual menu items back up for focusing / scrolling.\n\t */\n\titemRefs?: (listItem: HTMLLIElement | null, index: number) => void;\n\t/**\n\t * If provided, this function will be used to render the contents of each menu item.\n\t */\n\titemRenderer?: ComponentType<ListItemLabelProps>;\n\t/**\n\t * If provided, called to render the contents of each menu item. Takes precedence over `itemRenderer`.\n\t */\n\trenderItemLabel?: (props: ListItemLabelProps) => ReactNode;\n\t/**\n\t * Sets the height of the list based on the numeber of items.\n\t */\n\tlength?: null | '5' | '7' | '10' | 5 | 7 | 10;\n\t/**\n\t * Triggered when a list item is selected (via mouse or keyboard).\n\t */\n\tonSelect?: (index: number, event?: React.MouseEvent) => void;\n\t/**\n\t * An array of items to render in the list.\n\t */\n\toptions?: ListOption[];\n\t/**\n\t * The index of the currently selected item in the list.\n\t */\n\tselectedIndex?: number;\n\t/**\n\t * The indices of the currently selected items in the list (multi-select).\n\t */\n\tselectedIndices?: number[];\n\t/**\n\t * Accepts a `Tooltip` component to be used as the template for menu item tooltips that appear via the `tooltipContent` options object attribute
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../../components/utilities/menu-list/index.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\n// # List Component\n\n// ## Dependencies\n\n// ### React\nimport React, {\n\ttype ComponentType,\n\ttype ReactElement,\n\ttype ReactNode,\n} from 'react';\n\n// ### classNames\nimport classNames from 'classnames';\n\n// ## Children\nimport ListItem, { type ListItemProps } from './item';\nimport { type ListItemLabelProps } from './item-label';\n\n// ## Constants\nimport { LIST } from '../../../utilities/constants';\n\ntype ListOption = { disabled?: boolean; value?: unknown } & Record<\n\tstring,\n\tunknown\n>;\n\nexport interface MenuListProps {\n\t/**\n\t * Determines whether or not to show a checkmark for selected items.\n\t */\n\tcheckmark?: boolean;\n\t/**\n\t * CSS classes to be added to `<ul />`.\n\t */\n\tclassName?: string;\n\t/**\n\t * Used internally to determine the id that will be used for list items.\n\t */\n\tgetListItemId?: (index: number) => string;\n\t/**\n\t * Used internally to pass references to the individual menu items back up for focusing / scrolling.\n\t */\n\titemRefs?: (listItem: HTMLLIElement | null, index: number) => void;\n\t/**\n\t * If provided, this function will be used to render the contents of each menu item.\n\t */\n\titemRenderer?: ComponentType<ListItemLabelProps>;\n\t/**\n\t * If provided, called to render the contents of each menu item. Takes precedence over `itemRenderer`.\n\t */\n\trenderItemLabel?: (props: ListItemLabelProps) => ReactNode;\n\t/**\n\t * Sets the height of the list based on the numeber of items.\n\t */\n\tlength?: null | '5' | '7' | '10' | 5 | 7 | 10;\n\t/**\n\t * Triggered when a list item is selected (via mouse or keyboard).\n\t */\n\tonSelect?: (index: number, event?: React.MouseEvent) => void;\n\t/**\n\t * An array of items to render in the list.\n\t */\n\toptions?: ListOption[];\n\t/**\n\t * The index of the currently selected item in the list.\n\t */\n\tselectedIndex?: number;\n\t/**\n\t * The indices of the currently selected items in the list (multi-select).\n\t */\n\tselectedIndices?: number[];\n\t/**\n\t * Accepts a `Tooltip` component to be used as the template for menu item tooltips that appear via the `tooltipContent` options object attribute.\n\t */\n\ttooltipMenuItem?: ReactElement;\n\t/**\n\t * The id of the element which triggered this list (in a menu context).\n\t */\n\ttriggerId?: string;\n}\n\n/**\n * Component description.\n */\nclass List extends React.Component<MenuListProps> {\n\tstatic displayName = LIST;\n\n\tstatic defaultProps: Partial<MenuListProps> = {\n\t\tlength: '5',\n\t\toptions: [],\n\t\tselectedIndex: -1,\n\t};\n\n\trender() {\n\t\tlet lengthClassName;\n\n\t\tif (this.props.length) {\n\t\t\tlengthClassName = `slds-dropdown_length-${this.props.length}`;\n\t\t}\n\n\t\treturn (\n\t\t\t<ul\n\t\t\t\taria-labelledby={this.props.triggerId}\n\t\t\t\tclassName={classNames(\n\t\t\t\t\t'dropdown__list',\n\t\t\t\t\tlengthClassName,\n\t\t\t\t\tthis.props.className\n\t\t\t\t)}\n\t\t\t\trole=\"menu\"\n\t\t\t>\n\t\t\t\t{(this.props.options ?? []).map((option, index) => {\n\t\t\t\t\tconst id = this.props.getListItemId?.(index) ?? `${index}`;\n\t\t\t\t\tconst isSingleSelected = index === this.props.selectedIndex;\n\t\t\t\t\tconst isMultipleSelected =\n\t\t\t\t\t\t!!this.props.selectedIndices &&\n\t\t\t\t\t\tthis.props.selectedIndices.indexOf(index) !== -1;\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<ListItem\n\t\t\t\t\t\t\t{...(option as Partial<ListItemProps>)}\n\t\t\t\t\t\t\taria-disabled={option.disabled}\n\t\t\t\t\t\t\t// show checkmark\n\t\t\t\t\t\t\tcheckmark={\n\t\t\t\t\t\t\t\tthis.props.checkmark && (isSingleSelected || isMultipleSelected)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// show checkmark OR invisible placeholder icon\n\t\t\t\t\t\t\tisCheckmarkVariant={this.props.checkmark}\n\t\t\t\t\t\t\tdata={option}\n\t\t\t\t\t\t\tid={id}\n\t\t\t\t\t\t\tindex={index}\n\t\t\t\t\t\t\tisSelected={isSingleSelected || isMultipleSelected}\n\t\t\t\t\t\t\tkey={`${id}-${option.value}`}\n\t\t\t\t\t\t\tlabelRenderer={this.props.itemRenderer}\n\t\t\t\t\t\t\trenderLabel={this.props.renderItemLabel}\n\t\t\t\t\t\t\tonSelect={this.props.onSelect ?? (() => {})}\n\t\t\t\t\t\t\tnodeRef={(listItem) => this.props.itemRefs?.(listItem, index)}\n\t\t\t\t\t\t\ttooltipTemplate={this.props.tooltipMenuItem}\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t})}\n\t\t\t</ul>\n\t\t);\n\t}\n}\n\nexport default List;\n"],"mappings":";;;;;;AAuFA,IAAM,IAAN,cAAmB,EAAM,UAAyB;CACjD,OAAO,cAAc;CAErB,OAAO,eAAuC;EAC7C,QAAQ;EACR,SAAS,CAAC;EACV,eAAe;CAChB;CAEA,SAAS;EACR,IAAI;EAMJ,OAJI,KAAK,MAAM,WACd,IAAkB,wBAAwB,KAAK,MAAM,WAIrD,kBAAC,MAAD;GACC,mBAAiB,KAAK,MAAM;GAC5B,WAAW,EACV,kBACA,GACA,KAAK,MAAM,SACZ;GACA,MAAK;GAEH,WAAA,KAAK,MAAM,WAAW,CAAC,EAAA,CAAG,KAAK,GAAQ,MAAU;IAClD,IAAM,IAAK,KAAK,MAAM,gBAAgB,CAAK,KAAK,GAAG,KAC7C,IAAmB,MAAU,KAAK,MAAM,eACxC,IACL,CAAC,CAAC,KAAK,MAAM,mBACb,KAAK,MAAM,gBAAgB,QAAQ,CAAK,MAAM;IAC/C,OACC,kBAAC,GAAD;KACC,GAAK;KACL,iBAAe,EAAO;KAEtB,WACC,KAAK,MAAM,cAAc,KAAoB;KAG9C,oBAAoB,KAAK,MAAM;KAC/B,MAAM;KACF;KACG;KACP,YAAY,KAAoB;KAChC,KAAK,GAAG,EAAG,GAAG,EAAO;KACrB,eAAe,KAAK,MAAM;KAC1B,aAAa,KAAK,MAAM;KACxB,UAAU,KAAK,MAAM,mBAAmB,CAAC;KACzC,UAAU,MAAa,KAAK,MAAM,WAAW,GAAU,CAAK;KAC5D,iBAAiB,KAAK,MAAM;IAC5B,CAAA;GAEH,CAAC;EACE,CAAA;CAEN;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item-label.js","names":[],"sources":["../../../../../components/utilities/menu-list/item-label.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\n// # List Item Label Component\n\n// ## Dependencies\n\n// ### React\nimport { type ReactNode } from 'react';\n\n// ## Constants\nimport { LIST_ITEM_LABEL } from '../../../utilities/constants';\n\nexport interface ListItemLabelProps {\n\tdata?: Record<string, unknown>;\n\ticon?: ReactNode;\n\tindex?: number;\n\tinverted?: boolean;\n\tisSelected?: boolean;\n\tlabel?: string;\n\tcheckmark?: boolean;\n\tvalue?: unknown;\n}\n\n/**\n * Component description.\n */\nconst ListItemLabel = ({ label = '', icon }: ListItemLabelProps) => (\n\t<span className=\"slds-truncate\" title={label}>\n\t\t{icon}\n\t\t{label}\n\t</span>\n);\n\nListItemLabel.displayName = LIST_ITEM_LABEL;\n\nexport default ListItemLabel;\n"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"item-label.js","names":[],"sources":["../../../../../components/utilities/menu-list/item-label.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\n// # List Item Label Component\n\n// ## Dependencies\n\n// ### React\nimport { type ReactNode } from 'react';\n\n// ## Constants\nimport { LIST_ITEM_LABEL } from '../../../utilities/constants';\n\n/**\n * Props a menu item passes to its label renderer (`renderLabel` or\n * `labelRenderer`), taken from the menu option.\n */\nexport interface ListItemLabelProps {\n\t/** The option's `data`. */\n\tdata?: Record<string, unknown>;\n\t/** The rendered left icon, or the checkmark in the checkmark variant. */\n\ticon?: ReactNode;\n\t/** Index of the item in the menu. */\n\tindex?: number;\n\t/** Whether the menu uses the inverse color scheme. */\n\tinverted?: boolean;\n\t/** Whether the item is selected. */\n\tisSelected?: boolean;\n\t/** The option's `label`. Also used as the `title`. */\n\tlabel?: string;\n\t/** Whether the item shows a checkmark when selected. */\n\tcheckmark?: boolean;\n\t/** The option's `value`. */\n\tvalue?: unknown;\n}\n\n/**\n * Component description.\n */\nconst ListItemLabel = ({ label = '', icon }: ListItemLabelProps) => (\n\t<span className=\"slds-truncate\" title={label}>\n\t\t{icon}\n\t\t{label}\n\t</span>\n);\n\nListItemLabel.displayName = LIST_ITEM_LABEL;\n\nexport default ListItemLabel;\n"],"mappings":";;;AAuCA,IAAM,KAAiB,EAAE,WAAQ,IAAI,cACpC,kBAAC,QAAD;CAAM,WAAU;CAAgB,OAAO;CAAvC,UAAA,CACE,GACA,CACI;;AAGP,EAAc,cAAc"}
|