@iress-oss/ids-components 6.0.0-alpha.34 → 6.0.0-alpha.35

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.
@@ -1,11 +1,11 @@
1
- import { jsx as t, jsxs as m, Fragment as q } from "react/jsx-runtime";
1
+ import { jsx as t, jsxs as v, Fragment as q } from "react/jsx-runtime";
2
2
  import { C as z } from "../../floating-ui.react-B0nDXRN6.js";
3
3
  import { propagateTestid as H } from "../../helpers/utility/propagateTestid.js";
4
4
  import { TabSetProvider as R, TabSetContext as O } from "./TabSetProvider.js";
5
- import { useState as n, useRef as W, useEffect as u, useContext as $ } from "react";
6
- import { s as v } from "../../factory-CcYfm2kB.js";
5
+ import { useState as d, useRef as W, useEffect as h, useContext as $ } from "react";
6
+ import { s as p } from "../../factory-CcYfm2kB.js";
7
7
  import { tabSet as k } from "./TabSet.styles.js";
8
- import { c as p } from "../../cx-DN21T1EH.js";
8
+ import { c as u } from "../../cx-DN21T1EH.js";
9
9
  import { GlobalCSSClass as A } from "../../enums.js";
10
10
  const F = (r) => {
11
11
  const a = W({}), s = $(O);
@@ -23,22 +23,23 @@ const F = (r) => {
23
23
  ...a.current,
24
24
  opacity: 0
25
25
  };
26
- return u(() => {
26
+ return h(() => {
27
27
  s?.hover && (a.current = e);
28
28
  }, [s?.hover, e]), /* @__PURE__ */ t("div", { ...r, style: e });
29
29
  }, G = (r) => {
30
- const [a, s] = n({}), e = $(O);
31
- return u(() => {
32
- const i = setTimeout(() => {
33
- if (e?.active) {
34
- const { offsetLeft: l, scrollWidth: d } = e.active;
30
+ const [a, s] = d({}), e = $(O);
31
+ return h(() => {
32
+ const i = e?.active, l = setTimeout(() => {
33
+ if (i) {
34
+ const { offsetLeft: f, scrollWidth: n } = i;
35
35
  s({
36
- left: `${l}px`,
37
- width: `${d}px`
36
+ left: `${f}px`,
37
+ width: `${n}px`
38
38
  });
39
- }
39
+ } else
40
+ s({});
40
41
  }, 150);
41
- return () => clearTimeout(i);
42
+ return () => clearTimeout(l);
42
43
  }, [e?.active, e?.layoutVersion]), /* @__PURE__ */ t("div", { ...r, style: a });
43
44
  }, P = ({
44
45
  children: r,
@@ -47,22 +48,22 @@ const F = (r) => {
47
48
  layout: e = "top-left",
48
49
  onChange: i,
49
50
  panelStyle: l,
50
- selected: d,
51
- tabHolderStyle: h,
51
+ selected: f,
52
+ tabHolderStyle: n,
52
53
  type: w,
53
54
  ...S
54
55
  }) => {
55
- const [g, j] = n(null), [b, N] = n(!1), [x, E] = n(!1), f = W(null), o = k({ layout: e, overflowStart: b, overflowEnd: x, type: w });
56
- return u(() => {
56
+ const [g, j] = d(null), [b, N] = d(!1), [x, E] = d(!1), m = W(null), o = k({ layout: e, overflowStart: b, overflowEnd: x, type: w });
57
+ return h(() => {
57
58
  const c = () => {
58
- const y = f.current?.querySelector('[role="tablist"]');
59
+ const y = m.current?.querySelector('[role="tablist"]');
59
60
  if (y) {
60
61
  const { scrollWidth: I, clientWidth: L, scrollLeft: C } = y;
61
62
  I > L ? (N(C > 1), E(C < I - L - 1)) : (N(!1), E(!1));
62
63
  }
63
64
  };
64
65
  c();
65
- const T = f.current?.querySelector('[role="tablist"]');
66
+ const T = m.current?.querySelector('[role="tablist"]');
66
67
  return T?.addEventListener("scroll", c), window.addEventListener("resize", c), () => {
67
68
  T?.removeEventListener("scroll", c), window.removeEventListener("resize", c);
68
69
  };
@@ -72,24 +73,24 @@ const F = (r) => {
72
73
  defaultSelected: s,
73
74
  onChange: i,
74
75
  panel: g,
75
- selected: d,
76
+ selected: f,
76
77
  type: w,
77
78
  children: /* @__PURE__ */ t(
78
- v.div,
79
+ p.div,
79
80
  {
80
- className: p(a, o.root, A.TabSet),
81
+ className: u(a, o.root, A.TabSet),
81
82
  ...S,
82
- children: r && /* @__PURE__ */ m(q, { children: [
83
- /* @__PURE__ */ m(
84
- v.div,
83
+ children: r && /* @__PURE__ */ v(q, { children: [
84
+ /* @__PURE__ */ v(
85
+ p.div,
85
86
  {
86
- ...h,
87
- ref: f,
88
- className: p(o.listHolder, h?.className),
87
+ ...n,
88
+ ref: m,
89
+ className: u(o.listHolder, n?.className),
89
90
  children: [
90
91
  b && /* @__PURE__ */ t("div", { className: o.overflowStartIndicator }),
91
92
  x && /* @__PURE__ */ t("div", { className: o.overflowEndIndicator }),
92
- /* @__PURE__ */ m(
93
+ /* @__PURE__ */ v(
93
94
  z,
94
95
  {
95
96
  render: /* @__PURE__ */ t("div", { className: o.list, role: "tablist" }),
@@ -105,10 +106,10 @@ const F = (r) => {
105
106
  }
106
107
  ),
107
108
  /* @__PURE__ */ t(
108
- v.div,
109
+ p.div,
109
110
  {
110
111
  ...l,
111
- className: p(o.panel, l?.className),
112
+ className: u(o.panel, l?.className),
112
113
  "data-testid": l?.["data-testid"] ?? H(S["data-testid"], "panel"),
113
114
  ref: j
114
115
  }
@@ -9,17 +9,11 @@ export declare const tabSet: import('../../styled-system/types').SlotRecipeRunti
9
9
  list: {
10
10
  justifyContent: "center";
11
11
  };
12
- activeIndicator: {
13
- left: "[50%]";
14
- };
15
12
  };
16
13
  'top-right': {
17
14
  list: {
18
15
  justifyContent: "flex-end";
19
16
  };
20
- activeIndicator: {
21
- left: "[100%]";
22
- };
23
17
  };
24
18
  };
25
19
  overflowEnd: {
@@ -102,17 +102,11 @@ const e = t({
102
102
  "top-center": {
103
103
  list: {
104
104
  justifyContent: "center"
105
- },
106
- activeIndicator: {
107
- left: "[50%]"
108
105
  }
109
106
  },
110
107
  "top-right": {
111
108
  list: {
112
109
  justifyContent: "flex-end"
113
- },
114
- activeIndicator: {
115
- left: "[100%]"
116
110
  }
117
111
  }
118
112
  },
@@ -1,91 +1,101 @@
1
- import { jsx as y } from "react/jsx-runtime";
2
- import { createContext as H, useState as d, useMemo as T, useCallback as h, useEffect as j } from "react";
3
- import { useControlledState as k } from "../../hooks/useControlledState.js";
4
- const z = H(
1
+ import { jsx as j } from "react/jsx-runtime";
2
+ import { createContext as k, useState as l, useMemo as T, useCallback as h, useEffect as z } from "react";
3
+ import { useControlledState as A } from "../../hooks/useControlledState.js";
4
+ const E = k(
5
5
  void 0
6
- ), A = ({
6
+ ), H = ({
7
7
  children: C,
8
- defaultSelected: I,
9
- onChange: f,
10
- panel: v,
11
- selected: N,
12
- type: w
8
+ defaultSelected: N,
9
+ onChange: x,
10
+ panel: m,
11
+ selected: P,
12
+ type: v
13
13
  }) => {
14
- const [S, O] = d(), [r, m] = d(() => /* @__PURE__ */ new Set()), [n, x] = d(
14
+ const [S, V] = l(), [o, b] = l(() => /* @__PURE__ */ new Set()), [n, f] = l(
15
15
  () => /* @__PURE__ */ new Map()
16
- ), [b, p] = d(0), { value: i, setValue: u } = k({
16
+ ), [p, M] = l(0), { value: c, setValue: d } = A({
17
17
  component: "IressTabSet",
18
- defaultValue: I,
18
+ defaultValue: N,
19
19
  propName: "selected",
20
- value: N
21
- }), l = T(
22
- () => [...r].find(
23
- (e, t) => n.has(t) && n.get(t) === i || t === i
20
+ value: P
21
+ }), w = T(
22
+ () => [...o].find(
23
+ (t, e) => n.has(e) && n.get(e) === c || e === c
24
24
  ),
25
- [r, i, n]
26
- ), V = h(
27
- (e, t) => {
28
- m((s) => {
29
- let a = new Set(s);
30
- s.has(e) || (a = new Set(s).add(e), p((c) => c + 1));
31
- const o = [...a].indexOf(e);
32
- return t !== void 0 && x((c) => {
33
- const M = new Map(c);
34
- return M.set(o, t), M;
25
+ [o, c, n]
26
+ ), g = h(
27
+ (t, e) => {
28
+ b((s) => {
29
+ if (s.has(t)) {
30
+ if (e !== void 0) {
31
+ const r = [...s].indexOf(t);
32
+ f((u) => {
33
+ const O = new Map(u);
34
+ return O.set(r, e), O;
35
+ });
36
+ }
37
+ return s;
38
+ }
39
+ const a = new Set(s).add(t), i = [...a].indexOf(t);
40
+ return e !== void 0 && f((r) => {
41
+ const u = new Map(r);
42
+ return u.set(i, e), u;
35
43
  }), a;
36
- });
44
+ }), M((s) => s + 1);
37
45
  },
38
46
  []
39
- ), g = h((e) => {
40
- m((t) => {
41
- const s = new Set(t), a = [...s].indexOf(e);
42
- return s.delete(e), p((o) => o + 1), x((o) => {
43
- if (!o.has(a)) return o;
44
- const c = new Map(o);
45
- return c.delete(a), c;
47
+ ), I = h((t) => {
48
+ b((e) => {
49
+ const s = new Set(e), a = [...s].indexOf(t);
50
+ return s.delete(t), f((i) => {
51
+ if (!i.has(a)) return i;
52
+ const r = new Map(i);
53
+ return r.delete(a), r;
46
54
  }), s;
47
- });
55
+ }), M((e) => e + 1), V(
56
+ (e) => e === t ? void 0 : e
57
+ );
48
58
  }, []);
49
- j(() => {
50
- i === void 0 && r.size && u(n.get(0) ?? 0);
51
- }, [r, i, u, n]);
52
- const P = T(
59
+ z(() => {
60
+ c === void 0 && o.size && d(n.get(0) ?? 0);
61
+ }, [o, c, d, n]);
62
+ const y = T(
53
63
  () => ({
54
- active: l,
55
- activate(e) {
56
- if (!e) return;
57
- const t = [...r].indexOf(e), s = n.get(t);
58
- f?.({ index: t, value: s }), u(s ?? t);
64
+ active: w,
65
+ activate(t) {
66
+ if (!t) return;
67
+ const e = [...o].indexOf(t), s = n.get(e);
68
+ x?.({ index: e, value: s }), d(s ?? e);
59
69
  },
60
- isActive: (e) => e ? l === e : !1,
70
+ isActive: (t) => t ? w === t : !1,
61
71
  hover: S,
62
- layoutVersion: b,
63
- panel: v,
64
- register: V,
65
- setHover: (e) => {
66
- O(e);
72
+ layoutVersion: p,
73
+ panel: m,
74
+ register: g,
75
+ setHover: (t) => {
76
+ V(t);
67
77
  },
68
- unregister: g,
69
- type: w
78
+ unregister: I,
79
+ type: v
70
80
  }),
71
81
  [
72
- l,
82
+ w,
73
83
  S,
74
- b,
75
- v,
76
- V,
84
+ p,
85
+ m,
77
86
  g,
78
- w,
79
- r,
87
+ I,
88
+ v,
89
+ o,
80
90
  n,
81
- f,
82
- u
91
+ x,
92
+ d
83
93
  ]
84
94
  );
85
- return /* @__PURE__ */ y(z.Provider, { value: P, children: C });
95
+ return /* @__PURE__ */ j(E.Provider, { value: y, children: C });
86
96
  };
87
- A.displayName = "TabSetProvider";
97
+ H.displayName = "TabSetProvider";
88
98
  export {
89
- z as TabSetContext,
90
- A as TabSetProvider
99
+ E as TabSetContext,
100
+ H as TabSetProvider
91
101
  };