@lumx/react 3.20.1-alpha.5 → 3.20.1-alpha.6
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/_internal/index.js.map +1 -1
- package/index.d.ts +35 -34
- package/index.js +778 -651
- package/index.js.map +1 -1
- package/package.json +13 -12
- package/src/components/alert-dialog/AlertDialog.stories.tsx +1 -1
- package/src/components/alert-dialog/AlertDialog.test.tsx +3 -4
- package/src/components/autocomplete/Autocomplete.stories.tsx +1 -1
- package/src/components/autocomplete/Autocomplete.test.tsx +3 -5
- package/src/components/autocomplete/Autocomplete.tsx +1 -1
- package/src/components/autocomplete/AutocompleteMultiple.stories.tsx +1 -1
- package/src/components/autocomplete/AutocompleteMultiple.test.tsx +0 -2
- package/src/components/autocomplete/AutocompleteMultiple.tsx +1 -1
- package/src/components/avatar/Avatar.stories.tsx +0 -2
- package/src/components/avatar/Avatar.test.tsx +0 -2
- package/src/components/avatar/Avatar.tsx +1 -1
- package/src/components/badge/Badge.stories.tsx +0 -1
- package/src/components/badge/Badge.test.tsx +0 -2
- package/src/components/badge/Badge.tsx +1 -1
- package/src/components/badge/BadgeWrapper.stories.tsx +0 -1
- package/src/components/badge/BadgeWrapper.test.tsx +0 -2
- package/src/components/badge/BadgeWrapper.tsx +1 -1
- package/src/components/button/Button.stories.tsx +0 -1
- package/src/components/button/Button.test.tsx +9 -11
- package/src/components/button/Button.tsx +0 -2
- package/src/components/button/ButtonGroup.stories.tsx +0 -2
- package/src/components/button/ButtonGroup.test.tsx +0 -2
- package/src/components/button/ButtonGroup.tsx +0 -2
- package/src/components/button/ButtonRoot.tsx +7 -37
- package/src/components/button/IconButton.test.tsx +0 -2
- package/src/components/button/IconButton.tsx +0 -2
- package/src/components/checkbox/Checkbox.test.tsx +3 -5
- package/src/components/chip/Chip.stories.tsx +0 -2
- package/src/components/chip/Chip.test.tsx +19 -19
- package/src/components/chip/Chip.tsx +1 -1
- package/src/components/chip/ChipGroup.stories.tsx +0 -2
- package/src/components/chip/ChipGroup.test.tsx +0 -2
- package/src/components/chip/ChipGroup.tsx +1 -1
- package/src/components/comment-block/CommentBlock.stories.tsx +0 -1
- package/src/components/comment-block/CommentBlock.test.tsx +0 -1
- package/src/components/comment-block/CommentBlock.tsx +1 -1
- package/src/components/date-picker/DatePicker.test.tsx +3 -5
- package/src/components/date-picker/DatePicker.tsx +1 -1
- package/src/components/date-picker/DatePickerControlled.test.tsx +6 -8
- package/src/components/date-picker/DatePickerField.test.tsx +3 -5
- package/src/components/dialog/Dialog.test.tsx +4 -6
- package/src/components/divider/Divider.test.tsx +0 -2
- package/src/components/divider/Divider.tsx +0 -2
- package/src/components/drag-handle/DragHandle.test.tsx +0 -2
- package/src/components/drag-handle/DragHandle.tsx +0 -2
- package/src/components/dropdown/Dropdown.stories.tsx +1 -1
- package/src/components/dropdown/Dropdown.test.tsx +3 -3
- package/src/components/dropdown/Dropdown.tsx +1 -1
- package/src/components/expansion-panel/ExpansionPanel.test.tsx +6 -7
- package/src/components/flag/Flag.test.tsx +0 -2
- package/src/components/flag/Flag.tsx +0 -2
- package/src/components/flex-box/FlexBox.stories.tsx +0 -2
- package/src/components/flex-box/FlexBox.test.tsx +0 -1
- package/src/components/flex-box/FlexBox.tsx +1 -1
- package/src/components/generic-block/GenericBlock.test.tsx +1 -1
- package/src/components/grid/Grid.tsx +0 -2
- package/src/components/grid/GridItem.tsx +0 -2
- package/src/components/grid-column/GridColumn.stories.tsx +0 -1
- package/src/components/grid-column/GridColumn.test.jsx +0 -2
- package/src/components/grid-column/GridColumn.tsx +1 -1
- package/src/components/heading/Heading.stories.tsx +0 -1
- package/src/components/heading/Heading.test.tsx +0 -2
- package/src/components/heading/Heading.tsx +0 -2
- package/src/components/heading/HeadingLevelProvider.tsx +1 -1
- package/src/components/icon/Icon.stories.tsx +30 -4
- package/src/components/icon/Icon.test.tsx +85 -4
- package/src/components/icon/Icon.tsx +0 -2
- package/src/components/image-block/ImageBlock.stories.tsx +0 -2
- package/src/components/image-block/ImageBlock.test.tsx +0 -1
- package/src/components/image-block/ImageBlock.tsx +1 -1
- package/src/components/image-block/ImageCaption.tsx +1 -1
- package/src/components/image-lightbox/ImageLightbox.stories.tsx +0 -1
- package/src/components/image-lightbox/ImageLightbox.test.tsx +11 -9
- package/src/components/image-lightbox/types.ts +0 -2
- package/src/components/inline-list/InlineList.stories.tsx +0 -1
- package/src/components/inline-list/InlineList.test.tsx +0 -2
- package/src/components/inline-list/InlineList.tsx +1 -1
- package/src/components/input-helper/InputHelper.test.tsx +0 -2
- package/src/components/input-helper/InputHelper.tsx +1 -1
- package/src/components/input-label/InputLabel.stories.tsx +0 -2
- package/src/components/input-label/InputLabel.test.tsx +0 -2
- package/src/components/input-label/InputLabel.tsx +1 -1
- package/src/components/lightbox/Lightbox.test.tsx +0 -2
- package/src/components/lightbox/Lightbox.tsx +1 -1
- package/src/components/link/Link.stories.tsx +0 -1
- package/src/components/link/Link.test.tsx +13 -13
- package/src/components/link/Link.tsx +9 -22
- package/src/components/link-preview/LinkPreview.test.tsx +0 -2
- package/src/components/link-preview/LinkPreview.tsx +0 -2
- package/src/components/list/List.stories.tsx +1 -1
- package/src/components/list/List.test.tsx +0 -2
- package/src/components/list/List.tsx +1 -1
- package/src/components/list/ListDivider.test.tsx +0 -2
- package/src/components/list/ListDivider.tsx +0 -2
- package/src/components/list/ListItem.test.tsx +5 -7
- package/src/components/list/ListItem.tsx +1 -1
- package/src/components/list/ListSubheader.test.tsx +0 -2
- package/src/components/list/ListSubheader.tsx +1 -1
- package/src/components/message/Message.test.tsx +1 -2
- package/src/components/message/Message.tsx +1 -1
- package/src/components/mosaic/Mosaic.test.tsx +3 -5
- package/src/components/mosaic/Mosaic.tsx +1 -1
- package/src/components/navigation/Navigation.stories.tsx +0 -2
- package/src/components/navigation/Navigation.test.tsx +0 -2
- package/src/components/navigation/Navigation.tsx +0 -2
- package/src/components/navigation/NavigationItem.test.tsx +0 -2
- package/src/components/navigation/NavigationItem.tsx +7 -11
- package/src/components/navigation/NavigationSection.test.tsx +0 -2
- package/src/components/navigation/NavigationSection.tsx +5 -4
- package/src/components/notification/Notification.test.tsx +4 -5
- package/src/components/notification/Notification.tsx +1 -1
- package/src/components/popover/Popover.test.tsx +0 -2
- package/src/components/popover/Popover.tsx +1 -1
- package/src/components/popover/usePopoverStyle.tsx +1 -1
- package/src/components/popover-dialog/PopoverDialog.test.tsx +1 -2
- package/src/components/popover-dialog/PopoverDialog.tsx +0 -2
- package/src/components/post-block/PostBlock.test.tsx +0 -2
- package/src/components/post-block/PostBlock.tsx +1 -1
- package/src/components/progress/Progress.tsx +0 -2
- package/src/components/progress/ProgressCircular.stories.tsx +0 -1
- package/src/components/progress/ProgressCircular.test.tsx +0 -2
- package/src/components/progress/ProgressCircular.tsx +0 -2
- package/src/components/progress/ProgressLinear.test.tsx +0 -2
- package/src/components/progress/ProgressLinear.tsx +0 -2
- package/src/components/progress-tracker/ProgressTracker.stories.tsx +1 -1
- package/src/components/progress-tracker/ProgressTracker.test.tsx +0 -2
- package/src/components/progress-tracker/ProgressTrackerProvider.test.tsx +0 -2
- package/src/components/progress-tracker/ProgressTrackerProvider.tsx +1 -1
- package/src/components/progress-tracker/ProgressTrackerStep.test.tsx +0 -2
- package/src/components/progress-tracker/ProgressTrackerStep.tsx +1 -1
- package/src/components/progress-tracker/ProgressTrackerStepPanel.test.tsx +0 -2
- package/src/components/progress-tracker/ProgressTrackerStepPanel.tsx +0 -2
- package/src/components/radio-button/RadioButton.test.tsx +3 -5
- package/src/components/radio-button/RadioButton.tsx +1 -1
- package/src/components/radio-button/RadioGroup.stories.tsx +1 -1
- package/src/components/radio-button/RadioGroup.test.tsx +0 -2
- package/src/components/radio-button/RadioGroup.tsx +1 -1
- package/src/components/select/Select.stories.tsx +1 -1
- package/src/components/select/Select.test.tsx +8 -9
- package/src/components/select/Select.tsx +1 -1
- package/src/components/select/SelectMultiple.stories.tsx +1 -1
- package/src/components/select/SelectMultiple.test.tsx +5 -7
- package/src/components/select/SelectMultiple.tsx +1 -1
- package/src/components/select/WithSelectContext.tsx +1 -1
- package/src/components/select/constants.ts +1 -1
- package/src/components/side-navigation/SideNavigation.test.tsx +0 -2
- package/src/components/side-navigation/SideNavigation.tsx +1 -1
- package/src/components/side-navigation/SideNavigationItem.test.tsx +2 -4
- package/src/components/side-navigation/SideNavigationItem.tsx +23 -28
- package/src/components/skeleton/SkeletonCircle.test.tsx +0 -2
- package/src/components/skeleton/SkeletonCircle.tsx +0 -2
- package/src/components/skeleton/SkeletonRectangle.test.tsx +0 -2
- package/src/components/skeleton/SkeletonRectangle.tsx +0 -2
- package/src/components/skeleton/SkeletonTypography.stories.tsx +0 -2
- package/src/components/skeleton/SkeletonTypography.test.tsx +0 -2
- package/src/components/skeleton/SkeletonTypography.tsx +1 -1
- package/src/components/slider/Slider.test.tsx +1 -3
- package/src/components/slider/Slider.tsx +1 -1
- package/src/components/slideshow/Slideshow.stories.tsx +0 -1
- package/src/components/slideshow/Slideshow.test.tsx +0 -2
- package/src/components/slideshow/SlideshowControls.stories.tsx +0 -2
- package/src/components/slideshow/SlideshowItem.tsx +0 -2
- package/src/components/slideshow/useSlideFocusManagement.tsx +1 -1
- package/src/components/switch/Switch.test.tsx +5 -7
- package/src/components/switch/Switch.tsx +1 -1
- package/src/components/table/Table.test.tsx +0 -2
- package/src/components/table/Table.tsx +0 -2
- package/src/components/table/TableBody.test.tsx +0 -2
- package/src/components/table/TableBody.tsx +0 -2
- package/src/components/table/TableCell.test.tsx +1 -3
- package/src/components/table/TableCell.tsx +0 -2
- package/src/components/table/TableHeader.test.tsx +0 -2
- package/src/components/table/TableHeader.tsx +0 -2
- package/src/components/table/TableRow.test.tsx +0 -2
- package/src/components/table/TableRow.tsx +0 -2
- package/src/components/tabs/Tab.test.tsx +0 -2
- package/src/components/tabs/Tab.tsx +1 -1
- package/src/components/tabs/TabList.test.tsx +0 -2
- package/src/components/tabs/TabPanel.test.tsx +0 -2
- package/src/components/tabs/TabPanel.tsx +0 -2
- package/src/components/tabs/TabProvider.test.tsx +0 -2
- package/src/components/tabs/TabProvider.tsx +1 -1
- package/src/components/tabs/Tabs.stories.tsx +1 -1
- package/src/components/text/Text.stories.tsx +1 -1
- package/src/components/text/Text.test.tsx +0 -2
- package/src/components/text/Text.tsx +0 -2
- package/src/components/text-field/TextField.test.tsx +9 -10
- package/src/components/text-field/TextField.tsx +1 -1
- package/src/components/thumbnail/Thumbnail.test.tsx +29 -7
- package/src/components/thumbnail/Thumbnail.tsx +11 -11
- package/src/components/toolbar/Toolbar.tsx +1 -1
- package/src/components/tooltip/Tooltip.stories.tsx +2 -1
- package/src/components/tooltip/Tooltip.test.tsx +14 -8
- package/src/components/uploader/Uploader.test.tsx +2 -4
- package/src/components/user-block/UserBlock.stories.tsx +0 -2
- package/src/components/user-block/UserBlock.test.tsx +1 -3
- package/src/hooks/useId.test.tsx +0 -1
- package/src/hooks/useInfiniteScroll.tsx +1 -1
- package/src/hooks/usePreviousValue.ts +0 -1
- package/src/stories/decorators/withChromaticForceScreenSize.tsx +0 -1
- package/src/stories/decorators/withNestedProps.tsx +0 -1
- package/src/stories/decorators/withThemedBackground.tsx +0 -2
- package/src/stories/decorators/withWrapper.tsx +0 -2
- package/src/stories/utils/CustomLink.tsx +0 -1
- package/src/testing/utils/ThemeSentinel.tsx +0 -1
- package/src/untypped-modules.d.ts +4 -0
- package/src/utils/ClickAwayProvider/ClickAwayProvider.stories.jsx +1 -1
- package/src/utils/ClickAwayProvider/ClickAwayProvider.tsx +1 -1
- package/src/utils/MaterialThemeSwitcher/MaterialThemeSwitcher.tsx +1 -1
- package/src/utils/Portal/Portal.test.tsx +0 -1
- package/src/utils/Portal/PortalProvider.stories.jsx +0 -1
- package/src/utils/Portal/PortalProvider.test.tsx +1 -2
- package/src/utils/date/getYearDisplayName.test.ts +1 -1
- package/src/utils/disabled/DisabledStateProvider.stories.tsx +0 -2
- package/src/utils/disabled/useDisableStateProps.test.tsx +2 -2
- package/src/utils/react/OnBeforeUnmount.tsx +1 -1
- package/src/utils/react/RawClickable.test.tsx +153 -0
- package/src/utils/react/RawClickable.tsx +65 -0
- package/src/utils/react/skipRender.tsx +2 -2
- package/src/utils/react/wrapChildrenIconWithSpaces.test.tsx +1 -1
- package/src/utils/type/HasPolymorphicAs.ts +0 -2
- package/src/utils/type/HasRequiredLinkHref.ts +1 -0
- package/src/utils/type/index.ts +1 -0
- package/utils/index.d.ts +6 -6
- package/src/utils/react/renderButtonOrLink.tsx +0 -16
package/_internal/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/utils/disabled/DisabledStateContext.tsx","../../src/hooks/useClickAway.tsx","../../src/utils/ClickAwayProvider/ClickAwayProvider.tsx","../../src/utils/Portal/PortalProvider.tsx","../../src/utils/Portal/Portal.tsx"],"sourcesContent":["import React, { useContext } from 'react';\n\n/** Disable state */\ntype DisabledStateContextValue =\n | {\n state: 'disabled';\n }\n | { state: undefined | null };\n\nexport const DisabledStateContext = React.createContext<DisabledStateContextValue>({ state: null });\n\nexport type DisabledStateProviderProps = DisabledStateContextValue & {\n children: React.ReactNode;\n};\n\n/**\n * Disabled state provider.\n * All nested LumX Design System components inherit this disabled state.\n */\nexport function DisabledStateProvider({ children, ...value }: DisabledStateProviderProps) {\n return <DisabledStateContext.Provider value={value}>{children}</DisabledStateContext.Provider>;\n}\n\n/**\n * Get DisabledState context value\n */\nexport function useDisabledStateContext(): DisabledStateContextValue {\n return useContext(DisabledStateContext);\n}\n","import { RefObject, useEffect } from 'react';\n\nimport { Falsy } from '@lumx/react/utils/type';\n\nimport isEmpty from 'lodash/isEmpty';\n\nconst EVENT_TYPES = ['mousedown', 'touchstart'];\n\nfunction isClickAway(targets: HTMLElement[], refs: Array<RefObject<HTMLElement>>): boolean {\n // The targets elements are not contained in any of the listed element references.\n return !refs.some((ref) => targets.some((target) => ref?.current?.contains(target)));\n}\n\nexport interface ClickAwayParameters {\n /**\n * A callback function to call when the user clicks away from the elements.\n */\n callback: EventListener | Falsy;\n /**\n * Elements considered within the click away context (clicking outside them will trigger the click away callback).\n */\n childrenRefs: RefObject<Array<RefObject<HTMLElement>>>;\n}\n\n/**\n * Listen to clicks away from the given elements and callback the passed in function.\n *\n * Warning: If you need to detect click away on nested React portals, please use the `ClickAwayProvider` component.\n */\nexport function useClickAway({ callback, childrenRefs }: ClickAwayParameters): void {\n useEffect(() => {\n const { current: currentRefs } = childrenRefs;\n if (!callback || !currentRefs || isEmpty(currentRefs)) {\n return undefined;\n }\n const listener: EventListener = (evt) => {\n const targets = [evt.composedPath?.()[0], evt.target] as HTMLElement[];\n if (isClickAway(targets, currentRefs)) {\n callback(evt);\n }\n };\n\n EVENT_TYPES.forEach((evtType) => document.addEventListener(evtType, listener));\n return () => {\n EVENT_TYPES.forEach((evtType) => document.removeEventListener(evtType, listener));\n };\n }, [callback, childrenRefs]);\n}\n","import React, { createContext, RefObject, useContext, useEffect, useMemo, useRef } from 'react';\nimport { ClickAwayParameters, useClickAway } from '@lumx/react/hooks/useClickAway';\n\ninterface ContextValue {\n childrenRefs: Array<RefObject<HTMLElement>>;\n addRefs(...newChildrenRefs: Array<RefObject<HTMLElement>>): void;\n}\n\nconst ClickAwayAncestorContext = createContext<ContextValue | null>(null);\n\ninterface ClickAwayProviderProps extends ClickAwayParameters {\n /**\n * (Optional) Element that should be considered as part of the parent\n */\n parentRef?: RefObject<HTMLElement>;\n /**\n * Children\n */\n children?: React.ReactNode;\n}\n\n/**\n * Component combining the `useClickAway` hook with a React context to hook into the React component tree and make sure\n * we take into account both the DOM tree and the React tree to detect click away.\n *\n * @return the react component.\n */\nexport const ClickAwayProvider: React.FC<ClickAwayProviderProps> = ({\n children,\n callback,\n childrenRefs,\n parentRef,\n}) => {\n const parentContext = useContext(ClickAwayAncestorContext);\n const currentContext = useMemo(() => {\n const context: ContextValue = {\n childrenRefs: [],\n /**\n * Add element refs to the current context and propagate to the parent context.\n */\n addRefs(...newChildrenRefs) {\n // Add element refs that should be considered as inside the click away context.\n context.childrenRefs.push(...newChildrenRefs);\n\n if (parentContext) {\n // Also add then to the parent context\n parentContext.addRefs(...newChildrenRefs);\n if (parentRef) {\n // The parent element is also considered as inside the parent click away context but not inside the current context\n parentContext.addRefs(parentRef);\n }\n }\n },\n };\n return context;\n }, [parentContext, parentRef]);\n\n useEffect(() => {\n const { current: currentRefs } = childrenRefs;\n if (!currentRefs) {\n return;\n }\n currentContext.addRefs(...currentRefs);\n }, [currentContext, childrenRefs]);\n\n useClickAway({ callback, childrenRefs: useRef(currentContext.childrenRefs) });\n return <ClickAwayAncestorContext.Provider value={currentContext}>{children}</ClickAwayAncestorContext.Provider>;\n};\nClickAwayProvider.displayName = 'ClickAwayProvider';\n","import React from 'react';\n\ntype Container = DocumentFragment | Element;\n\n/**\n * Portal initializing function.\n * If it does not provide a container, the Portal children will render in classic React tree and not in a portal.\n */\nexport type PortalInit = () => {\n container?: Container;\n teardown?: () => void;\n};\n\nexport const PortalContext = React.createContext<PortalInit>(() => ({ container: document.body }));\n\nexport interface PortalProviderProps {\n children?: React.ReactNode;\n value: PortalInit;\n}\n\n/**\n * Customize where <Portal> wrapped elements render (tooltip, popover, dialog, etc.)\n */\nexport const PortalProvider: React.FC<PortalProviderProps> = PortalContext.Provider;\n","import React from 'react';\nimport { createPortal } from 'react-dom';\nimport { PortalContext } from './PortalProvider';\n\nexport interface PortalProps {\n enabled?: boolean;\n children: React.ReactNode;\n}\n\n/**\n * Render children in a portal outside the current DOM position\n * (defaults to `document.body` but can be customized with the PortalContextProvider)\n */\nexport const Portal: React.FC<PortalProps> = ({ children, enabled = true }) => {\n const init = React.useContext(PortalContext);\n const context = React.useMemo(\n () => {\n return enabled ? init() : null;\n },\n // Only update on 'enabled'\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [enabled],\n );\n\n React.useLayoutEffect(() => {\n return context?.teardown;\n }, [context?.teardown, enabled]);\n\n if (!context?.container) {\n return <>{children}</>;\n }\n return createPortal(children, context.container);\n};\n"],"names":["DisabledStateContext","React","createContext","state","DisabledStateProvider","_ref","children","value","_objectWithoutProperties","_excluded","_jsx","Provider","useDisabledStateContext","useContext","EVENT_TYPES","isClickAway","targets","refs","some","ref","target","_ref$current","current","contains","useClickAway","callback","childrenRefs","useEffect","currentRefs","isEmpty","undefined","listener","evt","_evt$composedPath","composedPath","call","forEach","evtType","document","addEventListener","removeEventListener","ClickAwayAncestorContext","ClickAwayProvider","parentRef","parentContext","currentContext","useMemo","context","addRefs","newChildrenRefs","push","useRef","displayName","PortalContext","container","body","PortalProvider","Portal","enabled","init","useLayoutEffect","teardown","_Fragment","createPortal"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASO,MAAMA,oBAAoB,gBAAGC,cAAK,CAACC,aAAa,CAA4B;AAAEC,EAAAA,KAAK,EAAE,IAAA;AAAK,CAAC,CAAC,CAAA;AAMnG;AACA;AACA;AACA;AACO,SAASC,qBAAqBA,CAAAC,IAAA,EAAqD;EAAA,IAApD;AAAEC,MAAAA,QAAAA;AAA+C,KAAC,GAAAD,IAAA;AAAnCE,IAAAA,KAAK,GAAAC,wBAAA,CAAAH,IAAA,EAAAI,SAAA,CAAA,CAAA;AACtD,EAAA,oBAAOC,GAAA,CAACV,oBAAoB,CAACW,QAAQ,EAAA;AAACJ,IAAAA,KAAK,EAAEA,KAAM;AAAAD,IAAAA,QAAA,EAAEA,QAAAA;AAAQ,GAAgC,CAAC,CAAA;AAClG,CAAA;;AAEA;AACA;AACA;AACO,SAASM,uBAAuBA,GAA8B;EACjE,OAAOC,UAAU,CAACb,oBAAoB,CAAC,CAAA;AAC3C;;ACtBA,MAAMc,WAAW,GAAG,CAAC,WAAW,EAAE,YAAY,CAAC,CAAA;AAE/C,SAASC,WAAWA,CAACC,OAAsB,EAAEC,IAAmC,EAAW;AACvF;EACA,OAAO,CAACA,IAAI,CAACC,IAAI,CAAEC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AOb,OAAO,KAAPA,IAAAA,IAAAA,OAAO,KAAPA,KAAAA,CAAAA,GAAAA,KAAAA,CAAAA,GAAAA,OAAO,CAAEc,QAAQ,CAAA;AAC5B,GAAC,EAAE,CAACd,OAAO,KAAA,IAAA,IAAPA,OAAO,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAPA,OAAO,CAAEc,QAAQ,EAAEH,OAAO,CAAC,CAAC,CAAA;EAEhC,IAAI,EAACX,OAAO,KAAPA,IAAAA,IAAAA,OAAO,eAAPA,OAAO,CAAEO,SAAS,CAAE,EAAA;IACrB,oBAAO5C,GAAA,CAAAoD,QAAA,EAAA;AAAAxD,MAAAA,QAAA,EAAGA,QAAAA;AAAQ,KAAG,CAAC,CAAA;AAC1B,GAAA;AACA,EAAA,oBAAOyD,YAAY,CAACzD,QAAQ,EAAEyC,OAAO,CAACO,SAAS,CAAC,CAAA;AACpD;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/utils/disabled/DisabledStateContext.tsx","../../src/hooks/useClickAway.tsx","../../src/utils/ClickAwayProvider/ClickAwayProvider.tsx","../../src/utils/Portal/PortalProvider.tsx","../../src/utils/Portal/Portal.tsx"],"sourcesContent":["import React, { useContext } from 'react';\n\n/** Disable state */\ntype DisabledStateContextValue =\n | {\n state: 'disabled';\n }\n | { state: undefined | null };\n\nexport const DisabledStateContext = React.createContext<DisabledStateContextValue>({ state: null });\n\nexport type DisabledStateProviderProps = DisabledStateContextValue & {\n children: React.ReactNode;\n};\n\n/**\n * Disabled state provider.\n * All nested LumX Design System components inherit this disabled state.\n */\nexport function DisabledStateProvider({ children, ...value }: DisabledStateProviderProps) {\n return <DisabledStateContext.Provider value={value}>{children}</DisabledStateContext.Provider>;\n}\n\n/**\n * Get DisabledState context value\n */\nexport function useDisabledStateContext(): DisabledStateContextValue {\n return useContext(DisabledStateContext);\n}\n","import { RefObject, useEffect } from 'react';\n\nimport { Falsy } from '@lumx/react/utils/type';\n\nimport isEmpty from 'lodash/isEmpty';\n\nconst EVENT_TYPES = ['mousedown', 'touchstart'];\n\nfunction isClickAway(targets: HTMLElement[], refs: Array<RefObject<HTMLElement>>): boolean {\n // The targets elements are not contained in any of the listed element references.\n return !refs.some((ref) => targets.some((target) => ref?.current?.contains(target)));\n}\n\nexport interface ClickAwayParameters {\n /**\n * A callback function to call when the user clicks away from the elements.\n */\n callback: EventListener | Falsy;\n /**\n * Elements considered within the click away context (clicking outside them will trigger the click away callback).\n */\n childrenRefs: RefObject<Array<RefObject<HTMLElement>>>;\n}\n\n/**\n * Listen to clicks away from the given elements and callback the passed in function.\n *\n * Warning: If you need to detect click away on nested React portals, please use the `ClickAwayProvider` component.\n */\nexport function useClickAway({ callback, childrenRefs }: ClickAwayParameters): void {\n useEffect(() => {\n const { current: currentRefs } = childrenRefs;\n if (!callback || !currentRefs || isEmpty(currentRefs)) {\n return undefined;\n }\n const listener: EventListener = (evt) => {\n const targets = [evt.composedPath?.()[0], evt.target] as HTMLElement[];\n if (isClickAway(targets, currentRefs)) {\n callback(evt);\n }\n };\n\n EVENT_TYPES.forEach((evtType) => document.addEventListener(evtType, listener));\n return () => {\n EVENT_TYPES.forEach((evtType) => document.removeEventListener(evtType, listener));\n };\n }, [callback, childrenRefs]);\n}\n","import { createContext, RefObject, useContext, useEffect, useMemo, useRef } from 'react';\nimport { ClickAwayParameters, useClickAway } from '@lumx/react/hooks/useClickAway';\n\ninterface ContextValue {\n childrenRefs: Array<RefObject<HTMLElement>>;\n addRefs(...newChildrenRefs: Array<RefObject<HTMLElement>>): void;\n}\n\nconst ClickAwayAncestorContext = createContext<ContextValue | null>(null);\n\ninterface ClickAwayProviderProps extends ClickAwayParameters {\n /**\n * (Optional) Element that should be considered as part of the parent\n */\n parentRef?: RefObject<HTMLElement>;\n /**\n * Children\n */\n children?: React.ReactNode;\n}\n\n/**\n * Component combining the `useClickAway` hook with a React context to hook into the React component tree and make sure\n * we take into account both the DOM tree and the React tree to detect click away.\n *\n * @return the react component.\n */\nexport const ClickAwayProvider: React.FC<ClickAwayProviderProps> = ({\n children,\n callback,\n childrenRefs,\n parentRef,\n}) => {\n const parentContext = useContext(ClickAwayAncestorContext);\n const currentContext = useMemo(() => {\n const context: ContextValue = {\n childrenRefs: [],\n /**\n * Add element refs to the current context and propagate to the parent context.\n */\n addRefs(...newChildrenRefs) {\n // Add element refs that should be considered as inside the click away context.\n context.childrenRefs.push(...newChildrenRefs);\n\n if (parentContext) {\n // Also add then to the parent context\n parentContext.addRefs(...newChildrenRefs);\n if (parentRef) {\n // The parent element is also considered as inside the parent click away context but not inside the current context\n parentContext.addRefs(parentRef);\n }\n }\n },\n };\n return context;\n }, [parentContext, parentRef]);\n\n useEffect(() => {\n const { current: currentRefs } = childrenRefs;\n if (!currentRefs) {\n return;\n }\n currentContext.addRefs(...currentRefs);\n }, [currentContext, childrenRefs]);\n\n useClickAway({ callback, childrenRefs: useRef(currentContext.childrenRefs) });\n return <ClickAwayAncestorContext.Provider value={currentContext}>{children}</ClickAwayAncestorContext.Provider>;\n};\nClickAwayProvider.displayName = 'ClickAwayProvider';\n","import React from 'react';\n\ntype Container = DocumentFragment | Element;\n\n/**\n * Portal initializing function.\n * If it does not provide a container, the Portal children will render in classic React tree and not in a portal.\n */\nexport type PortalInit = () => {\n container?: Container;\n teardown?: () => void;\n};\n\nexport const PortalContext = React.createContext<PortalInit>(() => ({ container: document.body }));\n\nexport interface PortalProviderProps {\n children?: React.ReactNode;\n value: PortalInit;\n}\n\n/**\n * Customize where <Portal> wrapped elements render (tooltip, popover, dialog, etc.)\n */\nexport const PortalProvider: React.FC<PortalProviderProps> = PortalContext.Provider;\n","import React from 'react';\nimport { createPortal } from 'react-dom';\nimport { PortalContext } from './PortalProvider';\n\nexport interface PortalProps {\n enabled?: boolean;\n children: React.ReactNode;\n}\n\n/**\n * Render children in a portal outside the current DOM position\n * (defaults to `document.body` but can be customized with the PortalContextProvider)\n */\nexport const Portal: React.FC<PortalProps> = ({ children, enabled = true }) => {\n const init = React.useContext(PortalContext);\n const context = React.useMemo(\n () => {\n return enabled ? init() : null;\n },\n // Only update on 'enabled'\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [enabled],\n );\n\n React.useLayoutEffect(() => {\n return context?.teardown;\n }, [context?.teardown, enabled]);\n\n if (!context?.container) {\n return <>{children}</>;\n }\n return createPortal(children, context.container);\n};\n"],"names":["DisabledStateContext","React","createContext","state","DisabledStateProvider","_ref","children","value","_objectWithoutProperties","_excluded","_jsx","Provider","useDisabledStateContext","useContext","EVENT_TYPES","isClickAway","targets","refs","some","ref","target","_ref$current","current","contains","useClickAway","callback","childrenRefs","useEffect","currentRefs","isEmpty","undefined","listener","evt","_evt$composedPath","composedPath","call","forEach","evtType","document","addEventListener","removeEventListener","ClickAwayAncestorContext","ClickAwayProvider","parentRef","parentContext","currentContext","useMemo","context","addRefs","newChildrenRefs","push","useRef","displayName","PortalContext","container","body","PortalProvider","Portal","enabled","init","useLayoutEffect","teardown","_Fragment","createPortal"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASO,MAAMA,oBAAoB,gBAAGC,cAAK,CAACC,aAAa,CAA4B;AAAEC,EAAAA,KAAK,EAAE,IAAA;AAAK,CAAC,CAAC,CAAA;AAMnG;AACA;AACA;AACA;AACO,SAASC,qBAAqBA,CAAAC,IAAA,EAAqD;EAAA,IAApD;AAAEC,MAAAA,QAAAA;AAA+C,KAAC,GAAAD,IAAA;AAAnCE,IAAAA,KAAK,GAAAC,wBAAA,CAAAH,IAAA,EAAAI,SAAA,CAAA,CAAA;AACtD,EAAA,oBAAOC,GAAA,CAACV,oBAAoB,CAACW,QAAQ,EAAA;AAACJ,IAAAA,KAAK,EAAEA,KAAM;AAAAD,IAAAA,QAAA,EAAEA,QAAAA;AAAQ,GAAgC,CAAC,CAAA;AAClG,CAAA;;AAEA;AACA;AACA;AACO,SAASM,uBAAuBA,GAA8B;EACjE,OA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,GAAG9C,cAAK,CAAC6C,OAAO,CACzB,MAAM;AACF,IAAA,OAAOY,OAAO,GAAGC,IAAI,EAAE,GAAG,IAAI,CAAA;GACjC;AACD;AACA;EACA,CAACD,OAAO,CACZ,CAAC,CAAA;EAEDzD,cAAK,CAAC2D,eAAe,CAAC,MAAM;AACxB,IAAA,OAAOb,OAAO,KAAPA,IAAAA,IAAAA,OAAO,KAAPA,KAAAA,CAAAA,GAAAA,KAAAA,CAAAA,GAAAA,OAAO,CAAEc,QAAQ,CAAA;AAC5B,GAAC,EAAE,CAACd,OAAO,KAAA,IAAA,IAAPA,OAAO,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAPA,OAAO,CAAEc,QAAQ,EAAEH,OAAO,CAAC,CAAC,CAAA;EAEhC,IAAI,EAACX,OAAO,KAAPA,IAAAA,IAAAA,OAAO,eAAPA,OAAO,CAAEO,SAAS,CAAE,EAAA;IACrB,oBAAO5C,GAAA,CAAAoD,QAAA,EAAA;AAAAxD,MAAAA,QAAA,EAAGA,QAAAA;AAAQ,KAAG,CAAC,CAAA;AAC1B,GAAA;AACA,EAAA,oBAAOyD,YAAY,CAACzD,QAAQ,EAAEyC,OAAO,CAACO,SAAS,CAAC,CAAA;AACpD;;;;"}
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { F as Falsy } from './_internal/Falsy.js';
|
|
2
|
-
import
|
|
2
|
+
import * as React$1 from 'react';
|
|
3
|
+
import React__default, { Ref, ReactElement, ReactNode, SyntheticEvent, MouseEventHandler, KeyboardEventHandler, AriaAttributes, DetailedHTMLProps, ButtonHTMLAttributes, InputHTMLAttributes, RefObject, ImgHTMLAttributes, CSSProperties, SetStateAction, Key, ElementType } from 'react';
|
|
3
4
|
|
|
4
5
|
/** Get types of the values of a record. */
|
|
5
6
|
type ValueOf<T extends Record<any, any>> = T[keyof T];
|
|
@@ -371,10 +372,14 @@ type Comp<P, T = HTMLElement> = {
|
|
|
371
372
|
* @example ComponentRef<'div'> => React.Ref<HTMLDivElement>
|
|
372
373
|
* @example ComponentRef<Button> => React.Ref<HTMLButtonElement
|
|
373
374
|
*/
|
|
374
|
-
type ComponentRef<C> = C extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[C]['ref'] : C extends Comp<any, infer T> ?
|
|
375
|
+
type ComponentRef<C> = C extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[C]['ref'] : C extends Comp<any, infer T> ? React__default.Ref<T> : C extends React__default.JSXElementConstructor<{
|
|
375
376
|
ref?: infer R;
|
|
376
377
|
}> ? R : never;
|
|
377
378
|
|
|
379
|
+
type HasRequiredLinkHref<E> = E extends 'a' ? {
|
|
380
|
+
href: string;
|
|
381
|
+
} : Record<string, unknown>;
|
|
382
|
+
|
|
378
383
|
interface AlertDialogProps extends Omit<DialogProps, 'header' | 'footer'> {
|
|
379
384
|
/** Message variant. */
|
|
380
385
|
kind?: Kind;
|
|
@@ -396,7 +401,7 @@ interface AlertDialogProps extends Omit<DialogProps, 'header' | 'footer'> {
|
|
|
396
401
|
/**
|
|
397
402
|
* Children
|
|
398
403
|
*/
|
|
399
|
-
children?:
|
|
404
|
+
children?: React__default.ReactNode;
|
|
400
405
|
}
|
|
401
406
|
/**
|
|
402
407
|
* AlertDialog component.
|
|
@@ -788,7 +793,7 @@ interface CheckboxProps extends GenericProps, HasTheme, HasAriaDisabled {
|
|
|
788
793
|
/** Native input id property. */
|
|
789
794
|
id?: string;
|
|
790
795
|
/** Native input ref. */
|
|
791
|
-
inputRef?:
|
|
796
|
+
inputRef?: React__default.Ref<HTMLInputElement>;
|
|
792
797
|
/** Whether it is checked or not or intermediate. */
|
|
793
798
|
isChecked?: boolean | 'intermediate';
|
|
794
799
|
/** Whether the component is disabled or not. */
|
|
@@ -1066,7 +1071,7 @@ interface DialogProps extends GenericProps {
|
|
|
1066
1071
|
/** whether to disable the scroll on the body or not */
|
|
1067
1072
|
disableBodyScroll?: boolean;
|
|
1068
1073
|
/** Children */
|
|
1069
|
-
children?:
|
|
1074
|
+
children?: React__default.ReactNode;
|
|
1070
1075
|
}
|
|
1071
1076
|
type DialogSizes = Extract<Size, 'tiny' | 'regular' | 'big' | 'huge'>;
|
|
1072
1077
|
/**
|
|
@@ -1305,15 +1310,15 @@ interface ExpansionPanelProps extends GenericProps, HasCloseMode, HasTheme {
|
|
|
1305
1310
|
/** Label text (overwritten if a `<header>` is provided in the children). */
|
|
1306
1311
|
label?: string;
|
|
1307
1312
|
/** On open callback. */
|
|
1308
|
-
onOpen?: (event:
|
|
1313
|
+
onOpen?: (event: React__default.MouseEvent) => void;
|
|
1309
1314
|
/** On close callback. */
|
|
1310
|
-
onClose?: (event:
|
|
1315
|
+
onClose?: (event: React__default.MouseEvent) => void;
|
|
1311
1316
|
/** Props to pass to the toggle button (minus those already set by the ExpansionPanel props). */
|
|
1312
1317
|
toggleButtonProps: Pick<IconButtonProps, 'label'> & Omit<IconButtonProps, 'label' | 'onClick' | 'icon' | 'emphasis' | 'color'>;
|
|
1313
1318
|
/** On toggle open or close callback. */
|
|
1314
|
-
onToggleOpen?(shouldOpen: boolean, event:
|
|
1319
|
+
onToggleOpen?(shouldOpen: boolean, event: React__default.MouseEvent): void;
|
|
1315
1320
|
/** Children */
|
|
1316
|
-
children?:
|
|
1321
|
+
children?: React__default.ReactNode;
|
|
1317
1322
|
}
|
|
1318
1323
|
/**
|
|
1319
1324
|
* ExpansionPanel component.
|
|
@@ -1693,7 +1698,7 @@ type FocusPoint = {
|
|
|
1693
1698
|
* https://github.com/typescript-cheatsheets/react-typescript-cheatsheet/blob/master/ADVANCED.md#adding-non-standard-attributes
|
|
1694
1699
|
*/
|
|
1695
1700
|
declare module 'react' {
|
|
1696
|
-
interface ImgHTMLAttributes<T> extends
|
|
1701
|
+
interface ImgHTMLAttributes<T> extends React__default.HTMLAttributes<T> {
|
|
1697
1702
|
loading?: 'eager' | 'lazy';
|
|
1698
1703
|
}
|
|
1699
1704
|
}
|
|
@@ -1759,7 +1764,7 @@ interface ThumbnailProps extends GenericProps, HasTheme {
|
|
|
1759
1764
|
/** Image loading mode. */
|
|
1760
1765
|
loading?: ImgHTMLProps['loading'];
|
|
1761
1766
|
/** Ref of an existing placeholder image to display while loading. */
|
|
1762
|
-
loadingPlaceholderImageRef?:
|
|
1767
|
+
loadingPlaceholderImageRef?: React__default.RefObject<HTMLImageElement>;
|
|
1763
1768
|
/** On click callback. */
|
|
1764
1769
|
onClick?: MouseEventHandler<HTMLDivElement>;
|
|
1765
1770
|
/** On key press callback. */
|
|
@@ -1767,7 +1772,7 @@ interface ThumbnailProps extends GenericProps, HasTheme {
|
|
|
1767
1772
|
/** Variant of the component. */
|
|
1768
1773
|
variant?: ThumbnailVariant;
|
|
1769
1774
|
/** Props to pass to the link wrapping the thumbnail. */
|
|
1770
|
-
linkProps?:
|
|
1775
|
+
linkProps?: React__default.DetailedHTMLProps<React__default.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>;
|
|
1771
1776
|
/** Custom react component for the link (can be used to inject react router Link). */
|
|
1772
1777
|
linkAs?: 'a' | any;
|
|
1773
1778
|
}
|
|
@@ -1884,8 +1889,8 @@ declare function useImageLightbox<P extends Partial<ImageLightboxProps>>(props:
|
|
|
1884
1889
|
* @param index Provide an index to choose which image to display when the image lightbox opens.
|
|
1885
1890
|
* */
|
|
1886
1891
|
getTriggerProps: (options?: TriggerOptions) => {
|
|
1887
|
-
onClick:
|
|
1888
|
-
ref:
|
|
1892
|
+
onClick: React__default.MouseEventHandler;
|
|
1893
|
+
ref: React__default.Ref<any>;
|
|
1889
1894
|
};
|
|
1890
1895
|
/** Props to forward to the ImageLightbox */
|
|
1891
1896
|
imageLightboxProps: ManagedProps & P;
|
|
@@ -2260,15 +2265,11 @@ type BaseNavigationItemProps = {
|
|
|
2260
2265
|
/** Mark as the current page link */
|
|
2261
2266
|
isCurrentPage?: boolean;
|
|
2262
2267
|
};
|
|
2263
|
-
|
|
2264
|
-
type RequiredLinkHref<E> = E extends 'a' ? {
|
|
2265
|
-
href: string;
|
|
2266
|
-
} : Record<string, unknown>;
|
|
2267
|
-
declare const NavigationItem: (<E extends React.ElementType = "a">(props: React.PropsWithoutRef<React.ComponentProps<E>> & {
|
|
2268
|
+
declare const NavigationItem: (<E extends ElementType = "a">(props: React$1.PropsWithoutRef<React$1.ComponentProps<E>> & {
|
|
2268
2269
|
as?: E | undefined;
|
|
2269
|
-
} & HasTheme & HasClassName & BaseNavigationItemProps &
|
|
2270
|
+
} & HasTheme & HasClassName & BaseNavigationItemProps & HasRequiredLinkHref<E> & React$1.ComponentProps<E> & {
|
|
2270
2271
|
ref?: ComponentRef<E> | undefined;
|
|
2271
|
-
}) => React.JSX.Element) & {
|
|
2272
|
+
}) => React$1.JSX.Element) & {
|
|
2272
2273
|
displayName: string;
|
|
2273
2274
|
className: string;
|
|
2274
2275
|
};
|
|
@@ -2845,7 +2846,7 @@ interface SlideshowProps extends GenericProps, Pick<SlidesProps, 'autoPlay' | 's
|
|
|
2845
2846
|
/** Callback when slide changes */
|
|
2846
2847
|
onChange?(index: number): void;
|
|
2847
2848
|
/** Children */
|
|
2848
|
-
children?:
|
|
2849
|
+
children?: React__default.ReactNode;
|
|
2849
2850
|
}
|
|
2850
2851
|
/**
|
|
2851
2852
|
* Slideshow component.
|
|
@@ -2948,7 +2949,7 @@ interface SlideshowControlsProps extends GenericProps, HasTheme {
|
|
|
2948
2949
|
/** Props to pass to the previous button (minus those already set by the SlideshowControls props). */
|
|
2949
2950
|
previousButtonProps: Pick<IconButtonProps, 'label'> & Omit<IconButtonProps, 'label' | 'onClick' | 'icon' | 'emphasis' | 'color'>;
|
|
2950
2951
|
/** Props to pass to the pagination wrapper */
|
|
2951
|
-
paginationProps?: Omit<
|
|
2952
|
+
paginationProps?: Omit<React__default.HTMLAttributes<HTMLDivElement>, 'className' | 'style' | 'role'>;
|
|
2952
2953
|
/** Number of slides. */
|
|
2953
2954
|
slidesCount: number;
|
|
2954
2955
|
/** On next button click callback. */
|
|
@@ -2967,7 +2968,7 @@ interface SlideshowControlsProps extends GenericProps, HasTheme {
|
|
|
2967
2968
|
/**
|
|
2968
2969
|
* function to be executed in order to retrieve the props for a pagination item.
|
|
2969
2970
|
*/
|
|
2970
|
-
paginationItemProps?: (itemIndex: number) =>
|
|
2971
|
+
paginationItemProps?: (itemIndex: number) => React__default.HTMLAttributes<HTMLButtonElement> & {
|
|
2971
2972
|
label?: string;
|
|
2972
2973
|
};
|
|
2973
2974
|
/** Props to pass to the lay button (minus those already set by the SlideshowControls props). */
|
|
@@ -3000,7 +3001,7 @@ interface SlidesProps extends GenericProps, HasTheme {
|
|
|
3000
3001
|
/** callback to change whether the slideshow is playing or not */
|
|
3001
3002
|
toggleAutoPlay: () => void;
|
|
3002
3003
|
/** component to be rendered after the slides */
|
|
3003
|
-
afterSlides?:
|
|
3004
|
+
afterSlides?: React__default.ReactNode;
|
|
3004
3005
|
/** Whether the slides have controls linked */
|
|
3005
3006
|
hasControls?: boolean;
|
|
3006
3007
|
/**
|
|
@@ -3009,7 +3010,7 @@ interface SlidesProps extends GenericProps, HasTheme {
|
|
|
3009
3010
|
* */
|
|
3010
3011
|
slideGroupLabel?: (groupPosition: number, groupTotal: number) => string;
|
|
3011
3012
|
/** Children */
|
|
3012
|
-
children?:
|
|
3013
|
+
children?: React__default.ReactNode;
|
|
3013
3014
|
}
|
|
3014
3015
|
/**
|
|
3015
3016
|
* Slides component.
|
|
@@ -3407,8 +3408,8 @@ type UploaderSize = Extract<Size, 'xl' | 'xxl'>;
|
|
|
3407
3408
|
/**
|
|
3408
3409
|
* Extend native HTML input props with specialized `onChange` providing the a `File` array.
|
|
3409
3410
|
*/
|
|
3410
|
-
interface FileInputProps extends Omit<
|
|
3411
|
-
onChange(files: File[], evt:
|
|
3411
|
+
interface FileInputProps extends Omit<React__default.ComponentProps<'input'>, 'onChange'> {
|
|
3412
|
+
onChange(files: File[], evt: React__default.ChangeEvent<HTMLInputElement>): void;
|
|
3412
3413
|
}
|
|
3413
3414
|
/**
|
|
3414
3415
|
* Defines the props of the component.
|
|
@@ -3453,13 +3454,13 @@ interface UserBlockProps extends GenericProps, HasTheme {
|
|
|
3453
3454
|
/** Additional fields used to describe the user. */
|
|
3454
3455
|
fields?: string[];
|
|
3455
3456
|
/** Props to pass to the link wrapping the avatar thumbnail. */
|
|
3456
|
-
linkProps?:
|
|
3457
|
+
linkProps?: React__default.DetailedHTMLProps<React__default.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>;
|
|
3457
3458
|
/** Custom react component for the link (can be used to inject react router Link). */
|
|
3458
3459
|
linkAs?: 'a' | any;
|
|
3459
3460
|
/** Multiple action toolbar content. */
|
|
3460
3461
|
multipleActions?: ReactNode;
|
|
3461
3462
|
/** User name. */
|
|
3462
|
-
name?:
|
|
3463
|
+
name?: React__default.ReactNode;
|
|
3463
3464
|
/** Props to pass to the name block. */
|
|
3464
3465
|
nameProps?: GenericProps;
|
|
3465
3466
|
/** Orientation. */
|
|
@@ -3475,9 +3476,9 @@ interface UserBlockProps extends GenericProps, HasTheme {
|
|
|
3475
3476
|
/** On mouse leave callback. */
|
|
3476
3477
|
onMouseLeave?(): void;
|
|
3477
3478
|
/** Display additional fields below the original name and fields */
|
|
3478
|
-
additionalFields?:
|
|
3479
|
+
additionalFields?: React__default.ReactNode;
|
|
3479
3480
|
/** Display an additional element after the entire component. (to the right if orientation is horizontal, at the bottom if orientation is vertical) */
|
|
3480
|
-
after?:
|
|
3481
|
+
after?: React__default.ReactNode;
|
|
3481
3482
|
}
|
|
3482
3483
|
/**
|
|
3483
3484
|
* UserBlock component.
|
|
@@ -3490,9 +3491,9 @@ declare const UserBlock: Comp<UserBlockProps, HTMLDivElement>;
|
|
|
3490
3491
|
|
|
3491
3492
|
type ThemeContextValue = Theme | undefined;
|
|
3492
3493
|
/** Provide a theme context to all children. */
|
|
3493
|
-
declare const ThemeProvider:
|
|
3494
|
+
declare const ThemeProvider: React__default.FC<{
|
|
3494
3495
|
value: ThemeContextValue;
|
|
3495
|
-
children?:
|
|
3496
|
+
children?: React__default.ReactNode;
|
|
3496
3497
|
}>;
|
|
3497
3498
|
/** Get the theme in the current context. */
|
|
3498
3499
|
declare function useTheme(): ThemeContextValue;
|