@selectwin/kit 0.1.223 → 0.1.225

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,86 +1,117 @@
1
- import { ChevronDownIcon as e } from "./icons.js";
2
- import { SelectTooltip as t } from "./SelectTooltip.js";
3
- import { useSelectMessages as n } from "./SelectLocale.js";
4
- import { SelectPopover as r } from "./SelectPopover.js";
5
- import { SelectMenu as i, SelectMenuHeading as a, SelectMenuItem as o } from "./SelectMenu.js";
6
- import { Fragment as s, forwardRef as c, useEffect as l, useLayoutEffect as u, useRef as d, useState as f } from "react";
7
- import { jsx as p, jsxs as m } from "react/jsx-runtime";
1
+ import { safeHref as e } from "./internal/safeHref.js";
2
+ import { ChevronDownIcon as t } from "./icons.js";
3
+ import { SelectTooltip as n } from "./SelectTooltip.js";
4
+ import { useSelectMessages as r } from "./SelectLocale.js";
5
+ import { SelectPopover as i } from "./SelectPopover.js";
6
+ import { SelectMenu as a, SelectMenuHeading as o, SelectMenuItem as s } from "./SelectMenu.js";
7
+ import { Fragment as c, forwardRef as l, useEffect as u, useLayoutEffect as d, useRef as f, useState as p } from "react";
8
+ import { jsx as m, jsxs as h } from "react/jsx-runtime";
9
+ import { Link as g } from "react-router-dom";
8
10
  //#region src/SelectSideNav.tsx
9
- function h(e, t) {
11
+ function _({ item: t, className: n, active: r, onSelect: i, tabIndex: a, label: o, children: s }) {
12
+ let c = t.to != null || t.href != null ? e(t.to ?? t.href) : void 0, l = {
13
+ className: n,
14
+ tabIndex: a,
15
+ "data-nav-id": t.id,
16
+ "aria-label": o,
17
+ onClick: () => i(t.id)
18
+ };
19
+ return c !== void 0 && t.to != null ? /* @__PURE__ */ m(g, {
20
+ ...l,
21
+ to: c,
22
+ "aria-current": r ? "page" : void 0,
23
+ children: s
24
+ }) : c === void 0 ? /* @__PURE__ */ m("button", {
25
+ type: "button",
26
+ ...l,
27
+ children: s
28
+ }) : /* @__PURE__ */ m("a", {
29
+ ...l,
30
+ href: c,
31
+ "aria-current": r ? "page" : void 0,
32
+ children: s
33
+ });
34
+ }
35
+ function v(e, t) {
10
36
  var n;
11
- return ((n = e.children) == null ? void 0 : n.some((e) => e.id === t || h(e, t))) ?? !1;
37
+ return ((n = e.children) == null ? void 0 : n.some((e) => e.id === t || v(e, t))) ?? !1;
12
38
  }
13
- function g({ item: t, active: n, onSelect: r }) {
14
- let i = t.alwaysOpen === !0, a = h(t, n), [o, s] = f(a);
15
- l(() => {
39
+ function y({ item: e, active: n, onSelect: r }) {
40
+ let i = e.alwaysOpen === !0, a = v(e, n), [o, s] = p(a);
41
+ u(() => {
16
42
  s(a);
17
43
  }, [a]);
18
- let c = i || o, g = d(null), [y, b] = f(null), [x, S] = f(0);
19
- return u(() => {
44
+ let c = i || o, l = f(null), [g, y] = p(null), [S, C] = p(0);
45
+ return d(() => {
20
46
  var e;
21
- let t = g.current, n = (t == null ? void 0 : t.querySelector(".select-sidenav__item--child.is-active")) ?? null, r = n == null ? void 0 : n.closest(".select-sidenav__subgroup .select-sidenav__collapse[data-open=\"false\"]");
22
- n && r && (n = ((e = r.parentElement) == null ? void 0 : e.querySelector(":scope > .select-sidenav__item")) ?? null), b(n && c ? _(n, t) : null);
47
+ let t = l.current, n = (t == null ? void 0 : t.querySelector(".select-sidenav__item--child.is-active")) ?? null, r = n == null ? void 0 : n.closest(".select-sidenav__subgroup .select-sidenav__collapse[data-open=\"false\"]");
48
+ n && r && (n = ((e = r.parentElement) == null ? void 0 : e.querySelector(":scope > .select-sidenav__item")) ?? null), y(n && c ? b(n, t) : null);
23
49
  }, [
24
50
  n,
25
51
  c,
26
- x
27
- ]), /* @__PURE__ */ m("div", {
52
+ S
53
+ ]), u(() => {
54
+ let e = l.current;
55
+ if (!e || typeof ResizeObserver > "u") return;
56
+ let t = new ResizeObserver(() => C((e) => e + 1));
57
+ return t.observe(e), () => t.disconnect();
58
+ }, []), /* @__PURE__ */ h("div", {
28
59
  className: "select-sidenav__group",
29
- children: [/* @__PURE__ */ m("button", {
60
+ children: [/* @__PURE__ */ h("button", {
30
61
  type: "button",
31
- className: i ? `select-sidenav__item${t.id === n ? " is-active" : ""}` : `select-sidenav__item select-sidenav__item--parent${o ? " is-open" : ""}`,
32
- onClick: () => i ? r(t.id) : s((e) => !e),
33
- "data-nav-id": t.id,
62
+ className: i ? `select-sidenav__item${e.id === n ? " is-active" : ""}` : `select-sidenav__item select-sidenav__item--parent${o ? " is-open" : ""}`,
63
+ onClick: () => i ? r(e.id) : s((e) => !e),
64
+ "data-nav-id": e.id,
34
65
  "aria-expanded": i ? void 0 : o,
35
66
  children: [
36
- t.icon && /* @__PURE__ */ p("span", {
67
+ e.icon && /* @__PURE__ */ m("span", {
37
68
  className: "select-sidenav__icon",
38
- children: t.icon
69
+ children: e.icon
39
70
  }),
40
- /* @__PURE__ */ p("span", {
71
+ /* @__PURE__ */ m("span", {
41
72
  className: "select-sidenav__label",
42
- children: t.label
73
+ children: e.label
43
74
  }),
44
- !i && /* @__PURE__ */ p("span", {
75
+ !i && /* @__PURE__ */ m("span", {
45
76
  className: "select-sidenav__chevron",
46
77
  "aria-hidden": "true",
47
- children: /* @__PURE__ */ p(e, {})
78
+ children: /* @__PURE__ */ m(t, {})
48
79
  })
49
80
  ]
50
- }), /* @__PURE__ */ p("div", {
81
+ }), /* @__PURE__ */ m("div", {
51
82
  className: "select-sidenav__collapse",
52
83
  "data-open": c,
53
84
  "aria-hidden": !c,
54
- children: /* @__PURE__ */ m("div", {
85
+ children: /* @__PURE__ */ h("div", {
55
86
  className: "select-sidenav__children",
56
- ref: g,
87
+ ref: l,
57
88
  onTransitionEnd: (e) => {
58
- e.propertyName === "grid-template-rows" && S((e) => e + 1);
89
+ e.propertyName === "grid-template-rows" && C((e) => e + 1);
59
90
  },
60
- children: [/* @__PURE__ */ p("span", {
91
+ children: [/* @__PURE__ */ m("span", {
61
92
  className: "select-sidenav__rail-active",
62
93
  "aria-hidden": "true",
63
94
  style: {
64
- top: y ?? 0,
65
- opacity: y == null ? 0 : 1
95
+ top: g ?? 0,
96
+ opacity: g == null ? 0 : 1
66
97
  }
67
- }), t.children.map((e) => {
98
+ }), e.children.map((e) => {
68
99
  var t;
69
- return (t = e.children) != null && t.length ? /* @__PURE__ */ p(v, {
100
+ return (t = e.children) != null && t.length ? /* @__PURE__ */ m(x, {
70
101
  item: e,
71
102
  active: n,
72
103
  onSelect: r,
73
104
  tabbable: c
74
- }, e.id) : /* @__PURE__ */ m("button", {
75
- type: "button",
105
+ }, e.id) : /* @__PURE__ */ h(_, {
106
+ item: e,
107
+ active: e.id === n,
108
+ onSelect: r,
76
109
  className: `select-sidenav__item select-sidenav__item--child${e.id === n ? " is-active" : ""}`,
77
- onClick: () => r(e.id),
78
110
  tabIndex: c ? void 0 : -1,
79
- "data-nav-id": e.id,
80
- children: [e.icon && /* @__PURE__ */ p("span", {
111
+ children: [e.icon && /* @__PURE__ */ m("span", {
81
112
  className: "select-sidenav__icon",
82
113
  children: e.icon
83
- }), /* @__PURE__ */ p("span", {
114
+ }), /* @__PURE__ */ m("span", {
84
115
  className: "select-sidenav__label",
85
116
  children: e.label
86
117
  })]
@@ -90,54 +121,54 @@ function g({ item: t, active: n, onSelect: r }) {
90
121
  })]
91
122
  });
92
123
  }
93
- function _(e, t) {
124
+ function b(e, t) {
94
125
  let n = e.getBoundingClientRect(), r = t.getBoundingClientRect();
95
126
  return n.top - r.top + t.scrollTop + n.height / 2;
96
127
  }
97
- function v({ item: t, active: n, onSelect: r, tabbable: i }) {
98
- let a = h(t, n), [o, s] = f(a);
99
- return l(() => {
128
+ function x({ item: e, active: n, onSelect: r, tabbable: i }) {
129
+ let a = v(e, n), [o, s] = p(a);
130
+ return u(() => {
100
131
  a && s(!0);
101
- }, [a]), /* @__PURE__ */ m("div", {
132
+ }, [a]), /* @__PURE__ */ h("div", {
102
133
  className: "select-sidenav__subgroup",
103
- children: [/* @__PURE__ */ m("button", {
134
+ children: [/* @__PURE__ */ h("button", {
104
135
  type: "button",
105
136
  className: `select-sidenav__item select-sidenav__item--child select-sidenav__item--subparent${o ? " is-open" : ""}${a && !o ? " is-active" : ""}`,
106
137
  onClick: () => s((e) => !e),
107
138
  "aria-expanded": o,
108
139
  tabIndex: i ? void 0 : -1,
109
- "data-nav-id": t.id,
140
+ "data-nav-id": e.id,
110
141
  children: [
111
- t.icon && /* @__PURE__ */ p("span", {
142
+ e.icon && /* @__PURE__ */ m("span", {
112
143
  className: "select-sidenav__icon",
113
- children: t.icon
144
+ children: e.icon
114
145
  }),
115
- /* @__PURE__ */ p("span", {
146
+ /* @__PURE__ */ m("span", {
116
147
  className: "select-sidenav__label",
117
- children: t.label
148
+ children: e.label
118
149
  }),
119
- /* @__PURE__ */ p("span", {
150
+ /* @__PURE__ */ m("span", {
120
151
  className: "select-sidenav__chevron",
121
152
  "aria-hidden": "true",
122
- children: /* @__PURE__ */ p(e, {})
153
+ children: /* @__PURE__ */ m(t, {})
123
154
  })
124
155
  ]
125
- }), /* @__PURE__ */ p("div", {
156
+ }), /* @__PURE__ */ m("div", {
126
157
  className: "select-sidenav__collapse",
127
158
  "data-open": o,
128
159
  "aria-hidden": !o,
129
- children: /* @__PURE__ */ p("div", {
160
+ children: /* @__PURE__ */ m("div", {
130
161
  className: "select-sidenav__subchildren",
131
- children: t.children.map((e) => /* @__PURE__ */ m("button", {
132
- type: "button",
162
+ children: e.children.map((e) => /* @__PURE__ */ h(_, {
163
+ item: e,
164
+ active: e.id === n,
165
+ onSelect: r,
133
166
  className: `select-sidenav__item select-sidenav__item--child select-sidenav__item--grandchild${e.id === n ? " is-active" : ""}`,
134
- onClick: () => r(e.id),
135
167
  tabIndex: i && o ? void 0 : -1,
136
- "data-nav-id": e.id,
137
- children: [e.icon && /* @__PURE__ */ p("span", {
168
+ children: [e.icon && /* @__PURE__ */ m("span", {
138
169
  className: "select-sidenav__icon",
139
170
  children: e.icon
140
- }), /* @__PURE__ */ p("span", {
171
+ }), /* @__PURE__ */ m("span", {
141
172
  className: "select-sidenav__label",
142
173
  children: e.label
143
174
  })]
@@ -146,62 +177,62 @@ function v({ item: t, active: n, onSelect: r, tabbable: i }) {
146
177
  })]
147
178
  });
148
179
  }
149
- function y(e) {
180
+ function S(e) {
150
181
  return e.hint ?? (typeof e.label == "string" ? e.label : e.id);
151
182
  }
152
- function b({ item: e, active: c, onSelect: l }) {
183
+ function C({ item: e, active: t, onSelect: l }) {
153
184
  var u;
154
- let [d, g] = f(!1), _ = n().sideNav.pending, v = y(e), b = !!((u = e.children) != null && u.length), x = e.id === c || h(e, c), S = /* @__PURE__ */ m("button", {
185
+ let [d, f] = p(!1), g = r().sideNav.pending, _ = S(e), y = !!((u = e.children) != null && u.length), b = e.id === t || v(e, t), x = /* @__PURE__ */ h("button", {
155
186
  type: "button",
156
- className: `select-sidenav__railitem${x ? " is-active" : ""}${d ? " is-open" : ""}`,
157
- "aria-label": e.indicator ? _(v) : v,
158
- "aria-haspopup": b ? "menu" : void 0,
159
- "aria-expanded": b ? d : void 0,
160
- "aria-current": !b && e.id === c ? "page" : void 0,
187
+ className: `select-sidenav__railitem${b ? " is-active" : ""}${d ? " is-open" : ""}`,
188
+ "aria-label": e.indicator ? g(_) : _,
189
+ "aria-haspopup": y ? "menu" : void 0,
190
+ "aria-expanded": y ? d : void 0,
191
+ "aria-current": !y && e.id === t ? "page" : void 0,
161
192
  "data-nav-id": e.id,
162
- onClick: () => b ? g((e) => !e) : l(e.id),
163
- children: [e.icon ? /* @__PURE__ */ p("span", {
193
+ onClick: () => y ? f((e) => !e) : l(e.id),
194
+ children: [e.icon ? /* @__PURE__ */ m("span", {
164
195
  className: "select-sidenav__icon",
165
196
  children: e.icon
166
- }) : /* @__PURE__ */ p("span", {
197
+ }) : /* @__PURE__ */ m("span", {
167
198
  className: "select-sidenav__railinitial",
168
- children: v.charAt(0)
169
- }), e.indicator ? /* @__PURE__ */ p("span", {
199
+ children: _.charAt(0)
200
+ }), e.indicator ? /* @__PURE__ */ m("span", {
170
201
  className: "select-sidenav__raildot",
171
202
  "aria-hidden": "true"
172
203
  }) : null]
173
204
  });
174
- if (!b) return /* @__PURE__ */ p(t, {
175
- content: v,
205
+ if (!y) return /* @__PURE__ */ m(n, {
206
+ content: _,
176
207
  placement: "right",
177
- children: S
208
+ children: x
178
209
  });
179
210
  let C = (e) => {
180
- g(!1), l(e);
211
+ f(!1), l(e);
181
212
  };
182
- return /* @__PURE__ */ p(r, {
213
+ return /* @__PURE__ */ m(i, {
183
214
  active: d,
184
- onClose: () => g(!1),
185
- activator: S,
215
+ onClose: () => f(!1),
216
+ activator: x,
186
217
  placement: "right",
187
218
  role: "menu",
188
- children: /* @__PURE__ */ m(i, {
219
+ children: /* @__PURE__ */ h(a, {
189
220
  className: "select-sidenav__railmenu",
190
221
  children: [
191
- /* @__PURE__ */ p(a, { children: v }),
192
- e.alwaysOpen ? /* @__PURE__ */ p(o, {
193
- active: e.id === c,
222
+ /* @__PURE__ */ m(o, { children: _ }),
223
+ e.alwaysOpen ? /* @__PURE__ */ m(s, {
224
+ active: e.id === t,
194
225
  onClick: () => C(e.id),
195
226
  children: e.label
196
227
  }) : null,
197
228
  e.children.map((e) => {
198
- var t;
199
- return (t = e.children) != null && t.length ? /* @__PURE__ */ m(s, { children: [/* @__PURE__ */ p(a, { children: y(e) }), e.children.map((e) => /* @__PURE__ */ p(o, {
200
- active: e.id === c,
229
+ var n;
230
+ return (n = e.children) != null && n.length ? /* @__PURE__ */ h(c, { children: [/* @__PURE__ */ m(o, { children: S(e) }), e.children.map((e) => /* @__PURE__ */ m(s, {
231
+ active: e.id === t,
201
232
  onClick: () => C(e.id),
202
233
  children: e.label
203
- }, e.id))] }, e.id) : /* @__PURE__ */ p(o, {
204
- active: e.id === c,
234
+ }, e.id))] }, e.id) : /* @__PURE__ */ m(s, {
235
+ active: e.id === t,
205
236
  onClick: () => C(e.id),
206
237
  children: e.label
207
238
  }, e.id);
@@ -210,46 +241,46 @@ function b({ item: e, active: c, onSelect: l }) {
210
241
  })
211
242
  });
212
243
  }
213
- var x = c(function({ sections: e, active: t, onSelect: n, header: r, collapsed: i = !1, className: a, ...o }, s) {
214
- return i ? /* @__PURE__ */ p("nav", {
244
+ var w = l(function({ sections: e, active: t, onSelect: n, header: r, collapsed: i = !1, className: a, ...o }, s) {
245
+ return i ? /* @__PURE__ */ m("nav", {
215
246
  ref: s,
216
247
  ...o,
217
248
  className: `select-sidenav select-sidenav--rail${a ? " " + a : ""}`,
218
- children: e.map((e, r) => /* @__PURE__ */ p("div", {
249
+ children: e.map((e, r) => /* @__PURE__ */ m("div", {
219
250
  className: "select-sidenav__section",
220
251
  role: "group",
221
252
  "aria-label": e.label,
222
- children: e.items.map((e) => /* @__PURE__ */ p(b, {
253
+ children: e.items.map((e) => /* @__PURE__ */ m(C, {
223
254
  item: e,
224
255
  active: t,
225
256
  onSelect: n
226
257
  }, e.id))
227
258
  }, r))
228
- }) : /* @__PURE__ */ m("nav", {
259
+ }) : /* @__PURE__ */ h("nav", {
229
260
  ref: s,
230
261
  ...o,
231
262
  className: `select-sidenav${a ? " " + a : ""}`,
232
- children: [r && /* @__PURE__ */ p("div", {
263
+ children: [r && /* @__PURE__ */ m("div", {
233
264
  className: "select-sidenav__header",
234
265
  children: r
235
- }), e.map((e, r) => /* @__PURE__ */ m("div", {
266
+ }), e.map((e, r) => /* @__PURE__ */ h("div", {
236
267
  className: "select-sidenav__section",
237
- children: [e.label && /* @__PURE__ */ p("div", {
268
+ children: [e.label && /* @__PURE__ */ m("div", {
238
269
  className: "select-sidenav__sectionlabel",
239
270
  children: e.label
240
- }), e.items.map((e) => e.children ? /* @__PURE__ */ p(g, {
271
+ }), e.items.map((e) => e.children ? /* @__PURE__ */ m(y, {
241
272
  item: e,
242
273
  active: t,
243
274
  onSelect: n
244
- }, e.id) : /* @__PURE__ */ m("button", {
245
- type: "button",
275
+ }, e.id) : /* @__PURE__ */ h(_, {
276
+ item: e,
277
+ active: e.id === t,
278
+ onSelect: n,
246
279
  className: `select-sidenav__item${e.id === t ? " is-active" : ""}`,
247
- onClick: () => n(e.id),
248
- "data-nav-id": e.id,
249
- children: [e.icon && /* @__PURE__ */ p("span", {
280
+ children: [e.icon && /* @__PURE__ */ m("span", {
250
281
  className: "select-sidenav__icon",
251
282
  children: e.icon
252
- }), /* @__PURE__ */ p("span", {
283
+ }), /* @__PURE__ */ m("span", {
253
284
  className: "select-sidenav__label",
254
285
  children: e.label
255
286
  })]
@@ -258,6 +289,6 @@ var x = c(function({ sections: e, active: t, onSelect: n, header: r, collapsed:
258
289
  });
259
290
  });
260
291
  //#endregion
261
- export { x as SelectSideNav };
292
+ export { w as SelectSideNav };
262
293
 
263
294
  //# sourceMappingURL=SelectSideNav.js.map
package/dist/index.d.ts CHANGED
@@ -71,7 +71,7 @@ export { SelectTabs } from './SelectTabs';
71
71
  export { SelectSideNav } from './SelectSideNav';
72
72
  export { SelectSearchInput } from './SelectSearchInput';
73
73
  export { SelectTable, SelectTableRow, SelectTableCell, SelectTableEmpty, SelectUserCell } from './SelectTable';
74
- export { SelectMenu, SelectMenuItem, SelectMenuLink, SelectMenuHeading, SelectMenuDivider, SelectMenuButton } from './SelectMenu';
74
+ export { SelectMenu, SelectMenuItem, SelectMenuLink, SelectMenuHeading, SelectMenuHeader, SelectMenuRow, SelectMenuDivider, SelectMenuButton, } from './SelectMenu';
75
75
  export { SelectFilterChip } from './SelectFilterChip';
76
76
  export { SelectCopyRow } from './SelectCopyRow';
77
77
  export type { SelectCopyRowProps } from './SelectCopyRow';