@elliemae/ds-dataviz 3.62.1 → 3.70.0-alpha.9

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 (51) hide show
  1. package/dist/cjs/graphs/Chart/SingleStackedBar/SingleStackedBar.js +48 -23
  2. package/dist/cjs/graphs/Chart/SingleStackedBar/SingleStackedBar.js.map +2 -2
  3. package/dist/cjs/graphs/Chart/SingleStackedBar/react-desc-prop-types.js.map +2 -2
  4. package/dist/cjs/graphs/Chart/parts/FocusableRegion.js +16 -10
  5. package/dist/cjs/graphs/Chart/parts/FocusableRegion.js.map +2 -2
  6. package/dist/cjs/graphs/Chart/parts/Scrapper/ScrapperLine.js +15 -12
  7. package/dist/cjs/graphs/Chart/parts/Scrapper/ScrapperLine.js.map +2 -2
  8. package/dist/cjs/graphs/Chart/parts/Scrapper/VerticalScrapperLine.js +13 -11
  9. package/dist/cjs/graphs/Chart/parts/Scrapper/VerticalScrapperLine.js.map +2 -2
  10. package/dist/cjs/graphs/Chart/react-desc-prop-types.js.map +1 -1
  11. package/dist/esm/graphs/Chart/SingleStackedBar/SingleStackedBar.js +48 -23
  12. package/dist/esm/graphs/Chart/SingleStackedBar/SingleStackedBar.js.map +2 -2
  13. package/dist/esm/graphs/Chart/SingleStackedBar/react-desc-prop-types.js.map +2 -2
  14. package/dist/esm/graphs/Chart/parts/FocusableRegion.js +17 -11
  15. package/dist/esm/graphs/Chart/parts/FocusableRegion.js.map +2 -2
  16. package/dist/esm/graphs/Chart/parts/Scrapper/ScrapperLine.js +16 -13
  17. package/dist/esm/graphs/Chart/parts/Scrapper/ScrapperLine.js.map +2 -2
  18. package/dist/esm/graphs/Chart/parts/Scrapper/VerticalScrapperLine.js +14 -12
  19. package/dist/esm/graphs/Chart/parts/Scrapper/VerticalScrapperLine.js.map +2 -2
  20. package/dist/esm/graphs/Chart/react-desc-prop-types.js.map +1 -1
  21. package/dist/types/graphs/Chart/SingleStackedBar/react-desc-prop-types.d.ts +3 -3
  22. package/dist/types/graphs/Chart/parts/Axis/Axis.d.ts +1 -1
  23. package/dist/types/graphs/Chart/parts/Axis/AxisBottom.d.ts +1 -1
  24. package/dist/types/graphs/Chart/parts/Axis/AxisLeft.d.ts +1 -1
  25. package/dist/types/graphs/Chart/parts/Axis/AxisRight.d.ts +1 -1
  26. package/dist/types/graphs/Chart/parts/ChartContainer.d.ts +2 -1
  27. package/dist/types/graphs/Chart/parts/ClipPaths.d.ts +2 -1
  28. package/dist/types/graphs/Chart/parts/Labels/index.d.ts +2 -1
  29. package/dist/types/graphs/Chart/parts/Legend/BottomLegend.d.ts +2 -1
  30. package/dist/types/graphs/Chart/parts/Legend/LeftLegend.d.ts +2 -1
  31. package/dist/types/graphs/Chart/parts/Legend/Legend.d.ts +2 -1
  32. package/dist/types/graphs/Chart/parts/Legend/LegendItem.d.ts +2 -1
  33. package/dist/types/graphs/Chart/parts/Legend/RightLegend.d.ts +2 -1
  34. package/dist/types/graphs/Chart/parts/Legend/TopLegend.d.ts +2 -1
  35. package/dist/types/graphs/Chart/parts/Scrapper/Scrapper.d.ts +2 -1
  36. package/dist/types/graphs/Chart/parts/Scrapper/VerticalScrapper.d.ts +2 -1
  37. package/dist/types/graphs/Chart/parts/Scroller/BlurMask.d.ts +2 -1
  38. package/dist/types/graphs/Chart/parts/Scroller/Controllers.d.ts +2 -1
  39. package/dist/types/graphs/Chart/parts/Scroller/ScrollBarX.d.ts +2 -1
  40. package/dist/types/graphs/Chart/parts/Scroller/ScrollBarY.d.ts +2 -1
  41. package/dist/types/graphs/Chart/parts/Scroller/ScrollableContainerX.d.ts +2 -1
  42. package/dist/types/graphs/Chart/parts/Scroller/ScrollableContainerY.d.ts +2 -1
  43. package/dist/types/graphs/Chart/parts/SeriesFactory.d.ts +2 -1
  44. package/dist/types/graphs/Chart/react-desc-prop-types.d.ts +2 -2
  45. package/dist/types/graphs/Chart/series/HorizontalBars.d.ts +2 -1
  46. package/dist/types/graphs/Chart/series/HorizontalStackedBars.d.ts +2 -1
  47. package/package.json +10 -10
  48. package/dist/types/graphs/Chart/tests/basic.test.d.ts +0 -1
  49. package/dist/types/graphs/Chart/tests/scrollable.test.d.ts +0 -1
  50. package/dist/types/graphs/Chart/tests/single-stacked-bar.test.d.ts +0 -1
  51. package/dist/types/typescript-testing/typescript-data-viz-valid.d.ts +0 -1
@@ -35,7 +35,7 @@ module.exports = __toCommonJS(SingleStackedBar_exports);
35
35
  var React = __toESM(require("react"));
36
36
  var import_jsx_runtime = require("react/jsx-runtime");
37
37
  var import_ds_grid = require("@elliemae/ds-grid");
38
- var import_ds_popperjs = require("@elliemae/ds-popperjs");
38
+ var import_ds_floating_context = require("@elliemae/ds-floating-context");
39
39
  var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
40
40
  var import_ds_system = require("@elliemae/ds-system");
41
41
  var import_react = __toESM(require("react"));
@@ -44,9 +44,20 @@ var import_exported_related = require("./exported-related/index.js");
44
44
  var import_react_desc_prop_types = require("./react-desc-prop-types.js");
45
45
  var import_styles = require("./styles.js");
46
46
  const Bar = import_react.default.memo((props) => {
47
- const [referenceElement, setReferenceElement] = (0, import_react.useState)(null);
48
47
  const [isHover, setIsHover] = (0, import_react.useState)(false);
49
48
  const { height, TooltipRenderer, datum, tabIndex, isFocused, borderRadius, bg } = props;
49
+ const isTooltipOpen = (isFocused || isHover) && !!TooltipRenderer;
50
+ const {
51
+ refs,
52
+ floatingStyles,
53
+ arrowStyles,
54
+ context,
55
+ isOpen: isFloatingOpen
56
+ } = (0, import_ds_floating_context.useFloatingContext)({
57
+ externallyControlledIsOpen: isTooltipOpen,
58
+ withoutAnimation: true,
59
+ customOffset: [0, 14]
60
+ });
50
61
  const handleRefCallback = (0, import_react.useCallback)(
51
62
  (_ref) => {
52
63
  if (isFocused) {
@@ -61,20 +72,31 @@ const Bar = import_react.default.memo((props) => {
61
72
  const handleMouseLeave = (0, import_react.useCallback)(() => {
62
73
  setIsHover(false);
63
74
  }, []);
75
+ const backgroundColor = datum.color in import_colorPallet.COLOR_PALLET ? import_colorPallet.COLOR_PALLET[datum.color] : datum.color;
64
76
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
65
- (isFocused || isHover) && TooltipRenderer ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ds_popperjs.DSPopperJS, { referenceElement, showPopover: true, children: [
66
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledMouseOverDetectionBox, {}),
67
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledTooltipContainer, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TooltipRenderer, { datum }) })
68
- ] }) : null,
77
+ TooltipRenderer && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
78
+ import_ds_floating_context.FloatingWrapper,
79
+ {
80
+ innerRef: refs.setFloating,
81
+ isOpen: isFloatingOpen,
82
+ floatingStyles,
83
+ context,
84
+ children: [
85
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledMouseOverDetectionBox, {}),
86
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledTooltipContainer, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TooltipRenderer, { datum }) }),
87
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ds_floating_context.PopoverArrow, { ...arrowStyles })
88
+ ]
89
+ }
90
+ ),
69
91
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
70
92
  import_styles.StyledBar,
71
93
  {
72
94
  onMouseEnter: handleMouseEnter,
73
95
  onMouseLeave: handleMouseLeave,
74
- bg,
96
+ bg: backgroundColor,
75
97
  height,
76
98
  borderRadius,
77
- innerRef: (0, import_ds_system.mergeRefs)(handleRefCallback, setReferenceElement),
99
+ innerRef: (0, import_ds_system.mergeRefs)(handleRefCallback, refs.setReference),
78
100
  tabIndex,
79
101
  role: "img",
80
102
  "aria-label": `${datum.name} value: ${datum.data}`
@@ -138,21 +160,24 @@ const DSSingleStackedBar = (props) => {
138
160
  onBlur: (e) => e.currentTarget !== e.target && setIsChartFocused(false),
139
161
  ...xstyledProps,
140
162
  ...globalAttributes,
141
- children: data.map((datum, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ds_grid.Grid, { rows, children: [
142
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
143
- Bar,
144
- {
145
- datum,
146
- isFocused: barNames[keyBarFocused] === datum.name && isChartFocused,
147
- borderRadius: getBorderRadius(i),
148
- bg: import_colorPallet.COLOR_PALLET[datum.color] ?? datum.color,
149
- tabIndex: i === keyBarFocused ? 0 : -1,
150
- ...props
151
- },
152
- datum.name
153
- ),
154
- LegendRenderer !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LegendRenderer, { datum }, `${datum.name}-legend`) : null
155
- ] }))
163
+ children: data.map((datum, i) => {
164
+ const backgroundColor = datum.color in import_colorPallet.COLOR_PALLET ? import_colorPallet.COLOR_PALLET[datum.color] : datum.color;
165
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ds_grid.Grid, { rows, children: [
166
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
167
+ Bar,
168
+ {
169
+ datum,
170
+ isFocused: barNames[keyBarFocused] === datum.name && isChartFocused,
171
+ borderRadius: getBorderRadius(i),
172
+ bg: backgroundColor,
173
+ tabIndex: i === keyBarFocused ? 0 : -1,
174
+ ...props
175
+ },
176
+ datum.name
177
+ ),
178
+ LegendRenderer !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LegendRenderer, { datum }, `${datum.name}-legend`) : null
179
+ ] });
180
+ })
156
181
  }
157
182
  );
158
183
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/graphs/Chart/SingleStackedBar/SingleStackedBar.tsx", "../../../../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["/* eslint-disable max-lines */\nimport type { DSGridT } from '@elliemae/ds-grid';\nimport { Grid } from '@elliemae/ds-grid';\nimport { DSPopperJS } from '@elliemae/ds-popperjs';\nimport {\n describe,\n useGetGlobalAttributes,\n useGetXstyledProps,\n useMemoMergePropsWithDefault,\n useValidateTypescriptPropTypes,\n} from '@elliemae/ds-props-helpers';\nimport { mergeRefs } from '@elliemae/ds-system';\nimport React, { useCallback, useMemo, useState, type WeakValidationMap } from 'react';\nimport { COLOR_PALLET } from '../helpers/colorPallet.js';\nimport { DSSingleStackedBarName } from './exported-related/index.js';\nimport { DSSingleStackedBarPropTypes, defaultProps, type DSSingleStackedBarT } from './react-desc-prop-types.js';\nimport { StyledBar, StyledMouseOverDetectionBox, StyledTooltipContainer, Wrapper } from './styles.js';\nconst Bar = React.memo((props: DSSingleStackedBarT.BarT) => {\n const [referenceElement, setReferenceElement] = useState<HTMLDivElement | null>(null);\n const [isHover, setIsHover] = useState(false);\n const { height, TooltipRenderer, datum, tabIndex, isFocused, borderRadius, bg } = props;\n const handleRefCallback = useCallback(\n (_ref: HTMLDivElement | null) => {\n if (isFocused) {\n _ref?.focus();\n }\n },\n [isFocused],\n );\n\n const handleMouseEnter = useCallback(() => {\n setIsHover(true);\n }, []);\n\n const handleMouseLeave = useCallback(() => {\n setIsHover(false);\n }, []);\n return (\n <div>\n {(isFocused || isHover) && TooltipRenderer ? (\n <DSPopperJS referenceElement={referenceElement} showPopover>\n <StyledMouseOverDetectionBox />\n <StyledTooltipContainer>\n <TooltipRenderer datum={datum} />\n </StyledTooltipContainer>\n </DSPopperJS>\n ) : null}\n <StyledBar\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n bg={bg}\n height={height}\n borderRadius={borderRadius}\n innerRef={mergeRefs(handleRefCallback, setReferenceElement)}\n tabIndex={tabIndex}\n role=\"img\"\n // until uziel work is merged we keep this default value\n aria-label={`${datum.name} value: ${datum.data}`}\n />\n </div>\n );\n});\n\nconst DSSingleStackedBar: React.ComponentType<DSSingleStackedBarT.Props> = (props) => {\n const propsWithDefaults = useMemoMergePropsWithDefault<DSSingleStackedBarT.InternalProps>(props, defaultProps);\n useValidateTypescriptPropTypes(propsWithDefaults, DSSingleStackedBarPropTypes, 'DSSingleStackedBar');\n\n const globalAttributes = useGetGlobalAttributes<DSSingleStackedBarT.InternalProps, HTMLDivElement, DSGridT.Props>(\n propsWithDefaults,\n );\n\n const xstyledProps = useGetXstyledProps(propsWithDefaults);\n\n const { data, LegendRenderer, gutter, height } = propsWithDefaults;\n const [keyBarFocused, setKeyBarFocused] = useState<number>(0);\n const [isChartFocused, setIsChartFocused] = useState(false);\n\n const total = useMemo(() => data.map((datum) => datum.data).reduce((acc, curr) => acc + curr, 0), [data]);\n const cols = useMemo(() => data.map((datum) => `${Math.ceil(datum.data * 100) / total}%`), [data, total]);\n const rows = useMemo(\n () => (LegendRenderer !== undefined ? [`${height}px`, 'auto'] : [`${height}px`]),\n [LegendRenderer, height],\n );\n const barNames = useMemo(() => data.map((datum) => datum.name), [data]);\n const getBorderRadius = useCallback(\n (index: number) => {\n if (index === 0) return '50px 0 0 50px';\n if (index === data.length - 1) return '0 50px 50px 0';\n return undefined;\n },\n [data.length],\n );\n\n const handleOnKeyDown: React.KeyboardEventHandler = useCallback(\n (e) => {\n if (e.code === 'ArrowRight') {\n if (barNames[keyBarFocused + 1]) {\n setKeyBarFocused(keyBarFocused + 1);\n } else {\n setKeyBarFocused(0);\n }\n }\n if (e.code === 'ArrowLeft') {\n if (barNames[keyBarFocused - 1]) {\n setKeyBarFocused(keyBarFocused - 1);\n } else {\n setKeyBarFocused(barNames.length - 1);\n }\n }\n },\n [keyBarFocused, barNames],\n );\n\n return (\n <Wrapper\n cols={cols}\n gutter={gutter}\n role=\"region\"\n onKeyDown={handleOnKeyDown}\n tabIndex={-1}\n onFocus={() => setIsChartFocused(true)}\n onBlur={(e) => e.currentTarget !== e.target && setIsChartFocused(false)}\n {...xstyledProps}\n {...globalAttributes}\n >\n {data.map((datum, i) => (\n <Grid rows={rows}>\n <Bar\n key={datum.name}\n datum={datum}\n isFocused={barNames[keyBarFocused] === datum.name && isChartFocused}\n borderRadius={getBorderRadius(i)}\n bg={COLOR_PALLET[datum.color as keyof typeof COLOR_PALLET] ?? datum.color}\n tabIndex={i === keyBarFocused ? 0 : -1}\n {...props}\n />\n {LegendRenderer !== undefined ? <LegendRenderer key={`${datum.name}-legend`} datum={datum} /> : null}\n </Grid>\n ))}\n </Wrapper>\n );\n};\n\nDSSingleStackedBar.displayName = DSSingleStackedBarName;\nconst DSSingleStackedBarWithSchema = describe(DSSingleStackedBar);\nDSSingleStackedBarWithSchema.propTypes =\n DSSingleStackedBarPropTypes as unknown as WeakValidationMap<DSSingleStackedBarT.Props>;\n\nexport { DSSingleStackedBar, DSSingleStackedBarWithSchema };\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADwCf;AAtCR,qBAAqB;AACrB,yBAA2B;AAC3B,8BAMO;AACP,uBAA0B;AAC1B,mBAA8E;AAC9E,yBAA6B;AAC7B,8BAAuC;AACvC,mCAAoF;AACpF,oBAAwF;AACxF,MAAM,MAAM,aAAAA,QAAM,KAAK,CAAC,UAAoC;AAC1D,QAAM,CAAC,kBAAkB,mBAAmB,QAAI,uBAAgC,IAAI;AACpF,QAAM,CAAC,SAAS,UAAU,QAAI,uBAAS,KAAK;AAC5C,QAAM,EAAE,QAAQ,iBAAiB,OAAO,UAAU,WAAW,cAAc,GAAG,IAAI;AAClF,QAAM,wBAAoB;AAAA,IACxB,CAAC,SAAgC;AAC/B,UAAI,WAAW;AACb,cAAM,MAAM;AAAA,MACd;AAAA,IACF;AAAA,IACA,CAAC,SAAS;AAAA,EACZ;AAEA,QAAM,uBAAmB,0BAAY,MAAM;AACzC,eAAW,IAAI;AAAA,EACjB,GAAG,CAAC,CAAC;AAEL,QAAM,uBAAmB,0BAAY,MAA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A,YACpE,UAAU,MAAM,gBAAgB,IAAI;AAAA,YACnC,GAAG;AAAA;AAAA,UANC,MAAM;AAAA,QAOb;AAAA,QACC,mBAAmB,SAAY,4CAAC,kBAA4C,SAAxB,GAAG,MAAM,IAAI,SAAyB,IAAK;AAAA,SAClG,CACD;AAAA;AAAA,EACH;AAEJ;AAEA,mBAAmB,cAAc;AACjC,MAAM,mCAA+B,kCAAS,kBAAkB;AAChE,6BAA6B,YAC3B;",
4
+ "sourcesContent": ["/* eslint-disable max-lines */\nimport type { DSGridT } from '@elliemae/ds-grid';\nimport { Grid } from '@elliemae/ds-grid';\nimport { useFloatingContext, FloatingWrapper, PopoverArrow } from '@elliemae/ds-floating-context';\nimport {\n describe,\n useGetGlobalAttributes,\n useGetXstyledProps,\n useMemoMergePropsWithDefault,\n useValidateTypescriptPropTypes,\n} from '@elliemae/ds-props-helpers';\nimport { mergeRefs } from '@elliemae/ds-system';\nimport React, { useCallback, useMemo, useState, type WeakValidationMap } from 'react';\nimport { COLOR_PALLET } from '../helpers/colorPallet.js';\nimport { DSSingleStackedBarName } from './exported-related/index.js';\nimport { DSSingleStackedBarPropTypes, defaultProps, type DSSingleStackedBarT } from './react-desc-prop-types.js';\nimport { StyledBar, StyledMouseOverDetectionBox, StyledTooltipContainer, Wrapper } from './styles.js';\nconst Bar = React.memo((props: DSSingleStackedBarT.BarT) => {\n const [isHover, setIsHover] = useState(false);\n const { height, TooltipRenderer, datum, tabIndex, isFocused, borderRadius, bg } = props;\n\n const isTooltipOpen = (isFocused || isHover) && !!TooltipRenderer;\n const {\n refs,\n floatingStyles,\n arrowStyles,\n context,\n isOpen: isFloatingOpen,\n } = useFloatingContext({\n externallyControlledIsOpen: isTooltipOpen,\n withoutAnimation: true,\n customOffset: [0, 14],\n });\n\n const handleRefCallback = useCallback(\n (_ref: HTMLDivElement | null) => {\n if (isFocused) {\n _ref?.focus();\n }\n },\n [isFocused],\n );\n\n const handleMouseEnter = useCallback(() => {\n setIsHover(true);\n }, []);\n\n const handleMouseLeave = useCallback(() => {\n setIsHover(false);\n }, []);\n\n const backgroundColor =\n datum.color in COLOR_PALLET ? COLOR_PALLET[datum.color as keyof typeof COLOR_PALLET] : datum.color;\n return (\n <div>\n {TooltipRenderer && (\n <FloatingWrapper\n innerRef={refs.setFloating}\n isOpen={isFloatingOpen}\n floatingStyles={floatingStyles}\n context={context}\n >\n <StyledMouseOverDetectionBox />\n <StyledTooltipContainer>\n <TooltipRenderer datum={datum} />\n </StyledTooltipContainer>\n <PopoverArrow {...arrowStyles} />\n </FloatingWrapper>\n )}\n <StyledBar\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n bg={backgroundColor}\n height={height}\n borderRadius={borderRadius}\n innerRef={mergeRefs(handleRefCallback, refs.setReference)}\n tabIndex={tabIndex}\n role=\"img\"\n // until uziel work is merged we keep this default value\n aria-label={`${datum.name} value: ${datum.data}`}\n />\n </div>\n );\n});\n\nconst DSSingleStackedBar: React.ComponentType<DSSingleStackedBarT.Props> = (props) => {\n const propsWithDefaults = useMemoMergePropsWithDefault<DSSingleStackedBarT.InternalProps>(props, defaultProps);\n useValidateTypescriptPropTypes(propsWithDefaults, DSSingleStackedBarPropTypes, 'DSSingleStackedBar');\n\n const globalAttributes = useGetGlobalAttributes<DSSingleStackedBarT.InternalProps, HTMLDivElement, DSGridT.Props>(\n propsWithDefaults,\n );\n\n const xstyledProps = useGetXstyledProps(propsWithDefaults);\n\n const { data, LegendRenderer, gutter, height } = propsWithDefaults;\n const [keyBarFocused, setKeyBarFocused] = useState<number>(0);\n const [isChartFocused, setIsChartFocused] = useState(false);\n\n const total = useMemo(() => data.map((datum) => datum.data).reduce((acc, curr) => acc + curr, 0), [data]);\n const cols = useMemo(() => data.map((datum) => `${Math.ceil(datum.data * 100) / total}%`), [data, total]);\n const rows = useMemo(\n () => (LegendRenderer !== undefined ? [`${height}px`, 'auto'] : [`${height}px`]),\n [LegendRenderer, height],\n );\n const barNames = useMemo(() => data.map((datum) => datum.name), [data]);\n const getBorderRadius = useCallback(\n (index: number) => {\n if (index === 0) return '50px 0 0 50px';\n if (index === data.length - 1) return '0 50px 50px 0';\n return undefined;\n },\n [data.length],\n );\n\n const handleOnKeyDown: React.KeyboardEventHandler = useCallback(\n (e) => {\n if (e.code === 'ArrowRight') {\n if (barNames[keyBarFocused + 1]) {\n setKeyBarFocused(keyBarFocused + 1);\n } else {\n setKeyBarFocused(0);\n }\n }\n if (e.code === 'ArrowLeft') {\n if (barNames[keyBarFocused - 1]) {\n setKeyBarFocused(keyBarFocused - 1);\n } else {\n setKeyBarFocused(barNames.length - 1);\n }\n }\n },\n [keyBarFocused, barNames],\n );\n\n return (\n <Wrapper\n cols={cols}\n gutter={gutter}\n role=\"region\"\n onKeyDown={handleOnKeyDown}\n tabIndex={-1}\n onFocus={() => setIsChartFocused(true)}\n onBlur={(e) => e.currentTarget !== e.target && setIsChartFocused(false)}\n {...xstyledProps}\n {...globalAttributes}\n >\n {data.map((datum, i) => {\n const backgroundColor =\n datum.color in COLOR_PALLET ? COLOR_PALLET[datum.color as keyof typeof COLOR_PALLET] : datum.color;\n return (\n <Grid rows={rows}>\n <Bar\n key={datum.name}\n datum={datum}\n isFocused={barNames[keyBarFocused] === datum.name && isChartFocused}\n borderRadius={getBorderRadius(i)}\n bg={backgroundColor}\n tabIndex={i === keyBarFocused ? 0 : -1}\n {...props}\n />\n {LegendRenderer !== undefined ? <LegendRenderer key={`${datum.name}-legend`} datum={datum} /> : null}\n </Grid>\n );\n })}\n </Wrapper>\n );\n};\n\nDSSingleStackedBar.displayName = DSSingleStackedBarName;\nconst DSSingleStackedBarWithSchema = describe(DSSingleStackedBar);\nDSSingleStackedBarWithSchema.propTypes =\n DSSingleStackedBarPropTypes as unknown as WeakValidationMap<DSSingleStackedBarT.Props>;\n\nexport { DSSingleStackedBar, DSSingleStackedBarWithSchema };\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;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SAAyB,IAAK;AAAA,WAClG;AAAA,MAEJ,CAAC;AAAA;AAAA,EACH;AAEJ;AAEA,mBAAmB,cAAc;AACjC,MAAM,mCAA+B,kCAAS,kBAAkB;AAChE,6BAA6B,YAC3B;",
6
6
  "names": ["React"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/graphs/Chart/SingleStackedBar/react-desc-prop-types.tsx", "../../../../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import { PropTypes, globalAttributesPropTypes, xstyledPropTypes } from '@elliemae/ds-props-helpers';\nimport type { GlobalAttributesT, XstyledProps, DSPropTypesSchema } from '@elliemae/ds-props-helpers';\nimport { type BackgroundProps, type BorderProps } from '@elliemae/ds-system';\n\nexport declare namespace DSSingleStackedBarT {\n export type DatumT = {\n name: string;\n data: number;\n color: string;\n };\n export type SingleStackedBarDatumT = DatumT[];\n export type TooltipRenderDataT = {\n datum: DatumT;\n };\n export interface SingleStackedBarT {\n data: SingleStackedBarDatumT;\n TooltipRenderer?: React.ComponentType<TooltipRenderDataT>;\n LegendRenderer?: React.ComponentType<TooltipRenderDataT>;\n height: string | number;\n gutter?: string | number;\n }\n\n export interface BarT extends SingleStackedBarT {\n isFocused: boolean;\n borderRadius?: BorderProps['borderRadius'];\n bg: BackgroundProps['bg'];\n tabIndex?: 0 | -1;\n datum: DatumT;\n }\n\n export interface RequiredProps {\n height: string | number;\n data: DatumT[];\n }\n\n export interface DefaultProps {\n gutter: string;\n }\n\n export interface OptionalProps {\n TooltipRenderer?: React.ComponentType<TooltipRenderDataT>;\n LegendRenderer?: React.ComponentType<TooltipRenderDataT>;\n }\n\n export interface Props\n extends Partial<DefaultProps>,\n OptionalProps,\n Omit<GlobalAttributesT<HTMLButtonElement>, keyof DefaultProps | keyof OptionalProps | keyof RequiredProps>,\n XstyledProps,\n RequiredProps {}\n\n export interface InternalProps\n extends DefaultProps,\n OptionalProps,\n Omit<GlobalAttributesT<HTMLButtonElement>, keyof DefaultProps | keyof OptionalProps | keyof RequiredProps>,\n XstyledProps,\n RequiredProps {}\n}\n\nexport const defaultProps: DSSingleStackedBarT.DefaultProps = {\n gutter: 'xxxs',\n};\n\nexport const DSSingleStackedBarPropTypes: DSPropTypesSchema<DSSingleStackedBarT.Props> = {\n ...globalAttributesPropTypes,\n ...xstyledPropTypes,\n height: PropTypes.string.description('Height of the bar').isRequired,\n gutter: PropTypes.string.description('Gap between the bars').defaultValue('xxxs'),\n TooltipRenderer: PropTypes.func.description('Callback function that returns a custom renderer for the tooltip'),\n LegendRenderer: PropTypes.func.description('Callback function that returns a custom renderer for the legend'),\n data: PropTypes.arrayOf(\n PropTypes.shape({ name: PropTypes.string, data: PropTypes.number, color: PropTypes.string }),\n ).description('Array of the series which represent the chart'),\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,8BAAuE;AA2DhE,MAAM,eAAiD;AAAA,EAC5D,QAAQ;AACV;AAEO,MAAM,8BAA4E;AAAA,EACvF,GAAG;AAAA,EACH,GAAG;AAAA,EACH,QAAQ,kCAAU,OAAO,YAAY,mBAAmB,EAAE;AAAA,EAC1D,QAAQ,kCAAU,OAAO,YAAY,sBAAsB,EAAE,aAAa,MAAM;AAAA,EAChF,iBAAiB,kCAAU,KAAK,YAAY,kEAAkE;AAAA,EAC9G,gBAAgB,kCAAU,KAAK,YAAY,iEAAiE;AAAA,EAC5G,MAAM,kCAAU;AAAA,IACd,kCAAU,MAAM,EAAE,MAAM,kCAAU,QAAQ,MAAM,kCAAU,QAAQ,OAAO,kCAAU,OAAO,CAAC;AAAA,EAC7F,EAAE,YAAY,+CAA+C;AAC/D;",
4
+ "sourcesContent": ["import type { DSPropTypesSchema, GlobalAttributesT, XstyledProps } from '@elliemae/ds-props-helpers';\nimport { PropTypes, globalAttributesPropTypes, xstyledPropTypes } from '@elliemae/ds-props-helpers';\nimport { type BorderProps } from '@elliemae/ds-system';\n\nexport declare namespace DSSingleStackedBarT {\n export type DatumT = {\n name: string;\n data: number;\n color: string;\n };\n export type SingleStackedBarDatumT = DatumT[];\n export type TooltipRenderDataT = {\n datum: DatumT;\n };\n export interface SingleStackedBarT {\n data: SingleStackedBarDatumT;\n TooltipRenderer?: React.ComponentType<TooltipRenderDataT>;\n LegendRenderer?: React.ComponentType<TooltipRenderDataT>;\n height: string | number;\n gutter?: string | number;\n }\n\n export interface BarT extends SingleStackedBarT {\n isFocused: boolean;\n borderRadius?: BorderProps['borderRadius'];\n bg: string;\n tabIndex?: 0 | -1;\n datum: DatumT;\n }\n\n export interface RequiredProps {\n height: string | number;\n data: DatumT[];\n }\n\n export interface DefaultProps {\n gutter: string;\n }\n\n export interface OptionalProps {\n TooltipRenderer?: React.ComponentType<TooltipRenderDataT>;\n LegendRenderer?: React.ComponentType<TooltipRenderDataT>;\n }\n\n export interface Props\n extends\n Partial<DefaultProps>,\n OptionalProps,\n Omit<GlobalAttributesT<HTMLButtonElement>, keyof DefaultProps | keyof OptionalProps | keyof RequiredProps>,\n XstyledProps,\n RequiredProps {}\n\n export interface InternalProps\n extends\n DefaultProps,\n OptionalProps,\n Omit<GlobalAttributesT<HTMLButtonElement>, keyof DefaultProps | keyof OptionalProps | keyof RequiredProps>,\n XstyledProps,\n RequiredProps {}\n}\n\nexport const defaultProps: DSSingleStackedBarT.DefaultProps = {\n gutter: 'xxxs',\n};\n\nexport const DSSingleStackedBarPropTypes: DSPropTypesSchema<DSSingleStackedBarT.Props> = {\n ...globalAttributesPropTypes,\n ...xstyledPropTypes,\n height: PropTypes.string.description('Height of the bar').isRequired,\n gutter: PropTypes.string.description('Gap between the bars').defaultValue('xxxs'),\n TooltipRenderer: PropTypes.func.description('Callback function that returns a custom renderer for the tooltip'),\n LegendRenderer: PropTypes.func.description('Callback function that returns a custom renderer for the legend'),\n data: PropTypes.arrayOf(\n PropTypes.shape({ name: PropTypes.string, data: PropTypes.number, color: PropTypes.string }),\n ).description('Array of the series which represent the chart'),\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,8BAAuE;AA4DhE,MAAM,eAAiD;AAAA,EAC5D,QAAQ;AACV;AAEO,MAAM,8BAA4E;AAAA,EACvF,GAAG;AAAA,EACH,GAAG;AAAA,EACH,QAAQ,kCAAU,OAAO,YAAY,mBAAmB,EAAE;AAAA,EAC1D,QAAQ,kCAAU,OAAO,YAAY,sBAAsB,EAAE,aAAa,MAAM;AAAA,EAChF,iBAAiB,kCAAU,KAAK,YAAY,kEAAkE;AAAA,EAC9G,gBAAgB,kCAAU,KAAK,YAAY,iEAAiE;AAAA,EAC5G,MAAM,kCAAU;AAAA,IACd,kCAAU,MAAM,EAAE,MAAM,kCAAU,QAAQ,MAAM,kCAAU,QAAQ,OAAO,kCAAU,OAAO,CAAC;AAAA,EAC7F,EAAE,YAAY,+CAA+C;AAC/D;",
6
6
  "names": []
7
7
  }
@@ -34,28 +34,34 @@ module.exports = __toCommonJS(FocusableRegion_exports);
34
34
  var React = __toESM(require("react"));
35
35
  var import_jsx_runtime = require("react/jsx-runtime");
36
36
  var import_react = require("react");
37
- var import_ds_popperjs = require("@elliemae/ds-popperjs");
37
+ var import_ds_floating_context = require("@elliemae/ds-floating-context");
38
38
  var import_ds_system = require("@elliemae/ds-system");
39
39
  var import_styles = require("../styles.js");
40
40
  const FocusableRegion = (props) => {
41
- const [referenceElement, setReferenceElement] = (0, import_react.useState)(null);
42
41
  const theme = (0, import_react.useContext)(import_ds_system.ThemeContext);
43
42
  const { content, ...rest } = props;
43
+ const { refs, floatingStyles, arrowStyles, context } = (0, import_ds_floating_context.useFloatingContext)({
44
+ externallyControlledIsOpen: true,
45
+ withoutAnimation: true,
46
+ customOffset: [0, 14]
47
+ });
44
48
  return (0, import_react.useMemo)(
45
- () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("foreignObject", { ...rest, ref: setReferenceElement, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
46
- import_ds_popperjs.DSPopperJS,
49
+ () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("foreignObject", { ...rest, ref: refs.setReference, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
50
+ import_ds_floating_context.FloatingWrapper,
47
51
  {
48
- withoutAnimation: true,
49
- referenceElement,
50
- showPopover: true,
51
- zIndex: theme.zIndex.tooltip,
52
+ innerRef: refs.setFloating,
53
+ isOpen: true,
54
+ floatingStyles: { ...floatingStyles, zIndex: theme.zIndex.tooltip },
55
+ context,
52
56
  children: [
53
57
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledMouseOverDetectionBox, {}),
54
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledTooltipContainer, { children: content })
58
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledTooltipContainer, { children: content }),
59
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ds_floating_context.PopoverArrow, { ...arrowStyles })
55
60
  ]
56
61
  }
57
62
  ) }),
58
- [content, referenceElement, rest, theme.zIndex.tooltip]
63
+ // eslint-disable-next-line react-hooks/exhaustive-deps
64
+ [content, refs, floatingStyles, context, rest, theme.zIndex.tooltip]
59
65
  );
60
66
  };
61
67
  //# sourceMappingURL=FocusableRegion.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/graphs/Chart/parts/FocusableRegion.tsx", "../../../../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["/* eslint-disable max-lines */\nimport React, { useState, useContext, useMemo } from 'react';\nimport { DSPopperJS } from '@elliemae/ds-popperjs';\nimport { ThemeContext } from '@elliemae/ds-system';\nimport { StyledTooltipContainer, StyledMouseOverDetectionBox } from '../styles.js';\n\ninterface FocusableRegionProps {\n content: React.ReactNode;\n id: string;\n width: number;\n height: number;\n x?: number;\n y?: number;\n transform?: string;\n tabIndex?: number;\n style?: React.CSSProperties;\n}\n\nexport const FocusableRegion: React.ComponentType<FocusableRegionProps> = (props) => {\n const [referenceElement, setReferenceElement] = useState<HTMLOrSVGElement | null>(null);\n const theme = useContext(ThemeContext);\n\n const { content, ...rest } = props;\n\n return useMemo(\n () => (\n <foreignObject {...rest} ref={setReferenceElement}>\n <DSPopperJS\n withoutAnimation\n referenceElement={referenceElement as HTMLElement}\n showPopover\n zIndex={theme.zIndex.tooltip}\n >\n <StyledMouseOverDetectionBox />\n <StyledTooltipContainer>{content}</StyledTooltipContainer>\n </DSPopperJS>\n </foreignObject>\n ),\n [content, referenceElement, rest, theme.zIndex.tooltip],\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;AD2Bf;AA1BR,mBAAqD;AACrD,yBAA2B;AAC3B,uBAA6B;AAC7B,oBAAoE;AAc7D,MAAM,kBAA6D,CAAC,UAAU;AACnF,QAAM,CAAC,kBAAkB,mBAAmB,QAAI,uBAAkC,IAAI;AACtF,QAAM,YAAQ,yBAAW,6BAAY;AAErC,QAAM,EAAE,SAAS,GAAG,KAAK,IAAI;AAE7B,aAAO;AAAA,IACL,MACE,4CAAC,mBAAe,GAAG,MAAM,KAAK,qBAC5B;AAAA,MAAC;AAAA;AAAA,QACC,kBAAgB;AAAA,QAChB;AAAA,QACA,aAAW;AAAA,QACX,QAAQ,MAAM,OAAO;AAAA,QAErB;AAAA,sDAAC,6CAA4B;AAAA,UAC7B,4CAAC,wCAAwB,mBAAQ;AAAA;AAAA;AAAA,IACnC,GACF;AAAA,IAEF,CAAC,SAAS,kBAAkB,MAAM,MAAM,OAAO,OAAO;AAAA,EACxD;AACF;",
4
+ "sourcesContent": ["/* eslint-disable max-lines */\nimport React, { useContext, useMemo } from 'react';\nimport { useFloatingContext, FloatingWrapper, PopoverArrow } from '@elliemae/ds-floating-context';\nimport { ThemeContext } from '@elliemae/ds-system';\nimport { StyledTooltipContainer, StyledMouseOverDetectionBox } from '../styles.js';\n\ninterface FocusableRegionProps {\n content: React.ReactNode;\n id: string;\n width: number;\n height: number;\n x?: number;\n y?: number;\n transform?: string;\n tabIndex?: number;\n style?: React.CSSProperties;\n}\n\nexport const FocusableRegion: React.ComponentType<FocusableRegionProps> = (props) => {\n const theme = useContext(ThemeContext);\n const { content, ...rest } = props;\n\n const { refs, floatingStyles, arrowStyles, context } = useFloatingContext({\n externallyControlledIsOpen: true,\n withoutAnimation: true,\n customOffset: [0, 14],\n });\n\n return useMemo(\n () => (\n <foreignObject {...rest} ref={refs.setReference as React.Ref<SVGForeignObjectElement>}>\n <FloatingWrapper\n innerRef={refs.setFloating}\n isOpen\n floatingStyles={{ ...floatingStyles, zIndex: theme.zIndex.tooltip }}\n context={context}\n >\n <StyledMouseOverDetectionBox />\n <StyledTooltipContainer>{content}</StyledTooltipContainer>\n <PopoverArrow {...arrowStyles} />\n </FloatingWrapper>\n </foreignObject>\n ),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [content, refs, floatingStyles, context, rest, theme.zIndex.tooltip],\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;AD+Bf;AA9BR,mBAA2C;AAC3C,iCAAkE;AAClE,uBAA6B;AAC7B,oBAAoE;AAc7D,MAAM,kBAA6D,CAAC,UAAU;AACnF,QAAM,YAAQ,yBAAW,6BAAY;AACrC,QAAM,EAAE,SAAS,GAAG,KAAK,IAAI;AAE7B,QAAM,EAAE,MAAM,gBAAgB,aAAa,QAAQ,QAAI,+CAAmB;AAAA,IACxE,4BAA4B;AAAA,IAC5B,kBAAkB;AAAA,IAClB,cAAc,CAAC,GAAG,EAAE;AAAA,EACtB,CAAC;AAED,aAAO;AAAA,IACL,MACE,4CAAC,mBAAe,GAAG,MAAM,KAAK,KAAK,cACjC;AAAA,MAAC;AAAA;AAAA,QACC,UAAU,KAAK;AAAA,QACf,QAAM;AAAA,QACN,gBAAgB,EAAE,GAAG,gBAAgB,QAAQ,MAAM,OAAO,QAAQ;AAAA,QAClE;AAAA,QAEA;AAAA,sDAAC,6CAA4B;AAAA,UAC7B,4CAAC,wCAAwB,mBAAQ;AAAA,UACjC,4CAAC,2CAAc,GAAG,aAAa;AAAA;AAAA;AAAA,IACjC,GACF;AAAA;AAAA,IAGF,CAAC,SAAS,MAAM,gBAAgB,SAAS,MAAM,MAAM,OAAO,OAAO;AAAA,EACrE;AACF;",
6
6
  "names": []
7
7
  }
@@ -34,7 +34,7 @@ module.exports = __toCommonJS(ScrapperLine_exports);
34
34
  var React = __toESM(require("react"));
35
35
  var import_jsx_runtime = require("react/jsx-runtime");
36
36
  var import_react = require("react");
37
- var import_ds_popperjs = require("@elliemae/ds-popperjs");
37
+ var import_ds_floating_context = require("@elliemae/ds-floating-context");
38
38
  var import_ds_system = require("@elliemae/ds-system");
39
39
  var import_ChartContext = require("../../ChartContext.js");
40
40
  var import_styles = require("../../styles.js");
@@ -49,25 +49,28 @@ const ScrapperLine = ({ yPosition, datum }) => {
49
49
  props: { TooltipRenderer, scrapper }
50
50
  } = (0, import_react.useContext)(import_ChartContext.ChartContext);
51
51
  const theme = (0, import_react.useContext)(import_ds_system.ThemeContext);
52
- const [referenceElement, setReferenceElement] = (0, import_react.useState)(null);
53
52
  const yPositionString = yPosition;
53
+ const isActive = scrapperPosY === yPositionString;
54
+ const { refs, floatingStyles, context } = (0, import_ds_floating_context.useFloatingContext)({
55
+ externallyControlledIsOpen: isActive && !!TooltipRenderer,
56
+ withoutAnimation: true,
57
+ customOffset: [0, 5],
58
+ placement: scrapper?.tooltipPreference
59
+ });
54
60
  const handleOnMouseEnter = (0, import_react.useCallback)(() => {
55
61
  if (!isGrabbed) setScrapperPosY(yPositionString);
56
62
  setActivePoint(null);
57
63
  }, [isGrabbed, setScrapperPosY, setActivePoint, yPositionString]);
58
64
  const strokeDetectorWidth = yScale?.type === "BAND" ? yScale?.getBandwidth() : "4px";
59
65
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", { children: [
60
- scrapperPosY === yPositionString ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", { children: [
66
+ isActive ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", { children: [
61
67
  TooltipRenderer ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("foreignObject", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
62
- import_ds_popperjs.DSPopperJS,
68
+ import_ds_floating_context.FloatingWrapper,
63
69
  {
64
- withoutAnimation: true,
65
- withoutArrow: true,
66
- customOffset: [0, 5],
67
- referenceElement,
68
- showPopover: true,
69
- zIndex: theme.zIndex.tooltip,
70
- startPlacementPreference: scrapper?.tooltipPreference,
70
+ innerRef: refs.setFloating,
71
+ isOpen: isActive,
72
+ floatingStyles: { ...floatingStyles, zIndex: theme.zIndex.tooltip },
73
+ context,
71
74
  children: [
72
75
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledMouseOverDetectionBox, {}),
73
76
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledTooltipContainer, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TooltipRenderer, { data: datum }) })
@@ -77,7 +80,7 @@ const ScrapperLine = ({ yPosition, datum }) => {
77
80
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
78
81
  "line",
79
82
  {
80
- ref: setReferenceElement,
83
+ ref: refs.setReference,
81
84
  x1: innerWidth,
82
85
  strokeWidth: "2px",
83
86
  stroke: "transparent",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/graphs/Chart/parts/Scrapper/ScrapperLine.tsx", "../../../../../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import React, { useContext, useCallback, useState } from 'react';\nimport { DSPopperJS } from '@elliemae/ds-popperjs';\nimport { ThemeContext } from '@elliemae/ds-system';\nimport { ChartContext } from '../../ChartContext.js';\nimport { StyledMouseOverDetectionBox, StyledTooltipContainer } from '../../styles.js';\nimport type { DSChartT } from '../../react-desc-prop-types.js';\ninterface ScrapperLineProps {\n yPosition: number;\n datum: DSChartT.ScrapperDatum[];\n}\n\nexport const ScrapperLine: React.ComponentType<ScrapperLineProps> = ({ yPosition, datum }) => {\n const {\n scrapperPosY,\n setScrapperPosY,\n innerWidth,\n yScale,\n setActivePoint,\n isGrabbed,\n props: { TooltipRenderer, scrapper },\n } = useContext(ChartContext);\n const theme = useContext(ThemeContext);\n const [referenceElement, setReferenceElement] = useState<HTMLOrSVGElement | null>(null);\n\n const yPositionString = yPosition;\n const handleOnMouseEnter = useCallback(() => {\n if (!isGrabbed) setScrapperPosY(yPositionString);\n setActivePoint(null);\n }, [isGrabbed, setScrapperPosY, setActivePoint, yPositionString]);\n\n const strokeDetectorWidth = yScale?.type === 'BAND' ? yScale?.getBandwidth() : '4px';\n\n return (\n <g>\n {scrapperPosY === yPositionString ? (\n <g>\n {TooltipRenderer ? (\n <foreignObject>\n <DSPopperJS\n withoutAnimation\n withoutArrow\n customOffset={[0, 5]}\n referenceElement={referenceElement as HTMLElement}\n showPopover\n zIndex={theme.zIndex.tooltip}\n startPlacementPreference={scrapper?.tooltipPreference}\n >\n <StyledMouseOverDetectionBox />\n <StyledTooltipContainer>\n <TooltipRenderer data={datum} />\n </StyledTooltipContainer>\n </DSPopperJS>\n </foreignObject>\n ) : null}\n <line\n ref={setReferenceElement}\n x1={innerWidth}\n strokeWidth=\"2px\"\n stroke=\"transparent\"\n y1={yPosition}\n x2={innerWidth}\n y2={yPosition}\n />\n <line\n x1={0}\n strokeWidth=\"2px\"\n stroke=\"grey\"\n strokeDasharray=\"4 4\"\n y1={yPosition}\n x2={innerWidth}\n y2={yPosition}\n />\n </g>\n ) : null}\n <line\n onMouseEnter={handleOnMouseEnter}\n x1={0}\n strokeWidth={strokeDetectorWidth}\n stroke=\"transparent\"\n y1={yPosition}\n x2={innerWidth}\n y2={yPosition}\n />\n </g>\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADsCT;AAtCd,mBAAyD;AACzD,yBAA2B;AAC3B,uBAA6B;AAC7B,0BAA6B;AAC7B,oBAAoE;AAO7D,MAAM,eAAuD,CAAC,EAAE,WAAW,MAAM,MAAM;AAC5F,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,EAAE,iBAAiB,SAAS;AAAA,EACrC,QAAI,yBAAW,gCAAY;AAC3B,QAAM,YAAQ,yBAAW,6BAAY;AACrC,QAAM,CAAC,kBAAkB,mBAAmB,QAAI,uBAAkC,IAAI;AAEtF,QAAM,kBAAkB;AACxB,QAAM,yBAAqB,0BAAY,MAAM;AAC3C,QAAI,CAAC,UAAW,iBAAgB,eAAe;AAC/C,mBAAe,IAAI;AAAA,EACrB,GAAG,CAAC,WAAW,iBAAiB,gBAAgB,eAAe,CAAC;AAEhE,QAAM,sBAAsB,QAAQ,SAAS,SAAS,QAAQ,aAAa,IAAI;AAE/E,SACE,6CAAC,OACE;AAAA,qBAAiB,kBAChB,6CAAC,OACE;AAAA,wBACC,4CAAC,mBACC;AAAA,QAAC;AAAA;AAAA,UACC,kBAAgB;AAAA,UAChB,cAAY;AAAA,UACZ,cAAc,CAAC,GAAG,CAAC;AAAA,UACnB;AAAA,UACA,aAAW;AAAA,UACX,QAAQ,MAAM,OAAO;AAAA,UACrB,0BAA0B,UAAU;AAAA,UAEpC;AAAA,wDAAC,6CAA4B;AAAA,YAC7B,4CAAC,wCACC,sDAAC,mBAAgB,MAAM,OAAO,GAChC;AAAA;AAAA;AAAA,MACF,GACF,IACE;AAAA,MACJ;AAAA,QAAC;AAAA;AAAA,UACC,KAAK;AAAA,UACL,IAAI;AAAA,UACJ,aAAY;AAAA,UACZ,QAAO;AAAA,UACP,IAAI;AAAA,UACJ,IAAI;AAAA,UACJ,IAAI;AAAA;AAAA,MACN;AAAA,MACA;AAAA,QAAC;AAAA;AAAA,UACC,IAAI;AAAA,UACJ,aAAY;AAAA,UACZ,QAAO;AAAA,UACP,iBAAgB;AAAA,UAChB,IAAI;AAAA,UACJ,IAAI;AAAA,UACJ,IAAI;AAAA;AAAA,MACN;AAAA,OACF,IACE;AAAA,IACJ;AAAA,MAAC;AAAA;AAAA,QACC,cAAc;AAAA,QACd,IAAI;AAAA,QACJ,aAAa;AAAA,QACb,QAAO;AAAA,QACP,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA;AAAA,IACN;AAAA,KACF;AAEJ;",
4
+ "sourcesContent": ["import React, { useContext, useCallback } from 'react';\nimport { useFloatingContext, FloatingWrapper } from '@elliemae/ds-floating-context';\nimport { ThemeContext } from '@elliemae/ds-system';\nimport { ChartContext } from '../../ChartContext.js';\nimport { StyledMouseOverDetectionBox, StyledTooltipContainer } from '../../styles.js';\nimport type { DSChartT } from '../../react-desc-prop-types.js';\ninterface ScrapperLineProps {\n yPosition: number;\n datum: DSChartT.ScrapperDatum[];\n}\n\nexport const ScrapperLine: React.ComponentType<ScrapperLineProps> = ({ yPosition, datum }) => {\n const {\n scrapperPosY,\n setScrapperPosY,\n innerWidth,\n yScale,\n setActivePoint,\n isGrabbed,\n props: { TooltipRenderer, scrapper },\n } = useContext(ChartContext);\n const theme = useContext(ThemeContext);\n\n const yPositionString = yPosition;\n const isActive = scrapperPosY === yPositionString;\n\n const { refs, floatingStyles, context } = useFloatingContext({\n externallyControlledIsOpen: isActive && !!TooltipRenderer,\n withoutAnimation: true,\n customOffset: [0, 5],\n placement: scrapper?.tooltipPreference,\n });\n\n const handleOnMouseEnter = useCallback(() => {\n if (!isGrabbed) setScrapperPosY(yPositionString);\n setActivePoint(null);\n }, [isGrabbed, setScrapperPosY, setActivePoint, yPositionString]);\n\n const strokeDetectorWidth = yScale?.type === 'BAND' ? yScale?.getBandwidth() : '4px';\n\n return (\n <g>\n {isActive ? (\n <g>\n {TooltipRenderer ? (\n <foreignObject>\n <FloatingWrapper\n innerRef={refs.setFloating}\n isOpen={isActive}\n floatingStyles={{ ...floatingStyles, zIndex: theme.zIndex.tooltip }}\n context={context}\n >\n <StyledMouseOverDetectionBox />\n <StyledTooltipContainer>\n <TooltipRenderer data={datum} />\n </StyledTooltipContainer>\n </FloatingWrapper>\n </foreignObject>\n ) : null}\n <line\n ref={refs.setReference as React.Ref<SVGLineElement>}\n x1={innerWidth}\n strokeWidth=\"2px\"\n stroke=\"transparent\"\n y1={yPosition}\n x2={innerWidth}\n y2={yPosition}\n />\n <line\n x1={0}\n strokeWidth=\"2px\"\n stroke=\"grey\"\n strokeDasharray=\"4 4\"\n y1={yPosition}\n x2={innerWidth}\n y2={yPosition}\n />\n </g>\n ) : null}\n <line\n onMouseEnter={handleOnMouseEnter}\n x1={0}\n strokeWidth={strokeDetectorWidth}\n stroke=\"transparent\"\n y1={yPosition}\n x2={innerWidth}\n y2={yPosition}\n />\n </g>\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;AD8CT;AA9Cd,mBAA+C;AAC/C,iCAAoD;AACpD,uBAA6B;AAC7B,0BAA6B;AAC7B,oBAAoE;AAO7D,MAAM,eAAuD,CAAC,EAAE,WAAW,MAAM,MAAM;AAC5F,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,EAAE,iBAAiB,SAAS;AAAA,E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AC;AAAA;AAAA,QACC,cAAc;AAAA,QACd,IAAI;AAAA,QACJ,aAAa;AAAA,QACb,QAAO;AAAA,QACP,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA;AAAA,IACN;AAAA,KACF;AAEJ;",
6
6
  "names": []
7
7
  }
@@ -34,7 +34,7 @@ module.exports = __toCommonJS(VerticalScrapperLine_exports);
34
34
  var React = __toESM(require("react"));
35
35
  var import_jsx_runtime = require("react/jsx-runtime");
36
36
  var import_react = __toESM(require("react"));
37
- var import_ds_popperjs = require("@elliemae/ds-popperjs");
37
+ var import_ds_floating_context = require("@elliemae/ds-floating-context");
38
38
  var import_ds_system = require("@elliemae/ds-system");
39
39
  var import_styles = require("../../styles.js");
40
40
  const VerticalScrapperLine = import_react.default.memo(
@@ -52,8 +52,13 @@ const VerticalScrapperLine = import_react.default.memo(
52
52
  scrapper
53
53
  }) => {
54
54
  const theme = (0, import_react.useContext)(import_ds_system.ThemeContext);
55
- const [referenceElement, setReferenceElement] = (0, import_react.useState)();
56
55
  const isActive = scrapperPosX === xPosition;
56
+ const { refs, floatingStyles, context } = (0, import_ds_floating_context.useFloatingContext)({
57
+ externallyControlledIsOpen: isActive && !isGrabbed && !!TooltipRenderer,
58
+ withoutAnimation: true,
59
+ customOffset: [0, 5],
60
+ placement: scrapper.tooltipPreference
61
+ });
57
62
  const handleOnMouseEnter = (0, import_react.useCallback)(() => {
58
63
  if (!isGrabbed) setScrapperPosX(xPosition);
59
64
  setActivePoint(null);
@@ -62,15 +67,12 @@ const VerticalScrapperLine = import_react.default.memo(
62
67
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", { transform: `translate(${nonNullXscale.type === "BAND" ? nonNullXscale.getBandwidth() / 2 : 0}, 0)`, children: [
63
68
  isActive && !isGrabbed ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", { children: [
64
69
  TooltipRenderer ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("foreignObject", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
65
- import_ds_popperjs.DSPopperJS,
70
+ import_ds_floating_context.FloatingWrapper,
66
71
  {
67
- withoutAnimation: true,
68
- withoutArrow: true,
69
- customOffset: [0, 5],
70
- referenceElement,
71
- showPopover: true,
72
- zIndex: theme.zIndex.tooltip,
73
- startPlacementPreference: scrapper.tooltipPreference,
72
+ innerRef: refs.setFloating,
73
+ isOpen: isActive && !isGrabbed,
74
+ floatingStyles: { ...floatingStyles, zIndex: theme.zIndex.tooltip },
75
+ context,
74
76
  children: [
75
77
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledMouseOverDetectionBox, {}),
76
78
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledTooltipContainer, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TooltipRenderer, { data }) })
@@ -80,7 +82,7 @@ const VerticalScrapperLine = import_react.default.memo(
80
82
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
81
83
  "line",
82
84
  {
83
- ref: setReferenceElement,
85
+ ref: refs.setReference,
84
86
  x1: xPosition,
85
87
  strokeWidth: "2px",
86
88
  stroke: scrapper.color,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/graphs/Chart/parts/Scrapper/VerticalScrapperLine.tsx", "../../../../../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["/* eslint-disable complexity */\nimport React, { useContext, useCallback, useState } from 'react';\nimport { DSPopperJS } from '@elliemae/ds-popperjs';\nimport { ThemeContext } from '@elliemae/ds-system';\nimport { StyledMouseOverDetectionBox, StyledTooltipContainer } from '../../styles.js';\nimport type { DSChartT } from '../../react-desc-prop-types.js';\nimport type { ScaleT } from '../../scales/index.js';\ninterface VerticalScrapperLineProps {\n rectDetector?: { left: number; right: number };\n xPosition: number;\n data: DSChartT.ScrapperDatum[];\n scrapperPosX: number;\n setScrapperPosX: (x: number) => void;\n isGrabbed: boolean;\n xScale: ScaleT | null;\n setActivePoint: React.Dispatch<React.SetStateAction<DSChartT.InternalDatum | null>>;\n innerHeight: number;\n TooltipRenderer?:\n | React.ComponentType<{\n data: {\n name: string;\n xValue: string | number | Date | null;\n yValue: string | number | Date | null;\n datum: DSChartT.InternalDatum;\n }[];\n }>\n | undefined;\n scrapper: DSChartT.ScrapperT;\n}\n\nexport const VerticalScrapperLine: React.ComponentType<VerticalScrapperLineProps> = React.memo(\n ({\n rectDetector,\n xPosition,\n data,\n scrapperPosX,\n setScrapperPosX,\n isGrabbed,\n xScale,\n setActivePoint,\n innerHeight,\n TooltipRenderer,\n scrapper,\n }) => {\n const theme = useContext(ThemeContext);\n const [referenceElement, setReferenceElement] = useState<HTMLOrSVGElement | null>();\n const isActive = scrapperPosX === xPosition;\n const handleOnMouseEnter = useCallback(() => {\n if (!isGrabbed) setScrapperPosX(xPosition);\n setActivePoint(null);\n }, [isGrabbed, setActivePoint, setScrapperPosX, xPosition]);\n // the code was abusing `xScale?.` even in place where it could lead to NaN\n // I am not sure what the `?.` was solving but xScale typescript says | null\n // this line is a monkeypatch to avoid the NaN but it charts should be properly revisited to use typesafe code and algorithms\n const nonNullXscale = xScale ?? { type: 'notBANDAndEverythingElseIsCurrentlyTreatedTheSame' };\n return (\n <g transform={`translate(${nonNullXscale.type === 'BAND' ? nonNullXscale.getBandwidth() / 2 : 0}, 0)`}>\n {isActive && !isGrabbed ? (\n <g>\n {TooltipRenderer ? (\n <foreignObject>\n <DSPopperJS\n withoutAnimation\n withoutArrow\n customOffset={[0, 5]}\n referenceElement={referenceElement as HTMLElement}\n showPopover\n zIndex={theme.zIndex.tooltip}\n startPlacementPreference={scrapper.tooltipPreference}\n >\n <StyledMouseOverDetectionBox />\n <StyledTooltipContainer>\n <TooltipRenderer data={data} />\n </StyledTooltipContainer>\n </DSPopperJS>\n </foreignObject>\n ) : null}\n <line\n ref={setReferenceElement}\n x1={xPosition}\n strokeWidth=\"2px\"\n stroke={scrapper.color}\n y1={0}\n x2={xPosition}\n y2={innerHeight}\n strokeDasharray=\"4 4\"\n />\n </g>\n ) : null}\n <rect\n onMouseOver={handleOnMouseEnter}\n x={\n nonNullXscale.type === 'BAND'\n ? xPosition - nonNullXscale.getBandwidth() / 2\n : xPosition - (rectDetector?.left ?? 0)\n }\n fill=\"transparent\"\n y={0}\n width={\n nonNullXscale.type === 'BAND'\n ? nonNullXscale.getBandwidth()\n : (rectDetector?.right ?? 0) + (rectDetector?.left ?? 0)\n }\n height={innerHeight}\n />\n </g>\n );\n },\n);\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;AD6DP;AA5DhB,mBAAyD;AACzD,yBAA2B;AAC3B,uBAA6B;AAC7B,oBAAoE;AA0B7D,MAAM,uBAAuE,aAAAA,QAAM;AAAA,EACxF,CAAC;AAAA,IACC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,MAAM;AACJ,UAAM,YAAQ,yBAAW,6BAAY;AACrC,UAAM,CAAC,kBAAkB,mBAAmB,QAAI,uBAAkC;AAClF,UAAM,WAAW,iBAAiB;AAClC,UAAM,yBAAqB,0BAAY,MAAM;AAC3C,UAAI,CAAC,UAAW,iBAAgB,SAAS;AACzC,qBAAe,IAAI;AAAA,IACrB,GAAG,CAAC,WAAW,gBAAgB,iBAAiB,SAAS,CAAC;AAI1D,UAAM,gBAAgB,UAAU,EAAE,MAAM,oDAAoD;AAC5F,WACE,6CAAC,OAAE,WAAW,aAAa,cAAc,SAAS,SAAS,cAAc,aAAa,IAAI,IAAI,CAAC,QAC5F;AAAA,kBAAY,CAAC,YACZ,6CAAC,OACE;AAAA,0BACC,4CAAC,mBACC;AAAA,UAAC;AAAA;AAAA,YACC,kBAAgB;AAAA,YAChB,cAAY;AAAA,YACZ,cAAc,CAAC,GAAG,CAAC;AAAA,YACnB;AAAA,YACA,aAAW;AAAA,YACX,QAAQ,MAAM,OAAO;AAAA,YACrB,0BAA0B,SAAS;AAAA,YAEnC;AAAA,0DAAC,6CAA4B;AAAA,cAC7B,4CAAC,wCACC,sDAAC,mBAAgB,MAAY,GAC/B;AAAA;AAAA;AAAA,QACF,GACF,IACE;AAAA,QACJ;AAAA,UAAC;AAAA;AAAA,YACC,KAAK;AAAA,YACL,IAAI;AAAA,YACJ,aAAY;AAAA,YACZ,QAAQ,SAAS;AAAA,YACjB,IAAI;AAAA,YACJ,IAAI;AAAA,YACJ,IAAI;AAAA,YACJ,iBAAgB;AAAA;AAAA,QAClB;AAAA,SACF,IACE;AAAA,MACJ;AAAA,QAAC;AAAA;AAAA,UACC,aAAa;AAAA,UACb,GACE,cAAc,SAAS,SACnB,YAAY,cAAc,aAAa,IAAI,IAC3C,aAAa,cAAc,QAAQ;AAAA,UAEzC,MAAK;AAAA,UACL,GAAG;AAAA,UACH,OACE,cAAc,SAAS,SACnB,cAAc,aAAa,KAC1B,cAAc,SAAS,MAAM,cAAc,QAAQ;AAAA,UAE1D,QAAQ;AAAA;AAAA,MACV;AAAA,OACF;AAAA,EAEJ;AACF;",
4
+ "sourcesContent": ["/* eslint-disable complexity */\nimport React, { useContext, useCallback } from 'react';\nimport { useFloatingContext, FloatingWrapper } from '@elliemae/ds-floating-context';\nimport { ThemeContext } from '@elliemae/ds-system';\nimport { StyledMouseOverDetectionBox, StyledTooltipContainer } from '../../styles.js';\nimport type { DSChartT } from '../../react-desc-prop-types.js';\nimport type { ScaleT } from '../../scales/index.js';\ninterface VerticalScrapperLineProps {\n rectDetector?: { left: number; right: number };\n xPosition: number;\n data: DSChartT.ScrapperDatum[];\n scrapperPosX: number;\n setScrapperPosX: (x: number) => void;\n isGrabbed: boolean;\n xScale: ScaleT | null;\n setActivePoint: React.Dispatch<React.SetStateAction<DSChartT.InternalDatum | null>>;\n innerHeight: number;\n TooltipRenderer?:\n | React.ComponentType<{\n data: {\n name: string;\n xValue: string | number | Date | null;\n yValue: string | number | Date | null;\n datum: DSChartT.InternalDatum;\n }[];\n }>\n | undefined;\n scrapper: DSChartT.ScrapperT;\n}\n\nexport const VerticalScrapperLine: React.ComponentType<VerticalScrapperLineProps> = React.memo(\n ({\n rectDetector,\n xPosition,\n data,\n scrapperPosX,\n setScrapperPosX,\n isGrabbed,\n xScale,\n setActivePoint,\n innerHeight,\n TooltipRenderer,\n scrapper,\n }) => {\n const theme = useContext(ThemeContext);\n const isActive = scrapperPosX === xPosition;\n\n const { refs, floatingStyles, context } = useFloatingContext({\n externallyControlledIsOpen: isActive && !isGrabbed && !!TooltipRenderer,\n withoutAnimation: true,\n customOffset: [0, 5],\n placement: scrapper.tooltipPreference,\n });\n\n const handleOnMouseEnter = useCallback(() => {\n if (!isGrabbed) setScrapperPosX(xPosition);\n setActivePoint(null);\n }, [isGrabbed, setActivePoint, setScrapperPosX, xPosition]);\n // the code was abusing `xScale?.` even in place where it could lead to NaN\n // I am not sure what the `?.` was solving but xScale typescript says | null\n // this line is a monkeypatch to avoid the NaN but it charts should be properly revisited to use typesafe code and algorithms\n const nonNullXscale = xScale ?? { type: 'notBANDAndEverythingElseIsCurrentlyTreatedTheSame' };\n return (\n <g transform={`translate(${nonNullXscale.type === 'BAND' ? nonNullXscale.getBandwidth() / 2 : 0}, 0)`}>\n {isActive && !isGrabbed ? (\n <g>\n {TooltipRenderer ? (\n <foreignObject>\n <FloatingWrapper\n innerRef={refs.setFloating}\n isOpen={isActive && !isGrabbed}\n floatingStyles={{ ...floatingStyles, zIndex: theme.zIndex.tooltip }}\n context={context}\n >\n <StyledMouseOverDetectionBox />\n <StyledTooltipContainer>\n <TooltipRenderer data={data} />\n </StyledTooltipContainer>\n </FloatingWrapper>\n </foreignObject>\n ) : null}\n <line\n ref={refs.setReference as React.Ref<SVGLineElement>}\n x1={xPosition}\n strokeWidth=\"2px\"\n stroke={scrapper.color}\n y1={0}\n x2={xPosition}\n y2={innerHeight}\n strokeDasharray=\"4 4\"\n />\n </g>\n ) : null}\n <rect\n onMouseOver={handleOnMouseEnter}\n x={\n nonNullXscale.type === 'BAND'\n ? xPosition - nonNullXscale.getBandwidth() / 2\n : xPosition - (rectDetector?.left ?? 0)\n }\n fill=\"transparent\"\n y={0}\n width={\n nonNullXscale.type === 'BAND'\n ? nonNullXscale.getBandwidth()\n : (rectDetector?.right ?? 0) + (rectDetector?.left ?? 0)\n }\n height={innerHeight}\n />\n </g>\n );\n },\n);\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADoEP;AAnEhB,mBAA+C;AAC/C,iCAAoD;AACpD,uBAA6B;AAC7B,oBAAoE;AA0B7D,MAAM,uBAAuE,aAAAA,QAAM;AAAA,EACxF,CAAC;AAAA,IACC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,MAAM;AACJ,UAAM,YAAQ,yBAAW,6BAAY;AACrC,UAAM,WAAW,iBAAiB;AAElC,UAAM,EAAE,MAAM,gBAAgB,QAAQ,QAAI,+CAAmB;AAAA,MAC3D,4BAA4B,YAAY,CAAC,aAAa,CAAC,CAAC;AAAA,MACxD,kBAAkB;AAAA,MAClB,cAAc,CAAC,GAAG,CAAC;AAAA,MACnB,WAAW,SAAS;AAAA,IACtB,CAAC;AAED,UAAM,yBAAqB,0BAAY,MAAM;AAC3C,UAAI,CAAC,UAAW,iBAAgB,SAAS;AACzC,qBAAe,IAAI;AAAA,IACrB,GAAG,CAAC,WAAW,gBAAgB,iBAAiB,SAAS,CAAC;AAI1D,UAAM,gBAAgB,UAAU,EAAE,MAAM,oDAAoD;AAC5F,WACE,6CAAC,OAAE,WAAW,aAAa,cAAc,SAAS,SAAS,cAAc,aAAa,IAAI,IAAI,CAAC,QAC5F;AAAA,kBAAY,CAAC,YACZ,6CAAC,OACE;AAAA,0BACC,4CAAC,mBACC;AAAA,UAAC;AAAA;AAAA,YACC,UAAU,KAAK;AAAA,YACf,QAAQ,YAAY,CAAC;AAAA,YACrB,gBAAgB,EAAE,GAAG,gBAAgB,QAAQ,MAAM,OAAO,QAAQ;AAAA,YAClE;AAAA,YAEA;AAAA,0DAAC,6CAA4B;AAAA,cAC7B,4CAAC,wCACC,sDAAC,mBAAgB,MAAY,GAC/B;AAAA;AAAA;AAAA,QACF,GACF,IACE;AAAA,QACJ;AAAA,UAAC;AAAA;AAAA,YACC,KAAK,KAAK;AAAA,YACV,IAAI;AAAA,YACJ,aAAY;AAAA,YACZ,QAAQ,SAAS;AAAA,YACjB,IAAI;AAAA,YACJ,IAAI;AAAA,YACJ,IAAI;AAAA,YACJ,iBAAgB;AAAA;AAAA,QAClB;AAAA,SACF,IACE;AAAA,MACJ;AAAA,QAAC;AAAA;AAAA,UACC,aAAa;AAAA,UACb,GACE,cAAc,SAAS,SACnB,YAAY,cAAc,aAAa,IAAI,IAC3C,aAAa,cAAc,QAAQ;AAAA,UAEzC,MAAK;AAAA,UACL,GAAG;AAAA,UACH,OACE,cAAc,SAAS,SACnB,cAAc,aAAa,KAC1B,cAAc,SAAS,MAAM,cAAc,QAAQ;AAAA,UAE1D,QAAQ;AAAA;AAAA,MACV;AAAA,OACF;AAAA,EAEJ;AACF;",
6
6
  "names": ["React"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/graphs/Chart/react-desc-prop-types.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["/* eslint-disable max-lines */\nimport { globalAttributesPropTypes, PropTypes } from '@elliemae/ds-props-helpers';\nimport type { Series, ScaleLinear, ScaleBand } from 'd3';\nimport { type DSPopperJST } from '@elliemae/ds-popperjs';\nimport { type SERIE_TYPES } from '../constants.js';\nexport declare namespace DSChartT {\n export type AxisTypeT = 'log' | 'band' | 'time' | 'linear';\n\n export type LinearScale = ScaleLinear<number, number, never>;\n export type BandScale = ScaleBand<string>;\n export type SeriesTypes = (typeof SERIE_TYPES)[keyof typeof SERIE_TYPES];\n export type Scales = LinearScale | BandScale;\n export interface SeriesT {\n name: string;\n data: Array<number | null | { x: number | string | Date; y: number }>;\n type: SeriesTypes;\n scale?: string;\n color: string;\n // line\n dashStyle?: string;\n pointRadius?: number;\n pointStyle?: string;\n }\n\n export interface ScrapperT {\n type: 'horizontal' | 'vertical';\n color: string;\n tooltipPreference: DSPopperJST.PopperPlacementsT;\n }\n\n export interface SerieComponentT {\n serie: InternalSerie;\n }\n\n export interface LegendT {\n position: 'right' | 'bottom' | 'left' | 'top';\n preventFilterAction?: boolean;\n }\n\n export interface AxisTickT {\n tickValues?: number[] | Date[];\n tickFormat?: ((value: string | number | Date) => string) | string;\n tickCount?: number;\n tickRotation?: number;\n overwriteTicks?: boolean;\n color?: string;\n }\n\n export type IntervalT = 'DAY' | 'WEEK' | 'MONTH' | 'YEAR';\n\n export interface AxisT {\n type: AxisTypeT;\n showGrid?: boolean;\n color?: string;\n label?: string;\n cols?: string[];\n domainPadding?: number | number[];\n intervalType?: IntervalT;\n hideAxis?: boolean;\n beginAtZero?: boolean;\n advanced?: {\n pointSpacing: {\n type: string;\n value: number;\n };\n };\n tick?: AxisTickT;\n plotRange?: number[];\n min?: number | Date;\n max?: number | Date;\n domainPaddingType?: string;\n }\n\n export interface InternalDatum {\n key: string;\n value: number | { x: number; y: number };\n position: number;\n serie: string;\n scale: string;\n color: string;\n }\n\n export interface InternalSerie {\n key: string;\n data: InternalDatum[];\n name: string;\n type: SeriesTypes;\n scale?: string | undefined;\n color: string;\n dashStyle?: string;\n pointRadius?: number;\n pointStyle?: string;\n curveStyle?: string;\n }\n\n export type InternalData = InternalSerie[];\n export interface TooltipRenderDataT {\n data: {\n datum: InternalDatum;\n name: string;\n xValue: string | number | Date | null;\n yValue: string | number | Date | null;\n }[];\n }\n export interface OptionalProps {\n groups?: string[][];\n types?: 'scatter';\n scrapper?: ScrapperT;\n withTrendHighlight?: boolean;\n TooltipRenderer?: React.ComponentType<TooltipRenderDataT>;\n height?: number;\n width?: number;\n legend?: LegendT;\n xScroll?: boolean;\n yScroll?: boolean;\n y2Axis?: AxisT;\n yAxis: AxisT;\n xAxis: AxisT;\n }\n\n export interface DefaultProps {\n series: SeriesT[];\n }\n\n export interface RequiredProps {}\n\n export interface Props extends OptionalProps, DefaultProps, RequiredProps {}\n\n export type StackedSeriesByGroupT = Series<\n {\n [key: string]: number;\n },\n string\n >[][];\n\n export interface ScrapperDatum {\n position: number | undefined;\n name: string;\n xValue: string | number | Date | null;\n yValue: string | number | Date | null;\n key: number;\n datum: DSChartT.InternalDatum;\n }\n}\n\nexport const defaultProps: DSChartT.DefaultProps = {\n series: [\n {\n name: '1',\n data: [0],\n color: 'grey-100',\n type: 'bar',\n },\n ],\n};\n\nexport const propTypes = {\n ...globalAttributesPropTypes,\n height: PropTypes.number.isRequired.description('height').defaultValue(''),\n width: PropTypes.number.isRequired.description('height').defaultValue(''),\n margin: PropTypes.shape({\n top: PropTypes.number,\n bottom: PropTypes.number,\n left: PropTypes.number,\n right: PropTypes.number,\n })\n .isRequired.description('margin')\n .defaultValue(''),\n series: PropTypes.arrayOf(PropTypes.object).description('yValue').defaultValue(''),\n};\n", "import * as React from 'react';\nexport { React };\n"],
4
+ "sourcesContent": ["/* eslint-disable max-lines */\nimport { globalAttributesPropTypes, PropTypes } from '@elliemae/ds-props-helpers';\nimport type { Series, ScaleLinear, ScaleBand } from 'd3';\nimport { type DSHookFloatingContextT } from '@elliemae/ds-floating-context';\nimport { type SERIE_TYPES } from '../constants.js';\nexport declare namespace DSChartT {\n export type AxisTypeT = 'log' | 'band' | 'time' | 'linear';\n\n export type LinearScale = ScaleLinear<number, number, never>;\n export type BandScale = ScaleBand<string>;\n export type SeriesTypes = (typeof SERIE_TYPES)[keyof typeof SERIE_TYPES];\n export type Scales = LinearScale | BandScale;\n export interface SeriesT {\n name: string;\n data: Array<number | null | { x: number | string | Date; y: number }>;\n type: SeriesTypes;\n scale?: string;\n color: string;\n // line\n dashStyle?: string;\n pointRadius?: number;\n pointStyle?: string;\n }\n\n export interface ScrapperT {\n type: 'horizontal' | 'vertical';\n color: string;\n tooltipPreference: DSHookFloatingContextT.PopperPlacementsT;\n }\n\n export interface SerieComponentT {\n serie: InternalSerie;\n }\n\n export interface LegendT {\n position: 'right' | 'bottom' | 'left' | 'top';\n preventFilterAction?: boolean;\n }\n\n export interface AxisTickT {\n tickValues?: number[] | Date[];\n tickFormat?: ((value: string | number | Date) => string) | string;\n tickCount?: number;\n tickRotation?: number;\n overwriteTicks?: boolean;\n color?: string;\n }\n\n export type IntervalT = 'DAY' | 'WEEK' | 'MONTH' | 'YEAR';\n\n export interface AxisT {\n type: AxisTypeT;\n showGrid?: boolean;\n color?: string;\n label?: string;\n cols?: string[];\n domainPadding?: number | number[];\n intervalType?: IntervalT;\n hideAxis?: boolean;\n beginAtZero?: boolean;\n advanced?: {\n pointSpacing: {\n type: string;\n value: number;\n };\n };\n tick?: AxisTickT;\n plotRange?: number[];\n min?: number | Date;\n max?: number | Date;\n domainPaddingType?: string;\n }\n\n export interface InternalDatum {\n key: string;\n value: number | { x: number; y: number };\n position: number;\n serie: string;\n scale: string;\n color: string;\n }\n\n export interface InternalSerie {\n key: string;\n data: InternalDatum[];\n name: string;\n type: SeriesTypes;\n scale?: string | undefined;\n color: string;\n dashStyle?: string;\n pointRadius?: number;\n pointStyle?: string;\n curveStyle?: string;\n }\n\n export type InternalData = InternalSerie[];\n export interface TooltipRenderDataT {\n data: {\n datum: InternalDatum;\n name: string;\n xValue: string | number | Date | null;\n yValue: string | number | Date | null;\n }[];\n }\n export interface OptionalProps {\n groups?: string[][];\n types?: 'scatter';\n scrapper?: ScrapperT;\n withTrendHighlight?: boolean;\n TooltipRenderer?: React.ComponentType<TooltipRenderDataT>;\n height?: number;\n width?: number;\n legend?: LegendT;\n xScroll?: boolean;\n yScroll?: boolean;\n y2Axis?: AxisT;\n yAxis: AxisT;\n xAxis: AxisT;\n }\n\n export interface DefaultProps {\n series: SeriesT[];\n }\n\n export interface RequiredProps {}\n\n export interface Props extends OptionalProps, DefaultProps, RequiredProps {}\n\n export type StackedSeriesByGroupT = Series<\n {\n [key: string]: number;\n },\n string\n >[][];\n\n export interface ScrapperDatum {\n position: number | undefined;\n name: string;\n xValue: string | number | Date | null;\n yValue: string | number | Date | null;\n key: number;\n datum: DSChartT.InternalDatum;\n }\n}\n\nexport const defaultProps: DSChartT.DefaultProps = {\n series: [\n {\n name: '1',\n data: [0],\n color: 'grey-100',\n type: 'bar',\n },\n ],\n};\n\nexport const propTypes = {\n ...globalAttributesPropTypes,\n height: PropTypes.number.isRequired.description('height').defaultValue(''),\n width: PropTypes.number.isRequired.description('height').defaultValue(''),\n margin: PropTypes.shape({\n top: PropTypes.number,\n bottom: PropTypes.number,\n left: PropTypes.number,\n right: PropTypes.number,\n })\n .isRequired.description('margin')\n .defaultValue(''),\n series: PropTypes.arrayOf(PropTypes.object).description('yValue').defaultValue(''),\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,8BAAqD;AAgJ9C,MAAM,eAAsC;AAAA,EACjD,QAAQ;AAAA,IACN;AAAA,MACE,MAAM;AAAA,MACN,MAAM,CAAC,CAAC;AAAA,MACR,OAAO;AAAA,MACP,MAAM;AAAA,IACR;AAAA,EACF;AACF;AAEO,MAAM,YAAY;AAAA,EACvB,GAAG;AAAA,EACH,QAAQ,kCAAU,OAAO,WAAW,YAAY,QAAQ,EAAE,aAAa,EAAE;AAAA,EACzE,OAAO,kCAAU,OAAO,WAAW,YAAY,QAAQ,EAAE,aAAa,EAAE;AAAA,EACxE,QAAQ,kCAAU,MAAM;AAAA,IACtB,KAAK,kCAAU;AAAA,IACf,QAAQ,kCAAU;AAAA,IAClB,MAAM,kCAAU;AAAA,IAChB,OAAO,kCAAU;AAAA,EACnB,CAAC,EACE,WAAW,YAAY,QAAQ,EAC/B,aAAa,EAAE;AAAA,EAClB,QAAQ,kCAAU,QAAQ,kCAAU,MAAM,EAAE,YAAY,QAAQ,EAAE,aAAa,EAAE;AACnF;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import { Grid } from "@elliemae/ds-grid";
4
- import { DSPopperJS } from "@elliemae/ds-popperjs";
4
+ import { useFloatingContext, FloatingWrapper, PopoverArrow } from "@elliemae/ds-floating-context";
5
5
  import {
6
6
  describe,
7
7
  useGetGlobalAttributes,
@@ -16,9 +16,20 @@ import { DSSingleStackedBarName } from "./exported-related/index.js";
16
16
  import { DSSingleStackedBarPropTypes, defaultProps } from "./react-desc-prop-types.js";
17
17
  import { StyledBar, StyledMouseOverDetectionBox, StyledTooltipContainer, Wrapper } from "./styles.js";
18
18
  const Bar = React2.memo((props) => {
19
- const [referenceElement, setReferenceElement] = useState(null);
20
19
  const [isHover, setIsHover] = useState(false);
21
20
  const { height, TooltipRenderer, datum, tabIndex, isFocused, borderRadius, bg } = props;
21
+ const isTooltipOpen = (isFocused || isHover) && !!TooltipRenderer;
22
+ const {
23
+ refs,
24
+ floatingStyles,
25
+ arrowStyles,
26
+ context,
27
+ isOpen: isFloatingOpen
28
+ } = useFloatingContext({
29
+ externallyControlledIsOpen: isTooltipOpen,
30
+ withoutAnimation: true,
31
+ customOffset: [0, 14]
32
+ });
22
33
  const handleRefCallback = useCallback(
23
34
  (_ref) => {
24
35
  if (isFocused) {
@@ -33,20 +44,31 @@ const Bar = React2.memo((props) => {
33
44
  const handleMouseLeave = useCallback(() => {
34
45
  setIsHover(false);
35
46
  }, []);
47
+ const backgroundColor = datum.color in COLOR_PALLET ? COLOR_PALLET[datum.color] : datum.color;
36
48
  return /* @__PURE__ */ jsxs("div", { children: [
37
- (isFocused || isHover) && TooltipRenderer ? /* @__PURE__ */ jsxs(DSPopperJS, { referenceElement, showPopover: true, children: [
38
- /* @__PURE__ */ jsx(StyledMouseOverDetectionBox, {}),
39
- /* @__PURE__ */ jsx(StyledTooltipContainer, { children: /* @__PURE__ */ jsx(TooltipRenderer, { datum }) })
40
- ] }) : null,
49
+ TooltipRenderer && /* @__PURE__ */ jsxs(
50
+ FloatingWrapper,
51
+ {
52
+ innerRef: refs.setFloating,
53
+ isOpen: isFloatingOpen,
54
+ floatingStyles,
55
+ context,
56
+ children: [
57
+ /* @__PURE__ */ jsx(StyledMouseOverDetectionBox, {}),
58
+ /* @__PURE__ */ jsx(StyledTooltipContainer, { children: /* @__PURE__ */ jsx(TooltipRenderer, { datum }) }),
59
+ /* @__PURE__ */ jsx(PopoverArrow, { ...arrowStyles })
60
+ ]
61
+ }
62
+ ),
41
63
  /* @__PURE__ */ jsx(
42
64
  StyledBar,
43
65
  {
44
66
  onMouseEnter: handleMouseEnter,
45
67
  onMouseLeave: handleMouseLeave,
46
- bg,
68
+ bg: backgroundColor,
47
69
  height,
48
70
  borderRadius,
49
- innerRef: mergeRefs(handleRefCallback, setReferenceElement),
71
+ innerRef: mergeRefs(handleRefCallback, refs.setReference),
50
72
  tabIndex,
51
73
  role: "img",
52
74
  "aria-label": `${datum.name} value: ${datum.data}`
@@ -110,21 +132,24 @@ const DSSingleStackedBar = (props) => {
110
132
  onBlur: (e) => e.currentTarget !== e.target && setIsChartFocused(false),
111
133
  ...xstyledProps,
112
134
  ...globalAttributes,
113
- children: data.map((datum, i) => /* @__PURE__ */ jsxs(Grid, { rows, children: [
114
- /* @__PURE__ */ jsx(
115
- Bar,
116
- {
117
- datum,
118
- isFocused: barNames[keyBarFocused] === datum.name && isChartFocused,
119
- borderRadius: getBorderRadius(i),
120
- bg: COLOR_PALLET[datum.color] ?? datum.color,
121
- tabIndex: i === keyBarFocused ? 0 : -1,
122
- ...props
123
- },
124
- datum.name
125
- ),
126
- LegendRenderer !== void 0 ? /* @__PURE__ */ jsx(LegendRenderer, { datum }, `${datum.name}-legend`) : null
127
- ] }))
135
+ children: data.map((datum, i) => {
136
+ const backgroundColor = datum.color in COLOR_PALLET ? COLOR_PALLET[datum.color] : datum.color;
137
+ return /* @__PURE__ */ jsxs(Grid, { rows, children: [
138
+ /* @__PURE__ */ jsx(
139
+ Bar,
140
+ {
141
+ datum,
142
+ isFocused: barNames[keyBarFocused] === datum.name && isChartFocused,
143
+ borderRadius: getBorderRadius(i),
144
+ bg: backgroundColor,
145
+ tabIndex: i === keyBarFocused ? 0 : -1,
146
+ ...props
147
+ },
148
+ datum.name
149
+ ),
150
+ LegendRenderer !== void 0 ? /* @__PURE__ */ jsx(LegendRenderer, { datum }, `${datum.name}-legend`) : null
151
+ ] });
152
+ })
128
153
  }
129
154
  );
130
155
  };