@db-ux/react-core-components 4.11.0 → 4.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @db-ux/react-core-components
2
2
 
3
+ ## 4.11.1
4
+
5
+ ### Patch Changes
6
+
7
+ - fix: remove `readonly` attribute on `DBInput` and `DBTextarea` when `readOnly`/`readonly` is `false` - [see commit 312ad4c](https://github.com/db-ux-design-system/core-web/commit/312ad4c7582b7315042b23a7cc8b485889ba6fd8):
8
+
9
+ - Passing `readOnly={false}` (e.g. via Angular's `formField` directive) previously rendered `readonly="false"` into the DOM. Since `readonly` is a boolean HTML attribute, its mere presence made the field read-only. The binding now resolves to `undefined` when not read-only, so the attribute is omitted entirely.
10
+
11
+ - fix(tooltip): clean up parent listeners and observers on unmount - [see commit b050660](https://github.com/db-ux-design-system/core-web/commit/b050660b3b8cc9f0fde2a9d96dfbd6c0f02cc24f)
12
+
3
13
  ## 4.11.0
4
14
 
5
15
  ### Minor Changes
@@ -138,7 +138,7 @@ function E(y, E) {
138
138
  minLength: c(y.minLength, y.minlength),
139
139
  max: s(y.max, y.type),
140
140
  min: s(y.min, y.type),
141
- readOnly: i(y.readOnly, "readOnly") || i(y.readonly, "readonly"),
141
+ readOnly: i(y.readOnly, "readOnly") || i(y.readonly, "readonly") || void 0,
142
142
  form: y.form,
143
143
  pattern: y.pattern,
144
144
  size: y.size,
@@ -118,7 +118,7 @@ function x(m, x) {
118
118
  "data-hide-resizer": a(m.showResizer ?? !0),
119
119
  disabled: i(m.disabled, "disabled"),
120
120
  required: i(m.required, "required"),
121
- readOnly: i(m.readOnly, "readOnly") || i(m.readonly, "readonly"),
121
+ readOnly: i(m.readOnly, "readOnly") || i(m.readonly, "readonly") || void 0,
122
122
  form: m.form,
123
123
  maxLength: o(m.maxLength, m.maxlength),
124
124
  minLength: o(m.minLength, m.minlength),
@@ -16,5 +16,14 @@ export type DBTooltipDefaultProps = {
16
16
  export type DBTooltipProps = DBTooltipDefaultProps & GlobalProps & EmphasisProps & PlacementProps & PopoverProps & WrapProps & TextProps;
17
17
  export type DBTooltipDefaultState = {
18
18
  getParent: () => HTMLElement;
19
+ _attachedParent?: HTMLElement;
20
+ _attachedId?: string;
21
+ _activeTriggerCount?: number;
22
+ _boundListeners?: {
23
+ parent: HTMLElement;
24
+ type: string;
25
+ fn: (event: any) => void;
26
+ }[];
27
+ _detachListeners: () => void;
19
28
  };
20
29
  export type DBTooltipState = DBTooltipDefaultState & GlobalState & ClickEventState<HTMLElement> & PopoverState & InitializedState & DocumentScrollState & ResetIdState;
@@ -8,55 +8,96 @@ import { forwardRef as c, useEffect as l, useId as u, useRef as d, useState as f
8
8
  import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
9
9
  //#region src/components/tooltip/tooltip.tsx
10
10
  function g(c, g) {
11
- let _ = u(), v = g || d(g), [y, b] = f(() => a), [x, S] = f(() => !1), [C, w] = f(() => void 0), [T, E] = f(() => void 0);
12
- function D(e) {
11
+ let _ = u(), v = g || d(g), [y, b] = f(() => a), [x, S] = f(() => !1), [C, w] = f(() => void 0), [T, E] = f(() => void 0), [D, O] = f(() => void 0), [k, A] = f(() => void 0), [j, M] = f(() => 0), [N, P] = f(() => []);
12
+ function F(e) {
13
13
  e.stopPropagation();
14
14
  }
15
- function O(e) {
16
- (!e || e.key === "Escape") && v.current && getComputedStyle(v.current).visibility === "visible" && k().blur();
15
+ function I(e) {
16
+ (!e || e.key === "Escape") && v.current && getComputedStyle(v.current).visibility === "visible" && L().blur();
17
17
  }
18
- function k() {
18
+ function L() {
19
19
  let e = v.current.parentElement;
20
20
  return e && e.localName.includes("tooltip") && (e = e.parentElement), e;
21
21
  }
22
- function A(e) {
22
+ function R(e) {
23
23
  e && v.current && r(() => {
24
24
  v.current && s(v.current, e, c.placement ?? "bottom");
25
25
  }, 1);
26
26
  }
27
- function j(e, t) {
28
- e?.target?.contains && e?.target?.contains(v.current) && A(t);
27
+ function z(e, t) {
28
+ e?.target?.contains && e?.target?.contains(v.current) && R(t);
29
29
  }
30
- function M() {
31
- C && new o().removeCallback(C), T?.unobserve(k());
30
+ function B() {
31
+ M(Math.max((j ?? 0) - 1, 0)), !((j ?? 0) > 0) && (C && (new o().removeCallback(C), w(void 0)), T?.unobserve(L()));
32
32
  }
33
- function N(e) {
34
- w(new o().addCallback((t) => j(t, e))), A(e), T?.observe(k());
33
+ function V(e) {
34
+ M((j ?? 0) + 1), j === 1 && (w(new o().addCallback((t) => z(t, e))), T?.observe(L())), R(e);
35
35
  }
36
- function P() {
36
+ function H() {
37
37
  b(c.id ?? c.propOverrides?.id ?? "tooltip-" + _);
38
38
  }
39
+ function U() {
40
+ let e = C;
41
+ e && (new o().removeCallback(e), w(void 0)), T?.disconnect(), E(void 0), M(0), (N ?? []).forEach((e) => {
42
+ e.parent.removeEventListener(e.type, e.fn);
43
+ }), P([]);
44
+ let t = D;
45
+ if (t) {
46
+ let e = k ?? y, n = t.querySelectorAll(".db-tooltip"), r = Array.from(n).some((e) => e !== v.current);
47
+ t.dataset.hasTooltip === "true" && !r && delete t.dataset.hasTooltip, t.getAttribute("aria-labelledby") === e && t.removeAttribute("aria-labelledby"), t.getAttribute("aria-describedby") === e && t.removeAttribute("aria-describedby"), O(void 0), A(void 0);
48
+ }
49
+ }
39
50
  return l(() => {
40
- P(), S(!0);
51
+ H(), S(!0);
41
52
  }, []), l(() => {
42
- (c.id ?? c.propOverrides?.id) && P();
53
+ (c.id ?? c.propOverrides?.id) && H();
43
54
  }, [c.id, c.propOverrides?.id]), l(() => {
44
55
  if (v.current && x && y) {
45
- let e = k();
46
- e && (A(e), ["mouseenter", "focusin"].forEach((t) => {
47
- e.addEventListener(t, () => N(e));
48
- }), e.addEventListener("keydown", (e) => O(e)), ["mouseleave", "focusout"].forEach((t) => {
49
- e.addEventListener(t, () => M());
50
- }), e.dataset.hasTooltip = "true", c.variant === "label" ? e.setAttribute("aria-labelledby", y) : e.setAttribute("aria-describedby", y)), typeof window < "u" && "IntersectionObserver" in window && E(new IntersectionObserver((e) => {
51
- let t = e.find(({ target: e }) => e === k());
52
- t && !t.isIntersecting && O(!1);
56
+ let e = L();
57
+ if (e) {
58
+ R(e);
59
+ let t = () => V(e), n = () => B(), r = (e) => I(e);
60
+ e.addEventListener("mouseenter", t), e.addEventListener("focusin", t), e.addEventListener("keydown", r), e.addEventListener("mouseleave", n), e.addEventListener("focusout", n), P([
61
+ ...N ?? [],
62
+ {
63
+ parent: e,
64
+ type: "mouseenter",
65
+ fn: t
66
+ },
67
+ {
68
+ parent: e,
69
+ type: "focusin",
70
+ fn: t
71
+ },
72
+ {
73
+ parent: e,
74
+ type: "keydown",
75
+ fn: r
76
+ },
77
+ {
78
+ parent: e,
79
+ type: "mouseleave",
80
+ fn: n
81
+ },
82
+ {
83
+ parent: e,
84
+ type: "focusout",
85
+ fn: n
86
+ }
87
+ ]), e.dataset.hasTooltip = "true", c.variant === "label" ? e.setAttribute("aria-labelledby", y) : e.setAttribute("aria-describedby", y), O(e), A(y);
88
+ }
89
+ typeof window < "u" && "IntersectionObserver" in window && E(new IntersectionObserver((e) => {
90
+ let t = e.find(({ target: e }) => e === L());
91
+ t && !t.isIntersecting && I(!1);
53
92
  })), S(!1);
54
93
  }
55
94
  }, [
56
95
  v.current,
57
96
  x,
58
97
  y
59
- ]), /* @__PURE__ */ h("i", {
98
+ ]), l(() => () => {
99
+ U();
100
+ }, []), /* @__PURE__ */ h("i", {
60
101
  role: "tooltip",
61
102
  "aria-hidden": "true",
62
103
  "data-gap": "true",
@@ -112,7 +153,7 @@ function g(c, g) {
112
153
  "data-width": c.width,
113
154
  "data-show-arrow": i(c.showArrow ?? !0, "showArrow"),
114
155
  "data-placement": c.placement,
115
- onClick: (e) => D(e),
156
+ onClick: (e) => F(e),
116
157
  children: [c.text ? /* @__PURE__ */ m(p, { children: c.text }) : null, c.children]
117
158
  });
118
159
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@db-ux/react-core-components",
3
- "version": "4.11.0",
3
+ "version": "4.11.1",
4
4
  "type": "module",
5
5
  "description": "React components for @db-ux/core-components",
6
6
  "repository": {
@@ -17,15 +17,15 @@
17
17
  "dist/"
18
18
  ],
19
19
  "dependencies": {
20
- "@db-ux/core-components": "4.11.0",
21
- "@db-ux/core-foundations": "4.11.0"
20
+ "@db-ux/core-components": "4.11.1",
21
+ "@db-ux/core-foundations": "4.11.1"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@playwright/experimental-ct-react": "1.60.0",
25
25
  "@types/react": "19.2.17",
26
26
  "@vitejs/plugin-react": "6.0.2",
27
27
  "cpr": "3.0.1",
28
- "npm-run-all2": "9.0.1",
28
+ "npm-run-all2": "9.0.2",
29
29
  "playwright": "1.60.0",
30
30
  "react": "19.2.7",
31
31
  "react-dom": "19.2.7",