@salesforce/design-system-react 11.0.0-rc.1 → 11.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -2
- package/dist/cjs/components/accordion/index.cjs +1 -1
- package/dist/cjs/components/accordion/index.cjs.map +1 -1
- package/dist/cjs/components/accordion/panel.cjs.map +1 -1
- package/dist/cjs/components/builder-header/nav-dropdown.cjs.map +1 -1
- package/dist/cjs/components/builder-header/nav-link.cjs.map +1 -1
- package/dist/cjs/components/builder-header/toolbar.cjs.map +1 -1
- package/dist/cjs/components/button/index.cjs.map +1 -1
- package/dist/cjs/components/button-stateful/index.cjs.map +1 -1
- package/dist/cjs/components/checkbox/index.cjs.map +1 -1
- package/dist/cjs/components/color-picker/color-picker.cjs.map +1 -1
- package/dist/cjs/components/combobox/combobox.cjs +1 -1
- package/dist/cjs/components/combobox/combobox.cjs.map +1 -1
- package/dist/cjs/components/date-picker/date-picker.cjs +1 -1
- package/dist/cjs/components/date-picker/date-picker.cjs.map +1 -1
- package/dist/cjs/components/date-picker/index.cjs.map +1 -1
- package/dist/cjs/components/files/file.cjs.map +1 -1
- package/dist/cjs/components/icon/index.cjs.map +1 -1
- package/dist/cjs/components/icon/input-icon/index.cjs.map +1 -1
- package/dist/cjs/components/icon-settings/index.cjs.map +1 -1
- package/dist/cjs/components/input/index.cjs.map +1 -1
- package/dist/cjs/components/input/private/inner-input.cjs.map +1 -1
- package/dist/cjs/components/menu-dropdown/button-trigger.cjs.map +1 -1
- package/dist/cjs/components/menu-dropdown/menu-dropdown.cjs.map +1 -1
- package/dist/cjs/components/modal/index.cjs.map +1 -1
- package/dist/cjs/components/panel/filtering/group.cjs.map +1 -1
- package/dist/cjs/components/pill/index.cjs.map +1 -1
- package/dist/cjs/components/popover/edit-dialog.cjs.map +1 -1
- package/dist/cjs/components/popover/popover.cjs.map +1 -1
- package/dist/cjs/components/progress-indicator/index.cjs.map +1 -1
- package/dist/cjs/components/progress-ring/index.cjs.map +1 -1
- package/dist/cjs/components/radio/index.cjs.map +1 -1
- package/dist/cjs/components/radio-group/check-props.cjs.map +1 -1
- package/dist/cjs/components/radio-group/index.cjs.map +1 -1
- package/dist/cjs/components/scoped-notification/index.cjs.map +1 -1
- package/dist/cjs/components/setup-assistant/step.cjs.map +1 -1
- package/dist/cjs/components/slider/index.cjs.map +1 -1
- package/dist/cjs/components/split-view/header.cjs.map +1 -1
- package/dist/cjs/components/tabs/index.cjs.map +1 -1
- package/dist/cjs/components/tabs/panel.cjs.map +1 -1
- package/dist/cjs/components/textarea/index.cjs +1 -1
- package/dist/cjs/components/textarea/index.cjs.map +1 -1
- package/dist/cjs/components/tooltip/index.cjs.map +1 -1
- package/dist/cjs/components/tree/tree.cjs.map +1 -1
- package/dist/cjs/components/trial-bar/button.cjs.map +1 -1
- package/dist/cjs/components/trial-bar/dropdown.cjs.map +1 -1
- package/dist/cjs/components/utilities/menu-list/item-label.cjs.map +1 -1
- package/dist/cjs/utilities/get-component-doc.cjs +1 -1
- package/dist/cjs/utilities/get-component-doc.cjs.map +1 -1
- package/dist/cjs/utilities/warning/children-as-trigger.cjs +1 -1
- package/dist/cjs/utilities/warning/children-as-trigger.cjs.map +1 -1
- package/dist/cjs/utilities/warning/deprecated-property-value.cjs +1 -1
- package/dist/cjs/utilities/warning/deprecated-property-value.cjs.map +1 -1
- package/dist/cjs/utilities/warning/deprecated-property.cjs +1 -1
- package/dist/cjs/utilities/warning/deprecated-property.cjs.map +1 -1
- package/dist/cjs/utilities/warning/removal-version.cjs +2 -0
- package/dist/cjs/utilities/warning/removal-version.cjs.map +1 -0
- package/dist/es/components/accordion/index.js +7 -3
- package/dist/es/components/accordion/index.js.map +1 -1
- package/dist/es/components/accordion/panel.js.map +1 -1
- package/dist/es/components/builder-header/nav-dropdown.js.map +1 -1
- package/dist/es/components/builder-header/nav-link.js.map +1 -1
- package/dist/es/components/builder-header/toolbar.js.map +1 -1
- package/dist/es/components/button/index.js.map +1 -1
- package/dist/es/components/button-stateful/index.js.map +1 -1
- package/dist/es/components/checkbox/index.js.map +1 -1
- package/dist/es/components/color-picker/color-picker.js.map +1 -1
- package/dist/es/components/combobox/combobox.js +4 -2
- package/dist/es/components/combobox/combobox.js.map +1 -1
- package/dist/es/components/date-picker/date-picker.js +1 -1
- package/dist/es/components/date-picker/date-picker.js.map +1 -1
- package/dist/es/components/date-picker/index.js.map +1 -1
- package/dist/es/components/files/file.js.map +1 -1
- package/dist/es/components/icon/index.js.map +1 -1
- package/dist/es/components/icon/input-icon/index.js.map +1 -1
- package/dist/es/components/icon-settings/index.js.map +1 -1
- package/dist/es/components/input/index.js.map +1 -1
- package/dist/es/components/input/private/inner-input.js.map +1 -1
- package/dist/es/components/menu-dropdown/button-trigger.js.map +1 -1
- package/dist/es/components/menu-dropdown/menu-dropdown.js.map +1 -1
- package/dist/es/components/modal/index.js.map +1 -1
- package/dist/es/components/panel/filtering/group.js.map +1 -1
- package/dist/es/components/pill/index.js.map +1 -1
- package/dist/es/components/popover/edit-dialog.js.map +1 -1
- package/dist/es/components/popover/popover.js.map +1 -1
- package/dist/es/components/progress-indicator/index.js.map +1 -1
- package/dist/es/components/progress-ring/index.js.map +1 -1
- package/dist/es/components/radio/index.js.map +1 -1
- package/dist/es/components/radio-group/check-props.js.map +1 -1
- package/dist/es/components/radio-group/index.js.map +1 -1
- package/dist/es/components/scoped-notification/index.js.map +1 -1
- package/dist/es/components/setup-assistant/step.js.map +1 -1
- package/dist/es/components/slider/index.js.map +1 -1
- package/dist/es/components/split-view/header.js.map +1 -1
- package/dist/es/components/tabs/index.js.map +1 -1
- package/dist/es/components/tabs/panel.js.map +1 -1
- package/dist/es/components/textarea/index.js +29 -44
- package/dist/es/components/textarea/index.js.map +1 -1
- package/dist/es/components/tooltip/index.js.map +1 -1
- package/dist/es/components/tree/tree.js.map +1 -1
- package/dist/es/components/trial-bar/button.js.map +1 -1
- package/dist/es/components/trial-bar/dropdown.js.map +1 -1
- package/dist/es/components/utilities/menu-list/item-label.js.map +1 -1
- package/dist/es/utilities/get-component-doc.js +6 -6
- package/dist/es/utilities/get-component-doc.js.map +1 -1
- package/dist/es/utilities/warning/children-as-trigger.js +9 -8
- package/dist/es/utilities/warning/children-as-trigger.js.map +1 -1
- package/dist/es/utilities/warning/deprecated-property-value.js +11 -10
- package/dist/es/utilities/warning/deprecated-property-value.js.map +1 -1
- package/dist/es/utilities/warning/deprecated-property.js +9 -8
- package/dist/es/utilities/warning/deprecated-property.js.map +1 -1
- package/dist/es/utilities/warning/removal-version.js +6 -0
- package/dist/es/utilities/warning/removal-version.js.map +1 -0
- package/dist/llms/components/accordion.md +267 -0
- package/dist/llms/components/alert.md +228 -0
- package/dist/llms/components/avatar.md +167 -0
- package/dist/llms/components/badge.md +153 -0
- package/dist/llms/components/breadcrumb.md +148 -0
- package/dist/llms/components/builder-header.examples.md +239 -0
- package/dist/llms/components/builder-header.md +736 -0
- package/dist/llms/components/button-group.md +167 -0
- package/dist/llms/components/button-stateful.md +246 -0
- package/dist/llms/components/button.md +661 -0
- package/dist/llms/components/card.md +368 -0
- package/dist/llms/components/carousel.md +365 -0
- package/dist/llms/components/checkbox.md +887 -0
- package/dist/llms/components/color-picker.md +591 -0
- package/dist/llms/components/combobox.examples.md +802 -0
- package/dist/llms/components/combobox.md +929 -0
- package/dist/llms/components/date-picker.md +546 -0
- package/dist/llms/components/docked-composer.md +173 -0
- package/dist/llms/components/dynamic-icon.md +226 -0
- package/dist/llms/components/expandable-section.md +198 -0
- package/dist/llms/components/files.md +337 -0
- package/dist/llms/components/filter.md +775 -0
- package/dist/llms/components/icon-settings.md +301 -0
- package/dist/llms/components/icon.md +1040 -0
- package/dist/llms/components/input.md +746 -0
- package/dist/llms/components/media-object.md +125 -0
- package/dist/llms/components/menu-dropdown.md +732 -0
- package/dist/llms/components/modal.md +504 -0
- package/dist/llms/components/page-header.md +282 -0
- package/dist/llms/components/panel.md +256 -0
- package/dist/llms/components/pill-container.md +218 -0
- package/dist/llms/components/pill.md +266 -0
- package/dist/llms/components/popover.md +600 -0
- package/dist/llms/components/portal-settings.md +371 -0
- package/dist/llms/components/progress-bar.md +175 -0
- package/dist/llms/components/progress-indicator.md +399 -0
- package/dist/llms/components/progress-ring.md +146 -0
- package/dist/llms/components/radio-button-group.md +285 -0
- package/dist/llms/components/radio-group.md +242 -0
- package/dist/llms/components/radio.md +269 -0
- package/dist/llms/components/scoped-notification.md +156 -0
- package/dist/llms/components/setup-assistant.md +398 -0
- package/dist/llms/components/simple-data-table.examples.md +2773 -0
- package/dist/llms/components/simple-data-table.md +919 -0
- package/dist/llms/components/slider.md +217 -0
- package/dist/llms/components/spinner.md +232 -0
- package/dist/llms/components/split-view.md +350 -0
- package/dist/llms/components/tabs.md +311 -0
- package/dist/llms/components/textarea.md +331 -0
- package/dist/llms/components/toast.md +267 -0
- package/dist/llms/components/tooltip.md +470 -0
- package/dist/llms/components/tree.md +1011 -0
- package/dist/llms/components/trial-bar.md +383 -0
- package/dist/llms/components/vertical-navigation.md +196 -0
- package/dist/llms/components/visual-picker.md +362 -0
- package/dist/llms/components/welcome-mat.md +885 -0
- package/dist/llms/docs/migration-v11.md +471 -0
- package/dist/llms/llms-full.txt +6874 -0
- package/dist/llms/llms.txt +133 -0
- package/dist/llms/rules.md +36 -0
- package/dist/types/components/accordion/index.d.ts.map +1 -1
- package/dist/types/components/accordion/panel.d.ts +7 -7
- package/dist/types/components/builder-header/nav-dropdown.d.ts +1 -0
- package/dist/types/components/builder-header/nav-dropdown.d.ts.map +1 -1
- package/dist/types/components/builder-header/nav-link.d.ts +0 -1
- package/dist/types/components/builder-header/nav-link.d.ts.map +1 -1
- package/dist/types/components/builder-header/toolbar.d.ts +0 -1
- package/dist/types/components/builder-header/toolbar.d.ts.map +1 -1
- package/dist/types/components/button/index.d.ts +6 -3
- package/dist/types/components/button/index.d.ts.map +1 -1
- package/dist/types/components/button-stateful/index.d.ts +4 -1
- package/dist/types/components/button-stateful/index.d.ts.map +1 -1
- package/dist/types/components/checkbox/index.d.ts +19 -5
- package/dist/types/components/checkbox/index.d.ts.map +1 -1
- package/dist/types/components/color-picker/color-picker.d.ts +6 -4
- package/dist/types/components/color-picker/color-picker.d.ts.map +1 -1
- package/dist/types/components/color-picker/types.d.ts +2 -2
- package/dist/types/components/combobox/combobox.d.ts +22 -0
- package/dist/types/components/combobox/combobox.d.ts.map +1 -1
- package/dist/types/components/date-picker/date-picker.d.ts +16 -4
- package/dist/types/components/date-picker/date-picker.d.ts.map +1 -1
- package/dist/types/components/date-picker/index.d.ts +2 -6
- package/dist/types/components/date-picker/index.d.ts.map +1 -1
- package/dist/types/components/files/file.d.ts +1 -1
- package/dist/types/components/icon/index.d.ts +1 -0
- package/dist/types/components/icon/index.d.ts.map +1 -1
- package/dist/types/components/icon/input-icon/index.d.ts +3 -0
- package/dist/types/components/icon/input-icon/index.d.ts.map +1 -1
- package/dist/types/components/icon-settings/index.d.ts.map +1 -1
- package/dist/types/components/input/index.d.ts +2 -1
- package/dist/types/components/input/index.d.ts.map +1 -1
- package/dist/types/components/menu-dropdown/button-trigger.d.ts +5 -0
- package/dist/types/components/menu-dropdown/button-trigger.d.ts.map +1 -1
- package/dist/types/components/menu-dropdown/menu-dropdown.d.ts +4 -0
- package/dist/types/components/menu-dropdown/menu-dropdown.d.ts.map +1 -1
- package/dist/types/components/modal/index.d.ts +5 -5
- package/dist/types/components/page-header/types.d.ts +3 -0
- package/dist/types/components/page-header/types.d.ts.map +1 -1
- package/dist/types/components/panel/filtering/group.d.ts +2 -0
- package/dist/types/components/panel/filtering/group.d.ts.map +1 -1
- package/dist/types/components/pill/index.d.ts +1 -0
- package/dist/types/components/pill/index.d.ts.map +1 -1
- package/dist/types/components/popover/edit-dialog.d.ts +1 -3
- package/dist/types/components/popover/edit-dialog.d.ts.map +1 -1
- package/dist/types/components/popover/popover.d.ts +1 -0
- package/dist/types/components/popover/popover.d.ts.map +1 -1
- package/dist/types/components/progress-indicator/index.d.ts +1 -0
- package/dist/types/components/progress-indicator/index.d.ts.map +1 -1
- package/dist/types/components/progress-ring/index.d.ts +1 -0
- package/dist/types/components/progress-ring/index.d.ts.map +1 -1
- package/dist/types/components/radio/index.d.ts +2 -2
- package/dist/types/components/radio/index.d.ts.map +1 -1
- package/dist/types/components/radio-group/index.d.ts +2 -0
- package/dist/types/components/radio-group/index.d.ts.map +1 -1
- package/dist/types/components/scoped-notification/index.d.ts +1 -0
- package/dist/types/components/scoped-notification/index.d.ts.map +1 -1
- package/dist/types/components/setup-assistant/step.d.ts +0 -1
- package/dist/types/components/setup-assistant/step.d.ts.map +1 -1
- package/dist/types/components/simple-data-table/types.d.ts +1 -0
- package/dist/types/components/simple-data-table/types.d.ts.map +1 -1
- package/dist/types/components/slider/index.d.ts +4 -2
- package/dist/types/components/slider/index.d.ts.map +1 -1
- package/dist/types/components/tabs/index.d.ts +1 -0
- package/dist/types/components/tabs/index.d.ts.map +1 -1
- package/dist/types/components/tabs/panel.d.ts +2 -1
- package/dist/types/components/tabs/panel.d.ts.map +1 -1
- package/dist/types/components/textarea/index.d.ts +9 -40
- package/dist/types/components/textarea/index.d.ts.map +1 -1
- package/dist/types/components/tooltip/index.d.ts +5 -0
- package/dist/types/components/tooltip/index.d.ts.map +1 -1
- package/dist/types/components/tree/tree.d.ts +5 -0
- package/dist/types/components/tree/tree.d.ts.map +1 -1
- package/dist/types/components/utilities/menu-list/item-label.d.ts +12 -0
- package/dist/types/components/utilities/menu-list/item-label.d.ts.map +1 -1
- package/package.json +8 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover.js","names":[],"sources":["../../../../components/popover/popover.tsx"],"sourcesContent":["/* eslint-disable max-lines */\n/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\nimport React, {\n\tforwardRef,\n\tuseEffect,\n\tuseRef,\n\tuseCallback,\n\tuseId,\n\tuseContext,\n\ttype ReactNode,\n\ttype MouseEvent,\n\ttype KeyboardEvent,\n\ttype FocusEvent,\n\ttype CSSProperties,\n} from 'react';\nimport classNames from 'classnames';\n\nimport Button from '../button';\nimport MediaObject from '../media-object';\nimport Icon from '../icon';\nimport Dialog from '../utilities/dialog';\nimport { useClickOutside, useControllableState } from '../../utilities/hooks';\nimport keyboardNavigableDialog from '../../utilities/keyboard-navigable-dialog';\nimport KEYS from '../../utilities/key-code';\nimport { POPOVER } from '../../utilities/constants';\nimport { IconSettingsContext } from '../icon-settings';\nimport deprecatedProperty from '../../utilities/warning/deprecated-property';\nimport sunsetProperty from '../../utilities/warning/sunset-property';\nimport mergeProps from '../../utilities/merge-props';\nimport getComponentDocFn from '../../utilities/get-component-doc';\nimport componentDoc from './component.json';\n\nconst documentDefined = typeof document !== 'undefined';\n\n// Shared overlay element for click-outside detection over iframes\nconst overlay = documentDefined\n\t? document.createElement('span')\n\t: ({ style: {} } as HTMLSpanElement);\nif (documentDefined) {\n\toverlay.style.top = '0';\n\toverlay.style.left = '0';\n\toverlay.style.width = '100%';\n\toverlay.style.height = '100%';\n\toverlay.style.position = 'absolute';\n}\n\n// Track currently open popover for single-popover-at-a-time behavior\nlet currentOpenPopover: {\n\thandleClose: (\n\t\tevent: MouseEvent | KeyboardEvent | undefined,\n\t\tdata: PopoverRequestCloseData\n\t) => void;\n\tgetId: () => string;\n} | null = null;\n\n/**\n * Popover alignment options\n */\nexport type PopoverAlign =\n\t| 'top'\n\t| 'top left'\n\t| 'top right'\n\t| 'right'\n\t| 'right top'\n\t| 'right bottom'\n\t| 'bottom'\n\t| 'bottom left'\n\t| 'bottom right'\n\t| 'left'\n\t| 'left top'\n\t| 'left bottom';\n\n/**\n * Popover position options\n */\nexport type PopoverPosition =\n\t'absolute' | 'overflowBoundaryElement' | 'relative';\n\n/**\n * Popover variant options\n */\nexport type PopoverVariant =\n\t| 'base'\n\t| 'error'\n\t| 'feature'\n\t| 'walkthrough'\n\t| 'walkthrough-action'\n\t| 'warning';\n\n/**\n * Assistive text for Popover\n */\nexport interface PopoverAssistiveText {\n\tcloseButton?: string;\n}\n\n/**\n * What caused `onRequestClose` to fire:\n * * `cancel`: the close button was clicked or Escape was pressed\n * * `clickOutside`: a click landed outside the popover\n * * `mouseLeave`: the mouse left the trigger/popover (`openOn` `hover`/`hybrid`) and `hoverCloseDelay` elapsed\n * * `newPopover`: another Popover opened (only one can be open at a time)\n * * `triggerClick`: the trigger was clicked while the popover was open\n */\nexport type PopoverRequestCloseTrigger =\n\t'cancel' | 'clickOutside' | 'mouseLeave' | 'newPopover' | 'triggerClick';\n\n/**\n * Data passed to `onRequestClose`\n */\nexport interface PopoverRequestCloseData {\n\t/** What caused the close request */\n\ttrigger: PopoverRequestCloseTrigger;\n\t/** HTML id of the popover being closed. Only present when `trigger` is `newPopover`. */\n\tid?: string;\n}\n\n/**\n * What caused `onRequestOpen` to fire:\n * * `focus`: the trigger received focus (`openOn` `hover`)\n * * `mouseEnter`: the mouse entered the trigger (`openOn` `hover`)\n * * `triggerClick`: the trigger was clicked while the popover was closed\n */\nexport type PopoverRequestOpenTrigger = 'focus' | 'mouseEnter' | 'triggerClick';\n\n/**\n * Data passed to `onRequestOpen`\n */\nexport interface PopoverRequestOpenData {\n\t/** What caused the open request */\n\ttrigger: PopoverRequestOpenTrigger;\n}\n\n/**\n * Data passed to `onOpen`\n */\nexport interface PopoverOpenData {\n\t/** The rendered popover dialog element */\n\tportal?: HTMLElement;\n}\n\n/**\n * Data passed to `onClose`\n */\nexport interface PopoverCloseData {\n\t/** `true` when the popover dialog is closing because it is being unmounted */\n\tcomponentWillUnmount: boolean;\n}\n\n/**\n * Props every Popover takes\n */\nexport interface PopoverBaseProps {\n\t/** Alignment relative to trigger */\n\talign?: PopoverAlign;\n\t/** Accessibility labels */\n\tassistiveText?: PopoverAssistiveText;\n\t/**\n\t * The element the popover attaches to (the first child), and optional other children rendered\n\t * beside it. The first child is the trigger: Popover adds `id`, `aria-haspopup`, `tabIndex` and\n\t * its open handlers to it, unless `openOn` is `'none'`, which leaves it as it is.\n\t */\n\tchildren: ReactNode;\n\t/** Popover body content */\n\tbody: ReactNode;\n\t/** CSS classes for the `.slds-popover__body` element */\n\tclassNameBody?: string | string[] | Record<string, boolean>;\n\t/** CSS classes for the `.slds-popover__footer` element */\n\tclassNameFooter?: string | string[] | Record<string, boolean>;\n\t/** @deprecated Use `classNameFooter`. */\n\tfooterClassName?: string | string[] | Record<string, boolean>;\n\t/**\n\t * CSS classes for the root element: the `div` that wraps the trigger. To style the\n\t * `.slds-popover` dialog (for example `slds-popover_large`), use `classNameDialog`.\n\t */\n\tclassName?: string | string[] | Record<string, boolean>;\n\t/** CSS classes for the `.slds-popover` dialog element */\n\tclassNameDialog?: string | string[] | Record<string, boolean>;\n\t/** @deprecated Use `classNameDialog`, which lands on the same element. */\n\tcontentsClassName?: string | string[] | Record<string, boolean>;\n\t/** Disable the popover */\n\tdisabled?: boolean;\n\t/** Footer content */\n\tfooter?: ReactNode;\n\t/** @deprecated Use `styleFooter`. */\n\tfooterStyle?: CSSProperties;\n\t/** Walkthrough footer actions */\n\tfooterWalkthroughActions?: ReactNode | ReactNode[];\n\t/** Hide close button */\n\thasNoCloseButton?: boolean;\n\t/** Hide nubbin/arrow */\n\thasNoNubbin?: boolean;\n\t/** Prevent position flipping */\n\thasStaticAlignment?: boolean;\n\t/** Remove trigger inline-block style */\n\thasNoTriggerStyles?: boolean;\n\t/** HTML id */\n\tid?: string;\n\t/**\n\t * Open state when the popover is controlled. When `isOpen` is set, the popover only opens and closes\n\t * when this prop changes: handle `onRequestOpen` and `onRequestClose` to update it. Leave it\n\t * `undefined` for an uncontrolled popover (see `defaultIsOpen`).\n\t */\n\tisOpen?: boolean;\n\t/** Initial open state of an uncontrolled popover (`isOpen` is `undefined`). Defaults to `false`. */\n\tdefaultIsOpen?: boolean;\n\t/** Click handler */\n\tonClick?: (event: MouseEvent) => void;\n\t/** Called after the popover dialog has closed (unmounted). There is no triggering event, so `event` is `undefined`. */\n\tonClose?: (event: undefined, data: PopoverCloseData) => void;\n\t/** Focus handler */\n\tonFocus?: (event: FocusEvent) => void;\n\t/** Key down handler */\n\tonKeyDown?: (event: KeyboardEvent) => void;\n\t/** Mouse down handler */\n\tonMouseDown?: (event: MouseEvent) => void;\n\t/** Mouse enter handler */\n\tonMouseEnter?: (event: MouseEvent) => void;\n\t/** Mouse leave handler */\n\tonMouseLeave?: (event: MouseEvent) => void;\n\t/** Called after the popover dialog has opened and rendered. There is no triggering event, so `event` is `undefined`. */\n\tonOpen?: (event: undefined, data: PopoverOpenData) => void;\n\t/**\n\t * Called when the popover requests to open (trigger click, or hover/focus with `openOn` `hover`),\n\t * controlled or not. `data.trigger` says why. A controlled popover opens only if the parent sets\n\t * `isOpen` to `true`.\n\t */\n\tonRequestOpen?: (\n\t\tevent: MouseEvent | FocusEvent,\n\t\tdata: PopoverRequestOpenData\n\t) => void;\n\t/**\n\t * Called when the popover requests to close, controlled or not. `data.trigger` says why. `event` is\n\t * the triggering click or key event, or `undefined` when there is none (`mouseLeave` timer,\n\t * `newPopover`). A controlled popover closes only if the parent sets `isOpen` to `false`.\n\t */\n\tonRequestClose?: (\n\t\tevent: MouseEvent | KeyboardEvent | undefined,\n\t\tdata: PopoverRequestCloseData\n\t) => void;\n\t/** Custom target element getter */\n\tonRequestTargetElement?: () => HTMLElement | null;\n\t/**\n\t * What on the first child opens the popover: `click` (the default), `hover`, or `hybrid` (click\n\t * or hover). `none` makes the first child only an anchor that the popover points at, such as\n\t * the target of a walkthrough step: Popover leaves its markup and handlers alone, and the\n\t * parent opens and closes the popover through `isOpen`.\n\t */\n\topenOn?: 'click' | 'hover' | 'hybrid' | 'none';\n\t/** Overlay for click-outside on iframes */\n\toverlay?:\n\t\tboolean | ((isOpen: boolean, overlayElement: HTMLSpanElement) => void);\n\t/** Positioning strategy */\n\tposition?: PopoverPosition;\n\t/** Walkthrough step text */\n\tstepText?: string;\n\t/** Styles for the root element: the `div` that wraps the trigger. To style the dialog, use `styleDialog`. */\n\tstyle?: CSSProperties;\n\t/** Styles for the `.slds-popover` dialog element */\n\tstyleDialog?: CSSProperties;\n\t/** Styles for the `.slds-popover__footer` element */\n\tstyleFooter?: CSSProperties;\n\t/** @deprecated Use `className`, which lands on the same element. */\n\ttriggerClassName?: string | string[] | Record<string, boolean>;\n\t/** Delay before closing on hover (ms) */\n\thoverCloseDelay?: number;\n}\n\n/** The `feature` variant, the only one with an `icon`. */\ninterface PopoverFeatureVariantProps {\n\t/** Popover variant */\n\tvariant: 'feature';\n\t/** Icon for the feature variant */\n\ticon?: ReactNode;\n}\n\n/** Every other variant. */\ninterface PopoverOtherVariantProps {\n\t/** Popover variant */\n\tvariant?: Exclude<PopoverVariant, 'feature'>;\n\ticon?: never;\n}\n\n/**\n * The dialog is named by `heading`, or by the `id` of another element in\n * `ariaLabelledby`, not both.\n */\nexport type PopoverLabelProps =\n\t| {\n\t\t\t/** Popover heading */\n\t\t\theading?: ReactNode;\n\t\t\tariaLabelledby?: never;\n\t }\n\t| {\n\t\t\theading?: never;\n\t\t\t/** HTML id of the heading element that labels the dialog. Use instead of `heading`. */\n\t\t\tariaLabelledby: string;\n\t };\n\n/**\n * Props for the Popover component: `icon` is feature-only, and `heading`\n * and `ariaLabelledby` are exclusive.\n */\nexport type PopoverProps = PopoverBaseProps &\n\t(PopoverFeatureVariantProps | PopoverOtherVariantProps) &\n\tPopoverLabelProps;\n\n/**\n * Props removed from the public API. Still destructured so they never reach\n * the DOM, and reported on mount.\n */\ninterface PopoverRemovedProps {\n\tcloseButtonAssistiveText?: unknown;\n\toffset?: unknown;\n}\n\n// Nubbin positions for export (legacy)\nexport const PopoverNubbinPositions = [\n\t'top left',\n\t'top',\n\t'top right',\n\t'bottom left',\n\t'bottom',\n\t'bottom right',\n];\n\nconst defaultAssistiveText: PopoverAssistiveText = {\n\tcloseButton: 'Close dialog',\n};\n\n/**\n * The Popover component is a non-modal dialog. It should be paired with a clickable\n * trigger such as a Button. It traps focus from the page and must be exited if focus\n * needs to be outside the Popover.\n */\nconst Popover = forwardRef<HTMLDivElement, PopoverProps>((props, ref) => {\n\tconst {\n\t\talign = 'right',\n\t\tassistiveText: propAssistiveText,\n\t\tariaLabelledby,\n\t\tchildren,\n\t\tbody,\n\t\tclassNameBody,\n\t\tclassNameFooter,\n\t\tfooterClassName,\n\t\tclassName,\n\t\tclassNameDialog,\n\t\tcontentsClassName,\n\t\tdisabled = false,\n\t\tfooter,\n\t\tfooterStyle,\n\t\tfooterWalkthroughActions,\n\t\thasNoCloseButton = false,\n\t\thasNoNubbin = false,\n\t\thasStaticAlignment = false,\n\t\thasNoTriggerStyles = false,\n\t\theading,\n\t\ticon,\n\t\tid: propId,\n\t\tisOpen: controlledIsOpen,\n\t\tdefaultIsOpen = false,\n\t\toffset,\n\t\tonClick,\n\t\tonClose,\n\t\tonFocus,\n\t\tonKeyDown,\n\t\tonMouseDown,\n\t\tonMouseEnter,\n\t\tonMouseLeave,\n\t\tonOpen,\n\t\tonRequestOpen,\n\t\tonRequestClose,\n\t\tonRequestTargetElement,\n\t\topenOn = 'click',\n\t\toverlay: overlayProp,\n\t\tposition = 'absolute',\n\t\tstepText,\n\t\tstyle,\n\t\tstyleDialog,\n\t\tstyleFooter,\n\t\ttriggerClassName,\n\t\tvariant = 'base',\n\t\thoverCloseDelay = 300,\n\t\tcloseButtonAssistiveText,\n\t} = props as PopoverBaseProps &\n\t\tPopoverRemovedProps & {\n\t\t\tariaLabelledby?: string;\n\t\t\theading?: ReactNode;\n\t\t\ticon?: ReactNode;\n\t\t\tvariant?: PopoverVariant;\n\t\t};\n\n\t// `check-props.js` is not wired up (its trigger and heading checks predate v11), so the\n\t// renamed and removed props are checked here.\n\tuseEffect(() => {\n\t\tif (process.env.NODE_ENV !== 'production') {\n\t\t\tconst createDocUrl = getComponentDocFn(componentDoc);\n\t\t\tconst renamedProps: [string, unknown, string][] = [\n\t\t\t\t['contentsClassName', contentsClassName, 'classNameDialog'],\n\t\t\t\t['footerClassName', footerClassName, 'classNameFooter'],\n\t\t\t\t['footerStyle', footerStyle, 'styleFooter'],\n\t\t\t\t['triggerClassName', triggerClassName, 'className'],\n\t\t\t];\n\t\t\trenamedProps.forEach(([oldProp, value, newProp]) => {\n\t\t\t\tdeprecatedProperty(\n\t\t\t\t\tPOPOVER,\n\t\t\t\t\tvalue,\n\t\t\t\t\toldProp,\n\t\t\t\t\tnewProp,\n\t\t\t\t\tcreateDocUrl(newProp)\n\t\t\t\t);\n\t\t\t});\n\t\t\tconst removedProps: [string, unknown, string | undefined][] = [\n\t\t\t\t[\n\t\t\t\t\t'closeButtonAssistiveText',\n\t\t\t\t\tcloseButtonAssistiveText,\n\t\t\t\t\t\"Use `assistiveText={{ closeButton: '...' }}` instead.\",\n\t\t\t\t],\n\t\t\t\t['offset', offset, undefined],\n\t\t\t];\n\t\t\tremovedProps.forEach(([oldProp, value, comment]) => {\n\t\t\t\tsunsetProperty(POPOVER, value, oldProp, comment);\n\t\t\t});\n\t\t}\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, []); // Only run on mount\n\n\tconst generatedId = useId();\n\tconst id = propId || generatedId;\n\tconst context = useContext(IconSettingsContext);\n\n\tconst assistiveText = { ...defaultAssistiveText, ...propAssistiveText };\n\n\t// State\n\tconst [currentIsOpen, setIsOpen] = useControllableState(\n\t\tcontrolledIsOpen,\n\t\tdefaultIsOpen\n\t);\n\n\t// Refs\n\tconst triggerRef = useRef<HTMLDivElement>(null);\n\tconst dialogRef = useRef<HTMLElement>(null);\n\tconst isHoverRef = useRef(false);\n\tconst isClosingRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\tconst overlayRef = useRef<HTMLSpanElement | null>(null);\n\tconst isUnmountingRef = useRef(false);\n\n\t// Derived state\n\tconst isOpen = !disabled && currentIsOpen;\n\n\t// Get target element for positioning\n\tconst getTargetElement = useCallback(() => {\n\t\tif (onRequestTargetElement) {\n\t\t\tconst target = onRequestTargetElement();\n\t\t\tif (target) return target;\n\t\t}\n\t\treturn triggerRef.current;\n\t}, [onRequestTargetElement]);\n\n\t// Handle dialog close (when unmounted)\n\tconst handleDialogClose = useCallback(\n\t\t(\n\t\t\t_event?: React.SyntheticEvent,\n\t\t\tdata?: { componentWillUnmount?: boolean }\n\t\t) => {\n\t\t\tconst componentWillUnmount = data?.componentWillUnmount || false;\n\n\t\t\tif (currentOpenPopover?.getId() === id) {\n\t\t\t\tcurrentOpenPopover = null;\n\t\t\t}\n\n\t\t\tif (onClose) {\n\t\t\t\tonClose(undefined, { componentWillUnmount });\n\t\t\t}\n\t\t},\n\t\t[id, onClose]\n\t);\n\n\t// Handle dialog open (after it has rendered)\n\tconst handleDialogOpen = useCallback(\n\t\t(_event?: unknown, data?: { portal?: HTMLElement }) => {\n\t\t\tif (onOpen) {\n\t\t\t\tonOpen(undefined, { portal: data?.portal });\n\t\t\t}\n\t\t},\n\t\t[onOpen]\n\t);\n\n\t// Handle close\n\tconst handleClose = useCallback(\n\t\t(\n\t\t\tevent: MouseEvent | KeyboardEvent | undefined,\n\t\t\tdata: PopoverRequestCloseData\n\t\t) => {\n\t\t\tif (isOpen) {\n\t\t\t\tif (onRequestClose) {\n\t\t\t\t\tonRequestClose(event, data);\n\t\t\t\t}\n\n\t\t\t\tif (currentOpenPopover?.getId() === id) {\n\t\t\t\t\tcurrentOpenPopover = null;\n\t\t\t\t}\n\n\t\t\t\tsetIsOpen(false);\n\t\t\t\tisHoverRef.current = false;\n\t\t\t}\n\t\t},\n\t\t[isOpen, id, onRequestClose, setIsOpen]\n\t);\n\n\t// Latest `handleClose`, so the \"close the other open popover\" path does not call a stale\n\t// closure from when this popover opened (whose `isOpen` was still `false`).\n\tconst handleCloseRef = useRef(handleClose);\n\tuseEffect(() => {\n\t\thandleCloseRef.current = handleClose;\n\t}, [handleClose]);\n\n\t// Handle open\n\tconst handleOpen = useCallback(\n\t\t(event: MouseEvent | FocusEvent, trigger: PopoverRequestOpenTrigger) => {\n\t\t\tif (!isOpen && !disabled) {\n\t\t\t\tonRequestOpen?.(event, { trigger });\n\n\t\t\t\t// Close any other open popover\n\t\t\t\tif (currentOpenPopover && currentOpenPopover.getId() !== id) {\n\t\t\t\t\tcurrentOpenPopover.handleClose(undefined, {\n\t\t\t\t\t\ttrigger: 'newPopover',\n\t\t\t\t\t\tid: currentOpenPopover.getId(),\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tcurrentOpenPopover = {\n\t\t\t\t\thandleClose: (event, data) => handleCloseRef.current(event, data),\n\t\t\t\t\tgetId: () => id,\n\t\t\t\t};\n\n\t\t\t\tsetIsOpen(true);\n\t\t\t}\n\t\t},\n\t\t[isOpen, disabled, id, onRequestOpen, setIsOpen]\n\t);\n\n\t// Handle cancel (close button or escape)\n\tconst handleCancel = useCallback(\n\t\t(event: MouseEvent | KeyboardEvent) => {\n\t\t\thandleClose(event, { trigger: 'cancel' });\n\t\t},\n\t\t[handleClose]\n\t);\n\n\t// Request a close on a mousedown outside the popover. The container holds the trigger\n\t// and an inline dialog; a dialog in a portal carries the ignore class instead.\n\tconst handleClickOutside = useCallback(\n\t\t(event: globalThis.MouseEvent | TouchEvent) => {\n\t\t\thandleClose(event as unknown as MouseEvent, { trigger: 'clickOutside' });\n\t\t},\n\t\t[handleClose]\n\t);\n\tuseClickOutside(triggerRef, handleClickOutside, {\n\t\tenabled: isOpen,\n\t\tignoreClass: `ignore-click-${id}`,\n\t});\n\n\t// Handle mouse enter\n\tconst handleMouseEnter = useCallback(\n\t\t(event: MouseEvent) => {\n\t\t\tisHoverRef.current = true;\n\n\t\t\tif (!isOpen && openOn === 'hover') {\n\t\t\t\thandleOpen(event, 'mouseEnter');\n\t\t\t} else {\n\t\t\t\tif (isClosingRef.current) {\n\t\t\t\t\tclearTimeout(isClosingRef.current);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (onMouseEnter) {\n\t\t\t\tonMouseEnter(event);\n\t\t\t}\n\t\t},\n\t\t[isOpen, openOn, handleOpen, onMouseEnter]\n\t);\n\n\t// Handle mouse leave\n\tconst handleMouseLeave = useCallback(\n\t\t(event: MouseEvent) => {\n\t\t\tif (isOpen) {\n\t\t\t\tisClosingRef.current = setTimeout(() => {\n\t\t\t\t\thandleClose(undefined, { trigger: 'mouseLeave' });\n\t\t\t\t}, hoverCloseDelay);\n\t\t\t}\n\n\t\t\tif (onMouseLeave) {\n\t\t\t\tonMouseLeave(event);\n\t\t\t}\n\t\t},\n\t\t[isOpen, hoverCloseDelay, handleClose, onMouseLeave]\n\t);\n\n\t// Handle click\n\tconst handleClick = useCallback(\n\t\t(event: MouseEvent, triggerOnClickCallback?: (e: MouseEvent) => void) => {\n\t\t\tif (!isOpen) {\n\t\t\t\thandleOpen(event, 'triggerClick');\n\t\t\t} else {\n\t\t\t\thandleClose(event, { trigger: 'triggerClick' });\n\t\t\t}\n\n\t\t\tif (onClick) {\n\t\t\t\tonClick(event);\n\t\t\t}\n\n\t\t\tif (triggerOnClickCallback) {\n\t\t\t\ttriggerOnClickCallback(event);\n\t\t\t}\n\t\t},\n\t\t[isOpen, handleOpen, handleClose, onClick]\n\t);\n\n\t// Handle focus\n\tconst handleFocus = useCallback(\n\t\t(event: FocusEvent) => {\n\t\t\tif (!isOpen) {\n\t\t\t\thandleOpen(event, 'focus');\n\t\t\t}\n\n\t\t\tif (onFocus) {\n\t\t\t\tonFocus(event);\n\t\t\t}\n\t\t},\n\t\t[isOpen, handleOpen, onFocus]\n\t);\n\n\t// Toggle from keyboard\n\t// `handleKeyDown` is only attached to the open dialog, so this only ever closes it (Escape).\n\tconst toggleOpenFromKeyboard = useCallback(\n\t\t(event: KeyboardEvent) => {\n\t\t\tif (isOpen) {\n\t\t\t\thandleCancel(event);\n\t\t\t}\n\t\t},\n\t\t[isOpen, handleCancel]\n\t);\n\n\t// Handle key down\n\tconst handleKeyDown = useCallback(\n\t\t(event: KeyboardEvent) => {\n\t\t\tif (event.key) {\n\t\t\t\tif (event.key !== KEYS.TAB) {\n\t\t\t\t\tkeyboardNavigableDialog({\n\t\t\t\t\t\tevent,\n\t\t\t\t\t\tisOpen,\n\t\t\t\t\t\thandleClick: (e: MouseEvent) => handleClick(e),\n\t\t\t\t\t\tkey: event.key,\n\t\t\t\t\t\teventTarget: event.target,\n\t\t\t\t\t\t// keyboardNavigableDialog calls `toggleOpen()` without the event; pass it through\n\t\t\t\t\t\ttoggleOpen: () => toggleOpenFromKeyboard(event),\n\t\t\t\t\t\ttrigger: triggerRef.current,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (onKeyDown) {\n\t\t\t\t\tonKeyDown(event);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t[isOpen, handleClick, toggleOpenFromKeyboard, onKeyDown]\n\t);\n\n\t// Render overlay for click-outside detection\n\tconst renderOverlay = useCallback(\n\t\t(shouldShow: boolean) => {\n\t\t\tif (typeof overlayProp === 'function' && documentDefined) {\n\t\t\t\toverlayProp(shouldShow, overlay);\n\t\t\t} else if (\n\t\t\t\toverlayProp &&\n\t\t\t\tshouldShow &&\n\t\t\t\t!overlayRef.current &&\n\t\t\t\tdocumentDefined\n\t\t\t) {\n\t\t\t\toverlayRef.current = overlay;\n\t\t\t\tdocument.querySelector('body')?.appendChild(overlay);\n\t\t\t} else if (!shouldShow && overlayRef.current?.parentNode) {\n\t\t\t\toverlayRef.current.parentNode.removeChild(overlayRef.current);\n\t\t\t\toverlayRef.current = null;\n\t\t\t}\n\t\t},\n\t\t[overlayProp]\n\t);\n\n\t// Container ref callback\n\tconst setContainerRef = useCallback(\n\t\t(component: HTMLDivElement | null) => {\n\t\t\t(triggerRef as React.RefObject<HTMLDivElement | null>).current =\n\t\t\t\tcomponent;\n\t\t\tif (typeof ref === 'function') {\n\t\t\t\tref(component);\n\t\t\t} else if (ref) {\n\t\t\t\tref.current = component;\n\t\t\t}\n\t\t},\n\t\t[ref]\n\t);\n\n\t// Dialog ref callback\n\tconst setMenuRef = useCallback((component: HTMLElement | null) => {\n\t\t(dialogRef as React.RefObject<HTMLElement | null>).current = component;\n\t}, []);\n\n\t// Cleanup on unmount\n\tuseEffect(() => {\n\t\treturn () => {\n\t\t\tisUnmountingRef.current = true;\n\t\t\tif (currentOpenPopover?.getId() === id) {\n\t\t\t\tcurrentOpenPopover = null;\n\t\t\t}\n\t\t\trenderOverlay(false);\n\t\t};\n\t}, [id, renderOverlay]);\n\n\t// Update overlay when isOpen changes\n\tuseEffect(() => {\n\t\trenderOverlay(isOpen);\n\t}, [isOpen, renderOverlay]);\n\n\t// Render header\n\tconst renderHeader = () => {\n\t\tconst hasThemedHeader = variant === 'error' || variant === 'warning';\n\t\tconst hasDefinedHeader = heading || hasThemedHeader;\n\n\t\tif (\n\t\t\t!hasDefinedHeader ||\n\t\t\tvariant === 'walkthrough-action' ||\n\t\t\tvariant === 'feature'\n\t\t) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst headerIcon = {\n\t\t\terror: <Icon category=\"utility\" name=\"error\" size=\"x-small\" inverse />,\n\t\t\twarning: (\n\t\t\t\t<Icon category=\"utility\" name=\"warning\" size=\"x-small\" inverse />\n\t\t\t),\n\t\t};\n\n\t\tif (hasThemedHeader) {\n\t\t\treturn (\n\t\t\t\t<header className=\"slds-popover__header\">\n\t\t\t\t\t<MediaObject\n\t\t\t\t\t\tbody={\n\t\t\t\t\t\t\t<h2\n\t\t\t\t\t\t\t\tid={ariaLabelledby || `${id}-dialog-heading`}\n\t\t\t\t\t\t\t\tclassName=\"slds-truncate slds-text-heading_medium\"\n\t\t\t\t\t\t\t\ttitle={typeof heading === 'string' ? heading : undefined}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{heading}\n\t\t\t\t\t\t\t</h2>\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfigure={headerIcon[variant as 'error' | 'warning']}\n\t\t\t\t\t\tverticalCenter\n\t\t\t\t\t/>\n\t\t\t\t</header>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<header\n\t\t\t\tclassName={classNames('slds-popover__header', {\n\t\t\t\t\t'slds-p-vertical_medium': variant === 'walkthrough',\n\t\t\t\t})}\n\t\t\t>\n\t\t\t\t<h2\n\t\t\t\t\tid={ariaLabelledby || `${id}-dialog-heading`}\n\t\t\t\t\tclassName={classNames({\n\t\t\t\t\t\t'slds-text-heading_small': variant !== 'walkthrough',\n\t\t\t\t\t\t'slds-text-heading_medium': variant === 'walkthrough',\n\t\t\t\t\t})}\n\t\t\t\t>\n\t\t\t\t\t{heading}\n\t\t\t\t</h2>\n\t\t\t</header>\n\t\t);\n\t};\n\n\t// Render body\n\tconst renderBody = () => {\n\t\tif (variant === 'error' || variant === 'warning') {\n\t\t\treturn (\n\t\t\t\t<div\n\t\t\t\t\tid={`${id}-dialog-body`}\n\t\t\t\t\tclassName={classNames('slds-popover__body', classNameBody as string)}\n\t\t\t\t>\n\t\t\t\t\t{body}\n\t\t\t\t</div>\n\t\t\t);\n\t\t}\n\n\t\tif (variant === 'walkthrough-action' || variant === 'feature') {\n\t\t\treturn (\n\t\t\t\t<div\n\t\t\t\t\tclassName={classNames('slds-popover__body', classNameBody as string)}\n\t\t\t\t\tid={`${id}-dialog-body`}\n\t\t\t\t>\n\t\t\t\t\t<div className=\"slds-media\">\n\t\t\t\t\t\t<div className=\"slds-media__figure\">\n\t\t\t\t\t\t\t{variant === 'walkthrough-action' ? (\n\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\tcategory=\"utility\"\n\t\t\t\t\t\t\t\t\tname=\"touch_action\"\n\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\tinverse\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\ticon\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div className=\"slds-media__body\">\n\t\t\t\t\t\t\t{heading && (\n\t\t\t\t\t\t\t\t<h2\n\t\t\t\t\t\t\t\t\tid={ariaLabelledby || `${id}-dialog-heading`}\n\t\t\t\t\t\t\t\t\tclassName=\"slds-text-heading_small\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{heading}\n\t\t\t\t\t\t\t\t</h2>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t{body}\n\t\t\t\t\t\t\t{stepText && (\n\t\t\t\t\t\t\t\t<p className=\"slds-m-top_medium slds-text-title\">{stepText}</p>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tid={`${id}-dialog-body`}\n\t\t\t\tclassName={classNames('slds-popover__body', classNameBody as string)}\n\t\t\t>\n\t\t\t\t{body}\n\t\t\t</div>\n\t\t);\n\t};\n\n\t// Render footer\n\tconst renderFooter = () => {\n\t\tconst footerClassNames = classNames(\n\t\t\t'slds-popover__footer',\n\t\t\tfooterClassName,\n\t\t\tclassNameFooter\n\t\t);\n\t\tconst footerStyles =\n\t\t\tfooterStyle || styleFooter\n\t\t\t\t? { ...footerStyle, ...styleFooter }\n\t\t\t\t: undefined;\n\n\t\tif (footer) {\n\t\t\treturn (\n\t\t\t\t<footer className={footerClassNames} style={footerStyles}>\n\t\t\t\t\t{footer}\n\t\t\t\t</footer>\n\t\t\t);\n\t\t}\n\n\t\tif (\n\t\t\tvariant !== 'walkthrough-action' &&\n\t\t\t(footerWalkthroughActions || stepText)\n\t\t) {\n\t\t\treturn (\n\t\t\t\t<footer className={footerClassNames} style={footerStyles}>\n\t\t\t\t\t<div className=\"slds-grid slds-grid_vertical-align-center\">\n\t\t\t\t\t\t{stepText && <span className=\"slds-text-title\">{stepText}</span>}\n\t\t\t\t\t\t{footerWalkthroughActions && (\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tclassName=\"slds-col_bump-left\"\n\t\t\t\t\t\t\t\tstyle={{ display: 'inline-block' }}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{footerWalkthroughActions}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</div>\n\t\t\t\t</footer>\n\t\t\t);\n\t\t}\n\n\t\treturn null;\n\t};\n\n\t// Render dialog\n\tconst renderDialog = () => {\n\t\tif (!isOpen) return null;\n\n\t\tconst outsideClickIgnoreClass = `ignore-click-${id}`;\n\n\t\treturn (\n\t\t\t<Dialog\n\t\t\t\thasNubbin={!hasNoNubbin}\n\t\t\t\talign={align}\n\t\t\t\tcontentsClassName={classNames(\n\t\t\t\t\tcontentsClassName,\n\t\t\t\t\t'ignore-react-onclickoutside',\n\t\t\t\t\t'slds-popover',\n\t\t\t\t\t{ 'slds-popover_error': variant === 'error' },\n\t\t\t\t\t{\n\t\t\t\t\t\t'slds-popover_walkthrough':\n\t\t\t\t\t\t\tvariant === 'walkthrough' ||\n\t\t\t\t\t\t\tvariant === 'walkthrough-action' ||\n\t\t\t\t\t\t\tvariant === 'feature',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t'slds-popover_walkthrough-alt': variant === 'walkthrough-action',\n\t\t\t\t\t},\n\t\t\t\t\t{ 'slds-popover_feature': variant === 'feature' },\n\t\t\t\t\t{ 'slds-popover_warning': variant === 'warning' },\n\t\t\t\t\tclassNameDialog\n\t\t\t\t)}\n\t\t\t\tcontext={context}\n\t\t\t\thasStaticAlignment={hasStaticAlignment}\n\t\t\t\tonClose={handleDialogClose}\n\t\t\t\tonOpen={handleDialogOpen}\n\t\t\t\tonKeyDown={handleKeyDown}\n\t\t\t\tonMouseEnter={openOn === 'hover' ? handleMouseEnter : undefined}\n\t\t\t\tonMouseLeave={openOn === 'hover' ? handleMouseLeave : undefined}\n\t\t\t\toutsideClickIgnoreClass={outsideClickIgnoreClass}\n\t\t\t\tonRequestTargetElement={getTargetElement}\n\t\t\t\tposition={position}\n\t\t\t\tstyle={styleDialog}\n\t\t\t\tvariant=\"popover\"\n\t\t\t\tref={setMenuRef}\n\t\t\t\tcontainerProps={{\n\t\t\t\t\tid: `${id}-popover`,\n\t\t\t\t\t'aria-labelledby': ariaLabelledby || `${id}-dialog-heading`,\n\t\t\t\t\t'aria-describedby': `${id}-dialog-body`,\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{!hasNoCloseButton && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tassistiveText={{ icon: assistiveText.closeButton }}\n\t\t\t\t\t\ticonCategory=\"utility\"\n\t\t\t\t\t\ticonName=\"close\"\n\t\t\t\t\t\tclassName={classNames(\n\t\t\t\t\t\t\t'slds-button slds-button_icon-small slds-float_right slds-popover__close slds-button_icon',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'slds-button_icon-inverse':\n\t\t\t\t\t\t\t\t\tvariant === 'walkthrough' ||\n\t\t\t\t\t\t\t\t\tvariant === 'walkthrough-action' ||\n\t\t\t\t\t\t\t\t\tvariant === 'feature',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t)}\n\t\t\t\t\t\tonClick={handleCancel}\n\t\t\t\t\t\tvariant=\"icon\"\n\t\t\t\t\t\tinverse={variant === 'error' || variant === 'warning'}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t\t{renderHeader()}\n\t\t\t\t{renderBody()}\n\t\t\t\t{renderFooter()}\n\t\t\t</Dialog>\n\t\t);\n\t};\n\n\t// Clone trigger element\n\tconst otherChildren: ReactNode[] = [];\n\tlet clonedTrigger: ReactNode = null;\n\n\tReact.Children.forEach(children, (child, index) => {\n\t\tif (index === 0 && openOn === 'none') {\n\t\t\t// An anchor only: the popover is positioned against it, nothing more\n\t\t\tclonedTrigger = child;\n\t\t} else if (index === 0 && React.isValidElement(child)) {\n\t\t\tconst childProps = child.props as Record<string, unknown>;\n\t\t\t// The trigger's own handlers run alongside the popover's instead of being replaced.\n\t\t\t// `onClick` already calls the trigger's after the popover's (see `handleClick`).\n\t\t\tconst childOnClick = childProps.onClick;\n\t\t\tconst triggerProps = mergeProps(\n\t\t\t\t{\n\t\t\t\t\t'aria-haspopup': 'dialog',\n\t\t\t\t\tid,\n\t\t\t\t\tonClick:\n\t\t\t\t\t\topenOn === 'click' || openOn === 'hybrid'\n\t\t\t\t\t\t\t? (event: MouseEvent) => {\n\t\t\t\t\t\t\t\t\thandleClick(event, childOnClick as (e: MouseEvent) => void);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: childOnClick,\n\t\t\t\t\tonFocus: openOn === 'hover' ? handleFocus : undefined,\n\t\t\t\t\tonMouseDown,\n\t\t\t\t\tonMouseEnter:\n\t\t\t\t\t\topenOn === 'hover' || openOn === 'hybrid'\n\t\t\t\t\t\t\t? handleMouseEnter\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\tonMouseLeave:\n\t\t\t\t\t\topenOn === 'hover' || openOn === 'hybrid'\n\t\t\t\t\t\t\t? handleMouseLeave\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t// `??` so a trigger can opt out of the tab order with -1 (or 0 as a string)\n\t\t\t\t\ttabIndex: childProps.tabIndex ?? 0,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tonFocus: childProps.onFocus,\n\t\t\t\t\tonMouseDown: childProps.onMouseDown,\n\t\t\t\t\tonMouseEnter: childProps.onMouseEnter,\n\t\t\t\t\tonMouseLeave: childProps.onMouseLeave,\n\t\t\t\t}\n\t\t\t);\n\t\t\tclonedTrigger = React.cloneElement(child, triggerProps);\n\t\t} else if (child) {\n\t\t\totherChildren.push(child);\n\t\t}\n\t});\n\n\tconst containerStyles: CSSProperties = {\n\t\tdisplay: hasNoTriggerStyles ? undefined : 'inline-block',\n\t\t...style,\n\t};\n\n\treturn (\n\t\t<div\n\t\t\tclassName={classNames(triggerClassName, className) || undefined}\n\t\t\tstyle={containerStyles}\n\t\t\tref={setContainerRef}\n\t\t>\n\t\t\t{clonedTrigger}\n\t\t\t{otherChildren.length > 0 ? otherChildren : null}\n\t\t\t{renderDialog()}\n\t\t</div>\n\t);\n});\n\nPopover.displayName = POPOVER;\n\nexport default Popover;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAkCA,IAAM,IAAkB,OAAO,WAAa,KAGtC,IAAU,IACb,SAAS,cAAc,MAAM,IAC5B,EAAE,OAAO,CAAC,EAAE;AACZ,MACH,EAAQ,MAAM,MAAM,KACpB,EAAQ,MAAM,OAAO,KACrB,EAAQ,MAAM,QAAQ,QACtB,EAAQ,MAAM,SAAS,QACvB,EAAQ,MAAM,WAAW;AAI1B,IAAI,IAMO,MAwQE,IAAyB;CACrC;CACA;CACA;CACA;CACA;CACA;AACD,GAEM,KAA6C,EAClD,aAAa,eACd,GAOM,IAAU,IAA0C,IAAO,MAAQ;CACxE,IAAM,EACL,WAAQ,SACR,eAAe,IACf,mBACA,cACA,SACA,kBACA,qBACA,qBACA,eACA,qBACA,uBACA,cAAW,IACX,YACA,gBACA,6BACA,uBAAmB,IACnB,kBAAc,IACd,yBAAqB,IACrB,yBAAqB,IACrB,YACA,UACA,IAAI,IACJ,QAAQ,IACR,oBAAgB,IAChB,YACA,YACA,YACA,YACA,cACA,iBACA,iBACA,iBACA,WACA,mBACA,mBACA,2BACA,YAAS,SACT,SAAS,GACT,eAAW,YACX,aACA,WACA,iBACA,iBACA,sBACA,aAAU,QACV,sBAAkB,KAClB,iCACG;CAUJ,QAAgB;EACf,IAAA,QAAA,IAAA,aAA6B,cAAc;GAC1C,IAAM,IAAe,EAAkB,EAAY;GAwBnD,AAjBA;IALC;KAAC;KAAqB;KAAmB;IAAiB;IAC1D;KAAC;KAAmB;KAAiB;IAAiB;IACtD;KAAC;KAAe;KAAa;IAAa;IAC1C;KAAC;KAAoB;KAAkB;IAAW;GAEnD,CAAA,CAAa,SAAS,CAAC,GAAS,GAAO,OAAa;IACnD,EACC,GACA,GACA,GACA,GACA,EAAa,CAAO,CACrB;GACD,CAAC,GASD,CAPC;IACC;IACA;IACA;GACD,GACA;IAAC;IAAU;IAAQ,KAAA;GAAS,CAE7B,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;EACtC,SAAS,KAAqB,KAAA,IAAY;EAC1C,GAAG;CACJ;CAEA,OACC,kBAAC,OAAD;EACC,WAAW,EAAW,IAAkB,EAAS,KAAK,KAAA;EACtD,OAAO;EACP,KAAK;EAHN,UAAA;GAKE;GACA,EAAc,SAAS,IAAI,IAAgB;GAC3C,GAAa;EACV;;AAEP,CAAC;AAED,EAAQ,cAAc"}
|
|
1
|
+
{"version":3,"file":"popover.js","names":[],"sources":["../../../../components/popover/popover.tsx"],"sourcesContent":["/* eslint-disable max-lines */\n/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\nimport React, {\n\tforwardRef,\n\tuseEffect,\n\tuseRef,\n\tuseCallback,\n\tuseId,\n\tuseContext,\n\ttype ReactNode,\n\ttype MouseEvent,\n\ttype KeyboardEvent,\n\ttype FocusEvent,\n\ttype CSSProperties,\n} from 'react';\nimport classNames from 'classnames';\n\nimport Button from '../button';\nimport MediaObject from '../media-object';\nimport Icon from '../icon';\nimport Dialog from '../utilities/dialog';\nimport { useClickOutside, useControllableState } from '../../utilities/hooks';\nimport keyboardNavigableDialog from '../../utilities/keyboard-navigable-dialog';\nimport KEYS from '../../utilities/key-code';\nimport { POPOVER } from '../../utilities/constants';\nimport { IconSettingsContext } from '../icon-settings';\nimport deprecatedProperty from '../../utilities/warning/deprecated-property';\nimport sunsetProperty from '../../utilities/warning/sunset-property';\nimport mergeProps from '../../utilities/merge-props';\nimport getComponentDocFn from '../../utilities/get-component-doc';\nimport componentDoc from './component.json';\n\nconst documentDefined = typeof document !== 'undefined';\n\n// Shared overlay element for click-outside detection over iframes\nconst overlay = documentDefined\n\t? document.createElement('span')\n\t: ({ style: {} } as HTMLSpanElement);\nif (documentDefined) {\n\toverlay.style.top = '0';\n\toverlay.style.left = '0';\n\toverlay.style.width = '100%';\n\toverlay.style.height = '100%';\n\toverlay.style.position = 'absolute';\n}\n\n// Track currently open popover for single-popover-at-a-time behavior\nlet currentOpenPopover: {\n\thandleClose: (\n\t\tevent: MouseEvent | KeyboardEvent | undefined,\n\t\tdata: PopoverRequestCloseData\n\t) => void;\n\tgetId: () => string;\n} | null = null;\n\n/**\n * Popover alignment options\n */\nexport type PopoverAlign =\n\t| 'top'\n\t| 'top left'\n\t| 'top right'\n\t| 'right'\n\t| 'right top'\n\t| 'right bottom'\n\t| 'bottom'\n\t| 'bottom left'\n\t| 'bottom right'\n\t| 'left'\n\t| 'left top'\n\t| 'left bottom';\n\n/**\n * Popover position options\n */\nexport type PopoverPosition =\n\t'absolute' | 'overflowBoundaryElement' | 'relative';\n\n/**\n * Popover variant options\n */\nexport type PopoverVariant =\n\t| 'base'\n\t| 'error'\n\t| 'feature'\n\t| 'walkthrough'\n\t| 'walkthrough-action'\n\t| 'warning';\n\n/**\n * Assistive text for Popover\n */\nexport interface PopoverAssistiveText {\n\t/** Label of the close button. Defaults to the English text `Close dialog`. */\n\tcloseButton?: string;\n}\n\n/**\n * What caused `onRequestClose` to fire:\n * * `cancel`: the close button was clicked or Escape was pressed\n * * `clickOutside`: a click landed outside the popover\n * * `mouseLeave`: the mouse left the trigger/popover (`openOn` `hover`/`hybrid`) and `hoverCloseDelay` elapsed\n * * `newPopover`: another Popover opened (only one can be open at a time)\n * * `triggerClick`: the trigger was clicked while the popover was open\n */\nexport type PopoverRequestCloseTrigger =\n\t'cancel' | 'clickOutside' | 'mouseLeave' | 'newPopover' | 'triggerClick';\n\n/**\n * Data passed to `onRequestClose`\n */\nexport interface PopoverRequestCloseData {\n\t/** What caused the close request */\n\ttrigger: PopoverRequestCloseTrigger;\n\t/** HTML id of the popover being closed. Only present when `trigger` is `newPopover`. */\n\tid?: string;\n}\n\n/**\n * What caused `onRequestOpen` to fire:\n * * `focus`: the trigger received focus (`openOn` `hover`)\n * * `mouseEnter`: the mouse entered the trigger (`openOn` `hover`)\n * * `triggerClick`: the trigger was clicked while the popover was closed\n */\nexport type PopoverRequestOpenTrigger = 'focus' | 'mouseEnter' | 'triggerClick';\n\n/**\n * Data passed to `onRequestOpen`\n */\nexport interface PopoverRequestOpenData {\n\t/** What caused the open request */\n\ttrigger: PopoverRequestOpenTrigger;\n}\n\n/**\n * Data passed to `onOpen`\n */\nexport interface PopoverOpenData {\n\t/** The rendered popover dialog element */\n\tportal?: HTMLElement;\n}\n\n/**\n * Data passed to `onClose`\n */\nexport interface PopoverCloseData {\n\t/** `true` when the popover dialog is closing because it is being unmounted */\n\tcomponentWillUnmount: boolean;\n}\n\n/**\n * Props every Popover takes\n */\nexport interface PopoverBaseProps {\n\t/** Alignment relative to trigger */\n\talign?: PopoverAlign;\n\t/** Accessibility labels */\n\tassistiveText?: PopoverAssistiveText;\n\t/**\n\t * The element the popover attaches to (the first child), and optional other children rendered\n\t * beside it. The first child is the trigger: Popover adds `id`, `aria-haspopup`, `tabIndex` and\n\t * its open handlers to it, unless `openOn` is `'none'`, which leaves it as it is.\n\t */\n\tchildren: ReactNode;\n\t/** Popover body content */\n\tbody: ReactNode;\n\t/** CSS classes for the `.slds-popover__body` element */\n\tclassNameBody?: string | string[] | Record<string, boolean>;\n\t/** CSS classes for the `.slds-popover__footer` element */\n\tclassNameFooter?: string | string[] | Record<string, boolean>;\n\t/** @deprecated Use `classNameFooter`. */\n\tfooterClassName?: string | string[] | Record<string, boolean>;\n\t/**\n\t * CSS classes for the root element: the `div` that wraps the trigger. To style the\n\t * `.slds-popover` dialog (for example `slds-popover_large`), use `classNameDialog`.\n\t */\n\tclassName?: string | string[] | Record<string, boolean>;\n\t/** CSS classes for the `.slds-popover` dialog element */\n\tclassNameDialog?: string | string[] | Record<string, boolean>;\n\t/** @deprecated Use `classNameDialog`, which lands on the same element. */\n\tcontentsClassName?: string | string[] | Record<string, boolean>;\n\t/** Disable the popover */\n\tdisabled?: boolean;\n\t/** Footer content */\n\tfooter?: ReactNode;\n\t/** @deprecated Use `styleFooter`. */\n\tfooterStyle?: CSSProperties;\n\t/** Walkthrough footer actions */\n\tfooterWalkthroughActions?: ReactNode | ReactNode[];\n\t/** Hide close button */\n\thasNoCloseButton?: boolean;\n\t/** Hide nubbin/arrow */\n\thasNoNubbin?: boolean;\n\t/** Prevent position flipping */\n\thasStaticAlignment?: boolean;\n\t/** Remove trigger inline-block style */\n\thasNoTriggerStyles?: boolean;\n\t/** HTML id */\n\tid?: string;\n\t/**\n\t * Open state when the popover is controlled. When `isOpen` is set, the popover only opens and closes\n\t * when this prop changes: handle `onRequestOpen` and `onRequestClose` to update it. Leave it\n\t * `undefined` for an uncontrolled popover (see `defaultIsOpen`).\n\t */\n\tisOpen?: boolean;\n\t/** Initial open state of an uncontrolled popover (`isOpen` is `undefined`). Defaults to `false`. */\n\tdefaultIsOpen?: boolean;\n\t/** Click handler */\n\tonClick?: (event: MouseEvent) => void;\n\t/** Called after the popover dialog has closed (unmounted). There is no triggering event, so `event` is `undefined`. */\n\tonClose?: (event: undefined, data: PopoverCloseData) => void;\n\t/** Focus handler */\n\tonFocus?: (event: FocusEvent) => void;\n\t/** Key down handler */\n\tonKeyDown?: (event: KeyboardEvent) => void;\n\t/** Mouse down handler */\n\tonMouseDown?: (event: MouseEvent) => void;\n\t/** Mouse enter handler */\n\tonMouseEnter?: (event: MouseEvent) => void;\n\t/** Mouse leave handler */\n\tonMouseLeave?: (event: MouseEvent) => void;\n\t/** Called after the popover dialog has opened and rendered. There is no triggering event, so `event` is `undefined`. */\n\tonOpen?: (event: undefined, data: PopoverOpenData) => void;\n\t/**\n\t * Called when the popover requests to open (trigger click, or hover/focus with `openOn` `hover`),\n\t * controlled or not. `data.trigger` says why. A controlled popover opens only if the parent sets\n\t * `isOpen` to `true`.\n\t */\n\tonRequestOpen?: (\n\t\tevent: MouseEvent | FocusEvent,\n\t\tdata: PopoverRequestOpenData\n\t) => void;\n\t/**\n\t * Called when the popover requests to close, controlled or not. `data.trigger` says why. `event` is\n\t * the triggering click or key event, or `undefined` when there is none (`mouseLeave` timer,\n\t * `newPopover`). A controlled popover closes only if the parent sets `isOpen` to `false`.\n\t */\n\tonRequestClose?: (\n\t\tevent: MouseEvent | KeyboardEvent | undefined,\n\t\tdata: PopoverRequestCloseData\n\t) => void;\n\t/** Custom target element getter */\n\tonRequestTargetElement?: () => HTMLElement | null;\n\t/**\n\t * What on the first child opens the popover: `click` (the default), `hover`, or `hybrid` (click\n\t * or hover). `none` makes the first child only an anchor that the popover points at, such as\n\t * the target of a walkthrough step: Popover leaves its markup and handlers alone, and the\n\t * parent opens and closes the popover through `isOpen`.\n\t */\n\topenOn?: 'click' | 'hover' | 'hybrid' | 'none';\n\t/** Overlay for click-outside on iframes */\n\toverlay?:\n\t\tboolean | ((isOpen: boolean, overlayElement: HTMLSpanElement) => void);\n\t/** Positioning strategy */\n\tposition?: PopoverPosition;\n\t/** Walkthrough step text */\n\tstepText?: string;\n\t/** Styles for the root element: the `div` that wraps the trigger. To style the dialog, use `styleDialog`. */\n\tstyle?: CSSProperties;\n\t/** Styles for the `.slds-popover` dialog element */\n\tstyleDialog?: CSSProperties;\n\t/** Styles for the `.slds-popover__footer` element */\n\tstyleFooter?: CSSProperties;\n\t/** @deprecated Use `className`, which lands on the same element. */\n\ttriggerClassName?: string | string[] | Record<string, boolean>;\n\t/** Delay before closing on hover (ms) */\n\thoverCloseDelay?: number;\n}\n\n/** The `feature` variant, the only one with an `icon`. */\ninterface PopoverFeatureVariantProps {\n\t/** Popover variant */\n\tvariant: 'feature';\n\t/** Icon for the feature variant */\n\ticon?: ReactNode;\n}\n\n/** Every other variant. */\ninterface PopoverOtherVariantProps {\n\t/** Popover variant */\n\tvariant?: Exclude<PopoverVariant, 'feature'>;\n\ticon?: never;\n}\n\n/**\n * The dialog is named by `heading`, or by the `id` of another element in\n * `ariaLabelledby`, not both.\n */\nexport type PopoverLabelProps =\n\t| {\n\t\t\t/** Popover heading */\n\t\t\theading?: ReactNode;\n\t\t\tariaLabelledby?: never;\n\t }\n\t| {\n\t\t\theading?: never;\n\t\t\t/** HTML id of the heading element that labels the dialog. Use instead of `heading`. */\n\t\t\tariaLabelledby: string;\n\t };\n\n/**\n * Props for the Popover component: `icon` is feature-only, and `heading`\n * and `ariaLabelledby` are exclusive.\n */\nexport type PopoverProps = PopoverBaseProps &\n\t(PopoverFeatureVariantProps | PopoverOtherVariantProps) &\n\tPopoverLabelProps;\n\n/**\n * Props removed from the public API. Still destructured so they never reach\n * the DOM, and reported on mount.\n */\ninterface PopoverRemovedProps {\n\tcloseButtonAssistiveText?: unknown;\n\toffset?: unknown;\n}\n\n// Nubbin positions for export (legacy)\nexport const PopoverNubbinPositions = [\n\t'top left',\n\t'top',\n\t'top right',\n\t'bottom left',\n\t'bottom',\n\t'bottom right',\n];\n\nconst defaultAssistiveText: PopoverAssistiveText = {\n\tcloseButton: 'Close dialog',\n};\n\n/**\n * The Popover component is a non-modal dialog. It should be paired with a clickable\n * trigger such as a Button. It traps focus from the page and must be exited if focus\n * needs to be outside the Popover.\n */\nconst Popover = forwardRef<HTMLDivElement, PopoverProps>((props, ref) => {\n\tconst {\n\t\talign = 'right',\n\t\tassistiveText: propAssistiveText,\n\t\tariaLabelledby,\n\t\tchildren,\n\t\tbody,\n\t\tclassNameBody,\n\t\tclassNameFooter,\n\t\tfooterClassName,\n\t\tclassName,\n\t\tclassNameDialog,\n\t\tcontentsClassName,\n\t\tdisabled = false,\n\t\tfooter,\n\t\tfooterStyle,\n\t\tfooterWalkthroughActions,\n\t\thasNoCloseButton = false,\n\t\thasNoNubbin = false,\n\t\thasStaticAlignment = false,\n\t\thasNoTriggerStyles = false,\n\t\theading,\n\t\ticon,\n\t\tid: propId,\n\t\tisOpen: controlledIsOpen,\n\t\tdefaultIsOpen = false,\n\t\toffset,\n\t\tonClick,\n\t\tonClose,\n\t\tonFocus,\n\t\tonKeyDown,\n\t\tonMouseDown,\n\t\tonMouseEnter,\n\t\tonMouseLeave,\n\t\tonOpen,\n\t\tonRequestOpen,\n\t\tonRequestClose,\n\t\tonRequestTargetElement,\n\t\topenOn = 'click',\n\t\toverlay: overlayProp,\n\t\tposition = 'absolute',\n\t\tstepText,\n\t\tstyle,\n\t\tstyleDialog,\n\t\tstyleFooter,\n\t\ttriggerClassName,\n\t\tvariant = 'base',\n\t\thoverCloseDelay = 300,\n\t\tcloseButtonAssistiveText,\n\t} = props as PopoverBaseProps &\n\t\tPopoverRemovedProps & {\n\t\t\tariaLabelledby?: string;\n\t\t\theading?: ReactNode;\n\t\t\ticon?: ReactNode;\n\t\t\tvariant?: PopoverVariant;\n\t\t};\n\n\t// `check-props.js` is not wired up (its trigger and heading checks predate v11), so the\n\t// renamed and removed props are checked here.\n\tuseEffect(() => {\n\t\tif (process.env.NODE_ENV !== 'production') {\n\t\t\tconst createDocUrl = getComponentDocFn(componentDoc);\n\t\t\tconst renamedProps: [string, unknown, string][] = [\n\t\t\t\t['contentsClassName', contentsClassName, 'classNameDialog'],\n\t\t\t\t['footerClassName', footerClassName, 'classNameFooter'],\n\t\t\t\t['footerStyle', footerStyle, 'styleFooter'],\n\t\t\t\t['triggerClassName', triggerClassName, 'className'],\n\t\t\t];\n\t\t\trenamedProps.forEach(([oldProp, value, newProp]) => {\n\t\t\t\tdeprecatedProperty(\n\t\t\t\t\tPOPOVER,\n\t\t\t\t\tvalue,\n\t\t\t\t\toldProp,\n\t\t\t\t\tnewProp,\n\t\t\t\t\tcreateDocUrl(newProp)\n\t\t\t\t);\n\t\t\t});\n\t\t\tconst removedProps: [string, unknown, string | undefined][] = [\n\t\t\t\t[\n\t\t\t\t\t'closeButtonAssistiveText',\n\t\t\t\t\tcloseButtonAssistiveText,\n\t\t\t\t\t\"Use `assistiveText={{ closeButton: '...' }}` instead.\",\n\t\t\t\t],\n\t\t\t\t['offset', offset, undefined],\n\t\t\t];\n\t\t\tremovedProps.forEach(([oldProp, value, comment]) => {\n\t\t\t\tsunsetProperty(POPOVER, value, oldProp, comment);\n\t\t\t});\n\t\t}\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, []); // Only run on mount\n\n\tconst generatedId = useId();\n\tconst id = propId || generatedId;\n\tconst context = useContext(IconSettingsContext);\n\n\tconst assistiveText = { ...defaultAssistiveText, ...propAssistiveText };\n\n\t// State\n\tconst [currentIsOpen, setIsOpen] = useControllableState(\n\t\tcontrolledIsOpen,\n\t\tdefaultIsOpen\n\t);\n\n\t// Refs\n\tconst triggerRef = useRef<HTMLDivElement>(null);\n\tconst dialogRef = useRef<HTMLElement>(null);\n\tconst isHoverRef = useRef(false);\n\tconst isClosingRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\tconst overlayRef = useRef<HTMLSpanElement | null>(null);\n\tconst isUnmountingRef = useRef(false);\n\n\t// Derived state\n\tconst isOpen = !disabled && currentIsOpen;\n\n\t// Get target element for positioning\n\tconst getTargetElement = useCallback(() => {\n\t\tif (onRequestTargetElement) {\n\t\t\tconst target = onRequestTargetElement();\n\t\t\tif (target) return target;\n\t\t}\n\t\treturn triggerRef.current;\n\t}, [onRequestTargetElement]);\n\n\t// Handle dialog close (when unmounted)\n\tconst handleDialogClose = useCallback(\n\t\t(\n\t\t\t_event?: React.SyntheticEvent,\n\t\t\tdata?: { componentWillUnmount?: boolean }\n\t\t) => {\n\t\t\tconst componentWillUnmount = data?.componentWillUnmount || false;\n\n\t\t\tif (currentOpenPopover?.getId() === id) {\n\t\t\t\tcurrentOpenPopover = null;\n\t\t\t}\n\n\t\t\tif (onClose) {\n\t\t\t\tonClose(undefined, { componentWillUnmount });\n\t\t\t}\n\t\t},\n\t\t[id, onClose]\n\t);\n\n\t// Handle dialog open (after it has rendered)\n\tconst handleDialogOpen = useCallback(\n\t\t(_event?: unknown, data?: { portal?: HTMLElement }) => {\n\t\t\tif (onOpen) {\n\t\t\t\tonOpen(undefined, { portal: data?.portal });\n\t\t\t}\n\t\t},\n\t\t[onOpen]\n\t);\n\n\t// Handle close\n\tconst handleClose = useCallback(\n\t\t(\n\t\t\tevent: MouseEvent | KeyboardEvent | undefined,\n\t\t\tdata: PopoverRequestCloseData\n\t\t) => {\n\t\t\tif (isOpen) {\n\t\t\t\tif (onRequestClose) {\n\t\t\t\t\tonRequestClose(event, data);\n\t\t\t\t}\n\n\t\t\t\tif (currentOpenPopover?.getId() === id) {\n\t\t\t\t\tcurrentOpenPopover = null;\n\t\t\t\t}\n\n\t\t\t\tsetIsOpen(false);\n\t\t\t\tisHoverRef.current = false;\n\t\t\t}\n\t\t},\n\t\t[isOpen, id, onRequestClose, setIsOpen]\n\t);\n\n\t// Latest `handleClose`, so the \"close the other open popover\" path does not call a stale\n\t// closure from when this popover opened (whose `isOpen` was still `false`).\n\tconst handleCloseRef = useRef(handleClose);\n\tuseEffect(() => {\n\t\thandleCloseRef.current = handleClose;\n\t}, [handleClose]);\n\n\t// Handle open\n\tconst handleOpen = useCallback(\n\t\t(event: MouseEvent | FocusEvent, trigger: PopoverRequestOpenTrigger) => {\n\t\t\tif (!isOpen && !disabled) {\n\t\t\t\tonRequestOpen?.(event, { trigger });\n\n\t\t\t\t// Close any other open popover\n\t\t\t\tif (currentOpenPopover && currentOpenPopover.getId() !== id) {\n\t\t\t\t\tcurrentOpenPopover.handleClose(undefined, {\n\t\t\t\t\t\ttrigger: 'newPopover',\n\t\t\t\t\t\tid: currentOpenPopover.getId(),\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tcurrentOpenPopover = {\n\t\t\t\t\thandleClose: (event, data) => handleCloseRef.current(event, data),\n\t\t\t\t\tgetId: () => id,\n\t\t\t\t};\n\n\t\t\t\tsetIsOpen(true);\n\t\t\t}\n\t\t},\n\t\t[isOpen, disabled, id, onRequestOpen, setIsOpen]\n\t);\n\n\t// Handle cancel (close button or escape)\n\tconst handleCancel = useCallback(\n\t\t(event: MouseEvent | KeyboardEvent) => {\n\t\t\thandleClose(event, { trigger: 'cancel' });\n\t\t},\n\t\t[handleClose]\n\t);\n\n\t// Request a close on a mousedown outside the popover. The container holds the trigger\n\t// and an inline dialog; a dialog in a portal carries the ignore class instead.\n\tconst handleClickOutside = useCallback(\n\t\t(event: globalThis.MouseEvent | TouchEvent) => {\n\t\t\thandleClose(event as unknown as MouseEvent, { trigger: 'clickOutside' });\n\t\t},\n\t\t[handleClose]\n\t);\n\tuseClickOutside(triggerRef, handleClickOutside, {\n\t\tenabled: isOpen,\n\t\tignoreClass: `ignore-click-${id}`,\n\t});\n\n\t// Handle mouse enter\n\tconst handleMouseEnter = useCallback(\n\t\t(event: MouseEvent) => {\n\t\t\tisHoverRef.current = true;\n\n\t\t\tif (!isOpen && openOn === 'hover') {\n\t\t\t\thandleOpen(event, 'mouseEnter');\n\t\t\t} else {\n\t\t\t\tif (isClosingRef.current) {\n\t\t\t\t\tclearTimeout(isClosingRef.current);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (onMouseEnter) {\n\t\t\t\tonMouseEnter(event);\n\t\t\t}\n\t\t},\n\t\t[isOpen, openOn, handleOpen, onMouseEnter]\n\t);\n\n\t// Handle mouse leave\n\tconst handleMouseLeave = useCallback(\n\t\t(event: MouseEvent) => {\n\t\t\tif (isOpen) {\n\t\t\t\tisClosingRef.current = setTimeout(() => {\n\t\t\t\t\thandleClose(undefined, { trigger: 'mouseLeave' });\n\t\t\t\t}, hoverCloseDelay);\n\t\t\t}\n\n\t\t\tif (onMouseLeave) {\n\t\t\t\tonMouseLeave(event);\n\t\t\t}\n\t\t},\n\t\t[isOpen, hoverCloseDelay, handleClose, onMouseLeave]\n\t);\n\n\t// Handle click\n\tconst handleClick = useCallback(\n\t\t(event: MouseEvent, triggerOnClickCallback?: (e: MouseEvent) => void) => {\n\t\t\tif (!isOpen) {\n\t\t\t\thandleOpen(event, 'triggerClick');\n\t\t\t} else {\n\t\t\t\thandleClose(event, { trigger: 'triggerClick' });\n\t\t\t}\n\n\t\t\tif (onClick) {\n\t\t\t\tonClick(event);\n\t\t\t}\n\n\t\t\tif (triggerOnClickCallback) {\n\t\t\t\ttriggerOnClickCallback(event);\n\t\t\t}\n\t\t},\n\t\t[isOpen, handleOpen, handleClose, onClick]\n\t);\n\n\t// Handle focus\n\tconst handleFocus = useCallback(\n\t\t(event: FocusEvent) => {\n\t\t\tif (!isOpen) {\n\t\t\t\thandleOpen(event, 'focus');\n\t\t\t}\n\n\t\t\tif (onFocus) {\n\t\t\t\tonFocus(event);\n\t\t\t}\n\t\t},\n\t\t[isOpen, handleOpen, onFocus]\n\t);\n\n\t// Toggle from keyboard\n\t// `handleKeyDown` is only attached to the open dialog, so this only ever closes it (Escape).\n\tconst toggleOpenFromKeyboard = useCallback(\n\t\t(event: KeyboardEvent) => {\n\t\t\tif (isOpen) {\n\t\t\t\thandleCancel(event);\n\t\t\t}\n\t\t},\n\t\t[isOpen, handleCancel]\n\t);\n\n\t// Handle key down\n\tconst handleKeyDown = useCallback(\n\t\t(event: KeyboardEvent) => {\n\t\t\tif (event.key) {\n\t\t\t\tif (event.key !== KEYS.TAB) {\n\t\t\t\t\tkeyboardNavigableDialog({\n\t\t\t\t\t\tevent,\n\t\t\t\t\t\tisOpen,\n\t\t\t\t\t\thandleClick: (e: MouseEvent) => handleClick(e),\n\t\t\t\t\t\tkey: event.key,\n\t\t\t\t\t\teventTarget: event.target,\n\t\t\t\t\t\t// keyboardNavigableDialog calls `toggleOpen()` without the event; pass it through\n\t\t\t\t\t\ttoggleOpen: () => toggleOpenFromKeyboard(event),\n\t\t\t\t\t\ttrigger: triggerRef.current,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (onKeyDown) {\n\t\t\t\t\tonKeyDown(event);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t[isOpen, handleClick, toggleOpenFromKeyboard, onKeyDown]\n\t);\n\n\t// Render overlay for click-outside detection\n\tconst renderOverlay = useCallback(\n\t\t(shouldShow: boolean) => {\n\t\t\tif (typeof overlayProp === 'function' && documentDefined) {\n\t\t\t\toverlayProp(shouldShow, overlay);\n\t\t\t} else if (\n\t\t\t\toverlayProp &&\n\t\t\t\tshouldShow &&\n\t\t\t\t!overlayRef.current &&\n\t\t\t\tdocumentDefined\n\t\t\t) {\n\t\t\t\toverlayRef.current = overlay;\n\t\t\t\tdocument.querySelector('body')?.appendChild(overlay);\n\t\t\t} else if (!shouldShow && overlayRef.current?.parentNode) {\n\t\t\t\toverlayRef.current.parentNode.removeChild(overlayRef.current);\n\t\t\t\toverlayRef.current = null;\n\t\t\t}\n\t\t},\n\t\t[overlayProp]\n\t);\n\n\t// Container ref callback\n\tconst setContainerRef = useCallback(\n\t\t(component: HTMLDivElement | null) => {\n\t\t\t(triggerRef as React.RefObject<HTMLDivElement | null>).current =\n\t\t\t\tcomponent;\n\t\t\tif (typeof ref === 'function') {\n\t\t\t\tref(component);\n\t\t\t} else if (ref) {\n\t\t\t\tref.current = component;\n\t\t\t}\n\t\t},\n\t\t[ref]\n\t);\n\n\t// Dialog ref callback\n\tconst setMenuRef = useCallback((component: HTMLElement | null) => {\n\t\t(dialogRef as React.RefObject<HTMLElement | null>).current = component;\n\t}, []);\n\n\t// Cleanup on unmount\n\tuseEffect(() => {\n\t\treturn () => {\n\t\t\tisUnmountingRef.current = true;\n\t\t\tif (currentOpenPopover?.getId() === id) {\n\t\t\t\tcurrentOpenPopover = null;\n\t\t\t}\n\t\t\trenderOverlay(false);\n\t\t};\n\t}, [id, renderOverlay]);\n\n\t// Update overlay when isOpen changes\n\tuseEffect(() => {\n\t\trenderOverlay(isOpen);\n\t}, [isOpen, renderOverlay]);\n\n\t// Render header\n\tconst renderHeader = () => {\n\t\tconst hasThemedHeader = variant === 'error' || variant === 'warning';\n\t\tconst hasDefinedHeader = heading || hasThemedHeader;\n\n\t\tif (\n\t\t\t!hasDefinedHeader ||\n\t\t\tvariant === 'walkthrough-action' ||\n\t\t\tvariant === 'feature'\n\t\t) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst headerIcon = {\n\t\t\terror: <Icon category=\"utility\" name=\"error\" size=\"x-small\" inverse />,\n\t\t\twarning: (\n\t\t\t\t<Icon category=\"utility\" name=\"warning\" size=\"x-small\" inverse />\n\t\t\t),\n\t\t};\n\n\t\tif (hasThemedHeader) {\n\t\t\treturn (\n\t\t\t\t<header className=\"slds-popover__header\">\n\t\t\t\t\t<MediaObject\n\t\t\t\t\t\tbody={\n\t\t\t\t\t\t\t<h2\n\t\t\t\t\t\t\t\tid={ariaLabelledby || `${id}-dialog-heading`}\n\t\t\t\t\t\t\t\tclassName=\"slds-truncate slds-text-heading_medium\"\n\t\t\t\t\t\t\t\ttitle={typeof heading === 'string' ? heading : undefined}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{heading}\n\t\t\t\t\t\t\t</h2>\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfigure={headerIcon[variant as 'error' | 'warning']}\n\t\t\t\t\t\tverticalCenter\n\t\t\t\t\t/>\n\t\t\t\t</header>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<header\n\t\t\t\tclassName={classNames('slds-popover__header', {\n\t\t\t\t\t'slds-p-vertical_medium': variant === 'walkthrough',\n\t\t\t\t})}\n\t\t\t>\n\t\t\t\t<h2\n\t\t\t\t\tid={ariaLabelledby || `${id}-dialog-heading`}\n\t\t\t\t\tclassName={classNames({\n\t\t\t\t\t\t'slds-text-heading_small': variant !== 'walkthrough',\n\t\t\t\t\t\t'slds-text-heading_medium': variant === 'walkthrough',\n\t\t\t\t\t})}\n\t\t\t\t>\n\t\t\t\t\t{heading}\n\t\t\t\t</h2>\n\t\t\t</header>\n\t\t);\n\t};\n\n\t// Render body\n\tconst renderBody = () => {\n\t\tif (variant === 'error' || variant === 'warning') {\n\t\t\treturn (\n\t\t\t\t<div\n\t\t\t\t\tid={`${id}-dialog-body`}\n\t\t\t\t\tclassName={classNames('slds-popover__body', classNameBody as string)}\n\t\t\t\t>\n\t\t\t\t\t{body}\n\t\t\t\t</div>\n\t\t\t);\n\t\t}\n\n\t\tif (variant === 'walkthrough-action' || variant === 'feature') {\n\t\t\treturn (\n\t\t\t\t<div\n\t\t\t\t\tclassName={classNames('slds-popover__body', classNameBody as string)}\n\t\t\t\t\tid={`${id}-dialog-body`}\n\t\t\t\t>\n\t\t\t\t\t<div className=\"slds-media\">\n\t\t\t\t\t\t<div className=\"slds-media__figure\">\n\t\t\t\t\t\t\t{variant === 'walkthrough-action' ? (\n\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\tcategory=\"utility\"\n\t\t\t\t\t\t\t\t\tname=\"touch_action\"\n\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\tinverse\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\ticon\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div className=\"slds-media__body\">\n\t\t\t\t\t\t\t{heading && (\n\t\t\t\t\t\t\t\t<h2\n\t\t\t\t\t\t\t\t\tid={ariaLabelledby || `${id}-dialog-heading`}\n\t\t\t\t\t\t\t\t\tclassName=\"slds-text-heading_small\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{heading}\n\t\t\t\t\t\t\t\t</h2>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t{body}\n\t\t\t\t\t\t\t{stepText && (\n\t\t\t\t\t\t\t\t<p className=\"slds-m-top_medium slds-text-title\">{stepText}</p>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tid={`${id}-dialog-body`}\n\t\t\t\tclassName={classNames('slds-popover__body', classNameBody as string)}\n\t\t\t>\n\t\t\t\t{body}\n\t\t\t</div>\n\t\t);\n\t};\n\n\t// Render footer\n\tconst renderFooter = () => {\n\t\tconst footerClassNames = classNames(\n\t\t\t'slds-popover__footer',\n\t\t\tfooterClassName,\n\t\t\tclassNameFooter\n\t\t);\n\t\tconst footerStyles =\n\t\t\tfooterStyle || styleFooter\n\t\t\t\t? { ...footerStyle, ...styleFooter }\n\t\t\t\t: undefined;\n\n\t\tif (footer) {\n\t\t\treturn (\n\t\t\t\t<footer className={footerClassNames} style={footerStyles}>\n\t\t\t\t\t{footer}\n\t\t\t\t</footer>\n\t\t\t);\n\t\t}\n\n\t\tif (\n\t\t\tvariant !== 'walkthrough-action' &&\n\t\t\t(footerWalkthroughActions || stepText)\n\t\t) {\n\t\t\treturn (\n\t\t\t\t<footer className={footerClassNames} style={footerStyles}>\n\t\t\t\t\t<div className=\"slds-grid slds-grid_vertical-align-center\">\n\t\t\t\t\t\t{stepText && <span className=\"slds-text-title\">{stepText}</span>}\n\t\t\t\t\t\t{footerWalkthroughActions && (\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tclassName=\"slds-col_bump-left\"\n\t\t\t\t\t\t\t\tstyle={{ display: 'inline-block' }}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{footerWalkthroughActions}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</div>\n\t\t\t\t</footer>\n\t\t\t);\n\t\t}\n\n\t\treturn null;\n\t};\n\n\t// Render dialog\n\tconst renderDialog = () => {\n\t\tif (!isOpen) return null;\n\n\t\tconst outsideClickIgnoreClass = `ignore-click-${id}`;\n\n\t\treturn (\n\t\t\t<Dialog\n\t\t\t\thasNubbin={!hasNoNubbin}\n\t\t\t\talign={align}\n\t\t\t\tcontentsClassName={classNames(\n\t\t\t\t\tcontentsClassName,\n\t\t\t\t\t'ignore-react-onclickoutside',\n\t\t\t\t\t'slds-popover',\n\t\t\t\t\t{ 'slds-popover_error': variant === 'error' },\n\t\t\t\t\t{\n\t\t\t\t\t\t'slds-popover_walkthrough':\n\t\t\t\t\t\t\tvariant === 'walkthrough' ||\n\t\t\t\t\t\t\tvariant === 'walkthrough-action' ||\n\t\t\t\t\t\t\tvariant === 'feature',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t'slds-popover_walkthrough-alt': variant === 'walkthrough-action',\n\t\t\t\t\t},\n\t\t\t\t\t{ 'slds-popover_feature': variant === 'feature' },\n\t\t\t\t\t{ 'slds-popover_warning': variant === 'warning' },\n\t\t\t\t\tclassNameDialog\n\t\t\t\t)}\n\t\t\t\tcontext={context}\n\t\t\t\thasStaticAlignment={hasStaticAlignment}\n\t\t\t\tonClose={handleDialogClose}\n\t\t\t\tonOpen={handleDialogOpen}\n\t\t\t\tonKeyDown={handleKeyDown}\n\t\t\t\tonMouseEnter={openOn === 'hover' ? handleMouseEnter : undefined}\n\t\t\t\tonMouseLeave={openOn === 'hover' ? handleMouseLeave : undefined}\n\t\t\t\toutsideClickIgnoreClass={outsideClickIgnoreClass}\n\t\t\t\tonRequestTargetElement={getTargetElement}\n\t\t\t\tposition={position}\n\t\t\t\tstyle={styleDialog}\n\t\t\t\tvariant=\"popover\"\n\t\t\t\tref={setMenuRef}\n\t\t\t\tcontainerProps={{\n\t\t\t\t\tid: `${id}-popover`,\n\t\t\t\t\t'aria-labelledby': ariaLabelledby || `${id}-dialog-heading`,\n\t\t\t\t\t'aria-describedby': `${id}-dialog-body`,\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{!hasNoCloseButton && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tassistiveText={{ icon: assistiveText.closeButton }}\n\t\t\t\t\t\ticonCategory=\"utility\"\n\t\t\t\t\t\ticonName=\"close\"\n\t\t\t\t\t\tclassName={classNames(\n\t\t\t\t\t\t\t'slds-button slds-button_icon-small slds-float_right slds-popover__close slds-button_icon',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'slds-button_icon-inverse':\n\t\t\t\t\t\t\t\t\tvariant === 'walkthrough' ||\n\t\t\t\t\t\t\t\t\tvariant === 'walkthrough-action' ||\n\t\t\t\t\t\t\t\t\tvariant === 'feature',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t)}\n\t\t\t\t\t\tonClick={handleCancel}\n\t\t\t\t\t\tvariant=\"icon\"\n\t\t\t\t\t\tinverse={variant === 'error' || variant === 'warning'}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t\t{renderHeader()}\n\t\t\t\t{renderBody()}\n\t\t\t\t{renderFooter()}\n\t\t\t</Dialog>\n\t\t);\n\t};\n\n\t// Clone trigger element\n\tconst otherChildren: ReactNode[] = [];\n\tlet clonedTrigger: ReactNode = null;\n\n\tReact.Children.forEach(children, (child, index) => {\n\t\tif (index === 0 && openOn === 'none') {\n\t\t\t// An anchor only: the popover is positioned against it, nothing more\n\t\t\tclonedTrigger = child;\n\t\t} else if (index === 0 && React.isValidElement(child)) {\n\t\t\tconst childProps = child.props as Record<string, unknown>;\n\t\t\t// The trigger's own handlers run alongside the popover's instead of being replaced.\n\t\t\t// `onClick` already calls the trigger's after the popover's (see `handleClick`).\n\t\t\tconst childOnClick = childProps.onClick;\n\t\t\tconst triggerProps = mergeProps(\n\t\t\t\t{\n\t\t\t\t\t'aria-haspopup': 'dialog',\n\t\t\t\t\tid,\n\t\t\t\t\tonClick:\n\t\t\t\t\t\topenOn === 'click' || openOn === 'hybrid'\n\t\t\t\t\t\t\t? (event: MouseEvent) => {\n\t\t\t\t\t\t\t\t\thandleClick(event, childOnClick as (e: MouseEvent) => void);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: childOnClick,\n\t\t\t\t\tonFocus: openOn === 'hover' ? handleFocus : undefined,\n\t\t\t\t\tonMouseDown,\n\t\t\t\t\tonMouseEnter:\n\t\t\t\t\t\topenOn === 'hover' || openOn === 'hybrid'\n\t\t\t\t\t\t\t? handleMouseEnter\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\tonMouseLeave:\n\t\t\t\t\t\topenOn === 'hover' || openOn === 'hybrid'\n\t\t\t\t\t\t\t? handleMouseLeave\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t// `??` so a trigger can opt out of the tab order with -1 (or 0 as a string)\n\t\t\t\t\ttabIndex: childProps.tabIndex ?? 0,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tonFocus: childProps.onFocus,\n\t\t\t\t\tonMouseDown: childProps.onMouseDown,\n\t\t\t\t\tonMouseEnter: childProps.onMouseEnter,\n\t\t\t\t\tonMouseLeave: childProps.onMouseLeave,\n\t\t\t\t}\n\t\t\t);\n\t\t\tclonedTrigger = React.cloneElement(child, triggerProps);\n\t\t} else if (child) {\n\t\t\totherChildren.push(child);\n\t\t}\n\t});\n\n\tconst containerStyles: CSSProperties = {\n\t\tdisplay: hasNoTriggerStyles ? undefined : 'inline-block',\n\t\t...style,\n\t};\n\n\treturn (\n\t\t<div\n\t\t\tclassName={classNames(triggerClassName, className) || undefined}\n\t\t\tstyle={containerStyles}\n\t\t\tref={setContainerRef}\n\t\t>\n\t\t\t{clonedTrigger}\n\t\t\t{otherChildren.length > 0 ? otherChildren : null}\n\t\t\t{renderDialog()}\n\t\t</div>\n\t);\n});\n\nPopover.displayName = POPOVER;\n\nexport default Popover;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAkCA,IAAM,IAAkB,OAAO,WAAa,KAGtC,IAAU,IACb,SAAS,cAAc,MAAM,IAC5B,EAAE,OAAO,CAAC,EAAE;AACZ,MACH,EAAQ,MAAM,MAAM,KACpB,EAAQ,MAAM,OAAO,KACrB,EAAQ,MAAM,QAAQ,QACtB,EAAQ,MAAM,SAAS,QACvB,EAAQ,MAAM,WAAW;AAI1B,IAAI,IAMO,MAyQE,IAAyB;CACrC;CACA;CACA;CACA;CACA;CACA;AACD,GAEM,KAA6C,EAClD,aAAa,eACd,GAOM,IAAU,IAA0C,IAAO,MAAQ;CACxE,IAAM,EACL,WAAQ,SACR,eAAe,IACf,mBACA,cACA,SACA,kBACA,qBACA,qBACA,eACA,qBACA,uBACA,cAAW,IACX,YACA,gBACA,6BACA,uBAAmB,IACnB,kBAAc,IACd,yBAAqB,IACrB,yBAAqB,IACrB,YACA,UACA,IAAI,IACJ,QAAQ,IACR,oBAAgB,IAChB,YACA,YACA,YACA,YACA,c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EAAM,eAAe,CAAK,GAAG;GACtD,IAAM,IAAa,EAAM,OAGnB,IAAe,EAAW,SAC1B,IAAe,GACpB;IACC,iBAAiB;IACjB;IACA,SACC,MAAW,WAAW,MAAW,YAC7B,MAAsB;KACvB,EAAY,GAAO,CAAuC;IAC3D,IACC;IACJ,SAAS,MAAW,UAAU,KAAc,KAAA;IAC5C;IACA,cACC,MAAW,WAAW,MAAW,WAC9B,IACA,KAAA;IACJ,cACC,MAAW,WAAW,MAAW,WAC9B,KACA,KAAA;IAEJ,UAAU,EAAW,YAAY;GAClC,GACA;IACC,SAAS,EAAW;IACpB,aAAa,EAAW;IACxB,cAAc,EAAW;IACzB,cAAc,EAAW;GAC1B,CACD;GACA,IAAgB,EAAM,aAAa,GAAO,CAAY;EACvD,OAAO,AAAI,KACV,EAAc,KAAK,CAAK;CAE1B,CAAC;CAED,IAAM,KAAiC;EACtC,SAAS,KAAqB,KAAA,IAAY;EAC1C,GAAG;CACJ;CAEA,OACC,kBAAC,OAAD;EACC,WAAW,EAAW,IAAkB,EAAS,KAAK,KAAA;EACtD,OAAO;EACP,KAAK;EAHN,UAAA;GAKE;GACA,EAAc,SAAS,IAAI,IAAgB;GAC3C,GAAa;EACV;;AAEP,CAAC;AAED,EAAQ,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../components/progress-indicator/index.tsx"],"sourcesContent":["/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\nimport React, {\n\tuseCallback,\n\tuseEffect,\n\tuseId,\n\tuseMemo,\n\ttype ReactNode,\n} from 'react';\nimport { PROGRESS_INDICATOR } from '../../utilities/constants';\nimport componentDoc from './component.json';\n\n// Child components\nimport Step from './private/step';\nimport Progress from './private/progress';\nimport StepVertical from './private/step-vertical';\nimport Path from './private/path';\n\n// This component's `checkProps` which issues warnings to developers about properties when in development mode\nimport checkProps from './check-props';\n\n/**\n * Progress indicator orientation\n */\nexport type ProgressIndicatorOrientation = 'horizontal' | 'vertical';\n\n/**\n * Progress indicator type\n */\nexport type ProgressIndicatorType = 'base' | 'path';\n\n/**\n * Progress indicator variant\n */\nexport type ProgressIndicatorVariant =\n\t'base' | 'modal' | 'setup-assistant' | 'shade';\n\n/**\n * Tooltip position\n */\nexport type TooltipPosition =\n\t'absolute' | 'overflowBoundaryElement' | 'relative';\n\n/**\n * Status of a single step. A step has at most one status.\n */\nexport type ProgressStepStatus = 'completed' | 'disabled' | 'error';\n\n/**\n * Step object structure\n */\nexport interface ProgressStep {\n\t/** Unique identifier. Steps are matched by `id`. */\n\tid: string | number;\n\t/**\n\t * Status of the step. A step has one status, so it cannot be both `error` and `completed`.\n\t * `disabled` and `error` apply to `type=\"base\"` only; `type=\"path\"` shows `completed`.\n\t */\n\tstatus?: ProgressStepStatus;\n\t/** Tooltip label */\n\tlabel: string;\n\t/** Optional assistive text override */\n\tassistiveText?: string;\n\t/** Action shown next to the step label. Only used by the `setup-assistant` variant. */\n\tsetupAssistantAction?: ReactNode;\n\t/** Estimated time shown next to the step label. Only used by the `setup-assistant` variant. */\n\tsetupAssistantEstimatedTime?: ReactNode;\n\t/** @deprecated Use `setupAssistantAction` instead. */\n\tonRenderSetupAssistantAction?: ReactNode;\n}\n\n/**\n * Assistive text for ProgressIndicator\n */\nexport interface ProgressIndicatorAssistiveText {\n\t/** `type=\"path\"` only: read before a completed stage's name. Defaults to `Stage Complete` */\n\tcompletedStage?: string;\n\t/** Label for completed steps */\n\tcompletedStep?: string;\n\t/** `type=\"path\"` only: read before the current stage's name. Defaults to `Current Stage:` */\n\tcurrentStage?: string;\n\t/** Label for disabled steps */\n\tdisabledStep?: string;\n\t/** Label for error steps */\n\terrorStep?: string;\n\t/** Label for progress percentage */\n\tpercentage?: string;\n\t/** Label prefix for steps */\n\tstep?: string;\n}\n\n/**\n * Text labels for ProgressIndicator\n */\nexport interface ProgressIndicatorLabels {\n\t/** `type=\"path\"` only: text before the current stage's name, which shows when the path collapses on narrow screens. Include any spacing between it and the name. Defaults to `Stage: ` */\n\tstageNameBefore?: React.ReactNode;\n\t/** `type=\"path\"` only: text after the current stage's name. Include any spacing between it and the name. */\n\tstageNameAfter?: React.ReactNode;\n}\n\n/**\n * Step event data\n */\nexport interface StepEventData {\n\tisCompleted: boolean;\n\tisDisabled: boolean;\n\tisError: boolean;\n\tisSelected: boolean;\n\tstep: ProgressStep;\n}\n\n/** Props every ProgressIndicator takes. */\ninterface ProgressIndicatorBaseProps {\n\t/** Assistive text for accessibility */\n\tassistiveText?: ProgressIndicatorAssistiveText;\n\t/** CSS classes */\n\tclassName?: string | string[] | Record<string, boolean>;\n\t/** @deprecated Set `status: 'completed'` on the step. Matched by `id`. */\n\tcompletedSteps?: ProgressStep[];\n\t/** HTML id attribute */\n\tid?: string;\n\t/** **Text labels for internationalization** */\n\tlabels?: ProgressIndicatorLabels;\n\t/** Click handler for steps */\n\tonStepClick?: (\n\t\tevent: React.MouseEvent | React.KeyboardEvent,\n\t\tdata: StepEventData\n\t) => void;\n\t/** Focus handler for steps */\n\tonStepFocus?: (event: React.FocusEvent, data: StepEventData) => void;\n\t/**\n\t * Currently selected step: the `id` of one of the `steps` (a step object is also accepted and\n\t * matched by its `id`; one without an `id` is matched by its content, which is deprecated). The\n\t * first step is selected when nothing matches.\n\t */\n\tselectedStep: ProgressStep | ProgressStep['id'];\n\t/** Array of all steps */\n\tsteps: ProgressStep[];\n}\n\n/** Props of the step markers on a progress bar: `type=\"base\"`, any variant. */\ninterface ProgressIndicatorMarkerProps {\n\t/** @deprecated Set `status: 'disabled'` on the step. Matched by `id`. */\n\tdisabledSteps?: ProgressStep[];\n\t/** @deprecated Set `status: 'error'` on the step. Matched by `id`. */\n\terrorSteps?: ProgressStep[];\n\t/** Steps with open tooltips (for development). */\n\ttooltipIsOpenSteps?: ProgressStep[];\n\t/** Tooltip position strategy. */\n\ttooltipPosition?: TooltipPosition;\n}\n\n/**\n * Step markers on a progress bar, with each step's label in a tooltip.\n * * `base` - (default) For white backgrounds.\n * * `shade` - For shaded backgrounds. Adds a light gray border to the step markers, like `variant=\"shade\"` on `lightning-progress-indicator`.\n * * `modal` - The `shade` styling, with tooltips positioned for a modal footer.\n */\ninterface ProgressIndicatorBarProps\n\textends ProgressIndicatorBaseProps, ProgressIndicatorMarkerProps {\n\t/**\n\t * Visual pattern, like `type` on `lightning-progress-indicator`.\n\t * * `base` - (default) Step markers on a progress bar.\n\t */\n\ttype?: 'base';\n\t/** Component variant. */\n\tvariant?: Exclude<ProgressIndicatorVariant, 'setup-assistant'>;\n\t/** Orientation (horizontal or vertical). */\n\torientation?: ProgressIndicatorOrientation;\n}\n\n/** Vertical steps with a bordered list, for Setup Assistant. Always vertical. */\ninterface ProgressIndicatorSetupAssistantProps\n\textends ProgressIndicatorBaseProps, ProgressIndicatorMarkerProps {\n\ttype?: 'base';\n\t/** Vertical steps with a bordered list, for Setup Assistant. */\n\tvariant: 'setup-assistant';\n\t/** Setup Assistant is always vertical. */\n\torientation?: 'vertical';\n}\n\n/**\n * SLDS Path, with each step's label shown in its stage. Use the arrow keys to\n * move between stages. Completion comes from `status: 'completed'`; there are no\n * error, disabled, tooltip, orientation or variant props.\n */\ninterface ProgressIndicatorPathProps extends ProgressIndicatorBaseProps {\n\t/** Visual pattern: SLDS Path, with each step's label shown in its stage. */\n\ttype: 'path';\n\tdisabledSteps?: never;\n\terrorSteps?: never;\n\torientation?: never;\n\ttooltip?: never;\n\ttooltipIsOpenSteps?: never;\n\ttooltipPosition?: never;\n\tvariant?: never;\n}\n\n/**\n * Props for the ProgressIndicator component: a union on `type` and `variant`,\n * so a prop that a pattern ignores (or `orientation` that Setup Assistant\n * overrides) does not compile.\n */\nexport type ProgressIndicatorProps =\n\t| ProgressIndicatorBarProps\n\t| ProgressIndicatorSetupAssistantProps\n\t| ProgressIndicatorPathProps;\n\nconst defaultSteps: ProgressStep[] = [\n\t{ id: 0, label: 'tooltip label #1' },\n\t{ id: 1, label: 'tooltip label #2' },\n\t{ id: 2, label: 'tooltip label #3' },\n\t{ id: 3, label: 'tooltip label #4' },\n\t{ id: 4, label: 'tooltip label #5' },\n];\n\nconst defaultAssistiveText: ProgressIndicatorAssistiveText = {\n\tcompletedStage: 'Stage Complete',\n\tcompletedStep: 'Completed',\n\tcurrentStage: 'Current Stage:',\n\tdisabledStep: 'Disabled',\n\terrorStep: 'Error',\n\tstep: 'Step',\n};\n\nconst defaultLabels: ProgressIndicatorLabels = {\n\tstageNameBefore: 'Stage: ',\n};\n\n/**\n * Check if steps prop is valid\n */\nfunction checkSteps(steps?: ProgressStep[]): boolean {\n\tif (!steps) return false;\n\treturn (\n\t\tArray.isArray(steps) && steps.every((step) => step.label !== undefined)\n\t);\n}\n\n/**\n * Check if a step is one of the items, matching by `id`\n */\nfunction findStep(\n\titem: ProgressStep | undefined,\n\titems: ProgressStep | ProgressStep[] | undefined\n): boolean {\n\tif (!item || !items) return false;\n\n\tconst itemsArray = Array.isArray(items) ? items : [items];\n\n\treturn itemsArray.some((arrayItem) => arrayItem.id === item.id);\n}\n\n/**\n * Progress Indicator communicates to the user the progress of a particular process.\n */\nconst ProgressIndicator = (\n\tprops: ProgressIndicatorProps\n): React.ReactElement => {\n\tconst {\n\t\tassistiveText: propAssistiveText,\n\t\tclassName,\n\t\tcompletedSteps: propCompletedSteps,\n\t\tdisabledSteps: propDisabledSteps,\n\t\terrorSteps: propErrorSteps,\n\t\tid: propId,\n\t\tlabels: propLabels,\n\t\torientation: propOrientation = 'horizontal',\n\t\tonStepClick = () => {},\n\t\tonStepFocus = () => {},\n\t\tselectedStep,\n\t\tsteps: propSteps,\n\t\ttooltipIsOpenSteps,\n\t\ttooltipPosition: propTooltipPosition,\n\t\ttype = 'base',\n\t\tvariant = 'base',\n\t} = props as ProgressIndicatorBaseProps &\n\t\tProgressIndicatorMarkerProps & {\n\t\t\torientation?: ProgressIndicatorOrientation;\n\t\t\ttype?: ProgressIndicatorType;\n\t\t\tvariant?: ProgressIndicatorVariant;\n\t\t};\n\tconst generatedId = useId();\n\tconst id = propId || generatedId;\n\n\tconst assistiveText = { ...defaultAssistiveText, ...propAssistiveText };\n\tconst hasValidSteps = checkSteps(propSteps);\n\tconst allSteps = hasValidSteps ? propSteps : defaultSteps;\n\tconst completedSteps = propCompletedSteps ?? [];\n\t// A step's own `status` wins over the deprecated arrays. It is one status, so it excludes the others.\n\tconst getStatusFlags = (step: ProgressStep) =>\n\t\tstep.status === undefined\n\t\t\t? {\n\t\t\t\t\tisCompleted: findStep(step, completedSteps),\n\t\t\t\t\tisDisabled: findStep(step, propDisabledSteps),\n\t\t\t\t\tisError: findStep(step, propErrorSteps),\n\t\t\t\t}\n\t\t\t: {\n\t\t\t\t\tisCompleted: step.status === 'completed',\n\t\t\t\t\tisDisabled: step.status === 'disabled',\n\t\t\t\t\tisError: step.status === 'error',\n\t\t\t\t};\n\tconst selectedStepId =\n\t\ttypeof selectedStep === 'object' ? selectedStep?.id : selectedStep;\n\t// A step object without an `id` is matched the 0.10.x way, by its whole content.\n\tconst selectedStepWithoutId =\n\t\ttypeof selectedStep === 'object' && selectedStep?.id === undefined\n\t\t\t? JSON.stringify(selectedStep)\n\t\t\t: undefined;\n\tconst isSelectedStep = useCallback(\n\t\t(step: ProgressStep) =>\n\t\t\tselectedStepWithoutId === undefined\n\t\t\t\t? step.id === selectedStepId\n\t\t\t\t: JSON.stringify(step) === selectedStepWithoutId,\n\t\t[selectedStepId, selectedStepWithoutId]\n\t);\n\n\t// Check props in development. Pass whether each step array has items, not the array itself, so that\n\t// an empty array doesn't count as passed and a new array on each render doesn't re-run the check.\n\tconst hasDisabledSteps = Boolean(propDisabledSteps?.length);\n\tconst hasErrorSteps = Boolean(propErrorSteps?.length);\n\tconst hasDeprecatedCompletedSteps = Boolean(propCompletedSteps?.length);\n\tconst hasInvalidSteps = propSteps !== undefined && !hasValidSteps;\n\tconst hasTooltipIsOpenSteps = Boolean(tooltipIsOpenSteps?.length);\n\tconst hasSelectedStepWithoutId = selectedStepWithoutId !== undefined;\n\tconst hasDeprecatedSetupAssistantAction = Boolean(\n\t\tpropSteps?.some((step) => step?.onRenderSetupAssistantAction !== undefined)\n\t);\n\tuseEffect(() => {\n\t\tcheckProps(\n\t\t\tPROGRESS_INDICATOR,\n\t\t\t{\n\t\t\t\tdisabledSteps: hasDisabledSteps,\n\t\t\t\terrorSteps: hasErrorSteps,\n\t\t\t\thasDeprecatedCompletedSteps,\n\t\t\t\thasInvalidSteps,\n\t\t\t\thasSelectedStepWithoutId,\n\t\t\t\thasDeprecatedSetupAssistantAction,\n\t\t\t\torientation: propOrientation,\n\t\t\t\ttooltipIsOpenSteps: hasTooltipIsOpenSteps,\n\t\t\t\ttooltipPosition: propTooltipPosition,\n\t\t\t\ttype,\n\t\t\t\tvariant,\n\t\t\t},\n\t\t\tcomponentDoc\n\t\t);\n\t}, [\n\t\thasDisabledSteps,\n\t\thasErrorSteps,\n\t\thasDeprecatedCompletedSteps,\n\t\thasInvalidSteps,\n\t\thasSelectedStepWithoutId,\n\t\thasDeprecatedSetupAssistantAction,\n\t\thasTooltipIsOpenSteps,\n\t\tpropOrientation,\n\t\tpropTooltipPosition,\n\t\ttype,\n\t\tvariant,\n\t]);\n\n\t// Find current step index\n\tconst currentStepIndex = useMemo(() => {\n\t\tlet index = 0;\n\t\tfor (let i = 0; i < allSteps.length; i += 1) {\n\t\t\tif (isSelectedStep(allSteps[i])) {\n\t\t\t\tindex = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn index;\n\t}, [allSteps, isSelectedStep]);\n\n\tif (type === 'path') {\n\t\treturn (\n\t\t\t<Path\n\t\t\t\tassistiveText={assistiveText}\n\t\t\t\tclassName={className}\n\t\t\t\tselectedIndex={currentStepIndex}\n\t\t\t\tid={id}\n\t\t\t\tlabels={{ ...defaultLabels, ...propLabels }}\n\t\t\t\tonStepClick={onStepClick}\n\t\t\t\tonStepFocus={onStepFocus}\n\t\t\t\tsteps={allSteps.map((step) => ({\n\t\t\t\t\tisCompleted: getStatusFlags(step).isCompleted,\n\t\t\t\t\tisSelected: isSelectedStep(step),\n\t\t\t\t\tstep,\n\t\t\t\t}))}\n\t\t\t/>\n\t\t);\n\t}\n\n\t// Calculate progress value\n\tconst progressValue =\n\t\tcurrentStepIndex === 0\n\t\t\t? '0'\n\t\t\t: `${100 * (currentStepIndex / (allSteps.length - 1))}`;\n\n\t// Determine orientation\n\tconst orientation =\n\t\tvariant === 'setup-assistant' ? 'vertical' : propOrientation;\n\n\t// Determine tooltip position\n\tconst tooltipPosition =\n\t\tpropTooltipPosition ||\n\t\t(variant === 'modal' ? 'absolute' : 'overflowBoundaryElement');\n\n\t// Select step component based on orientation\n\tconst StepComponent = (\n\t\torientation === 'vertical' ? StepVertical : Step\n\t) as React.ComponentType<\n\t\tReact.ComponentProps<typeof Step> &\n\t\t\tReact.ComponentProps<typeof StepVertical>\n\t>;\n\n\treturn (\n\t\t<Progress\n\t\t\tassistiveText={assistiveText}\n\t\t\tid={id}\n\t\t\torientation={orientation}\n\t\t\tvalue={progressValue}\n\t\t\tvariant={variant}\n\t\t\tclassName={className}\n\t\t>\n\t\t\t{allSteps.map((step, i) => (\n\t\t\t\t<StepComponent\n\t\t\t\t\tkey={`${id}-${step.id}`}\n\t\t\t\t\tassistiveText={assistiveText}\n\t\t\t\t\tid={id}\n\t\t\t\t\tindex={i}\n\t\t\t\t\tisSelected={isSelectedStep(step)}\n\t\t\t\t\tisDisabled={getStatusFlags(step).isDisabled}\n\t\t\t\t\tisError={getStatusFlags(step).isError}\n\t\t\t\t\tisCompleted={getStatusFlags(step).isCompleted}\n\t\t\t\t\tonClick={onStepClick}\n\t\t\t\t\tonFocus={onStepFocus}\n\t\t\t\t\tstep={step}\n\t\t\t\t\ttooltipIsOpen={findStep(step, tooltipIsOpenSteps)}\n\t\t\t\t\ttooltipPosition={tooltipPosition}\n\t\t\t\t\tvariant={variant}\n\t\t\t\t/>\n\t\t\t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AAe,CAAI;GAC/B;EACD,EAAE;CACF,CAAA;CAKH,IAAM,IACL,MAAqB,IAClB,MACA,GAAG,OAAO,KAAoB,EAAS,SAAS,OAG9C,IACL,MAAY,oBAAoB,aAAa,GAGxC,KACL,MACC,MAAY,UAAU,aAAa,4BAG/B,KACL,MAAgB,aAAa,IAAe;CAM7C,OACC,kBAAC,GAAD;EACgB;EACX;EACS;EACb,OAAO;EACE;EACE;EAEV,UAAA,EAAS,KAAK,GAAM,MACpB,kBAAC,IAAD;GAEgB;GACX;GACJ,OAAO;GACP,YAAY,EAAe,CAAI;GAC/B,YAAY,EAAe,CAAI,CAAC,CAAC;GACjC,SAAS,EAAe,CAAI,CAAC,CAAC;GAC9B,aAAa,EAAe,CAAI,CAAC,CAAC;GAClC,SAAS;GACT,SAAS;GACH;GACN,eAAe,EAAS,GAAM,CAAkB;GAC/B;GACR;EACT,GAdK,GAAG,EAAG,GAAG,EAAK,IAcnB,CACD;CACQ,CAAA;AAEZ;AAEA,EAAkB,cAAc"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../components/progress-indicator/index.tsx"],"sourcesContent":["/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\nimport React, {\n\tuseCallback,\n\tuseEffect,\n\tuseId,\n\tuseMemo,\n\ttype ReactNode,\n} from 'react';\nimport { PROGRESS_INDICATOR } from '../../utilities/constants';\nimport componentDoc from './component.json';\n\n// Child components\nimport Step from './private/step';\nimport Progress from './private/progress';\nimport StepVertical from './private/step-vertical';\nimport Path from './private/path';\n\n// This component's `checkProps` which issues warnings to developers about properties when in development mode\nimport checkProps from './check-props';\n\n/**\n * Progress indicator orientation\n */\nexport type ProgressIndicatorOrientation = 'horizontal' | 'vertical';\n\n/**\n * Progress indicator type\n */\nexport type ProgressIndicatorType = 'base' | 'path';\n\n/**\n * Progress indicator variant\n */\nexport type ProgressIndicatorVariant =\n\t'base' | 'modal' | 'setup-assistant' | 'shade';\n\n/**\n * Tooltip position\n */\nexport type TooltipPosition =\n\t'absolute' | 'overflowBoundaryElement' | 'relative';\n\n/**\n * Status of a single step. A step has at most one status.\n */\nexport type ProgressStepStatus = 'completed' | 'disabled' | 'error';\n\n/**\n * Step object structure\n */\nexport interface ProgressStep {\n\t/** Unique identifier. Steps are matched by `id`. */\n\tid: string | number;\n\t/**\n\t * Status of the step. A step has one status, so it cannot be both `error` and `completed`.\n\t * `disabled` and `error` apply to `type=\"base\"` only; `type=\"path\"` shows `completed`.\n\t */\n\tstatus?: ProgressStepStatus;\n\t/** Tooltip label */\n\tlabel: string;\n\t/** Optional assistive text override */\n\tassistiveText?: string;\n\t/** Action shown next to the step label. Only used by the `setup-assistant` variant. */\n\tsetupAssistantAction?: ReactNode;\n\t/** Estimated time shown next to the step label. Only used by the `setup-assistant` variant. */\n\tsetupAssistantEstimatedTime?: ReactNode;\n\t/** @deprecated Use `setupAssistantAction` instead. */\n\tonRenderSetupAssistantAction?: ReactNode;\n}\n\n/**\n * Assistive text for ProgressIndicator\n */\nexport interface ProgressIndicatorAssistiveText {\n\t/** `type=\"path\"` only: read before a completed stage's name. Defaults to `Stage Complete` */\n\tcompletedStage?: string;\n\t/** Label for completed steps */\n\tcompletedStep?: string;\n\t/** `type=\"path\"` only: read before the current stage's name. Defaults to `Current Stage:` */\n\tcurrentStage?: string;\n\t/** Label for disabled steps */\n\tdisabledStep?: string;\n\t/** Label for error steps */\n\terrorStep?: string;\n\t/** Label for progress percentage */\n\tpercentage?: string;\n\t/** Label prefix for steps */\n\tstep?: string;\n}\n\n/**\n * Text labels for ProgressIndicator\n */\nexport interface ProgressIndicatorLabels {\n\t/** `type=\"path\"` only: text before the current stage's name, which shows when the path collapses on narrow screens. Include any spacing between it and the name. Defaults to `Stage: ` */\n\tstageNameBefore?: React.ReactNode;\n\t/** `type=\"path\"` only: text after the current stage's name. Include any spacing between it and the name. */\n\tstageNameAfter?: React.ReactNode;\n}\n\n/**\n * Step event data\n */\nexport interface StepEventData {\n\tisCompleted: boolean;\n\tisDisabled: boolean;\n\tisError: boolean;\n\tisSelected: boolean;\n\tstep: ProgressStep;\n}\n\n/** Props every ProgressIndicator takes. */\ninterface ProgressIndicatorBaseProps {\n\t/** Assistive text for accessibility */\n\tassistiveText?: ProgressIndicatorAssistiveText;\n\t/** CSS classes */\n\tclassName?: string | string[] | Record<string, boolean>;\n\t/** @deprecated Set `status: 'completed'` on the step. Matched by `id`. */\n\tcompletedSteps?: ProgressStep[];\n\t/** HTML id attribute */\n\tid?: string;\n\t/** **Text labels for internationalization** */\n\tlabels?: ProgressIndicatorLabels;\n\t/** Click handler for steps */\n\tonStepClick?: (\n\t\tevent: React.MouseEvent | React.KeyboardEvent,\n\t\tdata: StepEventData\n\t) => void;\n\t/** Focus handler for steps */\n\tonStepFocus?: (event: React.FocusEvent, data: StepEventData) => void;\n\t/**\n\t * Currently selected step: the `id` of one of the `steps` (a step object is also accepted and\n\t * matched by its `id`; one without an `id` is matched by its content, which is deprecated). The\n\t * first step is selected when nothing matches.\n\t */\n\tselectedStep: ProgressStep | ProgressStep['id'];\n\t/** Array of all steps */\n\tsteps: ProgressStep[];\n}\n\n/** Props of the step markers on a progress bar: `type=\"base\"`, any variant. */\ninterface ProgressIndicatorMarkerProps {\n\t/** @deprecated Set `status: 'disabled'` on the step. Matched by `id`. */\n\tdisabledSteps?: ProgressStep[];\n\t/** @deprecated Set `status: 'error'` on the step. Matched by `id`. */\n\terrorSteps?: ProgressStep[];\n\t/** Steps with open tooltips (for development). */\n\ttooltipIsOpenSteps?: ProgressStep[];\n\t/** Tooltip position strategy. */\n\ttooltipPosition?: TooltipPosition;\n}\n\n/**\n * Step markers on a progress bar, with each step's label in a tooltip.\n * * `base` - (default) For white backgrounds.\n * * `shade` - For shaded backgrounds. Adds a light gray border to the step markers, like `variant=\"shade\"` on `lightning-progress-indicator`.\n * * `modal` - The `shade` styling, with tooltips positioned for a modal footer.\n */\ninterface ProgressIndicatorBarProps\n\textends ProgressIndicatorBaseProps, ProgressIndicatorMarkerProps {\n\t/**\n\t * Visual pattern, like `type` on `lightning-progress-indicator`.\n\t * * `base` - (default) Step markers on a progress bar.\n\t */\n\ttype?: 'base';\n\t/** Component variant. */\n\tvariant?: Exclude<ProgressIndicatorVariant, 'setup-assistant'>;\n\t/** Orientation (horizontal or vertical). */\n\torientation?: ProgressIndicatorOrientation;\n}\n\n/** Vertical steps with a bordered list, for Setup Assistant. Always vertical. */\ninterface ProgressIndicatorSetupAssistantProps\n\textends ProgressIndicatorBaseProps, ProgressIndicatorMarkerProps {\n\t/** Visual pattern. Setup Assistant uses the base progress indicator. */\n\ttype?: 'base';\n\t/** Vertical steps with a bordered list, for Setup Assistant. */\n\tvariant: 'setup-assistant';\n\t/** Setup Assistant is always vertical. */\n\torientation?: 'vertical';\n}\n\n/**\n * SLDS Path, with each step's label shown in its stage. Use the arrow keys to\n * move between stages. Completion comes from `status: 'completed'`; there are no\n * error, disabled, tooltip, orientation or variant props.\n */\ninterface ProgressIndicatorPathProps extends ProgressIndicatorBaseProps {\n\t/** Visual pattern: SLDS Path, with each step's label shown in its stage. */\n\ttype: 'path';\n\tdisabledSteps?: never;\n\terrorSteps?: never;\n\torientation?: never;\n\ttooltip?: never;\n\ttooltipIsOpenSteps?: never;\n\ttooltipPosition?: never;\n\tvariant?: never;\n}\n\n/**\n * Props for the ProgressIndicator component: a union on `type` and `variant`,\n * so a prop that a pattern ignores (or `orientation` that Setup Assistant\n * overrides) does not compile.\n */\nexport type ProgressIndicatorProps =\n\t| ProgressIndicatorBarProps\n\t| ProgressIndicatorSetupAssistantProps\n\t| ProgressIndicatorPathProps;\n\nconst defaultSteps: ProgressStep[] = [\n\t{ id: 0, label: 'tooltip label #1' },\n\t{ id: 1, label: 'tooltip label #2' },\n\t{ id: 2, label: 'tooltip label #3' },\n\t{ id: 3, label: 'tooltip label #4' },\n\t{ id: 4, label: 'tooltip label #5' },\n];\n\nconst defaultAssistiveText: ProgressIndicatorAssistiveText = {\n\tcompletedStage: 'Stage Complete',\n\tcompletedStep: 'Completed',\n\tcurrentStage: 'Current Stage:',\n\tdisabledStep: 'Disabled',\n\terrorStep: 'Error',\n\tstep: 'Step',\n};\n\nconst defaultLabels: ProgressIndicatorLabels = {\n\tstageNameBefore: 'Stage: ',\n};\n\n/**\n * Check if steps prop is valid\n */\nfunction checkSteps(steps?: ProgressStep[]): boolean {\n\tif (!steps) return false;\n\treturn (\n\t\tArray.isArray(steps) && steps.every((step) => step.label !== undefined)\n\t);\n}\n\n/**\n * Check if a step is one of the items, matching by `id`\n */\nfunction findStep(\n\titem: ProgressStep | undefined,\n\titems: ProgressStep | ProgressStep[] | undefined\n): boolean {\n\tif (!item || !items) return false;\n\n\tconst itemsArray = Array.isArray(items) ? items : [items];\n\n\treturn itemsArray.some((arrayItem) => arrayItem.id === item.id);\n}\n\n/**\n * Progress Indicator communicates to the user the progress of a particular process.\n */\nconst ProgressIndicator = (\n\tprops: ProgressIndicatorProps\n): React.ReactElement => {\n\tconst {\n\t\tassistiveText: propAssistiveText,\n\t\tclassName,\n\t\tcompletedSteps: propCompletedSteps,\n\t\tdisabledSteps: propDisabledSteps,\n\t\terrorSteps: propErrorSteps,\n\t\tid: propId,\n\t\tlabels: propLabels,\n\t\torientation: propOrientation = 'horizontal',\n\t\tonStepClick = () => {},\n\t\tonStepFocus = () => {},\n\t\tselectedStep,\n\t\tsteps: propSteps,\n\t\ttooltipIsOpenSteps,\n\t\ttooltipPosition: propTooltipPosition,\n\t\ttype = 'base',\n\t\tvariant = 'base',\n\t} = props as ProgressIndicatorBaseProps &\n\t\tProgressIndicatorMarkerProps & {\n\t\t\torientation?: ProgressIndicatorOrientation;\n\t\t\ttype?: ProgressIndicatorType;\n\t\t\tvariant?: ProgressIndicatorVariant;\n\t\t};\n\tconst generatedId = useId();\n\tconst id = propId || generatedId;\n\n\tconst assistiveText = { ...defaultAssistiveText, ...propAssistiveText };\n\tconst hasValidSteps = checkSteps(propSteps);\n\tconst allSteps = hasValidSteps ? propSteps : defaultSteps;\n\tconst completedSteps = propCompletedSteps ?? [];\n\t// A step's own `status` wins over the deprecated arrays. It is one status, so it excludes the others.\n\tconst getStatusFlags = (step: ProgressStep) =>\n\t\tstep.status === undefined\n\t\t\t? {\n\t\t\t\t\tisCompleted: findStep(step, completedSteps),\n\t\t\t\t\tisDisabled: findStep(step, propDisabledSteps),\n\t\t\t\t\tisError: findStep(step, propErrorSteps),\n\t\t\t\t}\n\t\t\t: {\n\t\t\t\t\tisCompleted: step.status === 'completed',\n\t\t\t\t\tisDisabled: step.status === 'disabled',\n\t\t\t\t\tisError: step.status === 'error',\n\t\t\t\t};\n\tconst selectedStepId =\n\t\ttypeof selectedStep === 'object' ? selectedStep?.id : selectedStep;\n\t// A step object without an `id` is matched the 0.10.x way, by its whole content.\n\tconst selectedStepWithoutId =\n\t\ttypeof selectedStep === 'object' && selectedStep?.id === undefined\n\t\t\t? JSON.stringify(selectedStep)\n\t\t\t: undefined;\n\tconst isSelectedStep = useCallback(\n\t\t(step: ProgressStep) =>\n\t\t\tselectedStepWithoutId === undefined\n\t\t\t\t? step.id === selectedStepId\n\t\t\t\t: JSON.stringify(step) === selectedStepWithoutId,\n\t\t[selectedStepId, selectedStepWithoutId]\n\t);\n\n\t// Check props in development. Pass whether each step array has items, not the array itself, so that\n\t// an empty array doesn't count as passed and a new array on each render doesn't re-run the check.\n\tconst hasDisabledSteps = Boolean(propDisabledSteps?.length);\n\tconst hasErrorSteps = Boolean(propErrorSteps?.length);\n\tconst hasDeprecatedCompletedSteps = Boolean(propCompletedSteps?.length);\n\tconst hasInvalidSteps = propSteps !== undefined && !hasValidSteps;\n\tconst hasTooltipIsOpenSteps = Boolean(tooltipIsOpenSteps?.length);\n\tconst hasSelectedStepWithoutId = selectedStepWithoutId !== undefined;\n\tconst hasDeprecatedSetupAssistantAction = Boolean(\n\t\tpropSteps?.some((step) => step?.onRenderSetupAssistantAction !== undefined)\n\t);\n\tuseEffect(() => {\n\t\tcheckProps(\n\t\t\tPROGRESS_INDICATOR,\n\t\t\t{\n\t\t\t\tdisabledSteps: hasDisabledSteps,\n\t\t\t\terrorSteps: hasErrorSteps,\n\t\t\t\thasDeprecatedCompletedSteps,\n\t\t\t\thasInvalidSteps,\n\t\t\t\thasSelectedStepWithoutId,\n\t\t\t\thasDeprecatedSetupAssistantAction,\n\t\t\t\torientation: propOrientation,\n\t\t\t\ttooltipIsOpenSteps: hasTooltipIsOpenSteps,\n\t\t\t\ttooltipPosition: propTooltipPosition,\n\t\t\t\ttype,\n\t\t\t\tvariant,\n\t\t\t},\n\t\t\tcomponentDoc\n\t\t);\n\t}, [\n\t\thasDisabledSteps,\n\t\thasErrorSteps,\n\t\thasDeprecatedCompletedSteps,\n\t\thasInvalidSteps,\n\t\thasSelectedStepWithoutId,\n\t\thasDeprecatedSetupAssistantAction,\n\t\thasTooltipIsOpenSteps,\n\t\tpropOrientation,\n\t\tpropTooltipPosition,\n\t\ttype,\n\t\tvariant,\n\t]);\n\n\t// Find current step index\n\tconst currentStepIndex = useMemo(() => {\n\t\tlet index = 0;\n\t\tfor (let i = 0; i < allSteps.length; i += 1) {\n\t\t\tif (isSelectedStep(allSteps[i])) {\n\t\t\t\tindex = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn index;\n\t}, [allSteps, isSelectedStep]);\n\n\tif (type === 'path') {\n\t\treturn (\n\t\t\t<Path\n\t\t\t\tassistiveText={assistiveText}\n\t\t\t\tclassName={className}\n\t\t\t\tselectedIndex={currentStepIndex}\n\t\t\t\tid={id}\n\t\t\t\tlabels={{ ...defaultLabels, ...propLabels }}\n\t\t\t\tonStepClick={onStepClick}\n\t\t\t\tonStepFocus={onStepFocus}\n\t\t\t\tsteps={allSteps.map((step) => ({\n\t\t\t\t\tisCompleted: getStatusFlags(step).isCompleted,\n\t\t\t\t\tisSelected: isSelectedStep(step),\n\t\t\t\t\tstep,\n\t\t\t\t}))}\n\t\t\t/>\n\t\t);\n\t}\n\n\t// Calculate progress value\n\tconst progressValue =\n\t\tcurrentStepIndex === 0\n\t\t\t? '0'\n\t\t\t: `${100 * (currentStepIndex / (allSteps.length - 1))}`;\n\n\t// Determine orientation\n\tconst orientation =\n\t\tvariant === 'setup-assistant' ? 'vertical' : propOrientation;\n\n\t// Determine tooltip position\n\tconst tooltipPosition =\n\t\tpropTooltipPosition ||\n\t\t(variant === 'modal' ? 'absolute' : 'overflowBoundaryElement');\n\n\t// Select step component based on orientation\n\tconst StepComponent = (\n\t\torientation === 'vertical' ? StepVertical : Step\n\t) as React.ComponentType<\n\t\tReact.ComponentProps<typeof Step> &\n\t\t\tReact.ComponentProps<typeof StepVertical>\n\t>;\n\n\treturn (\n\t\t<Progress\n\t\t\tassistiveText={assistiveText}\n\t\t\tid={id}\n\t\t\torientation={orientation}\n\t\t\tvalue={progressValue}\n\t\t\tvariant={variant}\n\t\t\tclassName={className}\n\t\t>\n\t\t\t{allSteps.map((step, i) => (\n\t\t\t\t<StepComponent\n\t\t\t\t\tkey={`${id}-${step.id}`}\n\t\t\t\t\tassistiveText={assistiveText}\n\t\t\t\t\tid={id}\n\t\t\t\t\tindex={i}\n\t\t\t\t\tisSelected={isSelectedStep(step)}\n\t\t\t\t\tisDisabled={getStatusFlags(step).isDisabled}\n\t\t\t\t\tisError={getStatusFlags(step).isError}\n\t\t\t\t\tisCompleted={getStatusFlags(step).isCompleted}\n\t\t\t\t\tonClick={onStepClick}\n\t\t\t\t\tonFocus={onStepFocus}\n\t\t\t\t\tstep={step}\n\t\t\t\t\ttooltipIsOpen={findStep(step, tooltipIsOpenSteps)}\n\t\t\t\t\ttooltipPosition={tooltipPosition}\n\t\t\t\t\tvariant={variant}\n\t\t\t\t/>\n\t\t\t))}\n\t\t</Progress>\n\t);\n};\n\nProgressIndicator.displayName = PROGRESS_INDICATOR;\n\nexport default ProgressIndicator;\n"],"mappings":";;;;;;;;;;AAmNA,IAAM,IAA+B;CACpC;EAAE,IAAI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GxC,KACL,MACC,MAAY,UAAU,aAAa,4BAG/B,KACL,MAAgB,aAAa,IAAe;CAM7C,OACC,kBAAC,GAAD;EACgB;EACX;EACS;EACb,OAAO;EACE;EACE;EAEV,UAAA,EAAS,KAAK,GAAM,MACpB,kBAAC,IAAD;GAEgB;GACX;GACJ,OAAO;GACP,YAAY,EAAe,CAAI;GAC/B,YAAY,EAAe,CAAI,CAAC,CAAC;GACjC,SAAS,EAAe,CAAI,CAAC,CAAC;GAC9B,aAAa,EAAe,CAAI,CAAC,CAAC;GAClC,SAAS;GACT,SAAS;GACH;GACN,eAAe,EAAS,GAAM,CAAkB;GAC/B;GACR;EACT,GAdK,GAAG,EAAG,GAAG,EAAK,IAcnB,CACD;CACQ,CAAA;AAEZ;AAEA,EAAkB,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../components/progress-ring/index.tsx"],"sourcesContent":["/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\nimport React, { type ReactNode } from 'react';\nimport classNames from 'classnames';\nimport { PROGRESS_RING } from '../../utilities/constants';\nimport Icon from '../icon';\nimport ProgressRingShape from './private/ring-shape';\n\n/**\n * Theme options for the progress ring\n */\nexport const THEME_OPTIONS = Object.freeze({\n\tACTIVE: 'active',\n\tWARNING: 'warning',\n\tEXPIRED: 'expired',\n\tCOMPLETE: 'complete',\n} as const);\n\nexport type ProgressRingTheme = 'active' | 'warning' | 'expired' | 'complete';\nexport type ProgressRingFlowDirection = 'drain' | 'fill';\nexport type ProgressRingSize = 'medium' | 'large';\n\n/**\n * CSS classes for each theme\n */\nconst THEME_CLASSES: Record<ProgressRingTheme, string> = {\n\tactive: 'slds-progress-ring_active-step',\n\twarning: 'slds-progress-ring_warning',\n\texpired: 'slds-progress-ring_expired',\n\tcomplete: 'slds-progress-ring_complete',\n};\n\n/**\n * Props shared by every ProgressRing\n */\ninterface ProgressRingBaseProps {\n\t/** HTML id attribute */\n\tid?: string;\n\t/** CSS classes */\n\tclassName?: string | string[] | Record<string, boolean>;\n\t/** Theme applied to the ring */\n\ttheme?: ProgressRingTheme;\n\t/** Progress percentage (0-100) */\n\tvalue: number;\n\t/** Flow direction of progress */\n\tflowDirection?: ProgressRingFlowDirection;\n\t/** Size of the progress ring */\n\tsize?: ProgressRingSize;\n}\n\n/** No icon is rendered, so a custom `icon` would be ignored. */\ninterface ProgressRingWithoutIconProps {\n\thasIcon?: false;\n\ticon?: never;\n}\n\n/** Renders the theme icon, or the custom `icon` when set. */\ninterface ProgressRingWithIconProps {\n\t/** Whether to display the theme icon */\n\thasIcon: true;\n\t/** Custom icon to display instead of the theme icon */\n\ticon?: ReactNode;\n}\n\n/**\n * Props for the ProgressRing component. `icon` is only honored with `hasIcon`,\n * so it is only accepted there.\n */\nexport type ProgressRingProps = ProgressRingBaseProps &\n\t(ProgressRingWithoutIconProps | ProgressRingWithIconProps);\n\n/**\n * Customizable progress ring displaying progress in a circular format.\n */\nconst ProgressRing = ({\n\tid,\n\tclassName,\n\ttheme,\n\ticon: propIcon,\n\thasIcon,\n\tvalue,\n\tflowDirection = 'drain',\n\tsize = 'medium',\n}: ProgressRingProps): React.ReactElement => {\n\t// Get icon based on theme or custom icon\n\tconst getIcon = (): ReactNode => {\n\t\tif (!hasIcon) return null;\n\n\t\tif (propIcon) return propIcon;\n\n\t\tswitch (theme) {\n\t\t\tcase 'warning':\n\t\t\t\treturn <Icon category=\"utility\" name=\"warning\" title=\"Warning\" />;\n\t\t\tcase 'expired':\n\t\t\t\treturn <Icon category=\"utility\" name=\"error\" title=\"Expired\" />;\n\t\t\tcase 'complete':\n\t\t\t\treturn <Icon category=\"utility\" name=\"check\" title=\"Complete\" />;\n\t\t\tdefault:\n\t\t\t\treturn null;\n\t\t}\n\t};\n\n\tconst themeClass = theme ? THEME_CLASSES[theme] : '';\n\tconst percentDecimal = value / 100;\n\n\treturn (\n\t\t<ProgressRingShape\n\t\t\tid={id}\n\t\t\tsize={size}\n\t\t\tclassName={classNames(className as string, themeClass, {\n\t\t\t\t'slds-progress-ring_large': size === 'large',\n\t\t\t})}\n\t\t\tfillPercentDecimal={percentDecimal}\n\t\t\tflowDirection={flowDirection}\n\t\t>\n\t\t\t{getIcon()}\n\t\t</ProgressRingShape>\n\t);\n};\n\nProgressRing.displayName = PROGRESS_RING;\n\nexport default ProgressRing;\n
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../components/progress-ring/index.tsx"],"sourcesContent":["/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\nimport React, { type ReactNode } from 'react';\nimport classNames from 'classnames';\nimport { PROGRESS_RING } from '../../utilities/constants';\nimport Icon from '../icon';\nimport ProgressRingShape from './private/ring-shape';\n\n/**\n * Theme options for the progress ring\n */\nexport const THEME_OPTIONS = Object.freeze({\n\tACTIVE: 'active',\n\tWARNING: 'warning',\n\tEXPIRED: 'expired',\n\tCOMPLETE: 'complete',\n} as const);\n\nexport type ProgressRingTheme = 'active' | 'warning' | 'expired' | 'complete';\nexport type ProgressRingFlowDirection = 'drain' | 'fill';\nexport type ProgressRingSize = 'medium' | 'large';\n\n/**\n * CSS classes for each theme\n */\nconst THEME_CLASSES: Record<ProgressRingTheme, string> = {\n\tactive: 'slds-progress-ring_active-step',\n\twarning: 'slds-progress-ring_warning',\n\texpired: 'slds-progress-ring_expired',\n\tcomplete: 'slds-progress-ring_complete',\n};\n\n/**\n * Props shared by every ProgressRing\n */\ninterface ProgressRingBaseProps {\n\t/** HTML id attribute */\n\tid?: string;\n\t/** CSS classes */\n\tclassName?: string | string[] | Record<string, boolean>;\n\t/** Theme applied to the ring */\n\ttheme?: ProgressRingTheme;\n\t/** Progress percentage (0-100) */\n\tvalue: number;\n\t/** Flow direction of progress */\n\tflowDirection?: ProgressRingFlowDirection;\n\t/** Size of the progress ring */\n\tsize?: ProgressRingSize;\n}\n\n/** No icon is rendered, so a custom `icon` would be ignored. */\ninterface ProgressRingWithoutIconProps {\n\t/** Whether to display the theme icon */\n\thasIcon?: false;\n\ticon?: never;\n}\n\n/** Renders the theme icon, or the custom `icon` when set. */\ninterface ProgressRingWithIconProps {\n\t/** Whether to display the theme icon */\n\thasIcon: true;\n\t/** Custom icon to display instead of the theme icon */\n\ticon?: ReactNode;\n}\n\n/**\n * Props for the ProgressRing component. `icon` is only honored with `hasIcon`,\n * so it is only accepted there.\n */\nexport type ProgressRingProps = ProgressRingBaseProps &\n\t(ProgressRingWithoutIconProps | ProgressRingWithIconProps);\n\n/**\n * Customizable progress ring displaying progress in a circular format.\n */\nconst ProgressRing = ({\n\tid,\n\tclassName,\n\ttheme,\n\ticon: propIcon,\n\thasIcon,\n\tvalue,\n\tflowDirection = 'drain',\n\tsize = 'medium',\n}: ProgressRingProps): React.ReactElement => {\n\t// Get icon based on theme or custom icon\n\tconst getIcon = (): ReactNode => {\n\t\tif (!hasIcon) return null;\n\n\t\tif (propIcon) return propIcon;\n\n\t\tswitch (theme) {\n\t\t\tcase 'warning':\n\t\t\t\treturn <Icon category=\"utility\" name=\"warning\" title=\"Warning\" />;\n\t\t\tcase 'expired':\n\t\t\t\treturn <Icon category=\"utility\" name=\"error\" title=\"Expired\" />;\n\t\t\tcase 'complete':\n\t\t\t\treturn <Icon category=\"utility\" name=\"check\" title=\"Complete\" />;\n\t\t\tdefault:\n\t\t\t\treturn null;\n\t\t}\n\t};\n\n\tconst themeClass = theme ? THEME_CLASSES[theme] : '';\n\tconst percentDecimal = value / 100;\n\n\treturn (\n\t\t<ProgressRingShape\n\t\t\tid={id}\n\t\t\tsize={size}\n\t\t\tclassName={classNames(className as string, themeClass, {\n\t\t\t\t'slds-progress-ring_large': size === 'large',\n\t\t\t})}\n\t\t\tfillPercentDecimal={percentDecimal}\n\t\t\tflowDirection={flowDirection}\n\t\t>\n\t\t\t{getIcon()}\n\t\t</ProgressRingShape>\n\t);\n};\n\nProgressRing.displayName = PROGRESS_RING;\n\nexport default ProgressRing;\n"],"mappings":";;;;;;;AAYA,IAAa,IAAgB,OAAO,OAAO;CAC1C,QAAQ;CACR,SAAS;CACT,SAAS;CACT,UAAU;AACX,CAAU,GASJ,IAAmD;CACxD,QAAQ;CACR,SAAS;CACT,SAAS;CACT,UAAU;AACX,GA6CM,KAAgB,EACrB,OACA,cACA,UACA,MAAM,GACN,YACA,UACA,mBAAgB,SAChB,UAAO,eACqC;CAE5C,IAAM,UAA2B;EAChC,IAAI,CAAC,GAAS,OAAO;EAErB,IAAI,GAAU,OAAO;EAErB,QAAQ,GAAR;GACC,KAAK,WACJ,OAAO,kBAAC,GAAD;IAAM,UAAS;IAAU,MAAK;IAAU,OAAM;GAAW,CAAA;GACjE,KAAK,WACJ,OAAO,kBAAC,GAAD;IAAM,UAAS;IAAU,MAAK;IAAQ,OAAM;GAAW,CAAA;GAC/D,KAAK,YACJ,OAAO,kBAAC,GAAD;IAAM,UAAS;IAAU,MAAK;IAAQ,OAAM;GAAY,CAAA;GAChE,SACC,OAAO;EACT;CACD,GAEM,IAAa,IAAQ,EAAc,KAAS,IAC5C,IAAiB,IAAQ;CAE/B,OACC,kBAAC,GAAD;EACK;EACE;EACN,WAAW,EAAW,GAAqB,GAAY,EACtD,4BAA4B,MAAS,QACtC,CAAC;EACD,oBAAoB;EACL;EAEd,UAAA,EAAQ;CACS,CAAA;AAErB;AAEA,EAAa,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../components/radio/index.tsx"],"sourcesContent":["/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\nimport React, {\n\tuseRef,\n\tuseId,\n\tuseCallback,\n\tuseEffect,\n\ttype ChangeEvent,\n\ttype FocusEvent,\n\ttype KeyboardEvent,\n\ttype MouseEvent,\n\ttype CSSProperties,\n} from 'react';\nimport classNames from 'classnames';\nimport KEYS from '../../utilities/key-code';\nimport { RADIO } from '../../utilities/constants';\nimport getAriaProps from '../../utilities/get-aria-props';\nimport getDataProps from '../../utilities/get-data-props';\nimport Swatch from '../../components/color-picker/private/swatch';\nimport Icon from '../icon';\nimport { checkDeprecatedProps } from './check-props';\nimport componentDoc from './component.json';\n\n/**\n * Radio variant types\n */\nexport type RadioVariant = 'base' | 'button-group' | 'swatch' | 'visual-picker';\nexport type RadioSize = 'medium' | 'large';\n\n/**\n * Assistive text for Radio\n */\nexport interface RadioAssistiveText {\n\t/** Visually hidden label */\n\tlabel?: string;\n}\n\n/**\n * Labels for Radio\n */\nexport interface RadioLabels {\n\t/** Heading for visual picker variant */\n\theading?: string;\n\t/** Label for the radio input */\n\tlabel?: string;\n}\n\n/**\n * Refs for Radio\n */\nexport interface RadioRefs {\n\t/** Ref callback for input element */\n\tinput?: (input: HTMLInputElement | null) => void;\n}\n\n/**\n * Change event data for Radio\n */\nexport interface RadioChangeData {\n\t/**\n\t * The requested checked state: `true` when the user selects the radio,\n\t * `false` when a `deselectable` radio that is checked is clicked again.\n\t */\n\tchecked: boolean;\n}\n\n/**\n * Event passed to a Radio's `onChange`: the input's `change` event when a\n * click selects it, the `click` event when a click deselects a checked\n * `deselectable` radio (a checked radio fires no `change`), or the `keydown`\n * event when Enter or Space selects or deselects it.\n */\nexport type RadioChangeEvent =\n\t| ChangeEvent<HTMLInputElement>\n\t| MouseEvent<HTMLInputElement>\n\t| KeyboardEvent<HTMLInputElement>;\n\n/**\n * Change handler for Radio\n */\nexport type RadioChangeHandler = (\n\tevent: RadioChangeEvent,\n\tdata: RadioChangeData\n) => void;\n\n/**\n * Props for the Radio component\n */\ninterface RadioBaseProps {\n\t/** Assistive text for accessibility */\n\tassistiveText?: RadioAssistiveText;\n\t/** ARIA describedby attribute */\n\t'aria-describedby'?: string;\n\t/** ARIA labelledby attribute */\n\t'aria-labelledby'?: string;\n\t/**\n\t * Whether the radio is checked. Radio is controlled: update this prop from\n\t * `onChange`. Inside a `RadioGroup`/`RadioButtonGroup`, pass `value` to the\n\t * group instead and the group derives `checked` for each radio.\n\t */\n\tchecked: boolean;\n\t/** CSS classes */\n\tclassName?: string | string[] | Record<string, boolean>;\n\t/** Whether radio can be deselected */\n\tdeselectable?: boolean;\n\t/** Whether radio is disabled */\n\tdisabled?: boolean;\n\t/** Unique ID for the input */\n\tid?: string;\n\t/** ID for the label element */\n\tlabelId?: string;\n\t/** Text labels */\n\tlabels?: RadioLabels;\n\t/** Input name attribute */\n\tname?: string;\n\t/**\n\t * Called with the requested checked state in `data.checked`. The rendered\n\t * state only changes when `checked` is updated.\n\t */\n\tonChange: RadioChangeHandler;\n\t/** Focus handler */\n\tonFocus?: (event: FocusEvent<HTMLInputElement>) => void;\n\t/**\n\t * @deprecated Focus the radio through `refs.input` instead. Called with the `<input>`\n\t * when `requestFocus` is set. Still works, and warns.\n\t */\n\tonRequestFocus?: (input: HTMLInputElement) => void;\n\t/** @deprecated Focus the radio through `refs.input` instead. Still works, and warns. */\n\trequestFocus?: boolean;\n\t/** Tab index */\n\ttabIndex?: number;\n\t/** Input value */\n\tvalue?: string;\n\t/** Ref callbacks */\n\trefs?: RadioRefs;\n}\n\n/** Props only the visual picker takes. */\ninterface RadioVisualPickerOnlyProps {\n\t/** Visual picker: coverable when selected */\n\tcoverable?: boolean;\n\t/** Visual picker: vertical layout */\n\tvertical?: boolean;\n\t/** Visual picker: figure content, rendered inside `.slds-visual-picker__figure` when not `coverable` */\n\tvisualPickerFigure?: React.ReactNode;\n\t/** Visual picker: coverable figure content shown when selected */\n\tvisualPickerFigureSelected?: React.ReactNode;\n\t/** Visual picker: coverable figure content shown when not selected */\n\tvisualPickerFigureNotSelected?: React.ReactNode;\n\t/** @deprecated Use `visualPickerFigure` instead. */\n\tonRenderVisualPicker?: () => React.ReactNode;\n\t/** @deprecated Use `visualPickerFigureSelected` instead. */\n\tonRenderVisualPickerSelected?: () => React.ReactNode;\n\t/** @deprecated Use `visualPickerFigureNotSelected` instead. */\n\tonRenderVisualPickerNotSelected?: () => React.ReactNode;\n\t/** Visual picker: size. Defaults to `medium`. */\n\tsize?: RadioSize;\n}\n\n/** Visual-picker-only props, rejected by the other variants. */\ntype RadioVisualPickerOnlyNever = {\n\t[K in keyof RadioVisualPickerOnlyProps]?: never;\n};\n\n/** A plain radio, or a button inside a `RadioButtonGroup`. */\ninterface RadioPlainVariantProps extends RadioVisualPickerOnlyNever {\n\t/** Radio variant */\n\tvariant?: 'base' | 'button-group';\n\tstyle?: never;\n}\n\n/** A color swatch button. `value` is the color. */\ninterface RadioSwatchVariantProps extends RadioVisualPickerOnlyNever {\n\t/** Radio variant */\n\tvariant: 'swatch';\n\t/** Custom styles for the swatch */\n\tstyle?: CSSProperties;\n}\n\n/** An option inside a `VisualPicker`. */\ninterface RadioVisualPickerVariantProps extends RadioVisualPickerOnlyProps {\n\t/** Radio variant */\n\tvariant: 'visual-picker';\n\tstyle?: never;\n}\n\ntype RadioVariantProps =\n\t| RadioPlainVariantProps\n\t| RadioSwatchVariantProps\n\t| RadioVisualPickerVariantProps;\n\n/**\n * Props for the Radio component: a union on `variant`, so a prop that a\n * variant ignores is a compile error.\n */\nexport type RadioProps = RadioBaseProps & RadioVariantProps;\n\n/**\n * Props for a `Radio` rendered as a child of `RadioGroup` or\n * `RadioButtonGroup`. The group injects `checked` (derived from its `value`)\n * and `onChange`, so neither is required here.\n */\nexport type RadioGroupItemProps = Omit<RadioBaseProps, 'checked' | 'onChange'> &\n\tRadioVariantProps &\n\tRadioGroupItemOwnProps;\n\ninterface RadioGroupItemOwnProps {\n\t/**\n\t * @deprecated Pass `value` to the `RadioGroup`/`RadioButtonGroup` instead.\n\t * Only used when the group has no `value`.\n\t */\n\tchecked?: boolean;\n\t/** Ignored inside a group: the group's `onChange` is called instead. */\n\tonChange?: RadioChangeHandler;\n}\n\nconst defaultAssistiveText: RadioAssistiveText = {};\nconst defaultLabels: RadioLabels = {};\n\n/**\n * A radio input that can have a single input checked at any one time.\n * Radios should be wrapped with a RadioGroup or RadioButtonGroup.\n */\nconst Radio = (props: RadioProps): React.ReactElement => {\n\tconst {\n\t\tassistiveText: propAssistiveText,\n\t\t'aria-describedby': ariaDescribedBy,\n\t\t'aria-labelledby': ariaLabelledBy,\n\t\tchecked,\n\t\tclassName,\n\t\t// Removed in v11. Destructured so they never reach the DOM;\n\t\t// `checkDeprecatedProps` warns about them.\n\t\tdefaultChecked,\n\t\tdeselectable,\n\t\tdisabled,\n\t\tid: propId,\n\t\tlabelId,\n\t\tlabels: propLabels,\n\t\tlabel,\n\t\tname,\n\t\tonChange,\n\t\tonFocus,\n\t\tonRequestFocus,\n\t\trequestFocus,\n\t\ttabIndex,\n\t\tvalue,\n\t\tvariant = 'base',\n\t\tcoverable = false,\n\t\tvertical,\n\t\tvisualPickerFigure,\n\t\tvisualPickerFigureSelected,\n\t\tvisualPickerFigureNotSelected,\n\t\tonRenderVisualPicker,\n\t\tonRenderVisualPickerSelected,\n\t\tonRenderVisualPickerNotSelected,\n\t\tsize = 'medium',\n\t\trefs,\n\t\tstyle,\n\t\t...rest\n\t} = props as RadioBaseProps &\n\t\tPartial<RadioVisualPickerOnlyProps> & {\n\t\t\tvariant?: RadioVariant;\n\t\t\tstyle?: CSSProperties;\n\t\t} & {\n\t\t\tdefaultChecked?: boolean;\n\t\t\tlabel?: unknown;\n\t\t};\n\tconst generatedId = useId();\n\tconst preventDuplicateRef = useRef(false);\n\n\tconst id = propId || generatedId;\n\tconst assistiveText = { ...defaultAssistiveText, ...propAssistiveText };\n\tconst labels = { ...defaultLabels, ...propLabels };\n\n\tuseEffect(() => {\n\t\tcheckDeprecatedProps(\n\t\t\tRADIO,\n\t\t\t{\n\t\t\t\tdefaultChecked,\n\t\t\t\tlabel,\n\t\t\t\tonRenderVisualPicker,\n\t\t\t\tonRenderVisualPickerSelected,\n\t\t\t\tonRenderVisualPickerNotSelected,\n\t\t\t\tonRequestFocus,\n\t\t\t\trequestFocus,\n\t\t\t},\n\t\t\tcomponentDoc\n\t\t);\n\t}, [\n\t\tdefaultChecked,\n\t\tlabel,\n\t\tonRequestFocus,\n\t\trequestFocus,\n\t\tonRenderVisualPicker,\n\t\tonRenderVisualPickerSelected,\n\t\tonRenderVisualPickerNotSelected,\n\t]);\n\n\tconst ariaProps = getAriaProps(rest);\n\tconst dataProps = getDataProps(rest);\n\n\tconst handleChange = useCallback(\n\t\t(event: RadioChangeEvent, preventDuplicate?: boolean) => {\n\t\t\tif (!preventDuplicateRef.current) {\n\t\t\t\tpreventDuplicateRef.current = Boolean(preventDuplicate);\n\t\t\t\tonChange?.(event, { checked: !checked });\n\t\t\t} else {\n\t\t\t\tpreventDuplicateRef.current = false;\n\t\t\t}\n\t\t},\n\t\t[checked, onChange]\n\t);\n\n\tconst handleInputRef = useCallback(\n\t\t(input: HTMLInputElement | null) => {\n\t\t\trefs?.input?.(input);\n\t\t\tif (input && requestFocus && onRequestFocus) {\n\t\t\t\tonRequestFocus(input);\n\t\t\t}\n\t\t},\n\t\t[refs, requestFocus, onRequestFocus]\n\t);\n\n\t// Render the label based on variant\n\tlet radioLabel: React.ReactNode;\n\n\tif (variant === 'swatch') {\n\t\tradioLabel = (\n\t\t\t<label\n\t\t\t\tstyle={{ border: 'var(--slds-g-sizing-border-1, 1px)' }}\n\t\t\t\tclassName=\"slds-radio_button__label\"\n\t\t\t\thtmlFor={id}\n\t\t\t>\n\t\t\t\t<span>\n\t\t\t\t\t<Swatch label={labels.label} style={style} color={value ?? ''} />\n\t\t\t\t</span>\n\t\t\t</label>\n\t\t);\n\t} else if (variant === 'button-group') {\n\t\tradioLabel = (\n\t\t\t<label className=\"slds-radio_button__label\" htmlFor={id}>\n\t\t\t\t<span className=\"slds-radio_faux\">{labels.label}</span>\n\t\t\t</label>\n\t\t);\n\t} else if (variant === 'visual-picker') {\n\t\tradioLabel = (\n\t\t\t<label htmlFor={id}>\n\t\t\t\t{coverable ? (\n\t\t\t\t\t<div className=\"slds-visual-picker__figure slds-visual-picker__icon slds-align_absolute-center\">\n\t\t\t\t\t\t<span className=\"slds-is-selected\">\n\t\t\t\t\t\t\t{visualPickerFigureSelected ?? onRenderVisualPickerSelected?.()}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<span className=\"slds-is-not-selected\">\n\t\t\t\t\t\t\t{visualPickerFigureNotSelected ??\n\t\t\t\t\t\t\t\tonRenderVisualPickerNotSelected?.()}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</div>\n\t\t\t\t) : (\n\t\t\t\t\t<span className=\"slds-visual-picker__figure slds-visual-picker__text slds-align_absolute-center\">\n\t\t\t\t\t\t{visualPickerFigure ?? onRenderVisualPicker?.()}\n\t\t\t\t\t</span>\n\t\t\t\t)}\n\t\t\t\t{!vertical && (\n\t\t\t\t\t<span className=\"slds-visual-picker__body\">\n\t\t\t\t\t\t{labels.heading && (\n\t\t\t\t\t\t\t<span className=\"slds-text-heading_small\">{labels.heading}</span>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t<span className=\"slds-text-title\">{labels.label}</span>\n\t\t\t\t\t</span>\n\t\t\t\t)}\n\t\t\t\t{!coverable && (\n\t\t\t\t\t<span className=\"slds-icon_container slds-visual-picker__text-check\">\n\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\tassistiveText={assistiveText}\n\t\t\t\t\t\t\tcategory=\"utility\"\n\t\t\t\t\t\t\tname=\"check\"\n\t\t\t\t\t\t\tcolorVariant=\"base\"\n\t\t\t\t\t\t\tsize=\"x-small\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</span>\n\t\t\t\t)}\n\t\t\t</label>\n\t\t);\n\t} else {\n\t\t// Base variant\n\t\tradioLabel = (\n\t\t\t<label className=\"slds-radio__label\" htmlFor={id} id={labelId}>\n\t\t\t\t<span className=\"slds-radio_faux\" />\n\t\t\t\t<span className=\"slds-form-element__label\">{labels.label}</span>\n\t\t\t\t{assistiveText.label && (\n\t\t\t\t\t<span className=\"slds-assistive-text\">{assistiveText.label}</span>\n\t\t\t\t)}\n\t\t\t</label>\n\t\t);\n\t}\n\n\treturn (\n\t\t<span\n\t\t\tclassName={classNames(\n\t\t\t\tvariant === 'visual-picker' ? `slds-visual-picker_${size}` : null,\n\t\t\t\t{\n\t\t\t\t\t'slds-radio': variant === 'base' || variant === 'swatch',\n\t\t\t\t\t'slds-button slds-radio_button': variant === 'button-group',\n\t\t\t\t\t'slds-visual-picker': variant === 'visual-picker',\n\t\t\t\t\t'slds-visual-picker_vertical':\n\t\t\t\t\t\tvariant === 'visual-picker' && vertical,\n\t\t\t\t},\n\t\t\t\tclassName as string\n\t\t\t)}\n\t\t>\n\t\t\t<input\n\t\t\t\ttype=\"radio\"\n\t\t\t\tid={id}\n\t\t\t\tname={name}\n\t\t\t\tvalue={value}\n\t\t\t\tchecked={!!checked}\n\t\t\t\tonFocus={onFocus}\n\t\t\t\tonChange={(event) => handleChange(event)}\n\t\t\t\tonClick={(event) => {\n\t\t\t\t\tif (checked && deselectable) {\n\t\t\t\t\t\thandleChange(event);\n\t\t\t\t\t}\n\t\t\t\t}}\n\t\t\t\tonKeyDown={(event) => {\n\t\t\t\t\tconst { key } = event;\n\t\t\t\t\tif (key === KEYS.SPACE && checked && deselectable) {\n\t\t\t\t\t\thandleChange(event, true);\n\t\t\t\t\t} else if (\n\t\t\t\t\t\t(key === KEYS.ENTER && checked && deselectable) ||\n\t\t\t\t\t\t(!checked && (key === KEYS.SPACE || key === KEYS.ENTER))\n\t\t\t\t\t) {\n\t\t\t\t\t\thandleChange(event);\n\t\t\t\t\t}\n\t\t\t\t}}\n\t\t\t\tdisabled={disabled}\n\t\t\t\ttabIndex={tabIndex}\n\t\t\t\taria-describedby={ariaDescribedBy}\n\t\t\t\taria-labelledby={ariaLabelledBy}\n\t\t\t\t{...ariaProps}\n\t\t\t\t{...dataProps}\n\t\t\t\tref={handleInputRef}\n\t\t\t/>\n\t\t\t{radioLabel}\n\t\t</span>\n\t);\n};\n\nRadio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sB,MAAY;GAClC,+BACC,MAAY,mBAAmB;EACjC,GACA,CACD;EAXD,UAAA,CAaC,kBAAC,SAAD;GACC,MAAK;GACD;GACE;GACC;GACP,SAAS,CAAC,CAAC;GACF;GACT,WAAW,MAAU,EAAa,CAAK;GACvC,UAAU,MAAU;IACnB,AAAI,KAAW,KACd,EAAa,CAAK;GAEpB;GACA,YAAY,MAAU;IACrB,IAAM,EAAE,WAAQ;IAChB,AAAI,MAAQ,EAAK,SAAS,KAAW,IACpC,EAAa,GAAO,EAAI,KAEvB,MAAQ,EAAK,SAAS,KAAW,KACjC,CAAC,MAAY,MAAQ,EAAK,SAAS,MAAQ,EAAK,WAEjD,EAAa,CAAK;GAEpB;GACU;GACA;GACV,oBAAkB;GAClB,mBAAiB;GACjB,GAAI;GACJ,GAAI;GACJ,KAAK;EACL,CAAA,GACA,CACI;;AAER;AAEA,EAAM,cAAc"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../components/radio/index.tsx"],"sourcesContent":["/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\nimport React, {\n\tuseRef,\n\tuseId,\n\tuseCallback,\n\tuseEffect,\n\ttype ChangeEvent,\n\ttype FocusEvent,\n\ttype KeyboardEvent,\n\ttype MouseEvent,\n\ttype CSSProperties,\n} from 'react';\nimport classNames from 'classnames';\nimport KEYS from '../../utilities/key-code';\nimport { RADIO } from '../../utilities/constants';\nimport getAriaProps from '../../utilities/get-aria-props';\nimport getDataProps from '../../utilities/get-data-props';\nimport Swatch from '../../components/color-picker/private/swatch';\nimport Icon from '../icon';\nimport { checkDeprecatedProps } from './check-props';\nimport componentDoc from './component.json';\n\n/**\n * Radio variant types\n */\nexport type RadioVariant = 'base' | 'button-group' | 'swatch' | 'visual-picker';\nexport type RadioSize = 'medium' | 'large';\n\n/**\n * Assistive text for Radio\n */\nexport interface RadioAssistiveText {\n\t/** Visually hidden label */\n\tlabel?: string;\n}\n\n/**\n * Labels for Radio\n */\nexport interface RadioLabels {\n\t/** Heading for visual picker variant */\n\theading?: string;\n\t/** Label for the radio input */\n\tlabel?: string;\n}\n\n/**\n * Refs for Radio\n */\nexport interface RadioRefs {\n\t/** Ref callback for input element */\n\tinput?: (input: HTMLInputElement | null) => void;\n}\n\n/**\n * Change event data for Radio\n */\nexport interface RadioChangeData {\n\t/**\n\t * The requested checked state: `true` when the user selects the radio,\n\t * `false` when a `deselectable` radio that is checked is clicked again.\n\t */\n\tchecked: boolean;\n}\n\n/**\n * Event passed to a Radio's `onChange`: the input's `change` event when a\n * click selects it, the `click` event when a click deselects a checked\n * `deselectable` radio (a checked radio fires no `change`), or the `keydown`\n * event when Enter or Space selects or deselects it.\n */\nexport type RadioChangeEvent =\n\t| ChangeEvent<HTMLInputElement>\n\t| MouseEvent<HTMLInputElement>\n\t| KeyboardEvent<HTMLInputElement>;\n\n/**\n * Change handler for Radio\n */\nexport type RadioChangeHandler = (\n\tevent: RadioChangeEvent,\n\tdata: RadioChangeData\n) => void;\n\n/**\n * Props for the Radio component\n */\ninterface RadioBaseProps {\n\t/** Assistive text for accessibility */\n\tassistiveText?: RadioAssistiveText;\n\t/** ARIA describedby attribute */\n\t'aria-describedby'?: string;\n\t/** ARIA labelledby attribute */\n\t'aria-labelledby'?: string;\n\t/**\n\t * Whether the radio is checked. Radio is controlled: update this prop from\n\t * `onChange`. Inside a `RadioGroup`/`RadioButtonGroup`, pass `value` to the\n\t * group instead and the group derives `checked` for each radio.\n\t */\n\tchecked: boolean;\n\t/** CSS classes */\n\tclassName?: string | string[] | Record<string, boolean>;\n\t/** Whether radio can be deselected */\n\tdeselectable?: boolean;\n\t/** Whether radio is disabled */\n\tdisabled?: boolean;\n\t/** Unique ID for the input */\n\tid?: string;\n\t/** ID for the label element */\n\tlabelId?: string;\n\t/** Text labels */\n\tlabels?: RadioLabels;\n\t/** Input name attribute */\n\tname?: string;\n\t/**\n\t * Called with the requested checked state in `data.checked`. The rendered\n\t * state only changes when `checked` is updated.\n\t */\n\tonChange: RadioChangeHandler;\n\t/** Focus handler */\n\tonFocus?: (event: FocusEvent<HTMLInputElement>) => void;\n\t/**\n\t * @deprecated Focus the radio through `refs.input` instead. Called with the `<input>`\n\t * when `requestFocus` is set. Works only in the 11.0.0 release candidates, and warns.\n\t */\n\tonRequestFocus?: (input: HTMLInputElement) => void;\n\t/** @deprecated Focus the radio through `refs.input` instead. Works only in the 11.0.0 release candidates, and warns. */\n\trequestFocus?: boolean;\n\t/** Tab index */\n\ttabIndex?: number;\n\t/** Input value */\n\tvalue?: string;\n\t/** Ref callbacks */\n\trefs?: RadioRefs;\n}\n\n/** Props only the visual picker takes. */\ninterface RadioVisualPickerOnlyProps {\n\t/** Visual picker: coverable when selected */\n\tcoverable?: boolean;\n\t/** Visual picker: vertical layout */\n\tvertical?: boolean;\n\t/** Visual picker: figure content, rendered inside `.slds-visual-picker__figure` when not `coverable` */\n\tvisualPickerFigure?: React.ReactNode;\n\t/** Visual picker: coverable figure content shown when selected */\n\tvisualPickerFigureSelected?: React.ReactNode;\n\t/** Visual picker: coverable figure content shown when not selected */\n\tvisualPickerFigureNotSelected?: React.ReactNode;\n\t/** @deprecated Use `visualPickerFigure` instead. */\n\tonRenderVisualPicker?: () => React.ReactNode;\n\t/** @deprecated Use `visualPickerFigureSelected` instead. */\n\tonRenderVisualPickerSelected?: () => React.ReactNode;\n\t/** @deprecated Use `visualPickerFigureNotSelected` instead. */\n\tonRenderVisualPickerNotSelected?: () => React.ReactNode;\n\t/** Visual picker: size. Defaults to `medium`. */\n\tsize?: RadioSize;\n}\n\n/** Visual-picker-only props, rejected by the other variants. */\ntype RadioVisualPickerOnlyNever = {\n\t[K in keyof RadioVisualPickerOnlyProps]?: never;\n};\n\n/** A plain radio, or a button inside a `RadioButtonGroup`. */\ninterface RadioPlainVariantProps extends RadioVisualPickerOnlyNever {\n\t/** Radio variant */\n\tvariant?: 'base' | 'button-group';\n\tstyle?: never;\n}\n\n/** A color swatch button. `value` is the color. */\ninterface RadioSwatchVariantProps extends RadioVisualPickerOnlyNever {\n\t/** Radio variant */\n\tvariant: 'swatch';\n\t/** Custom styles for the swatch */\n\tstyle?: CSSProperties;\n}\n\n/** An option inside a `VisualPicker`. */\ninterface RadioVisualPickerVariantProps extends RadioVisualPickerOnlyProps {\n\t/** Radio variant */\n\tvariant: 'visual-picker';\n\tstyle?: never;\n}\n\ntype RadioVariantProps =\n\t| RadioPlainVariantProps\n\t| RadioSwatchVariantProps\n\t| RadioVisualPickerVariantProps;\n\n/**\n * Props for the Radio component: a union on `variant`, so a prop that a\n * variant ignores is a compile error.\n */\nexport type RadioProps = RadioBaseProps & RadioVariantProps;\n\n/**\n * Props for a `Radio` rendered as a child of `RadioGroup` or\n * `RadioButtonGroup`. The group injects `checked` (derived from its `value`)\n * and `onChange`, so neither is required here.\n */\nexport type RadioGroupItemProps = Omit<RadioBaseProps, 'checked' | 'onChange'> &\n\tRadioVariantProps &\n\tRadioGroupItemOwnProps;\n\ninterface RadioGroupItemOwnProps {\n\t/**\n\t * @deprecated Pass `value` to the `RadioGroup`/`RadioButtonGroup` instead.\n\t * Only used when the group has no `value`.\n\t */\n\tchecked?: boolean;\n\t/** Ignored inside a group: the group's `onChange` is called instead. */\n\tonChange?: RadioChangeHandler;\n}\n\nconst defaultAssistiveText: RadioAssistiveText = {};\nconst defaultLabels: RadioLabels = {};\n\n/**\n * A radio input that can have a single input checked at any one time.\n * Radios should be wrapped with a RadioGroup or RadioButtonGroup.\n */\nconst Radio = (props: RadioProps): React.ReactElement => {\n\tconst {\n\t\tassistiveText: propAssistiveText,\n\t\t'aria-describedby': ariaDescribedBy,\n\t\t'aria-labelledby': ariaLabelledBy,\n\t\tchecked,\n\t\tclassName,\n\t\t// Removed in v11. Destructured so they never reach the DOM;\n\t\t// `checkDeprecatedProps` warns about them.\n\t\tdefaultChecked,\n\t\tdeselectable,\n\t\tdisabled,\n\t\tid: propId,\n\t\tlabelId,\n\t\tlabels: propLabels,\n\t\tlabel,\n\t\tname,\n\t\tonChange,\n\t\tonFocus,\n\t\tonRequestFocus,\n\t\trequestFocus,\n\t\ttabIndex,\n\t\tvalue,\n\t\tvariant = 'base',\n\t\tcoverable = false,\n\t\tvertical,\n\t\tvisualPickerFigure,\n\t\tvisualPickerFigureSelected,\n\t\tvisualPickerFigureNotSelected,\n\t\tonRenderVisualPicker,\n\t\tonRenderVisualPickerSelected,\n\t\tonRenderVisualPickerNotSelected,\n\t\tsize = 'medium',\n\t\trefs,\n\t\tstyle,\n\t\t...rest\n\t} = props as RadioBaseProps &\n\t\tPartial<RadioVisualPickerOnlyProps> & {\n\t\t\tvariant?: RadioVariant;\n\t\t\tstyle?: CSSProperties;\n\t\t} & {\n\t\t\tdefaultChecked?: boolean;\n\t\t\tlabel?: unknown;\n\t\t};\n\tconst generatedId = useId();\n\tconst preventDuplicateRef = useRef(false);\n\n\tconst id = propId || generatedId;\n\tconst assistiveText = { ...defaultAssistiveText, ...propAssistiveText };\n\tconst labels = { ...defaultLabels, ...propLabels };\n\n\tuseEffect(() => {\n\t\tcheckDeprecatedProps(\n\t\t\tRADIO,\n\t\t\t{\n\t\t\t\tdefaultChecked,\n\t\t\t\tlabel,\n\t\t\t\tonRenderVisualPicker,\n\t\t\t\tonRenderVisualPickerSelected,\n\t\t\t\tonRenderVisualPickerNotSelected,\n\t\t\t\tonRequestFocus,\n\t\t\t\trequestFocus,\n\t\t\t},\n\t\t\tcomponentDoc\n\t\t);\n\t}, [\n\t\tdefaultChecked,\n\t\tlabel,\n\t\tonRequestFocus,\n\t\trequestFocus,\n\t\tonRenderVisualPicker,\n\t\tonRenderVisualPickerSelected,\n\t\tonRenderVisualPickerNotSelected,\n\t]);\n\n\tconst ariaProps = getAriaProps(rest);\n\tconst dataProps = getDataProps(rest);\n\n\tconst handleChange = useCallback(\n\t\t(event: RadioChangeEvent, preventDuplicate?: boolean) => {\n\t\t\tif (!preventDuplicateRef.current) {\n\t\t\t\tpreventDuplicateRef.current = Boolean(preventDuplicate);\n\t\t\t\tonChange?.(event, { checked: !checked });\n\t\t\t} else {\n\t\t\t\tpreventDuplicateRef.current = false;\n\t\t\t}\n\t\t},\n\t\t[checked, onChange]\n\t);\n\n\tconst handleInputRef = useCallback(\n\t\t(input: HTMLInputElement | null) => {\n\t\t\trefs?.input?.(input);\n\t\t\tif (input && requestFocus && onRequestFocus) {\n\t\t\t\tonRequestFocus(input);\n\t\t\t}\n\t\t},\n\t\t[refs, requestFocus, onRequestFocus]\n\t);\n\n\t// Render the label based on variant\n\tlet radioLabel: React.ReactNode;\n\n\tif (variant === 'swatch') {\n\t\tradioLabel = (\n\t\t\t<label\n\t\t\t\tstyle={{ border: 'var(--slds-g-sizing-border-1, 1px)' }}\n\t\t\t\tclassName=\"slds-radio_button__label\"\n\t\t\t\thtmlFor={id}\n\t\t\t>\n\t\t\t\t<span>\n\t\t\t\t\t<Swatch label={labels.label} style={style} color={value ?? ''} />\n\t\t\t\t</span>\n\t\t\t</label>\n\t\t);\n\t} else if (variant === 'button-group') {\n\t\tradioLabel = (\n\t\t\t<label className=\"slds-radio_button__label\" htmlFor={id}>\n\t\t\t\t<span className=\"slds-radio_faux\">{labels.label}</span>\n\t\t\t</label>\n\t\t);\n\t} else if (variant === 'visual-picker') {\n\t\tradioLabel = (\n\t\t\t<label htmlFor={id}>\n\t\t\t\t{coverable ? (\n\t\t\t\t\t<div className=\"slds-visual-picker__figure slds-visual-picker__icon slds-align_absolute-center\">\n\t\t\t\t\t\t<span className=\"slds-is-selected\">\n\t\t\t\t\t\t\t{visualPickerFigureSelected ?? onRenderVisualPickerSelected?.()}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<span className=\"slds-is-not-selected\">\n\t\t\t\t\t\t\t{visualPickerFigureNotSelected ??\n\t\t\t\t\t\t\t\tonRenderVisualPickerNotSelected?.()}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</div>\n\t\t\t\t) : (\n\t\t\t\t\t<span className=\"slds-visual-picker__figure slds-visual-picker__text slds-align_absolute-center\">\n\t\t\t\t\t\t{visualPickerFigure ?? onRenderVisualPicker?.()}\n\t\t\t\t\t</span>\n\t\t\t\t)}\n\t\t\t\t{!vertical && (\n\t\t\t\t\t<span className=\"slds-visual-picker__body\">\n\t\t\t\t\t\t{labels.heading && (\n\t\t\t\t\t\t\t<span className=\"slds-text-heading_small\">{labels.heading}</span>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t<span className=\"slds-text-title\">{labels.label}</span>\n\t\t\t\t\t</span>\n\t\t\t\t)}\n\t\t\t\t{!coverable && (\n\t\t\t\t\t<span className=\"slds-icon_container slds-visual-picker__text-check\">\n\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\tassistiveText={assistiveText}\n\t\t\t\t\t\t\tcategory=\"utility\"\n\t\t\t\t\t\t\tname=\"check\"\n\t\t\t\t\t\t\tcolorVariant=\"base\"\n\t\t\t\t\t\t\tsize=\"x-small\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</span>\n\t\t\t\t)}\n\t\t\t</label>\n\t\t);\n\t} else {\n\t\t// Base variant\n\t\tradioLabel = (\n\t\t\t<label className=\"slds-radio__label\" htmlFor={id} id={labelId}>\n\t\t\t\t<span className=\"slds-radio_faux\" />\n\t\t\t\t<span className=\"slds-form-element__label\">{labels.label}</span>\n\t\t\t\t{assistiveText.label && (\n\t\t\t\t\t<span className=\"slds-assistive-text\">{assistiveText.label}</span>\n\t\t\t\t)}\n\t\t\t</label>\n\t\t);\n\t}\n\n\treturn (\n\t\t<span\n\t\t\tclassName={classNames(\n\t\t\t\tvariant === 'visual-picker' ? `slds-visual-picker_${size}` : null,\n\t\t\t\t{\n\t\t\t\t\t'slds-radio': variant === 'base' || variant === 'swatch',\n\t\t\t\t\t'slds-button slds-radio_button': variant === 'button-group',\n\t\t\t\t\t'slds-visual-picker': variant === 'visual-picker',\n\t\t\t\t\t'slds-visual-picker_vertical':\n\t\t\t\t\t\tvariant === 'visual-picker' && vertical,\n\t\t\t\t},\n\t\t\t\tclassName as string\n\t\t\t)}\n\t\t>\n\t\t\t<input\n\t\t\t\ttype=\"radio\"\n\t\t\t\tid={id}\n\t\t\t\tname={name}\n\t\t\t\tvalue={value}\n\t\t\t\tchecked={!!checked}\n\t\t\t\tonFocus={onFocus}\n\t\t\t\tonChange={(event) => handleChange(event)}\n\t\t\t\tonClick={(event) => {\n\t\t\t\t\tif (checked && deselectable) {\n\t\t\t\t\t\thandleChange(event);\n\t\t\t\t\t}\n\t\t\t\t}}\n\t\t\t\tonKeyDown={(event) => {\n\t\t\t\t\tconst { key } = event;\n\t\t\t\t\tif (key === KEYS.SPACE && checked && deselectable) {\n\t\t\t\t\t\thandleChange(event, true);\n\t\t\t\t\t} else if (\n\t\t\t\t\t\t(key === KEYS.ENTER && checked && deselectable) ||\n\t\t\t\t\t\t(!checked && (key === KEYS.SPACE || key === KEYS.ENTER))\n\t\t\t\t\t) {\n\t\t\t\t\t\thandleChange(event);\n\t\t\t\t\t}\n\t\t\t\t}}\n\t\t\t\tdisabled={disabled}\n\t\t\t\ttabIndex={tabIndex}\n\t\t\t\taria-describedby={ariaDescribedBy}\n\t\t\t\taria-labelledby={ariaLabelledBy}\n\t\t\t\t{...ariaProps}\n\t\t\t\t{...dataProps}\n\t\t\t\tref={handleInputRef}\n\t\t\t/>\n\t\t\t{radioLabel}\n\t\t</span>\n\t);\n};\n\nRadio.displayName = RADIO;\n\nexport default Radio;\n"],"mappings":";;;;;;;;;;;;AAyNA,IAAM,IAA2C,CAAC,GAC5C,IAA6B,CAAC,GAM9B,KAAS,MAA0C;CACxD,IAAM,EACL,eAAe,IACf,oBAAoB,IACpB,mBAAmB,GACnB,YACA,cAGA,mBACA,iBACA,aACA,IAAI,GACJ,YACA,QAAQ,GACR,UACA,UACA,aACA,YACA,mBACA,iBACA,aACA,UACA,aAAU,QACV,eAAY,IACZ,aACA,uBACA,+BACA,kCACA,yBACA,iCACA,oCACA,UAAO,UACP,SACA,U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S,KAAW,KACjC,CAAC,MAAY,MAAQ,EAAK,SAAS,MAAQ,EAAK,WAEjD,EAAa,CAAK;GAEpB;GACU;GACA;GACV,oBAAkB;GAClB,mBAAiB;GACjB,GAAI;GACJ,GAAI;GACJ,KAAK;EACL,CAAA,GACA,CACI;;AAER;AAEA,EAAM,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check-props.js","names":[],"sources":["../../../../components/radio-group/check-props.js"],"sourcesContent":["/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n/* eslint-disable import/no-mutable-exports */\n\nimport deprecatedProperty from '../../utilities/warning/deprecated-property';\nimport getComponentDocFn from '../../utilities/get-component-doc';\nimport requiredProperty from '../../utilities/warning/required-property';\n\nlet checkProps = function checkPropsFunction() {};\n\nif (process.env.NODE_ENV !== 'production') {\n\tcheckProps = function checkPropsFunction(COMPONENT, props, jsonDoc) {\n\t\tconst createDocUrl = getComponentDocFn(jsonDoc);\n\n\t\t// Without a group `value`, selection falls back to `checked` on each\n\t\t// child Radio. That
|
|
1
|
+
{"version":3,"file":"check-props.js","names":[],"sources":["../../../../components/radio-group/check-props.js"],"sourcesContent":["/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n/* eslint-disable import/no-mutable-exports */\n\nimport deprecatedProperty from '../../utilities/warning/deprecated-property';\nimport getComponentDocFn from '../../utilities/get-component-doc';\nimport requiredProperty from '../../utilities/warning/required-property';\n\nlet checkProps = function checkPropsFunction() {};\n\nif (process.env.NODE_ENV !== 'production') {\n\tcheckProps = function checkPropsFunction(COMPONENT, props, jsonDoc) {\n\t\tconst createDocUrl = getComponentDocFn(jsonDoc);\n\n\t\t// Without a group `value`, selection falls back to `checked` on each\n\t\t// child Radio. That works only in the 11.0.0 release candidates.\n\t\tdeprecatedProperty(\n\t\t\tCOMPONENT,\n\t\t\tprops.value === undefined ? true : undefined,\n\t\t\t'checked',\n\t\t\tundefined,\n\t\t\t`Pass \\`value\\` to RadioGroup or RadioButtonGroup instead of \\`checked\\` on each Radio, and read \\`data.value\\` in \\`onChange\\`. ${createDocUrl(\n\t\t\t\t'value'\n\t\t\t)}`\n\t\t);\n\n\t\t// React's own \"`checked` without `onChange`\" warning never fires,\n\t\t// because the group always attaches its own change handler.\n\t\trequiredProperty(\n\t\t\tCOMPONENT,\n\t\t\tprops.onChange !== undefined || !!props.disabled,\n\t\t\t'onChange',\n\t\t\t`RadioGroup and RadioButtonGroup are controlled: without \\`onChange\\`, selecting a radio does nothing. Update \\`value\\` from \\`data.value\\` in \\`onChange\\`, or set \\`disabled\\`. ${createDocUrl(\n\t\t\t\t'onChange'\n\t\t\t)}`\n\t\t);\n\t};\n}\n\nexport default checkProps;\n"],"mappings":";;;;AAQA,IAAI,IAAa,WAA8B,CAAC;AAEhD,QAAA,IAAA,aAA6B,iBAC5B,IAAa,SAA4B,GAAW,GAAO,GAAS;CACnE,IAAM,IAAe,EAAkB,CAAO;CAgB9C,AAZA,EACC,GACA,EAAM,UAAU,KAAA,KAAmB,KAAA,GACnC,WACA,KAAA,GACA,mIAAmI,EAClI,OACD,GACD,GAIA,EACC,GACA,EAAM,aAAa,KAAA,KAAa,CAAC,CAAC,EAAM,UACxC,YACA,oLAAoL,EACnL,UACD,GACD;AACD;AAGD,IAAA,IAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../components/radio-group/index.tsx"],"sourcesContent":["/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\nimport React, {\n\tuseEffect,\n\tuseId,\n\tuseMemo,\n\ttype ReactElement,\n\ttype CSSProperties,\n} from 'react';\nimport classNames from 'classnames';\nimport { RADIO_GROUP } from '../../utilities/constants';\nimport type {\n\tRadioChangeData,\n\tRadioChangeEvent,\n\tRadioChangeHandler,\n\tRadioGroupItemProps,\n} from '../radio/index';\nimport checkProps from './check-props';\nimport componentDoc from './component.json';\nimport type { ChildrenOf } from '../../types/common';\n\n/**\n * Radio group variant types\n */\nexport type RadioGroupVariant = 'base' | 'button-group';\n\n/**\n * Assistive text for RadioGroup\n */\nexport interface RadioGroupAssistiveText {\n\t/** Label for the group (shown in legend) */\n\tlabel?: string;\n\t/** Text for required indicator */\n\trequired?: string;\n}\n\n/**\n * Labels for RadioGroup\n */\nexport interface RadioGroupLabels {\n\t/** Error message to display */\n\terror?: string;\n\t/** Label above the radio group */\n\tlabel?: string;\n}\n\n/**\n * Change event data for RadioGroup\n */\nexport interface RadioGroupChangeData {\n\t/**\n\t * The requested selection: the `value` of the radio the user selected, or\n\t * `null` when a `deselectable` radio is deselected.\n\t */\n\tvalue: string | null;\n\t/**\n\t * Requested checked state of the radio that changed.\n\t * @deprecated Read `value` instead.\n\t */\n\tchecked: boolean;\n}\n\n/**\n * Called when the user selects a radio, with the requested selection in\n * `data.value`. The rendered selection only changes when `value` is updated.\n */\nexport type RadioGroupChangeHandler = (\n\tevent: RadioChangeEvent,\n\tdata: RadioGroupChangeData\n) => void;\n\n/**\n * The group is controlled, so `onChange` is required unless the group is\n * `disabled`: without it, selecting a radio does nothing.\n */\nexport type RadioGroupChangeProps =\n\t| {\n\t\t\t/**\n\t\t\t * Called when the user selects a radio, with the requested selection in\n\t\t\t * `data.value`. The rendered selection only changes when `value` is\n\t\t\t * updated. Required unless `disabled` is set.\n\t\t\t */\n\t\t\tonChange: RadioGroupChangeHandler;\n\t }\n\t| {
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../components/radio-group/index.tsx"],"sourcesContent":["/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\nimport React, {\n\tuseEffect,\n\tuseId,\n\tuseMemo,\n\ttype ReactElement,\n\ttype CSSProperties,\n} from 'react';\nimport classNames from 'classnames';\nimport { RADIO_GROUP } from '../../utilities/constants';\nimport type {\n\tRadioChangeData,\n\tRadioChangeEvent,\n\tRadioChangeHandler,\n\tRadioGroupItemProps,\n} from '../radio/index';\nimport checkProps from './check-props';\nimport componentDoc from './component.json';\nimport type { ChildrenOf } from '../../types/common';\n\n/**\n * Radio group variant types\n */\nexport type RadioGroupVariant = 'base' | 'button-group';\n\n/**\n * Assistive text for RadioGroup\n */\nexport interface RadioGroupAssistiveText {\n\t/** Label for the group (shown in legend) */\n\tlabel?: string;\n\t/** Text for required indicator */\n\trequired?: string;\n}\n\n/**\n * Labels for RadioGroup\n */\nexport interface RadioGroupLabels {\n\t/** Error message to display */\n\terror?: string;\n\t/** Label above the radio group */\n\tlabel?: string;\n}\n\n/**\n * Change event data for RadioGroup\n */\nexport interface RadioGroupChangeData {\n\t/**\n\t * The requested selection: the `value` of the radio the user selected, or\n\t * `null` when a `deselectable` radio is deselected.\n\t */\n\tvalue: string | null;\n\t/**\n\t * Requested checked state of the radio that changed.\n\t * @deprecated Read `value` instead.\n\t */\n\tchecked: boolean;\n}\n\n/**\n * Called when the user selects a radio, with the requested selection in\n * `data.value`. The rendered selection only changes when `value` is updated.\n */\nexport type RadioGroupChangeHandler = (\n\tevent: RadioChangeEvent,\n\tdata: RadioGroupChangeData\n) => void;\n\n/**\n * The group is controlled, so `onChange` is required unless the group is\n * `disabled`: without it, selecting a radio does nothing.\n */\nexport type RadioGroupChangeProps =\n\t| {\n\t\t\t/**\n\t\t\t * Called when the user selects a radio, with the requested selection in\n\t\t\t * `data.value`. The rendered selection only changes when `value` is\n\t\t\t * updated. Required unless `disabled` is set.\n\t\t\t */\n\t\t\tonChange: RadioGroupChangeHandler;\n\t }\n\t| {\n\t\t\t/** Disables the radio group. */\n\t\t\tdisabled: true;\n\t\t\t/** Called on change. Optional while disabled. */\n\t\t\tonChange?: RadioGroupChangeHandler;\n\t };\n\ninterface RadioGroupBaseProps {\n\t/** Assistive text for accessibility */\n\tassistiveText?: RadioGroupAssistiveText;\n\t/**\n\t * `Radio` elements (from `radio-group/radio`). The group passes each one\n\t * `name`, `onChange`, `aria-describedby`, `disabled` and, when `value` is\n\t * set, `checked`. A `Radio`'s own `name` wins, and its `aria-describedby`\n\t * is joined with the group's error id.\n\t */\n\tchildren: ChildrenOf<RadioGroupItemProps>;\n\t/** CSS classes */\n\tclassName?: string | string[] | Record<string, boolean>;\n\t/** Disable all radio inputs */\n\tdisabled?: boolean;\n\t/** ID for error message element */\n\terrorId?: string;\n\t/** Text labels */\n\tlabels?: RadioGroupLabels;\n\t/** Name attribute for all radios */\n\tname?: string;\n\t/** Whether the field is required */\n\trequired?: boolean;\n\t/**\n\t * The `value` of the selected radio, or `null` for no selection. The group\n\t * is controlled: each child radio is checked when its `value` equals this.\n\t * Leaving it `undefined` falls back to each `Radio`'s own `checked`\n\t * (deprecated).\n\t */\n\tvalue: string | null;\n}\n\n/** Radios stacked in a list. Has no wrapper element to style. */\ninterface RadioGroupBaseVariantProps {\n\t/** Group variant */\n\tvariant?: 'base';\n\tstyle?: never;\n}\n\n/** Radios rendered as a button group. */\ninterface RadioGroupButtonGroupVariantProps {\n\t/** Group variant */\n\tvariant: 'button-group';\n\t/** Custom styles for the button group */\n\tstyle?: CSSProperties;\n}\n\n/**\n * Props for the RadioGroup component: `style` styles the button-group wrapper,\n * so only `variant=\"button-group\"` accepts it.\n */\nexport type RadioGroupProps = RadioGroupBaseProps &\n\tRadioGroupChangeProps &\n\t(RadioGroupBaseVariantProps | RadioGroupButtonGroupVariantProps);\n\nconst defaultAssistiveText: RadioGroupAssistiveText = {\n\trequired: 'Required',\n};\n\nconst defaultLabels: RadioGroupLabels = {};\n\n/**\n * A styled select list that can have a single entry checked at any one time.\n * The RadioGroup component wraps Radio components, which should be used as children.\n */\nconst RadioGroup = ({\n\tassistiveText: propAssistiveText,\n\tchildren,\n\tclassName,\n\tdisabled,\n\terrorId: propErrorId,\n\tlabels: propLabels,\n\tname: propName,\n\tonChange,\n\trequired,\n\tstyle,\n\tvalue,\n\tvariant = 'base',\n}: RadioGroupProps): React.ReactElement => {\n\tconst generatedName = useId();\n\tconst generatedErrorId = useId();\n\n\tconst assistiveText = { ...defaultAssistiveText, ...propAssistiveText };\n\tconst labels = { ...defaultLabels, ...propLabels };\n\n\tconst name = propName || generatedName;\n\tconst hasError = Boolean(labels.error);\n\tconst errorId = hasError ? propErrorId || generatedErrorId : undefined;\n\n\tconst isControlled = value !== undefined;\n\n\tuseEffect(() => {\n\t\tcheckProps(RADIO_GROUP, { disabled, onChange, value }, componentDoc);\n\t});\n\n\t// Clone children with group props. With a group `value`, each radio's\n\t// `checked` is derived from it; without one (deprecated), the radio keeps\n\t// the `checked` it was given.\n\tconst enhancedChildren = useMemo(() => {\n\t\treturn React.Children.map(children, (child) => {\n\t\t\tif (React.isValidElement<RadioGroupItemProps>(child)) {\n\t\t\t\tconst childProps = child.props;\n\t\t\t\tconst childValue = childProps.value ?? null;\n\t\t\t\tconst handleChange: RadioChangeHandler = (\n\t\t\t\t\tevent,\n\t\t\t\t\tdata: RadioChangeData\n\t\t\t\t) => {\n\t\t\t\t\tonChange?.(event, {\n\t\t\t\t\t\tchecked: data.checked,\n\t\t\t\t\t\tvalue: data.checked ? childValue : null,\n\t\t\t\t\t});\n\t\t\t\t};\n\t\t\t\treturn React.cloneElement(child as ReactElement<RadioGroupItemProps>, {\n\t\t\t\t\tname: childProps.name ?? name,\n\t\t\t\t\tonChange: handleChange,\n\t\t\t\t\t'aria-describedby':\n\t\t\t\t\t\tclassNames(childProps['aria-describedby'], errorId) || undefined,\n\t\t\t\t\tdisabled: disabled || childProps.disabled,\n\t\t\t\t\t...(isControlled\n\t\t\t\t\t\t? { checked: childValue !== null && childValue === value }\n\t\t\t\t\t\t: {}),\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn child;\n\t\t});\n\t}, [children, name, onChange, errorId, disabled, isControlled, value]);\n\n\treturn (\n\t\t<fieldset\n\t\t\tclassName={classNames('slds-form-element', {\n\t\t\t\t'slds-has-error': hasError,\n\t\t\t})}\n\t\t>\n\t\t\t<legend\n\t\t\t\tclassName={classNames(\n\t\t\t\t\t'slds-form-element__legend',\n\t\t\t\t\t'slds-form-element__label',\n\t\t\t\t\t{ 'slds-assistive-text': assistiveText.label }\n\t\t\t\t)}\n\t\t\t>\n\t\t\t\t{required && (\n\t\t\t\t\t<abbr className=\"slds-required\" title=\"required\">\n\t\t\t\t\t\t*\n\t\t\t\t\t\t<div className=\"slds-assistive-text\">{assistiveText.required} </div>\n\t\t\t\t\t</abbr>\n\t\t\t\t)}\n\t\t\t\t{assistiveText.label || labels.label}\n\t\t\t</legend>\n\t\t\t<div\n\t\t\t\tclassName={classNames(\n\t\t\t\t\t'slds-form-element__control',\n\t\t\t\t\tclassName as string\n\t\t\t\t)}\n\t\t\t>\n\t\t\t\t{variant === 'button-group' ? (\n\t\t\t\t\t<div style={style} className=\"slds-radio_button-group\">\n\t\t\t\t\t\t{enhancedChildren}\n\t\t\t\t\t</div>\n\t\t\t\t) : (\n\t\t\t\t\tenhancedChildren\n\t\t\t\t)}\n\n\t\t\t\t{labels.error && (\n\t\t\t\t\t<div id={errorId} className=\"slds-form-element__help\">\n\t\t\t\t\t\t{labels.error}\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t</fieldset>\n\t);\n};\n\nRadioGroup.displayName = RADIO_GROUP;\n\nexport default RadioGroup;\n"],"mappings":";;;;;;;AAkJA,IAAM,IAAgD,EACrD,UAAU,WACX,GAEM,IAAkC,CAAC,GAMnC,KAAc,EACnB,eAAe,GACf,aACA,cACA,aACA,SAAS,GACT,QAAQ,GACR,MAAM,GACN,aACA,aACA,UACA,UACA,aAAU,aACgC;CAC1C,IAAM,IAAgB,EAAM,GACtB,IAAmB,EAAM,GAEzB,IAAgB;EAAE,GAAG;EAAsB,GAAG;CAAkB,GAChE,IAAS;EAAE,GAAG;EAAe,GAAG;CAA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C3B,UAAA;GACG,CAAA,IAEL,GAGA,EAAO,SACP,kBAAC,OAAD;IAAK,IAAI;IAAS,WAAU;IAC1B,UAAA,EAAO;GACJ,CAAA,CAEF;EACI,CAAA,CAAA;;AAEZ;AAEA,EAAW,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../components/scoped-notification/index.tsx"],"sourcesContent":["/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\nimport React, { useEffect, type ReactNode, type ReactElement } from 'react';\nimport classNames from 'classnames';\nimport Icon, { type IconProps } from '../icon';\nimport { SCOPED_NOTIFICATION } from '../../utilities/constants';\nimport checkProps from './check-props';\nimport componentDoc from './component.json';\n\n/**\n * Theme options for ScopedNotification\n */\nexport type ScopedNotificationTheme = 'dark' | 'light';\n\n/**\n * Assistive text for ScopedNotification\n */\nexport interface ScopedNotificationAssistiveText {\n\t/** Assistive text for icon */\n\ticon?: string;\n}\n\n/**\n * Props for the ScopedNotification component\n */\nexport interface ScopedNotificationProps {\n\t/** Assistive text for accessibility */\n\tassistiveText?: ScopedNotificationAssistiveText;\n\t/** CSS classes */\n\tclassName?: string | string[] | Record<string, boolean>;\n\t/** Content to display in the notification */\n\tchildren?: ReactNode;\n\t/** Custom `Icon`. Its own `assistiveText` wins over `assistiveText.icon`. */\n\ticon?: ReactElement<IconProps>;\n\t/** Theme for the notification */\n\ttheme?: ScopedNotificationTheme;\n}\n\n/**\n * Scoped Notification serves advisory information for the user\n * that is not important enough to justify an alert.\n */\nconst ScopedNotification = ({\n\tassistiveText,\n\tclassName,\n\tchildren,\n\ticon: propIcon,\n\ticonName,\n\ttheme,\n}: ScopedNotificationProps & {\n\t// Removed in v11. Destructured so it never reaches the DOM.\n\ticonName?: unknown;\n}): React.ReactElement => {\n\tuseEffect(() => {\n\t\tcheckProps(SCOPED_NOTIFICATION, { iconName }, componentDoc);\n\t}, [iconName]);\n\n\t// Build the icon element\n\tlet icon: ReactNode;\n\n\tif (propIcon) {\n\t\t// Clone the provided icon with merged assistive text\n\t\tconst { assistiveText: iconAssistiveText } = propIcon.props;\n\t\ticon = React.cloneElement(propIcon, {\n\t\t\tassistiveText: {\n\t\t\t\tlabel: assistiveText?.icon,\n\t\t\t\t...iconAssistiveText,\n\t\t\t},\n\t\t});\n\t} else {\n\t\t// Use default icon\n\t\ticon = (\n\t\t\t<Icon\n\t\t\t\tassistiveText={{\n\t\t\t\t\tlabel: assistiveText?.icon || 'Info',\n\t\t\t\t}}\n\t\t\t\tcategory=\"utility\"\n\t\t\t\tname=\"info\"\n\t\t\t\tcolorVariant={theme === 'dark' ? 'base' : undefined}\n\t\t\t\tsize=\"small\"\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<div\n\t\t\tclassName={classNames(\n\t\t\t\t'slds-scoped-notification',\n\t\t\t\t'slds-media',\n\t\t\t\t'slds-media_center',\n\t\t\t\t{\n\t\t\t\t\t'slds-scoped-notification_light': theme === 'light',\n\t\t\t\t\t'slds-scoped-notification_dark': theme === 'dark',\n\t\t\t\t},\n\t\t\t\tclassName as string\n\t\t\t)}\n\t\t\trole=\"status\"\n\t\t>\n\t\t\t<div className=\"slds-media__figure\">{icon}</div>\n\t\t\t<div className=\"slds-media__body\">{children}</div>\n\t\t</div>\n\t);\n};\n\nScopedNotification.displayName = SCOPED_NOTIFICATION;\n\nexport default ScopedNotification;\n"],"mappings":";;;;;;;;AA2CA,IAAM,KAAsB,EAC3B,kBACA,cACA,aACA,MAAM,GACN,aACA,
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../components/scoped-notification/index.tsx"],"sourcesContent":["/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\nimport React, { useEffect, type ReactNode, type ReactElement } from 'react';\nimport classNames from 'classnames';\nimport Icon, { type IconProps } from '../icon';\nimport { SCOPED_NOTIFICATION } from '../../utilities/constants';\nimport checkProps from './check-props';\nimport componentDoc from './component.json';\n\n/**\n * Theme options for ScopedNotification\n */\nexport type ScopedNotificationTheme = 'dark' | 'light';\n\n/**\n * Assistive text for ScopedNotification\n */\nexport interface ScopedNotificationAssistiveText {\n\t/** Assistive text for icon */\n\ticon?: string;\n}\n\n/**\n * Props for the ScopedNotification component\n */\nexport interface ScopedNotificationProps {\n\t/** Assistive text for accessibility */\n\tassistiveText?: ScopedNotificationAssistiveText;\n\t/** CSS classes */\n\tclassName?: string | string[] | Record<string, boolean>;\n\t/** Content to display in the notification */\n\tchildren?: ReactNode;\n\t/** Custom `Icon`. Its own `assistiveText` wins over `assistiveText.icon`. */\n\ticon?: ReactElement<IconProps>;\n\t/** Theme for the notification */\n\ttheme?: ScopedNotificationTheme;\n}\n\n/**\n * Scoped Notification serves advisory information for the user\n * that is not important enough to justify an alert.\n */\nconst ScopedNotification = ({\n\tassistiveText,\n\tclassName,\n\tchildren,\n\ticon: propIcon,\n\ticonName,\n\ttheme,\n}: ScopedNotificationProps & {\n\t// Removed in v11. Destructured so it never reaches the DOM.\n\t/** @deprecated Removed and ignored. Pass an `Icon` element to `icon`. */\n\ticonName?: unknown;\n}): React.ReactElement => {\n\tuseEffect(() => {\n\t\tcheckProps(SCOPED_NOTIFICATION, { iconName }, componentDoc);\n\t}, [iconName]);\n\n\t// Build the icon element\n\tlet icon: ReactNode;\n\n\tif (propIcon) {\n\t\t// Clone the provided icon with merged assistive text\n\t\tconst { assistiveText: iconAssistiveText } = propIcon.props;\n\t\ticon = React.cloneElement(propIcon, {\n\t\t\tassistiveText: {\n\t\t\t\tlabel: assistiveText?.icon,\n\t\t\t\t...iconAssistiveText,\n\t\t\t},\n\t\t});\n\t} else {\n\t\t// Use default icon\n\t\ticon = (\n\t\t\t<Icon\n\t\t\t\tassistiveText={{\n\t\t\t\t\tlabel: assistiveText?.icon || 'Info',\n\t\t\t\t}}\n\t\t\t\tcategory=\"utility\"\n\t\t\t\tname=\"info\"\n\t\t\t\tcolorVariant={theme === 'dark' ? 'base' : undefined}\n\t\t\t\tsize=\"small\"\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<div\n\t\t\tclassName={classNames(\n\t\t\t\t'slds-scoped-notification',\n\t\t\t\t'slds-media',\n\t\t\t\t'slds-media_center',\n\t\t\t\t{\n\t\t\t\t\t'slds-scoped-notification_light': theme === 'light',\n\t\t\t\t\t'slds-scoped-notification_dark': theme === 'dark',\n\t\t\t\t},\n\t\t\t\tclassName as string\n\t\t\t)}\n\t\t\trole=\"status\"\n\t\t>\n\t\t\t<div className=\"slds-media__figure\">{icon}</div>\n\t\t\t<div className=\"slds-media__body\">{children}</div>\n\t\t</div>\n\t);\n};\n\nScopedNotification.displayName = SCOPED_NOTIFICATION;\n\nexport default ScopedNotification;\n"],"mappings":";;;;;;;;AA2CA,IAAM,KAAsB,EAC3B,kBACA,cACA,aACA,MAAM,GACN,aACA,eAKyB;CACzB,QAAgB;EACf,EAAW,GAAqB,EAAE,YAAS,GAAG,CAAY;CAC3D,GAAG,CAAC,CAAQ,CAAC;CAGb,IAAI;CAEJ,IAAI,GAAU;EAEb,IAAM,EAAE,eAAe,MAAsB,EAAS;EACtD,IAAO,EAAM,aAAa,GAAU,EACnC,eAAe;GACd,OAAO,GAAe;GACtB,GAAG;EACJ,EACD,CAAC;CACF,OAEC,IACC,kBAAC,GAAD;EACC,eAAe,EACd,OAAO,GAAe,QAAQ,OAC/B;EACA,UAAS;EACT,MAAK;EACL,cAAc,MAAU,SAAS,SAAS,KAAA;EAC1C,MAAK;CACL,CAAA;CAIH,OACC,kBAAC,OAAD;EACC,WAAW,EACV,4BACA,cACA,qBACA;GACC,kCAAkC,MAAU;GAC5C,iCAAiC,MAAU;EAC5C,GACA,CACD;EACA,MAAK;EAXN,UAAA,CAaC,kBAAC,OAAD;GAAK,WAAU;GAAsB,UAAA;EAAU,CAAA,GAC/C,kBAAC,OAAD;GAAK,WAAU;GAAoB;EAAc,CAAA,CAC7C;;AAEP;AAEA,EAAmB,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step.js","names":[],"sources":["../../../../components/setup-assistant/step.tsx"],"sourcesContent":["/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\nimport React, {\n\ttype ReactNode,\n\ttype CSSProperties,\n\ttype SyntheticEvent,\n} from 'react';\nimport classNames from 'classnames';\n\nimport assign from 'lodash.assign';\n\n// This component's `checkProps` which issues warnings to developers about properties\n// when in development mode (similar to React's built in development tools)\nimport checkProps from './check-props';\nimport componentDoc from './component.json';\n\nimport Button from '../button';\nimport ProgressRing from '../progress-ring';\n\nimport Icon, { type IconProps } from '../icon';\n\nimport { SETUP_ASSISTANT_STEP } from '../../utilities/constants';\nimport isElementOfType from '../../utilities/is-element-of-type';\nimport generateId from '../../utilities/generate-id';\n\nexport interface StepAssistiveText {\n\t/** Button that examples a step */\n\texpandStep?: string;\n}\n\n/**\n * Data passed to `onToggleIsOpen`\n */\nexport interface StepToggleData {\n\t/** Index of the step within the Setup Assistant (set by the parent `SetupAssistant`) */\n\tindex?: number;\n\t/** Requested (next) open state: `true` to expand the step, `false` to collapse it */\n\tisOpen: boolean;\n\t/** Props of the step being toggled */\n\tstep: StepProps;\n}\n\nexport interface StepProps {\n\t/**\n\t * **Assistive text for accessibility**\n\t * This object is merged with the default props object on every render.\n\t * * `expandStep`: Button that examples a step\n\t * _Tested with snapshot testing._\n\t */\n\tassistiveText?: StepAssistiveText;\n\t/**\n\t * CSS class names to be added to the container element. `array`, `object`, or `string` are accepted.\n\t */\n\tclassName?: unknown[] | Record<string, unknown> | string;\n\t/**\n\t * Detailed description of the step\n\t */\n\tdescription?: string | ReactNode;\n\t/**\n\t * Estimated time for completing the step\n\t */\n\testimatedTime?: string | ReactNode;\n\t/**\n\t * Heading for the step\n\t */\n\theading?: string | ReactNode;\n\t/**\n\t * HTML id for component.\n\t */\n\tid?: string;\n\t/**\n\t * Dictates whether the step can be expanded / collapsed\n\t */\n\tisExpandable?: boolean;\n\t/**\n\t * Expanded state of an `isExpandable` step when it is controlled. When set, the step only expands and\n\t * collapses when this prop changes: update it from `onToggleIsOpen` (or the parent's\n\t * `onStepToggleIsOpen`). Leave it `undefined` for an uncontrolled step (see `defaultIsOpen`).\n\t */\n\tisOpen?: boolean;\n\t/**\n\t * Initial expanded state of an uncontrolled `isExpandable` step (`isOpen` is `undefined`). Defaults to `false`.\n\t */\n\tdefaultIsOpen?: boolean;\n\t/**\n\t * A step's available action(s). Typically a Button, Button of variant \"link,\" or Checkbox of variant \"toggle\"\n\t */\n\taction?: ReactNode;\n\t/**\n\t * Step content shown when an expandable step is open. Typically a ProgressIndicator and/or ScopedNotification component\n\t */\n\tcontent?: ReactNode;\n\t/**\n\t * Content within the media figure. Expects an Icon or ProgressRing component. An Icon is rendered at size `small`.\n\t */\n\tfigure?: ReactNode;\n\t/** @deprecated Use `action` instead. */\n\tonRenderAction?: () => ReactNode;\n\t/** @deprecated Use `content` instead. */\n\tonRenderContent?: () => ReactNode;\n\t/** @deprecated Use `figure` instead. */\n\tonRenderFigure?: () => ReactNode;\n\t/**\n\t * Called when the step requests to expand / collapse, controlled or not. `data.isOpen` is the\n\t * requested (next) state. Set by the parent `SetupAssistant` from `onStepToggleIsOpen` unless the\n\t * step passes its own.\n\t */\n\tonToggleIsOpen?: (event: SyntheticEvent, data: StepToggleData) => void;\n\t/**\n\t * Percentage of step completed. No progress indicator will be shown for the step unless this is provided\n\t */\n\tprogress?: number;\n\t/**\n\t * Display number for the step. Only appears if progress indicator is enabled. Determined automatically by parent if not provided.\n\t */\n\tstepNumber?: number;\n}\n\n/** Props the parent `SetupAssistant` injects. They aren't part of the public props. */\nexport interface StepInjectedProps {\n\t/** Index of the step within the Setup Assistant */\n\tindex?: number;\n}\n\ninterface StepState {\n\tisOpen: boolean;\n}\n\nconst defaultProps: Partial<StepProps> = {\n\tassistiveText: { expandStep: 'Expand Step' },\n};\n\n/**\n * Setup Assistant Step component is used to specify individual items within the Setup Assistant\n * filled with learning and task links along with a recommended sequence that may have progress tracking\n */\nclass Step extends React.Component<StepProps & StepInjectedProps, StepState> {\n\tstatic displayName = SETUP_ASSISTANT_STEP;\n\n\tstatic defaultProps = defaultProps;\n\n\tgeneratedId: string;\n\n\tconstructor(props: StepProps & StepInjectedProps) {\n\t\tsuper(props);\n\t\tthis.generatedId = generateId();\n\t\tthis.state = {\n\t\t\tisOpen: props.defaultIsOpen ?? false,\n\t\t};\n\t\tcheckProps(SETUP_ASSISTANT_STEP, { ...this.props }, componentDoc);\n\t}\n\n\tgetId() {\n\t\treturn this.props.id || this.generatedId;\n\t}\n\n\tgetIsOpen() {\n\t\treturn this.props.isOpen !== undefined\n\t\t\t? this.props.isOpen\n\t\t\t: this.state.isOpen;\n\t}\n\n\t// Controlled when `isOpen` is set: the step reports the requested state and waits for the prop.\n\ttoggleIsOpen = (event: SyntheticEvent) => {\n\t\tconst isOpen = !this.getIsOpen();\n\n\t\tif (this.props.isOpen === undefined) {\n\t\t\tthis.setState({ isOpen });\n\t\t}\n\n\t\tthis.props.onToggleIsOpen?.(event, {\n\t\t\tindex: this.props.index,\n\t\t\tisOpen,\n\t\t\tstep: this.props,\n\t\t});\n\t};\n\n\trenderMediaContent() {\n\t\treturn (\n\t\t\t<React.Fragment>\n\t\t\t\t<div className=\"slds-setup-assistant__step-summary-content slds-media__body\">\n\t\t\t\t\t<h3 className=\"slds-setup-assistant__step-summary-title slds-text-heading_small\">\n\t\t\t\t\t\t{this.props.isExpandable ? (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\taria-controls={`${this.getId()}-detail-content`}\n\t\t\t\t\t\t\t\tclassName=\"slds-button_reset\"\n\t\t\t\t\t\t\t\tlabel={this.props.heading}\n\t\t\t\t\t\t\t\tonClick={this.toggleIsOpen}\n\t\t\t\t\t\t\t\tvariant=\"base\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\tthis.props.heading\n\t\t\t\t\t\t)}\n\t\t\t\t\t</h3>\n\t\t\t\t\t<p>{this.props.description}</p>\n\t\t\t\t</div>\n\t\t\t\t<div className=\"slds-media__figure slds-media__figure_reverse\">\n\t\t\t\t\t{this.props.action ?? this.props.onRenderAction?.() ?? null}\n\t\t\t\t\t{this.props.estimatedTime ? (\n\t\t\t\t\t\t<p\n\t\t\t\t\t\t\tclassName={classNames(\n\t\t\t\t\t\t\t\t'slds-text-align_right',\n\t\t\t\t\t\t\t\t'slds-text-color_weak',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'slds-p-top_medium':\n\t\t\t\t\t\t\t\t\t\tthis.props.action !== undefined ||\n\t\t\t\t\t\t\t\t\t\tthis.props.onRenderAction !== undefined,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{this.props.estimatedTime}\n\t\t\t\t\t\t</p>\n\t\t\t\t\t) : null}\n\t\t\t\t</div>\n\t\t\t</React.Fragment>\n\t\t);\n\t}\n\n\trenderSummary() {\n\t\tlet figure: ReactNode;\n\t\tlet progressRingTheme: 'active' | 'complete' | undefined;\n\n\t\tif (\n\t\t\tthis.props.progress !== undefined &&\n\t\t\tthis.props.progress > 0 &&\n\t\t\tthis.props.progress < 100\n\t\t) {\n\t\t\tprogressRingTheme = 'active';\n\t\t} else if (this.props.progress === 100) {\n\t\t\tprogressRingTheme = 'complete';\n\t\t}\n\n\t\tif (this.props.figure !== undefined || this.props.onRenderFigure) {\n\t\t\tconst renderedFigure =\n\t\t\t\tthis.props.figure ?? this.props.onRenderFigure?.() ?? null;\n\n\t\t\tif (isElementOfType<IconProps>(renderedFigure, Icon)) {\n\t\t\t\tconst figureProps = renderedFigure.props;\n\t\t\t\tlet containerStyle: CSSProperties = {\n\t\t\t\t\tposition: 'relative',\n\t\t\t\t\ttop: this.props.isExpandable ? '5px' : '-3px',\n\t\t\t\t};\n\n\t\t\t\tif (figureProps.containerStyle) {\n\t\t\t\t\tcontainerStyle = {\n\t\t\t\t\t\t...containerStyle,\n\t\t\t\t\t\t...figureProps.containerStyle,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tconst clonedFigure = React.cloneElement(renderedFigure, {\n\t\t\t\t\t...figureProps,\n\t\t\t\t\tcontainerStyle,\n\t\t\t\t\tsize: 'small',\n\t\t\t\t} as Partial<unknown>);\n\t\t\t\tfigure = <div className=\"slds-media__figure\">{clonedFigure}</div>;\n\t\t\t} else {\n\t\t\t\tfigure = renderedFigure;\n\t\t\t}\n\t\t} else if (this.props.progress !== undefined) {\n\t\t\tfigure = (\n\t\t\t\t<div className=\"slds-media__figure\">\n\t\t\t\t\t<ProgressRing\n\t\t\t\t\t\thasIcon\n\t\t\t\t\t\ticon={this.props.progress === 100 ? null : this.props.stepNumber}\n\t\t\t\t\t\tflowDirection=\"fill\"\n\t\t\t\t\t\tsize=\"large\"\n\t\t\t\t\t\ttheme={progressRingTheme}\n\t\t\t\t\t\tvalue={this.props.progress}\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<div className=\"slds-setup-assistant__step-summary\">\n\t\t\t\t<div className=\"slds-media\">\n\t\t\t\t\t{figure}\n\t\t\t\t\t{this.props.isExpandable || this.props.progress !== undefined ? (\n\t\t\t\t\t\t<div className=\"slds-media__body slds-m-top_x-small\">\n\t\t\t\t\t\t\t<div className=\"slds-media\">{this.renderMediaContent()}</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) : (\n\t\t\t\t\t\tthis.renderMediaContent()\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t);\n\t}\n\n\trender() {\n\t\tconst assistiveText = assign(\n\t\t\t{},\n\t\t\tdefaultProps.assistiveText,\n\t\t\tthis.props.assistiveText\n\t\t);\n\t\treturn (\n\t\t\t<li\n\t\t\t\tclassName={classNames(\n\t\t\t\t\t'slds-setup-assistant__item',\n\t\t\t\t\tthis.props.className as string\n\t\t\t\t)}\n\t\t\t\tid={this.getId()}\n\t\t\t>\n\t\t\t\t<article className=\"slds-setup-assistant__step\">\n\t\t\t\t\t{this.props.isExpandable ? (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName={classNames('slds-summary-detail', {\n\t\t\t\t\t\t\t\t'slds-is-open': this.getIsOpen(),\n\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tassistiveText={{ icon: assistiveText.expandStep }}\n\t\t\t\t\t\t\t\taria-controls={`${this.getId()}-detail-content`}\n\t\t\t\t\t\t\t\tclassName=\"slds-m-right_x-small slds-m-top_x-small\"\n\t\t\t\t\t\t\t\ticonCategory=\"utility\"\n\t\t\t\t\t\t\t\ticonClassName=\"slds-summary-detail__action-icon\"\n\t\t\t\t\t\t\t\ticonName=\"switch\"\n\t\t\t\t\t\t\t\tonClick={this.toggleIsOpen}\n\t\t\t\t\t\t\t\tvariant=\"icon\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<div className=\"slds-container_fluid\">\n\t\t\t\t\t\t\t\t<div className=\"slds-summary-detail__title\">\n\t\t\t\t\t\t\t\t\t{this.renderSummary()}\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\tclassName=\"slds-summary-detail__content\"\n\t\t\t\t\t\t\t\t\tid={`${this.getId()}-detail-content`}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<div className=\"slds-setup-assistant__step-detail\">\n\t\t\t\t\t\t\t\t\t\t{this.props.content ??\n\t\t\t\t\t\t\t\t\t\t\tthis.props.onRenderContent?.() ??\n\t\t\t\t\t\t\t\t\t\t\tnull}\n\t\t\t\t\t\t\t\t\t</div>\n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file":"step.js","names":[],"sources":["../../../../components/setup-assistant/step.tsx"],"sourcesContent":["/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\nimport React, {\n\ttype ReactNode,\n\ttype CSSProperties,\n\ttype SyntheticEvent,\n} from 'react';\nimport classNames from 'classnames';\n\nimport assign from 'lodash.assign';\n\n// This component's `checkProps` which issues warnings to developers about properties\n// when in development mode (similar to React's built in development tools)\nimport checkProps from './check-props';\nimport componentDoc from './component.json';\n\nimport Button from '../button';\nimport ProgressRing from '../progress-ring';\n\nimport Icon, { type IconProps } from '../icon';\n\nimport { SETUP_ASSISTANT_STEP } from '../../utilities/constants';\nimport isElementOfType from '../../utilities/is-element-of-type';\nimport generateId from '../../utilities/generate-id';\n\nexport interface StepAssistiveText {\n\t/** Button that examples a step */\n\texpandStep?: string;\n}\n\n/**\n * Data passed to `onToggleIsOpen`\n */\nexport interface StepToggleData {\n\t/** Index of the step within the Setup Assistant (set by the parent `SetupAssistant`) */\n\tindex?: number;\n\t/** Requested (next) open state: `true` to expand the step, `false` to collapse it */\n\tisOpen: boolean;\n\t/** Props of the step being toggled */\n\tstep: StepProps;\n}\n\nexport interface StepProps {\n\t/**\n\t * **Assistive text for accessibility**\n\t * This object is merged with the default props object on every render.\n\t * * `expandStep`: Button that examples a step\n\t */\n\tassistiveText?: StepAssistiveText;\n\t/**\n\t * CSS class names to be added to the container element. `array`, `object`, or `string` are accepted.\n\t */\n\tclassName?: unknown[] | Record<string, unknown> | string;\n\t/**\n\t * Detailed description of the step\n\t */\n\tdescription?: string | ReactNode;\n\t/**\n\t * Estimated time for completing the step\n\t */\n\testimatedTime?: string | ReactNode;\n\t/**\n\t * Heading for the step\n\t */\n\theading?: string | ReactNode;\n\t/**\n\t * HTML id for component.\n\t */\n\tid?: string;\n\t/**\n\t * Dictates whether the step can be expanded / collapsed\n\t */\n\tisExpandable?: boolean;\n\t/**\n\t * Expanded state of an `isExpandable` step when it is controlled. When set, the step only expands and\n\t * collapses when this prop changes: update it from `onToggleIsOpen` (or the parent's\n\t * `onStepToggleIsOpen`). Leave it `undefined` for an uncontrolled step (see `defaultIsOpen`).\n\t */\n\tisOpen?: boolean;\n\t/**\n\t * Initial expanded state of an uncontrolled `isExpandable` step (`isOpen` is `undefined`). Defaults to `false`.\n\t */\n\tdefaultIsOpen?: boolean;\n\t/**\n\t * A step's available action(s). Typically a Button, Button of variant \"link,\" or Checkbox of variant \"toggle\"\n\t */\n\taction?: ReactNode;\n\t/**\n\t * Step content shown when an expandable step is open. Typically a ProgressIndicator and/or ScopedNotification component\n\t */\n\tcontent?: ReactNode;\n\t/**\n\t * Content within the media figure. Expects an Icon or ProgressRing component. An Icon is rendered at size `small`.\n\t */\n\tfigure?: ReactNode;\n\t/** @deprecated Use `action` instead. */\n\tonRenderAction?: () => ReactNode;\n\t/** @deprecated Use `content` instead. */\n\tonRenderContent?: () => ReactNode;\n\t/** @deprecated Use `figure` instead. */\n\tonRenderFigure?: () => ReactNode;\n\t/**\n\t * Called when the step requests to expand / collapse, controlled or not. `data.isOpen` is the\n\t * requested (next) state. Set by the parent `SetupAssistant` from `onStepToggleIsOpen` unless the\n\t * step passes its own.\n\t */\n\tonToggleIsOpen?: (event: SyntheticEvent, data: StepToggleData) => void;\n\t/**\n\t * Percentage of step completed. No progress indicator will be shown for the step unless this is provided\n\t */\n\tprogress?: number;\n\t/**\n\t * Display number for the step. Only appears if progress indicator is enabled. Determined automatically by parent if not provided.\n\t */\n\tstepNumber?: number;\n}\n\n/** Props the parent `SetupAssistant` injects. They aren't part of the public props. */\nexport interface StepInjectedProps {\n\t/** Index of the step within the Setup Assistant */\n\tindex?: number;\n}\n\ninterface StepState {\n\tisOpen: boolean;\n}\n\nconst defaultProps: Partial<StepProps> = {\n\tassistiveText: { expandStep: 'Expand Step' },\n};\n\n/**\n * Setup Assistant Step component is used to specify individual items within the Setup Assistant\n * filled with learning and task links along with a recommended sequence that may have progress tracking\n */\nclass Step extends React.Component<StepProps & StepInjectedProps, StepState> {\n\tstatic displayName = SETUP_ASSISTANT_STEP;\n\n\tstatic defaultProps = defaultProps;\n\n\tgeneratedId: string;\n\n\tconstructor(props: StepProps & StepInjectedProps) {\n\t\tsuper(props);\n\t\tthis.generatedId = generateId();\n\t\tthis.state = {\n\t\t\tisOpen: props.defaultIsOpen ?? false,\n\t\t};\n\t\tcheckProps(SETUP_ASSISTANT_STEP, { ...this.props }, componentDoc);\n\t}\n\n\tgetId() {\n\t\treturn this.props.id || this.generatedId;\n\t}\n\n\tgetIsOpen() {\n\t\treturn this.props.isOpen !== undefined\n\t\t\t? this.props.isOpen\n\t\t\t: this.state.isOpen;\n\t}\n\n\t// Controlled when `isOpen` is set: the step reports the requested state and waits for the prop.\n\ttoggleIsOpen = (event: SyntheticEvent) => {\n\t\tconst isOpen = !this.getIsOpen();\n\n\t\tif (this.props.isOpen === undefined) {\n\t\t\tthis.setState({ isOpen });\n\t\t}\n\n\t\tthis.props.onToggleIsOpen?.(event, {\n\t\t\tindex: this.props.index,\n\t\t\tisOpen,\n\t\t\tstep: this.props,\n\t\t});\n\t};\n\n\trenderMediaContent() {\n\t\treturn (\n\t\t\t<React.Fragment>\n\t\t\t\t<div className=\"slds-setup-assistant__step-summary-content slds-media__body\">\n\t\t\t\t\t<h3 className=\"slds-setup-assistant__step-summary-title slds-text-heading_small\">\n\t\t\t\t\t\t{this.props.isExpandable ? (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\taria-controls={`${this.getId()}-detail-content`}\n\t\t\t\t\t\t\t\tclassName=\"slds-button_reset\"\n\t\t\t\t\t\t\t\tlabel={this.props.heading}\n\t\t\t\t\t\t\t\tonClick={this.toggleIsOpen}\n\t\t\t\t\t\t\t\tvariant=\"base\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\tthis.props.heading\n\t\t\t\t\t\t)}\n\t\t\t\t\t</h3>\n\t\t\t\t\t<p>{this.props.description}</p>\n\t\t\t\t</div>\n\t\t\t\t<div className=\"slds-media__figure slds-media__figure_reverse\">\n\t\t\t\t\t{this.props.action ?? this.props.onRenderAction?.() ?? null}\n\t\t\t\t\t{this.props.estimatedTime ? (\n\t\t\t\t\t\t<p\n\t\t\t\t\t\t\tclassName={classNames(\n\t\t\t\t\t\t\t\t'slds-text-align_right',\n\t\t\t\t\t\t\t\t'slds-text-color_weak',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'slds-p-top_medium':\n\t\t\t\t\t\t\t\t\t\tthis.props.action !== undefined ||\n\t\t\t\t\t\t\t\t\t\tthis.props.onRenderAction !== undefined,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{this.props.estimatedTime}\n\t\t\t\t\t\t</p>\n\t\t\t\t\t) : null}\n\t\t\t\t</div>\n\t\t\t</React.Fragment>\n\t\t);\n\t}\n\n\trenderSummary() {\n\t\tlet figure: ReactNode;\n\t\tlet progressRingTheme: 'active' | 'complete' | undefined;\n\n\t\tif (\n\t\t\tthis.props.progress !== undefined &&\n\t\t\tthis.props.progress > 0 &&\n\t\t\tthis.props.progress < 100\n\t\t) {\n\t\t\tprogressRingTheme = 'active';\n\t\t} else if (this.props.progress === 100) {\n\t\t\tprogressRingTheme = 'complete';\n\t\t}\n\n\t\tif (this.props.figure !== undefined || this.props.onRenderFigure) {\n\t\t\tconst renderedFigure =\n\t\t\t\tthis.props.figure ?? this.props.onRenderFigure?.() ?? null;\n\n\t\t\tif (isElementOfType<IconProps>(renderedFigure, Icon)) {\n\t\t\t\tconst figureProps = renderedFigure.props;\n\t\t\t\tlet containerStyle: CSSProperties = {\n\t\t\t\t\tposition: 'relative',\n\t\t\t\t\ttop: this.props.isExpandable ? '5px' : '-3px',\n\t\t\t\t};\n\n\t\t\t\tif (figureProps.containerStyle) {\n\t\t\t\t\tcontainerStyle = {\n\t\t\t\t\t\t...containerStyle,\n\t\t\t\t\t\t...figureProps.containerStyle,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tconst clonedFigure = React.cloneElement(renderedFigure, {\n\t\t\t\t\t...figureProps,\n\t\t\t\t\tcontainerStyle,\n\t\t\t\t\tsize: 'small',\n\t\t\t\t} as Partial<unknown>);\n\t\t\t\tfigure = <div className=\"slds-media__figure\">{clonedFigure}</div>;\n\t\t\t} else {\n\t\t\t\tfigure = renderedFigure;\n\t\t\t}\n\t\t} else if (this.props.progress !== undefined) {\n\t\t\tfigure = (\n\t\t\t\t<div className=\"slds-media__figure\">\n\t\t\t\t\t<ProgressRing\n\t\t\t\t\t\thasIcon\n\t\t\t\t\t\ticon={this.props.progress === 100 ? null : this.props.stepNumber}\n\t\t\t\t\t\tflowDirection=\"fill\"\n\t\t\t\t\t\tsize=\"large\"\n\t\t\t\t\t\ttheme={progressRingTheme}\n\t\t\t\t\t\tvalue={this.props.progress}\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<div className=\"slds-setup-assistant__step-summary\">\n\t\t\t\t<div className=\"slds-media\">\n\t\t\t\t\t{figure}\n\t\t\t\t\t{this.props.isExpandable || this.props.progress !== undefined ? (\n\t\t\t\t\t\t<div className=\"slds-media__body slds-m-top_x-small\">\n\t\t\t\t\t\t\t<div className=\"slds-media\">{this.renderMediaContent()}</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) : (\n\t\t\t\t\t\tthis.renderMediaContent()\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t);\n\t}\n\n\trender() {\n\t\tconst assistiveText = assign(\n\t\t\t{},\n\t\t\tdefaultProps.assistiveText,\n\t\t\tthis.props.assistiveText\n\t\t);\n\t\treturn (\n\t\t\t<li\n\t\t\t\tclassName={classNames(\n\t\t\t\t\t'slds-setup-assistant__item',\n\t\t\t\t\tthis.props.className as string\n\t\t\t\t)}\n\t\t\t\tid={this.getId()}\n\t\t\t>\n\t\t\t\t<article className=\"slds-setup-assistant__step\">\n\t\t\t\t\t{this.props.isExpandable ? (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName={classNames('slds-summary-detail', {\n\t\t\t\t\t\t\t\t'slds-is-open': this.getIsOpen(),\n\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tassistiveText={{ icon: assistiveText.expandStep }}\n\t\t\t\t\t\t\t\taria-controls={`${this.getId()}-detail-content`}\n\t\t\t\t\t\t\t\tclassName=\"slds-m-right_x-small slds-m-top_x-small\"\n\t\t\t\t\t\t\t\ticonCategory=\"utility\"\n\t\t\t\t\t\t\t\ticonClassName=\"slds-summary-detail__action-icon\"\n\t\t\t\t\t\t\t\ticonName=\"switch\"\n\t\t\t\t\t\t\t\tonClick={this.toggleIsOpen}\n\t\t\t\t\t\t\t\tvariant=\"icon\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<div className=\"slds-container_fluid\">\n\t\t\t\t\t\t\t\t<div className=\"slds-summary-detail__title\">\n\t\t\t\t\t\t\t\t\t{this.renderSummary()}\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\tclassName=\"slds-summary-detail__content\"\n\t\t\t\t\t\t\t\t\tid={`${this.getId()}-detail-content`}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<div className=\"slds-setup-assistant__step-detail\">\n\t\t\t\t\t\t\t\t\t\t{this.props.content ??\n\t\t\t\t\t\t\t\t\t\t\tthis.props.onRenderContent?.() ??\n\t\t\t\t\t\t\t\t\t\t\tnull}\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) : (\n\t\t\t\t\t\tthis.renderSummary()\n\t\t\t\t\t)}\n\t\t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