@lumx/react 2.1.3 → 2.1.6-alpha.1
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/esm/_internal/Avatar2.js +5 -1
- package/esm/_internal/Avatar2.js.map +1 -1
- package/esm/_internal/Dialog2.js +13 -8
- package/esm/_internal/Dialog2.js.map +1 -1
- package/esm/_internal/DragHandle.js +1 -1
- package/esm/_internal/DragHandle.js.map +1 -1
- package/esm/_internal/Flag2.js +1 -3
- package/esm/_internal/Flag2.js.map +1 -1
- package/esm/_internal/Message2.js +2 -2
- package/esm/_internal/Message2.js.map +1 -1
- package/esm/_internal/SlideshowControls.js +2 -2
- package/esm/_internal/SlideshowControls.js.map +1 -1
- package/esm/_internal/Thumbnail2.js +29 -34
- package/esm/_internal/Thumbnail2.js.map +1 -1
- package/esm/_internal/UserBlock.js +44 -14
- package/esm/_internal/UserBlock.js.map +1 -1
- package/esm/_internal/user-block.js +1 -0
- package/esm/_internal/user-block.js.map +1 -1
- package/package.json +16 -17
- package/src/components/avatar/Avatar.tsx +8 -0
- package/src/components/dialog/Dialog.stories.tsx +44 -2
- package/src/components/dialog/Dialog.tsx +15 -11
- package/src/components/dialog/__snapshots__/Dialog.test.tsx.snap +76 -0
- package/src/components/drag-handle/DragHandle.tsx +5 -1
- package/src/components/flag/Flag.test.tsx +1 -2
- package/src/components/flag/Flag.tsx +2 -10
- package/src/components/flag/__snapshots__/Flag.test.tsx.snap +0 -15
- package/src/components/message/Message.tsx +2 -2
- package/src/components/slideshow/useKeyNavigate.ts +2 -2
- package/src/components/thumbnail/Thumbnail.stories.tsx +21 -0
- package/src/components/thumbnail/Thumbnail.test.tsx +20 -2
- package/src/components/thumbnail/Thumbnail.tsx +40 -15
- package/src/components/thumbnail/__snapshots__/Thumbnail.test.tsx.snap +53 -6
- package/src/components/user-block/UserBlock.stories.tsx +27 -4
- package/src/components/user-block/UserBlock.tsx +40 -16
- package/src/components/user-block/__snapshots__/UserBlock.test.tsx.snap +244 -145
- package/types.d.ts +12 -0
package/esm/_internal/Avatar2.js
CHANGED
|
@@ -44,7 +44,9 @@ var Avatar = forwardRef(function (props, ref) {
|
|
|
44
44
|
size = props.size,
|
|
45
45
|
theme = props.theme,
|
|
46
46
|
thumbnailProps = props.thumbnailProps,
|
|
47
|
-
|
|
47
|
+
linkProps = props.linkProps,
|
|
48
|
+
linkAs = props.linkAs,
|
|
49
|
+
forwardedProps = _objectWithoutProperties(props, ["actions", "alt", "badge", "className", "image", "onClick", "onKeyPress", "size", "theme", "thumbnailProps", "linkProps", "linkAs"]);
|
|
48
50
|
|
|
49
51
|
return React.createElement("div", _extends({
|
|
50
52
|
ref: ref
|
|
@@ -55,6 +57,8 @@ var Avatar = forwardRef(function (props, ref) {
|
|
|
55
57
|
theme: theme
|
|
56
58
|
}))
|
|
57
59
|
}), React.createElement(Thumbnail, _extends({
|
|
60
|
+
linkProps: linkProps,
|
|
61
|
+
linkAs: linkAs,
|
|
58
62
|
className: "".concat(CLASSNAME, "__thumbnail"),
|
|
59
63
|
onClick: onClick,
|
|
60
64
|
onKeyPress: onKeyPress
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Avatar2.js","sources":["../../../src/components/avatar/Avatar.tsx"],"sourcesContent":["import React, { forwardRef, KeyboardEventHandler, MouseEventHandler, ReactElement, ReactNode } from 'react';\n\nimport classNames from 'classnames';\n\nimport { AspectRatio, Size, Theme, Thumbnail, ThumbnailProps } from '@lumx/react';\n\nimport { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';\n\n/**\n * Avatar sizes.\n */\nexport type AvatarSize = Extract<Size, 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl'>;\n\n/**\n * Defines the props of the component.\n */\nexport interface AvatarProps extends GenericProps {\n /** Action toolbar content. */\n actions?: ReactNode;\n /** Image alternative text. */\n alt: string;\n /** Badge. */\n badge?: ReactElement;\n /** Image URL. */\n image: string;\n /** On click callback. */\n onClick?: MouseEventHandler<HTMLDivElement>;\n /** On key press callback. */\n onKeyPress?: KeyboardEventHandler<HTMLDivElement>;\n /** Size variant. */\n size?: AvatarSize;\n /** Theme adapting the component to light or dark background. */\n theme?: Theme;\n /** Props to pass to the thumbnail (minus those already set by the Avatar props). */\n thumbnailProps?: Omit<\n ThumbnailProps,\n 'image' | 'alt' | 'size' | 'theme' | 'align' | 'fillHeight' | 'variant' | 'aspectRatio'\n >;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'Avatar';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * Component default props.\n */\nconst DEFAULT_PROPS: Partial<AvatarProps> = {\n size: Size.m,\n theme: Theme.light,\n};\n\n/**\n * Avatar component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const Avatar: Comp<AvatarProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n actions,\n alt,\n badge,\n className,\n image,\n onClick,\n onKeyPress,\n size,\n theme,\n thumbnailProps,\n ...forwardedProps\n } = props;\n\n return (\n <div\n ref={ref}\n {...forwardedProps}\n className={classNames(className, handleBasicClasses({ prefix: CLASSNAME, size, theme }))}\n >\n <Thumbnail\n className={`${CLASSNAME}__thumbnail`}\n onClick={onClick}\n onKeyPress={onKeyPress}\n {...thumbnailProps}\n aspectRatio={AspectRatio.square}\n size={size}\n image={image}\n alt={alt}\n />\n {actions && <div className={`${CLASSNAME}__actions`}>{actions}</div>}\n {badge && <div className={`${CLASSNAME}__badge`}>{badge}</div>}\n </div>\n );\n});\nAvatar.displayName = COMPONENT_NAME;\nAvatar.className = CLASSNAME;\nAvatar.defaultProps = DEFAULT_PROPS;\n"],"names":["COMPONENT_NAME","CLASSNAME","getRootClassName","DEFAULT_PROPS","size","Size","m","theme","Theme","light","Avatar","forwardRef","props","ref","actions","alt","badge","className","image","onClick","onKeyPress","thumbnailProps","forwardedProps","classNames","handleBasicClasses","prefix","AspectRatio","square","displayName","defaultProps"],"mappings":";;;;;;AAQA;;;;
|
|
1
|
+
{"version":3,"file":"Avatar2.js","sources":["../../../src/components/avatar/Avatar.tsx"],"sourcesContent":["import React, { forwardRef, KeyboardEventHandler, MouseEventHandler, ReactElement, ReactNode } from 'react';\n\nimport classNames from 'classnames';\n\nimport { AspectRatio, Size, Theme, Thumbnail, ThumbnailProps } from '@lumx/react';\n\nimport { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';\n\n/**\n * Avatar sizes.\n */\nexport type AvatarSize = Extract<Size, 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl'>;\n\n/**\n * Defines the props of the component.\n */\nexport interface AvatarProps extends GenericProps {\n /** Action toolbar content. */\n actions?: ReactNode;\n /** Image alternative text. */\n alt: string;\n /** Badge. */\n badge?: ReactElement;\n /** Image URL. */\n image: string;\n /** On click callback. */\n onClick?: MouseEventHandler<HTMLDivElement>;\n /** On key press callback. */\n onKeyPress?: KeyboardEventHandler<HTMLDivElement>;\n /** Size variant. */\n size?: AvatarSize;\n /** Theme adapting the component to light or dark background. */\n theme?: Theme;\n /** Props to pass to the thumbnail (minus those already set by the Avatar props). */\n thumbnailProps?: Omit<\n ThumbnailProps,\n 'image' | 'alt' | 'size' | 'theme' | 'align' | 'fillHeight' | 'variant' | 'aspectRatio'\n >;\n /** Props to pass to the link wrapping the thumbnail. */\n linkProps?: React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>;\n /** Custom react component for the link (can be used to inject react router Link). */\n linkAs?: 'a' | any;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'Avatar';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * Component default props.\n */\nconst DEFAULT_PROPS: Partial<AvatarProps> = {\n size: Size.m,\n theme: Theme.light,\n};\n\n/**\n * Avatar component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const Avatar: Comp<AvatarProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n actions,\n alt,\n badge,\n className,\n image,\n onClick,\n onKeyPress,\n size,\n theme,\n thumbnailProps,\n linkProps,\n linkAs,\n ...forwardedProps\n } = props;\n\n return (\n <div\n ref={ref}\n {...forwardedProps}\n className={classNames(className, handleBasicClasses({ prefix: CLASSNAME, size, theme }))}\n >\n <Thumbnail\n linkProps={linkProps}\n linkAs={linkAs}\n className={`${CLASSNAME}__thumbnail`}\n onClick={onClick}\n onKeyPress={onKeyPress}\n {...thumbnailProps}\n aspectRatio={AspectRatio.square}\n size={size}\n image={image}\n alt={alt}\n />\n {actions && <div className={`${CLASSNAME}__actions`}>{actions}</div>}\n {badge && <div className={`${CLASSNAME}__badge`}>{badge}</div>}\n </div>\n );\n});\nAvatar.displayName = COMPONENT_NAME;\nAvatar.className = CLASSNAME;\nAvatar.defaultProps = DEFAULT_PROPS;\n"],"names":["COMPONENT_NAME","CLASSNAME","getRootClassName","DEFAULT_PROPS","size","Size","m","theme","Theme","light","Avatar","forwardRef","props","ref","actions","alt","badge","className","image","onClick","onKeyPress","thumbnailProps","linkProps","linkAs","forwardedProps","classNames","handleBasicClasses","prefix","AspectRatio","square","displayName","defaultProps"],"mappings":";;;;;;AAQA;;;;AAoCA;;;AAGA,IAAMA,cAAc,GAAG,QAAvB;AAEA;;;;AAGA,IAAMC,SAAS,GAAGC,gBAAgB,CAACF,cAAD,CAAlC;AAEA;;;;AAGA,IAAMG,aAAmC,GAAG;AACxCC,EAAAA,IAAI,EAAEC,IAAI,CAACC,CAD6B;AAExCC,EAAAA,KAAK,EAAEC,KAAK,CAACC;AAF2B,CAA5C;AAKA;;;;;;;;IAOaC,MAAyC,GAAGC,UAAU,CAAC,UAACC,KAAD,EAAQC,GAAR,EAAgB;AAAA,MAE5EC,OAF4E,GAe5EF,KAf4E,CAE5EE,OAF4E;AAAA,MAG5EC,GAH4E,GAe5EH,KAf4E,CAG5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,KAA0Ca,OAA1C,CAjBhB,EAkBKE,KAAK,IAAI;AAAK,IAAA,SAAS,YAAKf,SAAL;AAAd,KAAwCe,KAAxC,CAlBd,CADJ;AAsBH,CAvCkE;AAwCnEN,MAAM,CAACoB,WAAP,GAAqB9B,cAArB;AACAU,MAAM,CAACO,SAAP,GAAmBhB,SAAnB;AACAS,MAAM,CAACqB,YAAP,GAAsB5B,aAAtB;;;;"}
|
package/esm/_internal/Dialog2.js
CHANGED
|
@@ -151,17 +151,22 @@ var Dialog = forwardRef(function (props, ref) {
|
|
|
151
151
|
zIndex = props.zIndex,
|
|
152
152
|
dialogProps = props.dialogProps,
|
|
153
153
|
onVisibilityChange = props.onVisibilityChange,
|
|
154
|
-
forwardedProps = _objectWithoutProperties(props, ["children", "className", "header", "focusElement", "forceFooterDivider", "forceHeaderDivider", "footer", "isLoading", "isOpen", "onClose", "parentElement", "contentRef", "preventAutoClose", "size", "zIndex", "dialogProps", "onVisibilityChange"]);
|
|
154
|
+
forwardedProps = _objectWithoutProperties(props, ["children", "className", "header", "focusElement", "forceFooterDivider", "forceHeaderDivider", "footer", "isLoading", "isOpen", "onClose", "parentElement", "contentRef", "preventAutoClose", "size", "zIndex", "dialogProps", "onVisibilityChange"]); // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
155
155
|
|
|
156
|
-
var handleClose = onClose ? function () {
|
|
157
|
-
onClose(); // Focus the parent element on close.
|
|
158
156
|
|
|
159
|
-
|
|
160
|
-
|
|
157
|
+
var previousOpen = React.useRef(isOpen); // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
158
|
+
|
|
159
|
+
React.useEffect(function () {
|
|
160
|
+
if (isOpen !== previousOpen.current) {
|
|
161
|
+
previousOpen.current = isOpen; // Focus the parent element on close.
|
|
162
|
+
|
|
163
|
+
if (!isOpen && parentElement && parentElement.current) {
|
|
164
|
+
parentElement.current.focus();
|
|
165
|
+
}
|
|
161
166
|
}
|
|
162
|
-
}
|
|
167
|
+
}, [isOpen, parentElement]); // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
163
168
|
|
|
164
|
-
useCallbackOnEscape(
|
|
169
|
+
useCallbackOnEscape(onClose, isOpen && !preventAutoClose); // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
165
170
|
|
|
166
171
|
var wrapperRef = useRef(null);
|
|
167
172
|
/**
|
|
@@ -234,7 +239,7 @@ var Dialog = forwardRef(function (props, ref) {
|
|
|
234
239
|
role: "dialog",
|
|
235
240
|
"aria-modal": "true"
|
|
236
241
|
}, dialogProps), React.createElement(ClickAwayProvider, {
|
|
237
|
-
callback: !preventAutoClose &&
|
|
242
|
+
callback: !preventAutoClose && onClose,
|
|
238
243
|
refs: clickAwayRefs
|
|
239
244
|
}, React.createElement("div", {
|
|
240
245
|
className: "".concat(CLASSNAME, "__wrapper"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog2.js","sources":["../../../src/hooks/useIntersectionObserver.tsx","../../../src/components/dialog/Dialog.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nexport type Intersections<T> = Map<T, IntersectionObserverEntry>;\n\n/**\n * Convenient hook to create interaction observers.\n *\n * @param elements Elements to observe.\n * @param options IntersectionObserver options.\n * @return Map of intersections.\n */\nexport function useIntersectionObserver<T extends Element>(\n elements: Array<T | null | undefined>,\n options?: IntersectionObserverInit,\n): Intersections<T> {\n const [intersections, setIntersections] = useState<Intersections<T>>(() => new Map());\n\n useEffect(\n () => {\n if (elements.length < 1 || !elements.some(Boolean)) {\n return undefined;\n }\n\n const observer = new IntersectionObserver((entries) => {\n for (const entry of entries) {\n intersections.set(entry.target as T, entry);\n }\n setIntersections(new Map(intersections));\n }, options);\n\n for (const element of elements) {\n if (element) {\n observer.observe(element);\n }\n }\n return () => observer.disconnect();\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [...elements],\n );\n\n return intersections;\n}\n","import React, { Children, forwardRef, ReactElement, ReactNode, RefObject, useMemo, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\n\nimport classNames from 'classnames';\n\nimport { Progress, ProgressVariant, Size } from '@lumx/react';\n\nimport { DIALOG_TRANSITION_DURATION, DOCUMENT } from '@lumx/react/constants';\nimport { useCallbackOnEscape } from '@lumx/react/hooks/useCallbackOnEscape';\nimport { useFocusTrap } from '@lumx/react/hooks/useFocusTrap';\nimport { useIntersectionObserver } from '@lumx/react/hooks/useIntersectionObserver';\nimport {\n Comp,\n GenericProps,\n getRootClassName,\n handleBasicClasses,\n isComponent,\n partitionMulti,\n} from '@lumx/react/utils';\nimport { ClickAwayProvider } from '@lumx/react/utils/ClickAwayProvider';\nimport { mergeRefs } from '@lumx/react/utils/mergeRefs';\n\nimport { useDelayedVisibility } from '@lumx/react/hooks/useDelayedVisibility';\nimport { useDisableBodyScroll } from '@lumx/react/hooks/useDisableBodyScroll';\n\n/**\n * Defines the props of the component.\n */\nexport interface DialogProps extends GenericProps {\n /** Footer content. */\n footer?: ReactNode;\n /** Whether the divider between the dialog content and the footer is always displayed (instead of showing it on scroll). */\n forceFooterDivider?: boolean;\n /** Header content. */\n header?: ReactNode;\n /** Whether the divider between the dialog content and the footer is always displayed (instead of showing it on scroll). */\n forceHeaderDivider?: boolean;\n /** Whether the indefinite progress indicator over the dialog content is displayed or not. */\n isLoading?: boolean;\n /** Whether the component is open or not. */\n isOpen?: boolean;\n /** Reference to the parent element that triggered modal opening (will get back focus on close). */\n parentElement?: RefObject<HTMLElement>;\n /** Reference to the dialog content element. */\n contentRef?: RefObject<HTMLDivElement>;\n /** Reference to the of the element that should get the focus when the dialogs opens. By default, the first child will take focus. */\n focusElement?: RefObject<HTMLElement>;\n /** Whether to keep the dialog open on clickaway or escape press. */\n preventAutoClose?: boolean;\n /** Size variant. */\n size?: DialogSizes;\n /** Z-axis position. */\n zIndex?: number;\n /** Z-axis position. */\n dialogProps?: GenericProps;\n /** On close callback. */\n onClose?(): void;\n /** Callback called when the open animation starts and the close animation finishes. */\n onVisibilityChange?(isVisible: boolean): void;\n}\n\nexport type DialogSizes = Extract<Size, 'tiny' | 'regular' | 'big' | 'huge'>;\n\nconst isHeader = isComponent('header');\nconst isFooter = isComponent('footer');\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'Dialog';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * Component default props.\n */\nconst DEFAULT_PROPS: Partial<DialogProps> = {\n size: Size.big,\n};\n\n/**\n * Dialog component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const Dialog: Comp<DialogProps, HTMLDivElement> = forwardRef((props, ref) => {\n if (!DOCUMENT) {\n // Can't render in SSR.\n return null;\n }\n\n const {\n children,\n className,\n header,\n focusElement,\n forceFooterDivider,\n forceHeaderDivider,\n footer,\n isLoading,\n isOpen,\n onClose,\n parentElement,\n contentRef,\n preventAutoClose,\n size,\n zIndex,\n dialogProps,\n onVisibilityChange,\n ...forwardedProps\n } = props;\n\n const handleClose = onClose\n ? () => {\n onClose();\n // Focus the parent element on close.\n if (parentElement && parentElement.current) {\n parentElement.current.focus();\n }\n }\n : undefined;\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useCallbackOnEscape(handleClose, isOpen && !preventAutoClose);\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const wrapperRef = useRef<HTMLDivElement>(null);\n /**\n * Since the `contentRef` comes from the parent and is optional,\n * we need to create a stable contentRef that will always be available.\n */\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const localContentRef = useRef<HTMLDivElement>(null);\n // Handle focus trap.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useFocusTrap(wrapperRef.current, focusElement?.current);\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useDisableBodyScroll(isOpen && localContentRef.current);\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const [sentinelTop, setSentinelTop] = useState<Element | null>(null);\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const [sentinelBottom, setSentinelBottom] = useState<Element | null>(null);\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const intersections = useIntersectionObserver([sentinelTop, sentinelBottom], {\n threshold: [0, 1],\n });\n\n const hasTopIntersection = sentinelTop && !(intersections.get(sentinelTop)?.isIntersecting ?? true);\n const hasBottomIntersection = sentinelBottom && !(intersections.get(sentinelBottom)?.isIntersecting ?? true);\n\n // Separate header, footer and dialog content from children.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const [[headerChild], [footerChild], content] = useMemo(\n () => partitionMulti(Children.toArray(children), [isHeader, isFooter]),\n [children],\n );\n const headerChildProps = (headerChild as ReactElement)?.props;\n const headerChildContent = headerChildProps?.children;\n const footerChildProps = (footerChild as ReactElement)?.props;\n const footerChildContent = footerChildProps?.children;\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const isVisible = useDelayedVisibility(Boolean(isOpen), DIALOG_TRANSITION_DURATION, onVisibilityChange);\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const clickAwayRefs = useRef([wrapperRef]);\n\n return isOpen || isVisible\n ? createPortal(\n <div\n ref={ref}\n {...forwardedProps}\n className={classNames(\n className,\n handleBasicClasses({\n isHidden: !isOpen,\n isLoading,\n isShown: isOpen || isVisible,\n prefix: CLASSNAME,\n size,\n }),\n )}\n style={{ zIndex }}\n >\n <div className={`${CLASSNAME}__overlay`} />\n\n <section className={`${CLASSNAME}__container`} role=\"dialog\" aria-modal=\"true\" {...dialogProps}>\n <ClickAwayProvider callback={!preventAutoClose && handleClose} refs={clickAwayRefs}>\n <div className={`${CLASSNAME}__wrapper`} ref={wrapperRef}>\n {(header || headerChildContent) && (\n <header\n {...headerChildProps}\n className={classNames(\n `${CLASSNAME}__header`,\n (forceHeaderDivider || hasTopIntersection) &&\n `${CLASSNAME}__header--has-divider`,\n headerChildProps?.className,\n )}\n >\n {header}\n {headerChildContent}\n </header>\n )}\n\n <div ref={mergeRefs(contentRef, localContentRef)} className={`${CLASSNAME}__content`}>\n <div\n className={`${CLASSNAME}__sentinel ${CLASSNAME}__sentinel--top`}\n ref={setSentinelTop}\n />\n\n {content}\n\n <div\n className={`${CLASSNAME}__sentinel ${CLASSNAME}__sentinel--bottom`}\n ref={setSentinelBottom}\n />\n </div>\n\n {(footer || footerChildContent) && (\n <footer\n {...footerChildProps}\n className={classNames(\n `${CLASSNAME}__footer`,\n (forceFooterDivider || hasBottomIntersection) &&\n `${CLASSNAME}__footer--has-divider`,\n footerChildProps?.className,\n )}\n >\n {footer}\n {footerChildContent}\n </footer>\n )}\n\n {isLoading && (\n <div className={`${CLASSNAME}__progress-overlay`}>\n <Progress variant={ProgressVariant.circular} />\n </div>\n )}\n </div>\n </ClickAwayProvider>\n </section>\n </div>,\n document.body,\n )\n : null;\n});\nDialog.displayName = COMPONENT_NAME;\nDialog.className = CLASSNAME;\nDialog.defaultProps = DEFAULT_PROPS;\n"],"names":["useIntersectionObserver","elements","options","useState","Map","intersections","setIntersections","useEffect","length","some","Boolean","undefined","observer","IntersectionObserver","entries","entry","set","target","element","observe","disconnect","isHeader","isComponent","isFooter","COMPONENT_NAME","CLASSNAME","getRootClassName","DEFAULT_PROPS","size","Size","big","Dialog","forwardRef","props","ref","DOCUMENT","children","className","header","focusElement","forceFooterDivider","forceHeaderDivider","footer","isLoading","isOpen","onClose","parentElement","contentRef","preventAutoClose","zIndex","dialogProps","onVisibilityChange","forwardedProps","handleClose","current","focus","useCallbackOnEscape","wrapperRef","useRef","localContentRef","useFocusTrap","useDisableBodyScroll","sentinelTop","setSentinelTop","sentinelBottom","setSentinelBottom","threshold","hasTopIntersection","get","isIntersecting","hasBottomIntersection","useMemo","partitionMulti","Children","toArray","headerChild","footerChild","content","headerChildProps","headerChildContent","footerChildProps","footerChildContent","isVisible","useDelayedVisibility","DIALOG_TRANSITION_DURATION","clickAwayRefs","createPortal","classNames","handleBasicClasses","isHidden","isShown","prefix","mergeRefs","ProgressVariant","circular","document","body","displayName","defaultProps"],"mappings":";;;;;;;;;;;;;;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AAX,KACG,2CACQD,gBADR;AAEI,IAAA,SAAS,EAAEO,UAAU,WACd9D,SADc,eAEjB,CAACe,kBAAkB,IAAI8B,qBAAvB,eACO7C,SADP,0BAFiB,EAIjBuD,gBAJiB,aAIjBA,gBAJiB,uBAIjBA,gBAAgB,CAAE3C,SAJD;AAFzB,MASKK,MATL,EAUKuC,kBAVL,CA/BR,EA6CKtC,SAAS,IACN;AAAK,IAAA,SAAS,YAAKlB,SAAL;AAAd,KACI,oBAAC,QAAD;AAAU,IAAA,OAAO,EAAEoE,eAAe,CAACC;AAAnC,IADJ,CA9CR,CADJ,CADJ,CAjBJ,CADQ,EA0ERC,QAAQ,CAACC,IA1ED,CADX,GA6ED,IA7EN;AA8EH,CAlKkE;AAmKnEjE,MAAM,CAACkE,WAAP,GAAqBzE,cAArB;AACAO,MAAM,CAACM,SAAP,GAAmBZ,SAAnB;AACAM,MAAM,CAACmE,YAAP,GAAsBvE,aAAtB;;;;"}
|
|
1
|
+
{"version":3,"file":"Dialog2.js","sources":["../../../src/hooks/useIntersectionObserver.tsx","../../../src/components/dialog/Dialog.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nexport type Intersections<T> = Map<T, IntersectionObserverEntry>;\n\n/**\n * Convenient hook to create interaction observers.\n *\n * @param elements Elements to observe.\n * @param options IntersectionObserver options.\n * @return Map of intersections.\n */\nexport function useIntersectionObserver<T extends Element>(\n elements: Array<T | null | undefined>,\n options?: IntersectionObserverInit,\n): Intersections<T> {\n const [intersections, setIntersections] = useState<Intersections<T>>(() => new Map());\n\n useEffect(\n () => {\n if (elements.length < 1 || !elements.some(Boolean)) {\n return undefined;\n }\n\n const observer = new IntersectionObserver((entries) => {\n for (const entry of entries) {\n intersections.set(entry.target as T, entry);\n }\n setIntersections(new Map(intersections));\n }, options);\n\n for (const element of elements) {\n if (element) {\n observer.observe(element);\n }\n }\n return () => observer.disconnect();\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [...elements],\n );\n\n return intersections;\n}\n","import React, { Children, forwardRef, ReactElement, ReactNode, RefObject, useMemo, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\n\nimport classNames from 'classnames';\n\nimport { Progress, ProgressVariant, Size } from '@lumx/react';\n\nimport { DIALOG_TRANSITION_DURATION, DOCUMENT } from '@lumx/react/constants';\nimport { useCallbackOnEscape } from '@lumx/react/hooks/useCallbackOnEscape';\nimport { useFocusTrap } from '@lumx/react/hooks/useFocusTrap';\nimport { useIntersectionObserver } from '@lumx/react/hooks/useIntersectionObserver';\nimport {\n Comp,\n GenericProps,\n getRootClassName,\n handleBasicClasses,\n isComponent,\n partitionMulti,\n} from '@lumx/react/utils';\nimport { ClickAwayProvider } from '@lumx/react/utils/ClickAwayProvider';\nimport { mergeRefs } from '@lumx/react/utils/mergeRefs';\n\nimport { useDelayedVisibility } from '@lumx/react/hooks/useDelayedVisibility';\nimport { useDisableBodyScroll } from '@lumx/react/hooks/useDisableBodyScroll';\n\n/**\n * Defines the props of the component.\n */\nexport interface DialogProps extends GenericProps {\n /** Footer content. */\n footer?: ReactNode;\n /** Whether the divider between the dialog content and the footer is always displayed (instead of showing it on scroll). */\n forceFooterDivider?: boolean;\n /** Header content. */\n header?: ReactNode;\n /** Whether the divider between the dialog content and the footer is always displayed (instead of showing it on scroll). */\n forceHeaderDivider?: boolean;\n /** Whether the indefinite progress indicator over the dialog content is displayed or not. */\n isLoading?: boolean;\n /** Whether the component is open or not. */\n isOpen?: boolean;\n /** Reference to the parent element that triggered modal opening (will get back focus on close). */\n parentElement?: RefObject<HTMLElement>;\n /** Reference to the dialog content element. */\n contentRef?: RefObject<HTMLDivElement>;\n /** Reference to the of the element that should get the focus when the dialogs opens. By default, the first child will take focus. */\n focusElement?: RefObject<HTMLElement>;\n /** Whether to keep the dialog open on clickaway or escape press. */\n preventAutoClose?: boolean;\n /** Size variant. */\n size?: DialogSizes;\n /** Z-axis position. */\n zIndex?: number;\n /** Z-axis position. */\n dialogProps?: GenericProps;\n /** On close callback. */\n onClose?(): void;\n /** Callback called when the open animation starts and the close animation finishes. */\n onVisibilityChange?(isVisible: boolean): void;\n}\n\nexport type DialogSizes = Extract<Size, 'tiny' | 'regular' | 'big' | 'huge'>;\n\nconst isHeader = isComponent('header');\nconst isFooter = isComponent('footer');\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'Dialog';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * Component default props.\n */\nconst DEFAULT_PROPS: Partial<DialogProps> = {\n size: Size.big,\n};\n\n/**\n * Dialog component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const Dialog: Comp<DialogProps, HTMLDivElement> = forwardRef((props, ref) => {\n if (!DOCUMENT) {\n // Can't render in SSR.\n return null;\n }\n\n const {\n children,\n className,\n header,\n focusElement,\n forceFooterDivider,\n forceHeaderDivider,\n footer,\n isLoading,\n isOpen,\n onClose,\n parentElement,\n contentRef,\n preventAutoClose,\n size,\n zIndex,\n dialogProps,\n onVisibilityChange,\n ...forwardedProps\n } = props;\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const previousOpen = React.useRef(isOpen);\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useEffect(() => {\n if (isOpen !== previousOpen.current) {\n previousOpen.current = isOpen;\n\n // Focus the parent element on close.\n if (!isOpen && parentElement && parentElement.current) {\n parentElement.current.focus();\n }\n }\n }, [isOpen, parentElement]);\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useCallbackOnEscape(onClose, isOpen && !preventAutoClose);\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const wrapperRef = useRef<HTMLDivElement>(null);\n /**\n * Since the `contentRef` comes from the parent and is optional,\n * we need to create a stable contentRef that will always be available.\n */\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const localContentRef = useRef<HTMLDivElement>(null);\n // Handle focus trap.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useFocusTrap(wrapperRef.current, focusElement?.current);\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useDisableBodyScroll(isOpen && localContentRef.current);\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const [sentinelTop, setSentinelTop] = useState<Element | null>(null);\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const [sentinelBottom, setSentinelBottom] = useState<Element | null>(null);\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const intersections = useIntersectionObserver([sentinelTop, sentinelBottom], {\n threshold: [0, 1],\n });\n\n const hasTopIntersection = sentinelTop && !(intersections.get(sentinelTop)?.isIntersecting ?? true);\n const hasBottomIntersection = sentinelBottom && !(intersections.get(sentinelBottom)?.isIntersecting ?? true);\n\n // Separate header, footer and dialog content from children.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const [[headerChild], [footerChild], content] = useMemo(\n () => partitionMulti(Children.toArray(children), [isHeader, isFooter]),\n [children],\n );\n const headerChildProps = (headerChild as ReactElement)?.props;\n const headerChildContent = headerChildProps?.children;\n const footerChildProps = (footerChild as ReactElement)?.props;\n const footerChildContent = footerChildProps?.children;\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const isVisible = useDelayedVisibility(Boolean(isOpen), DIALOG_TRANSITION_DURATION, onVisibilityChange);\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const clickAwayRefs = useRef([wrapperRef]);\n\n return isOpen || isVisible\n ? createPortal(\n <div\n ref={ref}\n {...forwardedProps}\n className={classNames(\n className,\n handleBasicClasses({\n isHidden: !isOpen,\n isLoading,\n isShown: isOpen || isVisible,\n prefix: CLASSNAME,\n size,\n }),\n )}\n style={{ zIndex }}\n >\n <div className={`${CLASSNAME}__overlay`} />\n\n <section className={`${CLASSNAME}__container`} role=\"dialog\" aria-modal=\"true\" {...dialogProps}>\n <ClickAwayProvider callback={!preventAutoClose && onClose} refs={clickAwayRefs}>\n <div className={`${CLASSNAME}__wrapper`} ref={wrapperRef}>\n {(header || headerChildContent) && (\n <header\n {...headerChildProps}\n className={classNames(\n `${CLASSNAME}__header`,\n (forceHeaderDivider || hasTopIntersection) &&\n `${CLASSNAME}__header--has-divider`,\n headerChildProps?.className,\n )}\n >\n {header}\n {headerChildContent}\n </header>\n )}\n\n <div ref={mergeRefs(contentRef, localContentRef)} className={`${CLASSNAME}__content`}>\n <div\n className={`${CLASSNAME}__sentinel ${CLASSNAME}__sentinel--top`}\n ref={setSentinelTop}\n />\n\n {content}\n\n <div\n className={`${CLASSNAME}__sentinel ${CLASSNAME}__sentinel--bottom`}\n ref={setSentinelBottom}\n />\n </div>\n\n {(footer || footerChildContent) && (\n <footer\n {...footerChildProps}\n className={classNames(\n `${CLASSNAME}__footer`,\n (forceFooterDivider || hasBottomIntersection) &&\n `${CLASSNAME}__footer--has-divider`,\n footerChildProps?.className,\n )}\n >\n {footer}\n {footerChildContent}\n </footer>\n )}\n\n {isLoading && (\n <div className={`${CLASSNAME}__progress-overlay`}>\n <Progress variant={ProgressVariant.circular} />\n </div>\n )}\n </div>\n </ClickAwayProvider>\n </section>\n </div>,\n document.body,\n )\n : null;\n});\nDialog.displayName = COMPONENT_NAME;\nDialog.className = CLASSNAME;\nDialog.defaultProps = DEFAULT_PROPS;\n"],"names":["useIntersectionObserver","elements","options","useState","Map","intersections","setIntersections","useEffect","length","some","Boolean","undefined","observer","IntersectionObserver","entries","entry","set","target","element","observe","disconnect","isHeader","isComponent","isFooter","COMPONENT_NAME","CLASSNAME","getRootClassName","DEFAULT_PROPS","size","Size","big","Dialog","forwardRef","props","ref","DOCUMENT","children","className","header","focusElement","forceFooterDivider","forceHeaderDivider","footer","isLoading","isOpen","onClose","parentElement","contentRef","preventAutoClose","zIndex","dialogProps","onVisibilityChange","forwardedProps","previousOpen","React","useRef","current","focus","useCallbackOnEscape","wrapperRef","localContentRef","useFocusTrap","useDisableBodyScroll","sentinelTop","setSentinelTop","sentinelBottom","setSentinelBottom","threshold","hasTopIntersection","get","isIntersecting","hasBottomIntersection","useMemo","partitionMulti","Children","toArray","headerChild","footerChild","content","headerChildProps","headerChildContent","footerChildProps","footerChildContent","isVisible","useDelayedVisibility","DIALOG_TRANSITION_DURATION","clickAwayRefs","createPortal","classNames","handleBasicClasses","isHidden","isShown","prefix","mergeRefs","ProgressVariant","circular","document","body","displayName","defaultProps"],"mappings":";;;;;;;;;;;;;;;AAIA;;;;;;;AAOO,SAASA,uBAAT,CACHC,QADG,EAEHC,OAFG,EAGa;AAAA,kBAC0BC,QAAQ,CAAmB;AAAA,WAAM,IAAIC,GAAJ,EAAN;AAAA,GAAnB,CADlC;AAAA;AAAA,MACTC,aADS;AAAA,MACMC,gBADN;;AAGhBC,EAAAA,SAAS,CACL,YAAM;AACF,QAAIN,QAAQ,CAACO,MAAT,GAAkB,CAAlB,IAAuB,CAACP,QAAQ,CAACQ,IAAT,CAAcC,OAAd,CAA5B,EAAoD;AAChD,aAAOC,SAAP;AACH;;AAED,QAAMC,QAAQ,GAAG,IAAIC,oBAAJ,CAAyB,UAACC,OAAD,EAAa;AAAA;AAAA;AAAA;;AAAA;AACnD,6BAAoBA,OAApB,8HAA6B;AAAA,cAAlBC,KAAkB;AACzBV,UAAAA,aAAa,CAACW,GAAd,CAAkBD,KAAK,CAACE,MAAxB,EAAqCF,KAArC;AACH;AAHkD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAInDT,MAAAA,gBAAgB,CAAC,IAAIF,GAAJ,CAAQC,aAAR,CAAD,CAAhB;AACH,KALgB,EAKdH,OALc,CAAjB;AALE;AAAA;AAAA;;AAAA;AAYF,4BAAsBD,QAAtB,mIAAgC;AAAA,YAArBiB,OAAqB;;AAC5B,YAAIA,OAAJ,EAAa;AACTN,UAAAA,QAAQ,CAACO,OAAT,CAAiBD,OAAjB;AACH;AACJ;AAhBC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAiBF,WAAO;AA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AAgB,CAAE1C,SAJD;AAFzB,MASKC,MATL,EAUK0C,kBAVL,CAFR,EAgBI;AAAK,IAAA,GAAG,EAAEa,SAAS,CAAC9C,UAAD,EAAaa,eAAb,CAAnB;AAAkD,IAAA,SAAS,YAAKnC,SAAL;AAA3D,KACI;AACI,IAAA,SAAS,YAAKA,SAAL,wBAA4BA,SAA5B,oBADb;AAEI,IAAA,GAAG,EAAEuC;AAFT,IADJ,EAMKc,OANL,EAQI;AACI,IAAA,SAAS,YAAKrD,SAAL,wBAA4BA,SAA5B,uBADb;AAEI,IAAA,GAAG,EAAEyC;AAFT,IARJ,CAhBJ,EA8BK,CAACxB,MAAM,IAAIwC,kBAAX,KACG,2CACQD,gBADR;AAEI,IAAA,SAAS,EAAEO,UAAU,WACd/D,SADc,eAEjB,CAACe,kBAAkB,IAAI+B,qBAAvB,eACO9C,SADP,0BAFiB,EAIjBwD,gBAJiB,aAIjBA,gBAJiB,uBAIjBA,gBAAgB,CAAE5C,SAJD;AAFzB,MASKK,MATL,EAUKwC,kBAVL,CA/BR,EA6CKvC,SAAS,IACN;AAAK,IAAA,SAAS,YAAKlB,SAAL;AAAd,KACI,oBAAC,QAAD;AAAU,IAAA,OAAO,EAAEqE,eAAe,CAACC;AAAnC,IADJ,CA9CR,CADJ,CADJ,CAjBJ,CADQ,EA0ERC,QAAQ,CAACC,IA1ED,CADX,GA6ED,IA7EN;AA8EH,CAtKkE;AAuKnElE,MAAM,CAACmE,WAAP,GAAqB1E,cAArB;AACAO,MAAM,CAACM,SAAP,GAAmBZ,SAAnB;AACAM,MAAM,CAACoE,YAAP,GAAsBxE,aAAtB;;;;"}
|
|
@@ -40,7 +40,7 @@ var DragHandle = forwardRef(function (props, ref) {
|
|
|
40
40
|
}))
|
|
41
41
|
}), React.createElement(Icon, {
|
|
42
42
|
icon: mdiDragVertical,
|
|
43
|
-
color: theme === Theme.dark ? ColorPalette.light :
|
|
43
|
+
color: theme === Theme.dark ? ColorPalette.light : ColorPalette.dark,
|
|
44
44
|
size: Size.xs
|
|
45
45
|
}));
|
|
46
46
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DragHandle.js","sources":["../../../src/components/drag-handle/DragHandle.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\n\nimport classNames from 'classnames';\n\nimport { mdiDragVertical } from '@lumx/icons';\nimport { ColorPalette, Icon, Size, Theme } from '@lumx/react';\nimport { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';\n\n/**\n * Defines the props of the component.\n */\nexport interface DragHandleProps extends GenericProps {\n /** Theme adapting the component to light or dark background. */\n theme?: Theme;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'DragHandle';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * DragHandle component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const DragHandle: Comp<DragHandleProps, HTMLDivElement> = forwardRef((props, ref) => {\n const { className, theme, ...forwardedProps } = props;\n\n return (\n <div\n ref={ref}\n {...forwardedProps}\n className={classNames(className, handleBasicClasses({ prefix: CLASSNAME, theme }))}\n >\n <Icon
|
|
1
|
+
{"version":3,"file":"DragHandle.js","sources":["../../../src/components/drag-handle/DragHandle.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\n\nimport classNames from 'classnames';\n\nimport { mdiDragVertical } from '@lumx/icons';\nimport { ColorPalette, Icon, Size, Theme } from '@lumx/react';\nimport { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';\n\n/**\n * Defines the props of the component.\n */\nexport interface DragHandleProps extends GenericProps {\n /** Theme adapting the component to light or dark background. */\n theme?: Theme;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'DragHandle';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * DragHandle component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const DragHandle: Comp<DragHandleProps, HTMLDivElement> = forwardRef((props, ref) => {\n const { className, theme, ...forwardedProps } = props;\n\n return (\n <div\n ref={ref}\n {...forwardedProps}\n className={classNames(className, handleBasicClasses({ prefix: CLASSNAME, theme }))}\n >\n <Icon\n icon={mdiDragVertical}\n color={theme === Theme.dark ? ColorPalette.light : ColorPalette.dark}\n size={Size.xs}\n />\n </div>\n );\n});\nDragHandle.displayName = COMPONENT_NAME;\nDragHandle.className = CLASSNAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","getRootClassName","DragHandle","forwardRef","props","ref","className","theme","forwardedProps","classNames","handleBasicClasses","prefix","mdiDragVertical","Theme","dark","ColorPalette","light","Size","xs","displayName"],"mappings":";;;;;;;AAQA;;;;AAQA;;;AAGA,IAAMA,cAAc,GAAG,YAAvB;AAEA;;;;AAGA,IAAMC,SAAS,GAAGC,gBAAgB,CAACF,cAAD,CAAlC;AAEA;;;;;;;;IAOaG,UAAiD,GAAGC,UAAU,CAAC,UAACC,KAAD,EAAQC,GAAR,EAAgB;AAAA,MAChFC,SADgF,GACxCF,KADwC,CAChFE,SADgF;AAAA,MACrEC,KADqE,GACxCH,KADwC,CACrEG,KADqE;AAAA,MAC3DC,cAD2D,4BACxCJ,KADwC;;AAGxF,SACI;AACI,IAAA,GAAG,EAAEC;AADT,KAEQG,cAFR;AAGI,IAAA,SAAS,EAAEC,UAAU,CAACH,SAAD,EAAYI,kBAAkB,CAAC;AAAEC,MAAAA,MAAM,EAAEX,SAAV;AAAqBO,MAAAA,KAAK,EAALA;AAArB,KAAD,CAA9B;AAHzB,MAKI,oBAAC,IAAD;AACI,IAAA,IAAI,EAAEK,eADV;AAEI,IAAA,KAAK,EAAEL,KAAK,KAAKM,KAAK,CAACC,IAAhB,GAAuBC,YAAY,CAACC,KAApC,GAA4CD,YAAY,CAACD,IAFpE;AAGI,IAAA,IAAI,EAAEG,IAAI,CAACC;AAHf,IALJ,CADJ;AAaH,CAhB0E;AAiB3EhB,UAAU,CAACiB,WAAX,GAAyBpB,cAAzB;AACAG,UAAU,CAACI,SAAX,GAAuBN,SAAvB;;;;"}
|
package/esm/_internal/Flag2.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { b as _objectWithoutProperties, c as _extends } from './_rollupPluginBabelHelpers.js';
|
|
2
|
-
import {
|
|
2
|
+
import { Size, Theme, ColorPalette } from './components.js';
|
|
3
3
|
import React, { forwardRef } from 'react';
|
|
4
4
|
import { g as getRootClassName, c as classnames, h as handleBasicClasses } from './getRootClassName.js';
|
|
5
5
|
import { I as Icon } from './Icon2.js';
|
|
@@ -34,8 +34,6 @@ var Flag = forwardRef(function (props, ref) {
|
|
|
34
34
|
ref: ref
|
|
35
35
|
}), icon && React.createElement(Icon, {
|
|
36
36
|
icon: icon,
|
|
37
|
-
color: color,
|
|
38
|
-
colorVariant: ColorVariant.D2,
|
|
39
37
|
size: Size.xxs,
|
|
40
38
|
className: "".concat(CLASSNAME, "__icon")
|
|
41
39
|
}), React.createElement("span", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Flag2.js","sources":["../../../src/components/flag/Flag.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\nimport classNames from 'classnames';\n\nimport { ColorPalette,
|
|
1
|
+
{"version":3,"file":"Flag2.js","sources":["../../../src/components/flag/Flag.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\nimport classNames from 'classnames';\n\nimport { ColorPalette, Icon, Size, Theme } from '@lumx/react';\nimport { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';\n\nexport interface FlagProps extends GenericProps {\n /** Theme adapting the component to light or dark background. */\n theme?: Theme;\n /** Color of the component. */\n color?: ColorPalette;\n /** Icon to use before the label. */\n icon?: string;\n /** Text label of the flag. */\n label: string;\n}\n\nconst COMPONENT_NAME = 'Flag';\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\nconst DEFAULT_PROPS: Partial<FlagProps> = {\n theme: Theme.light,\n};\n\n/**\n * Flag component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const Flag: Comp<FlagProps, HTMLDivElement> = forwardRef((props, ref) => {\n const { label, icon, color, className, theme, ...forwardedProps } = props;\n const flagColor = color || (theme === Theme.light ? ColorPalette.dark : ColorPalette.light);\n\n return (\n <div\n {...forwardedProps}\n className={classNames(className, handleBasicClasses({ prefix: CLASSNAME, color: flagColor }))}\n ref={ref}\n >\n {icon && <Icon icon={icon} size={Size.xxs} className={`${CLASSNAME}__icon`} />}\n <span className={`${CLASSNAME}__label`}>{label}</span>\n </div>\n );\n});\nFlag.displayName = COMPONENT_NAME;\nFlag.className = CLASSNAME;\nFlag.defaultProps = DEFAULT_PROPS;\n"],"names":["COMPONENT_NAME","CLASSNAME","getRootClassName","DEFAULT_PROPS","theme","Theme","light","Flag","forwardRef","props","ref","label","icon","color","className","forwardedProps","flagColor","ColorPalette","dark","classNames","handleBasicClasses","prefix","Size","xxs","displayName","defaultProps"],"mappings":";;;;;;AAiBA,IAAMA,cAAc,GAAG,MAAvB;AACA,IAAMC,SAAS,GAAGC,gBAAgB,CAACF,cAAD,CAAlC;AACA,IAAMG,aAAiC,GAAG;AACtCC,EAAAA,KAAK,EAAEC,KAAK,CAACC;AADyB,CAA1C;AAIA;;;;;;;;IAOaC,IAAqC,GAAGC,UAAU,CAAC,UAACC,KAAD,EAAQC,GAAR,EAAgB;AAAA,MACpEC,KADoE,GACRF,KADQ,CACpEE,KADoE;AAAA,MAC7DC,IAD6D,GACRH,KADQ,CAC7DG,IAD6D;AAAA,MACvDC,KADuD,GACRJ,KADQ,CACvDI,KADuD;AAAA,MAChDC,SADgD,GACRL,KADQ,CAChDK,SADgD;AAAA,MACrCV,KADqC,GACRK,KADQ,CACrCL,KADqC;AAAA,MAC3BW,cAD2B,4BACRN,KADQ;;AAE5E,MAAMO,SAAS,GAAGH,KAAK,KAAKT,KAAK,KAAKC,KAAK,CAACC,KAAhB,GAAwBW,YAAY,CAACC,IAArC,GAA4CD,YAAY,CAACX,KAA9D,CAAvB;AAEA,SACI,wCACQS,cADR;AAEI,IAAA,SAAS,EAAEI,UAAU,CAACL,SAAD,EAAYM,kBAAkB,CAAC;AAAEC,MAAAA,MAAM,EAAEpB,SAAV;AAAqBY,MAAAA,KAAK,EAAEG;AAA5B,KAAD,CAA9B,CAFzB;AAGI,IAAA,GAAG,EAAEN;AAHT,MAKKE,IAAI,IAAI,oBAAC,IAAD;AAAM,IAAA,IAAI,EAAEA,IAAZ;AAAkB,IAAA,IAAI,EAAEU,IAAI,CAACC,GAA7B;AAAkC,IAAA,SAAS,YAAKtB,SAAL;AAA3C,IALb,EAMI;AAAM,IAAA,SAAS,YAAKA,SAAL;AAAf,KAAyCU,KAAzC,CANJ,CADJ;AAUH,CAd8D;AAe/DJ,IAAI,CAACiB,WAAL,GAAmBxB,cAAnB;AACAO,IAAI,CAACO,SAAL,GAAiBb,SAAjB;AACAM,IAAI,CAACkB,YAAL,GAAoBtB,aAApB;;;;"}
|
|
@@ -64,11 +64,11 @@ var Message = forwardRef(function (props, ref) {
|
|
|
64
64
|
prefix: CLASSNAME
|
|
65
65
|
}))
|
|
66
66
|
}, forwardedProps), (customIcon || icon) && React.createElement(Icon, {
|
|
67
|
-
className: "
|
|
67
|
+
className: "".concat(CLASSNAME, "__icon"),
|
|
68
68
|
icon: customIcon || icon,
|
|
69
69
|
size: Size.xs
|
|
70
70
|
}), React.createElement("div", {
|
|
71
|
-
className: "
|
|
71
|
+
className: "".concat(CLASSNAME, "__text")
|
|
72
72
|
}, children));
|
|
73
73
|
});
|
|
74
74
|
Message.displayName = COMPONENT_NAME;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Message2.js","sources":["../../../src/components/message/Message.tsx"],"sourcesContent":["import { mdiAlert, mdiAlertCircle, mdiCheckCircle, mdiInformation } from '@lumx/icons';\nimport { ColorPalette, Icon, Kind, Size } from '@lumx/react';\nimport { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';\nimport classNames from 'classnames';\nimport React, { forwardRef, ReactNode } from 'react';\n\n/**\n * Defines the props of the component.\n */\nexport interface MessageProps extends GenericProps {\n /** Content. */\n children?: ReactNode;\n /** Whether the message has a background or not. */\n hasBackground?: boolean;\n /** Message variant. */\n kind?: Kind;\n /** Message custom icon SVG path. */\n icon?: string;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'Message';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * Associative map from message kind to color and icon.\n */\nconst CONFIG = {\n [Kind.error]: { color: ColorPalette.red, icon: mdiAlert },\n [Kind.info]: { color: ColorPalette.dark, icon: mdiInformation },\n [Kind.success]: { color: ColorPalette.green, icon: mdiCheckCircle },\n [Kind.warning]: { color: ColorPalette.yellow, icon: mdiAlertCircle },\n};\n\n/**\n * Message component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const Message: Comp<MessageProps, HTMLDivElement> = forwardRef((props, ref) => {\n const { children, className, hasBackground, kind, icon: customIcon, ...forwardedProps } = props;\n const { color, icon } = CONFIG[kind as Kind] || {};\n\n return (\n <div\n ref={ref}\n className={classNames(\n className,\n handleBasicClasses({\n color,\n hasBackground,\n prefix: CLASSNAME,\n }),\n )}\n {...forwardedProps}\n >\n {(customIcon || icon) && <Icon className
|
|
1
|
+
{"version":3,"file":"Message2.js","sources":["../../../src/components/message/Message.tsx"],"sourcesContent":["import { mdiAlert, mdiAlertCircle, mdiCheckCircle, mdiInformation } from '@lumx/icons';\nimport { ColorPalette, Icon, Kind, Size } from '@lumx/react';\nimport { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';\nimport classNames from 'classnames';\nimport React, { forwardRef, ReactNode } from 'react';\n\n/**\n * Defines the props of the component.\n */\nexport interface MessageProps extends GenericProps {\n /** Content. */\n children?: ReactNode;\n /** Whether the message has a background or not. */\n hasBackground?: boolean;\n /** Message variant. */\n kind?: Kind;\n /** Message custom icon SVG path. */\n icon?: string;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'Message';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * Associative map from message kind to color and icon.\n */\nconst CONFIG = {\n [Kind.error]: { color: ColorPalette.red, icon: mdiAlert },\n [Kind.info]: { color: ColorPalette.dark, icon: mdiInformation },\n [Kind.success]: { color: ColorPalette.green, icon: mdiCheckCircle },\n [Kind.warning]: { color: ColorPalette.yellow, icon: mdiAlertCircle },\n};\n\n/**\n * Message component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const Message: Comp<MessageProps, HTMLDivElement> = forwardRef((props, ref) => {\n const { children, className, hasBackground, kind, icon: customIcon, ...forwardedProps } = props;\n const { color, icon } = CONFIG[kind as Kind] || {};\n\n return (\n <div\n ref={ref}\n className={classNames(\n className,\n handleBasicClasses({\n color,\n hasBackground,\n prefix: CLASSNAME,\n }),\n )}\n {...forwardedProps}\n >\n {(customIcon || icon) && <Icon className={`${CLASSNAME}__icon`} icon={customIcon || icon} size={Size.xs} />}\n <div className={`${CLASSNAME}__text`}>{children}</div>\n </div>\n );\n});\nMessage.displayName = COMPONENT_NAME;\nMessage.className = CLASSNAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","getRootClassName","CONFIG","Kind","error","color","ColorPalette","red","icon","mdiAlert","info","dark","mdiInformation","success","green","mdiCheckCircle","warning","yellow","mdiAlertCircle","Message","forwardRef","props","ref","children","className","hasBackground","kind","customIcon","forwardedProps","classNames","handleBasicClasses","prefix","Size","xs","displayName"],"mappings":";;;;;;;;AAMA;;;;AAcA;;;AAGA,IAAMA,cAAc,GAAG,SAAvB;AAEA;;;;AAGA,IAAMC,SAAS,GAAGC,gBAAgB,CAACF,cAAD,CAAlC;AAEA;;;;AAGA,IAAMG,MAAM,2CACPC,IAA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oBAAC,IAAD;AAAM,IAAA,SAAS,YAAKR,SAAL,WAAf;AAAuC,IAAA,IAAI,EAAE2B,UAAU,IAAInB,IAA3D;AAAiE,IAAA,IAAI,EAAEwB,IAAI,CAACC;AAA5E,IAZ7B,EAaI;AAAK,IAAA,SAAS,YAAKjC,SAAL;AAAd,KAAuCuB,QAAvC,CAbJ,CADJ;AAiBH,CArBoE;AAsBrEJ,OAAO,CAACe,WAAR,GAAsBnC,cAAtB;AACAoB,OAAO,CAACK,SAAR,GAAoBxB,SAApB;;;;"}
|
|
@@ -302,9 +302,9 @@ function useKeyNavigate(element, onNext, onPrevious) {
|
|
|
302
302
|
var callback;
|
|
303
303
|
|
|
304
304
|
if ((evt === null || evt === void 0 ? void 0 : evt.key) === 'ArrowRight') {
|
|
305
|
-
callback = onPrevious;
|
|
306
|
-
} else if ((evt === null || evt === void 0 ? void 0 : evt.key) === 'ArrowLeft') {
|
|
307
305
|
callback = onNext;
|
|
306
|
+
} else if ((evt === null || evt === void 0 ? void 0 : evt.key) === 'ArrowLeft') {
|
|
307
|
+
callback = onPrevious;
|
|
308
308
|
}
|
|
309
309
|
|
|
310
310
|
if (!callback) return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SlideshowControls.js","sources":["../../../src/components/slideshow/constants.ts","../../../src/hooks/useInterval.tsx","../../../src/components/slideshow/Slideshow.tsx","../../../src/components/slideshow/SlideshowItem.tsx","../../../src/components/slideshow/useSwipeNavigate.ts","../../../src/components/slideshow/useKeyNavigate.ts","../../../src/components/slideshow/usePaginationVisibleRange.ts","../../../src/components/slideshow/SlideshowControls.tsx"],"sourcesContent":["/**\n * Autoplay default interval in ms.\n */\nexport const AUTOPLAY_DEFAULT_INTERVAL = 5000;\n\n/**\n * Full width size in percent.\n */\nexport const FULL_WIDTH_PERCENT = 100;\n\n/**\n * Edge from the active index.\n */\nexport const EDGE_FROM_ACTIVE_INDEX = 2;\n\n/**\n * Max number of pagination items.\n */\nexport const PAGINATION_ITEMS_MAX = 5;\n\n/**\n * Size of a pagination item. Used to translate wrapper.\n */\nexport const PAGINATION_ITEM_SIZE = 12;\n","import { useEffect, useRef } from 'react';\n\nimport isFunction from 'lodash/isFunction';\nimport { Callback } from '../utils';\n\n/**\n * Making setInterval Declarative with React Hooks.\n * Credits: https://overreacted.io/making-setinterval-declarative-with-react-hooks/\n *\n * @param callback Function called by setInterval.\n * @param delay Delay for setInterval.\n */\nexport function useInterval(callback: Callback, delay: number | null): void {\n const savedCallback = useRef<Callback>();\n\n useEffect(() => {\n savedCallback.current = callback;\n });\n\n useEffect(() => {\n if (delay === null) return undefined;\n\n function tick() {\n if (isFunction(savedCallback.current)) {\n savedCallback.current();\n }\n }\n const id = setInterval(tick, delay);\n return () => clearInterval(id);\n }, [delay]);\n}\n","import React, { CSSProperties, forwardRef, useCallback, useEffect, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport { SlideshowControls, SlideshowControlsProps, Theme } from '@lumx/react';\n\nimport { AUTOPLAY_DEFAULT_INTERVAL, FULL_WIDTH_PERCENT } from '@lumx/react/components/slideshow/constants';\nimport { useInterval } from '@lumx/react/hooks/useInterval';\nimport { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';\nimport { mergeRefs } from '@lumx/react/utils/mergeRefs';\n\n/**\n * Defines the props of the component.\n */\nexport interface SlideshowProps extends GenericProps {\n /** Index of the current slide. */\n activeIndex?: number;\n /** Whether the automatic rotation of the slideshow is enabled or not. */\n autoPlay?: boolean;\n /** Whether the image has to fill its container height or not. */\n fillHeight?: boolean;\n /** Number of slides to group together. */\n groupBy?: number;\n /** Interval between each slide when automatic rotation is enabled. */\n interval?: number;\n /** Props to pass to the slideshow controls (minus those already set by the Slideshow props). */\n slideshowControlsProps?: Pick<SlideshowControlsProps, 'nextButtonProps' | 'previousButtonProps'> &\n Omit<\n SlideshowControlsProps,\n | 'activeIndex'\n | 'onPaginationClick'\n | 'onNextClick'\n | 'onPreviousClick'\n | 'slidesCount'\n | 'parentRef'\n | 'theme'\n >;\n /** Theme adapting the component to light or dark background. */\n theme?: Theme;\n /** Callback when slide changes */\n onChange?(index: number): void;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'Slideshow';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * Component default props.\n */\nconst DEFAULT_PROPS: Partial<SlideshowProps> = {\n activeIndex: 0,\n groupBy: 1,\n interval: AUTOPLAY_DEFAULT_INTERVAL,\n theme: Theme.light,\n};\n\n/**\n * Slideshow component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const Slideshow: Comp<SlideshowProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n activeIndex,\n autoPlay,\n children,\n className,\n fillHeight,\n groupBy,\n interval,\n onChange,\n slideshowControlsProps,\n theme,\n ...forwardedProps\n } = props;\n const [currentIndex, setCurrentIndex] = useState(activeIndex as number);\n // Use state instead of a ref to make the slideshow controls update directly when the element is set.\n const [element, setElement] = useState<HTMLDivElement>();\n\n // Number of slideshow items.\n const itemsCount = React.Children.count(children);\n // Number of slides when using groupBy prop.\n const slidesCount = Math.ceil(itemsCount / Math.min(groupBy as number, itemsCount));\n // Inline style of wrapper element.\n const wrapperStyle: CSSProperties = { transform: `translateX(-${FULL_WIDTH_PERCENT * currentIndex}%)` };\n\n // Change current index to display next slide.\n const goToNextSlide = useCallback(\n (loopback = true) => {\n setCurrentIndex((index) => {\n if (loopback && index === slidesCount - 1) {\n // Loopback to the start.\n return 0;\n }\n if (index < slidesCount - 1) {\n // Next slide.\n return index + 1;\n }\n return index;\n });\n },\n [slidesCount, setCurrentIndex],\n );\n\n // Change current index to display previous slide.\n const goToPreviousSlide = useCallback(\n (loopback = true) => {\n setCurrentIndex((index) => {\n if (loopback && index === 0) {\n // Loopback to the end.\n return slidesCount - 1;\n }\n if (index > 0) {\n // Previous slide.\n return index - 1;\n }\n return index;\n });\n },\n [slidesCount, setCurrentIndex],\n );\n\n // Auto play\n const [isAutoPlaying, setIsAutoPlaying] = useState(Boolean(autoPlay));\n // Start\n useInterval(goToNextSlide, isAutoPlaying && slidesCount > 1 ? (interval as number) : null);\n\n // Reset current index if it become invalid.\n useEffect(() => {\n if (currentIndex > slidesCount - 1) {\n setCurrentIndex(DEFAULT_PROPS.activeIndex as number);\n }\n }, [currentIndex, slidesCount]);\n\n // Handle click on a bullet to go to a specific slide.\n const handleControlGotToSlide = useCallback(\n (index: number) => {\n setIsAutoPlaying(false);\n\n if (index >= 0 && index < slidesCount) {\n setCurrentIndex(index);\n }\n },\n [slidesCount, setCurrentIndex],\n );\n\n // Handle click or keyboard event to go to next slide.\n const handleControlNextSlide = useCallback(\n (loopback = true) => {\n setIsAutoPlaying(false);\n goToNextSlide(loopback);\n },\n [goToNextSlide],\n );\n\n // Handle click or keyboard event to go to previous slide.\n const handleControlPreviousSlide = useCallback(\n (loopback = true) => {\n setIsAutoPlaying(false);\n goToPreviousSlide(loopback);\n },\n [goToPreviousSlide],\n );\n\n // If the activeIndex props changes, update the current slide\n useEffect(() => {\n setCurrentIndex(activeIndex as number);\n }, [activeIndex]);\n\n // If the slide changes, with autoplay for example, trigger \"onChange\"\n useEffect(() => {\n if (!onChange) return;\n onChange(currentIndex);\n }, [currentIndex, onChange]);\n\n /* eslint-disable jsx-a11y/no-noninteractive-tabindex */\n return (\n <div\n ref={mergeRefs(ref, setElement)}\n {...forwardedProps}\n className={classNames(className, handleBasicClasses({ prefix: CLASSNAME, theme }), {\n [`${CLASSNAME}--fill-height`]: fillHeight,\n [`${CLASSNAME}--group-by-${groupBy}`]: Boolean(groupBy),\n })}\n tabIndex={0}\n >\n <div className={`${CLASSNAME}__slides`}>\n <div className={`${CLASSNAME}__wrapper`} style={wrapperStyle}>\n {children}\n </div>\n </div>\n\n {slideshowControlsProps && slidesCount > 1 && (\n <div className={`${CLASSNAME}__controls`}>\n <SlideshowControls\n {...slideshowControlsProps}\n activeIndex={currentIndex}\n onPaginationClick={handleControlGotToSlide}\n onNextClick={handleControlNextSlide}\n onPreviousClick={handleControlPreviousSlide}\n slidesCount={slidesCount}\n parentRef={element}\n theme={theme}\n />\n </div>\n )}\n </div>\n );\n});\nSlideshow.displayName = COMPONENT_NAME;\nSlideshow.className = CLASSNAME;\nSlideshow.defaultProps = DEFAULT_PROPS;\n","import React, { forwardRef } from 'react';\n\nimport classNames from 'classnames';\n\nimport { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';\n\n/**\n * Defines the props of the component.\n */\nexport type SlideshowItemProps = GenericProps;\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'SlideshowItem';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * SlideshowItem component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const SlideshowItem: Comp<SlideshowItemProps, HTMLDivElement> = forwardRef((props, ref) => {\n const { className, children, ...forwardedProps } = props;\n\n return (\n <div\n ref={ref}\n {...forwardedProps}\n className={classNames(\n className,\n handleBasicClasses({\n prefix: CLASSNAME,\n }),\n )}\n >\n {children}\n </div>\n );\n});\nSlideshowItem.displayName = COMPONENT_NAME;\nSlideshowItem.className = CLASSNAME;\n","import { useEffect } from 'react';\nimport { detectHorizontalSwipe } from '@lumx/core/js/utils';\n\nconst isTouchDevice = () => 'ontouchstart' in window;\n\n/**\n * Listen swipe to navigate left and right.\n */\nexport function useSwipeNavigate(element?: HTMLElement | null, onNext?: () => void, onPrevious?: () => void): void {\n useEffect(() => {\n if (!element || !isTouchDevice()) return undefined;\n\n return detectHorizontalSwipe(element, (swipe) => {\n const callback = swipe === 'right' ? onPrevious : onNext;\n callback?.();\n });\n }, [onPrevious, onNext, element]);\n}\n","import { useEffect } from 'react';\n\n/**\n * Listen keyboard to navigate left and right.\n */\nexport function useKeyNavigate(element?: HTMLElement | null, onNext?: () => void, onPrevious?: () => void): void {\n useEffect(() => {\n if (!element) return undefined;\n const onKeyNavigate = (evt: KeyboardEvent) => {\n let callback;\n if (evt?.key === 'ArrowRight') {\n callback = onPrevious;\n } else if (evt?.key === 'ArrowLeft') {\n callback = onNext;\n }\n if (!callback) return;\n\n callback();\n evt.preventDefault();\n evt.stopPropagation();\n };\n\n element.addEventListener('keydown', onKeyNavigate);\n return () => {\n element.removeEventListener('keydown', onKeyNavigate);\n };\n }, [onPrevious, onNext, element]);\n}\n","import { useMemo, useRef } from 'react';\nimport { EDGE_FROM_ACTIVE_INDEX, PAGINATION_ITEMS_MAX } from '@lumx/react/components/slideshow/constants';\n\ntype Range = { min: number; max: number };\n\n/**\n * Calculate the currently visible pagination \"bullet\" range.\n */\nexport function usePaginationVisibleRange(activeIndex: number, slideCount: number): Range {\n const previousVisibleRangeRef = useRef<Range>();\n return useMemo(() => {\n const lastSlide = slideCount - 1;\n const { current: previousVisibleRange } = previousVisibleRangeRef;\n let newVisibleRange: Range;\n if (activeIndex === previousVisibleRange?.max && activeIndex < lastSlide) {\n newVisibleRange = { min: previousVisibleRange.min + 1, max: previousVisibleRange.max + 1 };\n } else if (activeIndex === previousVisibleRange?.min && activeIndex > 0) {\n newVisibleRange = { min: previousVisibleRange.min - 1, max: previousVisibleRange.max - 1 };\n } else {\n const deltaItems = PAGINATION_ITEMS_MAX - 1;\n let min = activeIndex - EDGE_FROM_ACTIVE_INDEX;\n let max = activeIndex + EDGE_FROM_ACTIVE_INDEX;\n\n if (activeIndex > lastSlide - EDGE_FROM_ACTIVE_INDEX) {\n min = lastSlide - deltaItems;\n max = lastSlide;\n } else if (activeIndex < deltaItems) {\n min = 0;\n max = deltaItems;\n }\n\n newVisibleRange = { min, max };\n }\n previousVisibleRangeRef.current = newVisibleRange;\n return newVisibleRange;\n }, [activeIndex, slideCount]);\n}\n","import React, { forwardRef, RefObject, useCallback, useMemo } from 'react';\n\nimport classNames from 'classnames';\nimport range from 'lodash/range';\n\nimport { mdiChevronLeft, mdiChevronRight } from '@lumx/icons';\nimport { Emphasis, IconButton, IconButtonProps, Theme } from '@lumx/react';\nimport { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';\nimport { WINDOW } from '@lumx/react/constants';\n\nimport { useSwipeNavigate } from './useSwipeNavigate';\nimport { useKeyNavigate } from './useKeyNavigate';\nimport { PAGINATION_ITEM_SIZE, PAGINATION_ITEMS_MAX } from './constants';\nimport { usePaginationVisibleRange } from './usePaginationVisibleRange';\n\n/**\n * Defines the props of the component.\n */\nexport interface SlideshowControlsProps extends GenericProps {\n /** Index of the current slide. */\n activeIndex?: number;\n /** Props to pass to the next button (minus those already set by the SlideshowControls props). */\n nextButtonProps: Pick<IconButtonProps, 'label'> &\n Omit<IconButtonProps, 'label' | 'onClick' | 'icon' | 'emphasis' | 'color'>;\n /** Reference to the parent element on which we want to listen touch swipe. */\n parentRef?: RefObject<HTMLDivElement> | HTMLDivElement;\n /** Props to pass to the previous button (minus those already set by the SlideshowControls props). */\n previousButtonProps: Pick<IconButtonProps, 'label'> &\n Omit<IconButtonProps, 'label' | 'onClick' | 'icon' | 'emphasis' | 'color'>;\n /** Number of slides. */\n slidesCount: number;\n /** Theme adapting the component to light or dark background. */\n theme?: Theme;\n /** On next button click callback. */\n onNextClick?(loopback?: boolean): void;\n /** On pagination change callback. */\n onPaginationClick?(index: number): void;\n /** On previous button click callback. */\n onPreviousClick?(loopback?: boolean): void;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'SlideshowControls';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * Component default props.\n */\nconst DEFAULT_PROPS: Partial<SlideshowControlsProps> = {\n activeIndex: 0,\n theme: Theme.light,\n};\n\n/**\n * SlideshowControls component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const SlideshowControls: Comp<SlideshowControlsProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n activeIndex,\n className,\n nextButtonProps,\n onNextClick,\n onPaginationClick,\n onPreviousClick,\n parentRef,\n previousButtonProps,\n slidesCount,\n theme,\n ...forwardedProps\n } = props;\n\n let parent;\n if (WINDOW) {\n // Checking window object to avoid errors in SSR.\n parent = parentRef instanceof HTMLElement ? parentRef : parentRef?.current;\n }\n // Listen to keyboard navigate left & right.\n useKeyNavigate(parent, onNextClick, onPreviousClick);\n // Listen to touch swipe navigate left & right.\n useSwipeNavigate(\n parent,\n // Go next without loopback.\n useCallback(() => onNextClick?.(false), [onNextClick]),\n // Go previous without loopback.\n useCallback(() => onPreviousClick?.(false), [onPreviousClick]),\n );\n\n // Pagination \"bullet\" range.\n const visibleRange = usePaginationVisibleRange(activeIndex as number, slidesCount);\n\n // Inline style of wrapper element.\n const wrapperStyle = { transform: `translateX(-${PAGINATION_ITEM_SIZE * visibleRange.min}px)` };\n\n return (\n <div\n ref={ref}\n {...forwardedProps}\n className={classNames(className, handleBasicClasses({ prefix: CLASSNAME, theme }), {\n [`${CLASSNAME}--has-infinite-pagination`]: slidesCount > PAGINATION_ITEMS_MAX,\n })}\n >\n <IconButton\n {...previousButtonProps}\n icon={mdiChevronLeft}\n className={`${CLASSNAME}__navigation`}\n color={theme === Theme.dark ? 'light' : 'dark'}\n emphasis={Emphasis.low}\n onClick={onPreviousClick}\n tabIndex={-1}\n />\n <div className={`${CLASSNAME}__pagination`}>\n <div className={`${CLASSNAME}__pagination-items`} style={wrapperStyle}>\n {useMemo(\n () =>\n range(slidesCount).map((index) => {\n const isOnEdge =\n index !== 0 &&\n index !== slidesCount - 1 &&\n (index === visibleRange.min || index === visibleRange.max);\n const isActive = activeIndex === index;\n const isOutRange = index < visibleRange.min || index > visibleRange.max;\n return (\n // eslint-disable-next-line jsx-a11y/control-has-associated-label\n <button\n className={classNames(\n handleBasicClasses({\n prefix: `${CLASSNAME}__pagination-item`,\n isActive,\n isOnEdge,\n isOutRange,\n }),\n )}\n key={index}\n type=\"button\"\n onClick={() => onPaginationClick?.(index)}\n tabIndex={-1}\n />\n );\n }),\n [slidesCount, visibleRange.min, visibleRange.max, activeIndex, onPaginationClick],\n )}\n </div>\n </div>\n <IconButton\n {...nextButtonProps}\n icon={mdiChevronRight}\n className={`${CLASSNAME}__navigation`}\n color={theme === Theme.dark ? 'light' : 'dark'}\n emphasis={Emphasis.low}\n onClick={onNextClick}\n tabIndex={-1}\n />\n </div>\n );\n});\nSlideshowControls.displayName = COMPONENT_NAME;\nSlideshowControls.className = CLASSNAME;\nSlideshowControls.defaultProps = DEFAULT_PROPS;\n"],"names":["AUTOPLAY_DEFAULT_INTERVAL","FULL_WIDTH_PERCENT","EDGE_FROM_ACTIVE_INDEX","PAGINATION_ITEMS_MAX","PAGINATION_ITEM_SIZE","useInterval","callback","delay","savedCallback","useRef","useEffect","current","undefined","tick","isFunction","id","setInterval","clearInterval","COMPONENT_NAME","CLASSNAME","getRootClassName","DEFAULT_PROPS","activeIndex","groupBy","interval","theme","Theme","light","Slideshow","forwardRef","props","ref","autoPlay","children","className","fillHeight","onChange","slideshowControlsProps","forwardedProps","useState","currentIndex","setCurrentIndex","element","setElement","itemsCount","React","Children","count","slidesCount","Math","ceil","min","wrapperStyle","transform","goToNextSlide","useCallback","loopback","index","goToPreviousSlide","Boolean","isAutoPlaying","setIsAutoPlaying","handleControlGotToSlide","handleControlNextSlide","handleControlPreviousSlide","mergeRefs","classNames","handleBasicClasses","prefix","displayName","defaultProps","SlideshowItem","isTouchDevice","window","useSwipeNavigate","onNext","onPrevious","detectHorizontalSwipe","swipe","useKeyNavigate","onKeyNavigate","evt","key","preventDefault","stopPropagation","addEventListener","removeEventListener","usePaginationVisibleRange","slideCount","previousVisibleRangeRef","useMemo","lastSlide","previousVisibleRange","newVisibleRange","max","deltaItems","SlideshowControls","nextButtonProps","onNextClick","onPaginationClick","onPreviousClick","parentRef","previousButtonProps","parent","WINDOW","HTMLElement","visibleRange","mdiChevronLeft","dark","Emphasis","low","range","map","isOnEdge","isActive","isOutRange","mdiChevronRight"],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AA,QAAQ,EAARA,QAHe;AAIfE,YAAAA,UAAU,EAAVA;AAJe,WAAD,CADD,CADzB;AASI,UAAA,GAAG,EAAE1D,KATT;AAUI,UAAA,IAAI,EAAC,QAVT;AAWI,UAAA,OAAO,EAAE;AAAA,mBAAM0C,iBAAN,aAAMA,iBAAN,uBAAMA,iBAAiB,CAAG1C,KAAH,CAAvB;AAAA,WAXb;AAYI,UAAA,QAAQ,EAAE,CAAC;AAZf;AAFJ;AAiBH,KAxBD,CADJ;AAAA,GADI,EA2BJ,CAACT,WAAD,EAAc0D,YAAY,CAACvD,GAA3B,EAAgCuD,YAAY,CAACZ,GAA7C,EAAkDxE,WAAlD,EAA+D6E,iBAA/D,CA3BI,CADZ,CADJ,CAhBJ,EAiDI,oBAAC,UAAD,eACQF,eADR;AAEI,IAAA,IAAI,EAAEmB,eAFV;AAGI,IAAA,SAAS,YAAKjG,WAAL,iBAHb;AAII,IAAA,KAAK,EAAEM,KAAK,KAAKC,KAAK,CAACkF,IAAhB,GAAuB,OAAvB,GAAiC,MAJ5C;AAKI,IAAA,QAAQ,EAAEC,QAAQ,CAACC,GALvB;AAMI,IAAA,OAAO,EAAEZ,WANb;AAOI,IAAA,QAAQ,EAAE,CAAC;AAPf,KAjDJ,CADJ;AA6DH,CAlGwF;AAmGzFF,iBAAiB,CAAC3B,WAAlB,GAAgCnD,gBAAhC;AACA8E,iBAAiB,CAAC9D,SAAlB,GAA8Bf,WAA9B;AACA6E,iBAAiB,CAAC1B,YAAlB,GAAiCjD,eAAjC;;;;"}
|
|
1
|
+
{"version":3,"file":"SlideshowControls.js","sources":["../../../src/components/slideshow/constants.ts","../../../src/hooks/useInterval.tsx","../../../src/components/slideshow/Slideshow.tsx","../../../src/components/slideshow/SlideshowItem.tsx","../../../src/components/slideshow/useSwipeNavigate.ts","../../../src/components/slideshow/useKeyNavigate.ts","../../../src/components/slideshow/usePaginationVisibleRange.ts","../../../src/components/slideshow/SlideshowControls.tsx"],"sourcesContent":["/**\n * Autoplay default interval in ms.\n */\nexport const AUTOPLAY_DEFAULT_INTERVAL = 5000;\n\n/**\n * Full width size in percent.\n */\nexport const FULL_WIDTH_PERCENT = 100;\n\n/**\n * Edge from the active index.\n */\nexport const EDGE_FROM_ACTIVE_INDEX = 2;\n\n/**\n * Max number of pagination items.\n */\nexport const PAGINATION_ITEMS_MAX = 5;\n\n/**\n * Size of a pagination item. Used to translate wrapper.\n */\nexport const PAGINATION_ITEM_SIZE = 12;\n","import { useEffect, useRef } from 'react';\n\nimport isFunction from 'lodash/isFunction';\nimport { Callback } from '../utils';\n\n/**\n * Making setInterval Declarative with React Hooks.\n * Credits: https://overreacted.io/making-setinterval-declarative-with-react-hooks/\n *\n * @param callback Function called by setInterval.\n * @param delay Delay for setInterval.\n */\nexport function useInterval(callback: Callback, delay: number | null): void {\n const savedCallback = useRef<Callback>();\n\n useEffect(() => {\n savedCallback.current = callback;\n });\n\n useEffect(() => {\n if (delay === null) return undefined;\n\n function tick() {\n if (isFunction(savedCallback.current)) {\n savedCallback.current();\n }\n }\n const id = setInterval(tick, delay);\n return () => clearInterval(id);\n }, [delay]);\n}\n","import React, { CSSProperties, forwardRef, useCallback, useEffect, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport { SlideshowControls, SlideshowControlsProps, Theme } from '@lumx/react';\n\nimport { AUTOPLAY_DEFAULT_INTERVAL, FULL_WIDTH_PERCENT } from '@lumx/react/components/slideshow/constants';\nimport { useInterval } from '@lumx/react/hooks/useInterval';\nimport { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';\nimport { mergeRefs } from '@lumx/react/utils/mergeRefs';\n\n/**\n * Defines the props of the component.\n */\nexport interface SlideshowProps extends GenericProps {\n /** Index of the current slide. */\n activeIndex?: number;\n /** Whether the automatic rotation of the slideshow is enabled or not. */\n autoPlay?: boolean;\n /** Whether the image has to fill its container height or not. */\n fillHeight?: boolean;\n /** Number of slides to group together. */\n groupBy?: number;\n /** Interval between each slide when automatic rotation is enabled. */\n interval?: number;\n /** Props to pass to the slideshow controls (minus those already set by the Slideshow props). */\n slideshowControlsProps?: Pick<SlideshowControlsProps, 'nextButtonProps' | 'previousButtonProps'> &\n Omit<\n SlideshowControlsProps,\n | 'activeIndex'\n | 'onPaginationClick'\n | 'onNextClick'\n | 'onPreviousClick'\n | 'slidesCount'\n | 'parentRef'\n | 'theme'\n >;\n /** Theme adapting the component to light or dark background. */\n theme?: Theme;\n /** Callback when slide changes */\n onChange?(index: number): void;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'Slideshow';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * Component default props.\n */\nconst DEFAULT_PROPS: Partial<SlideshowProps> = {\n activeIndex: 0,\n groupBy: 1,\n interval: AUTOPLAY_DEFAULT_INTERVAL,\n theme: Theme.light,\n};\n\n/**\n * Slideshow component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const Slideshow: Comp<SlideshowProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n activeIndex,\n autoPlay,\n children,\n className,\n fillHeight,\n groupBy,\n interval,\n onChange,\n slideshowControlsProps,\n theme,\n ...forwardedProps\n } = props;\n const [currentIndex, setCurrentIndex] = useState(activeIndex as number);\n // Use state instead of a ref to make the slideshow controls update directly when the element is set.\n const [element, setElement] = useState<HTMLDivElement>();\n\n // Number of slideshow items.\n const itemsCount = React.Children.count(children);\n // Number of slides when using groupBy prop.\n const slidesCount = Math.ceil(itemsCount / Math.min(groupBy as number, itemsCount));\n // Inline style of wrapper element.\n const wrapperStyle: CSSProperties = { transform: `translateX(-${FULL_WIDTH_PERCENT * currentIndex}%)` };\n\n // Change current index to display next slide.\n const goToNextSlide = useCallback(\n (loopback = true) => {\n setCurrentIndex((index) => {\n if (loopback && index === slidesCount - 1) {\n // Loopback to the start.\n return 0;\n }\n if (index < slidesCount - 1) {\n // Next slide.\n return index + 1;\n }\n return index;\n });\n },\n [slidesCount, setCurrentIndex],\n );\n\n // Change current index to display previous slide.\n const goToPreviousSlide = useCallback(\n (loopback = true) => {\n setCurrentIndex((index) => {\n if (loopback && index === 0) {\n // Loopback to the end.\n return slidesCount - 1;\n }\n if (index > 0) {\n // Previous slide.\n return index - 1;\n }\n return index;\n });\n },\n [slidesCount, setCurrentIndex],\n );\n\n // Auto play\n const [isAutoPlaying, setIsAutoPlaying] = useState(Boolean(autoPlay));\n // Start\n useInterval(goToNextSlide, isAutoPlaying && slidesCount > 1 ? (interval as number) : null);\n\n // Reset current index if it become invalid.\n useEffect(() => {\n if (currentIndex > slidesCount - 1) {\n setCurrentIndex(DEFAULT_PROPS.activeIndex as number);\n }\n }, [currentIndex, slidesCount]);\n\n // Handle click on a bullet to go to a specific slide.\n const handleControlGotToSlide = useCallback(\n (index: number) => {\n setIsAutoPlaying(false);\n\n if (index >= 0 && index < slidesCount) {\n setCurrentIndex(index);\n }\n },\n [slidesCount, setCurrentIndex],\n );\n\n // Handle click or keyboard event to go to next slide.\n const handleControlNextSlide = useCallback(\n (loopback = true) => {\n setIsAutoPlaying(false);\n goToNextSlide(loopback);\n },\n [goToNextSlide],\n );\n\n // Handle click or keyboard event to go to previous slide.\n const handleControlPreviousSlide = useCallback(\n (loopback = true) => {\n setIsAutoPlaying(false);\n goToPreviousSlide(loopback);\n },\n [goToPreviousSlide],\n );\n\n // If the activeIndex props changes, update the current slide\n useEffect(() => {\n setCurrentIndex(activeIndex as number);\n }, [activeIndex]);\n\n // If the slide changes, with autoplay for example, trigger \"onChange\"\n useEffect(() => {\n if (!onChange) return;\n onChange(currentIndex);\n }, [currentIndex, onChange]);\n\n /* eslint-disable jsx-a11y/no-noninteractive-tabindex */\n return (\n <div\n ref={mergeRefs(ref, setElement)}\n {...forwardedProps}\n className={classNames(className, handleBasicClasses({ prefix: CLASSNAME, theme }), {\n [`${CLASSNAME}--fill-height`]: fillHeight,\n [`${CLASSNAME}--group-by-${groupBy}`]: Boolean(groupBy),\n })}\n tabIndex={0}\n >\n <div className={`${CLASSNAME}__slides`}>\n <div className={`${CLASSNAME}__wrapper`} style={wrapperStyle}>\n {children}\n </div>\n </div>\n\n {slideshowControlsProps && slidesCount > 1 && (\n <div className={`${CLASSNAME}__controls`}>\n <SlideshowControls\n {...slideshowControlsProps}\n activeIndex={currentIndex}\n onPaginationClick={handleControlGotToSlide}\n onNextClick={handleControlNextSlide}\n onPreviousClick={handleControlPreviousSlide}\n slidesCount={slidesCount}\n parentRef={element}\n theme={theme}\n />\n </div>\n )}\n </div>\n );\n});\nSlideshow.displayName = COMPONENT_NAME;\nSlideshow.className = CLASSNAME;\nSlideshow.defaultProps = DEFAULT_PROPS;\n","import React, { forwardRef } from 'react';\n\nimport classNames from 'classnames';\n\nimport { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';\n\n/**\n * Defines the props of the component.\n */\nexport type SlideshowItemProps = GenericProps;\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'SlideshowItem';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * SlideshowItem component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const SlideshowItem: Comp<SlideshowItemProps, HTMLDivElement> = forwardRef((props, ref) => {\n const { className, children, ...forwardedProps } = props;\n\n return (\n <div\n ref={ref}\n {...forwardedProps}\n className={classNames(\n className,\n handleBasicClasses({\n prefix: CLASSNAME,\n }),\n )}\n >\n {children}\n </div>\n );\n});\nSlideshowItem.displayName = COMPONENT_NAME;\nSlideshowItem.className = CLASSNAME;\n","import { useEffect } from 'react';\nimport { detectHorizontalSwipe } from '@lumx/core/js/utils';\n\nconst isTouchDevice = () => 'ontouchstart' in window;\n\n/**\n * Listen swipe to navigate left and right.\n */\nexport function useSwipeNavigate(element?: HTMLElement | null, onNext?: () => void, onPrevious?: () => void): void {\n useEffect(() => {\n if (!element || !isTouchDevice()) return undefined;\n\n return detectHorizontalSwipe(element, (swipe) => {\n const callback = swipe === 'right' ? onPrevious : onNext;\n callback?.();\n });\n }, [onPrevious, onNext, element]);\n}\n","import { useEffect } from 'react';\n\n/**\n * Listen keyboard to navigate left and right.\n */\nexport function useKeyNavigate(element?: HTMLElement | null, onNext?: () => void, onPrevious?: () => void): void {\n useEffect(() => {\n if (!element) return undefined;\n const onKeyNavigate = (evt: KeyboardEvent) => {\n let callback;\n if (evt?.key === 'ArrowRight') {\n callback = onNext;\n } else if (evt?.key === 'ArrowLeft') {\n callback = onPrevious;\n }\n if (!callback) return;\n\n callback();\n evt.preventDefault();\n evt.stopPropagation();\n };\n\n element.addEventListener('keydown', onKeyNavigate);\n return () => {\n element.removeEventListener('keydown', onKeyNavigate);\n };\n }, [onPrevious, onNext, element]);\n}\n","import { useMemo, useRef } from 'react';\nimport { EDGE_FROM_ACTIVE_INDEX, PAGINATION_ITEMS_MAX } from '@lumx/react/components/slideshow/constants';\n\ntype Range = { min: number; max: number };\n\n/**\n * Calculate the currently visible pagination \"bullet\" range.\n */\nexport function usePaginationVisibleRange(activeIndex: number, slideCount: number): Range {\n const previousVisibleRangeRef = useRef<Range>();\n return useMemo(() => {\n const lastSlide = slideCount - 1;\n const { current: previousVisibleRange } = previousVisibleRangeRef;\n let newVisibleRange: Range;\n if (activeIndex === previousVisibleRange?.max && activeIndex < lastSlide) {\n newVisibleRange = { min: previousVisibleRange.min + 1, max: previousVisibleRange.max + 1 };\n } else if (activeIndex === previousVisibleRange?.min && activeIndex > 0) {\n newVisibleRange = { min: previousVisibleRange.min - 1, max: previousVisibleRange.max - 1 };\n } else {\n const deltaItems = PAGINATION_ITEMS_MAX - 1;\n let min = activeIndex - EDGE_FROM_ACTIVE_INDEX;\n let max = activeIndex + EDGE_FROM_ACTIVE_INDEX;\n\n if (activeIndex > lastSlide - EDGE_FROM_ACTIVE_INDEX) {\n min = lastSlide - deltaItems;\n max = lastSlide;\n } else if (activeIndex < deltaItems) {\n min = 0;\n max = deltaItems;\n }\n\n newVisibleRange = { min, max };\n }\n previousVisibleRangeRef.current = newVisibleRange;\n return newVisibleRange;\n }, [activeIndex, slideCount]);\n}\n","import React, { forwardRef, RefObject, useCallback, useMemo } from 'react';\n\nimport classNames from 'classnames';\nimport range from 'lodash/range';\n\nimport { mdiChevronLeft, mdiChevronRight } from '@lumx/icons';\nimport { Emphasis, IconButton, IconButtonProps, Theme } from '@lumx/react';\nimport { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';\nimport { WINDOW } from '@lumx/react/constants';\n\nimport { useSwipeNavigate } from './useSwipeNavigate';\nimport { useKeyNavigate } from './useKeyNavigate';\nimport { PAGINATION_ITEM_SIZE, PAGINATION_ITEMS_MAX } from './constants';\nimport { usePaginationVisibleRange } from './usePaginationVisibleRange';\n\n/**\n * Defines the props of the component.\n */\nexport interface SlideshowControlsProps extends GenericProps {\n /** Index of the current slide. */\n activeIndex?: number;\n /** Props to pass to the next button (minus those already set by the SlideshowControls props). */\n nextButtonProps: Pick<IconButtonProps, 'label'> &\n Omit<IconButtonProps, 'label' | 'onClick' | 'icon' | 'emphasis' | 'color'>;\n /** Reference to the parent element on which we want to listen touch swipe. */\n parentRef?: RefObject<HTMLDivElement> | HTMLDivElement;\n /** Props to pass to the previous button (minus those already set by the SlideshowControls props). */\n previousButtonProps: Pick<IconButtonProps, 'label'> &\n Omit<IconButtonProps, 'label' | 'onClick' | 'icon' | 'emphasis' | 'color'>;\n /** Number of slides. */\n slidesCount: number;\n /** Theme adapting the component to light or dark background. */\n theme?: Theme;\n /** On next button click callback. */\n onNextClick?(loopback?: boolean): void;\n /** On pagination change callback. */\n onPaginationClick?(index: number): void;\n /** On previous button click callback. */\n onPreviousClick?(loopback?: boolean): void;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'SlideshowControls';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * Component default props.\n */\nconst DEFAULT_PROPS: Partial<SlideshowControlsProps> = {\n activeIndex: 0,\n theme: Theme.light,\n};\n\n/**\n * SlideshowControls component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const SlideshowControls: Comp<SlideshowControlsProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n activeIndex,\n className,\n nextButtonProps,\n onNextClick,\n onPaginationClick,\n onPreviousClick,\n parentRef,\n previousButtonProps,\n slidesCount,\n theme,\n ...forwardedProps\n } = props;\n\n let parent;\n if (WINDOW) {\n // Checking window object to avoid errors in SSR.\n parent = parentRef instanceof HTMLElement ? parentRef : parentRef?.current;\n }\n // Listen to keyboard navigate left & right.\n useKeyNavigate(parent, onNextClick, onPreviousClick);\n // Listen to touch swipe navigate left & right.\n useSwipeNavigate(\n parent,\n // Go next without loopback.\n useCallback(() => onNextClick?.(false), [onNextClick]),\n // Go previous without loopback.\n useCallback(() => onPreviousClick?.(false), [onPreviousClick]),\n );\n\n // Pagination \"bullet\" range.\n const visibleRange = usePaginationVisibleRange(activeIndex as number, slidesCount);\n\n // Inline style of wrapper element.\n const wrapperStyle = { transform: `translateX(-${PAGINATION_ITEM_SIZE * visibleRange.min}px)` };\n\n return (\n <div\n ref={ref}\n {...forwardedProps}\n className={classNames(className, handleBasicClasses({ prefix: CLASSNAME, theme }), {\n [`${CLASSNAME}--has-infinite-pagination`]: slidesCount > PAGINATION_ITEMS_MAX,\n })}\n >\n <IconButton\n {...previousButtonProps}\n icon={mdiChevronLeft}\n className={`${CLASSNAME}__navigation`}\n color={theme === Theme.dark ? 'light' : 'dark'}\n emphasis={Emphasis.low}\n onClick={onPreviousClick}\n tabIndex={-1}\n />\n <div className={`${CLASSNAME}__pagination`}>\n <div className={`${CLASSNAME}__pagination-items`} style={wrapperStyle}>\n {useMemo(\n () =>\n range(slidesCount).map((index) => {\n const isOnEdge =\n index !== 0 &&\n index !== slidesCount - 1 &&\n (index === visibleRange.min || index === visibleRange.max);\n const isActive = activeIndex === index;\n const isOutRange = index < visibleRange.min || index > visibleRange.max;\n return (\n // eslint-disable-next-line jsx-a11y/control-has-associated-label\n <button\n className={classNames(\n handleBasicClasses({\n prefix: `${CLASSNAME}__pagination-item`,\n isActive,\n isOnEdge,\n isOutRange,\n }),\n )}\n key={index}\n type=\"button\"\n onClick={() => onPaginationClick?.(index)}\n tabIndex={-1}\n />\n );\n }),\n [slidesCount, visibleRange.min, visibleRange.max, activeIndex, onPaginationClick],\n )}\n </div>\n </div>\n <IconButton\n {...nextButtonProps}\n icon={mdiChevronRight}\n className={`${CLASSNAME}__navigation`}\n color={theme === Theme.dark ? 'light' : 'dark'}\n emphasis={Emphasis.low}\n onClick={onNextClick}\n tabIndex={-1}\n />\n </div>\n );\n});\nSlideshowControls.displayName = COMPONENT_NAME;\nSlideshowControls.className = CLASSNAME;\nSlideshowControls.defaultProps = DEFAULT_PROPS;\n"],"names":["AUTOPLAY_DEFAULT_INTERVAL","FULL_WIDTH_PERCENT","EDGE_FROM_ACTIVE_INDEX","PAGINATION_ITEMS_MAX","PAGINATION_ITEM_SIZE","useInterval","callback","delay","savedCallback","useRef","useEffect","current","undefined","tick","isFunction","id","setInterval","clearInterval","COMPONENT_NAME","CLASSNAME","getRootClassName","DEFAULT_PROPS","activeIndex","groupBy","interval","theme","Theme","light","Slideshow","forwardRef","props","ref","autoPlay","children","className","fillHeight","onChange","slideshowControlsProps","forwardedProps","useState","currentIndex","setCurrentIndex","element","setElement","itemsCount","React","Children","count","slidesCount","Math","ceil","min","wrapperStyle","transform","goToNextSlide","useCallback","loopback","index","goToPreviousSlide","Boolean","isAutoPlaying","setIsAutoPlaying","handleControlGotToSlide","handleControlNextSlide","handleControlPreviousSlide","mergeRefs","classNames","handleBasicClasses","prefix","displayName","defaultProps","SlideshowItem","isTouchDevice","window","useSwipeNavigate","onNext","onPrevious","detectHorizontalSwipe","swipe","useKeyNavigate","onKeyNavigate","evt","key","preventDefault","stopPropagation","addEventListener","removeEventListener","usePaginationVisibleRange","slideCount","previousVisibleRangeRef","useMemo","lastSlide","previousVisibleRange","newVisibleRange","max","deltaItems","SlideshowControls","nextButtonProps","onNextClick","onPaginationClick","onPreviousClick","parentRef","previousButtonProps","parent","WINDOW","HTMLElement","visibleRange","mdiChevronLeft","dark","Emphasis","low","range","map","isOnEdge","isActive","isOutRange","mdiChevronRight"],"mappings":";;;;;;;;;;;AAAA;;;AAGO,IAAMA,yBAAyB,GAAG,IAAlC;AAEP;;;;AAGO,IAAMC,kBAAkB,GAAG,GAA3B;AAEP;;;;AAGO,IAAMC,sBAAsB,GAAG,CAA/B;AAEP;;;;AAGO,IAAMC,oBAAoB,GAAG,CAA7B;AAEP;;;;AAGO,IAAMC,oBAAoB,GAAG,EAA7B;;AClBP;;;;;;;AAOO,SAASC,WAAT,CAAqBC,QAArB,EAAyCC,KAAzC,EAAqE;AACxE,MAAMC,aAAa,GAAGC,MAAM,EAA5B;AAEAC,EAAAA,SAAS,CAAC,YAAM;AACZF,IAAAA,aAAa,CAACG,OAAd,GAAwBL,QAAxB;AACH,GAFQ,CAAT;AAIAI,EAAAA,SAAS,CAAC,YAAM;AACZ,QAAIH,KAAK,KAAK,IAAd,EAAoB,OAAOK,SAAP;;AAEpB,aAASC,IAAT,GAAgB;AACZ,UAAIC,UAAU,CAACN,aAAa,CAACG,OAAf,CAAd,EAAuC;AACnCH,QAAAA,aAAa,CAACG,OAAd;AACH;AACJ;;AACD,QAAMI,EAAE,GAAGC,WAAW,CAACH,IAAD,EAAON,KAAP,CAAtB;AACA,WAAO;AAAA,aAAMU,aAAa,CAACF,EAAD,CAAnB;AAAA,KAAP;AACH,GAVQ,EAUN,CAACR,KAAD,CAVM,CAAT;AAWH;;ACnBD;;;;AAgCA;;;AAGA,IAAMW,cAAc,GAAG,WAAvB;AAEA;;;;AAGA,IAAMC,SAAS,GAAGC,gBAAgB,CAACF,cAAD,CAAlC;AAEA;;;;AAGA,IAAMG,aAAsC,GAAG;AAC3CC,EAAAA,WAAW,EAAE,CAD8B;AAE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|
}
|
|
752
752
|
|
|
753
|
-
var useClickable = function useClickable(_ref) {
|
|
754
|
-
var onClick = _ref.onClick,
|
|
755
|
-
_onKeyPress = _ref.onKeyPress;
|
|
756
|
-
return useMemo(function () {
|
|
757
|
-
if (!onClick) return undefined;
|
|
758
|
-
return {
|
|
759
|
-
role: 'button',
|
|
760
|
-
tabIndex: 0,
|
|
761
|
-
onClick: onClick,
|
|
762
|
-
onKeyPress: function onKeyPress(event) {
|
|
763
|
-
_onKeyPress === null || _onKeyPress === void 0 ? void 0 : _onKeyPress(event);
|
|
764
|
-
|
|
765
|
-
if (event.key === 'Enter' || event.key === ' ') {
|
|
766
|
-
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
};
|
|
770
|
-
}, [onClick, _onKeyPress]);
|
|
771
|
-
};
|
|
772
|
-
|
|
773
753
|
/**
|
|
774
754
|
* Component display name.
|
|
775
755
|
*/
|
|
@@ -815,7 +795,9 @@ var Thumbnail = forwardRef(function (props, ref) {
|
|
|
815
795
|
size = props.size,
|
|
816
796
|
theme = props.theme,
|
|
817
797
|
variant = props.variant,
|
|
818
|
-
|
|
798
|
+
linkProps = props.linkProps,
|
|
799
|
+
linkAs = props.linkAs,
|
|
800
|
+
forwardedProps = _objectWithoutProperties(props, ["align", "alt", "aspectRatio", "badge", "className", "crossOrigin", "fallback", "fillHeight", "focusPoint", "image", "imgProps", "imgRef", "loading", "size", "theme", "variant", "linkProps", "linkAs"]);
|
|
819
801
|
|
|
820
802
|
var imgRef = useRef(null); // Image loading state.
|
|
821
803
|
|
|
@@ -828,18 +810,19 @@ var Thumbnail = forwardRef(function (props, ref) {
|
|
|
828
810
|
wrapper = _useState2[0],
|
|
829
811
|
setWrapper = _useState2[1];
|
|
830
812
|
|
|
831
|
-
var
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
813
|
+
var isLink = Boolean((linkProps === null || linkProps === void 0 ? void 0 : linkProps.href) || linkAs);
|
|
814
|
+
var isButton = !!forwardedProps.onClick;
|
|
815
|
+
var isClickable = isButton || isLink;
|
|
816
|
+
var Wrapper = 'div';
|
|
817
|
+
|
|
818
|
+
var wrapperProps = _objectSpread2({}, forwardedProps);
|
|
819
|
+
|
|
820
|
+
if (isLink) {
|
|
821
|
+
Wrapper = linkAs || 'a';
|
|
822
|
+
Object.assign(wrapperProps, linkProps);
|
|
823
|
+
} else if (isButton) {
|
|
824
|
+
Wrapper = 'button';
|
|
825
|
+
} // Update img style according to focus point and aspect ratio.
|
|
843
826
|
|
|
844
827
|
|
|
845
828
|
var style = useFocusPoint({
|
|
@@ -850,7 +833,19 @@ var Thumbnail = forwardRef(function (props, ref) {
|
|
|
850
833
|
loadingState: loadingState,
|
|
851
834
|
wrapper: wrapper
|
|
852
835
|
});
|
|
853
|
-
return React.createElement(
|
|
836
|
+
return React.createElement(Wrapper, _extends({}, wrapperProps, {
|
|
837
|
+
ref: mergeRefs(setWrapper, ref),
|
|
838
|
+
className: classnames(linkProps === null || linkProps === void 0 ? void 0 : linkProps.className, className, handleBasicClasses({
|
|
839
|
+
align: align,
|
|
840
|
+
aspectRatio: aspectRatio,
|
|
841
|
+
prefix: CLASSNAME,
|
|
842
|
+
size: size,
|
|
843
|
+
theme: theme,
|
|
844
|
+
variant: variant,
|
|
845
|
+
isClickable: isClickable,
|
|
846
|
+
hasBadge: !!badge
|
|
847
|
+
}), isLoading && (wrapper === null || wrapper === void 0 ? void 0 : (_wrapper$getBoundingC = wrapper.getBoundingClientRect()) === null || _wrapper$getBoundingC === void 0 ? void 0 : _wrapper$getBoundingC.height) && 'lumx-color-background-dark-L6', fillHeight && "".concat(CLASSNAME, "--fill-height"))
|
|
848
|
+
}), React.createElement("div", {
|
|
854
849
|
className: "".concat(CLASSNAME, "__background"),
|
|
855
850
|
style: _objectSpread2({}, style === null || style === void 0 ? void 0 : style.wrapper, {
|
|
856
851
|
// Remove from layout if image not loaded correctly (use fallback)
|