@lumx/react 3.20.1-alpha.37 → 3.20.1-alpha.39
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/Portal.js +159 -0
- package/_internal/Portal.js.map +1 -0
- package/index.d.ts +4 -3
- package/index.js +10 -15
- package/index.js.map +1 -1
- package/package.json +7 -7
- package/utils/index.d.ts +2 -1
- package/utils/index.js +1 -158
- package/utils/index.js.map +1 -1
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import React__default, { useContext, useEffect, createContext, useMemo, useRef } from 'react';
|
|
2
|
+
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
3
|
+
import isEmpty from 'lodash/isEmpty';
|
|
4
|
+
import { createPortal } from 'react-dom';
|
|
5
|
+
|
|
6
|
+
const DisabledStateContext = /*#__PURE__*/React__default.createContext({
|
|
7
|
+
state: null
|
|
8
|
+
});
|
|
9
|
+
/**
|
|
10
|
+
* Disabled state provider.
|
|
11
|
+
* All nested LumX Design System components inherit this disabled state.
|
|
12
|
+
*/
|
|
13
|
+
function DisabledStateProvider({
|
|
14
|
+
children,
|
|
15
|
+
...value
|
|
16
|
+
}) {
|
|
17
|
+
return /*#__PURE__*/jsx(DisabledStateContext.Provider, {
|
|
18
|
+
value: value,
|
|
19
|
+
children: children
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Get DisabledState context value
|
|
25
|
+
*/
|
|
26
|
+
function useDisabledStateContext() {
|
|
27
|
+
return useContext(DisabledStateContext);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const EVENT_TYPES = ['mousedown', 'touchstart'];
|
|
31
|
+
function isClickAway(targets, refs) {
|
|
32
|
+
// The targets elements are not contained in any of the listed element references.
|
|
33
|
+
return !refs.some(ref => targets.some(target => ref?.current?.contains(target)));
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Listen to clicks away from the given elements and callback the passed in function.
|
|
37
|
+
*
|
|
38
|
+
* Warning: If you need to detect click away on nested React portals, please use the `ClickAwayProvider` component.
|
|
39
|
+
*/
|
|
40
|
+
function useClickAway({
|
|
41
|
+
callback,
|
|
42
|
+
childrenRefs
|
|
43
|
+
}) {
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
const {
|
|
46
|
+
current: currentRefs
|
|
47
|
+
} = childrenRefs;
|
|
48
|
+
if (!callback || !currentRefs || isEmpty(currentRefs)) {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
const listener = evt => {
|
|
52
|
+
const targets = [evt.composedPath?.()[0], evt.target];
|
|
53
|
+
if (isClickAway(targets, currentRefs)) {
|
|
54
|
+
callback(evt);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
EVENT_TYPES.forEach(evtType => document.addEventListener(evtType, listener));
|
|
58
|
+
return () => {
|
|
59
|
+
EVENT_TYPES.forEach(evtType => document.removeEventListener(evtType, listener));
|
|
60
|
+
};
|
|
61
|
+
}, [callback, childrenRefs]);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const ClickAwayAncestorContext = /*#__PURE__*/createContext(null);
|
|
65
|
+
/**
|
|
66
|
+
* Component combining the `useClickAway` hook with a React context to hook into the React component tree and make sure
|
|
67
|
+
* we take into account both the DOM tree and the React tree to detect click away.
|
|
68
|
+
*
|
|
69
|
+
* @return the react component.
|
|
70
|
+
*/
|
|
71
|
+
const ClickAwayProvider = ({
|
|
72
|
+
children,
|
|
73
|
+
callback,
|
|
74
|
+
childrenRefs,
|
|
75
|
+
parentRef
|
|
76
|
+
}) => {
|
|
77
|
+
const parentContext = useContext(ClickAwayAncestorContext);
|
|
78
|
+
const currentContext = useMemo(() => {
|
|
79
|
+
const context = {
|
|
80
|
+
childrenRefs: [],
|
|
81
|
+
/**
|
|
82
|
+
* Add element refs to the current context and propagate to the parent context.
|
|
83
|
+
*/
|
|
84
|
+
addRefs(...newChildrenRefs) {
|
|
85
|
+
// Add element refs that should be considered as inside the click away context.
|
|
86
|
+
context.childrenRefs.push(...newChildrenRefs);
|
|
87
|
+
if (parentContext) {
|
|
88
|
+
// Also add then to the parent context
|
|
89
|
+
parentContext.addRefs(...newChildrenRefs);
|
|
90
|
+
if (parentRef) {
|
|
91
|
+
// The parent element is also considered as inside the parent click away context but not inside the current context
|
|
92
|
+
parentContext.addRefs(parentRef);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
return context;
|
|
98
|
+
}, [parentContext, parentRef]);
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
const {
|
|
101
|
+
current: currentRefs
|
|
102
|
+
} = childrenRefs;
|
|
103
|
+
if (!currentRefs) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
currentContext.addRefs(...currentRefs);
|
|
107
|
+
}, [currentContext, childrenRefs]);
|
|
108
|
+
useClickAway({
|
|
109
|
+
callback,
|
|
110
|
+
childrenRefs: useRef(currentContext.childrenRefs)
|
|
111
|
+
});
|
|
112
|
+
return /*#__PURE__*/jsx(ClickAwayAncestorContext.Provider, {
|
|
113
|
+
value: currentContext,
|
|
114
|
+
children: children
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
ClickAwayProvider.displayName = 'ClickAwayProvider';
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Portal initializing function.
|
|
121
|
+
* If it does not provide a container, the Portal children will render in classic React tree and not in a portal.
|
|
122
|
+
*/
|
|
123
|
+
|
|
124
|
+
const PortalContext = /*#__PURE__*/React__default.createContext(() => ({
|
|
125
|
+
container: document.body
|
|
126
|
+
}));
|
|
127
|
+
/**
|
|
128
|
+
* Customize where <Portal> wrapped elements render (tooltip, popover, dialog, etc.)
|
|
129
|
+
*/
|
|
130
|
+
const PortalProvider = PortalContext.Provider;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Render children in a portal outside the current DOM position
|
|
134
|
+
* (defaults to `document.body` but can be customized with the PortalContextProvider)
|
|
135
|
+
*/
|
|
136
|
+
const Portal = ({
|
|
137
|
+
children,
|
|
138
|
+
enabled = true
|
|
139
|
+
}) => {
|
|
140
|
+
const init = React__default.useContext(PortalContext);
|
|
141
|
+
const context = React__default.useMemo(() => {
|
|
142
|
+
return enabled ? init() : null;
|
|
143
|
+
},
|
|
144
|
+
// Only update on 'enabled'
|
|
145
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
146
|
+
[enabled]);
|
|
147
|
+
React__default.useLayoutEffect(() => {
|
|
148
|
+
return context?.teardown;
|
|
149
|
+
}, [context?.teardown, enabled]);
|
|
150
|
+
if (!context?.container) {
|
|
151
|
+
return /*#__PURE__*/jsx(Fragment, {
|
|
152
|
+
children: children
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
return /*#__PURE__*/createPortal(children, context.container);
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
export { ClickAwayProvider as C, DisabledStateProvider as D, Portal as P, PortalProvider as a, useDisabledStateContext as u };
|
|
159
|
+
//# sourceMappingURL=Portal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Portal.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","children","value","_jsx","Provider","useDisabledStateContext","useContext","EVENT_TYPES","isClickAway","targets","refs","some","ref","target","current","contains","useClickAway","callback","childrenRefs","useEffect","currentRefs","isEmpty","undefined","listener","evt","composedPath","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;AAAK,CAAC,CAAC;AAMnG;AACA;AACA;AACA;AACO,SAASC,qBAAqBA,CAAC;EAAEC,QAAQ;EAAE,GAAGC;AAAkC,CAAC,EAAE;AACtF,EAAA,oBAAOC,GAAA,CAACP,oBAAoB,CAACQ,QAAQ,EAAA;AAACF,IAAAA,KAAK,EAAEA,KAAM;AAAAD,IAAAA,QAAA,EAAEA;AAAQ,GAAgC,CAAC;AAClG;;AAEA;AACA;AACA;AACO,SAASI,uBAAuBA,GAA8B;EACjE,OAAOC,UAAU,CAACV,oBAAoB,CAAC;AAC3C;;ACtBA,MAAMW,WAAW,GAAG,CAAC,WAAW,EAAE,YAAY,CAAC;AAE/C,SAASC,WAAWA,CAACC,OA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C,CAAC;AACnH;AACA+B,iBAAiB,CAACU,WAAW,GAAG,mBAAmB;;AChEnD;AACA;AACA;AACA;;AAMO,MAAMC,aAAa,gBAAG9C,cAAK,CAACC,aAAa,CAAa,OAAO;EAAE8C,SAAS,EAAEhB,QAAQ,CAACiB;AAAK,CAAC,CAAC,CAAC;AAOlG;AACA;AACA;AACO,MAAMC,cAA6C,GAAGH,aAAa,CAACvC;;ACd3E;AACA;AACA;AACA;AACO,MAAM2C,MAA6B,GAAGA,CAAC;EAAE9C,QAAQ;AAAE+C,EAAAA,OAAO,GAAG;AAAK,CAAC,KAAK;AAC3E,EAAA,MAAMC,IAAI,GAAGpD,cAAK,CAACS,UAAU,CAACqC,aAAa,CAAC;AAC5C,EAAA,MAAMN,OAAO,GAAGxC,cAAK,CAACuC,OAAO,CACzB,MAAM;AACF,IAAA,OAAOY,OAAO,GAAGC,IAAI,EAAE,GAAG,IAAI;EAClC,CAAC;AACD;AACA;EACA,CAACD,OAAO,CACZ,CAAC;EAEDnD,cAAK,CAACqD,eAAe,CAAC,MAAM;IACxB,OAAOb,OAAO,EAAEc,QAAQ;EAC5B,CAAC,EAAE,CAACd,OAAO,EAAEc,QAAQ,EAAEH,OAAO,CAAC,CAAC;AAEhC,EAAA,IAAI,CAACX,OAAO,EAAEO,SAAS,EAAE;IACrB,oBAAOzC,GAAA,CAAAiD,QAAA,EAAA;AAAAnD,MAAAA,QAAA,EAAGA;AAAQ,KAAG,CAAC;AAC1B,EAAA;AACA,EAAA,oBAAOoD,YAAY,CAACpD,QAAQ,EAAEoC,OAAO,CAACO,SAAS,CAAC;AACpD;;;;"}
|
package/index.d.ts
CHANGED
|
@@ -386,7 +386,7 @@ interface ButtonProps extends BaseButtonProps {
|
|
|
386
386
|
* @param ref Component ref.
|
|
387
387
|
* @return React element.
|
|
388
388
|
*/
|
|
389
|
-
declare const Button: Comp<ButtonProps,
|
|
389
|
+
declare const Button: Comp<ButtonProps, HTMLAnchorElement | HTMLButtonElement>;
|
|
390
390
|
|
|
391
391
|
interface IconButtonProps extends BaseButtonProps {
|
|
392
392
|
/**
|
|
@@ -1704,7 +1704,7 @@ interface LinkProps extends GenericProps, HasAriaDisabled {
|
|
|
1704
1704
|
* @param ref Component ref.
|
|
1705
1705
|
* @return React element.
|
|
1706
1706
|
*/
|
|
1707
|
-
declare const Link: Comp<LinkProps,
|
|
1707
|
+
declare const Link: Comp<LinkProps, HTMLAnchorElement | HTMLButtonElement>;
|
|
1708
1708
|
|
|
1709
1709
|
/**
|
|
1710
1710
|
* Defines the props of the component.
|
|
@@ -3152,4 +3152,5 @@ declare const ThemeProvider: React__default.FC<{
|
|
|
3152
3152
|
/** Get the theme in the current context. */
|
|
3153
3153
|
declare function useTheme(): ThemeContextValue;
|
|
3154
3154
|
|
|
3155
|
-
export { AlertDialog,
|
|
3155
|
+
export { AlertDialog, Autocomplete, AutocompleteMultiple, Avatar, Badge, BadgeWrapper, Button, ButtonEmphasis, ButtonGroup, Checkbox, Chip, ChipGroup, CommentBlock, CommentBlockVariant, DatePicker, DatePickerControlled, DatePickerField, Dialog, Divider, DragHandle, Dropdown, ExpansionPanel, Flag, FlexBox, GenericBlock, GenericBlockGapSize, Grid, GridColumn, GridItem, Heading, HeadingLevelProvider, Icon, IconButton, ImageBlock, ImageBlockCaptionPosition, ImageLightbox, InlineList, InputHelper, InputLabel, Lightbox, Link, LinkPreview, List, ListDivider, ListItem, ListSubheader, Message, Mosaic, Navigation, Notification, Placement, Popover, PopoverDialog, PostBlock, Progress, ProgressCircular, ProgressLinear, ProgressTracker, ProgressTrackerProvider, ProgressTrackerStep, ProgressTrackerStepPanel, ProgressVariant, RadioButton, RadioGroup, Select, SelectMultiple, SelectMultipleField, SelectVariant, SideNavigation, SideNavigationItem, SkeletonCircle, SkeletonRectangle, SkeletonRectangleVariant, SkeletonTypography, Slider, Slides, Slideshow, SlideshowControls, SlideshowItem, Switch, Tab, TabList, TabListLayout, TabPanel, TabProvider, Table, TableBody, TableCell, TableCellVariant, TableHeader, TableRow, Text, TextField, ThOrder, ThemeProvider, Thumbnail, ThumbnailAspectRatio, ThumbnailObjectFit, ThumbnailVariant, Toolbar, Tooltip, Uploader, UploaderVariant, UserBlock, clamp, isClickable, useFocusPointStyle, useHeadingLevel, useTheme };
|
|
3156
|
+
export type { AlertDialogProps, AutocompleteMultipleProps, AutocompleteProps, AvatarProps, AvatarSize, BadgeProps, BadgeWrapperProps, BaseButtonProps, ButtonGroupProps, ButtonProps, ButtonSize, CheckboxProps, ChipGroupProps, ChipProps, CommentBlockProps, DatePickerControlledProps, DatePickerFieldProps, DatePickerProps, DialogProps, DialogSizes, DividerProps, DragHandleProps, DropdownProps, Elevation, ExpansionPanelProps, FlagProps, FlexBoxProps, FlexHorizontalAlignment, FlexVerticalAlignment, FocusPoint, GapSize, GenericBlockProps, GridColumnGapSize, GridColumnProps, GridItemProps, GridProps, HeadingLevelProviderProps, HeadingProps, IconButtonProps, IconProps, IconSizes, ImageBlockProps, ImageBlockSize, ImageLightboxProps, InlineListProps, InputHelperProps, InputLabelProps, LightboxProps, LinkPreviewProps, LinkProps, ListDividerProps, ListItemProps, ListItemSize, ListProps, ListSubheaderProps, MarginAutoAlignment, MessageProps, MosaicProps, NavigationProps, NotificationProps, Offset, PopoverDialogProps, PopoverProps, PostBlockProps, ProgressCircularProps, ProgressCircularSize, ProgressLinearProps, ProgressProps, ProgressTrackerProps, ProgressTrackerProviderProps, ProgressTrackerStepPanelProps, ProgressTrackerStepProps, RadioButtonProps, RadioGroupProps, SelectMultipleProps, SelectProps, SideNavigationItemProps, SideNavigationProps, SkeletonCircleProps, SkeletonRectangleProps, SkeletonTypographyProps, SliderProps, SlidesProps, SlideshowControlsProps, SlideshowItemProps, SlideshowProps, SwitchProps, TabListProps, TabPanelProps, TabProps, TabProviderProps, TableBodyProps, TableCellProps, TableHeaderProps, TableProps, TableRowProps, TextFieldProps, TextProps, ThumbnailProps, ThumbnailSize, ToolbarProps, TooltipPlacement, TooltipProps, UploaderProps, UploaderSize, UserBlockProps, UserBlockSize };
|
package/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Kind,
|
|
1
|
+
import { Kind, Size, ColorPalette, Emphasis, Theme, AspectRatio, CSS_PREFIX, DIALOG_TRANSITION_DURATION, Orientation, Typography, Alignment, ColorVariant, NOTIFICATION_TRANSITION_DURATION, TOOLTIP_LONG_PRESS_DELAY, TOOLTIP_HOVER_DELAY } from '@lumx/core/js/constants';
|
|
2
2
|
export * from '@lumx/core/js/constants';
|
|
3
3
|
export * from '@lumx/core/js/types';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import React__default, { useState, useEffect, useMemo, useRef, useCallback, Children, isValidElement, cloneElement, useLayoutEffect, createContext, useContext, useReducer } from 'react';
|
|
6
6
|
import classNames from 'classnames';
|
|
7
|
-
import {
|
|
7
|
+
import { handleBasicClasses, getRootClassName, getBasicClass, getTypographyClassName, fontColorClass, resolveColorWithVariants } from '@lumx/core/js/utils/className';
|
|
8
8
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
9
9
|
import { onEnterPressed, onEscapePressed, onButtonPressed, detectHorizontalSwipe } from '@lumx/core/js/utils';
|
|
10
10
|
import last from 'lodash/last';
|
|
@@ -14,7 +14,7 @@ import concat from 'lodash/concat';
|
|
|
14
14
|
import dropRight from 'lodash/dropRight';
|
|
15
15
|
import partition from 'lodash/partition';
|
|
16
16
|
import reduce from 'lodash/reduce';
|
|
17
|
-
import { useDisabledStateContext, Portal, ClickAwayProvider } from './
|
|
17
|
+
import { u as useDisabledStateContext, P as Portal, C as ClickAwayProvider } from './_internal/Portal.js';
|
|
18
18
|
import isEmpty from 'lodash/isEmpty';
|
|
19
19
|
import memoize from 'lodash/memoize';
|
|
20
20
|
import isFunction from 'lodash/isFunction';
|
|
@@ -2045,7 +2045,7 @@ const DatePicker = forwardRef((props, ref) => {
|
|
|
2045
2045
|
}
|
|
2046
2046
|
const [selectedMonth, setSelectedMonth] = useState(referenceDate);
|
|
2047
2047
|
const setPrevMonth = () => setSelectedMonth(current => addMonthResetDay(current, -1));
|
|
2048
|
-
const setNextMonth = () => setSelectedMonth(current => addMonthResetDay(current,
|
|
2048
|
+
const setNextMonth = () => setSelectedMonth(current => addMonthResetDay(current, 1));
|
|
2049
2049
|
const onDatePickerChange = newDate => {
|
|
2050
2050
|
onChange(newDate);
|
|
2051
2051
|
};
|
|
@@ -2446,7 +2446,7 @@ var preventDefault = function preventDefault(rawEvent) {
|
|
|
2446
2446
|
var setOverflowHidden = function setOverflowHidden(options) {
|
|
2447
2447
|
// If previousBodyPaddingRight is already set, don't set it again.
|
|
2448
2448
|
if (previousBodyPaddingRight === undefined) {
|
|
2449
|
-
var _reserveScrollBarGap =
|
|
2449
|
+
var _reserveScrollBarGap = false;
|
|
2450
2450
|
var scrollBarGap = window.innerWidth - document.documentElement.clientWidth;
|
|
2451
2451
|
|
|
2452
2452
|
if (_reserveScrollBarGap && scrollBarGap > 0) {
|
|
@@ -2523,7 +2523,7 @@ var disableBodyScroll = function disableBodyScroll(targetElement, options) {
|
|
|
2523
2523
|
|
|
2524
2524
|
var lock = {
|
|
2525
2525
|
targetElement: targetElement,
|
|
2526
|
-
options:
|
|
2526
|
+
options: {}
|
|
2527
2527
|
};
|
|
2528
2528
|
|
|
2529
2529
|
locks = [].concat(_toConsumableArray(locks), [lock]);
|
|
@@ -2547,7 +2547,7 @@ var disableBodyScroll = function disableBodyScroll(targetElement, options) {
|
|
|
2547
2547
|
documentListenerAdded = true;
|
|
2548
2548
|
}
|
|
2549
2549
|
} else {
|
|
2550
|
-
setOverflowHidden(
|
|
2550
|
+
setOverflowHidden();
|
|
2551
2551
|
}
|
|
2552
2552
|
};
|
|
2553
2553
|
|
|
@@ -3230,9 +3230,9 @@ function requireReactIs_production_min () {
|
|
|
3230
3230
|
hasRequiredReactIs_production_min = 1;
|
|
3231
3231
|
var b=Symbol.for("react.element"),c=Symbol.for("react.portal"),d=Symbol.for("react.fragment"),e=Symbol.for("react.strict_mode"),f=Symbol.for("react.profiler"),g=Symbol.for("react.provider"),h=Symbol.for("react.context"),k=Symbol.for("react.server_context"),l=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),n=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),q=Symbol.for("react.lazy"),t=Symbol.for("react.offscreen"),u;u=Symbol.for("react.module.reference");
|
|
3232
3232
|
function v(a){if("object"===typeof a&&null!==a){var r=a.$$typeof;switch(r){case b:switch(a=a.type,a){case d:case f:case e:case m:case n:return a;default:switch(a=a&&a.$$typeof,a){case k:case h:case l:case q:case p:case g:return a;default:return r}}case c:return r}}}reactIs_production_min.ContextConsumer=h;reactIs_production_min.ContextProvider=g;reactIs_production_min.Element=b;reactIs_production_min.ForwardRef=l;reactIs_production_min.Fragment=d;reactIs_production_min.Lazy=q;reactIs_production_min.Memo=p;reactIs_production_min.Portal=c;reactIs_production_min.Profiler=f;reactIs_production_min.StrictMode=e;reactIs_production_min.Suspense=m;
|
|
3233
|
-
reactIs_production_min.SuspenseList=n;reactIs_production_min.isAsyncMode=function(){return
|
|
3233
|
+
reactIs_production_min.SuspenseList=n;reactIs_production_min.isAsyncMode=function(){return false};reactIs_production_min.isConcurrentMode=function(){return false};reactIs_production_min.isContextConsumer=function(a){return v(a)===h};reactIs_production_min.isContextProvider=function(a){return v(a)===g};reactIs_production_min.isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===b};reactIs_production_min.isForwardRef=function(a){return v(a)===l};reactIs_production_min.isFragment=function(a){return v(a)===d};reactIs_production_min.isLazy=function(a){return v(a)===q};reactIs_production_min.isMemo=function(a){return v(a)===p};
|
|
3234
3234
|
reactIs_production_min.isPortal=function(a){return v(a)===c};reactIs_production_min.isProfiler=function(a){return v(a)===f};reactIs_production_min.isStrictMode=function(a){return v(a)===e};reactIs_production_min.isSuspense=function(a){return v(a)===m};reactIs_production_min.isSuspenseList=function(a){return v(a)===n};
|
|
3235
|
-
reactIs_production_min.isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===d||a===f||a===e||a===m||a===n||a===t||"object"===typeof a&&null!==a&&(a.$$typeof===q||a.$$typeof===p||a.$$typeof===g||a.$$typeof===h||a.$$typeof===l||a.$$typeof===u||void 0!==a.getModuleId)
|
|
3235
|
+
reactIs_production_min.isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===d||a===f||a===e||a===m||a===n||a===t||"object"===typeof a&&null!==a&&(a.$$typeof===q||a.$$typeof===p||a.$$typeof===g||a.$$typeof===h||a.$$typeof===l||a.$$typeof===u||void 0!==a.getModuleId)?true:false};reactIs_production_min.typeOf=v;
|
|
3236
3236
|
return reactIs_production_min;
|
|
3237
3237
|
}
|
|
3238
3238
|
|
|
@@ -4701,7 +4701,6 @@ function detectOverflow(state, options) {
|
|
|
4701
4701
|
var popperOffsets = computeOffsets({
|
|
4702
4702
|
reference: referenceClientRect,
|
|
4703
4703
|
element: popperRect,
|
|
4704
|
-
strategy: 'absolute',
|
|
4705
4704
|
placement: placement
|
|
4706
4705
|
});
|
|
4707
4706
|
var popperClientRect = rectToClientRect(Object.assign(Object.assign({}, popperRect), popperOffsets));
|
|
@@ -5037,7 +5036,6 @@ function popperOffsets(_ref) {
|
|
|
5037
5036
|
state.modifiersData[name] = computeOffsets({
|
|
5038
5037
|
reference: state.rects.reference,
|
|
5039
5038
|
element: state.rects.popper,
|
|
5040
|
-
strategy: 'absolute',
|
|
5041
5039
|
placement: state.placement
|
|
5042
5040
|
});
|
|
5043
5041
|
} // eslint-disable-next-line import/no-unused-modules
|
|
@@ -5948,10 +5946,7 @@ const Placement = {
|
|
|
5948
5946
|
* Popover fit anchor width options.
|
|
5949
5947
|
*/
|
|
5950
5948
|
const FitAnchorWidth = {
|
|
5951
|
-
|
|
5952
|
-
MIN_WIDTH: 'minWidth',
|
|
5953
|
-
WIDTH: 'width'
|
|
5954
|
-
};
|
|
5949
|
+
MIN_WIDTH: 'minWidth'};
|
|
5955
5950
|
/**
|
|
5956
5951
|
* Arrow size (in pixel).
|
|
5957
5952
|
*/
|