@veeqo/ui 14.12.0 → 14.14.0-beta-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/dist/components/Alerts/Alert/Alert.cjs +16 -12
  2. package/dist/components/Alerts/Alert/Alert.cjs.map +1 -1
  3. package/dist/components/Alerts/Alert/Alert.d.ts +4 -1
  4. package/dist/components/Alerts/Alert/Alert.js +16 -12
  5. package/dist/components/Alerts/Alert/Alert.js.map +1 -1
  6. package/dist/components/Alerts/Alert/Alert.module.scss.cjs +2 -2
  7. package/dist/components/Alerts/Alert/Alert.module.scss.cjs.map +1 -1
  8. package/dist/components/Alerts/Alert/Alert.module.scss.js +2 -2
  9. package/dist/components/Alerts/Alert/Alert.module.scss.js.map +1 -1
  10. package/dist/components/Alerts/Alert/index.d.ts +1 -0
  11. package/dist/components/Alerts/Alert/types.d.ts +15 -1
  12. package/dist/components/Alerts/Alerts.module.scss.cjs +2 -2
  13. package/dist/components/Alerts/Alerts.module.scss.cjs.map +1 -1
  14. package/dist/components/Alerts/Alerts.module.scss.js +2 -2
  15. package/dist/components/Alerts/Alerts.module.scss.js.map +1 -1
  16. package/dist/components/Alerts/MiniAlert/MiniAlert.cjs +7 -4
  17. package/dist/components/Alerts/MiniAlert/MiniAlert.cjs.map +1 -1
  18. package/dist/components/Alerts/MiniAlert/MiniAlert.d.ts +4 -1
  19. package/dist/components/Alerts/MiniAlert/MiniAlert.js +7 -4
  20. package/dist/components/Alerts/MiniAlert/MiniAlert.js.map +1 -1
  21. package/dist/components/Alerts/MiniAlert/MiniAlert.module.scss.cjs +2 -2
  22. package/dist/components/Alerts/MiniAlert/MiniAlert.module.scss.cjs.map +1 -1
  23. package/dist/components/Alerts/MiniAlert/MiniAlert.module.scss.js +2 -2
  24. package/dist/components/Alerts/MiniAlert/MiniAlert.module.scss.js.map +1 -1
  25. package/dist/components/Alerts/MiniAlert/index.d.ts +1 -0
  26. package/dist/components/Alerts/MiniAlert/types.d.ts +10 -2
  27. package/dist/components/Alerts/constants.cjs.map +1 -1
  28. package/dist/components/Alerts/constants.d.ts +2 -2
  29. package/dist/components/Alerts/constants.js.map +1 -1
  30. package/dist/components/Alerts/types.d.ts +7 -1
  31. package/dist/components/DataGrid/components/Body/BodyCell/BodyCell.cjs +0 -1
  32. package/dist/components/DataGrid/components/Body/BodyCell/BodyCell.cjs.map +1 -1
  33. package/dist/components/DataGrid/components/Body/BodyCell/BodyCell.js +0 -1
  34. package/dist/components/DataGrid/components/Body/BodyCell/BodyCell.js.map +1 -1
  35. package/dist/components/DataGrid/components/Header/HeaderCell/HeaderCell.cjs +0 -1
  36. package/dist/components/DataGrid/components/Header/HeaderCell/HeaderCell.cjs.map +1 -1
  37. package/dist/components/DataGrid/components/Header/HeaderCell/HeaderCell.js +0 -1
  38. package/dist/components/DataGrid/components/Header/HeaderCell/HeaderCell.js.map +1 -1
  39. package/dist/components/DataTable/DataTable.cjs +0 -1
  40. package/dist/components/DataTable/DataTable.cjs.map +1 -1
  41. package/dist/components/DataTable/DataTable.js +0 -1
  42. package/dist/components/DataTable/DataTable.js.map +1 -1
  43. package/dist/components/DataTable/renderers/renderHeader.cjs +0 -1
  44. package/dist/components/DataTable/renderers/renderHeader.cjs.map +1 -1
  45. package/dist/components/DataTable/renderers/renderHeader.js +0 -1
  46. package/dist/components/DataTable/renderers/renderHeader.js.map +1 -1
  47. package/dist/components/LegacyDataTable/StickyHeader.cjs +22 -4
  48. package/dist/components/LegacyDataTable/StickyHeader.cjs.map +1 -1
  49. package/dist/components/LegacyDataTable/StickyHeader.js +23 -5
  50. package/dist/components/LegacyDataTable/StickyHeader.js.map +1 -1
  51. package/dist/components/Modal/Modal.cjs +2 -20
  52. package/dist/components/Modal/Modal.cjs.map +1 -1
  53. package/dist/components/Modal/Modal.js +1 -19
  54. package/dist/components/Modal/Modal.js.map +1 -1
  55. package/dist/components/Popup/Popup.cjs +28 -0
  56. package/dist/components/Popup/Popup.cjs.map +1 -0
  57. package/dist/components/Popup/Popup.d.ts +3 -0
  58. package/dist/components/Popup/Popup.js +22 -0
  59. package/dist/components/Popup/Popup.js.map +1 -0
  60. package/dist/components/Popup/Popup.module.scss.cjs +9 -0
  61. package/dist/components/Popup/Popup.module.scss.cjs.map +1 -0
  62. package/dist/components/Popup/Popup.module.scss.js +7 -0
  63. package/dist/components/Popup/Popup.module.scss.js.map +1 -0
  64. package/dist/components/Popup/index.d.ts +2 -0
  65. package/dist/components/{VideoModal/components/Popup.d.ts → Popup/types.d.ts} +1 -2
  66. package/dist/components/ScrollLock/ScrollLock.cjs +26 -0
  67. package/dist/components/ScrollLock/ScrollLock.cjs.map +1 -0
  68. package/dist/components/ScrollLock/ScrollLock.d.ts +1 -0
  69. package/dist/components/ScrollLock/ScrollLock.js +24 -0
  70. package/dist/components/ScrollLock/ScrollLock.js.map +1 -0
  71. package/dist/components/ScrollLock/index.d.ts +1 -0
  72. package/dist/components/ViewsContainer/hooks/useSetScrollPosition.cjs +8 -2
  73. package/dist/components/ViewsContainer/hooks/useSetScrollPosition.cjs.map +1 -1
  74. package/dist/components/ViewsContainer/hooks/useSetScrollPosition.js +8 -2
  75. package/dist/components/ViewsContainer/hooks/useSetScrollPosition.js.map +1 -1
  76. package/dist/components/index.d.ts +4 -3
  77. package/dist/index.cjs +2 -6
  78. package/dist/index.cjs.map +1 -1
  79. package/dist/index.js +1 -3
  80. package/dist/index.js.map +1 -1
  81. package/dist/theme/index.cjs +0 -1
  82. package/dist/theme/index.cjs.map +1 -1
  83. package/dist/theme/index.d.ts +0 -1
  84. package/dist/theme/index.js +0 -1
  85. package/dist/theme/index.js.map +1 -1
  86. package/package.json +2 -14
  87. package/dist/components/VideoModal/VideoModal.cjs +0 -26
  88. package/dist/components/VideoModal/VideoModal.cjs.map +0 -1
  89. package/dist/components/VideoModal/VideoModal.d.ts +0 -3
  90. package/dist/components/VideoModal/VideoModal.js +0 -20
  91. package/dist/components/VideoModal/VideoModal.js.map +0 -1
  92. package/dist/components/VideoModal/VideoModalDemo.d.ts +0 -2
  93. package/dist/components/VideoModal/components/Popup.cjs +0 -24
  94. package/dist/components/VideoModal/components/Popup.cjs.map +0 -1
  95. package/dist/components/VideoModal/components/Popup.js +0 -17
  96. package/dist/components/VideoModal/components/Popup.js.map +0 -1
  97. package/dist/components/VideoModal/components/styled.cjs +0 -26
  98. package/dist/components/VideoModal/components/styled.cjs.map +0 -1
  99. package/dist/components/VideoModal/components/styled.d.ts +0 -8
  100. package/dist/components/VideoModal/components/styled.js +0 -18
  101. package/dist/components/VideoModal/components/styled.js.map +0 -1
  102. package/dist/components/VideoModal/index.d.ts +0 -2
  103. package/dist/components/VideoModal/styled.cjs +0 -17
  104. package/dist/components/VideoModal/styled.cjs.map +0 -1
  105. package/dist/components/VideoModal/styled.d.ts +0 -11
  106. package/dist/components/VideoModal/styled.js +0 -9
  107. package/dist/components/VideoModal/styled.js.map +0 -1
  108. package/dist/components/VideoModal/types.d.ts +0 -9
  109. package/dist/theme/utils.cjs +0 -8
  110. package/dist/theme/utils.cjs.map +0 -1
  111. package/dist/theme/utils.d.ts +0 -2
  112. package/dist/theme/utils.js +0 -6
  113. package/dist/theme/utils.js.map +0 -1
  114. package/dist/utils/forms/inputStyles.d.ts +0 -22
  115. package/dist/utils/forms/variables.d.ts +0 -8
@@ -10,6 +10,7 @@ var useIsOverflowing = require('../../hooks/useIsOverflowing.cjs');
10
10
  var Button = require('../Button/Button.cjs');
11
11
  var Card = require('../Card/Card.cjs');
12
12
  var CardHeader = require('../CardHeader/CardHeader.cjs');
13
+ var ScrollLock = require('../ScrollLock/ScrollLock.cjs');
13
14
  var Stack = require('../Stack/Stack.cjs');
14
15
  var utils = require('./utils.cjs');
15
16
  var Modal_module = require('./Modal.module.scss.cjs');
@@ -19,25 +20,6 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
19
20
  var React__default = /*#__PURE__*/_interopDefaultCompat(React);
20
21
 
21
22
  /* eslint-disable react/destructuring-assignment */
22
- /**
23
- * Manages body scroll-lock as a component mounted inside AnimatePresence.
24
- * Reference-counted so multiple simultaneous modals don't conflict:
25
- * the class only removes when the last modal unmounts.
26
- */
27
- let scrollLockCount = 0;
28
- const ScrollLock = () => {
29
- React.useEffect(() => {
30
- scrollLockCount += 1;
31
- document.body.classList.add('veeqo-modal-open');
32
- return () => {
33
- scrollLockCount -= 1;
34
- if (scrollLockCount === 0) {
35
- document.body.classList.remove('veeqo-modal-open');
36
- }
37
- };
38
- }, []);
39
- return null;
40
- };
41
23
  const Modal = (props) => {
42
24
  const { shouldShow, showHeaderCloseButton = true, preventClose = false, displayMode = 'modal', fullBleed = false, variant = 'base', onClose: parentOnClose, children, ...rest } = props;
43
25
  const modalRef = React.useRef(null);
@@ -76,7 +58,7 @@ const Modal = (props) => {
76
58
  handleClose();
77
59
  };
78
60
  return (React__default.default.createElement(framerMotion.AnimatePresence, null, shouldShow && (React__default.default.createElement("div", { "data-testid": "dialog-wrapper", style: { position: 'absolute' } },
79
- React__default.default.createElement(ScrollLock, null),
61
+ React__default.default.createElement(ScrollLock.ScrollLock, null),
80
62
  React__default.default.createElement(Dialog.Dialog, { "data-dialog-type": "modal", displayMode: displayMode, variant: variant, ref: modalRef, onClose: handleClose, onKeyDown: preventClose ? utils.preventDefaultEventOnESC : handleKeyDown, onClick: handleBackdropClick, ...rest, "aria-describedby": "modal_title", appearance: (types.isSideDraw(props) && props.appearance) || 'primary' },
81
63
  React__default.default.createElement(Card.Card.Surface, null,
82
64
  types.hasHeaderSlot(props) ? (props.headerSlot) : (React__default.default.createElement(CardHeader.CardHeader, { id: "modal_title", headerVariant: "headingLarge", title: props.headerTitle, subtitle: props.headerSubtitle, ...(showHeaderCloseButton && { onClickClose: handleClose }) })),
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.cjs","sources":["../../../src/components/Modal/Modal.tsx"],"sourcesContent":["/* eslint-disable react/destructuring-assignment */\nimport React, { useEffect, useRef, useState } from 'react';\nimport { AnimatePresence } from 'framer-motion';\n\nimport { ModalProps, hasFooterSlot, hasHeaderSlot, isSideDraw } from './types';\nimport { Dialog } from './components/Dialog/Dialog';\n\nimport { buildClassnames } from '../../utils';\nimport { useIsOverflowing } from '../../hooks/useIsOverflowing';\nimport { Button } from '../Button';\nimport { Card } from '../Card';\nimport { CardHeader } from '../CardHeader';\nimport { Stack } from '../Stack';\nimport { preventDefaultEventOnESC } from './utils';\nimport modalStyles from './Modal.module.scss';\n\n/**\n * Manages body scroll-lock as a component mounted inside AnimatePresence.\n * Reference-counted so multiple simultaneous modals don't conflict:\n * the class only removes when the last modal unmounts.\n */\nlet scrollLockCount = 0;\n\nconst ScrollLock = () => {\n useEffect(() => {\n scrollLockCount += 1;\n document.body.classList.add('veeqo-modal-open');\n return () => {\n scrollLockCount -= 1;\n if (scrollLockCount === 0) {\n document.body.classList.remove('veeqo-modal-open');\n }\n };\n }, []);\n return null;\n};\n\nexport const Modal = (props: ModalProps) => {\n const {\n shouldShow,\n showHeaderCloseButton = true,\n preventClose = false,\n displayMode = 'modal',\n fullBleed = false,\n variant = 'base',\n onClose: parentOnClose,\n children,\n ...rest\n } = props;\n\n const modalRef = useRef<HTMLDialogElement | null>(null);\n const [mainSectionRef, setMainSectionRef] = useState<HTMLElement | null>(null);\n\n useEffect(() => {\n if (shouldShow) {\n modalRef.current?.removeAttribute('open'); // Allows for conditional rendering.\n modalRef.current?.showModal();\n }\n }, [shouldShow]);\n\n const { isOverflowing: isContentOverflowing, onScroll } = useIsOverflowing(mainSectionRef);\n\n const handleClose = () => {\n if (preventClose) return;\n\n const result = parentOnClose();\n if (result === false) return; // Otherwise close on void, or true.\n\n modalRef.current?.close();\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLDialogElement>) => {\n if (e.key === 'Escape') {\n e.preventDefault(); // Prevent default ESC behavior\n\n // Don't close if this is the top level and there are other dialogs open\n const openDialogs = document.querySelectorAll('dialog[open]');\n if (openDialogs.length > 1 && modalRef.current === openDialogs[0]) return;\n\n handleClose();\n }\n };\n\n const handleBackdropClick = async (e: React.MouseEvent<HTMLDialogElement>) => {\n if (displayMode === 'modal') return;\n if (e.target === modalRef.current) handleClose();\n };\n\n return (\n <AnimatePresence>\n {shouldShow && (\n <div data-testid=\"dialog-wrapper\" style={{ position: 'absolute' }}>\n <ScrollLock />\n <Dialog\n data-dialog-type=\"modal\"\n displayMode={displayMode}\n variant={variant}\n ref={modalRef}\n onClose={handleClose}\n onKeyDown={preventClose ? preventDefaultEventOnESC : handleKeyDown}\n onClick={handleBackdropClick}\n {...rest}\n aria-describedby=\"modal_title\"\n appearance={(isSideDraw(props) && props.appearance) || 'primary'}\n >\n <Card.Surface>\n {hasHeaderSlot(props) ? (\n props.headerSlot\n ) : (\n <CardHeader\n id=\"modal_title\"\n headerVariant=\"headingLarge\"\n title={props.headerTitle}\n subtitle={props.headerSubtitle}\n {...(showHeaderCloseButton && { onClickClose: handleClose })}\n />\n )}\n\n <section\n onScroll={onScroll}\n ref={setMainSectionRef}\n className={buildClassnames([\n modalStyles.mainSection,\n fullBleed && modalStyles.fullBleed,\n isContentOverflowing && modalStyles.scrollable,\n ])}\n >\n {children}\n </section>\n\n {hasFooterSlot(props) && props.footerSlot}\n\n {!hasFooterSlot(props) && (props.leftActions || props.rightActions) && (\n <Card.Footer>\n <Stack direction=\"horizontal\" alignX={props.leftActions ? 'between' : 'end'}>\n {props.leftActions && (\n <Stack\n direction=\"horizontal\"\n alignX=\"start\"\n data-testid=\"left-actions-container\"\n >\n {props.leftActions.map(({ label, ...actionProps }) => (\n <Button key={label} type=\"button\" {...actionProps}>\n {label}\n </Button>\n ))}\n </Stack>\n )}\n {props.rightActions && (\n <Stack\n direction=\"horizontal\"\n alignX=\"end\"\n data-testid=\"right-actions-container\"\n >\n {props.rightActions.map(({ label, ...actionProps }) => (\n <Button key={label} type=\"button\" {...actionProps}>\n {label}\n </Button>\n ))}\n </Stack>\n )}\n </Stack>\n </Card.Footer>\n )}\n </Card.Surface>\n </Dialog>\n </div>\n )}\n </AnimatePresence>\n );\n};\n"],"names":["useEffect","useRef","useState","useIsOverflowing","React","AnimatePresence","Dialog","preventDefaultEventOnESC","isSideDraw","Card","hasHeaderSlot","CardHeader","buildClassnames","modalStyles","hasFooterSlot","Stack","Button"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAgBA;;;;AAIG;AACH,IAAI,eAAe,GAAG,CAAC;AAEvB,MAAM,UAAU,GAAG,MAAK;IACtBA,eAAS,CAAC,MAAK;QACb,eAAe,IAAI,CAAC;QACpB,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,kBAAkB,CAAC;AAC/C,QAAA,OAAO,MAAK;YACV,eAAe,IAAI,CAAC;YACpB,IAAI,eAAe,KAAK,CAAC,EAAE;gBACzB,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,kBAAkB,CAAC;AACnD,YAAA;AACH,QAAA,CAAC;IACH,CAAC,EAAE,EAAE,CAAC;AACN,IAAA,OAAO,IAAI;AACb,CAAC;AAEM,MAAM,KAAK,GAAG,CAAC,KAAiB,KAAI;AACzC,IAAA,MAAM,EACJ,UAAU,EACV,qBAAqB,GAAG,IAAI,EAC5B,YAAY,GAAG,KAAK,EACpB,WAAW,GAAG,OAAO,EACrB,SAAS,GAAG,KAAK,EACjB,OAAO,GAAG,MAAM,EAChB,OAAO,EAAE,aAAa,EACtB,QAAQ,EACR,GAAG,IAAI,EACR,GAAG,KAAK;AAET,IAAA,MAAM,QAAQ,GAAGC,YAAM,CAA2B,IAAI,CAAC;IACvD,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAGC,cAAQ,CAAqB,IAAI,CAAC;IAE9EF,eAAS,CAAC,MAAK;;AACb,QAAA,IAAI,UAAU,EAAE;YACd,CAAA,EAAA,GAAA,QAAQ,CAAC,OAAO,MAAA,IAAA,IAAA,EAAA,KAAA,MAAA,GAAA,MAAA,GAAA,EAAA,CAAE,eAAe,CAAC,MAAM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Modal/Modal.tsx"],"sourcesContent":["/* eslint-disable react/destructuring-assignment */\nimport React, { useEffect, useRef, useState } from 'react';\nimport { AnimatePresence } from 'framer-motion';\n\nimport { ModalProps, hasFooterSlot, hasHeaderSlot, isSideDraw } from './types';\nimport { Dialog } from './components/Dialog/Dialog';\n\nimport { buildClassnames } from '../../utils';\nimport { useIsOverflowing } from '../../hooks/useIsOverflowing';\nimport { Button } from '../Button';\nimport { Card } from '../Card';\nimport { CardHeader } from '../CardHeader';\nimport { ScrollLock } from '../ScrollLock';\nimport { Stack } from '../Stack';\nimport { preventDefaultEventOnESC } from './utils';\nimport modalStyles from './Modal.module.scss';\n\nexport const Modal = (props: ModalProps) => {\n const {\n shouldShow,\n showHeaderCloseButton = true,\n preventClose = false,\n displayMode = 'modal',\n fullBleed = false,\n variant = 'base',\n onClose: parentOnClose,\n children,\n ...rest\n } = props;\n\n const modalRef = useRef<HTMLDialogElement | null>(null);\n const [mainSectionRef, setMainSectionRef] = useState<HTMLElement | null>(null);\n\n useEffect(() => {\n if (shouldShow) {\n modalRef.current?.removeAttribute('open'); // Allows for conditional rendering.\n modalRef.current?.showModal();\n }\n }, [shouldShow]);\n\n const { isOverflowing: isContentOverflowing, onScroll } = useIsOverflowing(mainSectionRef);\n\n const handleClose = () => {\n if (preventClose) return;\n\n const result = parentOnClose();\n if (result === false) return; // Otherwise close on void, or true.\n\n modalRef.current?.close();\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLDialogElement>) => {\n if (e.key === 'Escape') {\n e.preventDefault(); // Prevent default ESC behavior\n\n // Don't close if this is the top level and there are other dialogs open\n const openDialogs = document.querySelectorAll('dialog[open]');\n if (openDialogs.length > 1 && modalRef.current === openDialogs[0]) return;\n\n handleClose();\n }\n };\n\n const handleBackdropClick = async (e: React.MouseEvent<HTMLDialogElement>) => {\n if (displayMode === 'modal') return;\n if (e.target === modalRef.current) handleClose();\n };\n\n return (\n <AnimatePresence>\n {shouldShow && (\n <div data-testid=\"dialog-wrapper\" style={{ position: 'absolute' }}>\n <ScrollLock />\n <Dialog\n data-dialog-type=\"modal\"\n displayMode={displayMode}\n variant={variant}\n ref={modalRef}\n onClose={handleClose}\n onKeyDown={preventClose ? preventDefaultEventOnESC : handleKeyDown}\n onClick={handleBackdropClick}\n {...rest}\n aria-describedby=\"modal_title\"\n appearance={(isSideDraw(props) && props.appearance) || 'primary'}\n >\n <Card.Surface>\n {hasHeaderSlot(props) ? (\n props.headerSlot\n ) : (\n <CardHeader\n id=\"modal_title\"\n headerVariant=\"headingLarge\"\n title={props.headerTitle}\n subtitle={props.headerSubtitle}\n {...(showHeaderCloseButton && { onClickClose: handleClose })}\n />\n )}\n\n <section\n onScroll={onScroll}\n ref={setMainSectionRef}\n className={buildClassnames([\n modalStyles.mainSection,\n fullBleed && modalStyles.fullBleed,\n isContentOverflowing && modalStyles.scrollable,\n ])}\n >\n {children}\n </section>\n\n {hasFooterSlot(props) && props.footerSlot}\n\n {!hasFooterSlot(props) && (props.leftActions || props.rightActions) && (\n <Card.Footer>\n <Stack direction=\"horizontal\" alignX={props.leftActions ? 'between' : 'end'}>\n {props.leftActions && (\n <Stack\n direction=\"horizontal\"\n alignX=\"start\"\n data-testid=\"left-actions-container\"\n >\n {props.leftActions.map(({ label, ...actionProps }) => (\n <Button key={label} type=\"button\" {...actionProps}>\n {label}\n </Button>\n ))}\n </Stack>\n )}\n {props.rightActions && (\n <Stack\n direction=\"horizontal\"\n alignX=\"end\"\n data-testid=\"right-actions-container\"\n >\n {props.rightActions.map(({ label, ...actionProps }) => (\n <Button key={label} type=\"button\" {...actionProps}>\n {label}\n </Button>\n ))}\n </Stack>\n )}\n </Stack>\n </Card.Footer>\n )}\n </Card.Surface>\n </Dialog>\n </div>\n )}\n </AnimatePresence>\n );\n};\n"],"names":["useRef","useState","useEffect","useIsOverflowing","React","AnimatePresence","ScrollLock","Dialog","preventDefaultEventOnESC","isSideDraw","Card","hasHeaderSlot","CardHeader","buildClassnames","modalStyles","hasFooterS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AAA,CAAA,aAAA,CAACa,aAAM,EAAA,EAAC,GAAG,EAAE,KAAK,EAAE,IAAI,EAAC,QAAQ,EAAA,GAAK,WAAW,EAAA,EAC9C,KAAK,CACC,CACV,CAAC,CACI,CACT;AACA,wBAAA,KAAK,CAAC,YAAY,KACjBb,sBAAA,CAAA,aAAA,CAACY,WAAK,EAAA,EACJ,SAAS,EAAC,YAAY,EACtB,MAAM,EAAC,KAAK,EAAA,aAAA,EACA,yBAAyB,EAAA,EAEpC,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,WAAW,EAAE,MAChDZ,sBAAA,CAAA,aAAA,CAACa,aAAM,EAAA,EAAC,GAAG,EAAE,KAAK,EAAE,IAAI,EAAC,QAAQ,EAAA,GAAK,WAAW,EAAA,EAC9C,KAAK,CACC,CACV,CAAC,CACI,CACT,CACK,CACI,CACf,CACY,CACR,CACL,CACP,CACe;AAEtB;;;;"}
@@ -8,30 +8,12 @@ import { useIsOverflowing } from '../../hooks/useIsOverflowing.js';
8
8
  import { Button } from '../Button/Button.js';
9
9
  import { Card } from '../Card/Card.js';
10
10
  import { CardHeader } from '../CardHeader/CardHeader.js';
11
+ import { ScrollLock } from '../ScrollLock/ScrollLock.js';
11
12
  import { Stack } from '../Stack/Stack.js';
12
13
  import { preventDefaultEventOnESC } from './utils.js';
13
14
  import modalStyles from './Modal.module.scss.js';
14
15
 
15
16
  /* eslint-disable react/destructuring-assignment */
16
- /**
17
- * Manages body scroll-lock as a component mounted inside AnimatePresence.
18
- * Reference-counted so multiple simultaneous modals don't conflict:
19
- * the class only removes when the last modal unmounts.
20
- */
21
- let scrollLockCount = 0;
22
- const ScrollLock = () => {
23
- useEffect(() => {
24
- scrollLockCount += 1;
25
- document.body.classList.add('veeqo-modal-open');
26
- return () => {
27
- scrollLockCount -= 1;
28
- if (scrollLockCount === 0) {
29
- document.body.classList.remove('veeqo-modal-open');
30
- }
31
- };
32
- }, []);
33
- return null;
34
- };
35
17
  const Modal = (props) => {
36
18
  const { shouldShow, showHeaderCloseButton = true, preventClose = false, displayMode = 'modal', fullBleed = false, variant = 'base', onClose: parentOnClose, children, ...rest } = props;
37
19
  const modalRef = useRef(null);
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.js","sources":["../../../src/components/Modal/Modal.tsx"],"sourcesContent":["/* eslint-disable react/destructuring-assignment */\nimport React, { useEffect, useRef, useState } from 'react';\nimport { AnimatePresence } from 'framer-motion';\n\nimport { ModalProps, hasFooterSlot, hasHeaderSlot, isSideDraw } from './types';\nimport { Dialog } from './components/Dialog/Dialog';\n\nimport { buildClassnames } from '../../utils';\nimport { useIsOverflowing } from '../../hooks/useIsOverflowing';\nimport { Button } from '../Button';\nimport { Card } from '../Card';\nimport { CardHeader } from '../CardHeader';\nimport { Stack } from '../Stack';\nimport { preventDefaultEventOnESC } from './utils';\nimport modalStyles from './Modal.module.scss';\n\n/**\n * Manages body scroll-lock as a component mounted inside AnimatePresence.\n * Reference-counted so multiple simultaneous modals don't conflict:\n * the class only removes when the last modal unmounts.\n */\nlet scrollLockCount = 0;\n\nconst ScrollLock = () => {\n useEffect(() => {\n scrollLockCount += 1;\n document.body.classList.add('veeqo-modal-open');\n return () => {\n scrollLockCount -= 1;\n if (scrollLockCount === 0) {\n document.body.classList.remove('veeqo-modal-open');\n }\n };\n }, []);\n return null;\n};\n\nexport const Modal = (props: ModalProps) => {\n const {\n shouldShow,\n showHeaderCloseButton = true,\n preventClose = false,\n displayMode = 'modal',\n fullBleed = false,\n variant = 'base',\n onClose: parentOnClose,\n children,\n ...rest\n } = props;\n\n const modalRef = useRef<HTMLDialogElement | null>(null);\n const [mainSectionRef, setMainSectionRef] = useState<HTMLElement | null>(null);\n\n useEffect(() => {\n if (shouldShow) {\n modalRef.current?.removeAttribute('open'); // Allows for conditional rendering.\n modalRef.current?.showModal();\n }\n }, [shouldShow]);\n\n const { isOverflowing: isContentOverflowing, onScroll } = useIsOverflowing(mainSectionRef);\n\n const handleClose = () => {\n if (preventClose) return;\n\n const result = parentOnClose();\n if (result === false) return; // Otherwise close on void, or true.\n\n modalRef.current?.close();\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLDialogElement>) => {\n if (e.key === 'Escape') {\n e.preventDefault(); // Prevent default ESC behavior\n\n // Don't close if this is the top level and there are other dialogs open\n const openDialogs = document.querySelectorAll('dialog[open]');\n if (openDialogs.length > 1 && modalRef.current === openDialogs[0]) return;\n\n handleClose();\n }\n };\n\n const handleBackdropClick = async (e: React.MouseEvent<HTMLDialogElement>) => {\n if (displayMode === 'modal') return;\n if (e.target === modalRef.current) handleClose();\n };\n\n return (\n <AnimatePresence>\n {shouldShow && (\n <div data-testid=\"dialog-wrapper\" style={{ position: 'absolute' }}>\n <ScrollLock />\n <Dialog\n data-dialog-type=\"modal\"\n displayMode={displayMode}\n variant={variant}\n ref={modalRef}\n onClose={handleClose}\n onKeyDown={preventClose ? preventDefaultEventOnESC : handleKeyDown}\n onClick={handleBackdropClick}\n {...rest}\n aria-describedby=\"modal_title\"\n appearance={(isSideDraw(props) && props.appearance) || 'primary'}\n >\n <Card.Surface>\n {hasHeaderSlot(props) ? (\n props.headerSlot\n ) : (\n <CardHeader\n id=\"modal_title\"\n headerVariant=\"headingLarge\"\n title={props.headerTitle}\n subtitle={props.headerSubtitle}\n {...(showHeaderCloseButton && { onClickClose: handleClose })}\n />\n )}\n\n <section\n onScroll={onScroll}\n ref={setMainSectionRef}\n className={buildClassnames([\n modalStyles.mainSection,\n fullBleed && modalStyles.fullBleed,\n isContentOverflowing && modalStyles.scrollable,\n ])}\n >\n {children}\n </section>\n\n {hasFooterSlot(props) && props.footerSlot}\n\n {!hasFooterSlot(props) && (props.leftActions || props.rightActions) && (\n <Card.Footer>\n <Stack direction=\"horizontal\" alignX={props.leftActions ? 'between' : 'end'}>\n {props.leftActions && (\n <Stack\n direction=\"horizontal\"\n alignX=\"start\"\n data-testid=\"left-actions-container\"\n >\n {props.leftActions.map(({ label, ...actionProps }) => (\n <Button key={label} type=\"button\" {...actionProps}>\n {label}\n </Button>\n ))}\n </Stack>\n )}\n {props.rightActions && (\n <Stack\n direction=\"horizontal\"\n alignX=\"end\"\n data-testid=\"right-actions-container\"\n >\n {props.rightActions.map(({ label, ...actionProps }) => (\n <Button key={label} type=\"button\" {...actionProps}>\n {label}\n </Button>\n ))}\n </Stack>\n )}\n </Stack>\n </Card.Footer>\n )}\n </Card.Surface>\n </Dialog>\n </div>\n )}\n </AnimatePresence>\n );\n};\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;AAAA;AAgBA;;;;AAIG;AACH,IAAI,eAAe,GAAG,CAAC;AAEvB,MAAM,UAAU,GAAG,MAAK;IACtB,SAAS,CAAC,MAAK;QACb,eAAe,IAAI,CAAC;QACpB,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,kBAAkB,CAAC;AAC/C,QAAA,OAAO,MAAK;YACV,eAAe,IAAI,CAAC;YACpB,IAAI,eAAe,KAAK,CAAC,EAAE;gBACzB,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,kBAAkB,CAAC;AACnD,YAAA;AACH,QAAA,CAAC;IACH,CAAC,EAAE,EAAE,CAAC;AACN,IAAA,OAAO,IAAI;AACb,CAAC;AAEM,MAAM,KAAK,GAAG,CAAC,KAAiB,KAAI;AACzC,IAAA,MAAM,EACJ,UAAU,EACV,qBAAqB,GAAG,IAAI,EAC5B,YAAY,GAAG,KAAK,EACpB,WAAW,GAAG,OAAO,EACrB,SAAS,GAAG,KAAK,EACjB,OAAO,GAAG,MAAM,EAChB,OAAO,EAAE,aAAa,EACtB,QAAQ,EACR,GAAG,IAAI,EACR,GAAG,KAAK;AAET,IAAA,MAAM,QAAQ,GAAG,MAAM,CAA2B,IAAI,CAAC;IACvD,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAqB,IAAI,CAAC;IAE9E,SAAS,CAAC,MAAK;;AACb,QA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,CAAC,CACI,CACT,CACK,CACI,CACf,CACY,CACR,CACL,CACP,CACe;AAEtB;;;;"}
1
+ {"version":3,"file":"Modal.js","sources":["../../../src/components/Modal/Modal.tsx"],"sourcesContent":["/* eslint-disable react/destructuring-assignment */\nimport React, { useEffect, useRef, useState } from 'react';\nimport { AnimatePresence } from 'framer-motion';\n\nimport { ModalProps, hasFooterSlot, hasHeaderSlot, isSideDraw } from './types';\nimport { Dialog } from './components/Dialog/Dialog';\n\nimport { buildClassnames } from '../../utils';\nimport { useIsOverflowing } from '../../hooks/useIsOverflowing';\nimport { Button } from '../Button';\nimport { Card } from '../Card';\nimport { CardHeader } from '../CardHeader';\nimport { ScrollLock } from '../ScrollLock';\nimport { Stack } from '../Stack';\nimport { preventDefaultEventOnESC } from './utils';\nimport modalStyles from './Modal.module.scss';\n\nexport const Modal = (props: ModalProps) => {\n const {\n shouldShow,\n showHeaderCloseButton = true,\n preventClose = false,\n displayMode = 'modal',\n fullBleed = false,\n variant = 'base',\n onClose: parentOnClose,\n children,\n ...rest\n } = props;\n\n const modalRef = useRef<HTMLDialogElement | null>(null);\n const [mainSectionRef, setMainSectionRef] = useState<HTMLElement | null>(null);\n\n useEffect(() => {\n if (shouldShow) {\n modalRef.current?.removeAttribute('open'); // Allows for conditional rendering.\n modalRef.current?.showModal();\n }\n }, [shouldShow]);\n\n const { isOverflowing: isContentOverflowing, onScroll } = useIsOverflowing(mainSectionRef);\n\n const handleClose = () => {\n if (preventClose) return;\n\n const result = parentOnClose();\n if (result === false) return; // Otherwise close on void, or true.\n\n modalRef.current?.close();\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLDialogElement>) => {\n if (e.key === 'Escape') {\n e.preventDefault(); // Prevent default ESC behavior\n\n // Don't close if this is the top level and there are other dialogs open\n const openDialogs = document.querySelectorAll('dialog[open]');\n if (openDialogs.length > 1 && modalRef.current === openDialogs[0]) return;\n\n handleClose();\n }\n };\n\n const handleBackdropClick = async (e: React.MouseEvent<HTMLDialogElement>) => {\n if (displayMode === 'modal') return;\n if (e.target === modalRef.current) handleClose();\n };\n\n return (\n <AnimatePresence>\n {shouldShow && (\n <div data-testid=\"dialog-wrapper\" style={{ position: 'absolute' }}>\n <ScrollLock />\n <Dialog\n data-dialog-type=\"modal\"\n displayMode={displayMode}\n variant={variant}\n ref={modalRef}\n onClose={handleClose}\n onKeyDown={preventClose ? preventDefaultEventOnESC : handleKeyDown}\n onClick={handleBackdropClick}\n {...rest}\n aria-describedby=\"modal_title\"\n appearance={(isSideDraw(props) && props.appearance) || 'primary'}\n >\n <Card.Surface>\n {hasHeaderSlot(props) ? (\n props.headerSlot\n ) : (\n <CardHeader\n id=\"modal_title\"\n headerVariant=\"headingLarge\"\n title={props.headerTitle}\n subtitle={props.headerSubtitle}\n {...(showHeaderCloseButton && { onClickClose: handleClose })}\n />\n )}\n\n <section\n onScroll={onScroll}\n ref={setMainSectionRef}\n className={buildClassnames([\n modalStyles.mainSection,\n fullBleed && modalStyles.fullBleed,\n isContentOverflowing && modalStyles.scrollable,\n ])}\n >\n {children}\n </section>\n\n {hasFooterSlot(props) && props.footerSlot}\n\n {!hasFooterSlot(props) && (props.leftActions || props.rightActions) && (\n <Card.Footer>\n <Stack direction=\"horizontal\" alignX={props.leftActions ? 'between' : 'end'}>\n {props.leftActions && (\n <Stack\n direction=\"horizontal\"\n alignX=\"start\"\n data-testid=\"left-actions-container\"\n >\n {props.leftActions.map(({ label, ...actionProps }) => (\n <Button key={label} type=\"button\" {...actionProps}>\n {label}\n </Button>\n ))}\n </Stack>\n )}\n {props.rightActions && (\n <Stack\n direction=\"horizontal\"\n alignX=\"end\"\n data-testid=\"right-actions-container\"\n >\n {props.rightActions.map(({ label, ...actionProps }) => (\n <Button key={label} type=\"button\" {...actionProps}>\n {label}\n </Button>\n ))}\n </Stack>\n )}\n </Stack>\n </Card.Footer>\n )}\n </Card.Surface>\n </Dialog>\n </div>\n )}\n </AnimatePresence>\n );\n};\n"],"names":["React"],"mappings":";;;;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,EAAC,QAAQ,EAAA,GAAK,WAAW,EAAA,EAC9C,KAAK,CACC,CACV,CAAC,CACI,CACT;AACA,wBAAA,KAAK,CAAC,YAAY,KACjBA,cAAA,CAAA,aAAA,CAAC,KAAK,EAAA,EACJ,SAAS,EAAC,YAAY,EACtB,MAAM,EAAC,KAAK,EAAA,aAAA,EACA,yBAAyB,EAAA,EAEpC,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,WAAW,EAAE,MAChDA,cAAA,CAAA,aAAA,CAAC,MAAM,EAAA,EAAC,GAAG,EAAE,KAAK,EAAE,IAAI,EAAC,QAAQ,EAAA,GAAK,WAAW,EAAA,EAC9C,KAAK,CACC,CACV,CAAC,CACI,CACT,CACK,CACI,CACf,CACY,CACR,CACL,CACP,CACe;AAEtB;;;;"}
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var Portal = require('../Portal/Portal.cjs');
5
+ var ScrollLock = require('../ScrollLock/ScrollLock.cjs');
6
+ var buildClassnames = require('../../utils/buildClassnames.cjs');
7
+ var Popup_module = require('./Popup.module.scss.cjs');
8
+
9
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
10
+
11
+ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
12
+
13
+ const WithPortal = ({ usePortal, children }) => (
14
+ // eslint-disable-next-line react/jsx-no-useless-fragment
15
+ React__default.default.createElement(React__default.default.Fragment, null, usePortal ? React__default.default.createElement(Portal.Portal, null, children) : children));
16
+ const Popup = ({ className, children = null, shouldShow = false, usePortal = true, }) => (React__default.default.createElement(WithPortal, { usePortal: usePortal },
17
+ React__default.default.createElement("div", { className: buildClassnames.buildClassnames([
18
+ Popup_module.container,
19
+ shouldShow && Popup_module.visible,
20
+ className && `${className}-container`,
21
+ className,
22
+ ]) },
23
+ React__default.default.createElement("div", { className: Popup_module.shadow }),
24
+ shouldShow && React__default.default.createElement(ScrollLock.ScrollLock, null),
25
+ React__default.default.createElement("div", { className: buildClassnames.buildClassnames([Popup_module.wrap, className && `${className}-wrap`, className]) }, children))));
26
+
27
+ exports.Popup = Popup;
28
+ //# sourceMappingURL=Popup.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Popup.cjs","sources":["../../../src/components/Popup/Popup.tsx"],"sourcesContent":["import React, { ReactNode } from 'react';\n\nimport { Portal } from '../Portal';\nimport { ScrollLock } from '../ScrollLock';\nimport { buildClassnames } from '../../utils/buildClassnames';\nimport { PopupProps } from './types';\nimport styles from './Popup.module.scss';\n\ninterface WithPortalProps {\n usePortal?: boolean;\n children: ReactNode;\n}\n\nconst WithPortal = ({ usePortal, children }: WithPortalProps) => (\n // eslint-disable-next-line react/jsx-no-useless-fragment\n <>{usePortal ? <Portal>{children}</Portal> : children}</>\n);\n\nexport const Popup = ({\n className,\n children = null,\n shouldShow = false,\n usePortal = true,\n}: PopupProps) => (\n <WithPortal usePortal={usePortal}>\n <div\n className={buildClassnames([\n styles.container,\n shouldShow && styles.visible,\n className && `${className}-container`,\n className,\n ])}\n >\n <div className={styles.shadow} />\n {shouldShow && <ScrollLock />}\n <div className={buildClassnames([styles.wrap, className && `${className}-wrap`, className])}>\n {children}\n </div>\n </div>\n </WithPortal>\n);\n"],"names":["React","Portal","buildClassnames","styles","ScrollLock"],"mappings":";;;;;;;;;;;;AAaA,MAAM,UAAU,GAAG,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAmB;AAC1D;AACAA,sBAAA,CAAA,aAAA,CAAAA,sBAAA,CAAA,QAAA,EAAA,IAAA,EAAG,SAAS,GAAGA,qCAACC,aAAM,EAAA,IAAA,EAAE,QAAQ,CAAU,GAAG,QAAQ,CAAI,CAC1D;AAEM,MAAM,KAAK,GAAG,CAAC,EACpB,SAAS,EACT,QAAQ,GAAG,IAAI,EACf,UAAU,GAAG,KAAK,EAClB,SAAS,GAAG,IAAI,GACL,MACXD,sBAAA,CAAA,aAAA,CAAC,UAAU,EAAA,EAAC,SAAS,EAAE,SAAS,EAAA;IAC9BA,sBAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EACE,SAAS,EAAEE,+BAAe,CAAC;AACzB,YAAAC,YAAM,CAAC,SAAS;YAChB,UAAU,IAAIA,YAAM,CAAC,OAAO;YAC5B,SAAS,IAAI,CAAA,EAAG,SAAS,CAAA,UAAA,CAAY;YACrC,SAAS;SACV,CAAC,EAAA;AAEF,QAAAH,sBAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAEG,YAAM,CAAC,MAAM,EAAA,CAAI;QAChC,UAAU,IAAIH,sBAAA,CAAA,aAAA,CAACI,qBAAU,EAAA,IAAA,CAAG;QAC7BJ,sBAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAEE,+BAAe,CAAC,CAACC,YAAM,CAAC,IAAI,EAAE,SAAS,IAAI,CAAA,EAAG,SAAS,CAAA,KAAA,CAAO,EAAE,SAAS,CAAC,CAAC,EAAA,EACxF,QAAQ,CACL,CACF,CACK;;;;"}
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import { PopupProps } from './types';
3
+ export declare const Popup: ({ className, children, shouldShow, usePortal, }: PopupProps) => React.JSX.Element;
@@ -0,0 +1,22 @@
1
+ import React__default from 'react';
2
+ import { Portal } from '../Portal/Portal.js';
3
+ import { ScrollLock } from '../ScrollLock/ScrollLock.js';
4
+ import { buildClassnames } from '../../utils/buildClassnames.js';
5
+ import styles from './Popup.module.scss.js';
6
+
7
+ const WithPortal = ({ usePortal, children }) => (
8
+ // eslint-disable-next-line react/jsx-no-useless-fragment
9
+ React__default.createElement(React__default.Fragment, null, usePortal ? React__default.createElement(Portal, null, children) : children));
10
+ const Popup = ({ className, children = null, shouldShow = false, usePortal = true, }) => (React__default.createElement(WithPortal, { usePortal: usePortal },
11
+ React__default.createElement("div", { className: buildClassnames([
12
+ styles.container,
13
+ shouldShow && styles.visible,
14
+ className && `${className}-container`,
15
+ className,
16
+ ]) },
17
+ React__default.createElement("div", { className: styles.shadow }),
18
+ shouldShow && React__default.createElement(ScrollLock, null),
19
+ React__default.createElement("div", { className: buildClassnames([styles.wrap, className && `${className}-wrap`, className]) }, children))));
20
+
21
+ export { Popup };
22
+ //# sourceMappingURL=Popup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Popup.js","sources":["../../../src/components/Popup/Popup.tsx"],"sourcesContent":["import React, { ReactNode } from 'react';\n\nimport { Portal } from '../Portal';\nimport { ScrollLock } from '../ScrollLock';\nimport { buildClassnames } from '../../utils/buildClassnames';\nimport { PopupProps } from './types';\nimport styles from './Popup.module.scss';\n\ninterface WithPortalProps {\n usePortal?: boolean;\n children: ReactNode;\n}\n\nconst WithPortal = ({ usePortal, children }: WithPortalProps) => (\n // eslint-disable-next-line react/jsx-no-useless-fragment\n <>{usePortal ? <Portal>{children}</Portal> : children}</>\n);\n\nexport const Popup = ({\n className,\n children = null,\n shouldShow = false,\n usePortal = true,\n}: PopupProps) => (\n <WithPortal usePortal={usePortal}>\n <div\n className={buildClassnames([\n styles.container,\n shouldShow && styles.visible,\n className && `${className}-container`,\n className,\n ])}\n >\n <div className={styles.shadow} />\n {shouldShow && <ScrollLock />}\n <div className={buildClassnames([styles.wrap, className && `${className}-wrap`, className])}>\n {children}\n </div>\n </div>\n </WithPortal>\n);\n"],"names":["React"],"mappings":";;;;;;AAaA,MAAM,UAAU,GAAG,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAmB;AAC1D;AACAA,cAAA,CAAA,aAAA,CAAAA,cAAA,CAAA,QAAA,EAAA,IAAA,EAAG,SAAS,GAAGA,6BAAC,MAAM,EAAA,IAAA,EAAE,QAAQ,CAAU,GAAG,QAAQ,CAAI,CAC1D;AAEM,MAAM,KAAK,GAAG,CAAC,EACpB,SAAS,EACT,QAAQ,GAAG,IAAI,EACf,UAAU,GAAG,KAAK,EAClB,SAAS,GAAG,IAAI,GACL,MACXA,cAAA,CAAA,aAAA,CAAC,UAAU,EAAA,EAAC,SAAS,EAAE,SAAS,EAAA;IAC9BA,cAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EACE,SAAS,EAAE,eAAe,CAAC;AACzB,YAAA,MAAM,CAAC,SAAS;YAChB,UAAU,IAAI,MAAM,CAAC,OAAO;YAC5B,SAAS,IAAI,CAAA,EAAG,SAAS,CAAA,UAAA,CAAY;YACrC,SAAS;SACV,CAAC,EAAA;AAEF,QAAAA,cAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,MAAM,CAAC,MAAM,EAAA,CAAI;QAChC,UAAU,IAAIA,cAAA,CAAA,aAAA,CAAC,UAAU,EAAA,IAAA,CAAG;QAC7BA,cAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,eAAe,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,IAAI,CAAA,EAAG,SAAS,CAAA,KAAA,CAAO,EAAE,SAAS,CAAC,CAAC,EAAA,EACxF,QAAQ,CACL,CACF,CACK;;;;"}
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ var ___$insertStyle = require('../../_virtual/____insertStyle.cjs');
4
+
5
+ ___$insertStyle("body.veeqo-modal-open {\n overflow: hidden;\n scrollbar-gutter: stable;\n}\n\n._container_1llaq_6 {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n height: 100%;\n z-index: var(--layers-modal);\n display: none;\n}\n\n._visible_1llaq_17 {\n display: initial;\n}\n\n._shadow_1llaq_21 {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n height: 100%;\n background-color: rgba(55, 66, 77, 0.5);\n}\n\n._wrap_1llaq_31 {\n position: relative;\n height: 100%;\n width: 100%;\n z-index: 1;\n}");
6
+ var styles = {"container":"_container_1llaq_6","visible":"_visible_1llaq_17","shadow":"_shadow_1llaq_21","wrap":"_wrap_1llaq_31"};
7
+
8
+ module.exports = styles;
9
+ //# sourceMappingURL=Popup.module.scss.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Popup.module.scss.cjs","sources":["../../../src/components/Popup/Popup.module.scss"],"sourcesContent":[":global(body.veeqo-modal-open) {\n overflow: hidden;\n scrollbar-gutter: stable;\n}\n\n.container {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n height: 100%;\n z-index: var(--layers-modal);\n display: none;\n}\n\n.visible {\n display: initial;\n}\n\n.shadow {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n height: 100%;\n background-color: rgba(55, 66, 77, 0.5);\n}\n\n.wrap {\n position: relative;\n height: 100%;\n width: 100%;\n z-index: 1;\n}\n"],"names":[],"mappings":";;;;AACE,eAAA,CAAA,giBAAA;AACA,aAAA,CAAA,WAAA,CAAA,oBAAA,CAAA,SAAA,CAAA,mBAAA,CAAA,QAAA,CAAA,kBAAA,CAAA,MAAA,CAAA,gBAAA;;;;"}
@@ -0,0 +1,7 @@
1
+ import insertStyle from '../../_virtual/____insertStyle.js';
2
+
3
+ insertStyle("body.veeqo-modal-open {\n overflow: hidden;\n scrollbar-gutter: stable;\n}\n\n._container_1llaq_6 {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n height: 100%;\n z-index: var(--layers-modal);\n display: none;\n}\n\n._visible_1llaq_17 {\n display: initial;\n}\n\n._shadow_1llaq_21 {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n height: 100%;\n background-color: rgba(55, 66, 77, 0.5);\n}\n\n._wrap_1llaq_31 {\n position: relative;\n height: 100%;\n width: 100%;\n z-index: 1;\n}");
4
+ var styles = {"container":"_container_1llaq_6","visible":"_visible_1llaq_17","shadow":"_shadow_1llaq_21","wrap":"_wrap_1llaq_31"};
5
+
6
+ export { styles as default };
7
+ //# sourceMappingURL=Popup.module.scss.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Popup.module.scss.js","sources":["../../../src/components/Popup/Popup.module.scss"],"sourcesContent":[":global(body.veeqo-modal-open) {\n overflow: hidden;\n scrollbar-gutter: stable;\n}\n\n.container {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n height: 100%;\n z-index: var(--layers-modal);\n display: none;\n}\n\n.visible {\n display: initial;\n}\n\n.shadow {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n height: 100%;\n background-color: rgba(55, 66, 77, 0.5);\n}\n\n.wrap {\n position: relative;\n height: 100%;\n width: 100%;\n z-index: 1;\n}\n"],"names":["___$insertStyle"],"mappings":";;AACEA,WAAA,CAAA,giBAAA;AACA,aAAA,CAAA,WAAA,CAAA,oBAAA,CAAA,SAAA,CAAA,mBAAA,CAAA,QAAA,CAAA,kBAAA,CAAA,MAAA,CAAA,gBAAA;;;;"}
@@ -0,0 +1,2 @@
1
+ export { Popup } from './Popup';
2
+ export type { PopupProps } from './types';
@@ -1,8 +1,7 @@
1
- import { ReactNode, FC } from 'react';
1
+ import { ReactNode } from 'react';
2
2
  export interface PopupProps {
3
3
  children: ReactNode;
4
4
  shouldShow: boolean;
5
5
  usePortal?: boolean;
6
6
  className?: string;
7
7
  }
8
- export declare const Popup: FC<PopupProps>;
@@ -0,0 +1,26 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+
5
+ /**
6
+ * Reference-counted scroll lock for the document body.
7
+ * Adds `veeqo-modal-open` class when mounted, removes it only when
8
+ * the last instance unmounts. Safe with multiple simultaneous modals/popups.
9
+ */
10
+ let scrollLockCount = 0;
11
+ const ScrollLock = () => {
12
+ React.useEffect(() => {
13
+ scrollLockCount += 1;
14
+ document.body.classList.add('veeqo-modal-open');
15
+ return () => {
16
+ scrollLockCount -= 1;
17
+ if (scrollLockCount === 0) {
18
+ document.body.classList.remove('veeqo-modal-open');
19
+ }
20
+ };
21
+ }, []);
22
+ return null;
23
+ };
24
+
25
+ exports.ScrollLock = ScrollLock;
26
+ //# sourceMappingURL=ScrollLock.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScrollLock.cjs","sources":["../../../src/components/ScrollLock/ScrollLock.tsx"],"sourcesContent":["import { useEffect } from 'react';\n\n/**\n * Reference-counted scroll lock for the document body.\n * Adds `veeqo-modal-open` class when mounted, removes it only when\n * the last instance unmounts. Safe with multiple simultaneous modals/popups.\n */\nlet scrollLockCount = 0;\n\nexport const ScrollLock = () => {\n useEffect(() => {\n scrollLockCount += 1;\n document.body.classList.add('veeqo-modal-open');\n return () => {\n scrollLockCount -= 1;\n if (scrollLockCount === 0) {\n document.body.classList.remove('veeqo-modal-open');\n }\n };\n }, []);\n return null;\n};\n"],"names":["useEffect"],"mappings":";;;;AAEA;;;;AAIG;AACH,IAAI,eAAe,GAAG,CAAC;AAEhB,MAAM,UAAU,GAAG,MAAK;IAC7BA,eAAS,CAAC,MAAK;QACb,eAAe,IAAI,CAAC;QACpB,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,kBAAkB,CAAC;AAC/C,QAAA,OAAO,MAAK;YACV,eAAe,IAAI,CAAC;YACpB,IAAI,eAAe,KAAK,CAAC,EAAE;gBACzB,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,kBAAkB,CAAC;AACnD,YAAA;AACH,QAAA,CAAC;IACH,CAAC,EAAE,EAAE,CAAC;AACN,IAAA,OAAO,IAAI;AACb;;;;"}
@@ -0,0 +1 @@
1
+ export declare const ScrollLock: () => null;
@@ -0,0 +1,24 @@
1
+ import { useEffect } from 'react';
2
+
3
+ /**
4
+ * Reference-counted scroll lock for the document body.
5
+ * Adds `veeqo-modal-open` class when mounted, removes it only when
6
+ * the last instance unmounts. Safe with multiple simultaneous modals/popups.
7
+ */
8
+ let scrollLockCount = 0;
9
+ const ScrollLock = () => {
10
+ useEffect(() => {
11
+ scrollLockCount += 1;
12
+ document.body.classList.add('veeqo-modal-open');
13
+ return () => {
14
+ scrollLockCount -= 1;
15
+ if (scrollLockCount === 0) {
16
+ document.body.classList.remove('veeqo-modal-open');
17
+ }
18
+ };
19
+ }, []);
20
+ return null;
21
+ };
22
+
23
+ export { ScrollLock };
24
+ //# sourceMappingURL=ScrollLock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScrollLock.js","sources":["../../../src/components/ScrollLock/ScrollLock.tsx"],"sourcesContent":["import { useEffect } from 'react';\n\n/**\n * Reference-counted scroll lock for the document body.\n * Adds `veeqo-modal-open` class when mounted, removes it only when\n * the last instance unmounts. Safe with multiple simultaneous modals/popups.\n */\nlet scrollLockCount = 0;\n\nexport const ScrollLock = () => {\n useEffect(() => {\n scrollLockCount += 1;\n document.body.classList.add('veeqo-modal-open');\n return () => {\n scrollLockCount -= 1;\n if (scrollLockCount === 0) {\n document.body.classList.remove('veeqo-modal-open');\n }\n };\n }, []);\n return null;\n};\n"],"names":[],"mappings":";;AAEA;;;;AAIG;AACH,IAAI,eAAe,GAAG,CAAC;AAEhB,MAAM,UAAU,GAAG,MAAK;IAC7B,SAAS,CAAC,MAAK;QACb,eAAe,IAAI,CAAC;QACpB,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,kBAAkB,CAAC;AAC/C,QAAA,OAAO,MAAK;YACV,eAAe,IAAI,CAAC;YACpB,IAAI,eAAe,KAAK,CAAC,EAAE;gBACzB,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,kBAAkB,CAAC;AACnD,YAAA;AACH,QAAA,CAAC;IACH,CAAC,EAAE,EAAE,CAAC;AACN,IAAA,OAAO,IAAI;AACb;;;;"}
@@ -0,0 +1 @@
1
+ export { ScrollLock } from './ScrollLock';
@@ -1,16 +1,22 @@
1
1
  'use strict';
2
2
 
3
3
  var React = require('react');
4
- var reactUse = require('react-use');
5
4
  var utils = require('../utils.cjs');
6
5
 
6
+ function usePrevious(value) {
7
+ const ref = React.useRef();
8
+ React.useEffect(() => {
9
+ ref.current = value;
10
+ });
11
+ return ref.current;
12
+ }
7
13
  const useSetScrollPosition = ({ containerRef, children, hasMoreViews = false, onFetchMoreViews, isLoadingMoreViews = false, }) => {
8
14
  var _a;
9
15
  const [leftDisabled, setLeftDisabled] = React.useState(true);
10
16
  const [rightDisabled, setRightDisabled] = React.useState(false);
11
17
  const [viewStartPositions, setViewStartPositions] = React.useState([]);
12
18
  const activeTab = (_a = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('[aria-selected = true]');
13
- const prevActiveTab = reactUse.usePrevious(activeTab);
19
+ const prevActiveTab = usePrevious(activeTab);
14
20
  const handleScroll = React.useCallback(() => {
15
21
  var _a, _b, _c, _d, _e, _f, _g, _h;
16
22
  if (((_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.scrollLeft) > 0) {
@@ -1 +1 @@
1
- {"version":3,"file":"useSetScrollPosition.cjs","sources":["../../../../src/components/ViewsContainer/hooks/useSetScrollPosition.ts"],"sourcesContent":["import { MutableRefObject, ReactNode, useCallback, useEffect, useState, Children } from 'react';\nimport { usePrevious } from 'react-use';\nimport { createViewPositionArray, getNextViewPosition, getPrevViewPosition } from '../utils';\n\ntype UseSetScrollPositionProps = {\n containerRef: MutableRefObject<HTMLDivElement>;\n children: ReactNode;\n hasMoreViews?: boolean;\n onFetchMoreViews?: () => void;\n isLoadingMoreViews?: boolean;\n};\n\nexport const useSetScrollPosition = ({\n containerRef,\n children,\n hasMoreViews = false,\n onFetchMoreViews,\n isLoadingMoreViews = false,\n}: UseSetScrollPositionProps) => {\n const [leftDisabled, setLeftDisabled] = useState(true);\n const [rightDisabled, setRightDisabled] = useState(false);\n const [viewStartPositions, setViewStartPositions] = useState<number[]>([]);\n\n const activeTab = containerRef?.current?.querySelector('[aria-selected = true]');\n const prevActiveTab = usePrevious(activeTab);\n\n const handleScroll = useCallback(() => {\n if (containerRef.current?.scrollLeft > 0) {\n setLeftDisabled(false);\n } else {\n if (document.getElementById('left-arrow') === document.activeElement) {\n document.getElementById('right-arrow')?.focus();\n }\n setLeftDisabled(true);\n }\n\n const maxScrollWidth = containerRef.current?.scrollWidth ?? 0;\n const maxClientWidth = containerRef.current?.clientWidth ?? 0;\n const maxScrollLeft = maxScrollWidth - maxClientWidth;\n\n // -10 to prevent javascript assertion errors on floating points\n if (containerRef.current?.scrollLeft >= maxScrollLeft - 10) {\n if (document.getElementById('right-arrow') === document.activeElement) {\n document.getElementById('left-arrow')?.focus();\n }\n setRightDisabled(true);\n\n // Check if we've reached the end and should fetch more data\n // Only fetches more when not already loading more views and has more views to load\n if (hasMoreViews && onFetchMoreViews && !isLoadingMoreViews) {\n onFetchMoreViews();\n }\n } else {\n setRightDisabled(false);\n }\n }, [containerRef, onFetchMoreViews, isLoadingMoreViews, hasMoreViews]);\n\n const handleResize = useCallback(() => {\n if (!containerRef.current) return;\n if (containerRef.current.scrollWidth - containerRef.current.getBoundingClientRect().width < 5) {\n setRightDisabled(true);\n } else {\n setRightDisabled(false);\n }\n }, [containerRef]);\n\n const toNextScrollPosition = useCallback(() => {\n const newPosition = getNextViewPosition(\n viewStartPositions,\n containerRef.current.scrollLeft,\n containerRef.current.clientWidth,\n );\n\n containerRef.current.scrollTo({\n left: newPosition,\n top: 0,\n behavior: 'smooth',\n });\n }, [containerRef, viewStartPositions]);\n\n const toPrevScrollPosition = useCallback(() => {\n const newPosition = getPrevViewPosition(viewStartPositions, containerRef.current.scrollLeft);\n\n containerRef.current.scrollTo({\n left: newPosition,\n top: 0,\n behavior: 'smooth',\n });\n }, [containerRef, viewStartPositions]);\n\n // Initialize view positions when container first has children\n useEffect(() => {\n if (!containerRef?.current?.children?.length || viewStartPositions.length > 0) return;\n\n setViewStartPositions(createViewPositionArray(containerRef.current));\n }, [containerRef, viewStartPositions.length]);\n\n // Handle new item addition - scroll to end and update positions\n useEffect(() => {\n if (!containerRef?.current?.children?.length) return;\n\n const childrenCount = containerRef.current.children.length;\n const positionsCount = viewStartPositions.length;\n const totalChildren = Children.count(children);\n\n const shouldScrollToNewItem =\n childrenCount !== positionsCount && positionsCount > 0 && positionsCount < totalChildren;\n\n if (!shouldScrollToNewItem) return;\n\n containerRef.current.scrollTo({\n left: containerRef.current.scrollWidth - containerRef.current.clientWidth,\n top: 0,\n behavior: 'smooth',\n });\n\n // Compute the x position of the new item\n const lastChildRect =\n containerRef.current.children[positionsCount - 1]?.getBoundingClientRect();\n const newPosition = viewStartPositions[positionsCount - 1] + (lastChildRect?.x ?? 0) - 20;\n\n setViewStartPositions([...viewStartPositions, newPosition]);\n }, [containerRef, children, viewStartPositions]);\n\n // Handle active tab changes - scroll to active tab\n useEffect(() => {\n if (!containerRef?.current?.children?.length) return;\n if (activeTab === prevActiveTab || activeTab === null) return;\n if (containerRef.current.children.length !== viewStartPositions.length) return;\n\n const index = Array.from(containerRef.current.children).indexOf(activeTab);\n if (index === -1) return;\n\n containerRef.current.scrollTo({\n left: viewStartPositions[index],\n top: 0,\n behavior: 'smooth',\n });\n }, [activeTab, prevActiveTab, containerRef, viewStartPositions]);\n\n // Handle fetching more views - recompute positions\n useEffect(() => {\n if (!containerRef?.current?.children?.length) return;\n if (viewStartPositions.length >= containerRef.current.children.length) return;\n\n const currentScrollLeft = containerRef.current.scrollLeft;\n\n // Temporarily reset scroll to 0 to get accurate positions\n containerRef.current.scrollTo({ left: 0, top: 0, behavior: 'auto' });\n\n // Recompute positions from scroll position 0\n setViewStartPositions(createViewPositionArray(containerRef.current));\n\n // Restore the user's scroll position\n containerRef.current.scrollTo({ left: currentScrollLeft, top: 0, behavior: 'auto' });\n }, [containerRef, viewStartPositions.length]);\n\n // Handle window resize and scroll event listeners\n useEffect(() => {\n if (!containerRef?.current) return;\n\n const container = containerRef.current;\n\n handleResize();\n window.addEventListener('resize', handleResize);\n container.addEventListener('scroll', handleScroll);\n\n // eslint-disable-next-line consistent-return\n return () => {\n window.removeEventListener('resize', handleResize);\n container.removeEventListener('scroll', handleScroll);\n };\n }, [containerRef, handleResize, handleScroll]);\n\n return { rightDisabled, leftDisabled, toNextScrollPosition, toPrevScrollPosition };\n};\n"],"names":["useState","usePrevious","useCallback","getNextViewPosition","getPrevViewPosition","useEffect","createViewPositionArray","Children"],"mappings":";;;;;;MAYa,oBAAoB,GAAG,CAAC,EACnC,YAAY,EACZ,QAAQ,EACR,YAAY,GAAG,KAAK,EACpB,gBAAgB,EAChB,kBAAkB,GAAG,KAAK,GACA,KAAI;;IAC9B,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAGA,cAAQ,CAAC,IAAI,CAAC;IACtD,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAGA,cAAQ,CAAC,KAAK,CAAC;IACzD,MAAM,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,GAAGA,cAAQ,CAAW,EAAE,CAAC;AAE1E,IAAA,MAAM,SAAS,GAAG,CAAA,EAAA,GAAA,YAAY,aAAZ,YAAY,KAAA,MAAA,GAAA,MAAA,GAAZ,YAAY,CAAE,OAAO,MAAA,IAAA,IAAA,EAAA,KAAA,MAAA,GAAA,MAAA,GAAA,EAAA,CAAE,aAAa,CAAC,wBAAwB,CAAC;AAChF,IAAA,MAAM,aAAa,GAAGC,oBAAW,CAAC,SAAS,CAAC;AAE5C,IAAA,MAAM,YAAY,GAAGC,iBAAW,CAAC,MAAK;;QACpC,IAAI,CAAA,MAAA,YAAY,CAAC,OAAO,MAAA,IAAA,IAAA,EAAA,KAAA,MAAA,GAAA,MAAA,GAAA,EAAA,CAAE,UAAU,IAAG,CAAC,EAAE;YACxC,eAAe,CAAC,KAAK,CAAC;AACvB,QAAA;AAAM,aAAA;YACL,IAAI,QAAQ,CAAC,cAAc,CAAC,YAAY,CAAC,KAAK,QAAQ,CAAC,aAAa,EAAE;gBACpE,CAAA,EAAA,GAAA,QAAQ,CAAC,cAAc,CAAC,aAAa,CAAC,MAAA,IAAA,IAAA,EAAA,KAAA,MAAA,GAAA,MAAA,GAAA,EAAA,CAAE,KAAK,EAAE;AAChD,YAAA;YACD,eAAe,CAAC,IAAI,CAAC;AACtB,QAA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AE,YAAY,CAAC;AAC/C,QAAA,SAAS,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,CAAC;;AAGlD,QAAA,OAAO,MAAK;AACV,YAAA,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,YAAY,CAAC;AAClD,YAAA,SAAS,CAAC,mBAAmB,CAAC,QAAQ,EAAE,YAAY,CAAC;AACvD,QAAA,CAAC;IACH,CAAC,EAAE,CAAC,YAAY,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;IAE9C,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,oBAAoB,EAAE,oBAAoB,EAAE;AACpF;;;;"}
1
+ {"version":3,"file":"useSetScrollPosition.cjs","sources":["../../../../src/components/ViewsContainer/hooks/useSetScrollPosition.ts"],"sourcesContent":["import {\n MutableRefObject,\n ReactNode,\n useCallback,\n useEffect,\n useRef,\n useState,\n Children,\n} from 'react';\nimport { createViewPositionArray, getNextViewPosition, getPrevViewPosition } from '../utils';\n\nfunction usePrevious<T>(value: T): T | undefined {\n const ref = useRef<T>();\n useEffect(() => {\n ref.current = value;\n });\n return ref.current;\n}\n\ntype UseSetScrollPositionProps = {\n containerRef: MutableRefObject<HTMLDivElement>;\n children: ReactNode;\n hasMoreViews?: boolean;\n onFetchMoreViews?: () => void;\n isLoadingMoreViews?: boolean;\n};\n\nexport const useSetScrollPosition = ({\n containerRef,\n children,\n hasMoreViews = false,\n onFetchMoreViews,\n isLoadingMoreViews = false,\n}: UseSetScrollPositionProps) => {\n const [leftDisabled, setLeftDisabled] = useState(true);\n const [rightDisabled, setRightDisabled] = useState(false);\n const [viewStartPositions, setViewStartPositions] = useState<number[]>([]);\n\n const activeTab = containerRef?.current?.querySelector('[aria-selected = true]');\n const prevActiveTab = usePrevious(activeTab);\n\n const handleScroll = useCallback(() => {\n if (containerRef.current?.scrollLeft > 0) {\n setLeftDisabled(false);\n } else {\n if (document.getElementById('left-arrow') === document.activeElement) {\n document.getElementById('right-arrow')?.focus();\n }\n setLeftDisabled(true);\n }\n\n const maxScrollWidth = containerRef.current?.scrollWidth ?? 0;\n const maxClientWidth = containerRef.current?.clientWidth ?? 0;\n const maxScrollLeft = maxScrollWidth - maxClientWidth;\n\n // -10 to prevent javascript assertion errors on floating points\n if (containerRef.current?.scrollLeft >= maxScrollLeft - 10) {\n if (document.getElementById('right-arrow') === document.activeElement) {\n document.getElementById('left-arrow')?.focus();\n }\n setRightDisabled(true);\n\n // Check if we've reached the end and should fetch more data\n // Only fetches more when not already loading more views and has more views to load\n if (hasMoreViews && onFetchMoreViews && !isLoadingMoreViews) {\n onFetchMoreViews();\n }\n } else {\n setRightDisabled(false);\n }\n }, [containerRef, onFetchMoreViews, isLoadingMoreViews, hasMoreViews]);\n\n const handleResize = useCallback(() => {\n if (!containerRef.current) return;\n if (containerRef.current.scrollWidth - containerRef.current.getBoundingClientRect().width < 5) {\n setRightDisabled(true);\n } else {\n setRightDisabled(false);\n }\n }, [containerRef]);\n\n const toNextScrollPosition = useCallback(() => {\n const newPosition = getNextViewPosition(\n viewStartPositions,\n containerRef.current.scrollLeft,\n containerRef.current.clientWidth,\n );\n\n containerRef.current.scrollTo({\n left: newPosition,\n top: 0,\n behavior: 'smooth',\n });\n }, [containerRef, viewStartPositions]);\n\n const toPrevScrollPosition = useCallback(() => {\n const newPosition = getPrevViewPosition(viewStartPositions, containerRef.current.scrollLeft);\n\n containerRef.current.scrollTo({\n left: newPosition,\n top: 0,\n behavior: 'smooth',\n });\n }, [containerRef, viewStartPositions]);\n\n // Initialize view positions when container first has children\n useEffect(() => {\n if (!containerRef?.current?.children?.length || viewStartPositions.length > 0) return;\n\n setViewStartPositions(createViewPositionArray(containerRef.current));\n }, [containerRef, viewStartPositions.length]);\n\n // Handle new item addition - scroll to end and update positions\n useEffect(() => {\n if (!containerRef?.current?.children?.length) return;\n\n const childrenCount = containerRef.current.children.length;\n const positionsCount = viewStartPositions.length;\n const totalChildren = Children.count(children);\n\n const shouldScrollToNewItem =\n childrenCount !== positionsCount && positionsCount > 0 && positionsCount < totalChildren;\n\n if (!shouldScrollToNewItem) return;\n\n containerRef.current.scrollTo({\n left: containerRef.current.scrollWidth - containerRef.current.clientWidth,\n top: 0,\n behavior: 'smooth',\n });\n\n // Compute the x position of the new item\n const lastChildRect =\n containerRef.current.children[positionsCount - 1]?.getBoundingClientRect();\n const newPosition = viewStartPositions[positionsCount - 1] + (lastChildRect?.x ?? 0) - 20;\n\n setViewStartPositions([...viewStartPositions, newPosition]);\n }, [containerRef, children, viewStartPositions]);\n\n // Handle active tab changes - scroll to active tab\n useEffect(() => {\n if (!containerRef?.current?.children?.length) return;\n if (activeTab === prevActiveTab || activeTab === null) return;\n if (containerRef.current.children.length !== viewStartPositions.length) return;\n\n const index = Array.from(containerRef.current.children).indexOf(activeTab);\n if (index === -1) return;\n\n containerRef.current.scrollTo({\n left: viewStartPositions[index],\n top: 0,\n behavior: 'smooth',\n });\n }, [activeTab, prevActiveTab, containerRef, viewStartPositions]);\n\n // Handle fetching more views - recompute positions\n useEffect(() => {\n if (!containerRef?.current?.children?.length) return;\n if (viewStartPositions.length >= containerRef.current.children.length) return;\n\n const currentScrollLeft = containerRef.current.scrollLeft;\n\n // Temporarily reset scroll to 0 to get accurate positions\n containerRef.current.scrollTo({ left: 0, top: 0, behavior: 'auto' });\n\n // Recompute positions from scroll position 0\n setViewStartPositions(createViewPositionArray(containerRef.current));\n\n // Restore the user's scroll position\n containerRef.current.scrollTo({ left: currentScrollLeft, top: 0, behavior: 'auto' });\n }, [containerRef, viewStartPositions.length]);\n\n // Handle window resize and scroll event listeners\n useEffect(() => {\n if (!containerRef?.current) return;\n\n const container = containerRef.current;\n\n handleResize();\n window.addEventListener('resize', handleResize);\n container.addEventListener('scroll', handleScroll);\n\n // eslint-disable-next-line consistent-return\n return () => {\n window.removeEventListener('resize', handleResize);\n container.removeEventListener('scroll', handleScroll);\n };\n }, [containerRef, handleResize, handleScroll]);\n\n return { rightDisabled, leftDisabled, toNextScrollPosition, toPrevScrollPosition };\n};\n"],"names":["useRef","useEffect","useState","useCallback","getNextViewPosition","getPrevViewPosition","createViewPositionArray","Children"],"mappings":";;;;;AAWA,SAAS,WAAW,CAAI,KAAQ,EAAA;AAC9B,IAAA,MAAM,GAAG,GAAGA,YAAM,EAAK;IACvBC,eAAS,CAAC,MAAK;AACb,QAAA,GAAG,CAAC,OAAO,GAAG,KAAK;AACrB,IAAA,CAAC,CAAC;IACF,OAAO,GAAG,CAAC,OAAO;AACpB;MAUa,oBAAoB,GAAG,CAAC,EACnC,YAAY,EACZ,QAAQ,EACR,YAAY,GAAG,KAAK,EACpB,gBAAgB,EAChB,kBAAkB,GAAG,KAAK,GACA,KAAI;;IAC9B,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAGC,cAAQ,CAAC,IAAI,CAAC;IACtD,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAGA,cAAQ,CAAC,KAAK,CAAC;IACzD,MAAM,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,GAAGA,cAAQ,CAAW,EAAE,CAAC;AAE1E,IAAA,MAAM,SAAS,GAAG,CAAA,EAAA,GAAA,YAAY,aAAZ,YAAY,KAAA,MAAA,GAAA,MAAA,GAAZ,YAAY,CAAE,OAAO,MAAA,IAAA,IAAA,EAAA,KAAA,MAAA,GAAA,MAAA,GAAA,EAAA,CAAE,aAAa,CAAC,wBAAwB,CAAC;AAChF,IAAA,MAAM,aAAa,GAAG,WAAW,CAAC,SAAS,CAAC;AAE5C,IAAA,MAAM,YAAY,GAAGC,iBAAW,CAAC,MAAK;;QACpC,IAAI,CAAA,MAAA,YAAY,CAAC,OAAO,MAAA,IAAA,IAAA,EAAA,KAAA,MAAA,GAAA,MAAA,GAAA,EAAA,CAAE,UAAU,IAAG,CAAC,EAAE;YACxC,eAAe,CAAC,KAAK,CAAC;AACvB,QAAA;AAAM,aAAA;YACL,IAAI,QAAQ,CAAC,cAAc,CAAC,YAAY,CAAC,KAAK,QAAQ,CAAC,a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,IAAA,IAAZ,YAAY,KAAA,MAAA,GAAA,MAAA,GAAZ,YAAY,CAAE,OAAO,CAAA;YAAE;AAE5B,QAAA,MAAM,SAAS,GAAG,YAAY,CAAC,OAAO;AAEtC,QAAA,YAAY,EAAE;AACd,QAAA,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,CAAC;AAC/C,QAAA,SAAS,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,CAAC;;AAGlD,QAAA,OAAO,MAAK;AACV,YAAA,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,YAAY,CAAC;AAClD,YAAA,SAAS,CAAC,mBAAmB,CAAC,QAAQ,EAAE,YAAY,CAAC;AACvD,QAAA,CAAC;IACH,CAAC,EAAE,CAAC,YAAY,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;IAE9C,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,oBAAoB,EAAE,oBAAoB,EAAE;AACpF;;;;"}
@@ -1,7 +1,13 @@
1
- import { useState, useCallback, useEffect, Children } from 'react';
2
- import { usePrevious } from 'react-use';
1
+ import { useState, useCallback, useEffect, Children, useRef } from 'react';
3
2
  import { getNextViewPosition, getPrevViewPosition, createViewPositionArray } from '../utils.js';
4
3
 
4
+ function usePrevious(value) {
5
+ const ref = useRef();
6
+ useEffect(() => {
7
+ ref.current = value;
8
+ });
9
+ return ref.current;
10
+ }
5
11
  const useSetScrollPosition = ({ containerRef, children, hasMoreViews = false, onFetchMoreViews, isLoadingMoreViews = false, }) => {
6
12
  var _a;
7
13
  const [leftDisabled, setLeftDisabled] = useState(true);
@@ -1 +1 @@
1
- {"version":3,"file":"useSetScrollPosition.js","sources":["../../../../src/components/ViewsContainer/hooks/useSetScrollPosition.ts"],"sourcesContent":["import { MutableRefObject, ReactNode, useCallback, useEffect, useState, Children } from 'react';\nimport { usePrevious } from 'react-use';\nimport { createViewPositionArray, getNextViewPosition, getPrevViewPosition } from '../utils';\n\ntype UseSetScrollPositionProps = {\n containerRef: MutableRefObject<HTMLDivElement>;\n children: ReactNode;\n hasMoreViews?: boolean;\n onFetchMoreViews?: () => void;\n isLoadingMoreViews?: boolean;\n};\n\nexport const useSetScrollPosition = ({\n containerRef,\n children,\n hasMoreViews = false,\n onFetchMoreViews,\n isLoadingMoreViews = false,\n}: UseSetScrollPositionProps) => {\n const [leftDisabled, setLeftDisabled] = useState(true);\n const [rightDisabled, setRightDisabled] = useState(false);\n const [viewStartPositions, setViewStartPositions] = useState<number[]>([]);\n\n const activeTab = containerRef?.current?.querySelector('[aria-selected = true]');\n const prevActiveTab = usePrevious(activeTab);\n\n const handleScroll = useCallback(() => {\n if (containerRef.current?.scrollLeft > 0) {\n setLeftDisabled(false);\n } else {\n if (document.getElementById('left-arrow') === document.activeElement) {\n document.getElementById('right-arrow')?.focus();\n }\n setLeftDisabled(true);\n }\n\n const maxScrollWidth = containerRef.current?.scrollWidth ?? 0;\n const maxClientWidth = containerRef.current?.clientWidth ?? 0;\n const maxScrollLeft = maxScrollWidth - maxClientWidth;\n\n // -10 to prevent javascript assertion errors on floating points\n if (containerRef.current?.scrollLeft >= maxScrollLeft - 10) {\n if (document.getElementById('right-arrow') === document.activeElement) {\n document.getElementById('left-arrow')?.focus();\n }\n setRightDisabled(true);\n\n // Check if we've reached the end and should fetch more data\n // Only fetches more when not already loading more views and has more views to load\n if (hasMoreViews && onFetchMoreViews && !isLoadingMoreViews) {\n onFetchMoreViews();\n }\n } else {\n setRightDisabled(false);\n }\n }, [containerRef, onFetchMoreViews, isLoadingMoreViews, hasMoreViews]);\n\n const handleResize = useCallback(() => {\n if (!containerRef.current) return;\n if (containerRef.current.scrollWidth - containerRef.current.getBoundingClientRect().width < 5) {\n setRightDisabled(true);\n } else {\n setRightDisabled(false);\n }\n }, [containerRef]);\n\n const toNextScrollPosition = useCallback(() => {\n const newPosition = getNextViewPosition(\n viewStartPositions,\n containerRef.current.scrollLeft,\n containerRef.current.clientWidth,\n );\n\n containerRef.current.scrollTo({\n left: newPosition,\n top: 0,\n behavior: 'smooth',\n });\n }, [containerRef, viewStartPositions]);\n\n const toPrevScrollPosition = useCallback(() => {\n const newPosition = getPrevViewPosition(viewStartPositions, containerRef.current.scrollLeft);\n\n containerRef.current.scrollTo({\n left: newPosition,\n top: 0,\n behavior: 'smooth',\n });\n }, [containerRef, viewStartPositions]);\n\n // Initialize view positions when container first has children\n useEffect(() => {\n if (!containerRef?.current?.children?.length || viewStartPositions.length > 0) return;\n\n setViewStartPositions(createViewPositionArray(containerRef.current));\n }, [containerRef, viewStartPositions.length]);\n\n // Handle new item addition - scroll to end and update positions\n useEffect(() => {\n if (!containerRef?.current?.children?.length) return;\n\n const childrenCount = containerRef.current.children.length;\n const positionsCount = viewStartPositions.length;\n const totalChildren = Children.count(children);\n\n const shouldScrollToNewItem =\n childrenCount !== positionsCount && positionsCount > 0 && positionsCount < totalChildren;\n\n if (!shouldScrollToNewItem) return;\n\n containerRef.current.scrollTo({\n left: containerRef.current.scrollWidth - containerRef.current.clientWidth,\n top: 0,\n behavior: 'smooth',\n });\n\n // Compute the x position of the new item\n const lastChildRect =\n containerRef.current.children[positionsCount - 1]?.getBoundingClientRect();\n const newPosition = viewStartPositions[positionsCount - 1] + (lastChildRect?.x ?? 0) - 20;\n\n setViewStartPositions([...viewStartPositions, newPosition]);\n }, [containerRef, children, viewStartPositions]);\n\n // Handle active tab changes - scroll to active tab\n useEffect(() => {\n if (!containerRef?.current?.children?.length) return;\n if (activeTab === prevActiveTab || activeTab === null) return;\n if (containerRef.current.children.length !== viewStartPositions.length) return;\n\n const index = Array.from(containerRef.current.children).indexOf(activeTab);\n if (index === -1) return;\n\n containerRef.current.scrollTo({\n left: viewStartPositions[index],\n top: 0,\n behavior: 'smooth',\n });\n }, [activeTab, prevActiveTab, containerRef, viewStartPositions]);\n\n // Handle fetching more views - recompute positions\n useEffect(() => {\n if (!containerRef?.current?.children?.length) return;\n if (viewStartPositions.length >= containerRef.current.children.length) return;\n\n const currentScrollLeft = containerRef.current.scrollLeft;\n\n // Temporarily reset scroll to 0 to get accurate positions\n containerRef.current.scrollTo({ left: 0, top: 0, behavior: 'auto' });\n\n // Recompute positions from scroll position 0\n setViewStartPositions(createViewPositionArray(containerRef.current));\n\n // Restore the user's scroll position\n containerRef.current.scrollTo({ left: currentScrollLeft, top: 0, behavior: 'auto' });\n }, [containerRef, viewStartPositions.length]);\n\n // Handle window resize and scroll event listeners\n useEffect(() => {\n if (!containerRef?.current) return;\n\n const container = containerRef.current;\n\n handleResize();\n window.addEventListener('resize', handleResize);\n container.addEventListener('scroll', handleScroll);\n\n // eslint-disable-next-line consistent-return\n return () => {\n window.removeEventListener('resize', handleResize);\n container.removeEventListener('scroll', handleScroll);\n };\n }, [containerRef, handleResize, handleScroll]);\n\n return { rightDisabled, leftDisabled, toNextScrollPosition, toPrevScrollPosition };\n};\n"],"names":[],"mappings":";;;;MAYa,oBAAoB,GAAG,CAAC,EACnC,YAAY,EACZ,QAAQ,EACR,YAAY,GAAG,KAAK,EACpB,gBAAgB,EAChB,kBAAkB,GAAG,KAAK,GACA,KAAI;;IAC9B,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC;IACtD,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;IACzD,MAAM,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,GAAG,QAAQ,CAAW,EAAE,CAAC;AAE1E,IAAA,MAAM,SAAS,GAAG,CAAA,EAAA,GAAA,YAAY,aAAZ,YAAY,KAAA,MAAA,GAAA,MAAA,GAAZ,YAAY,CAAE,OAAO,MAAA,IAAA,IAAA,EAAA,KAAA,MAAA,GAAA,MAAA,GAAA,EAAA,CAAE,aAAa,CAAC,wBAAwB,CAAC;AAChF,IAAA,MAAM,aAAa,GAAG,WAAW,CAAC,SAAS,CAAC;AAE5C,IAAA,MAAM,YAAY,GAAG,WAAW,CAAC,MAAK;;QACpC,IAAI,C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QAAQ,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,GAAG,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;IACtF,CAAC,EAAE,CAAC,YAAY,EAAE,kBAAkB,CAAC,MAAM,CAAC,CAAC;;IAG7C,SAAS,CAAC,MAAK;QACb,IAAI,EAAC,YAAY,KAAA,IAAA,IAAZ,YAAY,KAAA,MAAA,GAAA,MAAA,GAAZ,YAAY,CAAE,OAAO,CAAA;YAAE;AAE5B,QAAA,MAAM,SAAS,GAAG,YAAY,CAAC,OAAO;AAEtC,QAAA,YAAY,EAAE;AACd,QAAA,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,CAAC;AAC/C,QAAA,SAAS,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,CAAC;;AAGlD,QAAA,OAAO,MAAK;AACV,YAAA,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,YAAY,CAAC;AAClD,YAAA,SAAS,CAAC,mBAAmB,CAAC,QAAQ,EAAE,YAAY,CAAC;AACvD,QAAA,CAAC;IACH,CAAC,EAAE,CAAC,YAAY,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;IAE9C,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,oBAAoB,EAAE,oBAAoB,EAAE;AACpF;;;;"}
1
+ {"version":3,"file":"useSetScrollPosition.js","sources":["../../../../src/components/ViewsContainer/hooks/useSetScrollPosition.ts"],"sourcesContent":["import {\n MutableRefObject,\n ReactNode,\n useCallback,\n useEffect,\n useRef,\n useState,\n Children,\n} from 'react';\nimport { createViewPositionArray, getNextViewPosition, getPrevViewPosition } from '../utils';\n\nfunction usePrevious<T>(value: T): T | undefined {\n const ref = useRef<T>();\n useEffect(() => {\n ref.current = value;\n });\n return ref.current;\n}\n\ntype UseSetScrollPositionProps = {\n containerRef: MutableRefObject<HTMLDivElement>;\n children: ReactNode;\n hasMoreViews?: boolean;\n onFetchMoreViews?: () => void;\n isLoadingMoreViews?: boolean;\n};\n\nexport const useSetScrollPosition = ({\n containerRef,\n children,\n hasMoreViews = false,\n onFetchMoreViews,\n isLoadingMoreViews = false,\n}: UseSetScrollPositionProps) => {\n const [leftDisabled, setLeftDisabled] = useState(true);\n const [rightDisabled, setRightDisabled] = useState(false);\n const [viewStartPositions, setViewStartPositions] = useState<number[]>([]);\n\n const activeTab = containerRef?.current?.querySelector('[aria-selected = true]');\n const prevActiveTab = usePrevious(activeTab);\n\n const handleScroll = useCallback(() => {\n if (containerRef.current?.scrollLeft > 0) {\n setLeftDisabled(false);\n } else {\n if (document.getElementById('left-arrow') === document.activeElement) {\n document.getElementById('right-arrow')?.focus();\n }\n setLeftDisabled(true);\n }\n\n const maxScrollWidth = containerRef.current?.scrollWidth ?? 0;\n const maxClientWidth = containerRef.current?.clientWidth ?? 0;\n const maxScrollLeft = maxScrollWidth - maxClientWidth;\n\n // -10 to prevent javascript assertion errors on floating points\n if (containerRef.current?.scrollLeft >= maxScrollLeft - 10) {\n if (document.getElementById('right-arrow') === document.activeElement) {\n document.getElementById('left-arrow')?.focus();\n }\n setRightDisabled(true);\n\n // Check if we've reached the end and should fetch more data\n // Only fetches more when not already loading more views and has more views to load\n if (hasMoreViews && onFetchMoreViews && !isLoadingMoreViews) {\n onFetchMoreViews();\n }\n } else {\n setRightDisabled(false);\n }\n }, [containerRef, onFetchMoreViews, isLoadingMoreViews, hasMoreViews]);\n\n const handleResize = useCallback(() => {\n if (!containerRef.current) return;\n if (containerRef.current.scrollWidth - containerRef.current.getBoundingClientRect().width < 5) {\n setRightDisabled(true);\n } else {\n setRightDisabled(false);\n }\n }, [containerRef]);\n\n const toNextScrollPosition = useCallback(() => {\n const newPosition = getNextViewPosition(\n viewStartPositions,\n containerRef.current.scrollLeft,\n containerRef.current.clientWidth,\n );\n\n containerRef.current.scrollTo({\n left: newPosition,\n top: 0,\n behavior: 'smooth',\n });\n }, [containerRef, viewStartPositions]);\n\n const toPrevScrollPosition = useCallback(() => {\n const newPosition = getPrevViewPosition(viewStartPositions, containerRef.current.scrollLeft);\n\n containerRef.current.scrollTo({\n left: newPosition,\n top: 0,\n behavior: 'smooth',\n });\n }, [containerRef, viewStartPositions]);\n\n // Initialize view positions when container first has children\n useEffect(() => {\n if (!containerRef?.current?.children?.length || viewStartPositions.length > 0) return;\n\n setViewStartPositions(createViewPositionArray(containerRef.current));\n }, [containerRef, viewStartPositions.length]);\n\n // Handle new item addition - scroll to end and update positions\n useEffect(() => {\n if (!containerRef?.current?.children?.length) return;\n\n const childrenCount = containerRef.current.children.length;\n const positionsCount = viewStartPositions.length;\n const totalChildren = Children.count(children);\n\n const shouldScrollToNewItem =\n childrenCount !== positionsCount && positionsCount > 0 && positionsCount < totalChildren;\n\n if (!shouldScrollToNewItem) return;\n\n containerRef.current.scrollTo({\n left: containerRef.current.scrollWidth - containerRef.current.clientWidth,\n top: 0,\n behavior: 'smooth',\n });\n\n // Compute the x position of the new item\n const lastChildRect =\n containerRef.current.children[positionsCount - 1]?.getBoundingClientRect();\n const newPosition = viewStartPositions[positionsCount - 1] + (lastChildRect?.x ?? 0) - 20;\n\n setViewStartPositions([...viewStartPositions, newPosition]);\n }, [containerRef, children, viewStartPositions]);\n\n // Handle active tab changes - scroll to active tab\n useEffect(() => {\n if (!containerRef?.current?.children?.length) return;\n if (activeTab === prevActiveTab || activeTab === null) return;\n if (containerRef.current.children.length !== viewStartPositions.length) return;\n\n const index = Array.from(containerRef.current.children).indexOf(activeTab);\n if (index === -1) return;\n\n containerRef.current.scrollTo({\n left: viewStartPositions[index],\n top: 0,\n behavior: 'smooth',\n });\n }, [activeTab, prevActiveTab, containerRef, viewStartPositions]);\n\n // Handle fetching more views - recompute positions\n useEffect(() => {\n if (!containerRef?.current?.children?.length) return;\n if (viewStartPositions.length >= containerRef.current.children.length) return;\n\n const currentScrollLeft = containerRef.current.scrollLeft;\n\n // Temporarily reset scroll to 0 to get accurate positions\n containerRef.current.scrollTo({ left: 0, top: 0, behavior: 'auto' });\n\n // Recompute positions from scroll position 0\n setViewStartPositions(createViewPositionArray(containerRef.current));\n\n // Restore the user's scroll position\n containerRef.current.scrollTo({ left: currentScrollLeft, top: 0, behavior: 'auto' });\n }, [containerRef, viewStartPositions.length]);\n\n // Handle window resize and scroll event listeners\n useEffect(() => {\n if (!containerRef?.current) return;\n\n const container = containerRef.current;\n\n handleResize();\n window.addEventListener('resize', handleResize);\n container.addEventListener('scroll', handleScroll);\n\n // eslint-disable-next-line consistent-return\n return () => {\n window.removeEventListener('resize', handleResize);\n container.removeEventListener('scroll', handleScroll);\n };\n }, [containerRef, handleResize, handleScroll]);\n\n return { rightDisabled, leftDisabled, toNextScrollPosition, toPrevScrollPosition };\n};\n"],"names":[],"mappings":";;;AAWA,SAAS,WAAW,CAAI,KAAQ,EAAA;AAC9B,IAAA,MAAM,GAAG,GAAG,MAAM,EAAK;IACvB,SAAS,CAAC,MAAK;AACb,QAAA,GAAG,CAAC,OAAO,GAAG,KAAK;AACrB,IAAA,CAAC,CAAC;IACF,OAAO,GAAG,CAAC,OAAO;AACpB;MAUa,oBAAoB,GAAG,CAAC,EACnC,YAAY,EACZ,QAAQ,EACR,YAAY,GAAG,KAAK,EACpB,gBAAgB,EAChB,kBAAkB,GAAG,KAAK,GACA,KAAI;;IAC9B,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC;IACtD,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;IACzD,MAAM,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,GAAG,QAAQ,CAAW,EAAE,CAAC;AAE1E,IAAA,MAAM,SAAS,GAAG,CAAA,EAAA,GAAA,YAAY,aAAZ,YAAY,KAAA,MAAA,GAAA,MAAA,GAAZ,YAAY,CAAE,OAAO,MAAA,IAAA,IAAA,EAAA,KAAA,MAAA,GAAA,MAAA,GAAA,EAAA,CAAE,aAAa,CAAC,wBAAwB,CAAC;AACh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E,CAAC;;QAGpE,qBAAqB,CAAC,uBAAuB,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;;AAGpE,QAAA,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,GAAG,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;IACtF,CAAC,EAAE,CAAC,YAAY,EAAE,kBAAkB,CAAC,MAAM,CAAC,CAAC;;IAG7C,SAAS,CAAC,MAAK;QACb,IAAI,EAAC,YAAY,KAAA,IAAA,IAAZ,YAAY,KAAA,MAAA,GAAA,MAAA,GAAZ,YAAY,CAAE,OAAO,CAAA;YAAE;AAE5B,QAAA,MAAM,SAAS,GAAG,YAAY,CAAC,OAAO;AAEtC,QAAA,YAAY,EAAE;AACd,QAAA,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,CAAC;AAC/C,QAAA,SAAS,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,CAAC;;AAGlD,QAAA,OAAO,MAAK;AACV,YAAA,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,YAAY,CAAC;AAClD,YAAA,SAAS,CAAC,mBAAmB,CAAC,QAAQ,EAAE,YAAY,CAAC;AACvD,QAAA,CAAC;IACH,CAAC,EAAE,CAAC,YAAY,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;IAE9C,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,oBAAoB,EAAE,oBAAoB,EAAE;AACpF;;;;"}
@@ -1,8 +1,9 @@
1
1
  export { Accordion } from './Accordion';
2
2
  export { Action, type ActionProps, type ActionVariant } from './Action';
3
3
  export { ActionMenu } from './ActionMenu';
4
- export { Alert } from './Alerts/Alert';
5
- export { MiniAlert } from './Alerts/MiniAlert';
4
+ export { Alert, type AlertProps, type AlertSizes, type AlertDirection } from './Alerts/Alert';
5
+ export { MiniAlert, type MiniAlertProps } from './Alerts/MiniAlert';
6
+ export type { AlertVariants, MiniAlertVariants } from './Alerts/types';
6
7
  export { Anchor, isAnchorUrl, isRelativeUrl, createContextAwareUrl, addPrefixToUrl, shouldAddPrefix, } from './Anchor';
7
8
  export { AnimatedDropdown } from './AnimatedDropdown';
8
9
  export { Avatar } from './Avatar';
@@ -41,6 +42,7 @@ export { LoginWithAmazonButton } from './LoginWithAmazonButton';
41
42
  export { Modal, type Action as ModalAction } from './Modal';
42
43
  export { Pagination } from './Pagination';
43
44
  export { Popover } from './Popover';
45
+ export { Popup, type PopupProps } from './Popup';
44
46
  export { Portal } from './Portal';
45
47
  export { PriceInput } from './PriceInput';
46
48
  export { Radio } from './Radio';
@@ -68,7 +70,6 @@ export { UploadFile } from './UploadFile';
68
70
  export { AcceptedFileTypes, FileSizeUnit } from './UploadFile/constants';
69
71
  export { UploadedFile } from './UploadedFile';
70
72
  export { VeeqoLogo, type LogoVariant, type ColorVariant } from './VeeqoLogo';
71
- export { VideoModal, Popup } from './VideoModal';
72
73
  export { View } from './View';
73
74
  export { ViewTab } from './ViewTab';
74
75
  export { ViewsContainer } from './ViewsContainer';