@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":"index.cjs","names":[],"sources":["../../../../components/slider/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 {\n\tforwardRef,\n\tuseId,\n\tuseCallback,\n\tuseEffect,\n\ttype ChangeEvent,\n\ttype InputEvent,\n\ttype ReactNode,\n} from 'react';\nimport classNames from 'classnames';\nimport { SLIDER } from '../../utilities/constants';\nimport getAriaProps from '../../utilities/get-aria-props';\nimport checkProps from './check-props';\nimport componentDoc from './component.json';\n\n/**\n * Slider size options\n */\nexport type SliderSize = 'x-small' | 'small' | 'medium' | 'large';\n\n/**\n * Assistive text for Slider\n */\nexport interface SliderAssistiveText {\n\t/** Text for disabled state */\n\tdisabled?: string;\n\t/** Visually hidden label */\n\tlabel?: string;\n}\n\n/**\n * Labels for Slider\n */\nexport interface SliderLabels {\n\t/** Error message shown below the slider while `hasError` is true */\n\terror?: ReactNode;\n\t/** Visible label */\n\tlabel?: ReactNode;\n}\n\nexport type SliderChangeHandler = (\n\tevent: ChangeEvent<HTMLInputElement>,\n\tdata: { value: number }\n) => void;\n\n/**\n * `onChange` is required unless the slider is `disabled`: Slider is\n * controlled, so without it the thumb won't move.\n */\nexport type SliderChangeProps =\n\t| {\n\t\t\t/**\n\t\t\t * Called when the value changes. Slider is controlled: update `value`\n\t\t\t * from `data.value`, or the thumb won't move. Required unless `disabled`\n\t\t\t * is set.\n\t\t\t */\n\t\t\tonChange: SliderChangeHandler;\n\t }\n\t| { disabled: true; onChange?: SliderChangeHandler };\n\ninterface SliderBaseProps {\n\t/** ARIA describedby attribute */\n\t'aria-describedby'?: string;\n\t/**\n\t * **Assistive text for accessibility**\n\t * * `disabled`: Read after the range while the slider is disabled\n\t * * `label`: Visually hidden label. Use instead of `labels.label`.\n\t */\n\tassistiveText?: SliderAssistiveText;\n\t/** CSS classes for the root `.slds-form-element` div */\n\tclassName?: string | string[] | Record<string, boolean>;\n\t/** @deprecated Use `className`, which lands on the same element. */\n\tclassNameContainer?: string | string[] | Record<string, boolean>;\n\t/** Whether the slider is disabled */\n\tdisabled?: boolean;\n\t/** @deprecated Use `labels.error` and `hasError` instead. */\n\terrorText?: string;\n\t/** Puts the slider in an error state and shows `labels.error` */\n\thasError?: boolean;\n\t/** HTML id attribute */\n\tid?: string;\n\t/** @deprecated Use `labels.label` instead. */\n\tlabel?: string;\n\t/**\n\t * **Text labels for internationalization**\n\t * * `error`: Error message shown below the slider while `hasError` is true\n\t * * `label`: Visible label. Use `assistiveText.label` for a visually hidden label.\n\t */\n\tlabels?: SliderLabels;\n\t/** Maximum value (default: 100) */\n\tmax?: number;\n\t/** Minimum value (default: 0) */\n\tmin?: number;\n\t/** Form input name */\n\tname?: string;\n\t/** Called on input event */\n\tonInput?: (\n\t\tevent: InputEvent<HTMLInputElement>,\n\t\tdata: { value: number }\n\t) => void;\n\t/** Size of the slider */\n\tsize?: SliderSize;\n\t/** Step increment (default: 1) */\n\tstep?: number;\n\t/** The current value. Required: Slider is controlled. */\n\tvalue: number;\n\t/** Display vertically */\n\tvertical?: boolean;\n}\n\n/**\n * Props for the Slider component\n */\nexport type SliderProps = SliderBaseProps & SliderChangeProps;\n\n/**\n * Props removed in v11. They are ignored at runtime and warn in development.\n */\ninterface SliderRemovedProps {\n\t/** @removed Slider is controlled: pass `value` and update it in `onChange`. */\n\tdefaultValue?: unknown;\n}\n\nconst defaultAssistiveText: SliderAssistiveText = {\n\tdisabled: 'Disabled',\n};\n\n/**\n * The ability to style sliders with CSS varies across browsers.\n * Using this component ensures sliders look the same everywhere.\n */\nconst Slider = forwardRef<HTMLDivElement, SliderProps>((props, ref) => {\n\tconst {\n\t\t'aria-describedby': ariaDescribedBy,\n\t\tassistiveText: propAssistiveText,\n\t\tclassName,\n\t\tclassNameContainer,\n\t\tdefaultValue,\n\t\tdisabled,\n\t\terrorText,\n\t\thasError: hasErrorProp,\n\t\tid: propId,\n\t\tlabel: labelProp,\n\t\tlabels,\n\t\tmax = 100,\n\t\tmin = 0,\n\t\tname,\n\t\tonChange,\n\t\tonInput,\n\t\tsize,\n\t\tstep = 1,\n\t\tvalue,\n\t\tvertical,\n\t\t...rest\n\t} = props as SliderProps & SliderRemovedProps;\n\n\tconst generatedId = useId();\n\tconst generatedErrorId = useId();\n\n\tconst id = propId || generatedId;\n\t// `errorText` is deprecated: it sets both the error state and the message\n\tconst hasError = hasErrorProp ?? !!errorText;\n\tconst errorMessage = hasError ? (labels?.error ?? errorText) : undefined;\n\tconst errorId =\n\t\tariaDescribedBy || (errorMessage ? generatedErrorId : undefined);\n\tconst assistiveText = { ...defaultAssistiveText, ...propAssistiveText };\n\t// `label` is deprecated\n\tconst label = labels?.label ?? labelProp;\n\tconst labelText = label || assistiveText.label;\n\n\tuseEffect(() => {\n\t\tcheckProps(\n\t\t\tSLIDER,\n\t\t\t{\n\t\t\t\tassistiveText: propAssistiveText,\n\t\t\t\tclassNameContainer,\n\t\t\t\tdefaultValue,\n\t\t\t\tdisabled,\n\t\t\t\terrorText,\n\t\t\t\tlabel: labelProp,\n\t\t\t\tlabels,\n\t\t\t\tonChange,\n\t\t\t},\n\t\t\tcomponentDoc\n\t\t);\n\t}, [\n\t\tpropAssistiveText,\n\t\tclassNameContainer,\n\t\tdefaultValue,\n\t\tdisabled,\n\t\terrorText,\n\t\tlabelProp,\n\t\tlabels,\n\t\tonChange,\n\t]);\n\n\tconst ariaProps = getAriaProps(rest) as Record<string, unknown>;\n\tif (errorId) {\n\t\tariaProps['aria-describedby'] = errorId;\n\t}\n\n\tconst handleChange = useCallback(\n\t\t(event: ChangeEvent<HTMLInputElement>) => {\n\t\t\tonChange?.(event, { value: Number(event.target.value) });\n\t\t},\n\t\t[onChange]\n\t);\n\n\tconst handleInput = useCallback(\n\t\t(event: InputEvent<HTMLInputElement>) => {\n\t\t\tonInput?.(event, {\n\t\t\t\tvalue: Number((event.target as HTMLInputElement).value),\n\t\t\t});\n\t\t},\n\t\t[onInput]\n\t);\n\n\treturn (\n\t\t<div\n\t\t\tclassName={classNames(\n\t\t\t\t'slds-form-element',\n\t\t\t\t{ 'slds-has-error': hasError },\n\t\t\t\tclassNameContainer,\n\t\t\t\tclassName\n\t\t\t)}\n\t\t\tref={ref}\n\t\t>\n\t\t\t<label\n\t\t\t\tclassName={classNames('slds-form-element__label', {\n\t\t\t\t\t'slds-assistive-text': assistiveText.label && !label,\n\t\t\t\t})}\n\t\t\t\thtmlFor={id}\n\t\t\t>\n\t\t\t\t<span className=\"slds-slider-label\">\n\t\t\t\t\t{labelText && (\n\t\t\t\t\t\t<span className=\"slds-slider-label__label\">{labelText}</span>\n\t\t\t\t\t)}\n\t\t\t\t\t<span className=\"slds-slider-label__range\">\n\t\t\t\t\t\t{min} - {max}\n\t\t\t\t\t</span>\n\t\t\t\t\t{disabled && (\n\t\t\t\t\t\t<span className=\"slds-assistive-text\">\n\t\t\t\t\t\t\t{' '}\n\t\t\t\t\t\t\t{assistiveText.disabled}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t)}\n\t\t\t\t</span>\n\t\t\t</label>\n\t\t\t<div className=\"slds-form-element__control\">\n\t\t\t\t<div\n\t\t\t\t\tclassName={classNames('slds-slider', {\n\t\t\t\t\t\t'slds-slider_vertical': vertical,\n\t\t\t\t\t\t'slds-size_x-small': size === 'x-small',\n\t\t\t\t\t\t'slds-size_small': size === 'small',\n\t\t\t\t\t\t'slds-size_medium': size === 'medium',\n\t\t\t\t\t\t'slds-size_large': size === 'large',\n\t\t\t\t\t})}\n\t\t\t\t>\n\t\t\t\t\t<input\n\t\t\t\t\t\ttype=\"range\"\n\t\t\t\t\t\tid={id}\n\t\t\t\t\t\tname={name}\n\t\t\t\t\t\tclassName=\"slds-slider__range\"\n\t\t\t\t\t\tmin={min}\n\t\t\t\t\t\tmax={max}\n\t\t\t\t\t\tstep={step}\n\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\tonChange={handleChange}\n\t\t\t\t\t\tonInput={handleInput}\n\t\t\t\t\t\t{...ariaProps}\n\t\t\t\t\t\tvalue={value}\n\t\t\t\t\t/>\n\t\t\t\t\t<span className=\"slds-slider__value\" aria-hidden=\"true\">\n\t\t\t\t\t\t{value}\n\t\t\t\t\t</span>\n\t\t\t\t</div>\n\t\t\t\t{errorMessage && (\n\t\t\t\t\t<div id={errorId} className=\"slds-form-element__help\">\n\t\t\t\t\t\t{errorMessage}\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t</div>\n\t);\n});\n\nSlider.displayName = SLIDER;\n\nexport default Slider;\n"],"mappings":"iZA8HA,IAAM,EAA4C,CACjD,SAAU,UACX,EAMM,GAAA,EAAS,EAAA,WAAA,EAAyC,EAAO,IAAQ,CACtE,GAAM,CACL,mBAAoB,EACpB,cAAe,EACf,YACA,qBACA,eACA,WACA,YACA,SAAU,EACV,GAAI,EACJ,MAAO,EACP,SACA,MAAM,IACN,MAAM,EACN,OACA,WACA,UACA,OACA,OAAO,EACP,QACA,WACA,GAAG,GACA,EAEE,GAAA,EAAc,EAAA,MAAA,CAAM,EACpB,GAAA,EAAmB,EAAA,MAAA,CAAM,EAEzB,EAAK,GAAU,EAEf,EAAW,GAAgB,CAAC,CAAC,EAC7B,EAAe,EAAY,GAAQ,OAAS,EAAa,IAAA,GACzD,EACL,IAAoB,EAAe,EAAmB,IAAA,IACjD,EAAgB,CAAE,GAAG,EAAsB,GAAG,CAAkB,EAEhE,EAAQ,GAAQ,OAAS,EACzB,EAAY,GAAS,EAAc,OAEzC,EAAA,EAAA,UAAA,KAAgB,CACf,EAAA,QACC,EAAA,OACA,CACC,cAAe,EACf,qBACA,eACA,WACA,YACA,MAAO,EACP,SACA,UACD,EACA,EAAA,OACD,CACD,EAAG,CACF,EACA,EACA,EACA,EACA,EACA,EACA,EACA,CACD,CAAC,EAED,IAAM,EAAY,EAAA,QAAa,CAAI,EAC/B,IACH,EAAU,oBAAsB,GAGjC,IAAM,GAAA,EAAe,EAAA,YAAA,CACnB,GAAyC,CACzC,IAAW,EAAO,CAAE,MAAO,OAAO,EAAM,OAAO,KAAK,CAAE,CAAC,CACxD,EACA,CAAC,CAAQ,CACV,EAEM,GAAA,EAAc,EAAA,YAAA,CAClB,GAAwC,CACxC,IAAU,EAAO,CAChB,MAAO,OAAQ,EAAM,OAA4B,KAAK,CACvD,CAAC,CACF,EACA,CAAC,CAAO,CACT,EAEA,O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YAAc,EAAA"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../../../../components/slider/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 {\n\tforwardRef,\n\tuseId,\n\tuseCallback,\n\tuseEffect,\n\ttype ChangeEvent,\n\ttype InputEvent,\n\ttype ReactNode,\n} from 'react';\nimport classNames from 'classnames';\nimport { SLIDER } from '../../utilities/constants';\nimport getAriaProps from '../../utilities/get-aria-props';\nimport checkProps from './check-props';\nimport componentDoc from './component.json';\n\n/**\n * Slider size options\n */\nexport type SliderSize = 'x-small' | 'small' | 'medium' | 'large';\n\n/**\n * Assistive text for Slider\n */\nexport interface SliderAssistiveText {\n\t/** Text for disabled state */\n\tdisabled?: string;\n\t/** Visually hidden label */\n\tlabel?: string;\n}\n\n/**\n * Labels for Slider\n */\nexport interface SliderLabels {\n\t/** Error message shown below the slider while `hasError` is true */\n\terror?: ReactNode;\n\t/** Visible label */\n\tlabel?: ReactNode;\n}\n\nexport type SliderChangeHandler = (\n\tevent: ChangeEvent<HTMLInputElement>,\n\tdata: { value: number }\n) => void;\n\n/**\n * `onChange` is required unless the slider is `disabled`: Slider is\n * controlled, so without it the thumb won't move.\n */\nexport type SliderChangeProps =\n\t| {\n\t\t\t/**\n\t\t\t * Called when the value changes. Slider is controlled: update `value`\n\t\t\t * from `data.value`, or the thumb won't move. Required unless `disabled`\n\t\t\t * is set.\n\t\t\t */\n\t\t\tonChange: SliderChangeHandler;\n\t }\n\t| {\n\t\t\t/** Disables the slider. */\n\t\t\tdisabled: true;\n\t\t\t/** Called on change. Optional while disabled. */\n\t\t\tonChange?: SliderChangeHandler;\n\t };\n\ninterface SliderBaseProps {\n\t/** ARIA describedby attribute */\n\t'aria-describedby'?: string;\n\t/**\n\t * **Assistive text for accessibility**\n\t * * `disabled`: Read after the range while the slider is disabled\n\t * * `label`: Visually hidden label. Use instead of `labels.label`.\n\t */\n\tassistiveText?: SliderAssistiveText;\n\t/** CSS classes for the root `.slds-form-element` div */\n\tclassName?: string | string[] | Record<string, boolean>;\n\t/** @deprecated Use `className`, which lands on the same element. */\n\tclassNameContainer?: string | string[] | Record<string, boolean>;\n\t/** Whether the slider is disabled */\n\tdisabled?: boolean;\n\t/** @deprecated Use `labels.error` and `hasError` instead. */\n\terrorText?: string;\n\t/** Puts the slider in an error state and shows `labels.error` */\n\thasError?: boolean;\n\t/** HTML id attribute */\n\tid?: string;\n\t/** @deprecated Use `labels.label` instead. */\n\tlabel?: string;\n\t/**\n\t * **Text labels for internationalization**\n\t * * `error`: Error message shown below the slider while `hasError` is true\n\t * * `label`: Visible label. Use `assistiveText.label` for a visually hidden label.\n\t */\n\tlabels?: SliderLabels;\n\t/** Maximum value (default: 100) */\n\tmax?: number;\n\t/** Minimum value (default: 0) */\n\tmin?: number;\n\t/** Form input name */\n\tname?: string;\n\t/** Called on input event */\n\tonInput?: (\n\t\tevent: InputEvent<HTMLInputElement>,\n\t\tdata: { value: number }\n\t) => void;\n\t/** Size of the slider */\n\tsize?: SliderSize;\n\t/** Step increment (default: 1) */\n\tstep?: number;\n\t/** The current value. Required: Slider is controlled. */\n\tvalue: number;\n\t/** Display vertically */\n\tvertical?: boolean;\n}\n\n/**\n * Props for the Slider component\n */\nexport type SliderProps = SliderBaseProps & SliderChangeProps;\n\n/**\n * Props removed in v11. They are ignored at runtime and warn in development.\n */\ninterface SliderRemovedProps {\n\t/** @removed Slider is controlled: pass `value` and update it in `onChange`. */\n\tdefaultValue?: unknown;\n}\n\nconst defaultAssistiveText: SliderAssistiveText = {\n\tdisabled: 'Disabled',\n};\n\n/**\n * A range input to select a number between `min` and `max`. It looks the same\n * in every browser.\n */\nconst Slider = forwardRef<HTMLDivElement, SliderProps>((props, ref) => {\n\tconst {\n\t\t'aria-describedby': ariaDescribedBy,\n\t\tassistiveText: propAssistiveText,\n\t\tclassName,\n\t\tclassNameContainer,\n\t\tdefaultValue,\n\t\tdisabled,\n\t\terrorText,\n\t\thasError: hasErrorProp,\n\t\tid: propId,\n\t\tlabel: labelProp,\n\t\tlabels,\n\t\tmax = 100,\n\t\tmin = 0,\n\t\tname,\n\t\tonChange,\n\t\tonInput,\n\t\tsize,\n\t\tstep = 1,\n\t\tvalue,\n\t\tvertical,\n\t\t...rest\n\t} = props as SliderProps & SliderRemovedProps;\n\n\tconst generatedId = useId();\n\tconst generatedErrorId = useId();\n\n\tconst id = propId || generatedId;\n\t// `errorText` is deprecated: it sets both the error state and the message\n\tconst hasError = hasErrorProp ?? !!errorText;\n\tconst errorMessage = hasError ? (labels?.error ?? errorText) : undefined;\n\tconst errorId =\n\t\tariaDescribedBy || (errorMessage ? generatedErrorId : undefined);\n\tconst assistiveText = { ...defaultAssistiveText, ...propAssistiveText };\n\t// `label` is deprecated\n\tconst label = labels?.label ?? labelProp;\n\tconst labelText = label || assistiveText.label;\n\n\tuseEffect(() => {\n\t\tcheckProps(\n\t\t\tSLIDER,\n\t\t\t{\n\t\t\t\tassistiveText: propAssistiveText,\n\t\t\t\tclassNameContainer,\n\t\t\t\tdefaultValue,\n\t\t\t\tdisabled,\n\t\t\t\terrorText,\n\t\t\t\tlabel: labelProp,\n\t\t\t\tlabels,\n\t\t\t\tonChange,\n\t\t\t},\n\t\t\tcomponentDoc\n\t\t);\n\t}, [\n\t\tpropAssistiveText,\n\t\tclassNameContainer,\n\t\tdefaultValue,\n\t\tdisabled,\n\t\terrorText,\n\t\tlabelProp,\n\t\tlabels,\n\t\tonChange,\n\t]);\n\n\tconst ariaProps = getAriaProps(rest) as Record<string, unknown>;\n\tif (errorId) {\n\t\tariaProps['aria-describedby'] = errorId;\n\t}\n\n\tconst handleChange = useCallback(\n\t\t(event: ChangeEvent<HTMLInputElement>) => {\n\t\t\tonChange?.(event, { value: Number(event.target.value) });\n\t\t},\n\t\t[onChange]\n\t);\n\n\tconst handleInput = useCallback(\n\t\t(event: InputEvent<HTMLInputElement>) => {\n\t\t\tonInput?.(event, {\n\t\t\t\tvalue: Number((event.target as HTMLInputElement).value),\n\t\t\t});\n\t\t},\n\t\t[onInput]\n\t);\n\n\treturn (\n\t\t<div\n\t\t\tclassName={classNames(\n\t\t\t\t'slds-form-element',\n\t\t\t\t{ 'slds-has-error': hasError },\n\t\t\t\tclassNameContainer,\n\t\t\t\tclassName\n\t\t\t)}\n\t\t\tref={ref}\n\t\t>\n\t\t\t<label\n\t\t\t\tclassName={classNames('slds-form-element__label', {\n\t\t\t\t\t'slds-assistive-text': assistiveText.label && !label,\n\t\t\t\t})}\n\t\t\t\thtmlFor={id}\n\t\t\t>\n\t\t\t\t<span className=\"slds-slider-label\">\n\t\t\t\t\t{labelText && (\n\t\t\t\t\t\t<span className=\"slds-slider-label__label\">{labelText}</span>\n\t\t\t\t\t)}\n\t\t\t\t\t<span className=\"slds-slider-label__range\">\n\t\t\t\t\t\t{min} - {max}\n\t\t\t\t\t</span>\n\t\t\t\t\t{disabled && (\n\t\t\t\t\t\t<span className=\"slds-assistive-text\">\n\t\t\t\t\t\t\t{' '}\n\t\t\t\t\t\t\t{assistiveText.disabled}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t)}\n\t\t\t\t</span>\n\t\t\t</label>\n\t\t\t<div className=\"slds-form-element__control\">\n\t\t\t\t<div\n\t\t\t\t\tclassName={classNames('slds-slider', {\n\t\t\t\t\t\t'slds-slider_vertical': vertical,\n\t\t\t\t\t\t'slds-size_x-small': size === 'x-small',\n\t\t\t\t\t\t'slds-size_small': size === 'small',\n\t\t\t\t\t\t'slds-size_medium': size === 'medium',\n\t\t\t\t\t\t'slds-size_large': size === 'large',\n\t\t\t\t\t})}\n\t\t\t\t>\n\t\t\t\t\t<input\n\t\t\t\t\t\ttype=\"range\"\n\t\t\t\t\t\tid={id}\n\t\t\t\t\t\tname={name}\n\t\t\t\t\t\tclassName=\"slds-slider__range\"\n\t\t\t\t\t\tmin={min}\n\t\t\t\t\t\tmax={max}\n\t\t\t\t\t\tstep={step}\n\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\tonChange={handleChange}\n\t\t\t\t\t\tonInput={handleInput}\n\t\t\t\t\t\t{...ariaProps}\n\t\t\t\t\t\tvalue={value}\n\t\t\t\t\t/>\n\t\t\t\t\t<span className=\"slds-slider__value\" aria-hidden=\"true\">\n\t\t\t\t\t\t{value}\n\t\t\t\t\t</span>\n\t\t\t\t</div>\n\t\t\t\t{errorMessage && (\n\t\t\t\t\t<div id={errorId} className=\"slds-form-element__help\">\n\t\t\t\t\t\t{errorMessage}\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t</div>\n\t);\n});\n\nSlider.displayName = SLIDER;\n\nexport default Slider;\n"],"mappings":"iZAmIA,IAAM,EAA4C,CACjD,SAAU,UACX,EAMM,GAAA,EAAS,EAAA,WAAA,EAAyC,EAAO,IAAQ,CACtE,GAAM,CACL,mBAAoB,EACpB,cAAe,EACf,YACA,qBACA,eACA,WACA,YACA,SAAU,EACV,GAAI,EACJ,MAAO,EACP,SACA,MAAM,IACN,MAAM,EACN,OACA,WACA,UACA,OACA,OAAO,EACP,QACA,WACA,GAAG,GACA,EAEE,GAAA,EAAc,EAAA,MAAA,CAAM,EACpB,GAAA,EAAmB,EAAA,MAAA,CAAM,EAEzB,EAAK,GAAU,EAEf,EAAW,GAAgB,CAAC,CAAC,EAC7B,EAAe,EAAY,GAAQ,OAAS,EAAa,IAAA,GACzD,EACL,IAAoB,EAAe,EAAmB,IAAA,IACjD,EAAgB,CAAE,GAAG,EAAsB,GAAG,CAAkB,EAEhE,EAAQ,GAAQ,OAAS,EACzB,EAAY,GAAS,EAAc,OAEzC,EAAA,EAAA,UAAA,KAAgB,CACf,EAAA,QACC,EAAA,OACA,CACC,cAAe,EACf,qBACA,eACA,WACA,YACA,MAAO,EACP,SACA,UACD,EACA,EAAA,OACD,CACD,EAAG,CACF,EACA,EACA,EACA,EACA,EACA,EACA,EACA,CACD,CAAC,EAED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AAC,QAAD,CACC,KAAK,QACD,KACE,OACN,UAAU,qBACL,MACA,MACC,OACI,WACV,SAAU,EACV,QAAS,EACT,GAAI,EACG,OACP,CAAA,GACD,EAAA,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,qBAAqB,cAAY,OAC/C,SAAA,CACI,CAAA,CACF,CACJ,CAAA,EAAA,IACA,EAAA,EAAA,IAAA,CAAC,MAAD,CAAK,GAAI,EAAS,UAAU,0BAC1B,SAAA,CACG,CAAA,CAEF,CACD,CAAA,CAAA,GAEP,CAAC,EAED,EAAO,YAAc,EAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"header.cjs","names":[],"sources":["../../../../components/split-view/header.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 from 'react';\nimport classNames from 'classnames';\nimport PageHeader, { type PageHeaderProps } from '../page-header';\n\nimport { SPLIT_VIEW_HEADER } from '../../utilities/constants';\n\n/** The Split View Header takes the same properties as `PageHeader`. */\nexport type SplitViewHeaderProps = PageHeaderProps;\n\n/**\n * The Split View Header takes the same properties as the
|
|
1
|
+
{"version":3,"file":"header.cjs","names":[],"sources":["../../../../components/split-view/header.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 from 'react';\nimport classNames from 'classnames';\nimport PageHeader, { type PageHeaderProps } from '../page-header';\n\nimport { SPLIT_VIEW_HEADER } from '../../utilities/constants';\n\n/** The Split View Header takes the same properties as `PageHeader`. */\nexport type SplitViewHeaderProps = PageHeaderProps;\n\n/**\n * The Split View Header takes the same properties as the `PageHeader` component.\n */\nconst SplitViewHeader = ({\n\tclassName,\n\t...rest\n}: SplitViewHeaderProps): React.ReactElement => (\n\t<PageHeader\n\t\tclassName={classNames(\n\t\t\t'slds-split-view__header slds-has-bottom-magnet',\n\t\t\tclassName\n\t\t)}\n\t\t{...rest}\n\t/>\n);\n\nSplitViewHeader.displayName = SPLIT_VIEW_HEADER;\n\nexport default SplitViewHeader;\n"],"mappings":"iQAeA,IAAM,GAAmB,CACxB,YACA,GAAG,MAEH,EAAA,EAAA,IAAA,CAAC,EAAA,QAAD,CACC,WAAA,EAAW,EAAA,QAAA,CACV,iDACA,CACD,EACA,GAAI,CACJ,CAAA,EAGF,EAAgB,YAAc,EAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":[],"sources":["../../../../components/tabs/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\tuseState,\n\tuseRef,\n\tuseCallback,\n\tuseEffect,\n\tuseId,\n\ttype MouseEvent,\n\ttype KeyboardEvent,\n} from 'react';\nimport classNames from 'classnames';\n\n// Child components\nimport TabsList from './private/tabs-list';\nimport Tab from './private/tab';\nimport TabPanel from './private/tab-panel';\nimport type { TabsPanelProps } from './panel';\nimport type { ChildrenOf } from '../../types/common';\n\nimport { TABS } from '../../utilities/constants';\nimport KEYS from '../../utilities/key-code';\nimport EventUtil from '../../utilities/event';\n\nimport checkProps from './check-props';\nimport componentDoc from './component.json';\n\n/**\n * Tabs variant types\n */\nexport type TabsVariant = 'default' | 'scoped' | 'vertical';\n\n/** @deprecated Use `TabsPanelProps` from `tabs/panel`. */\nexport type TabChildProps = TabsPanelProps;\n\n/**\n * Data passed to the Tabs `onSelect` callback\n */\nexport interface TabsSelectData {\n\t/**\n\t * `value` of the tab being selected: the panel's `value`, or its index as a\n\t * string (`'0'`, `'1'`, ...) when the panel has no `value`.\n\t */\n\tvalue: string;\n\t/**\n\t * `value` of the tab that was selected before this selection, or `undefined`\n\t * when no tab was selected.\n\t */\n\tpreviousValue: string | undefined;\n\t/** Index of the tab being selected */\n\tselectedIndex: number;\n\t/** Index of the tab that was selected before this selection, or `-1` when no tab was selected */\n\tpreviousIndex: number;\n}\n\n/**\n * Props shared by both ways of controlling the selected tab\n */\ninterface TabsBaseProps {\n\t/** `TabsPanel` elements, one per tab. Tabs reads each panel's `label`, `value`, `disabled`, `hasError` and `assistiveText`. */\n\tchildren: ChildrenOf<TabsPanelProps>;\n\t/** CSS classes */\n\tclassName?: string | string[] | Record<string, boolean>;\n\t/** HTML id */\n\tid?: string;\n\t/**\n\t * Called when a tab is requested by click or arrow key. Receives the triggering event and\n\t * `{ value, previousValue, selectedIndex, previousIndex }`. Tabs is controlled: update `value`\n\t * from this callback to change tabs. It is not called for a disabled tab or for the tab that is\n\t * already selected.\n\t */\n\tonSelect: (\n\t\tevent: MouseEvent<HTMLDivElement> | KeyboardEvent<HTMLDivElement>,\n\t\tdata: TabsSelectData\n\t) => void;\n\t/** Tab style variant */\n\tvariant?: TabsVariant;\n}\n\n/**\n * Select the tab by the `value` of its `TabsPanel`.\n */\ninterface TabsValueProps {\n\t/**\n\t * `value` of the selected `TabsPanel` (required, controlled). A panel without a `value` is\n\t * matched by its index as a string (`'0'`, `'1'`, ...). When no panel matches, no tab is selected.\n\t */\n\tvalue: string;\n\tselectedIndex?: never;\n}\n\n/**\n * Select the tab by index (deprecated).\n */\ninterface TabsSelectedIndexProps {\n\tvalue?: undefined;\n\t/**\n\t * @deprecated Use `value` instead (set `value` on each `TabsPanel`, or use the index as a\n\t * string). Index of the selected tab, controlled. Used only when `value` is not passed.\n\t */\n\tselectedIndex: number;\n}\n\n/**\n * Props for the Tabs component\n */\nexport type TabsProps = TabsBaseProps &\n\t(TabsValueProps | TabsSelectedIndexProps);\n\n// The value a panel is matched by: its `value`, or its index as a string.\nconst getPanelValue = (\n\tchild: React.ReactElement<TabsPanelProps>,\n\tindex: number\n): string => child.props.value ?? String(index);\n\n// Determine if a node from event.target is a Tab element\nfunction isTabNode(node: HTMLElement): boolean {\n\treturn (\n\t\t(node.nodeName === 'A' && node.getAttribute('role') === 'tab') ||\n\t\t(node.nodeName === 'LI' &&\n\t\t\t(node.classList.contains('slds-tabs_default__item') ||\n\t\t\t\tnode.classList.contains('slds-tabs_scoped__item') ||\n\t\t\t\tnode.classList.contains('slds-vertical-tabs__nav-item')))\n\t);\n}\n\n// Determine if a tab node is disabled (from DOM)\nfunction isTabNodeDisabled(node: HTMLElement): boolean {\n\tif (node.classList?.contains('slds-disabled')) {\n\t\treturn true;\n\t}\n\tif (node.getAttribute?.('aria-disabled') === 'true') {\n\t\treturn true;\n\t}\n\treturn false;\n}\n\n// Determine if a tab React element is disabled\nfunction isTabDisabled(tab: React.ReactElement<TabsPanelProps>): boolean {\n\treturn Boolean(tab.props?.disabled);\n}\n\n/**\n * Tabs keeps related content in a single container that is shown and hidden through navigation.\n */\nconst Tabs = (props: TabsProps): React.ReactElement => {\n\tconst {\n\t\tchildren,\n\t\tclassName,\n\t\tid: propId,\n\t\tonSelect,\n\t\tselectedIndex: selectedIndexProp,\n\t\tvalue,\n\t\tvariant = 'default',\n\t} = props;\n\tconst generatedId = useId();\n\tconst id = propId || generatedId;\n\n\tuseEffect(() => {\n\t\tcheckProps(\n\t\t\tTABS,\n\t\t\t{\n\t\t\t\tdefaultSelectedIndex: (props as { defaultSelectedIndex?: number })\n\t\t\t\t\t.defaultSelectedIndex,\n\t\t\t\tselectedIndex: selectedIndexProp,\n\t\t\t\tvalue,\n\t\t\t},\n\t\t\tcomponentDoc\n\t\t);\n\t});\n\n\tconst [focus, setFocus] = useState(false);\n\tconst tabsRef = useRef<\n\t\tArray<{ tab: React.ReactElement<TabsPanelProps>; node: HTMLElement | null }>\n\t>([]);\n\tconst tabsNodeRef = useRef<HTMLDivElement>(null);\n\n\tconst childArray = React.Children.toArray(\n\t\tchildren\n\t) as React.ReactElement<TabsPanelProps>[];\n\tconst tabsCount = childArray.length;\n\n\t// Selection is controlled: derived from `value`, or from the deprecated\n\t// `selectedIndex` when `value` is not passed. There is no internal copy.\n\tconst selectedIndex =\n\t\tvalue !== undefined\n\t\t\t? childArray.findIndex(\n\t\t\t\t\t(child, index) => getPanelValue(child, index) === value\n\t\t\t\t)\n\t\t\t: Number.isInteger(selectedIndexProp)\n\t\t\t\t? (selectedIndexProp as number)\n\t\t\t\t: -1;\n\n\tconst getNextTab = useCallback(\n\t\t(index: number): number => {\n\t\t\t// Look for non-disabled tab from index to the last tab\n\t\t\tfor (let i = index + 1; i < tabsCount; i++) {\n\t\t\t\tconst tab = tabsRef.current[i];\n\t\t\t\tif (tab && !isTabDisabled(tab.tab)) {\n\t\t\t\t\treturn i;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Continue from first tab\n\t\t\tfor (let i = 0; i < index; i++) {\n\t\t\t\tconst tab = tabsRef.current[i];\n\t\t\t\tif (tab && !isTabDisabled(tab.tab)) {\n\t\t\t\t\treturn i;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn index;\n\t\t},\n\t\t[tabsCount]\n\t);\n\n\tconst getPrevTab = useCallback(\n\t\t(index: number): number => {\n\t\t\t// Look for non-disabled tab backwards\n\t\t\tfor (let i = index - 1; i >= 0; i--) {\n\t\t\t\tconst tab = tabsRef.current[i];\n\t\t\t\tif (tab && !isTabDisabled(tab.tab)) {\n\t\t\t\t\treturn i;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Continue from last tab\n\t\t\tfor (let i = tabsCount - 1; i > index; i--) {\n\t\t\t\tconst tab = tabsRef.current[i];\n\t\t\t\tif (tab && !isTabDisabled(tab.tab)) {\n\t\t\t\t\treturn i;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn index;\n\t\t},\n\t\t[tabsCount]\n\t);\n\n\tconst setSelected = useCallback(\n\t\t(\n\t\t\tevent: MouseEvent<HTMLDivElement> | KeyboardEvent<HTMLDivElement>,\n\t\t\tindex: number,\n\t\t\tshouldFocus?: boolean\n\t\t) => {\n\t\t\tif (index < 0 || index >= tabsCount || index === selectedIndex) return;\n\n\t\t\tconst previous =\n\t\t\t\tselectedIndex >= 0 ? childArray[selectedIndex] : undefined;\n\t\t\tonSelect?.(event, {\n\t\t\t\tvalue: getPanelValue(childArray[index], index),\n\t\t\t\tpreviousValue: previous\n\t\t\t\t\t? getPanelValue(previous, selectedIndex)\n\t\t\t\t\t: undefined,\n\t\t\t\tselectedIndex: index,\n\t\t\t\tpreviousIndex: selectedIndex,\n\t\t\t});\n\t\t\t// Focus follows the selection once the parent updates `value`.\n\t\t\tsetFocus(shouldFocus === true);\n\t\t},\n\t\t[tabsCount, onSelect, selectedIndex, childArray]\n\t);\n\n\tconst isTabFromContainer = useCallback((node: HTMLElement): boolean => {\n\t\tif (!isTabNode(node)) return false;\n\n\t\tlet nodeAncestor: HTMLElement | null = node.parentElement;\n\t\twhile (nodeAncestor) {\n\t\t\tif (nodeAncestor === tabsNodeRef.current) return true;\n\t\t\tif (nodeAncestor.getAttribute('data-tabs')) break;\n\t\t\tnodeAncestor = nodeAncestor.parentElement;\n\t\t}\n\t\treturn false;\n\t}, []);\n\n\tconst handleClick = useCallback(\n\t\t(e: MouseEvent<HTMLDivElement>) => {\n\t\t\tlet node = e.target as HTMLElement;\n\t\t\tdo {\n\t\t\t\tif (isTabFromContainer(node)) {\n\t\t\t\t\tif (isTabNodeDisabled(node)) return;\n\n\t\t\t\t\tlet parentNode = node.parentNode as HTMLElement;\n\t\t\t\t\tif (parentNode?.nodeName === 'LI') {\n\t\t\t\t\t\tnode = parentNode;\n\t\t\t\t\t\tparentNode = node.parentNode as HTMLElement;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst index = Array.from(parentNode.children).indexOf(node);\n\t\t\t\t\tsetSelected(e, index);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tnode = node.parentNode as HTMLElement;\n\t\t\t} while (node !== null);\n\t\t},\n\t\t[isTabFromContainer, setSelected]\n\t);\n\n\tconst handleKeyDown = useCallback(\n\t\t(event: KeyboardEvent<HTMLDivElement>) => {\n\t\t\tif (isTabFromContainer(event.target as HTMLElement)) {\n\t\t\t\tlet index = selectedIndex;\n\t\t\t\tlet preventDefault = false;\n\n\t\t\t\tif (event.key === KEYS.LEFT || event.key === KEYS.UP) {\n\t\t\t\t\tindex = getPrevTab(index);\n\t\t\t\t\tpreventDefault = true;\n\t\t\t\t} else if (event.key === KEYS.RIGHT || event.key === KEYS.DOWN) {\n\t\t\t\t\tindex = getNextTab(index);\n\t\t\t\t\tpreventDefault = true;\n\t\t\t\t}\n\n\t\t\t\tif (preventDefault) {\n\t\t\t\t\tEventUtil.trap(event);\n\t\t\t\t}\n\n\t\t\t\tsetSelected(event, index, true);\n\t\t\t}\n\t\t},\n\t\t[isTabFromContainer, selectedIndex, getPrevTab, getNextTab, setSelected]\n\t);\n\n\tconst renderTabsList = () => (\n\t\t<TabsList id={id} variant={variant}>\n\t\t\t{childArray.map((child, index) => {\n\t\t\t\tconst tabId = `${id}-slds-tabs_tab-${index}`;\n\t\t\t\tconst panelId = `${id}-slds-tabs_panel-${index}`;\n\t\t\t\tconst isSelected = selectedIndex === index;\n\t\t\t\tconst shouldFocus = isSelected && focus;\n\n\t\t\t\treturn (\n\t\t\t\t\t<Tab\n\t\t\t\t\t\tkey={child.key ?? index}\n\t\t\t\t\t\tref={(node: HTMLElement | null) => {\n\t\t\t\t\t\t\ttabsRef.current[index] = { tab: child, node };\n\t\t\t\t\t\t\tif (focus) {\n\t\t\t\t\t\t\t\tsetFocus(false);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tfocus={shouldFocus}\n\t\t\t\t\t\tselected={isSelected}\n\t\t\t\t\t\tid={tabId}\n\t\t\t\t\t\tpanelId={panelId}\n\t\t\t\t\t\tdisabled={child.props.disabled}\n\t\t\t\t\t\tvariant={variant}\n\t\t\t\t\t\thasError={child.props.hasError}\n\t\t\t\t\t\tassistiveText={child.props.assistiveText}\n\t\t\t\t\t>\n\t\t\t\t\t\t{child.props.label}\n\t\t\t\t\t</Tab>\n\t\t\t\t);\n\t\t\t})}\n\t\t</TabsList>\n\t);\n\n\tconst renderTabPanels = () =>\n\t\tchildArray.map((child, index) => {\n\t\t\tconst tabId = `${id}-slds-tabs_tab-${index}`;\n\t\t\tconst panelId = `${id}-slds-tabs_panel-${index}`;\n\t\t\tconst isSelected = selectedIndex === index;\n\n\t\t\treturn (\n\t\t\t\t<TabPanel\n\t\t\t\t\tkey={child.key ?? index}\n\t\t\t\t\tselected={isSelected}\n\t\t\t\t\tid={panelId}\n\t\t\t\t\ttabId={tabId}\n\t\t\t\t\tvariant={variant}\n\t\t\t\t>\n\t\t\t\t\t{child}\n\t\t\t\t</TabPanel>\n\t\t\t);\n\t\t});\n\n\treturn (\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions -- wrapper delegates events from the focusable tabs it contains\n\t\t<div\n\t\t\tid={id}\n\t\t\tclassName={classNames(\n\t\t\t\t{\n\t\t\t\t\t'slds-tabs_default': variant === 'default',\n\t\t\t\t\t'slds-tabs_scoped': variant === 'scoped',\n\t\t\t\t\t'slds-vertical-tabs': variant === 'vertical',\n\t\t\t\t},\n\t\t\t\tclassName as string\n\t\t\t)}\n\t\t\tonClick={handleClick}\n\t\t\tonKeyDown={handleKeyDown}\n\t\t\tdata-tabs\n\t\t\tref={tabsNodeRef}\n\t\t>\n\t\t\t{renderTabsList()}\n\t\t\t{renderTabPanels()}\n\t\t</div>\n\t);\n};\n\nTabs.displayName = TABS;\n\nexport default Tabs;\n"],"mappings":"gjBA+GA,IAAM,GACL,EACA,IACY,EAAM,MAAM,OAAS,OAAO,CAAK,EAG9C,SAAS,EAAU,EAA4B,CAC9C,OACE,EAAK,WAAa,KAAO,EAAK,aAAa,MAAM,IAAM,OACvD,EAAK,WAAa,OACjB,EAAK,UAAU,SAAS,yBAAyB,GACjD,EAAK,UAAU,SAAS,wBAAwB,GAChD,EAAK,UAAU,SAAS,8BAA8B,EAE1D,CAGA,SAAS,EAAkB,EAA4B,CAOtD,MAHA,GAHI,EAAK,WAAW,SAAS,eAAe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ChC,IAAM,EAAQ,GAAG,EAAG,iBAAiB,IAC/B,EAAU,GAAG,EAAG,mBAAmB,IAGzC,OACC,EAAA,EAAA,IAAA,CAAC,EAAA,QAAD,CAEC,SALiB,IAAkB,EAMnC,GAAI,EACG,QACE,UAER,SAAA,CACQ,EAPJ,EAAM,KAAO,CAOT,CAEZ,CAAC,CAqBI,GAEP,EAEA,EAAK,YAAc,EAAA"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../../../../components/tabs/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\tuseState,\n\tuseRef,\n\tuseCallback,\n\tuseEffect,\n\tuseId,\n\ttype MouseEvent,\n\ttype KeyboardEvent,\n} from 'react';\nimport classNames from 'classnames';\n\n// Child components\nimport TabsList from './private/tabs-list';\nimport Tab from './private/tab';\nimport TabPanel from './private/tab-panel';\nimport type { TabsPanelProps } from './panel';\nimport type { ChildrenOf } from '../../types/common';\n\nimport { TABS } from '../../utilities/constants';\nimport KEYS from '../../utilities/key-code';\nimport EventUtil from '../../utilities/event';\n\nimport checkProps from './check-props';\nimport componentDoc from './component.json';\n\n/**\n * Tabs variant types\n */\nexport type TabsVariant = 'default' | 'scoped' | 'vertical';\n\n/** @deprecated Use `TabsPanelProps` from `tabs/panel`. */\nexport type TabChildProps = TabsPanelProps;\n\n/**\n * Data passed to the Tabs `onSelect` callback\n */\nexport interface TabsSelectData {\n\t/**\n\t * `value` of the tab being selected: the panel's `value`, or its index as a\n\t * string (`'0'`, `'1'`, ...) when the panel has no `value`.\n\t */\n\tvalue: string;\n\t/**\n\t * `value` of the tab that was selected before this selection, or `undefined`\n\t * when no tab was selected.\n\t */\n\tpreviousValue: string | undefined;\n\t/** Index of the tab being selected */\n\tselectedIndex: number;\n\t/** Index of the tab that was selected before this selection, or `-1` when no tab was selected */\n\tpreviousIndex: number;\n}\n\n/**\n * Props shared by both ways of controlling the selected tab\n */\ninterface TabsBaseProps {\n\t/** `TabsPanel` elements, one per tab. Tabs reads each panel's `label`, `value`, `disabled`, `hasError` and `assistiveText`. */\n\tchildren: ChildrenOf<TabsPanelProps>;\n\t/** CSS classes */\n\tclassName?: string | string[] | Record<string, boolean>;\n\t/** HTML id */\n\tid?: string;\n\t/**\n\t * Called when a tab is requested by click or arrow key. Receives the triggering event and\n\t * `{ value, previousValue, selectedIndex, previousIndex }`. Tabs is controlled: update `value`\n\t * from this callback to change tabs. It is not called for a disabled tab or for the tab that is\n\t * already selected.\n\t */\n\tonSelect: (\n\t\tevent: MouseEvent<HTMLDivElement> | KeyboardEvent<HTMLDivElement>,\n\t\tdata: TabsSelectData\n\t) => void;\n\t/** Tab style variant */\n\tvariant?: TabsVariant;\n}\n\n/**\n * Select the tab by the `value` of its `TabsPanel`.\n */\ninterface TabsValueProps {\n\t/**\n\t * `value` of the selected `TabsPanel` (required, controlled). A panel without a `value` is\n\t * matched by its index as a string (`'0'`, `'1'`, ...). When no panel matches, no tab is selected.\n\t */\n\tvalue: string;\n\tselectedIndex?: never;\n}\n\n/**\n * Select the tab by index (deprecated).\n */\ninterface TabsSelectedIndexProps {\n\t/** Unset when the deprecated `selectedIndex` is used. */\n\tvalue?: undefined;\n\t/**\n\t * @deprecated Use `value` instead (set `value` on each `TabsPanel`, or use the index as a\n\t * string). Index of the selected tab, controlled. Used only when `value` is not passed.\n\t */\n\tselectedIndex: number;\n}\n\n/**\n * Props for the Tabs component\n */\nexport type TabsProps = TabsBaseProps &\n\t(TabsValueProps | TabsSelectedIndexProps);\n\n// The value a panel is matched by: its `value`, or its index as a string.\nconst getPanelValue = (\n\tchild: React.ReactElement<TabsPanelProps>,\n\tindex: number\n): string => child.props.value ?? String(index);\n\n// Determine if a node from event.target is a Tab element\nfunction isTabNode(node: HTMLElement): boolean {\n\treturn (\n\t\t(node.nodeName === 'A' && node.getAttribute('role') === 'tab') ||\n\t\t(node.nodeName === 'LI' &&\n\t\t\t(node.classList.contains('slds-tabs_default__item') ||\n\t\t\t\tnode.classList.contains('slds-tabs_scoped__item') ||\n\t\t\t\tnode.classList.contains('slds-vertical-tabs__nav-item')))\n\t);\n}\n\n// Determine if a tab node is disabled (from DOM)\nfunction isTabNodeDisabled(node: HTMLElement): boolean {\n\tif (node.classList?.contains('slds-disabled')) {\n\t\treturn true;\n\t}\n\tif (node.getAttribute?.('aria-disabled') === 'true') {\n\t\treturn true;\n\t}\n\treturn false;\n}\n\n// Determine if a tab React element is disabled\nfunction isTabDisabled(tab: React.ReactElement<TabsPanelProps>): boolean {\n\treturn Boolean(tab.props?.disabled);\n}\n\n/**\n * Tabs keeps related content in a single container that is shown and hidden through navigation.\n */\nconst Tabs = (props: TabsProps): React.ReactElement => {\n\tconst {\n\t\tchildren,\n\t\tclassName,\n\t\tid: propId,\n\t\tonSelect,\n\t\tselectedIndex: selectedIndexProp,\n\t\tvalue,\n\t\tvariant = 'default',\n\t} = props;\n\tconst generatedId = useId();\n\tconst id = propId || generatedId;\n\n\tuseEffect(() => {\n\t\tcheckProps(\n\t\t\tTABS,\n\t\t\t{\n\t\t\t\tdefaultSelectedIndex: (props as { defaultSelectedIndex?: number })\n\t\t\t\t\t.defaultSelectedIndex,\n\t\t\t\tselectedIndex: selectedIndexProp,\n\t\t\t\tvalue,\n\t\t\t},\n\t\t\tcomponentDoc\n\t\t);\n\t});\n\n\tconst [focus, setFocus] = useState(false);\n\tconst tabsRef = useRef<\n\t\tArray<{ tab: React.ReactElement<TabsPanelProps>; node: HTMLElement | null }>\n\t>([]);\n\tconst tabsNodeRef = useRef<HTMLDivElement>(null);\n\n\tconst childArray = React.Children.toArray(\n\t\tchildren\n\t) as React.ReactElement<TabsPanelProps>[];\n\tconst tabsCount = childArray.length;\n\n\t// Selection is controlled: derived from `value`, or from the deprecated\n\t// `selectedIndex` when `value` is not passed. There is no internal copy.\n\tconst selectedIndex =\n\t\tvalue !== undefined\n\t\t\t? childArray.findIndex(\n\t\t\t\t\t(child, index) => getPanelValue(child, index) === value\n\t\t\t\t)\n\t\t\t: Number.isInteger(selectedIndexProp)\n\t\t\t\t? (selectedIndexProp as number)\n\t\t\t\t: -1;\n\n\tconst getNextTab = useCallback(\n\t\t(index: number): number => {\n\t\t\t// Look for non-disabled tab from index to the last tab\n\t\t\tfor (let i = index + 1; i < tabsCount; i++) {\n\t\t\t\tconst tab = tabsRef.current[i];\n\t\t\t\tif (tab && !isTabDisabled(tab.tab)) {\n\t\t\t\t\treturn i;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Continue from first tab\n\t\t\tfor (let i = 0; i < index; i++) {\n\t\t\t\tconst tab = tabsRef.current[i];\n\t\t\t\tif (tab && !isTabDisabled(tab.tab)) {\n\t\t\t\t\treturn i;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn index;\n\t\t},\n\t\t[tabsCount]\n\t);\n\n\tconst getPrevTab = useCallback(\n\t\t(index: number): number => {\n\t\t\t// Look for non-disabled tab backwards\n\t\t\tfor (let i = index - 1; i >= 0; i--) {\n\t\t\t\tconst tab = tabsRef.current[i];\n\t\t\t\tif (tab && !isTabDisabled(tab.tab)) {\n\t\t\t\t\treturn i;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Continue from last tab\n\t\t\tfor (let i = tabsCount - 1; i > index; i--) {\n\t\t\t\tconst tab = tabsRef.current[i];\n\t\t\t\tif (tab && !isTabDisabled(tab.tab)) {\n\t\t\t\t\treturn i;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn index;\n\t\t},\n\t\t[tabsCount]\n\t);\n\n\tconst setSelected = useCallback(\n\t\t(\n\t\t\tevent: MouseEvent<HTMLDivElement> | KeyboardEvent<HTMLDivElement>,\n\t\t\tindex: number,\n\t\t\tshouldFocus?: boolean\n\t\t) => {\n\t\t\tif (index < 0 || index >= tabsCount || index === selectedIndex) return;\n\n\t\t\tconst previous =\n\t\t\t\tselectedIndex >= 0 ? childArray[selectedIndex] : undefined;\n\t\t\tonSelect?.(event, {\n\t\t\t\tvalue: getPanelValue(childArray[index], index),\n\t\t\t\tpreviousValue: previous\n\t\t\t\t\t? getPanelValue(previous, selectedIndex)\n\t\t\t\t\t: undefined,\n\t\t\t\tselectedIndex: index,\n\t\t\t\tpreviousIndex: selectedIndex,\n\t\t\t});\n\t\t\t// Focus follows the selection once the parent updates `value`.\n\t\t\tsetFocus(shouldFocus === true);\n\t\t},\n\t\t[tabsCount, onSelect, selectedIndex, childArray]\n\t);\n\n\tconst isTabFromContainer = useCallback((node: HTMLElement): boolean => {\n\t\tif (!isTabNode(node)) return false;\n\n\t\tlet nodeAncestor: HTMLElement | null = node.parentElement;\n\t\twhile (nodeAncestor) {\n\t\t\tif (nodeAncestor === tabsNodeRef.current) return true;\n\t\t\tif (nodeAncestor.getAttribute('data-tabs')) break;\n\t\t\tnodeAncestor = nodeAncestor.parentElement;\n\t\t}\n\t\treturn false;\n\t}, []);\n\n\tconst handleClick = useCallback(\n\t\t(e: MouseEvent<HTMLDivElement>) => {\n\t\t\tlet node = e.target as HTMLElement;\n\t\t\tdo {\n\t\t\t\tif (isTabFromContainer(node)) {\n\t\t\t\t\tif (isTabNodeDisabled(node)) return;\n\n\t\t\t\t\tlet parentNode = node.parentNode as HTMLElement;\n\t\t\t\t\tif (parentNode?.nodeName === 'LI') {\n\t\t\t\t\t\tnode = parentNode;\n\t\t\t\t\t\tparentNode = node.parentNode as HTMLElement;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst index = Array.from(parentNode.children).indexOf(node);\n\t\t\t\t\tsetSelected(e, index);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tnode = node.parentNode as HTMLElement;\n\t\t\t} while (node !== null);\n\t\t},\n\t\t[isTabFromContainer, setSelected]\n\t);\n\n\tconst handleKeyDown = useCallback(\n\t\t(event: KeyboardEvent<HTMLDivElement>) => {\n\t\t\tif (isTabFromContainer(event.target as HTMLElement)) {\n\t\t\t\tlet index = selectedIndex;\n\t\t\t\tlet preventDefault = false;\n\n\t\t\t\tif (event.key === KEYS.LEFT || event.key === KEYS.UP) {\n\t\t\t\t\tindex = getPrevTab(index);\n\t\t\t\t\tpreventDefault = true;\n\t\t\t\t} else if (event.key === KEYS.RIGHT || event.key === KEYS.DOWN) {\n\t\t\t\t\tindex = getNextTab(index);\n\t\t\t\t\tpreventDefault = true;\n\t\t\t\t}\n\n\t\t\t\tif (preventDefault) {\n\t\t\t\t\tEventUtil.trap(event);\n\t\t\t\t}\n\n\t\t\t\tsetSelected(event, index, true);\n\t\t\t}\n\t\t},\n\t\t[isTabFromContainer, selectedIndex, getPrevTab, getNextTab, setSelected]\n\t);\n\n\tconst renderTabsList = () => (\n\t\t<TabsList id={id} variant={variant}>\n\t\t\t{childArray.map((child, index) => {\n\t\t\t\tconst tabId = `${id}-slds-tabs_tab-${index}`;\n\t\t\t\tconst panelId = `${id}-slds-tabs_panel-${index}`;\n\t\t\t\tconst isSelected = selectedIndex === index;\n\t\t\t\tconst shouldFocus = isSelected && focus;\n\n\t\t\t\treturn (\n\t\t\t\t\t<Tab\n\t\t\t\t\t\tkey={child.key ?? index}\n\t\t\t\t\t\tref={(node: HTMLElement | null) => {\n\t\t\t\t\t\t\ttabsRef.current[index] = { tab: child, node };\n\t\t\t\t\t\t\tif (focus) {\n\t\t\t\t\t\t\t\tsetFocus(false);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tfocus={shouldFocus}\n\t\t\t\t\t\tselected={isSelected}\n\t\t\t\t\t\tid={tabId}\n\t\t\t\t\t\tpanelId={panelId}\n\t\t\t\t\t\tdisabled={child.props.disabled}\n\t\t\t\t\t\tvariant={variant}\n\t\t\t\t\t\thasError={child.props.hasError}\n\t\t\t\t\t\tassistiveText={child.props.assistiveText}\n\t\t\t\t\t>\n\t\t\t\t\t\t{child.props.label}\n\t\t\t\t\t</Tab>\n\t\t\t\t);\n\t\t\t})}\n\t\t</TabsList>\n\t);\n\n\tconst renderTabPanels = () =>\n\t\tchildArray.map((child, index) => {\n\t\t\tconst tabId = `${id}-slds-tabs_tab-${index}`;\n\t\t\tconst panelId = `${id}-slds-tabs_panel-${index}`;\n\t\t\tconst isSelected = selectedIndex === index;\n\n\t\t\treturn (\n\t\t\t\t<TabPanel\n\t\t\t\t\tkey={child.key ?? index}\n\t\t\t\t\tselected={isSelected}\n\t\t\t\t\tid={panelId}\n\t\t\t\t\ttabId={tabId}\n\t\t\t\t\tvariant={variant}\n\t\t\t\t>\n\t\t\t\t\t{child}\n\t\t\t\t</TabPanel>\n\t\t\t);\n\t\t});\n\n\treturn (\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions -- wrapper delegates events from the focusable tabs it contains\n\t\t<div\n\t\t\tid={id}\n\t\t\tclassName={classNames(\n\t\t\t\t{\n\t\t\t\t\t'slds-tabs_default': variant === 'default',\n\t\t\t\t\t'slds-tabs_scoped': variant === 'scoped',\n\t\t\t\t\t'slds-vertical-tabs': variant === 'vertical',\n\t\t\t\t},\n\t\t\t\tclassName as string\n\t\t\t)}\n\t\t\tonClick={handleClick}\n\t\t\tonKeyDown={handleKeyDown}\n\t\t\tdata-tabs\n\t\t\tref={tabsNodeRef}\n\t\t>\n\t\t\t{renderTabsList()}\n\t\t\t{renderTabPanels()}\n\t\t</div>\n\t);\n};\n\nTabs.displayName = TABS;\n\nexport default Tabs;\n"],"mappings":"gjBAgHA,IAAM,GACL,EACA,IACY,EAAM,MAAM,OAAS,OAAO,CAAK,EAG9C,SAAS,EAAU,EAA4B,CAC9C,OACE,EAAK,WAAa,KAAO,EAAK,aAAa,MAAM,IAAM,OACvD,EAAK,WAAa,OACjB,EAAK,UAAU,SAAS,yBAAyB,GACjD,EAAK,UAAU,SAAS,wBAAwB,GAChD,EAAK,UAAU,SAAS,8BAA8B,EAE1D,CAGA,SAAS,EAAkB,EAA4B,CAOtD,MAHA,GAHI,EAAK,WAAW,SAAS,eAAe,GAGxC,EAAK,eAAe,eAAe,IAAM,OAI9C,CA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B,EAAU,GAAG,EAAG,mBAAmB,IAGzC,OACC,EAAA,EAAA,IAAA,CAAC,EAAA,QAAD,CAEC,SALiB,IAAkB,EAMnC,GAAI,EACG,QACE,UAER,SAAA,CACQ,EAPJ,EAAM,KAAO,CAOT,CAEZ,CAAC,CAqBI,GAEP,EAEA,EAAK,YAAc,EAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"panel.cjs","names":[],"sources":["../../../../components/tabs/panel.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';\n\nimport { TABS_PANEL } from '../../utilities/constants';\n\nexport interface TabsPanelProps {\n\t/**\n\t * The string or element that is handed off to the `<Tab />` component, ends up being the title and the label for the tab associated with its tab panel.\n\t */\n\tlabel: ReactNode;\n\t/**\n\t * Identifies this panel for the `value` prop of `<Tabs />` and the `value`/`previousValue` reported by its `onSelect`. When omitted, the panel is identified by its index as a string (`'0'`, `'1'`, ...). Rendered `id`s are always index-based.\n\t */\n\tvalue?: string;\n\t/**\n\t * The `children` are the actual tab panels to be rendered.
|
|
1
|
+
{"version":3,"file":"panel.cjs","names":[],"sources":["../../../../components/tabs/panel.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';\n\nimport { TABS_PANEL } from '../../utilities/constants';\n\nexport interface TabsPanelProps {\n\t/**\n\t * The string or element that is handed off to the `<Tab />` component, ends up being the title and the label for the tab associated with its tab panel.\n\t */\n\tlabel: ReactNode;\n\t/**\n\t * Identifies this panel for the `value` prop of `<Tabs />` and the `value`/`previousValue` reported by its `onSelect`. When omitted, the panel is identified by its index as a string (`'0'`, `'1'`, ...). Rendered `id`s are always index-based.\n\t */\n\tvalue?: string;\n\t/**\n\t * The `children` are the actual tab panels to be rendered. `<Tabs />` renders them.\n\t *\n\t * Note that the `<TabsPanel />` component inserts a `div` element around the children, because React requires exactly one \"parent\" element returned. The `<TabPanel />` component simply dips down into `children` to get the children of this wrapping `div` so that it does not get rendered in the DOM.\n\t */\n\tchildren: ReactNode;\n\t/**\n\t * Disables the `<Tab />` associated with this panel so it cannot be selected.\n\t */\n\tdisabled?: boolean;\n\t/**\n\t * Show an icon on the `<Tab />` next to the title that can be used to communicate when a tab contains a validation error that needs attention\n\t */\n\thasError?: boolean;\n\t/**\n\t * **Assistive text for accessibility**\n\t * This object is merged with the default props object on every render.\n\t * * `withErrorIcon`: This text is for the error icon that will be placed next to the `<Tab />` title\n\t */\n\tassistiveText?: {\n\t\t/** Label of the error icon shown with `hasError`. Defaults to the English text `This item has an error`. */\n\t\twithErrorIcon?: string;\n\t};\n}\n\n/**\n * The `<TabsPanel />` component allows us to simplify the structure of the `<Tabs />` component.\n\n * Rather than require different (deeply nested) children for tabslist, with its tab(s) as well as tabpanel(s), we provide this `TabsPanel` component which takes a `label` property that will become what is shown on the `<Tab />` that will be associated with it.\n\n * The `children` of the Panel will be fed to the `<TabPanel />` component, while its `label` is handled in `<Tab />`, via `<TabsList />`.\n *\n * ```\n * <TabsPanel label=\"Tab 1\" value=\"tab-1\">\n * \t<div>\n * \t\t<h2 className=\"slds-text-heading_medium\">This is my tab 1 contents!</h2>\n * \t\t<p>They show when you click the first tab.</p>\n * \t</div>\n * </TabsPanel>\n * ```\n */\nconst Panel = ({ children }: TabsPanelProps) => (\n\t<div>{React.Children.toArray(children)}</div>\n);\n\nPanel.displayName = TABS_PANEL;\n\nexport default Panel;\n"],"mappings":"8KAyDA,IAAM,GAAS,CAAE,eAChB,EAAA,EAAA,IAAA,CAAC,MAAD,CAAA,SAAM,EAAA,QAAM,SAAS,QAAQ,CAAQ,CAAO,CAAA,EAG7C,EAAM,YAAc,EAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../utilities/constants.cjs"),n=require("../../utilities/get-aria-props.cjs"),r=require("./check-props.cjs"),i=require("./component.cjs");let a=require("react"),o=require("classnames");o=e.__toESM(o,1);let s=require("react/jsx-runtime");var c=(0,a.forwardRef)((e,c)=>{let{assistiveText:l,
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../utilities/constants.cjs"),n=require("../../utilities/get-aria-props.cjs"),r=require("./check-props.cjs"),i=require("./component.cjs");let a=require("react"),o=require("classnames");o=e.__toESM(o,1);let s=require("react/jsx-runtime");var c=(0,a.forwardRef)((e,c)=>{let{assistiveText:l,children:u,className:d,classNameContainer:f,errorText:p,hasError:m,id:h,label:g,labels:_,maxLength:v,onChange:y,onKeyPress:b,required:x,defaultValue:S,...C}=e;r.default(t.TEXTAREA,{...e},i.default);let w=(0,a.useId)(),T=(0,a.useId)(),E=()=>h||w,D=()=>C[`aria-describedby`]||T,O=n.default(C),k=l?.label,A=_?.label??g,j=A||k,M=m??!!p,N=M?_?.error??p:void 0;return(0,a.useEffect)(()=>{r.default(t.TEXTAREA,{assistiveText:l,errorText:p,label:g,labels:_,onKeyPress:b},i.default)},[l,p,g,_,b]),(0,s.jsxs)(`div`,{className:(0,o.default)(`slds-form-element`,{"slds-has-error":M},f),children:[j&&(0,s.jsxs)(`label`,{className:(0,o.default)(`slds-form-element__label`,{"slds-assistive-text":k&&!A}),htmlFor:E(),children:[x&&(0,s.jsx)(`abbr`,{className:`slds-required`,title:`required`,children:`*`}),j]}),(0,s.jsx)(`div`,{className:`slds-form-element__control`,children:(0,s.jsx)(`textarea`,{...C,...O,className:(0,o.default)(`slds-textarea`,d),id:E(),maxLength:typeof v==`string`?parseInt(v,10):v,onChange:e=>{y?.(e,{value:e.target.value})},onKeyPress:b,ref:c,required:x,"aria-describedby":N?D():C[`aria-describedby`]})}),N&&(0,s.jsx)(`div`,{id:D(),className:`slds-form-element__help`,children:N}),u]})});c.displayName=t.TEXTAREA,exports.default=c;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":[],"sources":["../../../../components/textarea/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 {\n\tuseId,\n\tuseEffect,\n\tforwardRef,\n\ttype ChangeEvent,\n\ttype FocusEvent,\n\ttype KeyboardEvent,\n\ttype MouseEvent,\n\ttype InputEvent,\n\ttype SubmitEvent,\n\ttype SyntheticEvent,\n\ttype CSSProperties,\n\ttype ReactNode,\n\ttype TextareaHTMLAttributes,\n} from 'react';\nimport classNames from 'classnames';\nimport getAriaProps from '../../utilities/get-aria-props';\nimport { TEXTAREA } from '../../utilities/constants';\nimport checkProps from './check-props';\nimport componentDoc from './component.json';\n\n/**\n * Assistive text for Textarea\n */\nexport interface TextareaAssistiveText {\n\t/** Visually hidden label for screen readers */\n\tlabel?: string;\n}\n\n/**\n * Labels for Textarea\n */\nexport interface TextareaLabels {\n\t/** Error message shown below the textarea while `hasError` is true */\n\terror?: ReactNode;\n\t/** Visible label above the textarea */\n\tlabel?: ReactNode;\n}\n\n/**\n * Data passed to `onChange`\n */\nexport interface TextareaChangeData {\n\t/** The new text */\n\tvalue: string;\n}\n\n/**\n * Props removed in v11. They are ignored at runtime and warn in development.\n */\ninterface TextareaRemovedProps {\n\t/** @removed Textarea is controlled: pass `value` and update it in `onChange`. */\n\tdefaultValue?: unknown;\n}\n\n/**\n * Props for the Textarea component\n */\nexport interface TextareaProps extends Pick<\n\tTextareaHTMLAttributes<HTMLTextAreaElement>,\n\t| 'aria-activedescendant'\n\t| 'aria-autocomplete'\n\t| 'aria-controls'\n\t| 'aria-describedby'\n\t| 'aria-expanded'\n\t| 'aria-haspopup'\n\t| 'aria-labelledby'\n\t| 'aria-owns'\n\t| 'aria-required'\n> {\n\t/**\n\t * **Assistive text for accessibility**\n\t * * `label`: Visually hidden label. Use instead of `labels.label`.\n\t */\n\tassistiveText?: TextareaAssistiveText;\n\t/** Autofocus on load (poor UX) */\n\tautoFocus?: boolean;\n\t/** Elements rendered after the textarea, inside the form element */\n\tchildren?: ReactNode;\n\t/** CSS class for textarea element */\n\tclassName?: string | string[] | Record<string, boolean>;\n\t/** CSS class for container */\n\tclassNameContainer?: string | string[] | Record<string, boolean>;\n\t/** Disable the textarea */\n\tdisabled?: boolean;\n\t/** @deprecated Use `labels.error` and `hasError` instead. */\n\terrorText?: string;\n\t/** Puts the textarea in an error state and shows `labels.error` */\n\thasError?: boolean;\n\t/** Unique ID */\n\tid?: string;\n\t/** @deprecated Use `labels.label` instead. */\n\tlabel?: string;\n\t/**\n\t * **Text labels for internationalization**\n\t * * `error`: Error message shown below the textarea while `hasError` is true\n\t * * `label`: Visible label. Use `assistiveText.label` for a visually hidden label.\n\t */\n\tlabels?: TextareaLabels;\n\t/** Maximum character count */\n\tmaxLength?: number;\n\t/** Form parameter name */\n\tname?: string;\n\t/** Blur event handler */\n\tonBlur?: (event: FocusEvent<HTMLTextAreaElement>) => void;\n\t/**\n\t * Called when the text changes. Textarea is controlled: update `value` from\n\t * `data.value`, or the text won't change.\n\t */\n\tonChange: (\n\t\tevent: ChangeEvent<HTMLTextAreaElement>,\n\t\tdata: TextareaChangeData\n\t) => void;\n\t/** Click event handler */\n\tonClick?: (event: MouseEvent<HTMLTextAreaElement>) => void;\n\t/** Focus event handler */\n\tonFocus?: (event: FocusEvent<HTMLTextAreaElement>) => void;\n\t/** Input event handler */\n\tonInput?: (event: InputEvent<HTMLTextAreaElement>) => void;\n\t/** Invalid event handler */\n\tonInvalid?: (event: SyntheticEvent<HTMLTextAreaElement>) => void;\n\t/** Key down event handler */\n\tonKeyDown?: (event: KeyboardEvent<HTMLTextAreaElement>) => void;\n\t/**\n\t * @deprecated `keypress` is a deprecated DOM event. Use `onKeyDown` and read\n\t * `event.key` instead. Still works, and warns.\n\t */\n\tonKeyPress?: (event: KeyboardEvent<HTMLTextAreaElement>) => void;\n\t/** Key up event handler */\n\tonKeyUp?: (event: KeyboardEvent<HTMLTextAreaElement>) => void;\n\t/** Select event handler */\n\tonSelect?: (event: SyntheticEvent<HTMLTextAreaElement>) => void;\n\t/** Submit event handler */\n\tonSubmit?: (event: SubmitEvent<HTMLTextAreaElement>) => void;\n\t/** Placeholder text */\n\tplaceholder?: string;\n\t/** Mark as required field */\n\trequired?: boolean;\n\t/** ARIA role */\n\trole?: string;\n\t/** The text in the textarea. Required: Textarea is controlled. */\n\tvalue: string;\n\t/** Text wrapping mode */\n\twrap?: 'soft' | 'hard';\n\t/** Custom styles */\n\tstyle?: CSSProperties;\n}\n\n/**\n * A multi-line plain-text editing control.\n */\nconst Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(\n\t(props, ref) => {\n\t\tconst {\n\t\t\tassistiveText,\n\t\t\tautoFocus,\n\t\t\tchildren,\n\t\t\tclassName,\n\t\t\tclassNameContainer,\n\t\t\tdisabled,\n\t\t\terrorText,\n\t\t\thasError: hasErrorProp,\n\t\t\tid: propId,\n\t\t\tlabel: labelProp,\n\t\t\tlabels,\n\t\t\tmaxLength,\n\t\t\tname,\n\t\t\tonBlur,\n\t\t\tonChange,\n\t\t\tonClick,\n\t\t\tonFocus,\n\t\t\tonInput,\n\t\t\tonInvalid,\n\t\t\tonKeyDown,\n\t\t\tonKeyPress,\n\t\t\tonKeyUp,\n\t\t\tonSelect,\n\t\t\tonSubmit,\n\t\t\tplaceholder,\n\t\t\trequired,\n\t\t\trole,\n\t\t\tvalue,\n\t\t\t// Removed in v11: destructured so it doesn't reach the DOM. check-props warns.\n\t\t\tdefaultValue: _defaultValue,\n\t\t\twrap,\n\t\t\t...restProps\n\t\t} = props as TextareaProps & TextareaRemovedProps;\n\n\t\tcheckProps(TEXTAREA, { ...props }, componentDoc);\n\n\t\tconst generatedId = useId();\n\t\tconst generatedErrorId = useId();\n\n\t\tconst getId = () => propId || generatedId;\n\t\tconst getErrorId = () => restProps['aria-describedby'] || generatedErrorId;\n\n\t\tconst ariaProps = getAriaProps(restProps);\n\n\t\tconst assistiveTextLabel = assistiveText?.label;\n\n\t\t// `label` is deprecated\n\t\tconst label = labels?.label ?? labelProp;\n\t\tconst labelText = label || assistiveTextLabel;\n\n\t\t// `errorText` is deprecated: it sets both the error state and the message\n\t\tconst hasError = hasErrorProp ?? !!errorText;\n\t\tconst errorMessage = hasError ? (labels?.error ?? errorText) : undefined;\n\n\t\tuseEffect(() => {\n\t\t\tcheckProps(\n\t\t\t\tTEXTAREA,\n\t\t\t\t{ assistiveText, errorText, label: labelProp, labels, onKeyPress },\n\t\t\t\tcomponentDoc\n\t\t\t);\n\t\t}, [assistiveText, errorText, labelProp, labels, onKeyPress]);\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tclassName={classNames(\n\t\t\t\t\t'slds-form-element',\n\t\t\t\t\t{\n\t\t\t\t\t\t'slds-has-error': hasError,\n\t\t\t\t\t},\n\t\t\t\t\tclassNameContainer as string\n\t\t\t\t)}\n\t\t\t>\n\t\t\t\t{labelText && (\n\t\t\t\t\t<label\n\t\t\t\t\t\tclassName={classNames('slds-form-element__label', {\n\t\t\t\t\t\t\t'slds-assistive-text': assistiveTextLabel && !label,\n\t\t\t\t\t\t})}\n\t\t\t\t\t\thtmlFor={getId()}\n\t\t\t\t\t>\n\t\t\t\t\t\t{required && (\n\t\t\t\t\t\t\t<abbr className=\"slds-required\" title=\"required\">\n\t\t\t\t\t\t\t\t*\n\t\t\t\t\t\t\t</abbr>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t{labelText}\n\t\t\t\t\t</label>\n\t\t\t\t)}\n\t\t\t\t<div className=\"slds-form-element__control\">\n\t\t\t\t\t<textarea\n\t\t\t\t\t\tclassName={classNames('slds-textarea', className as string)}\n\t\t\t\t\t\t// eslint-disable-next-line jsx-a11y/no-autofocus -- consumer opt-in through the autoFocus prop\n\t\t\t\t\t\tautoFocus={autoFocus}\n\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\tid={getId()}\n\t\t\t\t\t\tmaxLength={\n\t\t\t\t\t\t\t// Strings are still accepted at runtime for untyped callers; check-props warns.\n\t\t\t\t\t\t\ttypeof maxLength === 'string'\n\t\t\t\t\t\t\t\t? parseInt(maxLength, 10)\n\t\t\t\t\t\t\t\t: maxLength\n\t\t\t\t\t\t}\n\t\t\t\t\t\tname={name}\n\t\t\t\t\t\tonBlur={onBlur}\n\t\t\t\t\t\tonChange={(event) => {\n\t\t\t\t\t\t\tonChange?.(event, { value: event.target.value });\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tonClick={onClick}\n\t\t\t\t\t\tonFocus={onFocus}\n\t\t\t\t\t\tonInput={onInput}\n\t\t\t\t\t\tonInvalid={onInvalid}\n\t\t\t\t\t\tonKeyDown={onKeyDown}\n\t\t\t\t\t\t// eslint-disable-next-line local/no-deprecated -- forwards the deprecated `onKeyPress` prop until 11.0\n\t\t\t\t\t\tonKeyPress={onKeyPress}\n\t\t\t\t\t\tonKeyUp={onKeyUp}\n\t\t\t\t\t\tonSelect={onSelect}\n\t\t\t\t\t\tonSubmit={onSubmit}\n\t\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t\t\tref={ref}\n\t\t\t\t\t\trole={role}\n\t\t\t\t\t\trequired={required}\n\t\t\t\t\t\twrap={wrap}\n\t\t\t\t\t\tvalue={value}\n\t\t\t\t\t\taria-describedby={\n\t\t\t\t\t\t\terrorMessage\n\t\t\t\t\t\t\t\t? getErrorId()\n\t\t\t\t\t\t\t\t: ((ariaProps as Record<string, unknown>)[\n\t\t\t\t\t\t\t\t\t\t'aria-describedby'\n\t\t\t\t\t\t\t\t\t] as string | undefined)\n\t\t\t\t\t\t}\n\t\t\t\t\t\t{...ariaProps}\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t\t{errorMessage && (\n\t\t\t\t\t<div id={getErrorId()} className=\"slds-form-element__help\">\n\t\t\t\t\t\t{errorMessage}\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t);\n\t}\n);\n\nTextarea.displayName = TEXTAREA;\n\nexport default Textarea;\n"],"mappings":"iZA0JA,IAAM,GAAA,EAAW,EAAA,WAAA,EACf,EAAO,IAAQ,CACf,GAAM,CACL,gBACA,YACA,WACA,YACA,qBACA,WACA,YACA,SAAU,EACV,GAAI,EACJ,MAAO,EACP,SACA,YACA,OACA,SACA,WACA,UACA,UACA,UACA,YACA,YACA,aACA,UACA,WACA,WACA,cACA,WACA,OACA,QAEA,aAAc,EACd,OACA,GAAG,GACA,EAEJ,EAAA,QAAW,EAAA,SAAU,CAAE,GAAG,CAAM,EAAG,EAAA,OAAY,EAE/C,IAAM,GAAA,EAAc,EAAA,MAAA,CAAM,EACpB,GAAA,EAAmB,EAAA,MAAA,CAAM,EAEzB,MAAc,GAAU,EACxB,MAAmB,EAAU,qBAAuB,EAEpD,EAAY,EAAA,QAAa,CAAS,EAElC,EAAqB,GAAe,MAGpC,EAAQ,GAAQ,OAAS,EACzB,EAAY,GAAS,EAGrB,EAAW,GAAgB,CAAC,CAAC,EAC7B,EAAe,EAAY,GAAQ,OAAS,EAAa,IAAA,GAU/D,OARA,EAAA,EAAA,UAAA,KAAgB,CACf,EAAA,QACC,EAAA,SACA,CAAE,gBAAe,YAAW,MAAO,EAAW,SAAQ,YAAW,EACjE,EAAA,OACD,CACD,EAAG,CAAC,EAAe,EAAW,EAAW,EAAQ,CAAU,CAAC,GAG3D,EAAA,EAAA,KAAA,CAAC,MAAD,CACC,WAAA,EAAW,EAAA,QAAA,CACV,oBACA,CACC,iBAAkB,CACnB,EACA,CACD,EAPD,SAAA,CASE,IACA,EAAA,EAAA,KAAA,CAAC,QAAD,CACC,WAAA,EAAW,EAAA,QAAA,CAAW,2BAA4B,CACjD,sBAAuB,GAAsB,CAAC,CAC/C,CAAC,EACD,QAAS,EAAM,EAJhB,SAAA,CAME,IACA,EAAA,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,gBAAgB,MAAM,WAAW,SAAA,GAE3C,CAAA,EAEN,CACK,KAER,EAAA,EAAA,IAAA,CAAC,MAAD,CAAK,UAAU,6BACd,UAAA,EAAA,EAAA,IAAA,CAAC,WAAD,CACC,WAAA,EAAW,EAAA,QAAA,CAAW,gBAAiB,CAAmB,EAE/C,YACD,WACV,GAAI,EAAM,EACV,UAEC,OAAO,GAAc,SAClB,SAAS,EAAW,EAAE,EACtB,EAEE,OACE,SACR,SAAW,GAAU,CACpB,IAAW,EAAO,CAAE,MAAO,EAAM,OAAO,KAAM,CAAC,CAChD,EACS,UACA,UACA,UACE,YACA,YAEC,aACH,UACC,WACA,WACG,cACR,MACC,OACI,WACJ,OACC,QACP,mBACC,EACG,EAAW,EACT,EACF,oBAGJ,GAAI,CACJ,CAAA,CACG,CAAA,EACJ,IACA,EAAA,EAAA,IAAA,CAAC,MAAD,CAAK,GAAI,EAAW,EAAG,UAAU,0BAC/B,SAAA,CACG,CAAA,EAEL,CACG,GAEP,CACD,EAEA,EAAS,YAAc,EAAA"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../../../../components/textarea/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 {\n\tuseId,\n\tuseEffect,\n\tforwardRef,\n\ttype ChangeEvent,\n\ttype KeyboardEvent,\n\ttype ReactNode,\n\ttype TextareaHTMLAttributes,\n} from 'react';\nimport classNames from 'classnames';\nimport getAriaProps from '../../utilities/get-aria-props';\nimport { TEXTAREA } from '../../utilities/constants';\nimport checkProps from './check-props';\nimport componentDoc from './component.json';\n\n/**\n * Assistive text for Textarea\n */\nexport interface TextareaAssistiveText {\n\t/** Visually hidden label for screen readers */\n\tlabel?: string;\n}\n\n/**\n * Labels for Textarea\n */\nexport interface TextareaLabels {\n\t/** Error message shown below the textarea while `hasError` is true */\n\terror?: ReactNode;\n\t/** Visible label above the textarea */\n\tlabel?: ReactNode;\n}\n\n/**\n * Data passed to `onChange`\n */\nexport interface TextareaChangeData {\n\t/** The new text */\n\tvalue: string;\n}\n\n/**\n * Props removed in v11. They are ignored at runtime and warn in development.\n */\ninterface TextareaRemovedProps {\n\t/** @removed Textarea is controlled: pass `value` and update it in `onChange`. */\n\tdefaultValue?: unknown;\n}\n\n/**\n * Props for the Textarea component.\n *\n * Other `<textarea>` attributes (`rows`, `cols`, `autoComplete`, `readOnly`,\n * …) pass through to the element via `TextareaHTMLAttributes` — the same\n * approach as `Button` / `ButtonHTMLAttributes`, and equivalent to\n * `React.ComponentProps<'textarea'>` without `ref` (ref is via `forwardRef`).\n */\nexport interface TextareaProps extends Omit<\n\tTextareaHTMLAttributes<HTMLTextAreaElement>,\n\t'children' | 'className' | 'defaultValue' | 'onChange' | 'value'\n> {\n\t/**\n\t * **Assistive text for accessibility**\n\t * * `label`: Visually hidden label. Use instead of `labels.label`.\n\t */\n\tassistiveText?: TextareaAssistiveText;\n\t/** Elements rendered after the textarea, inside the form element */\n\tchildren?: ReactNode;\n\t/** CSS class for textarea element */\n\tclassName?: string | string[] | Record<string, boolean>;\n\t/** CSS class for container */\n\tclassNameContainer?: string | string[] | Record<string, boolean>;\n\t/** @deprecated Use `labels.error` and `hasError` instead. */\n\terrorText?: string;\n\t/** Puts the textarea in an error state and shows `labels.error` */\n\thasError?: boolean;\n\t/** @deprecated Use `labels.label` instead. */\n\tlabel?: string;\n\t/**\n\t * **Text labels for internationalization**\n\t * * `error`: Error message shown below the textarea while `hasError` is true\n\t * * `label`: Visible label. Use `assistiveText.label` for a visually hidden label.\n\t */\n\tlabels?: TextareaLabels;\n\t/**\n\t * Called when the text changes. Textarea is controlled: update `value` from\n\t * `data.value`, or the text won't change.\n\t */\n\tonChange: (\n\t\tevent: ChangeEvent<HTMLTextAreaElement>,\n\t\tdata: TextareaChangeData\n\t) => void;\n\t/**\n\t * @deprecated `keypress` is a deprecated DOM event. Use `onKeyDown` and read\n\t * `event.key` instead. Works only in the 11.0.0 release candidates, and warns.\n\t */\n\tonKeyPress?: (event: KeyboardEvent<HTMLTextAreaElement>) => void;\n\t/** The text in the textarea. Required: Textarea is controlled. */\n\tvalue: string;\n\t/** Text wrapping mode */\n\twrap?: 'soft' | 'hard';\n}\n\n/**\n * A multi-line plain-text editing control.\n */\nconst Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(\n\t(props, ref) => {\n\t\tconst {\n\t\t\tassistiveText,\n\t\t\tchildren,\n\t\t\tclassName,\n\t\t\tclassNameContainer,\n\t\t\terrorText,\n\t\t\thasError: hasErrorProp,\n\t\t\tid: propId,\n\t\t\tlabel: labelProp,\n\t\t\tlabels,\n\t\t\tmaxLength,\n\t\t\tonChange,\n\t\t\tonKeyPress,\n\t\t\trequired,\n\t\t\t// Removed in v11: destructured so it doesn't reach the DOM. check-props warns.\n\t\t\tdefaultValue: _defaultValue,\n\t\t\t...restProps\n\t\t} = props as TextareaProps & TextareaRemovedProps;\n\n\t\tcheckProps(TEXTAREA, { ...props }, componentDoc);\n\n\t\tconst generatedId = useId();\n\t\tconst generatedErrorId = useId();\n\n\t\tconst getId = () => propId || generatedId;\n\t\tconst getErrorId = () => restProps['aria-describedby'] || generatedErrorId;\n\n\t\tconst ariaProps = getAriaProps(restProps);\n\n\t\tconst assistiveTextLabel = assistiveText?.label;\n\n\t\t// `label` is deprecated\n\t\tconst label = labels?.label ?? labelProp;\n\t\tconst labelText = label || assistiveTextLabel;\n\n\t\t// `errorText` is deprecated: it sets both the error state and the message\n\t\tconst hasError = hasErrorProp ?? !!errorText;\n\t\tconst errorMessage = hasError ? (labels?.error ?? errorText) : undefined;\n\n\t\tuseEffect(() => {\n\t\t\tcheckProps(\n\t\t\t\tTEXTAREA,\n\t\t\t\t{ assistiveText, errorText, label: labelProp, labels, onKeyPress },\n\t\t\t\tcomponentDoc\n\t\t\t);\n\t\t}, [assistiveText, errorText, labelProp, labels, onKeyPress]);\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tclassName={classNames(\n\t\t\t\t\t'slds-form-element',\n\t\t\t\t\t{\n\t\t\t\t\t\t'slds-has-error': hasError,\n\t\t\t\t\t},\n\t\t\t\t\tclassNameContainer as string\n\t\t\t\t)}\n\t\t\t>\n\t\t\t\t{labelText && (\n\t\t\t\t\t<label\n\t\t\t\t\t\tclassName={classNames('slds-form-element__label', {\n\t\t\t\t\t\t\t'slds-assistive-text': assistiveTextLabel && !label,\n\t\t\t\t\t\t})}\n\t\t\t\t\t\thtmlFor={getId()}\n\t\t\t\t\t>\n\t\t\t\t\t\t{required && (\n\t\t\t\t\t\t\t<abbr className=\"slds-required\" title=\"required\">\n\t\t\t\t\t\t\t\t*\n\t\t\t\t\t\t\t</abbr>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t{labelText}\n\t\t\t\t\t</label>\n\t\t\t\t)}\n\t\t\t\t<div className=\"slds-form-element__control\">\n\t\t\t\t\t<textarea\n\t\t\t\t\t\t{...restProps}\n\t\t\t\t\t\t{...ariaProps}\n\t\t\t\t\t\tclassName={classNames('slds-textarea', className as string)}\n\t\t\t\t\t\tid={getId()}\n\t\t\t\t\t\tmaxLength={\n\t\t\t\t\t\t\t// Strings are still accepted at runtime for untyped callers; check-props warns.\n\t\t\t\t\t\t\ttypeof maxLength === 'string'\n\t\t\t\t\t\t\t\t? parseInt(maxLength, 10)\n\t\t\t\t\t\t\t\t: maxLength\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonChange={(event) => {\n\t\t\t\t\t\t\tonChange?.(event, { value: event.target.value });\n\t\t\t\t\t\t}}\n\t\t\t\t\t\t// eslint-disable-next-line local/no-deprecated -- forwards the deprecated `onKeyPress` prop until 11.0\n\t\t\t\t\t\tonKeyPress={onKeyPress}\n\t\t\t\t\t\tref={ref}\n\t\t\t\t\t\trequired={required}\n\t\t\t\t\t\taria-describedby={\n\t\t\t\t\t\t\terrorMessage ? getErrorId() : restProps['aria-describedby']\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t\t{errorMessage && (\n\t\t\t\t\t<div id={getErrorId()} className=\"slds-form-element__help\">\n\t\t\t\t\t\t{errorMessage}\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t);\n\t}\n);\n\nTextarea.displayName = TEXTAREA;\n\nexport default Textarea;\n"],"mappings":"iZA6GA,IAAM,GAAA,EAAW,EAAA,WAAA,EACf,EAAO,IAAQ,CACf,GAAM,CACL,gBACA,WACA,YACA,qBACA,YACA,SAAU,EACV,GAAI,EACJ,MAAO,EACP,SACA,YACA,WACA,aACA,WAEA,aAAc,EACd,GAAG,GACA,EAEJ,EAAA,QAAW,EAAA,SAAU,CAAE,GAAG,CAAM,EAAG,EAAA,OAAY,EAE/C,IAAM,GAAA,EAAc,EAAA,MAAA,CAAM,EACpB,GAAA,EAAmB,EAAA,MAAA,CAAM,EAEzB,MAAc,GAAU,EACxB,MAAmB,EAAU,qBAAuB,EAEpD,EAAY,EAAA,QAAa,CAAS,EAElC,EAAqB,GAAe,MAGpC,EAAQ,GAAQ,OAAS,EACzB,EAAY,GAAS,EAGrB,EAAW,GAAgB,CAAC,CAAC,EAC7B,EAAe,EAAY,GAAQ,OAAS,EAAa,IAAA,GAU/D,OARA,EAAA,EAAA,UAAA,KAAgB,CACf,EAAA,QACC,EAAA,SACA,CAAE,gBAAe,YAAW,MAAO,EAAW,SAAQ,YAAW,EACjE,EAAA,OACD,CACD,EAAG,CAAC,EAAe,EAAW,EAAW,EAAQ,CAAU,CAAC,GAG3D,EAAA,EAAA,KAAA,CAAC,MAAD,CACC,WAAA,EAAW,EAAA,QAAA,CACV,oBACA,CACC,iBAAkB,CACnB,EACA,CACD,EAPD,SAAA,CASE,IACA,EAAA,EAAA,KAAA,CAAC,QAAD,CACC,WAAA,EAAW,EAAA,QAAA,CAAW,2BAA4B,CACjD,sBAAuB,GAAsB,CAAC,CAC/C,CAAC,EACD,QAAS,EAAM,EAJhB,SAAA,CAME,IACA,EAAA,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,gBAAgB,MAAM,WAAW,SAAA,GAE3C,CAAA,EAEN,CACK,KAER,EAAA,EAAA,IAAA,CAAC,MAAD,CAAK,UAAU,6BACd,UAAA,EAAA,EAAA,IAAA,CAAC,WAAD,CACC,GAAI,EACJ,GAAI,EACJ,WAAA,EAAW,EAAA,QAAA,CAAW,gBAAiB,CAAmB,EAC1D,GAAI,EAAM,EACV,UAEC,OAAO,GAAc,SAClB,SAAS,EAAW,EAAE,EACtB,EAEJ,SAAW,GAAU,CACpB,IAAW,EAAO,CAAE,MAAO,EAAM,OAAO,KAAM,CAAC,CAChD,EAEY,aACP,MACK,WACV,mBACC,EAAe,EAAW,EAAI,EAAU,mBAEzC,CAAA,CACG,CAAA,EACJ,IACA,EAAA,EAAA,IAAA,CAAC,MAAD,CAAK,GAAI,EAAW,EAAG,UAAU,0BAC/B,SAAA,CACG,CAAA,EAEL,CACG,GAEP,CACD,EAEA,EAAS,YAAc,EAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":[],"sources":["../../../../components/tooltip/index.tsx"],"sourcesContent":["/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\n// # Tooltip\n\nimport React, {\n\tuseId,\n\tuseState,\n\tuseEffect,\n\tuseLayoutEffect,\n\tuseRef,\n\tuseCallback,\n\tuseContext,\n\ttype ReactNode,\n\ttype CSSProperties,\n\ttype KeyboardEvent,\n\ttype FocusEvent,\n\ttype MouseEvent,\n} from 'react';\nimport classNames from 'classnames';\n\nimport EventUtil from '../../utilities/event';\nimport { useControllableState } from '../../utilities/hooks';\nimport { POPOVER_TOOLTIP } from '../../utilities/constants';\nimport { renderTrigger } from '../../utilities/merge-props';\nimport type { TriggerRender } from '../../types/common';\n\nimport Dialog from '../utilities/dialog';\nimport Icon from '../icon';\n// eslint-disable-next-line import/no-cycle\nimport Button from '../button';\n\n// This component's `checkProps` which issues warnings to developers about properties when in development mode\nimport checkProps from './check-props';\nimport componentDoc from './component.json';\nimport { IconSettingsContext } from '../icon-settings';\n\n// ### Types\n\nexport type { TriggerRender };\n\nexport type TooltipAlign =\n\t| 'top'\n\t| 'top left'\n\t| 'top right'\n\t| 'right'\n\t| 'right top'\n\t| 'right bottom'\n\t| 'bottom'\n\t| 'bottom left'\n\t| 'bottom right'\n\t| 'left'\n\t| 'left top'\n\t| 'left bottom';\n\nexport type TooltipPosition =\n\t'absolute' | 'overflowBoundaryElement' | 'relative';\n\nexport type TooltipTheme = 'info' | 'error';\n\nexport type TooltipIconVariant = 'bare' | 'error' | 'inverse' | 'warning';\n\nexport type TooltipVariant = 'base' | 'learnMore' | 'list-item';\n\nexport interface TooltipAssistiveText {\n\t/** This text is inside the info icon within the tooltip content and exists to \"complete the sentence\" for assistive tech users. */\n\ttooltipTipLearnMoreIcon?: string;\n\t/** This text is inside the info icon that triggers the tooltip in order to have text within the link. */\n\ttriggerLearnMoreIcon?: string;\n}\n\nexport interface TooltipLabels {\n\t/** This label appears in the tooltip after the info icon. */\n\tlearnMoreAfter?: string;\n\t/** This label appears in the tooltip before the info icon. */\n\tlearnMoreBefore?: string;\n}\n\n/**\n * What caused `onRequestOpen` to fire:\n * * `focus`: the trigger received focus\n * * `mouseEnter`: the mouse entered the trigger\n */\nexport type TooltipRequestOpenTrigger = 'focus' | 'mouseEnter';\n\n/**\n * Data passed to `onRequestOpen`\n */\nexport interface TooltipRequestOpenData {\n\t/** What caused the open request */\n\ttrigger: TooltipRequestOpenTrigger;\n}\n\n/**\n * What caused `onRequestClose` to fire:\n * * `blur`: focus left the trigger (including Tab from the tooltip)\n * * `cancel`: Escape was pressed on the trigger\n * * `clickOutside`: a click landed outside the tooltip\n * * `mouseLeave`: the mouse left the trigger or the tooltip\n */\nexport type TooltipRequestCloseTrigger =\n\t'blur' | 'cancel' | 'clickOutside' | 'mouseLeave';\n\n/**\n * Data passed to `onRequestClose`\n */\nexport interface TooltipRequestCloseData {\n\t/** What caused the close request */\n\ttrigger: TooltipRequestCloseTrigger;\n}\n\n/**\n * Props Tooltip gives its trigger. A `trigger` element has them merged into its own\n * props; a `trigger` function receives them to spread onto the element it returns.\n */\nexport interface TooltipTriggerProps {\n\t/** The tooltip's id while it's open */\n\t'aria-describedby'?: string;\n\tonBlur: (event: FocusEvent<HTMLElement>) => void;\n\tonFocus: (event: FocusEvent<HTMLElement>) => void;\n\tonKeyDown: (event: KeyboardEvent<HTMLElement>) => void;\n\tonMouseEnter: (event: MouseEvent<HTMLElement>) => void;\n\tonMouseLeave: (event: MouseEvent<HTMLElement>) => void;\n}\n\nexport interface TooltipProps {\n\t/**\n\t * Alignment of the Tooltip relative to the element that triggers it.\n\t */\n\talign?: TooltipAlign;\n\t/**\n\t * **Assistive text for accessibility**\n\t * This object is merged with the default props object on every render.\n\t */\n\tassistiveText?: TooltipAssistiveText;\n\t/**\n\t * @deprecated Use `trigger`. Each child element is used as a trigger.\n\t */\n\tchildren?: ReactNode;\n\t/**\n\t * Content inside Tooltip.\n\t */\n\tcontent?: ReactNode;\n\t/**\n\t * CSS classes to be added to the popover dialog. That is the element with `.slds-popover` on it.\n\t */\n\tdialogClassName?: string | string[] | Record<string, boolean>;\n\t/**\n\t * Enabling this hides the default nubbin, replacing it with one attached directly to the tooltip trigger.\n\t */\n\thasAnchoredNubbin?: boolean;\n\t/**\n\t * By default, dialogs will flip their alignment if they extend beyond a boundary element.\n\t * `hasStaticAlignment` disables this behavior.\n\t */\n\thasStaticAlignment?: boolean;\n\t/**\n\t * Styles the default info icon trigger that renders when no children are passed. Matches `icon-variant` on `lightning-helptext`.\n\t * * `bare` - (default) Default icon color.\n\t * * `error` - Red icon, to call out an error.\n\t * * `inverse` - White icon, for dark backgrounds.\n\t * * `warning` - Yellow icon, to advise caution.\n\t */\n\ticonVariant?: TooltipIconVariant;\n\t/**\n\t * Delay on Tooltip closing in milliseconds. Defaults to 50\n\t */\n\thoverCloseDelay?: number;\n\t/**\n\t * Delay on Tooltip opening in milliseconds. Defaults to 0\n\t */\n\thoverOpenDelay?: number;\n\t/**\n\t * A unique ID is needed in order to support keyboard navigation, ARIA support, and connect the popover to the triggering element.\n\t */\n\tid?: string;\n\t/**\n\t * **Text labels for internationalization**\n\t */\n\tlabels?: TooltipLabels;\n\t/**\n\t * Open state when the tooltip is controlled. When set, the tooltip only opens and closes when this\n\t * prop changes: `isOpen={false}` keeps it closed and `isOpen={true}` keeps it open, whatever the\n\t * user does. Handle `onRequestOpen`/`onRequestClose` to update it. Leave it `undefined` for an\n\t * uncontrolled tooltip that opens on hover and focus (see `defaultIsOpen`).\n\t */\n\tisOpen?: boolean;\n\t/**\n\t * Initial open state of an uncontrolled tooltip (`isOpen` is `undefined`). Defaults to `false`.\n\t */\n\tdefaultIsOpen?: boolean;\n\t/**\n\t * Turns the tooltip off: it never opens and renders no dialog, whatever `isOpen` or\n\t * `defaultIsOpen` is. The trigger still renders.\n\t */\n\tisDisabled?: boolean;\n\t/**\n\t * Called when the tooltip requests to open (hover after `hoverOpenDelay`, or focus), controlled or\n\t * not. `data.trigger` says why. A controlled tooltip opens only if the parent sets `isOpen` to `true`.\n\t */\n\tonRequestOpen?: (\n\t\tevent: MouseEvent<HTMLElement> | FocusEvent<HTMLElement>,\n\t\tdata: TooltipRequestOpenData\n\t) => void;\n\t/**\n\t * Called when the tooltip requests to close (mouse leave, blur, Escape, click outside), controlled\n\t * or not. `data.trigger` says why. `event` is `undefined` for `clickOutside`. A controlled tooltip\n\t * closes only if the parent sets `isOpen` to `false`.\n\t */\n\tonRequestClose?: (\n\t\tevent:\n\t\t\t| MouseEvent<HTMLElement>\n\t\t\t| FocusEvent<HTMLElement>\n\t\t\t| KeyboardEvent<HTMLElement>\n\t\t\t| undefined,\n\t\tdata: TooltipRequestCloseData\n\t) => void;\n\t/**\n\t * Callback that returns an element or React `ref` to align the Tooltip with.\n\t */\n\tonRequestTargetElement?: () => HTMLElement | null;\n\t/**\n\t * Callback when the info icon in learn more variant is clicked\n\t */\n\tonClickTrigger?: (event: MouseEvent<HTMLAnchorElement>) => void;\n\t/**\n\t * CSS classes to be added to tag with `slds-tooltip-trigger`.\n\t */\n\ttriggerClassName?: string | string[] | Record<string, boolean>;\n\t/**\n\t * Please select one of the following:\n\t * * `absolute` - (default) The dialog will use `position: absolute` and style attributes to position itself.\n\t * * `overflowBoundaryElement` - The dialog will overflow scrolling parents.\n\t * * `relative` - No styling or portals will be used.\n\t */\n\tposition?: TooltipPosition;\n\t/**\n\t * Custom styles to be added to wrapping triggering `div`.\n\t */\n\ttriggerStyle?: CSSProperties;\n\t/**\n\t * Determines the theme of tooltip: for informative purpose (blue background) or warning purpose (red background).\n\t */\n\ttheme?: TooltipTheme;\n\t/**\n\t * The element that shows the Tooltip on hover and focus. It must be focusable, such as a\n\t * `Button`, an anchor, or an element with `tabIndex`. Pass an element to have Tooltip merge\n\t * its trigger props into the element's: event handlers run the element's first, then\n\t * Tooltip's, `aria-describedby` is joined, and the element's other props win. Or pass a\n\t * function that receives the trigger props (`TooltipTriggerProps`) and returns the trigger.\n\t * Without a trigger, Tooltip renders an info icon button.\n\t */\n\ttrigger?: TriggerRender<TooltipTriggerProps>;\n\t/**\n\t * Determines the type of the tooltip.\n\t */\n\tvariant?: TooltipVariant;\n}\n\n/**\n * Props library components set on a Tooltip. Not part of the public API.\n */\nexport interface TooltipInjectedProps {\n\t/** Skips the warning for a trigger that isn't tabbable, for triggers focused another way */\n\tsilenceTriggerTabbableWarning?: boolean;\n}\n\nconst defaultAssistiveText: TooltipAssistiveText = {\n\ttooltipTipLearnMoreIcon: 'this link',\n\ttriggerLearnMoreIcon: 'Help',\n};\n\nconst defaultLabels: TooltipLabels = {\n\tlearnMoreAfter: 'to learn more.',\n\tlearnMoreBefore: 'Click',\n};\n\n// Renders the trigger slot as a component, so the trigger props' handlers are only\n// handed to the slot rather than called from Tooltip's render\nconst TooltipTrigger = ({\n\trender,\n\ttriggerProps,\n}: {\n\trender: TriggerRender<TooltipTriggerProps>;\n\ttriggerProps: TooltipTriggerProps;\n}) => renderTrigger(render, triggerProps);\n\n/**\n * The PopoverTooltip component is variant of the Lightning Design System Popover component.\n * This component wraps an element that triggers it to open. It must be a focusable child element\n * (either a button or an anchor), so that keyboard users can navigate to it.\n */\nconst Tooltip = ({\n\talign = 'top',\n\tassistiveText: assistiveTextProp,\n\tchildren,\n\tcontent = <span>Tooltip</span>,\n\tdialogClassName,\n\thasAnchoredNubbin = false,\n\thasStaticAlignment = false,\n\thoverCloseDelay = 50,\n\thoverOpenDelay = 0,\n\ticonVariant = 'bare',\n\tid: idProp,\n\tlabels: labelsProp,\n\tisOpen: isOpenProp,\n\tdefaultIsOpen = false,\n\tisDisabled = false,\n\tonRequestOpen,\n\tonRequestClose,\n\tonRequestTargetElement,\n\tonClickTrigger,\n\ttriggerClassName,\n\tposition = 'absolute',\n\ttriggerStyle,\n\ttheme = 'info',\n\ttrigger,\n\tvariant = 'base',\n\tsilenceTriggerTabbableWarning,\n}: TooltipProps & TooltipInjectedProps): React.ReactElement => {\n\t// Merge assistive text and labels with defaults\n\tconst assistiveText = { ...defaultAssistiveText, ...assistiveTextProp };\n\tconst labels = { ...defaultLabels, ...labelsProp };\n\n\t// Context\n\tconst iconSettings = useContext(IconSettingsContext);\n\n\t// State\n\tconst [isOpen, setIsOpen] = useControllableState(isOpenProp, defaultIsOpen);\n\tconst [triggerRendered, setTriggerRendered] = useState(false);\n\tconst generatedId = useId();\n\t// Trigger size for the anchored nubbin, measured once the tooltip opens\n\tconst [triggerSize, setTriggerSize] = useState({ height: 0, width: 0 });\n\n\t// Refs\n\tconst triggerRef = useRef<HTMLDivElement>(null);\n\tconst tooltipTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\tconst isUnmountingRef = useRef(false);\n\t// Latest open state, read by the hover/blur/Escape timers\n\tconst isOpenRef = useRef(isOpen);\n\tuseEffect(() => {\n\t\tisOpenRef.current = isOpen;\n\t}, [isOpen]);\n\n\t// Check props in development\n\tuseEffect(() => {\n\t\tcheckProps(\n\t\t\tPOPOVER_TOOLTIP,\n\t\t\t{\n\t\t\t\talign,\n\t\t\t\tassistiveText,\n\t\t\t\tchildren,\n\t\t\t\tcontent,\n\t\t\t\tdialogClassName,\n\t\t\t\thasAnchoredNubbin,\n\t\t\t\thasStaticAlignment,\n\t\t\t\thoverCloseDelay,\n\t\t\t\thoverOpenDelay,\n\t\t\t\ticonVariant,\n\t\t\t\tid: idProp,\n\t\t\t\tlabels,\n\t\t\t\tisOpen: isOpenProp,\n\t\t\t\tonRequestTargetElement,\n\t\t\t\tonClickTrigger,\n\t\t\t\ttriggerClassName,\n\t\t\t\tposition,\n\t\t\t\ttriggerStyle,\n\t\t\t\ttheme,\n\t\t\t\ttrigger,\n\t\t\t\tvariant,\n\t\t\t\tsilenceTriggerTabbableWarning,\n\t\t\t},\n\t\t\tcomponentDoc\n\t\t);\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, []); // Only run on mount\n\n\t// Cleanup on unmount\n\tuseEffect(() => {\n\t\treturn () => {\n\t\t\tisUnmountingRef.current = true;\n\t\t\tif (tooltipTimeoutRef.current) {\n\t\t\t\tclearTimeout(tooltipTimeoutRef.current);\n\t\t\t}\n\t\t};\n\t}, []);\n\n\t// Get computed values\n\tconst getId = useCallback(() => {\n\t\treturn idProp || generatedId;\n\t}, [idProp, generatedId]);\n\n\tconst getIsOpen = useCallback(\n\t\t() => !isDisabled && isOpen,\n\t\t[isDisabled, isOpen]\n\t);\n\n\tconst getTooltipTarget = useCallback(() => {\n\t\tif (onRequestTargetElement) {\n\t\t\treturn onRequestTargetElement();\n\t\t}\n\n\t\treturn triggerRef.current;\n\t}, [onRequestTargetElement]);\n\n\t// Event handlers\n\tconst clearTooltipTimeout = () => {\n\t\tif (tooltipTimeoutRef.current) {\n\t\t\tclearTimeout(tooltipTimeoutRef.current);\n\t\t}\n\t};\n\n\tconst requestOpen = useCallback(\n\t\t(\n\t\t\tevent: MouseEvent<HTMLElement> | FocusEvent<HTMLElement>,\n\t\t\ttrigger: TooltipRequestOpenTrigger\n\t\t) => {\n\t\t\tif (isUnmountingRef.current || isDisabled || isOpenRef.current) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tonRequestOpen?.(event, { trigger });\n\t\t\tsetIsOpen(true);\n\t\t},\n\t\t[isDisabled, onRequestOpen, setIsOpen]\n\t);\n\n\tconst requestClose = useCallback(\n\t\t(\n\t\t\tevent:\n\t\t\t\t| MouseEvent<HTMLElement>\n\t\t\t\t| FocusEvent<HTMLElement>\n\t\t\t\t| KeyboardEvent<HTMLElement>\n\t\t\t\t| undefined,\n\t\t\ttrigger: TooltipRequestCloseTrigger\n\t\t) => {\n\t\t\tif (isUnmountingRef.current || !isOpenRef.current) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tonRequestClose?.(event, { trigger });\n\t\t\tsetIsOpen(false);\n\t\t},\n\t\t[onRequestClose, setIsOpen]\n\t);\n\n\t// Called by the Dialog on click outside, Tab and unmount\n\tconst handleDialogClose = useCallback(\n\t\t(\n\t\t\tevent?: KeyboardEvent<HTMLElement>,\n\t\t\tdata?: { componentWillUnmount?: boolean }\n\t\t) => {\n\t\t\tclearTooltipTimeout();\n\t\t\t// The dialog unmounts because the tooltip already closed: nothing to request\n\t\t\tif (data?.componentWillUnmount) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\trequestClose(event, event ? 'blur' : 'clickOutside');\n\t\t},\n\t\t[requestClose]\n\t);\n\n\tconst handleDialogMouseLeave = useCallback(\n\t\t(event: MouseEvent) => {\n\t\t\tclearTooltipTimeout();\n\t\t\trequestClose(event as MouseEvent<HTMLElement>, 'mouseLeave');\n\t\t},\n\t\t[requestClose]\n\t);\n\n\tconst scheduleOpen = useCallback(\n\t\t(\n\t\t\tevent: MouseEvent<HTMLElement> | FocusEvent<HTMLElement>,\n\t\t\ttrigger: TooltipRequestOpenTrigger\n\t\t) => {\n\t\t\tclearTooltipTimeout();\n\t\t\ttooltipTimeoutRef.current = setTimeout(() => {\n\t\t\t\trequestOpen(event, trigger);\n\t\t\t}, hoverOpenDelay);\n\t\t},\n\t\t[hoverOpenDelay, requestOpen]\n\t);\n\n\tconst handleMouseEnter = useCallback(\n\t\t(event: MouseEvent<HTMLElement>) => scheduleOpen(event, 'mouseEnter'),\n\t\t[scheduleOpen]\n\t);\n\n\tconst handleFocus = useCallback(\n\t\t(event: FocusEvent<HTMLElement>) => scheduleOpen(event, 'focus'),\n\t\t[scheduleOpen]\n\t);\n\n\tconst scheduleClose = useCallback(\n\t\t(\n\t\t\te: MouseEvent<HTMLElement> | FocusEvent<HTMLElement>,\n\t\t\ttrigger: TooltipRequestCloseTrigger\n\t\t) => {\n\t\t\te.stopPropagation();\n\t\t\tclearTooltipTimeout();\n\n\t\t\ttooltipTimeoutRef.current = setTimeout(() => {\n\t\t\t\tconst relatedTarget = (e as MouseEvent<HTMLElement>)\n\t\t\t\t\t.relatedTarget as HTMLElement | null;\n\t\t\t\tconst isHoveringTooltip =\n\t\t\t\t\trelatedTarget?.classList?.contains('slds-popover_tooltip') ||\n\t\t\t\t\trelatedTarget?.classList?.contains('slds-popover__body');\n\n\t\t\t\tif (!isHoveringTooltip) {\n\t\t\t\t\trequestClose(e, trigger);\n\t\t\t\t}\n\t\t\t}, hoverCloseDelay);\n\t\t},\n\t\t[hoverCloseDelay, requestClose]\n\t);\n\n\tconst handleMouseLeave = useCallback(\n\t\t(e: MouseEvent<HTMLElement>) => scheduleClose(e, 'mouseLeave'),\n\t\t[scheduleClose]\n\t);\n\n\tconst handleBlur = useCallback(\n\t\t(e: FocusEvent<HTMLElement>) => scheduleClose(e, 'blur'),\n\t\t[scheduleClose]\n\t);\n\n\tconst handleKeyDown = useCallback(\n\t\t(e: KeyboardEvent<HTMLElement>) => {\n\t\t\te.stopPropagation();\n\n\t\t\ttooltipTimeoutRef.current = setTimeout(() => {\n\t\t\t\tif (e.key === 'Escape') {\n\t\t\t\t\trequestClose(e, 'cancel');\n\t\t\t\t}\n\t\t\t}, hoverCloseDelay);\n\t\t},\n\t\t[hoverCloseDelay, requestClose]\n\t);\n\n\t// Save trigger ref and trigger re-render once mounted\n\tconst saveTriggerRef = useCallback(\n\t\t(component: HTMLDivElement | null) => {\n\t\t\tif (component && triggerRef.current !== component) {\n\t\t\t\t(triggerRef as React.RefObject<HTMLDivElement | null>).current =\n\t\t\t\t\tcomponent;\n\t\t\t\t// Dialog/Popper.js cannot place the popover until\n\t\t\t\t// the trigger/target DOM node is mounted.\n\t\t\t\tif (!triggerRendered) {\n\t\t\t\t\tsetTriggerRendered(true);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t[triggerRendered]\n\t);\n\n\t// Measure the trigger for the anchored nubbin before paint, so it is placed on open.\n\t// Runs after every render, as the old in-render measurement did, so a trigger that\n\t// resizes while the tooltip is open is re-measured.\n\tconst isAnchoredNubbinOpen = hasAnchoredNubbin && getIsOpen();\n\t// eslint-disable-next-line react-hooks/exhaustive-deps -- no deps on purpose; the updater returns the same state when the size is unchanged, so it settles\n\tuseLayoutEffect(() => {\n\t\tif (!isAnchoredNubbinOpen || !triggerRef.current) {\n\t\t\treturn;\n\t\t}\n\t\tconst { height, width } = triggerRef.current.getBoundingClientRect();\n\t\tsetTriggerSize((size) =>\n\t\t\tsize.height === height && size.width === width ? size : { height, width }\n\t\t);\n\t});\n\n\t// Render helpers\n\tconst getAnchoredNubbinStyles = () => {\n\t\tif (!hasAnchoredNubbin) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst alignment = align.split(' ')[0] as\n\t\t\t'top' | 'bottom' | 'left' | 'right';\n\t\tconst nubbinContainerStyles: CSSProperties = {\n\t\t\theight: '0',\n\t\t\tposition: 'relative',\n\t\t\twidth: '0',\n\t\t};\n\t\tconst nubbinStyles: CSSProperties = {\n\t\t\t// Same chain as the SLDS 2 tooltip body, so the nubbin matches it.\n\t\t\tbackgroundColor:\n\t\t\t\t'var(--slds-c-tooltip-color-background, var(--slds-g-color-surface-inverse-1, #16325c))',\n\t\t\tcontent: '\"\"',\n\t\t\theight: '1rem',\n\t\t\tposition: 'absolute',\n\t\t\ttransform: 'rotate(45deg)',\n\t\t\twidth: '1rem',\n\t\t};\n\t\tconst triggerDimensions = triggerSize;\n\n\t\tswitch (alignment) {\n\t\t\tcase 'bottom': {\n\t\t\t\tnubbinContainerStyles.left = `${triggerDimensions.width / 2}px`;\n\t\t\t\tnubbinContainerStyles.top = `${triggerDimensions.height}px`;\n\t\t\t\tnubbinStyles.left = '-8px';\n\t\t\t\tnubbinStyles.top = '3px';\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'left': {\n\t\t\t\tnubbinContainerStyles.left = '0';\n\t\t\t\tnubbinContainerStyles.top = `${triggerDimensions.height / 2}px`;\n\t\t\t\tnubbinStyles.left = '-19px';\n\t\t\t\tnubbinStyles.top = '-9px';\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'right': {\n\t\t\t\tnubbinContainerStyles.left = `${triggerDimensions.width}px`;\n\t\t\t\tnubbinContainerStyles.top = `${triggerDimensions.height / 2}px`;\n\t\t\t\tnubbinStyles.left = '3px';\n\t\t\t\tnubbinStyles.top = '-9px';\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\t// top\n\t\t\t\tnubbinContainerStyles.left = `${triggerDimensions.width / 2}px`;\n\t\t\t\tnubbinContainerStyles.top = '0';\n\t\t\t\tnubbinStyles.left = '-8px';\n\t\t\t\tnubbinStyles.top = '-19px';\n\t\t\t}\n\t\t}\n\n\t\t// The dialog doesn't draw its own nubbin (`isNubbinHidden`); this one is\n\t\t// drawn with inline styles, which CSP `style-src` doesn't block.\n\t\treturn getIsOpen() ? (\n\t\t\t<div style={nubbinContainerStyles}>\n\t\t\t\t<div style={nubbinStyles} />\n\t\t\t</div>\n\t\t) : null;\n\t};\n\n\tconst getContent = () => {\n\t\tconst isInverseIcon = iconVariant === 'inverse';\n\t\tconst iconColorVariant =\n\t\t\ticonVariant === 'error' || iconVariant === 'warning'\n\t\t\t\t? iconVariant\n\t\t\t\t: undefined;\n\n\t\tconst triggerProps: TooltipTriggerProps = {\n\t\t\t'aria-describedby': getIsOpen() ? getId() : undefined,\n\t\t\tonBlur: handleBlur,\n\t\t\tonFocus: handleFocus,\n\t\t\tonKeyDown: handleKeyDown,\n\t\t\tonMouseEnter: handleMouseEnter,\n\t\t\tonMouseLeave: handleMouseLeave,\n\t\t};\n\n\t\tif (trigger !== undefined) {\n\t\t\treturn <TooltipTrigger render={trigger} triggerProps={triggerProps} />;\n\t\t}\n\n\t\t// Deprecated: each child element is a trigger\n\t\tif (React.Children.count(children) !== 0) {\n\t\t\treturn React.Children.map(children, (child) =>\n\t\t\t\tReact.isValidElement(child) ? (\n\t\t\t\t\t<TooltipTrigger render={child} triggerProps={triggerProps} />\n\t\t\t\t) : (\n\t\t\t\t\tchild\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\tif (onClickTrigger) {\n\t\t\treturn (\n\t\t\t\t<TooltipTrigger\n\t\t\t\t\trender={\n\t\t\t\t\t\t// eslint-disable-next-line jsx-a11y/anchor-is-valid -- SLDS tooltip markup uses an anchor for the clickable trigger\n\t\t\t\t\t\t<a\n\t\t\t\t\t\t\thref=\"#\"\n\t\t\t\t\t\t\tonClick={\n\t\t\t\t\t\t\t\tEventUtil.trappedHandler(\n\t\t\t\t\t\t\t\t\tonClickTrigger\n\t\t\t\t\t\t\t\t) as React.MouseEventHandler<HTMLAnchorElement>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\tcategory=\"utility\"\n\t\t\t\t\t\t\t\tcolorVariant={iconColorVariant}\n\t\t\t\t\t\t\t\tinverse={isInverseIcon}\n\t\t\t\t\t\t\t\tname=\"info\"\n\t\t\t\t\t\t\t\tassistiveText={{\n\t\t\t\t\t\t\t\t\tlabel: assistiveText.triggerLearnMoreIcon,\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\tsize=\"x-small\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</a>\n\t\t\t\t\t}\n\t\t\t\t\ttriggerProps={triggerProps}\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<TooltipTrigger\n\t\t\t\trender={\n\t\t\t\t\t<Button\n\t\t\t\t\t\taria-disabled\n\t\t\t\t\t\tassistiveText={{\n\t\t\t\t\t\t\ticon: assistiveText.triggerLearnMoreIcon,\n\t\t\t\t\t\t}}\n\t\t\t\t\t\ticonCategory=\"utility\"\n\t\t\t\t\t\ticonClassName={\n\t\t\t\t\t\t\ticonColorVariant && `slds-icon-text-${iconColorVariant}`\n\t\t\t\t\t\t}\n\t\t\t\t\t\ticonName=\"info\"\n\t\t\t\t\t\t// `bare` keeps `slds-button_icon`, which Button drops for `inverse` alone\n\t\t\t\t\t\ticonVariant={isInverseIcon ? 'bare' : undefined}\n\t\t\t\t\t\tinverse={isInverseIcon}\n\t\t\t\t\t\tvariant=\"icon\"\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t\ttriggerProps={triggerProps}\n\t\t\t/>\n\t\t);\n\t};\n\n\tconst getTooltipContent = () => {\n\t\tconst isErrorTheme = theme === 'error';\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tclassName={classNames('slds-popover__body', {\n\t\t\t\t\t// Ensure text contrast on error theme (red background needs white text)\n\t\t\t\t\t'slds-text-color_inverse': isErrorTheme,\n\t\t\t\t})}\n\t\t\t>\n\t\t\t\t{content}\n\t\t\t\t{variant === 'learnMore' && onClickTrigger ? (\n\t\t\t\t\t<div className=\"slds-m-top_x-small\" aria-hidden=\"true\">\n\t\t\t\t\t\t{labels.learnMoreBefore}{' '}\n\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\tassistiveText={{\n\t\t\t\t\t\t\t\tlabel: assistiveText.tooltipTipLearnMoreIcon,\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\tcategory=\"utility\"\n\t\t\t\t\t\t\tinverse\n\t\t\t\t\t\t\tname=\"info\"\n\t\t\t\t\t\t\tsize=\"x-small\"\n\t\t\t\t\t\t/>{' '}\n\t\t\t\t\t\t{labels.learnMoreAfter}{' '}\n\t\t\t\t\t</div>\n\t\t\t\t) : null}\n\t\t\t</div>\n\t\t);\n\t};\n\n\tconst getTooltip = () => {\n\t\treturn getIsOpen() ? (\n\t\t\t<Dialog\n\t\t\t\tcloseOnTabKey\n\t\t\t\thasNubbin\n\t\t\t\tisNubbinHidden={hasAnchoredNubbin}\n\t\t\t\tcontentsClassName={classNames(\n\t\t\t\t\t'slds-popover',\n\t\t\t\t\t'slds-popover_tooltip',\n\t\t\t\t\t{\n\t\t\t\t\t\t'slds-theme_error': theme === 'error',\n\t\t\t\t\t},\n\t\t\t\t\tdialogClassName\n\t\t\t\t)}\n\t\t\t\talign={align}\n\t\t\t\tcontext={iconSettings}\n\t\t\t\thasStaticAlignment={hasStaticAlignment}\n\t\t\t\tonClose={handleDialogClose}\n\t\t\t\tonRequestTargetElement={getTooltipTarget}\n\t\t\t\tonMouseLeave={handleDialogMouseLeave}\n\t\t\t\tposition={position}\n\t\t\t\tvariant=\"tooltip\"\n\t\t\t\tcontainerProps={{\n\t\t\t\t\tid: getId(),\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{getTooltipContent()}\n\t\t\t</Dialog>\n\t\t) : (\n\t\t\t<span />\n\t\t);\n\t};\n\n\tconst containerStyles: CSSProperties = {\n\t\tdisplay: 'inline-block',\n\t\tlineHeight: 'var(--slds-g-font-line-height-1, 1)',\n\t\t...triggerStyle,\n\t};\n\n\treturn (\n\t\t<div\n\t\t\tclassName={classNames('slds-tooltip-trigger', triggerClassName)}\n\t\t\tstyle={containerStyles}\n\t\t\tref={saveTriggerRef}\n\t\t>\n\t\t\t{getAnchoredNubbinStyles()}\n\t\t\t{getContent()}\n\t\t\t{getTooltip()}\n\t\t</div>\n\t);\n};\n\nTooltip.displayName = POPOVER_TOOLTIP;\n\nexport default Tooltip as React.FC<TooltipProps>;\n"],"mappings":"+pBA2QA,IAAM,EAA6C,CAClD,wBAAyB,YACzB,qBAAsB,MACvB,EAEM,GAA+B,CACpC,eAAgB,iBAChB,gBAAiB,OAClB,EAIM,GAAkB,CACvB,SACA,kBAIK,EAAA,cAAc,EAAQ,CAAY,EAOlC,GAAW,CAChB,QAAQ,MACR,cAAe,EACf,WACA,WAAU,EAAA,EAAA,IAAA,CAAC,OAAD,CAAA,SAAM,SAAa,CAAA,EAC7B,kBACA,oBAAoB,GACpB,qBAAqB,GACrB,kBAAkB,GAClB,iBAAiB,EACjB,cAAc,OACd,GAAI,EACJ,OAAQ,GACR,OAAQ,EACR,gBAAgB,GAChB,aAAa,GACb,gBACA,iBACA,yBACA,iBACA,mBACA,WAAW,WACX,eACA,QAAQ,OACR,UACA,UAAU,OACV,oCAC8D,CAE9D,IAAM,EAAgB,CAAE,GAAG,EAAsB,GAAG,CAAkB,EAChE,EAAS,CAAE,GAAG,GAAe,GAAG,EAAW,EAG3C,IAAA,EAAe,EAAA,WAAA,CAAW,EAAA,mBAAmB,EAG7C,CAAC,EAAQ,GAAa,EAAA,qBAAqB,EAAY,CAAa,EACpE,CAAC,EAAiB,KAAA,EAAsB,EAAA,SAAA,CAAS,EAAK,EACtD,GAAA,EAAc,EAAA,MAAA,CAAM,EAEpB,CAAC,EAAa,IAAA,EAAkB,EAAA,SAAA,CAAS,CAAE,OAAQ,EAAG,MAAO,CAAE,CAAC,EAGhE,GAAA,EAAa,EAAA,OAAA,CAAuB,IAAI,EACxC,GAAA,EAAoB,EAAA,OAAA,CAA6C,IAAI,EACrE,GAA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IAAY,aAAe,GAC3B,EAAA,EAAA,KAAA,CAAC,MAAD,CAAK,UAAU,qBAAqB,cAAY,OAAhD,SAAA,CACE,EAAO,gBAAiB,KACzB,EAAA,EAAA,IAAA,CAAC,EAAA,QAAD,CACC,cAAe,CACd,MAAO,EAAc,uBACtB,EACA,SAAS,UACT,QAAA,GACA,KAAK,OACL,KAAK,SACL,CAAA,EAAE,IACF,EAAO,eAAgB,GACpB,CACF,CAAA,EAAA,IACA,IAID,OACE,EAAU,GAChB,EAAA,EAAA,IAAA,CAAC,GAAA,QAAD,CACC,cAAA,GACA,UAAA,GACA,eAAgB,EAChB,mBAAA,EAAmB,EAAA,QAAA,CAClB,eACA,uBACA,CACC,mBAAoB,IAAU,OAC/B,EACA,CACD,EACO,QACP,QAAS,GACW,qBACpB,QAAS,GACT,uBAAwB,GACxB,aAAc,GACJ,WACV,QAAQ,UACR,eAAgB,CACf,GAAI,EAAM,CACX,EAEC,SAAA,GAAkB,CACZ,CAAA,GAER,EAAA,EAAA,IAAA,CAAC,OAAD,CAAO,CAAA,EAIH,GAAiC,CACtC,QAAS,eACT,WAAY,sCACZ,GAAG,CACJ,EAEA,OACC,EAAA,EAAA,KAAA,CAAC,MAAD,CACC,WAAA,EAAW,EAAA,QAAA,CAAW,uBAAwB,CAAgB,EAC9D,MAAO,GACP,IAAK,EAHN,SAAA,CAKE,GAAwB,EACxB,GAAW,EACX,GAAW,CACR,GAEP,EAEA,EAAQ,YAAc,EAAA"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../../../../components/tooltip/index.tsx"],"sourcesContent":["/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\n// # Tooltip\n\nimport React, {\n\tuseId,\n\tuseState,\n\tuseEffect,\n\tuseLayoutEffect,\n\tuseRef,\n\tuseCallback,\n\tuseContext,\n\ttype ReactNode,\n\ttype CSSProperties,\n\ttype KeyboardEvent,\n\ttype FocusEvent,\n\ttype MouseEvent,\n} from 'react';\nimport classNames from 'classnames';\n\nimport EventUtil from '../../utilities/event';\nimport { useControllableState } from '../../utilities/hooks';\nimport { POPOVER_TOOLTIP } from '../../utilities/constants';\nimport { renderTrigger } from '../../utilities/merge-props';\nimport type { TriggerRender } from '../../types/common';\n\nimport Dialog from '../utilities/dialog';\nimport Icon from '../icon';\n// eslint-disable-next-line import/no-cycle\nimport Button from '../button';\n\n// This component's `checkProps` which issues warnings to developers about properties when in development mode\nimport checkProps from './check-props';\nimport componentDoc from './component.json';\nimport { IconSettingsContext } from '../icon-settings';\n\n// ### Types\n\nexport type { TriggerRender };\n\nexport type TooltipAlign =\n\t| 'top'\n\t| 'top left'\n\t| 'top right'\n\t| 'right'\n\t| 'right top'\n\t| 'right bottom'\n\t| 'bottom'\n\t| 'bottom left'\n\t| 'bottom right'\n\t| 'left'\n\t| 'left top'\n\t| 'left bottom';\n\nexport type TooltipPosition =\n\t'absolute' | 'overflowBoundaryElement' | 'relative';\n\nexport type TooltipTheme = 'info' | 'error';\n\nexport type TooltipIconVariant = 'bare' | 'error' | 'inverse' | 'warning';\n\nexport type TooltipVariant = 'base' | 'learnMore' | 'list-item';\n\nexport interface TooltipAssistiveText {\n\t/** This text is inside the info icon within the tooltip content and exists to \"complete the sentence\" for assistive tech users. */\n\ttooltipTipLearnMoreIcon?: string;\n\t/** This text is inside the info icon that triggers the tooltip in order to have text within the link. */\n\ttriggerLearnMoreIcon?: string;\n}\n\nexport interface TooltipLabels {\n\t/** This label appears in the tooltip after the info icon. */\n\tlearnMoreAfter?: string;\n\t/** This label appears in the tooltip before the info icon. */\n\tlearnMoreBefore?: string;\n}\n\n/**\n * What caused `onRequestOpen` to fire:\n * * `focus`: the trigger received focus\n * * `mouseEnter`: the mouse entered the trigger\n */\nexport type TooltipRequestOpenTrigger = 'focus' | 'mouseEnter';\n\n/**\n * Data passed to `onRequestOpen`\n */\nexport interface TooltipRequestOpenData {\n\t/** What caused the open request */\n\ttrigger: TooltipRequestOpenTrigger;\n}\n\n/**\n * What caused `onRequestClose` to fire:\n * * `blur`: focus left the trigger (including Tab from the tooltip)\n * * `cancel`: Escape was pressed on the trigger\n * * `clickOutside`: a click landed outside the tooltip\n * * `mouseLeave`: the mouse left the trigger or the tooltip\n */\nexport type TooltipRequestCloseTrigger =\n\t'blur' | 'cancel' | 'clickOutside' | 'mouseLeave';\n\n/**\n * Data passed to `onRequestClose`\n */\nexport interface TooltipRequestCloseData {\n\t/** What caused the close request */\n\ttrigger: TooltipRequestCloseTrigger;\n}\n\n/**\n * Props Tooltip gives its trigger. A `trigger` element has them merged into its own\n * props; a `trigger` function receives them to spread onto the element it returns.\n */\nexport interface TooltipTriggerProps {\n\t/** The tooltip's id while it's open */\n\t'aria-describedby'?: string;\n\t/** Requests close when the trigger loses focus. */\n\tonBlur: (event: FocusEvent<HTMLElement>) => void;\n\t/** Requests open when the trigger gains focus. */\n\tonFocus: (event: FocusEvent<HTMLElement>) => void;\n\t/** Requests close on Escape. */\n\tonKeyDown: (event: KeyboardEvent<HTMLElement>) => void;\n\t/** Requests open on hover. */\n\tonMouseEnter: (event: MouseEvent<HTMLElement>) => void;\n\t/** Requests close when the pointer leaves, after `hoverCloseDelay`. */\n\tonMouseLeave: (event: MouseEvent<HTMLElement>) => void;\n}\n\nexport interface TooltipProps {\n\t/**\n\t * Alignment of the Tooltip relative to the element that triggers it.\n\t */\n\talign?: TooltipAlign;\n\t/**\n\t * **Assistive text for accessibility**\n\t * This object is merged with the default props object on every render.\n\t */\n\tassistiveText?: TooltipAssistiveText;\n\t/**\n\t * @deprecated Use `trigger`. Each child element is used as a trigger.\n\t */\n\tchildren?: ReactNode;\n\t/**\n\t * Content inside Tooltip.\n\t */\n\tcontent?: ReactNode;\n\t/**\n\t * CSS classes to be added to the popover dialog. That is the element with `.slds-popover` on it.\n\t */\n\tdialogClassName?: string | string[] | Record<string, boolean>;\n\t/**\n\t * Enabling this hides the default nubbin, replacing it with one attached directly to the tooltip trigger.\n\t */\n\thasAnchoredNubbin?: boolean;\n\t/**\n\t * By default, dialogs will flip their alignment if they extend beyond a boundary element.\n\t * `hasStaticAlignment` disables this behavior.\n\t */\n\thasStaticAlignment?: boolean;\n\t/**\n\t * Styles the default info icon trigger that renders when no children are passed. Matches `icon-variant` on `lightning-helptext`.\n\t * * `bare` - (default) Default icon color.\n\t * * `error` - Red icon, to call out an error.\n\t * * `inverse` - White icon, for dark backgrounds.\n\t * * `warning` - Yellow icon, to advise caution.\n\t */\n\ticonVariant?: TooltipIconVariant;\n\t/**\n\t * Delay on Tooltip closing in milliseconds. Defaults to 50\n\t */\n\thoverCloseDelay?: number;\n\t/**\n\t * Delay on Tooltip opening in milliseconds. Defaults to 0\n\t */\n\thoverOpenDelay?: number;\n\t/**\n\t * A unique ID is needed in order to support keyboard navigation, ARIA support, and connect the popover to the triggering element.\n\t */\n\tid?: string;\n\t/**\n\t * **Text labels for internationalization**\n\t */\n\tlabels?: TooltipLabels;\n\t/**\n\t * Open state when the tooltip is controlled. When set, the tooltip only opens and closes when this\n\t * prop changes: `isOpen={false}` keeps it closed and `isOpen={true}` keeps it open, whatever the\n\t * user does. Handle `onRequestOpen`/`onRequestClose` to update it. Leave it `undefined` for an\n\t * uncontrolled tooltip that opens on hover and focus (see `defaultIsOpen`).\n\t */\n\tisOpen?: boolean;\n\t/**\n\t * Initial open state of an uncontrolled tooltip (`isOpen` is `undefined`). Defaults to `false`.\n\t */\n\tdefaultIsOpen?: boolean;\n\t/**\n\t * Turns the tooltip off: it never opens and renders no dialog, whatever `isOpen` or\n\t * `defaultIsOpen` is. The trigger still renders.\n\t */\n\tisDisabled?: boolean;\n\t/**\n\t * Called when the tooltip requests to open (hover after `hoverOpenDelay`, or focus), controlled or\n\t * not. `data.trigger` says why. A controlled tooltip opens only if the parent sets `isOpen` to `true`.\n\t */\n\tonRequestOpen?: (\n\t\tevent: MouseEvent<HTMLElement> | FocusEvent<HTMLElement>,\n\t\tdata: TooltipRequestOpenData\n\t) => void;\n\t/**\n\t * Called when the tooltip requests to close (mouse leave, blur, Escape, click outside), controlled\n\t * or not. `data.trigger` says why. `event` is `undefined` for `clickOutside`. A controlled tooltip\n\t * closes only if the parent sets `isOpen` to `false`.\n\t */\n\tonRequestClose?: (\n\t\tevent:\n\t\t\t| MouseEvent<HTMLElement>\n\t\t\t| FocusEvent<HTMLElement>\n\t\t\t| KeyboardEvent<HTMLElement>\n\t\t\t| undefined,\n\t\tdata: TooltipRequestCloseData\n\t) => void;\n\t/**\n\t * Callback that returns an element or React `ref` to align the Tooltip with.\n\t */\n\tonRequestTargetElement?: () => HTMLElement | null;\n\t/**\n\t * Callback when the info icon in learn more variant is clicked\n\t */\n\tonClickTrigger?: (event: MouseEvent<HTMLAnchorElement>) => void;\n\t/**\n\t * CSS classes to be added to tag with `slds-tooltip-trigger`.\n\t */\n\ttriggerClassName?: string | string[] | Record<string, boolean>;\n\t/**\n\t * Please select one of the following:\n\t * * `absolute` - (default) The dialog will use `position: absolute` and style attributes to position itself.\n\t * * `overflowBoundaryElement` - The dialog will overflow scrolling parents.\n\t * * `relative` - No styling or portals will be used.\n\t */\n\tposition?: TooltipPosition;\n\t/**\n\t * Custom styles to be added to wrapping triggering `div`.\n\t */\n\ttriggerStyle?: CSSProperties;\n\t/**\n\t * Determines the theme of tooltip: for informative purpose (blue background) or warning purpose (red background).\n\t */\n\ttheme?: TooltipTheme;\n\t/**\n\t * The element that shows the Tooltip on hover and focus. It must be focusable, such as a\n\t * `Button`, an anchor, or an element with `tabIndex`. Pass an element to have Tooltip merge\n\t * its trigger props into the element's: event handlers run the element's first, then\n\t * Tooltip's, `aria-describedby` is joined, and the element's other props win. Or pass a\n\t * function that receives the trigger props (`TooltipTriggerProps`) and returns the trigger.\n\t * Without a trigger, Tooltip renders an info icon button.\n\t */\n\ttrigger?: TriggerRender<TooltipTriggerProps>;\n\t/**\n\t * Determines the type of the tooltip.\n\t */\n\tvariant?: TooltipVariant;\n}\n\n/**\n * Props library components set on a Tooltip. Not part of the public API.\n */\nexport interface TooltipInjectedProps {\n\t/** Skips the warning for a trigger that isn't tabbable, for triggers focused another way */\n\tsilenceTriggerTabbableWarning?: boolean;\n}\n\nconst defaultAssistiveText: TooltipAssistiveText = {\n\ttooltipTipLearnMoreIcon: 'this link',\n\ttriggerLearnMoreIcon: 'Help',\n};\n\nconst defaultLabels: TooltipLabels = {\n\tlearnMoreAfter: 'to learn more.',\n\tlearnMoreBefore: 'Click',\n};\n\n// Renders the trigger slot as a component, so the trigger props' handlers are only\n// handed to the slot rather than called from Tooltip's render\nconst TooltipTrigger = ({\n\trender,\n\ttriggerProps,\n}: {\n\trender: TriggerRender<TooltipTriggerProps>;\n\ttriggerProps: TooltipTriggerProps;\n}) => renderTrigger(render, triggerProps);\n\n/**\n * The Tooltip component is a variant of the Lightning Design System Popover component.\n * This component wraps an element that triggers it to open. It must be a focusable child element\n * (either a button or an anchor), so that keyboard users can navigate to it.\n */\nconst Tooltip = ({\n\talign = 'top',\n\tassistiveText: assistiveTextProp,\n\tchildren,\n\tcontent = <span>Tooltip</span>,\n\tdialogClassName,\n\thasAnchoredNubbin = false,\n\thasStaticAlignment = false,\n\thoverCloseDelay = 50,\n\thoverOpenDelay = 0,\n\ticonVariant = 'bare',\n\tid: idProp,\n\tlabels: labelsProp,\n\tisOpen: isOpenProp,\n\tdefaultIsOpen = false,\n\tisDisabled = false,\n\tonRequestOpen,\n\tonRequestClose,\n\tonRequestTargetElement,\n\tonClickTrigger,\n\ttriggerClassName,\n\tposition = 'absolute',\n\ttriggerStyle,\n\ttheme = 'info',\n\ttrigger,\n\tvariant = 'base',\n\tsilenceTriggerTabbableWarning,\n}: TooltipProps & TooltipInjectedProps): React.ReactElement => {\n\t// Merge assistive text and labels with defaults\n\tconst assistiveText = { ...defaultAssistiveText, ...assistiveTextProp };\n\tconst labels = { ...defaultLabels, ...labelsProp };\n\n\t// Context\n\tconst iconSettings = useContext(IconSettingsContext);\n\n\t// State\n\tconst [isOpen, setIsOpen] = useControllableState(isOpenProp, defaultIsOpen);\n\tconst [triggerRendered, setTriggerRendered] = useState(false);\n\tconst generatedId = useId();\n\t// Trigger size for the anchored nubbin, measured once the tooltip opens\n\tconst [triggerSize, setTriggerSize] = useState({ height: 0, width: 0 });\n\n\t// Refs\n\tconst triggerRef = useRef<HTMLDivElement>(null);\n\tconst tooltipTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\tconst isUnmountingRef = useRef(false);\n\t// Latest open state, read by the hover/blur/Escape timers\n\tconst isOpenRef = useRef(isOpen);\n\tuseEffect(() => {\n\t\tisOpenRef.current = isOpen;\n\t}, [isOpen]);\n\n\t// Check props in development\n\tuseEffect(() => {\n\t\tcheckProps(\n\t\t\tPOPOVER_TOOLTIP,\n\t\t\t{\n\t\t\t\talign,\n\t\t\t\tassistiveText,\n\t\t\t\tchildren,\n\t\t\t\tcontent,\n\t\t\t\tdialogClassName,\n\t\t\t\thasAnchoredNubbin,\n\t\t\t\thasStaticAlignment,\n\t\t\t\thoverCloseDelay,\n\t\t\t\thoverOpenDelay,\n\t\t\t\ticonVariant,\n\t\t\t\tid: idProp,\n\t\t\t\tlabels,\n\t\t\t\tisOpen: isOpenProp,\n\t\t\t\tonRequestTargetElement,\n\t\t\t\tonClickTrigger,\n\t\t\t\ttriggerClassName,\n\t\t\t\tposition,\n\t\t\t\ttriggerStyle,\n\t\t\t\ttheme,\n\t\t\t\ttrigger,\n\t\t\t\tvariant,\n\t\t\t\tsilenceTriggerTabbableWarning,\n\t\t\t},\n\t\t\tcomponentDoc\n\t\t);\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, []); // Only run on mount\n\n\t// Cleanup on unmount\n\tuseEffect(() => {\n\t\treturn () => {\n\t\t\tisUnmountingRef.current = true;\n\t\t\tif (tooltipTimeoutRef.current) {\n\t\t\t\tclearTimeout(tooltipTimeoutRef.current);\n\t\t\t}\n\t\t};\n\t}, []);\n\n\t// Get computed values\n\tconst getId = useCallback(() => {\n\t\treturn idProp || generatedId;\n\t}, [idProp, generatedId]);\n\n\tconst getIsOpen = useCallback(\n\t\t() => !isDisabled && isOpen,\n\t\t[isDisabled, isOpen]\n\t);\n\n\tconst getTooltipTarget = useCallback(() => {\n\t\tif (onRequestTargetElement) {\n\t\t\treturn onRequestTargetElement();\n\t\t}\n\n\t\treturn triggerRef.current;\n\t}, [onRequestTargetElement]);\n\n\t// Event handlers\n\tconst clearTooltipTimeout = () => {\n\t\tif (tooltipTimeoutRef.current) {\n\t\t\tclearTimeout(tooltipTimeoutRef.current);\n\t\t}\n\t};\n\n\tconst requestOpen = useCallback(\n\t\t(\n\t\t\tevent: MouseEvent<HTMLElement> | FocusEvent<HTMLElement>,\n\t\t\ttrigger: TooltipRequestOpenTrigger\n\t\t) => {\n\t\t\tif (isUnmountingRef.current || isDisabled || isOpenRef.current) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tonRequestOpen?.(event, { trigger });\n\t\t\tsetIsOpen(true);\n\t\t},\n\t\t[isDisabled, onRequestOpen, setIsOpen]\n\t);\n\n\tconst requestClose = useCallback(\n\t\t(\n\t\t\tevent:\n\t\t\t\t| MouseEvent<HTMLElement>\n\t\t\t\t| FocusEvent<HTMLElement>\n\t\t\t\t| KeyboardEvent<HTMLElement>\n\t\t\t\t| undefined,\n\t\t\ttrigger: TooltipRequestCloseTrigger\n\t\t) => {\n\t\t\tif (isUnmountingRef.current || !isOpenRef.current) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tonRequestClose?.(event, { trigger });\n\t\t\tsetIsOpen(false);\n\t\t},\n\t\t[onRequestClose, setIsOpen]\n\t);\n\n\t// Called by the Dialog on click outside, Tab and unmount\n\tconst handleDialogClose = useCallback(\n\t\t(\n\t\t\tevent?: KeyboardEvent<HTMLElement>,\n\t\t\tdata?: { componentWillUnmount?: boolean }\n\t\t) => {\n\t\t\tclearTooltipTimeout();\n\t\t\t// The dialog unmounts because the tooltip already closed: nothing to request\n\t\t\tif (data?.componentWillUnmount) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\trequestClose(event, event ? 'blur' : 'clickOutside');\n\t\t},\n\t\t[requestClose]\n\t);\n\n\tconst handleDialogMouseLeave = useCallback(\n\t\t(event: MouseEvent) => {\n\t\t\tclearTooltipTimeout();\n\t\t\trequestClose(event as MouseEvent<HTMLElement>, 'mouseLeave');\n\t\t},\n\t\t[requestClose]\n\t);\n\n\tconst scheduleOpen = useCallback(\n\t\t(\n\t\t\tevent: MouseEvent<HTMLElement> | FocusEvent<HTMLElement>,\n\t\t\ttrigger: TooltipRequestOpenTrigger\n\t\t) => {\n\t\t\tclearTooltipTimeout();\n\t\t\ttooltipTimeoutRef.current = setTimeout(() => {\n\t\t\t\trequestOpen(event, trigger);\n\t\t\t}, hoverOpenDelay);\n\t\t},\n\t\t[hoverOpenDelay, requestOpen]\n\t);\n\n\tconst handleMouseEnter = useCallback(\n\t\t(event: MouseEvent<HTMLElement>) => scheduleOpen(event, 'mouseEnter'),\n\t\t[scheduleOpen]\n\t);\n\n\tconst handleFocus = useCallback(\n\t\t(event: FocusEvent<HTMLElement>) => scheduleOpen(event, 'focus'),\n\t\t[scheduleOpen]\n\t);\n\n\tconst scheduleClose = useCallback(\n\t\t(\n\t\t\te: MouseEvent<HTMLElement> | FocusEvent<HTMLElement>,\n\t\t\ttrigger: TooltipRequestCloseTrigger\n\t\t) => {\n\t\t\te.stopPropagation();\n\t\t\tclearTooltipTimeout();\n\n\t\t\ttooltipTimeoutRef.current = setTimeout(() => {\n\t\t\t\tconst relatedTarget = (e as MouseEvent<HTMLElement>)\n\t\t\t\t\t.relatedTarget as HTMLElement | null;\n\t\t\t\tconst isHoveringTooltip =\n\t\t\t\t\trelatedTarget?.classList?.contains('slds-popover_tooltip') ||\n\t\t\t\t\trelatedTarget?.classList?.contains('slds-popover__body');\n\n\t\t\t\tif (!isHoveringTooltip) {\n\t\t\t\t\trequestClose(e, trigger);\n\t\t\t\t}\n\t\t\t}, hoverCloseDelay);\n\t\t},\n\t\t[hoverCloseDelay, requestClose]\n\t);\n\n\tconst handleMouseLeave = useCallback(\n\t\t(e: MouseEvent<HTMLElement>) => scheduleClose(e, 'mouseLeave'),\n\t\t[scheduleClose]\n\t);\n\n\tconst handleBlur = useCallback(\n\t\t(e: FocusEvent<HTMLElement>) => scheduleClose(e, 'blur'),\n\t\t[scheduleClose]\n\t);\n\n\tconst handleKeyDown = useCallback(\n\t\t(e: KeyboardEvent<HTMLElement>) => {\n\t\t\te.stopPropagation();\n\n\t\t\ttooltipTimeoutRef.current = setTimeout(() => {\n\t\t\t\tif (e.key === 'Escape') {\n\t\t\t\t\trequestClose(e, 'cancel');\n\t\t\t\t}\n\t\t\t}, hoverCloseDelay);\n\t\t},\n\t\t[hoverCloseDelay, requestClose]\n\t);\n\n\t// Save trigger ref and trigger re-render once mounted\n\tconst saveTriggerRef = useCallback(\n\t\t(component: HTMLDivElement | null) => {\n\t\t\tif (component && triggerRef.current !== component) {\n\t\t\t\t(triggerRef as React.RefObject<HTMLDivElement | null>).current =\n\t\t\t\t\tcomponent;\n\t\t\t\t// Dialog/Popper.js cannot place the popover until\n\t\t\t\t// the trigger/target DOM node is mounted.\n\t\t\t\tif (!triggerRendered) {\n\t\t\t\t\tsetTriggerRendered(true);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t[triggerRendered]\n\t);\n\n\t// Measure the trigger for the anchored nubbin before paint, so it is placed on open.\n\t// Runs after every render, as the old in-render measurement did, so a trigger that\n\t// resizes while the tooltip is open is re-measured.\n\tconst isAnchoredNubbinOpen = hasAnchoredNubbin && getIsOpen();\n\t// eslint-disable-next-line react-hooks/exhaustive-deps -- no deps on purpose; the updater returns the same state when the size is unchanged, so it settles\n\tuseLayoutEffect(() => {\n\t\tif (!isAnchoredNubbinOpen || !triggerRef.current) {\n\t\t\treturn;\n\t\t}\n\t\tconst { height, width } = triggerRef.current.getBoundingClientRect();\n\t\tsetTriggerSize((size) =>\n\t\t\tsize.height === height && size.width === width ? size : { height, width }\n\t\t);\n\t});\n\n\t// Render helpers\n\tconst getAnchoredNubbinStyles = () => {\n\t\tif (!hasAnchoredNubbin) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst alignment = align.split(' ')[0] as\n\t\t\t'top' | 'bottom' | 'left' | 'right';\n\t\tconst nubbinContainerStyles: CSSProperties = {\n\t\t\theight: '0',\n\t\t\tposition: 'relative',\n\t\t\twidth: '0',\n\t\t};\n\t\tconst nubbinStyles: CSSProperties = {\n\t\t\t// Same chain as the SLDS 2 tooltip body, so the nubbin matches it.\n\t\t\tbackgroundColor:\n\t\t\t\t'var(--slds-c-tooltip-color-background, var(--slds-g-color-surface-inverse-1, #16325c))',\n\t\t\tcontent: '\"\"',\n\t\t\theight: '1rem',\n\t\t\tposition: 'absolute',\n\t\t\ttransform: 'rotate(45deg)',\n\t\t\twidth: '1rem',\n\t\t};\n\t\tconst triggerDimensions = triggerSize;\n\n\t\tswitch (alignment) {\n\t\t\tcase 'bottom': {\n\t\t\t\tnubbinContainerStyles.left = `${triggerDimensions.width / 2}px`;\n\t\t\t\tnubbinContainerStyles.top = `${triggerDimensions.height}px`;\n\t\t\t\tnubbinStyles.left = '-8px';\n\t\t\t\tnubbinStyles.top = '3px';\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'left': {\n\t\t\t\tnubbinContainerStyles.left = '0';\n\t\t\t\tnubbinContainerStyles.top = `${triggerDimensions.height / 2}px`;\n\t\t\t\tnubbinStyles.left = '-19px';\n\t\t\t\tnubbinStyles.top = '-9px';\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'right': {\n\t\t\t\tnubbinContainerStyles.left = `${triggerDimensions.width}px`;\n\t\t\t\tnubbinContainerStyles.top = `${triggerDimensions.height / 2}px`;\n\t\t\t\tnubbinStyles.left = '3px';\n\t\t\t\tnubbinStyles.top = '-9px';\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\t// top\n\t\t\t\tnubbinContainerStyles.left = `${triggerDimensions.width / 2}px`;\n\t\t\t\tnubbinContainerStyles.top = '0';\n\t\t\t\tnubbinStyles.left = '-8px';\n\t\t\t\tnubbinStyles.top = '-19px';\n\t\t\t}\n\t\t}\n\n\t\t// The dialog doesn't draw its own nubbin (`isNubbinHidden`); this one is\n\t\t// drawn with inline styles, which CSP `style-src` doesn't block.\n\t\treturn getIsOpen() ? (\n\t\t\t<div style={nubbinContainerStyles}>\n\t\t\t\t<div style={nubbinStyles} />\n\t\t\t</div>\n\t\t) : null;\n\t};\n\n\tconst getContent = () => {\n\t\tconst isInverseIcon = iconVariant === 'inverse';\n\t\tconst iconColorVariant =\n\t\t\ticonVariant === 'error' || iconVariant === 'warning'\n\t\t\t\t? iconVariant\n\t\t\t\t: undefined;\n\n\t\tconst triggerProps: TooltipTriggerProps = {\n\t\t\t'aria-describedby': getIsOpen() ? getId() : undefined,\n\t\t\tonBlur: handleBlur,\n\t\t\tonFocus: handleFocus,\n\t\t\tonKeyDown: handleKeyDown,\n\t\t\tonMouseEnter: handleMouseEnter,\n\t\t\tonMouseLeave: handleMouseLeave,\n\t\t};\n\n\t\tif (trigger !== undefined) {\n\t\t\treturn <TooltipTrigger render={trigger} triggerProps={triggerProps} />;\n\t\t}\n\n\t\t// Deprecated: each child element is a trigger\n\t\tif (React.Children.count(children) !== 0) {\n\t\t\treturn React.Children.map(children, (child) =>\n\t\t\t\tReact.isValidElement(child) ? (\n\t\t\t\t\t<TooltipTrigger render={child} triggerProps={triggerProps} />\n\t\t\t\t) : (\n\t\t\t\t\tchild\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\tif (onClickTrigger) {\n\t\t\treturn (\n\t\t\t\t<TooltipTrigger\n\t\t\t\t\trender={\n\t\t\t\t\t\t// eslint-disable-next-line jsx-a11y/anchor-is-valid -- SLDS tooltip markup uses an anchor for the clickable trigger\n\t\t\t\t\t\t<a\n\t\t\t\t\t\t\thref=\"#\"\n\t\t\t\t\t\t\tonClick={\n\t\t\t\t\t\t\t\tEventUtil.trappedHandler(\n\t\t\t\t\t\t\t\t\tonClickTrigger\n\t\t\t\t\t\t\t\t) as React.MouseEventHandler<HTMLAnchorElement>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\tcategory=\"utility\"\n\t\t\t\t\t\t\t\tcolorVariant={iconColorVariant}\n\t\t\t\t\t\t\t\tinverse={isInverseIcon}\n\t\t\t\t\t\t\t\tname=\"info\"\n\t\t\t\t\t\t\t\tassistiveText={{\n\t\t\t\t\t\t\t\t\tlabel: assistiveText.triggerLearnMoreIcon,\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\tsize=\"x-small\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</a>\n\t\t\t\t\t}\n\t\t\t\t\ttriggerProps={triggerProps}\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<TooltipTrigger\n\t\t\t\trender={\n\t\t\t\t\t<Button\n\t\t\t\t\t\taria-disabled\n\t\t\t\t\t\tassistiveText={{\n\t\t\t\t\t\t\ticon: assistiveText.triggerLearnMoreIcon,\n\t\t\t\t\t\t}}\n\t\t\t\t\t\ticonCategory=\"utility\"\n\t\t\t\t\t\ticonClassName={\n\t\t\t\t\t\t\ticonColorVariant && `slds-icon-text-${iconColorVariant}`\n\t\t\t\t\t\t}\n\t\t\t\t\t\ticonName=\"info\"\n\t\t\t\t\t\t// `bare` keeps `slds-button_icon`, which Button drops for `inverse` alone\n\t\t\t\t\t\ticonVariant={isInverseIcon ? 'bare' : undefined}\n\t\t\t\t\t\tinverse={isInverseIcon}\n\t\t\t\t\t\tvariant=\"icon\"\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t\ttriggerProps={triggerProps}\n\t\t\t/>\n\t\t);\n\t};\n\n\tconst getTooltipContent = () => {\n\t\tconst isErrorTheme = theme === 'error';\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tclassName={classNames('slds-popover__body', {\n\t\t\t\t\t// Ensure text contrast on error theme (red background needs white text)\n\t\t\t\t\t'slds-text-color_inverse': isErrorTheme,\n\t\t\t\t})}\n\t\t\t>\n\t\t\t\t{content}\n\t\t\t\t{variant === 'learnMore' && onClickTrigger ? (\n\t\t\t\t\t<div className=\"slds-m-top_x-small\" aria-hidden=\"true\">\n\t\t\t\t\t\t{labels.learnMoreBefore}{' '}\n\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\tassistiveText={{\n\t\t\t\t\t\t\t\tlabel: assistiveText.tooltipTipLearnMoreIcon,\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\tcategory=\"utility\"\n\t\t\t\t\t\t\tinverse\n\t\t\t\t\t\t\tname=\"info\"\n\t\t\t\t\t\t\tsize=\"x-small\"\n\t\t\t\t\t\t/>{' '}\n\t\t\t\t\t\t{labels.learnMoreAfter}{' '}\n\t\t\t\t\t</div>\n\t\t\t\t) : null}\n\t\t\t</div>\n\t\t);\n\t};\n\n\tconst getTooltip = () => {\n\t\treturn getIsOpen() ? (\n\t\t\t<Dialog\n\t\t\t\tcloseOnTabKey\n\t\t\t\thasNubbin\n\t\t\t\tisNubbinHidden={hasAnchoredNubbin}\n\t\t\t\tcontentsClassName={classNames(\n\t\t\t\t\t'slds-popover',\n\t\t\t\t\t'slds-popover_tooltip',\n\t\t\t\t\t{\n\t\t\t\t\t\t'slds-theme_error': theme === 'error',\n\t\t\t\t\t},\n\t\t\t\t\tdialogClassName\n\t\t\t\t)}\n\t\t\t\talign={align}\n\t\t\t\tcontext={iconSettings}\n\t\t\t\thasStaticAlignment={hasStaticAlignment}\n\t\t\t\tonClose={handleDialogClose}\n\t\t\t\tonRequestTargetElement={getTooltipTarget}\n\t\t\t\tonMouseLeave={handleDialogMouseLeave}\n\t\t\t\tposition={position}\n\t\t\t\tvariant=\"tooltip\"\n\t\t\t\tcontainerProps={{\n\t\t\t\t\tid: getId(),\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{getTooltipContent()}\n\t\t\t</Dialog>\n\t\t) : (\n\t\t\t<span />\n\t\t);\n\t};\n\n\tconst containerStyles: CSSProperties = {\n\t\tdisplay: 'inline-block',\n\t\tlineHeight: 'var(--slds-g-font-line-height-1, 1)',\n\t\t...triggerStyle,\n\t};\n\n\treturn (\n\t\t<div\n\t\t\tclassName={classNames('slds-tooltip-trigger', triggerClassName)}\n\t\t\tstyle={containerStyles}\n\t\t\tref={saveTriggerRef}\n\t\t>\n\t\t\t{getAnchoredNubbinStyles()}\n\t\t\t{getContent()}\n\t\t\t{getTooltip()}\n\t\t</div>\n\t);\n};\n\nTooltip.displayName = POPOVER_TOOLTIP;\n\nexport default Tooltip as React.FC<TooltipProps>;\n"],"mappings":"+pBAgRA,IAAM,EAA6C,CAClD,wBAAyB,YACzB,qBAAsB,MACvB,EAEM,GAA+B,CACpC,eAAgB,iBAChB,gBAAiB,OAClB,EAIM,GAAkB,CACvB,SACA,kBAIK,EAAA,cAAc,EAAQ,CAAY,EAOlC,GAAW,CAChB,QAAQ,MACR,cAAe,EACf,WACA,WAAU,EAAA,EAAA,IAAA,CAAC,OAAD,CAAA,SAAM,SAAa,CAAA,EAC7B,kBACA,oBAAoB,GACpB,qBAAqB,GACrB,kBAAkB,GAClB,iBAAiB,EACjB,cAAc,OACd,GAAI,EACJ,OAAQ,GACR,OAAQ,EACR,gBAAgB,GAChB,aAAa,GACb,gBACA,iBACA,yBACA,iBACA,mBACA,WAAW,WACX,eACA,QAAQ,OACR,UACA,UAAU,OACV,oCAC8D,CAE9D,IAAM,EAAgB,CAAE,GAAG,EAAsB,GAAG,CAAkB,EAChE,EAAS,CAAE,GAAG,GAAe,GAAG,EAAW,EAG3C,IAAA,EAAe,EAAA,WAAA,CAAW,EAAA,mBAAmB,EAG7C,CAAC,EAAQ,GAAa,EAAA,qBAAqB,EAAY,CAAa,EACpE,CAAC,EAAiB,KAAA,EAAsB,EAAA,SAAA,CAAS,EAAK,E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,GAXO,EAAA,EAAA,IAAA,CAAC,EAAD,CAAgB,OAAQ,EAAuB,cAAe,CAAA,CAkEvE,EAEM,QAIJ,EAAA,EAAA,KAAA,CAAC,MAAD,CACC,WAAA,EAAW,EAAA,QAAA,CAAW,qBAAsB,CAE3C,0BANkB,IAAU,OAO7B,CAAC,EAJF,SAAA,CAME,EACA,IAAY,aAAe,GAC3B,EAAA,EAAA,KAAA,CAAC,MAAD,CAAK,UAAU,qBAAqB,cAAY,OAAhD,SAAA,CACE,EAAO,gBAAiB,KACzB,EAAA,EAAA,IAAA,CAAC,EAAA,QAAD,CACC,cAAe,CACd,MAAO,EAAc,uBACtB,EACA,SAAS,UACT,QAAA,GACA,KAAK,OACL,KAAK,SACL,CAAA,EAAE,IACF,EAAO,eAAgB,GACpB,CACF,CAAA,EAAA,IACA,IAID,OACE,EAAU,GAChB,EAAA,EAAA,IAAA,CAAC,GAAA,QAAD,CACC,cAAA,GACA,UAAA,GACA,eAAgB,EAChB,mBAAA,EAAmB,EAAA,QAAA,CAClB,eACA,uBACA,CACC,mBAAoB,IAAU,OAC/B,EACA,CACD,EACO,QACP,QAAS,GACW,qBACpB,QAAS,GACT,uBAAwB,GACxB,aAAc,GACJ,WACV,QAAQ,UACR,eAAgB,CACf,GAAI,EAAM,CACX,EAEC,SAAA,GAAkB,CACZ,CAAA,GAER,EAAA,EAAA,IAAA,CAAC,OAAD,CAAO,CAAA,EAIH,GAAiC,CACtC,QAAS,eACT,WAAY,sCACZ,GAAG,CACJ,EAEA,OACC,EAAA,EAAA,KAAA,CAAC,MAAD,CACC,WAAA,EAAW,EAAA,QAAA,CAAW,uBAAwB,CAAgB,EAC9D,MAAO,GACP,IAAK,EAHN,SAAA,CAKE,GAAwB,EACxB,GAAW,EACX,GAAW,CACR,GAEP,EAEA,EAAQ,YAAc,EAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree.cjs","names":[],"sources":["../../../../components/tree/tree.tsx"],"sourcesContent":["/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\nimport React, {\n\tforwardRef,\n\tuseState,\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n} from 'react';\nimport classNames from 'classnames';\n// Using native Array.find instead of lodash for better TypeScript support\n\n// Child components\nimport Branch from './private/branch';\n\n// Similar to React's PropTypes check\nimport checkProps, { checkLegacyNodeFields } from './check-props';\nimport { useControllableState } from '../../utilities/hooks';\n\n// Constants\nimport { TREE } from '../../utilities/constants';\nimport componentDoc from './component.json';\n\nimport {\n\tTreeNode,\n\tTreeNodeId,\n\tFlattenedNode,\n\tTreeAssistiveText,\n\tTreeLabels,\n\tTreeNodeSelectData,\n\tTreeRequestToggleData,\n\tTreeSelectData,\n\tTreeExpandData,\n\tTreeScrollData,\n} from './types';\n\ninterface TreeBaseProps {\n\t/** Class names for the root `.slds-tree_container` div */\n\tclassName?: string | string[] | Record<string, boolean>;\n\t/** Class names for the top-level `ul.slds-tree` element */\n\tclassNameList?: string | string[] | Record<string, boolean>;\n\t/** @deprecated Use `classNameList`. */\n\tlistClassName?: string | string[] | Record<string, boolean>;\n\t/**\n\t * Resolves a node's children, for trees that store child ids instead of `nodes`. Used at every level.\n\t */\n\tgetNodes?: (node: { nodes?: TreeNode[] }) => TreeNode[] | undefined;\n\t/** HTML id of the tree container (required) */\n\tid: string;\n\t/**\n\t * Array of tree nodes. The tree never modifies them: selection comes from `selectedIds` and\n\t * expansion from `expandedIds` / `defaultExpandedIds`.\n\t */\n\tnodes: TreeNode[];\n\t/**\n\t * Ids of the selected nodes (`[]` for none). The tree is controlled: it renders this selection and\n\t * reports changes through `onSelect`, where `data.selectedIds` is the requested selection.\n\t *\n\t * When omitted, the tree falls back to the deprecated `node.selected` fields (read-only) and warns.\n\t */\n\tselectedIds: TreeNodeId[];\n\t/**\n\t * Ids of the expanded branches. Pass it to control expansion and update it from\n\t * `onRequestToggle` (`data.expandedIds` is the requested set). Leave it `undefined` to let the\n\t * tree manage expansion itself, starting from `defaultExpandedIds`.\n\t */\n\texpandedIds?: TreeNodeId[];\n\t/**\n\t * Ids of the branches expanded on first render when `expandedIds` is not passed. Defaults to `[]`.\n\t *\n\t * When neither `expandedIds` nor `defaultExpandedIds` is passed, a branch's deprecated\n\t * `node.expanded` field (read-only) still decides whether it is expanded, and the tree warns.\n\t */\n\tdefaultExpandedIds?: TreeNodeId[];\n\t/**\n\t * Called when an item or branch is selected or deselected: by click, by focus, or by keyboard\n\t * (Enter, Up/Down arrows, Right arrow into an expanded branch, Left arrow to the parent node).\n\t * `data.isSelected` is the requested selection state of `data.node` and `data.selectedIds` the\n\t * requested selection. Update `selectedIds` to apply it. Required: without it, selecting a\n\t * node does nothing.\n\t */\n\tonSelect: (event: React.SyntheticEvent, data: TreeNodeSelectData) => void;\n\t/**\n\t * Called when an item or branch is selected.\n\t * @deprecated Use `onSelect`, which receives `{ node, isSelected }`. Ignored when `onSelect` is passed.\n\t */\n\tonClick?: (event: React.SyntheticEvent, data: TreeSelectData) => void;\n\t/**\n\t * Called when a branch is asked to expand or collapse: by clicking its toggle button, by Right\n\t * arrow on a collapsed branch, or by Left arrow on an expanded branch. `data.isExpanded` is the\n\t * requested expansion state of `data.node` and `data.expandedIds` the requested set. Called\n\t * whether or not expansion is controlled; when `expandedIds` is passed, update it to apply the change.\n\t */\n\tonRequestToggle?: (\n\t\tevent: React.SyntheticEvent,\n\t\tdata: TreeRequestToggleData\n\t) => void;\n\t/**\n\t * Called when a branch's expand/collapse button is clicked, or when the Left arrow is pressed\n\t * on a collapsed branch or item (with `data.select: true` and `data.node` set to the parent).\n\t * @deprecated Use `onRequestToggle`, which receives `{ node, isExpanded }`. With\n\t * `onRequestToggle`, Left arrow on a collapsed branch or item selects the parent via\n\t * `onSelect` instead. Ignored when `onRequestToggle` is passed.\n\t */\n\tonExpandClick?: (event: React.SyntheticEvent, data: TreeExpandData) => void;\n\t/** Callback when the tree list scrolls. `data.ratio` is the scroll position from `0` to `1`. */\n\tonScroll?: (\n\t\tevent: React.UIEvent<HTMLUListElement>,\n\t\tdata: TreeScrollData\n\t) => void;\n\t/** Search term to highlight in node labels */\n\tsearchTerm?: string;\n\t/** Styles for the top-level `ul.slds-tree` element */\n\tstyleList?: React.CSSProperties;\n\t/** @deprecated Use `styleList`. */\n\tlistStyle?: React.CSSProperties;\n}\n\ntype ReactNode = React.ReactNode;\n\n/** A visible heading. A tree needs a heading, visible or not. */\ninterface TreeVisibleHeadingProps {\n\t/**\n\t * **Text labels for internationalization**\n\t * * `heading`: Visible tree heading that describes its contents.\n\t */\n\tlabels: TreeLabels & { heading: ReactNode };\n\tassistiveText?: TreeAssistiveText & { heading?: never; label?: never };\n\theading?: never;\n}\n\n/** A visually hidden heading, for screen readers only. */\ninterface TreeHiddenHeadingProps {\n\t/**\n\t * **Assistive text for accessibility**\n\t * * `heading`: Visually hidden tree heading.\n\t */\n\tassistiveText: TreeAssistiveText & { heading: string };\n\tlabels?: TreeLabels & { heading?: never };\n\theading?: never;\n}\n\n/** @deprecated Use `labels.heading`. */\ninterface TreeDeprecatedHeadingProps {\n\t/** @deprecated Use `labels.heading` instead. */\n\theading: ReactNode;\n\tassistiveText?: TreeAssistiveText & { heading?: never };\n\tlabels?: TreeLabels & { heading?: never };\n}\n\n/** @deprecated Use `assistiveText.heading`. */\ninterface TreeDeprecatedAssistiveLabelProps {\n\t/** **Assistive text for accessibility** */\n\tassistiveText: TreeAssistiveText & { label: string; heading?: never };\n\tlabels?: TreeLabels & { heading?: never };\n\theading?: never;\n}\n\n/**\n * Props for the Tree component. The heading is either visible (`labels.heading`) or\n * visually hidden (`assistiveText.heading`), not both.\n */\nexport type TreeProps = TreeBaseProps &\n\t(\n\t\t| TreeVisibleHeadingProps\n\t\t| TreeHiddenHeadingProps\n\t\t| TreeDeprecatedHeadingProps\n\t\t| TreeDeprecatedAssistiveLabelProps\n\t);\n\ntype GetNodes = (node: { nodes?: TreeNode[] }) => TreeNode[] | undefined;\n\nconst EMPTY_IDS: TreeNodeId[] = [];\n\n/**\n * Flattens the visible part of the tree (expanded branches only) into a flat array.\n * The first item is the root and should be removed with slice(1).\n */\nconst flattenTree = (\n\troot: { nodes?: TreeNode[] },\n\tgetNodes: GetNodes,\n\tisExpanded: (node: TreeNode) => boolean,\n\ttreeIndex = '',\n\tfirstLevel = true\n): FlattenedNode[] => {\n\tif (!root.nodes) {\n\t\treturn [{ node: root as TreeNode, treeIndex }];\n\t}\n\tlet nodes: FlattenedNode[] = [{ node: root as TreeNode, treeIndex }];\n\tif (firstLevel || isExpanded(root as TreeNode)) {\n\t\tfor (let index = 0; index < root.nodes.length; index += 1) {\n\t\t\tconst curNode = firstLevel ? root.nodes[index] : getNodes(root)?.[index];\n\t\t\tif (curNode) {\n\t\t\t\tnodes = nodes.concat(\n\t\t\t\t\tflattenTree(\n\t\t\t\t\t\tcurNode,\n\t\t\t\t\t\tgetNodes,\n\t\t\t\t\t\tisExpanded,\n\t\t\t\t\t\ttreeIndex ? `${treeIndex}-${index}` : `${index}`,\n\t\t\t\t\t\tfalse\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\treturn nodes;\n};\n\n/**\n * Ids of every node in the tree (visible or not) that matches `predicate`.\n * Used only for the deprecated `node.selected` / `node.expanded` fallback.\n */\nconst collectNodeIds = (\n\tnodes: TreeNode[],\n\tgetNodes: GetNodes,\n\tpredicate: (node: TreeNode) => boolean\n): TreeNodeId[] => {\n\tconst ids: TreeNodeId[] = [];\n\tconst visited = new Set<TreeNode>();\n\tconst visit = (list: TreeNode[] | undefined) => {\n\t\tlist?.forEach((node) => {\n\t\t\tif (node && !visited.has(node)) {\n\t\t\t\tvisited.add(node);\n\t\t\t\tif (predicate(node)) {\n\t\t\t\t\tids.push(node.id);\n\t\t\t\t}\n\t\t\t\tvisit(getNodes(node));\n\t\t\t}\n\t\t});\n\t};\n\tvisit(getNodes({ nodes }));\n\treturn ids;\n};\n\nconst defaultGetNodes = (node: { nodes?: TreeNode[] }) => node.nodes;\n\n/**\n * A tree is visualization of a structure hierarchy.\n * A branch can be expanded or collapsed.\n * Selection is controlled through `selectedIds`. Expansion is controlled through `expandedIds`, or\n * managed by the tree (starting from `defaultExpandedIds`) when `expandedIds` is not passed.\n */\nconst Tree = forwardRef<HTMLDivElement, TreeProps>(\n\t(\n\t\t{\n\t\t\tassistiveText: assistiveTextProp,\n\t\t\tclassName,\n\t\t\tclassNameList,\n\t\t\tlistClassName,\n\t\t\tgetNodes = defaultGetNodes,\n\t\t\theading: headingProp,\n\t\t\tid,\n\t\t\tlabels,\n\t\t\tnodes,\n\t\t\tselectedIds,\n\t\t\texpandedIds,\n\t\t\tdefaultExpandedIds,\n\t\t\tonSelect,\n\t\t\tonClick,\n\t\t\tonRequestToggle,\n\t\t\tonExpandClick,\n\t\t\tonScroll,\n\t\t\tsearchTerm,\n\t\t\tstyleList,\n\t\t\tlistStyle,\n\t\t},\n\t\tref\n\t) => {\n\t\t// `assistiveText.label` is deprecated\n\t\tconst assistiveHeading =\n\t\t\tassistiveTextProp?.heading ?? assistiveTextProp?.label;\n\t\t// `heading` is deprecated\n\t\tconst visibleHeading = labels?.heading ?? headingProp;\n\n\t\t// Without `selectedIds`, selection is read from the deprecated `node.selected` fields\n\t\tconst isLegacySelection = selectedIds === undefined;\n\t\t// Without `expandedIds` and `defaultExpandedIds`, the deprecated `node.expanded` fields win\n\t\tconst isLegacyExpansion =\n\t\t\texpandedIds === undefined && defaultExpandedIds === undefined;\n\n\t\t// Expansion is ephemeral UI state: controlled when `expandedIds` is passed\n\t\tconst [currentExpandedIds, setExpandedIds] = useControllableState(\n\t\t\texpandedIds,\n\t\t\tdefaultExpandedIds ?? EMPTY_IDS\n\t\t);\n\n\t\tconst selectedIdSet = useMemo(\n\t\t\t() => new Set<TreeNodeId>(selectedIds ?? EMPTY_IDS),\n\t\t\t[selectedIds]\n\t\t);\n\t\tconst expandedIdSet = useMemo(\n\t\t\t() => new Set<TreeNodeId>(currentExpandedIds),\n\t\t\t[currentExpandedIds]\n\t\t);\n\n\t\tconst isNodeSelected = useCallback(\n\t\t\t(node: TreeNode) =>\n\t\t\t\tisLegacySelection ? !!node.selected : selectedIdSet.has(node.id),\n\t\t\t[isLegacySelection, selectedIdSet]\n\t\t);\n\n\t\tconst isNodeExpanded = useCallback(\n\t\t\t(node: TreeNode) =>\n\t\t\t\tisLegacyExpansion && node.expanded !== undefined\n\t\t\t\t\t? !!node.expanded\n\t\t\t\t\t: expandedIdSet.has(node.id),\n\t\t\t[isLegacyExpansion, expandedIdSet]\n\t\t);\n\n\t\t// Track if tree has focus\n\t\tconst treeHasFocusRef = useRef(false);\n\n\t\t// Visible nodes in display order\n\t\tconst flattenedNodes = useMemo(\n\t\t\t() =>\n\t\t\t\tflattenTree(\n\t\t\t\t\t{ nodes: getNodes({ nodes }) },\n\t\t\t\t\tgetNodes,\n\t\t\t\t\tisNodeExpanded\n\t\t\t\t).slice(1),\n\t\t\t[getNodes, nodes, isNodeExpanded]\n\t\t);\n\n\t\t// Roving focus is ephemeral and internal. Until a node has been focused, the first visible\n\t\t// selected node is the tab stop.\n\t\tconst [focusedNodeIndex, setFocusedNodeIndex] = useState<\n\t\t\tstring | undefined\n\t\t>(undefined);\n\t\tconst effectiveFocusedNodeIndex =\n\t\t\tfocusedNodeIndex ??\n\t\t\tflattenedNodes.find((flattenedNode) => isNodeSelected(flattenedNode.node))\n\t\t\t\t?.treeIndex;\n\t\tconst tabStopIndex =\n\t\t\teffectiveFocusedNodeIndex ?? flattenedNodes[0]?.treeIndex;\n\n\t\t// Check props on mount\n\t\tuseEffect(() => {\n\t\t\tcheckProps(\n\t\t\t\tTREE,\n\t\t\t\t{\n\t\t\t\t\tassistiveText: assistiveTextProp,\n\t\t\t\t\tclassName,\n\t\t\t\t\tclassNameList,\n\t\t\t\t\tlistClassName,\n\t\t\t\t\tgetNodes,\n\t\t\t\t\theading: headingProp,\n\t\t\t\t\tid,\n\t\t\t\t\tlabels,\n\t\t\t\t\tnodes,\n\t\t\t\t\tselectedIds,\n\t\t\t\t\texpandedIds,\n\t\t\t\t\tdefaultExpandedIds,\n\t\t\t\t\tonSelect,\n\t\t\t\t\tonClick,\n\t\t\t\t\tonRequestToggle,\n\t\t\t\t\tonExpandClick,\n\t\t\t\t\tonScroll,\n\t\t\t\t\tsearchTerm,\n\t\t\t\t\tstyleList,\n\t\t\t\t\tlistStyle,\n\t\t\t\t},\n\t\t\t\tcomponentDoc\n\t\t\t);\n\t\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t}, []);\n\n\t\t// Warn about the deprecated `node.expanded` fallback whenever visible nodes use it\n\t\tuseEffect(() => {\n\t\t\tif (process.env.NODE_ENV !== 'production' && isLegacyExpansion) {\n\t\t\t\tcheckLegacyNodeFields(TREE, {\n\t\t\t\t\thasExpandedField: flattenedNodes.some(\n\t\t\t\t\t\t(flattenedNode) => flattenedNode.node.expanded !== undefined\n\t\t\t\t\t),\n\t\t\t\t});\n\t\t\t}\n\t\t}, [isLegacyExpansion, flattenedNodes]);\n\n\t\tconst getSelectedIds = useCallback(\n\t\t\t() =>\n\t\t\t\tisLegacySelection\n\t\t\t\t\t? collectNodeIds(nodes, getNodes, (node) => !!node.selected)\n\t\t\t\t\t: (selectedIds as TreeNodeId[]),\n\t\t\t[isLegacySelection, nodes, getNodes, selectedIds]\n\t\t);\n\n\t\tconst getExpandedIds = useCallback(\n\t\t\t() =>\n\t\t\t\tisLegacyExpansion\n\t\t\t\t\t? collectNodeIds(\n\t\t\t\t\t\t\tnodes,\n\t\t\t\t\t\t\tgetNodes,\n\t\t\t\t\t\t\t(node) => node.type === 'branch' && isNodeExpanded(node)\n\t\t\t\t\t\t)\n\t\t\t\t\t: currentExpandedIds,\n\t\t\t[isLegacyExpansion, nodes, getNodes, isNodeExpanded, currentExpandedIds]\n\t\t);\n\n\t\t// Handle node selection. Never writes to `nodes`: it reports the requested selection.\n\t\tconst handleSelect = useCallback(\n\t\t\t({\n\t\t\t\tevent,\n\t\t\t\tdata,\n\t\t\t\tclearSelectedNodes,\n\t\t\t\tfromFocus,\n\t\t\t}: {\n\t\t\t\tevent: React.SyntheticEvent;\n\t\t\t\tdata: TreeSelectData;\n\t\t\t\tclearSelectedNodes?: boolean;\n\t\t\t\tfromFocus?: boolean;\n\t\t\t}) => {\n\t\t\t\t// Prevent firing twice on first click due to focus event\n\t\t\t\tif (!fromFocus) {\n\t\t\t\t\tif (onSelect) {\n\t\t\t\t\t\t// Keyboard navigation moves the selection to the node; click and Enter toggle it\n\t\t\t\t\t\tconst others = clearSelectedNodes\n\t\t\t\t\t\t\t? []\n\t\t\t\t\t\t\t: getSelectedIds().filter((nodeId) => nodeId !== data.node.id);\n\t\t\t\t\t\tonSelect(event, {\n\t\t\t\t\t\t\tnode: data.node,\n\t\t\t\t\t\t\tisSelected: data.select,\n\t\t\t\t\t\t\tselectedIds: data.select ? [...others, data.node.id] : others,\n\t\t\t\t\t\t});\n\t\t\t\t\t} else if (onClick) {\n\t\t\t\t\t\tonClick(event, data);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\ttreeHasFocusRef.current = true;\n\t\t\t\tsetFocusedNodeIndex(data.treeIndex);\n\t\t\t},\n\t\t\t[getSelectedIds, onSelect, onClick]\n\t\t);\n\n\t\t// Handle node blur\n\t\tconst handleNodeBlur = useCallback(() => {\n\t\t\ttreeHasFocusRef.current = false;\n\t\t}, []);\n\n\t\t// Handle expand/collapse\n\t\tconst handleExpand = useCallback(\n\t\t\t({\n\t\t\t\tevent,\n\t\t\t\tdata,\n\t\t\t}: {\n\t\t\t\tevent: React.SyntheticEvent;\n\t\t\t\tdata: TreeExpandData;\n\t\t\t}) => {\n\t\t\t\t// `data.select` marks Left arrow on a collapsed branch or item: move to the parent node.\n\t\t\t\tif (data.select) {\n\t\t\t\t\tif (!onRequestToggle && onExpandClick) {\n\t\t\t\t\t\t// Deprecated behavior: report it to `onExpandClick` with the parent node\n\t\t\t\t\t\ttreeHasFocusRef.current = true;\n\t\t\t\t\t\tonExpandClick(event, data);\n\t\t\t\t\t\tsetFocusedNodeIndex(data.treeIndex);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Not an expand/collapse request: select the parent, like Up/Down arrows do\n\t\t\t\t\t\thandleSelect({\n\t\t\t\t\t\t\tevent,\n\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\tnode: data.node,\n\t\t\t\t\t\t\t\tselect: true,\n\t\t\t\t\t\t\t\ttreeIndex: data.treeIndex,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tclearSelectedNodes: true,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\ttreeHasFocusRef.current = true;\n\t\t\t\tconst others = getExpandedIds().filter(\n\t\t\t\t\t(nodeId) => nodeId !== data.node.id\n\t\t\t\t);\n\t\t\t\tconst nextExpandedIds = data.expand\n\t\t\t\t\t? [...others, data.node.id]\n\t\t\t\t\t: others;\n\t\t\t\t// No-op when `expandedIds` is controlled\n\t\t\t\tsetExpandedIds(nextExpandedIds);\n\t\t\t\tif (onRequestToggle) {\n\t\t\t\t\tonRequestToggle(event, {\n\t\t\t\t\t\tnode: data.node,\n\t\t\t\t\t\tisExpanded: data.expand,\n\t\t\t\t\t\texpandedIds: nextExpandedIds,\n\t\t\t\t\t});\n\t\t\t\t} else if (onExpandClick) {\n\t\t\t\t\tonExpandClick(event, data);\n\t\t\t\t}\n\t\t\t},\n\t\t\t[\n\t\t\t\thandleSelect,\n\t\t\t\tgetExpandedIds,\n\t\t\t\tsetExpandedIds,\n\t\t\t\tonRequestToggle,\n\t\t\t\tonExpandClick,\n\t\t\t]\n\t\t);\n\n\t\t// Determine heading text\n\t\tconst headingText = assistiveHeading || visibleHeading;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tid={id}\n\t\t\t\tclassName={classNames('slds-tree_container', className)}\n\t\t\t\tref={ref}\n\t\t\t>\n\t\t\t\t<h4\n\t\t\t\t\tclassName={classNames('slds-tree__group-header', {\n\t\t\t\t\t\t'slds-assistive-text': !!assistiveHeading,\n\t\t\t\t\t})}\n\t\t\t\t\tid={`${id}__heading`}\n\t\t\t\t>\n\t\t\t\t\t{headingText}\n\t\t\t\t</h4>\n\t\t\t\t<Branch\n\t\t\t\t\tgetNodes={getNodes}\n\t\t\t\t\tinitalClassName={classNames(listClassName, classNameList)}\n\t\t\t\t\thtmlId={id}\n\t\t\t\t\tinitialStyle={\n\t\t\t\t\t\tlistStyle || styleList ? { ...listStyle, ...styleList } : undefined\n\t\t\t\t\t}\n\t\t\t\t\tlevel={0}\n\t\t\t\t\tnode={{ nodes }}\n\t\t\t\t\tflattenedNodes={flattenedNodes}\n\t\t\t\t\tisNodeSelected={isNodeSelected}\n\t\t\t\t\tisNodeExpanded={isNodeExpanded}\n\t\t\t\t\ttabStopIndex={tabStopIndex}\n\t\t\t\t\tfocusedNodeIndex={effectiveFocusedNodeIndex}\n\t\t\t\t\ttreeHasFocus={treeHasFocusRef.current}\n\t\t\t\t\tonNodeBlur={handleNodeBlur}\n\t\t\t\t\tonSelect={handleSelect}\n\t\t\t\t\tonExpand={handleExpand}\n\t\t\t\t\tonScroll={onScroll}\n\t\t\t\t\tsearchTerm={searchTerm}\n\t\t\t\t\ttreeId={id}\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n);\n\nTree.displayName = TREE;\n\nexport default Tree;\n"],"mappings":"uXA8KA,IAAM,EAA0B,CAAC,EAM3B,GACL,EACA,EACA,EACA,EAAY,GACZ,EAAa,KACQ,CACrB,GAAI,CAAC,EAAK,MACT,MAAO,CAAC,CAAE,KAAM,EAAkB,WAAU,CAAC,EAE9C,IAAI,EAAyB,CAAC,CAAE,KAAM,EAAkB,WAAU,CAAC,EACnE,GAAI,GAAc,EAAW,CAAgB,EAC5C,IAAK,IAAI,EAAQ,EAAG,EAAQ,EAAK,MAAM,OAAQ,G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CACK,KACJ,WAAA,EAAW,EAAA,QAAA,CAAW,sBAAuB,CAAS,EACjD,MAHN,SAAA,EAKC,EAAA,EAAA,IAAA,CAAC,KAAD,CACC,WAAA,EAAW,EAAA,QAAA,CAAW,0BAA2B,CAChD,sBAAuB,CAAC,CAAC,CAC1B,CAAC,EACD,GAAI,GAAG,EAAG,WAET,SAAA,EACE,CAAA,GACJ,EAAA,EAAA,IAAA,CAAC,EAAA,QAAD,CACW,WACV,iBAAA,EAAiB,EAAA,QAAA,CAAW,EAAe,CAAa,EACxD,OAAQ,EACR,aACC,GAAa,EAAY,CAAE,GAAG,EAAW,GAAG,CAAU,EAAI,IAAA,GAE3D,MAAO,EACP,KAAM,CAAE,OAAM,EACE,iBACA,iBACA,iBACF,eACd,iBAAkB,EAClB,aAAc,EAAgB,QAC9B,WAAY,EACZ,SAAU,EACV,SAAU,EACA,WACE,aACZ,OAAQ,CACR,CAAA,CACG,GAEP,CACD,EAEA,EAAK,YAAc,EAAA"}
|
|
1
|
+
{"version":3,"file":"tree.cjs","names":[],"sources":["../../../../components/tree/tree.tsx"],"sourcesContent":["/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\nimport React, {\n\tforwardRef,\n\tuseState,\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n} from 'react';\nimport classNames from 'classnames';\n// Using native Array.find instead of lodash for better TypeScript support\n\n// Child components\nimport Branch from './private/branch';\n\n// Similar to React's PropTypes check\nimport checkProps, { checkLegacyNodeFields } from './check-props';\nimport { useControllableState } from '../../utilities/hooks';\n\n// Constants\nimport { TREE } from '../../utilities/constants';\nimport componentDoc from './component.json';\n\nimport {\n\tTreeNode,\n\tTreeNodeId,\n\tFlattenedNode,\n\tTreeAssistiveText,\n\tTreeLabels,\n\tTreeNodeSelectData,\n\tTreeRequestToggleData,\n\tTreeSelectData,\n\tTreeExpandData,\n\tTreeScrollData,\n} from './types';\n\ninterface TreeBaseProps {\n\t/** Class names for the root `.slds-tree_container` div */\n\tclassName?: string | string[] | Record<string, boolean>;\n\t/** Class names for the top-level `ul.slds-tree` element */\n\tclassNameList?: string | string[] | Record<string, boolean>;\n\t/** @deprecated Use `classNameList`. */\n\tlistClassName?: string | string[] | Record<string, boolean>;\n\t/**\n\t * Resolves a node's children, for trees that store child ids instead of `nodes`. Used at every level.\n\t */\n\tgetNodes?: (node: { nodes?: TreeNode[] }) => TreeNode[] | undefined;\n\t/** HTML id of the tree container (required) */\n\tid: string;\n\t/**\n\t * Array of tree nodes. The tree never modifies them: selection comes from `selectedIds` and\n\t * expansion from `expandedIds` / `defaultExpandedIds`.\n\t */\n\tnodes: TreeNode[];\n\t/**\n\t * Ids of the selected nodes (`[]` for none). The tree is controlled: it renders this selection and\n\t * reports changes through `onSelect`, where `data.selectedIds` is the requested selection.\n\t *\n\t * When omitted, the tree falls back to the deprecated `node.selected` fields (read-only) and warns.\n\t */\n\tselectedIds: TreeNodeId[];\n\t/**\n\t * Ids of the expanded branches. Pass it to control expansion and update it from\n\t * `onRequestToggle` (`data.expandedIds` is the requested set). Leave it `undefined` to let the\n\t * tree manage expansion itself, starting from `defaultExpandedIds`.\n\t */\n\texpandedIds?: TreeNodeId[];\n\t/**\n\t * Ids of the branches expanded on first render when `expandedIds` is not passed. Defaults to `[]`.\n\t *\n\t * When neither `expandedIds` nor `defaultExpandedIds` is passed, a branch's deprecated\n\t * `node.expanded` field (read-only) still decides whether it is expanded, and the tree warns.\n\t */\n\tdefaultExpandedIds?: TreeNodeId[];\n\t/**\n\t * Called when an item or branch is selected or deselected: by click, by focus, or by keyboard\n\t * (Enter, Up/Down arrows, Right arrow into an expanded branch, Left arrow to the parent node).\n\t * `data.isSelected` is the requested selection state of `data.node` and `data.selectedIds` the\n\t * requested selection. Update `selectedIds` to apply it. Required: without it, selecting a\n\t * node does nothing.\n\t */\n\tonSelect: (event: React.SyntheticEvent, data: TreeNodeSelectData) => void;\n\t/**\n\t * Called when an item or branch is selected.\n\t * @deprecated Use `onSelect`, which receives `{ node, isSelected }`. Ignored when `onSelect` is passed.\n\t */\n\tonClick?: (event: React.SyntheticEvent, data: TreeSelectData) => void;\n\t/**\n\t * Called when a branch is asked to expand or collapse: by clicking its toggle button, by Right\n\t * arrow on a collapsed branch, or by Left arrow on an expanded branch. `data.isExpanded` is the\n\t * requested expansion state of `data.node` and `data.expandedIds` the requested set. Called\n\t * whether or not expansion is controlled; when `expandedIds` is passed, update it to apply the change.\n\t */\n\tonRequestToggle?: (\n\t\tevent: React.SyntheticEvent,\n\t\tdata: TreeRequestToggleData\n\t) => void;\n\t/**\n\t * Called when a branch's expand/collapse button is clicked, or when the Left arrow is pressed\n\t * on a collapsed branch or item (with `data.select: true` and `data.node` set to the parent).\n\t * @deprecated Use `onRequestToggle`, which receives `{ node, isExpanded }`. With\n\t * `onRequestToggle`, Left arrow on a collapsed branch or item selects the parent via\n\t * `onSelect` instead. Ignored when `onRequestToggle` is passed.\n\t */\n\tonExpandClick?: (event: React.SyntheticEvent, data: TreeExpandData) => void;\n\t/** Callback when the tree list scrolls. `data.ratio` is the scroll position from `0` to `1`. */\n\tonScroll?: (\n\t\tevent: React.UIEvent<HTMLUListElement>,\n\t\tdata: TreeScrollData\n\t) => void;\n\t/** Search term to highlight in node labels */\n\tsearchTerm?: string;\n\t/** Styles for the top-level `ul.slds-tree` element */\n\tstyleList?: React.CSSProperties;\n\t/** @deprecated Use `styleList`. */\n\tlistStyle?: React.CSSProperties;\n}\n\ntype ReactNode = React.ReactNode;\n\n/** A visible heading. A tree needs a heading, visible or not. */\ninterface TreeVisibleHeadingProps {\n\t/**\n\t * **Text labels for internationalization**\n\t * * `heading`: Visible tree heading that describes its contents.\n\t */\n\tlabels: TreeLabels & { heading: ReactNode };\n\t/** **Assistive text for accessibility**. Has no `heading` when `labels.heading` is set. */\n\tassistiveText?: TreeAssistiveText & { heading?: never; label?: never };\n\theading?: never;\n}\n\n/** A visually hidden heading, for screen readers only. */\ninterface TreeHiddenHeadingProps {\n\t/**\n\t * **Assistive text for accessibility**\n\t * * `heading`: Visually hidden tree heading.\n\t */\n\tassistiveText: TreeAssistiveText & { heading: string };\n\t/** **Text labels for internationalization**. Has no `heading` when `assistiveText.heading` is set. */\n\tlabels?: TreeLabels & { heading?: never };\n\theading?: never;\n}\n\n/** @deprecated Use `labels.heading`. */\ninterface TreeDeprecatedHeadingProps {\n\t/** @deprecated Use `labels.heading` instead. */\n\theading: ReactNode;\n\t/** **Assistive text for accessibility**. Has no `heading` when `heading` is set. */\n\tassistiveText?: TreeAssistiveText & { heading?: never };\n\t/** **Text labels for internationalization**. Has no `heading` when `heading` is set. */\n\tlabels?: TreeLabels & { heading?: never };\n}\n\n/** @deprecated Use `assistiveText.heading`. */\ninterface TreeDeprecatedAssistiveLabelProps {\n\t/** **Assistive text for accessibility** */\n\tassistiveText: TreeAssistiveText & { label: string; heading?: never };\n\t/** **Text labels for internationalization**. Has no `heading` when `assistiveText.label` is set. */\n\tlabels?: TreeLabels & { heading?: never };\n\theading?: never;\n}\n\n/**\n * Props for the Tree component. The heading is either visible (`labels.heading`) or\n * visually hidden (`assistiveText.heading`), not both.\n */\nexport type TreeProps = TreeBaseProps &\n\t(\n\t\t| TreeVisibleHeadingProps\n\t\t| TreeHiddenHeadingProps\n\t\t| TreeDeprecatedHeadingProps\n\t\t| TreeDeprecatedAssistiveLabelProps\n\t);\n\ntype GetNodes = (node: { nodes?: TreeNode[] }) => TreeNode[] | undefined;\n\nconst EMPTY_IDS: TreeNodeId[] = [];\n\n/**\n * Flattens the visible part of the tree (expanded branches only) into a flat array.\n * The first item is the root and should be removed with slice(1).\n */\nconst flattenTree = (\n\troot: { nodes?: TreeNode[] },\n\tgetNodes: GetNodes,\n\tisExpanded: (node: TreeNode) => boolean,\n\ttreeIndex = '',\n\tfirstLevel = true\n): FlattenedNode[] => {\n\tif (!root.nodes) {\n\t\treturn [{ node: root as TreeNode, treeIndex }];\n\t}\n\tlet nodes: FlattenedNode[] = [{ node: root as TreeNode, treeIndex }];\n\tif (firstLevel || isExpanded(root as TreeNode)) {\n\t\tfor (let index = 0; index < root.nodes.length; index += 1) {\n\t\t\tconst curNode = firstLevel ? root.nodes[index] : getNodes(root)?.[index];\n\t\t\tif (curNode) {\n\t\t\t\tnodes = nodes.concat(\n\t\t\t\t\tflattenTree(\n\t\t\t\t\t\tcurNode,\n\t\t\t\t\t\tgetNodes,\n\t\t\t\t\t\tisExpanded,\n\t\t\t\t\t\ttreeIndex ? `${treeIndex}-${index}` : `${index}`,\n\t\t\t\t\t\tfalse\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\treturn nodes;\n};\n\n/**\n * Ids of every node in the tree (visible or not) that matches `predicate`.\n * Used only for the deprecated `node.selected` / `node.expanded` fallback.\n */\nconst collectNodeIds = (\n\tnodes: TreeNode[],\n\tgetNodes: GetNodes,\n\tpredicate: (node: TreeNode) => boolean\n): TreeNodeId[] => {\n\tconst ids: TreeNodeId[] = [];\n\tconst visited = new Set<TreeNode>();\n\tconst visit = (list: TreeNode[] | undefined) => {\n\t\tlist?.forEach((node) => {\n\t\t\tif (node && !visited.has(node)) {\n\t\t\t\tvisited.add(node);\n\t\t\t\tif (predicate(node)) {\n\t\t\t\t\tids.push(node.id);\n\t\t\t\t}\n\t\t\t\tvisit(getNodes(node));\n\t\t\t}\n\t\t});\n\t};\n\tvisit(getNodes({ nodes }));\n\treturn ids;\n};\n\nconst defaultGetNodes = (node: { nodes?: TreeNode[] }) => node.nodes;\n\n/**\n * A tree is visualization of a structure hierarchy.\n * A branch can be expanded or collapsed.\n * Selection is controlled through `selectedIds`. Expansion is controlled through `expandedIds`, or\n * managed by the tree (starting from `defaultExpandedIds`) when `expandedIds` is not passed.\n */\nconst Tree = forwardRef<HTMLDivElement, TreeProps>(\n\t(\n\t\t{\n\t\t\tassistiveText: assistiveTextProp,\n\t\t\tclassName,\n\t\t\tclassNameList,\n\t\t\tlistClassName,\n\t\t\tgetNodes = defaultGetNodes,\n\t\t\theading: headingProp,\n\t\t\tid,\n\t\t\tlabels,\n\t\t\tnodes,\n\t\t\tselectedIds,\n\t\t\texpandedIds,\n\t\t\tdefaultExpandedIds,\n\t\t\tonSelect,\n\t\t\tonClick,\n\t\t\tonRequestToggle,\n\t\t\tonExpandClick,\n\t\t\tonScroll,\n\t\t\tsearchTerm,\n\t\t\tstyleList,\n\t\t\tlistStyle,\n\t\t},\n\t\tref\n\t) => {\n\t\t// `assistiveText.label` is deprecated\n\t\tconst assistiveHeading =\n\t\t\tassistiveTextProp?.heading ?? assistiveTextProp?.label;\n\t\t// `heading` is deprecated\n\t\tconst visibleHeading = labels?.heading ?? headingProp;\n\n\t\t// Without `selectedIds`, selection is read from the deprecated `node.selected` fields\n\t\tconst isLegacySelection = selectedIds === undefined;\n\t\t// Without `expandedIds` and `defaultExpandedIds`, the deprecated `node.expanded` fields win\n\t\tconst isLegacyExpansion =\n\t\t\texpandedIds === undefined && defaultExpandedIds === undefined;\n\n\t\t// Expansion is ephemeral UI state: controlled when `expandedIds` is passed\n\t\tconst [currentExpandedIds, setExpandedIds] = useControllableState(\n\t\t\texpandedIds,\n\t\t\tdefaultExpandedIds ?? EMPTY_IDS\n\t\t);\n\n\t\tconst selectedIdSet = useMemo(\n\t\t\t() => new Set<TreeNodeId>(selectedIds ?? EMPTY_IDS),\n\t\t\t[selectedIds]\n\t\t);\n\t\tconst expandedIdSet = useMemo(\n\t\t\t() => new Set<TreeNodeId>(currentExpandedIds),\n\t\t\t[currentExpandedIds]\n\t\t);\n\n\t\tconst isNodeSelected = useCallback(\n\t\t\t(node: TreeNode) =>\n\t\t\t\tisLegacySelection ? !!node.selected : selectedIdSet.has(node.id),\n\t\t\t[isLegacySelection, selectedIdSet]\n\t\t);\n\n\t\tconst isNodeExpanded = useCallback(\n\t\t\t(node: TreeNode) =>\n\t\t\t\tisLegacyExpansion && node.expanded !== undefined\n\t\t\t\t\t? !!node.expanded\n\t\t\t\t\t: expandedIdSet.has(node.id),\n\t\t\t[isLegacyExpansion, expandedIdSet]\n\t\t);\n\n\t\t// Track if tree has focus\n\t\tconst treeHasFocusRef = useRef(false);\n\n\t\t// Visible nodes in display order\n\t\tconst flattenedNodes = useMemo(\n\t\t\t() =>\n\t\t\t\tflattenTree(\n\t\t\t\t\t{ nodes: getNodes({ nodes }) },\n\t\t\t\t\tgetNodes,\n\t\t\t\t\tisNodeExpanded\n\t\t\t\t).slice(1),\n\t\t\t[getNodes, nodes, isNodeExpanded]\n\t\t);\n\n\t\t// Roving focus is ephemeral and internal. Until a node has been focused, the first visible\n\t\t// selected node is the tab stop.\n\t\tconst [focusedNodeIndex, setFocusedNodeIndex] = useState<\n\t\t\tstring | undefined\n\t\t>(undefined);\n\t\tconst effectiveFocusedNodeIndex =\n\t\t\tfocusedNodeIndex ??\n\t\t\tflattenedNodes.find((flattenedNode) => isNodeSelected(flattenedNode.node))\n\t\t\t\t?.treeIndex;\n\t\tconst tabStopIndex =\n\t\t\teffectiveFocusedNodeIndex ?? flattenedNodes[0]?.treeIndex;\n\n\t\t// Check props on mount\n\t\tuseEffect(() => {\n\t\t\tcheckProps(\n\t\t\t\tTREE,\n\t\t\t\t{\n\t\t\t\t\tassistiveText: assistiveTextProp,\n\t\t\t\t\tclassName,\n\t\t\t\t\tclassNameList,\n\t\t\t\t\tlistClassName,\n\t\t\t\t\tgetNodes,\n\t\t\t\t\theading: headingProp,\n\t\t\t\t\tid,\n\t\t\t\t\tlabels,\n\t\t\t\t\tnodes,\n\t\t\t\t\tselectedIds,\n\t\t\t\t\texpandedIds,\n\t\t\t\t\tdefaultExpandedIds,\n\t\t\t\t\tonSelect,\n\t\t\t\t\tonClick,\n\t\t\t\t\tonRequestToggle,\n\t\t\t\t\tonExpandClick,\n\t\t\t\t\tonScroll,\n\t\t\t\t\tsearchTerm,\n\t\t\t\t\tstyleList,\n\t\t\t\t\tlistStyle,\n\t\t\t\t},\n\t\t\t\tcomponentDoc\n\t\t\t);\n\t\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t}, []);\n\n\t\t// Warn about the deprecated `node.expanded` fallback whenever visible nodes use it\n\t\tuseEffect(() => {\n\t\t\tif (process.env.NODE_ENV !== 'production' && isLegacyExpansion) {\n\t\t\t\tcheckLegacyNodeFields(TREE, {\n\t\t\t\t\thasExpandedField: flattenedNodes.some(\n\t\t\t\t\t\t(flattenedNode) => flattenedNode.node.expanded !== undefined\n\t\t\t\t\t),\n\t\t\t\t});\n\t\t\t}\n\t\t}, [isLegacyExpansion, flattenedNodes]);\n\n\t\tconst getSelectedIds = useCallback(\n\t\t\t() =>\n\t\t\t\tisLegacySelection\n\t\t\t\t\t? collectNodeIds(nodes, getNodes, (node) => !!node.selected)\n\t\t\t\t\t: (selectedIds as TreeNodeId[]),\n\t\t\t[isLegacySelection, nodes, getNodes, selectedIds]\n\t\t);\n\n\t\tconst getExpandedIds = useCallback(\n\t\t\t() =>\n\t\t\t\tisLegacyExpansion\n\t\t\t\t\t? collectNodeIds(\n\t\t\t\t\t\t\tnodes,\n\t\t\t\t\t\t\tgetNodes,\n\t\t\t\t\t\t\t(node) => node.type === 'branch' && isNodeExpanded(node)\n\t\t\t\t\t\t)\n\t\t\t\t\t: currentExpandedIds,\n\t\t\t[isLegacyExpansion, nodes, getNodes, isNodeExpanded, currentExpandedIds]\n\t\t);\n\n\t\t// Handle node selection. Never writes to `nodes`: it reports the requested selection.\n\t\tconst handleSelect = useCallback(\n\t\t\t({\n\t\t\t\tevent,\n\t\t\t\tdata,\n\t\t\t\tclearSelectedNodes,\n\t\t\t\tfromFocus,\n\t\t\t}: {\n\t\t\t\tevent: React.SyntheticEvent;\n\t\t\t\tdata: TreeSelectData;\n\t\t\t\tclearSelectedNodes?: boolean;\n\t\t\t\tfromFocus?: boolean;\n\t\t\t}) => {\n\t\t\t\t// Prevent firing twice on first click due to focus event\n\t\t\t\tif (!fromFocus) {\n\t\t\t\t\tif (onSelect) {\n\t\t\t\t\t\t// Keyboard navigation moves the selection to the node; click and Enter toggle it\n\t\t\t\t\t\tconst others = clearSelectedNodes\n\t\t\t\t\t\t\t? []\n\t\t\t\t\t\t\t: getSelectedIds().filter((nodeId) => nodeId !== data.node.id);\n\t\t\t\t\t\tonSelect(event, {\n\t\t\t\t\t\t\tnode: data.node,\n\t\t\t\t\t\t\tisSelected: data.select,\n\t\t\t\t\t\t\tselectedIds: data.select ? [...others, data.node.id] : others,\n\t\t\t\t\t\t});\n\t\t\t\t\t} else if (onClick) {\n\t\t\t\t\t\tonClick(event, data);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\ttreeHasFocusRef.current = true;\n\t\t\t\tsetFocusedNodeIndex(data.treeIndex);\n\t\t\t},\n\t\t\t[getSelectedIds, onSelect, onClick]\n\t\t);\n\n\t\t// Handle node blur\n\t\tconst handleNodeBlur = useCallback(() => {\n\t\t\ttreeHasFocusRef.current = false;\n\t\t}, []);\n\n\t\t// Handle expand/collapse\n\t\tconst handleExpand = useCallback(\n\t\t\t({\n\t\t\t\tevent,\n\t\t\t\tdata,\n\t\t\t}: {\n\t\t\t\tevent: React.SyntheticEvent;\n\t\t\t\tdata: TreeExpandData;\n\t\t\t}) => {\n\t\t\t\t// `data.select` marks Left arrow on a collapsed branch or item: move to the parent node.\n\t\t\t\tif (data.select) {\n\t\t\t\t\tif (!onRequestToggle && onExpandClick) {\n\t\t\t\t\t\t// Deprecated behavior: report it to `onExpandClick` with the parent node\n\t\t\t\t\t\ttreeHasFocusRef.current = true;\n\t\t\t\t\t\tonExpandClick(event, data);\n\t\t\t\t\t\tsetFocusedNodeIndex(data.treeIndex);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Not an expand/collapse request: select the parent, like Up/Down arrows do\n\t\t\t\t\t\thandleSelect({\n\t\t\t\t\t\t\tevent,\n\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\tnode: data.node,\n\t\t\t\t\t\t\t\tselect: true,\n\t\t\t\t\t\t\t\ttreeIndex: data.treeIndex,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tclearSelectedNodes: true,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\ttreeHasFocusRef.current = true;\n\t\t\t\tconst others = getExpandedIds().filter(\n\t\t\t\t\t(nodeId) => nodeId !== data.node.id\n\t\t\t\t);\n\t\t\t\tconst nextExpandedIds = data.expand\n\t\t\t\t\t? [...others, data.node.id]\n\t\t\t\t\t: others;\n\t\t\t\t// No-op when `expandedIds` is controlled\n\t\t\t\tsetExpandedIds(nextExpandedIds);\n\t\t\t\tif (onRequestToggle) {\n\t\t\t\t\tonRequestToggle(event, {\n\t\t\t\t\t\tnode: data.node,\n\t\t\t\t\t\tisExpanded: data.expand,\n\t\t\t\t\t\texpandedIds: nextExpandedIds,\n\t\t\t\t\t});\n\t\t\t\t} else if (onExpandClick) {\n\t\t\t\t\tonExpandClick(event, data);\n\t\t\t\t}\n\t\t\t},\n\t\t\t[\n\t\t\t\thandleSelect,\n\t\t\t\tgetExpandedIds,\n\t\t\t\tsetExpandedIds,\n\t\t\t\tonRequestToggle,\n\t\t\t\tonExpandClick,\n\t\t\t]\n\t\t);\n\n\t\t// Determine heading text\n\t\tconst headingText = assistiveHeading || visibleHeading;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tid={id}\n\t\t\t\tclassName={classNames('slds-tree_container', className)}\n\t\t\t\tref={ref}\n\t\t\t>\n\t\t\t\t<h4\n\t\t\t\t\tclassName={classNames('slds-tree__group-header', {\n\t\t\t\t\t\t'slds-assistive-text': !!assistiveHeading,\n\t\t\t\t\t})}\n\t\t\t\t\tid={`${id}__heading`}\n\t\t\t\t>\n\t\t\t\t\t{headingText}\n\t\t\t\t</h4>\n\t\t\t\t<Branch\n\t\t\t\t\tgetNodes={getNodes}\n\t\t\t\t\tinitalClassName={classNames(listClassName, classNameList)}\n\t\t\t\t\thtmlId={id}\n\t\t\t\t\tinitialStyle={\n\t\t\t\t\t\tlistStyle || styleList ? { ...listStyle, ...styleList } : undefined\n\t\t\t\t\t}\n\t\t\t\t\tlevel={0}\n\t\t\t\t\tnode={{ nodes }}\n\t\t\t\t\tflattenedNodes={flattenedNodes}\n\t\t\t\t\tisNodeSelected={isNodeSelected}\n\t\t\t\t\tisNodeExpanded={isNodeExpanded}\n\t\t\t\t\ttabStopIndex={tabStopIndex}\n\t\t\t\t\tfocusedNodeIndex={effectiveFocusedNodeIndex}\n\t\t\t\t\ttreeHasFocus={treeHasFocusRef.current}\n\t\t\t\t\tonNodeBlur={handleNodeBlur}\n\t\t\t\t\tonSelect={handleSelect}\n\t\t\t\t\tonExpand={handleExpand}\n\t\t\t\t\tonScroll={onScroll}\n\t\t\t\t\tsearchTerm={searchTerm}\n\t\t\t\t\ttreeId={id}\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n);\n\nTree.displayName = TREE;\n\nexport default Tree;\n"],"mappings":"uXAmLA,IAAM,EAA0B,CAAC,EAM3B,GACL,EACA,EACA,EACA,EAAY,GACZ,EAAa,KACQ,CACrB,GAAI,CAAC,EAAK,MACT,MAAO,CAAC,CAAE,KAAM,EAAkB,WAAU,CAAC,EAE9C,IAAI,EAAyB,CAAC,CAAE,KAAM,EAAkB,WAAU,CAAC,EACnE,GAAI,GAAc,EAAW,CAAgB,EAC5C,IAAK,IAAI,EAAQ,EAAG,EAAQ,EAAK,MAAM,OAAQ,GAAS,EAAG,CAC1D,IAAM,EAAU,EAAa,EAAK,MAAM,GAAS,EAAS,CAAI,CAAC,GAAG,GAC9D,IACH,EAAQ,EAAM,OACb,EACC,EACA,EACA,EACA,EAAY,GAAG,EAAU,GAAG,IAAU,GAAG,IACzC,EACD,CACD,EAEF,CAED,OAAO,CACR,EAMM,GACL,EACA,EACA,IACkB,CAClB,IAAM,EAAoB,CAAC,EACrB,EAAU,IAAI,IACd,EAAS,GAAiC,CAC/C,GAAM,QAAS,GAAS,CACnB,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,EAAe,CAAa,EACxD,OAAQ,EACR,aACC,GAAa,EAAY,CAAE,GAAG,EAAW,GAAG,CAAU,EAAI,IAAA,GAE3D,MAAO,EACP,KAAM,CAAE,OAAM,EACE,iBACA,iBACA,iBACF,eACd,iBAAkB,EAClB,aAAc,EAAgB,QAC9B,WAAY,EACZ,SAAU,EACV,SAAU,EACA,WACE,aACZ,OAAQ,CACR,CAAA,CACG,GAEP,CACD,EAEA,EAAK,YAAc,EAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.cjs","names":[],"sources":["../../../../components/trial-bar/button.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport Button, { type ButtonProps } from '../button';\nimport { TRIAL_BAR_BUTTON } from '../../utilities/constants';\n\n/**\n * A
|
|
1
|
+
{"version":3,"file":"button.cjs","names":[],"sources":["../../../../components/trial-bar/button.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport Button, { type ButtonProps } from '../button';\nimport { TRIAL_BAR_BUTTON } from '../../utilities/constants';\n\n/**\n * A `Button` within the Trial Bar.\n */\nconst TrialBarButton = ({ className, style, ...props }: ButtonProps) => (\n\t<Button\n\t\t{...props}\n\t\tinverse\n\t\tstyle={{ border: 0, padding: 0, ...style }}\n\t\tclassName={classNames(\n\t\t\t'slds-m-right_small',\n\t\t\tclassName as string | string[] | Record<string, boolean>\n\t\t)}\n\t/>\n);\n\nTrialBarButton.displayName = TRIAL_BAR_BUTTON;\n\nexport default TrialBarButton;\n"],"mappings":"oNAOA,IAAM,GAAkB,CAAE,YAAW,QAAO,GAAG,MAC9C,EAAA,EAAA,IAAA,CAAC,EAAA,QAAD,CACC,GAAI,EACJ,QAAA,GACA,MAAO,CAAE,OAAQ,EAAG,QAAS,EAAG,GAAG,CAAM,EACzC,WAAA,EAAW,EAAA,QAAA,CACV,qBACA,CACD,CACA,CAAA,EAGF,EAAe,YAAc,EAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropdown.cjs","names":[],"sources":["../../../../components/trial-bar/dropdown.tsx"],"sourcesContent":["import classNames from 'classnames';\n\nimport Dropdown from '../menu-dropdown';\nimport { type MenuDropdownBaseProps } from '../menu-dropdown/menu-dropdown';\nimport Button from '../button';\n\nimport { TRIAL_BAR_DROPDOWN } from '../../utilities/constants';\n\nexport interface TrialBarDropdownProps extends Omit<\n\tMenuDropdownBaseProps,\n\t'inverse' | 'label' | 'trigger'\n> {\n\t/**\n\t * Label rendered on the dropdown trigger button.\n\t */\n\tlabel?: string;\n}\n\n/**\n * A
|
|
1
|
+
{"version":3,"file":"dropdown.cjs","names":[],"sources":["../../../../components/trial-bar/dropdown.tsx"],"sourcesContent":["import classNames from 'classnames';\n\nimport Dropdown from '../menu-dropdown';\nimport { type MenuDropdownBaseProps } from '../menu-dropdown/menu-dropdown';\nimport Button from '../button';\n\nimport { TRIAL_BAR_DROPDOWN } from '../../utilities/constants';\n\nexport interface TrialBarDropdownProps extends Omit<\n\tMenuDropdownBaseProps,\n\t'inverse' | 'label' | 'trigger'\n> {\n\t/**\n\t * Label rendered on the dropdown trigger button.\n\t */\n\tlabel?: string;\n}\n\n/**\n * A `MenuDropdown` within the Trial Bar.\n */\nconst TrialBarDropdown = (props: TrialBarDropdownProps) => {\n\tconst { label, triggerClassName, ...rest } = props;\n\treturn (\n\t\t<Dropdown\n\t\t\t{...rest}\n\t\t\tinverse\n\t\t\ttriggerClassName={classNames('slds-grid', triggerClassName)}\n\t\t\ttrigger={\n\t\t\t\t<Button\n\t\t\t\t\tinverse\n\t\t\t\t\tstyle={{ border: 0, height: '100%', padding: 0 }}\n\t\t\t\t\ticonCategory=\"utility\"\n\t\t\t\t\ticonName=\"right\"\n\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\tlabel={label}\n\t\t\t\t/>\n\t\t\t}\n\t\t/>\n\t);\n};\n\nTrialBarDropdown.displayName = TRIAL_BAR_DROPDOWN;\nexport default TrialBarDropdown;\n"],"mappings":"4PAqBA,IAAM,EAAoB,GAAiC,CAC1D,GAAM,CAAE,QAAO,mBAAkB,GAAG,GAAS,EAC7C,OACC,EAAA,EAAA,IAAA,CAAC,EAAA,QAAD,CACC,GAAI,EACJ,QAAA,GACA,kBAAA,EAAkB,EAAA,QAAA,CAAW,YAAa,CAAgB,EAC1D,SACC,EAAA,EAAA,IAAA,CAAC,EAAA,QAAD,CACC,QAAA,GACA,MAAO,CAAE,OAAQ,EAAG,OAAQ,OAAQ,QAAS,CAAE,EAC/C,aAAa,UACb,SAAS,QACT,aAAa,OACN,OACP,CAAA,CAEF,CAAA,CAEH,EAEA,EAAiB,YAAc,EAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item-label.cjs","names":[],"sources":["../../../../../components/utilities/menu-list/item-label.tsx"],"sourcesContent":["/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\n// # List Item Label Component\n\n// ## Dependencies\n\n// ### React\nimport { type ReactNode } from 'react';\n\n// ## Constants\nimport { LIST_ITEM_LABEL } from '../../../utilities/constants';\n\nexport interface ListItemLabelProps {\n\tdata?: Record<string, unknown>;\n\ticon?: ReactNode;\n\tindex?: number;\n\tinverted?: boolean;\n\tisSelected?: boolean;\n\tlabel?: string;\n\tcheckmark?: boolean;\n\tvalue?: unknown;\n}\n\n/**\n * Component description.\n */\nconst ListItemLabel = ({ label = '', icon }: ListItemLabelProps) => (\n\t<span className=\"slds-truncate\" title={label}>\n\t\t{icon}\n\t\t{label}\n\t</span>\n);\n\nListItemLabel.displayName = LIST_ITEM_LABEL;\n\nexport default ListItemLabel;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"item-label.cjs","names":[],"sources":["../../../../../components/utilities/menu-list/item-label.tsx"],"sourcesContent":["/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\n// # List Item Label Component\n\n// ## Dependencies\n\n// ### React\nimport { type ReactNode } from 'react';\n\n// ## Constants\nimport { LIST_ITEM_LABEL } from '../../../utilities/constants';\n\n/**\n * Props a menu item passes to its label renderer (`renderLabel` or\n * `labelRenderer`), taken from the menu option.\n */\nexport interface ListItemLabelProps {\n\t/** The option's `data`. */\n\tdata?: Record<string, unknown>;\n\t/** The rendered left icon, or the checkmark in the checkmark variant. */\n\ticon?: ReactNode;\n\t/** Index of the item in the menu. */\n\tindex?: number;\n\t/** Whether the menu uses the inverse color scheme. */\n\tinverted?: boolean;\n\t/** Whether the item is selected. */\n\tisSelected?: boolean;\n\t/** The option's `label`. Also used as the `title`. */\n\tlabel?: string;\n\t/** Whether the item shows a checkmark when selected. */\n\tcheckmark?: boolean;\n\t/** The option's `value`. */\n\tvalue?: unknown;\n}\n\n/**\n * Component description.\n */\nconst ListItemLabel = ({ label = '', icon }: ListItemLabelProps) => (\n\t<span className=\"slds-truncate\" title={label}>\n\t\t{icon}\n\t\t{label}\n\t</span>\n);\n\nListItemLabel.displayName = LIST_ITEM_LABEL;\n\nexport default ListItemLabel;\n"],"mappings":"uFAuCA,IAAM,GAAiB,CAAE,QAAQ,GAAI,WACpC,EAAA,EAAA,KAAA,CAAC,OAAD,CAAM,UAAU,gBAAgB,MAAO,EAAvC,SAAA,CACE,EACA,CACI,IAGP,EAAc,YAAc,EAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e=function(){}
|
|
1
|
+
var e=`https://opensource.salesforce.com/design-system-react/`,t=t=>t?`${e}?path=/docs/components-${t.toLowerCase()}--docs`:e,n=function(){};process.env.NODE_ENV!==`production`&&(n=function(e){let n=t(e&&e.classKey);return()=>`See the documentation: ${n}`});var r=n;exports.DOCS_SITE=e,exports.default=r,exports.storybookDocsUrl=t;
|
|
2
2
|
//# sourceMappingURL=get-component-doc.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-component-doc.cjs","names":[],"sources":["../../../utilities/get-component-doc.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\
|
|
1
|
+
{"version":3,"file":"get-component-doc.cjs","names":[],"sources":["../../../utilities/get-component-doc.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\n/** The hosted v11 docs: Storybook, with the LLM docs at the root. */\nexport const DOCS_SITE =\n\t'https://opensource.salesforce.com/design-system-react/';\n\n/**\n * The Storybook docs page of a component. A component's stories file has the\n * title `Components/<classKey>` (its `component.json` `classKey`), and\n * Storybook makes the page id from the title: `Components/ButtonGroup` is\n * `components-buttongroup--docs`. `scripts/__tests__/storybook-doc-links.test.mjs`\n * checks every component against Storybook's own `toId`.\n */\nexport const storybookDocsUrl = (classKey) =>\n\tclassKey\n\t\t? `${DOCS_SITE}?path=/docs/components-${classKey.toLowerCase()}--docs`\n\t\t: DOCS_SITE;\n\nlet getComponentDocFn = function getComponentDocFnEmpty() {};\n\nif (process.env.NODE_ENV !== 'production') {\n\t/**\n\t * Returns the link that a component's prop warnings end with. Callers pass\n\t * the prop name, but Storybook has no anchor per prop, so every warning\n\t * links the component's docs page.\n\t */\n\tgetComponentDocFn = function getComponentDocFnInside(jsonDoc) {\n\t\tconst url = storybookDocsUrl(jsonDoc && jsonDoc.classKey);\n\t\treturn () => `See the documentation: ${url}`;\n\t};\n}\n\nexport default getComponentDocFn;\n"],"mappings":"AAKA,IAAa,EACZ,yDASY,EAAoB,GAChC,EACG,GAAG,EAAU,yBAAyB,EAAS,YAAY,EAAE,QAC7D,EAEA,EAAoB,UAAkC,CAAC,EAE3D,QAAA,IAAA,WAA6B,eAM5B,EAAoB,SAAiC,EAAS,CAC7D,IAAM,EAAM,EAAiB,GAAW,EAAQ,QAAQ,EACxD,UAAa,0BAA0B,GACxC,GAGD,IAAA,EAAe"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("./warned-registry.cjs");let
|
|
1
|
+
const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("./warned-registry.cjs"),n=require("./removal-version.cjs");let r=require("warning");r=e.__toESM(r,1);var i=function(){};if(process.env.NODE_ENV!==`production`){let e=t.createWarnedMap();i=function(t,i,a){let o=a?` ${a}`:``;i&&!e[t]&&((0,r.default)(!1,`[Design System React] Passing the trigger of ${t} as \`children\` is deprecated and will be removed in ${n.REMOVAL_VERSION}. Use \`trigger\` instead: an element, whose props ${t} merges with its own, or a function that receives ${t}'s trigger props.${o}`),e[t]=!0)}}var a=i;exports.default=a;
|
|
2
2
|
//# sourceMappingURL=children-as-trigger.cjs.map
|