@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,2 +1,2 @@
|
|
|
1
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../icon/index.cjs"),n=require("../../spinner/index.cjs");let r=require("react");r=e.__toESM(r,1);let i=require("classnames");i=e.__toESM(i,1);let a=require("react/jsx-runtime"),o=require("dequal");var s=(e,t)=>{if(!e||e.length===0||!t||t.length===0)return e;let n=e.toLowerCase().indexOf(t.toLowerCase());return n>-1?(0,a.jsxs)(r.default.Fragment,{children:[e.
|
|
1
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../icon/index.cjs"),n=require("../../spinner/index.cjs");let r=require("react");r=e.__toESM(r,1);let i=require("classnames");i=e.__toESM(i,1);let a=require("react/jsx-runtime"),o=require("dequal");var s=(e,t)=>{if(!e||e.length===0||!t||t.length===0)return e;let n=e.toLowerCase().indexOf(t.toLowerCase());return n>-1?(0,a.jsxs)(r.default.Fragment,{children:[e.slice(0,n),(0,a.jsx)(`span`,{className:`slds-text-title_bold`,children:`${e.slice(n,n+t.length)}`},`bold`),e.slice(n+t.length)]}):e},c=(e,t)=>e==null||typeof e==`string`?e:e(t),l=e=>e.props.size==null?r.default.cloneElement(e,{size:`small`}):e,u=e=>typeof e?.label==`string`?e.label:void 0,d=({activeOption:e,activeOptionIndex:u=-1,assistiveText:d={},classNameMenuSubHeader:f,classNameMenu:p,inheritWidthOf:m,inputId:h,inputValue:g=``,isSelected:_,itemVisibleLength:v,labels:y,hasMenuSpinner:b,maxWidth:x,menuPosition:S,menuRef:C,renderMenuItem:w,onSelect:T,options:E,selection:D,tooltipMenuItemDisabled:O,variant:k=`icon-title-subtitle`})=>{let A=m===`menu`?`inherit`:void 0;A=m===`menu`&&x?x:A;let j=E.map((n,p)=>{let m=p===u&&e&&(0,o.dequal)(n.id,e.id),v=_({selection:D,option:n})&&n.type!==`header`&&n.type!==`footer`;if(n.type===`separator`)return n.label?(0,a.jsx)(`li`,{className:`slds-dropdown__header slds-truncate`,title:typeof n.label==`string`?n.label:void 0,role:`separator`,children:(0,a.jsx)(`span`,{className:(0,i.default)(`slds-listbox__option-header`,f),children:typeof n.label==`string`?n.label:n.label?.(g)})},`menu-separator-${n.id}`):(0,a.jsx)(`li`,{className:`slds-has-divider_top-space`,role:`separator`},`menu-separator-${n.id}`);if(n.type===`header`)return(0,a.jsx)(`li`,{role:`presentation`,className:`slds-listbox__item`,children:(0,a.jsxs)(`div`,{onClick:n.disabled?void 0:e=>{T(e,{option:n})},"aria-selected":m,"aria-disabled":n.disabled||void 0,id:`${h}-listbox-option-${n.id}`,className:(0,i.default)(`slds-media slds-listbox__option`,`slds-listbox__option_entity slds-listbox__option_term`,{"slds-has-focus":m}),role:`option`,children:[(0,a.jsx)(`span`,{className:`slds-media__figure slds-listbox__option-icon`,children:n.icon&&l(n.icon)}),(0,a.jsx)(`span`,{className:`slds-media__body`,children:c(n.label,g)})]})},`menu-header-${n.id}}`);if(n.type===`footer`)return(0,a.jsx)(`li`,{role:`presentation`,className:`slds-listbox__item`,children:(0,a.jsxs)(`div`,{"aria-selected":m,"aria-disabled":n.disabled||void 0,onClick:n.disabled?void 0:e=>{T(e,{option:n})},id:`${h}-listbox-option-${n.id}`,className:(0,i.default)(`slds-media slds-listbox__option`,`slds-listbox__option_entity slds-listbox__option_term`,{"slds-has-focus":m}),role:`option`,children:[(0,a.jsx)(`span`,{className:`slds-media__figure slds-listbox__option-icon`,children:n.icon&&l(n.icon)}),(0,a.jsx)(`span`,{className:`slds-media__body`,children:c(n.label,g)})]})},`menu-footer-${n.id}}`);let y={},b=`${h}-listbox-option-help-${n.id}`;n.disabled&&O&&m&&(y[`aria-describedby`]=b),n.disabled&&(y[`aria-disabled`]=!0,y.style={cursor:`default`});let x=typeof n.label==`string`?n.label:void 0,S={"icon-title-subtitle":(0,r.createElement)(`span`,{"aria-selected":m,...y,id:`${h}-listbox-option-${n.id}`,key:`menu-subtitle-${n.id}`,className:(0,i.default)(`slds-media slds-listbox__option`,`slds-listbox__option_entity slds-listbox__option_has-meta`,{"slds-has-focus":m}),onClick:n.disabled?void 0:e=>{T(e,{option:n})},role:`option`},n.icon&&!w?(0,a.jsx)(`span`,{className:`slds-media__figure`,children:n.icon&&l(n.icon)}):null,w?w({isSelected:v,option:n}):(0,a.jsxs)(`span`,{className:`slds-media__body`,children:[(0,a.jsx)(`span`,{className:(0,i.default)(`slds-listbox__option-text`,`slds-listbox__option-text_entity`,{"slds-disabled-text":n.disabled}),title:x,children:s(x,g)}),(0,a.jsx)(`span`,{className:(0,i.default)(`slds-listbox__option-meta slds-listbox__option-meta_entity`,{"slds-disabled-text":n.disabled}),title:n.subTitle,children:s(n.subTitle,g)})]})),checkbox:(0,r.createElement)(`span`,{"aria-selected":m,...y,id:`${h}-listbox-option-${n.id}`,key:`menu-checkbox-${n.id}`,className:(0,i.default)(`slds-media slds-listbox__option`,` slds-listbox__option_plain slds-media_small slds-media_center`,{"slds-has-focus":m,"slds-is-selected":v}),onClick:n.disabled?void 0:e=>{T(e,{selection:D,option:n})},role:`option`},(0,a.jsx)(`span`,{className:`slds-media__figure`,children:(0,a.jsx)(t.default,{className:`slds-listbox__icon-selected`,category:`utility`,name:`check`,size:`x-small`})}),(0,a.jsx)(`span`,{className:`slds-media__body`,children:w?w({isSelected:v,option:n}):(0,a.jsxs)(`span`,{className:(0,i.default)(`slds-truncate`,{"slds-disabled-text":n.disabled}),title:x,children:[v?(0,a.jsx)(`span`,{className:`slds-assistive-text`,children:d.optionSelectedInMenu}):null,` `,n.type===`deselect`?(0,a.jsx)(`em`,{children:x}):x]})}))},C;if(n.disabled&&O){let{content:e,...t}=O.props,i={align:`top`,content:n.tooltipContent||e,id:b,position:`absolute`,silenceTriggerTabbableWarning:!0,triggerStyle:{width:`100%`},...t};m&&i.isOpen===void 0&&(i.isOpen=!0),i.trigger=S[k],C=r.default.cloneElement(O,i)}else C=S[k];return(0,a.jsx)(`li`,{className:`slds-listbox__item`,role:`presentation`,children:C},`menu-option-${n.id}`)});return(0,a.jsxs)(`ul`,{className:(0,i.default)(`slds-listbox slds-listbox_vertical slds-dropdown slds-dropdown_fluid`,{"slds-dropdown_length-with-icon-5":v===5,"slds-dropdown_length-with-icon-7":v===7,"slds-dropdown_length-with-icon-10":v===10},p),ref:C,role:`presentation`,style:{width:m===`menu`?`auto`:void 0,maxWidth:A,position:S===`relative`?void 0:`relative`},children:[j.length?j:(0,a.jsx)(`li`,{className:`slds-listbox__item slds-listbox__status`,role:`status`,"aria-live":`polite`,children:(0,a.jsx)(`span`,{className:`slds-m-left_x-large slds-p-vertical_medium`,children:y.noOptionsFound})}),b&&(0,a.jsx)(`li`,{role:`presentation`,className:`slds-listbox__item`,children:(0,a.jsx)(`div`,{className:`slds-align_absolute-center slds-p-top_medium`,children:(0,a.jsx)(n.default,{assistiveText:{label:d.loadingMenuItems},hasContainer:!1,placement:`inline`,size:`x-small`})})})]})};d.displayName=`Menu`,exports.default=d,exports.getOptionLabel=u;
|
|
2
2
|
//# sourceMappingURL=menu.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu.cjs","names":[],"sources":["../../../../../components/combobox/private/menu.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\ttype ReactNode,\n\ttype ReactElement,\n\ttype CSSProperties,\n} from 'react';\nimport { dequal as isEqual } from 'dequal';\nimport classNames from 'classnames';\n\nimport Icon from '../../icon';\nimport Spinner from '../../spinner';\nimport type { TooltipProps } from '../../tooltip';\nimport type {\n\tComboboxMenuRenderMenuItemData,\n\tComboboxOption,\n\tComboboxOptionIcon,\n} from '../types';\n\nexport interface MenuAssistiveText {\n\tloadingMenuItems?: string;\n\toptionSelectedInMenu?: string;\n}\n\nexport interface MenuLabels {\n\tnoOptionsFound: ReactNode | string;\n}\n\nexport interface MenuProps {\n\t/** Active descendant in menu */\n\tactiveOption?: ComboboxOption;\n\t/** Index of active descendant in menu */\n\tactiveOptionIndex?: number;\n\t/** Assistive text for accessibility */\n\tassistiveText?: MenuAssistiveText;\n\t/** CSS classes to be added to menu sub header span tag */\n\tclassNameMenuSubHeader?: string | string[] | Record<string, boolean>;\n\t/** CSS classes for menu */\n\tclassNameMenu?: string | string[] | Record<string, boolean>;\n\t/** Sets the dialog width */\n\tinheritWidthOf?: 'target' | 'menu' | 'none';\n\t/** Id used for assistive technology */\n\tinputId?: string;\n\t/** Input value for bolding matches */\n\tinputValue?: string;\n\t/** Function to check if option is selected */\n\tisSelected: (params: {\n\t\tselection: ComboboxOption[];\n\t\toption: ComboboxOption;\n\t}) => boolean;\n\t/** Determines the height of the menu */\n\titemVisibleLength?: 5 | 7 | 10 | null;\n\t/** Text labels */\n\tlabels: MenuLabels;\n\t/** Adds loading spinner below the options */\n\thasMenuSpinner?: boolean;\n\t/** Sets a maximum width for menu */\n\tmaxWidth?: string;\n\t/** Menu position */\n\tmenuPosition?: 'absolute' | 'overflowBoundaryElement' | 'relative';\n\t/** Ref for menu element */\n\tmenuRef?:\n\t\tReact.RefCallback<HTMLUListElement> | React.RefObject<HTMLUListElement>;\n\t/** Renders an option's content in place of the default label and icon */\n\trenderMenuItem?: (data: ComboboxMenuRenderMenuItemData) => ReactNode;\n\t/** Callback when option is selected */\n\tonSelect: (\n\t\tevent: React.MouseEvent,\n\t\tdata: { option: ComboboxOption; selection?: ComboboxOption[] }\n\t) => void;\n\t/** Menu options */\n\toptions: ComboboxOption[];\n\t/** Selected options */\n\tselection: ComboboxOption[];\n\t/** Tooltip for disabled menu items */\n\ttooltipMenuItemDisabled?: ReactElement<Partial<TooltipProps>>;\n\t/** Menu variant */\n\tvariant?: 'icon-title-subtitle' | 'checkbox';\n}\n\nconst setBold = (label: string | undefined, searchTerm: string): ReactNode => {\n\tif (!label || label.length === 0 || !searchTerm || searchTerm.length === 0) {\n\t\treturn label;\n\t}\n\tconst position = label.toLowerCase().indexOf(searchTerm.toLowerCase());\n\tif (position > -1) {\n\t\treturn (\n\t\t\t<React.Fragment>\n\t\t\t\t{label.substr(0, position)}\n\t\t\t\t<span key=\"bold\" className=\"slds-text-title_bold\">{`${label.substr(\n\t\t\t\t\tposition,\n\t\t\t\t\tsearchTerm.length\n\t\t\t\t)}`}</span>\n\t\t\t\t{label.substr(position + searchTerm.length)}\n\t\t\t</React.Fragment>\n\t\t);\n\t}\n\treturn label;\n};\n\nconst renderLabel = (\n\tlabelProp: string | ((searchTerm: string) => ReactNode) | undefined,\n\tsearchTerm: string\n): ReactNode => {\n\tif (labelProp == null || typeof labelProp === 'string') {\n\t\treturn labelProp;\n\t}\n\treturn labelProp(searchTerm);\n};\n\n// Entity icons in a combobox listbox option render at \"small\" per SLDS. `Icon`\n// defaults to \"medium\", so an option icon passed without an explicit size shows\n// oversized in the menu (SLDS 2 no longer shrinks it via CSS the way SLDS 1\n// did). Clone the icon to enforce \"small\" unless the consumer set a size\n// themselves. Leaves non-<Icon> nodes untouched.\nconst sizeOptionIcon = (icon: ComboboxOptionIcon): ReactNode =>\n\ticon.props.size != null ? icon : React.cloneElement(icon, { size: 'small' });\n\n/**\n * The text of an option's label. A label render function (separator and action\n * rows only) has no text, so it returns `undefined`.\n */\nexport const getOptionLabel = (option?: ComboboxOption): string | undefined =>\n\ttypeof option?.label === 'string' ? option.label : undefined;\n\nconst Menu: React.FC<MenuProps> = ({\n\tactiveOption,\n\tactiveOptionIndex = -1,\n\tassistiveText = {},\n\tclassNameMenuSubHeader,\n\tclassNameMenu,\n\tinheritWidthOf,\n\tinputId,\n\tinputValue = '',\n\tisSelected,\n\titemVisibleLength,\n\tlabels,\n\thasMenuSpinner,\n\tmaxWidth,\n\tmenuPosition,\n\tmenuRef,\n\trenderMenuItem,\n\tonSelect,\n\toptions,\n\tselection,\n\ttooltipMenuItemDisabled,\n\tvariant = 'icon-title-subtitle',\n}) => {\n\tlet menuMaxWidth: string | undefined =\n\t\tinheritWidthOf === 'menu' ? 'inherit' : undefined;\n\tmenuMaxWidth =\n\t\tinheritWidthOf === 'menu' && maxWidth ? maxWidth : menuMaxWidth;\n\n\tconst menuOptions = options.map((optionData, index) => {\n\t\tconst active =\n\t\t\tindex === activeOptionIndex &&\n\t\t\tactiveOption &&\n\t\t\tisEqual(optionData.id, activeOption.id);\n\t\tconst selected =\n\t\t\tisSelected({\n\t\t\t\tselection,\n\t\t\t\toption: optionData,\n\t\t\t}) &&\n\t\t\toptionData.type !== 'header' &&\n\t\t\toptionData.type !== 'footer';\n\n\t\tif (optionData.type === 'separator') {\n\t\t\treturn optionData.label ? (\n\t\t\t\t<li\n\t\t\t\t\tclassName=\"slds-dropdown__header slds-truncate\"\n\t\t\t\t\ttitle={\n\t\t\t\t\t\ttypeof optionData.label === 'string' ? optionData.label : undefined\n\t\t\t\t\t}\n\t\t\t\t\trole=\"separator\"\n\t\t\t\t\tkey={`menu-separator-${optionData.id}`}\n\t\t\t\t>\n\t\t\t\t\t<span\n\t\t\t\t\t\tclassName={classNames(\n\t\t\t\t\t\t\t'slds-listbox__option-header',\n\t\t\t\t\t\t\tclassNameMenuSubHeader\n\t\t\t\t\t\t)}\n\t\t\t\t\t>\n\t\t\t\t\t\t{typeof optionData.label === 'string'\n\t\t\t\t\t\t\t? optionData.label\n\t\t\t\t\t\t\t: optionData.label?.(inputValue)}\n\t\t\t\t\t</span>\n\t\t\t\t</li>\n\t\t\t) : (\n\t\t\t\t<li\n\t\t\t\t\tclassName=\"slds-has-divider_top-space\"\n\t\t\t\t\trole=\"separator\"\n\t\t\t\t\tkey={`menu-separator-${optionData.id}`}\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\tif (optionData.type === 'header') {\n\t\t\treturn (\n\t\t\t\t<li\n\t\t\t\t\tkey={`menu-header-${optionData.id}}`}\n\t\t\t\t\trole=\"presentation\"\n\t\t\t\t\tclassName=\"slds-listbox__item\"\n\t\t\t\t>\n\t\t\t\t\t<div\n\t\t\t\t\t\tonClick={\n\t\t\t\t\t\t\toptionData.disabled\n\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t: (event) => {\n\t\t\t\t\t\t\t\t\t\tonSelect(event, { option: optionData });\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\taria-selected={active}\n\t\t\t\t\t\taria-disabled={optionData.disabled || undefined}\n\t\t\t\t\t\tid={`${inputId}-listbox-option-${optionData.id}`}\n\t\t\t\t\t\tclassName={classNames(\n\t\t\t\t\t\t\t'slds-media slds-listbox__option',\n\t\t\t\t\t\t\t'slds-listbox__option_entity slds-listbox__option_term',\n\t\t\t\t\t\t\t{ 'slds-has-focus': active }\n\t\t\t\t\t\t)}\n\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<span className=\"slds-media__figure slds-listbox__option-icon\">\n\t\t\t\t\t\t\t{optionData.icon && sizeOptionIcon(optionData.icon)}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<span className=\"slds-media__body\">\n\t\t\t\t\t\t\t{renderLabel(optionData.label, inputValue)}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</div>\n\t\t\t\t</li>\n\t\t\t);\n\t\t}\n\n\t\tif (optionData.type === 'footer') {\n\t\t\treturn (\n\t\t\t\t<li\n\t\t\t\t\tkey={`menu-footer-${optionData.id}}`}\n\t\t\t\t\trole=\"presentation\"\n\t\t\t\t\tclassName=\"slds-listbox__item\"\n\t\t\t\t>\n\t\t\t\t\t<div\n\t\t\t\t\t\taria-selected={active}\n\t\t\t\t\t\taria-disabled={optionData.disabled || undefined}\n\t\t\t\t\t\tonClick={\n\t\t\t\t\t\t\toptionData.disabled\n\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t: (event) => {\n\t\t\t\t\t\t\t\t\t\tonSelect(event, { option: optionData });\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tid={`${inputId}-listbox-option-${optionData.id}`}\n\t\t\t\t\t\tclassName={classNames(\n\t\t\t\t\t\t\t'slds-media slds-listbox__option',\n\t\t\t\t\t\t\t'slds-listbox__option_entity slds-listbox__option_term',\n\t\t\t\t\t\t\t{ 'slds-has-focus': active }\n\t\t\t\t\t\t)}\n\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<span className=\"slds-media__figure slds-listbox__option-icon\">\n\t\t\t\t\t\t\t{optionData.icon && sizeOptionIcon(optionData.icon)}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<span className=\"slds-media__body\">\n\t\t\t\t\t\t\t{renderLabel(optionData.label, inputValue)}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</div>\n\t\t\t\t</li>\n\t\t\t);\n\t\t}\n\n\t\tconst disabledProps: {\n\t\t\t'aria-describedby'?: string;\n\t\t\t'aria-disabled'?: boolean;\n\t\t\tstyle?: CSSProperties;\n\t\t} = {};\n\t\tconst tooltipId = `${inputId}-listbox-option-help-${optionData.id}`;\n\t\tif (optionData.disabled && tooltipMenuItemDisabled && active) {\n\t\t\tdisabledProps['aria-describedby'] = tooltipId;\n\t\t}\n\t\tif (optionData.disabled) {\n\t\t\tdisabledProps['aria-disabled'] = true;\n\t\t\tdisabledProps.style = { cursor: 'default' };\n\t\t}\n\n\t\tconst labelString =\n\t\t\ttypeof optionData.label === 'string' ? optionData.label : undefined;\n\n\t\tconst menuItem: Record<string, ReactNode> = {\n\t\t\t'icon-title-subtitle': (\n\t\t\t\t<span\n\t\t\t\t\taria-selected={active}\n\t\t\t\t\t{...disabledProps}\n\t\t\t\t\tid={`${inputId}-listbox-option-${optionData.id}`}\n\t\t\t\t\tkey={`menu-subtitle-${optionData.id}`}\n\t\t\t\t\tclassName={classNames(\n\t\t\t\t\t\t'slds-media slds-listbox__option',\n\t\t\t\t\t\t'slds-listbox__option_entity slds-listbox__option_has-meta',\n\t\t\t\t\t\t{ 'slds-has-focus': active }\n\t\t\t\t\t)}\n\t\t\t\t\tonClick={\n\t\t\t\t\t\toptionData.disabled\n\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t: (event) => {\n\t\t\t\t\t\t\t\t\tonSelect(event, { option: optionData });\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\trole=\"option\"\n\t\t\t\t>\n\t\t\t\t\t{optionData.icon && !renderMenuItem ? (\n\t\t\t\t\t\t<span className=\"slds-media__figure\">\n\t\t\t\t\t\t\t{optionData.icon && sizeOptionIcon(optionData.icon)}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) : null}\n\t\t\t\t\t{renderMenuItem ? (\n\t\t\t\t\t\trenderMenuItem({ isSelected: selected, option: optionData })\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<span className=\"slds-media__body\">\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tclassName={classNames(\n\t\t\t\t\t\t\t\t\t'slds-listbox__option-text',\n\t\t\t\t\t\t\t\t\t'slds-listbox__option-text_entity',\n\t\t\t\t\t\t\t\t\t{ 'slds-disabled-text': optionData.disabled }\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\ttitle={labelString}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{setBold(labelString, inputValue)}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tclassName={classNames(\n\t\t\t\t\t\t\t\t\t'slds-listbox__option-meta slds-listbox__option-meta_entity',\n\t\t\t\t\t\t\t\t\t{ 'slds-disabled-text': optionData.disabled }\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\ttitle={optionData.subTitle}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{setBold(optionData.subTitle, inputValue)}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t)}\n\t\t\t\t</span>\n\t\t\t),\n\t\t\tcheckbox: (\n\t\t\t\t<span\n\t\t\t\t\taria-selected={active}\n\t\t\t\t\t{...disabledProps}\n\t\t\t\t\tid={`${inputId}-listbox-option-${optionData.id}`}\n\t\t\t\t\tkey={`menu-checkbox-${optionData.id}`}\n\t\t\t\t\tclassName={classNames(\n\t\t\t\t\t\t'slds-media slds-listbox__option',\n\t\t\t\t\t\t' slds-listbox__option_plain slds-media_small slds-media_center',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'slds-has-focus': active,\n\t\t\t\t\t\t\t'slds-is-selected': selected,\n\t\t\t\t\t\t}\n\t\t\t\t\t)}\n\t\t\t\t\tonClick={\n\t\t\t\t\t\toptionData.disabled\n\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t: (event) => {\n\t\t\t\t\t\t\t\t\tonSelect(event, {\n\t\t\t\t\t\t\t\t\t\tselection,\n\t\t\t\t\t\t\t\t\t\toption: optionData,\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\trole=\"option\"\n\t\t\t\t>\n\t\t\t\t\t<span className=\"slds-media__figure\">\n\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\tclassName=\"slds-listbox__icon-selected\"\n\t\t\t\t\t\t\tcategory=\"utility\"\n\t\t\t\t\t\t\tname=\"check\"\n\t\t\t\t\t\t\tsize=\"x-small\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</span>\n\t\t\t\t\t<span className=\"slds-media__body\">\n\t\t\t\t\t\t{renderMenuItem ? (\n\t\t\t\t\t\t\trenderMenuItem({ isSelected: selected, option: optionData })\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tclassName={classNames('slds-truncate', {\n\t\t\t\t\t\t\t\t\t'slds-disabled-text': optionData.disabled,\n\t\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\t\ttitle={labelString}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{selected ? (\n\t\t\t\t\t\t\t\t\t<span className=\"slds-assistive-text\">\n\t\t\t\t\t\t\t\t\t\t{assistiveText.optionSelectedInMenu}\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t) : null}{' '}\n\t\t\t\t\t\t\t\t{optionData.type === 'deselect' ? (\n\t\t\t\t\t\t\t\t\t<em>{labelString}</em>\n\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\tlabelString\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</span>\n\t\t\t\t</span>\n\t\t\t),\n\t\t};\n\n\t\tlet item: ReactNode;\n\t\tif (optionData.disabled && tooltipMenuItemDisabled) {\n\t\t\tconst tooltipPropsFromElement = tooltipMenuItemDisabled.props as {\n\t\t\t\tcontent?: ReactNode;\n\t\t\t\t[key: string]: unknown;\n\t\t\t};\n\t\t\tconst { content, ...userDefinedTooltipProps } = tooltipPropsFromElement;\n\t\t\tconst tooltipProps: Record<string, unknown> = {\n\t\t\t\talign: 'top',\n\t\t\t\tcontent: optionData.tooltipContent || content,\n\t\t\t\tid: tooltipId,\n\t\t\t\tposition: 'absolute',\n\t\t\t\tsilenceTriggerTabbableWarning: true,\n\t\t\t\ttriggerStyle: { width: '100%' },\n\t\t\t\t...userDefinedTooltipProps,\n\t\t\t};\n\t\t\tif (active && tooltipProps.isOpen === undefined) {\n\t\t\t\ttooltipProps.isOpen = true;\n\t\t\t}\n\t\t\ttooltipProps.trigger = menuItem[variant];\n\t\t\titem = React.cloneElement(tooltipMenuItemDisabled, tooltipProps);\n\t\t} else {\n\t\t\titem = menuItem[variant];\n\t\t}\n\n\t\treturn (\n\t\t\t<li\n\t\t\t\tclassName=\"slds-listbox__item\"\n\t\t\t\tkey={`menu-option-${optionData.id}`}\n\t\t\t\trole=\"presentation\"\n\t\t\t>\n\t\t\t\t{item}\n\t\t\t</li>\n\t\t);\n\t});\n\n\treturn (\n\t\t<ul\n\t\t\tclassName={classNames(\n\t\t\t\t'slds-listbox slds-listbox_vertical slds-dropdown slds-dropdown_fluid',\n\t\t\t\t{\n\t\t\t\t\t'slds-dropdown_length-with-icon-5': itemVisibleLength === 5,\n\t\t\t\t\t'slds-dropdown_length-with-icon-7': itemVisibleLength === 7,\n\t\t\t\t\t'slds-dropdown_length-with-icon-10': itemVisibleLength === 10,\n\t\t\t\t},\n\t\t\t\tclassNameMenu\n\t\t\t)}\n\t\t\tref={menuRef}\n\t\t\trole=\"presentation\"\n\t\t\tstyle={{\n\t\t\t\twidth: inheritWidthOf === 'menu' ? 'auto' : undefined,\n\t\t\t\tmaxWidth: menuMaxWidth,\n\t\t\t\tposition: menuPosition !== 'relative' ? 'relative' : undefined,\n\t\t\t}}\n\t\t>\n\t\t\t{menuOptions.length ? (\n\t\t\t\tmenuOptions\n\t\t\t) : (\n\t\t\t\t<li\n\t\t\t\t\tclassName=\"slds-listbox__item slds-listbox__status\"\n\t\t\t\t\trole=\"status\"\n\t\t\t\t\taria-live=\"polite\"\n\t\t\t\t>\n\t\t\t\t\t<span className=\"slds-m-left_x-large slds-p-vertical_medium\">\n\t\t\t\t\t\t{labels.noOptionsFound}\n\t\t\t\t\t</span>\n\t\t\t\t</li>\n\t\t\t)}\n\t\t\t{hasMenuSpinner && (\n\t\t\t\t<li role=\"presentation\" className=\"slds-listbox__item\">\n\t\t\t\t\t<div className=\"slds-align_absolute-center slds-p-top_medium\">\n\t\t\t\t\t\t<Spinner\n\t\t\t\t\t\t\tassistiveText={{ label: assistiveText.loadingMenuItems }}\n\t\t\t\t\t\t\thasContainer={false}\n\t\t\t\t\t\t\tplacement=\"inline\"\n\t\t\t\t\t\t\tsize=\"x-small\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</li>\n\t\t\t)}\n\t\t</ul>\n\t);\n};\n\nMenu.displayName = 'Menu';\n\nexport default Menu;\n"],"mappings":"8QAiFA,IAAM,GAAW,EAA2B,IAAkC,CAC7E,GAAI,CAAC,GAAS,EAAM,SAAW,GAAK,CAAC,GAAc,EAAW,SAAW,EACxE,OAAO,EAER,IAAM,EAAW,EAAM,YAAY,CAAC,CAAC,QAAQ,EAAW,YAAY,CAAC,EAarE,OAZI,EAAW,IAEb,EAAA,EAAA,KAAA,CAAC,EAAA,QAAM,SAAP,CAAA,SAAA,CACE,EAAM,OAAO,EAAG,CAAQ,GACzB,EAAA,EAAA,IAAA,CAAC,OAAD,CAAiB,UAAU,uBAAwB,SAAA,GAAG,EAAM,OAC3D,EACA,EAAW,MACZ,GAAU,EAHA,MAGA,EACT,EAAM,OAAO,EAAW,EAAW,MAAM,CAC3B,CAAA,CAAA,EAGX,CACR,EAEM,GACL,EACA,IAEI,GAAa,MAAQ,OAAO,GAAc,SACtC,EAED,EAAU,CAAU,EAQtB,EAAkB,GACvB,EAAK,MAAM,MA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,OACC,EAAA,EAAA,KAAA,CAAC,KAAD,CACC,WAAA,EAAW,EAAA,QAAA,CACV,uEACA,CACC,mCAAoC,IAAsB,EAC1D,mCAAoC,IAAsB,EAC1D,oCAAqC,IAAsB,EAC5D,EACA,CACD,EACA,IAAK,EACL,KAAK,eACL,MAAO,CACN,MAAO,IAAmB,OAAS,OAAS,IAAA,GAC5C,SAAU,EACV,SAAU,IAAiB,WAA0B,IAAA,GAAb,UACzC,EAhBD,SAAA,CAkBE,EAAY,OACZ,GAEA,EAAA,EAAA,IAAA,CAAC,KAAD,CACC,UAAU,0CACV,KAAK,SACL,YAAU,SAEV,UAAA,EAAA,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,6CACd,SAAA,EAAO,cACH,CAAA,CACH,CAAA,EAEJ,IACA,EAAA,EAAA,IAAA,CAAC,KAAD,CAAI,KAAK,eAAe,UAAU,qBACjC,UAAA,EAAA,EAAA,IAAA,CAAC,MAAD,CAAK,UAAU,+CACd,UAAA,EAAA,EAAA,IAAA,CAAC,EAAA,QAAD,CACC,cAAe,CAAE,MAAO,EAAc,gBAAiB,EACvD,aAAc,GACd,UAAU,SACV,KAAK,SACL,CAAA,CACG,CAAA,CACF,CAAA,CAEF,GAEN,EAEA,EAAK,YAAc"}
|
|
1
|
+
{"version":3,"file":"menu.cjs","names":[],"sources":["../../../../../components/combobox/private/menu.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\ttype ReactNode,\n\ttype ReactElement,\n\ttype CSSProperties,\n} from 'react';\nimport { dequal as isEqual } from 'dequal';\nimport classNames from 'classnames';\n\nimport Icon from '../../icon';\nimport Spinner from '../../spinner';\nimport type { TooltipProps } from '../../tooltip';\nimport type {\n\tComboboxMenuRenderMenuItemData,\n\tComboboxOption,\n\tComboboxOptionIcon,\n} from '../types';\n\nexport interface MenuAssistiveText {\n\tloadingMenuItems?: string;\n\toptionSelectedInMenu?: string;\n}\n\nexport interface MenuLabels {\n\tnoOptionsFound: ReactNode | string;\n}\n\nexport interface MenuProps {\n\t/** Active descendant in menu */\n\tactiveOption?: ComboboxOption;\n\t/** Index of active descendant in menu */\n\tactiveOptionIndex?: number;\n\t/** Assistive text for accessibility */\n\tassistiveText?: MenuAssistiveText;\n\t/** CSS classes to be added to menu sub header span tag */\n\tclassNameMenuSubHeader?: string | string[] | Record<string, boolean>;\n\t/** CSS classes for menu */\n\tclassNameMenu?: string | string[] | Record<string, boolean>;\n\t/** Sets the dialog width */\n\tinheritWidthOf?: 'target' | 'menu' | 'none';\n\t/** Id used for assistive technology */\n\tinputId?: string;\n\t/** Input value for bolding matches */\n\tinputValue?: string;\n\t/** Function to check if option is selected */\n\tisSelected: (params: {\n\t\tselection: ComboboxOption[];\n\t\toption: ComboboxOption;\n\t}) => boolean;\n\t/** Determines the height of the menu */\n\titemVisibleLength?: 5 | 7 | 10 | null;\n\t/** Text labels */\n\tlabels: MenuLabels;\n\t/** Adds loading spinner below the options */\n\thasMenuSpinner?: boolean;\n\t/** Sets a maximum width for menu */\n\tmaxWidth?: string;\n\t/** Menu position */\n\tmenuPosition?: 'absolute' | 'overflowBoundaryElement' | 'relative';\n\t/** Ref for menu element */\n\tmenuRef?:\n\t\tReact.RefCallback<HTMLUListElement> | React.RefObject<HTMLUListElement>;\n\t/** Renders an option's content in place of the default label and icon */\n\trenderMenuItem?: (data: ComboboxMenuRenderMenuItemData) => ReactNode;\n\t/** Callback when option is selected */\n\tonSelect: (\n\t\tevent: React.MouseEvent,\n\t\tdata: { option: ComboboxOption; selection?: ComboboxOption[] }\n\t) => void;\n\t/** Menu options */\n\toptions: ComboboxOption[];\n\t/** Selected options */\n\tselection: ComboboxOption[];\n\t/** Tooltip for disabled menu items */\n\ttooltipMenuItemDisabled?: ReactElement<Partial<TooltipProps>>;\n\t/** Menu variant */\n\tvariant?: 'icon-title-subtitle' | 'checkbox';\n}\n\nconst setBold = (label: string | undefined, searchTerm: string): ReactNode => {\n\tif (!label || label.length === 0 || !searchTerm || searchTerm.length === 0) {\n\t\treturn label;\n\t}\n\tconst position = label.toLowerCase().indexOf(searchTerm.toLowerCase());\n\tif (position > -1) {\n\t\treturn (\n\t\t\t<React.Fragment>\n\t\t\t\t{label.slice(0, position)}\n\t\t\t\t<span key=\"bold\" className=\"slds-text-title_bold\">{`${label.slice(\n\t\t\t\t\tposition,\n\t\t\t\t\tposition + searchTerm.length\n\t\t\t\t)}`}</span>\n\t\t\t\t{label.slice(position + searchTerm.length)}\n\t\t\t</React.Fragment>\n\t\t);\n\t}\n\treturn label;\n};\n\nconst renderLabel = (\n\tlabelProp: string | ((searchTerm: string) => ReactNode) | undefined,\n\tsearchTerm: string\n): ReactNode => {\n\tif (labelProp == null || typeof labelProp === 'string') {\n\t\treturn labelProp;\n\t}\n\treturn labelProp(searchTerm);\n};\n\n// Entity icons in a combobox listbox option render at \"small\" per SLDS. `Icon`\n// defaults to \"medium\", so an option icon passed without an explicit size shows\n// oversized in the menu (SLDS 2 no longer shrinks it via CSS the way SLDS 1\n// did). Clone the icon to enforce \"small\" unless the consumer set a size\n// themselves. Leaves non-<Icon> nodes untouched.\nconst sizeOptionIcon = (icon: ComboboxOptionIcon): ReactNode =>\n\ticon.props.size != null ? icon : React.cloneElement(icon, { size: 'small' });\n\n/**\n * The text of an option's label. A label render function (separator and action\n * rows only) has no text, so it returns `undefined`.\n */\nexport const getOptionLabel = (option?: ComboboxOption): string | undefined =>\n\ttypeof option?.label === 'string' ? option.label : undefined;\n\nconst Menu: React.FC<MenuProps> = ({\n\tactiveOption,\n\tactiveOptionIndex = -1,\n\tassistiveText = {},\n\tclassNameMenuSubHeader,\n\tclassNameMenu,\n\tinheritWidthOf,\n\tinputId,\n\tinputValue = '',\n\tisSelected,\n\titemVisibleLength,\n\tlabels,\n\thasMenuSpinner,\n\tmaxWidth,\n\tmenuPosition,\n\tmenuRef,\n\trenderMenuItem,\n\tonSelect,\n\toptions,\n\tselection,\n\ttooltipMenuItemDisabled,\n\tvariant = 'icon-title-subtitle',\n}) => {\n\tlet menuMaxWidth: string | undefined =\n\t\tinheritWidthOf === 'menu' ? 'inherit' : undefined;\n\tmenuMaxWidth =\n\t\tinheritWidthOf === 'menu' && maxWidth ? maxWidth : menuMaxWidth;\n\n\tconst menuOptions = options.map((optionData, index) => {\n\t\tconst active =\n\t\t\tindex === activeOptionIndex &&\n\t\t\tactiveOption &&\n\t\t\tisEqual(optionData.id, activeOption.id);\n\t\tconst selected =\n\t\t\tisSelected({\n\t\t\t\tselection,\n\t\t\t\toption: optionData,\n\t\t\t}) &&\n\t\t\toptionData.type !== 'header' &&\n\t\t\toptionData.type !== 'footer';\n\n\t\tif (optionData.type === 'separator') {\n\t\t\treturn optionData.label ? (\n\t\t\t\t<li\n\t\t\t\t\tclassName=\"slds-dropdown__header slds-truncate\"\n\t\t\t\t\ttitle={\n\t\t\t\t\t\ttypeof optionData.label === 'string' ? optionData.label : undefined\n\t\t\t\t\t}\n\t\t\t\t\trole=\"separator\"\n\t\t\t\t\tkey={`menu-separator-${optionData.id}`}\n\t\t\t\t>\n\t\t\t\t\t<span\n\t\t\t\t\t\tclassName={classNames(\n\t\t\t\t\t\t\t'slds-listbox__option-header',\n\t\t\t\t\t\t\tclassNameMenuSubHeader\n\t\t\t\t\t\t)}\n\t\t\t\t\t>\n\t\t\t\t\t\t{typeof optionData.label === 'string'\n\t\t\t\t\t\t\t? optionData.label\n\t\t\t\t\t\t\t: optionData.label?.(inputValue)}\n\t\t\t\t\t</span>\n\t\t\t\t</li>\n\t\t\t) : (\n\t\t\t\t<li\n\t\t\t\t\tclassName=\"slds-has-divider_top-space\"\n\t\t\t\t\trole=\"separator\"\n\t\t\t\t\tkey={`menu-separator-${optionData.id}`}\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\tif (optionData.type === 'header') {\n\t\t\treturn (\n\t\t\t\t<li\n\t\t\t\t\tkey={`menu-header-${optionData.id}}`}\n\t\t\t\t\trole=\"presentation\"\n\t\t\t\t\tclassName=\"slds-listbox__item\"\n\t\t\t\t>\n\t\t\t\t\t{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/interactive-supports-focus -- focus stays on the combobox input, which drives options through aria-activedescendant */}\n\t\t\t\t\t<div\n\t\t\t\t\t\tonClick={\n\t\t\t\t\t\t\toptionData.disabled\n\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t: (event) => {\n\t\t\t\t\t\t\t\t\t\tonSelect(event, { option: optionData });\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\taria-selected={active}\n\t\t\t\t\t\taria-disabled={optionData.disabled || undefined}\n\t\t\t\t\t\tid={`${inputId}-listbox-option-${optionData.id}`}\n\t\t\t\t\t\tclassName={classNames(\n\t\t\t\t\t\t\t'slds-media slds-listbox__option',\n\t\t\t\t\t\t\t'slds-listbox__option_entity slds-listbox__option_term',\n\t\t\t\t\t\t\t{ 'slds-has-focus': active }\n\t\t\t\t\t\t)}\n\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<span className=\"slds-media__figure slds-listbox__option-icon\">\n\t\t\t\t\t\t\t{optionData.icon && sizeOptionIcon(optionData.icon)}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<span className=\"slds-media__body\">\n\t\t\t\t\t\t\t{renderLabel(optionData.label, inputValue)}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</div>\n\t\t\t\t</li>\n\t\t\t);\n\t\t}\n\n\t\tif (optionData.type === 'footer') {\n\t\t\treturn (\n\t\t\t\t<li\n\t\t\t\t\tkey={`menu-footer-${optionData.id}}`}\n\t\t\t\t\trole=\"presentation\"\n\t\t\t\t\tclassName=\"slds-listbox__item\"\n\t\t\t\t>\n\t\t\t\t\t{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/interactive-supports-focus -- focus stays on the combobox input, which drives options through aria-activedescendant */}\n\t\t\t\t\t<div\n\t\t\t\t\t\taria-selected={active}\n\t\t\t\t\t\taria-disabled={optionData.disabled || undefined}\n\t\t\t\t\t\tonClick={\n\t\t\t\t\t\t\toptionData.disabled\n\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t: (event) => {\n\t\t\t\t\t\t\t\t\t\tonSelect(event, { option: optionData });\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tid={`${inputId}-listbox-option-${optionData.id}`}\n\t\t\t\t\t\tclassName={classNames(\n\t\t\t\t\t\t\t'slds-media slds-listbox__option',\n\t\t\t\t\t\t\t'slds-listbox__option_entity slds-listbox__option_term',\n\t\t\t\t\t\t\t{ 'slds-has-focus': active }\n\t\t\t\t\t\t)}\n\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<span className=\"slds-media__figure slds-listbox__option-icon\">\n\t\t\t\t\t\t\t{optionData.icon && sizeOptionIcon(optionData.icon)}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<span className=\"slds-media__body\">\n\t\t\t\t\t\t\t{renderLabel(optionData.label, inputValue)}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</div>\n\t\t\t\t</li>\n\t\t\t);\n\t\t}\n\n\t\tconst disabledProps: {\n\t\t\t'aria-describedby'?: string;\n\t\t\t'aria-disabled'?: boolean;\n\t\t\tstyle?: CSSProperties;\n\t\t} = {};\n\t\tconst tooltipId = `${inputId}-listbox-option-help-${optionData.id}`;\n\t\tif (optionData.disabled && tooltipMenuItemDisabled && active) {\n\t\t\tdisabledProps['aria-describedby'] = tooltipId;\n\t\t}\n\t\tif (optionData.disabled) {\n\t\t\tdisabledProps['aria-disabled'] = true;\n\t\t\tdisabledProps.style = { cursor: 'default' };\n\t\t}\n\n\t\tconst labelString =\n\t\t\ttypeof optionData.label === 'string' ? optionData.label : undefined;\n\n\t\tconst menuItem: Record<string, ReactNode> = {\n\t\t\t'icon-title-subtitle': (\n\t\t\t\t// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/interactive-supports-focus -- focus stays on the combobox input, which drives options through aria-activedescendant\n\t\t\t\t<span\n\t\t\t\t\taria-selected={active}\n\t\t\t\t\t{...disabledProps}\n\t\t\t\t\tid={`${inputId}-listbox-option-${optionData.id}`}\n\t\t\t\t\tkey={`menu-subtitle-${optionData.id}`}\n\t\t\t\t\tclassName={classNames(\n\t\t\t\t\t\t'slds-media slds-listbox__option',\n\t\t\t\t\t\t'slds-listbox__option_entity slds-listbox__option_has-meta',\n\t\t\t\t\t\t{ 'slds-has-focus': active }\n\t\t\t\t\t)}\n\t\t\t\t\tonClick={\n\t\t\t\t\t\toptionData.disabled\n\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t: (event) => {\n\t\t\t\t\t\t\t\t\tonSelect(event, { option: optionData });\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\trole=\"option\"\n\t\t\t\t>\n\t\t\t\t\t{optionData.icon && !renderMenuItem ? (\n\t\t\t\t\t\t<span className=\"slds-media__figure\">\n\t\t\t\t\t\t\t{optionData.icon && sizeOptionIcon(optionData.icon)}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) : null}\n\t\t\t\t\t{renderMenuItem ? (\n\t\t\t\t\t\trenderMenuItem({ isSelected: selected, option: optionData })\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<span className=\"slds-media__body\">\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tclassName={classNames(\n\t\t\t\t\t\t\t\t\t'slds-listbox__option-text',\n\t\t\t\t\t\t\t\t\t'slds-listbox__option-text_entity',\n\t\t\t\t\t\t\t\t\t{ 'slds-disabled-text': optionData.disabled }\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\ttitle={labelString}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{setBold(labelString, inputValue)}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tclassName={classNames(\n\t\t\t\t\t\t\t\t\t'slds-listbox__option-meta slds-listbox__option-meta_entity',\n\t\t\t\t\t\t\t\t\t{ 'slds-disabled-text': optionData.disabled }\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\ttitle={optionData.subTitle}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{setBold(optionData.subTitle, inputValue)}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t)}\n\t\t\t\t</span>\n\t\t\t),\n\t\t\tcheckbox: (\n\t\t\t\t// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/interactive-supports-focus -- focus stays on the combobox input, which drives options through aria-activedescendant\n\t\t\t\t<span\n\t\t\t\t\taria-selected={active}\n\t\t\t\t\t{...disabledProps}\n\t\t\t\t\tid={`${inputId}-listbox-option-${optionData.id}`}\n\t\t\t\t\tkey={`menu-checkbox-${optionData.id}`}\n\t\t\t\t\tclassName={classNames(\n\t\t\t\t\t\t'slds-media slds-listbox__option',\n\t\t\t\t\t\t' slds-listbox__option_plain slds-media_small slds-media_center',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'slds-has-focus': active,\n\t\t\t\t\t\t\t'slds-is-selected': selected,\n\t\t\t\t\t\t}\n\t\t\t\t\t)}\n\t\t\t\t\tonClick={\n\t\t\t\t\t\toptionData.disabled\n\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t: (event) => {\n\t\t\t\t\t\t\t\t\tonSelect(event, {\n\t\t\t\t\t\t\t\t\t\tselection,\n\t\t\t\t\t\t\t\t\t\toption: optionData,\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\trole=\"option\"\n\t\t\t\t>\n\t\t\t\t\t<span className=\"slds-media__figure\">\n\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\tclassName=\"slds-listbox__icon-selected\"\n\t\t\t\t\t\t\tcategory=\"utility\"\n\t\t\t\t\t\t\tname=\"check\"\n\t\t\t\t\t\t\tsize=\"x-small\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</span>\n\t\t\t\t\t<span className=\"slds-media__body\">\n\t\t\t\t\t\t{renderMenuItem ? (\n\t\t\t\t\t\t\trenderMenuItem({ isSelected: selected, option: optionData })\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tclassName={classNames('slds-truncate', {\n\t\t\t\t\t\t\t\t\t'slds-disabled-text': optionData.disabled,\n\t\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\t\ttitle={labelString}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{selected ? (\n\t\t\t\t\t\t\t\t\t<span className=\"slds-assistive-text\">\n\t\t\t\t\t\t\t\t\t\t{assistiveText.optionSelectedInMenu}\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t) : null}{' '}\n\t\t\t\t\t\t\t\t{optionData.type === 'deselect' ? (\n\t\t\t\t\t\t\t\t\t<em>{labelString}</em>\n\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\tlabelString\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</span>\n\t\t\t\t</span>\n\t\t\t),\n\t\t};\n\n\t\tlet item: ReactNode;\n\t\tif (optionData.disabled && tooltipMenuItemDisabled) {\n\t\t\tconst tooltipPropsFromElement = tooltipMenuItemDisabled.props as {\n\t\t\t\tcontent?: ReactNode;\n\t\t\t\t[key: string]: unknown;\n\t\t\t};\n\t\t\tconst { content, ...userDefinedTooltipProps } = tooltipPropsFromElement;\n\t\t\tconst tooltipProps: Record<string, unknown> = {\n\t\t\t\talign: 'top',\n\t\t\t\tcontent: optionData.tooltipContent || content,\n\t\t\t\tid: tooltipId,\n\t\t\t\tposition: 'absolute',\n\t\t\t\tsilenceTriggerTabbableWarning: true,\n\t\t\t\ttriggerStyle: { width: '100%' },\n\t\t\t\t...userDefinedTooltipProps,\n\t\t\t};\n\t\t\tif (active && tooltipProps.isOpen === undefined) {\n\t\t\t\ttooltipProps.isOpen = true;\n\t\t\t}\n\t\t\ttooltipProps.trigger = menuItem[variant];\n\t\t\titem = React.cloneElement(tooltipMenuItemDisabled, tooltipProps);\n\t\t} else {\n\t\t\titem = menuItem[variant];\n\t\t}\n\n\t\treturn (\n\t\t\t<li\n\t\t\t\tclassName=\"slds-listbox__item\"\n\t\t\t\tkey={`menu-option-${optionData.id}`}\n\t\t\t\trole=\"presentation\"\n\t\t\t>\n\t\t\t\t{item}\n\t\t\t</li>\n\t\t);\n\t});\n\n\treturn (\n\t\t<ul\n\t\t\tclassName={classNames(\n\t\t\t\t'slds-listbox slds-listbox_vertical slds-dropdown slds-dropdown_fluid',\n\t\t\t\t{\n\t\t\t\t\t'slds-dropdown_length-with-icon-5': itemVisibleLength === 5,\n\t\t\t\t\t'slds-dropdown_length-with-icon-7': itemVisibleLength === 7,\n\t\t\t\t\t'slds-dropdown_length-with-icon-10': itemVisibleLength === 10,\n\t\t\t\t},\n\t\t\t\tclassNameMenu\n\t\t\t)}\n\t\t\tref={menuRef}\n\t\t\trole=\"presentation\"\n\t\t\tstyle={{\n\t\t\t\twidth: inheritWidthOf === 'menu' ? 'auto' : undefined,\n\t\t\t\tmaxWidth: menuMaxWidth,\n\t\t\t\tposition: menuPosition !== 'relative' ? 'relative' : undefined,\n\t\t\t}}\n\t\t>\n\t\t\t{menuOptions.length ? (\n\t\t\t\tmenuOptions\n\t\t\t) : (\n\t\t\t\t<li\n\t\t\t\t\tclassName=\"slds-listbox__item slds-listbox__status\"\n\t\t\t\t\trole=\"status\"\n\t\t\t\t\taria-live=\"polite\"\n\t\t\t\t>\n\t\t\t\t\t<span className=\"slds-m-left_x-large slds-p-vertical_medium\">\n\t\t\t\t\t\t{labels.noOptionsFound}\n\t\t\t\t\t</span>\n\t\t\t\t</li>\n\t\t\t)}\n\t\t\t{hasMenuSpinner && (\n\t\t\t\t<li role=\"presentation\" className=\"slds-listbox__item\">\n\t\t\t\t\t<div className=\"slds-align_absolute-center slds-p-top_medium\">\n\t\t\t\t\t\t<Spinner\n\t\t\t\t\t\t\tassistiveText={{ label: assistiveText.loadingMenuItems }}\n\t\t\t\t\t\t\thasContainer={false}\n\t\t\t\t\t\t\tplacement=\"inline\"\n\t\t\t\t\t\t\tsize=\"x-small\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</li>\n\t\t\t)}\n\t\t</ul>\n\t);\n};\n\nMenu.displayName = 'Menu';\n\nexport default Menu;\n"],"mappings":"8QAiFA,IAAM,GAAW,EAA2B,IAAkC,CAC7E,GAAI,CAAC,GAAS,EAAM,SAAW,GAAK,CAAC,GAAc,EAAW,SAAW,EACxE,OAAO,EAER,IAAM,EAAW,EAAM,YAAY,CAAC,CAAC,QAAQ,EAAW,YAAY,CAAC,EAarE,OAZI,EAAW,IAEb,EAAA,EAAA,KAAA,CAAC,EAAA,QAAM,SAAP,CAAA,SAAA,CACE,EAAM,MAAM,EAAG,CAAQ,GACxB,EAAA,EAAA,IAAA,CAAC,OAAD,CAAiB,UAAU,uBAAwB,SAAA,GAAG,EAAM,MAC3D,EACA,EAAW,EAAW,MACvB,GAAU,EAHA,MAGA,EACT,EAAM,MAAM,EAAW,EAAW,MAAM,CAC1B,CAAA,CAAA,EAGX,CACR,EAEM,GACL,EACA,IAEI,GAAa,MAAQ,OAAO,GAAc,SACtC,EAED,EAAU,CAAU,EAQtB,EAAkB,GACvB,EAAK,MAAM,MAAQ,KAAc,EAAA,QAAM,aAAa,EAAM,CAAE,KAAM,OAAQ,CAAC,EAAjD,EAMd,EAAkB,GAC9B,OAAO,GAAQ,OAAU,SAAW,EAAO,MAAQ,IAAA,GAE9C,GAA6B,CAClC,eACA,oBAAoB,GACpB,gBAAgB,CAAC,EACjB,yBAC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N,MAAO,IAAmB,OAAS,OAAS,IAAA,GAC5C,SAAU,EACV,SAAU,IAAiB,WAA0B,IAAA,GAAb,UACzC,EAhBD,SAAA,CAkBE,EAAY,OACZ,GAEA,EAAA,EAAA,IAAA,CAAC,KAAD,CACC,UAAU,0CACV,KAAK,SACL,YAAU,SAEV,UAAA,EAAA,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,6CACd,SAAA,EAAO,cACH,CAAA,CACH,CAAA,EAEJ,IACA,EAAA,EAAA,IAAA,CAAC,KAAD,CAAI,KAAK,eAAe,UAAU,qBACjC,UAAA,EAAA,EAAA,IAAA,CAAC,MAAD,CAAK,UAAU,+CACd,UAAA,EAAA,EAAA,IAAA,CAAC,EAAA,QAAD,CACC,cAAe,CAAE,MAAO,EAAc,gBAAiB,EACvD,aAAc,GACd,UAAU,SACV,KAAK,SACL,CAAA,CACG,CAAA,CACF,CAAA,CAEF,GAEN,EAEA,EAAK,YAAc"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../utilities/constants.cjs"),n=require("../icon-settings/index.cjs"),r=require("../../utilities/key-code.cjs"),i=require("../../utilities/event.cjs"),a=require("../utilities/dialog/index.cjs"),ee=require("../../utilities/
|
|
1
|
+
const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../utilities/constants.cjs"),n=require("../icon-settings/index.cjs"),r=require("../../utilities/key-code.cjs"),i=require("../../utilities/event.cjs"),a=require("../utilities/dialog/index.cjs"),ee=require("../../utilities/hooks/use-controllable-state.cjs"),te=require("../../utilities/hooks/use-click-outside.cjs"),ne=require("../input/index.cjs"),re=require("../icon/input-icon/index.cjs"),ie=require("./private/calendar-wrapper.cjs"),ae=require("./check-props.cjs"),oe=require("./component.cjs"),o=require("../../utilities/warning/low-priority-warning.cjs");let s=require("react");s=e.__toESM(s,1);let c=require("classnames");c=e.__toESM(c,1);let l=require("react/jsx-runtime"),u=require("lodash.assign");u=e.__toESM(u,1);var se={nextMonth:`Next month`,openCalendar:`Open Calendar`,previousMonth:`Previous month`,year:`Year`},ce={abbreviatedWeekDays:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],label:``,months:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],placeholder:`Pick a Date`,today:`Today`,weekDays:[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`]},le=e=>e?`${e.getMonth()+1}/${e.getDate()}/${e.getFullYear()}`:``,ue=e=>(o.default(!1,`Please use an external library for date parsing and internationalization like MomentJS (https://github.com/moment/moment/) instead of the default parser.`),new Date(e)),d=e=>Object.prototype.toString.call(e)===`[object Date]`,f=e=>e?String(e.getTime()):`null`,p=e=>{let{assistiveText:o={},align:p=`left`,className:m,disabled:h,dateDisabled:de=()=>!1,defaultIsOpen:fe=!1,formatter:g=le,hasError:pe,hasStaticAlignment:me,id:he,input:ge,isOpen:_e,isIsoWeekday:ve,labels:ye={},menuPosition:_=`absolute`,onCalendarFocus:v,onChange:y,onClose:b,onOpen:x,onRequestClose:S,onRequestOpen:C,parser:w=ue,portalMount:T,relativeYearFrom:E=-10,relativeYearTo:D=10,triggerClassName:be,value:xe,required:O,onBlur:k,onFocus:A,onKeyDown:j}=e,M=(0,u.default)({},se,o),N=(0,u.default)({},ce,ye),P=(0,s.useContext)(n.IconSettingsContext),F=(0,s.useRef)(null),I=(0,s.useRef)(null),L=(0,s.useRef)(null),R=(0,s.useId)(),z=xe??null,B=f(z),[V,H]=ee.useControllableState(_e,fe),[U,W]=(0,s.useState)(!1),[G,Se]=(0,s.useState)(()=>({text:g(z),valueKey:B,typedKey:null})),[Ce,we]=(0,s.useState)(!1);G.valueKey!==B&&Se({text:G.typedKey===B?G.text:g(z),valueKey:B,typedKey:null});let Te=G.text;(0,s.useEffect)(()=>{typeof ae.default==`function`&&ae.default(t.DATE_PICKER,e,oe.default)},[]);let K=(0,s.useCallback)(()=>he||R,[he,R]),q=(0,s.useCallback)(()=>!!V,[V]),Ee=(0,s.useCallback)(e=>{let t=w(e);return(!d(t)||isNaN(t.getTime()))&&(t=new Date),t},[w]),J=(0,s.useCallback)((e,t)=>{q()&&(S?.(e,t),H(!1),W(!1),I.current&&I.current.focus())},[S,q,H]),De=(0,s.useCallback)(e=>{J(e,{trigger:`escape`})},[J]),Y=(0,s.useCallback)((e,t)=>{b?.(e,{componentWillUnmount:!!t?.componentWillUnmount})},[b]),Oe=(0,s.useCallback)((e,t)=>{x&&x(e,t),L.current&&U&&L.current.focus()},[x,U]),X=(0,s.useCallback)((e,t,n=!1)=>{n||W(!1),H(!0),C?.(e,t)},[C,H]),ke=(0,s.useCallback)(e=>{W(!0),X(e,{trigger:`icon-click`},!0)},[X]),Ae=(0,s.useCallback)((e,{date:t})=>{J(e,{trigger:`date-select`}),y&&y(e,{date:t,formattedDate:g(t),timezoneOffset:t.getTimezoneOffset()})},[g,J,y]),Z=(0,s.useCallback)(e=>{let t=e.target.value,n=t===``?null:w(t),r=d(n)?n:null;Se(e=>({...e,text:t,typedKey:f(r)})),J(e,{trigger:`input-change`}),y&&y(e,{date:r,formattedDate:t,timezoneOffset:(r??new Date).getTimezoneOffset()})},[J,w,y]),je=(0,s.useCallback)(e=>{e.key&&!e.shiftKey&&(e.key===r.default.DOWN||e.key===r.default.UP)&&(i.default.trapEvent(e),q()||X(e,{trigger:`keyboard`})),(e.key===r.default.ESCAPE||e.key===r.default.ENTER)&&(i.default.trapEvent(e),J(e,{trigger:e.key===r.default.ESCAPE?`escape`:`enter`})),j&&j(e,{})},[q,X,J,j]),Me=(0,s.useCallback)(e=>{J(e,{trigger:`click-outside`})},[J]);te.default(F,Me,{enabled:q(),ignoreClass:`ignore-react-onclickoutside`});let Q=(0,s.useCallback)(e=>{I.current=e,Ce||we(!0)},[Ce]),$=(0,s.useCallback)(()=>{let e;if(z){let t=g(z);e=t?Ee(t):z}else e=new Date;return(0,l.jsx)(ie.default,{abbreviatedWeekDayLabels:N.abbreviatedWeekDays,assistiveTextNextMonth:M.nextMonth,assistiveTextPreviousMonth:M.previousMonth,assistiveTextYear:M.year,canFocusCalendar:U,id:K(),isIsoWeekday:ve,monthLabels:N.months,onCalendarFocus:v,dateDisabled:de,onRequestClose:De,onSelectDate:Ae,relativeYearFrom:E,relativeYearTo:D,selectedDate:e,selectedDateRef:e=>{L.current=e},todayLabel:N.today,weekDayLabels:N.weekDays})},[z,g,Ee,N,M,U,K,ve,v,de,De,Ae,E,D]),Ne=(0,s.useCallback)(()=>{let e=_===`relative`?{}:{transform:`none`};if(h||!q())return null;let t={align:`bottom ${p}`,contentsClassName:(0,c.default)(`slds-datepicker slds-dropdown`,{"slds-dropdown_right":_===`relative`&&p===`right`,"slds-dropdown_left":_===`relative`&&p===`left`},m),context:P,hasStaticAlignment:me,style:e,onClose:Y,onOpen:Oe,onRequestTargetElement:()=>I.current,position:_,portalMount:T};return(0,l.jsx)(a.default,{...t,children:$()})},[_,h,q,p,m,P,me,Y,Oe,T,$]),Pe=(0,s.useCallback)(()=>{let e={iconRight:(0,l.jsx)(re.default,{assistiveText:{icon:M.openCalendar},"aria-haspopup":!0,"aria-expanded":q(),category:`utility`,name:`event`,onClick:e=>{ke(e)},type:`button`}),inputRef:e=>{Q(e)},id:K(),onChange:Z,onClick:e=>{X(e,{trigger:`input-click`})},onKeyDown:je,value:Te},t={disabled:h,label:N.label,onBlur:k,onFocus:A,placeholder:N.placeholder,required:O},n=ge?.props||{},r=n,i=r.onChange,a=r.inputRef;return{...e,...t,...n,onChange:(e,...t)=>{i?.(e,...t),Z(e)},inputRef:e=>{typeof a==`function`?a(e):a&&(a.current=e),Q(e)}}},[M.openCalendar,q,ke,Q,K,Z,X,je,Te,h,N.label,N.placeholder,k,A,O,ge])(),Fe=(0,l.jsx)(ne.default,{...Pe});return(0,l.jsxs)(`div`,{ref:F,className:(0,c.default)(`slds-dropdown-trigger`,`slds-dropdown-trigger_click`,`ignore-react-onclickoutside`,{"slds-has-error":pe,"slds-is-open":q()},be),children:[Fe,Ne()]})};p.displayName=t.DATE_PICKER,exports.default=p;
|
|
2
2
|
//# sourceMappingURL=date-picker.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-picker.cjs","names":[],"sources":["../../../../components/date-picker/date-picker.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\tuseState,\n\tuseRef,\n\tuseCallback,\n\tuseEffect,\n\tuseContext,\n\ttype ReactNode,\n\ttype ReactElement,\n\ttype KeyboardEvent,\n\ttype ChangeEvent,\n} from 'react';\n\nimport assign from 'lodash.assign';\nimport classNames from 'classnames';\n\nimport Dialog from '../utilities/dialog';\nimport CalendarWrapper from './private/calendar-wrapper';\nimport InputIcon from '../icon/input-icon';\nimport Input from '../input';\n\nimport checkProps from './check-props';\nimport componentDoc from './component.json';\n\nimport EventUtil from '../../utilities/event';\nimport KEYS from '../../utilities/key-code';\nimport lowPriorityWarning from '../../utilities/warning/low-priority-warning';\n\nimport { DATE_PICKER } from '../../utilities/constants';\nimport generateId from '../../utilities/generate-id';\nimport { IconSettingsContext } from '../icon-settings';\nimport { useClickOutside, useControllableState } from '../../utilities/hooks';\n\n// ===== Types =====\n\nexport interface DatePickerAssistiveText {\n\tnextMonth?: string;\n\topenCalendar?: string;\n\tpreviousMonth?: string;\n\tyear?: string;\n}\n\nexport interface DatePickerLabels {\n\tabbreviatedWeekDays?: string[];\n\tlabel?: string;\n\tmonths?: string[];\n\tplaceholder?: string;\n\ttoday?: string;\n\tweekDays?: string[];\n}\n\nexport interface DatePickerChangeData {\n\t/**\n\t * The requested date: the selected calendar date, or the result of `parser` for typed text.\n\t * `null` when the input is cleared.\n\t */\n\tdate: Date | null;\n\t/** The formatted date, or the typed text */\n\tformattedDate: string;\n\t/** `date.getTimezoneOffset()`, or the current offset when `date` is `null` */\n\ttimezoneOffset: number;\n}\n\n/**\n * What caused the DatePicker to request opening its calendar.\n * - `input-click`: the input was clicked\n * - `icon-click`: the calendar icon button was clicked\n * - `keyboard`: Down or Up arrow was pressed in the input\n */\nexport type DatePickerRequestOpenTrigger =\n\t'input-click' | 'icon-click' | 'keyboard';\n\n/** Data passed to `onRequestOpen` */\nexport interface DatePickerRequestOpenData {\n\t/** What caused the open request */\n\ttrigger: DatePickerRequestOpenTrigger;\n}\n\n/**\n * What caused the DatePicker to request closing its calendar.\n * - `date-select`: a date was selected in the calendar (click, Space, or Enter)\n * - `escape`: Escape was pressed in the input or in the calendar\n * - `enter`: Enter was pressed in the input\n * - `click-outside`: a mousedown/touchstart happened outside the DatePicker\n * - `input-change`: the user typed in the input\n */\nexport type DatePickerRequestCloseTrigger =\n\t'date-select' | 'escape' | 'enter' | 'click-outside' | 'input-change';\n\n/** Data passed to `onRequestClose` */\nexport interface DatePickerRequestCloseData {\n\t/** What caused the close request */\n\ttrigger: DatePickerRequestCloseTrigger;\n}\n\n/** Data passed to `onClose` */\n/** Which way keyboard focus left the calendar grid: past the last day, or before the first. */\nexport type DatePickerFocusDirection = 'next' | 'previous';\n\nexport interface DatePickerCloseData {\n\t/**\n\t * `true` when the close was reported by the calendar dialog unmounting. The calendar\n\t * dialog is unmounted whenever the DatePicker closes, so this is currently always `true`.\n\t */\n\tcomponentWillUnmount: boolean;\n}\n\nexport type DatePickerChangeHandler = (\n\tevent: React.SyntheticEvent,\n\tdata: DatePickerChangeData\n) => void;\n\n/**\n * `onChange` is required unless the date picker is `disabled`: DatePicker is\n * controlled, so without it picking a date does nothing.\n */\nexport type DatePickerChangeProps =\n\t| {\n\t\t\t/**\n\t\t\t * Called when the user selects a date in the calendar or types in the input. `value` is\n\t\t\t * controlled: set it to `data.date` here (or keep the old value to reject the change).\n\t\t\t * Clearing the input reports `date: null`. Required unless `disabled` is set.\n\t\t\t */\n\t\t\tonChange: DatePickerChangeHandler;\n\t }\n\t| { disabled: true; onChange?: DatePickerChangeHandler };\n\ninterface DatePickerBaseProps {\n\t/** Assistive text for accessibility */\n\tassistiveText?: DatePickerAssistiveText;\n\t/** Alignment of dropdown */\n\talign?: 'left' | 'right';\n\t/** CSS classes for datepicker */\n\tclassName?: string | string[] | Record<string, boolean>;\n\t/** Whether component is disabled */\n\tdisabled?: boolean;\n\t/** Function to determine if a date should be disabled. Receives `{ date }`. */\n\tdateDisabled?: (data: { date: Date }) => boolean;\n\t/** Date formatting function. Called with `null` when there is no date. */\n\tformatter?: (date: Date | null | undefined) => string;\n\t/** Whether to show error state */\n\thasError?: boolean;\n\t/** Prevent dropdown position flipping */\n\thasStaticAlignment?: boolean;\n\t/** HTML id */\n\tid?: string;\n\t/** Custom input component */\n\tinput?: ReactElement;\n\t/**\n\t * Initial open state of the calendar when `isOpen` is not set (uncontrolled). Defaults to `false`.\n\t */\n\tdefaultIsOpen?: boolean;\n\t/**\n\t * Whether the calendar is open. When set, the calendar is controlled: it never opens or closes\n\t * itself, so update it from `onRequestOpen` and `onRequestClose`. When `undefined`, the calendar\n\t * manages its own open state (see `defaultIsOpen`).\n\t */\n\tisOpen?: boolean;\n\t/** Make Monday first day of week */\n\tisIsoWeekday?: boolean;\n\t/** Text labels for internationalization */\n\tlabels?: DatePickerLabels;\n\t/** Menu position strategy */\n\tmenuPosition?: 'absolute' | 'overflowBoundaryElement' | 'relative';\n\t/**\n\t * Called when keyboard focus moves to another day. `event` is the keyboard event, or\n\t * `undefined` when focus moves because a new month rendered.\n\t */\n\tonCalendarFocus?: (\n\t\tevent: React.SyntheticEvent | undefined,\n\t\tdata: {\n\t\t\tdate?: Date;\n\t\t\tref?: HTMLElement;\n\t\t\tdirection?: DatePickerFocusDirection;\n\t\t}\n\t) => void;\n\t/**\n\t * Called after the calendar has closed. `event` is `undefined` because the close\n\t * is reported when the calendar dialog unmounts, not by a user event.\n\t */\n\tonClose?: (\n\t\tevent: React.SyntheticEvent | undefined,\n\t\tdata: DatePickerCloseData\n\t) => void;\n\t/** Called when calendar opens */\n\tonOpen?: (\n\t\tevent: React.SyntheticEvent | undefined,\n\t\tdata: { portal?: HTMLElement }\n\t) => void;\n\t/**\n\t * Called when the calendar requests to close. Only fires while the calendar is open.\n\t * `event` is the triggering React event; for `trigger: 'click-outside'` it is the\n\t * native `mousedown`/`touchstart` event from the document listener. It is typed as\n\t * possibly `undefined` because the internal calendar's close request has an optional event.\n\t * When `isOpen` is `undefined` the calendar also closes itself; when `isOpen` is set,\n\t * set it to `false` here.\n\t */\n\tonRequestClose?: (\n\t\tevent: React.SyntheticEvent | MouseEvent | TouchEvent | undefined,\n\t\tdata: DatePickerRequestCloseData\n\t) => void;\n\t/**\n\t * Called when the calendar requests to open (input click, icon click, or Down/Up arrow).\n\t * When `isOpen` is `undefined` the calendar also opens itself; when `isOpen` is set, set it\n\t * to `true` here. Not fired by the arrow keys while already open.\n\t */\n\tonRequestOpen?: (\n\t\tevent: React.MouseEvent | KeyboardEvent,\n\t\tdata: DatePickerRequestOpenData\n\t) => void;\n\t/** Date parsing function */\n\tparser?: (str: string) => Date;\n\t/** Portal mount function */\n\tportalMount?: (element: ReactNode, container: HTMLElement) => void;\n\t/** Years before current year in dropdown */\n\trelativeYearFrom?: number;\n\t/** Years after current year in dropdown */\n\trelativeYearTo?: number;\n\t/** CSS classes for trigger wrapper */\n\ttriggerClassName?: string | string[] | Record<string, boolean>;\n\t/**\n\t * Selected date, or `null` for no date. Required and controlled: the input and calendar\n\t * always reflect it, and the input's typed text is reset from it whenever it changes.\n\t * Update it from `onChange`. (`undefined` is treated as `null` and warns in development.)\n\t */\n\tvalue: Date | null;\n\t/** Whether field is required */\n\trequired?: boolean;\n\t/** Blur handler */\n\tonBlur?: (event: React.FocusEvent) => void;\n\t/** Focus handler */\n\tonFocus?: (event: React.FocusEvent) => void;\n\t/** Keydown handler */\n\tonKeyDown?: (event: KeyboardEvent, data: Record<string, unknown>) => void;\n}\n\nexport type DatePickerProps = DatePickerBaseProps & DatePickerChangeProps;\n\n// ===== Default Props =====\n\nconst defaultAssistiveText: Required<DatePickerAssistiveText> = {\n\tnextMonth: 'Next month',\n\topenCalendar: 'Open Calendar',\n\tpreviousMonth: 'Previous month',\n\tyear: 'Year',\n};\n\nconst defaultLabels: Required<DatePickerLabels> = {\n\tabbreviatedWeekDays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],\n\tlabel: '',\n\tmonths: [\n\t\t'January',\n\t\t'February',\n\t\t'March',\n\t\t'April',\n\t\t'May',\n\t\t'June',\n\t\t'July',\n\t\t'August',\n\t\t'September',\n\t\t'October',\n\t\t'November',\n\t\t'December',\n\t],\n\tplaceholder: 'Pick a Date',\n\ttoday: 'Today',\n\tweekDays: [\n\t\t'Sunday',\n\t\t'Monday',\n\t\t'Tuesday',\n\t\t'Wednesday',\n\t\t'Thursday',\n\t\t'Friday',\n\t\t'Saturday',\n\t],\n};\n\nconst defaultFormatter = (date: Date | null | undefined): string => {\n\treturn date\n\t\t? `${date.getMonth() + 1}/${date.getDate()}/${date.getFullYear()}`\n\t\t: '';\n};\n\nconst defaultParser = (str: string): Date => {\n\tlowPriorityWarning(\n\t\tfalse,\n\t\t`Please use an external library for date parsing and internationalization like MomentJS (https://github.com/moment/moment/) instead of the default parser.`\n\t);\n\treturn new Date(str);\n};\n\nconst isDate = (date: unknown): date is Date =>\n\tObject.prototype.toString.call(date) === '[object Date]';\n\n/**\n * Stable identity of a `value`, so a parent passing `new Date(...)` on every render does not\n * re-sync the typed text. Invalid dates share one key.\n */\nconst getDateKey = (date: Date | null): string =>\n\tdate ? String(date.getTime()) : 'null';\n\n// ===== Component =====\n\nconst Datepicker: React.FC<DatePickerProps> = (props) => {\n\tconst {\n\t\tassistiveText: assistiveTextProp = {},\n\t\talign = 'left',\n\t\tclassName,\n\t\tdisabled,\n\t\tdateDisabled = () => false,\n\t\tdefaultIsOpen = false,\n\t\tformatter = defaultFormatter,\n\t\thasError,\n\t\thasStaticAlignment,\n\t\tid: idProp,\n\t\tinput,\n\t\tisOpen: isOpenProp,\n\t\tisIsoWeekday,\n\t\tlabels: labelsProp = {},\n\t\tmenuPosition = 'absolute',\n\t\tonCalendarFocus,\n\t\tonChange,\n\t\tonClose,\n\t\tonOpen,\n\t\tonRequestClose,\n\t\tonRequestOpen,\n\t\tparser = defaultParser,\n\t\tportalMount,\n\t\trelativeYearFrom = -10,\n\t\trelativeYearTo = 10,\n\t\ttriggerClassName,\n\t\tvalue: valueProp,\n\t\t// Deprecated props\n\t\trequired,\n\t\tonBlur,\n\t\tonFocus,\n\t\tonKeyDown,\n\t} = props;\n\n\t// Merge with defaults\n\tconst assistiveText = assign({}, defaultAssistiveText, assistiveTextProp);\n\tconst labels = assign({}, defaultLabels, labelsProp);\n\n\t// Context\n\tconst iconSettingsContext = useContext(IconSettingsContext);\n\n\t// Refs\n\tconst triggerRef = useRef<HTMLDivElement | null>(null);\n\tconst inputRef = useRef<HTMLInputElement | null>(null);\n\tconst selectedDateCellRef = useRef<HTMLElement | null>(null);\n\tconst generatedId = useRef(generateId());\n\n\t// `value` is controlled data; `undefined` (warned in `checkProps`) means no date\n\tconst value = valueProp ?? null;\n\tconst valueKey = getDateKey(value);\n\n\t// State\n\t// The calendar's open state is ephemeral UI: controlled when `isOpen` is set\n\tconst [isOpen, setIsOpen] = useControllableState(isOpenProp, defaultIsOpen);\n\tconst [isOpenFromIcon, setIsOpenFromIcon] = useState(false);\n\t// The input's text is a buffer so it can hold partial input. `valueKey` is the `value` it was\n\t// last synced from, and `typedKey` the date reported for the typed text.\n\tconst [inputBuffer, setInputBuffer] = useState<{\n\t\ttext: string;\n\t\tvalueKey: string;\n\t\ttypedKey: string | null;\n\t}>(() => ({ text: formatter(value), valueKey, typedKey: null }));\n\tconst [inputRendered, setInputRendered] = useState(false);\n\n\t// Re-sync the typed text whenever `value` changes, unless the change is the parent accepting\n\t// the date that was just typed (so the user's text is not reformatted mid-typing)\n\tif (inputBuffer.valueKey !== valueKey) {\n\t\tsetInputBuffer({\n\t\t\ttext:\n\t\t\t\tinputBuffer.typedKey === valueKey ? inputBuffer.text : formatter(value),\n\t\t\tvalueKey,\n\t\t\ttypedKey: null,\n\t\t});\n\t}\n\tconst inputValue = inputBuffer.text;\n\n\t// Check props on mount (only in development)\n\tuseEffect(() => {\n\t\tif (typeof checkProps === 'function') {\n\t\t\tcheckProps(\n\t\t\t\tDATE_PICKER,\n\t\t\t\tprops as unknown as Record<string, unknown>,\n\t\t\t\tcomponentDoc\n\t\t\t);\n\t\t}\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, []);\n\n\t// Derived state\n\tconst getId = useCallback(() => idProp || generatedId.current, [idProp]);\n\n\tconst getIsOpen = useCallback(() => !!isOpen, [isOpen]);\n\n\tconst parseDate = useCallback(\n\t\t(dateString: string): Date => {\n\t\t\tlet parsedDate = parser(dateString);\n\t\t\tif (!isDate(parsedDate) || isNaN(parsedDate.getTime())) {\n\t\t\t\tparsedDate = new Date();\n\t\t\t}\n\t\t\treturn parsedDate;\n\t\t},\n\t\t[parser]\n\t);\n\n\t// ===== Event Handlers =====\n\n\tconst handleRequestClose = useCallback(\n\t\t(\n\t\t\tevent: React.SyntheticEvent | MouseEvent | TouchEvent | undefined,\n\t\t\tdata: DatePickerRequestCloseData\n\t\t) => {\n\t\t\t// Only request a close while open, so `onRequestClose` never fires when\n\t\t\t// the calendar is already closed (e.g. Escape in a closed input).\n\t\t\tif (!getIsOpen()) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tonRequestClose?.(event, data);\n\n\t\t\t// No-op when `isOpen` is controlled: the parent decides\n\t\t\tsetIsOpen(false);\n\t\t\tsetIsOpenFromIcon(false);\n\n\t\t\tif (inputRef.current) {\n\t\t\t\tinputRef.current.focus();\n\t\t\t}\n\t\t},\n\t\t[onRequestClose, getIsOpen, setIsOpen]\n\t);\n\n\tconst handleCalendarRequestClose = useCallback(\n\t\t(event?: React.SyntheticEvent) => {\n\t\t\t// The calendar's only close request is Escape (see `CalendarWrapper#handleKeyDown`)\n\t\t\thandleRequestClose(event, { trigger: 'escape' });\n\t\t},\n\t\t[handleRequestClose]\n\t);\n\n\tconst handleClose = useCallback(\n\t\t(\n\t\t\tevent: React.SyntheticEvent | undefined,\n\t\t\tdata?: { componentWillUnmount?: boolean }\n\t\t) => {\n\t\t\tonClose?.(event, {\n\t\t\t\tcomponentWillUnmount: !!data?.componentWillUnmount,\n\t\t\t});\n\t\t},\n\t\t[onClose]\n\t);\n\n\tconst handleOpen = useCallback(\n\t\t(\n\t\t\tevent: React.SyntheticEvent | undefined,\n\t\t\tdata: { portal?: HTMLElement }\n\t\t) => {\n\t\t\tif (onOpen) {\n\t\t\t\tonOpen(event, data);\n\t\t\t}\n\n\t\t\tif (selectedDateCellRef.current && isOpenFromIcon) {\n\t\t\t\tselectedDateCellRef.current.focus();\n\t\t\t}\n\t\t},\n\t\t[onOpen, isOpenFromIcon]\n\t);\n\n\tconst openDialog = useCallback(\n\t\t(\n\t\t\tevent: React.MouseEvent | KeyboardEvent,\n\t\t\tdata: DatePickerRequestOpenData,\n\t\t\tfromIcon = false\n\t\t) => {\n\t\t\tif (!fromIcon) {\n\t\t\t\tsetIsOpenFromIcon(false);\n\t\t\t}\n\n\t\t\t// No-op when `isOpen` is controlled: the parent decides\n\t\t\tsetIsOpen(true);\n\t\t\tonRequestOpen?.(event, data);\n\t\t},\n\t\t[onRequestOpen, setIsOpen]\n\t);\n\n\tconst openDialogFromIcon = useCallback(\n\t\t(event: React.MouseEvent) => {\n\t\t\tsetIsOpenFromIcon(true);\n\t\t\topenDialog(event, { trigger: 'icon-click' }, true);\n\t\t},\n\t\t[openDialog]\n\t);\n\n\tconst handleCalendarChange = useCallback(\n\t\t(event: React.SyntheticEvent, { date }: { date: Date }) => {\n\t\t\thandleRequestClose(event, { trigger: 'date-select' });\n\n\t\t\tif (onChange) {\n\t\t\t\tonChange(event, {\n\t\t\t\t\tdate,\n\t\t\t\t\tformattedDate: formatter(date),\n\t\t\t\t\ttimezoneOffset: date.getTimezoneOffset(),\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\t[formatter, handleRequestClose, onChange]\n\t);\n\n\tconst handleInputChange = useCallback(\n\t\t(event: ChangeEvent<HTMLInputElement>) => {\n\t\t\tconst text = event.target.value;\n\t\t\t// Clearing the input requests no date. `parser` is typed to return a `Date`, but guard\n\t\t\t// against parsers that return `null` for partial input.\n\t\t\tconst parsedDate = text === '' ? null : parser(text);\n\t\t\tconst date = isDate(parsedDate) ? parsedDate : null;\n\n\t\t\tsetInputBuffer((buffer) => ({\n\t\t\t\t...buffer,\n\t\t\t\ttext,\n\t\t\t\ttypedKey: getDateKey(date),\n\t\t\t}));\n\n\t\t\t// Typing closes the calendar, through the same request path as the keyboard and mouse\n\t\t\thandleRequestClose(event, { trigger: 'input-change' });\n\n\t\t\tif (onChange) {\n\t\t\t\tonChange(event, {\n\t\t\t\t\tdate,\n\t\t\t\t\tformattedDate: text,\n\t\t\t\t\ttimezoneOffset: (date ?? new Date()).getTimezoneOffset(),\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\t[handleRequestClose, parser, onChange]\n\t);\n\n\tconst handleKeyDown = useCallback(\n\t\t(event: KeyboardEvent<HTMLInputElement>) => {\n\t\t\t// Don't open if user is selecting text\n\t\t\tif (\n\t\t\t\tevent.key &&\n\t\t\t\t!event.shiftKey &&\n\t\t\t\t(event.key === KEYS.DOWN || event.key === KEYS.UP)\n\t\t\t) {\n\t\t\t\tEventUtil.trapEvent(event);\n\t\t\t\t// Go through the same request path as clicking, so a controlled\n\t\t\t\t// DatePicker hears about keyboard opens via `onRequestOpen`\n\t\t\t\tif (!getIsOpen()) {\n\t\t\t\t\topenDialog(event, { trigger: 'keyboard' });\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (event.key === KEYS.ESCAPE || event.key === KEYS.ENTER) {\n\t\t\t\tEventUtil.trapEvent(event);\n\t\t\t\thandleRequestClose(event, {\n\t\t\t\t\ttrigger: event.key === KEYS.ESCAPE ? 'escape' : 'enter',\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (onKeyDown) {\n\t\t\t\tonKeyDown(event, {});\n\t\t\t}\n\t\t},\n\t\t[getIsOpen, openDialog, handleRequestClose, onKeyDown]\n\t);\n\n\tconst handleClickOutside = useCallback(\n\t\t(event: MouseEvent | TouchEvent) => {\n\t\t\thandleRequestClose(event, { trigger: 'click-outside' });\n\t\t},\n\t\t[handleRequestClose]\n\t);\n\n\t// Detect clicks outside the trigger/calendar and close the dialog. Anchored\n\t// on the trigger element so this works whether the DatePicker is controlled\n\t// (`onRequestClose` is invoked via `handleRequestClose`) or uncontrolled\n\t// (internal open state is reset). The trigger carries the\n\t// `ignore-react-onclickoutside` class and, in `overflowBoundaryElement`\n\t// mode, so does the portaled calendar, so clicks within the calendar are\n\t// treated as inside.\n\tuseClickOutside(triggerRef, handleClickOutside, {\n\t\tenabled: getIsOpen(),\n\t\tignoreClass: 'ignore-react-onclickoutside',\n\t});\n\n\t// ===== Refs =====\n\n\tconst setInputRefCallback = useCallback(\n\t\t(component: HTMLInputElement | null) => {\n\t\t\tinputRef.current = component;\n\t\t\tif (!inputRendered) {\n\t\t\t\tsetInputRendered(true);\n\t\t\t}\n\t\t},\n\t\t[inputRendered]\n\t);\n\n\t// ===== Render Helpers =====\n\n\tconst getDatePicker = useCallback(() => {\n\t\tlet date: Date;\n\t\tif (value) {\n\t\t\tconst formattedDate = formatter(value);\n\t\t\tdate = formattedDate ? parseDate(formattedDate) : value;\n\t\t} else {\n\t\t\tdate = new Date();\n\t\t}\n\n\t\treturn (\n\t\t\t<CalendarWrapper\n\t\t\t\tabbreviatedWeekDayLabels={labels.abbreviatedWeekDays}\n\t\t\t\tassistiveTextNextMonth={assistiveText.nextMonth}\n\t\t\t\tassistiveTextPreviousMonth={assistiveText.previousMonth}\n\t\t\t\tassistiveTextYear={assistiveText.year}\n\t\t\t\tcanFocusCalendar={isOpenFromIcon}\n\t\t\t\tid={getId()}\n\t\t\t\tisIsoWeekday={isIsoWeekday}\n\t\t\t\tmonthLabels={labels.months}\n\t\t\t\tonCalendarFocus={onCalendarFocus}\n\t\t\t\tdateDisabled={dateDisabled}\n\t\t\t\tonRequestClose={handleCalendarRequestClose}\n\t\t\t\tonSelectDate={handleCalendarChange}\n\t\t\t\trelativeYearFrom={relativeYearFrom}\n\t\t\t\trelativeYearTo={relativeYearTo}\n\t\t\t\tselectedDate={date}\n\t\t\t\tselectedDateRef={(component: HTMLElement | null) => {\n\t\t\t\t\tselectedDateCellRef.current = component;\n\t\t\t\t}}\n\t\t\t\ttodayLabel={labels.today}\n\t\t\t\tweekDayLabels={labels.weekDays}\n\t\t\t/>\n\t\t);\n\t}, [\n\t\tvalue,\n\t\tformatter,\n\t\tparseDate,\n\t\tlabels,\n\t\tassistiveText,\n\t\tisOpenFromIcon,\n\t\tgetId,\n\t\tisIsoWeekday,\n\t\tonCalendarFocus,\n\t\tdateDisabled,\n\t\thandleCalendarRequestClose,\n\t\thandleCalendarChange,\n\t\trelativeYearFrom,\n\t\trelativeYearTo,\n\t]);\n\n\tconst getDialog = useCallback(() => {\n\t\t// SLDS override\n\t\tconst style = menuPosition !== 'relative' ? { transform: 'none' } : {};\n\n\t\tif (disabled || !getIsOpen()) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst dialogProps = {\n\t\t\talign: `bottom ${align}` as const,\n\t\t\tcontentsClassName: classNames(\n\t\t\t\t'slds-datepicker slds-dropdown',\n\t\t\t\t{\n\t\t\t\t\t'slds-dropdown_right':\n\t\t\t\t\t\tmenuPosition === 'relative' && align === 'right',\n\t\t\t\t\t'slds-dropdown_left': menuPosition === 'relative' && align === 'left',\n\t\t\t\t},\n\t\t\t\tclassName\n\t\t\t),\n\t\t\tcontext: iconSettingsContext,\n\t\t\thasStaticAlignment,\n\t\t\tstyle,\n\t\t\tonClose: handleClose,\n\t\t\tonOpen: handleOpen,\n\t\t\tonRequestTargetElement: () => inputRef.current,\n\t\t\tposition: menuPosition,\n\t\t\tportalMount,\n\t\t};\n\n\t\treturn (\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t<Dialog {...(dialogProps as any)}>{getDatePicker()}</Dialog>\n\t\t);\n\t}, [\n\t\tmenuPosition,\n\t\tdisabled,\n\t\tgetIsOpen,\n\t\talign,\n\t\tclassName,\n\t\ticonSettingsContext,\n\t\thasStaticAlignment,\n\t\thandleClose,\n\t\thandleOpen,\n\t\tportalMount,\n\t\tgetDatePicker,\n\t]);\n\n\tconst getInputProps = useCallback(() => {\n\t\tconst defaultInputProps = {\n\t\t\ticonRight: (\n\t\t\t\t<InputIcon\n\t\t\t\t\tassistiveText={{\n\t\t\t\t\t\ticon: assistiveText.openCalendar,\n\t\t\t\t\t}}\n\t\t\t\t\taria-haspopup\n\t\t\t\t\taria-expanded={getIsOpen()}\n\t\t\t\t\tcategory=\"utility\"\n\t\t\t\t\tname=\"event\"\n\t\t\t\t\tonClick={(event: React.MouseEvent) => {\n\t\t\t\t\t\topenDialogFromIcon(event);\n\t\t\t\t\t}}\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t/>\n\t\t\t),\n\t\t\tinputRef: (component: HTMLInputElement | null) => {\n\t\t\t\tsetInputRefCallback(component);\n\t\t\t},\n\t\t\tid: getId(),\n\t\t\tonChange: handleInputChange,\n\t\t\tonClick: (event: React.MouseEvent<HTMLInputElement>) => {\n\t\t\t\topenDialog(event, { trigger: 'input-click' });\n\t\t\t},\n\t\t\tonKeyDown: handleKeyDown,\n\t\t\tvalue: inputValue,\n\t\t};\n\n\t\tconst topLevelDeprecatedComponentProps = {\n\t\t\tdisabled,\n\t\t\tlabel: labels.label,\n\t\t\tonBlur,\n\t\t\tonFocus,\n\t\t\tplaceholder: labels.placeholder,\n\t\t\trequired,\n\t\t};\n\n\t\tconst inputRenderProps = (input?.props || {}) as Record<string, unknown>;\n\n\t\t// The `input` element's props win, except `onChange` and\n\t\t// `inputRef`: the picker needs its own to track typed text and to return focus to the input\n\t\t// on close, so both are called.\n\t\tconst consumerProps = inputRenderProps;\n\t\tconst consumerOnChange = consumerProps.onChange as\n\t\t\t((...args: unknown[]) => void) | undefined;\n\t\tconst consumerInputRef = consumerProps.inputRef as\n\t\t\tReact.Ref<HTMLInputElement> | undefined;\n\n\t\treturn {\n\t\t\t...defaultInputProps,\n\t\t\t...topLevelDeprecatedComponentProps,\n\t\t\t...inputRenderProps,\n\t\t\tonChange: (event: ChangeEvent<HTMLInputElement>, ...rest: unknown[]) => {\n\t\t\t\tconsumerOnChange?.(event, ...rest);\n\t\t\t\thandleInputChange(event);\n\t\t\t},\n\t\t\tinputRef: (component: HTMLInputElement | null) => {\n\t\t\t\tif (typeof consumerInputRef === 'function') {\n\t\t\t\t\tconsumerInputRef(component);\n\t\t\t\t} else if (consumerInputRef) {\n\t\t\t\t\t(\n\t\t\t\t\t\tconsumerInputRef as React.RefObject<HTMLInputElement | null>\n\t\t\t\t\t).current = component;\n\t\t\t\t}\n\t\t\t\tsetInputRefCallback(component);\n\t\t\t},\n\t\t};\n\t}, [\n\t\tassistiveText.openCalendar,\n\t\tgetIsOpen,\n\t\topenDialogFromIcon,\n\t\tsetInputRefCallback,\n\t\tgetId,\n\t\thandleInputChange,\n\t\topenDialog,\n\t\thandleKeyDown,\n\t\tinputValue,\n\t\tdisabled,\n\t\tlabels.label,\n\t\tlabels.placeholder,\n\t\tonBlur,\n\t\tonFocus,\n\t\trequired,\n\t\tinput,\n\t]);\n\n\t// ===== Main Render =====\n\n\tconst inputProps = getInputProps();\n\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tconst inputToRender = <Input {...(inputProps as any)} />;\n\n\treturn (\n\t\t<div\n\t\t\tref={triggerRef}\n\t\t\tclassName={classNames(\n\t\t\t\t'slds-dropdown-trigger',\n\t\t\t\t'slds-dropdown-trigger_click',\n\t\t\t\t'ignore-react-onclickoutside',\n\t\t\t\t{\n\t\t\t\t\t'slds-has-error': hasError,\n\t\t\t\t\t'slds-is-open': getIsOpen(),\n\t\t\t\t},\n\t\t\t\ttriggerClassName\n\t\t\t)}\n\t\t>\n\t\t\t{inputToRender}\n\t\t\t{getDialog()}\n\t\t</div>\n\t);\n};\n\nDatepicker.displayName = DATE_PICKER;\n\nexport default Datepicker;\n"],"mappings":"u0BAkPA,IAAM,GAA0D,CAC/D,UAAW,aACX,aAAc,gBACd,cAAe,iBACf,KAAM,MACP,EAEM,GAA4C,CACjD,oBAAqB,CAAC,MAAO,MAAO,MAAO,MAAO,MAAO,MAAO,KAAK,EACrE,MAAO,GACP,OAAQ,CACP,UACA,WACA,QACA,QACA,MACA,OACA,OACA,SACA,YACA,UACA,WACA,UACD,EACA,YAAa,cACb,MAAO,QACP,SAAU,CACT,SACA,SACA,UACA,YACA,WACA,SACA,UACD,CACD,EAEM,GAAoB,GAClB,EACJ,GAAG,EAAK,SAAS,EAAI,EAAE,GAAG,EAAK,QAAQ,EAAE,GAAG,EAAK,YAAY,IAC7D,GAGE,GAAiB,IACtB,EAAA,QACC,GACA,2JACD,EACO,IAAI,KAAK,CAAG,GAGd,GAAU,GACf,OAAO,UAAU,SAAS,KAAK,CAAI,IAAM,gBAMpC,EAAc,GACnB,EAAO,OAAO,EAAK,QAAQ,CAAC,EAAI,OAI3B,EAAyC,GAAU,CACxD,GAAM,CACL,cAAe,EAAoB,CAAC,EACpC,QAAQ,OACR,YACA,WACA,oBAAqB,GACrB,iBAAgB,GAChB,YAAY,GACZ,YACA,sBACA,GAAI,GACJ,SACA,OAAQ,GACR,eACA,OAAQ,GAAa,CAAC,EACtB,eAAe,WACf,kBACA,WACA,UACA,SACA,iBACA,gBACA,SAAS,GACT,cACA,mBAAmB,IACnB,iBAAiB,GACjB,oBACA,MAAO,GAEP,WACA,SACA,UACA,aACG,EAGE,GAAA,EAAgB,EAAA,QAAA,CAAO,CAAC,EAAG,GAAsB,CAAiB,EAClE,GAAA,EAAS,EAAA,QAAA,CAAO,CAAC,EAAG,GAAe,EAAU,EAG7C,GAAA,EA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A,EAEF,SAAW,GAAuC,CACjD,EAAoB,CAAS,CAC9B,EACA,GAAI,EAAM,EACV,SAAU,EACV,QAAU,GAA8C,CACvD,EAAW,EAAO,CAAE,QAAS,aAAc,CAAC,CAC7C,EACA,UAAW,GACX,MAAO,EACR,EAEM,EAAmC,CACxC,WACA,MAAO,EAAO,MACd,SACA,UACA,YAAa,EAAO,YACpB,UACD,EAEM,EAAoB,IAAO,OAAS,CAAC,EAKrC,EAAgB,EAChB,EAAmB,EAAc,SAEjC,EAAmB,EAAc,SAGvC,MAAO,CACN,GAAG,EACH,GAAG,EACH,GAAG,EACH,UAAW,EAAsC,GAAG,IAAoB,CACvE,IAAmB,EAAO,GAAG,CAAI,EACjC,EAAkB,CAAK,CACxB,EACA,SAAW,GAAuC,CAC7C,OAAO,GAAqB,WAC/B,EAAiB,CAAS,EAChB,IACV,EAEE,QAAU,GAEb,EAAoB,CAAS,CAC9B,CACD,CACD,EAAG,CACF,EAAc,aACd,EACA,EACA,EACA,EACA,EACA,EACA,GACA,GACA,EACA,EAAO,MACP,EAAO,YACP,EACA,EACA,EACA,EACD,CAImB,CAAA,CAAc,EAG3B,IAAgB,EAAA,EAAA,IAAA,CAAC,GAAA,QAAD,CAAO,GAAK,EAAqB,CAAA,EAEvD,OACC,EAAA,EAAA,KAAA,CAAC,MAAD,CACC,IAAK,EACL,WAAA,EAAW,EAAA,QAAA,CACV,wBACA,8BACA,8BACA,CACC,iBAAkB,GAClB,eAAgB,EAAU,CAC3B,EACA,EACD,EAXD,SAAA,CAaE,GACA,GAAU,CACP,GAEP,EAEA,EAAW,YAAc,EAAA"}
|
|
1
|
+
{"version":3,"file":"date-picker.cjs","names":[],"sources":["../../../../components/date-picker/date-picker.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\tuseId,\n\tuseState,\n\tuseRef,\n\tuseCallback,\n\tuseEffect,\n\tuseContext,\n\ttype ReactNode,\n\ttype ReactElement,\n\ttype KeyboardEvent,\n\ttype ChangeEvent,\n} from 'react';\n\nimport assign from 'lodash.assign';\nimport classNames from 'classnames';\n\nimport Dialog from '../utilities/dialog';\nimport CalendarWrapper from './private/calendar-wrapper';\nimport InputIcon from '../icon/input-icon';\nimport Input from '../input';\n\nimport checkProps from './check-props';\nimport componentDoc from './component.json';\n\nimport EventUtil from '../../utilities/event';\nimport KEYS from '../../utilities/key-code';\nimport lowPriorityWarning from '../../utilities/warning/low-priority-warning';\n\nimport { DATE_PICKER } from '../../utilities/constants';\nimport { IconSettingsContext } from '../icon-settings';\nimport { useClickOutside, useControllableState } from '../../utilities/hooks';\n\n// ===== Types =====\n\nexport interface DatePickerAssistiveText {\n\tnextMonth?: string;\n\topenCalendar?: string;\n\tpreviousMonth?: string;\n\tyear?: string;\n}\n\nexport interface DatePickerLabels {\n\tabbreviatedWeekDays?: string[];\n\tlabel?: string;\n\tmonths?: string[];\n\tplaceholder?: string;\n\ttoday?: string;\n\tweekDays?: string[];\n}\n\nexport interface DatePickerChangeData {\n\t/**\n\t * The requested date: the selected calendar date, or the result of `parser` for typed text.\n\t * `null` when the input is cleared.\n\t */\n\tdate: Date | null;\n\t/** The formatted date, or the typed text */\n\tformattedDate: string;\n\t/** `date.getTimezoneOffset()`, or the current offset when `date` is `null` */\n\ttimezoneOffset: number;\n}\n\n/**\n * What caused the DatePicker to request opening its calendar.\n * - `input-click`: the input was clicked\n * - `icon-click`: the calendar icon button was clicked\n * - `keyboard`: Down or Up arrow was pressed in the input\n */\nexport type DatePickerRequestOpenTrigger =\n\t'input-click' | 'icon-click' | 'keyboard';\n\n/** Data passed to `onRequestOpen` */\nexport interface DatePickerRequestOpenData {\n\t/** What caused the open request */\n\ttrigger: DatePickerRequestOpenTrigger;\n}\n\n/**\n * What caused the DatePicker to request closing its calendar.\n * - `date-select`: a date was selected in the calendar (click, Space, or Enter)\n * - `escape`: Escape was pressed in the input or in the calendar\n * - `enter`: Enter was pressed in the input\n * - `click-outside`: a mousedown/touchstart happened outside the DatePicker\n * - `input-change`: the user typed in the input\n */\nexport type DatePickerRequestCloseTrigger =\n\t'date-select' | 'escape' | 'enter' | 'click-outside' | 'input-change';\n\n/** Data passed to `onRequestClose` */\nexport interface DatePickerRequestCloseData {\n\t/** What caused the close request */\n\ttrigger: DatePickerRequestCloseTrigger;\n}\n\n/** Data passed to `onClose` */\n/** Which way keyboard focus left the calendar grid: past the last day, or before the first. */\nexport type DatePickerFocusDirection = 'next' | 'previous';\n\nexport interface DatePickerCloseData {\n\t/**\n\t * `true` when the close was reported by the calendar dialog unmounting. The calendar\n\t * dialog is unmounted whenever the DatePicker closes, so this is currently always `true`.\n\t */\n\tcomponentWillUnmount: boolean;\n}\n\nexport type DatePickerChangeHandler = (\n\tevent: React.SyntheticEvent,\n\tdata: DatePickerChangeData\n) => void;\n\n/**\n * `onChange` is required unless the date picker is `disabled`: DatePicker is\n * controlled, so without it picking a date does nothing.\n */\nexport type DatePickerChangeProps =\n\t| {\n\t\t\t/**\n\t\t\t * Called when the user selects a date in the calendar or types in the input. `value` is\n\t\t\t * controlled: set it to `data.date` here (or keep the old value to reject the change).\n\t\t\t * Clearing the input reports `date: null`. Required unless `disabled` is set.\n\t\t\t */\n\t\t\tonChange: DatePickerChangeHandler;\n\t }\n\t| { disabled: true; onChange?: DatePickerChangeHandler };\n\ninterface DatePickerBaseProps {\n\t/** Assistive text for accessibility */\n\tassistiveText?: DatePickerAssistiveText;\n\t/** Alignment of dropdown */\n\talign?: 'left' | 'right';\n\t/** CSS classes for datepicker */\n\tclassName?: string | string[] | Record<string, boolean>;\n\t/** Whether component is disabled */\n\tdisabled?: boolean;\n\t/** Function to determine if a date should be disabled. Receives `{ date }`. */\n\tdateDisabled?: (data: { date: Date }) => boolean;\n\t/** Date formatting function. Called with `null` when there is no date. */\n\tformatter?: (date: Date | null | undefined) => string;\n\t/** Whether to show error state */\n\thasError?: boolean;\n\t/** Prevent dropdown position flipping */\n\thasStaticAlignment?: boolean;\n\t/** HTML id */\n\tid?: string;\n\t/** Custom input component */\n\tinput?: ReactElement;\n\t/**\n\t * Initial open state of the calendar when `isOpen` is not set (uncontrolled). Defaults to `false`.\n\t */\n\tdefaultIsOpen?: boolean;\n\t/**\n\t * Whether the calendar is open. When set, the calendar is controlled: it never opens or closes\n\t * itself, so update it from `onRequestOpen` and `onRequestClose`. When `undefined`, the calendar\n\t * manages its own open state (see `defaultIsOpen`).\n\t */\n\tisOpen?: boolean;\n\t/** Make Monday first day of week */\n\tisIsoWeekday?: boolean;\n\t/** Text labels for internationalization */\n\tlabels?: DatePickerLabels;\n\t/** Menu position strategy */\n\tmenuPosition?: 'absolute' | 'overflowBoundaryElement' | 'relative';\n\t/**\n\t * Called when keyboard focus moves to another day. `event` is the keyboard event, or\n\t * `undefined` when focus moves because a new month rendered.\n\t */\n\tonCalendarFocus?: (\n\t\tevent: React.SyntheticEvent | undefined,\n\t\tdata: {\n\t\t\tdate?: Date;\n\t\t\tref?: HTMLElement;\n\t\t\tdirection?: DatePickerFocusDirection;\n\t\t}\n\t) => void;\n\t/**\n\t * Called after the calendar has closed. `event` is `undefined` because the close\n\t * is reported when the calendar dialog unmounts, not by a user event.\n\t */\n\tonClose?: (\n\t\tevent: React.SyntheticEvent | undefined,\n\t\tdata: DatePickerCloseData\n\t) => void;\n\t/** Called when calendar opens */\n\tonOpen?: (\n\t\tevent: React.SyntheticEvent | undefined,\n\t\tdata: { portal?: HTMLElement }\n\t) => void;\n\t/**\n\t * Called when the calendar requests to close. Only fires while the calendar is open.\n\t * `event` is the triggering React event; for `trigger: 'click-outside'` it is the\n\t * native `mousedown`/`touchstart` event from the document listener. It is typed as\n\t * possibly `undefined` because the internal calendar's close request has an optional event.\n\t * When `isOpen` is `undefined` the calendar also closes itself; when `isOpen` is set,\n\t * set it to `false` here.\n\t */\n\tonRequestClose?: (\n\t\tevent: React.SyntheticEvent | MouseEvent | TouchEvent | undefined,\n\t\tdata: DatePickerRequestCloseData\n\t) => void;\n\t/**\n\t * Called when the calendar requests to open (input click, icon click, or Down/Up arrow).\n\t * When `isOpen` is `undefined` the calendar also opens itself; when `isOpen` is set, set it\n\t * to `true` here. Not fired by the arrow keys while already open.\n\t */\n\tonRequestOpen?: (\n\t\tevent: React.MouseEvent | KeyboardEvent,\n\t\tdata: DatePickerRequestOpenData\n\t) => void;\n\t/** Date parsing function */\n\tparser?: (str: string) => Date;\n\t/** Portal mount function */\n\tportalMount?: (element: ReactNode, container: HTMLElement) => void;\n\t/** Years before current year in dropdown */\n\trelativeYearFrom?: number;\n\t/** Years after current year in dropdown */\n\trelativeYearTo?: number;\n\t/** CSS classes for trigger wrapper */\n\ttriggerClassName?: string | string[] | Record<string, boolean>;\n\t/**\n\t * Selected date, or `null` for no date. Required and controlled: the input and calendar\n\t * always reflect it, and the input's typed text is reset from it whenever it changes.\n\t * Update it from `onChange`. (`undefined` is treated as `null` and warns in development.)\n\t */\n\tvalue: Date | null;\n\t/** Whether field is required */\n\trequired?: boolean;\n\t/** Blur handler */\n\tonBlur?: (event: React.FocusEvent) => void;\n\t/** Focus handler */\n\tonFocus?: (event: React.FocusEvent) => void;\n\t/** Keydown handler */\n\tonKeyDown?: (event: KeyboardEvent, data: Record<string, unknown>) => void;\n}\n\nexport type DatePickerProps = DatePickerBaseProps & DatePickerChangeProps;\n\n// ===== Default Props =====\n\nconst defaultAssistiveText: Required<DatePickerAssistiveText> = {\n\tnextMonth: 'Next month',\n\topenCalendar: 'Open Calendar',\n\tpreviousMonth: 'Previous month',\n\tyear: 'Year',\n};\n\nconst defaultLabels: Required<DatePickerLabels> = {\n\tabbreviatedWeekDays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],\n\tlabel: '',\n\tmonths: [\n\t\t'January',\n\t\t'February',\n\t\t'March',\n\t\t'April',\n\t\t'May',\n\t\t'June',\n\t\t'July',\n\t\t'August',\n\t\t'September',\n\t\t'October',\n\t\t'November',\n\t\t'December',\n\t],\n\tplaceholder: 'Pick a Date',\n\ttoday: 'Today',\n\tweekDays: [\n\t\t'Sunday',\n\t\t'Monday',\n\t\t'Tuesday',\n\t\t'Wednesday',\n\t\t'Thursday',\n\t\t'Friday',\n\t\t'Saturday',\n\t],\n};\n\nconst defaultFormatter = (date: Date | null | undefined): string => {\n\treturn date\n\t\t? `${date.getMonth() + 1}/${date.getDate()}/${date.getFullYear()}`\n\t\t: '';\n};\n\nconst defaultParser = (str: string): Date => {\n\tlowPriorityWarning(\n\t\tfalse,\n\t\t`Please use an external library for date parsing and internationalization like MomentJS (https://github.com/moment/moment/) instead of the default parser.`\n\t);\n\treturn new Date(str);\n};\n\nconst isDate = (date: unknown): date is Date =>\n\tObject.prototype.toString.call(date) === '[object Date]';\n\n/**\n * Stable identity of a `value`, so a parent passing `new Date(...)` on every render does not\n * re-sync the typed text. Invalid dates share one key.\n */\nconst getDateKey = (date: Date | null): string =>\n\tdate ? String(date.getTime()) : 'null';\n\n// ===== Component =====\n\nconst Datepicker: React.FC<DatePickerProps> = (props) => {\n\tconst {\n\t\tassistiveText: assistiveTextProp = {},\n\t\talign = 'left',\n\t\tclassName,\n\t\tdisabled,\n\t\tdateDisabled = () => false,\n\t\tdefaultIsOpen = false,\n\t\tformatter = defaultFormatter,\n\t\thasError,\n\t\thasStaticAlignment,\n\t\tid: idProp,\n\t\tinput,\n\t\tisOpen: isOpenProp,\n\t\tisIsoWeekday,\n\t\tlabels: labelsProp = {},\n\t\tmenuPosition = 'absolute',\n\t\tonCalendarFocus,\n\t\tonChange,\n\t\tonClose,\n\t\tonOpen,\n\t\tonRequestClose,\n\t\tonRequestOpen,\n\t\tparser = defaultParser,\n\t\tportalMount,\n\t\trelativeYearFrom = -10,\n\t\trelativeYearTo = 10,\n\t\ttriggerClassName,\n\t\tvalue: valueProp,\n\t\t// Deprecated props\n\t\trequired,\n\t\tonBlur,\n\t\tonFocus,\n\t\tonKeyDown,\n\t} = props;\n\n\t// Merge with defaults\n\tconst assistiveText = assign({}, defaultAssistiveText, assistiveTextProp);\n\tconst labels = assign({}, defaultLabels, labelsProp);\n\n\t// Context\n\tconst iconSettingsContext = useContext(IconSettingsContext);\n\n\t// Refs\n\tconst triggerRef = useRef<HTMLDivElement | null>(null);\n\tconst inputRef = useRef<HTMLInputElement | null>(null);\n\tconst selectedDateCellRef = useRef<HTMLElement | null>(null);\n\tconst generatedId = useId();\n\n\t// `value` is controlled data; `undefined` (warned in `checkProps`) means no date\n\tconst value = valueProp ?? null;\n\tconst valueKey = getDateKey(value);\n\n\t// State\n\t// The calendar's open state is ephemeral UI: controlled when `isOpen` is set\n\tconst [isOpen, setIsOpen] = useControllableState(isOpenProp, defaultIsOpen);\n\tconst [isOpenFromIcon, setIsOpenFromIcon] = useState(false);\n\t// The input's text is a buffer so it can hold partial input. `valueKey` is the `value` it was\n\t// last synced from, and `typedKey` the date reported for the typed text.\n\tconst [inputBuffer, setInputBuffer] = useState<{\n\t\ttext: string;\n\t\tvalueKey: string;\n\t\ttypedKey: string | null;\n\t}>(() => ({ text: formatter(value), valueKey, typedKey: null }));\n\tconst [inputRendered, setInputRendered] = useState(false);\n\n\t// Re-sync the typed text whenever `value` changes, unless the change is the parent accepting\n\t// the date that was just typed (so the user's text is not reformatted mid-typing)\n\tif (inputBuffer.valueKey !== valueKey) {\n\t\tsetInputBuffer({\n\t\t\ttext:\n\t\t\t\tinputBuffer.typedKey === valueKey ? inputBuffer.text : formatter(value),\n\t\t\tvalueKey,\n\t\t\ttypedKey: null,\n\t\t});\n\t}\n\tconst inputValue = inputBuffer.text;\n\n\t// Check props on mount (only in development)\n\tuseEffect(() => {\n\t\tif (typeof checkProps === 'function') {\n\t\t\tcheckProps(\n\t\t\t\tDATE_PICKER,\n\t\t\t\tprops as unknown as Record<string, unknown>,\n\t\t\t\tcomponentDoc\n\t\t\t);\n\t\t}\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, []);\n\n\t// Derived state\n\tconst getId = useCallback(() => idProp || generatedId, [idProp, generatedId]);\n\n\tconst getIsOpen = useCallback(() => !!isOpen, [isOpen]);\n\n\tconst parseDate = useCallback(\n\t\t(dateString: string): Date => {\n\t\t\tlet parsedDate = parser(dateString);\n\t\t\tif (!isDate(parsedDate) || isNaN(parsedDate.getTime())) {\n\t\t\t\tparsedDate = new Date();\n\t\t\t}\n\t\t\treturn parsedDate;\n\t\t},\n\t\t[parser]\n\t);\n\n\t// ===== Event Handlers =====\n\n\tconst handleRequestClose = useCallback(\n\t\t(\n\t\t\tevent: React.SyntheticEvent | MouseEvent | TouchEvent | undefined,\n\t\t\tdata: DatePickerRequestCloseData\n\t\t) => {\n\t\t\t// Only request a close while open, so `onRequestClose` never fires when\n\t\t\t// the calendar is already closed (e.g. Escape in a closed input).\n\t\t\tif (!getIsOpen()) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tonRequestClose?.(event, data);\n\n\t\t\t// No-op when `isOpen` is controlled: the parent decides\n\t\t\tsetIsOpen(false);\n\t\t\tsetIsOpenFromIcon(false);\n\n\t\t\tif (inputRef.current) {\n\t\t\t\tinputRef.current.focus();\n\t\t\t}\n\t\t},\n\t\t[onRequestClose, getIsOpen, setIsOpen]\n\t);\n\n\tconst handleCalendarRequestClose = useCallback(\n\t\t(event?: React.SyntheticEvent) => {\n\t\t\t// The calendar's only close request is Escape (see `CalendarWrapper#handleKeyDown`)\n\t\t\thandleRequestClose(event, { trigger: 'escape' });\n\t\t},\n\t\t[handleRequestClose]\n\t);\n\n\tconst handleClose = useCallback(\n\t\t(\n\t\t\tevent: React.SyntheticEvent | undefined,\n\t\t\tdata?: { componentWillUnmount?: boolean }\n\t\t) => {\n\t\t\tonClose?.(event, {\n\t\t\t\tcomponentWillUnmount: !!data?.componentWillUnmount,\n\t\t\t});\n\t\t},\n\t\t[onClose]\n\t);\n\n\tconst handleOpen = useCallback(\n\t\t(\n\t\t\tevent: React.SyntheticEvent | undefined,\n\t\t\tdata: { portal?: HTMLElement }\n\t\t) => {\n\t\t\tif (onOpen) {\n\t\t\t\tonOpen(event, data);\n\t\t\t}\n\n\t\t\tif (selectedDateCellRef.current && isOpenFromIcon) {\n\t\t\t\tselectedDateCellRef.current.focus();\n\t\t\t}\n\t\t},\n\t\t[onOpen, isOpenFromIcon]\n\t);\n\n\tconst openDialog = useCallback(\n\t\t(\n\t\t\tevent: React.MouseEvent | KeyboardEvent,\n\t\t\tdata: DatePickerRequestOpenData,\n\t\t\tfromIcon = false\n\t\t) => {\n\t\t\tif (!fromIcon) {\n\t\t\t\tsetIsOpenFromIcon(false);\n\t\t\t}\n\n\t\t\t// No-op when `isOpen` is controlled: the parent decides\n\t\t\tsetIsOpen(true);\n\t\t\tonRequestOpen?.(event, data);\n\t\t},\n\t\t[onRequestOpen, setIsOpen]\n\t);\n\n\tconst openDialogFromIcon = useCallback(\n\t\t(event: React.MouseEvent) => {\n\t\t\tsetIsOpenFromIcon(true);\n\t\t\topenDialog(event, { trigger: 'icon-click' }, true);\n\t\t},\n\t\t[openDialog]\n\t);\n\n\tconst handleCalendarChange = useCallback(\n\t\t(event: React.SyntheticEvent, { date }: { date: Date }) => {\n\t\t\thandleRequestClose(event, { trigger: 'date-select' });\n\n\t\t\tif (onChange) {\n\t\t\t\tonChange(event, {\n\t\t\t\t\tdate,\n\t\t\t\t\tformattedDate: formatter(date),\n\t\t\t\t\ttimezoneOffset: date.getTimezoneOffset(),\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\t[formatter, handleRequestClose, onChange]\n\t);\n\n\tconst handleInputChange = useCallback(\n\t\t(event: ChangeEvent<HTMLInputElement>) => {\n\t\t\tconst text = event.target.value;\n\t\t\t// Clearing the input requests no date. `parser` is typed to return a `Date`, but guard\n\t\t\t// against parsers that return `null` for partial input.\n\t\t\tconst parsedDate = text === '' ? null : parser(text);\n\t\t\tconst date = isDate(parsedDate) ? parsedDate : null;\n\n\t\t\tsetInputBuffer((buffer) => ({\n\t\t\t\t...buffer,\n\t\t\t\ttext,\n\t\t\t\ttypedKey: getDateKey(date),\n\t\t\t}));\n\n\t\t\t// Typing closes the calendar, through the same request path as the keyboard and mouse\n\t\t\thandleRequestClose(event, { trigger: 'input-change' });\n\n\t\t\tif (onChange) {\n\t\t\t\tonChange(event, {\n\t\t\t\t\tdate,\n\t\t\t\t\tformattedDate: text,\n\t\t\t\t\ttimezoneOffset: (date ?? new Date()).getTimezoneOffset(),\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\t[handleRequestClose, parser, onChange]\n\t);\n\n\tconst handleKeyDown = useCallback(\n\t\t(event: KeyboardEvent<HTMLInputElement>) => {\n\t\t\t// Don't open if user is selecting text\n\t\t\tif (\n\t\t\t\tevent.key &&\n\t\t\t\t!event.shiftKey &&\n\t\t\t\t(event.key === KEYS.DOWN || event.key === KEYS.UP)\n\t\t\t) {\n\t\t\t\tEventUtil.trapEvent(event);\n\t\t\t\t// Go through the same request path as clicking, so a controlled\n\t\t\t\t// DatePicker hears about keyboard opens via `onRequestOpen`\n\t\t\t\tif (!getIsOpen()) {\n\t\t\t\t\topenDialog(event, { trigger: 'keyboard' });\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (event.key === KEYS.ESCAPE || event.key === KEYS.ENTER) {\n\t\t\t\tEventUtil.trapEvent(event);\n\t\t\t\thandleRequestClose(event, {\n\t\t\t\t\ttrigger: event.key === KEYS.ESCAPE ? 'escape' : 'enter',\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (onKeyDown) {\n\t\t\t\tonKeyDown(event, {});\n\t\t\t}\n\t\t},\n\t\t[getIsOpen, openDialog, handleRequestClose, onKeyDown]\n\t);\n\n\tconst handleClickOutside = useCallback(\n\t\t(event: MouseEvent | TouchEvent) => {\n\t\t\thandleRequestClose(event, { trigger: 'click-outside' });\n\t\t},\n\t\t[handleRequestClose]\n\t);\n\n\t// Detect clicks outside the trigger/calendar and close the dialog. Anchored\n\t// on the trigger element so this works whether the DatePicker is controlled\n\t// (`onRequestClose` is invoked via `handleRequestClose`) or uncontrolled\n\t// (internal open state is reset). The trigger carries the\n\t// `ignore-react-onclickoutside` class and, in `overflowBoundaryElement`\n\t// mode, so does the portaled calendar, so clicks within the calendar are\n\t// treated as inside.\n\tuseClickOutside(triggerRef, handleClickOutside, {\n\t\tenabled: getIsOpen(),\n\t\tignoreClass: 'ignore-react-onclickoutside',\n\t});\n\n\t// ===== Refs =====\n\n\tconst setInputRefCallback = useCallback(\n\t\t(component: HTMLInputElement | null) => {\n\t\t\tinputRef.current = component;\n\t\t\tif (!inputRendered) {\n\t\t\t\tsetInputRendered(true);\n\t\t\t}\n\t\t},\n\t\t[inputRendered]\n\t);\n\n\t// ===== Render Helpers =====\n\n\tconst getDatePicker = useCallback(() => {\n\t\tlet date: Date;\n\t\tif (value) {\n\t\t\tconst formattedDate = formatter(value);\n\t\t\tdate = formattedDate ? parseDate(formattedDate) : value;\n\t\t} else {\n\t\t\tdate = new Date();\n\t\t}\n\n\t\treturn (\n\t\t\t<CalendarWrapper\n\t\t\t\tabbreviatedWeekDayLabels={labels.abbreviatedWeekDays}\n\t\t\t\tassistiveTextNextMonth={assistiveText.nextMonth}\n\t\t\t\tassistiveTextPreviousMonth={assistiveText.previousMonth}\n\t\t\t\tassistiveTextYear={assistiveText.year}\n\t\t\t\tcanFocusCalendar={isOpenFromIcon}\n\t\t\t\tid={getId()}\n\t\t\t\tisIsoWeekday={isIsoWeekday}\n\t\t\t\tmonthLabels={labels.months}\n\t\t\t\tonCalendarFocus={onCalendarFocus}\n\t\t\t\tdateDisabled={dateDisabled}\n\t\t\t\tonRequestClose={handleCalendarRequestClose}\n\t\t\t\tonSelectDate={handleCalendarChange}\n\t\t\t\trelativeYearFrom={relativeYearFrom}\n\t\t\t\trelativeYearTo={relativeYearTo}\n\t\t\t\tselectedDate={date}\n\t\t\t\tselectedDateRef={(component: HTMLElement | null) => {\n\t\t\t\t\tselectedDateCellRef.current = component;\n\t\t\t\t}}\n\t\t\t\ttodayLabel={labels.today}\n\t\t\t\tweekDayLabels={labels.weekDays}\n\t\t\t/>\n\t\t);\n\t}, [\n\t\tvalue,\n\t\tformatter,\n\t\tparseDate,\n\t\tlabels,\n\t\tassistiveText,\n\t\tisOpenFromIcon,\n\t\tgetId,\n\t\tisIsoWeekday,\n\t\tonCalendarFocus,\n\t\tdateDisabled,\n\t\thandleCalendarRequestClose,\n\t\thandleCalendarChange,\n\t\trelativeYearFrom,\n\t\trelativeYearTo,\n\t]);\n\n\tconst getDialog = useCallback(() => {\n\t\t// SLDS override\n\t\tconst style = menuPosition !== 'relative' ? { transform: 'none' } : {};\n\n\t\tif (disabled || !getIsOpen()) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst dialogProps = {\n\t\t\talign: `bottom ${align}` as const,\n\t\t\tcontentsClassName: classNames(\n\t\t\t\t'slds-datepicker slds-dropdown',\n\t\t\t\t{\n\t\t\t\t\t'slds-dropdown_right':\n\t\t\t\t\t\tmenuPosition === 'relative' && align === 'right',\n\t\t\t\t\t'slds-dropdown_left': menuPosition === 'relative' && align === 'left',\n\t\t\t\t},\n\t\t\t\tclassName\n\t\t\t),\n\t\t\tcontext: iconSettingsContext,\n\t\t\thasStaticAlignment,\n\t\t\tstyle,\n\t\t\tonClose: handleClose,\n\t\t\tonOpen: handleOpen,\n\t\t\tonRequestTargetElement: () => inputRef.current,\n\t\t\tposition: menuPosition,\n\t\t\tportalMount,\n\t\t};\n\n\t\treturn (\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t<Dialog {...(dialogProps as any)}>{getDatePicker()}</Dialog>\n\t\t);\n\t}, [\n\t\tmenuPosition,\n\t\tdisabled,\n\t\tgetIsOpen,\n\t\talign,\n\t\tclassName,\n\t\ticonSettingsContext,\n\t\thasStaticAlignment,\n\t\thandleClose,\n\t\thandleOpen,\n\t\tportalMount,\n\t\tgetDatePicker,\n\t]);\n\n\tconst getInputProps = useCallback(() => {\n\t\tconst defaultInputProps = {\n\t\t\ticonRight: (\n\t\t\t\t<InputIcon\n\t\t\t\t\tassistiveText={{\n\t\t\t\t\t\ticon: assistiveText.openCalendar,\n\t\t\t\t\t}}\n\t\t\t\t\taria-haspopup\n\t\t\t\t\taria-expanded={getIsOpen()}\n\t\t\t\t\tcategory=\"utility\"\n\t\t\t\t\tname=\"event\"\n\t\t\t\t\tonClick={(event: React.MouseEvent) => {\n\t\t\t\t\t\topenDialogFromIcon(event);\n\t\t\t\t\t}}\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t/>\n\t\t\t),\n\t\t\tinputRef: (component: HTMLInputElement | null) => {\n\t\t\t\tsetInputRefCallback(component);\n\t\t\t},\n\t\t\tid: getId(),\n\t\t\tonChange: handleInputChange,\n\t\t\tonClick: (event: React.MouseEvent<HTMLInputElement>) => {\n\t\t\t\topenDialog(event, { trigger: 'input-click' });\n\t\t\t},\n\t\t\tonKeyDown: handleKeyDown,\n\t\t\tvalue: inputValue,\n\t\t};\n\n\t\tconst topLevelDeprecatedComponentProps = {\n\t\t\tdisabled,\n\t\t\tlabel: labels.label,\n\t\t\tonBlur,\n\t\t\tonFocus,\n\t\t\tplaceholder: labels.placeholder,\n\t\t\trequired,\n\t\t};\n\n\t\tconst inputRenderProps = (input?.props || {}) as Record<string, unknown>;\n\n\t\t// The `input` element's props win, except `onChange` and\n\t\t// `inputRef`: the picker needs its own to track typed text and to return focus to the input\n\t\t// on close, so both are called.\n\t\tconst consumerProps = inputRenderProps;\n\t\tconst consumerOnChange = consumerProps.onChange as\n\t\t\t((...args: unknown[]) => void) | undefined;\n\t\tconst consumerInputRef = consumerProps.inputRef as\n\t\t\tReact.Ref<HTMLInputElement> | undefined;\n\n\t\treturn {\n\t\t\t...defaultInputProps,\n\t\t\t...topLevelDeprecatedComponentProps,\n\t\t\t...inputRenderProps,\n\t\t\tonChange: (event: ChangeEvent<HTMLInputElement>, ...rest: unknown[]) => {\n\t\t\t\tconsumerOnChange?.(event, ...rest);\n\t\t\t\thandleInputChange(event);\n\t\t\t},\n\t\t\tinputRef: (component: HTMLInputElement | null) => {\n\t\t\t\tif (typeof consumerInputRef === 'function') {\n\t\t\t\t\tconsumerInputRef(component);\n\t\t\t\t} else if (consumerInputRef) {\n\t\t\t\t\t(\n\t\t\t\t\t\tconsumerInputRef as React.RefObject<HTMLInputElement | null>\n\t\t\t\t\t).current = component;\n\t\t\t\t}\n\t\t\t\tsetInputRefCallback(component);\n\t\t\t},\n\t\t};\n\t}, [\n\t\tassistiveText.openCalendar,\n\t\tgetIsOpen,\n\t\topenDialogFromIcon,\n\t\tsetInputRefCallback,\n\t\tgetId,\n\t\thandleInputChange,\n\t\topenDialog,\n\t\thandleKeyDown,\n\t\tinputValue,\n\t\tdisabled,\n\t\tlabels.label,\n\t\tlabels.placeholder,\n\t\tonBlur,\n\t\tonFocus,\n\t\trequired,\n\t\tinput,\n\t]);\n\n\t// ===== Main Render =====\n\n\tconst inputProps = getInputProps();\n\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tconst inputToRender = <Input {...(inputProps as any)} />;\n\n\treturn (\n\t\t<div\n\t\t\tref={triggerRef}\n\t\t\tclassName={classNames(\n\t\t\t\t'slds-dropdown-trigger',\n\t\t\t\t'slds-dropdown-trigger_click',\n\t\t\t\t'ignore-react-onclickoutside',\n\t\t\t\t{\n\t\t\t\t\t'slds-has-error': hasError,\n\t\t\t\t\t'slds-is-open': getIsOpen(),\n\t\t\t\t},\n\t\t\t\ttriggerClassName\n\t\t\t)}\n\t\t>\n\t\t\t{inputToRender}\n\t\t\t{getDialog()}\n\t\t</div>\n\t);\n};\n\nDatepicker.displayName = DATE_PICKER;\n\nexport default Datepicker;\n"],"mappings":"yxBAkPA,IAAM,GAA0D,CAC/D,UAAW,aACX,aAAc,gBACd,cAAe,iBACf,KAAM,MACP,EAEM,GAA4C,CACjD,oBAAqB,CAAC,MAAO,MAAO,MAAO,MAAO,MAAO,MAAO,KAAK,EACrE,MAAO,GACP,OAAQ,CACP,UACA,WACA,QACA,QACA,MACA,OACA,OACA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CACvE,IAAmB,EAAO,GAAG,CAAI,EACjC,EAAkB,CAAK,CACxB,EACA,SAAW,GAAuC,CAC7C,OAAO,GAAqB,WAC/B,EAAiB,CAAS,EAChB,IACV,EAEE,QAAU,GAEb,EAAoB,CAAS,CAC9B,CACD,CACD,EAAG,CACF,EAAc,aACd,EACA,GACA,EACA,EACA,EACA,EACA,GACA,GACA,EACA,EAAO,MACP,EAAO,YACP,EACA,EACA,EACA,EACD,CAImB,CAAA,CAAc,EAG3B,IAAgB,EAAA,EAAA,IAAA,CAAC,GAAA,QAAD,CAAO,GAAK,EAAqB,CAAA,EAEvD,OACC,EAAA,EAAA,KAAA,CAAC,MAAD,CACC,IAAK,EACL,WAAA,EAAW,EAAA,QAAA,CACV,wBACA,8BACA,8BACA,CACC,iBAAkB,GAClB,eAAgB,EAAU,CAC3B,EACA,EACD,EAXD,SAAA,CAaE,GACA,GAAU,CACP,GAEP,EAEA,EAAW,YAAc,EAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendar.cjs","names":[],"sources":["../../../../../components/date-picker/private/calendar.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 type { DatePickerFocusDirection } from '../date-picker';\nimport React, { type ReactElement, type SyntheticEvent } from 'react';\n\nimport Week from './week';\nimport DateUtil from '../../../utilities/date';\n\nexport interface CalendarProps {\n\t/** Three letter abbreviations of the days of the week */\n\tabbreviatedWeekDayLabels: string[];\n\t/** Function to determine if a date should be disabled */\n\tdateDisabled?: (data: { date: Date }) => boolean;\n\t/** HTML id for component */\n\tid: string;\n\t/** Date used to create calendar that is displayed */\n\tinitialDateForCalendarRender: Date;\n\t/** Makes Monday the first day of the week */\n\tisIsoWeekday?: boolean;\n\t/** Called when focus moves off calendar */\n\tonCalendarBlur: (\n\t\tevent: SyntheticEvent,\n\t\tdata: { direction: DatePickerFocusDirection }\n\t) => void;\n\t/** Called when month changes */\n\tonChangeMonth: (event: SyntheticEvent | undefined, date: Date) => void;\n\t/** Called when internal focus date requested */\n\tonRequestInternalFocusDate?: (\n\t\tevent: SyntheticEvent | undefined,\n\t\tdata: { date: Date; ref?: HTMLElement | null; triggerCallback?: boolean }\n\t) => void;\n\t/** Called when calendar should close */\n\tonRequestClose: (\n\t\tevent?: SyntheticEvent,\n\t\tdata?: Record<string, unknown>\n\t) => void;\n\t/** Called when a date is selected */\n\tonSelectDate: (event: SyntheticEvent, data: { date: Date }) => void;\n\t/** Currently selected date */\n\tselectedDate?: Date;\n\t/** Ref callback for selected date cell */\n\tselectedDateRef?: (ref: HTMLElement | null) => void;\n\t/** Label for today shortcut */\n\ttodayLabel: string;\n\t/** Called on last focusable node keydown */\n\tonLastFocusableNodeKeyDown?: (event: React.KeyboardEvent) => void;\n\t/** Ref callback for today link */\n\ttodayRef?: (ref: HTMLAnchorElement | null) => void;\n\t/** Full names of the days of the week */\n\tweekDayLabels: string[];\n}\n\ninterface CalendarState {\n\tfocusedDate: Date;\n\tcalendarHasFocus: boolean;\n\ttodayFocus: boolean;\n\tselected?: Date;\n}\n\nclass DatepickerCalendar extends React.Component<CalendarProps, CalendarState> {\n\tstatic displayName = 'SLDSDatepickerCalendar';\n\n\tstate: CalendarState = {\n\t\tfocusedDate: this.props.initialDateForCalendarRender,\n\t\tcalendarHasFocus: true,\n\t\ttodayFocus: false,\n\t};\n\n\tcomponentDidUpdate(prevProps: CalendarProps) {\n\t\tthis.setCalendarRenderSeedDate(prevProps);\n\t}\n\n\tsetCalendarRenderSeedDate = (prevProps: CalendarProps) => {\n\t\t// Set prop that sets focus in child component once it is rendered. This occurs when the month DOM has changed. This will trigger a re-render, but no DOM change will occur, just a DOM focus.\n\t\tif (\n\t\t\t!DateUtil.isEqual(\n\t\t\t\tthis.props.initialDateForCalendarRender,\n\t\t\t\tprevProps.initialDateForCalendarRender\n\t\t\t)\n\t\t) {\n\t\t\tthis.setState({ focusedDate: this.props.initialDateForCalendarRender });\n\t\t\tthis.props.onRequestInternalFocusDate?.(undefined, {\n\t\t\t\tdate: this.props.initialDateForCalendarRender,\n\t\t\t\ttriggerCallback: true,\n\t\t\t});\n\t\t}\n\t};\n\n\thandleSelectDate = (event: SyntheticEvent, { date }: { date: Date }) => {\n\t\tif (!this.props.dateDisabled?.({ date })) {\n\t\t\tthis.setState({ selected: date });\n\t\t\tthis.props.onSelectDate(event, { date });\n\t\t}\n\t};\n\n\thandleRequestClose = (event?: SyntheticEvent) => {\n\t\tif (this.props.onRequestClose) {\n\t\t\tthis.props.onRequestClose(event, {});\n\t\t}\n\t};\n\n\thandleKeyboardNavigateToPreviousDay = (\n\t\tevent: SyntheticEvent,\n\t\t{ date }: { date: Date }\n\t) => {\n\t\tconst prevDate = DateUtil.addDays(date, -1);\n\t\tif (!DateUtil.isSameMonth(prevDate, date)) {\n\t\t\tthis.props.onChangeMonth(event, prevDate);\n\t\t} else {\n\t\t\tthis.setState({ focusedDate: prevDate });\n\t\t\tthis.props.onRequestInternalFocusDate?.(event, {\n\t\t\t\tdate: prevDate,\n\t\t\t\ttriggerCallback: true,\n\t\t\t});\n\t\t}\n\t};\n\n\thandleKeyboardNavigateToNextDay = (\n\t\tevent: SyntheticEvent,\n\t\t{ date }: { date: Date }\n\t) => {\n\t\tconst nextDate = DateUtil.addDays(date, 1);\n\t\tif (!DateUtil.isSameMonth(nextDate, date)) {\n\t\t\tthis.props.onChangeMonth(event, nextDate);\n\t\t} else {\n\t\t\tthis.setState({ focusedDate: nextDate });\n\t\t\tthis.props.onRequestInternalFocusDate?.(event, {\n\t\t\t\tdate: nextDate,\n\t\t\t\ttriggerCallback: true,\n\t\t\t});\n\t\t}\n\t};\n\n\thandleKeyboardNavigateToPreviousWeek = (\n\t\tevent: SyntheticEvent,\n\t\t{ date }: { date: Date }\n\t) => {\n\t\tconst prevDate = DateUtil.addDays(date, -7);\n\t\tif (!DateUtil.isSameMonth(prevDate, date)) {\n\t\t\tthis.props.onChangeMonth(event, prevDate);\n\t\t} else {\n\t\t\tthis.setState({ focusedDate: prevDate });\n\t\t\tthis.props.onRequestInternalFocusDate?.(event, {\n\t\t\t\tdate: prevDate,\n\t\t\t\ttriggerCallback: true,\n\t\t\t});\n\t\t}\n\t};\n\n\thandleKeyboardNavigateToNextWeek = (\n\t\tevent: SyntheticEvent,\n\t\t{ date }: { date: Date }\n\t) => {\n\t\tconst nextDate = DateUtil.addDays(date, 7);\n\t\tif (!DateUtil.isSameMonth(nextDate, date)) {\n\t\t\tthis.props.onChangeMonth(event, nextDate);\n\t\t} else {\n\t\t\tthis.setState({ focusedDate: nextDate });\n\t\t\tthis.props.onRequestInternalFocusDate?.(event, {\n\t\t\t\tdate: nextDate,\n\t\t\t\ttriggerCallback: true,\n\t\t\t});\n\t\t}\n\t};\n\n\trenderWeeks = () => {\n\t\tconst firstDayOfWeekOffset = this.props.isIsoWeekday ? 1 : 0;\n\n\t\tconst firstDayOfMonth = DateUtil.firstDayOfMonth(\n\t\t\tthis.props.initialDateForCalendarRender\n\t\t);\n\n\t\tlet firstDayOfWeek;\n\t\tif (\n\t\t\tfirstDayOfMonth.getDay() > firstDayOfWeekOffset ||\n\t\t\tfirstDayOfMonth.getDay() < firstDayOfWeekOffset\n\t\t) {\n\t\t\tconst prevWeek = DateUtil.addWeeks(firstDayOfMonth, -1);\n\t\t\tfirstDayOfWeek = DateUtil.nearestWeekDay(prevWeek, firstDayOfWeekOffset);\n\t\t} else {\n\t\t\tfirstDayOfWeek = firstDayOfMonth;\n\t\t}\n\n\t\tconst weeks: ReactElement[] = [];\n\t\tlet done = false;\n\n\t\tlet monthIndex = firstDayOfWeek.getMonth();\n\t\tlet count = 0;\n\n\t\twhile (!done) {\n\t\t\tweeks.push(\n\t\t\t\t<Week\n\t\t\t\t\tcalendarHasFocus={this.state.calendarHasFocus}\n\t\t\t\t\tdateDisabled={this.props.dateDisabled}\n\t\t\t\t\tfirstDayOfWeek={firstDayOfWeek}\n\t\t\t\t\tkey={firstDayOfWeek.toString()}\n\t\t\t\t\tfocusedDate={this.state.focusedDate}\n\t\t\t\t\tinitialDateForCalendarRender={this.props.initialDateForCalendarRender}\n\t\t\t\t\tonCalendarBlur={this.props.onCalendarBlur}\n\t\t\t\t\tonKeyboardNavigateToPreviousDay={\n\t\t\t\t\t\tthis.handleKeyboardNavigateToPreviousDay\n\t\t\t\t\t}\n\t\t\t\t\tonKeyboardNavigateToNextDay={this.handleKeyboardNavigateToNextDay}\n\t\t\t\t\tonKeyboardNavigateToPreviousWeek={\n\t\t\t\t\t\tthis.handleKeyboardNavigateToPreviousWeek\n\t\t\t\t\t}\n\t\t\t\t\tonKeyboardNavigateToNextWeek={this.handleKeyboardNavigateToNextWeek}\n\t\t\t\t\tonRequestClose={this.handleRequestClose}\n\t\t\t\t\tonRequestInternalFocusDate={this.props.onRequestInternalFocusDate}\n\t\t\t\t\tonSelectDate={this.handleSelectDate}\n\t\t\t\t\tselectedDate={this.props.selectedDate}\n\t\t\t\t\tselectedDateRef={this.props.selectedDateRef}\n\t\t\t\t\ttodayLabel={this.props.todayLabel}\n\t\t\t\t/>\n\t\t\t);\n\n\t\t\t// create new weeks\n\t\t\tfirstDayOfWeek = DateUtil.addWeeks(firstDayOfWeek, 1);\n\t\t\tdone = count > 2 && monthIndex !== firstDayOfWeek.getMonth();\n\t\t\tcount += 1;\n\t\t\tmonthIndex = firstDayOfWeek.getMonth();\n\t\t}\n\t\tlet extraWeeks = 0;\n\t\twhile (weeks.length < 6) {\n\t\t\textraWeeks += 1;\n\t\t\tweeks.push(\n\t\t\t\t<tr key={`extra_${extraWeeks}`} className=\"week\">\n\t\t\t\t\t<td\n\t\t\t\t\t\taria-disabled=\"true\"\n\t\t\t\t\t\taria-selected=\"false\"\n\t\t\t\t\t\tclassName=\"slds-disabled-text\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<span className=\"slds-day \"> </span>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t);\n\t\t}\n\n\t\treturn weeks;\n\t};\n\n\trender() {\n\t\tconst sunday = (\n\t\t\t<th>\n\t\t\t\t<abbr title={this.props.weekDayLabels[0]}>\n\t\t\t\t\t{this.props.abbreviatedWeekDayLabels[0]}\n\t\t\t\t</abbr>\n\t\t\t</th>\n\t\t);\n\n\t\treturn (\n\t\t\t<div className=\"calendar\">\n\t\t\t\t<table\n\t\t\t\t\tclassName=\"datepicker__month\"\n\t\t\t\t\trole=\"grid\"\n\t\t\t\t\taria-labelledby={`${this.props.id}-month`}\n\t\t\t\t>\n\t\t\t\t\t<thead>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t{this.props.isIsoWeekday ? null : sunday}\n\t\t\t\t\t\t\t<th scope=\"col\">\n\t\t\t\t\t\t\t\t<abbr title={this.props.weekDayLabels[1]}>\n\t\t\t\t\t\t\t\t\t{this.props.abbreviatedWeekDayLabels[1]}\n\t\t\t\t\t\t\t\t</abbr>\n\t\t\t\t\t\t\t</th>\n\t\t\t\t\t\t\t<th scope=\"col\">\n\t\t\t\t\t\t\t\t<abbr title={this.props.weekDayLabels[2]}>\n\t\t\t\t\t\t\t\t\t{this.props.abbreviatedWeekDayLabels[2]}\n\t\t\t\t\t\t\t\t</abbr>\n\t\t\t\t\t\t\t</th>\n\t\t\t\t\t\t\t<th scope=\"col\">\n\t\t\t\t\t\t\t\t<abbr title={this.props.weekDayLabels[3]}>\n\t\t\t\t\t\t\t\t\t{this.props.abbreviatedWeekDayLabels[3]}\n\t\t\t\t\t\t\t\t</abbr>\n\t\t\t\t\t\t\t</th>\n\t\t\t\t\t\t\t<th scope=\"col\">\n\t\t\t\t\t\t\t\t<abbr title={this.props.weekDayLabels[4]}>\n\t\t\t\t\t\t\t\t\t{this.props.abbreviatedWeekDayLabels[4]}\n\t\t\t\t\t\t\t\t</abbr>\n\t\t\t\t\t\t\t</th>\n\t\t\t\t\t\t\t<th scope=\"col\">\n\t\t\t\t\t\t\t\t<abbr title={this.props.weekDayLabels[5]}>\n\t\t\t\t\t\t\t\t\t{this.props.abbreviatedWeekDayLabels[5]}\n\t\t\t\t\t\t\t\t</abbr>\n\t\t\t\t\t\t\t</th>\n\t\t\t\t\t\t\t<th scope=\"col\">\n\t\t\t\t\t\t\t\t<abbr title={this.props.weekDayLabels[6]}>\n\t\t\t\t\t\t\t\t\t{this.props.abbreviatedWeekDayLabels[6]}\n\t\t\t\t\t\t\t\t</abbr>\n\t\t\t\t\t\t\t</th>\n\t\t\t\t\t\t\t{this.props.isIsoWeekday && sunday}\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</thead>\n\t\t\t\t\t<tbody>\n\t\t\t\t\t\t{this.renderWeeks()}\n\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td colSpan={7} role=\"gridcell\">\n\t\t\t\t\t\t\t\t<a\n\t\t\t\t\t\t\t\t\thref=\"#\"\n\t\t\t\t\t\t\t\t\ttabIndex={0}\n\t\t\t\t\t\t\t\t\tclassName=\"slds-show_inline-block slds-p-bottom_x-small\"\n\t\t\t\t\t\t\t\t\tonClick={(event) => {\n\t\t\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\t\t\tthis.handleSelectDate(event, { date: new Date() });\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\tonKeyDown={this.props.onLastFocusableNodeKeyDown}\n\t\t\t\t\t\t\t\t\tref={this.props.todayRef}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{this.props.todayLabel}\n\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</tbody>\n\t\t\t\t</table>\n\t\t\t</div>\n\t\t);\n\t}\n}\n\nexport default DatepickerCalendar;\n"],"mappings":"uMA4DA,IAAM,EAAN,cAAiC,EAAA,QAAM,SAAwC,CAC9E,OAAO,YAAc,yBAErB,MAAuB,CACtB,YAAa,KAAK,MAAM,6BACxB,iBAAkB,GAClB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D,CAAA,CACE,CAAA,CAAA,CACD,GACH,CAAA,CAEP,CACD"}
|
|
1
|
+
{"version":3,"file":"calendar.cjs","names":[],"sources":["../../../../../components/date-picker/private/calendar.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 type { DatePickerFocusDirection } from '../date-picker';\nimport React, { type ReactElement, type SyntheticEvent } from 'react';\n\nimport Week from './week';\nimport DateUtil from '../../../utilities/date';\n\nexport interface CalendarProps {\n\t/** Three letter abbreviations of the days of the week */\n\tabbreviatedWeekDayLabels: string[];\n\t/** Function to determine if a date should be disabled */\n\tdateDisabled?: (data: { date: Date }) => boolean;\n\t/** HTML id for component */\n\tid: string;\n\t/** Date used to create calendar that is displayed */\n\tinitialDateForCalendarRender: Date;\n\t/** Makes Monday the first day of the week */\n\tisIsoWeekday?: boolean;\n\t/** Called when focus moves off calendar */\n\tonCalendarBlur: (\n\t\tevent: SyntheticEvent,\n\t\tdata: { direction: DatePickerFocusDirection }\n\t) => void;\n\t/** Called when month changes */\n\tonChangeMonth: (event: SyntheticEvent | undefined, date: Date) => void;\n\t/** Called when internal focus date requested */\n\tonRequestInternalFocusDate?: (\n\t\tevent: SyntheticEvent | undefined,\n\t\tdata: { date: Date; ref?: HTMLElement | null; triggerCallback?: boolean }\n\t) => void;\n\t/** Called when calendar should close */\n\tonRequestClose: (\n\t\tevent?: SyntheticEvent,\n\t\tdata?: Record<string, unknown>\n\t) => void;\n\t/** Called when a date is selected */\n\tonSelectDate: (event: SyntheticEvent, data: { date: Date }) => void;\n\t/** Currently selected date */\n\tselectedDate?: Date;\n\t/** Ref callback for selected date cell */\n\tselectedDateRef?: (ref: HTMLElement | null) => void;\n\t/** Label for today shortcut */\n\ttodayLabel: string;\n\t/** Called on last focusable node keydown */\n\tonLastFocusableNodeKeyDown?: (event: React.KeyboardEvent) => void;\n\t/** Ref callback for today link */\n\ttodayRef?: (ref: HTMLAnchorElement | null) => void;\n\t/** Full names of the days of the week */\n\tweekDayLabels: string[];\n}\n\ninterface CalendarState {\n\tfocusedDate: Date;\n\tcalendarHasFocus: boolean;\n\ttodayFocus: boolean;\n\tselected?: Date;\n}\n\nclass DatepickerCalendar extends React.Component<CalendarProps, CalendarState> {\n\tstatic displayName = 'SLDSDatepickerCalendar';\n\n\tstate: CalendarState = {\n\t\tfocusedDate: this.props.initialDateForCalendarRender,\n\t\tcalendarHasFocus: true,\n\t\ttodayFocus: false,\n\t};\n\n\tcomponentDidUpdate(prevProps: CalendarProps) {\n\t\tthis.setCalendarRenderSeedDate(prevProps);\n\t}\n\n\tsetCalendarRenderSeedDate = (prevProps: CalendarProps) => {\n\t\t// Set prop that sets focus in child component once it is rendered. This occurs when the month DOM has changed. This will trigger a re-render, but no DOM change will occur, just a DOM focus.\n\t\tif (\n\t\t\t!DateUtil.isEqual(\n\t\t\t\tthis.props.initialDateForCalendarRender,\n\t\t\t\tprevProps.initialDateForCalendarRender\n\t\t\t)\n\t\t) {\n\t\t\tthis.setState({ focusedDate: this.props.initialDateForCalendarRender });\n\t\t\tthis.props.onRequestInternalFocusDate?.(undefined, {\n\t\t\t\tdate: this.props.initialDateForCalendarRender,\n\t\t\t\ttriggerCallback: true,\n\t\t\t});\n\t\t}\n\t};\n\n\thandleSelectDate = (event: SyntheticEvent, { date }: { date: Date }) => {\n\t\tif (!this.props.dateDisabled?.({ date })) {\n\t\t\tthis.setState({ selected: date });\n\t\t\tthis.props.onSelectDate(event, { date });\n\t\t}\n\t};\n\n\thandleRequestClose = (event?: SyntheticEvent) => {\n\t\tif (this.props.onRequestClose) {\n\t\t\tthis.props.onRequestClose(event, {});\n\t\t}\n\t};\n\n\thandleKeyboardNavigateToPreviousDay = (\n\t\tevent: SyntheticEvent,\n\t\t{ date }: { date: Date }\n\t) => {\n\t\tconst prevDate = DateUtil.addDays(date, -1);\n\t\tif (!DateUtil.isSameMonth(prevDate, date)) {\n\t\t\tthis.props.onChangeMonth(event, prevDate);\n\t\t} else {\n\t\t\tthis.setState({ focusedDate: prevDate });\n\t\t\tthis.props.onRequestInternalFocusDate?.(event, {\n\t\t\t\tdate: prevDate,\n\t\t\t\ttriggerCallback: true,\n\t\t\t});\n\t\t}\n\t};\n\n\thandleKeyboardNavigateToNextDay = (\n\t\tevent: SyntheticEvent,\n\t\t{ date }: { date: Date }\n\t) => {\n\t\tconst nextDate = DateUtil.addDays(date, 1);\n\t\tif (!DateUtil.isSameMonth(nextDate, date)) {\n\t\t\tthis.props.onChangeMonth(event, nextDate);\n\t\t} else {\n\t\t\tthis.setState({ focusedDate: nextDate });\n\t\t\tthis.props.onRequestInternalFocusDate?.(event, {\n\t\t\t\tdate: nextDate,\n\t\t\t\ttriggerCallback: true,\n\t\t\t});\n\t\t}\n\t};\n\n\thandleKeyboardNavigateToPreviousWeek = (\n\t\tevent: SyntheticEvent,\n\t\t{ date }: { date: Date }\n\t) => {\n\t\tconst prevDate = DateUtil.addDays(date, -7);\n\t\tif (!DateUtil.isSameMonth(prevDate, date)) {\n\t\t\tthis.props.onChangeMonth(event, prevDate);\n\t\t} else {\n\t\t\tthis.setState({ focusedDate: prevDate });\n\t\t\tthis.props.onRequestInternalFocusDate?.(event, {\n\t\t\t\tdate: prevDate,\n\t\t\t\ttriggerCallback: true,\n\t\t\t});\n\t\t}\n\t};\n\n\thandleKeyboardNavigateToNextWeek = (\n\t\tevent: SyntheticEvent,\n\t\t{ date }: { date: Date }\n\t) => {\n\t\tconst nextDate = DateUtil.addDays(date, 7);\n\t\tif (!DateUtil.isSameMonth(nextDate, date)) {\n\t\t\tthis.props.onChangeMonth(event, nextDate);\n\t\t} else {\n\t\t\tthis.setState({ focusedDate: nextDate });\n\t\t\tthis.props.onRequestInternalFocusDate?.(event, {\n\t\t\t\tdate: nextDate,\n\t\t\t\ttriggerCallback: true,\n\t\t\t});\n\t\t}\n\t};\n\n\trenderWeeks = () => {\n\t\tconst firstDayOfWeekOffset = this.props.isIsoWeekday ? 1 : 0;\n\n\t\tconst firstDayOfMonth = DateUtil.firstDayOfMonth(\n\t\t\tthis.props.initialDateForCalendarRender\n\t\t);\n\n\t\tlet firstDayOfWeek;\n\t\tif (\n\t\t\tfirstDayOfMonth.getDay() > firstDayOfWeekOffset ||\n\t\t\tfirstDayOfMonth.getDay() < firstDayOfWeekOffset\n\t\t) {\n\t\t\tconst prevWeek = DateUtil.addWeeks(firstDayOfMonth, -1);\n\t\t\tfirstDayOfWeek = DateUtil.nearestWeekDay(prevWeek, firstDayOfWeekOffset);\n\t\t} else {\n\t\t\tfirstDayOfWeek = firstDayOfMonth;\n\t\t}\n\n\t\tconst weeks: ReactElement[] = [];\n\t\tlet done = false;\n\n\t\tlet monthIndex = firstDayOfWeek.getMonth();\n\t\tlet count = 0;\n\n\t\twhile (!done) {\n\t\t\tweeks.push(\n\t\t\t\t<Week\n\t\t\t\t\tcalendarHasFocus={this.state.calendarHasFocus}\n\t\t\t\t\tdateDisabled={this.props.dateDisabled}\n\t\t\t\t\tfirstDayOfWeek={firstDayOfWeek}\n\t\t\t\t\tkey={firstDayOfWeek.toString()}\n\t\t\t\t\tfocusedDate={this.state.focusedDate}\n\t\t\t\t\tinitialDateForCalendarRender={this.props.initialDateForCalendarRender}\n\t\t\t\t\tonCalendarBlur={this.props.onCalendarBlur}\n\t\t\t\t\tonKeyboardNavigateToPreviousDay={\n\t\t\t\t\t\tthis.handleKeyboardNavigateToPreviousDay\n\t\t\t\t\t}\n\t\t\t\t\tonKeyboardNavigateToNextDay={this.handleKeyboardNavigateToNextDay}\n\t\t\t\t\tonKeyboardNavigateToPreviousWeek={\n\t\t\t\t\t\tthis.handleKeyboardNavigateToPreviousWeek\n\t\t\t\t\t}\n\t\t\t\t\tonKeyboardNavigateToNextWeek={this.handleKeyboardNavigateToNextWeek}\n\t\t\t\t\tonRequestClose={this.handleRequestClose}\n\t\t\t\t\tonRequestInternalFocusDate={this.props.onRequestInternalFocusDate}\n\t\t\t\t\tonSelectDate={this.handleSelectDate}\n\t\t\t\t\tselectedDate={this.props.selectedDate}\n\t\t\t\t\tselectedDateRef={this.props.selectedDateRef}\n\t\t\t\t\ttodayLabel={this.props.todayLabel}\n\t\t\t\t/>\n\t\t\t);\n\n\t\t\t// create new weeks\n\t\t\tfirstDayOfWeek = DateUtil.addWeeks(firstDayOfWeek, 1);\n\t\t\tdone = count > 2 && monthIndex !== firstDayOfWeek.getMonth();\n\t\t\tcount += 1;\n\t\t\tmonthIndex = firstDayOfWeek.getMonth();\n\t\t}\n\t\tlet extraWeeks = 0;\n\t\twhile (weeks.length < 6) {\n\t\t\textraWeeks += 1;\n\t\t\tweeks.push(\n\t\t\t\t<tr key={`extra_${extraWeeks}`} className=\"week\">\n\t\t\t\t\t<td\n\t\t\t\t\t\taria-disabled=\"true\"\n\t\t\t\t\t\taria-selected=\"false\"\n\t\t\t\t\t\tclassName=\"slds-disabled-text\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<span className=\"slds-day \"> </span>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t);\n\t\t}\n\n\t\treturn weeks;\n\t};\n\n\trender() {\n\t\tconst sunday = (\n\t\t\t<th>\n\t\t\t\t<abbr title={this.props.weekDayLabels[0]}>\n\t\t\t\t\t{this.props.abbreviatedWeekDayLabels[0]}\n\t\t\t\t</abbr>\n\t\t\t</th>\n\t\t);\n\n\t\treturn (\n\t\t\t<div className=\"calendar\">\n\t\t\t\t<table\n\t\t\t\t\tclassName=\"datepicker__month\"\n\t\t\t\t\trole=\"grid\"\n\t\t\t\t\taria-labelledby={`${this.props.id}-month`}\n\t\t\t\t>\n\t\t\t\t\t<thead>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t{this.props.isIsoWeekday ? null : sunday}\n\t\t\t\t\t\t\t<th scope=\"col\">\n\t\t\t\t\t\t\t\t<abbr title={this.props.weekDayLabels[1]}>\n\t\t\t\t\t\t\t\t\t{this.props.abbreviatedWeekDayLabels[1]}\n\t\t\t\t\t\t\t\t</abbr>\n\t\t\t\t\t\t\t</th>\n\t\t\t\t\t\t\t<th scope=\"col\">\n\t\t\t\t\t\t\t\t<abbr title={this.props.weekDayLabels[2]}>\n\t\t\t\t\t\t\t\t\t{this.props.abbreviatedWeekDayLabels[2]}\n\t\t\t\t\t\t\t\t</abbr>\n\t\t\t\t\t\t\t</th>\n\t\t\t\t\t\t\t<th scope=\"col\">\n\t\t\t\t\t\t\t\t<abbr title={this.props.weekDayLabels[3]}>\n\t\t\t\t\t\t\t\t\t{this.props.abbreviatedWeekDayLabels[3]}\n\t\t\t\t\t\t\t\t</abbr>\n\t\t\t\t\t\t\t</th>\n\t\t\t\t\t\t\t<th scope=\"col\">\n\t\t\t\t\t\t\t\t<abbr title={this.props.weekDayLabels[4]}>\n\t\t\t\t\t\t\t\t\t{this.props.abbreviatedWeekDayLabels[4]}\n\t\t\t\t\t\t\t\t</abbr>\n\t\t\t\t\t\t\t</th>\n\t\t\t\t\t\t\t<th scope=\"col\">\n\t\t\t\t\t\t\t\t<abbr title={this.props.weekDayLabels[5]}>\n\t\t\t\t\t\t\t\t\t{this.props.abbreviatedWeekDayLabels[5]}\n\t\t\t\t\t\t\t\t</abbr>\n\t\t\t\t\t\t\t</th>\n\t\t\t\t\t\t\t<th scope=\"col\">\n\t\t\t\t\t\t\t\t<abbr title={this.props.weekDayLabels[6]}>\n\t\t\t\t\t\t\t\t\t{this.props.abbreviatedWeekDayLabels[6]}\n\t\t\t\t\t\t\t\t</abbr>\n\t\t\t\t\t\t\t</th>\n\t\t\t\t\t\t\t{this.props.isIsoWeekday && sunday}\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</thead>\n\t\t\t\t\t<tbody>\n\t\t\t\t\t\t{this.renderWeeks()}\n\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td colSpan={7} role=\"gridcell\">\n\t\t\t\t\t\t\t\t{/* eslint-disable-next-line jsx-a11y/anchor-is-valid -- SLDS datepicker markup uses an anchor for \"Today\" */}\n\t\t\t\t\t\t\t\t<a\n\t\t\t\t\t\t\t\t\thref=\"#\"\n\t\t\t\t\t\t\t\t\ttabIndex={0}\n\t\t\t\t\t\t\t\t\tclassName=\"slds-show_inline-block slds-p-bottom_x-small\"\n\t\t\t\t\t\t\t\t\tonClick={(event) => {\n\t\t\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\t\t\tthis.handleSelectDate(event, { date: new Date() });\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\tonKeyDown={this.props.onLastFocusableNodeKeyDown}\n\t\t\t\t\t\t\t\t\tref={this.props.todayRef}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{this.props.todayLabel}\n\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</tbody>\n\t\t\t\t</table>\n\t\t\t</div>\n\t\t);\n\t}\n}\n\nexport default DatepickerCalendar;\n"],"mappings":"uMA4DA,IAAM,EAAN,cAAiC,EAAA,QAAM,SAAwC,CAC9E,OAAO,YAAc,yBAErB,MAAuB,CACtB,YAAa,KAAK,MAAM,6BACxB,iBAAkB,GAClB,WAAY,EACb,EAEA,mBAAmB,EAA0B,CAC5C,KAAK,0BAA0B,CAAS,CACzC,CAEA,0BAA6B,GAA6B,CAGvD,EAAA,QAAS,QACT,KAAK,MAAM,6BACX,EAAU,4BACX,IAEA,KAAK,SAAS,CAAE,YAAa,KAAK,MAAM,4BAA6B,CAAC,EACtE,KAAK,MAAM,6BAA6B,IAAA,GAAW,CAClD,KAAM,KAAK,MAAM,6BACjB,gBAAiB,EAClB,CAAC,EAEH,EAEA,kBAAoB,EAAuB,CAAE,UAA2B,CAClE,KAAK,MAAM,eAAe,CAAE,MAAK,CAAC,IACtC,KAAK,SAAS,CAAE,SAAU,CAAK,CAAC,EAChC,KAAK,MAAM,aAAa,EAAO,CAAE,MAAK,CAAC,EAEzC,EA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CAAC,OAAD,CAAM,MAAO,KAAK,MAAM,cAAc,GACpC,SAAA,KAAK,MAAM,yBAAyB,EAChC,CAAA,CACH,CAAA,GACJ,EAAA,EAAA,IAAA,CAAC,KAAD,CAAI,MAAM,MACT,UAAA,EAAA,EAAA,IAAA,CAAC,OAAD,CAAM,MAAO,KAAK,MAAM,cAAc,GACpC,SAAA,KAAK,MAAM,yBAAyB,EAChC,CAAA,CACH,CAAA,EACH,KAAK,MAAM,cAAgB,CACzB,CAAA,CAAA,CACE,CAAA,GACP,EAAA,EAAA,KAAA,CAAC,QAAD,CAAA,SAAA,CACE,KAAK,YAAY,GAElB,EAAA,EAAA,IAAA,CAAC,KAAD,CAAA,UACC,EAAA,EAAA,IAAA,CAAC,KAAD,CAAI,QAAS,EAAG,KAAK,WAEpB,UAAA,EAAA,EAAA,IAAA,CAAC,IAAD,CACC,KAAK,IACL,SAAU,EACV,UAAU,+CACV,QAAU,GAAU,CACnB,EAAM,eAAe,EACrB,KAAK,iBAAiB,EAAO,CAAE,KAAM,IAAI,IAAO,CAAC,CAClD,EACA,UAAW,KAAK,MAAM,2BACtB,IAAK,KAAK,MAAM,SAEf,SAAA,KAAK,MAAM,UACV,CAAA,CACA,CAAA,CACD,CAAA,CACE,CAAA,CAAA,CACD,GACH,CAAA,CAEP,CACD"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../utilities/UNSAFE_direction/index.cjs"),n=require("../../utilities/UNSAFE_direction/private/language-direction.cjs"),r=require("../../../utilities/key-code.cjs"),i=require("../../../utilities/event.cjs"),a=require("../../../utilities/date.cjs");let o=require("react");o=e.__toESM(o,1);let s=require("classnames");s=e.__toESM(s,1);let c=require("react/jsx-runtime");var l=(e,{date:t,onSelectDate:n})=>{n(e,{date:t})},u=(e,{date:n,onCalendarBlur:a,onSelectDate:o,onKeyboardNavigateToPreviousDay:s,onKeyboardNavigateToNextDay:c,onKeyboardNavigateToPreviousWeek:l,onKeyboardNavigateToNextWeek:u,direction:d})=>{let f={[r.default.SPACE]:()=>{o(e,{date:n})},[r.default.ENTER]:()=>{o(e,{date:n})},[r.default.TAB]:()=>{a(e,{direction:`next`})},[r.default.LEFT]:()=>{d===t.DIRECTIONS.RTL?c(e,{date:n}):s(e,{date:n})},[r.default.RIGHT]:()=>{d===t.DIRECTIONS.RTL?s(e,{date:n}):c(e,{date:n})},[r.default.UP]:()=>{l(e,{date:n})},[r.default.DOWN]:()=>{u(e,{date:n})}},p={[r.default.TAB]:()=>{a(e,{direction:`previous`})}};e.key&&(e.shiftKey&&
|
|
1
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../utilities/UNSAFE_direction/index.cjs"),n=require("../../utilities/UNSAFE_direction/private/language-direction.cjs"),r=require("../../../utilities/key-code.cjs"),i=require("../../../utilities/event.cjs"),a=require("../../../utilities/date.cjs");let o=require("react");o=e.__toESM(o,1);let s=require("classnames");s=e.__toESM(s,1);let c=require("react/jsx-runtime");var l=(e,{date:t,onSelectDate:n})=>{n(e,{date:t})},u=(e,{date:n,onCalendarBlur:a,onSelectDate:o,onKeyboardNavigateToPreviousDay:s,onKeyboardNavigateToNextDay:c,onKeyboardNavigateToPreviousWeek:l,onKeyboardNavigateToNextWeek:u,direction:d})=>{let f={[r.default.SPACE]:()=>{o(e,{date:n})},[r.default.ENTER]:()=>{o(e,{date:n})},[r.default.TAB]:()=>{a(e,{direction:`next`})},[r.default.LEFT]:()=>{d===t.DIRECTIONS.RTL?c(e,{date:n}):s(e,{date:n})},[r.default.RIGHT]:()=>{d===t.DIRECTIONS.RTL?s(e,{date:n}):c(e,{date:n})},[r.default.UP]:()=>{l(e,{date:n})},[r.default.DOWN]:()=>{u(e,{date:n})}},p={[r.default.TAB]:()=>{a(e,{direction:`previous`})}};e.key&&(e.shiftKey&&p[e.key]?(i.default.trapEvent(e),p[e.key]()):f[e.key]&&(i.default.trapEvent(e),f[e.key]()))},d=e=>{let t=a.default.isSameMonth(e.date,e.initialDateForCalendarRender),n=a.default.isToday(e.date),r=a.default.isSameDay(e.date,e.selectedDate),i=a.default.isFirstDayOfMonth(e.date),o=!t||e.disabled;return(0,c.jsx)(`td`,{"aria-disabled":o,"aria-selected":r,className:(0,s.default)({"slds-is-today":n,"slds-disabled-text":o,"slds-is-selected":r}),onClick:t=>{l(t,{date:e.date,onSelectDate:e.onSelectDate})},onKeyDown:t=>{u(t,{...e})},ref:n=>{r&&e.selectedDateRef?.(n),e.calendarHasFocus&&a.default.isSameDay(e.focusedDate,e.date)&&t&&e.onRequestInternalFocusDate?.(void 0,{date:e.date,ref:n})},role:`gridcell`,tabIndex:!e.calendarHasFocus&&i&&t?0:-1,children:(0,c.jsxs)(`span`,{className:`slds-day`,children:[n?(0,c.jsx)(`span`,{className:`slds-assistive-text`,children:`${e.todayLabel}: `}):null,e.date.getDate()]})})};d.displayName=`SLDSDatepickerCalendarDay`;var f=n.default(d);exports.default=f;
|
|
2
2
|
//# sourceMappingURL=day.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"day.cjs","names":[],"sources":["../../../../../components/date-picker/private/day.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 type { DatePickerFocusDirection } from '../date-picker';\nimport React, { type SyntheticEvent } from 'react';\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 EventUtil from '../../../utilities/event';\nimport DateUtil from '../../../utilities/date';\nimport KEYS from '../../../utilities/key-code';\n\nimport { DIRECTIONS } from '../../utilities/UNSAFE_direction';\nimport LanguageDirection from '../../utilities/UNSAFE_direction/private/language-direction';\n\nexport interface DayProps {\n\t/** If elements within the calendar have focus */\n\tcalendarHasFocus?: boolean;\n\t/** Date of day */\n\tdate: Date;\n\t/** If date is disabled */\n\tdisabled?: boolean;\n\t/** Date used to create calendar that is displayed */\n\tinitialDateForCalendarRender: Date;\n\t/** Date that has focus */\n\tfocusedDate?: Date;\n\t/** Called when focus moves off calendar */\n\tonCalendarBlur: (\n\t\tevent: SyntheticEvent,\n\t\tdata: { direction: DatePickerFocusDirection }\n\t) => void;\n\t/** Called on next day keyboard navigation */\n\tonKeyboardNavigateToNextDay: (\n\t\tevent: SyntheticEvent,\n\t\tdata: { date: Date }\n\t) => void;\n\t/** Called on next week keyboard navigation */\n\tonKeyboardNavigateToNextWeek: (\n\t\tevent: SyntheticEvent,\n\t\tdata: { date: Date }\n\t) => void;\n\t/** Called on previous day keyboard navigation */\n\tonKeyboardNavigateToPreviousDay: (\n\t\tevent: SyntheticEvent,\n\t\tdata: { date: Date }\n\t) => void;\n\t/** Called on previous week keyboard navigation */\n\tonKeyboardNavigateToPreviousWeek: (\n\t\tevent: SyntheticEvent,\n\t\tdata: { date: Date }\n\t) => void;\n\t/** Called when internal focus date requested */\n\tonRequestInternalFocusDate?: (\n\t\tevent: SyntheticEvent | undefined,\n\t\tdata: { date: Date; ref?: HTMLElement | null; triggerCallback?: boolean }\n\t) => void;\n\t/** Called when a date is selected */\n\tonSelectDate: (event: SyntheticEvent, data: { date: Date }) => void;\n\t/** Currently selected date */\n\tselectedDate?: Date;\n\t/** Ref callback for selected date cell */\n\tselectedDateRef?: (ref: HTMLElement | null) => void;\n\t/** Label for today shortcut */\n\ttodayLabel: string;\n\t/** Text direction */\n\tdirection?: 'ltr' | 'rtl';\n}\n\ntype DayHandlerProps = Pick<\n\tDayProps,\n\t| 'date'\n\t| 'onCalendarBlur'\n\t| 'onSelectDate'\n\t| 'onKeyboardNavigateToPreviousDay'\n\t| 'onKeyboardNavigateToNextDay'\n\t| 'onKeyboardNavigateToPreviousWeek'\n\t| 'onKeyboardNavigateToNextWeek'\n\t| 'direction'\n>;\n\nconst handleClick = (\n\tevent: SyntheticEvent,\n\t{ date, onSelectDate }: Pick<DayProps, 'date' | 'onSelectDate'>\n) => {\n\tonSelectDate(event, { date });\n};\n\nconst handleKeyDown = (\n\tevent: React.KeyboardEvent,\n\t{\n\t\tdate,\n\t\tonCalendarBlur,\n\t\tonSelectDate,\n\t\tonKeyboardNavigateToPreviousDay,\n\t\tonKeyboardNavigateToNextDay,\n\t\tonKeyboardNavigateToPreviousWeek,\n\t\tonKeyboardNavigateToNextWeek,\n\t\tdirection,\n\t}: DayHandlerProps\n) => {\n\tconst keyDownCallbacks: Record<string, () => void> = {\n\t\t[KEYS.SPACE]: () => {\n\t\t\tonSelectDate(event, { date });\n\t\t},\n\t\t[KEYS.ENTER]: () => {\n\t\t\tonSelectDate(event, { date });\n\t\t},\n\t\t[KEYS.TAB]: () => {\n\t\t\tonCalendarBlur(event, { direction: 'next' });\n\t\t},\n\t\t[KEYS.LEFT]: () => {\n\t\t\tif (direction === DIRECTIONS.RTL) {\n\t\t\t\tonKeyboardNavigateToNextDay(event, { date });\n\t\t\t} else {\n\t\t\t\tonKeyboardNavigateToPreviousDay(event, { date });\n\t\t\t}\n\t\t},\n\t\t[KEYS.RIGHT]: () => {\n\t\t\tif (direction === DIRECTIONS.RTL) {\n\t\t\t\tonKeyboardNavigateToPreviousDay(event, { date });\n\t\t\t} else {\n\t\t\t\tonKeyboardNavigateToNextDay(event, { date });\n\t\t\t}\n\t\t},\n\t\t[KEYS.UP]: () => {\n\t\t\tonKeyboardNavigateToPreviousWeek(event, { date });\n\t\t},\n\t\t[KEYS.DOWN]: () => {\n\t\t\tonKeyboardNavigateToNextWeek(event, { date });\n\t\t},\n\t};\n\n\tconst shiftKeyDownCallbacks: Record<string, () => void> = {\n\t\t[KEYS.TAB]: () => {\n\t\t\tonCalendarBlur(event, { direction: 'previous' });\n\t\t},\n\t};\n\n\tif (event.key) {\n\t\tif (event.shiftKey &&
|
|
1
|
+
{"version":3,"file":"day.cjs","names":[],"sources":["../../../../../components/date-picker/private/day.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 type { DatePickerFocusDirection } from '../date-picker';\nimport React, { type SyntheticEvent } from 'react';\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 EventUtil from '../../../utilities/event';\nimport DateUtil from '../../../utilities/date';\nimport KEYS from '../../../utilities/key-code';\n\nimport { DIRECTIONS } from '../../utilities/UNSAFE_direction';\nimport LanguageDirection from '../../utilities/UNSAFE_direction/private/language-direction';\n\nexport interface DayProps {\n\t/** If elements within the calendar have focus */\n\tcalendarHasFocus?: boolean;\n\t/** Date of day */\n\tdate: Date;\n\t/** If date is disabled */\n\tdisabled?: boolean;\n\t/** Date used to create calendar that is displayed */\n\tinitialDateForCalendarRender: Date;\n\t/** Date that has focus */\n\tfocusedDate?: Date;\n\t/** Called when focus moves off calendar */\n\tonCalendarBlur: (\n\t\tevent: SyntheticEvent,\n\t\tdata: { direction: DatePickerFocusDirection }\n\t) => void;\n\t/** Called on next day keyboard navigation */\n\tonKeyboardNavigateToNextDay: (\n\t\tevent: SyntheticEvent,\n\t\tdata: { date: Date }\n\t) => void;\n\t/** Called on next week keyboard navigation */\n\tonKeyboardNavigateToNextWeek: (\n\t\tevent: SyntheticEvent,\n\t\tdata: { date: Date }\n\t) => void;\n\t/** Called on previous day keyboard navigation */\n\tonKeyboardNavigateToPreviousDay: (\n\t\tevent: SyntheticEvent,\n\t\tdata: { date: Date }\n\t) => void;\n\t/** Called on previous week keyboard navigation */\n\tonKeyboardNavigateToPreviousWeek: (\n\t\tevent: SyntheticEvent,\n\t\tdata: { date: Date }\n\t) => void;\n\t/** Called when internal focus date requested */\n\tonRequestInternalFocusDate?: (\n\t\tevent: SyntheticEvent | undefined,\n\t\tdata: { date: Date; ref?: HTMLElement | null; triggerCallback?: boolean }\n\t) => void;\n\t/** Called when a date is selected */\n\tonSelectDate: (event: SyntheticEvent, data: { date: Date }) => void;\n\t/** Currently selected date */\n\tselectedDate?: Date;\n\t/** Ref callback for selected date cell */\n\tselectedDateRef?: (ref: HTMLElement | null) => void;\n\t/** Label for today shortcut */\n\ttodayLabel: string;\n\t/** Text direction */\n\tdirection?: 'ltr' | 'rtl';\n}\n\ntype DayHandlerProps = Pick<\n\tDayProps,\n\t| 'date'\n\t| 'onCalendarBlur'\n\t| 'onSelectDate'\n\t| 'onKeyboardNavigateToPreviousDay'\n\t| 'onKeyboardNavigateToNextDay'\n\t| 'onKeyboardNavigateToPreviousWeek'\n\t| 'onKeyboardNavigateToNextWeek'\n\t| 'direction'\n>;\n\nconst handleClick = (\n\tevent: SyntheticEvent,\n\t{ date, onSelectDate }: Pick<DayProps, 'date' | 'onSelectDate'>\n) => {\n\tonSelectDate(event, { date });\n};\n\nconst handleKeyDown = (\n\tevent: React.KeyboardEvent,\n\t{\n\t\tdate,\n\t\tonCalendarBlur,\n\t\tonSelectDate,\n\t\tonKeyboardNavigateToPreviousDay,\n\t\tonKeyboardNavigateToNextDay,\n\t\tonKeyboardNavigateToPreviousWeek,\n\t\tonKeyboardNavigateToNextWeek,\n\t\tdirection,\n\t}: DayHandlerProps\n) => {\n\tconst keyDownCallbacks: Record<string, () => void> = {\n\t\t[KEYS.SPACE]: () => {\n\t\t\tonSelectDate(event, { date });\n\t\t},\n\t\t[KEYS.ENTER]: () => {\n\t\t\tonSelectDate(event, { date });\n\t\t},\n\t\t[KEYS.TAB]: () => {\n\t\t\tonCalendarBlur(event, { direction: 'next' });\n\t\t},\n\t\t[KEYS.LEFT]: () => {\n\t\t\tif (direction === DIRECTIONS.RTL) {\n\t\t\t\tonKeyboardNavigateToNextDay(event, { date });\n\t\t\t} else {\n\t\t\t\tonKeyboardNavigateToPreviousDay(event, { date });\n\t\t\t}\n\t\t},\n\t\t[KEYS.RIGHT]: () => {\n\t\t\tif (direction === DIRECTIONS.RTL) {\n\t\t\t\tonKeyboardNavigateToPreviousDay(event, { date });\n\t\t\t} else {\n\t\t\t\tonKeyboardNavigateToNextDay(event, { date });\n\t\t\t}\n\t\t},\n\t\t[KEYS.UP]: () => {\n\t\t\tonKeyboardNavigateToPreviousWeek(event, { date });\n\t\t},\n\t\t[KEYS.DOWN]: () => {\n\t\t\tonKeyboardNavigateToNextWeek(event, { date });\n\t\t},\n\t};\n\n\tconst shiftKeyDownCallbacks: Record<string, () => void> = {\n\t\t[KEYS.TAB]: () => {\n\t\t\tonCalendarBlur(event, { direction: 'previous' });\n\t\t},\n\t};\n\n\tif (event.key) {\n\t\tif (event.shiftKey && shiftKeyDownCallbacks[event.key]) {\n\t\t\tEventUtil.trapEvent(event);\n\t\t\tshiftKeyDownCallbacks[event.key]();\n\t\t} else if (keyDownCallbacks[event.key]) {\n\t\t\tEventUtil.trapEvent(event);\n\t\t\tkeyDownCallbacks[event.key]();\n\t\t}\n\t}\n};\n\nconst DatepickerCalendarDay = (props: DayProps) => {\n\tconst isCurrentMonth = DateUtil.isSameMonth(\n\t\tprops.date,\n\t\tprops.initialDateForCalendarRender\n\t);\n\tconst isToday = DateUtil.isToday(props.date);\n\tconst isSelectedDay = DateUtil.isSameDay(props.date, props.selectedDate);\n\tconst isFirstDayOfMonth = DateUtil.isFirstDayOfMonth(props.date);\n\tconst isDisabled = !isCurrentMonth || props.disabled;\n\n\treturn (\n\t\t/* eslint-disable jsx-a11y/no-static-element-interactions */\n\t\t<td\n\t\t\taria-disabled={isDisabled}\n\t\t\taria-selected={isSelectedDay}\n\t\t\tclassName={classNames({\n\t\t\t\t'slds-is-today': isToday,\n\t\t\t\t'slds-disabled-text': isDisabled,\n\t\t\t\t'slds-is-selected': isSelectedDay,\n\t\t\t})}\n\t\t\tonClick={(event) => {\n\t\t\t\thandleClick(event, {\n\t\t\t\t\tdate: props.date,\n\t\t\t\t\tonSelectDate: props.onSelectDate,\n\t\t\t\t});\n\t\t\t}}\n\t\t\tonKeyDown={(event) => {\n\t\t\t\thandleKeyDown(event, {\n\t\t\t\t\t...props,\n\t\t\t\t});\n\t\t\t}}\n\t\t\tref={(component) => {\n\t\t\t\tif (isSelectedDay) {\n\t\t\t\t\tprops.selectedDateRef?.(component);\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\tprops.calendarHasFocus &&\n\t\t\t\t\tDateUtil.isSameDay(props.focusedDate, props.date) &&\n\t\t\t\t\tisCurrentMonth\n\t\t\t\t) {\n\t\t\t\t\tprops.onRequestInternalFocusDate?.(undefined, {\n\t\t\t\t\t\tdate: props.date,\n\t\t\t\t\t\tref: component,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}}\n\t\t\trole=\"gridcell\"\n\t\t\ttabIndex={\n\t\t\t\t!props.calendarHasFocus && isFirstDayOfMonth && isCurrentMonth ? 0 : -1\n\t\t\t}\n\t\t>\n\t\t\t{/* eslint-enable jsx-a11y/no-static-element-interactions */}\n\t\t\t<span className=\"slds-day\">\n\t\t\t\t{isToday ? (\n\t\t\t\t\t<span className=\"slds-assistive-text\">{`${props.todayLabel}: `}</span>\n\t\t\t\t) : null}\n\t\t\t\t{props.date.getDate()}\n\t\t\t</span>\n\t\t</td>\n\t);\n};\n\nDatepickerCalendarDay.displayName = 'SLDSDatepickerCalendarDay';\n\nexport default LanguageDirection(DatepickerCalendarDay);\n"],"mappings":"wbAoFA,IAAM,GACL,EACA,CAAE,OAAM,kBACJ,CACJ,EAAa,EAAO,CAAE,MAAK,CAAC,CAC7B,EAEM,GACL,EACA,CACC,OACA,iBACA,eACA,kCACA,8BACA,mCACA,+BACA,eAEG,CACJ,IAAM,EAA+C,EACnD,EAAA,QAAK,WAAc,CACnB,EAAa,EAAO,CAAE,MAAK,CAAC,CAC7B,GACC,EAAA,QAAK,WAAc,CACnB,EAAa,EAAO,CAAE,MAAK,CAAC,CAC7B,GACC,EAAA,QAAK,SAAY,CACjB,EAAe,EAAO,CAAE,UAAW,MAAO,C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B,GAAG,CACJ,CAAC,CACF,EACA,IAAM,GAAc,CACf,GACH,EAAM,kBAAkB,CAAS,EAIjC,EAAM,kBACN,EAAA,QAAS,UAAU,EAAM,YAAa,EAAM,IAAI,GAChD,GAEA,EAAM,6BAA6B,IAAA,GAAW,CAC7C,KAAM,EAAM,KACZ,IAAK,CACN,CAAC,CAEH,EACA,KAAK,WACL,SACC,CAAC,EAAM,kBAAoB,GAAqB,EAAiB,EAAI,GAItE,UAAA,EAAA,EAAA,KAAA,CAAC,OAAD,CAAM,UAAU,WAAhB,SAAA,CACE,GACA,EAAA,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,sBAAuB,SAAA,GAAG,EAAM,WAAW,GAAU,CAAA,EAClE,KACH,EAAM,KAAK,QAAQ,CACf,GACH,CAAA,CAEN,EAEA,EAAsB,YAAc,4BAEpC,IAAA,EAAe,EAAA,QAAkB,CAAqB"}
|
|
@@ -1,9 +1,2 @@
|
|
|
1
|
-
const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../utilities/constants.cjs"),n=require("../../utilities/generate-id.cjs"),r=require("./private/file-figure.cjs"),i=require("./private/file-actions.cjs");let a=require("react");a=e.__toESM(a,1);let o=require("classnames");o=e.__toESM(o,1);let s=require("react/jsx-runtime");var c=t.FILES_FILE,l={assistiveText:{download:`download`,link:`Preview:`,loading:`loading`,moreActions:`more actions`},href:`#`,isLoading:!1,hasNoVisibleTitle:!1},u=class
|
|
2
|
-
.dsr-file__more-actions-dropdown ul.dropdown__list li.slds-dropdown__item > a:before
|
|
3
|
-
{ background: none; }
|
|
4
|
-
.dsr-file__more-actions-dropdown ul.dropdown__list li.slds-dropdown__item > a:after
|
|
5
|
-
{ background: none; }
|
|
6
|
-
.dsr-file__more-actions > button:first-child
|
|
7
|
-
{ border-radius: 0 0.25rem 0.25rem 0!important;}
|
|
8
|
-
`})}generatedId;constructor(e){super(e),this.generatedId=n.default()}getId(){return this.props.id||this.generatedId}handleOnClickImage=e=>{this.props.href===`#`&&e.preventDefault(),this.props.onClickImage&&this.props.onClickImage(e)};render(){let t={...l.assistiveText,...this.props.assistiveText};return(0,s.jsxs)(`div`,{id:this.getId(),className:(0,o.default)(`slds-file`,`slds-file_card`,this.props.hasNoVisibleTitle?null:`slds-has-title`,this.props.className),children:[(0,s.jsxs)(`figure`,{children:[(0,s.jsx)(`a`,{href:this.props.href,className:(0,o.default)(`slds-file__crop`,`slds-file__crop_${this.props.crop??`16-by-9`}`),onClick:this.handleOnClickImage,children:(0,s.jsx)(r.default,{assistiveText:t,labels:{title:this.props.labels.title},isLoading:this.props.isLoading,image:this.props.image,icon:this.props.icon})}),this.props.hasNoVisibleTitle?null:(0,s.jsxs)(`figcaption`,{className:`slds-file__title slds-file__title_card`,children:[(0,s.jsx)(`div`,{className:`slds-media__figure slds-line-height_reset`,children:this.props.icon?a.default.cloneElement(this.props.icon,{size:`x-small`}):null}),(0,s.jsx)(`div`,{className:`slds-media__body`,children:(0,s.jsx)(`span`,{className:`slds-file__text slds-truncate`,title:this.props.labels.title,children:this.props.labels.title})})]})]}),this.props.externalIcon?(0,s.jsx)(`div`,{className:`slds-file__external-icon`,children:a.default.cloneElement(this.props.externalIcon,{containerClassName:(0,o.default)(`slds-file__icon slds-icon_container`,this.props.externalIcon.props.containerClassName)})}):null,this.props.moreActionsDropdown?e.injectMoreActionsStyles():null,(0,s.jsx)(i.default,{assistiveText:t,hasNoVisibleTitle:this.props.hasNoVisibleTitle,onClickDownload:this.props.onClickDownload,moreActionsDropdown:this.props.moreActionsDropdown})]})}};exports.default=u;
|
|
1
|
+
const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../utilities/constants.cjs"),n=require("../../utilities/generate-id.cjs"),r=require("./private/file-figure.cjs"),i=require("./private/file-actions.cjs");let a=require("react");a=e.__toESM(a,1);let o=require("classnames");o=e.__toESM(o,1);let s=require("react/jsx-runtime");var c=t.FILES_FILE,l={assistiveText:{download:`download`,link:`Preview:`,loading:`loading`,moreActions:`more actions`},href:`#`,isLoading:!1,hasNoVisibleTitle:!1},u=class extends a.default.Component{static displayName=c;static defaultProps=l;static injectMoreActionsStyles(){return null}generatedId;constructor(e){super(e),this.generatedId=n.default()}getId(){return this.props.id||this.generatedId}handleOnClickImage=e=>{this.props.href===`#`&&e.preventDefault(),this.props.onClickImage&&this.props.onClickImage(e)};render(){let e={...l.assistiveText,...this.props.assistiveText};return(0,s.jsxs)(`div`,{id:this.getId(),className:(0,o.default)(`slds-file`,`slds-file_card`,this.props.hasNoVisibleTitle?null:`slds-has-title`,this.props.className),children:[(0,s.jsxs)(`figure`,{children:[(0,s.jsx)(`a`,{href:this.props.href,className:(0,o.default)(`slds-file__crop`,`slds-file__crop_${this.props.crop??`16-by-9`}`),onClick:this.handleOnClickImage,children:(0,s.jsx)(r.default,{assistiveText:e,labels:{title:this.props.labels.title},isLoading:this.props.isLoading,image:this.props.image,icon:this.props.icon})}),this.props.hasNoVisibleTitle?null:(0,s.jsxs)(`figcaption`,{className:`slds-file__title slds-file__title_card`,children:[(0,s.jsx)(`div`,{className:`slds-media__figure slds-line-height_reset`,children:this.props.icon?a.default.cloneElement(this.props.icon,{size:`x-small`}):null}),(0,s.jsx)(`div`,{className:`slds-media__body`,children:(0,s.jsx)(`span`,{className:`slds-file__text slds-truncate`,title:this.props.labels.title,children:this.props.labels.title})})]})]}),this.props.externalIcon?(0,s.jsx)(`div`,{className:`slds-file__external-icon`,children:a.default.cloneElement(this.props.externalIcon,{containerClassName:(0,o.default)(`slds-file__icon slds-icon_container`,this.props.externalIcon.props.containerClassName)})}):null,(0,s.jsx)(i.default,{assistiveText:e,hasNoVisibleTitle:this.props.hasNoVisibleTitle,onClickDownload:this.props.onClickDownload,moreActionsDropdown:this.props.moreActionsDropdown})]})}};exports.default=u;
|
|
9
2
|
//# sourceMappingURL=file.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.cjs","names":[],"sources":["../../../../components/files/file.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// Implements the [Files design pattern](https://lightningdesignsystem.com/components/files/) in React.\n// Based on SLDS v2.4.0\nimport React, { type ReactElement, type ReactNode } from 'react';\nimport classNames from 'classnames';\n\nimport { FILES_FILE } from '../../utilities/constants';\nimport generateId from '../../utilities/generate-id';\n\nimport type { IconProps } from '../icon';\nimport type { MenuDropdownProps } from '../menu-dropdown';\nimport FileFigure from './private/file-figure';\nimport FileActions from './private/file-actions';\n\nconst displayName = FILES_FILE;\n\nexport interface FileAssistiveText {\n\tdownload?: string;\n\timage?: string;\n\tlink?: string;\n\tloading?: string;\n\tmoreActions?: string;\n}\n\nexport interface FileProps {\n\t/**\n\t * **Assistive text for accessibility**\n\t * * download - description for the download button if present\n\t * * image - description for the file image\n\t * * link - description for the file link\n\t * * loading - description for the loading spinner if present\n\t * * moreActions - description for the more actions dropdown if present\n\t */\n\tassistiveText?: FileAssistiveText;\n\t/**\n\t * CSS class names to be added to the container element. `array`, `object`, or `string` are accepted.\n\t */\n\tclassName?: unknown[] | Record<string, unknown> | string;\n\t/**\n\t * Controls different cropping aspect ratios for the component. Inside `Files`, defaults to its `crop`; otherwise `16-by-9`.\n\t */\n\tcrop?: '16-by-9' | '4-by-3' | '1-by-1';\n\t/**\n\t * `Icon` shown in the top left corner of the file. Its `containerClassName` is added to the file's own classes.\n\t */\n\texternalIcon?: ReactElement<IconProps>;\n\t/**\n\t * Controls whether the file's title should be visible\n\t */\n\thasNoVisibleTitle?: boolean;\n\t/**\n\t * Href attribute for image. Defaults to `#`, which does not navigate, so `onClickImage`\n\t * can handle the click without a URL.\n\t */\n\thref?: string;\n\t/**\n\t * `Icon` associated with the file. The file renders it in the preview and the title, and sets its `size` in each.\n\t */\n\ticon?: ReactElement<IconProps>;\n\t/**\n\t * HTML id for component.\n\t */\n\tid?: string;\n\t/**\n\t * Link to thumbnail image\n\t */\n\timage?: string;\n\t/**\n\t * Controls whether file preview is loading\n\t */\n\tisLoading?: boolean;\n\t/**\n\t * Labels for the File Component\n\t * * title - title for the file, shown under the preview and used as its name.\n\t */\n\tlabels: {\n\t\ttitle: string;\n\t};\n\t/**\n\t * `MenuDropdown` for the more actions button; doesn't show more actions button if empty.\n\t * The file styles it as an icon button; props you set on it win.\n\t */\n\tmoreActionsDropdown?: ReactElement<Partial<MenuDropdownProps>>;\n\t/**\n\t * Action to be done on clicking download button; doesn't show download button if empty\n\t */\n\tonClickDownload?: (event: React.MouseEvent) => void;\n\t/**\n\t * Function that is called when image is clicked; can be used instead of href for more advanced event handling\n\t */\n\tonClickImage?: (event: React.MouseEvent) => void;\n}\n\nconst defaultProps: Pick<\n\tFileProps,\n\t'assistiveText' | 'hasNoVisibleTitle' | 'href' | 'isLoading'\n> = {\n\tassistiveText: {\n\t\tdownload: 'download',\n\t\tlink: 'Preview:',\n\t\tloading: 'loading',\n\t\tmoreActions: 'more actions',\n\t},\n\thref: '#',\n\tisLoading: false,\n\thasNoVisibleTitle: false,\n};\n\n/**\n * File is a component that represents content uploaded as an attachment.\n */\nclass File extends React.Component<FileProps> {\n\tstatic displayName = displayName;\n\n\tstatic defaultProps = defaultProps;\n\n\
|
|
1
|
+
{"version":3,"file":"file.cjs","names":[],"sources":["../../../../components/files/file.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// Implements the [Files design pattern](https://lightningdesignsystem.com/components/files/) in React.\n// Based on SLDS v2.4.0\nimport React, { type ReactElement, type ReactNode } from 'react';\nimport classNames from 'classnames';\n\nimport { FILES_FILE } from '../../utilities/constants';\nimport generateId from '../../utilities/generate-id';\n\nimport type { IconProps } from '../icon';\nimport type { MenuDropdownProps } from '../menu-dropdown';\nimport FileFigure from './private/file-figure';\nimport FileActions from './private/file-actions';\n\nconst displayName = FILES_FILE;\n\nexport interface FileAssistiveText {\n\tdownload?: string;\n\timage?: string;\n\tlink?: string;\n\tloading?: string;\n\tmoreActions?: string;\n}\n\nexport interface FileProps {\n\t/**\n\t * **Assistive text for accessibility**\n\t * * download - description for the download button if present\n\t * * image - description for the file image\n\t * * link - description for the file link\n\t * * loading - description for the loading spinner if present\n\t * * moreActions - description for the more actions dropdown if present\n\t */\n\tassistiveText?: FileAssistiveText;\n\t/**\n\t * CSS class names to be added to the container element. `array`, `object`, or `string` are accepted.\n\t */\n\tclassName?: unknown[] | Record<string, unknown> | string;\n\t/**\n\t * Controls different cropping aspect ratios for the component. Inside `Files`, defaults to its `crop`; otherwise `16-by-9`.\n\t */\n\tcrop?: '16-by-9' | '4-by-3' | '1-by-1';\n\t/**\n\t * `Icon` shown in the top left corner of the file. Its `containerClassName` is added to the file's own classes.\n\t */\n\texternalIcon?: ReactElement<IconProps>;\n\t/**\n\t * Controls whether the file's title should be visible\n\t */\n\thasNoVisibleTitle?: boolean;\n\t/**\n\t * Href attribute for image. Defaults to `#`, which does not navigate, so `onClickImage`\n\t * can handle the click without a URL.\n\t */\n\thref?: string;\n\t/**\n\t * `Icon` associated with the file. The file renders it in the preview and the title, and sets its `size` in each.\n\t */\n\ticon?: ReactElement<IconProps>;\n\t/**\n\t * HTML id for component.\n\t */\n\tid?: string;\n\t/**\n\t * Link to thumbnail image\n\t */\n\timage?: string;\n\t/**\n\t * Controls whether file preview is loading\n\t */\n\tisLoading?: boolean;\n\t/**\n\t * Labels for the File Component\n\t * * title - title for the file, shown under the preview and used as its name.\n\t */\n\tlabels: {\n\t\ttitle: string;\n\t};\n\t/**\n\t * `MenuDropdown` for the more actions button; doesn't show more actions button if empty.\n\t * The file styles it as an icon button; props you set on it win.\n\t */\n\tmoreActionsDropdown?: ReactElement<Partial<MenuDropdownProps>>;\n\t/**\n\t * Action to be done on clicking download button; doesn't show download button if empty\n\t */\n\tonClickDownload?: (event: React.MouseEvent) => void;\n\t/**\n\t * Function that is called when image is clicked; can be used instead of href for more advanced event handling\n\t */\n\tonClickImage?: (event: React.MouseEvent) => void;\n}\n\nconst defaultProps: Pick<\n\tFileProps,\n\t'assistiveText' | 'hasNoVisibleTitle' | 'href' | 'isLoading'\n> = {\n\tassistiveText: {\n\t\tdownload: 'download',\n\t\tlink: 'Preview:',\n\t\tloading: 'loading',\n\t\tmoreActions: 'more actions',\n\t},\n\thref: '#',\n\tisLoading: false,\n\thasNoVisibleTitle: false,\n};\n\n/**\n * File is a component that represents content uploaded as an attachment.\n */\nclass File extends React.Component<FileProps> {\n\tstatic displayName = displayName;\n\n\tstatic defaultProps = defaultProps;\n\n\t/**\n\t * @deprecated The more-actions button now uses SLDS's `slds-button_last`,\n\t * so this returns `null` and `File` no longer calls it. It will be removed\n\t * in a future major.\n\t */\n\tstatic injectMoreActionsStyles(): ReactNode {\n\t\treturn null;\n\t}\n\n\tgeneratedId: string;\n\n\tconstructor(props: FileProps) {\n\t\tsuper(props);\n\n\t\tthis.generatedId = generateId();\n\t}\n\n\t/**\n\t * Get the File's HTML id. Generate a new one if no ID present.\n\t */\n\tgetId() {\n\t\treturn this.props.id || this.generatedId;\n\t}\n\n\thandleOnClickImage = (event: React.MouseEvent) => {\n\t\tif (this.props.href === '#') {\n\t\t\tevent.preventDefault();\n\t\t}\n\n\t\tif (this.props.onClickImage) {\n\t\t\tthis.props.onClickImage(event);\n\t\t}\n\t};\n\n\trender() {\n\t\tconst assistiveText = {\n\t\t\t...defaultProps.assistiveText,\n\t\t\t...this.props.assistiveText,\n\t\t};\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tid={this.getId()}\n\t\t\t\tclassName={classNames(\n\t\t\t\t\t'slds-file',\n\t\t\t\t\t'slds-file_card',\n\t\t\t\t\t!this.props.hasNoVisibleTitle ? 'slds-has-title' : null,\n\t\t\t\t\tthis.props.className as string\n\t\t\t\t)}\n\t\t\t>\n\t\t\t\t<figure>\n\t\t\t\t\t<a\n\t\t\t\t\t\thref={this.props.href}\n\t\t\t\t\t\tclassName={classNames(\n\t\t\t\t\t\t\t'slds-file__crop',\n\t\t\t\t\t\t\t`slds-file__crop_${this.props.crop ?? '16-by-9'}`\n\t\t\t\t\t\t)}\n\t\t\t\t\t\tonClick={this.handleOnClickImage}\n\t\t\t\t\t>\n\t\t\t\t\t\t<FileFigure\n\t\t\t\t\t\t\tassistiveText={assistiveText}\n\t\t\t\t\t\t\tlabels={{\n\t\t\t\t\t\t\t\ttitle: this.props.labels.title,\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\tisLoading={this.props.isLoading}\n\t\t\t\t\t\t\timage={this.props.image}\n\t\t\t\t\t\t\ticon={this.props.icon}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</a>\n\t\t\t\t\t{!this.props.hasNoVisibleTitle ? (\n\t\t\t\t\t\t<figcaption className=\"slds-file__title slds-file__title_card\">\n\t\t\t\t\t\t\t<div className=\"slds-media__figure slds-line-height_reset\">\n\t\t\t\t\t\t\t\t{this.props.icon\n\t\t\t\t\t\t\t\t\t? React.cloneElement(this.props.icon, {\n\t\t\t\t\t\t\t\t\t\t\tsize: 'x-small',\n\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t: null}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div className=\"slds-media__body\">\n\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\tclassName=\"slds-file__text slds-truncate\"\n\t\t\t\t\t\t\t\t\ttitle={this.props.labels.title}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{this.props.labels.title}\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</figcaption>\n\t\t\t\t\t) : null}\n\t\t\t\t</figure>\n\t\t\t\t{this.props.externalIcon ? (\n\t\t\t\t\t<div className=\"slds-file__external-icon\">\n\t\t\t\t\t\t{React.cloneElement(this.props.externalIcon, {\n\t\t\t\t\t\t\tcontainerClassName: classNames(\n\t\t\t\t\t\t\t\t'slds-file__icon slds-icon_container',\n\t\t\t\t\t\t\t\tthis.props.externalIcon.props.containerClassName\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t})}\n\t\t\t\t\t</div>\n\t\t\t\t) : null}\n\t\t\t\t<FileActions\n\t\t\t\t\tassistiveText={assistiveText}\n\t\t\t\t\thasNoVisibleTitle={this.props.hasNoVisibleTitle}\n\t\t\t\t\tonClickDownload={this.props.onClickDownload}\n\t\t\t\t\tmoreActionsDropdown={this.props.moreActionsDropdown}\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n}\n\nexport default File;\n"],"mappings":"uVAgBA,IAAM,EAAc,EAAA,WA+Ed,EAGF,CACH,cAAe,CACd,SAAU,WACV,KAAM,WACN,QAAS,UACT,YAAa,cACd,EACA,KAAM,IACN,UAAW,GACX,kBAAmB,EACpB,EAKM,EAAN,cAAmB,EAAA,QAAM,SAAqB,CAC7C,OAAO,YAAc,EAErB,OAAO,aAAe,EAOtB,OAAO,yBAAqC,CAC3C,OAAO,IACR,CAEA,YAEA,YAAY,EAAkB,CAC7B,MAAM,CAAK,EAEX,KAAK,YAAc,EAAA,QAAW,CAC/B,CAKA,OAAQ,CACP,OAAO,KAAK,MAAM,IAAM,KAAK,WAC9B,CAEA,mBAAsB,GAA4B,CAC7C,KAAK,MAAM,OAAS,KACvB,EAAM,eAAe,EAGlB,KAAK,MAAM,cACd,KAAK,MAAM,aAAa,CAAK,CAE/B,EAEA,QAAS,CACR,IAAM,EAAgB,CACrB,GAAG,EAAa,cAChB,GAAG,KAAK,MAAM,aACf,EAEA,OACC,EAAA,EAAA,KAAA,CAAC,MAAD,CACC,GAAI,KAAK,MAAM,EACf,WAAA,EAAW,EAAA,QAAA,CACV,YACA,iBACC,KAAK,MAAM,kBAAuC,KAAnB,iBAChC,KAAK,MAAM,SACZ,EAPD,SAAA,EASC,EAAA,EAAA,KAAA,CAAC,SAAD,CAAA,SAAA,EACC,EAAA,EAAA,IAAA,CAAC,IAAD,CACC,KAAM,KAAK,MAAM,KACjB,WAAA,EAAW,EAAA,QAAA,CACV,kBACA,mBAAmB,KAAK,MAAM,MAAQ,WACvC,EACA,QAAS,KAAK,mBAEd,UAAA,EAAA,EAAA,IAAA,CAAC,EAAA,QAAD,CACgB,gBACf,OAAQ,CACP,MAAO,KAAK,MAAM,OAAO,KAC1B,EACA,UAAW,KAAK,MAAM,UACtB,MAAO,KAAK,MAAM,MAClB,KAAM,KAAK,MAAM,IACjB,CAAA,CACC,CAAA,EACD,KAAK,MAAM,kBAkBT,MAjBH,EAAA,EAAA,KAAA,CAAC,aAAD,CAAY,UAAU,yCAAtB,SAAA,EACC,EAAA,EAAA,IAAA,CAAC,MAAD,CAAK,UAAU,4CACb,SAAA,KAAK,MAAM,KACT,EAAA,QAAM,aAAa,KAAK,MAAM,KAAM,CACpC,KAAM,SACP,CAAC,EACA,IACC,CAAA,GACL,EAAA,EAAA,IAAA,CAAC,MAAD,CAAK,UAAU,mBACd,UAAA,EAAA,EAAA,IAAA,CAAC,OAAD,CACC,UAAU,gCACV,MAAO,KAAK,MAAM,OAAO,MAExB,SAAA,KAAK,MAAM,OAAO,KACd,CAAA,CACF,CAAA,CACM,CACT,CAAA,CACG,CAAA,CAAA,EACP,KAAK,MAAM,cACX,EAAA,EAAA,IAAA,CAAC,MAAD,CAAK,UAAU,2BACb,SAAA,EAAA,QAAM,aAAa,KAAK,MAAM,aAAc,CAC5C,oBAAA,EAAoB,EAAA,QAAA,CACnB,sCACA,KAAK,MAAM,aAAa,MAAM,kBAC/B,CACD,CAAC,CACG,CAAA,EACF,MACJ,EAAA,EAAA,IAAA,CAAC,EAAA,QAAD,CACgB,gBACf,kBAAmB,KAAK,MAAM,kBAC9B,gBAAiB,KAAK,MAAM,gBAC5B,oBAAqB,KAAK,MAAM,mBAChC,CAAA,CACG,GAEP,CACD"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../utilities/constants.cjs"),n=require("../../button/index.cjs"),r=require("../../icon/index.cjs");let i=require("react");i=e.__toESM(i,1);let a=require("classnames");a=e.__toESM(a,1);let o=require("react/jsx-runtime");var s=e=>{let t=e.assistiveText??{},{moreActionsDropdown:s}=e,c=(0,o.jsx)(`div`,{className:`slds-file__actions-menu`,children:(0,o.jsxs)(`div`,{className:`slds-button-group`,role:`group`,children:[typeof e.onClickDownload==`function`?(0,o.jsx)(n.default,{type:`button`,variant:`icon`,iconSize:`x-small`,onClick:e.onClickDownload,title:`Download`,className:`slds-button_icon-inverse`,children:(0,o.jsx)(r.default,{assistiveText:{label:t.download},category:`utility`,name:`download`,size:`xx-small`,inverse:e.hasNoVisibleTitle})}):null,s?i.default.cloneElement(s,{assistiveText:{icon:t.moreActions,...s.props.assistiveText},overlay:s.props.overlay??!1,buttonVariant:s.props.buttonVariant??`icon`,buttonInverse:s.props.buttonInverse??e.hasNoVisibleTitle,
|
|
1
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../utilities/constants.cjs"),n=require("../../button/index.cjs"),r=require("../../icon/index.cjs");let i=require("react");i=e.__toESM(i,1);let a=require("classnames");a=e.__toESM(a,1);let o=require("react/jsx-runtime");var s=e=>{let t=e.assistiveText??{},{moreActionsDropdown:s}=e,c=(0,o.jsx)(`div`,{className:`slds-file__actions-menu`,children:(0,o.jsxs)(`div`,{className:`slds-button-group`,role:`group`,children:[typeof e.onClickDownload==`function`?(0,o.jsx)(n.default,{type:`button`,variant:`icon`,iconSize:`x-small`,onClick:e.onClickDownload,title:`Download`,className:`slds-button_icon-inverse`,children:(0,o.jsx)(r.default,{assistiveText:{label:t.download},category:`utility`,name:`download`,size:`xx-small`,inverse:e.hasNoVisibleTitle})}):null,s?i.default.cloneElement(s,{assistiveText:{icon:t.moreActions,...s.props.assistiveText},overlay:s.props.overlay??!1,menuPosition:s.props.menuPosition??`overflowBoundaryElement`,buttonVariant:s.props.buttonVariant??`icon`,buttonInverse:s.props.buttonInverse??e.hasNoVisibleTitle,triggerClassName:(0,a.default)(`slds-button_last`,s.props.triggerClassName)}):null]})});return typeof e.onClickDownload==`function`||e.moreActionsDropdown?e.hasNoVisibleTitle?(0,o.jsx)(`div`,{className:`slds-file__title slds-file__title_scrim`,children:c}):c:null};s.displayName=t.FILES_ACTIONS,exports.default=s;
|
|
2
2
|
//# sourceMappingURL=file-actions.cjs.map
|