@muraldevkit/ui-toolkit 4.72.0 → 4.73.0-dev-t0WE.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/dist/cjs/components/avatar/MrlAvatarButton/MrlAvatarButton.js +8 -1
- package/dist/cjs/components/avatar/MrlAvatarButton/MrlAvatarButton.js.map +1 -1
- package/dist/cjs/components/breadcrumb/MrlBreadcrumbItem/MrlBreadcrumbItem.js +14 -4
- package/dist/cjs/components/breadcrumb/MrlBreadcrumbItem/MrlBreadcrumbItem.js.map +1 -1
- package/dist/cjs/components/button/MrlAnimatedIconButton/MrlAnimatedIconButton.js +8 -1
- package/dist/cjs/components/button/MrlAnimatedIconButton/MrlAnimatedIconButton.js.map +1 -1
- package/dist/cjs/components/button/MrlButton/MrlButton.js +3 -3
- package/dist/cjs/components/button/MrlButton/MrlButton.js.map +1 -1
- package/dist/cjs/components/button/MrlIconButton/MrlIconButton.js +8 -1
- package/dist/cjs/components/button/MrlIconButton/MrlIconButton.js.map +1 -1
- package/dist/cjs/components/button/MrlProcessingButton/MrlProcessingButton.js +21 -2
- package/dist/cjs/components/button/MrlProcessingButton/MrlProcessingButton.js.map +1 -1
- package/dist/cjs/components/callout/MrlCallout/MrlCallout.js +36 -3
- package/dist/cjs/components/callout/MrlCallout/MrlCallout.js.map +1 -1
- package/dist/cjs/components/filter/MrlFilter/MrlFilter.js +18 -2
- package/dist/cjs/components/filter/MrlFilter/MrlFilter.js.map +1 -1
- package/dist/cjs/components/filter/MrlFilterItem/MrlFilterItem.js +11 -1
- package/dist/cjs/components/filter/MrlFilterItem/MrlFilterItem.js.map +1 -1
- package/dist/cjs/components/form/checkbox/MrlCheckbox/MrlCheckbox.js +17 -1
- package/dist/cjs/components/form/checkbox/MrlCheckbox/MrlCheckbox.js.map +1 -1
- package/dist/cjs/components/form/checkbox/MrlCheckboxStandalone/MrlCheckboxStandalone.js +24 -1
- package/dist/cjs/components/form/checkbox/MrlCheckboxStandalone/MrlCheckboxStandalone.js.map +1 -1
- package/dist/cjs/components/form/date-picker/MrlDatePicker.js +17 -2
- package/dist/cjs/components/form/date-picker/MrlDatePicker.js.map +1 -1
- package/dist/cjs/components/form/legacy-select/MrlLegacySelect/MrlLegacySelect.js +11 -2
- package/dist/cjs/components/form/legacy-select/MrlLegacySelect/MrlLegacySelect.js.map +1 -1
- package/dist/cjs/components/form/legacy-select/MrlLegacySelectItem/MrlLegacySelectItem.js +8 -1
- package/dist/cjs/components/form/legacy-select/MrlLegacySelectItem/MrlLegacySelectItem.js.map +1 -1
- package/dist/cjs/components/form/radio/MrlRadioButton/MrlRadioButton.js +19 -1
- package/dist/cjs/components/form/radio/MrlRadioButton/MrlRadioButton.js.map +1 -1
- package/dist/cjs/components/form/radio/MrlRadioButtonStandalone/MrlRadioButtonStandalone.js +19 -1
- package/dist/cjs/components/form/radio/MrlRadioButtonStandalone/MrlRadioButtonStandalone.js.map +1 -1
- package/dist/cjs/components/form/select/MrlCreatableSelect/MrlCreatableSelect.js +42 -2
- package/dist/cjs/components/form/select/MrlCreatableSelect/MrlCreatableSelect.js.map +1 -1
- package/dist/cjs/components/form/select/MrlMultiCreatableSelect/MrlMultiCreatableSelect.js +42 -2
- package/dist/cjs/components/form/select/MrlMultiCreatableSelect/MrlMultiCreatableSelect.js.map +1 -1
- package/dist/cjs/components/form/select/MrlMultiSelect/MrlMultiSelect.js +34 -2
- package/dist/cjs/components/form/select/MrlMultiSelect/MrlMultiSelect.js.map +1 -1
- package/dist/cjs/components/form/select/MrlSelect/MrlSelect.js +34 -2
- package/dist/cjs/components/form/select/MrlSelect/MrlSelect.js.map +1 -1
- package/dist/cjs/components/form/switch/MrlSwitch/MrlSwitch.js +14 -2
- package/dist/cjs/components/form/switch/MrlSwitch/MrlSwitch.js.map +1 -1
- package/dist/cjs/components/form/switch/MrlSwitchStandalone/MrlSwitchStandalone.js +10 -1
- package/dist/cjs/components/form/switch/MrlSwitchStandalone/MrlSwitchStandalone.js.map +1 -1
- package/dist/cjs/components/form/text-input/MrlEditableTextInput/MrlEditableTextInput.js +20 -3
- package/dist/cjs/components/form/text-input/MrlEditableTextInput/MrlEditableTextInput.js.map +1 -1
- package/dist/cjs/components/form/text-input/MrlTextInput/MrlTextInput.js +20 -3
- package/dist/cjs/components/form/text-input/MrlTextInput/MrlTextInput.js.map +1 -1
- package/dist/cjs/components/form/textarea/MrlEditableTextarea/MrlEditableTextarea.js +20 -3
- package/dist/cjs/components/form/textarea/MrlEditableTextarea/MrlEditableTextarea.js.map +1 -1
- package/dist/cjs/components/form/textarea/MrlTextarea/MrlTextarea.js +38 -1
- package/dist/cjs/components/form/textarea/MrlTextarea/MrlTextarea.js.map +1 -1
- package/dist/cjs/components/layout/MrlSidebar/MrlSidebar.js +12 -2
- package/dist/cjs/components/layout/MrlSidebar/MrlSidebar.js.map +1 -1
- package/dist/cjs/components/link/MrlLink/MrlLink.js +21 -2
- package/dist/cjs/components/link/MrlLink/MrlLink.js.map +1 -1
- package/dist/cjs/components/link/MrlLinkButton/MrlLinkButton.js +12 -1
- package/dist/cjs/components/link/MrlLinkButton/MrlLinkButton.js.map +1 -1
- package/dist/cjs/components/menu/MrlMenu/MrlMenu.js +20 -1
- package/dist/cjs/components/menu/MrlMenu/MrlMenu.js.map +1 -1
- package/dist/cjs/components/menu/MrlMenuItem/MrlMenuItem.js +18 -1
- package/dist/cjs/components/menu/MrlMenuItem/MrlMenuItem.js.map +1 -1
- package/dist/cjs/components/menu/MrlMenuItemLink/MrlMenuItemLink.js +10 -1
- package/dist/cjs/components/menu/MrlMenuItemLink/MrlMenuItemLink.js.map +1 -1
- package/dist/cjs/components/modal/MrlModal/MrlModal.js +22 -1
- package/dist/cjs/components/modal/MrlModal/MrlModal.js.map +1 -1
- package/dist/cjs/components/notification/MrlBlockNotification/MrlBlockNotification.js +27 -1
- package/dist/cjs/components/notification/MrlBlockNotification/MrlBlockNotification.js.map +1 -1
- package/dist/cjs/components/notification/MrlToast/MrlToast.js +28 -3
- package/dist/cjs/components/notification/MrlToast/MrlToast.js.map +1 -1
- package/dist/cjs/components/pagination/MrlPaginationButton/MrlPaginationButton.js +18 -2
- package/dist/cjs/components/pagination/MrlPaginationButton/MrlPaginationButton.js.map +1 -1
- package/dist/cjs/components/panel/MrlPanel/MrlPanel.js +24 -4
- package/dist/cjs/components/panel/MrlPanel/MrlPanel.js.map +1 -1
- package/dist/cjs/components/popover/MrlPopover/MrlPopover.js +18 -1
- package/dist/cjs/components/popover/MrlPopover/MrlPopover.js.map +1 -1
- package/dist/cjs/components/table/MrlSmartTable/MrlSmartTable.js +31 -2
- package/dist/cjs/components/table/MrlSmartTable/MrlSmartTable.js.map +1 -1
- package/dist/cjs/components/table/MrlTableRow/MrlTableRow.js +13 -3
- package/dist/cjs/components/table/MrlTableRow/MrlTableRow.js.map +1 -1
- package/dist/cjs/components/tabs/MrlTab/MrlTab.js +10 -1
- package/dist/cjs/components/tabs/MrlTab/MrlTab.js.map +1 -1
- package/dist/cjs/components/tabs/MrlTabLink/MrlTabLink.js +10 -1
- package/dist/cjs/components/tabs/MrlTabLink/MrlTabLink.js.map +1 -1
- package/dist/cjs/components/toolbar/MrlToolbarButton/MrlToolbarButton.js +19 -3
- package/dist/cjs/components/toolbar/MrlToolbarButton/MrlToolbarButton.js.map +1 -1
- package/dist/cjs/components/tooltip/MrlTooltip/MrlTooltip.js +23 -1
- package/dist/cjs/components/tooltip/MrlTooltip/MrlTooltip.js.map +1 -1
- package/dist/cjs/hooks/useMrlAnalytics/useMrlAnalytics.js +7 -7
- package/dist/cjs/hooks/useMrlAnalytics/useMrlAnalytics.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/components/avatar/MrlAvatarButton/MrlAvatarButton.d.ts +6 -1
- package/dist/components/breadcrumb/MrlBreadcrumbItem/MrlBreadcrumbItem.d.ts +5 -0
- package/dist/components/button/MrlButton/MrlButton.d.ts +1 -1
- package/dist/components/button/MrlIconButton/MrlIconButton.d.ts +5 -0
- package/dist/components/callout/MrlCallout/MrlCallout.d.ts +7 -0
- package/dist/components/filter/MrlFilter/MrlFilter.d.ts +7 -0
- package/dist/components/filter/MrlFilterItem/MrlFilterItem.d.ts +7 -0
- package/dist/components/form/checkbox/MrlCheckbox/MrlCheckbox.d.ts +6 -1
- package/dist/components/form/checkbox/MrlCheckboxStandalone/MrlCheckboxStandalone.d.ts +6 -1
- package/dist/components/form/date-picker/MrlDatePicker.d.ts +7 -0
- package/dist/components/form/legacy-select/MrlLegacySelect/MrlLegacySelect.d.ts +6 -1
- package/dist/components/form/legacy-select/MrlLegacySelectItem/MrlLegacySelectItem.d.ts +8 -1
- package/dist/components/form/radio/MrlRadioButton/MrlRadioButton.d.ts +6 -1
- package/dist/components/form/radio/MrlRadioButtonStandalone/MrlRadioButtonStandalone.d.ts +6 -1
- package/dist/components/form/select/MrlCreatableSelect/MrlCreatableSelect.d.ts +7 -0
- package/dist/components/form/select/MrlMultiCreatableSelect/MrlMultiCreatableSelect.d.ts +7 -0
- package/dist/components/form/select/MrlMultiSelect/MrlMultiSelect.d.ts +7 -0
- package/dist/components/form/select/MrlSelect/MrlSelect.d.ts +7 -0
- package/dist/components/form/switch/MrlSwitch/MrlSwitch.d.ts +6 -1
- package/dist/components/form/switch/MrlSwitchStandalone/MrlSwitchStandalone.d.ts +6 -1
- package/dist/components/form/text-input/MrlEditableTextInput/MrlEditableTextInput.d.ts +8 -0
- package/dist/components/form/text-input/MrlTextInput/MrlTextInput.d.ts +8 -0
- package/dist/components/form/textarea/MrlEditableTextarea/MrlEditableTextarea.d.ts +8 -0
- package/dist/components/form/textarea/MrlTextarea/MrlTextarea.d.ts +9 -1
- package/dist/components/layout/MrlSidebar/MrlSidebar.d.ts +8 -1
- package/dist/components/link/MrlLink/MrlLink.d.ts +6 -1
- package/dist/components/link/MrlLinkButton/MrlLinkButton.d.ts +5 -0
- package/dist/components/menu/MrlMenu/MrlMenu.d.ts +6 -1
- package/dist/components/menu/MrlMenuItem/MrlMenuItem.d.ts +6 -1
- package/dist/components/menu/MrlMenuItemLink/MrlMenuItemLink.d.ts +6 -1
- package/dist/components/modal/MrlModal/MrlModal.d.ts +5 -0
- package/dist/components/notification/MrlBlockNotification/MrlBlockNotification.d.ts +7 -0
- package/dist/components/notification/MrlToast/MrlToast.d.ts +8 -1
- package/dist/components/pagination/MrlPaginationButton/MrlPaginationButton.d.ts +6 -1
- package/dist/components/panel/MrlPanel/MrlPanel.d.ts +8 -0
- package/dist/components/popover/MrlPopover/MrlPopover.d.ts +6 -1
- package/dist/components/table/MrlSmartTable/MrlSmartTable.d.ts +7 -0
- package/dist/components/table/MrlTableRow/MrlTableRow.d.ts +7 -0
- package/dist/components/tabs/MrlTab/MrlTab.d.ts +6 -1
- package/dist/components/tabs/MrlTabLink/MrlTabLink.d.ts +6 -1
- package/dist/components/toolbar/MrlToolbarButton/MrlToolbarButton.d.ts +5 -0
- package/dist/components/tooltip/MrlTooltip/MrlTooltip.d.ts +8 -0
- package/dist/contexts/MrlAnalyticsContext/types.d.ts +1 -1
- package/dist/esm/components/avatar/MrlAvatarButton/MrlAvatarButton.js +8 -1
- package/dist/esm/components/avatar/MrlAvatarButton/MrlAvatarButton.js.map +1 -1
- package/dist/esm/components/breadcrumb/MrlBreadcrumbItem/MrlBreadcrumbItem.js +14 -4
- package/dist/esm/components/breadcrumb/MrlBreadcrumbItem/MrlBreadcrumbItem.js.map +1 -1
- package/dist/esm/components/button/MrlAnimatedIconButton/MrlAnimatedIconButton.js +8 -1
- package/dist/esm/components/button/MrlAnimatedIconButton/MrlAnimatedIconButton.js.map +1 -1
- package/dist/esm/components/button/MrlButton/MrlButton.js +3 -3
- package/dist/esm/components/button/MrlButton/MrlButton.js.map +1 -1
- package/dist/esm/components/button/MrlIconButton/MrlIconButton.js +8 -1
- package/dist/esm/components/button/MrlIconButton/MrlIconButton.js.map +1 -1
- package/dist/esm/components/button/MrlProcessingButton/MrlProcessingButton.js +21 -2
- package/dist/esm/components/button/MrlProcessingButton/MrlProcessingButton.js.map +1 -1
- package/dist/esm/components/callout/MrlCallout/MrlCallout.js +36 -3
- package/dist/esm/components/callout/MrlCallout/MrlCallout.js.map +1 -1
- package/dist/esm/components/filter/MrlFilter/MrlFilter.js +18 -2
- package/dist/esm/components/filter/MrlFilter/MrlFilter.js.map +1 -1
- package/dist/esm/components/filter/MrlFilterItem/MrlFilterItem.js +11 -1
- package/dist/esm/components/filter/MrlFilterItem/MrlFilterItem.js.map +1 -1
- package/dist/esm/components/form/checkbox/MrlCheckbox/MrlCheckbox.js +17 -1
- package/dist/esm/components/form/checkbox/MrlCheckbox/MrlCheckbox.js.map +1 -1
- package/dist/esm/components/form/checkbox/MrlCheckboxStandalone/MrlCheckboxStandalone.js +24 -1
- package/dist/esm/components/form/checkbox/MrlCheckboxStandalone/MrlCheckboxStandalone.js.map +1 -1
- package/dist/esm/components/form/date-picker/MrlDatePicker.js +17 -2
- package/dist/esm/components/form/date-picker/MrlDatePicker.js.map +1 -1
- package/dist/esm/components/form/legacy-select/MrlLegacySelect/MrlLegacySelect.js +11 -2
- package/dist/esm/components/form/legacy-select/MrlLegacySelect/MrlLegacySelect.js.map +1 -1
- package/dist/esm/components/form/legacy-select/MrlLegacySelectItem/MrlLegacySelectItem.js +8 -1
- package/dist/esm/components/form/legacy-select/MrlLegacySelectItem/MrlLegacySelectItem.js.map +1 -1
- package/dist/esm/components/form/radio/MrlRadioButton/MrlRadioButton.js +19 -1
- package/dist/esm/components/form/radio/MrlRadioButton/MrlRadioButton.js.map +1 -1
- package/dist/esm/components/form/radio/MrlRadioButtonStandalone/MrlRadioButtonStandalone.js +19 -1
- package/dist/esm/components/form/radio/MrlRadioButtonStandalone/MrlRadioButtonStandalone.js.map +1 -1
- package/dist/esm/components/form/select/MrlCreatableSelect/MrlCreatableSelect.js +42 -2
- package/dist/esm/components/form/select/MrlCreatableSelect/MrlCreatableSelect.js.map +1 -1
- package/dist/esm/components/form/select/MrlMultiCreatableSelect/MrlMultiCreatableSelect.js +42 -2
- package/dist/esm/components/form/select/MrlMultiCreatableSelect/MrlMultiCreatableSelect.js.map +1 -1
- package/dist/esm/components/form/select/MrlMultiSelect/MrlMultiSelect.js +34 -2
- package/dist/esm/components/form/select/MrlMultiSelect/MrlMultiSelect.js.map +1 -1
- package/dist/esm/components/form/select/MrlSelect/MrlSelect.js +34 -2
- package/dist/esm/components/form/select/MrlSelect/MrlSelect.js.map +1 -1
- package/dist/esm/components/form/switch/MrlSwitch/MrlSwitch.js +14 -2
- package/dist/esm/components/form/switch/MrlSwitch/MrlSwitch.js.map +1 -1
- package/dist/esm/components/form/switch/MrlSwitchStandalone/MrlSwitchStandalone.js +10 -1
- package/dist/esm/components/form/switch/MrlSwitchStandalone/MrlSwitchStandalone.js.map +1 -1
- package/dist/esm/components/form/text-input/MrlEditableTextInput/MrlEditableTextInput.js +20 -3
- package/dist/esm/components/form/text-input/MrlEditableTextInput/MrlEditableTextInput.js.map +1 -1
- package/dist/esm/components/form/text-input/MrlTextInput/MrlTextInput.js +20 -3
- package/dist/esm/components/form/text-input/MrlTextInput/MrlTextInput.js.map +1 -1
- package/dist/esm/components/form/textarea/MrlEditableTextarea/MrlEditableTextarea.js +20 -3
- package/dist/esm/components/form/textarea/MrlEditableTextarea/MrlEditableTextarea.js.map +1 -1
- package/dist/esm/components/form/textarea/MrlTextarea/MrlTextarea.js +38 -1
- package/dist/esm/components/form/textarea/MrlTextarea/MrlTextarea.js.map +1 -1
- package/dist/esm/components/layout/MrlSidebar/MrlSidebar.js +12 -2
- package/dist/esm/components/layout/MrlSidebar/MrlSidebar.js.map +1 -1
- package/dist/esm/components/link/MrlLink/MrlLink.js +21 -2
- package/dist/esm/components/link/MrlLink/MrlLink.js.map +1 -1
- package/dist/esm/components/link/MrlLinkButton/MrlLinkButton.js +12 -1
- package/dist/esm/components/link/MrlLinkButton/MrlLinkButton.js.map +1 -1
- package/dist/esm/components/menu/MrlMenu/MrlMenu.js +20 -1
- package/dist/esm/components/menu/MrlMenu/MrlMenu.js.map +1 -1
- package/dist/esm/components/menu/MrlMenuItem/MrlMenuItem.js +18 -1
- package/dist/esm/components/menu/MrlMenuItem/MrlMenuItem.js.map +1 -1
- package/dist/esm/components/menu/MrlMenuItemLink/MrlMenuItemLink.js +10 -1
- package/dist/esm/components/menu/MrlMenuItemLink/MrlMenuItemLink.js.map +1 -1
- package/dist/esm/components/modal/MrlModal/MrlModal.js +22 -1
- package/dist/esm/components/modal/MrlModal/MrlModal.js.map +1 -1
- package/dist/esm/components/notification/MrlBlockNotification/MrlBlockNotification.js +27 -1
- package/dist/esm/components/notification/MrlBlockNotification/MrlBlockNotification.js.map +1 -1
- package/dist/esm/components/notification/MrlToast/MrlToast.js +28 -3
- package/dist/esm/components/notification/MrlToast/MrlToast.js.map +1 -1
- package/dist/esm/components/pagination/MrlPaginationButton/MrlPaginationButton.js +18 -2
- package/dist/esm/components/pagination/MrlPaginationButton/MrlPaginationButton.js.map +1 -1
- package/dist/esm/components/panel/MrlPanel/MrlPanel.js +24 -4
- package/dist/esm/components/panel/MrlPanel/MrlPanel.js.map +1 -1
- package/dist/esm/components/popover/MrlPopover/MrlPopover.js +18 -1
- package/dist/esm/components/popover/MrlPopover/MrlPopover.js.map +1 -1
- package/dist/esm/components/table/MrlSmartTable/MrlSmartTable.js +31 -2
- package/dist/esm/components/table/MrlSmartTable/MrlSmartTable.js.map +1 -1
- package/dist/esm/components/table/MrlTableRow/MrlTableRow.js +13 -3
- package/dist/esm/components/table/MrlTableRow/MrlTableRow.js.map +1 -1
- package/dist/esm/components/tabs/MrlTab/MrlTab.js +10 -1
- package/dist/esm/components/tabs/MrlTab/MrlTab.js.map +1 -1
- package/dist/esm/components/tabs/MrlTabLink/MrlTabLink.js +10 -1
- package/dist/esm/components/tabs/MrlTabLink/MrlTabLink.js.map +1 -1
- package/dist/esm/components/toolbar/MrlToolbarButton/MrlToolbarButton.js +19 -3
- package/dist/esm/components/toolbar/MrlToolbarButton/MrlToolbarButton.js.map +1 -1
- package/dist/esm/components/tooltip/MrlTooltip/MrlTooltip.js +23 -1
- package/dist/esm/components/tooltip/MrlTooltip/MrlTooltip.js.map +1 -1
- package/dist/esm/hooks/useMrlAnalytics/useMrlAnalytics.js +7 -7
- package/dist/esm/hooks/useMrlAnalytics/useMrlAnalytics.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/hooks/useMrlAnalytics/useMrlAnalytics.d.ts +4 -4
- package/dist/types/components/avatar/MrlAvatarButton/MrlAvatarButton.d.ts +6 -1
- package/dist/types/components/breadcrumb/MrlBreadcrumbItem/MrlBreadcrumbItem.d.ts +5 -0
- package/dist/types/components/button/MrlButton/MrlButton.d.ts +1 -1
- package/dist/types/components/button/MrlIconButton/MrlIconButton.d.ts +5 -0
- package/dist/types/components/callout/MrlCallout/MrlCallout.d.ts +7 -0
- package/dist/types/components/filter/MrlFilter/MrlFilter.d.ts +7 -0
- package/dist/types/components/filter/MrlFilterItem/MrlFilterItem.d.ts +7 -0
- package/dist/types/components/form/checkbox/MrlCheckbox/MrlCheckbox.d.ts +6 -1
- package/dist/types/components/form/checkbox/MrlCheckboxStandalone/MrlCheckboxStandalone.d.ts +6 -1
- package/dist/types/components/form/date-picker/MrlDatePicker.d.ts +7 -0
- package/dist/types/components/form/legacy-select/MrlLegacySelect/MrlLegacySelect.d.ts +6 -1
- package/dist/types/components/form/legacy-select/MrlLegacySelectItem/MrlLegacySelectItem.d.ts +8 -1
- package/dist/types/components/form/radio/MrlRadioButton/MrlRadioButton.d.ts +6 -1
- package/dist/types/components/form/radio/MrlRadioButtonStandalone/MrlRadioButtonStandalone.d.ts +6 -1
- package/dist/types/components/form/select/MrlCreatableSelect/MrlCreatableSelect.d.ts +7 -0
- package/dist/types/components/form/select/MrlMultiCreatableSelect/MrlMultiCreatableSelect.d.ts +7 -0
- package/dist/types/components/form/select/MrlMultiSelect/MrlMultiSelect.d.ts +7 -0
- package/dist/types/components/form/select/MrlSelect/MrlSelect.d.ts +7 -0
- package/dist/types/components/form/switch/MrlSwitch/MrlSwitch.d.ts +6 -1
- package/dist/types/components/form/switch/MrlSwitchStandalone/MrlSwitchStandalone.d.ts +6 -1
- package/dist/types/components/form/text-input/MrlEditableTextInput/MrlEditableTextInput.d.ts +8 -0
- package/dist/types/components/form/text-input/MrlTextInput/MrlTextInput.d.ts +8 -0
- package/dist/types/components/form/textarea/MrlEditableTextarea/MrlEditableTextarea.d.ts +8 -0
- package/dist/types/components/form/textarea/MrlTextarea/MrlTextarea.d.ts +9 -1
- package/dist/types/components/layout/MrlSidebar/MrlSidebar.d.ts +8 -1
- package/dist/types/components/link/MrlLink/MrlLink.d.ts +6 -1
- package/dist/types/components/link/MrlLinkButton/MrlLinkButton.d.ts +5 -0
- package/dist/types/components/menu/MrlMenu/MrlMenu.d.ts +6 -1
- package/dist/types/components/menu/MrlMenuItem/MrlMenuItem.d.ts +6 -1
- package/dist/types/components/menu/MrlMenuItemLink/MrlMenuItemLink.d.ts +6 -1
- package/dist/types/components/modal/MrlModal/MrlModal.d.ts +5 -0
- package/dist/types/components/notification/MrlBlockNotification/MrlBlockNotification.d.ts +7 -0
- package/dist/types/components/notification/MrlToast/MrlToast.d.ts +8 -1
- package/dist/types/components/pagination/MrlPaginationButton/MrlPaginationButton.d.ts +6 -1
- package/dist/types/components/panel/MrlPanel/MrlPanel.d.ts +8 -0
- package/dist/types/components/popover/MrlPopover/MrlPopover.d.ts +6 -1
- package/dist/types/components/table/MrlSmartTable/MrlSmartTable.d.ts +7 -0
- package/dist/types/components/table/MrlTableRow/MrlTableRow.d.ts +7 -0
- package/dist/types/components/tabs/MrlTab/MrlTab.d.ts +6 -1
- package/dist/types/components/tabs/MrlTabLink/MrlTabLink.d.ts +6 -1
- package/dist/types/components/toolbar/MrlToolbarButton/MrlToolbarButton.d.ts +5 -0
- package/dist/types/components/tooltip/MrlTooltip/MrlTooltip.d.ts +8 -0
- package/dist/types/contexts/MrlAnalyticsContext/types.d.ts +1 -1
- package/dist/types/hooks/useMrlAnalytics/useMrlAnalytics.d.ts +4 -4
- package/package.json +1 -1
|
@@ -6,6 +6,7 @@ var classnames = require('classnames');
|
|
|
6
6
|
var helpers = require('../../button/helpers.js');
|
|
7
7
|
var constants = require('../../button/constants.js');
|
|
8
8
|
var MrlAvatarButton_module = require('./MrlAvatarButton.module.scss.js');
|
|
9
|
+
var useMrlAnalytics = require('../../../hooks/useMrlAnalytics/useMrlAnalytics.js');
|
|
9
10
|
var setAttributes = require('../../../utils/setAttributes/setAttributes.js');
|
|
10
11
|
var MrlTooltip = require('../../tooltip/MrlTooltip/MrlTooltip.js');
|
|
11
12
|
var MrlAvatar = require('../MrlAvatar/MrlAvatar.js');
|
|
@@ -34,7 +35,7 @@ function _interopNamespace(e) {
|
|
|
34
35
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
35
36
|
var classnames__default = /*#__PURE__*/_interopDefault(classnames);
|
|
36
37
|
|
|
37
|
-
var _excluded = ["buttonClassName", "dataQa", "id", "includeInRoving", "isToggleButton", "label", "loading", "loadingText", "onClick", "size", "state", "toggleAria", "tooltip", "triggerRef"];
|
|
38
|
+
var _excluded = ["buttonClassName", "dataQa", "id", "includeInRoving", "isToggleButton", "label", "loading", "loadingText", "onClick", "size", "state", "toggleAria", "tooltip", "eventId", "triggerRef"];
|
|
38
39
|
/**
|
|
39
40
|
* Renders an avatar button
|
|
40
41
|
* @param {MrlAvatarButtonPropTypes} props the props for your MrlAvatarButton
|
|
@@ -58,12 +59,14 @@ var MrlAvatarButton = _ref => {
|
|
|
58
59
|
_ref$toggleAria = _ref.toggleAria,
|
|
59
60
|
toggleAria = _ref$toggleAria === void 0 ? constants.buttonDefaults.toggleAria : _ref$toggleAria,
|
|
60
61
|
tooltip = _ref.tooltip,
|
|
62
|
+
eventId = _ref.eventId,
|
|
61
63
|
triggerRef = _ref.triggerRef,
|
|
62
64
|
rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
|
|
63
65
|
var _React$useState = React__namespace.useState(() => helpers._isSelected(state)),
|
|
64
66
|
_React$useState2 = _rollupPluginBabelHelpers.slicedToArray(_React$useState, 2),
|
|
65
67
|
isSelected = _React$useState2[0],
|
|
66
68
|
setIsSelected = _React$useState2[1];
|
|
69
|
+
var trackInteraction = useMrlAnalytics.useMrlTrackInteraction('MrlAvatarButton', eventId);
|
|
67
70
|
|
|
68
71
|
/**
|
|
69
72
|
* We need to watch the value of state to keep in sync
|
|
@@ -101,6 +104,10 @@ var MrlAvatarButton = _ref => {
|
|
|
101
104
|
if (helpers._isDisabled(state, loading)) {
|
|
102
105
|
return;
|
|
103
106
|
}
|
|
107
|
+
trackInteraction({
|
|
108
|
+
action: 'click',
|
|
109
|
+
variant: size
|
|
110
|
+
});
|
|
104
111
|
if (isToggleButton) {
|
|
105
112
|
setIsSelected(prevIsSelected => !prevIsSelected);
|
|
106
113
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MrlAvatarButton.js","sources":["../../../../../src/components/avatar/MrlAvatarButton/MrlAvatarButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport classNames from 'classnames';\nimport {\n\tMrlAvatar,\n\tMrlAvatarPropTypes,\n\tMrlButtonState,\n\tMrlSpinner,\n\tMrlTooltip,\n\tTooltipConfig\n} from '../../';\nimport { _isDisabled, _isSelected } from '../../button/helpers';\nimport { ToggleAria, buttonDefaults } from '../../button/constants';\nimport { setAttributes } from '../../../utils';\n\nimport styles from './MrlAvatarButton.module.scss';\n\nexport interface MrlAvatarButtonPropTypes\n\textends MrlAvatarPropTypes,\n\t\tReact.HTMLAttributes<HTMLButtonElement> {\n\t/**\n\t * An optional class name to add to button wrapping the MrlAvatar.\n\t */\n\tbuttonClassName?: string;\n\n\t/**\n\t * An optional boolean prop to include the button in roving tabindex\n\t */\n\tincludeInRoving?: boolean;\n\n\t/**\n\t * Selected state variant when the button is a Toggle Button. Setting this prop\n\t * informs the component that this is a toggle button and to add that functionality\n\t */\n\tisToggleButton?: boolean;\n\n\t/**\n\t * An optional aria-label to apply to the button element\n\t */\n\tlabel?: string;\n\n\t/**\n\t * Displays a spinner in the button to indicate some action is in progress.\n\t */\n\tloading?: boolean;\n\n\t/**\n\t * Text for the spinner when the button is in a loading state.\n\t */\n\tloadingText?: string;\n\n\t/**\n\t * onClick event for the button.\n\t */\n\tonClick?: (e: React.SyntheticEvent<HTMLButtonElement>) => void;\n\n\t/**\n\t * Changes the state of the button based on user permissions or actions.\n\t */\n\tstate?: MrlButtonState;\n\n\t/**\n\t * Determines which aria setup to use for various toggle/selected styles.\n\t * pressed - use for an traditional “toggle button”\n\t * selected - use for tabs and custom select options\n\t * expanded - use for menus, panels, and popovers\n\t * checked - use for custom [radiobutton](https://www.w3.org/WAI/ARIA/apg/patterns/radiobutton/#wai-aria-roles-states-and-properties-16)\n\t * \t\tor [checkbox](https://www.w3.org/WAI/ARIA/apg/patterns/checkbox/#wai-aria-roles-states-and-properties-5) inputs\n\t */\n\ttoggleAria?: ToggleAria;\n\n\t/**\n\t * Tooltip configuration for the button\n\t */\n\ttooltip?: TooltipConfig;\n\n\t/**\n\t * Reference to the DOM element that is the MrlAvatarButton\n\t */\n\ttriggerRef?: React.RefObject<HTMLButtonElement>;\n}\n\n/**\n * Renders an avatar button\n * @param {MrlAvatarButtonPropTypes} props the props for your MrlAvatarButton\n * @returns {React.ReactElement} an avatar button containing the props you pass\n */\nexport const MrlAvatarButton = ({\n\tbuttonClassName,\n\tdataQa,\n\tid,\n\tincludeInRoving,\n\tisToggleButton,\n\tlabel,\n\tloading = false,\n\tloadingText = 'Loading',\n\tonClick,\n\tsize,\n\tstate = 'default',\n\ttoggleAria = buttonDefaults.toggleAria,\n\ttooltip,\n\ttriggerRef,\n\t...rest\n}: MrlAvatarButtonPropTypes): React.ReactElement => {\n\tconst [isSelected, setIsSelected] = React.useState(() => _isSelected(state));\n\n\t/**\n\t * We need to watch the value of state to keep in sync\n\t * the value of state passed as props and the internal\n\t * isSelected piece of state.\n\t */\n\tReact.useEffect(() => {\n\t\t// allows consumers to set the 'selected' or 'selected-disabled' state from a parent component.\n\t\tsetIsSelected(_isSelected(state));\n\t}, [state]);\n\n\tconst spinner = (\n\t\t<MrlSpinner\n\t\t\tclassName=\"mrlButton-spinner MrlAvatarButton-spinner\"\n\t\t\tkind=\"default\"\n\t\t\trole=\"none\"\n\t\t\tsize=\"small\"\n\t\t\ttext={loadingText}\n\t\t/>\n\t);\n\n\tconst attributes = setAttributes(\n\t\t{},\n\t\t{\n\t\t\t'aria-disabled': _isDisabled(state, loading),\n\t\t\t'aria-label': label,\n\t\t\t...(isToggleButton && { [`aria-${toggleAria}`]: isSelected || false }),\n\t\t\t'data-roving': includeInRoving ? 'true' : undefined,\n\t\t\trole: 'button',\n\t\t\ttype: 'button'\n\t\t}\n\t);\n\n\t/**\n\t * Handle onClick events\n\t * @param {React.MouseEvent<HTMLButtonElement>} e - mouse event\n\t */\n\tfunction handleOnClick(e: React.MouseEvent<HTMLButtonElement>) {\n\t\te.stopPropagation();\n\n\t\tif (_isDisabled(state, loading)) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (isToggleButton) {\n\t\t\tsetIsSelected((prevIsSelected) => !prevIsSelected);\n\t\t}\n\n\t\tif (onClick && typeof onClick === 'function') {\n\t\t\tonClick(e);\n\t\t}\n\t}\n\n\tconst buttonClasses = classNames('MrlAvatarButton', styles['MrlAvatarButton'], buttonClassName, {\n\t\t[styles['MrlAvatarButton--large']]: size && size === 'large'\n\t});\n\n\tconst renderAvatarButton = () => (\n\t\t<button\n\t\t\t{...attributes}\n\t\t\taria-label={tooltip && tooltip.text}\n\t\t\tclassName={buttonClasses}\n\t\t\tdata-qa={dataQa && `${dataQa}-button`}\n\t\t\tid={id}\n\t\t\tonClick={handleOnClick}\n\t\t\tref={triggerRef}\n\t\t>\n\t\t\t{loading ? spinner : <MrlAvatar dataQa={dataQa} size={size} {...rest} />}\n\t\t</button>\n\t);\n\n\treturn !tooltip ? (\n\t\trenderAvatarButton()\n\t) : (\n\t\t<MrlTooltip\n\t\t\tposition={tooltip.position || 'bottom'}\n\t\t\tanchor={tooltip.anchor || 'center'}\n\t\t\ttext={tooltip.text}\n\t\t\tdataQa={tooltip.dataQa}\n\t\t>\n\t\t\t{renderAvatarButton()}\n\t\t</MrlTooltip>\n\t);\n};\n"],"names":["MrlAvatarButton","_ref","buttonClassName","dataQa","id","includeInRoving","isToggleButton","label","_ref$loading","loading","_ref$loadingText","loadingText","onClick","size","_ref$state","state","_ref$toggleAria","toggleAria","buttonDefaults","tooltip","triggerRef","rest","_objectWithoutProperties","_excluded","_React$useState","React","useState","_isSelected","_React$useState2","_slicedToArray","isSelected","setIsSelected","useEffect","spinner","createElement","MrlSpinner","className","kind","role","text","attributes","setAttributes","_objectSpread","_isDisabled","concat","undefined","type","handleOnClick","e","stopPropagation","prevIsSelected","buttonClasses","classNames","styles","renderAvatarButton","_extends","ref","MrlAvatar","MrlTooltip","position","anchor"],"mappings":"
|
|
1
|
+
{"version":3,"file":"MrlAvatarButton.js","sources":["../../../../../src/components/avatar/MrlAvatarButton/MrlAvatarButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport classNames from 'classnames';\nimport {\n\tMrlAvatar,\n\tMrlAvatarPropTypes,\n\tMrlButtonState,\n\tMrlSpinner,\n\tMrlTooltip,\n\tTooltipConfig\n} from '../../';\nimport { _isDisabled, _isSelected } from '../../button/helpers';\nimport { ToggleAria, buttonDefaults } from '../../button/constants';\nimport { setAttributes } from '../../../utils';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\n\nimport styles from './MrlAvatarButton.module.scss';\n\nexport interface MrlAvatarButtonPropTypes\n\textends MrlAvatarPropTypes,\n\t\tReact.HTMLAttributes<HTMLButtonElement> {\n\t/**\n\t * An optional class name to add to button wrapping the MrlAvatar.\n\t */\n\tbuttonClassName?: string;\n\n\t/**\n\t * An optional boolean prop to include the button in roving tabindex\n\t */\n\tincludeInRoving?: boolean;\n\n\t/**\n\t * Selected state variant when the button is a Toggle Button. Setting this prop\n\t * informs the component that this is a toggle button and to add that functionality\n\t */\n\tisToggleButton?: boolean;\n\n\t/**\n\t * An optional aria-label to apply to the button element\n\t */\n\tlabel?: string;\n\n\t/**\n\t * Displays a spinner in the button to indicate some action is in progress.\n\t */\n\tloading?: boolean;\n\n\t/**\n\t * Text for the spinner when the button is in a loading state.\n\t */\n\tloadingText?: string;\n\n\t/**\n\t * onClick event for the button.\n\t */\n\tonClick?: (e: React.SyntheticEvent<HTMLButtonElement>) => void;\n\n\t/**\n\t * Changes the state of the button based on user permissions or actions.\n\t */\n\tstate?: MrlButtonState;\n\n\t/**\n\t * Determines which aria setup to use for various toggle/selected styles.\n\t * pressed - use for an traditional “toggle button”\n\t * selected - use for tabs and custom select options\n\t * expanded - use for menus, panels, and popovers\n\t * checked - use for custom [radiobutton](https://www.w3.org/WAI/ARIA/apg/patterns/radiobutton/#wai-aria-roles-states-and-properties-16)\n\t * \t\tor [checkbox](https://www.w3.org/WAI/ARIA/apg/patterns/checkbox/#wai-aria-roles-states-and-properties-5) inputs\n\t */\n\ttoggleAria?: ToggleAria;\n\n\t/**\n\t * Tooltip configuration for the button\n\t */\n\ttooltip?: TooltipConfig;\n\n\t/**\n\t * Enables interaction tracking for this button. Provide a stable, non-PII id\n\t * (e.g. 'workspace-member-avatar'). When omitted, the button emits no analytics.\n\t */\n\teventId?: string;\n\n\t/**\n\t * Reference to the DOM element that is the MrlAvatarButton\n\t */\n\ttriggerRef?: React.RefObject<HTMLButtonElement>;\n}\n\n/**\n * Renders an avatar button\n * @param {MrlAvatarButtonPropTypes} props the props for your MrlAvatarButton\n * @returns {React.ReactElement} an avatar button containing the props you pass\n */\nexport const MrlAvatarButton = ({\n\tbuttonClassName,\n\tdataQa,\n\tid,\n\tincludeInRoving,\n\tisToggleButton,\n\tlabel,\n\tloading = false,\n\tloadingText = 'Loading',\n\tonClick,\n\tsize,\n\tstate = 'default',\n\ttoggleAria = buttonDefaults.toggleAria,\n\ttooltip,\n\teventId,\n\ttriggerRef,\n\t...rest\n}: MrlAvatarButtonPropTypes): React.ReactElement => {\n\tconst [isSelected, setIsSelected] = React.useState(() => _isSelected(state));\n\n\tconst trackInteraction = useMrlTrackInteraction('MrlAvatarButton', eventId);\n\n\t/**\n\t * We need to watch the value of state to keep in sync\n\t * the value of state passed as props and the internal\n\t * isSelected piece of state.\n\t */\n\tReact.useEffect(() => {\n\t\t// allows consumers to set the 'selected' or 'selected-disabled' state from a parent component.\n\t\tsetIsSelected(_isSelected(state));\n\t}, [state]);\n\n\tconst spinner = (\n\t\t<MrlSpinner\n\t\t\tclassName=\"mrlButton-spinner MrlAvatarButton-spinner\"\n\t\t\tkind=\"default\"\n\t\t\trole=\"none\"\n\t\t\tsize=\"small\"\n\t\t\ttext={loadingText}\n\t\t/>\n\t);\n\n\tconst attributes = setAttributes(\n\t\t{},\n\t\t{\n\t\t\t'aria-disabled': _isDisabled(state, loading),\n\t\t\t'aria-label': label,\n\t\t\t...(isToggleButton && { [`aria-${toggleAria}`]: isSelected || false }),\n\t\t\t'data-roving': includeInRoving ? 'true' : undefined,\n\t\t\trole: 'button',\n\t\t\ttype: 'button'\n\t\t}\n\t);\n\n\t/**\n\t * Handle onClick events\n\t * @param {React.MouseEvent<HTMLButtonElement>} e - mouse event\n\t */\n\tfunction handleOnClick(e: React.MouseEvent<HTMLButtonElement>) {\n\t\te.stopPropagation();\n\n\t\tif (_isDisabled(state, loading)) {\n\t\t\treturn;\n\t\t}\n\n\t\ttrackInteraction({ action: 'click', variant: size });\n\n\t\tif (isToggleButton) {\n\t\t\tsetIsSelected((prevIsSelected) => !prevIsSelected);\n\t\t}\n\n\t\tif (onClick && typeof onClick === 'function') {\n\t\t\tonClick(e);\n\t\t}\n\t}\n\n\tconst buttonClasses = classNames('MrlAvatarButton', styles['MrlAvatarButton'], buttonClassName, {\n\t\t[styles['MrlAvatarButton--large']]: size && size === 'large'\n\t});\n\n\tconst renderAvatarButton = () => (\n\t\t<button\n\t\t\t{...attributes}\n\t\t\taria-label={tooltip && tooltip.text}\n\t\t\tclassName={buttonClasses}\n\t\t\tdata-qa={dataQa && `${dataQa}-button`}\n\t\t\tid={id}\n\t\t\tonClick={handleOnClick}\n\t\t\tref={triggerRef}\n\t\t>\n\t\t\t{loading ? spinner : <MrlAvatar dataQa={dataQa} size={size} {...rest} />}\n\t\t</button>\n\t);\n\n\treturn !tooltip ? (\n\t\trenderAvatarButton()\n\t) : (\n\t\t<MrlTooltip\n\t\t\tposition={tooltip.position || 'bottom'}\n\t\t\tanchor={tooltip.anchor || 'center'}\n\t\t\ttext={tooltip.text}\n\t\t\tdataQa={tooltip.dataQa}\n\t\t>\n\t\t\t{renderAvatarButton()}\n\t\t</MrlTooltip>\n\t);\n};\n"],"names":["MrlAvatarButton","_ref","buttonClassName","dataQa","id","includeInRoving","isToggleButton","label","_ref$loading","loading","_ref$loadingText","loadingText","onClick","size","_ref$state","state","_ref$toggleAria","toggleAria","buttonDefaults","tooltip","eventId","triggerRef","rest","_objectWithoutProperties","_excluded","_React$useState","React","useState","_isSelected","_React$useState2","_slicedToArray","isSelected","setIsSelected","trackInteraction","useMrlTrackInteraction","useEffect","spinner","createElement","MrlSpinner","className","kind","role","text","attributes","setAttributes","_objectSpread","_isDisabled","concat","undefined","type","handleOnClick","e","stopPropagation","action","variant","prevIsSelected","buttonClasses","classNames","styles","renderAvatarButton","_extends","ref","MrlAvatar","MrlTooltip","position","anchor"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwFA;AACA;AACA;AACA;AACA;AACO,IAAMA,eAAe,GAAGC,IAAA,IAiBqB;AAAA,EAAA,IAhBnDC,eAAe,GAAAD,IAAA,CAAfC,eAAe;IACfC,MAAM,GAAAF,IAAA,CAANE,MAAM;IACNC,EAAE,GAAAH,IAAA,CAAFG,EAAE;IACFC,eAAe,GAAAJ,IAAA,CAAfI,eAAe;IACfC,cAAc,GAAAL,IAAA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require('classnames');
|
|
|
6
6
|
var reactRouterDom = require('react-router-dom');
|
|
7
7
|
var MrlBreadcrumbItem_module = require('./MrlBreadcrumbItem.module.scss.js');
|
|
8
8
|
var dsIcons = require('@muraldevkit/ds-icons');
|
|
9
|
+
var useMrlAnalytics = require('../../../hooks/useMrlAnalytics/useMrlAnalytics.js');
|
|
9
10
|
var MrlSvg = require('../../svg/MrlSvg/MrlSvg.js');
|
|
10
11
|
var MrlBreadcrumbSeparator = require('../MrlBreadcrumbSeparator/MrlBreadcrumbSeparator.js');
|
|
11
12
|
|
|
@@ -32,7 +33,7 @@ function _interopNamespace(e) {
|
|
|
32
33
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
33
34
|
var classnames__default = /*#__PURE__*/_interopDefault(classnames);
|
|
34
35
|
|
|
35
|
-
var _excluded = ["link", "text", "isSelected", "hasSeparator", "isTruncated"];
|
|
36
|
+
var _excluded = ["link", "text", "isSelected", "hasSeparator", "isTruncated", "eventId"];
|
|
36
37
|
/**
|
|
37
38
|
* MrlBreadcrumbItem component.
|
|
38
39
|
* @param props The MrlBreadcrumbItem component properties.
|
|
@@ -46,22 +47,31 @@ function MrlBreadcrumbItem(props) {
|
|
|
46
47
|
hasSeparator = _props$hasSeparator === void 0 ? true : _props$hasSeparator,
|
|
47
48
|
_props$isTruncated = props.isTruncated,
|
|
48
49
|
isTruncated = _props$isTruncated === void 0 ? false : _props$isTruncated,
|
|
50
|
+
eventId = props.eventId,
|
|
49
51
|
rest = _rollupPluginBabelHelpers.objectWithoutProperties(props, _excluded);
|
|
52
|
+
var trackInteraction = useMrlAnalytics.useMrlTrackInteraction('MrlBreadcrumbItem', eventId);
|
|
50
53
|
var breadcrumbItem = React__namespace.useMemo(() => {
|
|
54
|
+
// the selected crumb is the current page, so it navigates nowhere and emits nothing.
|
|
51
55
|
if (isSelected) {
|
|
52
56
|
// eslint-disable-next-line jsx-a11y/anchor-is-valid
|
|
53
57
|
return /*#__PURE__*/React__namespace.createElement("a", {
|
|
54
58
|
"aria-current": "page"
|
|
55
59
|
}, text);
|
|
56
60
|
}
|
|
61
|
+
var handleClick = () => trackInteraction({
|
|
62
|
+
action: 'click'
|
|
63
|
+
});
|
|
57
64
|
if (typeof link === 'string') {
|
|
58
65
|
return /*#__PURE__*/React__namespace.createElement("a", {
|
|
59
|
-
href: link
|
|
66
|
+
href: link,
|
|
67
|
+
onClick: handleClick
|
|
60
68
|
}, text);
|
|
61
69
|
} else if (typeof link === 'object') {
|
|
62
|
-
return /*#__PURE__*/React__namespace.createElement(reactRouterDom.Link, link,
|
|
70
|
+
return /*#__PURE__*/React__namespace.createElement(reactRouterDom.Link, _rollupPluginBabelHelpers.extends({}, link, {
|
|
71
|
+
onClick: handleClick
|
|
72
|
+
}), text);
|
|
63
73
|
}
|
|
64
|
-
}, [link, text, isSelected]);
|
|
74
|
+
}, [link, text, isSelected, trackInteraction]);
|
|
65
75
|
return /*#__PURE__*/React__namespace.createElement("li", _rollupPluginBabelHelpers.extends({}, rest, {
|
|
66
76
|
className: classnames__default.default(MrlBreadcrumbItem_module.default['MrlBreadcrumbItem'], 'MrlBreadcrumbItem', {
|
|
67
77
|
[MrlBreadcrumbItem_module.default['MrlBreadcrumbItem--selected']]: isSelected,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MrlBreadcrumbItem.js","sources":["../../../../../src/components/breadcrumb/MrlBreadcrumbItem/MrlBreadcrumbItem.tsx"],"sourcesContent":["/* eslint-disable no-mixed-spaces-and-tabs */\nimport * as React from 'react';\nimport classnames from 'classnames';\nimport { Link } from 'react-router-dom';\nimport styles from './MrlBreadcrumbItem.module.scss';\nimport { MrlSvg } from '../../svg';\nimport { more } from '@muraldevkit/ds-icons';\nimport { MrlBreadcrumbSeparator } from '../MrlBreadcrumbSeparator';\n\nexport type BreadcrumbItemLink =\n\t| {\n\t\t\ttext: string;\n\t\t\tlink: string;\n\t }\n\t| {\n\t\t\ttext: string;\n\t\t\tlink: React.ComponentPropsWithoutRef<typeof Link>;\n\t };\n\nexport type BreadcrumbItem = {\n\tisSelected?: boolean;\n\thasSeparator?: boolean;\n\tisTruncated?: boolean;\n} & BreadcrumbItemLink;\n\nexport interface MrlBreadcrumbItemProps extends React.ComponentPropsWithRef<'li'> {\n\t/**\n\t * Children to be rendered within the component\n\t */\n\tchildren?: React.ReactNode;\n\n\t/**\n\t * Determines whether a separator should be displayed after this breadcrumb item.\n\t */\n\thasSeparator?: BreadcrumbItem['hasSeparator'];\n\n\t/**\n\t * Indicates whether this breadcrumb item represents the currently selected or\n\t * active page.\n\t */\n\tisSelected?: BreadcrumbItem['isSelected'];\n\n\t/**\n\t * Specifies whether the text content of this breadcrumb item should be truncated\n\t * if it exceeds a certain width. This is useful for handling long page titles\n\t * or labels within the breadcrumb.\n\t */\n\tisTruncated?: boolean;\n\n\tlink?: BreadcrumbItem['link'];\n\ttext?: BreadcrumbItem['text'];\n}\n\n/**\n * MrlBreadcrumbItem component.\n * @param props The MrlBreadcrumbItem component properties.\n * @returns The MrlBreadcrumbItem component.\n */\nexport function MrlBreadcrumbItem(props: MrlBreadcrumbItemProps): JSX.Element {\n\tconst {
|
|
1
|
+
{"version":3,"file":"MrlBreadcrumbItem.js","sources":["../../../../../src/components/breadcrumb/MrlBreadcrumbItem/MrlBreadcrumbItem.tsx"],"sourcesContent":["/* eslint-disable no-mixed-spaces-and-tabs */\nimport * as React from 'react';\nimport classnames from 'classnames';\nimport { Link } from 'react-router-dom';\nimport styles from './MrlBreadcrumbItem.module.scss';\nimport { MrlSvg } from '../../svg';\nimport { more } from '@muraldevkit/ds-icons';\nimport { MrlBreadcrumbSeparator } from '../MrlBreadcrumbSeparator';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\n\nexport type BreadcrumbItemLink =\n\t| {\n\t\t\ttext: string;\n\t\t\tlink: string;\n\t }\n\t| {\n\t\t\ttext: string;\n\t\t\tlink: React.ComponentPropsWithoutRef<typeof Link>;\n\t };\n\nexport type BreadcrumbItem = {\n\tisSelected?: boolean;\n\thasSeparator?: boolean;\n\tisTruncated?: boolean;\n} & BreadcrumbItemLink;\n\nexport interface MrlBreadcrumbItemProps extends React.ComponentPropsWithRef<'li'> {\n\t/**\n\t * Children to be rendered within the component\n\t */\n\tchildren?: React.ReactNode;\n\n\t/**\n\t * Determines whether a separator should be displayed after this breadcrumb item.\n\t */\n\thasSeparator?: BreadcrumbItem['hasSeparator'];\n\n\t/**\n\t * Indicates whether this breadcrumb item represents the currently selected or\n\t * active page.\n\t */\n\tisSelected?: BreadcrumbItem['isSelected'];\n\n\t/**\n\t * Specifies whether the text content of this breadcrumb item should be truncated\n\t * if it exceeds a certain width. This is useful for handling long page titles\n\t * or labels within the breadcrumb.\n\t */\n\tisTruncated?: boolean;\n\n\tlink?: BreadcrumbItem['link'];\n\ttext?: BreadcrumbItem['text'];\n\n\t/**\n\t * Enables interaction tracking for this breadcrumb. Provide a stable, non-PII id\n\t * (e.g. 'room-breadcrumb'). When omitted, the breadcrumb emits no analytics.\n\t */\n\teventId?: string;\n}\n\n/**\n * MrlBreadcrumbItem component.\n * @param props The MrlBreadcrumbItem component properties.\n * @returns The MrlBreadcrumbItem component.\n */\nexport function MrlBreadcrumbItem(props: MrlBreadcrumbItemProps): JSX.Element {\n\tconst {\n\t\tlink,\n\t\ttext,\n\t\tisSelected,\n\t\thasSeparator = true,\n\t\tisTruncated = false,\n\t\teventId,\n\t\t...rest\n\t} = props;\n\n\tconst trackInteraction = useMrlTrackInteraction('MrlBreadcrumbItem', eventId);\n\n\tconst breadcrumbItem = React.useMemo(() => {\n\t\t// the selected crumb is the current page, so it navigates nowhere and emits nothing.\n\t\tif (isSelected) {\n\t\t\t// eslint-disable-next-line jsx-a11y/anchor-is-valid\n\t\t\treturn <a aria-current=\"page\">{text}</a>;\n\t\t}\n\n\t\tconst handleClick = () => trackInteraction({ action: 'click' });\n\n\t\tif (typeof link === 'string') {\n\t\t\treturn (\n\t\t\t\t<a href={link} onClick={handleClick}>\n\t\t\t\t\t{text}\n\t\t\t\t</a>\n\t\t\t);\n\t\t} else if (typeof link === 'object') {\n\t\t\treturn (\n\t\t\t\t<Link {...link} onClick={handleClick}>\n\t\t\t\t\t{text}\n\t\t\t\t</Link>\n\t\t\t);\n\t\t}\n\t}, [link, text, isSelected, trackInteraction]);\n\n\treturn (\n\t\t<li\n\t\t\t{...rest}\n\t\t\tclassName={classnames(styles['MrlBreadcrumbItem'], 'MrlBreadcrumbItem', {\n\t\t\t\t[styles['MrlBreadcrumbItem--selected']]: isSelected,\n\t\t\t\t['MrlBreadcrumbItem--selected']: isSelected\n\t\t\t})}\n\t\t>\n\t\t\t{isTruncated && (\n\t\t\t\t<span className={classnames(styles['MrlBreadcrumbItem--icon'])}>\n\t\t\t\t\t<MrlSvg size=\"auto\" svg={more} />\n\t\t\t\t</span>\n\t\t\t)}\n\t\t\t{!isTruncated && breadcrumbItem}\n\t\t\t{hasSeparator && <MrlBreadcrumbSeparator />}\n\t\t</li>\n\t);\n}\n"],"names":["MrlBreadcrumbItem","props","link","text","isSelected","_props$hasSeparator","hasSeparator","_props$isTruncated","isTruncated","eventId","rest","_objectWithoutProperties","_excluded","trackInteraction","useMrlTrackInteraction","breadcrumbItem","React","useMemo","createElement","handleClick","action","href","onClick","Link","_extends","className","classnames","styles","MrlSvg","size","svg","more","MrlBreadcrumbSeparator"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DA;AACA;AACA;AACA;AACA;AACO,SAASA,iBAAiBA,CAACC,KAA6B,EAAe;AAC7E,EAAA,IACCC,IAAI,GAODD,KAAK,CAPRC,IAAI;IACJC,IAAI,GAMDF,KAAK,CANRE,IAAI;IACJC,UAAU,GAKPH,KAAK,CALRG,UAAU;IAAAC,mBAAA,GAKPJ,KAAK,CAJRK,YAAY;AAAZA,IAAAA,YAAY,GAAAD,mBAAA,KAAA,MAAA,GAAG,IAAI,GAAAA,mBAAA;IAAAE,kBAAA,GAIhBN,KAAK,CAHR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EAAE,mBAAmB,EAAE;AACvE,MAAA,CAACA,gCAAM,CAAC,6BAA6B,CAAC,GAAGvB,UAAU;AACnD,MAAA,CAAC,6BAA6B,GAAGA;KACjC;AAAE,GAAA,CAAA,EAEFI,WAAW,iBACXQ,gBAAA,CAAAE,aAAA,CAAA,MAAA,EAAA;AAAMO,IAAAA,SAAS,EAAEC,2BAAU,CAACC,gCAAM,CAAC,yBAAyB,CAAC;AAAE,GAAA,eAC9DX,gBAAA,CAAAE,aAAA,CAACU,aAAM,EAAA;AAACC,IAAAA,IAAI,EAAC,MAAM;AAACC,IAAAA,GAAG,EAAEC;AAAK,GAAE,CAC3B,CACN,EACA,CAACvB,WAAW,IAAIO,cAAc,EAC9BT,YAAY,iBAAIU,gBAAA,CAAAE,aAAA,CAACc,6CAAsB,EAAA,IAAE,CACvC,CAAC;AAEP;;;;"}
|
|
@@ -7,6 +7,7 @@ var MrlSvgAnimate = require('../../svg/MrlSvgAnimate/MrlSvgAnimate.js');
|
|
|
7
7
|
var constants = require('../../tooltip/constants.js');
|
|
8
8
|
var constants$1 = require('../constants.js');
|
|
9
9
|
var helpers = require('../helpers.js');
|
|
10
|
+
var useMrlAnalytics = require('../../../hooks/useMrlAnalytics/useMrlAnalytics.js');
|
|
10
11
|
var setAttributes = require('../../../utils/setAttributes/setAttributes.js');
|
|
11
12
|
var MrlTooltip = require('../../tooltip/MrlTooltip/MrlTooltip.js');
|
|
12
13
|
|
|
@@ -33,7 +34,7 @@ function _interopNamespace(e) {
|
|
|
33
34
|
var classnames__default = /*#__PURE__*/_interopDefault(classnames);
|
|
34
35
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
35
36
|
|
|
36
|
-
var _excluded = ["attrs", "badge", "disableEvents", "icon", "kind", "loading", "onClick", "position", "toggleAria", "toggleStyle", "text", "tipAnchor", "size", "state"];
|
|
37
|
+
var _excluded = ["attrs", "badge", "disableEvents", "icon", "kind", "loading", "onClick", "position", "toggleAria", "toggleStyle", "text", "tipAnchor", "eventId", "size", "state"];
|
|
37
38
|
var MrlAnimatedIconButton = /*#__PURE__*/React__namespace.forwardRef(function MrlAnimatedIconButton(_ref, ref) {
|
|
38
39
|
var _ref$attrs = _ref.attrs,
|
|
39
40
|
attrs = _ref$attrs === void 0 ? {} : _ref$attrs,
|
|
@@ -54,6 +55,7 @@ var MrlAnimatedIconButton = /*#__PURE__*/React__namespace.forwardRef(function Mr
|
|
|
54
55
|
text = _ref.text,
|
|
55
56
|
_ref$tipAnchor = _ref.tipAnchor,
|
|
56
57
|
tipAnchor = _ref$tipAnchor === void 0 ? constants.MrlTooltipDefaults.anchor : _ref$tipAnchor,
|
|
58
|
+
eventId = _ref.eventId,
|
|
57
59
|
_ref$size = _ref.size,
|
|
58
60
|
size = _ref$size === void 0 ? constants$1.buttonDefaults.size : _ref$size,
|
|
59
61
|
_ref$state = _ref.state,
|
|
@@ -74,6 +76,7 @@ var MrlAnimatedIconButton = /*#__PURE__*/React__namespace.forwardRef(function Mr
|
|
|
74
76
|
_React$useState6 = _rollupPluginBabelHelpers.slicedToArray(_React$useState5, 2),
|
|
75
77
|
isSelected = _React$useState6[0],
|
|
76
78
|
setIsSelected = _React$useState6[1];
|
|
79
|
+
var trackInteraction = useMrlAnalytics.useMrlTrackInteraction('MrlAnimatedIconButton', eventId);
|
|
77
80
|
var buttonRef = React__namespace.useRef(null);
|
|
78
81
|
/**
|
|
79
82
|
* `useImperativeHandle` customizes the instance value
|
|
@@ -105,6 +108,10 @@ var MrlAnimatedIconButton = /*#__PURE__*/React__namespace.forwardRef(function Mr
|
|
|
105
108
|
if (helpers._isDisabled(state, loading) || disableEvents) {
|
|
106
109
|
return;
|
|
107
110
|
}
|
|
111
|
+
trackInteraction({
|
|
112
|
+
action: 'click',
|
|
113
|
+
variant: kind
|
|
114
|
+
});
|
|
108
115
|
if (isToggleButton) {
|
|
109
116
|
setIsSelected(prevIsSelected => !prevIsSelected);
|
|
110
117
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MrlAnimatedIconButton.js","sources":["../../../../../src/components/button/MrlAnimatedIconButton/MrlAnimatedIconButton.tsx"],"sourcesContent":["import classnames from 'classnames';\nimport * as React from 'react';\nimport { setAttributes } from '../../../utils';\nimport { MrlSvgAnimate, MrlSvgAnimateProps } from '../../svg/MrlSvgAnimate/MrlSvgAnimate';\nimport { AnimatedState } from '../../svg/constants';\nimport { MrlTooltip } from '../../tooltip';\nimport { MrlTooltipDefaults } from '../../tooltip/constants';\nimport { MrlIconButtonProps } from '../MrlIconButton/MrlIconButton';\nimport { buttonDefaults } from '../constants';\nimport { _isDisabled, _isSelected, _isToggleButton } from '../helpers';\n\nimport './MrlAnimatedIconButton.scss';\n\ninterface MrlAnimatedIconButtonProps extends Omit<MrlIconButtonProps, 'icon'> {\n\ticon: MrlSvgAnimateProps;\n}\n\ntype animationEvent = 'hover' | 'blur' | 'focus';\n\nexport const MrlAnimatedIconButton = React.forwardRef<\n\tHTMLButtonElement,\n\tMrlAnimatedIconButtonProps\n>(function MrlAnimatedIconButton(\n\t{\n\t\tattrs = {},\n\t\tbadge,\n\t\tdisableEvents = false,\n\t\ticon,\n\t\t// We intentionally deviate from the basic button for icon-buttons since the vast\n\t\t// majority of icon buttons are ghost buttons. The proptype remains\n\t\t// consistent with the basic button however to keep our code DRY.\n\t\tkind = 'ghost-inverse',\n\t\tloading = false,\n\t\tonClick,\n\t\tposition = MrlTooltipDefaults.position,\n\t\ttoggleAria = buttonDefaults.toggleAria,\n\t\ttoggleStyle,\n\t\ttext,\n\t\ttipAnchor = MrlTooltipDefaults.anchor,\n\t\tsize = buttonDefaults.size,\n\t\tstate = buttonDefaults.state,\n\t\t...remainingProps\n\t}: MrlAnimatedIconButtonProps,\n\tref\n) {\n\t/**\n\t * State value to determine if the icon should be animating\n\t */\n\tconst [isAnimating, setAnimation] = React.useState<AnimatedState>('stop');\n\n\tconst [isHovered, setHover] = React.useState(false);\n\n\tconst [isSelected, setIsSelected] = React.useState(() => _isSelected(state));\n\n\tconst buttonRef = React.useRef<HTMLButtonElement>(null);\n\t/**\n\t * `useImperativeHandle` customizes the instance value\n\t * that is exposed to parent components when using ref.\n\t */\n\tReact.useImperativeHandle<HTMLButtonElement | null, HTMLButtonElement | null>(\n\t\tref,\n\t\t() => buttonRef.current\n\t);\n\n\t/**\n\t * MrlAnimatedIconButton could behave as a toggle button if toggleStyle is 'default' or 'secondary'\n\t */\n\tconst isToggleButton = toggleStyle && _isToggleButton(toggleStyle);\n\n\t/**\n\t * We need to watch the value of state to keep in sync\n\t * the value of state passed as props and the internal\n\t * isSelected piece of state.\n\t */\n\tReact.useEffect(() => {\n\t\t// allows consumers to set the 'selected' or 'selected-disabled' state from a parent component.\n\t\tsetIsSelected(_isSelected(state));\n\t}, [state]);\n\n\t/**\n\t * Handle onClick events\n\t * @param {React.MouseEvent<HTMLButtonElement>} e - mouse event\n\t */\n\tconst handleOnClick = (e: React.MouseEvent<HTMLButtonElement>): void => {\n\t\te.stopPropagation();\n\n\t\tif (_isDisabled(state, loading) || disableEvents) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (isToggleButton) {\n\t\t\tsetIsSelected((prevIsSelected) => !prevIsSelected);\n\t\t}\n\n\t\tif (onClick && typeof onClick === 'function') {\n\t\t\tonClick(e);\n\t\t}\n\t};\n\n\t/**\n\t * Handle animation status for mouse events exclusively\n\t * @param {boolean} mouseEnter - Determines if this is a mouseEnter event\n\t * @returns {void}\n\t */\n\tconst handleMouseInteraction = (mouseEnter: boolean): void => {\n\t\t/** Set hover status of button */\n\t\tsetHover(mouseEnter);\n\n\t\t/**\n\t\t * If the button is in focus and we trigger a mouse event\n\t\t * we don't need to change the animation state.\n\t\t */\n\t\tif (document.activeElement === buttonRef.current) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (isAnimating === 'play') {\n\t\t\tsetAnimation('stop');\n\t\t} else {\n\t\t\tsetAnimation('play');\n\t\t}\n\t};\n\n\t/**\n\t * Handle animation status for mouse and keyboard events\n\t * @param {animationEvent} eventType - The type of interaction that is triggering the animation update.\n\t * @param {boolean} startEvent - Whether or not this event should start an animation\n\t * @returns {void}\n\t */\n\tconst handleAnimation = (eventType: animationEvent, startEvent = false): void => {\n\t\t/** If the button is diabled or selected, the animation must be stopped */\n\t\tif (isSelected || _isDisabled(state, loading)) {\n\t\t\tsetAnimation('stop');\n\t\t\t/** We still need to track the hover state */\n\t\t\tsetHover(startEvent);\n\t\t\treturn;\n\t\t}\n\n\t\t/**\n\t\t * If the event is a hover interaction, handle them appropriately.\n\t\t * We do this to ensure you can hover and focus without restarting\n\t\t * or stopping the animation incorrectly.\n\t\t */\n\t\tif (eventType === 'hover') {\n\t\t\thandleMouseInteraction(startEvent);\n\n\t\t\treturn;\n\t\t}\n\n\t\t/**\n\t\t * Keyboard events\n\t\t */\n\t\tif (isAnimating === 'play') {\n\t\t\t/**\n\t\t\t * If a button is hovered and focused, do not stop the\n\t\t\t * animation on blur.\n\t\t\t */\n\t\t\tif (isHovered) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetAnimation('stop');\n\t\t\treturn;\n\t\t}\n\n\t\tsetAnimation('play');\n\t};\n\n\tconst handleBlur = () => {\n\t\thandleAnimation('blur');\n\t};\n\n\tconst handleFocus = () => {\n\t\thandleAnimation('focus');\n\t};\n\n\tconst handleMouseEnter = () => {\n\t\thandleAnimation('hover', true);\n\t};\n\n\tconst handleMouseLeave = () => {\n\t\thandleAnimation('hover');\n\t};\n\n\tconst classNames = classnames(\n\t\t'mrlIconButton',\n\t\t`mrlIconButton--${size}`,\n\t\t`mrlIconButton--${kind}`,\n\t\t'mrlAnimatedIconButton',\n\t\t`toggleStyle--${toggleStyle}`\n\t);\n\n\tconst attributes = setAttributes(attrs, {\n\t\t'aria-disabled': _isDisabled(state, loading),\n\t\t'aria-label': text,\n\t\t...(isToggleButton && { [`aria-${toggleAria}`]: isSelected || false }),\n\t\ttype: 'button'\n\t});\n\n\treturn (\n\t\t<MrlTooltip anchor={tipAnchor} position={position} text={text}>\n\t\t\t<button\n\t\t\t\t{...attributes}\n\t\t\t\t{...remainingProps}\n\t\t\t\tclassName={classNames}\n\t\t\t\tref={buttonRef}\n\t\t\t\tonBlur={handleBlur}\n\t\t\t\tonClick={handleOnClick}\n\t\t\t\tonFocus={handleFocus}\n\t\t\t\tonMouseEnter={handleMouseEnter}\n\t\t\t\tonMouseLeave={handleMouseLeave}\n\t\t\t>\n\t\t\t\t<div className=\"mrlAnimatedIconButton-iconContainer\">\n\t\t\t\t\t<MrlSvgAnimate {...icon} state={isAnimating} />\n\t\t\t\t</div>\n\t\t\t\t{badge}\n\t\t\t</button>\n\t\t</MrlTooltip>\n\t);\n});\n"],"names":["MrlAnimatedIconButton","React","forwardRef","_ref","ref","_ref$attrs","attrs","badge","_ref$disableEvents","disableEvents","icon","_ref$kind","kind","_ref$loading","loading","onClick","_ref$position","position","MrlTooltipDefaults","_ref$toggleAria","toggleAria","buttonDefaults","toggleStyle","text","_ref$tipAnchor","tipAnchor","anchor","_ref$size","size","_ref$state","state","remainingProps","_objectWithoutProperties","_excluded","_React$useState","useState","_React$useState2","_slicedToArray","isAnimating","setAnimation","_React$useState3","_React$useState4","isHovered","setHover","_React$useState5","_isSelected","_React$useState6","isSelected","setIsSelected","buttonRef","useRef","useImperativeHandle","current","isToggleButton","_isToggleButton","useEffect","handleOnClick","e","stopPropagation","_isDisabled","prevIsSelected","handleMouseInteraction","mouseEnter","document","activeElement","handleAnimation","eventType","startEvent","arguments","length","undefined","handleBlur","handleFocus","handleMouseEnter","handleMouseLeave","classNames","classnames","concat","attributes","setAttributes","_objectSpread","type","createElement","MrlTooltip","_extends","className","onBlur","onFocus","onMouseEnter","onMouseLeave","MrlSvgAnimate"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBO,IAAMA,qBAAqB,gBAAGC,gBAAK,CAACC,UAAU,CAGnD,SAASF,qBAAqBA,CAAAG,IAAA,EAqB/BC,GAAG,EACF;AAAA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U,IAAI;GAAO,CAAA,EAAA,EAAA,EAAA;AACrEkC,IAAAA,IAAI,EAAE;AAAQ,GAAA,CACd,CAAC;AAEF,EAAA,oBACChF,gBAAA,CAAAiF,aAAA,CAACC,qBAAU,EAAA;AAACzD,IAAAA,MAAM,EAAED,SAAU;AAACR,IAAAA,QAAQ,EAAEA,QAAS;AAACM,IAAAA,IAAI,EAAEA;GAAK,eAC7DtB,gBAAA,CAAAiF,aAAA,CAAA,QAAA,EAAAE,iCAAA,CAAA,EAAA,EACKN,UAAU,EACV/C,cAAc,EAAA;AAClBsD,IAAAA,SAAS,EAAEV,UAAW;AACtBvE,IAAAA,GAAG,EAAE6C,SAAU;AACfqC,IAAAA,MAAM,EAAEf,UAAW;AACnBxD,IAAAA,OAAO,EAAEyC,aAAc;AACvB+B,IAAAA,OAAO,EAAEf,WAAY;AACrBgB,IAAAA,YAAY,EAAEf,gBAAiB;AAC/BgB,IAAAA,YAAY,EAAEf;GAAiB,CAAA,eAE/BzE,gBAAA,CAAAiF,aAAA,CAAA,KAAA,EAAA;AAAKG,IAAAA,SAAS,EAAC;GAAqC,eACnDpF,gBAAA,CAAAiF,aAAA,CAACQ,2BAAa,EAAAN,iCAAA,KAAK1E,IAAI,EAAA;AAAEoB,IAAAA,KAAK,EAAEQ;AAAY,GAAA,CAAE,CAC1C,CAAC,EACL/B,KACM,CACG,CAAC;AAEf,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"MrlAnimatedIconButton.js","sources":["../../../../../src/components/button/MrlAnimatedIconButton/MrlAnimatedIconButton.tsx"],"sourcesContent":["import classnames from 'classnames';\nimport * as React from 'react';\nimport { setAttributes } from '../../../utils';\nimport { MrlSvgAnimate, MrlSvgAnimateProps } from '../../svg/MrlSvgAnimate/MrlSvgAnimate';\nimport { AnimatedState } from '../../svg/constants';\nimport { MrlTooltip } from '../../tooltip';\nimport { MrlTooltipDefaults } from '../../tooltip/constants';\nimport { MrlIconButtonProps } from '../MrlIconButton/MrlIconButton';\nimport { buttonDefaults } from '../constants';\nimport { _isDisabled, _isSelected, _isToggleButton } from '../helpers';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\n\nimport './MrlAnimatedIconButton.scss';\n\ninterface MrlAnimatedIconButtonProps extends Omit<MrlIconButtonProps, 'icon'> {\n\ticon: MrlSvgAnimateProps;\n}\n\ntype animationEvent = 'hover' | 'blur' | 'focus';\n\nexport const MrlAnimatedIconButton = React.forwardRef<\n\tHTMLButtonElement,\n\tMrlAnimatedIconButtonProps\n>(function MrlAnimatedIconButton(\n\t{\n\t\tattrs = {},\n\t\tbadge,\n\t\tdisableEvents = false,\n\t\ticon,\n\t\t// We intentionally deviate from the basic button for icon-buttons since the vast\n\t\t// majority of icon buttons are ghost buttons. The proptype remains\n\t\t// consistent with the basic button however to keep our code DRY.\n\t\tkind = 'ghost-inverse',\n\t\tloading = false,\n\t\tonClick,\n\t\tposition = MrlTooltipDefaults.position,\n\t\ttoggleAria = buttonDefaults.toggleAria,\n\t\ttoggleStyle,\n\t\ttext,\n\t\ttipAnchor = MrlTooltipDefaults.anchor,\n\t\teventId,\n\t\tsize = buttonDefaults.size,\n\t\tstate = buttonDefaults.state,\n\t\t...remainingProps\n\t}: MrlAnimatedIconButtonProps,\n\tref\n) {\n\t/**\n\t * State value to determine if the icon should be animating\n\t */\n\tconst [isAnimating, setAnimation] = React.useState<AnimatedState>('stop');\n\n\tconst [isHovered, setHover] = React.useState(false);\n\n\tconst [isSelected, setIsSelected] = React.useState(() => _isSelected(state));\n\n\tconst trackInteraction = useMrlTrackInteraction('MrlAnimatedIconButton', eventId);\n\n\tconst buttonRef = React.useRef<HTMLButtonElement>(null);\n\t/**\n\t * `useImperativeHandle` customizes the instance value\n\t * that is exposed to parent components when using ref.\n\t */\n\tReact.useImperativeHandle<HTMLButtonElement | null, HTMLButtonElement | null>(\n\t\tref,\n\t\t() => buttonRef.current\n\t);\n\n\t/**\n\t * MrlAnimatedIconButton could behave as a toggle button if toggleStyle is 'default' or 'secondary'\n\t */\n\tconst isToggleButton = toggleStyle && _isToggleButton(toggleStyle);\n\n\t/**\n\t * We need to watch the value of state to keep in sync\n\t * the value of state passed as props and the internal\n\t * isSelected piece of state.\n\t */\n\tReact.useEffect(() => {\n\t\t// allows consumers to set the 'selected' or 'selected-disabled' state from a parent component.\n\t\tsetIsSelected(_isSelected(state));\n\t}, [state]);\n\n\t/**\n\t * Handle onClick events\n\t * @param {React.MouseEvent<HTMLButtonElement>} e - mouse event\n\t */\n\tconst handleOnClick = (e: React.MouseEvent<HTMLButtonElement>): void => {\n\t\te.stopPropagation();\n\n\t\tif (_isDisabled(state, loading) || disableEvents) {\n\t\t\treturn;\n\t\t}\n\n\t\ttrackInteraction({ action: 'click', variant: kind });\n\n\t\tif (isToggleButton) {\n\t\t\tsetIsSelected((prevIsSelected) => !prevIsSelected);\n\t\t}\n\n\t\tif (onClick && typeof onClick === 'function') {\n\t\t\tonClick(e);\n\t\t}\n\t};\n\n\t/**\n\t * Handle animation status for mouse events exclusively\n\t * @param {boolean} mouseEnter - Determines if this is a mouseEnter event\n\t * @returns {void}\n\t */\n\tconst handleMouseInteraction = (mouseEnter: boolean): void => {\n\t\t/** Set hover status of button */\n\t\tsetHover(mouseEnter);\n\n\t\t/**\n\t\t * If the button is in focus and we trigger a mouse event\n\t\t * we don't need to change the animation state.\n\t\t */\n\t\tif (document.activeElement === buttonRef.current) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (isAnimating === 'play') {\n\t\t\tsetAnimation('stop');\n\t\t} else {\n\t\t\tsetAnimation('play');\n\t\t}\n\t};\n\n\t/**\n\t * Handle animation status for mouse and keyboard events\n\t * @param {animationEvent} eventType - The type of interaction that is triggering the animation update.\n\t * @param {boolean} startEvent - Whether or not this event should start an animation\n\t * @returns {void}\n\t */\n\tconst handleAnimation = (eventType: animationEvent, startEvent = false): void => {\n\t\t/** If the button is diabled or selected, the animation must be stopped */\n\t\tif (isSelected || _isDisabled(state, loading)) {\n\t\t\tsetAnimation('stop');\n\t\t\t/** We still need to track the hover state */\n\t\t\tsetHover(startEvent);\n\t\t\treturn;\n\t\t}\n\n\t\t/**\n\t\t * If the event is a hover interaction, handle them appropriately.\n\t\t * We do this to ensure you can hover and focus without restarting\n\t\t * or stopping the animation incorrectly.\n\t\t */\n\t\tif (eventType === 'hover') {\n\t\t\thandleMouseInteraction(startEvent);\n\n\t\t\treturn;\n\t\t}\n\n\t\t/**\n\t\t * Keyboard events\n\t\t */\n\t\tif (isAnimating === 'play') {\n\t\t\t/**\n\t\t\t * If a button is hovered and focused, do not stop the\n\t\t\t * animation on blur.\n\t\t\t */\n\t\t\tif (isHovered) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetAnimation('stop');\n\t\t\treturn;\n\t\t}\n\n\t\tsetAnimation('play');\n\t};\n\n\tconst handleBlur = () => {\n\t\thandleAnimation('blur');\n\t};\n\n\tconst handleFocus = () => {\n\t\thandleAnimation('focus');\n\t};\n\n\tconst handleMouseEnter = () => {\n\t\thandleAnimation('hover', true);\n\t};\n\n\tconst handleMouseLeave = () => {\n\t\thandleAnimation('hover');\n\t};\n\n\tconst classNames = classnames(\n\t\t'mrlIconButton',\n\t\t`mrlIconButton--${size}`,\n\t\t`mrlIconButton--${kind}`,\n\t\t'mrlAnimatedIconButton',\n\t\t`toggleStyle--${toggleStyle}`\n\t);\n\n\tconst attributes = setAttributes(attrs, {\n\t\t'aria-disabled': _isDisabled(state, loading),\n\t\t'aria-label': text,\n\t\t...(isToggleButton && { [`aria-${toggleAria}`]: isSelected || false }),\n\t\ttype: 'button'\n\t});\n\n\treturn (\n\t\t<MrlTooltip anchor={tipAnchor} position={position} text={text}>\n\t\t\t<button\n\t\t\t\t{...attributes}\n\t\t\t\t{...remainingProps}\n\t\t\t\tclassName={classNames}\n\t\t\t\tref={buttonRef}\n\t\t\t\tonBlur={handleBlur}\n\t\t\t\tonClick={handleOnClick}\n\t\t\t\tonFocus={handleFocus}\n\t\t\t\tonMouseEnter={handleMouseEnter}\n\t\t\t\tonMouseLeave={handleMouseLeave}\n\t\t\t>\n\t\t\t\t<div className=\"mrlAnimatedIconButton-iconContainer\">\n\t\t\t\t\t<MrlSvgAnimate {...icon} state={isAnimating} />\n\t\t\t\t</div>\n\t\t\t\t{badge}\n\t\t\t</button>\n\t\t</MrlTooltip>\n\t);\n});\n"],"names":["MrlAnimatedIconButton","React","forwardRef","_ref","ref","_ref$attrs","attrs","badge","_ref$disableEvents","disableEvents","icon","_ref$kind","kind","_ref$loading","loading","onClick","_ref$position","position","MrlTooltipDefaults","_ref$toggleAria","toggleAria","buttonDefaults","toggleStyle","text","_ref$tipAnchor","tipAnchor","anchor","eventId","_ref$size","size","_ref$state","state","remainingProps","_objectWithoutProperties","_excluded","_React$useState","useState","_React$useState2","_slicedToArray","isAnimating","setAnimation","_React$useState3","_React$useState4","isHovered","setHover","_React$useState5","_isSelected","_React$useState6","isSelected","setIsSelected","trackInteraction","useMrlTrackInteraction","buttonRef","useRef","useImperativeHandle","current","isToggleButton","_isToggleButton","useEffect","handleOnClick","e","stopPropagation","_isDisabled","action","variant","prevIsSelected","handleMouseInteraction","mouseEnter","document","activeElement","handleAnimation","eventType","startEvent","arguments","length","undefined","handleBlur","handleFocus","handleMouseEnter","handleMouseLeave","classNames","classnames","concat","attributes","setAttributes","_objectSpread","type","createElement","MrlTooltip","_extends","className","onBlur","onFocus","onMouseEnter","onMouseLeave","MrlSvgAnimate"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBO,IAAMA,qBAAqB,gBAAGC,gBAAK,CAACC,UAAU,CAGnD,SAASF,qBAAqBA,CAAAG,IAAA,EAsB/BC,GAAG,EACF;AAAA,EAAA,IAAAC,UAAA,GAAAF,IAAA,CArBAG,KAAK;AAALA,IAAAA,KAAK,GAAAD,UAAA,KAAA,MAAA,GAAG,EAAE,GAAAA,UAAA;IACVE,KAAK,GAAAJ,IAAA,CAALI,KAAK;IAAAC,kBAAA,GAAAL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AAA,CAAA,OAAA,CAAA0B,MAAA,CAAS9D,UAAU,CAAA,GAAK4B,UAAU,IAAI;GAAO,CAAA,EAAA,EAAA,EAAA;AACrEsC,IAAAA,IAAI,EAAE;AAAQ,GAAA,CACd,CAAC;AAEF,EAAA,oBACCrF,gBAAA,CAAAsF,aAAA,CAACC,qBAAU,EAAA;AAAC9D,IAAAA,MAAM,EAAED,SAAU;AAACR,IAAAA,QAAQ,EAAEA,QAAS;AAACM,IAAAA,IAAI,EAAEA;GAAK,eAC7DtB,gBAAA,CAAAsF,aAAA,CAAA,QAAA,EAAAE,iCAAA,CAAA,EAAA,EACKN,UAAU,EACVnD,cAAc,EAAA;AAClB0D,IAAAA,SAAS,EAAEV,UAAW;AACtB5E,IAAAA,GAAG,EAAEgD,SAAU;AACfuC,IAAAA,MAAM,EAAEf,UAAW;AACnB7D,IAAAA,OAAO,EAAE4C,aAAc;AACvBiC,IAAAA,OAAO,EAAEf,WAAY;AACrBgB,IAAAA,YAAY,EAAEf,gBAAiB;AAC/BgB,IAAAA,YAAY,EAAEf;GAAiB,CAAA,eAE/B9E,gBAAA,CAAAsF,aAAA,CAAA,KAAA,EAAA;AAAKG,IAAAA,SAAS,EAAC;GAAqC,eACnDzF,gBAAA,CAAAsF,aAAA,CAACQ,2BAAa,EAAAN,iCAAA,KAAK/E,IAAI,EAAA;AAAEqB,IAAAA,KAAK,EAAEQ;AAAY,GAAA,CAAE,CAC1C,CAAC,EACLhC,KACM,CACG,CAAC;AAEf,CAAC;;;;"}
|
|
@@ -34,7 +34,7 @@ function _interopNamespace(e) {
|
|
|
34
34
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
35
35
|
var classnames__default = /*#__PURE__*/_interopDefault(classnames);
|
|
36
36
|
|
|
37
|
-
var _excluded = ["attrs", "badge", "className", "disabled", "disableEvents", "icon", "iconPos", "kind", "loading", "loadingText", "onClick", "toggleAria", "toggleStyle", "text", "
|
|
37
|
+
var _excluded = ["attrs", "badge", "className", "disabled", "disableEvents", "icon", "iconPos", "kind", "loading", "loadingText", "onClick", "toggleAria", "toggleStyle", "text", "eventId", "size", "state", "tooltip"];
|
|
38
38
|
var MrlButton = /*#__PURE__*/React__namespace.forwardRef(function MrlButton(_ref, ref) {
|
|
39
39
|
var attrs = _ref.attrs,
|
|
40
40
|
badge = _ref.badge,
|
|
@@ -57,7 +57,7 @@ var MrlButton = /*#__PURE__*/React__namespace.forwardRef(function MrlButton(_ref
|
|
|
57
57
|
toggleAria = _ref$toggleAria === void 0 ? constants$1.buttonDefaults.toggleAria : _ref$toggleAria,
|
|
58
58
|
toggleStyle = _ref.toggleStyle,
|
|
59
59
|
text = _ref.text,
|
|
60
|
-
|
|
60
|
+
eventId = _ref.eventId,
|
|
61
61
|
_ref$size = _ref.size,
|
|
62
62
|
size = _ref$size === void 0 ? constants$1.buttonDefaults.size : _ref$size,
|
|
63
63
|
_ref$state = _ref.state,
|
|
@@ -68,7 +68,7 @@ var MrlButton = /*#__PURE__*/React__namespace.forwardRef(function MrlButton(_ref
|
|
|
68
68
|
_React$useState2 = _rollupPluginBabelHelpers.slicedToArray(_React$useState, 2),
|
|
69
69
|
isSelected = _React$useState2[0],
|
|
70
70
|
setIsSelected = _React$useState2[1];
|
|
71
|
-
var trackInteraction = useMrlAnalytics.useMrlTrackInteraction('MrlButton',
|
|
71
|
+
var trackInteraction = useMrlAnalytics.useMrlTrackInteraction('MrlButton', eventId);
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
74
|
* MrlButton could behave as a toggle button if toggleStyle is 'default' or 'secondary'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MrlButton.js","sources":["../../../../../src/components/button/MrlButton/MrlButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport {\n\tallowedButtonValues,\n\tbuttonDefaults,\n\tMrlButtonKind,\n\tMrlButtonSize,\n\tToggleAria,\n\tIconPosition\n} from '../constants';\nimport { _isDisabled, _isSelected, _spinnerProps } from '../helpers';\nimport { MrlSpinner, MrlTooltipAnchor, MrlTooltipPosition, MrlTooltip } from '../../';\nimport { spinnerDefaults } from '../../loader/constants';\nimport { AttrsObject, MrlComponentProps, setAttributes } from '../../../utils';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\n\nimport './MrlButton.global.scss';\n\nexport type MrlButtonState = (typeof allowedButtonValues.states)[number];\nexport type ToggleStyle = (typeof allowedButtonValues.toggleStyles)[number];\n\nexport interface TooltipConfig {\n\t/**\n\t * The text to display in the tooltip\n\t */\n\ttext: string;\n\t/**\n\t * The position of the tooltip relative to the button\n\t */\n\tposition?: MrlTooltipPosition;\n\n\t/**\n\t * The anchor of the tooltip relative to the button\n\t */\n\tanchor?: MrlTooltipAnchor;\n\n\t/**\n\t * The data-qa attribute for the tooltip\n\t */\n\tdataQa?: string;\n}\n\nexport interface MrlButtonProps\n\textends Omit<MrlComponentProps, 'style'>,\n\t\tReact.ComponentProps<'button'> {\n\t/**\n\t * Applies additional HTML attributes to the button element.\n\t *\n\t * @deprecated\n\t */\n\tattrs?: AttrsObject;\n\t/**\n\t * Allow developers to add badge to buttons.\n\t */\n\tbadge?: React.ReactElement;\n\n\t/**\n\t * @deprecated - Use state=\"disabled\" or \"selected-disabled\" or \"skeleton\" instead.\n\t * Allow developers to change the disabled state based on user interactions.\n\t */\n\tdisabled?: boolean;\n\t/**\n\t * Allows developers the ability to disable built in event listeners so they can manage user\n\t * interactions from the application.\n\t */\n\tdisableEvents?: boolean;\n\t/**\n\t * Allow developers to add icon to buttons.\n\t */\n\ticon?: React.ReactElement;\n\t/**\n\t * Allows developers to right-align an icon within a button.\n\t */\n\ticonPos?: IconPosition;\n\t/**\n\t * Changes the visual emphasis of the button.\n\t */\n\tkind?: MrlButtonKind;\n\t/**\n\t * Displays a spinner in the button to indicate some action is in progress.\n\t */\n\tloading?: boolean;\n\t/**\n\t * Text for the spinner when the button is in a loading state.\n\t */\n\tloadingText?: string;\n\t/**\n\t * onClick event for the button.\n\t */\n\tonClick?: (e: React.SyntheticEvent<HTMLButtonElement>) => void;\n\t/**\n\t * Changes the size of the button so it can scale with its surrounding context.\n\t */\n\tsize?: MrlButtonSize;\n\t/**\n\t * Changes the state of the button based on user permissions or actions.\n\t */\n\tstate?: MrlButtonState;\n\t/**\n\t * The textual label describing the button's purpose/action.\n\t * Icon buttons require a text label to ensure accessibility.\n\t */\n\ttext: string;\n\t/**\n\t * Enables interaction tracking for this button. Provide a stable, non-PII id\n\t * (e.g. 'board-share-cta'). When omitted, the button emits no analytics.\n\t */\n\ttrackingId?: string;\n\t/**\n\t * Determines which aria setup to use for various toggle/selected styles.\n\t * pressed - use for an traditional “toggle button”\n\t * selected - use for tabs and custom select options\n\t * expanded - use for menus, panels, and popovers\n\t * checked - use for custom [radiobutton](https://www.w3.org/WAI/ARIA/apg/patterns/radiobutton/#wai-aria-roles-states-and-properties-16)\n\t * \t\tor [checkbox](https://www.w3.org/WAI/ARIA/apg/patterns/checkbox/#wai-aria-roles-states-and-properties-5) inputs\n\t */\n\ttoggleAria?: ToggleAria;\n\n\t/**\n\t * Tooltip configuration for the button\n\t */\n\ttooltip?: TooltipConfig;\n\n\t/**\n\t * Selected state variant when the button is a Toggle Button. The visual styles\n\t * are also impacted by the \"kind\" prop. Toggle buttons are only supported\n\t * when \"kind\" is set to either \"ghost\" or \"ghost-inverse\". Setting this prop\n\t * informs the component that this is a toggle button and to add that functionality\n\t */\n\ttoggleStyle?: ToggleStyle;\n}\n\nexport const MrlButton = React.forwardRef<HTMLButtonElement, MrlButtonProps>(function MrlButton(\n\t{\n\t\tattrs,\n\t\tbadge,\n\t\tclassName,\n\t\tdisabled = buttonDefaults.disabled,\n\t\tdisableEvents = false,\n\t\ticon,\n\t\ticonPos = buttonDefaults.iconPos,\n\t\tkind = buttonDefaults.kind,\n\t\tloading = false,\n\t\tloadingText = spinnerDefaults.text,\n\t\tonClick,\n\t\ttoggleAria = buttonDefaults.toggleAria,\n\t\ttoggleStyle,\n\t\ttext,\n\t\ttrackingId,\n\t\tsize = buttonDefaults.size,\n\t\tstate = buttonDefaults.state,\n\t\ttooltip,\n\t\t...remainingProps\n\t}: MrlButtonProps,\n\tref\n) {\n\tconst [isSelected, setIsSelected] = React.useState(() => _isSelected(state));\n\n\tconst trackInteraction = useMrlTrackInteraction('MrlButton', trackingId);\n\n\t/**\n\t * MrlButton could behave as a toggle button if toggleStyle is 'default' or 'secondary'\n\t */\n\tconst isToggleButton = toggleStyle && allowedButtonValues.toggleStyles.includes(toggleStyle);\n\n\t/**\n\t * We need to watch the value of state to keep in sync\n\t * the value of state passed as props and the internal\n\t * isSelected piece of state.\n\t */\n\tReact.useEffect(() => {\n\t\t// allows consumers to set the 'selected' or 'selected-disabled' state from a parent component.\n\t\tsetIsSelected(_isSelected(state));\n\t}, [state]);\n\n\t/**\n\t * Handle onClick events\n\t *\n\t * @param {React.MouseEvent<HTMLButtonElement>} e - mouse event\n\t */\n\tfunction handleOnClick(e: React.MouseEvent<HTMLButtonElement>) {\n\t\te.stopPropagation();\n\n\t\tif (_isDisabled(state, loading) || disabled || disableEvents) {\n\t\t\treturn;\n\t\t}\n\n\t\ttrackInteraction({ action: 'click', variant: kind });\n\n\t\tif (isToggleButton) {\n\t\t\tsetIsSelected((prevIsSelected) => !prevIsSelected);\n\t\t}\n\n\t\tif (onClick && typeof onClick === 'function') {\n\t\t\tonClick(e);\n\t\t}\n\t}\n\n\tconst classNames = classnames(\n\t\t'mrlButton',\n\t\t`mrlButton--${size}`,\n\t\t`mrlButton--${kind}`,\n\t\tstate === 'skeleton' && `mrlButton--skeleton`,\n\t\t!icon && loading && `mrlButton--loading`,\n\t\tisToggleButton && `toggleStyle--${toggleStyle}`,\n\t\ticon && `mrlButton--icon-${iconPos}`,\n\t\tclassName,\n\t\tattrs?.class || attrs?.className\n\t);\n\n\tif (attrs && attrs.class) delete attrs.class;\n\tif (attrs && attrs.className) delete attrs.className;\n\n\tconst spinnerProps = _spinnerProps(kind, size);\n\tconst spinner = (\n\t\t<MrlSpinner kind={spinnerProps.kind} role=\"none\" size={spinnerProps.size} text={loadingText} />\n\t);\n\n\tconst attributes = setAttributes(attrs || {}, {\n\t\t'aria-disabled': _isDisabled(state, loading) || disabled,\n\t\t...(isToggleButton && { [`aria-${toggleAria}`]: isSelected || false }),\n\t\trole: 'button',\n\t\ttype: 'button'\n\t});\n\n\tconst renderButton = () => (\n\t\t<button\n\t\t\t{...attributes}\n\t\t\t{...remainingProps}\n\t\t\tclassName={classNames}\n\t\t\tref={ref}\n\t\t\tonClick={handleOnClick}\n\t\t>\n\t\t\t{loading ? spinner : icon}\n\t\t\t<span className=\"mrlButton-text\">{text}</span>\n\t\t\t{badge}\n\t\t</button>\n\t);\n\n\treturn !tooltip ? (\n\t\trenderButton()\n\t) : (\n\t\t<MrlTooltip\n\t\t\tposition={tooltip.position || 'bottom'}\n\t\t\tanchor={tooltip.anchor || 'center'}\n\t\t\ttext={tooltip.text}\n\t\t\tdataQa={tooltip.dataQa}\n\t\t>\n\t\t\t{renderButton()}\n\t\t</MrlTooltip>\n\t);\n});\n"],"names":["MrlButton","React","forwardRef","_ref","ref","attrs","badge","className","_ref$disabled","disabled","buttonDefaults","_ref$disableEvents","disableEvents","icon","_ref$iconPos","iconPos","_ref$kind","kind","_ref$loading","loading","_ref$loadingText","loadingText","spinnerDefaults","text","onClick","_ref$toggleAria","toggleAria","toggleStyle","trackingId","_ref$size","size","_ref$state","state","tooltip","remainingProps","_objectWithoutProperties","_excluded","_React$useState","useState","_isSelected","_React$useState2","_slicedToArray","isSelected","setIsSelected","trackInteraction","useMrlTrackInteraction","isToggleButton","allowedButtonValues","toggleStyles","includes","useEffect","handleOnClick","e","stopPropagation","_isDisabled","action","variant","prevIsSelected","classNames","classnames","concat","class","spinnerProps","_spinnerProps","spinner","createElement","MrlSpinner","role","attributes","setAttributes","_objectSpread","type","renderButton","_extends","MrlTooltip","position","anchor","dataQa"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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U,OAAO,CAACV,IAAK;IACnBsD,MAAM,EAAE5C,OAAO,CAAC4C;GAAO,EAEtBL,YAAY,EACF,CACZ;AACF,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"MrlButton.js","sources":["../../../../../src/components/button/MrlButton/MrlButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport {\n\tallowedButtonValues,\n\tbuttonDefaults,\n\tMrlButtonKind,\n\tMrlButtonSize,\n\tToggleAria,\n\tIconPosition\n} from '../constants';\nimport { _isDisabled, _isSelected, _spinnerProps } from '../helpers';\nimport { MrlSpinner, MrlTooltipAnchor, MrlTooltipPosition, MrlTooltip } from '../../';\nimport { spinnerDefaults } from '../../loader/constants';\nimport { AttrsObject, MrlComponentProps, setAttributes } from '../../../utils';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\n\nimport './MrlButton.global.scss';\n\nexport type MrlButtonState = (typeof allowedButtonValues.states)[number];\nexport type ToggleStyle = (typeof allowedButtonValues.toggleStyles)[number];\n\nexport interface TooltipConfig {\n\t/**\n\t * The text to display in the tooltip\n\t */\n\ttext: string;\n\t/**\n\t * The position of the tooltip relative to the button\n\t */\n\tposition?: MrlTooltipPosition;\n\n\t/**\n\t * The anchor of the tooltip relative to the button\n\t */\n\tanchor?: MrlTooltipAnchor;\n\n\t/**\n\t * The data-qa attribute for the tooltip\n\t */\n\tdataQa?: string;\n}\n\nexport interface MrlButtonProps\n\textends Omit<MrlComponentProps, 'style'>,\n\t\tReact.ComponentProps<'button'> {\n\t/**\n\t * Applies additional HTML attributes to the button element.\n\t *\n\t * @deprecated\n\t */\n\tattrs?: AttrsObject;\n\t/**\n\t * Allow developers to add badge to buttons.\n\t */\n\tbadge?: React.ReactElement;\n\n\t/**\n\t * @deprecated - Use state=\"disabled\" or \"selected-disabled\" or \"skeleton\" instead.\n\t * Allow developers to change the disabled state based on user interactions.\n\t */\n\tdisabled?: boolean;\n\t/**\n\t * Allows developers the ability to disable built in event listeners so they can manage user\n\t * interactions from the application.\n\t */\n\tdisableEvents?: boolean;\n\t/**\n\t * Allow developers to add icon to buttons.\n\t */\n\ticon?: React.ReactElement;\n\t/**\n\t * Allows developers to right-align an icon within a button.\n\t */\n\ticonPos?: IconPosition;\n\t/**\n\t * Changes the visual emphasis of the button.\n\t */\n\tkind?: MrlButtonKind;\n\t/**\n\t * Displays a spinner in the button to indicate some action is in progress.\n\t */\n\tloading?: boolean;\n\t/**\n\t * Text for the spinner when the button is in a loading state.\n\t */\n\tloadingText?: string;\n\t/**\n\t * onClick event for the button.\n\t */\n\tonClick?: (e: React.SyntheticEvent<HTMLButtonElement>) => void;\n\t/**\n\t * Changes the size of the button so it can scale with its surrounding context.\n\t */\n\tsize?: MrlButtonSize;\n\t/**\n\t * Changes the state of the button based on user permissions or actions.\n\t */\n\tstate?: MrlButtonState;\n\t/**\n\t * The textual label describing the button's purpose/action.\n\t * Icon buttons require a text label to ensure accessibility.\n\t */\n\ttext: string;\n\t/**\n\t * Enables interaction tracking for this button. Provide a stable, non-PII id\n\t * (e.g. 'board-share-cta'). When omitted, the button emits no analytics.\n\t */\n\teventId?: string;\n\t/**\n\t * Determines which aria setup to use for various toggle/selected styles.\n\t * pressed - use for an traditional “toggle button”\n\t * selected - use for tabs and custom select options\n\t * expanded - use for menus, panels, and popovers\n\t * checked - use for custom [radiobutton](https://www.w3.org/WAI/ARIA/apg/patterns/radiobutton/#wai-aria-roles-states-and-properties-16)\n\t * \t\tor [checkbox](https://www.w3.org/WAI/ARIA/apg/patterns/checkbox/#wai-aria-roles-states-and-properties-5) inputs\n\t */\n\ttoggleAria?: ToggleAria;\n\n\t/**\n\t * Tooltip configuration for the button\n\t */\n\ttooltip?: TooltipConfig;\n\n\t/**\n\t * Selected state variant when the button is a Toggle Button. The visual styles\n\t * are also impacted by the \"kind\" prop. Toggle buttons are only supported\n\t * when \"kind\" is set to either \"ghost\" or \"ghost-inverse\". Setting this prop\n\t * informs the component that this is a toggle button and to add that functionality\n\t */\n\ttoggleStyle?: ToggleStyle;\n}\n\nexport const MrlButton = React.forwardRef<HTMLButtonElement, MrlButtonProps>(function MrlButton(\n\t{\n\t\tattrs,\n\t\tbadge,\n\t\tclassName,\n\t\tdisabled = buttonDefaults.disabled,\n\t\tdisableEvents = false,\n\t\ticon,\n\t\ticonPos = buttonDefaults.iconPos,\n\t\tkind = buttonDefaults.kind,\n\t\tloading = false,\n\t\tloadingText = spinnerDefaults.text,\n\t\tonClick,\n\t\ttoggleAria = buttonDefaults.toggleAria,\n\t\ttoggleStyle,\n\t\ttext,\n\t\teventId,\n\t\tsize = buttonDefaults.size,\n\t\tstate = buttonDefaults.state,\n\t\ttooltip,\n\t\t...remainingProps\n\t}: MrlButtonProps,\n\tref\n) {\n\tconst [isSelected, setIsSelected] = React.useState(() => _isSelected(state));\n\n\tconst trackInteraction = useMrlTrackInteraction('MrlButton', eventId);\n\n\t/**\n\t * MrlButton could behave as a toggle button if toggleStyle is 'default' or 'secondary'\n\t */\n\tconst isToggleButton = toggleStyle && allowedButtonValues.toggleStyles.includes(toggleStyle);\n\n\t/**\n\t * We need to watch the value of state to keep in sync\n\t * the value of state passed as props and the internal\n\t * isSelected piece of state.\n\t */\n\tReact.useEffect(() => {\n\t\t// allows consumers to set the 'selected' or 'selected-disabled' state from a parent component.\n\t\tsetIsSelected(_isSelected(state));\n\t}, [state]);\n\n\t/**\n\t * Handle onClick events\n\t *\n\t * @param {React.MouseEvent<HTMLButtonElement>} e - mouse event\n\t */\n\tfunction handleOnClick(e: React.MouseEvent<HTMLButtonElement>) {\n\t\te.stopPropagation();\n\n\t\tif (_isDisabled(state, loading) || disabled || disableEvents) {\n\t\t\treturn;\n\t\t}\n\n\t\ttrackInteraction({ action: 'click', variant: kind });\n\n\t\tif (isToggleButton) {\n\t\t\tsetIsSelected((prevIsSelected) => !prevIsSelected);\n\t\t}\n\n\t\tif (onClick && typeof onClick === 'function') {\n\t\t\tonClick(e);\n\t\t}\n\t}\n\n\tconst classNames = classnames(\n\t\t'mrlButton',\n\t\t`mrlButton--${size}`,\n\t\t`mrlButton--${kind}`,\n\t\tstate === 'skeleton' && `mrlButton--skeleton`,\n\t\t!icon && loading && `mrlButton--loading`,\n\t\tisToggleButton && `toggleStyle--${toggleStyle}`,\n\t\ticon && `mrlButton--icon-${iconPos}`,\n\t\tclassName,\n\t\tattrs?.class || attrs?.className\n\t);\n\n\tif (attrs && attrs.class) delete attrs.class;\n\tif (attrs && attrs.className) delete attrs.className;\n\n\tconst spinnerProps = _spinnerProps(kind, size);\n\tconst spinner = (\n\t\t<MrlSpinner kind={spinnerProps.kind} role=\"none\" size={spinnerProps.size} text={loadingText} />\n\t);\n\n\tconst attributes = setAttributes(attrs || {}, {\n\t\t'aria-disabled': _isDisabled(state, loading) || disabled,\n\t\t...(isToggleButton && { [`aria-${toggleAria}`]: isSelected || false }),\n\t\trole: 'button',\n\t\ttype: 'button'\n\t});\n\n\tconst renderButton = () => (\n\t\t<button\n\t\t\t{...attributes}\n\t\t\t{...remainingProps}\n\t\t\tclassName={classNames}\n\t\t\tref={ref}\n\t\t\tonClick={handleOnClick}\n\t\t>\n\t\t\t{loading ? spinner : icon}\n\t\t\t<span className=\"mrlButton-text\">{text}</span>\n\t\t\t{badge}\n\t\t</button>\n\t);\n\n\treturn !tooltip ? (\n\t\trenderButton()\n\t) : (\n\t\t<MrlTooltip\n\t\t\tposition={tooltip.position || 'bottom'}\n\t\t\tanchor={tooltip.anchor || 'center'}\n\t\t\ttext={tooltip.text}\n\t\t\tdataQa={tooltip.dataQa}\n\t\t>\n\t\t\t{renderButton()}\n\t\t</MrlTooltip>\n\t);\n});\n"],"names":["MrlButton","React","forwardRef","_ref","ref","attrs","badge","className","_ref$disabled","disabled","buttonDefaults","_ref$disableEvents","disableEvents","icon","_ref$iconPos","iconPos","_ref$kind","kind","_ref$loading","loading","_ref$loadingText","loadingText","spinnerDefaults","text","onClick","_ref$toggleAria","toggleAria","toggleStyle","eventId","_ref$size","size","_ref$state","state","tooltip","remainingProps","_objectWithoutProperties","_excluded","_React$useState","useState","_isSelected","_React$useState2","_slicedToArray","isSelected","setIsSelected","trackInteraction","useMrlTrackInteraction","isToggleButton","allowedButtonValues","toggleStyles","includes","useEffect","handleOnClick","e","stopPropagation","_isDisabled","action","variant","prevIsSelected","classNames","classnames","concat","class","spinnerProps","_spinnerProps","spinner","createElement","MrlSpinner","role","attributes","setAttributes","_objectSpread","type","renderButton","_extends","MrlTooltip","position","anchor","dataQa"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoIO,IAAMA,SAAS,gBAAGC,gBAAK,CAACC,UAAU,CAAoC,SAASF,SAASA,CAAAG,IAAA,EAsB9FC,GAAG,EACF;AAAA,EAAA,IArBAC,KAAK,GAAAF,IAAA,CAALE,KAAK;IACLC,KAAK,GAAAH,IAAA,CAALG,KAAK;IACLC,SAAS,GAAAJ,IAAA,CAATI,SAAS;IAAAC,aAAA,GAAAL,IAAA,CACTM,QAAQ;AAARA,IAAAA,QAAQ,GAAAD,aAAA,KAAA,MAAA,GAAGE,0BAAc,CAACD,QAAQ,GAAAD,aAAA;IAAAG,kBAAA,GAAAR,IAAA,CAClCS,aAAa;AAAbA,IAAAA,aAAa,GAAAD,kBAAA,KAAA,MAAA,GAAG,KAAK,GAAAA,kBAAA;IACrBE,IAAI,GAAAV,IAAA,CAAJU,IAAI;IAAAC,YAAA,GAAAX,IAAA,CACJY,OAAO;AAAPA,IAAAA,OAAO,GAAAD,YAAA,KAAA,MAAA,GAAGJ,0BAAc,CAACK,OAAO,GAAAD,YAAA;IAAAE,SAAA,GAAAb,IAAA,CAChCc,IAAI;AAAJA,IAAAA,IAAI,GAAAD,SAAA,KAAA,MAAA,GAAGN,0BAAc,CAACO,IAAI,GAAAD,SAAA;IAAAE,YAAA,GAAAf,IAAA,CAC1BgB,OAAO;AAAPA,IAAAA,OAAO,GAAAD,YAAA,KAAA,MAAA,GAAG,KAAK,GAAAA,YAAA;IAAAE,gB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,aAAA,CAAA,MAAA,EAAA;AAAM1D,IAAAA,SAAS,EAAC;AAAgB,GAAA,EAAEgB,IAAW,CAAC,EAC7CjB,KACM,CACR;EAED,OAAO,CAAC2B,OAAO,GACduC,YAAY,EAAE,gBAEdvE,gBAAA,CAAAgE,aAAA,CAACS,qBAAU,EAAA;AACVC,IAAAA,QAAQ,EAAE1C,OAAO,CAAC0C,QAAQ,IAAI,QAAS;AACvCC,IAAAA,MAAM,EAAE3C,OAAO,CAAC2C,MAAM,IAAI,QAAS;IACnCrD,IAAI,EAAEU,OAAO,CAACV,IAAK;IACnBsD,MAAM,EAAE5C,OAAO,CAAC4C;GAAO,EAEtBL,YAAY,EACF,CACZ;AACF,CAAC;;;;"}
|
|
@@ -7,6 +7,7 @@ var constants$2 = require('../constants.js');
|
|
|
7
7
|
var helpers = require('../helpers.js');
|
|
8
8
|
var constants$1 = require('../../tooltip/constants.js');
|
|
9
9
|
var constants = require('../../loader/constants.js');
|
|
10
|
+
var useMrlAnalytics = require('../../../hooks/useMrlAnalytics/useMrlAnalytics.js');
|
|
10
11
|
var setAttributes = require('../../../utils/setAttributes/setAttributes.js');
|
|
11
12
|
var MrlTooltip = require('../../tooltip/MrlTooltip/MrlTooltip.js');
|
|
12
13
|
var MrlSpinner = require('../../loader/MrlSpinner/MrlSpinner.js');
|
|
@@ -34,7 +35,7 @@ function _interopNamespace(e) {
|
|
|
34
35
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
35
36
|
var classnames__default = /*#__PURE__*/_interopDefault(classnames);
|
|
36
37
|
|
|
37
|
-
var _excluded = ["aria-label", "attrs", "badge", "className", "disableEvents", "disableTooltipHover", "icon", "kind", "loading", "loadingText", "onClick", "onKeyUp", "onMouseUp", "position", "toggleAria", "toggleStyle", "text", "tipAnchor", "size", "state", "wrapperClassName", "controlledState"];
|
|
38
|
+
var _excluded = ["aria-label", "attrs", "badge", "className", "disableEvents", "disableTooltipHover", "icon", "kind", "loading", "loadingText", "onClick", "onKeyUp", "onMouseUp", "position", "toggleAria", "toggleStyle", "text", "tipAnchor", "eventId", "size", "state", "wrapperClassName", "controlledState"];
|
|
38
39
|
var MrlIconButton = /*#__PURE__*/React__namespace.forwardRef(function MrlIconButton(_ref, ref) {
|
|
39
40
|
var ariaLabel = _ref['aria-label'],
|
|
40
41
|
_ref$attrs = _ref.attrs,
|
|
@@ -63,6 +64,7 @@ var MrlIconButton = /*#__PURE__*/React__namespace.forwardRef(function MrlIconBut
|
|
|
63
64
|
text = _ref.text,
|
|
64
65
|
_ref$tipAnchor = _ref.tipAnchor,
|
|
65
66
|
tipAnchor = _ref$tipAnchor === void 0 ? constants$1.MrlTooltipDefaults.anchor : _ref$tipAnchor,
|
|
67
|
+
eventId = _ref.eventId,
|
|
66
68
|
_ref$size = _ref.size,
|
|
67
69
|
size = _ref$size === void 0 ? constants$2.buttonDefaults.size : _ref$size,
|
|
68
70
|
_ref$state = _ref.state,
|
|
@@ -81,6 +83,7 @@ var MrlIconButton = /*#__PURE__*/React__namespace.forwardRef(function MrlIconBut
|
|
|
81
83
|
_React$useState2 = _rollupPluginBabelHelpers.slicedToArray(_React$useState, 2),
|
|
82
84
|
isSelected = _React$useState2[0],
|
|
83
85
|
setIsSelected = _React$useState2[1];
|
|
86
|
+
var trackInteraction = useMrlAnalytics.useMrlTrackInteraction('MrlIconButton', eventId);
|
|
84
87
|
var buttonRef = React__namespace.useRef(null);
|
|
85
88
|
React__namespace.useImperativeHandle(ref, () => buttonRef.current);
|
|
86
89
|
|
|
@@ -108,6 +111,10 @@ var MrlIconButton = /*#__PURE__*/React__namespace.forwardRef(function MrlIconBut
|
|
|
108
111
|
if (helpers._isDisabled(effectiveButtonState, loading) || disableEvents) {
|
|
109
112
|
return;
|
|
110
113
|
}
|
|
114
|
+
trackInteraction({
|
|
115
|
+
action: 'click',
|
|
116
|
+
variant: kind
|
|
117
|
+
});
|
|
111
118
|
if (isToggleButton && !controlledState) {
|
|
112
119
|
setIsSelected(prevIsSelected => !prevIsSelected);
|
|
113
120
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MrlIconButton.js","sources":["../../../../../src/components/button/MrlIconButton/MrlIconButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport {\n\tbuttonDefaults,\n\tMrlButtonKind,\n\tMrlButtonSize,\n\tMrlGhostIconButtonSize,\n\tToggleAria\n} from '../constants';\nimport { _isDisabled, _isSelected, _isToggleButton, _spinnerProps } from '../helpers';\nimport { AttrsObject, MrlComponentProps, setAttributes, getUniqueId } from '../../../utils';\nimport { MrlTooltipAnchor, MrlTooltipDefaults, MrlTooltipPosition } from '../../tooltip/constants';\nimport { MrlButtonState, MrlSpinner, MrlTooltip, ToggleStyle } from '../../';\nimport { spinnerDefaults } from '../../loader/constants';\nimport './MrlIconButton.scss';\n\nexport interface MrlIconButtonProps\n\textends Omit<MrlComponentProps, 'style'>,\n\t\tReact.ComponentProps<'button'> {\n\t/**\n\t * Applies additional HTML attributes to the button element.\n\t * @deprecated\n\t */\n\tattrs?: AttrsObject;\n\t/**\n\t * Allow developers to add badge to buttons.\n\t */\n\tbadge?: React.ReactElement;\n\t/** Additional class to add to the button */\n\tclassName?: string;\n\t/**\n\t * Allows developers the ability to disable built in event listeners so they can manage user\n\t * interactions from the application.\n\t */\n\tdisableEvents?: boolean;\n\n\t/** Whether to disable the tooltip hover action that keeps it open */\n\tdisableTooltipHover?: boolean;\n\n\t/**\n\t * The icon that will be rendered.\n\t */\n\ticon: React.ReactElement;\n\t/**\n\t * Changes the visual emphasis of the button.\n\t *\n\t * Note: size=\"xsmall\" should ONLY be used with a kind of `ghost` or `ghost-inverse`.\n\t */\n\tkind?: MrlButtonKind;\n\t/**\n\t * Displays a spinner in the button to indicate some action is in progress.\n\t */\n\tloading?: boolean;\n\t/**\n\t * Text for the spinner when the button is in a loading state.\n\t */\n\tloadingText?: string;\n\n\t/**\n\t * onClick event for the button.\n\t */\n\tonClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;\n\n\t/**\n\t * onKeyDown event for the button.\n\t */\n\tonKeyUp?: (e: React.KeyboardEvent<HTMLButtonElement>) => void;\n\n\t/**\n\t * onMouseUp event for the button.\n\t */\n\tonMouseUp?: (e: React.MouseEvent<HTMLButtonElement>) => void;\n\n\t/**\n\t * The placement of the tooltip in relation to the button.\n\t */\n\tposition?: MrlTooltipPosition;\n\t/**\n\t * Changes the size of the button so it can scale with its surrounding context.\n\t *\n\t * Note: size=\"xsmall\" should ONLY be used with a kind of `ghost` or `ghost-inverse`.\n\t */\n\tsize?: MrlButtonSize | MrlGhostIconButtonSize;\n\t/**\n\t * Changes the state of the button based on user permissions or actions.\n\t *\n\t * Note: The Basic Button does not fully support state=\"disabled\", use\n\t * the 'disabled' prop instead. Since it does not support state=\"disabled\",\n\t * it also doesn't not support state=\"selected-disabled\".\n\t */\n\tstate?: MrlButtonState;\n\t/**\n\t * The textual label describing the button's purpose/action.\n\t * Icon buttons require a text label to ensure accessibility.\n\t */\n\ttext: string;\n\t/**\n\t * The arrow position of the tooltip in relation to the button.\n\t */\n\ttipAnchor?: MrlTooltipAnchor;\n\n\t/**\n\t * Determines which aria setup to use for various toggle/selected styles.\n\t * pressed - use for an traditional “toggle button”\n\t * selected - use for tabs and custom select options\n\t * expanded - use for menus, panels, and popovers\n\t * checked - use for custom [radiobutton](https://www.w3.org/WAI/ARIA/apg/patterns/radiobutton/#wai-aria-roles-states-and-properties-16)\n\t * \t\tor [checkbox](https://www.w3.org/WAI/ARIA/apg/patterns/checkbox/#wai-aria-roles-states-and-properties-5) inputs\n\t */\n\ttoggleAria?: ToggleAria;\n\t/**\n\t * Selected state variant when the button is a Toggle Button. The visual styles\n\t * are also impacted by the \"kind\" prop. Toggle buttons are only supported\n\t * when \"kind\" is set to either \"ghost\" or \"ghost-inverse\". Setting this prop\n\t * informs the component that this is a toggle button and to add that functionality\n\t */\n\ttoggleStyle?: ToggleStyle;\n\n\t/**\n\t * An optional class name to add to the tooltip wrapper.\n\t */\n\twrapperClassName?: string;\n\n\t/**\n\t * Controlled state that overrides the internal state management.\n\t * When provided, this takes precedence over the `state` prop and allows\n\t * the parent component to fully control the icon button's state.\n\t */\n\tcontrolledState?: MrlButtonState;\n}\n\nexport const MrlIconButton = React.forwardRef<HTMLButtonElement, MrlIconButtonProps>(\n\tfunction MrlIconButton(\n\t\t{\n\t\t\t['aria-label']: ariaLabel,\n\t\t\tattrs = {},\n\t\t\tbadge,\n\t\t\tclassName,\n\t\t\tdisableEvents = false,\n\t\t\tdisableTooltipHover = false,\n\t\t\ticon,\n\t\t\t// We intentionally deviate from the basic button for icon-buttons since the vast\n\t\t\t// majority of icon buttons are ghost buttons. The proptype remains\n\t\t\t// consistent with the basic button however to keep our code DRY.\n\t\t\tkind = 'ghost',\n\t\t\tloading = false,\n\t\t\tloadingText = spinnerDefaults.text,\n\t\t\tonClick,\n\t\t\tonKeyUp,\n\t\t\tonMouseUp,\n\t\t\tposition = MrlTooltipDefaults.position,\n\t\t\ttoggleAria = buttonDefaults.toggleAria,\n\t\t\ttoggleStyle,\n\t\t\ttext,\n\t\t\ttipAnchor = MrlTooltipDefaults.anchor,\n\t\t\tsize = buttonDefaults.size,\n\t\t\tstate = buttonDefaults.state,\n\t\t\twrapperClassName,\n\t\t\tcontrolledState,\n\t\t\t...remainingProps\n\t\t}: MrlIconButtonProps,\n\t\tref\n\t) {\n\t\t/**\n\t\t * Determine the effective button state.\n\t\t * Uses controlledState if provided (controlled mode),\n\t\t * otherwise falls back to the state prop (uncontrolled mode).\n\t\t * This allows the component to work in both controlled and uncontrolled scenarios.\n\t\t */\n\t\tconst effectiveButtonState = controlledState ?? state;\n\n\t\tconst [isSelected, setIsSelected] = React.useState(() => _isSelected(effectiveButtonState));\n\n\t\tconst buttonRef = React.useRef<HTMLButtonElement>(null);\n\t\tReact.useImperativeHandle<HTMLButtonElement | null, HTMLButtonElement | null>(\n\t\t\tref,\n\t\t\t() => buttonRef.current\n\t\t);\n\n\t\t/**\n\t\t * MrlIconButton could behave as a toggle button if toggleStyle is 'default' or 'secondary'\n\t\t */\n\t\tconst isToggleButton = toggleStyle && _isToggleButton(toggleStyle);\n\n\t\t/**\n\t\t * We need to watch the value of state to keep in sync\n\t\t * the value of state passed as props and the internal\n\t\t * isSelected piece of state.\n\t\t */\n\t\tReact.useEffect(() => {\n\t\t\t// allows consumers to set the 'selected' or 'selected-disabled' state from a parent component.\n\t\t\tsetIsSelected(_isSelected(effectiveButtonState));\n\t\t}, [effectiveButtonState]);\n\n\t\t/**\n\t\t * Handle onClick events\n\t\t * @param {React.MouseEvent<HTMLButtonElement>} e - mouse event\n\t\t */\n\t\tfunction handleOnClick(e: React.MouseEvent<HTMLButtonElement>) {\n\t\t\te.stopPropagation();\n\n\t\t\tif (_isDisabled(effectiveButtonState, loading) || disableEvents) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (isToggleButton && !controlledState) {\n\t\t\t\tsetIsSelected((prevIsSelected) => !prevIsSelected);\n\t\t\t}\n\n\t\t\tif (onClick && typeof onClick === 'function') {\n\t\t\t\tonClick(e);\n\t\t\t}\n\t\t}\n\n\t\tconst classNames = classnames(\n\t\t\t'mrlIconButton',\n\t\t\t`mrlIconButton--${size}`,\n\t\t\t`mrlIconButton--${kind}`,\n\t\t\tisToggleButton && toggleStyle && `toggleStyle--${toggleStyle}`,\n\t\t\tattrs.class || attrs.className,\n\t\t\tclassName\n\t\t);\n\n\t\tdelete attrs.class;\n\t\tdelete attrs.className;\n\n\t\tconst getAriaLabel = (): string => {\n\t\t\t// Set loading text if loading\n\t\t\tif (loading) return `${loadingText} ${text}`;\n\n\t\t\t// Only set aria-label if we have actual content\n\t\t\tconst hasAriaLabel = ariaLabel && ariaLabel.trim() !== '';\n\n\t\t\t// If we have a custom ariaLabel, override the default text\n\t\t\tif (hasAriaLabel) return ariaLabel;\n\n\t\t\t// Fallback to icon button text\n\t\t\treturn text;\n\t\t};\n\n\t\tconst ariaLabelValue = getAriaLabel();\n\n\t\tconst attributes = setAttributes(attrs, {\n\t\t\t'aria-disabled': _isDisabled(effectiveButtonState, loading),\n\t\t\t'aria-label': ariaLabelValue,\n\t\t\t...(isToggleButton && { [`aria-${toggleAria}`]: isSelected || false }),\n\t\t\ttype: 'button'\n\t\t});\n\n\t\t// MrlSvg should always have size=\"auto\"\n\t\tconst iconWithSizeAuto = React.useMemo(\n\t\t\t() =>\n\t\t\t\tReact.cloneElement(icon, {\n\t\t\t\t\tsize: 'auto'\n\t\t\t\t}),\n\t\t\t[icon]\n\t\t);\n\n\t\tconst spinnerProps = _spinnerProps(kind, size);\n\t\tconst spinner = <MrlSpinner kind={spinnerProps.kind} size={spinnerProps.size} />;\n\n\t\tconst dataQaProp = (remainingProps as { 'data-qa'?: string })['data-qa'];\n\t\tconst tooltipQa = dataQaProp ? `${dataQaProp}-tooltip` : getUniqueId('tooltip');\n\t\tconst tooltipContentClass =\n\t\t\tsize === 'xsmall' || size === 'small' ? `mrlIconButton--${size}-wrapper` : undefined;\n\n\t\treturn (\n\t\t\t<MrlTooltip\n\t\t\t\tanchor={tipAnchor}\n\t\t\t\tdataQa={tooltipQa}\n\t\t\t\tposition={position}\n\t\t\t\ttext={text}\n\t\t\t\ttooltipClass={classnames('mrlIconButton-wrapper', wrapperClassName)}\n\t\t\t\ttooltipContentClass={tooltipContentClass}\n\t\t\t\tdisableTooltipHover={disableTooltipHover}\n\t\t\t\tsrAnnouncement={false}\n\t\t\t>\n\t\t\t\t<button\n\t\t\t\t\t{...attributes}\n\t\t\t\t\t{...remainingProps}\n\t\t\t\t\tclassName={classNames}\n\t\t\t\t\tref={buttonRef}\n\t\t\t\t\tonClick={handleOnClick}\n\t\t\t\t\tonKeyUp={onKeyUp}\n\t\t\t\t\tonMouseUp={onMouseUp}\n\t\t\t\t>\n\t\t\t\t\t{loading ? spinner : iconWithSizeAuto}\n\t\t\t\t\t{badge}\n\t\t\t\t</button>\n\t\t\t</MrlTooltip>\n\t\t);\n\t}\n);\n"],"names":["MrlIconButton","React","forwardRef","_ref","ref","ariaLabel","_ref$attrs","attrs","badge","className","_ref$disableEvents","disableEvents","_ref$disableTooltipHo","disableTooltipHover","icon","_ref$kind","kind","_ref$loading","loading","_ref$loadingText","loadingText","spinnerDefaults","text","onClick","onKeyUp","onMouseUp","_ref$position","position","MrlTooltipDefaults","_ref$toggleAria","toggleAria","buttonDefaults","toggleStyle","_ref$tipAnchor","tipAnchor","anchor","_ref$size","size","_ref$state","state","wrapperClassName","controlledState","remainingProps","_objectWithoutProperties","_excluded","effectiveButtonState","_React$useState","useState","_isSelected","_React$useState2","_slicedToArray","isSelected","setIsSelected","buttonRef","useRef","useImperativeHandle","current","isToggleButton","_isToggleButton","useEffect","handleOnClick","e","stopPropagation","_isDisabled","prevIsSelected","classNames","classnames","concat","class","getAriaLabel","hasAriaLabel","trim","ariaLabelValue","attributes","setAttributes","_objectSpread","type","iconWithSizeAuto","useMemo","cloneElement","spinnerProps","_spinnerProps","spinner","createElement","MrlSpinner","dataQaProp","tooltipQa","getUniqueId","tooltipContentClass","undefined","MrlTooltip","dataQa","tooltipClass","srAnnouncement","_extends"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmIO,IAAMA,aAAa,gBAAGC,gBAAK,CAACC,UAAU,CAC5C,SAASF,aAAaA,CAAAG,IAAA,EA6BrBC,GAAG,EACF;AAAA,EAAA,IA5BgBC,SAAS,GAAAF,IAAA,CAAxB,YAAY,CAAA;IAAAG,UAAA,GAAAH,IAAA,CACbI,KAAK;AAALA,IAAAA,KAAK,GAAAD,UAAA,KAAA,MAAA,GAAG,EAAE,GAAAA,UAAA;IACVE,KAAK,GAAAL,IAAA,CAALK,KAAK;IACLC,SAAS,GAAAN,IAAA,CAATM,SAAS;IAAAC,kBAAA,GAAAP,IAAA,CACTQ,aAAa;AAAbA,IAAAA,aAAa,GAAAD,kBAAA,KAAA,MAAA,GAAG,KAAK,GAAAA,kBAAA;IAAAE,qBAAA,GAAAT,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,mBAAoB;AACzC3E,IAAAA,mBAAmB,EAAEA,mBAAoB;AACzCgF,IAAAA,cAAc,EAAE;GAAM,eAEtB5F,gBAAA,CAAAkF,aAAA,CAAA,QAAA,EAAAW,iCAAA,CAAA,EAAA,EACKrB,UAAU,EACV/B,cAAc,EAAA;AAClBjC,IAAAA,SAAS,EAAEwD,UAAW;AACtB7D,IAAAA,GAAG,EAAEiD,SAAU;AACf9B,IAAAA,OAAO,EAAEqC,aAAc;AACvBpC,IAAAA,OAAO,EAAEA,OAAQ;AACjBC,IAAAA,SAAS,EAAEA;GAAU,CAAA,EAEpBP,OAAO,GAAGgE,OAAO,GAAGL,gBAAgB,EACpCrE,KACM,CACG,CAAC;AAEf,CACD;;;;"}
|
|
1
|
+
{"version":3,"file":"MrlIconButton.js","sources":["../../../../../src/components/button/MrlIconButton/MrlIconButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport {\n\tbuttonDefaults,\n\tMrlButtonKind,\n\tMrlButtonSize,\n\tMrlGhostIconButtonSize,\n\tToggleAria\n} from '../constants';\nimport { _isDisabled, _isSelected, _isToggleButton, _spinnerProps } from '../helpers';\nimport { AttrsObject, MrlComponentProps, setAttributes, getUniqueId } from '../../../utils';\nimport { MrlTooltipAnchor, MrlTooltipDefaults, MrlTooltipPosition } from '../../tooltip/constants';\nimport { MrlButtonState, MrlSpinner, MrlTooltip, ToggleStyle } from '../../';\nimport { spinnerDefaults } from '../../loader/constants';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\nimport './MrlIconButton.scss';\n\nexport interface MrlIconButtonProps\n\textends Omit<MrlComponentProps, 'style'>,\n\t\tReact.ComponentProps<'button'> {\n\t/**\n\t * Applies additional HTML attributes to the button element.\n\t * @deprecated\n\t */\n\tattrs?: AttrsObject;\n\t/**\n\t * Allow developers to add badge to buttons.\n\t */\n\tbadge?: React.ReactElement;\n\t/** Additional class to add to the button */\n\tclassName?: string;\n\t/**\n\t * Allows developers the ability to disable built in event listeners so they can manage user\n\t * interactions from the application.\n\t */\n\tdisableEvents?: boolean;\n\n\t/** Whether to disable the tooltip hover action that keeps it open */\n\tdisableTooltipHover?: boolean;\n\n\t/**\n\t * The icon that will be rendered.\n\t */\n\ticon: React.ReactElement;\n\t/**\n\t * Changes the visual emphasis of the button.\n\t *\n\t * Note: size=\"xsmall\" should ONLY be used with a kind of `ghost` or `ghost-inverse`.\n\t */\n\tkind?: MrlButtonKind;\n\t/**\n\t * Displays a spinner in the button to indicate some action is in progress.\n\t */\n\tloading?: boolean;\n\t/**\n\t * Text for the spinner when the button is in a loading state.\n\t */\n\tloadingText?: string;\n\n\t/**\n\t * onClick event for the button.\n\t */\n\tonClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;\n\n\t/**\n\t * onKeyDown event for the button.\n\t */\n\tonKeyUp?: (e: React.KeyboardEvent<HTMLButtonElement>) => void;\n\n\t/**\n\t * onMouseUp event for the button.\n\t */\n\tonMouseUp?: (e: React.MouseEvent<HTMLButtonElement>) => void;\n\n\t/**\n\t * The placement of the tooltip in relation to the button.\n\t */\n\tposition?: MrlTooltipPosition;\n\t/**\n\t * Changes the size of the button so it can scale with its surrounding context.\n\t *\n\t * Note: size=\"xsmall\" should ONLY be used with a kind of `ghost` or `ghost-inverse`.\n\t */\n\tsize?: MrlButtonSize | MrlGhostIconButtonSize;\n\t/**\n\t * Changes the state of the button based on user permissions or actions.\n\t *\n\t * Note: The Basic Button does not fully support state=\"disabled\", use\n\t * the 'disabled' prop instead. Since it does not support state=\"disabled\",\n\t * it also doesn't not support state=\"selected-disabled\".\n\t */\n\tstate?: MrlButtonState;\n\t/**\n\t * The textual label describing the button's purpose/action.\n\t * Icon buttons require a text label to ensure accessibility.\n\t */\n\ttext: string;\n\t/**\n\t * The arrow position of the tooltip in relation to the button.\n\t */\n\ttipAnchor?: MrlTooltipAnchor;\n\n\t/**\n\t * Enables interaction tracking for this button. Provide a stable, non-PII id\n\t * (e.g. 'board-share-cta'). When omitted, the button emits no analytics.\n\t */\n\teventId?: string;\n\n\t/**\n\t * Determines which aria setup to use for various toggle/selected styles.\n\t * pressed - use for an traditional “toggle button”\n\t * selected - use for tabs and custom select options\n\t * expanded - use for menus, panels, and popovers\n\t * checked - use for custom [radiobutton](https://www.w3.org/WAI/ARIA/apg/patterns/radiobutton/#wai-aria-roles-states-and-properties-16)\n\t * \t\tor [checkbox](https://www.w3.org/WAI/ARIA/apg/patterns/checkbox/#wai-aria-roles-states-and-properties-5) inputs\n\t */\n\ttoggleAria?: ToggleAria;\n\t/**\n\t * Selected state variant when the button is a Toggle Button. The visual styles\n\t * are also impacted by the \"kind\" prop. Toggle buttons are only supported\n\t * when \"kind\" is set to either \"ghost\" or \"ghost-inverse\". Setting this prop\n\t * informs the component that this is a toggle button and to add that functionality\n\t */\n\ttoggleStyle?: ToggleStyle;\n\n\t/**\n\t * An optional class name to add to the tooltip wrapper.\n\t */\n\twrapperClassName?: string;\n\n\t/**\n\t * Controlled state that overrides the internal state management.\n\t * When provided, this takes precedence over the `state` prop and allows\n\t * the parent component to fully control the icon button's state.\n\t */\n\tcontrolledState?: MrlButtonState;\n}\n\nexport const MrlIconButton = React.forwardRef<HTMLButtonElement, MrlIconButtonProps>(\n\tfunction MrlIconButton(\n\t\t{\n\t\t\t['aria-label']: ariaLabel,\n\t\t\tattrs = {},\n\t\t\tbadge,\n\t\t\tclassName,\n\t\t\tdisableEvents = false,\n\t\t\tdisableTooltipHover = false,\n\t\t\ticon,\n\t\t\t// We intentionally deviate from the basic button for icon-buttons since the vast\n\t\t\t// majority of icon buttons are ghost buttons. The proptype remains\n\t\t\t// consistent with the basic button however to keep our code DRY.\n\t\t\tkind = 'ghost',\n\t\t\tloading = false,\n\t\t\tloadingText = spinnerDefaults.text,\n\t\t\tonClick,\n\t\t\tonKeyUp,\n\t\t\tonMouseUp,\n\t\t\tposition = MrlTooltipDefaults.position,\n\t\t\ttoggleAria = buttonDefaults.toggleAria,\n\t\t\ttoggleStyle,\n\t\t\ttext,\n\t\t\ttipAnchor = MrlTooltipDefaults.anchor,\n\t\t\teventId,\n\t\t\tsize = buttonDefaults.size,\n\t\t\tstate = buttonDefaults.state,\n\t\t\twrapperClassName,\n\t\t\tcontrolledState,\n\t\t\t...remainingProps\n\t\t}: MrlIconButtonProps,\n\t\tref\n\t) {\n\t\t/**\n\t\t * Determine the effective button state.\n\t\t * Uses controlledState if provided (controlled mode),\n\t\t * otherwise falls back to the state prop (uncontrolled mode).\n\t\t * This allows the component to work in both controlled and uncontrolled scenarios.\n\t\t */\n\t\tconst effectiveButtonState = controlledState ?? state;\n\n\t\tconst [isSelected, setIsSelected] = React.useState(() => _isSelected(effectiveButtonState));\n\n\t\tconst trackInteraction = useMrlTrackInteraction('MrlIconButton', eventId);\n\n\t\tconst buttonRef = React.useRef<HTMLButtonElement>(null);\n\t\tReact.useImperativeHandle<HTMLButtonElement | null, HTMLButtonElement | null>(\n\t\t\tref,\n\t\t\t() => buttonRef.current\n\t\t);\n\n\t\t/**\n\t\t * MrlIconButton could behave as a toggle button if toggleStyle is 'default' or 'secondary'\n\t\t */\n\t\tconst isToggleButton = toggleStyle && _isToggleButton(toggleStyle);\n\n\t\t/**\n\t\t * We need to watch the value of state to keep in sync\n\t\t * the value of state passed as props and the internal\n\t\t * isSelected piece of state.\n\t\t */\n\t\tReact.useEffect(() => {\n\t\t\t// allows consumers to set the 'selected' or 'selected-disabled' state from a parent component.\n\t\t\tsetIsSelected(_isSelected(effectiveButtonState));\n\t\t}, [effectiveButtonState]);\n\n\t\t/**\n\t\t * Handle onClick events\n\t\t * @param {React.MouseEvent<HTMLButtonElement>} e - mouse event\n\t\t */\n\t\tfunction handleOnClick(e: React.MouseEvent<HTMLButtonElement>) {\n\t\t\te.stopPropagation();\n\n\t\t\tif (_isDisabled(effectiveButtonState, loading) || disableEvents) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\ttrackInteraction({ action: 'click', variant: kind });\n\n\t\t\tif (isToggleButton && !controlledState) {\n\t\t\t\tsetIsSelected((prevIsSelected) => !prevIsSelected);\n\t\t\t}\n\n\t\t\tif (onClick && typeof onClick === 'function') {\n\t\t\t\tonClick(e);\n\t\t\t}\n\t\t}\n\n\t\tconst classNames = classnames(\n\t\t\t'mrlIconButton',\n\t\t\t`mrlIconButton--${size}`,\n\t\t\t`mrlIconButton--${kind}`,\n\t\t\tisToggleButton && toggleStyle && `toggleStyle--${toggleStyle}`,\n\t\t\tattrs.class || attrs.className,\n\t\t\tclassName\n\t\t);\n\n\t\tdelete attrs.class;\n\t\tdelete attrs.className;\n\n\t\tconst getAriaLabel = (): string => {\n\t\t\t// Set loading text if loading\n\t\t\tif (loading) return `${loadingText} ${text}`;\n\n\t\t\t// Only set aria-label if we have actual content\n\t\t\tconst hasAriaLabel = ariaLabel && ariaLabel.trim() !== '';\n\n\t\t\t// If we have a custom ariaLabel, override the default text\n\t\t\tif (hasAriaLabel) return ariaLabel;\n\n\t\t\t// Fallback to icon button text\n\t\t\treturn text;\n\t\t};\n\n\t\tconst ariaLabelValue = getAriaLabel();\n\n\t\tconst attributes = setAttributes(attrs, {\n\t\t\t'aria-disabled': _isDisabled(effectiveButtonState, loading),\n\t\t\t'aria-label': ariaLabelValue,\n\t\t\t...(isToggleButton && { [`aria-${toggleAria}`]: isSelected || false }),\n\t\t\ttype: 'button'\n\t\t});\n\n\t\t// MrlSvg should always have size=\"auto\"\n\t\tconst iconWithSizeAuto = React.useMemo(\n\t\t\t() =>\n\t\t\t\tReact.cloneElement(icon, {\n\t\t\t\t\tsize: 'auto'\n\t\t\t\t}),\n\t\t\t[icon]\n\t\t);\n\n\t\tconst spinnerProps = _spinnerProps(kind, size);\n\t\tconst spinner = <MrlSpinner kind={spinnerProps.kind} size={spinnerProps.size} />;\n\n\t\tconst dataQaProp = (remainingProps as { 'data-qa'?: string })['data-qa'];\n\t\tconst tooltipQa = dataQaProp ? `${dataQaProp}-tooltip` : getUniqueId('tooltip');\n\t\tconst tooltipContentClass =\n\t\t\tsize === 'xsmall' || size === 'small' ? `mrlIconButton--${size}-wrapper` : undefined;\n\n\t\treturn (\n\t\t\t<MrlTooltip\n\t\t\t\tanchor={tipAnchor}\n\t\t\t\tdataQa={tooltipQa}\n\t\t\t\tposition={position}\n\t\t\t\ttext={text}\n\t\t\t\ttooltipClass={classnames('mrlIconButton-wrapper', wrapperClassName)}\n\t\t\t\ttooltipContentClass={tooltipContentClass}\n\t\t\t\tdisableTooltipHover={disableTooltipHover}\n\t\t\t\tsrAnnouncement={false}\n\t\t\t>\n\t\t\t\t<button\n\t\t\t\t\t{...attributes}\n\t\t\t\t\t{...remainingProps}\n\t\t\t\t\tclassName={classNames}\n\t\t\t\t\tref={buttonRef}\n\t\t\t\t\tonClick={handleOnClick}\n\t\t\t\t\tonKeyUp={onKeyUp}\n\t\t\t\t\tonMouseUp={onMouseUp}\n\t\t\t\t>\n\t\t\t\t\t{loading ? spinner : iconWithSizeAuto}\n\t\t\t\t\t{badge}\n\t\t\t\t</button>\n\t\t\t</MrlTooltip>\n\t\t);\n\t}\n);\n"],"names":["MrlIconButton","React","forwardRef","_ref","ref","ariaLabel","_ref$attrs","attrs","badge","className","_ref$disableEvents","disableEvents","_ref$disableTooltipHo","disableTooltipHover","icon","_ref$kind","kind","_ref$loading","loading","_ref$loadingText","loadingText","spinnerDefaults","text","onClick","onKeyUp","onMouseUp","_ref$position","position","MrlTooltipDefaults","_ref$toggleAria","toggleAria","buttonDefaults","toggleStyle","_ref$tipAnchor","tipAnchor","anchor","eventId","_ref$size","size","_ref$state","state","wrapperClassName","controlledState","remainingProps","_objectWithoutProperties","_excluded","effectiveButtonState","_React$useState","useState","_isSelected","_React$useState2","_slicedToArray","isSelected","setIsSelected","trackInteraction","useMrlTrackInteraction","buttonRef","useRef","useImperativeHandle","current","isToggleButton","_isToggleButton","useEffect","handleOnClick","e","stopPropagation","_isDisabled","action","variant","prevIsSelected","classNames","classnames","concat","class","getAriaLabel","hasAriaLabel","trim","ariaLabelValue","attributes","setAttributes","_objectSpread","type","iconWithSizeAuto","useMemo","cloneElement","spinnerProps","_spinnerProps","spinner","createElement","MrlSpinner","dataQaProp","tooltipQa","getUniqueId","tooltipContentClass","undefined","MrlTooltip","dataQa","tooltipClass","srAnnouncement","_extends"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0IO,IAAMA,aAAa,gBAAGC,gBAAK,CAACC,UAAU,CAC5C,SAASF,aAAaA,CAAAG,IAAA,EA8BrBC,GAAG,EACF;AAAA,EAAA,IA7BgBC,SAAS,GAAAF,IAAA,CAAxB,YAAY,CAAA;IAAAG,UAAA,GAAAH,IAAA,CACbI,KAAK;AAALA,IAAAA,KAAK,GAAAD,UAAA,KAAA,MAAA,GAAG,EAAE,GAAAA,UAAA;IACVE,KAAK,GAAAL,IAAA,CAALK,KAAK;IACLC,SAAS,GAAAN,IAAA,CAATM,SAAS;IAAAC,kBAAA,GAAAP,IAAA,CACTQ,aAAa;AAAbA,IAAAA,aAAa,GAAAD,kBAAA,KAAA,MAAA,GAAG,KAAK,GAAAA,kBAAA;IAAAE,qBAAA,GAAAT,IAAA,CACrBU,mBAAmB;AAAnBA,IAAAA,mBAAmB,GAAAD,qBAAA,KAAA,MAAA,GAAG,KAAK,GAAAA,qBAAA;IAC3BE,IAAI,GAAAX,IAAA,CAAJW,IAAI;IAAAC,SAAA,GAAAZ,IAAA,CAIJa,IAAI;AAAJA,IAAAA,IAAI,GAAAD,SAAA,KAAA,MAAA,GAAG,OAAO,GAAAA,SAAA;IAAAE,YAAA,GAAAd,IAAA,CACde,OAAO;AAAPA,IAAAA,OAAO,GAAAD,YAAA,KAAA,MAAA,GAAG,KAAK,GAAAA,YAAA;IAAAE,gBAAA,GAAAhB,IAAA,CACfiB,WAAW;AAAXA,IAAAA,WAAW,GAAAD,gBAAA,KAAA,MAAA,GAAGE,yBAAe,CAACC,IAAI,GAAAH,gBAAA;IAClCI,OAAO,GAAApB,IAAA,CAAPoB,OAAO;IACPC,OAA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,EAAEA,OAAQ;AACjBC,IAAAA,SAAS,EAAEA;GAAU,CAAA,EAEpBP,OAAO,GAAGqE,OAAO,GAAGL,gBAAgB,EACpC1E,KACM,CACG,CAAC;AAEf,CACD;;;;"}
|
|
@@ -5,6 +5,7 @@ var React = require('react');
|
|
|
5
5
|
var classnames = require('classnames');
|
|
6
6
|
var dsIcons = require('@muraldevkit/ds-icons');
|
|
7
7
|
var MrlProcessingButton_module = require('./MrlProcessingButton.module.scss.js');
|
|
8
|
+
var useMrlAnalytics = require('../../../hooks/useMrlAnalytics/useMrlAnalytics.js');
|
|
8
9
|
var MrlButton = require('../MrlButton/MrlButton.js');
|
|
9
10
|
var MrlSvg = require('../../svg/MrlSvg/MrlSvg.js');
|
|
10
11
|
var MrlLiveRegion = require('../../live-region/MrlLiveRegion/MrlLiveRegion.js');
|
|
@@ -32,7 +33,7 @@ function _interopNamespace(e) {
|
|
|
32
33
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
33
34
|
var classnames__default = /*#__PURE__*/_interopDefault(classnames);
|
|
34
35
|
|
|
35
|
-
var _excluded = ["data-qa", "processingButtonConfig", "resetTime", "className"];
|
|
36
|
+
var _excluded = ["data-qa", "processingButtonConfig", "resetTime", "className", "eventId"];
|
|
36
37
|
var DEFAULT_RESET_TIME = 4000;
|
|
37
38
|
var DEFAULT_FEEDBACK_TIME = 500;
|
|
38
39
|
/**
|
|
@@ -52,32 +53,50 @@ function MrlProcessingButton(props) {
|
|
|
52
53
|
_props$resetTime = props.resetTime,
|
|
53
54
|
resetTime = _props$resetTime === void 0 ? DEFAULT_RESET_TIME : _props$resetTime,
|
|
54
55
|
className = props.className,
|
|
56
|
+
eventId = props.eventId,
|
|
55
57
|
buttonProps = _rollupPluginBabelHelpers.objectWithoutProperties(props, _excluded);
|
|
56
58
|
var _React$useState = React__namespace.useState('normal'),
|
|
57
59
|
_React$useState2 = _rollupPluginBabelHelpers.slicedToArray(_React$useState, 2),
|
|
58
60
|
currentState = _React$useState2[0],
|
|
59
61
|
setCurrentState = _React$useState2[1];
|
|
60
62
|
var timeoutRef = React__namespace.useRef(null);
|
|
63
|
+
var trackInteraction = useMrlAnalytics.useMrlTrackInteraction('MrlProcessingButton', eventId);
|
|
61
64
|
var handleClick = () => {
|
|
62
65
|
if (currentState === 'processing') return;
|
|
66
|
+
trackInteraction({
|
|
67
|
+
action: 'click',
|
|
68
|
+
variant: buttonProps.kind
|
|
69
|
+
});
|
|
63
70
|
setCurrentState('processing');
|
|
64
71
|
};
|
|
65
72
|
var feedbackTime = (_processingButtonConf = processingButtonConfig.processing.feedbackTime) !== null && _processingButtonConf !== void 0 ? _processingButtonConf : DEFAULT_FEEDBACK_TIME;
|
|
66
73
|
var executeAction = React__namespace.useCallback(() => {
|
|
67
74
|
processingButtonConfig.processing.action().then(() => {
|
|
75
|
+
trackInteraction({
|
|
76
|
+
action: 'submit',
|
|
77
|
+
metadata: {
|
|
78
|
+
outcome: 'success'
|
|
79
|
+
}
|
|
80
|
+
});
|
|
68
81
|
if (processingButtonConfig.success) {
|
|
69
82
|
setCurrentState('success');
|
|
70
83
|
} else {
|
|
71
84
|
setCurrentState('normal');
|
|
72
85
|
}
|
|
73
86
|
}).catch(() => {
|
|
87
|
+
trackInteraction({
|
|
88
|
+
action: 'submit',
|
|
89
|
+
metadata: {
|
|
90
|
+
outcome: 'error'
|
|
91
|
+
}
|
|
92
|
+
});
|
|
74
93
|
if (processingButtonConfig.error) {
|
|
75
94
|
setCurrentState('error');
|
|
76
95
|
} else {
|
|
77
96
|
setCurrentState('normal');
|
|
78
97
|
}
|
|
79
98
|
});
|
|
80
|
-
}, [processingButtonConfig.error, processingButtonConfig.processing, processingButtonConfig.success]);
|
|
99
|
+
}, [processingButtonConfig.error, processingButtonConfig.processing, processingButtonConfig.success, trackInteraction]);
|
|
81
100
|
React__namespace.useEffect(() => {
|
|
82
101
|
switch (currentState) {
|
|
83
102
|
case 'processing':
|