@lumx/react 3.20.1-alpha.3 → 3.20.1-alpha.5
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 +34 -35
- package/index.js +215 -212
- package/index.js.map +1 -1
- package/package.json +12 -10
- package/src/components/alert-dialog/AlertDialog.stories.tsx +1 -1
- package/src/components/alert-dialog/AlertDialog.test.tsx +4 -3
- package/src/components/autocomplete/Autocomplete.stories.tsx +1 -1
- package/src/components/autocomplete/Autocomplete.test.tsx +5 -3
- package/src/components/autocomplete/Autocomplete.tsx +1 -1
- package/src/components/autocomplete/AutocompleteMultiple.stories.tsx +1 -1
- package/src/components/autocomplete/AutocompleteMultiple.test.tsx +2 -0
- package/src/components/autocomplete/AutocompleteMultiple.tsx +1 -1
- package/src/components/avatar/Avatar.stories.tsx +2 -0
- package/src/components/avatar/Avatar.test.tsx +2 -0
- package/src/components/avatar/Avatar.tsx +1 -1
- package/src/components/badge/Badge.stories.tsx +1 -0
- package/src/components/badge/Badge.test.tsx +2 -0
- package/src/components/badge/Badge.tsx +1 -1
- package/src/components/badge/BadgeWrapper.stories.tsx +1 -0
- package/src/components/badge/BadgeWrapper.test.tsx +2 -0
- package/src/components/badge/BadgeWrapper.tsx +1 -1
- package/src/components/button/Button.stories.tsx +1 -0
- package/src/components/button/Button.test.tsx +11 -9
- package/src/components/button/Button.tsx +2 -0
- package/src/components/button/ButtonGroup.stories.tsx +2 -0
- package/src/components/button/ButtonGroup.test.tsx +2 -0
- package/src/components/button/ButtonGroup.tsx +2 -0
- package/src/components/button/ButtonRoot.tsx +37 -7
- package/src/components/button/IconButton.test.tsx +2 -0
- package/src/components/button/IconButton.tsx +2 -0
- package/src/components/checkbox/Checkbox.test.tsx +5 -3
- package/src/components/chip/Chip.stories.tsx +2 -0
- package/src/components/chip/Chip.test.tsx +19 -19
- package/src/components/chip/Chip.tsx +1 -1
- package/src/components/chip/ChipGroup.stories.tsx +2 -0
- package/src/components/chip/ChipGroup.test.tsx +2 -0
- package/src/components/chip/ChipGroup.tsx +1 -1
- package/src/components/comment-block/CommentBlock.stories.tsx +1 -0
- package/src/components/comment-block/CommentBlock.test.tsx +1 -0
- package/src/components/comment-block/CommentBlock.tsx +1 -1
- package/src/components/date-picker/DatePicker.test.tsx +5 -3
- package/src/components/date-picker/DatePicker.tsx +1 -1
- package/src/components/date-picker/DatePickerControlled.test.tsx +8 -6
- package/src/components/date-picker/DatePickerField.test.tsx +5 -3
- package/src/components/dialog/Dialog.test.tsx +6 -4
- package/src/components/divider/Divider.test.tsx +2 -0
- package/src/components/divider/Divider.tsx +2 -0
- package/src/components/drag-handle/DragHandle.test.tsx +2 -0
- package/src/components/drag-handle/DragHandle.tsx +2 -0
- 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 +7 -6
- package/src/components/flag/Flag.test.tsx +2 -0
- package/src/components/flag/Flag.tsx +2 -0
- package/src/components/flex-box/FlexBox.stories.tsx +2 -0
- package/src/components/flex-box/FlexBox.test.tsx +1 -0
- 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 +2 -0
- package/src/components/grid/GridItem.tsx +2 -0
- package/src/components/grid-column/GridColumn.stories.tsx +1 -0
- package/src/components/grid-column/GridColumn.test.jsx +2 -0
- package/src/components/grid-column/GridColumn.tsx +1 -1
- package/src/components/heading/Heading.stories.tsx +1 -0
- package/src/components/heading/Heading.test.tsx +2 -0
- package/src/components/heading/Heading.tsx +2 -0
- package/src/components/heading/HeadingLevelProvider.tsx +1 -1
- package/src/components/icon/Icon.stories.tsx +4 -30
- package/src/components/icon/Icon.test.tsx +4 -85
- package/src/components/icon/Icon.tsx +2 -0
- package/src/components/image-block/ImageBlock.stories.tsx +2 -0
- package/src/components/image-block/ImageBlock.test.tsx +1 -0
- 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 +1 -0
- package/src/components/image-lightbox/ImageLightbox.test.tsx +9 -11
- package/src/components/image-lightbox/types.ts +2 -0
- package/src/components/inline-list/InlineList.stories.tsx +1 -0
- package/src/components/inline-list/InlineList.test.tsx +2 -0
- package/src/components/inline-list/InlineList.tsx +1 -1
- package/src/components/input-helper/InputHelper.test.tsx +2 -0
- package/src/components/input-helper/InputHelper.tsx +1 -1
- package/src/components/input-label/InputLabel.stories.tsx +2 -0
- package/src/components/input-label/InputLabel.test.tsx +2 -0
- package/src/components/input-label/InputLabel.tsx +1 -1
- package/src/components/lightbox/Lightbox.test.tsx +2 -0
- package/src/components/lightbox/Lightbox.tsx +1 -1
- package/src/components/link/Link.stories.tsx +1 -0
- package/src/components/link/Link.test.tsx +13 -13
- package/src/components/link/Link.tsx +22 -9
- package/src/components/link-preview/LinkPreview.test.tsx +2 -0
- package/src/components/link-preview/LinkPreview.tsx +2 -0
- package/src/components/list/List.stories.tsx +1 -1
- package/src/components/list/List.test.tsx +2 -0
- package/src/components/list/List.tsx +1 -1
- package/src/components/list/ListDivider.test.tsx +2 -0
- package/src/components/list/ListDivider.tsx +2 -0
- package/src/components/list/ListItem.test.tsx +7 -5
- package/src/components/list/ListItem.tsx +1 -1
- package/src/components/list/ListSubheader.test.tsx +2 -0
- package/src/components/list/ListSubheader.tsx +1 -1
- package/src/components/message/Message.test.tsx +2 -1
- package/src/components/message/Message.tsx +1 -1
- package/src/components/mosaic/Mosaic.test.tsx +5 -3
- package/src/components/mosaic/Mosaic.tsx +1 -1
- package/src/components/navigation/Navigation.stories.tsx +2 -0
- package/src/components/navigation/Navigation.test.tsx +2 -0
- package/src/components/navigation/Navigation.tsx +2 -0
- package/src/components/navigation/NavigationItem.test.tsx +2 -0
- package/src/components/navigation/NavigationItem.tsx +11 -7
- package/src/components/navigation/NavigationSection.test.tsx +2 -0
- package/src/components/navigation/NavigationSection.tsx +4 -5
- package/src/components/notification/Notification.test.tsx +5 -4
- package/src/components/notification/Notification.tsx +1 -1
- package/src/components/popover/Popover.test.tsx +2 -0
- package/src/components/popover/Popover.tsx +1 -1
- package/src/components/popover/usePopoverStyle.tsx +1 -1
- package/src/components/popover-dialog/PopoverDialog.test.tsx +2 -1
- package/src/components/popover-dialog/PopoverDialog.tsx +2 -0
- package/src/components/post-block/PostBlock.test.tsx +2 -0
- package/src/components/post-block/PostBlock.tsx +1 -1
- package/src/components/progress/Progress.tsx +2 -0
- package/src/components/progress/ProgressCircular.stories.tsx +1 -0
- package/src/components/progress/ProgressCircular.test.tsx +2 -0
- package/src/components/progress/ProgressCircular.tsx +2 -0
- package/src/components/progress/ProgressLinear.test.tsx +2 -0
- package/src/components/progress/ProgressLinear.tsx +2 -0
- package/src/components/progress-tracker/ProgressTracker.stories.tsx +1 -1
- package/src/components/progress-tracker/ProgressTracker.test.tsx +2 -0
- package/src/components/progress-tracker/ProgressTrackerProvider.test.tsx +2 -0
- package/src/components/progress-tracker/ProgressTrackerProvider.tsx +1 -1
- package/src/components/progress-tracker/ProgressTrackerStep.test.tsx +2 -0
- package/src/components/progress-tracker/ProgressTrackerStep.tsx +1 -1
- package/src/components/progress-tracker/ProgressTrackerStepPanel.test.tsx +2 -0
- package/src/components/progress-tracker/ProgressTrackerStepPanel.tsx +2 -0
- package/src/components/radio-button/RadioButton.test.tsx +5 -3
- 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 +2 -0
- 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 +9 -8
- package/src/components/select/Select.tsx +1 -1
- package/src/components/select/SelectMultiple.stories.tsx +1 -1
- package/src/components/select/SelectMultiple.test.tsx +7 -5
- 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 +2 -0
- package/src/components/side-navigation/SideNavigation.tsx +1 -1
- package/src/components/side-navigation/SideNavigationItem.test.tsx +4 -2
- package/src/components/side-navigation/SideNavigationItem.tsx +28 -23
- package/src/components/skeleton/SkeletonCircle.test.tsx +2 -0
- package/src/components/skeleton/SkeletonCircle.tsx +2 -0
- package/src/components/skeleton/SkeletonRectangle.test.tsx +2 -0
- package/src/components/skeleton/SkeletonRectangle.tsx +2 -0
- package/src/components/skeleton/SkeletonTypography.stories.tsx +2 -0
- package/src/components/skeleton/SkeletonTypography.test.tsx +2 -0
- package/src/components/skeleton/SkeletonTypography.tsx +1 -1
- package/src/components/slider/Slider.test.tsx +3 -1
- package/src/components/slider/Slider.tsx +1 -1
- package/src/components/slideshow/Slideshow.stories.tsx +1 -0
- package/src/components/slideshow/Slideshow.test.tsx +2 -0
- package/src/components/slideshow/SlideshowControls.stories.tsx +2 -0
- package/src/components/slideshow/SlideshowItem.tsx +2 -0
- package/src/components/slideshow/useSlideFocusManagement.tsx +1 -1
- package/src/components/switch/Switch.test.tsx +7 -5
- package/src/components/switch/Switch.tsx +1 -1
- package/src/components/table/Table.test.tsx +2 -0
- package/src/components/table/Table.tsx +2 -0
- package/src/components/table/TableBody.test.tsx +2 -0
- package/src/components/table/TableBody.tsx +2 -0
- package/src/components/table/TableCell.test.tsx +3 -1
- package/src/components/table/TableCell.tsx +2 -0
- package/src/components/table/TableHeader.test.tsx +2 -0
- package/src/components/table/TableHeader.tsx +2 -0
- package/src/components/table/TableRow.test.tsx +2 -0
- package/src/components/table/TableRow.tsx +2 -0
- package/src/components/tabs/Tab.test.tsx +2 -0
- package/src/components/tabs/Tab.tsx +1 -1
- package/src/components/tabs/TabList.test.tsx +2 -0
- package/src/components/tabs/TabPanel.test.tsx +2 -0
- package/src/components/tabs/TabPanel.tsx +2 -0
- package/src/components/tabs/TabProvider.test.tsx +2 -0
- 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 +2 -0
- package/src/components/text/Text.tsx +2 -0
- package/src/components/text-field/TextField.test.tsx +10 -9
- package/src/components/text-field/TextField.tsx +1 -1
- package/src/components/thumbnail/Thumbnail.test.tsx +7 -29
- package/src/components/thumbnail/Thumbnail.tsx +11 -11
- package/src/components/toolbar/Toolbar.tsx +1 -1
- package/src/components/tooltip/Tooltip.stories.tsx +1 -2
- package/src/components/tooltip/Tooltip.test.tsx +8 -14
- package/src/components/uploader/Uploader.test.tsx +4 -2
- package/src/components/user-block/UserBlock.stories.tsx +2 -0
- package/src/components/user-block/UserBlock.test.tsx +3 -1
- package/src/hooks/useId.test.tsx +1 -0
- package/src/hooks/useInfiniteScroll.tsx +1 -1
- package/src/hooks/usePreviousValue.ts +1 -0
- package/src/stories/decorators/withChromaticForceScreenSize.tsx +1 -0
- package/src/stories/decorators/withNestedProps.tsx +1 -0
- package/src/stories/decorators/withThemedBackground.tsx +2 -0
- package/src/stories/decorators/withWrapper.tsx +2 -0
- package/src/stories/utils/CustomLink.tsx +1 -0
- package/src/testing/utils/ThemeSentinel.tsx +1 -0
- package/src/untypped-modules.d.ts +0 -4
- 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 +1 -0
- package/src/utils/Portal/PortalProvider.stories.jsx +1 -0
- package/src/utils/Portal/PortalProvider.test.tsx +2 -1
- package/src/utils/date/getYearDisplayName.test.ts +1 -1
- package/src/utils/disabled/DisabledStateProvider.stories.tsx +2 -0
- package/src/utils/disabled/useDisableStateProps.test.tsx +2 -2
- package/src/utils/react/OnBeforeUnmount.tsx +1 -1
- package/src/utils/react/renderButtonOrLink.tsx +16 -0
- package/src/utils/react/skipRender.tsx +2 -2
- package/src/utils/react/wrapChildrenIconWithSpaces.test.tsx +1 -1
- package/src/utils/type/HasPolymorphicAs.ts +2 -0
- package/src/utils/type/index.ts +0 -1
- package/utils/index.d.ts +6 -6
- package/src/utils/react/RawClickable.test.tsx +0 -153
- package/src/utils/react/RawClickable.tsx +0 -65
- package/src/utils/type/HasRequiredLinkHref.ts +0 -1
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 { 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,G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b,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 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,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,6 +1,5 @@
|
|
|
1
1
|
import { F as Falsy } from './_internal/Falsy.js';
|
|
2
|
-
import
|
|
3
|
-
import React__default, { Ref, ReactElement, ReactNode, SyntheticEvent, MouseEventHandler, KeyboardEventHandler, AriaAttributes, DetailedHTMLProps, ButtonHTMLAttributes, InputHTMLAttributes, RefObject, ImgHTMLAttributes, CSSProperties, SetStateAction, Key, ElementType } from 'react';
|
|
2
|
+
import React, { Ref, ReactElement, ReactNode, SyntheticEvent, MouseEventHandler, KeyboardEventHandler, AriaAttributes, DetailedHTMLProps, ButtonHTMLAttributes, InputHTMLAttributes, RefObject, ImgHTMLAttributes, CSSProperties, SetStateAction, Key } from 'react';
|
|
4
3
|
|
|
5
4
|
/** Get types of the values of a record. */
|
|
6
5
|
type ValueOf<T extends Record<any, any>> = T[keyof T];
|
|
@@ -372,14 +371,10 @@ type Comp<P, T = HTMLElement> = {
|
|
|
372
371
|
* @example ComponentRef<'div'> => React.Ref<HTMLDivElement>
|
|
373
372
|
* @example ComponentRef<Button> => React.Ref<HTMLButtonElement
|
|
374
373
|
*/
|
|
375
|
-
type ComponentRef<C> = C extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[C]['ref'] : C extends Comp<any, infer T> ?
|
|
374
|
+
type ComponentRef<C> = C extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[C]['ref'] : C extends Comp<any, infer T> ? React.Ref<T> : C extends React.JSXElementConstructor<{
|
|
376
375
|
ref?: infer R;
|
|
377
376
|
}> ? R : never;
|
|
378
377
|
|
|
379
|
-
type HasRequiredLinkHref<E> = E extends 'a' ? {
|
|
380
|
-
href: string;
|
|
381
|
-
} : Record<string, unknown>;
|
|
382
|
-
|
|
383
378
|
interface AlertDialogProps extends Omit<DialogProps, 'header' | 'footer'> {
|
|
384
379
|
/** Message variant. */
|
|
385
380
|
kind?: Kind;
|
|
@@ -401,7 +396,7 @@ interface AlertDialogProps extends Omit<DialogProps, 'header' | 'footer'> {
|
|
|
401
396
|
/**
|
|
402
397
|
* Children
|
|
403
398
|
*/
|
|
404
|
-
children?:
|
|
399
|
+
children?: React.ReactNode;
|
|
405
400
|
}
|
|
406
401
|
/**
|
|
407
402
|
* AlertDialog component.
|
|
@@ -793,7 +788,7 @@ interface CheckboxProps extends GenericProps, HasTheme, HasAriaDisabled {
|
|
|
793
788
|
/** Native input id property. */
|
|
794
789
|
id?: string;
|
|
795
790
|
/** Native input ref. */
|
|
796
|
-
inputRef?:
|
|
791
|
+
inputRef?: React.Ref<HTMLInputElement>;
|
|
797
792
|
/** Whether it is checked or not or intermediate. */
|
|
798
793
|
isChecked?: boolean | 'intermediate';
|
|
799
794
|
/** Whether the component is disabled or not. */
|
|
@@ -1071,7 +1066,7 @@ interface DialogProps extends GenericProps {
|
|
|
1071
1066
|
/** whether to disable the scroll on the body or not */
|
|
1072
1067
|
disableBodyScroll?: boolean;
|
|
1073
1068
|
/** Children */
|
|
1074
|
-
children?:
|
|
1069
|
+
children?: React.ReactNode;
|
|
1075
1070
|
}
|
|
1076
1071
|
type DialogSizes = Extract<Size, 'tiny' | 'regular' | 'big' | 'huge'>;
|
|
1077
1072
|
/**
|
|
@@ -1310,15 +1305,15 @@ interface ExpansionPanelProps extends GenericProps, HasCloseMode, HasTheme {
|
|
|
1310
1305
|
/** Label text (overwritten if a `<header>` is provided in the children). */
|
|
1311
1306
|
label?: string;
|
|
1312
1307
|
/** On open callback. */
|
|
1313
|
-
onOpen?: (event:
|
|
1308
|
+
onOpen?: (event: React.MouseEvent) => void;
|
|
1314
1309
|
/** On close callback. */
|
|
1315
|
-
onClose?: (event:
|
|
1310
|
+
onClose?: (event: React.MouseEvent) => void;
|
|
1316
1311
|
/** Props to pass to the toggle button (minus those already set by the ExpansionPanel props). */
|
|
1317
1312
|
toggleButtonProps: Pick<IconButtonProps, 'label'> & Omit<IconButtonProps, 'label' | 'onClick' | 'icon' | 'emphasis' | 'color'>;
|
|
1318
1313
|
/** On toggle open or close callback. */
|
|
1319
|
-
onToggleOpen?(shouldOpen: boolean, event:
|
|
1314
|
+
onToggleOpen?(shouldOpen: boolean, event: React.MouseEvent): void;
|
|
1320
1315
|
/** Children */
|
|
1321
|
-
children?:
|
|
1316
|
+
children?: React.ReactNode;
|
|
1322
1317
|
}
|
|
1323
1318
|
/**
|
|
1324
1319
|
* ExpansionPanel component.
|
|
@@ -1698,7 +1693,7 @@ type FocusPoint = {
|
|
|
1698
1693
|
* https://github.com/typescript-cheatsheets/react-typescript-cheatsheet/blob/master/ADVANCED.md#adding-non-standard-attributes
|
|
1699
1694
|
*/
|
|
1700
1695
|
declare module 'react' {
|
|
1701
|
-
interface ImgHTMLAttributes<T> extends
|
|
1696
|
+
interface ImgHTMLAttributes<T> extends React.HTMLAttributes<T> {
|
|
1702
1697
|
loading?: 'eager' | 'lazy';
|
|
1703
1698
|
}
|
|
1704
1699
|
}
|
|
@@ -1764,7 +1759,7 @@ interface ThumbnailProps extends GenericProps, HasTheme {
|
|
|
1764
1759
|
/** Image loading mode. */
|
|
1765
1760
|
loading?: ImgHTMLProps['loading'];
|
|
1766
1761
|
/** Ref of an existing placeholder image to display while loading. */
|
|
1767
|
-
loadingPlaceholderImageRef?:
|
|
1762
|
+
loadingPlaceholderImageRef?: React.RefObject<HTMLImageElement>;
|
|
1768
1763
|
/** On click callback. */
|
|
1769
1764
|
onClick?: MouseEventHandler<HTMLDivElement>;
|
|
1770
1765
|
/** On key press callback. */
|
|
@@ -1772,7 +1767,7 @@ interface ThumbnailProps extends GenericProps, HasTheme {
|
|
|
1772
1767
|
/** Variant of the component. */
|
|
1773
1768
|
variant?: ThumbnailVariant;
|
|
1774
1769
|
/** Props to pass to the link wrapping the thumbnail. */
|
|
1775
|
-
linkProps?:
|
|
1770
|
+
linkProps?: React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>;
|
|
1776
1771
|
/** Custom react component for the link (can be used to inject react router Link). */
|
|
1777
1772
|
linkAs?: 'a' | any;
|
|
1778
1773
|
}
|
|
@@ -1889,8 +1884,8 @@ declare function useImageLightbox<P extends Partial<ImageLightboxProps>>(props:
|
|
|
1889
1884
|
* @param index Provide an index to choose which image to display when the image lightbox opens.
|
|
1890
1885
|
* */
|
|
1891
1886
|
getTriggerProps: (options?: TriggerOptions) => {
|
|
1892
|
-
onClick:
|
|
1893
|
-
ref:
|
|
1887
|
+
onClick: React.MouseEventHandler;
|
|
1888
|
+
ref: React.Ref<any>;
|
|
1894
1889
|
};
|
|
1895
1890
|
/** Props to forward to the ImageLightbox */
|
|
1896
1891
|
imageLightboxProps: ManagedProps & P;
|
|
@@ -2265,11 +2260,15 @@ type BaseNavigationItemProps = {
|
|
|
2265
2260
|
/** Mark as the current page link */
|
|
2266
2261
|
isCurrentPage?: boolean;
|
|
2267
2262
|
};
|
|
2268
|
-
|
|
2263
|
+
/** Make `href` required when `as` is `a` */
|
|
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>> & {
|
|
2269
2268
|
as?: E | undefined;
|
|
2270
|
-
} & HasTheme & HasClassName & BaseNavigationItemProps &
|
|
2269
|
+
} & HasTheme & HasClassName & BaseNavigationItemProps & RequiredLinkHref<E> & React.ComponentProps<E> & {
|
|
2271
2270
|
ref?: ComponentRef<E> | undefined;
|
|
2272
|
-
}) => React
|
|
2271
|
+
}) => React.JSX.Element) & {
|
|
2273
2272
|
displayName: string;
|
|
2274
2273
|
className: string;
|
|
2275
2274
|
};
|
|
@@ -2846,7 +2845,7 @@ interface SlideshowProps extends GenericProps, Pick<SlidesProps, 'autoPlay' | 's
|
|
|
2846
2845
|
/** Callback when slide changes */
|
|
2847
2846
|
onChange?(index: number): void;
|
|
2848
2847
|
/** Children */
|
|
2849
|
-
children?:
|
|
2848
|
+
children?: React.ReactNode;
|
|
2850
2849
|
}
|
|
2851
2850
|
/**
|
|
2852
2851
|
* Slideshow component.
|
|
@@ -2949,7 +2948,7 @@ interface SlideshowControlsProps extends GenericProps, HasTheme {
|
|
|
2949
2948
|
/** Props to pass to the previous button (minus those already set by the SlideshowControls props). */
|
|
2950
2949
|
previousButtonProps: Pick<IconButtonProps, 'label'> & Omit<IconButtonProps, 'label' | 'onClick' | 'icon' | 'emphasis' | 'color'>;
|
|
2951
2950
|
/** Props to pass to the pagination wrapper */
|
|
2952
|
-
paginationProps?: Omit<
|
|
2951
|
+
paginationProps?: Omit<React.HTMLAttributes<HTMLDivElement>, 'className' | 'style' | 'role'>;
|
|
2953
2952
|
/** Number of slides. */
|
|
2954
2953
|
slidesCount: number;
|
|
2955
2954
|
/** On next button click callback. */
|
|
@@ -2968,7 +2967,7 @@ interface SlideshowControlsProps extends GenericProps, HasTheme {
|
|
|
2968
2967
|
/**
|
|
2969
2968
|
* function to be executed in order to retrieve the props for a pagination item.
|
|
2970
2969
|
*/
|
|
2971
|
-
paginationItemProps?: (itemIndex: number) =>
|
|
2970
|
+
paginationItemProps?: (itemIndex: number) => React.HTMLAttributes<HTMLButtonElement> & {
|
|
2972
2971
|
label?: string;
|
|
2973
2972
|
};
|
|
2974
2973
|
/** Props to pass to the lay button (minus those already set by the SlideshowControls props). */
|
|
@@ -3001,7 +3000,7 @@ interface SlidesProps extends GenericProps, HasTheme {
|
|
|
3001
3000
|
/** callback to change whether the slideshow is playing or not */
|
|
3002
3001
|
toggleAutoPlay: () => void;
|
|
3003
3002
|
/** component to be rendered after the slides */
|
|
3004
|
-
afterSlides?:
|
|
3003
|
+
afterSlides?: React.ReactNode;
|
|
3005
3004
|
/** Whether the slides have controls linked */
|
|
3006
3005
|
hasControls?: boolean;
|
|
3007
3006
|
/**
|
|
@@ -3010,7 +3009,7 @@ interface SlidesProps extends GenericProps, HasTheme {
|
|
|
3010
3009
|
* */
|
|
3011
3010
|
slideGroupLabel?: (groupPosition: number, groupTotal: number) => string;
|
|
3012
3011
|
/** Children */
|
|
3013
|
-
children?:
|
|
3012
|
+
children?: React.ReactNode;
|
|
3014
3013
|
}
|
|
3015
3014
|
/**
|
|
3016
3015
|
* Slides component.
|
|
@@ -3408,8 +3407,8 @@ type UploaderSize = Extract<Size, 'xl' | 'xxl'>;
|
|
|
3408
3407
|
/**
|
|
3409
3408
|
* Extend native HTML input props with specialized `onChange` providing the a `File` array.
|
|
3410
3409
|
*/
|
|
3411
|
-
interface FileInputProps extends Omit<
|
|
3412
|
-
onChange(files: File[], evt:
|
|
3410
|
+
interface FileInputProps extends Omit<React.ComponentProps<'input'>, 'onChange'> {
|
|
3411
|
+
onChange(files: File[], evt: React.ChangeEvent<HTMLInputElement>): void;
|
|
3413
3412
|
}
|
|
3414
3413
|
/**
|
|
3415
3414
|
* Defines the props of the component.
|
|
@@ -3454,13 +3453,13 @@ interface UserBlockProps extends GenericProps, HasTheme {
|
|
|
3454
3453
|
/** Additional fields used to describe the user. */
|
|
3455
3454
|
fields?: string[];
|
|
3456
3455
|
/** Props to pass to the link wrapping the avatar thumbnail. */
|
|
3457
|
-
linkProps?:
|
|
3456
|
+
linkProps?: React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>;
|
|
3458
3457
|
/** Custom react component for the link (can be used to inject react router Link). */
|
|
3459
3458
|
linkAs?: 'a' | any;
|
|
3460
3459
|
/** Multiple action toolbar content. */
|
|
3461
3460
|
multipleActions?: ReactNode;
|
|
3462
3461
|
/** User name. */
|
|
3463
|
-
name?:
|
|
3462
|
+
name?: React.ReactNode;
|
|
3464
3463
|
/** Props to pass to the name block. */
|
|
3465
3464
|
nameProps?: GenericProps;
|
|
3466
3465
|
/** Orientation. */
|
|
@@ -3476,9 +3475,9 @@ interface UserBlockProps extends GenericProps, HasTheme {
|
|
|
3476
3475
|
/** On mouse leave callback. */
|
|
3477
3476
|
onMouseLeave?(): void;
|
|
3478
3477
|
/** Display additional fields below the original name and fields */
|
|
3479
|
-
additionalFields?:
|
|
3478
|
+
additionalFields?: React.ReactNode;
|
|
3480
3479
|
/** Display an additional element after the entire component. (to the right if orientation is horizontal, at the bottom if orientation is vertical) */
|
|
3481
|
-
after?:
|
|
3480
|
+
after?: React.ReactNode;
|
|
3482
3481
|
}
|
|
3483
3482
|
/**
|
|
3484
3483
|
* UserBlock component.
|
|
@@ -3491,9 +3490,9 @@ declare const UserBlock: Comp<UserBlockProps, HTMLDivElement>;
|
|
|
3491
3490
|
|
|
3492
3491
|
type ThemeContextValue = Theme | undefined;
|
|
3493
3492
|
/** Provide a theme context to all children. */
|
|
3494
|
-
declare const ThemeProvider:
|
|
3493
|
+
declare const ThemeProvider: React.FC<{
|
|
3495
3494
|
value: ThemeContextValue;
|
|
3496
|
-
children?:
|
|
3495
|
+
children?: React.ReactNode;
|
|
3497
3496
|
}>;
|
|
3498
3497
|
/** Get the theme in the current context. */
|
|
3499
3498
|
declare function useTheme(): ThemeContextValue;
|