cetec-design-system 1.3.1 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3017,6 +3017,7 @@ const tooltip = /* @__PURE__ */ Object.assign(tooltipFn, {
3017
3017
  });
3018
3018
  const DS_CHAIN_SEPARATOR = ">";
3019
3019
  const DS_CHAIN_MAX_DEPTH = 5;
3020
+ const DS_OBJECT_ATTRIBUTE = "data-track-object";
3020
3021
  const EMPTY_CHAIN = Object.freeze([]);
3021
3022
  const DsChainContext = createContext(EMPTY_CHAIN);
3022
3023
  const useDsChain = () => useContext(DsChainContext);
@@ -3026,6 +3027,10 @@ const extendDsChain = (chain, testId) => {
3026
3027
  return next.length > DS_CHAIN_MAX_DEPTH ? next.slice(-DS_CHAIN_MAX_DEPTH) : next;
3027
3028
  };
3028
3029
  const dsChainValue = (chain) => chain.length > 0 ? chain.join(DS_CHAIN_SEPARATOR) : void 0;
3030
+ const dsObjectValue = (element) => {
3031
+ var _a;
3032
+ return ((_a = element == null ? void 0 : element.closest(`[${DS_OBJECT_ATTRIBUTE}]`)) == null ? void 0 : _a.getAttribute(DS_OBJECT_ATTRIBUTE)) || void 0;
3033
+ };
3029
3034
  const DsChainScope = ({ testId, children }) => {
3030
3035
  const parentChain = useDsChain();
3031
3036
  const chain = useMemo(
@@ -15317,16 +15322,28 @@ const useOverlayFloating = (options) => {
15317
15322
  middleware: middleware ?? createOverlayMiddleware({ offset: offset2, shiftPadding })
15318
15323
  });
15319
15324
  };
15320
- const DsChainPortalRoot = ({ children }) => {
15325
+ const DsChainPortalRoot = ({
15326
+ children,
15327
+ reference
15328
+ }) => {
15321
15329
  const chain = useDsChain();
15322
15330
  return (
15323
- // The marker is unconditional; the chain value is not. An empty chain emits
15324
- // no `data-ds-chain`, so without the marker an untagged portal is
15331
+ // The marker is unconditional; neither value is. An empty chain emits no
15332
+ // `data-ds-chain`, so without the marker an untagged portal is
15325
15333
  // indistinguishable from an ordinary element and a consumer walking up the
15326
15334
  // DOM continues past it into `document.body` — producing a chain from
15327
15335
  // whatever it finds there, with no error. The marker makes "portal
15328
- // boundary, chain resolved to nothing" a state a reader can detect.
15329
- /* @__PURE__ */ jsx("div", { "data-ds-portal-root": "", "data-ds-chain": dsChainValue(chain), children })
15336
+ // boundary, resolved to nothing" a state a reader can detect, and it is
15337
+ // what tells that reader to stop and take both values from here.
15338
+ /* @__PURE__ */ jsx(
15339
+ "div",
15340
+ {
15341
+ "data-ds-portal-root": "",
15342
+ "data-ds-chain": dsChainValue(chain),
15343
+ "data-track-object": dsObjectValue(reference),
15344
+ children
15345
+ }
15346
+ )
15330
15347
  );
15331
15348
  };
15332
15349
  const Tooltip = (props) => {
@@ -15344,7 +15361,7 @@ const Tooltip = (props) => {
15344
15361
  const [className, otherProps] = splitProps(rest);
15345
15362
  const [isOpen, setIsOpen] = useState(false);
15346
15363
  const arrowRef = useRef(null);
15347
- const { refs, floatingStyles, context: context2 } = useOverlayFloating({
15364
+ const { refs, elements, floatingStyles, context: context2 } = useOverlayFloating({
15348
15365
  open: isOpen,
15349
15366
  onOpenChange: setIsOpen,
15350
15367
  placement,
@@ -15377,7 +15394,7 @@ const Tooltip = (props) => {
15377
15394
  children
15378
15395
  }
15379
15396
  ),
15380
- isOpen && /* @__PURE__ */ jsx(FloatingPortal, { children: /* @__PURE__ */ jsx(DsChainPortalRoot, { children: /* @__PURE__ */ jsxs(
15397
+ isOpen && /* @__PURE__ */ jsx(FloatingPortal, { children: /* @__PURE__ */ jsx(DsChainPortalRoot, { reference: elements.domReference, children: /* @__PURE__ */ jsxs(
15381
15398
  Box,
15382
15399
  {
15383
15400
  ...dsComponent("Tooltip"),
@@ -18281,7 +18298,7 @@ const Menu = (props) => {
18281
18298
  onKeyDown: composedTriggerOnKeyDown
18282
18299
  }
18283
18300
  ),
18284
- isOpen && /* @__PURE__ */ jsx(FloatingPortal, { children: /* @__PURE__ */ jsx(DsChainPortalRoot, { children: /* @__PURE__ */ jsx(
18301
+ isOpen && /* @__PURE__ */ jsx(FloatingPortal, { children: /* @__PURE__ */ jsx(DsChainPortalRoot, { reference: floating.elements.domReference, children: /* @__PURE__ */ jsx(
18285
18302
  FloatingFocusManager,
18286
18303
  {
18287
18304
  context: floating.context,
@@ -19095,7 +19112,7 @@ const SubMenu = (props) => {
19095
19112
  ]
19096
19113
  }
19097
19114
  ),
19098
- open && /* @__PURE__ */ jsx(FloatingPortal, { children: /* @__PURE__ */ jsx(DsChainPortalRoot, { children: /* @__PURE__ */ jsx(
19115
+ open && /* @__PURE__ */ jsx(FloatingPortal, { children: /* @__PURE__ */ jsx(DsChainPortalRoot, { reference: floating.elements.domReference, children: /* @__PURE__ */ jsx(
19099
19116
  FloatingFocusManager,
19100
19117
  {
19101
19118
  context: floating.context,
@@ -22104,7 +22121,7 @@ const Autocomplete = (props) => {
22104
22121
  children: announcement
22105
22122
  }
22106
22123
  ),
22107
- isOpen && !disabled && !readOnly && /* @__PURE__ */ jsx(FloatingPortal, { children: /* @__PURE__ */ jsx(DsChainPortalRoot, { children: /* @__PURE__ */ jsx(
22124
+ isOpen && !disabled && !readOnly && /* @__PURE__ */ jsx(FloatingPortal, { children: /* @__PURE__ */ jsx(DsChainPortalRoot, { reference: floating.elements.domReference, children: /* @__PURE__ */ jsx(
22108
22125
  FloatingFocusManager,
22109
22126
  {
22110
22127
  context: floating.context,
@@ -22457,7 +22474,7 @@ const Select = (props) => {
22457
22474
  children: /* @__PURE__ */ jsx(Icon, { name: "caret-down" })
22458
22475
  }
22459
22476
  ),
22460
- isOpen && !disabled && /* @__PURE__ */ jsx(FloatingPortal, { children: /* @__PURE__ */ jsx(DsChainPortalRoot, { children: /* @__PURE__ */ jsx(
22477
+ isOpen && !disabled && /* @__PURE__ */ jsx(FloatingPortal, { children: /* @__PURE__ */ jsx(DsChainPortalRoot, { reference: floating.elements.domReference, children: /* @__PURE__ */ jsx(
22461
22478
  FloatingFocusManager,
22462
22479
  {
22463
22480
  context: floating.context,