@lumx/react 2.0.3 → 2.1.0-alpha.11

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.
@@ -4,7 +4,6 @@ import React, { useState, useEffect, forwardRef, useRef, useMemo, Children } fro
4
4
  import { D as DOCUMENT } from './constants.js';
5
5
  import { p as partitionMulti } from './partitionMulti.js';
6
6
  import { i as isComponent } from './type.js';
7
- import { m as mergeRefs } from './mergeRefs.js';
8
7
  import { u as useFocusTrap } from './useFocusTrap.js';
9
8
  import { createPortal } from 'react-dom';
10
9
  import { u as useCallbackOnEscape, C as ClickAwayProvider } from './ClickAwayProvider.js';
@@ -162,19 +161,12 @@ var Dialog = forwardRef(function (props, ref) {
162
161
 
163
162
  useCallbackOnEscape(handleClose, isOpen && !preventAutoClose); // eslint-disable-next-line react-hooks/rules-of-hooks
164
163
 
165
- var wrapperRef = useRef(null);
166
- /**
167
- * Since the `contentRef` comes from the parent and is optional,
168
- * we need to create a stable contentRef that will always be available.
169
- */
170
- // eslint-disable-next-line react-hooks/rules-of-hooks
171
-
172
- var localContentRef = useRef(null); // Handle focus trap.
164
+ var wrapperRef = useRef(null); // Handle focus trap.
173
165
  // eslint-disable-next-line react-hooks/rules-of-hooks
174
166
 
175
167
  useFocusTrap(wrapperRef.current, focusElement === null || focusElement === void 0 ? void 0 : focusElement.current); // eslint-disable-next-line react-hooks/rules-of-hooks
176
168
 
177
- useDisableBodyScroll(isOpen && localContentRef.current); // eslint-disable-next-line react-hooks/rules-of-hooks
169
+ useDisableBodyScroll(isOpen && wrapperRef.current); // eslint-disable-next-line react-hooks/rules-of-hooks
178
170
 
179
171
  var _useState = useState(null),
180
172
  _useState2 = _slicedToArray(_useState, 2),
@@ -241,7 +233,7 @@ var Dialog = forwardRef(function (props, ref) {
241
233
  }, (header || headerChildContent) && React.createElement("header", _extends({}, headerChildProps, {
242
234
  className: classnames("".concat(CLASSNAME, "__header"), (forceHeaderDivider || hasTopIntersection) && "".concat(CLASSNAME, "__header--has-divider"), headerChildProps === null || headerChildProps === void 0 ? void 0 : headerChildProps.className)
243
235
  }), header, headerChildContent), React.createElement("div", {
244
- ref: mergeRefs(contentRef, localContentRef),
236
+ ref: contentRef,
245
237
  className: "".concat(CLASSNAME, "__content")
246
238
  }, React.createElement("div", {
247
239
  className: "".concat(CLASSNAME, "__sentinel ").concat(CLASSNAME, "__sentinel--top"),
@@ -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":";;;;;;;;;;;;;;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,IA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AS,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';\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 // 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 && wrapperRef.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={contentRef} 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","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","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,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ArB;AACAO,MAAM,CAACM,SAAP,GAAmBZ,SAAnB;AACAM,MAAM,CAACiE,YAAP,GAAsBrE,aAAtB;;;;"}
@@ -4,8 +4,6 @@ import { i as isComponent } from './type.js';
4
4
  import { a as Popover, P as Placement } from './Popover2.js';
5
5
  import { L as List } from './List2.js';
6
6
 
7
- // The error margin in px we want to have for triggering infinite scroll
8
- var SCROLL_TRIGGER_MARGIN = 5;
9
7
  /**
10
8
  * Listen to clicks away from a given element and callback the passed in function.
11
9
  *
@@ -13,10 +11,8 @@ var SCROLL_TRIGGER_MARGIN = 5;
13
11
  * @param [callback] A callback function to call when the bottom of the reference element is reached.
14
12
  * @param [callbackOnMount] A callback function to call when the component is mounted.
15
13
  */
16
-
17
14
  var useInfiniteScroll = function useInfiniteScroll(ref, callback) {
18
15
  var callbackOnMount = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
19
- var scrollTriggerMargin = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : SCROLL_TRIGGER_MARGIN;
20
16
  useEffect(function () {
21
17
  var current = ref.current;
22
18
 
@@ -25,7 +21,7 @@ var useInfiniteScroll = function useInfiniteScroll(ref, callback) {
25
21
  }
26
22
 
27
23
  var isAtBottom = function isAtBottom() {
28
- return Boolean(current && current.scrollHeight - (current.scrollTop + current.clientHeight) <= scrollTriggerMargin);
24
+ return Boolean(current && current.scrollTop + current.clientHeight >= current.scrollHeight);
29
25
  };
30
26
 
31
27
  var onScroll = function onScroll(e) {
@@ -44,7 +40,7 @@ var useInfiniteScroll = function useInfiniteScroll(ref, callback) {
44
40
  current.removeEventListener('scroll', onScroll);
45
41
  current.removeEventListener('resize', onScroll);
46
42
  };
47
- }, [ref, callback, scrollTriggerMargin]);
43
+ }, [ref, callback]);
48
44
  useEffect(function () {
49
45
  if (callback && callbackOnMount) {
50
46
  callback();
@@ -129,7 +125,6 @@ var Dropdown = forwardRef(function (props, ref) {
129
125
  className: classnames(className, handleBasicClasses({
130
126
  prefix: CLASSNAME
131
127
  })),
132
- elevation: 0,
133
128
  closeOnClickAway: closeOnClickAway,
134
129
  closeOnEscape: closeOnEscape,
135
130
  fitToAnchorWidth: fitToAnchorWidth,
@@ -1 +1 @@
1
- {"version":3,"file":"Dropdown2.js","sources":["../../../src/hooks/useInfiniteScroll.tsx","../../../src/components/dropdown/Dropdown.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\n\ntype useInfiniteScrollType = (\n ref: React.RefObject<HTMLElement>,\n callback?: EventCallback,\n callbackOnMount?: boolean,\n) => void;\ntype EventCallback = (evt?: Event) => void;\n\n// The error margin in px we want to have for triggering infinite scroll\nconst SCROLL_TRIGGER_MARGIN = 5;\n\n/**\n * Listen to clicks away from a given element and callback the passed in function.\n *\n * @param ref A reference to the element on which you want to listen scroll event.\n * @param [callback] A callback function to call when the bottom of the reference element is reached.\n * @param [callbackOnMount] A callback function to call when the component is mounted.\n */\nexport const useInfiniteScroll: useInfiniteScrollType = (\n ref,\n callback,\n callbackOnMount = false,\n scrollTriggerMargin = SCROLL_TRIGGER_MARGIN,\n) => {\n useEffect(() => {\n const { current } = ref;\n if (!callback || !current) {\n return undefined;\n }\n\n const isAtBottom = () =>\n Boolean(\n current && current.scrollHeight - (current.scrollTop + current.clientHeight) <= scrollTriggerMargin,\n );\n\n const onScroll = (e?: Event): void => {\n if (isAtBottom()) {\n callback(e);\n }\n };\n\n if (isAtBottom()) {\n onScroll();\n }\n\n current.addEventListener('scroll', onScroll);\n current.addEventListener('resize', onScroll);\n return () => {\n current.removeEventListener('scroll', onScroll);\n current.removeEventListener('resize', onScroll);\n };\n }, [ref, callback, scrollTriggerMargin]);\n\n useEffect(() => {\n if (callback && callbackOnMount) {\n callback();\n }\n }, [callback, callbackOnMount]);\n};\n","import React, { cloneElement, forwardRef, useMemo, useRef } from 'react';\n\nimport classNames from 'classnames';\n\nimport { List, ListProps } from '@lumx/react/components/list/List';\nimport { Offset, Placement, Popover } from '@lumx/react/components/popover/Popover';\nimport { useInfiniteScroll } from '@lumx/react/hooks/useInfiniteScroll';\nimport { Comp, GenericProps, getRootClassName, handleBasicClasses, isComponent } from '@lumx/react/utils';\n\n/**\n * Defines the props of the component.\n */\nexport interface DropdownProps extends GenericProps {\n /** Reference to the element around which the dropdown is placed.\n * @see {@link PopoverProps#anchorRef}\n */\n anchorRef: React.RefObject<HTMLElement>;\n /** Dropdown content. */\n children: React.ReactNode;\n /**\n * Whether a click anywhere out of the Dropdown would close it or not.\n * @see {@link PopoverProps#closeOnClickAway}\n */\n closeOnClickAway?: boolean;\n /**\n * Whether to close the Dropdown when clicking in it or not.\n */\n closeOnClick?: boolean;\n /**\n * Whether an escape key press would close the Dropdown or not.\n * @see {@link PopoverProps#closeOnEscape}\n */\n closeOnEscape?: boolean;\n /**\n * Whether the dropdown should fit to the anchor width (if dropdown is smaller) or not.\n * @see {@link PopoverProps#fitToAnchorWidth}\n */\n fitToAnchorWidth?: boolean;\n /**\n * Whether the dropdown should shrink to fit within the viewport height or not.\n * @see {@link PopoverProps#fitWithinViewportHeight}\n */\n fitWithinViewportHeight?: boolean;\n /**\n * Whether the dropdown should be displayed or not. Useful to control the Dropdown from outside the component.\n * @see {@link PopoverProps#isOpen}\n */\n isOpen: boolean;\n /**\n * Offset applied to the Dropdown position.\n * @see {@link PopoverProps#offset}\n */\n offset?: Offset;\n /**\n * Preferred Dropdown placement against the anchor element.\n * @see {@link PopoverProps#placement}\n */\n placement?: Placement;\n /** Whether the focus should be set on the list when the dropdown is open or not. */\n shouldFocusOnOpen?: boolean;\n /**\n * Z-axis position.\n * @see {@link PopoverProps#zIndex}\n */\n zIndex?: number;\n /**\n * On close callback.\n * @see {@link PopoverProps#onClose}\n */\n onClose?(): void;\n /** On scroll end callback. */\n onInfiniteScroll?(): void;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'Dropdown';\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<DropdownProps> = {\n closeOnClick: true,\n closeOnClickAway: true,\n closeOnEscape: true,\n fitToAnchorWidth: true,\n fitWithinViewportHeight: true,\n placement: Placement.BOTTOM_START,\n shouldFocusOnOpen: true,\n};\n\n/**\n * Dropdown component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const Dropdown: Comp<DropdownProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n anchorRef,\n children,\n className,\n closeOnClick,\n closeOnClickAway,\n closeOnEscape,\n fitToAnchorWidth,\n fitWithinViewportHeight,\n isOpen,\n offset,\n onClose,\n onInfiniteScroll,\n placement,\n shouldFocusOnOpen,\n zIndex,\n ...forwardedProps\n } = props;\n const innerRef = useRef<HTMLDivElement>(null);\n const listElement = useRef(null);\n\n useInfiniteScroll(innerRef, onInfiniteScroll);\n\n const popperElement = useMemo(() => {\n return !Array.isArray(children) && isComponent(List)(children)\n ? cloneElement<ListProps>(children, {\n ...children.props,\n ref: listElement,\n onClick(evt: MouseEvent) {\n children.props.onClick?.(evt);\n\n if (closeOnClick) {\n onClose?.();\n }\n },\n isClickable: true,\n })\n : children;\n }, [children, closeOnClick, onClose]);\n\n return isOpen ? (\n <Popover\n ref={ref}\n {...forwardedProps}\n anchorRef={anchorRef}\n className={classNames(className, handleBasicClasses({ prefix: CLASSNAME }))}\n elevation={0 as any}\n closeOnClickAway={closeOnClickAway}\n closeOnEscape={closeOnEscape}\n fitToAnchorWidth={fitToAnchorWidth}\n fitWithinViewportHeight={fitWithinViewportHeight}\n focusElement={shouldFocusOnOpen ? listElement : undefined}\n isOpen={isOpen}\n offset={offset}\n onClose={onClose}\n placement={placement}\n zIndex={zIndex}\n >\n <div className={`${CLASSNAME}__menu`} ref={innerRef}>\n {popperElement}\n </div>\n </Popover>\n ) : null;\n});\nDropdown.displayName = COMPONENT_NAME;\nDropdown.className = CLASSNAME;\nDropdown.defaultProps = DEFAULT_PROPS;\n"],"names":["SCROLL_TRIGGER_MARGIN","useInfiniteScroll","ref","callback","callbackOnMount","scrollTriggerMargin","useEffect","current","undefined","isAtBottom","Boolean","scrollHeight","scrollTop","clientHeight","onScroll","e","addEventListener","removeEventListener","COMPONENT_NAME","CLASSNAME","getRootClassName","DEFAULT_PROPS","closeOnClick","closeOnClickAway","closeOnEscape","fitToAnchorWidth","fitWithinViewportHeight","placement","Placement","BOTTOM_START","shouldFocusOnOpen","Dropdown","forwardRef","props","anchorRef","children","className","isOpen","offset","onClose","onInfiniteScroll","zIndex","forwardedProps","innerRef","useRef","listElement","popperElement","useMemo","Array","isArray","isComponent","List","cloneElement","onClick","evt","isClickable","classNames","handleBasicClasses","prefix","displayName","defaultProps"],"mappings":";;;;;;AASA;AACA,IAAMA,qBAAqB,GAAG,CAA9B;AAEA;;;;;;;;AAOO,IAAMC,iBAAwC,GAAG,SAA3CA,iBAA2C,CACpDC,GADoD,EAEpDC,QAFoD,EAKnD;AAAA,MAFDC,eAEC,uEAFiB,KAEjB;AAAA,MADDC,mBACC,uEADqBL,qBACrB;AACDM,EAAAA,SAAS,CAAC,YAAM;AAAA,QACJC,OADI,GACQL,GADR,CACJK,OADI;;AAEZ,QAAI,CAACJ,QAAD,IAAa,CAACI,OAAlB,EAA2B;AACvB,aAAOC,SAAP;AACH;;AAED,QAAMC,UAAU,GAAG,SAAbA,UAAa;AAAA,aACfC,OAAO,CACHH,OAAO,IAAIA,OAAO,CAACI,YAAR,IAAwBJ,OAAO,CAACK,SAAR,GAAoBL,OAAO,CAACM,YAApD,KAAqER,mBAD7E,CADQ;AAAA,KAAnB;;AAKA,QAAMS,QAAQ,GAAG,SAAXA,QAAW,CAACC,CAAD,EAAqB;AAClC,UAAIN,UAAU,EAAd,EAAkB;AACdN,QAAAA,QAAQ,CAACY,CAAD,CAAR;AACH;AACJ,KAJD;;AAMA,QAAIN,UAAU,EAAd,EAAkB;AACdK,MAAAA,QAAQ;AACX;;AAEDP,IAAAA,OAAO,CAACS,gBAAR,CAAyB,QAAzB,EAAmCF,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AP,YAAAA,OAAO;AACV;AACJ,OATO;AAURgB,MAAAA,WAAW,EAAE;AAVL,OADX,GAaDpB,QAbN;AAcH,GAf4B,EAe1B,CAACA,QAAD,EAAWb,YAAX,EAAyBiB,OAAzB,CAf0B,CAA7B;AAiBA,SAAOF,MAAM,GACT,oBAAC,OAAD;AACI,IAAA,GAAG,EAAEnC;AADT,KAEQwC,cAFR;AAGI,IAAA,SAAS,EAAER,SAHf;AAII,IAAA,SAAS,EAAEsB,UAAU,CAACpB,SAAD,EAAYqB,kBAAkB,CAAC;AAAEC,MAAAA,MAAM,EAAEvC;AAAV,KAAD,CAA9B,CAJzB;AAKI,IAAA,SAAS,EAAE,CALf;AAMI,IAAA,gBAAgB,EAAEI,gBANtB;AAOI,IAAA,aAAa,EAAEC,aAPnB;AAQI,IAAA,gBAAgB,EAAEC,gBARtB;AASI,IAAA,uBAAuB,EAAEC,uBAT7B;AAUI,IAAA,YAAY,EAAEI,iBAAiB,GAAGe,WAAH,GAAiBrC,SAVpD;AAWI,IAAA,MAAM,EAAE6B,MAXZ;AAYI,IAAA,MAAM,EAAEC,MAZZ;AAaI,IAAA,OAAO,EAAEC,OAbb;AAcI,IAAA,SAAS,EAAEZ,SAdf;AAeI,IAAA,MAAM,EAAEc;AAfZ,MAiBI;AAAK,IAAA,SAAS,YAAKtB,SAAL,WAAd;AAAsC,IAAA,GAAG,EAAEwB;AAA3C,KACKG,aADL,CAjBJ,CADS,GAsBT,IAtBJ;AAuBH,CAhEsE;AAiEvEf,QAAQ,CAAC4B,WAAT,GAAuBzC,cAAvB;AACAa,QAAQ,CAACK,SAAT,GAAqBjB,SAArB;AACAY,QAAQ,CAAC6B,YAAT,GAAwBvC,aAAxB;;;;"}
1
+ {"version":3,"file":"Dropdown2.js","sources":["../../../src/hooks/useInfiniteScroll.tsx","../../../src/components/dropdown/Dropdown.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\n\ntype useInfiniteScrollType = (\n ref: React.RefObject<HTMLElement>,\n callback?: EventCallback,\n callbackOnMount?: boolean,\n) => void;\ntype EventCallback = (evt?: Event) => void;\n\n/**\n * Listen to clicks away from a given element and callback the passed in function.\n *\n * @param ref A reference to the element on which you want to listen scroll event.\n * @param [callback] A callback function to call when the bottom of the reference element is reached.\n * @param [callbackOnMount] A callback function to call when the component is mounted.\n */\nexport const useInfiniteScroll: useInfiniteScrollType = (ref, callback, callbackOnMount = false) => {\n useEffect(() => {\n const { current } = ref;\n if (!callback || !current) {\n return undefined;\n }\n\n const isAtBottom = () => Boolean(current && current.scrollTop + current.clientHeight >= current.scrollHeight);\n\n const onScroll = (e?: Event): void => {\n if (isAtBottom()) {\n callback(e);\n }\n };\n\n if (isAtBottom()) {\n onScroll();\n }\n\n current.addEventListener('scroll', onScroll);\n current.addEventListener('resize', onScroll);\n return () => {\n current.removeEventListener('scroll', onScroll);\n current.removeEventListener('resize', onScroll);\n };\n }, [ref, callback]);\n\n useEffect(() => {\n if (callback && callbackOnMount) {\n callback();\n }\n }, [callback, callbackOnMount]);\n};\n","import React, { cloneElement, forwardRef, useMemo, useRef } from 'react';\n\nimport classNames from 'classnames';\n\nimport { List, ListProps } from '@lumx/react/components/list/List';\nimport { Offset, Placement, Popover } from '@lumx/react/components/popover/Popover';\nimport { useInfiniteScroll } from '@lumx/react/hooks/useInfiniteScroll';\nimport { Comp, GenericProps, getRootClassName, handleBasicClasses, isComponent } from '@lumx/react/utils';\n\n/**\n * Defines the props of the component.\n */\nexport interface DropdownProps extends GenericProps {\n /** Reference to the element around which the dropdown is placed.\n * @see {@link PopoverProps#anchorRef}\n */\n anchorRef: React.RefObject<HTMLElement>;\n /** Dropdown content. */\n children: React.ReactNode;\n /**\n * Whether a click anywhere out of the Dropdown would close it or not.\n * @see {@link PopoverProps#closeOnClickAway}\n */\n closeOnClickAway?: boolean;\n /**\n * Whether to close the Dropdown when clicking in it or not.\n */\n closeOnClick?: boolean;\n /**\n * Whether an escape key press would close the Dropdown or not.\n * @see {@link PopoverProps#closeOnEscape}\n */\n closeOnEscape?: boolean;\n /**\n * Whether the dropdown should fit to the anchor width (if dropdown is smaller) or not.\n * @see {@link PopoverProps#fitToAnchorWidth}\n */\n fitToAnchorWidth?: boolean;\n /**\n * Whether the dropdown should shrink to fit within the viewport height or not.\n * @see {@link PopoverProps#fitWithinViewportHeight}\n */\n fitWithinViewportHeight?: boolean;\n /**\n * Whether the dropdown should be displayed or not. Useful to control the Dropdown from outside the component.\n * @see {@link PopoverProps#isOpen}\n */\n isOpen: boolean;\n /**\n * Offset applied to the Dropdown position.\n * @see {@link PopoverProps#offset}\n */\n offset?: Offset;\n /**\n * Preferred Dropdown placement against the anchor element.\n * @see {@link PopoverProps#placement}\n */\n placement?: Placement;\n /** Whether the focus should be set on the list when the dropdown is open or not. */\n shouldFocusOnOpen?: boolean;\n /**\n * Z-axis position.\n * @see {@link PopoverProps#zIndex}\n */\n zIndex?: number;\n /**\n * On close callback.\n * @see {@link PopoverProps#onClose}\n */\n onClose?(): void;\n /** On scroll end callback. */\n onInfiniteScroll?(): void;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'Dropdown';\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<DropdownProps> = {\n closeOnClick: true,\n closeOnClickAway: true,\n closeOnEscape: true,\n fitToAnchorWidth: true,\n fitWithinViewportHeight: true,\n placement: Placement.BOTTOM_START,\n shouldFocusOnOpen: true,\n};\n\n/**\n * Dropdown component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const Dropdown: Comp<DropdownProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n anchorRef,\n children,\n className,\n closeOnClick,\n closeOnClickAway,\n closeOnEscape,\n fitToAnchorWidth,\n fitWithinViewportHeight,\n isOpen,\n offset,\n onClose,\n onInfiniteScroll,\n placement,\n shouldFocusOnOpen,\n zIndex,\n ...forwardedProps\n } = props;\n const innerRef = useRef<HTMLDivElement>(null);\n const listElement = useRef(null);\n\n useInfiniteScroll(innerRef, onInfiniteScroll);\n\n const popperElement = useMemo(() => {\n return !Array.isArray(children) && isComponent(List)(children)\n ? cloneElement<ListProps>(children, {\n ...children.props,\n ref: listElement,\n onClick(evt: MouseEvent) {\n children.props.onClick?.(evt);\n\n if (closeOnClick) {\n onClose?.();\n }\n },\n isClickable: true,\n })\n : children;\n }, [children, closeOnClick, onClose]);\n\n return isOpen ? (\n <Popover\n ref={ref}\n {...forwardedProps}\n anchorRef={anchorRef}\n className={classNames(className, handleBasicClasses({ prefix: CLASSNAME }))}\n closeOnClickAway={closeOnClickAway}\n closeOnEscape={closeOnEscape}\n fitToAnchorWidth={fitToAnchorWidth}\n fitWithinViewportHeight={fitWithinViewportHeight}\n focusElement={shouldFocusOnOpen ? listElement : undefined}\n isOpen={isOpen}\n offset={offset}\n onClose={onClose}\n placement={placement}\n zIndex={zIndex}\n >\n <div className={`${CLASSNAME}__menu`} ref={innerRef}>\n {popperElement}\n </div>\n </Popover>\n ) : null;\n});\nDropdown.displayName = COMPONENT_NAME;\nDropdown.className = CLASSNAME;\nDropdown.defaultProps = DEFAULT_PROPS;\n"],"names":["useInfiniteScroll","ref","callback","callbackOnMount","useEffect","current","undefined","isAtBottom","Boolean","scrollTop","clientHeight","scrollHeight","onScroll","e","addEventListener","removeEventListener","COMPONENT_NAME","CLASSNAME","getRootClassName","DEFAULT_PROPS","closeOnClick","closeOnClickAway","closeOnEscape","fitToAnchorWidth","fitWithinViewportHeight","placement","Placement","BOTTOM_START","shouldFocusOnOpen","Dropdown","forwardRef","props","anchorRef","children","className","isOpen","offset","onClose","onInfiniteScroll","zIndex","forwardedProps","innerRef","useRef","listElement","popperElement","useMemo","Array","isArray","isComponent","List","cloneElement","onClick","evt","isClickable","classNames","handleBasicClasses","prefix","displayName","defaultProps"],"mappings":";;;;;;AASA;;;;;;;AAOO,IAAMA,iBAAwC,GAAG,SAA3CA,iBAA2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AUI,IAAA,MAAM,EAAE6B,MAVZ;AAWI,IAAA,MAAM,EAAEC,MAXZ;AAYI,IAAA,OAAO,EAAEC,OAZb;AAaI,IAAA,SAAS,EAAEZ,SAbf;AAcI,IAAA,MAAM,EAAEc;AAdZ,MAgBI;AAAK,IAAA,SAAS,YAAKtB,SAAL,WAAd;AAAsC,IAAA,GAAG,EAAEwB;AAA3C,KACKG,aADL,CAhBJ,CADS,GAqBT,IArBJ;AAsBH,CA/DsE;AAgEvEf,QAAQ,CAAC4B,WAAT,GAAuBzC,cAAvB;AACAa,QAAQ,CAACK,SAAT,GAAqBjB,SAArB;AACAY,QAAQ,CAAC6B,YAAT,GAAwBvC,aAAxB;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"SkeletonTypography.js","sources":["../../../src/components/skeleton/SkeletonCircle.tsx","../../../src/components/skeleton/SkeletonRectangle.tsx","../../../src/components/skeleton/SkeletonTypography.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport React, { forwardRef } from 'react';\n\nimport { GlobalSize, 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 SkeletonCircleProps extends GenericProps {\n /** Size variant. */\n size: GlobalSize;\n /** Theme. */\n theme?: Theme;\n}\n\nconst DEFAULT_PROPS: Partial<SkeletonCircleProps> = {\n theme: Theme.light,\n};\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'SkeletonCircle';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * SkeletonCircle component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const SkeletonCircle: Comp<SkeletonCircleProps, HTMLDivElement> = forwardRef((props, ref) => {\n const { className, size, theme, ...forwardedProps } = props;\n\n return (\n <div\n ref={ref}\n {...forwardedProps}\n className={classNames(className, handleBasicClasses({ prefix: CLASSNAME, size, theme }))}\n />\n );\n});\nSkeletonCircle.displayName = COMPONENT_NAME;\nSkeletonCircle.defaultProps = DEFAULT_PROPS;\nSkeletonCircle.className = CLASSNAME;\n","import classNames from 'classnames';\nimport React, { forwardRef } from 'react';\n\nimport { AspectRatio, GlobalSize, Theme } from '@lumx/react';\nimport { Comp, GenericProps, getRootClassName, handleBasicClasses, ValueOf } from '@lumx/react/utils';\n\n/**\n * Skeleton variants.\n */\nexport const SkeletonRectangleVariant = { squared: 'squared', rounded: 'rounded', pill: 'pill' } as const;\nexport type SkeletonRectangleVariant = ValueOf<typeof SkeletonRectangleVariant>;\n\n/**\n * Defines the props of the component.\n */\nexport interface SkeletonRectangleProps extends GenericProps {\n /** Aspect ratio (use with width and not height). */\n aspectRatio?: Extract<AspectRatio, 'square' | 'horizontal' | 'vertical' | 'wide'>;\n /** Height size. */\n height?: GlobalSize;\n /** Theme adapting the component to light or dark background. */\n theme?: Theme;\n /** Border variant. */\n variant?: SkeletonRectangleVariant;\n /** Width size. */\n width?: GlobalSize;\n}\n\nconst DEFAULT_PROPS: Partial<SkeletonRectangleProps> = {\n theme: Theme.light,\n variant: SkeletonRectangleVariant.squared,\n};\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'SkeletonRectangle';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * SkeletonRectangle component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const SkeletonRectangle: Comp<SkeletonRectangleProps, HTMLDivElement> = forwardRef((props, ref) => {\n const { aspectRatio, className, height, theme, variant, width, ...forwardedProps } = props;\n\n return (\n <div\n ref={ref}\n {...forwardedProps}\n className={classNames(\n className,\n handleBasicClasses({\n prefix: CLASSNAME,\n aspectRatio,\n height: aspectRatio ? undefined : height,\n theme,\n variant,\n width,\n }),\n )}\n >\n <div className={`${CLASSNAME}__inner`} />\n </div>\n );\n});\nSkeletonRectangle.displayName = COMPONENT_NAME;\nSkeletonRectangle.className = CLASSNAME;\nSkeletonRectangle.defaultProps = DEFAULT_PROPS;\n","import classNames from 'classnames';\nimport React, { CSSProperties, forwardRef } from 'react';\n\nimport { Theme, Typography } from '@lumx/react';\nimport { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';\n\n/**\n * Defines the props of the component.\n */\nexport interface SkeletonTypographyProps extends GenericProps {\n /** Theme adapting the component to light or dark background. */\n theme?: Theme;\n /** Typography variant. */\n typography: Typography;\n /** Width CSS property. */\n width?: CSSProperties['width'];\n}\n\nconst DEFAULT_PROPS: Partial<SkeletonTypographyProps> = {\n theme: Theme.light,\n};\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'SkeletonTypography';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * SkeletonTypography component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const SkeletonTypography: Comp<SkeletonTypographyProps, HTMLDivElement> = forwardRef((props, ref) => {\n const { className, theme, typography, width, ...forwardedProps } = props;\n\n return (\n <div\n ref={ref}\n {...forwardedProps}\n className={classNames(className, handleBasicClasses({ prefix: CLASSNAME, theme, typography }))}\n style={{ ...forwardedProps.style, width }}\n >\n <div className={`${CLASSNAME}__inner`} />\n </div>\n );\n});\nSkeletonTypography.displayName = COMPONENT_NAME;\nSkeletonTypography.defaultProps = DEFAULT_PROPS;\nSkeletonTypography.className = CLASSNAME;\n"],"names":["DEFAULT_PROPS","theme","Theme","light","COMPONENT_NAME","CLASSNAME","getRootClassName","SkeletonCircle","forwardRef","props","ref","className","size","forwardedProps","classNames","handleBasicClasses","prefix","displayName","defaultProps","SkeletonRectangleVariant","squared","rounded","pill","variant","SkeletonRectangle","aspectRatio","height","width","undefined","SkeletonTypography","typography","style"],"mappings":";;;;AAMA;;;;AAUA,IAAMA,aAA2C,GAAG;AAChDC,EAAAA,KAAK,EAAEC,KAAK,CAACC;AADmC,CAApD;AAIA;;;;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AAAA,MACrFV,KADqF,GACrCQ,KADqC,CACrFR,KADqF;AAAA,MAC9E6B,UAD8E,GACrCrB,KADqC,CAC9EqB,UAD8E;AAAA,MAClEH,KADkE,GACrClB,KADqC,CAClEkB,KADkE;AAAA,MACxDd,cADwD,4BACrCJ,KADqC;;AAGxG,SACI;AACI,IAAA,GAAG,EAAEC;AADT,KAEQG,cAFR;AAGI,IAAA,SAAS,EAAEC,UAAU,CAACH,SAAD,EAAYI,kBAAkB,CAAC;AAAEC,MAAAA,MAAM,EAAEX,WAAV;AAAqBJ,MAAAA,KAAK,EAALA,KAArB;AAA4B6B,MAAAA,UAAU,EAAVA;AAA5B,KAAD,CAA9B,CAHzB;AAII,IAAA,KAAK,qBAAOjB,cAAc,CAACkB,KAAtB;AAA6BJ,MAAAA,KAAK,EAALA;AAA7B;AAJT,MAMI;AAAK,IAAA,SAAS,YAAKtB,WAAL;AAAd,IANJ,CADJ;AAUH,CAb0F;AAc3FwB,kBAAkB,CAACZ,WAAnB,GAAiCb,gBAAjC;AACAyB,kBAAkB,CAACX,YAAnB,GAAkClB,eAAlC;AACA6B,kBAAkB,CAAClB,SAAnB,GAA+BN,WAA/B;;;;"}
1
+ {"version":3,"file":"SkeletonTypography.js","sources":["../../../src/components/skeleton/SkeletonCircle.tsx","../../../src/components/skeleton/SkeletonRectangle.tsx","../../../src/components/skeleton/SkeletonTypography.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport React, { forwardRef } from 'react';\n\nimport { GlobalSize, 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 SkeletonCircleProps extends GenericProps {\n /** Size variant. */\n size: GlobalSize;\n /** Theme. */\n theme?: Theme;\n}\n\nconst DEFAULT_PROPS: Partial<SkeletonCircleProps> = {\n theme: Theme.light,\n};\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'SkeletonCircle';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * SkeletonCircle component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const SkeletonCircle: Comp<SkeletonCircleProps, HTMLDivElement> = forwardRef((props, ref) => {\n const { className, size, theme, ...forwardedProps } = props;\n\n return (\n <div\n ref={ref}\n {...forwardedProps}\n className={classNames(className, handleBasicClasses({ prefix: CLASSNAME, size, theme }))}\n />\n );\n});\nSkeletonCircle.displayName = COMPONENT_NAME;\nSkeletonCircle.defaultProps = DEFAULT_PROPS;\nSkeletonCircle.className = CLASSNAME;\n","import classNames from 'classnames';\nimport React, { forwardRef } from 'react';\n\nimport { AspectRatio, GlobalSize, Theme } from '@lumx/react';\nimport { Comp, GenericProps, getRootClassName, handleBasicClasses, ValueOf } from '@lumx/react/utils';\n\n/**\n * Skeleton variants.\n */\nexport const SkeletonRectangleVariant = { squared: 'squared', rounded: 'rounded', pill: 'pill' } as const;\nexport type SkeletonRectangleVariant = ValueOf<typeof SkeletonRectangleVariant>;\n\n/**\n * Defines the props of the component.\n */\nexport interface SkeletonRectangleProps extends GenericProps {\n /** Aspect ratio (use with width and not height). */\n aspectRatio?: Extract<AspectRatio, 'square' | 'horizontal' | 'vertical'>;\n /** Height size. */\n height?: GlobalSize;\n /** Theme adapting the component to light or dark background. */\n theme?: Theme;\n /** Border variant. */\n variant?: SkeletonRectangleVariant;\n /** Width size. */\n width?: GlobalSize;\n}\n\nconst DEFAULT_PROPS: Partial<SkeletonRectangleProps> = {\n theme: Theme.light,\n variant: SkeletonRectangleVariant.squared,\n};\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'SkeletonRectangle';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * SkeletonRectangle component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const SkeletonRectangle: Comp<SkeletonRectangleProps, HTMLDivElement> = forwardRef((props, ref) => {\n const { aspectRatio, className, height, theme, variant, width, ...forwardedProps } = props;\n\n return (\n <div\n ref={ref}\n {...forwardedProps}\n className={classNames(\n className,\n handleBasicClasses({\n prefix: CLASSNAME,\n aspectRatio,\n height: aspectRatio ? undefined : height,\n theme,\n variant,\n width,\n }),\n )}\n >\n <div className={`${CLASSNAME}__inner`} />\n </div>\n );\n});\nSkeletonRectangle.displayName = COMPONENT_NAME;\nSkeletonRectangle.className = CLASSNAME;\nSkeletonRectangle.defaultProps = DEFAULT_PROPS;\n","import classNames from 'classnames';\nimport React, { CSSProperties, forwardRef } from 'react';\n\nimport { Theme, Typography } from '@lumx/react';\nimport { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';\n\n/**\n * Defines the props of the component.\n */\nexport interface SkeletonTypographyProps extends GenericProps {\n /** Theme adapting the component to light or dark background. */\n theme?: Theme;\n /** Typography variant. */\n typography: Typography;\n /** Width CSS property. */\n width?: CSSProperties['width'];\n}\n\nconst DEFAULT_PROPS: Partial<SkeletonTypographyProps> = {\n theme: Theme.light,\n};\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'SkeletonTypography';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * SkeletonTypography component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const SkeletonTypography: Comp<SkeletonTypographyProps, HTMLDivElement> = forwardRef((props, ref) => {\n const { className, theme, typography, width, ...forwardedProps } = props;\n\n return (\n <div\n ref={ref}\n {...forwardedProps}\n className={classNames(className, handleBasicClasses({ prefix: CLASSNAME, theme, typography }))}\n style={{ ...forwardedProps.style, width }}\n >\n <div className={`${CLASSNAME}__inner`} />\n </div>\n );\n});\nSkeletonTypography.displayName = COMPONENT_NAME;\nSkeletonTypography.defaultProps = DEFAULT_PROPS;\nSkeletonTypography.className = CLASSNAME;\n"],"names":["DEFAULT_PROPS","theme","Theme","light","COMPONENT_NAME","CLASSNAME","getRootClassName","SkeletonCircle","forwardRef","props","ref","className","size","forwardedProps","classNames","handleBasicClasses","prefix","displayName","defaultProps","SkeletonRectangleVariant","squared","rounded","pill","variant","SkeletonRectangle","aspectRatio","height","width","undefined","SkeletonTypography","typography","style"],"mappings":";;;;AAMA;;;;AAUA,IAAMA,aAA2C,GAAG;AAChDC,EAAAA,KAAK,EAAEC,KAAK,CAACC;AADmC,CAApD;AAIA;;;;AAGA,IAAMC,cAAc,GAAG,gBAAvB;AAEA;;;;AAGA,IAAMC,SAAS,GAAGC,gBAAgB,CAACF,cAAD,CAAlC;AAEA;;;;;;;;IAOaG,cAAyD,GAAGC,UAAU,CAAC,UAACC,KAAD,EAAQC,GAAR,EAAgB;AAAA,MACxFC,SADwF,GAC1CF,KAD0C,CACxFE,SADwF;AAAA,MAC7EC,IAD6E,GAC1CH,KAD0C,CAC7EG,IAD6E;AAAA,MACvEX,KADuE,GAC1CQ,KAD0C,CACvER,KADuE;AAAA,MAC7DY,cAD6D,4BAC1CJ,KAD0C;;AAGhG,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,IAAI,EAAJA,IAArB;AAA2BX,MAAAA,KAAK,EAALA;AAA3B,KAAD,CAA9B;AAHzB,KADJ;AAOH,CAVkF;AAWnFM,cAAc,CAACU,WAAf,GAA6Bb,cAA7B;AACAG,cAAc,CAACW,YAAf,GAA8BlB,aAA9B;AACAO,cAAc,CAACI,SAAf,GAA2BN,SAA3B;;AC5CA;;;;IAGac,wBAAwB,GAAG;AAAEC,EAAAA,OAAO,EAAE,SAAX;AAAsBC,EAAAA,OAAO,EAAE,SAA/B;AAA0CC,EAAAA,IAAI,EAAE;AAAhD;AAmBxC,IAAMtB,eAA8C,GAAG;AACnDC,EAAAA,KAAK,EAAEC,KAAK,C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,KAAK,EAAEC,KAAK,CAACC;AADuC,CAAxD;AAIA;;;;AAGA,IAAMC,gBAAc,GAAG,oBAAvB;AAEA;;;;AAGA,IAAMC,WAAS,GAAGC,gBAAgB,CAACF,gBAAD,CAAlC;AAEA;;;;;;;;IAOayB,kBAAiE,GAAGrB,UAAU,CAAC,UAACC,KAAD,EAAQC,GAAR,EAAgB;AAAA,MAChGC,SADgG,GACrCF,KADqC,CAChGE,SADgG;AAAA,MACrFV,KADqF,GACrCQ,KADqC,CACrFR,KADqF;AAAA,MAC9E6B,UAD8E,GACrCrB,KADqC,CAC9EqB,UAD8E;AAAA,MAClEH,KADkE,GACrClB,KADqC,CAClEkB,KADkE;AAAA,MACxDd,cADwD,4BACrCJ,KADqC;;AAGxG,SACI;AACI,IAAA,GAAG,EAAEC;AADT,KAEQG,cAFR;AAGI,IAAA,SAAS,EAAEC,UAAU,CAACH,SAAD,EAAYI,kBAAkB,CAAC;AAAEC,MAAAA,MAAM,EAAEX,WAAV;AAAqBJ,MAAAA,KAAK,EAALA,KAArB;AAA4B6B,MAAAA,UAAU,EAAVA;AAA5B,KAAD,CAA9B,CAHzB;AAII,IAAA,KAAK,qBAAOjB,cAAc,CAACkB,KAAtB;AAA6BJ,MAAAA,KAAK,EAALA;AAA7B;AAJT,MAMI;AAAK,IAAA,SAAS,YAAKtB,WAAL;AAAd,IANJ,CADJ;AAUH,CAb0F;AAc3FwB,kBAAkB,CAACZ,WAAnB,GAAiCb,gBAAjC;AACAyB,kBAAkB,CAACX,YAAnB,GAAkClB,eAAlC;AACA6B,kBAAkB,CAAClB,SAAnB,GAA+BN,WAA/B;;;;"}
@@ -17,7 +17,6 @@ import './partitionMulti.js';
17
17
  import 'lodash/get';
18
18
  import './type.js';
19
19
  export { A as AlertDialog } from './AlertDialog.js';
20
- import './mergeRefs.js';
21
20
  import './renderLink.js';
22
21
  import './ButtonRoot.js';
23
22
  import './Button2.js';
@@ -1 +1 @@
1
- {"version":3,"file":"alert-dialog.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"alert-dialog.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -88,22 +88,10 @@ var Typography = {
88
88
  * All available aspect ratios.
89
89
  */
90
90
  var AspectRatio = {
91
- /** Intrinsic content ratio. */
92
91
  original: 'original',
93
-
94
- /** Ratio 16:9 */
95
- wide: 'wide',
96
-
97
- /** Ratio 3:2 */
98
92
  horizontal: 'horizontal',
99
-
100
- /** Ratio 3:2 */
101
93
  vertical: 'vertical',
102
-
103
- /** Ratio 1:1 */
104
94
  square: 'square',
105
-
106
- /** Ratio constrained by the parent. */
107
95
  free: 'free'
108
96
  };
109
97
 
@@ -1 +1 @@
1
- {"version":3,"file":"components.js","sources":["../../../src/components/index.ts"],"sourcesContent":["import { ValueOf } from '@lumx/react/utils';\n\n/**\n * Alignments.\n */\nexport const Alignment = {\n bottom: 'bottom',\n center: 'center',\n end: 'end',\n left: 'left',\n right: 'right',\n spaceAround: 'space-around',\n spaceBetween: 'space-between',\n start: 'start',\n top: 'top',\n} as const;\nexport type Alignment = ValueOf<typeof Alignment>;\nexport type VerticalAlignment = Extract<Alignment, 'top' | 'center' | 'bottom'>;\nexport type HorizontalAlignment = Extract<Alignment, 'right' | 'center' | 'left'>;\n\n/**\n * See SCSS variable $lumx-color-palette\n */\nexport const ColorPalette = {\n primary: 'primary',\n secondary: 'secondary',\n blue: 'blue',\n dark: 'dark',\n green: 'green',\n yellow: 'yellow',\n red: 'red',\n light: 'light',\n grey: 'grey',\n} as const;\nexport type ColorPalette = ValueOf<typeof ColorPalette>;\nexport type Color = ColorPalette | string;\n\n/**\n * See SCSS variable $lumx-color-variants\n */\nexport const ColorVariant = {\n D1: 'D1',\n D2: 'D2',\n L1: 'L1',\n L2: 'L2',\n L3: 'L3',\n L4: 'L4',\n L5: 'L5',\n L6: 'L6',\n N: 'N',\n} as const;\nexport type ColorVariant = ValueOf<typeof ColorVariant>;\n\nexport const Theme = {\n light: 'light',\n dark: 'dark',\n} as const;\nexport type Theme = ValueOf<typeof Theme>;\n\nexport const Size = {\n xxs: 'xxs',\n xs: 'xs',\n s: 's',\n m: 'm',\n l: 'l',\n xl: 'xl',\n xxl: 'xxl',\n tiny: 'tiny',\n regular: 'regular',\n big: 'big',\n huge: 'huge',\n} as const;\nexport type Size = ValueOf<typeof Size>;\nexport type GlobalSize = Extract<Size, 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl'>;\n\nexport const Orientation = {\n horizontal: 'horizontal',\n vertical: 'vertical',\n} as const;\nexport type Orientation = ValueOf<typeof Orientation>;\n\nexport const Emphasis = {\n low: 'low',\n medium: 'medium',\n high: 'high',\n} as const;\nexport type Emphasis = ValueOf<typeof Emphasis>;\n\n/**\n * List of typographies.\n */\nexport const Typography = {\n overline: 'overline',\n caption: 'caption',\n body1: 'body1',\n body2: 'body2',\n subtitle1: 'subtitle1',\n subtitle2: 'subtitle2',\n title: 'title',\n headline: 'headline',\n display1: 'display1',\n} as const;\nexport type Typography = ValueOf<typeof Typography>;\n\n/**\n * All available aspect ratios.\n */\nexport const AspectRatio = {\n /** Intrinsic content ratio. */\n original: 'original',\n /** Ratio 16:9 */\n wide: 'wide',\n /** Ratio 3:2 */\n horizontal: 'horizontal',\n /** Ratio 3:2 */\n vertical: 'vertical',\n /** Ratio 1:1 */\n square: 'square',\n /** Ratio constrained by the parent. */\n free: 'free',\n} as const;\nexport type AspectRatio = ValueOf<typeof AspectRatio>;\n\n/**\n * Semantic info about the purpose of the component\n */\nexport const Kind = {\n info: 'info',\n success: 'success',\n warning: 'warning',\n error: 'error',\n} as const;\nexport type Kind = ValueOf<typeof Kind>;\n"],"names":["Alignment","bottom","center","end","left","right","spaceAround","spaceBetween","start","top","ColorPalette","primary","secondary","blue","dark","green","yellow","red","light","grey","ColorVariant","D1","D2","L1","L2","L3","L4","L5","L6","N","Theme","Size","xxs","xs","s","m","l","xl","xxl","tiny","regular","big","huge","Orientation","horizontal","vertical","Emphasis","low","medium","high","Typography","overline","caption","body1","body2","subtitle1","subtitle2","title","headline","display1","AspectRatio","original","wide","square","free","Kind","info","success","warning","error"],"mappings":"AAEA;;;IAGaA,SAAS,GAAG;AACrBC,EAAAA,MAAM,EAAE,QADa;AAErBC,EAAAA,MAAM,EAAE,QAFa;AAGrBC,EAAAA,GAAG,EAAE,KAHgB;AAIrBC,EAAAA,IAAI,EAAE,MAJe;AAKrBC,EAAAA,KAAK,EAAE,OALc;AAMrBC,EAAAA,WAAW,EAAE,cANQ;AAOrBC,EAAAA,YAAY,EAAE,eAPO;AAQrBC,EAAAA,KAAK,EAAE,OARc;AASrBC,EAAAA,GAAG,EAAE;AATgB;;AAezB;;;IAGaC,YAAY,GAAG;AACxBC,EAAAA,OAAO,EAAE,SADe;AAExBC,EAAAA,SAAS,EAAE,WAFa;AAGxBC,EAAAA,IAAI,EAAE,MAHkB;AAIxBC,EAAAA,IAAI,EAAE,MAJkB;AAKxBC,EAAAA,KAAK,EAAE,OALiB;AAMxBC,EAAAA,MAAM,EAAE,QANgB;AAOxBC,EAAAA,GAAG,EAAE,KAPmB;AAQxBC,EAAAA,KAAK,EAAE,OARiB;AASxBC,EAAAA,IAAI,EAAE;AATkB;;AAc5B;;;IAGaC,YAAY,GAAG;AACxBC,EAAAA,EAAE,EAAE,IADoB;AAExBC,EAAAA,EAAE,EAAE,IAFoB;AAGxBC,EAAAA,EAAE,EAAE,IAHoB;AAIxBC,EAAAA,EAAE,EAAE,IAJoB;AAKxBC,EAAAA,EAAE,EAAE,IALoB;AAMxBC,EAAAA,EAAE,EAAE,IANoB;AAOxBC,EAAAA,EAAE,EAAE,IAPoB;AAQxBC,EAAAA,EAAE,EAAE,IARoB;AASxBC,EAAAA,CAAC,EAAE;AATqB;IAafC,KAAK,GAAG;AACjBZ,EAAAA,KAAK,EAAE,OADU;AAEjBJ,EAAAA,IA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AAChBC,EAAAA,IAAI,EAAE,MADU;AAEhBC,EAAAA,OAAO,EAAE,SAFO;AAGhBC,EAAAA,OAAO,EAAE,SAHO;AAIhBC,EAAAA,KAAK,EAAE;AAJS;;;;"}
1
+ {"version":3,"file":"components.js","sources":["../../../src/components/index.ts"],"sourcesContent":["import { ValueOf } from '@lumx/react/utils';\n\n/**\n * Alignments.\n */\nexport const Alignment = {\n bottom: 'bottom',\n center: 'center',\n end: 'end',\n left: 'left',\n right: 'right',\n spaceAround: 'space-around',\n spaceBetween: 'space-between',\n start: 'start',\n top: 'top',\n} as const;\nexport type Alignment = ValueOf<typeof Alignment>;\nexport type VerticalAlignment = Extract<Alignment, 'top' | 'center' | 'bottom'>;\nexport type HorizontalAlignment = Extract<Alignment, 'right' | 'center' | 'left'>;\n\n/**\n * See SCSS variable $lumx-color-palette\n */\nexport const ColorPalette = {\n primary: 'primary',\n secondary: 'secondary',\n blue: 'blue',\n dark: 'dark',\n green: 'green',\n yellow: 'yellow',\n red: 'red',\n light: 'light',\n grey: 'grey',\n} as const;\nexport type ColorPalette = ValueOf<typeof ColorPalette>;\nexport type Color = ColorPalette | string;\n\n/**\n * See SCSS variable $lumx-color-variants\n */\nexport const ColorVariant = {\n D1: 'D1',\n D2: 'D2',\n L1: 'L1',\n L2: 'L2',\n L3: 'L3',\n L4: 'L4',\n L5: 'L5',\n L6: 'L6',\n N: 'N',\n} as const;\nexport type ColorVariant = ValueOf<typeof ColorVariant>;\n\nexport const Theme = {\n light: 'light',\n dark: 'dark',\n} as const;\nexport type Theme = ValueOf<typeof Theme>;\n\nexport const Size = {\n xxs: 'xxs',\n xs: 'xs',\n s: 's',\n m: 'm',\n l: 'l',\n xl: 'xl',\n xxl: 'xxl',\n tiny: 'tiny',\n regular: 'regular',\n big: 'big',\n huge: 'huge',\n} as const;\nexport type Size = ValueOf<typeof Size>;\nexport type GlobalSize = Extract<Size, 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl'>;\n\nexport const Orientation = {\n horizontal: 'horizontal',\n vertical: 'vertical',\n} as const;\nexport type Orientation = ValueOf<typeof Orientation>;\n\nexport const Emphasis = {\n low: 'low',\n medium: 'medium',\n high: 'high',\n} as const;\nexport type Emphasis = ValueOf<typeof Emphasis>;\n\n/**\n * List of typographies.\n */\nexport const Typography = {\n overline: 'overline',\n caption: 'caption',\n body1: 'body1',\n body2: 'body2',\n subtitle1: 'subtitle1',\n subtitle2: 'subtitle2',\n title: 'title',\n headline: 'headline',\n display1: 'display1',\n} as const;\nexport type Typography = ValueOf<typeof Typography>;\n\n/**\n * All available aspect ratios.\n */\nexport const AspectRatio = {\n original: 'original',\n horizontal: 'horizontal',\n vertical: 'vertical',\n square: 'square',\n free: 'free',\n} as const;\nexport type AspectRatio = ValueOf<typeof AspectRatio>;\n\n/**\n * Semantic info about the purpose of the component\n */\nexport const Kind = {\n info: 'info',\n success: 'success',\n warning: 'warning',\n error: 'error',\n} as const;\nexport type Kind = ValueOf<typeof Kind>;\n"],"names":["Alignment","bottom","center","end","left","right","spaceAround","spaceBetween","start","top","ColorPalette","primary","secondary","blue","dark","green","yellow","red","light","grey","ColorVariant","D1","D2","L1","L2","L3","L4","L5","L6","N","Theme","Size","xxs","xs","s","m","l","xl","xxl","tiny","regular","big","huge","Orientation","horizontal","vertical","Emphasis","low","medium","high","Typography","overline","caption","body1","body2","subtitle1","subtitle2","title","headline","display1","AspectRatio","original","square","free","Kind","info","success","warning","error"],"mappings":"AAEA;;;IAGaA,SAAS,GAAG;AACrBC,EAAAA,MAAM,EAAE,QADa;AAErBC,EAAAA,MAAM,EAAE,QAFa;AAGrBC,EAAAA,GAAG,EAAE,KAHgB;AAIrBC,EAAAA,IAAI,EAAE,MAJe;AAKrBC,EAAAA,KAAK,EAAE,OALc;AAMrBC,EAAAA,WAAW,EAAE,cANQ;AAOrBC,EAAAA,YAAY,EAAE,eAPO;AAQrBC,EAAAA,KAAK,EAAE,OARc;AASrBC,EAAAA,GAAG,EAAE;AATgB;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,GAAG;AACpBC,EAAAA,GAAG,EAAE,KADe;AAEpBC,EAAAA,MAAM,EAAE,QAFY;AAGpBC,EAAAA,IAAI,EAAE;AAHc;;AAOxB;;;IAGaC,UAAU,GAAG;AACtBC,EAAAA,QAAQ,EAAE,UADY;AAEtBC,EAAAA,OAAO,EAAE,SAFa;AAGtBC,EAAAA,KAAK,EAAE,OAHe;AAItBC,EAAAA,KAAK,EAAE,OAJe;AAKtBC,EAAAA,SAAS,EAAE,WALW;AAMtBC,EAAAA,SAAS,EAAE,WANW;AAOtBC,EAAAA,KAAK,EAAE,OAPe;AAQtBC,EAAAA,QAAQ,EAAE,UARY;AAStBC,EAAAA,QAAQ,EAAE;AATY;;AAa1B;;;IAGaC,WAAW,GAAG;AACvBC,EAAAA,QAAQ,EAAE,UADa;AAEvBjB,EAAAA,UAAU,EAAE,YAFW;AAGvBC,EAAAA,QAAQ,EAAE,UAHa;AAIvBiB,EAAAA,MAAM,EAAE,QAJe;AAKvBC,EAAAA,IAAI,EAAE;AALiB;;AAS3B;;;IAGaC,IAAI,GAAG;AAChBC,EAAAA,IAAI,EAAE,MADU;AAEhBC,EAAAA,OAAO,EAAE,SAFO;AAGhBC,EAAAA,OAAO,EAAE,SAHO;AAIhBC,EAAAA,KAAK,EAAE;AAJS;;;;"}
@@ -14,7 +14,6 @@ import 'lodash/reduce';
14
14
  import './partitionMulti.js';
15
15
  import 'lodash/get';
16
16
  import './type.js';
17
- import './mergeRefs.js';
18
17
  import './useFocusTrap.js';
19
18
  import 'react-dom';
20
19
  import './ClickAwayProvider.js';
@@ -1 +1 @@
1
- {"version":3,"file":"dialog.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"dialog.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;"}
@@ -190,12 +190,6 @@ var enableBodyScroll = function enableBodyScroll(targetElement) {
190
190
  }
191
191
  };
192
192
 
193
- /**
194
- * Disables the scroll on the body to make it only usable in the current modal element.
195
- * When the modal element is not provided anymore, the scroll is restored.
196
- *
197
- * @param modalElement The modal element.
198
- */
199
193
  var useDisableBodyScroll = function useDisableBodyScroll(modalElement) {
200
194
  useEffect(function () {
201
195
  if (!modalElement) {
@@ -209,9 +203,7 @@ var useDisableBodyScroll = function useDisableBodyScroll(modalElement) {
209
203
  return function () {
210
204
  enableBodyScroll(modalElement); // Restore the previous overflow style.
211
205
 
212
- requestAnimationFrame(function () {
213
- document.documentElement.style.overflow = previousDocumentOverflow;
214
- });
206
+ document.documentElement.style.overflow = previousDocumentOverflow;
215
207
  };
216
208
  }, [modalElement]);
217
209
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useDisableBodyScroll.js","sources":["../../../../../node_modules/body-scroll-lock/lib/bodyScrollLock.esm.js","../../../src/hooks/useDisableBodyScroll.ts"],"sourcesContent":["function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }\n\n// Older browsers don't support event options, feature detect it.\n\n// Adopted and modified solution from Bohdan Didukh (2017)\n// https://stackoverflow.com/questions/41594997/ios-10-safari-prevent-scrolling-behind-a-fixed-overlay-and-maintain-scroll-posi\n\nvar hasPassiveEvents = false;\nif (typeof window !== 'undefined') {\n var passiveTestOptions = {\n get passive() {\n hasPassiveEvents = true;\n return undefined;\n }\n };\n window.addEventListener('testPassive', null, passiveTestOptions);\n window.removeEventListener('testPassive', null, passiveTestOptions);\n}\n\nvar isIosDevice = typeof window !== 'undefined' && window.navigator && window.navigator.platform && (/iP(ad|hone|od)/.test(window.navigator.platform) || window.navigator.platform === 'MacIntel' && window.navigator.maxTouchPoints > 1);\n\n\nvar locks = [];\nvar documentListenerAdded = false;\nvar initialClientY = -1;\nvar previousBodyOverflowSetting = void 0;\nvar previousBodyPaddingRight = void 0;\n\n// returns true if `el` should be allowed to receive touchmove events.\nvar allowTouchMove = function allowTouchMove(el) {\n return locks.some(function (lock) {\n if (lock.options.allowTouchMove && lock.options.allowTouchMove(el)) {\n return true;\n }\n\n return false;\n });\n};\n\nvar preventDefault = function preventDefault(rawEvent) {\n var e = rawEvent || window.event;\n\n // For the case whereby consumers adds a touchmove event listener to document.\n // Recall that we do document.addEventListener('touchmove', preventDefault, { passive: false })\n // in disableBodyScroll - so if we provide this opportunity to allowTouchMove, then\n // the touchmove event on document will break.\n if (allowTouchMove(e.target)) {\n return true;\n }\n\n // Do not prevent if the event has more than one touch (usually meaning this is a multi touch gesture like pinch to zoom).\n if (e.touches.length > 1) return true;\n\n if (e.preventDefault) e.preventDefault();\n\n return false;\n};\n\nvar setOverflowHidden = function setOverflowHidden(options) {\n // If previousBodyPaddingRight is already set, don't set it again.\n if (previousBodyPaddingRight === undefined) {\n var _reserveScrollBarGap = !!options && options.reserveScrollBarGap === true;\n var scrollBarGap = window.innerWidth - document.documentElement.clientWidth;\n\n if (_reserveScrollBarGap && scrollBarGap > 0) {\n previousBodyPaddingRight = document.body.style.paddingRight;\n document.body.style.paddingRight = scrollBarGap + 'px';\n }\n }\n\n // If previousBodyOverflowSetting is already set, don't set it again.\n if (previousBodyOverflowSetting === undefined) {\n previousBodyOverflowSetting = document.body.style.overflow;\n document.body.style.overflow = 'hidden';\n }\n};\n\nvar restoreOverflowSetting = function restoreOverflowSetting() {\n if (previousBodyPaddingRight !== undefined) {\n document.body.style.paddingRight = previousBodyPaddingRight;\n\n // Restore previousBodyPaddingRight to undefined so setOverflowHidden knows it\n // can be set again.\n previousBodyPaddingRight = undefined;\n }\n\n if (previousBodyOverflowSetting !== undefined) {\n document.body.style.overflow = previousBodyOverflowSetting;\n\n // Restore previousBodyOverflowSetting to undefined\n // so setOverflowHidden knows it can be set again.\n previousBodyOverflowSetting = undefined;\n }\n};\n\n// https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight#Problems_and_solutions\nvar isTargetElementTotallyScrolled = function isTargetElementTotallyScrolled(targetElement) {\n return targetElement ? targetElement.scrollHeight - targetElement.scrollTop <= targetElement.clientHeight : false;\n};\n\nvar handleScroll = function handleScroll(event, targetElement) {\n var clientY = event.targetTouches[0].clientY - initialClientY;\n\n if (allowTouchMove(event.target)) {\n return false;\n }\n\n if (targetElement && targetElement.scrollTop === 0 && clientY > 0) {\n // element is at the top of its scroll.\n return preventDefault(event);\n }\n\n if (isTargetElementTotallyScrolled(targetElement) && clientY < 0) {\n // element is at the bottom of its scroll.\n return preventDefault(event);\n }\n\n event.stopPropagation();\n return true;\n};\n\nexport var disableBodyScroll = function disableBodyScroll(targetElement, options) {\n // targetElement must be provided\n if (!targetElement) {\n // eslint-disable-next-line no-console\n console.error('disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.');\n return;\n }\n\n // disableBodyScroll must not have been called on this targetElement before\n if (locks.some(function (lock) {\n return lock.targetElement === targetElement;\n })) {\n return;\n }\n\n var lock = {\n targetElement: targetElement,\n options: options || {}\n };\n\n locks = [].concat(_toConsumableArray(locks), [lock]);\n\n if (isIosDevice) {\n targetElement.ontouchstart = function (event) {\n if (event.targetTouches.length === 1) {\n // detect single touch.\n initialClientY = event.targetTouches[0].clientY;\n }\n };\n targetElement.ontouchmove = function (event) {\n if (event.targetTouches.length === 1) {\n // detect single touch.\n handleScroll(event, targetElement);\n }\n };\n\n if (!documentListenerAdded) {\n document.addEventListener('touchmove', preventDefault, hasPassiveEvents ? { passive: false } : undefined);\n documentListenerAdded = true;\n }\n } else {\n setOverflowHidden(options);\n }\n};\n\nexport var clearAllBodyScrollLocks = function clearAllBodyScrollLocks() {\n if (isIosDevice) {\n // Clear all locks ontouchstart/ontouchmove handlers, and the references.\n locks.forEach(function (lock) {\n lock.targetElement.ontouchstart = null;\n lock.targetElement.ontouchmove = null;\n });\n\n if (documentListenerAdded) {\n document.removeEventListener('touchmove', preventDefault, hasPassiveEvents ? { passive: false } : undefined);\n documentListenerAdded = false;\n }\n\n // Reset initial clientY.\n initialClientY = -1;\n } else {\n restoreOverflowSetting();\n }\n\n locks = [];\n};\n\nexport var enableBodyScroll = function enableBodyScroll(targetElement) {\n if (!targetElement) {\n // eslint-disable-next-line no-console\n console.error('enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.');\n return;\n }\n\n locks = locks.filter(function (lock) {\n return lock.targetElement !== targetElement;\n });\n\n if (isIosDevice) {\n targetElement.ontouchstart = null;\n targetElement.ontouchmove = null;\n\n if (documentListenerAdded && locks.length === 0) {\n document.removeEventListener('touchmove', preventDefault, hasPassiveEvents ? { passive: false } : undefined);\n documentListenerAdded = false;\n }\n } else if (!locks.length) {\n restoreOverflowSetting();\n }\n};\n\n","import { useEffect } from 'react';\nimport { disableBodyScroll, enableBodyScroll } from 'body-scroll-lock';\nimport { Falsy } from '@lumx/react/utils';\n\n/**\n * Disables the scroll on the body to make it only usable in the current modal element.\n * When the modal element is not provided anymore, the scroll is restored.\n *\n * @param modalElement The modal element.\n */\nexport const useDisableBodyScroll = (modalElement: Element | Falsy): void => {\n useEffect(() => {\n if (!modalElement) {\n return undefined;\n }\n // Fixing the document overflow style to prevent a bug that scrolls the window to the top.\n const previousDocumentOverflow = document.documentElement.style.overflow;\n document.documentElement.style.overflow = 'visible';\n disableBodyScroll(modalElement);\n return () => {\n enableBodyScroll(modalElement);\n // Restore the previous overflow style.\n requestAnimationFrame(() => {\n document.documentElement.style.overflow = previousDocumentOverflow;\n });\n };\n }, [modalElement]);\n};\n"],"names":["useDisableBodyScroll","modalElement","useEffect","undefined","previousDocumentOverflow","document","documentElement","style","overflow","disableBodyScroll","enableBodyScroll","requestAnimationFrame"],"mappings":";;AAAA,SAAS,kBAAkB,CAAC,GAAG,EAAE,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,G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,KAAK,EAAE,GAAG,SAAS,CAAC,CAAC;AACnH,MAAM,qBAAqB,GAAG,KAAK,CAAC;AACpC,KAAK;AACL,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;AAC5B,IAAI,sBAAsB,EAAE,CAAC;AAC7B,GAAG;AACH,CAAC;;AC9MD;;;;;;IAMaA,oBAAoB,GAAG,SAAvBA,oBAAuB,CAACC,YAAD,EAAyC;AACzEC,EAAAA,SAAS,CAAC,YAAM;AACZ,QAAI,CAACD,YAAL,EAAmB;AACf,aAAOE,SAAP;AACH,KAHW;;;AAKZ,QAAMC,wBAAwB,GAAGC,QAAQ,CAACC,eAAT,CAAyBC,KAAzB,CAA+BC,QAAhE;AACAH,IAAAA,QAAQ,CAACC,eAAT,CAAyBC,KAAzB,CAA+BC,QAA/B,GAA0C,SAA1C;AACAC,IAAAA,iBAAiB,CAACR,YAAD,CAAjB;AACA,WAAO,YAAM;AACTS,MAAAA,gBAAgB,CAACT,YAAD,CAAhB,CADS;;AAGTU,MAAAA,qBAAqB,CAAC,YAAM;AACxBN,QAAAA,QAAQ,CAACC,eAAT,CAAyBC,KAAzB,CAA+BC,QAA/B,GAA0CJ,wBAA1C;AACH,OAFoB,CAArB;AAGH,KAND;AAOH,GAfQ,EAeN,CAACH,YAAD,CAfM,CAAT;AAgBH;;;;"}
1
+ {"version":3,"file":"useDisableBodyScroll.js","sources":["../../../../../node_modules/body-scroll-lock/lib/bodyScrollLock.esm.js","../../../src/hooks/useDisableBodyScroll.ts"],"sourcesContent":["function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }\n\n// Older browsers don't support event options, feature detect it.\n\n// Adopted and modified solution from Bohdan Didukh (2017)\n// https://stackoverflow.com/questions/41594997/ios-10-safari-prevent-scrolling-behind-a-fixed-overlay-and-maintain-scroll-posi\n\nvar hasPassiveEvents = false;\nif (typeof window !== 'undefined') {\n var passiveTestOptions = {\n get passive() {\n hasPassiveEvents = true;\n return undefined;\n }\n };\n window.addEventListener('testPassive', null, passiveTestOptions);\n window.removeEventListener('testPassive', null, passiveTestOptions);\n}\n\nvar isIosDevice = typeof window !== 'undefined' && window.navigator && window.navigator.platform && (/iP(ad|hone|od)/.test(window.navigator.platform) || window.navigator.platform === 'MacIntel' && window.navigator.maxTouchPoints > 1);\n\n\nvar locks = [];\nvar documentListenerAdded = false;\nvar initialClientY = -1;\nvar previousBodyOverflowSetting = void 0;\nvar previousBodyPaddingRight = void 0;\n\n// returns true if `el` should be allowed to receive touchmove events.\nvar allowTouchMove = function allowTouchMove(el) {\n return locks.some(function (lock) {\n if (lock.options.allowTouchMove && lock.options.allowTouchMove(el)) {\n return true;\n }\n\n return false;\n });\n};\n\nvar preventDefault = function preventDefault(rawEvent) {\n var e = rawEvent || window.event;\n\n // For the case whereby consumers adds a touchmove event listener to document.\n // Recall that we do document.addEventListener('touchmove', preventDefault, { passive: false })\n // in disableBodyScroll - so if we provide this opportunity to allowTouchMove, then\n // the touchmove event on document will break.\n if (allowTouchMove(e.target)) {\n return true;\n }\n\n // Do not prevent if the event has more than one touch (usually meaning this is a multi touch gesture like pinch to zoom).\n if (e.touches.length > 1) return true;\n\n if (e.preventDefault) e.preventDefault();\n\n return false;\n};\n\nvar setOverflowHidden = function setOverflowHidden(options) {\n // If previousBodyPaddingRight is already set, don't set it again.\n if (previousBodyPaddingRight === undefined) {\n var _reserveScrollBarGap = !!options && options.reserveScrollBarGap === true;\n var scrollBarGap = window.innerWidth - document.documentElement.clientWidth;\n\n if (_reserveScrollBarGap && scrollBarGap > 0) {\n previousBodyPaddingRight = document.body.style.paddingRight;\n document.body.style.paddingRight = scrollBarGap + 'px';\n }\n }\n\n // If previousBodyOverflowSetting is already set, don't set it again.\n if (previousBodyOverflowSetting === undefined) {\n previousBodyOverflowSetting = document.body.style.overflow;\n document.body.style.overflow = 'hidden';\n }\n};\n\nvar restoreOverflowSetting = function restoreOverflowSetting() {\n if (previousBodyPaddingRight !== undefined) {\n document.body.style.paddingRight = previousBodyPaddingRight;\n\n // Restore previousBodyPaddingRight to undefined so setOverflowHidden knows it\n // can be set again.\n previousBodyPaddingRight = undefined;\n }\n\n if (previousBodyOverflowSetting !== undefined) {\n document.body.style.overflow = previousBodyOverflowSetting;\n\n // Restore previousBodyOverflowSetting to undefined\n // so setOverflowHidden knows it can be set again.\n previousBodyOverflowSetting = undefined;\n }\n};\n\n// https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight#Problems_and_solutions\nvar isTargetElementTotallyScrolled = function isTargetElementTotallyScrolled(targetElement) {\n return targetElement ? targetElement.scrollHeight - targetElement.scrollTop <= targetElement.clientHeight : false;\n};\n\nvar handleScroll = function handleScroll(event, targetElement) {\n var clientY = event.targetTouches[0].clientY - initialClientY;\n\n if (allowTouchMove(event.target)) {\n return false;\n }\n\n if (targetElement && targetElement.scrollTop === 0 && clientY > 0) {\n // element is at the top of its scroll.\n return preventDefault(event);\n }\n\n if (isTargetElementTotallyScrolled(targetElement) && clientY < 0) {\n // element is at the bottom of its scroll.\n return preventDefault(event);\n }\n\n event.stopPropagation();\n return true;\n};\n\nexport var disableBodyScroll = function disableBodyScroll(targetElement, options) {\n // targetElement must be provided\n if (!targetElement) {\n // eslint-disable-next-line no-console\n console.error('disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.');\n return;\n }\n\n // disableBodyScroll must not have been called on this targetElement before\n if (locks.some(function (lock) {\n return lock.targetElement === targetElement;\n })) {\n return;\n }\n\n var lock = {\n targetElement: targetElement,\n options: options || {}\n };\n\n locks = [].concat(_toConsumableArray(locks), [lock]);\n\n if (isIosDevice) {\n targetElement.ontouchstart = function (event) {\n if (event.targetTouches.length === 1) {\n // detect single touch.\n initialClientY = event.targetTouches[0].clientY;\n }\n };\n targetElement.ontouchmove = function (event) {\n if (event.targetTouches.length === 1) {\n // detect single touch.\n handleScroll(event, targetElement);\n }\n };\n\n if (!documentListenerAdded) {\n document.addEventListener('touchmove', preventDefault, hasPassiveEvents ? { passive: false } : undefined);\n documentListenerAdded = true;\n }\n } else {\n setOverflowHidden(options);\n }\n};\n\nexport var clearAllBodyScrollLocks = function clearAllBodyScrollLocks() {\n if (isIosDevice) {\n // Clear all locks ontouchstart/ontouchmove handlers, and the references.\n locks.forEach(function (lock) {\n lock.targetElement.ontouchstart = null;\n lock.targetElement.ontouchmove = null;\n });\n\n if (documentListenerAdded) {\n document.removeEventListener('touchmove', preventDefault, hasPassiveEvents ? { passive: false } : undefined);\n documentListenerAdded = false;\n }\n\n // Reset initial clientY.\n initialClientY = -1;\n } else {\n restoreOverflowSetting();\n }\n\n locks = [];\n};\n\nexport var enableBodyScroll = function enableBodyScroll(targetElement) {\n if (!targetElement) {\n // eslint-disable-next-line no-console\n console.error('enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.');\n return;\n }\n\n locks = locks.filter(function (lock) {\n return lock.targetElement !== targetElement;\n });\n\n if (isIosDevice) {\n targetElement.ontouchstart = null;\n targetElement.ontouchmove = null;\n\n if (documentListenerAdded && locks.length === 0) {\n document.removeEventListener('touchmove', preventDefault, hasPassiveEvents ? { passive: false } : undefined);\n documentListenerAdded = false;\n }\n } else if (!locks.length) {\n restoreOverflowSetting();\n }\n};\n\n","import { useEffect } from 'react';\nimport { disableBodyScroll, enableBodyScroll } from 'body-scroll-lock';\nimport { Falsy } from '@lumx/react/utils';\n\nexport const useDisableBodyScroll = (modalElement: Element | Falsy): void => {\n useEffect(() => {\n if (!modalElement) {\n return undefined;\n }\n // Fixing the document overflow style to prevent a bug that scrolls the window to the top.\n const previousDocumentOverflow = document.documentElement.style.overflow;\n document.documentElement.style.overflow = 'visible';\n disableBodyScroll(modalElement);\n return () => {\n enableBodyScroll(modalElement);\n // Restore the previous overflow style.\n document.documentElement.style.overflow = previousDocumentOverflow;\n };\n }, [modalElement]);\n};\n"],"names":["useDisableBodyScroll","modalElement","useEffect","undefined","previousDocumentOverflow","document","documentElement","style","overflow","disableBodyScroll","enableBodyScroll"],"mappings":";;AAAA,SAAS,kBAAkB,CAAC,GAAG,EAAE,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE;AACnM;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,gBAAgB,GAAG,KAAK,CAAC;AAC7B,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;AACnC,EAAE,IAAI,kBAAkB,GAAG;AAC3B,IAAI,IAAI,OAAO,GAAG;AAClB,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAC9B,MAAM,OAAO,SAAS,CAAC;AACvB,KAAK;AACL,GAAG,CAAC;AACJ,EAAE,MAAM,CAAC,gBAAgB,CAAC,aAAa,EAAE,IAAI,EAAE,kBAAkB,CAAC,CAAC;AACnE,EAAE,MAAM,CAAC,mBAAmB,CAAC,aAAa,EAAE,IAAI,EAAE,kBAAkB,CAAC,CAAC;AACtE,CAAC;AACD;AACA,IAAI,WAAW,GAAG,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,SAAS,CAAC,QAAQ,KAAK,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,SAAS,CAAC,QAAQ,KAAK,UAAU,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,GAAG,CAAC,CAAC,CA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EAAE;AACnB,IAAI,aAAa,CAAC,YAAY,GAAG,IAAI,CAAC;AACtC,IAAI,aAAa,CAAC,WAAW,GAAG,IAAI,CAAC;AACrC;AACA,IAAI,IAAI,qBAAqB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;AACrD,MAAM,QAAQ,CAAC,mBAAmB,CAAC,WAAW,EAAE,cAAc,EAAE,gBAAgB,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,SAAS,CAAC,CAAC;AACnH,MAAM,qBAAqB,GAAG,KAAK,CAAC;AACpC,KAAK;AACL,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;AAC5B,IAAI,sBAAsB,EAAE,CAAC;AAC7B,GAAG;AACH,CAAC;;IC9MYA,oBAAoB,GAAG,SAAvBA,oBAAuB,CAACC,YAAD,EAAyC;AACzEC,EAAAA,SAAS,CAAC,YAAM;AACZ,QAAI,CAACD,YAAL,EAAmB;AACf,aAAOE,SAAP;AACH,KAHW;;;AAKZ,QAAMC,wBAAwB,GAAGC,QAAQ,CAACC,eAAT,CAAyBC,KAAzB,CAA+BC,QAAhE;AACAH,IAAAA,QAAQ,CAACC,eAAT,CAAyBC,KAAzB,CAA+BC,QAA/B,GAA0C,SAA1C;AACAC,IAAAA,iBAAiB,CAACR,YAAD,CAAjB;AACA,WAAO,YAAM;AACTS,MAAAA,gBAAgB,CAACT,YAAD,CAAhB,CADS;;AAGTI,MAAAA,QAAQ,CAACC,eAAT,CAAyBC,KAAzB,CAA+BC,QAA/B,GAA0CJ,wBAA1C;AACH,KAJD;AAKH,GAbQ,EAaN,CAACH,YAAD,CAbM,CAAT;AAcH;;;;"}
package/package.json CHANGED
@@ -7,8 +7,8 @@
7
7
  },
8
8
  "dependencies": {
9
9
  "@juggle/resize-observer": "^3.2.0",
10
- "@lumx/core": "^2.0.3",
11
- "@lumx/icons": "^2.0.3",
10
+ "@lumx/core": "^2.1.0-alpha.11",
11
+ "@lumx/icons": "^2.1.0-alpha.11",
12
12
  "@popperjs/core": "^2.5.4",
13
13
  "body-scroll-lock": "^3.1.5",
14
14
  "classnames": "^2.2.6",
@@ -123,9 +123,9 @@
123
123
  "storybook": "start-storybook -s ../site-demo/static/ -p 9000"
124
124
  },
125
125
  "sideEffects": false,
126
- "version": "2.0.3",
126
+ "version": "2.1.0-alpha.11",
127
127
  "resolutions": {
128
128
  "**/style-loader": "^1.0.0"
129
129
  },
130
- "gitHead": "90aa7bf6b149fb7c4d2096aeba8f1eed7d302f41"
130
+ "gitHead": "f5e1d18bd6db9aeba81a40ad9f1bcada38e9e272"
131
131
  }
@@ -18,7 +18,6 @@ import {
18
18
  partitionMulti,
19
19
  } from '@lumx/react/utils';
20
20
  import { ClickAwayProvider } from '@lumx/react/utils/ClickAwayProvider';
21
- import { mergeRefs } from '@lumx/react/utils/mergeRefs';
22
21
 
23
22
  import { useDelayedVisibility } from '@lumx/react/hooks/useDelayedVisibility';
24
23
  import { useDisableBodyScroll } from '@lumx/react/hooks/useDisableBodyScroll';
@@ -130,18 +129,13 @@ export const Dialog: Comp<DialogProps, HTMLDivElement> = forwardRef((props, ref)
130
129
 
131
130
  // eslint-disable-next-line react-hooks/rules-of-hooks
132
131
  const wrapperRef = useRef<HTMLDivElement>(null);
133
- /**
134
- * Since the `contentRef` comes from the parent and is optional,
135
- * we need to create a stable contentRef that will always be available.
136
- */
137
- // eslint-disable-next-line react-hooks/rules-of-hooks
138
- const localContentRef = useRef<HTMLDivElement>(null);
132
+
139
133
  // Handle focus trap.
140
134
  // eslint-disable-next-line react-hooks/rules-of-hooks
141
135
  useFocusTrap(wrapperRef.current, focusElement?.current);
142
136
 
143
137
  // eslint-disable-next-line react-hooks/rules-of-hooks
144
- useDisableBodyScroll(isOpen && localContentRef.current);
138
+ useDisableBodyScroll(isOpen && wrapperRef.current);
145
139
 
146
140
  // eslint-disable-next-line react-hooks/rules-of-hooks
147
141
  const [sentinelTop, setSentinelTop] = useState<Element | null>(null);
@@ -209,7 +203,7 @@ export const Dialog: Comp<DialogProps, HTMLDivElement> = forwardRef((props, ref)
209
203
  </header>
210
204
  )}
211
205
 
212
- <div ref={mergeRefs(contentRef, localContentRef)} className={`${CLASSNAME}__content`}>
206
+ <div ref={contentRef} className={`${CLASSNAME}__content`}>
213
207
  <div
214
208
  className={`${CLASSNAME}__sentinel ${CLASSNAME}__sentinel--top`}
215
209
  ref={setSentinelTop}
@@ -149,7 +149,6 @@ export const Dropdown: Comp<DropdownProps, HTMLDivElement> = forwardRef((props,
149
149
  {...forwardedProps}
150
150
  anchorRef={anchorRef}
151
151
  className={classNames(className, handleBasicClasses({ prefix: CLASSNAME }))}
152
- elevation={0 as any}
153
152
  closeOnClickAway={closeOnClickAway}
154
153
  closeOnEscape={closeOnEscape}
155
154
  fitToAnchorWidth={fitToAnchorWidth}
@@ -10,7 +10,7 @@ exports[`<Dropdown> Snapshots and structure should render correctly 1`] = `
10
10
  className="lumx-dropdown"
11
11
  closeOnClickAway={true}
12
12
  closeOnEscape={true}
13
- elevation={0}
13
+ elevation={3}
14
14
  fitToAnchorWidth={true}
15
15
  fitWithinViewportHeight={true}
16
16
  focusElement={
@@ -106,17 +106,10 @@ export type Typography = ValueOf<typeof Typography>;
106
106
  * All available aspect ratios.
107
107
  */
108
108
  export const AspectRatio = {
109
- /** Intrinsic content ratio. */
110
109
  original: 'original',
111
- /** Ratio 16:9 */
112
- wide: 'wide',
113
- /** Ratio 3:2 */
114
110
  horizontal: 'horizontal',
115
- /** Ratio 3:2 */
116
111
  vertical: 'vertical',
117
- /** Ratio 1:1 */
118
112
  square: 'square',
119
- /** Ratio constrained by the parent. */
120
113
  free: 'free',
121
114
  } as const;
122
115
  export type AspectRatio = ValueOf<typeof AspectRatio>;
@@ -21,7 +21,7 @@ const variants = [
21
21
  SkeletonRectangleVariant.pill,
22
22
  ] as const;
23
23
  const sizes = [Size.xxs, Size.xs, Size.s, Size.m, Size.l, Size.xl, Size.xxl] as const;
24
- const aspectRatios = [AspectRatio.vertical, AspectRatio.square, AspectRatio.horizontal, AspectRatio.wide] as const;
24
+ const aspectRatios = [AspectRatio.vertical, AspectRatio.square, AspectRatio.horizontal] as const;
25
25
 
26
26
  export const Rectangle = ({ theme }: any) => (
27
27
  <>
@@ -15,7 +15,7 @@ export type SkeletonRectangleVariant = ValueOf<typeof SkeletonRectangleVariant>;
15
15
  */
16
16
  export interface SkeletonRectangleProps extends GenericProps {
17
17
  /** Aspect ratio (use with width and not height). */
18
- aspectRatio?: Extract<AspectRatio, 'square' | 'horizontal' | 'vertical' | 'wide'>;
18
+ aspectRatio?: Extract<AspectRatio, 'square' | 'horizontal' | 'vertical'>;
19
19
  /** Height size. */
20
20
  height?: GlobalSize;
21
21
  /** Theme adapting the component to light or dark background. */
@@ -2,12 +2,6 @@ import { useEffect } from 'react';
2
2
  import { disableBodyScroll, enableBodyScroll } from 'body-scroll-lock';
3
3
  import { Falsy } from '@lumx/react/utils';
4
4
 
5
- /**
6
- * Disables the scroll on the body to make it only usable in the current modal element.
7
- * When the modal element is not provided anymore, the scroll is restored.
8
- *
9
- * @param modalElement The modal element.
10
- */
11
5
  export const useDisableBodyScroll = (modalElement: Element | Falsy): void => {
12
6
  useEffect(() => {
13
7
  if (!modalElement) {
@@ -20,9 +14,7 @@ export const useDisableBodyScroll = (modalElement: Element | Falsy): void => {
20
14
  return () => {
21
15
  enableBodyScroll(modalElement);
22
16
  // Restore the previous overflow style.
23
- requestAnimationFrame(() => {
24
- document.documentElement.style.overflow = previousDocumentOverflow;
25
- });
17
+ document.documentElement.style.overflow = previousDocumentOverflow;
26
18
  };
27
19
  }, [modalElement]);
28
20
  };
@@ -7,9 +7,6 @@ type useInfiniteScrollType = (
7
7
  ) => void;
8
8
  type EventCallback = (evt?: Event) => void;
9
9
 
10
- // The error margin in px we want to have for triggering infinite scroll
11
- const SCROLL_TRIGGER_MARGIN = 5;
12
-
13
10
  /**
14
11
  * Listen to clicks away from a given element and callback the passed in function.
15
12
  *
@@ -17,22 +14,14 @@ const SCROLL_TRIGGER_MARGIN = 5;
17
14
  * @param [callback] A callback function to call when the bottom of the reference element is reached.
18
15
  * @param [callbackOnMount] A callback function to call when the component is mounted.
19
16
  */
20
- export const useInfiniteScroll: useInfiniteScrollType = (
21
- ref,
22
- callback,
23
- callbackOnMount = false,
24
- scrollTriggerMargin = SCROLL_TRIGGER_MARGIN,
25
- ) => {
17
+ export const useInfiniteScroll: useInfiniteScrollType = (ref, callback, callbackOnMount = false) => {
26
18
  useEffect(() => {
27
19
  const { current } = ref;
28
20
  if (!callback || !current) {
29
21
  return undefined;
30
22
  }
31
23
 
32
- const isAtBottom = () =>
33
- Boolean(
34
- current && current.scrollHeight - (current.scrollTop + current.clientHeight) <= scrollTriggerMargin,
35
- );
24
+ const isAtBottom = () => Boolean(current && current.scrollTop + current.clientHeight >= current.scrollHeight);
36
25
 
37
26
  const onScroll = (e?: Event): void => {
38
27
  if (isAtBottom()) {
@@ -50,7 +39,7 @@ export const useInfiniteScroll: useInfiniteScrollType = (
50
39
  current.removeEventListener('scroll', onScroll);
51
40
  current.removeEventListener('resize', onScroll);
52
41
  };
53
- }, [ref, callback, scrollTriggerMargin]);
42
+ }, [ref, callback]);
54
43
 
55
44
  useEffect(() => {
56
45
  if (callback && callbackOnMount) {
package/types.d.ts CHANGED
@@ -130,17 +130,10 @@ export declare type Typography = ValueOf<typeof Typography>;
130
130
  * All available aspect ratios.
131
131
  */
132
132
  export declare const AspectRatio: {
133
- /** Intrinsic content ratio. */
134
133
  readonly original: "original";
135
- /** Ratio 16:9 */
136
- readonly wide: "wide";
137
- /** Ratio 3:2 */
138
134
  readonly horizontal: "horizontal";
139
- /** Ratio 3:2 */
140
135
  readonly vertical: "vertical";
141
- /** Ratio 1:1 */
142
136
  readonly square: "square";
143
- /** Ratio constrained by the parent. */
144
137
  readonly free: "free";
145
138
  };
146
139
  export declare type AspectRatio = ValueOf<typeof AspectRatio>;
@@ -1909,7 +1902,7 @@ export declare type SkeletonRectangleVariant = ValueOf<typeof SkeletonRectangleV
1909
1902
  */
1910
1903
  export interface SkeletonRectangleProps extends GenericProps {
1911
1904
  /** Aspect ratio (use with width and not height). */
1912
- aspectRatio?: Extract<AspectRatio, "square" | "horizontal" | "vertical" | "wide">;
1905
+ aspectRatio?: Extract<AspectRatio, "square" | "horizontal" | "vertical">;
1913
1906
  /** Height size. */
1914
1907
  height?: GlobalSize;
1915
1908
  /** Theme adapting the component to light or dark background. */