@elliemae/ds-floating-context 3.52.1 → 3.53.0-alpha.2

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 (43) hide show
  1. package/dist/cjs/DSFloatingContext.js +47 -57
  2. package/dist/cjs/DSFloatingContext.js.map +2 -2
  3. package/dist/cjs/parts/FloatingWrapper/FloatingWrapper.js +0 -1
  4. package/dist/cjs/parts/FloatingWrapper/FloatingWrapper.js.map +2 -2
  5. package/dist/cjs/parts/PopoverArrow.js +42 -9
  6. package/dist/cjs/parts/PopoverArrow.js.map +2 -2
  7. package/dist/cjs/typescript-testing/typescript-floating-context-valid.js +94 -0
  8. package/dist/cjs/typescript-testing/typescript-floating-context-valid.js.map +7 -0
  9. package/dist/cjs/useComputedPositionStyles.js +69 -48
  10. package/dist/cjs/useComputedPositionStyles.js.map +3 -3
  11. package/dist/cjs/utils/computePosition.js +4 -7
  12. package/dist/cjs/utils/computePosition.js.map +2 -2
  13. package/dist/cjs/utils/detectOverflow.js +5 -3
  14. package/dist/cjs/utils/detectOverflow.js.map +2 -2
  15. package/dist/esm/DSFloatingContext.js +48 -58
  16. package/dist/esm/DSFloatingContext.js.map +2 -2
  17. package/dist/esm/parts/FloatingWrapper/FloatingWrapper.js +0 -1
  18. package/dist/esm/parts/FloatingWrapper/FloatingWrapper.js.map +2 -2
  19. package/dist/esm/parts/PopoverArrow.js +42 -9
  20. package/dist/esm/parts/PopoverArrow.js.map +2 -2
  21. package/dist/esm/typescript-testing/typescript-floating-context-valid.js +71 -0
  22. package/dist/esm/typescript-testing/typescript-floating-context-valid.js.map +7 -0
  23. package/dist/esm/useComputedPositionStyles.js +69 -48
  24. package/dist/esm/useComputedPositionStyles.js.map +3 -3
  25. package/dist/esm/utils/computePosition.js +4 -7
  26. package/dist/esm/utils/computePosition.js.map +2 -2
  27. package/dist/esm/utils/detectOverflow.js +5 -3
  28. package/dist/esm/utils/detectOverflow.js.map +2 -2
  29. package/dist/types/DSFloatingContext.d.ts +3 -2
  30. package/dist/types/constants/index.d.ts +3 -0
  31. package/dist/types/parts/FloatingWrapper/config/useFloatingWrapper.d.ts +182 -182
  32. package/dist/types/parts/FloatingWrapper/react-desc-prop-types.d.ts +0 -2
  33. package/dist/types/tests/ControlledTestRenderer.d.ts +1 -0
  34. package/dist/types/tests/FloatingContext.a11y.test.d.ts +1 -0
  35. package/dist/types/tests/FloatingContext.data-testid.test.d.ts +1 -0
  36. package/dist/types/tests/FloatingContext.event.test.d.ts +1 -0
  37. package/dist/types/tests/FloatingContext.exports.test.d.ts +1 -0
  38. package/dist/types/tests/FloatingContext.get-owner-props.test.d.ts +1 -0
  39. package/dist/types/tests/playwright/FloatingContext.test.playwright.d.ts +1 -0
  40. package/dist/types/typescript-testing/typescript-floating-context-valid.d.ts +1 -0
  41. package/dist/types/useComputedPositionStyles.d.ts +6 -24
  42. package/dist/types/utils/computePosition.d.ts +2 -2
  43. package/package.json +8 -8
@@ -36,7 +36,6 @@ var React = __toESM(require("react"));
36
36
  var import_react = __toESM(require("react"));
37
37
  var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
38
38
  var import_ds_hooks_headless_tooltip = require("@elliemae/ds-hooks-headless-tooltip");
39
- var import_ds_system = require("@elliemae/ds-system");
40
39
  var import_react_desc_prop_types = require("./react-desc-prop-types.js");
41
40
  var import_useComputedPositionStyles = require("./useComputedPositionStyles.js");
42
41
  var import_positionObserver = require("./utils/positionObserver.js");
@@ -56,76 +55,65 @@ const useFloatingContext = (props = {}) => {
56
55
  externallyControlledIsOpen
57
56
  } = propsWithDefault;
58
57
  const [internalIsOpen, setInternalIsOpen] = import_react.default.useState(false);
59
- const isOpenSourceOfTruth = (0, import_react.useMemo)(() => {
60
- if (externallyControlledIsOpen !== void 0) return externallyControlledIsOpen;
61
- return internalIsOpen;
62
- }, [externallyControlledIsOpen, internalIsOpen]);
63
- const overChargedOnOpen = import_react.default.useCallback(() => {
58
+ const isOpen = (0, import_react.useMemo)(
59
+ () => externallyControlledIsOpen !== void 0 ? externallyControlledIsOpen : internalIsOpen,
60
+ [externallyControlledIsOpen, internalIsOpen]
61
+ );
62
+ const handleOpen = import_react.default.useCallback(() => {
64
63
  setInternalIsOpen(true);
65
64
  onOpen?.();
66
65
  }, [onOpen]);
67
- const overChargedOnClose = import_react.default.useCallback(() => {
66
+ const handleClose = import_react.default.useCallback(() => {
68
67
  setInternalIsOpen(false);
69
68
  onClose?.();
70
69
  }, [onClose]);
71
- const tooltipHelpers = (0, import_ds_hooks_headless_tooltip.useHeadlessTooltip)({ onOpen: overChargedOnOpen, onClose: overChargedOnClose });
72
- const { setReferenceElement, hideTooltip, showTooltip } = tooltipHelpers;
73
- const [reference, _setReference] = import_react.default.useState(null);
70
+ const tooltipHelpers = (0, import_ds_hooks_headless_tooltip.useHeadlessTooltip)({ onOpen: handleOpen, onClose: handleClose });
71
+ const { setReferenceElement, referenceElement, hideTooltip, showTooltip } = tooltipHelpers;
74
72
  const [floating, setFloating] = import_react.default.useState(null);
75
- const [workaroundToEnsureAPositionWasCalculatedIfOpen, setWorkaroundToEnsureAPositionWasCalculatedIfOpen] = import_react.default.useState(0);
76
- const { arrowStyles, floatingStyles, mutableUpdateStyles, debouncedUpdateStyles } = (0, import_useComputedPositionStyles.useComputedPositionStyles)({
77
- reference,
73
+ const { arrowStyles, floatingStyles, hasComputedOnce, updateStyles, debouncedUpdateStyles, mutableUpdateStyles } = (0, import_useComputedPositionStyles.useComputedPositionStyles)({
74
+ reference: referenceElement,
78
75
  floating,
79
76
  placement,
80
77
  placementOrderPreference,
81
78
  customOffset,
82
- withoutPortal
79
+ withoutPortal,
80
+ preventComputing: !isOpen,
81
+ debounceMs: 150
83
82
  });
84
83
  (0, import_react.useEffect)(() => {
85
- requestAnimationFrame(() => {
86
- mutableUpdateStyles?.current();
87
- });
88
- }, [reference, mutableUpdateStyles]);
89
- const updatePosOnIntersection = import_react.default.useCallback(() => {
90
- if (reference) {
91
- requestAnimationFrame(() => {
92
- debouncedUpdateStyles();
84
+ if (!isOpen) return;
85
+ const observers = [];
86
+ if (floating) {
87
+ const roFloating = new ResizeObserver(() => {
88
+ mutableUpdateStyles.current();
93
89
  });
90
+ roFloating.observe(floating);
91
+ observers.push(roFloating);
94
92
  }
95
- }, [reference, debouncedUpdateStyles]);
96
- (0, import_positionObserver.usePositionObserver)(reference, updatePosOnIntersection);
97
- (0, import_react.useEffect)(() => {
98
- requestAnimationFrame(() => {
99
- mutableUpdateStyles?.current();
100
- });
101
- }, [isOpenSourceOfTruth, mutableUpdateStyles]);
102
- const { visibility } = floatingStyles;
103
- const needsToCalculateBecauseStillInvisibleWhenShouldBeOpen = isOpenSourceOfTruth && visibility === "hidden";
104
- (0, import_react.useEffect)(() => {
105
- if (needsToCalculateBecauseStillInvisibleWhenShouldBeOpen) {
106
- mutableUpdateStyles?.current();
107
- requestAnimationFrame(() => {
108
- setWorkaroundToEnsureAPositionWasCalculatedIfOpen((o) => o + 1);
109
- });
110
- }
111
- }, [
112
- needsToCalculateBecauseStillInvisibleWhenShouldBeOpen,
113
- mutableUpdateStyles,
114
- // this dependency is the point of this useEffect
115
- // it will keep triggering until the position is calculated if it needs to be calculated
116
- workaroundToEnsureAPositionWasCalculatedIfOpen
117
- ]);
118
- const setReference = (0, import_ds_system.mergeRefs)(_setReference, setReferenceElement);
119
- const refs = import_react.default.useMemo(
93
+ return () => observers.forEach((o) => o.disconnect());
94
+ }, [isOpen, floating, updateStyles, mutableUpdateStyles]);
95
+ const onObservedMovement = import_react.default.useCallback(() => {
96
+ if (!isOpen) return;
97
+ debouncedUpdateStyles();
98
+ }, [isOpen, debouncedUpdateStyles]);
99
+ (0, import_positionObserver.usePositionObserver)(referenceElement, onObservedMovement);
100
+ const computedFloatingStyles = (0, import_react.useMemo)(
101
+ () => ({
102
+ ...floatingStyles,
103
+ visibility: isOpen && hasComputedOnce ? "visible" : "hidden"
104
+ }),
105
+ [floatingStyles, hasComputedOnce, isOpen]
106
+ );
107
+ const refs = (0, import_react.useMemo)(
120
108
  () => ({
121
- setReference,
109
+ setReference: setReferenceElement,
122
110
  setFloating,
123
111
  floating,
124
- reference
112
+ reference: referenceElement
125
113
  }),
126
- [setReference, floating, reference]
114
+ [setReferenceElement, floating, referenceElement]
127
115
  );
128
- const handlers = import_react.default.useMemo(
116
+ const handlers = (0, import_react.useMemo)(
129
117
  () => ({
130
118
  onMouseEnter: tooltipHelpers.onMouseEnter,
131
119
  onMouseLeave: tooltipHelpers.onMouseLeave,
@@ -137,9 +125,9 @@ const useFloatingContext = (props = {}) => {
137
125
  return (0, import_react.useMemo)(
138
126
  () => ({
139
127
  refs,
140
- floatingStyles,
128
+ floatingStyles: computedFloatingStyles,
141
129
  handlers,
142
- isOpen: isOpenSourceOfTruth,
130
+ isOpen,
143
131
  arrowStyles,
144
132
  hideTooltip,
145
133
  showTooltip,
@@ -149,13 +137,14 @@ const useFloatingContext = (props = {}) => {
149
137
  portalDOMContainer,
150
138
  animationDuration
151
139
  },
152
- mutableUpdateStyles
140
+ mutableUpdateStyles,
141
+ forceUpdatePosition: updateStyles
153
142
  }),
154
143
  [
155
144
  refs,
156
- floatingStyles,
145
+ computedFloatingStyles,
157
146
  handlers,
158
- isOpenSourceOfTruth,
147
+ isOpen,
159
148
  arrowStyles,
160
149
  hideTooltip,
161
150
  showTooltip,
@@ -163,7 +152,8 @@ const useFloatingContext = (props = {}) => {
163
152
  withoutAnimation,
164
153
  portalDOMContainer,
165
154
  animationDuration,
166
- mutableUpdateStyles
155
+ mutableUpdateStyles,
156
+ updateStyles
167
157
  ]
168
158
  );
169
159
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/DSFloatingContext.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["/* eslint-disable max-statements */\nimport React, { useEffect, useMemo } from 'react';\nimport {\n useMemoMergePropsWithDefault,\n useValidateTypescriptPropTypes,\n describe,\n type ValidationMap,\n} from '@elliemae/ds-props-helpers';\nimport { useHeadlessTooltip } from '@elliemae/ds-hooks-headless-tooltip';\nimport { mergeRefs } from '@elliemae/ds-system';\nimport type { DSHookFloatingContextT } from './react-desc-prop-types.js';\nimport { defaultProps, DSFloatingContextPropTypes } from './react-desc-prop-types.js';\nimport { useComputedPositionStyles } from './useComputedPositionStyles.js';\nimport { usePositionObserver } from './utils/positionObserver.js';\n\nconst useFloatingContext = (props: DSHookFloatingContextT.Props = {}) => {\n const propsWithDefault = useMemoMergePropsWithDefault<DSHookFloatingContextT.InternalProps>(props, defaultProps);\n useValidateTypescriptPropTypes(propsWithDefault, DSFloatingContextPropTypes, 'FloatingContext');\n\n const {\n withoutPortal,\n withoutAnimation,\n portalDOMContainer,\n animationDuration,\n placement,\n customOffset,\n placementOrderPreference,\n onOpen,\n onClose,\n externallyControlledIsOpen,\n } = propsWithDefault;\n\n const [internalIsOpen, setInternalIsOpen] = React.useState<boolean>(false);\n const isOpenSourceOfTruth = useMemo(() => {\n if (externallyControlledIsOpen !== undefined) return externallyControlledIsOpen;\n return internalIsOpen;\n }, [externallyControlledIsOpen, internalIsOpen]);\n\n const overChargedOnOpen = React.useCallback(() => {\n setInternalIsOpen(true);\n onOpen?.();\n }, [onOpen]);\n const overChargedOnClose = React.useCallback(() => {\n setInternalIsOpen(false);\n onClose?.();\n }, [onClose]);\n const tooltipHelpers = useHeadlessTooltip({ onOpen: overChargedOnOpen, onClose: overChargedOnClose });\n const { setReferenceElement, hideTooltip, showTooltip } = tooltipHelpers;\n // eslint-disable-next-line @typescript-eslint/naming-convention\n const [reference, _setReference] = React.useState<Element | null>(null);\n const [floating, setFloating] = React.useState<HTMLElement | null>(null);\n const [workaroundToEnsureAPositionWasCalculatedIfOpen, setWorkaroundToEnsureAPositionWasCalculatedIfOpen] =\n React.useState<number>(0);\n\n const { arrowStyles, floatingStyles, mutableUpdateStyles, debouncedUpdateStyles } = useComputedPositionStyles({\n reference,\n floating,\n placement,\n placementOrderPreference,\n customOffset,\n withoutPortal,\n });\n\n // calculate position on mount\n // AND everytime the reference (which is actually immutable because it's stored in a React.useState)\n // changes\n useEffect(() => {\n requestAnimationFrame(() => {\n mutableUpdateStyles?.current();\n });\n // the dependency array is equal to being empty because mutableUpdateStyles is a ref.\n // this is effectively an \"on mount\"\n }, [reference, mutableUpdateStyles]);\n\n // use intersection observer to detect when the position of the reference changes needing to recalculate the position\n const updatePosOnIntersection = React.useCallback(() => {\n if (reference) {\n requestAnimationFrame(() => {\n debouncedUpdateStyles();\n });\n }\n }, [reference, debouncedUpdateStyles]);\n usePositionObserver(reference, updatePosOnIntersection);\n\n // when we detect that the flag about it being open/closed changes\n // we refresh the position of the tooltip calculation\n useEffect(() => {\n requestAnimationFrame(() => {\n mutableUpdateStyles?.current();\n });\n }, [isOpenSourceOfTruth, mutableUpdateStyles]);\n\n // this is a workaround to ensure that the position is calculated at least once when the tooltip is open\n const { visibility } = floatingStyles;\n const needsToCalculateBecauseStillInvisibleWhenShouldBeOpen = isOpenSourceOfTruth && visibility === 'hidden';\n useEffect(() => {\n if (needsToCalculateBecauseStillInvisibleWhenShouldBeOpen) {\n mutableUpdateStyles?.current();\n requestAnimationFrame(() => {\n setWorkaroundToEnsureAPositionWasCalculatedIfOpen((o) => o + 1);\n });\n }\n }, [\n needsToCalculateBecauseStillInvisibleWhenShouldBeOpen,\n mutableUpdateStyles,\n // this dependency is the point of this useEffect\n // it will keep triggering until the position is calculated if it needs to be calculated\n workaroundToEnsureAPositionWasCalculatedIfOpen,\n ]);\n\n const setReference = mergeRefs(_setReference, setReferenceElement);\n const refs = React.useMemo(\n () => ({\n setReference,\n setFloating,\n floating,\n reference,\n }),\n [setReference, floating, reference],\n );\n\n const handlers = React.useMemo(\n () => ({\n onMouseEnter: tooltipHelpers.onMouseEnter,\n onMouseLeave: tooltipHelpers.onMouseLeave,\n onFocus: tooltipHelpers.onFocus,\n onBlur: tooltipHelpers.onBlur,\n }),\n [tooltipHelpers.onBlur, tooltipHelpers.onFocus, tooltipHelpers.onMouseEnter, tooltipHelpers.onMouseLeave],\n );\n\n return useMemo(\n () => ({\n refs,\n floatingStyles,\n handlers,\n isOpen: isOpenSourceOfTruth,\n arrowStyles,\n hideTooltip,\n showTooltip,\n context: {\n withoutPortal,\n withoutAnimation,\n portalDOMContainer,\n animationDuration,\n },\n mutableUpdateStyles,\n }),\n [\n refs,\n floatingStyles,\n handlers,\n isOpenSourceOfTruth,\n arrowStyles,\n hideTooltip,\n showTooltip,\n withoutPortal,\n withoutAnimation,\n portalDOMContainer,\n animationDuration,\n mutableUpdateStyles,\n ],\n );\n};\n\nuseFloatingContext.displayName = 'FloatingContext';\nconst UseFloatingContextWithSchema = describe(useFloatingContext);\nUseFloatingContextWithSchema.propTypes =\n DSFloatingContextPropTypes as unknown as ValidationMap<DSHookFloatingContextT.Props>;\n\nexport { useFloatingContext, UseFloatingContextWithSchema };\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,mBAA0C;AAC1C,8BAKO;AACP,uCAAmC;AACnC,uBAA0B;AAE1B,mCAAyD;AACzD,uCAA0C;AAC1C,8BAAoC;AAEpC,MAAM,qBAAqB,CAAC,QAAsC,CAAC,MAAM;AACvE,QAAM,uBAAmB,sDAAmE,OAAO,yCAAY;AAC/G,8DAA+B,kBAAkB,yDAA4B,iBAAiB;AAE9F,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,aAAAA,QAAM,SAAkB,KAAK;AACzE,QAAM,0BAAsB,sBAAQ,MAAM;AACxC,QAAI,+BAA+B,OAAW,QAAO;AACrD,WAAO;AAAA,EACT,GAAG,CAAC,4BAA4B,cAAc,CAAC;AA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uDAAuD;AACzD,2BAAqB,QAAQ;AAC7B,4BAAsB,MAAM;AAC1B,0DAAkD,CAAC,MAAM,IAAI,CAAC;AAAA,MAChE,CAAC;AAAA,IACH;AAAA,EACF,GAAG;AAAA,IACD;AAAA,IACA;AAAA;AAAA;AAAA,IAGA;AAAA,EACF,CAAC;AAED,QAAM,mBAAe,4BAAU,eAAe,mBAAmB;AACjE,QAAM,OAAO,aAAAA,QAAM;AAAA,IACjB,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,CAAC,cAAc,UAAU,SAAS;AAAA,EACpC;AAEA,QAAM,WAAW,aAAAA,QAAM;AAAA,IACrB,OAAO;AAAA,MACL,cAAc,eAAe;AAAA,MAC7B,cAAc,eAAe;AAAA,MAC7B,SAAS,eAAe;AAAA,MACxB,QAAQ,eAAe;AAAA,IACzB;AAAA,IACA,CAAC,eAAe,QAAQ,eAAe,SAAS,eAAe,cAAc,eAAe,YAAY;AAAA,EAC1G;AAEA,aAAO;AAAA,IACL,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA,QAAQ;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAS;AAAA,QACP;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MACA;AAAA,IACF;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;AAEA,mBAAmB,cAAc;AACjC,MAAM,mCAA+B,kCAAS,kBAAkB;AAChE,6BAA6B,YAC3B;",
4
+ "sourcesContent": ["/* eslint-disable max-lines */\n/* eslint-disable consistent-return */\n/* eslint-disable max-statements */\nimport React, { useMemo, useEffect } from 'react';\nimport {\n useMemoMergePropsWithDefault,\n useValidateTypescriptPropTypes,\n describe,\n type ValidationMap,\n} from '@elliemae/ds-props-helpers';\nimport { useHeadlessTooltip } from '@elliemae/ds-hooks-headless-tooltip';\nimport type { DSHookFloatingContextT } from './react-desc-prop-types.js';\nimport { defaultProps, DSFloatingContextPropTypes } from './react-desc-prop-types.js';\nimport { useComputedPositionStyles } from './useComputedPositionStyles.js';\nimport { usePositionObserver } from './utils/positionObserver.js';\n\nconst useFloatingContext = (props: DSHookFloatingContextT.Props = {}) => {\n const propsWithDefault = useMemoMergePropsWithDefault<DSHookFloatingContextT.InternalProps>(props, defaultProps);\n useValidateTypescriptPropTypes(propsWithDefault, DSFloatingContextPropTypes, 'FloatingContext');\n\n const {\n withoutPortal,\n withoutAnimation,\n portalDOMContainer,\n animationDuration,\n placement,\n customOffset,\n placementOrderPreference,\n onOpen,\n onClose,\n externallyControlledIsOpen,\n } = propsWithDefault;\n\n const [internalIsOpen, setInternalIsOpen] = React.useState<boolean>(false);\n const isOpen = useMemo(\n () => (externallyControlledIsOpen !== undefined ? externallyControlledIsOpen : internalIsOpen),\n [externallyControlledIsOpen, internalIsOpen],\n );\n\n const handleOpen = React.useCallback(() => {\n setInternalIsOpen(true);\n onOpen?.();\n }, [onOpen]);\n\n const handleClose = React.useCallback(() => {\n setInternalIsOpen(false);\n onClose?.();\n }, [onClose]);\n\n const tooltipHelpers = useHeadlessTooltip({ onOpen: handleOpen, onClose: handleClose });\n const { setReferenceElement, referenceElement, hideTooltip, showTooltip } = tooltipHelpers;\n\n // Anchor and floating refs\n const [floating, setFloating] = React.useState<HTMLElement | null>(null);\n\n // Compute position (skip when closed)\n const { arrowStyles, floatingStyles, hasComputedOnce, updateStyles, debouncedUpdateStyles, mutableUpdateStyles } =\n useComputedPositionStyles({\n reference: referenceElement,\n floating,\n placement,\n placementOrderPreference,\n customOffset,\n withoutPortal,\n preventComputing: !isOpen,\n debounceMs: 150,\n });\n\n useEffect(() => {\n if (!isOpen) return;\n\n const observers: ResizeObserver[] = [];\n\n if (floating) {\n const roFloating = new ResizeObserver(() => {\n mutableUpdateStyles.current();\n });\n roFloating.observe(floating);\n observers.push(roFloating);\n }\n\n return () => observers.forEach((o) => o.disconnect());\n }, [isOpen, floating, updateStyles, mutableUpdateStyles]);\n\n const onObservedMovement = React.useCallback(() => {\n if (!isOpen) return;\n debouncedUpdateStyles();\n }, [isOpen, debouncedUpdateStyles]);\n usePositionObserver(referenceElement, onObservedMovement);\n\n // Expose visibility: only visible if open and already computed at least once\n const computedFloatingStyles = useMemo<React.CSSProperties>(\n () => ({\n ...floatingStyles,\n visibility: isOpen && hasComputedOnce ? 'visible' : 'hidden',\n }),\n [floatingStyles, hasComputedOnce, isOpen],\n );\n\n const refs = useMemo(\n () => ({\n setReference: setReferenceElement,\n setFloating,\n floating,\n reference: referenceElement,\n }),\n [setReferenceElement, floating, referenceElement],\n );\n\n const handlers = useMemo(\n () => ({\n onMouseEnter: tooltipHelpers.onMouseEnter,\n onMouseLeave: tooltipHelpers.onMouseLeave,\n onFocus: tooltipHelpers.onFocus,\n onBlur: tooltipHelpers.onBlur,\n }),\n [tooltipHelpers.onBlur, tooltipHelpers.onFocus, tooltipHelpers.onMouseEnter, tooltipHelpers.onMouseLeave],\n );\n\n return useMemo(\n () => ({\n refs,\n floatingStyles: computedFloatingStyles,\n handlers,\n isOpen,\n arrowStyles,\n hideTooltip,\n showTooltip,\n context: {\n withoutPortal,\n withoutAnimation,\n portalDOMContainer,\n animationDuration,\n },\n mutableUpdateStyles,\n forceUpdatePosition: updateStyles,\n }),\n [\n refs,\n computedFloatingStyles,\n handlers,\n isOpen,\n arrowStyles,\n hideTooltip,\n showTooltip,\n withoutPortal,\n withoutAnimation,\n portalDOMContainer,\n animationDuration,\n mutableUpdateStyles,\n updateStyles,\n ],\n );\n};\n\nuseFloatingContext.displayName = 'FloatingContext';\nconst UseFloatingContextWithSchema = describe(useFloatingContext);\nUseFloatingContextWithSchema.propTypes =\n DSFloatingContextPropTypes as unknown as ValidationMap<DSHookFloatingContextT.Props>;\n\nexport {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ACA;AAAA,MACA,SAAS;AAAA,QACP;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MACA;AAAA,MACA,qBAAqB;AAAA,IACvB;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;AAEA,mBAAmB,cAAc;AACjC,MAAM,mCAA+B,kCAAS,kBAAkB;AAChE,6BAA6B,YAC3B;",
6
6
  "names": ["React"]
7
7
  }
@@ -60,7 +60,6 @@ const ContentComponent = import_react.default.memo(
60
60
  innerRef,
61
61
  style: floatingStyles,
62
62
  ...xstyledProps,
63
- role: "complementary",
64
63
  "data-testid": "ds-floating-wrapper-root",
65
64
  ...globalsAttrs,
66
65
  ...ownerPropsConfig,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/parts/FloatingWrapper/FloatingWrapper.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import React from 'react';\nimport { createPortal } from 'react-dom';\nimport { describe, type ValidationMap, useOwnerProps } from '@elliemae/ds-props-helpers';\nimport { StyledFloatingAnimation, StyledFloatingWrapper } from './styled.js';\nimport { type DSFloatingWrapperT, DSFloatingWrapperPropTypes } from './react-desc-prop-types.js';\nimport { useFloatingWrapper } from './config/useFloatingWrapper.js';\nimport { DSFloatingWrapperName } from '../../constants/index.js';\nimport { getDocumentMainLandmarkOrBody } from '../../utils/getDocumentMainLandmarkOrBody.js';\n\ntype ContentComponentPropsT = {\n xstyledProps: ReturnType<typeof useFloatingWrapper>['xstyledProps'];\n globalsAttrs: ReturnType<typeof useFloatingWrapper>['globalsAttrs'];\n ownerPropsConfig: {\n getOwnerProps: () => DSFloatingWrapperT.Props;\n getOwnerPropsArguments: () => object;\n };\n handleAnimationEnd: React.AnimationEventHandler<HTMLDivElement>;\n // for performance reasons, it's better for pure component to not receive nested objects\n // so the following is just the typescript way of describing we spread the props\n} & Omit<DSFloatingWrapperT.InternalProps, 'context'> &\n DSFloatingWrapperT.InternalProps['context'];\n\nconst ContentComponent = React.memo<ContentComponentPropsT>(\n ({\n children,\n innerRef,\n floatingStyles,\n isOpen,\n animationDuration,\n withoutAnimation,\n handleAnimationEnd,\n xstyledProps,\n globalsAttrs,\n ownerPropsConfig,\n }) => (\n <StyledFloatingWrapper\n innerRef={innerRef}\n style={floatingStyles}\n {...xstyledProps}\n role=\"complementary\"\n data-testid=\"ds-floating-wrapper-root\"\n {...globalsAttrs}\n {...ownerPropsConfig}\n >\n <StyledFloatingAnimation\n onAnimationEnd={handleAnimationEnd}\n isOpen={isOpen}\n animationDuration={animationDuration}\n withoutAnimation={withoutAnimation}\n {...ownerPropsConfig}\n >\n {children}\n </StyledFloatingAnimation>\n </StyledFloatingWrapper>\n ),\n);\n\nconst FloatingWrapper: React.ComponentType<DSFloatingWrapperT.Props> = (props) => {\n const { propsWithDefault, xstyledProps, globalsAttrs } = useFloatingWrapper(props);\n const { isOpen } = propsWithDefault;\n const ownerPropsConfig = useOwnerProps(props);\n\n const { context, onAnimationEnd, onAnimationStartTriggered, ...contentProps } = propsWithDefault;\n const { portalDOMContainer, withoutPortal, withoutAnimation } = context;\n\n const [isAnimating, setIsAnimating] = React.useState(false);\n React.useEffect(() => {\n if (isOpen && !withoutAnimation) {\n setIsAnimating(true);\n onAnimationStartTriggered?.();\n }\n }, [isOpen, onAnimationStartTriggered, withoutAnimation]);\n\n const handleAnimationEnd = React.useCallback<React.AnimationEventHandler<HTMLDivElement>>(\n (e) => {\n setIsAnimating(false);\n if (onAnimationEnd) onAnimationEnd(e);\n },\n [onAnimationEnd],\n );\n\n if (isOpen || isAnimating) {\n if (withoutPortal === true)\n return (\n <ContentComponent\n xstyledProps={xstyledProps}\n globalsAttrs={globalsAttrs}\n ownerPropsConfig={ownerPropsConfig}\n {...contentProps}\n {...context}\n handleAnimationEnd={handleAnimationEnd}\n />\n );\n if (!withoutPortal)\n return (\n <>\n {createPortal(\n <ContentComponent\n xstyledProps={xstyledProps}\n globalsAttrs={globalsAttrs}\n ownerPropsConfig={ownerPropsConfig}\n {...contentProps}\n {...context}\n handleAnimationEnd={handleAnimationEnd}\n />,\n portalDOMContainer || getDocumentMainLandmarkOrBody(),\n )}\n </>\n );\n }\n return null;\n};\n\nFloatingWrapper.displayName = DSFloatingWrapperName;\nconst FloatingWrapperWithSchema = describe(FloatingWrapper);\nFloatingWrapperWithSchema.propTypes = DSFloatingWrapperPropTypes as unknown as ValidationMap<DSFloatingWrapperT.Props>;\nexport { FloatingWrapper, FloatingWrapperWithSchema };\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;AD4CjB;AA5CN,mBAAkB;AAClB,uBAA6B;AAC7B,8BAA4D;AAC5D,oBAA+D;AAC/D,mCAAoE;AACpE,gCAAmC;AACnC,uBAAsC;AACtC,2CAA8C;AAe9C,MAAM,mBAAmB,aAAAA,QAAM;AAAA,EAC7B,CAAC;AAAA,IACC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,MACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,OAAO;AAAA,MACN,GAAG;AAAA,MACJ,MAAK;AAAA,MACL,eAAY;AAAA,MACX,GAAG;AAAA,MACH,GAAG;AAAA,MAEJ;AAAA,QAAC;AAAA;AAAA,UACC,gBAAgB;AAAA,UAChB;AAAA,UACA;AAAA,UACA;AAAA,UACC,GAAG;AAAA,UAEH;AAAA;AAAA,MACH;AAAA;AAAA,EACF;AAEJ;AAEA,MAAM,kBAAiE,CAAC,UAAU;AAChF,QAAM,EAAE,kBAAkB,cAAc,aAAa,QAAI,8CAAmB,KAAK;AACjF,QAAM,EAAE,OAAO,IAAI;AACnB,QAAM,uBAAmB,uCAAc,KAAK;AAE5C,QAAM,EAAE,SAAS,gBAAgB,2BAA2B,GAAG,aAAa,IAAI;AAChF,QAAM,EAAE,oBAAoB,eAAe,iBAAiB,IAAI;AAEhE,QAAM,CAAC,aAAa,cAAc,IAAI,aAAAA,QAAM,SAAS,KAAK;AAC1D,eAAAA,QAAM,UAAU,MAAM;AACpB,QAAI,UAAU,CAAC,kBAAkB;AAC/B,qBAAe,IAAI;AACnB,kCAA4B;AAAA,IAC9B;AAAA,EACF,GAAG,CAAC,QAAQ,2BAA2B,gBAAgB,CAAC;AAExD,QAAM,qBAAqB,aAAAA,QAAM;AAAA,IAC/B,CAAC,MAAM;AACL,qBAAe,KAAK;AACpB,UAAI,eAAgB,gBAAe,CAAC;AAAA,IACtC;AAAA,IACA,CAAC,cAAc;AAAA,EACjB;AAEA,MAAI,UAAU,aAAa;AACzB,QAAI,kBAAkB;AACpB,aACE;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA,UACC,GAAG;AAAA,UACH,GAAG;AAAA,UACJ;AAAA;AAAA,MACF;AAEJ,QAAI,CAAC;AACH,aACE,2EACG;AAAA,QACC;AAAA,UAAC;AAAA;AAAA,YACC;AAAA,YACA;AAAA,YACA;AAAA,YACC,GAAG;AAAA,YACH,GAAG;AAAA,YACJ;AAAA;AAAA,QACF;AAAA,QACA,0BAAsB,oEAA8B;AAAA,MACtD,GACF;AAAA,EAEN;AACA,SAAO;AACT;AAEA,gBAAgB,cAAc;AAC9B,MAAM,gCAA4B,kCAAS,eAAe;AAC1D,0BAA0B,YAAY;",
4
+ "sourcesContent": ["import React from 'react';\nimport { createPortal } from 'react-dom';\nimport { describe, type ValidationMap, useOwnerProps } from '@elliemae/ds-props-helpers';\nimport { StyledFloatingAnimation, StyledFloatingWrapper } from './styled.js';\nimport { type DSFloatingWrapperT, DSFloatingWrapperPropTypes } from './react-desc-prop-types.js';\nimport { useFloatingWrapper } from './config/useFloatingWrapper.js';\nimport { DSFloatingWrapperName } from '../../constants/index.js';\nimport { getDocumentMainLandmarkOrBody } from '../../utils/getDocumentMainLandmarkOrBody.js';\n\ntype ContentComponentPropsT = {\n xstyledProps: ReturnType<typeof useFloatingWrapper>['xstyledProps'];\n globalsAttrs: ReturnType<typeof useFloatingWrapper>['globalsAttrs'];\n ownerPropsConfig: {\n getOwnerProps: () => DSFloatingWrapperT.Props;\n getOwnerPropsArguments: () => object;\n };\n handleAnimationEnd: React.AnimationEventHandler<HTMLDivElement>;\n // for performance reasons, it's better for pure component to not receive nested objects\n // so the following is just the typescript way of describing we spread the props\n} & Omit<DSFloatingWrapperT.InternalProps, 'context'> &\n DSFloatingWrapperT.InternalProps['context'];\n\nconst ContentComponent = React.memo<ContentComponentPropsT>(\n ({\n children,\n innerRef,\n floatingStyles,\n isOpen,\n animationDuration,\n withoutAnimation,\n handleAnimationEnd,\n xstyledProps,\n globalsAttrs,\n ownerPropsConfig,\n }) => (\n <StyledFloatingWrapper\n innerRef={innerRef}\n style={floatingStyles}\n {...xstyledProps}\n data-testid=\"ds-floating-wrapper-root\"\n {...globalsAttrs}\n {...ownerPropsConfig}\n >\n <StyledFloatingAnimation\n onAnimationEnd={handleAnimationEnd}\n isOpen={isOpen}\n animationDuration={animationDuration}\n withoutAnimation={withoutAnimation}\n {...ownerPropsConfig}\n >\n {children}\n </StyledFloatingAnimation>\n </StyledFloatingWrapper>\n ),\n);\n\nconst FloatingWrapper: React.ComponentType<DSFloatingWrapperT.Props> = (props) => {\n const { propsWithDefault, xstyledProps, globalsAttrs } = useFloatingWrapper(props);\n const { isOpen } = propsWithDefault;\n const ownerPropsConfig = useOwnerProps(props);\n\n const { context, onAnimationEnd, onAnimationStartTriggered, ...contentProps } = propsWithDefault;\n const { portalDOMContainer, withoutPortal, withoutAnimation } = context;\n\n const [isAnimating, setIsAnimating] = React.useState(false);\n React.useEffect(() => {\n if (isOpen && !withoutAnimation) {\n setIsAnimating(true);\n onAnimationStartTriggered?.();\n }\n }, [isOpen, onAnimationStartTriggered, withoutAnimation]);\n\n const handleAnimationEnd = React.useCallback<React.AnimationEventHandler<HTMLDivElement>>(\n (e) => {\n setIsAnimating(false);\n if (onAnimationEnd) onAnimationEnd(e);\n },\n [onAnimationEnd],\n );\n\n if (isOpen || isAnimating) {\n if (withoutPortal === true)\n return (\n <ContentComponent\n xstyledProps={xstyledProps}\n globalsAttrs={globalsAttrs}\n ownerPropsConfig={ownerPropsConfig}\n {...contentProps}\n {...context}\n handleAnimationEnd={handleAnimationEnd}\n />\n );\n if (!withoutPortal)\n return (\n <>\n {createPortal(\n <ContentComponent\n xstyledProps={xstyledProps}\n globalsAttrs={globalsAttrs}\n ownerPropsConfig={ownerPropsConfig}\n {...contentProps}\n {...context}\n handleAnimationEnd={handleAnimationEnd}\n />,\n portalDOMContainer || getDocumentMainLandmarkOrBody(),\n )}\n </>\n );\n }\n return null;\n};\n\nFloatingWrapper.displayName = DSFloatingWrapperName;\nconst FloatingWrapperWithSchema = describe(FloatingWrapper);\nFloatingWrapperWithSchema.propTypes = DSFloatingWrapperPropTypes as unknown as ValidationMap<DSFloatingWrapperT.Props>;\nexport { FloatingWrapper, FloatingWrapperWithSchema };\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;AD2CjB;AA3CN,mBAAkB;AAClB,uBAA6B;AAC7B,8BAA4D;AAC5D,oBAA+D;AAC/D,mCAAoE;AACpE,gCAAmC;AACnC,uBAAsC;AACtC,2CAA8C;AAe9C,MAAM,mBAAmB,aAAAA,QAAM;AAAA,EAC7B,CAAC;AAAA,IACC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,E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;AAAA;AAAA,QACF;AAAA,QACA,0BAAsB,oEAA8B;AAAA,MACtD,GACF;AAAA,EAEN;AACA,SAAO;AACT;AAEA,gBAAgB,cAAc;AAC9B,MAAM,gCAA4B,kCAAS,eAAe;AAC1D,0BAA0B,YAAY;",
6
6
  "names": ["React"]
7
7
  }
@@ -37,15 +37,23 @@ var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
37
37
  var import_ds_system = require("@elliemae/ds-system");
38
38
  var import_constants = require("../constants/index.js");
39
39
  const arrowWidth = 18;
40
- const arrowHeight = 18;
41
40
  const OFFSET_FIX_SHADOW_DEFECT = 0.25;
41
+ const arrowDimensionBase13 = arrowWidth / 13;
42
+ const OFFSET_FIX_SHADOW_DEFECT_BASE13 = OFFSET_FIX_SHADOW_DEFECT / 13;
43
+ const arrowDimensionBase16 = arrowWidth / 16;
44
+ const OFFSET_FIX_SHADOW_DEFECT_BASE16 = OFFSET_FIX_SHADOW_DEFECT / 16;
45
+ const arrowPlacementBase13 = arrowDimensionBase13 - OFFSET_FIX_SHADOW_DEFECT_BASE13;
46
+ const arrowPlacementBase16 = arrowDimensionBase16 - OFFSET_FIX_SHADOW_DEFECT_BASE16;
47
+ const isTopOrBottom = (placement) => placement.startsWith("top") || placement.startsWith("bottom");
48
+ const isLeftOrRight = (placement) => placement.startsWith("left") || placement.startsWith("right");
42
49
  const StyledArrow = (0, import_ds_system.styled)("div", {
43
50
  name: import_constants.DSFloatingWrapperName,
44
51
  slot: import_constants.DSFloatingWrapperSlots.ARROW
45
52
  })`
53
+ line-height: 0;
46
54
  position: absolute;
47
- width: ${arrowWidth}px;
48
- height: ${arrowHeight}px;
55
+ width: ${arrowDimensionBase16}rem;
56
+ height: ${arrowDimensionBase16}rem;
49
57
  pointer-events: none;
50
58
  background-color: transparent;
51
59
  & .stroke {
@@ -60,7 +68,7 @@ const StyledArrow = (0, import_ds_system.styled)("div", {
60
68
  svg {
61
69
  transform: rotateZ(180deg);
62
70
  }
63
- bottom: -${arrowHeight - OFFSET_FIX_SHADOW_DEFECT}px;
71
+ bottom: -${arrowPlacementBase16}rem;
64
72
  left: ${(props) => {
65
73
  if (props["data-placement"].endsWith("start")) return `25%`;
66
74
  if (props["data-placement"].endsWith("end")) return `75%`;
@@ -71,10 +79,10 @@ const StyledArrow = (0, import_ds_system.styled)("div", {
71
79
  svg {
72
80
  transform: rotateZ(-90deg);
73
81
  }
74
- left: -${arrowWidth - OFFSET_FIX_SHADOW_DEFECT}px;
82
+ left: -${arrowPlacementBase16}rem;
75
83
  }
76
84
  &[data-placement^='bottom'] {
77
- top: -${arrowHeight - OFFSET_FIX_SHADOW_DEFECT}px;
85
+ top: -${arrowPlacementBase16}rem;
78
86
  left: ${(props) => {
79
87
  if (props["data-placement"].endsWith("start")) return `25%`;
80
88
  if (props["data-placement"].endsWith("end")) return `75%`;
@@ -85,10 +93,35 @@ const StyledArrow = (0, import_ds_system.styled)("div", {
85
93
  svg {
86
94
  transform: rotateZ(90deg);
87
95
  }
88
- right: -${arrowWidth - OFFSET_FIX_SHADOW_DEFECT}px;
96
+ right: -${arrowPlacementBase16}rem;
97
+ }
98
+ margin-left: ${(props) => isTopOrBottom(props["data-placement"]) ? `-${arrowDimensionBase16 / 2}rem` : "0"};
99
+ margin-top: ${(props) => isLeftOrRight(props["data-placement"]) ? `-${arrowDimensionBase16 / 2}rem` : "0"};
100
+
101
+ @media (min-width: ${({ theme }) => theme.breakpoints.small}) {
102
+ width: ${arrowDimensionBase13}rem;
103
+ height: ${arrowDimensionBase13}rem;
104
+
105
+ &[data-placement^='top'] {
106
+ bottom: -${arrowPlacementBase13}rem;
107
+ }
108
+
109
+ &[data-placement^='bottom'] {
110
+ top: -${arrowPlacementBase13}rem;
111
+ }
112
+
113
+ &[data-placement^='left'] {
114
+ right: -${arrowPlacementBase13}rem;
115
+ }
116
+
117
+ &[data-placement^='right'] {
118
+ left: -${arrowPlacementBase13}rem;
119
+ }
120
+
121
+ margin-left: ${(props) => isTopOrBottom(props["data-placement"]) ? `-${arrowDimensionBase13 / 2}rem` : "0"};
122
+
123
+ margin-top: ${(props) => isLeftOrRight(props["data-placement"]) ? `-${arrowDimensionBase13 / 2}rem` : "0"};
89
124
  }
90
- margin-left: ${(props) => props["data-placement"].startsWith("top") || props["data-placement"].startsWith("bottom") ? `-${arrowWidth / 2}px;` : "0;"};
91
- margin-top: ${(props) => props["data-placement"].startsWith("left") || props["data-placement"].startsWith("right") ? `-${arrowHeight / 2}px;` : "0;"};
92
125
  `;
93
126
  const StylePathShadow = (0, import_ds_system.styled)("path", {
94
127
  name: import_constants.DSFloatingWrapperName,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/parts/PopoverArrow.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import React from 'react';\nimport { useOwnerProps, useGetGlobalAttributes, useGetXstyledProps } from '@elliemae/ds-props-helpers';\nimport { styled } from '@elliemae/ds-system';\nimport type { TypescriptHelpersT } from '@elliemae/ds-typescript-helpers';\nimport { DSFloatingWrapperSlots, DSFloatingWrapperName } from '../constants/index.js';\nexport interface PopoverArrowT\n extends TypescriptHelpersT.PropsForGlobalOnSlots<typeof DSFloatingWrapperName, typeof DSFloatingWrapperSlots> {\n placement: string;\n style: React.CSSProperties;\n arrowElementRef?: React.Dispatch<React.SetStateAction<HTMLDivElement | null>>;\n}\nconst arrowWidth = 18;\nconst arrowHeight = 18;\n\nconst OFFSET_FIX_SHADOW_DEFECT = 0.25;\nconst StyledArrow = styled('div', {\n name: DSFloatingWrapperName,\n slot: DSFloatingWrapperSlots.ARROW,\n})<{ 'data-placement': string }>`\n position: absolute;\n width: ${arrowWidth}px;\n height: ${arrowHeight}px;\n pointer-events: none;\n background-color: transparent;\n & .stroke {\n fill: rgb(105, 116, 137);\n fill-opacity: 0.4;\n }\n & .fill {\n fill: rgb(255, 255, 255);\n }\n\n &[data-placement^='top'] {\n svg {\n transform: rotateZ(180deg);\n }\n bottom: -${arrowHeight - OFFSET_FIX_SHADOW_DEFECT}px;\n left: ${(props) => {\n if (props['data-placement'].endsWith('start')) return `25%`;\n if (props['data-placement'].endsWith('end')) return `75%`;\n return '';\n }};\n }\n &[data-placement^='right'] {\n svg {\n transform: rotateZ(-90deg);\n }\n left: -${arrowWidth - OFFSET_FIX_SHADOW_DEFECT}px;\n }\n &[data-placement^='bottom'] {\n top: -${arrowHeight - OFFSET_FIX_SHADOW_DEFECT}px;\n left: ${(props) => {\n if (props['data-placement'].endsWith('start')) return `25%`;\n if (props['data-placement'].endsWith('end')) return `75%`;\n return '';\n }};\n }\n &[data-placement^='left'] {\n svg {\n transform: rotateZ(90deg);\n }\n right: -${arrowWidth - OFFSET_FIX_SHADOW_DEFECT}px;\n }\n margin-left: ${(props) =>\n props['data-placement'].startsWith('top') || props['data-placement'].startsWith('bottom')\n ? `-${arrowWidth / 2}px;`\n : '0;'};\n margin-top: ${(props) =>\n props['data-placement'].startsWith('left') || props['data-placement'].startsWith('right')\n ? `-${arrowHeight / 2}px;`\n : '0;'};\n`;\n\nconst StylePathShadow = styled('path', {\n name: DSFloatingWrapperName,\n slot: DSFloatingWrapperSlots.ARROW_SHADOW,\n})``;\n\nconst StylePathFill = styled('path', {\n name: DSFloatingWrapperName,\n slot: DSFloatingWrapperSlots.ARROW_FILL,\n})``;\n\nexport const PopoverArrow = ({ placement, style, arrowElementRef, ...rest }: PopoverArrowT): React.ReactElement => {\n const ownerProps = useOwnerProps(rest);\n const globalAttributes = useGetGlobalAttributes(rest);\n const xstyledProps = useGetXstyledProps(rest);\n return (\n <StyledArrow\n key=\"popper-arrow\"\n data-placement={placement}\n style={style}\n innerRef={arrowElementRef}\n data-testid=\"ds-tooltip-arrow\"\n aria-hidden=\"true\"\n {...ownerProps}\n {...globalAttributes}\n {...xstyledProps}\n >\n <svg viewBox=\"0 0 30 30\">\n <StylePathShadow\n {...ownerProps}\n className=\"stroke\"\n d=\"M23.7,27.1L17,19.9C16.5,19.3,15.8,19,15,19s-1.6,0.3-2.1,0.9l-6.6,7.2C5.3,28.1,3.4,29,2,29h26\n C26.7,29,24.6,28.1,23.7,27.1z\"\n />\n <StylePathFill\n {...ownerProps}\n className=\"fill\"\n d=\"M23,27.8c1.1,1.2,3.4,2.2,5,2.2h2H0h2c1.7,0,3.9-1,5-2.2l6.6-7.2c0.7-0.8,2-0.8,2.7,0L23,27.8L23,27.8z\"\n />\n </svg>\n </StyledArrow>\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADmGjB;AAlGN,8BAA0E;AAC1E,uBAAuB;AAEvB,uBAA8D;AAO9D,MAAM,aAAa;AACnB,MAAM,cAAc;AAEpB,MAAM,2BAA2B;AACjC,MAAM,kBAAc,yBAAO,OAAO;AAAA,EAChC,MAAM;AAAA,EACN,MAAM,wCAAuB;AAC/B,CAAC;AAAA;AAAA,WAEU,UAAU;AAAA,YACT,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAeR,cAAc,wBAAwB;AAAA,YACzC,CAAC,UAAU;AACjB,MAAI,MAAM,gBAAgB,EAAE,SAAS,OAAO,EAAG,QAAO;AACtD,MAAI,MAAM,gBAAgB,EAAE,SAAS,KAAK,EAAG,QAAO;AACpD,SAAO;AACT,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAMQ,aAAa,wBAAwB;AAAA;AAAA;AAAA,YAGtC,cAAc,wBAAwB;AAAA,YACtC,CAAC,UAAU;AACjB,MAAI,MAAM,gBAAgB,EAAE,SAAS,OAAO,EAAG,QAAO;AACtD,MAAI,MAAM,gBAAgB,EAAE,SAAS,KAAK,EAAG,QAAO;AACpD,SAAO;AACT,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,cAMS,aAAa,wBAAwB;AAAA;AAAA,iBAElC,CAAC,UACd,MAAM,gBAAgB,EAAE,WAAW,KAAK,KAAK,MAAM,gBAAgB,EAAE,WAAW,QAAQ,IACpF,IAAI,aAAa,CAAC,QAClB,IAAI;AAAA,gBACI,CAAC,UACb,MAAM,gBAAgB,EAAE,WAAW,MAAM,KAAK,MAAM,gBAAgB,EAAE,WAAW,OAAO,IACpF,IAAI,cAAc,CAAC,QACnB,IAAI;AAAA;AAGZ,MAAM,sBAAkB,yBAAO,QAAQ;AAAA,EACrC,MAAM;AAAA,EACN,MAAM,wCAAuB;AAC/B,CAAC;AAED,MAAM,oBAAgB,yBAAO,QAAQ;AAAA,EACnC,MAAM;AAAA,EACN,MAAM,wCAAuB;AAC/B,CAAC;AAEM,MAAM,eAAe,CAAC,EAAE,WAAW,OAAO,iBAAiB,GAAG,KAAK,MAAyC;AACjH,QAAM,iBAAa,uCAAc,IAAI;AACrC,QAAM,uBAAmB,gDAAuB,IAAI;AACpD,QAAM,mBAAe,4CAAmB,IAAI;AAC5C,SACE;AAAA,IAAC;AAAA;AAAA,MAEC,kBAAgB;AAAA,MAChB;AAAA,MACA,UAAU;AAAA,MACV,eAAY;AAAA,MACZ,eAAY;AAAA,MACX,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MAEJ,uDAAC,SAAI,SAAQ,aACX;AAAA;AAAA,UAAC;AAAA;AAAA,YACE,GAAG;AAAA,YACJ,WAAU;AAAA,YACV,GAAE;AAAA;AAAA,QAEJ;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACE,GAAG;AAAA,YACJ,WAAU;AAAA,YACV,GAAE;AAAA;AAAA,QACJ;AAAA,SACF;AAAA;AAAA,IAtBI;AAAA,EAuBN;AAEJ;",
4
+ "sourcesContent": ["import React from 'react';\nimport { useOwnerProps, useGetGlobalAttributes, useGetXstyledProps } from '@elliemae/ds-props-helpers';\nimport { styled } from '@elliemae/ds-system';\nimport type { TypescriptHelpersT } from '@elliemae/ds-typescript-helpers';\nimport { DSFloatingWrapperSlots, DSFloatingWrapperName } from '../constants/index.js';\nexport interface PopoverArrowT\n extends TypescriptHelpersT.PropsForGlobalOnSlots<typeof DSFloatingWrapperName, typeof DSFloatingWrapperSlots> {\n placement: string;\n style: React.CSSProperties;\n arrowElementRef?: React.Dispatch<React.SetStateAction<HTMLDivElement | null>>;\n}\nconst arrowWidth = 18;\nconst OFFSET_FIX_SHADOW_DEFECT = 0.25;\n\nconst arrowDimensionBase13 = arrowWidth / 13;\nconst OFFSET_FIX_SHADOW_DEFECT_BASE13 = OFFSET_FIX_SHADOW_DEFECT / 13;\nconst arrowDimensionBase16 = arrowWidth / 16;\nconst OFFSET_FIX_SHADOW_DEFECT_BASE16 = OFFSET_FIX_SHADOW_DEFECT / 16;\n\nconst arrowPlacementBase13 = arrowDimensionBase13 - OFFSET_FIX_SHADOW_DEFECT_BASE13;\nconst arrowPlacementBase16 = arrowDimensionBase16 - OFFSET_FIX_SHADOW_DEFECT_BASE16;\n\nconst isTopOrBottom = (placement: string) => placement.startsWith('top') || placement.startsWith('bottom');\n\nconst isLeftOrRight = (placement: string) => placement.startsWith('left') || placement.startsWith('right');\n\nconst StyledArrow = styled('div', {\n name: DSFloatingWrapperName,\n slot: DSFloatingWrapperSlots.ARROW,\n})<{ 'data-placement': string }>`\n line-height: 0;\n position: absolute;\n width: ${arrowDimensionBase16}rem;\n height: ${arrowDimensionBase16}rem;\n pointer-events: none;\n background-color: transparent;\n & .stroke {\n fill: rgb(105, 116, 137);\n fill-opacity: 0.4;\n }\n & .fill {\n fill: rgb(255, 255, 255);\n }\n\n &[data-placement^='top'] {\n svg {\n transform: rotateZ(180deg);\n }\n bottom: -${arrowPlacementBase16}rem;\n left: ${(props) => {\n if (props['data-placement'].endsWith('start')) return `25%`;\n if (props['data-placement'].endsWith('end')) return `75%`;\n return '';\n }};\n }\n &[data-placement^='right'] {\n svg {\n transform: rotateZ(-90deg);\n }\n left: -${arrowPlacementBase16}rem;\n }\n &[data-placement^='bottom'] {\n top: -${arrowPlacementBase16}rem;\n left: ${(props) => {\n if (props['data-placement'].endsWith('start')) return `25%`;\n if (props['data-placement'].endsWith('end')) return `75%`;\n return '';\n }};\n }\n &[data-placement^='left'] {\n svg {\n transform: rotateZ(90deg);\n }\n right: -${arrowPlacementBase16}rem;\n }\n margin-left: ${(props) => (isTopOrBottom(props['data-placement']) ? `-${arrowDimensionBase16 / 2}rem` : '0')};\n margin-top: ${(props) => (isLeftOrRight(props['data-placement']) ? `-${arrowDimensionBase16 / 2}rem` : '0')};\n\n @media (min-width: ${({ theme }) => theme.breakpoints.small}) {\n width: ${arrowDimensionBase13}rem;\n height: ${arrowDimensionBase13}rem;\n\n &[data-placement^='top'] {\n bottom: -${arrowPlacementBase13}rem;\n }\n\n &[data-placement^='bottom'] {\n top: -${arrowPlacementBase13}rem;\n }\n\n &[data-placement^='left'] {\n right: -${arrowPlacementBase13}rem;\n }\n\n &[data-placement^='right'] {\n left: -${arrowPlacementBase13}rem;\n }\n\n margin-left: ${(props) => (isTopOrBottom(props['data-placement']) ? `-${arrowDimensionBase13 / 2}rem` : '0')};\n\n margin-top: ${(props) => (isLeftOrRight(props['data-placement']) ? `-${arrowDimensionBase13 / 2}rem` : '0')};\n }\n`;\n\nconst StylePathShadow = styled('path', {\n name: DSFloatingWrapperName,\n slot: DSFloatingWrapperSlots.ARROW_SHADOW,\n})``;\n\nconst StylePathFill = styled('path', {\n name: DSFloatingWrapperName,\n slot: DSFloatingWrapperSlots.ARROW_FILL,\n})``;\n\nexport const PopoverArrow = ({ placement, style, arrowElementRef, ...rest }: PopoverArrowT): React.ReactElement => {\n const ownerProps = useOwnerProps(rest);\n const globalAttributes = useGetGlobalAttributes(rest);\n const xstyledProps = useGetXstyledProps(rest);\n return (\n <StyledArrow\n key=\"popper-arrow\"\n data-placement={placement}\n style={style}\n innerRef={arrowElementRef}\n data-testid=\"ds-tooltip-arrow\"\n aria-hidden=\"true\"\n {...ownerProps}\n {...globalAttributes}\n {...xstyledProps}\n >\n <svg viewBox=\"0 0 30 30\">\n <StylePathShadow\n {...ownerProps}\n className=\"stroke\"\n d=\"M23.7,27.1L17,19.9C16.5,19.3,15.8,19,15,19s-1.6,0.3-2.1,0.9l-6.6,7.2C5.3,28.1,3.4,29,2,29h26\n C26.7,29,24.6,28.1,23.7,27.1z\"\n />\n <StylePathFill\n {...ownerProps}\n className=\"fill\"\n d=\"M23,27.8c1.1,1.2,3.4,2.2,5,2.2h2H0h2c1.7,0,3.9-1,5-2.2l6.6-7.2c0.7-0.8,2-0.8,2.7,0L23,27.8L23,27.8z\"\n />\n </svg>\n </StyledArrow>\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADkIjB;AAjIN,8BAA0E;AAC1E,uBAAuB;AAEvB,uBAA8D;AAO9D,MAAM,aAAa;AACnB,MAAM,2BAA2B;AAEjC,MAAM,uBAAuB,aAAa;AAC1C,MAAM,kCAAkC,2BAA2B;AACnE,MAAM,uBAAuB,aAAa;AAC1C,MAAM,kCAAkC,2BAA2B;AAEnE,MAAM,uBAAuB,uBAAuB;AACpD,MAAM,uBAAuB,uBAAuB;AAEpD,MAAM,gBAAgB,CAAC,cAAsB,UAAU,WAAW,KAAK,KAAK,UAAU,WAAW,QAAQ;AAEzG,MAAM,gBAAgB,CAAC,cAAsB,UAAU,WAAW,MAAM,KAAK,UAAU,WAAW,OAAO;AAEzG,MAAM,kBAAc,yBAAO,OAAO;AAAA,EAChC,MAAM;AAAA,EACN,MAAM,wCAAuB;AAC/B,CAAC;AAAA;AAAA;AAAA,WAGU,oBAAoB;AAAA,YACnB,oBAAoB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAejB,oBAAoB;AAAA,YACvB,CAAC,UAAU;AACjB,MAAI,MAAM,gBAAgB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,wCAAuB;AAC/B,CAAC;AAEM,MAAM,eAAe,CAAC,EAAE,WAAW,OAAO,iBAAiB,GAAG,KAAK,MAAyC;AACjH,QAAM,iBAAa,uCAAc,IAAI;AACrC,QAAM,uBAAmB,gDAAuB,IAAI;AACpD,QAAM,mBAAe,4CAAmB,IAAI;AAC5C,SACE;AAAA,IAAC;AAAA;AAAA,MAEC,kBAAgB;AAAA,MAChB;AAAA,MACA,UAAU;AAAA,MACV,eAAY;AAAA,MACZ,eAAY;AAAA,MACX,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MAEJ,uDAAC,SAAI,SAAQ,aACX;AAAA;AAAA,UAAC;AAAA;AAAA,YACE,GAAG;AAAA,YACJ,WAAU;AAAA,YACV,GAAE;AAAA;AAAA,QAEJ;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACE,GAAG;AAAA,YACJ,WAAU;AAAA,YACV,GAAE;AAAA;AAAA,QACJ;AAAA,SACF;AAAA;AAAA,IAtBI;AAAA,EAuBN;AAEJ;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (let key of __getOwnPropNames(from))
11
+ if (!__hasOwnProp.call(to, key) && key !== except)
12
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ }
14
+ return to;
15
+ };
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ // If the importer is in node compatibility mode or this is not an ESM
18
+ // file that has been converted to a CommonJS file using a Babel-
19
+ // compatible transform (i.e. "__esModule" has not been set), then set
20
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var React = __toESM(require("react"));
25
+ var import_jsx_runtime = require("react/jsx-runtime");
26
+ var import_react = __toESM(require("react"));
27
+ var import__ = require("../index.js");
28
+ const testOptionalProps = {};
29
+ const testPartialDefaults = {
30
+ withoutAnimation: false,
31
+ withoutPortal: false,
32
+ animationDuration: 300
33
+ };
34
+ const testCompleteDefaults = {
35
+ withoutAnimation: false,
36
+ withoutPortal: false,
37
+ animationDuration: 300,
38
+ placement: "top",
39
+ customOffset: [10, 10],
40
+ portalDOMContainer: document.body
41
+ };
42
+ const testInternalProps = {
43
+ ...testOptionalProps,
44
+ ...testCompleteDefaults
45
+ };
46
+ const testInternalPropsAsSyntax = {
47
+ ...testOptionalProps,
48
+ ...testCompleteDefaults
49
+ };
50
+ const testExplicitDefinition = {
51
+ animationDuration: 300,
52
+ withoutAnimation: false,
53
+ withoutPortal: false,
54
+ placement: "top",
55
+ customOffset: [10, 10],
56
+ portalDOMContainer: document.body,
57
+ ...testOptionalProps
58
+ };
59
+ const testInferedTypeCompatibility = {
60
+ ...testOptionalProps,
61
+ ...testPartialDefaults,
62
+ animationDuration: 300
63
+ };
64
+ const testDefinitionAsConst = {
65
+ animationDuration: 300,
66
+ withoutAnimation: false,
67
+ withoutPortal: false,
68
+ placement: "top",
69
+ portalDOMContainer: document.body
70
+ };
71
+ const ExampleUsageComponent = () => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
72
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
73
+ import__.FloatingWrapper,
74
+ {
75
+ ...testExplicitDefinition,
76
+ innerRef: import_react.default.createRef(),
77
+ isOpen: true,
78
+ floatingStyles: {},
79
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: "Content" })
80
+ }
81
+ ),
82
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
83
+ import__.FloatingWrapper,
84
+ {
85
+ ...testInferedTypeCompatibility,
86
+ innerRef: import_react.default.createRef(),
87
+ isOpen: true,
88
+ floatingStyles: {},
89
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: "Content" })
90
+ }
91
+ ),
92
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.FloatingWrapper, { ...testDefinitionAsConst, innerRef: import_react.default.createRef(), isOpen: true, floatingStyles: {}, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: "Content" }) })
93
+ ] });
94
+ //# sourceMappingURL=typescript-floating-context-valid.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/typescript-testing/typescript-floating-context-valid.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */\nimport React from 'react';\nimport { FloatingWrapper } from '../index.js';\nimport type { DSHookFloatingContextT } from '../index.js';\n\n// test we expose the namespace and the namespace follows our deliverable conventions\ntype ComponentPropsForApp = DSHookFloatingContextT.Props;\ntype ComponentPropsInternals = DSHookFloatingContextT.InternalProps;\ntype ComponentPropsDefaultProps = DSHookFloatingContextT.DefaultProps;\ntype ComponentPropsOptionalProps = DSHookFloatingContextT.OptionalProps;\n\nconst testOptionalProps: ComponentPropsOptionalProps = {};\n\n// difference Props and InternalProps is that InternalProps has all the default props filled in\n// Props allows for partial defaults\nconst testPartialDefaults: Partial<ComponentPropsDefaultProps> = {\n withoutAnimation: false,\n withoutPortal: false,\n animationDuration: 300,\n};\n\n// InternalProps requires all defaults to be filled in\nconst testCompleteDefaults: Required<ComponentPropsDefaultProps> = {\n withoutAnimation: false,\n withoutPortal: false,\n animationDuration: 300,\n placement: 'top',\n customOffset: [10, 10],\n portalDOMContainer: document.body,\n};\n\nconst testInternalProps: ComponentPropsInternals = {\n ...testOptionalProps,\n ...testCompleteDefaults,\n};\n\nconst testInternalPropsAsSyntax = {\n ...testOptionalProps,\n ...testCompleteDefaults,\n} as ComponentPropsInternals;\n\n// using the explicit type definition, if there is an error, it will be marked on the key that is wrong\nconst testExplicitDefinition: ComponentPropsForApp = {\n animationDuration: 300,\n withoutAnimation: false,\n withoutPortal: false,\n placement: 'top',\n customOffset: [10, 10],\n portalDOMContainer: document.body,\n ...testOptionalProps,\n};\n\n// using the \"as\" syntax, if there is an error, it will be marking the whole object as wrong because it is not compatible with the type\nconst testInferedTypeCompatibility = {\n ...testOptionalProps,\n ...testPartialDefaults,\n animationDuration: 300,\n} as ComponentPropsForApp;\n\nconst testDefinitionAsConst = {\n animationDuration: 300,\n withoutAnimation: false,\n withoutPortal: false,\n placement: 'top',\n portalDOMContainer: document.body,\n} as const;\n\nconst ExampleUsageComponent = () => (\n <>\n {/* works with explicitly casted props, all syntaxes */}\n <FloatingWrapper\n {...testExplicitDefinition}\n innerRef={React.createRef<HTMLDivElement>()}\n isOpen\n floatingStyles={{}}\n >\n <div>Content</div>\n </FloatingWrapper>\n <FloatingWrapper\n {...testInferedTypeCompatibility}\n innerRef={React.createRef<HTMLDivElement>()}\n isOpen\n floatingStyles={{}}\n >\n <div>Content</div>\n </FloatingWrapper>\n <FloatingWrapper {...testDefinitionAsConst} innerRef={React.createRef<HTMLDivElement>()} isOpen floatingStyles={{}}>\n <div>Content</div>\n </FloatingWrapper>\n {/* works with inline values */}\n </>\n);\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA,YAAuB;ACoErB;AAnEF,mBAAkB;AAClB,eAAgC;AAShC,MAAM,oBAAiD,CAAC;AAIxD,MAAM,sBAA2D;AAAA,EAC/D,kBAAkB;AAAA,EAClB,eAAe;AAAA,EACf,mBAAmB;AACrB;AAGA,MAAM,uBAA6D;AAAA,EACjE,kBAAkB;AAAA,EAClB,eA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