@salesforce/design-system-react 11.0.0-rc.0 → 11.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -0
- 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-link.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/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/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/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/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/private/step.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/index.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/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/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/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.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-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/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/alert/index.js +4 -5
- package/dist/es/components/alert/index.js.map +1 -1
- package/dist/es/components/builder-header/nav-link.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 +565 -580
- 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/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/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/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/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/private/step.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/index.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/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/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 +4 -2
- 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/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.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-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 +8 -7
- package/dist/es/utilities/warning/children-as-trigger.js.map +1 -1
- package/dist/es/utilities/warning/deprecated-property-value.js +11 -10
- package/dist/es/utilities/warning/deprecated-property-value.js.map +1 -1
- package/dist/es/utilities/warning/deprecated-property.js +8 -7
- 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/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/types/components/builder-header/nav-link.d.ts.map +1 -1
- package/dist/types/components/button/index.d.ts +14 -4
- package/dist/types/components/button/index.d.ts.map +1 -1
- package/dist/types/components/button-stateful/index.d.ts +5 -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 +4 -1
- package/dist/types/components/checkbox/index.d.ts.map +1 -1
- package/dist/types/components/color-picker/color-picker.d.ts.map +1 -1
- 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.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 +7 -1
- package/dist/types/components/icon/index.d.ts.map +1 -1
- package/dist/types/components/input/index.d.ts +9 -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.map +1 -1
- package/dist/types/components/menu-dropdown/menu-dropdown.d.ts +9 -3
- package/dist/types/components/menu-dropdown/menu-dropdown.d.ts.map +1 -1
- package/dist/types/components/modal/index.d.ts.map +1 -1
- package/dist/types/components/pill/index.d.ts.map +1 -1
- package/dist/types/components/popover/index.d.ts.map +1 -1
- package/dist/types/components/popover/popover.d.ts.map +1 -1
- package/dist/types/components/radio/index.d.ts +9 -2
- package/dist/types/components/radio/index.d.ts.map +1 -1
- package/dist/types/components/radio-group/index.d.ts +3 -3
- package/dist/types/components/radio-group/index.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 +10 -2
- package/dist/types/components/simple-data-table/types.d.ts.map +1 -1
- package/dist/types/components/slider/index.d.ts +2 -2
- 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.map +1 -1
- package/dist/types/components/textarea/index.d.ts +9 -6
- 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.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.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 +2 -3
- 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":"index.js","names":[],"sources":["../../../../components/tooltip/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// # Tooltip\n\nimport React, {\n\tuseState,\n\tuseEffect,\n\tuseRef,\n\tuseCallback,\n\tuseContext,\n\ttype ReactNode,\n\ttype CSSProperties,\n\ttype KeyboardEvent,\n\ttype FocusEvent,\n\ttype MouseEvent,\n} from 'react';\nimport classNames from 'classnames';\n\nimport EventUtil from '../../utilities/event';\nimport { useControllableState } from '../../utilities/hooks';\nimport { POPOVER_TOOLTIP } from '../../utilities/constants';\nimport generateId from '../../utilities/generate-id';\nimport { renderTrigger } from '../../utilities/merge-props';\nimport type { TriggerRender } from '../../types/common';\n\nimport Dialog from '../utilities/dialog';\nimport Icon from '../icon';\n// eslint-disable-next-line import/no-cycle\nimport Button from '../button';\n\n// This component's `checkProps` which issues warnings to developers about properties when in development mode\nimport checkProps from './check-props';\nimport componentDoc from './component.json';\nimport { IconSettingsContext } from '../icon-settings';\n\n// ### Types\n\nexport type { TriggerRender };\n\nexport type TooltipAlign =\n\t| 'top'\n\t| 'top left'\n\t| 'top right'\n\t| 'right'\n\t| 'right top'\n\t| 'right bottom'\n\t| 'bottom'\n\t| 'bottom left'\n\t| 'bottom right'\n\t| 'left'\n\t| 'left top'\n\t| 'left bottom';\n\nexport type TooltipPosition =\n\t'absolute' | 'overflowBoundaryElement' | 'relative';\n\nexport type TooltipTheme = 'info' | 'error';\n\nexport type TooltipIconVariant = 'bare' | 'error' | 'inverse' | 'warning';\n\nexport type TooltipVariant = 'base' | 'learnMore' | 'list-item';\n\nexport interface TooltipAssistiveText {\n\t/** This text is inside the info icon within the tooltip content and exists to \"complete the sentence\" for assistive tech users. */\n\ttooltipTipLearnMoreIcon?: string;\n\t/** This text is inside the info icon that triggers the tooltip in order to have text within the link. */\n\ttriggerLearnMoreIcon?: string;\n}\n\nexport interface TooltipLabels {\n\t/** This label appears in the tooltip after the info icon. */\n\tlearnMoreAfter?: string;\n\t/** This label appears in the tooltip before the info icon. */\n\tlearnMoreBefore?: string;\n}\n\n/**\n * What caused `onRequestOpen` to fire:\n * * `focus`: the trigger received focus\n * * `mouseEnter`: the mouse entered the trigger\n */\nexport type TooltipRequestOpenTrigger = 'focus' | 'mouseEnter';\n\n/**\n * Data passed to `onRequestOpen`\n */\nexport interface TooltipRequestOpenData {\n\t/** What caused the open request */\n\ttrigger: TooltipRequestOpenTrigger;\n}\n\n/**\n * What caused `onRequestClose` to fire:\n * * `blur`: focus left the trigger (including Tab from the tooltip)\n * * `cancel`: Escape was pressed on the trigger\n * * `clickOutside`: a click landed outside the tooltip\n * * `mouseLeave`: the mouse left the trigger or the tooltip\n */\nexport type TooltipRequestCloseTrigger =\n\t'blur' | 'cancel' | 'clickOutside' | 'mouseLeave';\n\n/**\n * Data passed to `onRequestClose`\n */\nexport interface TooltipRequestCloseData {\n\t/** What caused the close request */\n\ttrigger: TooltipRequestCloseTrigger;\n}\n\n/**\n * Props Tooltip gives its trigger. A `trigger` element has them merged into its own\n * props; a `trigger` function receives them to spread onto the element it returns.\n */\nexport interface TooltipTriggerProps {\n\t/** The tooltip's id while it's open */\n\t'aria-describedby'?: string;\n\tonBlur: (event: FocusEvent<HTMLElement>) => void;\n\tonFocus: (event: FocusEvent<HTMLElement>) => void;\n\tonKeyDown: (event: KeyboardEvent<HTMLElement>) => void;\n\tonMouseEnter: (event: MouseEvent<HTMLElement>) => void;\n\tonMouseLeave: (event: MouseEvent<HTMLElement>) => void;\n}\n\nexport interface TooltipProps {\n\t/**\n\t * Alignment of the Tooltip relative to the element that triggers it.\n\t */\n\talign?: TooltipAlign;\n\t/**\n\t * **Assistive text for accessibility**\n\t * This object is merged with the default props object on every render.\n\t */\n\tassistiveText?: TooltipAssistiveText;\n\t/**\n\t * @deprecated Use `trigger`. Each child element is used as a trigger.\n\t */\n\tchildren?: ReactNode;\n\t/**\n\t * Content inside Tooltip.\n\t */\n\tcontent?: ReactNode;\n\t/**\n\t * CSS classes to be added to the popover dialog. That is the element with `.slds-popover` on it.\n\t */\n\tdialogClassName?: string | string[] | Record<string, boolean>;\n\t/**\n\t * Enabling this hides the default nubbin, replacing it with one attached directly to the tooltip trigger.\n\t */\n\thasAnchoredNubbin?: boolean;\n\t/**\n\t * By default, dialogs will flip their alignment if they extend beyond a boundary element.\n\t * `hasStaticAlignment` disables this behavior.\n\t */\n\thasStaticAlignment?: boolean;\n\t/**\n\t * Styles the default info icon trigger that renders when no children are passed. Matches `icon-variant` on `lightning-helptext`.\n\t * * `bare` - (default) Default icon color.\n\t * * `error` - Red icon, to call out an error.\n\t * * `inverse` - White icon, for dark backgrounds.\n\t * * `warning` - Yellow icon, to advise caution.\n\t */\n\ticonVariant?: TooltipIconVariant;\n\t/**\n\t * Delay on Tooltip closing in milliseconds. Defaults to 50\n\t */\n\thoverCloseDelay?: number;\n\t/**\n\t * Delay on Tooltip opening in milliseconds. Defaults to 0\n\t */\n\thoverOpenDelay?: number;\n\t/**\n\t * A unique ID is needed in order to support keyboard navigation, ARIA support, and connect the popover to the triggering element.\n\t */\n\tid?: string;\n\t/**\n\t * **Text labels for internationalization**\n\t */\n\tlabels?: TooltipLabels;\n\t/**\n\t * Open state when the tooltip is controlled. When set, the tooltip only opens and closes when this\n\t * prop changes: `isOpen={false}` keeps it closed and `isOpen={true}` keeps it open, whatever the\n\t * user does. Handle `onRequestOpen`/`onRequestClose` to update it. Leave it `undefined` for an\n\t * uncontrolled tooltip that opens on hover and focus (see `defaultIsOpen`).\n\t */\n\tisOpen?: boolean;\n\t/**\n\t * Initial open state of an uncontrolled tooltip (`isOpen` is `undefined`). Defaults to `false`.\n\t */\n\tdefaultIsOpen?: boolean;\n\t/**\n\t * Turns the tooltip off: it never opens and renders no dialog, whatever `isOpen` or\n\t * `defaultIsOpen` is. The trigger still renders.\n\t */\n\tisDisabled?: boolean;\n\t/**\n\t * Called when the tooltip requests to open (hover after `hoverOpenDelay`, or focus), controlled or\n\t * not. `data.trigger` says why. A controlled tooltip opens only if the parent sets `isOpen` to `true`.\n\t */\n\tonRequestOpen?: (\n\t\tevent: MouseEvent<HTMLElement> | FocusEvent<HTMLElement>,\n\t\tdata: TooltipRequestOpenData\n\t) => void;\n\t/**\n\t * Called when the tooltip requests to close (mouse leave, blur, Escape, click outside), controlled\n\t * or not. `data.trigger` says why. `event` is `undefined` for `clickOutside`. A controlled tooltip\n\t * closes only if the parent sets `isOpen` to `false`.\n\t */\n\tonRequestClose?: (\n\t\tevent:\n\t\t\t| MouseEvent<HTMLElement>\n\t\t\t| FocusEvent<HTMLElement>\n\t\t\t| KeyboardEvent<HTMLElement>\n\t\t\t| undefined,\n\t\tdata: TooltipRequestCloseData\n\t) => void;\n\t/**\n\t * Callback that returns an element or React `ref` to align the Tooltip with.\n\t */\n\tonRequestTargetElement?: () => HTMLElement | null;\n\t/**\n\t * Callback when the info icon in learn more variant is clicked\n\t */\n\tonClickTrigger?: (event: MouseEvent<HTMLAnchorElement>) => void;\n\t/**\n\t * CSS classes to be added to tag with `slds-tooltip-trigger`.\n\t */\n\ttriggerClassName?: string | string[] | Record<string, boolean>;\n\t/**\n\t * Please select one of the following:\n\t * * `absolute` - (default) The dialog will use `position: absolute` and style attributes to position itself.\n\t * * `overflowBoundaryElement` - The dialog will overflow scrolling parents.\n\t * * `relative` - No styling or portals will be used.\n\t */\n\tposition?: TooltipPosition;\n\t/**\n\t * Custom styles to be added to wrapping triggering `div`.\n\t */\n\ttriggerStyle?: CSSProperties;\n\t/**\n\t * Determines the theme of tooltip: for informative purpose (blue background) or warning purpose (red background).\n\t */\n\ttheme?: TooltipTheme;\n\t/**\n\t * The element that shows the Tooltip on hover and focus. It must be focusable, such as a\n\t * `Button`, an anchor, or an element with `tabIndex`. Pass an element to have Tooltip merge\n\t * its trigger props into the element's: event handlers run the element's first, then\n\t * Tooltip's, `aria-describedby` is joined, and the element's other props win. Or pass a\n\t * function that receives the trigger props (`TooltipTriggerProps`) and returns the trigger.\n\t * Without a trigger, Tooltip renders an info icon button.\n\t */\n\ttrigger?: TriggerRender<TooltipTriggerProps>;\n\t/**\n\t * Determines the type of the tooltip.\n\t */\n\tvariant?: TooltipVariant;\n}\n\n/**\n * Props library components set on a Tooltip. Not part of the public API.\n */\nexport interface TooltipInjectedProps {\n\t/** Skips the warning for a trigger that isn't tabbable, for triggers focused another way */\n\tsilenceTriggerTabbableWarning?: boolean;\n}\n\nconst defaultAssistiveText: TooltipAssistiveText = {\n\ttooltipTipLearnMoreIcon: 'this link',\n\ttriggerLearnMoreIcon: 'Help',\n};\n\nconst defaultLabels: TooltipLabels = {\n\tlearnMoreAfter: 'to learn more.',\n\tlearnMoreBefore: 'Click',\n};\n\n/**\n * The PopoverTooltip component is variant of the Lightning Design System Popover component.\n * This component wraps an element that triggers it to open. It must be a focusable child element\n * (either a button or an anchor), so that keyboard users can navigate to it.\n */\nconst Tooltip = ({\n\talign = 'top',\n\tassistiveText: assistiveTextProp,\n\tchildren,\n\tcontent = <span>Tooltip</span>,\n\tdialogClassName,\n\thasAnchoredNubbin = false,\n\thasStaticAlignment = false,\n\thoverCloseDelay = 50,\n\thoverOpenDelay = 0,\n\ticonVariant = 'bare',\n\tid: idProp,\n\tlabels: labelsProp,\n\tisOpen: isOpenProp,\n\tdefaultIsOpen = false,\n\tisDisabled = false,\n\tonRequestOpen,\n\tonRequestClose,\n\tonRequestTargetElement,\n\tonClickTrigger,\n\ttriggerClassName,\n\tposition = 'absolute',\n\ttriggerStyle,\n\ttheme = 'info',\n\ttrigger,\n\tvariant = 'base',\n\tsilenceTriggerTabbableWarning,\n}: TooltipProps & TooltipInjectedProps): React.ReactElement => {\n\t// Merge assistive text and labels with defaults\n\tconst assistiveText = { ...defaultAssistiveText, ...assistiveTextProp };\n\tconst labels = { ...defaultLabels, ...labelsProp };\n\n\t// Context\n\tconst iconSettings = useContext(IconSettingsContext);\n\n\t// State\n\tconst [isOpen, setIsOpen] = useControllableState(isOpenProp, defaultIsOpen);\n\tconst [triggerRendered, setTriggerRendered] = useState(false);\n\n\t// Refs\n\tconst triggerRef = useRef<HTMLDivElement>(null);\n\tconst tooltipTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\tconst generatedIdRef = useRef(generateId());\n\tconst isUnmountingRef = useRef(false);\n\t// Latest open state, read by the hover/blur/Escape timers\n\tconst isOpenRef = useRef(isOpen);\n\tuseEffect(() => {\n\t\tisOpenRef.current = isOpen;\n\t}, [isOpen]);\n\n\t// Check props in development\n\tuseEffect(() => {\n\t\tcheckProps(\n\t\t\tPOPOVER_TOOLTIP,\n\t\t\t{\n\t\t\t\talign,\n\t\t\t\tassistiveText,\n\t\t\t\tchildren,\n\t\t\t\tcontent,\n\t\t\t\tdialogClassName,\n\t\t\t\thasAnchoredNubbin,\n\t\t\t\thasStaticAlignment,\n\t\t\t\thoverCloseDelay,\n\t\t\t\thoverOpenDelay,\n\t\t\t\ticonVariant,\n\t\t\t\tid: idProp,\n\t\t\t\tlabels,\n\t\t\t\tisOpen: isOpenProp,\n\t\t\t\tonRequestTargetElement,\n\t\t\t\tonClickTrigger,\n\t\t\t\ttriggerClassName,\n\t\t\t\tposition,\n\t\t\t\ttriggerStyle,\n\t\t\t\ttheme,\n\t\t\t\ttrigger,\n\t\t\t\tvariant,\n\t\t\t\tsilenceTriggerTabbableWarning,\n\t\t\t},\n\t\t\tcomponentDoc\n\t\t);\n\t}, []);\n\n\t// Cleanup on unmount\n\tuseEffect(() => {\n\t\treturn () => {\n\t\t\tisUnmountingRef.current = true;\n\t\t\tif (tooltipTimeoutRef.current) {\n\t\t\t\tclearTimeout(tooltipTimeoutRef.current);\n\t\t\t}\n\t\t};\n\t}, []);\n\n\t// Get computed values\n\tconst getId = useCallback(() => {\n\t\treturn idProp || generatedIdRef.current;\n\t}, [idProp]);\n\n\tconst getIsOpen = useCallback(\n\t\t() => !isDisabled && isOpen,\n\t\t[isDisabled, isOpen]\n\t);\n\n\tconst getTooltipTarget = useCallback(() => {\n\t\tif (onRequestTargetElement) {\n\t\t\treturn onRequestTargetElement();\n\t\t}\n\n\t\treturn triggerRef.current;\n\t}, [onRequestTargetElement]);\n\n\t// Event handlers\n\tconst clearTooltipTimeout = () => {\n\t\tif (tooltipTimeoutRef.current) {\n\t\t\tclearTimeout(tooltipTimeoutRef.current);\n\t\t}\n\t};\n\n\tconst requestOpen = useCallback(\n\t\t(\n\t\t\tevent: MouseEvent<HTMLElement> | FocusEvent<HTMLElement>,\n\t\t\ttrigger: TooltipRequestOpenTrigger\n\t\t) => {\n\t\t\tif (isUnmountingRef.current || isDisabled || isOpenRef.current) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tonRequestOpen?.(event, { trigger });\n\t\t\tsetIsOpen(true);\n\t\t},\n\t\t[isDisabled, onRequestOpen, setIsOpen]\n\t);\n\n\tconst requestClose = useCallback(\n\t\t(\n\t\t\tevent:\n\t\t\t\t| MouseEvent<HTMLElement>\n\t\t\t\t| FocusEvent<HTMLElement>\n\t\t\t\t| KeyboardEvent<HTMLElement>\n\t\t\t\t| undefined,\n\t\t\ttrigger: TooltipRequestCloseTrigger\n\t\t) => {\n\t\t\tif (isUnmountingRef.current || !isOpenRef.current) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tonRequestClose?.(event, { trigger });\n\t\t\tsetIsOpen(false);\n\t\t},\n\t\t[onRequestClose, setIsOpen]\n\t);\n\n\t// Called by the Dialog on click outside, Tab and unmount\n\tconst handleDialogClose = useCallback(\n\t\t(\n\t\t\tevent?: KeyboardEvent<HTMLElement>,\n\t\t\tdata?: { componentWillUnmount?: boolean }\n\t\t) => {\n\t\t\tclearTooltipTimeout();\n\t\t\t// The dialog unmounts because the tooltip already closed: nothing to request\n\t\t\tif (data?.componentWillUnmount) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\trequestClose(event, event ? 'blur' : 'clickOutside');\n\t\t},\n\t\t[requestClose]\n\t);\n\n\tconst handleDialogMouseLeave = useCallback(\n\t\t(event: MouseEvent) => {\n\t\t\tclearTooltipTimeout();\n\t\t\trequestClose(event as MouseEvent<HTMLElement>, 'mouseLeave');\n\t\t},\n\t\t[requestClose]\n\t);\n\n\tconst scheduleOpen = useCallback(\n\t\t(\n\t\t\tevent: MouseEvent<HTMLElement> | FocusEvent<HTMLElement>,\n\t\t\ttrigger: TooltipRequestOpenTrigger\n\t\t) => {\n\t\t\tclearTooltipTimeout();\n\t\t\ttooltipTimeoutRef.current = setTimeout(() => {\n\t\t\t\trequestOpen(event, trigger);\n\t\t\t}, hoverOpenDelay);\n\t\t},\n\t\t[hoverOpenDelay, requestOpen]\n\t);\n\n\tconst handleMouseEnter = useCallback(\n\t\t(event: MouseEvent<HTMLElement>) => scheduleOpen(event, 'mouseEnter'),\n\t\t[scheduleOpen]\n\t);\n\n\tconst handleFocus = useCallback(\n\t\t(event: FocusEvent<HTMLElement>) => scheduleOpen(event, 'focus'),\n\t\t[scheduleOpen]\n\t);\n\n\tconst scheduleClose = useCallback(\n\t\t(\n\t\t\te: MouseEvent<HTMLElement> | FocusEvent<HTMLElement>,\n\t\t\ttrigger: TooltipRequestCloseTrigger\n\t\t) => {\n\t\t\te.stopPropagation();\n\t\t\tclearTooltipTimeout();\n\n\t\t\ttooltipTimeoutRef.current = setTimeout(() => {\n\t\t\t\tconst relatedTarget = (e as MouseEvent<HTMLElement>)\n\t\t\t\t\t.relatedTarget as HTMLElement | null;\n\t\t\t\tconst isHoveringTooltip =\n\t\t\t\t\trelatedTarget?.classList?.contains('slds-popover_tooltip') ||\n\t\t\t\t\trelatedTarget?.classList?.contains('slds-popover__body');\n\n\t\t\t\tif (!isHoveringTooltip) {\n\t\t\t\t\trequestClose(e, trigger);\n\t\t\t\t}\n\t\t\t}, hoverCloseDelay);\n\t\t},\n\t\t[hoverCloseDelay, requestClose]\n\t);\n\n\tconst handleMouseLeave = useCallback(\n\t\t(e: MouseEvent<HTMLElement>) => scheduleClose(e, 'mouseLeave'),\n\t\t[scheduleClose]\n\t);\n\n\tconst handleBlur = useCallback(\n\t\t(e: FocusEvent<HTMLElement>) => scheduleClose(e, 'blur'),\n\t\t[scheduleClose]\n\t);\n\n\tconst handleKeyDown = useCallback(\n\t\t(e: KeyboardEvent<HTMLElement>) => {\n\t\t\te.stopPropagation();\n\n\t\t\ttooltipTimeoutRef.current = setTimeout(() => {\n\t\t\t\tif (e.key === 'Escape') {\n\t\t\t\t\trequestClose(e, 'cancel');\n\t\t\t\t}\n\t\t\t}, hoverCloseDelay);\n\t\t},\n\t\t[hoverCloseDelay, requestClose]\n\t);\n\n\t// Save trigger ref and trigger re-render once mounted\n\tconst saveTriggerRef = useCallback(\n\t\t(component: HTMLDivElement | null) => {\n\t\t\tif (component && triggerRef.current !== component) {\n\t\t\t\t(triggerRef as React.MutableRefObject<HTMLDivElement | null>).current =\n\t\t\t\t\tcomponent;\n\t\t\t\t// Dialog/Popper.js cannot place the popover until\n\t\t\t\t// the trigger/target DOM node is mounted.\n\t\t\t\tif (!triggerRendered) {\n\t\t\t\t\tsetTriggerRendered(true);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t[triggerRendered]\n\t);\n\n\t// Render helpers\n\tconst getAnchoredNubbinStyles = () => {\n\t\tif (!hasAnchoredNubbin) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst alignment = align.split(' ')[0] as\n\t\t\t'top' | 'bottom' | 'left' | 'right';\n\t\tconst nubbinContainerStyles: CSSProperties = {\n\t\t\theight: '0',\n\t\t\tposition: 'relative',\n\t\t\twidth: '0',\n\t\t};\n\t\tconst nubbinStyles: CSSProperties = {\n\t\t\tbackgroundColor: '#16325c',\n\t\t\tcontent: '\"\"',\n\t\t\theight: '1rem',\n\t\t\tposition: 'absolute',\n\t\t\ttransform: 'rotate(45deg)',\n\t\t\twidth: '1rem',\n\t\t};\n\t\tconst triggerDimensions = {\n\t\t\theight: triggerRef.current\n\t\t\t\t? triggerRef.current.getBoundingClientRect().height\n\t\t\t\t: 0,\n\t\t\twidth: triggerRef.current\n\t\t\t\t? triggerRef.current.getBoundingClientRect().width\n\t\t\t\t: 0,\n\t\t};\n\n\t\tswitch (alignment) {\n\t\t\tcase 'bottom': {\n\t\t\t\tnubbinContainerStyles.left = `${triggerDimensions.width / 2}px`;\n\t\t\t\tnubbinContainerStyles.top = `${triggerDimensions.height}px`;\n\t\t\t\tnubbinStyles.left = '-8px';\n\t\t\t\tnubbinStyles.top = '3px';\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'left': {\n\t\t\t\tnubbinContainerStyles.left = '0';\n\t\t\t\tnubbinContainerStyles.top = `${triggerDimensions.height / 2}px`;\n\t\t\t\tnubbinStyles.left = '-19px';\n\t\t\t\tnubbinStyles.top = '-9px';\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'right': {\n\t\t\t\tnubbinContainerStyles.left = `${triggerDimensions.width}px`;\n\t\t\t\tnubbinContainerStyles.top = `${triggerDimensions.height / 2}px`;\n\t\t\t\tnubbinStyles.left = '3px';\n\t\t\t\tnubbinStyles.top = '-9px';\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\t// top\n\t\t\t\tnubbinContainerStyles.left = `${triggerDimensions.width / 2}px`;\n\t\t\t\tnubbinContainerStyles.top = '0';\n\t\t\t\tnubbinStyles.left = '-8px';\n\t\t\t\tnubbinStyles.top = '-19px';\n\t\t\t}\n\t\t}\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<style>{`#${getId()}:after, #${getId()}:before {\n\tdisplay: none;\n}`}</style>\n\t\t\t\t{getIsOpen() ? (\n\t\t\t\t\t<div style={nubbinContainerStyles}>\n\t\t\t\t\t\t<div style={nubbinStyles} />\n\t\t\t\t\t</div>\n\t\t\t\t) : null}\n\t\t\t</>\n\t\t);\n\t};\n\n\tconst getContent = () => {\n\t\tconst isInverseIcon = iconVariant === 'inverse';\n\t\tconst iconColorVariant =\n\t\t\ticonVariant === 'error' || iconVariant === 'warning'\n\t\t\t\t? iconVariant\n\t\t\t\t: undefined;\n\n\t\tconst triggerProps: TooltipTriggerProps = {\n\t\t\t'aria-describedby': getIsOpen() ? getId() : undefined,\n\t\t\tonBlur: handleBlur,\n\t\t\tonFocus: handleFocus,\n\t\t\tonKeyDown: handleKeyDown,\n\t\t\tonMouseEnter: handleMouseEnter,\n\t\t\tonMouseLeave: handleMouseLeave,\n\t\t};\n\n\t\tif (trigger !== undefined) {\n\t\t\treturn renderTrigger(trigger, triggerProps);\n\t\t}\n\n\t\t// Deprecated: each child element is a trigger\n\t\tif (React.Children.count(children) !== 0) {\n\t\t\treturn React.Children.map(children, (child) =>\n\t\t\t\tReact.isValidElement(child) ? renderTrigger(child, triggerProps) : child\n\t\t\t);\n\t\t}\n\n\t\tif (onClickTrigger) {\n\t\t\treturn renderTrigger(\n\t\t\t\t<a\n\t\t\t\t\thref=\"#\"\n\t\t\t\t\tonClick={\n\t\t\t\t\t\tEventUtil.trappedHandler(\n\t\t\t\t\t\t\tonClickTrigger\n\t\t\t\t\t\t) as React.MouseEventHandler<HTMLAnchorElement>\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<Icon\n\t\t\t\t\t\tcategory=\"utility\"\n\t\t\t\t\t\tcolorVariant={iconColorVariant}\n\t\t\t\t\t\tinverse={isInverseIcon}\n\t\t\t\t\t\tname=\"info\"\n\t\t\t\t\t\tassistiveText={{\n\t\t\t\t\t\t\tlabel: assistiveText.triggerLearnMoreIcon,\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tsize=\"x-small\"\n\t\t\t\t\t/>\n\t\t\t\t</a>,\n\t\t\t\ttriggerProps\n\t\t\t);\n\t\t}\n\n\t\treturn renderTrigger(\n\t\t\t<Button\n\t\t\t\taria-disabled\n\t\t\t\tassistiveText={{\n\t\t\t\t\ticon: assistiveText.triggerLearnMoreIcon,\n\t\t\t\t}}\n\t\t\t\ticonCategory=\"utility\"\n\t\t\t\ticonClassName={iconColorVariant && `slds-icon-text-${iconColorVariant}`}\n\t\t\t\ticonName=\"info\"\n\t\t\t\t// `bare` keeps `slds-button_icon`, which Button drops for `inverse` alone\n\t\t\t\ticonVariant={isInverseIcon ? 'bare' : undefined}\n\t\t\t\tinverse={isInverseIcon}\n\t\t\t\tvariant=\"icon\"\n\t\t\t/>,\n\t\t\ttriggerProps\n\t\t);\n\t};\n\n\tconst getTooltipContent = () => {\n\t\tconst isErrorTheme = theme === 'error';\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tclassName={classNames('slds-popover__body', {\n\t\t\t\t\t// Ensure text contrast on error theme (red background needs white text)\n\t\t\t\t\t'slds-text-color_inverse': isErrorTheme,\n\t\t\t\t})}\n\t\t\t>\n\t\t\t\t{content}\n\t\t\t\t{variant === 'learnMore' && onClickTrigger ? (\n\t\t\t\t\t<div className=\"slds-m-top_x-small\" aria-hidden=\"true\">\n\t\t\t\t\t\t{labels.learnMoreBefore}{' '}\n\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\tassistiveText={{\n\t\t\t\t\t\t\t\tlabel: assistiveText.tooltipTipLearnMoreIcon,\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\tcategory=\"utility\"\n\t\t\t\t\t\t\tinverse\n\t\t\t\t\t\t\tname=\"info\"\n\t\t\t\t\t\t\tsize=\"x-small\"\n\t\t\t\t\t\t/>{' '}\n\t\t\t\t\t\t{labels.learnMoreAfter}{' '}\n\t\t\t\t\t</div>\n\t\t\t\t) : null}\n\t\t\t</div>\n\t\t);\n\t};\n\n\tconst getTooltip = () => {\n\t\treturn getIsOpen() ? (\n\t\t\t<Dialog\n\t\t\t\tcloseOnTabKey\n\t\t\t\thasNubbin\n\t\t\t\tcontentsClassName={classNames(\n\t\t\t\t\t'slds-popover',\n\t\t\t\t\t'slds-popover_tooltip',\n\t\t\t\t\t{\n\t\t\t\t\t\t'slds-theme_error': theme === 'error',\n\t\t\t\t\t},\n\t\t\t\t\tdialogClassName\n\t\t\t\t)}\n\t\t\t\talign={align}\n\t\t\t\tcontext={iconSettings}\n\t\t\t\thasStaticAlignment={hasStaticAlignment}\n\t\t\t\tonClose={handleDialogClose}\n\t\t\t\tonRequestTargetElement={getTooltipTarget}\n\t\t\t\tonMouseLeave={handleDialogMouseLeave}\n\t\t\t\tposition={position}\n\t\t\t\tvariant=\"tooltip\"\n\t\t\t\tcontainerProps={{\n\t\t\t\t\tid: getId(),\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{getTooltipContent()}\n\t\t\t</Dialog>\n\t\t) : (\n\t\t\t<span />\n\t\t);\n\t};\n\n\tconst containerStyles: CSSProperties = {\n\t\tdisplay: 'inline-block',\n\t\tlineHeight: '1',\n\t\t...triggerStyle,\n\t};\n\n\treturn (\n\t\t<div\n\t\t\tclassName={classNames('slds-tooltip-trigger', triggerClassName)}\n\t\t\tstyle={containerStyles}\n\t\t\tref={saveTriggerRef}\n\t\t>\n\t\t\t{getAnchoredNubbinStyles()}\n\t\t\t{getContent()}\n\t\t\t{getTooltip()}\n\t\t</div>\n\t);\n};\n\nTooltip.displayName = POPOVER_TOOLTIP;\n\nexport default Tooltip as React.FC<TooltipProps>;\n"],"mappings":";;;;;;;;;;;;;;;AA0QA,IAAM,KAA6C;CAClD,yBAAyB;CACzB,sBAAsB;AACvB,GAEM,KAA+B;CACpC,gBAAgB;CAChB,iBAAiB;AAClB,GAOM,KAAW,EAChB,WAAQ,OACR,eAAe,GACf,aACA,aAAU,kBAAC,QAAD,EAAA,UAAM,UAAa,CAAA,GAC7B,oBACA,uBAAoB,IACpB,wBAAqB,IACrB,qBAAkB,IAClB,oBAAiB,GACjB,iBAAc,QACd,IAAI,GACJ,QAAQ,IACR,QAAQ,GACR,oBAAgB,IAChB,gBAAa,IACb,kBACA,mBACA,2BACA,mBACA,qBACA,cAAW,YACX,iBACA,WAAQ,QACR,YACA,aAAU,QACV,wCAC8D;CAE9D,IAAM,IAAgB;EAAE,GAAG;EAAsB,GAAG;CAAkB,GAChE,IAAS;EAAE,GAAG;EAAe,GAAG;CAAW,GAG3C,KAAe,GAAW,CAAmB,GAG7C,CAAC,GAAQ,KAAa,EAAqB,GAAY,EAAa,GACpE,CAAC,GAAiB,MAAsB,GAAS,EAAK,GAGtD,IAAa,EAAuB,IAAI,GACxC,IAAoB,EAA6C,IAAI,GACrE,KAAiB,EAAO,GAAW,CAAC,GACpC,IAAkB,EAAO,EAAK,GAE9B,IAAY,EAAO,CAAM;CAsC/B,AArCA,QAAgB;EACf,EAAU,UAAU;CACrB,GAAG,CAAC,CAAM,CAAC,GAGX,QAAgB;EACf,GACC,GACA;GACC;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,IAAI;GACJ;GACA,QAAQ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Ae,EACd,MAAM,EAAc,qBACrB;GACA,cAAa;GACb,eAAe,KAAoB,kBAAkB;GACrD,UAAS;GAET,aAAa,IAAgB,SAAS,KAAA;GACtC,SAAS;GACT,SAAQ;EACR,CAAA,GAjBA,CACD,IA3BO,EAAM,SAAS,IAAI,IAAW,MACpC,EAAM,eAAe,CAAK,IAAI,EAAc,GAAO,CAAY,IAAI,CACpE,IAPO,EAAc,GAAS,CAAY;CAmD5C,GAEM,WAIJ,kBAAC,OAAD;EACC,WAAW,EAAW,sBAAsB,EAE3C,2BANkB,MAAU,QAO7B,CAAC;EAJF,UAAA,CAME,GACA,MAAY,eAAe,IAC3B,kBAAC,OAAD;GAAK,WAAU;GAAqB,eAAY;GAAhD,UAAA;IACE,EAAO;IAAiB;IACzB,kBAAC,GAAD;KACC,eAAe,EACd,OAAO,EAAc,wBACtB;KACA,UAAS;KACT,SAAA;KACA,MAAK;KACL,MAAK;IACL,CAAA;IAAE;IACF,EAAO;IAAgB;GACpB;EACF,CAAA,IAAA,IACA;KAID,WACE,EAAU,IAChB,kBAAC,GAAD;EACC,eAAA;EACA,WAAA;EACA,mBAAmB,EAClB,gBACA,wBACA,EACC,oBAAoB,MAAU,QAC/B,GACA,CACD;EACO;EACP,SAAS;EACW;EACpB,SAAS;EACT,wBAAwB;EACxB,cAAc;EACJ;EACV,SAAQ;EACR,gBAAgB,EACf,IAAI,EAAM,EACX;EAEC,UAAA,GAAkB;CACZ,CAAA,IAER,kBAAC,QAAD,CAAO,CAAA,GAIH,KAAiC;EACtC,SAAS;EACT,YAAY;EACZ,GAAG;CACJ;CAEA,OACC,kBAAC,OAAD;EACC,WAAW,EAAW,wBAAwB,CAAgB;EAC9D,OAAO;EACP,KAAK;EAHN,UAAA;GAKE,GAAwB;GACxB,GAAW;GACX,GAAW;EACR;;AAEP;AAEA,EAAQ,cAAc"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../components/tooltip/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// # Tooltip\n\nimport React, {\n\tuseId,\n\tuseState,\n\tuseEffect,\n\tuseLayoutEffect,\n\tuseRef,\n\tuseCallback,\n\tuseContext,\n\ttype ReactNode,\n\ttype CSSProperties,\n\ttype KeyboardEvent,\n\ttype FocusEvent,\n\ttype MouseEvent,\n} from 'react';\nimport classNames from 'classnames';\n\nimport EventUtil from '../../utilities/event';\nimport { useControllableState } from '../../utilities/hooks';\nimport { POPOVER_TOOLTIP } from '../../utilities/constants';\nimport { renderTrigger } from '../../utilities/merge-props';\nimport type { TriggerRender } from '../../types/common';\n\nimport Dialog from '../utilities/dialog';\nimport Icon from '../icon';\n// eslint-disable-next-line import/no-cycle\nimport Button from '../button';\n\n// This component's `checkProps` which issues warnings to developers about properties when in development mode\nimport checkProps from './check-props';\nimport componentDoc from './component.json';\nimport { IconSettingsContext } from '../icon-settings';\n\n// ### Types\n\nexport type { TriggerRender };\n\nexport type TooltipAlign =\n\t| 'top'\n\t| 'top left'\n\t| 'top right'\n\t| 'right'\n\t| 'right top'\n\t| 'right bottom'\n\t| 'bottom'\n\t| 'bottom left'\n\t| 'bottom right'\n\t| 'left'\n\t| 'left top'\n\t| 'left bottom';\n\nexport type TooltipPosition =\n\t'absolute' | 'overflowBoundaryElement' | 'relative';\n\nexport type TooltipTheme = 'info' | 'error';\n\nexport type TooltipIconVariant = 'bare' | 'error' | 'inverse' | 'warning';\n\nexport type TooltipVariant = 'base' | 'learnMore' | 'list-item';\n\nexport interface TooltipAssistiveText {\n\t/** This text is inside the info icon within the tooltip content and exists to \"complete the sentence\" for assistive tech users. */\n\ttooltipTipLearnMoreIcon?: string;\n\t/** This text is inside the info icon that triggers the tooltip in order to have text within the link. */\n\ttriggerLearnMoreIcon?: string;\n}\n\nexport interface TooltipLabels {\n\t/** This label appears in the tooltip after the info icon. */\n\tlearnMoreAfter?: string;\n\t/** This label appears in the tooltip before the info icon. */\n\tlearnMoreBefore?: string;\n}\n\n/**\n * What caused `onRequestOpen` to fire:\n * * `focus`: the trigger received focus\n * * `mouseEnter`: the mouse entered the trigger\n */\nexport type TooltipRequestOpenTrigger = 'focus' | 'mouseEnter';\n\n/**\n * Data passed to `onRequestOpen`\n */\nexport interface TooltipRequestOpenData {\n\t/** What caused the open request */\n\ttrigger: TooltipRequestOpenTrigger;\n}\n\n/**\n * What caused `onRequestClose` to fire:\n * * `blur`: focus left the trigger (including Tab from the tooltip)\n * * `cancel`: Escape was pressed on the trigger\n * * `clickOutside`: a click landed outside the tooltip\n * * `mouseLeave`: the mouse left the trigger or the tooltip\n */\nexport type TooltipRequestCloseTrigger =\n\t'blur' | 'cancel' | 'clickOutside' | 'mouseLeave';\n\n/**\n * Data passed to `onRequestClose`\n */\nexport interface TooltipRequestCloseData {\n\t/** What caused the close request */\n\ttrigger: TooltipRequestCloseTrigger;\n}\n\n/**\n * Props Tooltip gives its trigger. A `trigger` element has them merged into its own\n * props; a `trigger` function receives them to spread onto the element it returns.\n */\nexport interface TooltipTriggerProps {\n\t/** The tooltip's id while it's open */\n\t'aria-describedby'?: string;\n\tonBlur: (event: FocusEvent<HTMLElement>) => void;\n\tonFocus: (event: FocusEvent<HTMLElement>) => void;\n\tonKeyDown: (event: KeyboardEvent<HTMLElement>) => void;\n\tonMouseEnter: (event: MouseEvent<HTMLElement>) => void;\n\tonMouseLeave: (event: MouseEvent<HTMLElement>) => void;\n}\n\nexport interface TooltipProps {\n\t/**\n\t * Alignment of the Tooltip relative to the element that triggers it.\n\t */\n\talign?: TooltipAlign;\n\t/**\n\t * **Assistive text for accessibility**\n\t * This object is merged with the default props object on every render.\n\t */\n\tassistiveText?: TooltipAssistiveText;\n\t/**\n\t * @deprecated Use `trigger`. Each child element is used as a trigger.\n\t */\n\tchildren?: ReactNode;\n\t/**\n\t * Content inside Tooltip.\n\t */\n\tcontent?: ReactNode;\n\t/**\n\t * CSS classes to be added to the popover dialog. That is the element with `.slds-popover` on it.\n\t */\n\tdialogClassName?: string | string[] | Record<string, boolean>;\n\t/**\n\t * Enabling this hides the default nubbin, replacing it with one attached directly to the tooltip trigger.\n\t */\n\thasAnchoredNubbin?: boolean;\n\t/**\n\t * By default, dialogs will flip their alignment if they extend beyond a boundary element.\n\t * `hasStaticAlignment` disables this behavior.\n\t */\n\thasStaticAlignment?: boolean;\n\t/**\n\t * Styles the default info icon trigger that renders when no children are passed. Matches `icon-variant` on `lightning-helptext`.\n\t * * `bare` - (default) Default icon color.\n\t * * `error` - Red icon, to call out an error.\n\t * * `inverse` - White icon, for dark backgrounds.\n\t * * `warning` - Yellow icon, to advise caution.\n\t */\n\ticonVariant?: TooltipIconVariant;\n\t/**\n\t * Delay on Tooltip closing in milliseconds. Defaults to 50\n\t */\n\thoverCloseDelay?: number;\n\t/**\n\t * Delay on Tooltip opening in milliseconds. Defaults to 0\n\t */\n\thoverOpenDelay?: number;\n\t/**\n\t * A unique ID is needed in order to support keyboard navigation, ARIA support, and connect the popover to the triggering element.\n\t */\n\tid?: string;\n\t/**\n\t * **Text labels for internationalization**\n\t */\n\tlabels?: TooltipLabels;\n\t/**\n\t * Open state when the tooltip is controlled. When set, the tooltip only opens and closes when this\n\t * prop changes: `isOpen={false}` keeps it closed and `isOpen={true}` keeps it open, whatever the\n\t * user does. Handle `onRequestOpen`/`onRequestClose` to update it. Leave it `undefined` for an\n\t * uncontrolled tooltip that opens on hover and focus (see `defaultIsOpen`).\n\t */\n\tisOpen?: boolean;\n\t/**\n\t * Initial open state of an uncontrolled tooltip (`isOpen` is `undefined`). Defaults to `false`.\n\t */\n\tdefaultIsOpen?: boolean;\n\t/**\n\t * Turns the tooltip off: it never opens and renders no dialog, whatever `isOpen` or\n\t * `defaultIsOpen` is. The trigger still renders.\n\t */\n\tisDisabled?: boolean;\n\t/**\n\t * Called when the tooltip requests to open (hover after `hoverOpenDelay`, or focus), controlled or\n\t * not. `data.trigger` says why. A controlled tooltip opens only if the parent sets `isOpen` to `true`.\n\t */\n\tonRequestOpen?: (\n\t\tevent: MouseEvent<HTMLElement> | FocusEvent<HTMLElement>,\n\t\tdata: TooltipRequestOpenData\n\t) => void;\n\t/**\n\t * Called when the tooltip requests to close (mouse leave, blur, Escape, click outside), controlled\n\t * or not. `data.trigger` says why. `event` is `undefined` for `clickOutside`. A controlled tooltip\n\t * closes only if the parent sets `isOpen` to `false`.\n\t */\n\tonRequestClose?: (\n\t\tevent:\n\t\t\t| MouseEvent<HTMLElement>\n\t\t\t| FocusEvent<HTMLElement>\n\t\t\t| KeyboardEvent<HTMLElement>\n\t\t\t| undefined,\n\t\tdata: TooltipRequestCloseData\n\t) => void;\n\t/**\n\t * Callback that returns an element or React `ref` to align the Tooltip with.\n\t */\n\tonRequestTargetElement?: () => HTMLElement | null;\n\t/**\n\t * Callback when the info icon in learn more variant is clicked\n\t */\n\tonClickTrigger?: (event: MouseEvent<HTMLAnchorElement>) => void;\n\t/**\n\t * CSS classes to be added to tag with `slds-tooltip-trigger`.\n\t */\n\ttriggerClassName?: string | string[] | Record<string, boolean>;\n\t/**\n\t * Please select one of the following:\n\t * * `absolute` - (default) The dialog will use `position: absolute` and style attributes to position itself.\n\t * * `overflowBoundaryElement` - The dialog will overflow scrolling parents.\n\t * * `relative` - No styling or portals will be used.\n\t */\n\tposition?: TooltipPosition;\n\t/**\n\t * Custom styles to be added to wrapping triggering `div`.\n\t */\n\ttriggerStyle?: CSSProperties;\n\t/**\n\t * Determines the theme of tooltip: for informative purpose (blue background) or warning purpose (red background).\n\t */\n\ttheme?: TooltipTheme;\n\t/**\n\t * The element that shows the Tooltip on hover and focus. It must be focusable, such as a\n\t * `Button`, an anchor, or an element with `tabIndex`. Pass an element to have Tooltip merge\n\t * its trigger props into the element's: event handlers run the element's first, then\n\t * Tooltip's, `aria-describedby` is joined, and the element's other props win. Or pass a\n\t * function that receives the trigger props (`TooltipTriggerProps`) and returns the trigger.\n\t * Without a trigger, Tooltip renders an info icon button.\n\t */\n\ttrigger?: TriggerRender<TooltipTriggerProps>;\n\t/**\n\t * Determines the type of the tooltip.\n\t */\n\tvariant?: TooltipVariant;\n}\n\n/**\n * Props library components set on a Tooltip. Not part of the public API.\n */\nexport interface TooltipInjectedProps {\n\t/** Skips the warning for a trigger that isn't tabbable, for triggers focused another way */\n\tsilenceTriggerTabbableWarning?: boolean;\n}\n\nconst defaultAssistiveText: TooltipAssistiveText = {\n\ttooltipTipLearnMoreIcon: 'this link',\n\ttriggerLearnMoreIcon: 'Help',\n};\n\nconst defaultLabels: TooltipLabels = {\n\tlearnMoreAfter: 'to learn more.',\n\tlearnMoreBefore: 'Click',\n};\n\n// Renders the trigger slot as a component, so the trigger props' handlers are only\n// handed to the slot rather than called from Tooltip's render\nconst TooltipTrigger = ({\n\trender,\n\ttriggerProps,\n}: {\n\trender: TriggerRender<TooltipTriggerProps>;\n\ttriggerProps: TooltipTriggerProps;\n}) => renderTrigger(render, triggerProps);\n\n/**\n * The PopoverTooltip component is variant of the Lightning Design System Popover component.\n * This component wraps an element that triggers it to open. It must be a focusable child element\n * (either a button or an anchor), so that keyboard users can navigate to it.\n */\nconst Tooltip = ({\n\talign = 'top',\n\tassistiveText: assistiveTextProp,\n\tchildren,\n\tcontent = <span>Tooltip</span>,\n\tdialogClassName,\n\thasAnchoredNubbin = false,\n\thasStaticAlignment = false,\n\thoverCloseDelay = 50,\n\thoverOpenDelay = 0,\n\ticonVariant = 'bare',\n\tid: idProp,\n\tlabels: labelsProp,\n\tisOpen: isOpenProp,\n\tdefaultIsOpen = false,\n\tisDisabled = false,\n\tonRequestOpen,\n\tonRequestClose,\n\tonRequestTargetElement,\n\tonClickTrigger,\n\ttriggerClassName,\n\tposition = 'absolute',\n\ttriggerStyle,\n\ttheme = 'info',\n\ttrigger,\n\tvariant = 'base',\n\tsilenceTriggerTabbableWarning,\n}: TooltipProps & TooltipInjectedProps): React.ReactElement => {\n\t// Merge assistive text and labels with defaults\n\tconst assistiveText = { ...defaultAssistiveText, ...assistiveTextProp };\n\tconst labels = { ...defaultLabels, ...labelsProp };\n\n\t// Context\n\tconst iconSettings = useContext(IconSettingsContext);\n\n\t// State\n\tconst [isOpen, setIsOpen] = useControllableState(isOpenProp, defaultIsOpen);\n\tconst [triggerRendered, setTriggerRendered] = useState(false);\n\tconst generatedId = useId();\n\t// Trigger size for the anchored nubbin, measured once the tooltip opens\n\tconst [triggerSize, setTriggerSize] = useState({ height: 0, width: 0 });\n\n\t// Refs\n\tconst triggerRef = useRef<HTMLDivElement>(null);\n\tconst tooltipTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\tconst isUnmountingRef = useRef(false);\n\t// Latest open state, read by the hover/blur/Escape timers\n\tconst isOpenRef = useRef(isOpen);\n\tuseEffect(() => {\n\t\tisOpenRef.current = isOpen;\n\t}, [isOpen]);\n\n\t// Check props in development\n\tuseEffect(() => {\n\t\tcheckProps(\n\t\t\tPOPOVER_TOOLTIP,\n\t\t\t{\n\t\t\t\talign,\n\t\t\t\tassistiveText,\n\t\t\t\tchildren,\n\t\t\t\tcontent,\n\t\t\t\tdialogClassName,\n\t\t\t\thasAnchoredNubbin,\n\t\t\t\thasStaticAlignment,\n\t\t\t\thoverCloseDelay,\n\t\t\t\thoverOpenDelay,\n\t\t\t\ticonVariant,\n\t\t\t\tid: idProp,\n\t\t\t\tlabels,\n\t\t\t\tisOpen: isOpenProp,\n\t\t\t\tonRequestTargetElement,\n\t\t\t\tonClickTrigger,\n\t\t\t\ttriggerClassName,\n\t\t\t\tposition,\n\t\t\t\ttriggerStyle,\n\t\t\t\ttheme,\n\t\t\t\ttrigger,\n\t\t\t\tvariant,\n\t\t\t\tsilenceTriggerTabbableWarning,\n\t\t\t},\n\t\t\tcomponentDoc\n\t\t);\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, []); // Only run on mount\n\n\t// Cleanup on unmount\n\tuseEffect(() => {\n\t\treturn () => {\n\t\t\tisUnmountingRef.current = true;\n\t\t\tif (tooltipTimeoutRef.current) {\n\t\t\t\tclearTimeout(tooltipTimeoutRef.current);\n\t\t\t}\n\t\t};\n\t}, []);\n\n\t// Get computed values\n\tconst getId = useCallback(() => {\n\t\treturn idProp || generatedId;\n\t}, [idProp, generatedId]);\n\n\tconst getIsOpen = useCallback(\n\t\t() => !isDisabled && isOpen,\n\t\t[isDisabled, isOpen]\n\t);\n\n\tconst getTooltipTarget = useCallback(() => {\n\t\tif (onRequestTargetElement) {\n\t\t\treturn onRequestTargetElement();\n\t\t}\n\n\t\treturn triggerRef.current;\n\t}, [onRequestTargetElement]);\n\n\t// Event handlers\n\tconst clearTooltipTimeout = () => {\n\t\tif (tooltipTimeoutRef.current) {\n\t\t\tclearTimeout(tooltipTimeoutRef.current);\n\t\t}\n\t};\n\n\tconst requestOpen = useCallback(\n\t\t(\n\t\t\tevent: MouseEvent<HTMLElement> | FocusEvent<HTMLElement>,\n\t\t\ttrigger: TooltipRequestOpenTrigger\n\t\t) => {\n\t\t\tif (isUnmountingRef.current || isDisabled || isOpenRef.current) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tonRequestOpen?.(event, { trigger });\n\t\t\tsetIsOpen(true);\n\t\t},\n\t\t[isDisabled, onRequestOpen, setIsOpen]\n\t);\n\n\tconst requestClose = useCallback(\n\t\t(\n\t\t\tevent:\n\t\t\t\t| MouseEvent<HTMLElement>\n\t\t\t\t| FocusEvent<HTMLElement>\n\t\t\t\t| KeyboardEvent<HTMLElement>\n\t\t\t\t| undefined,\n\t\t\ttrigger: TooltipRequestCloseTrigger\n\t\t) => {\n\t\t\tif (isUnmountingRef.current || !isOpenRef.current) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tonRequestClose?.(event, { trigger });\n\t\t\tsetIsOpen(false);\n\t\t},\n\t\t[onRequestClose, setIsOpen]\n\t);\n\n\t// Called by the Dialog on click outside, Tab and unmount\n\tconst handleDialogClose = useCallback(\n\t\t(\n\t\t\tevent?: KeyboardEvent<HTMLElement>,\n\t\t\tdata?: { componentWillUnmount?: boolean }\n\t\t) => {\n\t\t\tclearTooltipTimeout();\n\t\t\t// The dialog unmounts because the tooltip already closed: nothing to request\n\t\t\tif (data?.componentWillUnmount) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\trequestClose(event, event ? 'blur' : 'clickOutside');\n\t\t},\n\t\t[requestClose]\n\t);\n\n\tconst handleDialogMouseLeave = useCallback(\n\t\t(event: MouseEvent) => {\n\t\t\tclearTooltipTimeout();\n\t\t\trequestClose(event as MouseEvent<HTMLElement>, 'mouseLeave');\n\t\t},\n\t\t[requestClose]\n\t);\n\n\tconst scheduleOpen = useCallback(\n\t\t(\n\t\t\tevent: MouseEvent<HTMLElement> | FocusEvent<HTMLElement>,\n\t\t\ttrigger: TooltipRequestOpenTrigger\n\t\t) => {\n\t\t\tclearTooltipTimeout();\n\t\t\ttooltipTimeoutRef.current = setTimeout(() => {\n\t\t\t\trequestOpen(event, trigger);\n\t\t\t}, hoverOpenDelay);\n\t\t},\n\t\t[hoverOpenDelay, requestOpen]\n\t);\n\n\tconst handleMouseEnter = useCallback(\n\t\t(event: MouseEvent<HTMLElement>) => scheduleOpen(event, 'mouseEnter'),\n\t\t[scheduleOpen]\n\t);\n\n\tconst handleFocus = useCallback(\n\t\t(event: FocusEvent<HTMLElement>) => scheduleOpen(event, 'focus'),\n\t\t[scheduleOpen]\n\t);\n\n\tconst scheduleClose = useCallback(\n\t\t(\n\t\t\te: MouseEvent<HTMLElement> | FocusEvent<HTMLElement>,\n\t\t\ttrigger: TooltipRequestCloseTrigger\n\t\t) => {\n\t\t\te.stopPropagation();\n\t\t\tclearTooltipTimeout();\n\n\t\t\ttooltipTimeoutRef.current = setTimeout(() => {\n\t\t\t\tconst relatedTarget = (e as MouseEvent<HTMLElement>)\n\t\t\t\t\t.relatedTarget as HTMLElement | null;\n\t\t\t\tconst isHoveringTooltip =\n\t\t\t\t\trelatedTarget?.classList?.contains('slds-popover_tooltip') ||\n\t\t\t\t\trelatedTarget?.classList?.contains('slds-popover__body');\n\n\t\t\t\tif (!isHoveringTooltip) {\n\t\t\t\t\trequestClose(e, trigger);\n\t\t\t\t}\n\t\t\t}, hoverCloseDelay);\n\t\t},\n\t\t[hoverCloseDelay, requestClose]\n\t);\n\n\tconst handleMouseLeave = useCallback(\n\t\t(e: MouseEvent<HTMLElement>) => scheduleClose(e, 'mouseLeave'),\n\t\t[scheduleClose]\n\t);\n\n\tconst handleBlur = useCallback(\n\t\t(e: FocusEvent<HTMLElement>) => scheduleClose(e, 'blur'),\n\t\t[scheduleClose]\n\t);\n\n\tconst handleKeyDown = useCallback(\n\t\t(e: KeyboardEvent<HTMLElement>) => {\n\t\t\te.stopPropagation();\n\n\t\t\ttooltipTimeoutRef.current = setTimeout(() => {\n\t\t\t\tif (e.key === 'Escape') {\n\t\t\t\t\trequestClose(e, 'cancel');\n\t\t\t\t}\n\t\t\t}, hoverCloseDelay);\n\t\t},\n\t\t[hoverCloseDelay, requestClose]\n\t);\n\n\t// Save trigger ref and trigger re-render once mounted\n\tconst saveTriggerRef = useCallback(\n\t\t(component: HTMLDivElement | null) => {\n\t\t\tif (component && triggerRef.current !== component) {\n\t\t\t\t(triggerRef as React.RefObject<HTMLDivElement | null>).current =\n\t\t\t\t\tcomponent;\n\t\t\t\t// Dialog/Popper.js cannot place the popover until\n\t\t\t\t// the trigger/target DOM node is mounted.\n\t\t\t\tif (!triggerRendered) {\n\t\t\t\t\tsetTriggerRendered(true);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t[triggerRendered]\n\t);\n\n\t// Measure the trigger for the anchored nubbin before paint, so it is placed on open.\n\t// Runs after every render, as the old in-render measurement did, so a trigger that\n\t// resizes while the tooltip is open is re-measured.\n\tconst isAnchoredNubbinOpen = hasAnchoredNubbin && getIsOpen();\n\t// eslint-disable-next-line react-hooks/exhaustive-deps -- no deps on purpose; the updater returns the same state when the size is unchanged, so it settles\n\tuseLayoutEffect(() => {\n\t\tif (!isAnchoredNubbinOpen || !triggerRef.current) {\n\t\t\treturn;\n\t\t}\n\t\tconst { height, width } = triggerRef.current.getBoundingClientRect();\n\t\tsetTriggerSize((size) =>\n\t\t\tsize.height === height && size.width === width ? size : { height, width }\n\t\t);\n\t});\n\n\t// Render helpers\n\tconst getAnchoredNubbinStyles = () => {\n\t\tif (!hasAnchoredNubbin) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst alignment = align.split(' ')[0] as\n\t\t\t'top' | 'bottom' | 'left' | 'right';\n\t\tconst nubbinContainerStyles: CSSProperties = {\n\t\t\theight: '0',\n\t\t\tposition: 'relative',\n\t\t\twidth: '0',\n\t\t};\n\t\tconst nubbinStyles: CSSProperties = {\n\t\t\t// Same chain as the SLDS 2 tooltip body, so the nubbin matches it.\n\t\t\tbackgroundColor:\n\t\t\t\t'var(--slds-c-tooltip-color-background, var(--slds-g-color-surface-inverse-1, #16325c))',\n\t\t\tcontent: '\"\"',\n\t\t\theight: '1rem',\n\t\t\tposition: 'absolute',\n\t\t\ttransform: 'rotate(45deg)',\n\t\t\twidth: '1rem',\n\t\t};\n\t\tconst triggerDimensions = triggerSize;\n\n\t\tswitch (alignment) {\n\t\t\tcase 'bottom': {\n\t\t\t\tnubbinContainerStyles.left = `${triggerDimensions.width / 2}px`;\n\t\t\t\tnubbinContainerStyles.top = `${triggerDimensions.height}px`;\n\t\t\t\tnubbinStyles.left = '-8px';\n\t\t\t\tnubbinStyles.top = '3px';\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'left': {\n\t\t\t\tnubbinContainerStyles.left = '0';\n\t\t\t\tnubbinContainerStyles.top = `${triggerDimensions.height / 2}px`;\n\t\t\t\tnubbinStyles.left = '-19px';\n\t\t\t\tnubbinStyles.top = '-9px';\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'right': {\n\t\t\t\tnubbinContainerStyles.left = `${triggerDimensions.width}px`;\n\t\t\t\tnubbinContainerStyles.top = `${triggerDimensions.height / 2}px`;\n\t\t\t\tnubbinStyles.left = '3px';\n\t\t\t\tnubbinStyles.top = '-9px';\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\t// top\n\t\t\t\tnubbinContainerStyles.left = `${triggerDimensions.width / 2}px`;\n\t\t\t\tnubbinContainerStyles.top = '0';\n\t\t\t\tnubbinStyles.left = '-8px';\n\t\t\t\tnubbinStyles.top = '-19px';\n\t\t\t}\n\t\t}\n\n\t\t// The dialog doesn't draw its own nubbin (`isNubbinHidden`); this one is\n\t\t// drawn with inline styles, which CSP `style-src` doesn't block.\n\t\treturn getIsOpen() ? (\n\t\t\t<div style={nubbinContainerStyles}>\n\t\t\t\t<div style={nubbinStyles} />\n\t\t\t</div>\n\t\t) : null;\n\t};\n\n\tconst getContent = () => {\n\t\tconst isInverseIcon = iconVariant === 'inverse';\n\t\tconst iconColorVariant =\n\t\t\ticonVariant === 'error' || iconVariant === 'warning'\n\t\t\t\t? iconVariant\n\t\t\t\t: undefined;\n\n\t\tconst triggerProps: TooltipTriggerProps = {\n\t\t\t'aria-describedby': getIsOpen() ? getId() : undefined,\n\t\t\tonBlur: handleBlur,\n\t\t\tonFocus: handleFocus,\n\t\t\tonKeyDown: handleKeyDown,\n\t\t\tonMouseEnter: handleMouseEnter,\n\t\t\tonMouseLeave: handleMouseLeave,\n\t\t};\n\n\t\tif (trigger !== undefined) {\n\t\t\treturn <TooltipTrigger render={trigger} triggerProps={triggerProps} />;\n\t\t}\n\n\t\t// Deprecated: each child element is a trigger\n\t\tif (React.Children.count(children) !== 0) {\n\t\t\treturn React.Children.map(children, (child) =>\n\t\t\t\tReact.isValidElement(child) ? (\n\t\t\t\t\t<TooltipTrigger render={child} triggerProps={triggerProps} />\n\t\t\t\t) : (\n\t\t\t\t\tchild\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\tif (onClickTrigger) {\n\t\t\treturn (\n\t\t\t\t<TooltipTrigger\n\t\t\t\t\trender={\n\t\t\t\t\t\t// eslint-disable-next-line jsx-a11y/anchor-is-valid -- SLDS tooltip markup uses an anchor for the clickable trigger\n\t\t\t\t\t\t<a\n\t\t\t\t\t\t\thref=\"#\"\n\t\t\t\t\t\t\tonClick={\n\t\t\t\t\t\t\t\tEventUtil.trappedHandler(\n\t\t\t\t\t\t\t\t\tonClickTrigger\n\t\t\t\t\t\t\t\t) as React.MouseEventHandler<HTMLAnchorElement>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\tcategory=\"utility\"\n\t\t\t\t\t\t\t\tcolorVariant={iconColorVariant}\n\t\t\t\t\t\t\t\tinverse={isInverseIcon}\n\t\t\t\t\t\t\t\tname=\"info\"\n\t\t\t\t\t\t\t\tassistiveText={{\n\t\t\t\t\t\t\t\t\tlabel: assistiveText.triggerLearnMoreIcon,\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\tsize=\"x-small\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</a>\n\t\t\t\t\t}\n\t\t\t\t\ttriggerProps={triggerProps}\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<TooltipTrigger\n\t\t\t\trender={\n\t\t\t\t\t<Button\n\t\t\t\t\t\taria-disabled\n\t\t\t\t\t\tassistiveText={{\n\t\t\t\t\t\t\ticon: assistiveText.triggerLearnMoreIcon,\n\t\t\t\t\t\t}}\n\t\t\t\t\t\ticonCategory=\"utility\"\n\t\t\t\t\t\ticonClassName={\n\t\t\t\t\t\t\ticonColorVariant && `slds-icon-text-${iconColorVariant}`\n\t\t\t\t\t\t}\n\t\t\t\t\t\ticonName=\"info\"\n\t\t\t\t\t\t// `bare` keeps `slds-button_icon`, which Button drops for `inverse` alone\n\t\t\t\t\t\ticonVariant={isInverseIcon ? 'bare' : undefined}\n\t\t\t\t\t\tinverse={isInverseIcon}\n\t\t\t\t\t\tvariant=\"icon\"\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t\ttriggerProps={triggerProps}\n\t\t\t/>\n\t\t);\n\t};\n\n\tconst getTooltipContent = () => {\n\t\tconst isErrorTheme = theme === 'error';\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tclassName={classNames('slds-popover__body', {\n\t\t\t\t\t// Ensure text contrast on error theme (red background needs white text)\n\t\t\t\t\t'slds-text-color_inverse': isErrorTheme,\n\t\t\t\t})}\n\t\t\t>\n\t\t\t\t{content}\n\t\t\t\t{variant === 'learnMore' && onClickTrigger ? (\n\t\t\t\t\t<div className=\"slds-m-top_x-small\" aria-hidden=\"true\">\n\t\t\t\t\t\t{labels.learnMoreBefore}{' '}\n\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\tassistiveText={{\n\t\t\t\t\t\t\t\tlabel: assistiveText.tooltipTipLearnMoreIcon,\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\tcategory=\"utility\"\n\t\t\t\t\t\t\tinverse\n\t\t\t\t\t\t\tname=\"info\"\n\t\t\t\t\t\t\tsize=\"x-small\"\n\t\t\t\t\t\t/>{' '}\n\t\t\t\t\t\t{labels.learnMoreAfter}{' '}\n\t\t\t\t\t</div>\n\t\t\t\t) : null}\n\t\t\t</div>\n\t\t);\n\t};\n\n\tconst getTooltip = () => {\n\t\treturn getIsOpen() ? (\n\t\t\t<Dialog\n\t\t\t\tcloseOnTabKey\n\t\t\t\thasNubbin\n\t\t\t\tisNubbinHidden={hasAnchoredNubbin}\n\t\t\t\tcontentsClassName={classNames(\n\t\t\t\t\t'slds-popover',\n\t\t\t\t\t'slds-popover_tooltip',\n\t\t\t\t\t{\n\t\t\t\t\t\t'slds-theme_error': theme === 'error',\n\t\t\t\t\t},\n\t\t\t\t\tdialogClassName\n\t\t\t\t)}\n\t\t\t\talign={align}\n\t\t\t\tcontext={iconSettings}\n\t\t\t\thasStaticAlignment={hasStaticAlignment}\n\t\t\t\tonClose={handleDialogClose}\n\t\t\t\tonRequestTargetElement={getTooltipTarget}\n\t\t\t\tonMouseLeave={handleDialogMouseLeave}\n\t\t\t\tposition={position}\n\t\t\t\tvariant=\"tooltip\"\n\t\t\t\tcontainerProps={{\n\t\t\t\t\tid: getId(),\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{getTooltipContent()}\n\t\t\t</Dialog>\n\t\t) : (\n\t\t\t<span />\n\t\t);\n\t};\n\n\tconst containerStyles: CSSProperties = {\n\t\tdisplay: 'inline-block',\n\t\tlineHeight: 'var(--slds-g-font-line-height-1, 1)',\n\t\t...triggerStyle,\n\t};\n\n\treturn (\n\t\t<div\n\t\t\tclassName={classNames('slds-tooltip-trigger', triggerClassName)}\n\t\t\tstyle={containerStyles}\n\t\t\tref={saveTriggerRef}\n\t\t>\n\t\t\t{getAnchoredNubbinStyles()}\n\t\t\t{getContent()}\n\t\t\t{getTooltip()}\n\t\t</div>\n\t);\n};\n\nTooltip.displayName = POPOVER_TOOLTIP;\n\nexport default Tooltip as React.FC<TooltipProps>;\n"],"mappings":";;;;;;;;;;;;;;AA2QA,IAAM,KAA6C;CAClD,yBAAyB;CACzB,sBAAsB;AACvB,GAEM,KAA+B;CACpC,gBAAgB;CAChB,iBAAiB;AAClB,GAIM,KAAkB,EACvB,WACA,sBAIK,EAAc,GAAQ,CAAY,GAOlC,KAAW,EAChB,WAAQ,OACR,eAAe,GACf,aACA,aAAU,kBAAC,QAAD,EAAA,UAAM,UAAa,CAAA,GAC7B,oBACA,uBAAoB,IACpB,wBAAqB,IACrB,qBAAkB,IAClB,oBAAiB,GACjB,iBAAc,QACd,IAAI,GACJ,QAAQ,IACR,QAAQ,GACR,oBAAgB,IAChB,gBAAa,IACb,kBACA,mBACA,2BACA,mBACA,qBACA,cAAW,YACX,iBACA,WAAQ,QACR,YACA,aAAU,QACV,wCAC8D;CAE9D,IAAM,IAAgB;EAAE,GAAG;EAAsB,GAAG;CAAkB,GAChE,IAAS;EAAE,GAAG;EAAe,GAAG;CAAW,GAG3C,KAAe,GAAW,CAAmB,GAG7C,CAAC,GAAQ,KAAa,GAAqB,GAA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ACA,wBACA,EACC,oBAAoB,MAAU,QAC/B,GACA,CACD;EACO;EACP,SAAS;EACW;EACpB,SAAS;EACT,wBAAwB;EACxB,cAAc;EACJ;EACV,SAAQ;EACR,gBAAgB,EACf,IAAI,EAAM,EACX;EAEC,UAAA,GAAkB;CACZ,CAAA,IAER,kBAAC,QAAD,CAAO,CAAA,GAIH,KAAiC;EACtC,SAAS;EACT,YAAY;EACZ,GAAG;CACJ;CAEA,OACC,kBAAC,OAAD;EACC,WAAW,EAAW,wBAAwB,CAAgB;EAC9D,OAAO;EACP,KAAK;EAHN,UAAA;GAKE,GAAwB;GACxB,GAAW;GACX,GAAW;EACR;;AAEP;AAEA,EAAQ,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"branch.js","names":[],"sources":["../../../../../components/tree/private/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';\n\nimport Item from './item';\nimport RenderInitialBranch from './render-initial-branch';\nimport RenderBranch from './render-branch';\n\nimport { TREE_BRANCH } from '../../../utilities/constants';\nimport
|
|
1
|
+
{"version":3,"file":"branch.js","names":[],"sources":["../../../../../components/tree/private/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';\n\nimport Item from './item';\nimport RenderInitialBranch from './render-initial-branch';\nimport RenderBranch from './render-branch';\n\nimport { TREE_BRANCH } from '../../../utilities/constants';\nimport { TreeNode, FlattenedNode, TreeScrollData } from '../types';\n\nexport interface BranchProps {\n\tgetNodes?: (node: { nodes?: TreeNode[] }) => TreeNode[] | undefined;\n\thtmlId: string | number;\n\tindex?: number;\n\tinitial?: boolean;\n\tinitalClassName?: string | string[] | Record<string, boolean>;\n\tinitialStyle?: React.CSSProperties;\n\tlabel?: ReactNode | string;\n\tlevel: number;\n\tnode: TreeNode | { nodes?: TreeNode[] };\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\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\tonScroll?: (\n\t\tevent: React.UIEvent<HTMLUListElement>,\n\t\tdata: TreeScrollData\n\t) => void;\n\tsearchTerm?: string;\n\ttreeId: string;\n\ttreeIndex?: string;\n\tflattenedNodes: FlattenedNode[];\n\t/** Whether a node is selected (from `selectedIds`, or the deprecated `node.selected`) */\n\tisNodeSelected: (node: TreeNode) => boolean;\n\t/** Whether a branch is expanded (from expansion state, or the deprecated `node.expanded`) */\n\tisNodeExpanded: (node: TreeNode) => boolean;\n\t/** Tree index of the node that is the tree's tab stop */\n\ttabStopIndex?: string;\n\tfocusedNodeIndex?: string;\n\tonNodeBlur?: () => void;\n\ttreeHasFocus?: boolean;\n\tparent?: TreeNode | { nodes?: TreeNode[] };\n\tnodes?: TreeNode[];\n}\n\nconst defaultGetNodes = (node: { nodes?: TreeNode[] }) => node.nodes;\n\n/**\n * A Tree Branch is an expandable node in a hierarchical list.\n */\nconst Branch: React.FC<BranchProps> = ({\n\tlevel = 0,\n\tlabel = '',\n\ttreeIndex = '',\n\tgetNodes = defaultGetNodes,\n\t...rest\n}) => {\n\tconst props = {\n\t\tlevel,\n\t\tlabel,\n\t\ttreeIndex,\n\t\tgetNodes,\n\t\t...rest,\n\t};\n\n\tconst { treeId, onExpand, searchTerm, node } = props;\n\tlet resolvedTreeIndex = '';\n\tlet children: ReactNode = null;\n\n\tconst nodeChildren = getNodes(node);\n\tif (Array.isArray(nodeChildren)) {\n\t\tchildren = nodeChildren.map((childNode, index) => {\n\t\t\tlet child: ReactNode;\n\t\t\tconst htmlId = `${treeId}-${childNode.id}`;\n\t\t\tresolvedTreeIndex = `${index}`;\n\t\t\tif (treeIndex) {\n\t\t\t\tresolvedTreeIndex = `${treeIndex}-${resolvedTreeIndex}`;\n\t\t\t}\n\n\t\t\tif (childNode.type === 'branch') {\n\t\t\t\tchild = (\n\t\t\t\t\t<Branch\n\t\t\t\t\t\tgetNodes={getNodes}\n\t\t\t\t\t\thtmlId={htmlId}\n\t\t\t\t\t\tkey={childNode.id}\n\t\t\t\t\t\tlabel={childNode.label}\n\t\t\t\t\t\tlevel={level + 1}\n\t\t\t\t\t\tnode={childNode}\n\t\t\t\t\t\tflattenedNodes={props.flattenedNodes}\n\t\t\t\t\t\tisNodeSelected={props.isNodeSelected}\n\t\t\t\t\t\tisNodeExpanded={props.isNodeExpanded}\n\t\t\t\t\t\ttabStopIndex={props.tabStopIndex}\n\t\t\t\t\t\tfocusedNodeIndex={props.focusedNodeIndex}\n\t\t\t\t\t\ttreeHasFocus={props.treeHasFocus}\n\t\t\t\t\t\tonNodeBlur={props.onNodeBlur}\n\t\t\t\t\t\tnodes={childNode.nodes}\n\t\t\t\t\t\tonSelect={props.onSelect}\n\t\t\t\t\t\tonExpand={onExpand}\n\t\t\t\t\t\tsearchTerm={searchTerm}\n\t\t\t\t\t\ttreeId={treeId}\n\t\t\t\t\t\ttreeIndex={resolvedTreeIndex}\n\t\t\t\t\t\tparent={node}\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tchild = (\n\t\t\t\t\t<Item\n\t\t\t\t\t\tlabel={childNode.label}\n\t\t\t\t\t\thtmlId={htmlId}\n\t\t\t\t\t\tkey={childNode.id}\n\t\t\t\t\t\tlevel={level + 1}\n\t\t\t\t\t\tnode={childNode}\n\t\t\t\t\t\tflattenedNodes={props.flattenedNodes}\n\t\t\t\t\t\tisNodeSelected={props.isNodeSelected}\n\t\t\t\t\t\tisNodeExpanded={props.isNodeExpanded}\n\t\t\t\t\t\ttabStopIndex={props.tabStopIndex}\n\t\t\t\t\t\tfocusedNodeIndex={props.focusedNodeIndex}\n\t\t\t\t\t\ttreeHasFocus={props.treeHasFocus}\n\t\t\t\t\t\tonNodeBlur={props.onNodeBlur}\n\t\t\t\t\t\tonSelect={props.onSelect}\n\t\t\t\t\t\tonExpand={onExpand}\n\t\t\t\t\t\tsearchTerm={searchTerm}\n\t\t\t\t\t\ttreeIndex={resolvedTreeIndex}\n\t\t\t\t\t\ttreeId={treeId}\n\t\t\t\t\t\tparent={node}\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn child;\n\t\t});\n\t}\n\n\tconst branch =\n\t\tlevel === 0\n\t\t\t? RenderInitialBranch(children, props)\n\t\t\t: RenderBranch(children, {\n\t\t\t\t\t...props,\n\t\t\t\t\tnode: node as TreeNode,\n\t\t\t\t\ttreeIndex,\n\t\t\t\t});\n\n\treturn branch;\n};\n\nBranch.displayName = TREE_BRANCH;\n\nexport default Branch;\n"],"mappings":";;;;;;;AA8DA,IAAM,KAAmB,MAAiC,EAAK,OAKzD,KAAiC,EACtC,WAAQ,GACR,WAAQ,IACR,eAAY,IACZ,cAAW,GACX,GAAG,QACE;CACL,IAAM,IAAQ;EACb;EACA;EACA;EACA;EACA,GAAG;CACJ,GAEM,EAAE,WAAQ,aAAU,eAAY,YAAS,GAC3C,IAAoB,IACpB,IAAsB,MAEpB,IAAe,EAAS,CAAI;CAwElC,OAvEI,MAAM,QAAQ,CAAY,MAC7B,IAAW,EAAa,KAAK,GAAW,MAAU;EACjD,IAAI,GACE,IAAS,GAAG,EAAO,GAAG,EAAU;EAuDtC,OAtDA,IAAoB,GAAG,KACnB,MACH,IAAoB,GAAG,EAAU,GAAG,MAGrC,AA0BC,IA1BG,EAAU,SAAS,WAErB,kBAAC,GAAD;GACW;GACF;GAER,OAAO,EAAU;GACjB,OAAO,IAAQ;GACf,MAAM;GACN,gBAAgB,EAAM;GACtB,gBAAgB,EAAM;GACtB,gBAAgB,EAAM;GACtB,cAAc,EAAM;GACpB,kBAAkB,EAAM;GACxB,cAAc,EAAM;GACpB,YAAY,EAAM;GAClB,OAAO,EAAU;GACjB,UAAU,EAAM;GACN;GACE;GACJ;GACR,WAAW;GACX,QAAQ;EACR,GAlBK,EAAU,EAkBf,IAID,kBAAC,GAAD;GACC,OAAO,EAAU;GACT;GAER,OAAO,IAAQ;GACf,MAAM;GACN,gBAAgB,EAAM;GACtB,gBAAgB,EAAM;GACtB,gBAAgB,EAAM;GACtB,cAAc,EAAM;GACpB,kBAAkB,EAAM;GACxB,cAAc,EAAM;GACpB,YAAY,EAAM;GAClB,UAAU,EAAM;GACN;GACE;GACZ,WAAW;GACH;GACR,QAAQ;EACR,GAhBK,EAAU,EAgBf,GAGI;CACR,CAAC,IAID,MAAU,IACP,EAAoB,GAAU,CAAK,IACnC,EAAa,GAAU;EACvB,GAAG;EACG;EACN;CACD,CAAC;AAGL;AAEA,EAAO,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item.js","names":[],"sources":["../../../../../components/tree/private/item.tsx"],"sourcesContent":["/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\nimport React, { ReactNode } from 'react';\nimport classNames from 'classnames';\nimport findIndex from 'lodash.findindex';\nimport isFunction from 'lodash.isfunction';\n\nimport Button from '../../button';\nimport Highlighter from '../../utilities/highlighter';\n\nimport EventUtil from '../../../utilities/event';\nimport KEYS from '../../../utilities/key-code';\nimport mapKeyEventCallbacks from '../../../utilities/key-callbacks';\nimport { TREE_ITEM } from '../../../utilities/constants';\nimport { TreeNode, FlattenedNode } from '../types';\n\nexport interface ItemProps {\n\thtmlId: string;\n\tlabel: ReactNode | string;\n\tlevel: number;\n\tnode: TreeNode;\n\tonExpand: (params: {\n\t\tevent: React.SyntheticEvent;\n\t\tdata: {\n\t\t\tnode: TreeNode;\n\t\t\tselect?: boolean;\n\t\t\texpand: boolean;\n\t\t\ttreeIndex: string;\n\t\t};\n\t}) => void;\n\tonSelect?: (params: {\n\t\tevent: React.SyntheticEvent;\n\t\tdata: {\n\t\t\tnode: TreeNode;\n\t\t\tselect: boolean;\n\t\t\ttreeIndex: string;\n\t\t};\n\t\tfromFocus?: boolean;\n\t\tclearSelectedNodes?: boolean;\n\t}) => void;\n\tsearchTerm?: string;\n\ttreeId?: string;\n\ttreeIndex: string;\n\tflattenedNodes: FlattenedNode[];\n\tisNodeSelected: (node: TreeNode) => boolean;\n\tisNodeExpanded: (node: TreeNode) => boolean;\n\ttabStopIndex?: string;\n\tfocusedNodeIndex?: string;\n\tonNodeBlur?: () => void;\n\ttreeHasFocus?: boolean;\n\tparent?: TreeNode | { nodes?: TreeNode[] };\n}\n\nconst handleSelect = ({\n\tevent,\n\tprops,\n\tfromFocus,\n}: {\n\tevent: React.SyntheticEvent;\n\tprops: ItemProps;\n\tfromFocus?: boolean;\n}) => {\n\tEventUtil.trap(event);\n\tif (isFunction(props.onSelect)) {\n\t\tprops.onSelect({\n\t\t\tevent,\n\t\t\tdata: {\n\t\t\t\tnode: props.node,\n\t\t\t\tselect: !props.isNodeSelected(props.node),\n\t\t\t\ttreeIndex: props.treeIndex,\n\t\t\t},\n\t\t\tfromFocus,\n\t\t});\n\t}\n};\n\nconst findNextNode = (flattenedNodes: FlattenedNode[], node: TreeNode) => {\n\tconst nodes = flattenedNodes.map((flattenedNode) => flattenedNode.node);\n\tconst index = findIndex(nodes, { id: node.id });\n\treturn flattenedNodes[(index + 1) % flattenedNodes.length];\n};\n\nconst findPreviousNode = (flattenedNodes: FlattenedNode[], node: TreeNode) => {\n\tconst nodes = flattenedNodes.map((flattenedNode) => flattenedNode.node);\n\tlet index = findIndex(nodes, { id: node.id }) - 1;\n\tif (index < 0) {\n\t\tindex += flattenedNodes.length;\n\t}\n\treturn flattenedNodes[index];\n};\n\nconst handleKeyDownDown = (event: React.KeyboardEvent, props: ItemProps) => {\n\tif (props.focusedNodeIndex === props.treeIndex) {\n\t\tconst flattenedNode = findNextNode(props.flattenedNodes, props.node);\n\t\tprops.onSelect?.({\n\t\t\tevent,\n\t\t\tdata: {\n\t\t\t\tnode: flattenedNode.node,\n\t\t\t\tselect: true,\n\t\t\t\ttreeIndex: flattenedNode.treeIndex,\n\t\t\t},\n\t\t\tclearSelectedNodes: true,\n\t\t});\n\t}\n};\n\nconst handleKeyDownUp = (event: React.KeyboardEvent, props: ItemProps) => {\n\tif (props.focusedNodeIndex === props.treeIndex) {\n\t\tconst flattenedNode = findPreviousNode(props.flattenedNodes, props.node);\n\t\tprops.onSelect?.({\n\t\t\tevent,\n\t\t\tdata: {\n\t\t\t\tnode: flattenedNode.node,\n\t\t\t\tselect: true,\n\t\t\t\ttreeIndex: flattenedNode.treeIndex,\n\t\t\t},\n\t\t\tclearSelectedNodes: true,\n\t\t});\n\t}\n};\n\nconst handleKeyDownLeft = (event: React.KeyboardEvent, props: ItemProps) => {\n\tconst nodes = props.flattenedNodes.map((flattenedNode) => flattenedNode.node);\n\tconst parent = props.parent as TreeNode;\n\tconst index = findIndex(nodes, { id: parent?.id });\n\tif (index !== -1) {\n\t\t// `select: true` marks a move to the parent node, not an expand/collapse request.\n\t\t// Tree routes it to `onSelect` (or to the deprecated `onExpandClick`).\n\t\tprops.onExpand({\n\t\t\tevent,\n\t\t\tdata: {\n\t\t\t\tnode: parent,\n\t\t\t\tselect: true,\n\t\t\t\texpand: !props.isNodeExpanded(parent),\n\t\t\t\ttreeIndex: props.flattenedNodes[index].treeIndex,\n\t\t\t},\n\t\t});\n\t}\n};\n\nconst handleKeyDownEnter = (event: React.KeyboardEvent, props: ItemProps) => {\n\thandleSelect({ event, props });\n};\n\nconst handleKeyDown = (event: React.KeyboardEvent, props: ItemProps) => {\n\tmapKeyEventCallbacks(event, {\n\t\tcallbacks: {\n\t\t\t[KEYS.DOWN]: {\n\t\t\t\tcallback: (evt: React.KeyboardEvent) => handleKeyDownDown(evt, props),\n\t\t\t},\n\t\t\t[KEYS.UP]: {\n\t\t\t\tcallback: (evt: React.KeyboardEvent) => handleKeyDownUp(evt, props),\n\t\t\t},\n\t\t\t[KEYS.LEFT]: {\n\t\t\t\tcallback: (evt: React.KeyboardEvent) => handleKeyDownLeft(evt, props),\n\t\t\t},\n\t\t\t[KEYS.ENTER]: {\n\t\t\t\tcallback: (evt: React.KeyboardEvent) => handleKeyDownEnter(evt, props),\n\t\t\t},\n\t\t},\n\t});\n};\n\nconst handleFocus = (event: React.FocusEvent, props: ItemProps) => {\n\tif (\n\t\t!props.treeHasFocus &&\n\t\t!props.focusedNodeIndex &&\n\t\tevent.target === event.currentTarget\n\t) {\n\t\thandleSelect({ event, props });\n\t}\n};\n\nconst getTabIndex = (props: ItemProps): number =>\n\tprops.treeIndex === props.tabStopIndex ? 0 : -1;\n\n/**\n * A Tree Item is a non-branching node in a hierarchical list.\n */\nconst Item: React.FC<ItemProps> = (props) => {\n\tconst isSelected = props.isNodeSelected(props.node);\n\tconst isFocused = props.treeIndex === props.focusedNodeIndex;\n\n\treturn (\n\t\t<li\n\t\t\tid={`${props.treeId}-${props.node.id}`}\n\t\t\trole=\"treeitem\"\n\t\t\taria-level={props.level}\n\t\t\taria-selected={isSelected ? 'true' : 'false'}\n\t\t\ttabIndex={getTabIndex(props)}\n\t\t\tonKeyDown={(event) => handleKeyDown(event, props)}\n\t\t\tonFocus={(event) => handleFocus(event, props)}\n\t\t\tonBlur={props.onNodeBlur}\n\t\t\tref={(component) => {\n\t\t\t\tif (props.treeHasFocus && component && isFocused) {\n\t\t\t\t\tcomponent.focus();\n\t\t\t\t}\n\t\t\t}}\n\t\t>\n\t\t\t<div\n\t\t\t\tclassName={classNames('slds-tree__item', {\n\t\t\t\t\t'slds-is-selected': isSelected,\n\t\t\t\t})}\n\t\t\t\tonClick={(event) => handleSelect({ event, props })}\n\t\t\t>\n\t\t\t\t<Button\n\t\t\t\t\taria-hidden\n\t\t\t\t\ttabIndex={-1}\n\t\t\t\t\tassistiveText={{ icon: '' }}\n\t\t\t\t\ticonCategory=\"utility\"\n\t\t\t\t\ticonName=\"chevronright\"\n\t\t\t\t\ticonSize=\"small\"\n\t\t\t\t\tvariant=\"icon\"\n\t\t\t\t\t// `slds-hidden` keeps the chevron's space so leaf labels align with\n\t\t\t\t\t// branch labels; SLDS 2 no longer hides `.slds-is-disabled` here.\n\t\t\t\t\tclassName=\"slds-m-right_small slds-is-disabled slds-hidden\"\n\t\t\t\t\tdisabled\n\t\t\t\t/>\n\t\t\t\t<span className=\"slds-size_1-of-1\">\n\t\t\t\t\t<Highlighter\n\t\t\t\t\t\tsearch={props.searchTerm}\n\t\t\t\t\t\tclassName=\"slds-tree__item-label slds-truncate\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{props.label}\n\t\t\t\t\t</Highlighter>\n\t\t\t\t</span>\n\t\t\t</div>\n\t\t</li>\n\t);\n};\n\nItem.displayName = TREE_ITEM;\n\nexport default Item;\n"],"mappings":";;;;;;;;;;;;AAsDA,IAAM,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,MAAmB;CAC7E,IAAM,IAAQ,EAAe,KAAK,MAAkB,EAAc,IAAI,GAClE,IAAQ,EAAU,GAAO,EAAE,IAAI,EAAK,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W,MAA6B,EAAmB,GAAK,CAAK,EACtE;CACD,EACD,CAAC;AACF,GAEM,KAAe,GAAyB,MAAqB;CAClE,AACC,CAAC,EAAM,gBACP,CAAC,EAAM,oBACP,EAAM,WAAW,EAAM,iBAEvB,EAAa;EAAE;EAAO;CAAM,CAAC;AAE/B,GAEM,KAAe,MACpB,EAAM,cAAc,EAAM,eAAe,IAAI,IAKxC,KAA6B,MAAU;CAC5C,IAAM,IAAa,EAAM,eAAe,EAAM,IAAI,GAC5C,IAAY,EAAM,cAAc,EAAM;CAE5C,OACC,kBAAC,MAAD;EACC,IAAI,GAAG,EAAM,OAAO,GAAG,EAAM,KAAK;EAClC,MAAK;EACL,cAAY,EAAM;EAClB,iBAAe,IAAa,SAAS;EACrC,UAAU,EAAY,CAAK;EAC3B,YAAY,MAAU,EAAc,GAAO,CAAK;EAChD,UAAU,MAAU,EAAY,GAAO,CAAK;EAC5C,QAAQ,EAAM;EACd,MAAM,MAAc;GACnB,AAAI,EAAM,gBAAgB,KAAa,KACtC,EAAU,MAAM;EAElB;
|
|
1
|
+
{"version":3,"file":"item.js","names":[],"sources":["../../../../../components/tree/private/item.tsx"],"sourcesContent":["/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\nimport React, { ReactNode } from 'react';\nimport classNames from 'classnames';\nimport findIndex from 'lodash.findindex';\nimport isFunction from 'lodash.isfunction';\n\nimport Button from '../../button';\nimport Highlighter from '../../utilities/highlighter';\n\nimport EventUtil from '../../../utilities/event';\nimport KEYS from '../../../utilities/key-code';\nimport mapKeyEventCallbacks from '../../../utilities/key-callbacks';\nimport { TREE_ITEM } from '../../../utilities/constants';\nimport { TreeNode, FlattenedNode } from '../types';\n\nexport interface ItemProps {\n\thtmlId: string;\n\tlabel: ReactNode | string;\n\tlevel: number;\n\tnode: TreeNode;\n\tonExpand: (params: {\n\t\tevent: React.SyntheticEvent;\n\t\tdata: {\n\t\t\tnode: TreeNode;\n\t\t\tselect?: boolean;\n\t\t\texpand: boolean;\n\t\t\ttreeIndex: string;\n\t\t};\n\t}) => void;\n\tonSelect?: (params: {\n\t\tevent: React.SyntheticEvent;\n\t\tdata: {\n\t\t\tnode: TreeNode;\n\t\t\tselect: boolean;\n\t\t\ttreeIndex: string;\n\t\t};\n\t\tfromFocus?: boolean;\n\t\tclearSelectedNodes?: boolean;\n\t}) => void;\n\tsearchTerm?: string;\n\ttreeId?: string;\n\ttreeIndex: string;\n\tflattenedNodes: FlattenedNode[];\n\tisNodeSelected: (node: TreeNode) => boolean;\n\tisNodeExpanded: (node: TreeNode) => boolean;\n\ttabStopIndex?: string;\n\tfocusedNodeIndex?: string;\n\tonNodeBlur?: () => void;\n\ttreeHasFocus?: boolean;\n\tparent?: TreeNode | { nodes?: TreeNode[] };\n}\n\nconst handleSelect = ({\n\tevent,\n\tprops,\n\tfromFocus,\n}: {\n\tevent: React.SyntheticEvent;\n\tprops: ItemProps;\n\tfromFocus?: boolean;\n}) => {\n\tEventUtil.trap(event);\n\tif (isFunction(props.onSelect)) {\n\t\tprops.onSelect({\n\t\t\tevent,\n\t\t\tdata: {\n\t\t\t\tnode: props.node,\n\t\t\t\tselect: !props.isNodeSelected(props.node),\n\t\t\t\ttreeIndex: props.treeIndex,\n\t\t\t},\n\t\t\tfromFocus,\n\t\t});\n\t}\n};\n\nconst findNextNode = (flattenedNodes: FlattenedNode[], node: TreeNode) => {\n\tconst nodes = flattenedNodes.map((flattenedNode) => flattenedNode.node);\n\tconst index = findIndex(nodes, { id: node.id });\n\treturn flattenedNodes[(index + 1) % flattenedNodes.length];\n};\n\nconst findPreviousNode = (flattenedNodes: FlattenedNode[], node: TreeNode) => {\n\tconst nodes = flattenedNodes.map((flattenedNode) => flattenedNode.node);\n\tlet index = findIndex(nodes, { id: node.id }) - 1;\n\tif (index < 0) {\n\t\tindex += flattenedNodes.length;\n\t}\n\treturn flattenedNodes[index];\n};\n\nconst handleKeyDownDown = (event: React.KeyboardEvent, props: ItemProps) => {\n\tif (props.focusedNodeIndex === props.treeIndex) {\n\t\tconst flattenedNode = findNextNode(props.flattenedNodes, props.node);\n\t\tprops.onSelect?.({\n\t\t\tevent,\n\t\t\tdata: {\n\t\t\t\tnode: flattenedNode.node,\n\t\t\t\tselect: true,\n\t\t\t\ttreeIndex: flattenedNode.treeIndex,\n\t\t\t},\n\t\t\tclearSelectedNodes: true,\n\t\t});\n\t}\n};\n\nconst handleKeyDownUp = (event: React.KeyboardEvent, props: ItemProps) => {\n\tif (props.focusedNodeIndex === props.treeIndex) {\n\t\tconst flattenedNode = findPreviousNode(props.flattenedNodes, props.node);\n\t\tprops.onSelect?.({\n\t\t\tevent,\n\t\t\tdata: {\n\t\t\t\tnode: flattenedNode.node,\n\t\t\t\tselect: true,\n\t\t\t\ttreeIndex: flattenedNode.treeIndex,\n\t\t\t},\n\t\t\tclearSelectedNodes: true,\n\t\t});\n\t}\n};\n\nconst handleKeyDownLeft = (event: React.KeyboardEvent, props: ItemProps) => {\n\tconst nodes = props.flattenedNodes.map((flattenedNode) => flattenedNode.node);\n\tconst parent = props.parent as TreeNode;\n\tconst index = findIndex(nodes, { id: parent?.id });\n\tif (index !== -1) {\n\t\t// `select: true` marks a move to the parent node, not an expand/collapse request.\n\t\t// Tree routes it to `onSelect` (or to the deprecated `onExpandClick`).\n\t\tprops.onExpand({\n\t\t\tevent,\n\t\t\tdata: {\n\t\t\t\tnode: parent,\n\t\t\t\tselect: true,\n\t\t\t\texpand: !props.isNodeExpanded(parent),\n\t\t\t\ttreeIndex: props.flattenedNodes[index].treeIndex,\n\t\t\t},\n\t\t});\n\t}\n};\n\nconst handleKeyDownEnter = (event: React.KeyboardEvent, props: ItemProps) => {\n\thandleSelect({ event, props });\n};\n\nconst handleKeyDown = (event: React.KeyboardEvent, props: ItemProps) => {\n\tmapKeyEventCallbacks(event, {\n\t\tcallbacks: {\n\t\t\t[KEYS.DOWN]: {\n\t\t\t\tcallback: (evt: React.KeyboardEvent) => handleKeyDownDown(evt, props),\n\t\t\t},\n\t\t\t[KEYS.UP]: {\n\t\t\t\tcallback: (evt: React.KeyboardEvent) => handleKeyDownUp(evt, props),\n\t\t\t},\n\t\t\t[KEYS.LEFT]: {\n\t\t\t\tcallback: (evt: React.KeyboardEvent) => handleKeyDownLeft(evt, props),\n\t\t\t},\n\t\t\t[KEYS.ENTER]: {\n\t\t\t\tcallback: (evt: React.KeyboardEvent) => handleKeyDownEnter(evt, props),\n\t\t\t},\n\t\t},\n\t});\n};\n\nconst handleFocus = (event: React.FocusEvent, props: ItemProps) => {\n\tif (\n\t\t!props.treeHasFocus &&\n\t\t!props.focusedNodeIndex &&\n\t\tevent.target === event.currentTarget\n\t) {\n\t\thandleSelect({ event, props });\n\t}\n};\n\nconst getTabIndex = (props: ItemProps): number =>\n\tprops.treeIndex === props.tabStopIndex ? 0 : -1;\n\n/**\n * A Tree Item is a non-branching node in a hierarchical list.\n */\nconst Item: React.FC<ItemProps> = (props) => {\n\tconst isSelected = props.isNodeSelected(props.node);\n\tconst isFocused = props.treeIndex === props.focusedNodeIndex;\n\n\treturn (\n\t\t<li\n\t\t\tid={`${props.treeId}-${props.node.id}`}\n\t\t\trole=\"treeitem\"\n\t\t\taria-level={props.level}\n\t\t\taria-selected={isSelected ? 'true' : 'false'}\n\t\t\ttabIndex={getTabIndex(props)}\n\t\t\tonKeyDown={(event) => handleKeyDown(event, props)}\n\t\t\tonFocus={(event) => handleFocus(event, props)}\n\t\t\tonBlur={props.onNodeBlur}\n\t\t\tref={(component) => {\n\t\t\t\tif (props.treeHasFocus && component && isFocused) {\n\t\t\t\t\tcomponent.focus();\n\t\t\t\t}\n\t\t\t}}\n\t\t>\n\t\t\t{/* 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\taria-hidden\n\t\t\t\t\ttabIndex={-1}\n\t\t\t\t\tassistiveText={{ icon: '' }}\n\t\t\t\t\ticonCategory=\"utility\"\n\t\t\t\t\ticonName=\"chevronright\"\n\t\t\t\t\ticonSize=\"small\"\n\t\t\t\t\tvariant=\"icon\"\n\t\t\t\t\t// `slds-hidden` keeps the chevron's space so leaf labels align with\n\t\t\t\t\t// branch labels; SLDS 2 no longer hides `.slds-is-disabled` here.\n\t\t\t\t\tclassName=\"slds-m-right_small slds-is-disabled slds-hidden\"\n\t\t\t\t\tdisabled\n\t\t\t\t/>\n\t\t\t\t<span className=\"slds-size_1-of-1\">\n\t\t\t\t\t<Highlighter\n\t\t\t\t\t\tsearch={props.searchTerm}\n\t\t\t\t\t\tclassName=\"slds-tree__item-label slds-truncate\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{props.label}\n\t\t\t\t\t</Highlighter>\n\t\t\t\t</span>\n\t\t\t</div>\n\t\t</li>\n\t);\n};\n\nItem.displayName = TREE_ITEM;\n\nexport default Item;\n"],"mappings":";;;;;;;;;;;;AAsDA,IAAM,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,MAAmB;CAC7E,IAAM,IAAQ,EAAe,KAAK,MAAkB,EAAc,IAAI,GAClE,IAA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});
|
|
101
|
-
}, x = (e) => e.treeIndex === e.tabStopIndex ? 0 : -1, S =
|
|
101
|
+
}, x = (e) => e.treeIndex === e.tabStopIndex ? 0 : -1, S = {
|
|
102
|
+
borderRadius: "var(--slds-g-radius-border-pill, 15rem)",
|
|
103
|
+
display: "block",
|
|
104
|
+
marginBottom: "var(--slds-g-spacing-3, .75rem)",
|
|
105
|
+
height: "var(--slds-g-sizing-3, .5rem)",
|
|
106
|
+
backgroundColor: "var(--slds-g-color-surface-container-3, rgb(224, 229, 238))"
|
|
107
|
+
}, C = (t, n) => {
|
|
102
108
|
let r = n.isNodeExpanded(n.node), c = n.isNodeSelected(n.node), l = n.treeIndex === n.focusedNodeIndex, f = n.node.loading, p = /* @__PURE__ */ s("div", {
|
|
103
109
|
style: {
|
|
104
110
|
display: "block",
|
|
105
111
|
paddingLeft: `${1.5 * n.level + 1.5}rem`,
|
|
106
|
-
marginTop: ".5rem"
|
|
112
|
+
marginTop: "var(--slds-g-spacing-2, .5rem)"
|
|
107
113
|
},
|
|
108
114
|
children: [
|
|
109
115
|
/* @__PURE__ */ o("div", { style: {
|
|
110
|
-
|
|
111
|
-
display: "block",
|
|
112
|
-
marginBottom: ".75rem",
|
|
113
|
-
height: ".5rem",
|
|
114
|
-
backgroundColor: "rgb(224, 229, 238)",
|
|
116
|
+
...S,
|
|
115
117
|
width: "40%"
|
|
116
118
|
} }),
|
|
117
119
|
/* @__PURE__ */ o("div", { style: {
|
|
118
|
-
|
|
119
|
-
display: "block",
|
|
120
|
-
marginBottom: ".75rem",
|
|
121
|
-
height: ".5rem",
|
|
122
|
-
backgroundColor: "rgb(224, 229, 238)",
|
|
120
|
+
...S,
|
|
123
121
|
width: "80%"
|
|
124
122
|
} }),
|
|
125
123
|
/* @__PURE__ */ o("div", { style: {
|
|
126
|
-
|
|
127
|
-
display: "block",
|
|
128
|
-
marginBottom: ".75rem",
|
|
129
|
-
height: ".5rem",
|
|
130
|
-
backgroundColor: "rgb(224, 229, 238)",
|
|
124
|
+
...S,
|
|
131
125
|
width: "60%"
|
|
132
126
|
} })
|
|
133
127
|
]
|
|
@@ -139,6 +133,7 @@ var u = (e, t) => {
|
|
|
139
133
|
return /* @__PURE__ */ s("li", {
|
|
140
134
|
id: String(n.htmlId),
|
|
141
135
|
role: "treeitem",
|
|
136
|
+
"aria-selected": c ? "true" : "false",
|
|
142
137
|
...h,
|
|
143
138
|
tabIndex: x(n),
|
|
144
139
|
onKeyDown: (e) => y(e, n),
|
|
@@ -188,8 +183,8 @@ var u = (e, t) => {
|
|
|
188
183
|
]
|
|
189
184
|
});
|
|
190
185
|
};
|
|
191
|
-
|
|
186
|
+
C.displayName = "Branch";
|
|
192
187
|
//#endregion
|
|
193
|
-
export {
|
|
188
|
+
export { C as default };
|
|
194
189
|
|
|
195
190
|
//# sourceMappingURL=render-branch.js.map
|
|
@@ -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,MAAmB;CAC7E,IAAM,IAAQ,EAAe,KAAK,MAAkB,EAAc,IAAI,GAClE,IAAQ,EAAU,GAAO,EAAE,IAAI,EAAK,GAAG,CAAC,IAAI;CAIhD,OAHI,IAAQ,MACX,KAAS,EAAe,SAElB,EAAe;AACvB,GAEM,KACL,GACA,MACI;CACJ,IAAI,EAAM,qBAAqB,EAAM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,IAAI,IAAQ,KAAA;CAC5D;CAEA,OAEC,kBAAC,MAAD;EACC,IAAI,OAAO,EAAM,MAAM;EACvB,MAAK;EACL,GAAI;EACJ,UAAU,EAAY,CAAK;EAC3B,YAAY,MAAU,EAAc,GAAO,CAAK;EAChD,UAAU,MAAU,EAAY,GAAO,CAAK;EAC5C,QAAQ,EAAM;EACd,MAAM,MAAc;GACnB,AAAI,EAAM,gBAAgB,KAAa,KACtC,EAAU,MAAM;EAElB;EAZD,UAAA;GAcC,kBAAC,OAAD;IACC,WAAW,EAAW,mBAAmB,EACxC,oBAAoB,EACrB,CAAC;IACD,UAAU,MAAU,EAAa;KAAE;KAAO;IAAM,CAAC;IAJlD,UAAA,CAMC,kBAAC,GAAD;KAEC,iBAAe,OAAO,EAAM,MAAM;KAClC,eAAA;KACA,eAAe,EAAE,MAAM,qBAAqB;KAC5C,cAAa;KACb,UAAS;KACT,UAAS;KACT,SAAQ;KACR,WAAU;KACV,UAAU,MAAU,EAAa,GAAO,CAAK;KAC7C,UAAU;IACV,CAAA,GACD,kBAAC,QAAD;KAAM,WAAU;KAAmB,IAAI,GAAG,EAAM,OAAO;KACtD,UAAA,kBAAC,GAAD;MACC,QAAQ,EAAM;MACd,WAAU;MAET,UAAA,EAAM;KACK,CAAA;IACR,CAAA,CACF;;GACJ,IAAY,IAAS;GACtB,kBAAC,MAAD;IACC,WAAW,EAAW;KACrB,oBAAoB;KACpB,qBAAqB,CAAC;IACvB,CAAC;IACD,MAAK;IACL,mBAAiB,GAAG,EAAM,OAAO;IAEhC,UAAA,KAAc,CAAC,IAAY,IAAW;GACpC,CAAA;EACD;;AAEN;AAEA,EAAa,cAAc"}
|
|
1
|
+
{"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,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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AM,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"}
|
|
@@ -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;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OAAO,CAAC,CACzD,QAAQ,MAAQ,EAAQ,KAAK,QAAQ,EAAK,CAAC,CAC3C,QACC,GAAoB,OAAS;KAC7B,GAAG;MACG,IAAM,KAAK,QAAQ;IAC1B,IACA,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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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"}
|
|
@@ -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":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