@sylwellsoftware/fray 0.1.0-alpha.1 → 0.3.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.
Files changed (75) hide show
  1. package/README.md +324 -21
  2. package/colors/README.md +15 -0
  3. package/colors/gray/colors.css +29 -0
  4. package/colors/green/colors.css +29 -0
  5. package/colors/iceblue/colors.css +29 -0
  6. package/colors/ocean/colors.css +29 -0
  7. package/colors/orange/colors.css +29 -0
  8. package/colors/purple/colors.css +29 -0
  9. package/colors/red/colors.css +29 -0
  10. package/colors/yellow/colors.css +29 -0
  11. package/dist/Components/Placeholder.d.ts +1 -1
  12. package/dist/Components/Placeholder.d.ts.map +1 -1
  13. package/dist/Components/controlUtils.d.ts.map +1 -1
  14. package/dist/Components/data/filterState.d.ts +38 -0
  15. package/dist/Components/data/filterState.d.ts.map +1 -0
  16. package/dist/Components/data/listview/listview.d.ts +16 -5
  17. package/dist/Components/data/listview/listview.d.ts.map +1 -1
  18. package/dist/Components/data/selectionhandler.d.ts +24 -5
  19. package/dist/Components/data/selectionhandler.d.ts.map +1 -1
  20. package/dist/Components/data/table/DataTable.d.ts +36 -30
  21. package/dist/Components/data/table/DataTable.d.ts.map +1 -1
  22. package/dist/Components/data/table/FilterPanel.d.ts +8 -1
  23. package/dist/Components/data/table/FilterPanel.d.ts.map +1 -1
  24. package/dist/Components/data/table/TableHeaderCell.d.ts.map +1 -1
  25. package/dist/Components/data/table/tableDataSource.d.ts +49 -0
  26. package/dist/Components/data/table/tableDataSource.d.ts.map +1 -0
  27. package/dist/Components/data/table/tableQuery.d.ts +6 -2
  28. package/dist/Components/data/table/tableQuery.d.ts.map +1 -1
  29. package/dist/Components/data/treeview/treeModel.d.ts +23 -0
  30. package/dist/Components/data/treeview/treeModel.d.ts.map +1 -0
  31. package/dist/Components/data/treeview/treeview.d.ts +1 -1
  32. package/dist/Components/data/treeview/treeview.d.ts.map +1 -1
  33. package/dist/Components/dialog/dialog.d.ts +1 -1
  34. package/dist/Components/dialog/dialog.d.ts.map +1 -1
  35. package/dist/Components/layout/panel.d.ts.map +1 -1
  36. package/dist/Components/layout/tabpanel/tabline.d.ts.map +1 -1
  37. package/dist/Components/lineinputs/checkbox/Checkbox.d.ts +1 -1
  38. package/dist/Components/lineinputs/checkbox/Checkbox.d.ts.map +1 -1
  39. package/dist/Components/lineinputs/checkbox/QuadCheckbox.d.ts +2 -2
  40. package/dist/Components/lineinputs/checkbox/QuadCheckbox.d.ts.map +1 -1
  41. package/dist/Components/lineinputs/checkbox/TriCheckbox.d.ts +2 -2
  42. package/dist/Components/lineinputs/checkbox/TriCheckbox.d.ts.map +1 -1
  43. package/dist/Components/lineinputs/toggle.d.ts.map +1 -1
  44. package/dist/Components/status/progressBar.d.ts.map +1 -1
  45. package/dist/Components/theme/stylesheetPicker.d.ts +40 -0
  46. package/dist/Components/theme/stylesheetPicker.d.ts.map +1 -0
  47. package/dist/index.d.ts +16 -0
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +2807 -559
  50. package/dist/index.js.map +1 -1
  51. package/dist/{jsx-dev-runtime-CarwHDyL.js → jsx-dev-runtime-DukiDpV9.js} +202 -214
  52. package/dist/jsx-dev-runtime-DukiDpV9.js.map +1 -0
  53. package/dist/jsx-dev-runtime.js +1 -1
  54. package/dist/jsx-runtime.js +1 -1
  55. package/dist/styling/baseStyleDefinitions.d.ts +3 -0
  56. package/dist/styling/baseStyleDefinitions.d.ts.map +1 -1
  57. package/dist/styling/styleRegistry.d.ts.map +1 -1
  58. package/dist/styling/theme.d.ts +27 -0
  59. package/dist/styling/theme.d.ts.map +1 -0
  60. package/dist/util/filterMode.d.ts +6 -4
  61. package/dist/util/filterMode.d.ts.map +1 -1
  62. package/package.json +14 -11
  63. package/styles/structural.css +922 -0
  64. package/themes/README.md +84 -30
  65. package/themes/java/theme.css +140 -0
  66. package/themes/minimal/theme.css +128 -0
  67. package/themes/shiny/theme.css +314 -0
  68. package/EXPERIMENTAL.md +0 -75
  69. package/dist/button-BRDkmR1C.js +0 -203
  70. package/dist/button-BRDkmR1C.js.map +0 -1
  71. package/dist/experimental.d.ts +0 -16
  72. package/dist/experimental.d.ts.map +0 -1
  73. package/dist/experimental.js +0 -1361
  74. package/dist/experimental.js.map +0 -1
  75. package/dist/jsx-dev-runtime-CarwHDyL.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,163 +1,207 @@
1
- var nt = Object.defineProperty;
2
- var st = (n, s, t) => s in n ? nt(n, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[s] = t;
3
- var a = (n, s, t) => st(n, typeof s != "symbol" ? s + "" : s, t);
4
- import { C as p, j as c, c as m, a as g, i as K } from "./jsx-dev-runtime-CarwHDyL.js";
5
- import { F as vt, b as yt, S as wt, d as Et, e as xt, f as It, h as Nt, g as St, l as Ht, s as Tt } from "./jsx-dev-runtime-CarwHDyL.js";
6
- import { a as T, i as H, c as b, b as x, C as Z, F as v, d as B } from "./button-BRDkmR1C.js";
7
- import { B as Rt } from "./button-BRDkmR1C.js";
8
- import { Emitter as ot } from "@sylwellsoftware/glue";
9
- class Q extends p {
1
+ var Ye = Object.defineProperty;
2
+ var _e = (t, r, e) => r in t ? Ye(t, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[r] = e;
3
+ var s = (t, r, e) => _e(t, typeof r != "symbol" ? r + "" : r, e);
4
+ import { C as g, j as u, c as v, a as w, i as ie } from "./jsx-dev-runtime-DukiDpV9.js";
5
+ import { F as pr, b as mr, S as br, d as yr, e as gr, f as wr, h as Er, g as vr, l as Sr, s as kr } from "./jsx-dev-runtime-DukiDpV9.js";
6
+ import { Emitter as I, DerivedEmitter as le, FetchState as k, QueryArg as ke, LiveQuery as Xe, RestQueryHandler as Ze } from "@sylwellsoftware/glue";
7
+ class ze extends g {
10
8
  render() {
11
9
  return this.props.children ?? [];
12
10
  }
13
11
  }
14
- class I extends p {
15
- constructor(t = {}) {
16
- var e;
17
- super(t);
18
- a(this, "valueEmitter");
19
- a(this, "activeTabEmitter");
20
- const r = t.tabs ?? [];
21
- M(r);
22
- const i = { ...t };
23
- i.valueEmitter == null && t.activeTabEmitter != null && (i.valueEmitter = t.activeTabEmitter), i.defaultValue == null && t.initialActiveTabId != null && (i.defaultValue = t.initialActiveTabId), this.valueEmitter = T(
12
+ const y = {
13
+ /** Deny mode: Excludes items that match the filter. */
14
+ Deny: "deny",
15
+ /** Require mode: Includes only items that match the filter. */
16
+ Require: "require",
17
+ /** Prefer mode: If there are any filter options that are set to Prefer, at least one of the preferred filter options must match. Otherwise, it is treated as Neutral. */
18
+ Prefer: "prefer",
19
+ /** Neutral mode: Does not affect the inclusion or exclusion of items. */
20
+ Neutral: "neutral"
21
+ };
22
+ function de(t) {
23
+ return Object.values(y).some((r) => r === t);
24
+ }
25
+ let et = 1;
26
+ function j(t, r) {
27
+ return r != null && String(r).length > 0 ? String(r) : `fray-${t}-${et++}`;
28
+ }
29
+ function M(t, r, e, a) {
30
+ if (r.valueEmitter != null)
31
+ return tt(r.valueEmitter, "valueEmitter"), r.valueEmitter;
32
+ const i = r.defaultValue ?? r.value ?? r.initialValue ?? e, n = { owner: t, purpose: a };
33
+ return new I(i, n);
34
+ }
35
+ function tt(t, r = "emitter") {
36
+ if (t == null || typeof t != "object" && typeof t != "function" || typeof Reflect.get(t, "get") != "function" || typeof Reflect.get(t, "set") != "function" || typeof Reflect.get(t, "subscribe") != "function")
37
+ throw new TypeError(`${r} must be an emitter`);
38
+ }
39
+ function E(t) {
40
+ return t.className ?? t.class ?? "";
41
+ }
42
+ function C(t, ...r) {
43
+ if (t != null) {
44
+ if (typeof t != "function") throw new TypeError("Control callback must be a function");
45
+ t(...r);
46
+ }
47
+ }
48
+ function fe(t, r = "options") {
49
+ if (!Array.isArray(t)) throw new TypeError(`${r} must be an array`);
50
+ }
51
+ function rt(t) {
52
+ return de(t) ? t : String(t);
53
+ }
54
+ class L extends g {
55
+ constructor(e = {}) {
56
+ var n;
57
+ super(e);
58
+ s(this, "valueEmitter");
59
+ s(this, "activeTabEmitter");
60
+ const a = e.tabs ?? [];
61
+ Ie(a);
62
+ const i = { ...e };
63
+ i.valueEmitter == null && e.activeTabEmitter != null && (i.valueEmitter = e.activeTabEmitter), i.defaultValue == null && e.initialActiveTabId != null && (i.defaultValue = e.initialActiveTabId), this.valueEmitter = M(
24
64
  this,
25
65
  i,
26
- ((e = r.find((l) => !l.disabled)) == null ? void 0 : e.id) ?? null,
66
+ ((n = a.find((o) => !o.disabled)) == null ? void 0 : n.id) ?? null,
27
67
  "active tab"
28
68
  ), this.activeTabEmitter = this.valueEmitter;
29
69
  }
30
70
  initialize() {
31
71
  this.watch(this.valueEmitter);
32
72
  }
33
- selectTab(t, r = null) {
34
- t == null || t.disabled || (this.valueEmitter.set(t.id, "tab selected"), H(this.props.onChange, t.id, r));
73
+ selectTab(e, a = null) {
74
+ e == null || e.disabled || (this.valueEmitter.set(e.id, "tab selected"), C(this.props.onChange, e.id, a));
35
75
  }
36
76
  render() {
37
- const { tabs: t = [], label: r = "Sections", baseId: i = "fray-tabs" } = this.props;
38
- M(t);
39
- const e = this.valueEmitter.get(), l = this.Host;
40
- return /* @__PURE__ */ c(
41
- l,
77
+ const { tabs: e = [], label: a = "Sections", baseId: i = "fray-tabs" } = this.props;
78
+ Ie(e);
79
+ const n = this.valueEmitter.get(), o = this.Host;
80
+ return /* @__PURE__ */ u(
81
+ o,
42
82
  {
43
83
  role: "tablist",
44
- className: b(this.props) || null,
45
- "aria-label": r,
46
- children: t.map((o, d) => /* @__PURE__ */ c(
84
+ className: E(this.props) || null,
85
+ "aria-label": a,
86
+ children: e.map((l, d) => /* @__PURE__ */ u(
47
87
  "button",
48
88
  {
49
- id: _(i, o.id),
89
+ id: qe(i, l.id),
50
90
  type: "button",
51
91
  role: "tab",
52
- disabled: !!o.disabled,
92
+ disabled: !!l.disabled,
53
93
  "data-part": "tab",
54
- "aria-selected": Object.is(e, o.id) ? "true" : "false",
55
- "aria-controls": tt(i, o.id),
56
- tabIndex: Object.is(e, o.id) ? 0 : -1,
57
- onClick: (u) => this.selectTab(o, u),
58
- onKeyDown: (u) => this.handleKeyDown(u, d, t),
59
- children: o.label ?? String(o.id)
94
+ "aria-selected": Object.is(n, l.id) ? "true" : "false",
95
+ "aria-controls": Le(i, l.id),
96
+ tabIndex: Object.is(n, l.id) ? 0 : -1,
97
+ onClick: (h) => this.selectTab(l, h),
98
+ onKeyDown: (h) => this.handleKeyDown(h, d, e),
99
+ children: l.label ?? String(l.id)
60
100
  },
61
- String(o.id)
101
+ String(l.id)
62
102
  ))
63
103
  }
64
104
  );
65
105
  }
66
- handleKeyDown(t, r, i) {
67
- const e = i.map((d, u) => ({ tab: d, tabIndex: u })).filter(({ tab: d }) => !d.disabled);
68
- if (e.length === 0) return;
69
- const l = Math.max(
106
+ handleKeyDown(e, a, i) {
107
+ const n = i.map((d, h) => ({ tab: d, tabIndex: h })).filter(({ tab: d }) => !d.disabled);
108
+ if (n.length === 0) return;
109
+ const o = Math.max(
70
110
  0,
71
- e.findIndex(({ tabIndex: d }) => d === r)
111
+ n.findIndex(({ tabIndex: d }) => d === a)
72
112
  );
73
- let o;
74
- if (t.key === "ArrowRight" || t.key === "ArrowDown")
75
- o = e[(l + 1) % e.length];
76
- else if (t.key === "ArrowLeft" || t.key === "ArrowUp")
77
- o = e[(l - 1 + e.length) % e.length];
78
- else if (t.key === "Home") o = e[0];
79
- else if (t.key === "End") o = e.at(-1);
113
+ let l;
114
+ if (e.key === "ArrowRight" || e.key === "ArrowDown")
115
+ l = n[(o + 1) % n.length];
116
+ else if (e.key === "ArrowLeft" || e.key === "ArrowUp")
117
+ l = n[(o - 1 + n.length) % n.length];
118
+ else if (e.key === "Home") l = n[0];
119
+ else if (e.key === "End") l = n.at(-1);
80
120
  else return;
81
- if (o != null && (t.preventDefault(), this.selectTab(o.tab, t), this.dom instanceof Element)) {
82
- const d = this.dom.querySelectorAll('[role="tab"]')[o.tabIndex];
121
+ if (l != null && (e.preventDefault(), this.selectTab(l.tab, e), this.dom instanceof Element)) {
122
+ const d = this.dom.querySelectorAll('[role="tab"]')[l.tabIndex];
83
123
  d == null || d.focus();
84
124
  }
85
125
  }
86
126
  }
87
- a(I, "hostName", "tab-line"), a(I, "standaloneHostName", "tab-line"), a(I, "baseStyles", [
127
+ s(L, "hostName", "tab-line"), s(L, "standaloneHostName", "tab-line"), s(L, "baseStyles", [
88
128
  ['& > [data-part="tab"]', ["uiline", "button"]]
89
- ]), a(I, "css", m`
129
+ ]), s(L, "css", v`
90
130
  & {
91
131
  display: flex;
92
132
  flex-flow: row wrap;
93
133
  padding-top: 3px;
94
- background: var(--tabline-bg, #f5f5f5);
134
+ background: var(--fray-tabline-background, var(--tabline-bg));
95
135
  }
96
136
 
97
137
  & > [data-part="tab"] {
98
- border-radius: var(--ui-border-radius) var(--ui-border-radius) 0 0;
138
+ background: var(--fray-tab-button-background, var(--fray-button-background));
139
+ border-radius: var(--fray-radius-md, var(--ui-border-radius)) var(--fray-radius-md, var(--ui-border-radius)) 0 0;
99
140
  }
100
141
 
101
142
  & > [data-part="tab"][aria-selected="true"] {
102
- background: var(--tab-bg-active, var(--panel-bg, #fff));
143
+ background: var(
144
+ --fray-tab-button-background-active,
145
+ var(--fray-tab-active-background, var(--tab-bg-active))
146
+ );
103
147
  }
104
148
  `);
105
- function _(n, s) {
106
- return `${n}-tab-${et(s)}`;
149
+ function qe(t, r) {
150
+ return `${t}-tab-${Ve(r)}`;
107
151
  }
108
- function tt(n, s) {
109
- return `${n}-panel-${et(s)}`;
152
+ function Le(t, r) {
153
+ return `${t}-panel-${Ve(r)}`;
110
154
  }
111
- function et(n) {
112
- return encodeURIComponent(String(n)).replaceAll("%", "-");
155
+ function Ve(t) {
156
+ return encodeURIComponent(String(t)).replaceAll("%", "-");
113
157
  }
114
- function M(n) {
115
- if (!Array.isArray(n)) throw new TypeError("TabLine tabs must be an array");
116
- const s = /* @__PURE__ */ new Set();
117
- for (const t of n) {
118
- if (t == null || t.id == null) throw new TypeError("Each tab requires an id");
119
- if (s.has(t.id)) throw new Error(`Duplicate tab id: ${String(t.id)}`);
120
- s.add(t.id);
158
+ function Ie(t) {
159
+ if (!Array.isArray(t)) throw new TypeError("TabLine tabs must be an array");
160
+ const r = /* @__PURE__ */ new Set();
161
+ for (const e of t) {
162
+ if (e == null || e.id == null) throw new TypeError("Each tab requires an id");
163
+ if (r.has(e.id)) throw new Error(`Duplicate tab id: ${String(e.id)}`);
164
+ r.add(e.id);
121
165
  }
122
166
  }
123
- class z extends p {
124
- constructor(t = {}) {
125
- var e;
126
- super(t);
127
- a(this, "valueEmitter");
128
- a(this, "activeTabEmitter");
129
- a(this, "baseId");
130
- const r = O(t), i = { ...t };
131
- i.valueEmitter == null && t.activeTabEmitter != null && (i.valueEmitter = t.activeTabEmitter), i.defaultValue == null && t.initialActiveTabId != null && (i.defaultValue = t.initialActiveTabId), this.valueEmitter = T(
167
+ class J extends g {
168
+ constructor(e = {}) {
169
+ var n;
170
+ super(e);
171
+ s(this, "valueEmitter");
172
+ s(this, "activeTabEmitter");
173
+ s(this, "baseId");
174
+ const a = Y(e), i = { ...e };
175
+ i.valueEmitter == null && e.activeTabEmitter != null && (i.valueEmitter = e.activeTabEmitter), i.defaultValue == null && e.initialActiveTabId != null && (i.defaultValue = e.initialActiveTabId), this.valueEmitter = M(
132
176
  this,
133
177
  i,
134
- ((e = r.find((l) => !l.disabled)) == null ? void 0 : e.id) ?? null,
178
+ ((n = a.find((o) => !o.disabled)) == null ? void 0 : n.id) ?? null,
135
179
  "active tab"
136
- ), this.activeTabEmitter = this.valueEmitter, this.baseId = x("tabs", t.id);
180
+ ), this.activeTabEmitter = this.valueEmitter, this.baseId = j("tabs", e.id);
137
181
  }
138
182
  initialize() {
139
- var r;
140
- const t = O(this.props);
141
- t.some(({ id: i }) => Object.is(i, this.valueEmitter.get())) || this.valueEmitter.set(((r = t.find((i) => !i.disabled)) == null ? void 0 : r.id) ?? null), this.watch(this.valueEmitter);
183
+ var a;
184
+ const e = Y(this.props);
185
+ e.some(({ id: i }) => Object.is(i, this.valueEmitter.get())) || this.valueEmitter.set(((a = e.find((i) => !i.disabled)) == null ? void 0 : a.id) ?? null), this.watch(this.valueEmitter);
142
186
  }
143
- setProps(t) {
187
+ setProps(e) {
144
188
  var i;
145
- super.setProps(t);
146
- const r = O(t);
147
- return r.some(({ id: e }) => Object.is(e, this.valueEmitter.get())) || this.valueEmitter.set(((i = r.find((e) => !e.disabled)) == null ? void 0 : i.id) ?? null), this;
189
+ super.setProps(e);
190
+ const a = Y(e);
191
+ return a.some(({ id: n }) => Object.is(n, this.valueEmitter.get())) || this.valueEmitter.set(((i = a.find((n) => !n.disabled)) == null ? void 0 : i.id) ?? null), this;
148
192
  }
149
193
  render() {
150
- const t = O(this.props), r = t.find(({ id: e }) => Object.is(e, this.valueEmitter.get())) ?? t.find((e) => !e.disabled) ?? null, i = this.Host;
151
- return /* @__PURE__ */ g(
194
+ const e = Y(this.props), a = e.find(({ id: n }) => Object.is(n, this.valueEmitter.get())) ?? e.find((n) => !n.disabled) ?? null, i = this.Host;
195
+ return /* @__PURE__ */ w(
152
196
  i,
153
197
  {
154
198
  id: this.baseId,
155
- className: b(this.props) || null,
199
+ className: E(this.props) || null,
156
200
  children: [
157
- /* @__PURE__ */ c(
158
- I,
201
+ /* @__PURE__ */ u(
202
+ L,
159
203
  {
160
- tabs: t.map(({ id: e, label: l, disabled: o }) => ({ id: e, label: l, disabled: o })),
204
+ tabs: e.map(({ id: n, label: o, disabled: l }) => ({ id: n, label: o, disabled: l })),
161
205
  valueEmitter: this.valueEmitter,
162
206
  baseId: this.baseId,
163
207
  ...this.props.label == null ? {} : { label: this.props.label },
@@ -165,33 +209,33 @@ class z extends p {
165
209
  },
166
210
  "tab-list"
167
211
  ),
168
- r == null ? null : /* @__PURE__ */ c(
212
+ a == null ? null : /* @__PURE__ */ u(
169
213
  "div",
170
214
  {
171
- id: tt(this.baseId, r.id),
215
+ id: Le(this.baseId, a.id),
172
216
  role: "tabpanel",
173
217
  "data-part": "content",
174
- "aria-labelledby": _(this.baseId, r.id),
218
+ "aria-labelledby": qe(this.baseId, a.id),
175
219
  tabIndex: 0,
176
- children: r.content
220
+ children: a.content
177
221
  },
178
- String(r.id)
222
+ String(a.id)
179
223
  )
180
224
  ]
181
225
  }
182
226
  );
183
227
  }
184
228
  }
185
- a(z, "dependencies", [I, Q]), a(z, "hostName", "tab-panel"), a(z, "standaloneHostName", "tab-panel"), a(z, "css", m`
229
+ s(J, "dependencies", [L, ze]), s(J, "hostName", "tab-panel"), s(J, "standaloneHostName", "tab-panel"), s(J, "css", v`
186
230
  & {
187
231
  display: flex;
188
232
  flex-direction: column;
189
233
  width: 100%;
190
234
  min-height: 0;
191
235
  overflow: hidden;
192
- background: var(--panel-bg, white);
193
- border-radius: var(--panel-radius, var(--ui-border-radius));
194
- box-shadow: var(--panel-shadow, none);
236
+ background: var(--fray-panel-background, var(--panel-bg, transparent));
237
+ border-radius: var(--fray-panel-radius, var(--panel-radius));
238
+ box-shadow: var(--fray-panel-shadow, var(--panel-shadow, none));
195
239
  }
196
240
 
197
241
  & > [data-part="content"] {
@@ -199,75 +243,75 @@ a(z, "dependencies", [I, Q]), a(z, "hostName", "tab-panel"), a(z, "standaloneHos
199
243
  flex-direction: column;
200
244
  flex: 1;
201
245
  overflow: auto;
202
- background: var(--panel-bg, white);
246
+ background: var(--fray-panel-background, var(--panel-bg, transparent));
203
247
  }
204
248
  `);
205
- function O(n) {
206
- const s = n.tabs ?? [];
207
- if (!Array.isArray(s)) throw new TypeError("TabPanel tabs must be an array");
208
- const r = (Array.isArray(n.children) ? n.children : n.children == null ? [] : [n.children]).filter((l) => K(l) && l.type === Q).map((l, o) => {
209
- if (!K(l)) throw new TypeError("TabPanel children must be Tab nodes");
210
- const d = l.props;
249
+ function Y(t) {
250
+ const r = t.tabs ?? [];
251
+ if (!Array.isArray(r)) throw new TypeError("TabPanel tabs must be an array");
252
+ const a = (Array.isArray(t.children) ? t.children : t.children == null ? [] : [t.children]).filter((o) => ie(o) && o.type === ze).map((o, l) => {
253
+ if (!ie(o)) throw new TypeError("TabPanel children must be Tab nodes");
254
+ const d = o.props;
211
255
  return {
212
- id: d.id ?? `tab-${o + 1}`,
213
- label: d.label ?? `Tab ${o + 1}`,
256
+ id: d.id ?? `tab-${l + 1}`,
257
+ label: d.label ?? `Tab ${l + 1}`,
214
258
  disabled: !!d.disabled,
215
259
  content: d.children ?? []
216
260
  };
217
- }), i = s.length > 0 ? s.map((l) => ({
218
- ...l,
219
- label: l.label ?? String(l.id),
220
- disabled: !!l.disabled,
221
- content: l.content ?? l.component ?? []
222
- })) : r, e = /* @__PURE__ */ new Set();
223
- for (const l of i) {
224
- if ((l == null ? void 0 : l.id) == null) throw new TypeError("Each tab requires an id");
225
- if (e.has(l.id)) throw new Error(`Duplicate tab id: ${String(l.id)}`);
226
- e.add(l.id);
261
+ }), i = r.length > 0 ? r.map((o) => ({
262
+ ...o,
263
+ label: o.label ?? String(o.id),
264
+ disabled: !!o.disabled,
265
+ content: o.content ?? o.component ?? []
266
+ })) : a, n = /* @__PURE__ */ new Set();
267
+ for (const o of i) {
268
+ if ((o == null ? void 0 : o.id) == null) throw new TypeError("Each tab requires an id");
269
+ if (n.has(o.id)) throw new Error(`Duplicate tab id: ${String(o.id)}`);
270
+ n.add(o.id);
227
271
  }
228
272
  return i;
229
273
  }
230
- class $ extends p {
231
- constructor(t = {}) {
232
- super(t);
233
- a(this, "panelId");
234
- a(this, "headerId");
235
- this.panelId = x("panel", t.id), this.headerId = `${this.panelId}-title`;
274
+ class _ extends g {
275
+ constructor(e = {}) {
276
+ super(e);
277
+ s(this, "panelId");
278
+ s(this, "headerId");
279
+ this.panelId = j("panel", e.id), this.headerId = `${this.panelId}-title`;
236
280
  }
237
281
  render() {
238
282
  const {
239
- header: t = null,
240
- toolbar: r = null,
283
+ header: e = null,
284
+ toolbar: a = null,
241
285
  children: i = [],
242
- orientation: e = "vertical",
243
- disabled: l = !1
286
+ orientation: n = "vertical",
287
+ disabled: o = !1
244
288
  } = this.props;
245
- if (!["horizontal", "vertical"].includes(e))
289
+ if (!["horizontal", "vertical"].includes(n))
246
290
  throw new TypeError("Panel orientation must be horizontal or vertical");
247
- const o = this.Host, d = t == null ? null : /* @__PURE__ */ c("header", { "data-part": "header", children: typeof t == "string" || typeof t == "number" ? /* @__PURE__ */ c("h2", { id: this.headerId, children: t }) : /* @__PURE__ */ c("div", { id: this.headerId, children: t }) });
248
- return /* @__PURE__ */ g(
249
- o,
291
+ const l = this.Host, d = e == null ? null : /* @__PURE__ */ u("header", { "data-part": "header", children: typeof e == "string" || typeof e == "number" ? /* @__PURE__ */ u("h2", { id: this.headerId, children: e }) : /* @__PURE__ */ u("div", { id: this.headerId, children: e }) });
292
+ return /* @__PURE__ */ w(
293
+ l,
250
294
  {
251
295
  id: this.panelId,
252
- role: t == null ? null : "region",
253
- className: b(this.props) || null,
254
- "data-orientation": e,
255
- "data-disabled": l ? "" : null,
256
- "aria-disabled": l ? "true" : null,
257
- "aria-labelledby": t == null ? null : this.headerId,
296
+ role: e == null ? null : "region",
297
+ className: E(this.props) || null,
298
+ "data-orientation": n,
299
+ "data-disabled": o ? "" : null,
300
+ "aria-disabled": o ? "true" : null,
301
+ "aria-labelledby": e == null ? null : this.headerId,
258
302
  children: [
259
303
  d,
260
- r,
261
- /* @__PURE__ */ c("div", { "data-part": "content", "data-orientation": e, children: i })
304
+ a,
305
+ /* @__PURE__ */ u("div", { "data-part": "content", "data-orientation": n, children: i })
262
306
  ]
263
307
  }
264
308
  );
265
309
  }
266
310
  }
267
- a($, "hostName", "panel"), a($, "standaloneHostName", "layout-panel"), a($, "baseStyles", [
311
+ s(_, "hostName", "panel"), s(_, "standaloneHostName", "layout-panel"), s(_, "baseStyles", [
268
312
  ["&", ["panel"]],
269
313
  ['& > [data-part="header"]', ["sectionheader"]]
270
- ]), a($, "css", m`
314
+ ]), s(_, "css", v`
271
315
  & {
272
316
  display: flex;
273
317
  flex-direction: column;
@@ -280,6 +324,19 @@ a($, "hostName", "panel"), a($, "standaloneHostName", "layout-panel"), a($, "bas
280
324
  font: inherit;
281
325
  }
282
326
 
327
+ & > [data-part="header"] {
328
+ background: var(
329
+ --fray-panel-header-background,
330
+ var(--fray-section-header-background, var(--fray-header-background))
331
+ );
332
+ color: var(
333
+ --fray-panel-header-color,
334
+ var(--fray-section-header-color, var(--fray-header-color))
335
+ );
336
+ border: var(--fray-section-header-border, var(--fray-header-border));
337
+ box-shadow: var(--fray-section-header-shadow, var(--fray-header-shadow));
338
+ }
339
+
283
340
  & > [data-part="content"] {
284
341
  display: flex;
285
342
  flex: 1;
@@ -296,41 +353,41 @@ a($, "hostName", "panel"), a($, "standaloneHostName", "layout-panel"), a($, "bas
296
353
  flex-direction: column;
297
354
  }
298
355
  `);
299
- class P extends p {
300
- constructor(t = {}) {
301
- super(t);
302
- a(this, "sidebarId");
303
- a(this, "headerId");
304
- this.sidebarId = x("sidebar", t.id), this.headerId = `${this.sidebarId}-title`;
356
+ class xe extends g {
357
+ constructor(e = {}) {
358
+ super(e);
359
+ s(this, "sidebarId");
360
+ s(this, "headerId");
361
+ this.sidebarId = j("sidebar", e.id), this.headerId = `${this.sidebarId}-title`;
305
362
  }
306
363
  render() {
307
364
  const {
308
- header: t = null,
309
- toolbar: r = null,
365
+ header: e = null,
366
+ toolbar: a = null,
310
367
  ariaLabel: i,
311
- children: e = []
312
- } = this.props, l = t == null ? null : /* @__PURE__ */ c("header", { "data-part": "header", children: typeof t == "string" || typeof t == "number" ? /* @__PURE__ */ c("h2", { id: this.headerId, children: t }) : /* @__PURE__ */ c("div", { id: this.headerId, children: t }) });
313
- return /* @__PURE__ */ g(
368
+ children: n = []
369
+ } = this.props, o = e == null ? null : /* @__PURE__ */ u("header", { "data-part": "header", children: typeof e == "string" || typeof e == "number" ? /* @__PURE__ */ u("h2", { id: this.headerId, children: e }) : /* @__PURE__ */ u("div", { id: this.headerId, children: e }) });
370
+ return /* @__PURE__ */ w(
314
371
  "aside",
315
372
  {
316
373
  id: this.sidebarId,
317
- className: b(this.props) || void 0,
374
+ className: E(this.props) || void 0,
318
375
  "data-fray-component": "sidebar",
319
- "aria-label": t == null ? i : null,
320
- "aria-labelledby": t == null ? null : this.headerId,
376
+ "aria-label": e == null ? i : null,
377
+ "aria-labelledby": e == null ? null : this.headerId,
321
378
  children: [
322
- l,
323
- r == null ? null : /* @__PURE__ */ c("div", { "data-part": "toolbar", children: r }),
324
- /* @__PURE__ */ c("div", { "data-part": "content", tabIndex: 0, children: e })
379
+ o,
380
+ a == null ? null : /* @__PURE__ */ u("div", { "data-part": "toolbar", children: a }),
381
+ /* @__PURE__ */ u("div", { "data-part": "content", tabIndex: 0, children: n })
325
382
  ]
326
383
  }
327
384
  );
328
385
  }
329
386
  }
330
- a(P, "baseStyles", [
387
+ s(xe, "baseStyles", [
331
388
  ['aside[data-fray-component="sidebar"]', ["panel"]],
332
389
  ['aside[data-fray-component="sidebar"] > [data-part="header"]', ["sectionheader"]]
333
- ]), a(P, "css", m`
390
+ ]), s(xe, "css", v`
334
391
  aside[data-fray-component="sidebar"] {
335
392
  display: flex;
336
393
  flex-direction: column;
@@ -357,44 +414,44 @@ a(P, "baseStyles", [
357
414
  overflow-y: auto;
358
415
  }
359
416
  `);
360
- class F extends p {
417
+ class ce extends g {
361
418
  render() {
362
419
  const {
363
- primary: s = null,
364
- secondary: t = null,
365
- direction: r = "horizontal",
420
+ primary: r = null,
421
+ secondary: e = null,
422
+ direction: a = "horizontal",
366
423
  primarySize: i,
367
- primaryLabel: e,
368
- secondaryLabel: l
424
+ primaryLabel: n,
425
+ secondaryLabel: o
369
426
  } = this.props;
370
- if (r !== "horizontal" && r !== "vertical")
427
+ if (a !== "horizontal" && a !== "vertical")
371
428
  throw new TypeError("SplitView direction must be horizontal or vertical");
372
429
  if (i != null && (typeof i != "string" || i.length === 0))
373
430
  throw new TypeError("SplitView primarySize must be a non-empty CSS size");
374
- const o = this.Host;
375
- return /* @__PURE__ */ g(
376
- o,
431
+ const l = this.Host;
432
+ return /* @__PURE__ */ w(
433
+ l,
377
434
  {
378
- className: b(this.props) || null,
379
- "data-direction": r,
435
+ className: E(this.props) || null,
436
+ "data-direction": a,
380
437
  style: i == null ? void 0 : { "--split-primary-size": i },
381
438
  children: [
382
- /* @__PURE__ */ c(
439
+ /* @__PURE__ */ u(
383
440
  "div",
384
441
  {
385
442
  "data-part": "primary",
386
- role: e == null ? null : "region",
387
- "aria-label": e,
388
- children: s
443
+ role: n == null ? null : "region",
444
+ "aria-label": n,
445
+ children: r
389
446
  }
390
447
  ),
391
- /* @__PURE__ */ c(
448
+ /* @__PURE__ */ u(
392
449
  "div",
393
450
  {
394
451
  "data-part": "secondary",
395
- role: l == null ? null : "region",
396
- "aria-label": l,
397
- children: t ?? this.props.children ?? []
452
+ role: o == null ? null : "region",
453
+ "aria-label": o,
454
+ children: e ?? this.props.children ?? []
398
455
  }
399
456
  )
400
457
  ]
@@ -402,7 +459,7 @@ class F extends p {
402
459
  );
403
460
  }
404
461
  }
405
- a(F, "hostName", "split-view"), a(F, "standaloneHostName", "split-view"), a(F, "css", m`
462
+ s(ce, "hostName", "split-view"), s(ce, "standaloneHostName", "split-view"), s(ce, "css", v`
406
463
  & {
407
464
  display: grid;
408
465
  flex: 1 1 auto;
@@ -437,23 +494,23 @@ a(F, "hostName", "split-view"), a(F, "standaloneHostName", "split-view"), a(F, "
437
494
  border-block-end: 1px solid var(--ui-border-color);
438
495
  }
439
496
  `);
440
- class at extends p {
497
+ class Ue extends g {
441
498
  render() {
442
- const { term: s, value: t, children: r = [] } = this.props;
443
- return /* @__PURE__ */ g(
499
+ const { term: r, value: e, children: a = [] } = this.props;
500
+ return /* @__PURE__ */ w(
444
501
  "div",
445
502
  {
446
- className: b(this.props) || void 0,
503
+ className: E(this.props) || void 0,
447
504
  "data-fray-component": "description-item",
448
505
  children: [
449
- /* @__PURE__ */ c("dt", { children: s }),
450
- /* @__PURE__ */ c("dd", { children: t ?? r })
506
+ /* @__PURE__ */ u("dt", { children: r }),
507
+ /* @__PURE__ */ u("dd", { children: e ?? a })
451
508
  ]
452
509
  }
453
510
  );
454
511
  }
455
512
  }
456
- a(at, "css", m`
513
+ s(Ue, "css", v`
457
514
  div[data-fray-component="description-item"] {
458
515
  display: grid;
459
516
  grid-template-columns: minmax(7rem, 0.7fr) minmax(0, 1.3fr);
@@ -480,12 +537,12 @@ a(at, "css", m`
480
537
  }
481
538
  }
482
539
  `);
483
- class U extends p {
540
+ class Te extends g {
484
541
  render() {
485
- return /* @__PURE__ */ c(
542
+ return /* @__PURE__ */ u(
486
543
  "dl",
487
544
  {
488
- className: b(this.props) || void 0,
545
+ className: E(this.props) || void 0,
489
546
  "data-fray-component": "description-list",
490
547
  "aria-label": this.props.label,
491
548
  children: this.props.children ?? []
@@ -493,349 +550,2225 @@ class U extends p {
493
550
  );
494
551
  }
495
552
  }
496
- a(U, "dependencies", [at]), a(U, "css", m`
553
+ s(Te, "dependencies", [Ue]), s(Te, "css", v`
497
554
  dl[data-fray-component="description-list"] {
498
555
  display: grid;
499
556
  margin: 0;
500
557
  }
501
558
  `);
502
- const w = class w extends Z {
503
- constructor(s = {}) {
504
- super({ ...s, symbols: w.symbols });
559
+ class H extends g {
560
+ render() {
561
+ const r = at(this.props.width ?? 65), e = this.Host;
562
+ return /* @__PURE__ */ u(e, { style: { width: `${r}%` }, "aria-hidden": "true" });
505
563
  }
506
- };
507
- a(w, "hostName", "quad-checkbox"), a(w, "standaloneHostName", "quad-checkbox"), a(w, "symbols", [
508
- ["", v.Deny],
509
- ["", v.Neutral],
510
- ["✓", v.Prefer],
511
- ["+", v.Require]
512
- ]), a(w, "defaultSemanticState", v.Neutral);
513
- let G = w;
514
- const E = class E extends Z {
515
- constructor(s = {}) {
516
- super({ ...s, symbols: E.symbols });
564
+ }
565
+ s(H, "hostName", "placeholder"), s(H, "standaloneHostName", "loading-placeholder"), s(H, "baseStyles", [
566
+ ["&::after", ["after", "working"]]
567
+ ]), s(H, "css", v`
568
+ & {
569
+ display: block;
570
+ min-width: 3rem;
571
+ height: 1em;
572
+ overflow: hidden;
573
+ background: currentColor;
574
+ border-radius: var(--ui-border-radius);
575
+ opacity: 0.18;
576
+ position: relative;
577
+ }
578
+
579
+ @keyframes fray-placeholder-progress {
580
+ from { background-position: 0 0; }
581
+ to { background-position: 2rem 0; }
582
+ }
583
+ `);
584
+ function at(t) {
585
+ const r = Number(t);
586
+ if (!Number.isFinite(r)) throw new TypeError("Placeholder width must be numeric");
587
+ return Math.min(100, Math.max(10, r));
588
+ }
589
+ function Pe(t, r, e) {
590
+ ye(e);
591
+ for (const a of e) {
592
+ const i = r[a.key];
593
+ if (i == null) continue;
594
+ const n = a.options.flatMap((d) => {
595
+ const h = i[d.key];
596
+ return h == null || h === y.Neutral ? [] : [{ option: d, mode: h }];
597
+ });
598
+ if (n.some(({ option: d, mode: h }) => h === y.Deny && d.matches(t)) || n.filter(({ mode: d }) => d === y.Require).some(({ option: d }) => !d.matches(t)))
599
+ return !1;
600
+ const l = n.filter(({ mode: d }) => d === y.Prefer);
601
+ if (l.length > 0 && !l.some(({ option: d }) => d.matches(t)))
602
+ return !1;
517
603
  }
518
- };
519
- a(E, "hostName", "tri-checkbox"), a(E, "standaloneHostName", "tri-checkbox"), a(E, "symbols", [
520
- ["✖", v.Deny],
521
- ["", v.Neutral],
522
- ["✓", v.Prefer]
523
- ]), a(E, "defaultSemanticState", v.Neutral);
524
- let J = E;
525
- class j extends p {
526
- constructor(t = {}) {
604
+ return !0;
605
+ }
606
+ function it(t, r, e) {
607
+ if (!Array.isArray(t)) throw new TypeError("Filtered items must be an array");
608
+ return t.filter((a) => Pe(a, r, e));
609
+ }
610
+ function ar(t, r, e = null) {
611
+ return ye(r), new le(
612
+ [t],
613
+ ([a]) => (i) => Pe(i, a, r),
614
+ { owner: e, purpose: "filter predicate" }
615
+ );
616
+ }
617
+ function ir(t, r, e, a = null) {
618
+ return ye(e), new le(
619
+ [t, r],
620
+ ([i, n]) => it(i, n, e),
621
+ { owner: a, purpose: "filtered items" }
622
+ );
623
+ }
624
+ function nr(t) {
625
+ nt(t);
626
+ const r = {};
627
+ for (const e of Object.keys(t).sort()) {
628
+ const a = {}, i = t[e];
629
+ for (const n of Object.keys(i).sort())
630
+ a[n] = i[n];
631
+ r[e] = a;
632
+ }
633
+ return { version: 1, dimensions: r };
634
+ }
635
+ function sr(t) {
636
+ if (!Q(t) || t.version !== 1 || !Q(t.dimensions))
637
+ throw new TypeError("Filter state must use version 1 with a dimensions object");
638
+ const r = {};
639
+ for (const [e, a] of Object.entries(t.dimensions)) {
640
+ if (U(e, "Filter dimension"), !Q(a))
641
+ throw new TypeError(`Filter dimension ${e} must be an object`);
642
+ const i = {};
643
+ for (const [n, o] of Object.entries(a)) {
644
+ if (U(n, `Filter option in ${e}`), !de(o))
645
+ throw new TypeError(
646
+ `Unknown filter mode for ${e}.${n}: ${String(o)}`
647
+ );
648
+ i[n] = o;
649
+ }
650
+ r[e] = i;
651
+ }
652
+ return r;
653
+ }
654
+ function nt(t) {
655
+ if (!Q(t)) throw new TypeError("Filter state must be an object");
656
+ for (const [r, e] of Object.entries(t)) {
657
+ if (U(r, "Filter dimension"), !Q(e))
658
+ throw new TypeError(`Filter dimension ${r} must be an object`);
659
+ for (const [a, i] of Object.entries(e))
660
+ if (U(a, `Filter option in ${r}`), !de(i))
661
+ throw new TypeError(
662
+ `Unknown filter mode for ${r}.${a}: ${String(i)}`
663
+ );
664
+ }
665
+ }
666
+ function ye(t) {
667
+ if (!Array.isArray(t)) throw new TypeError("Filter dimensions must be an array");
668
+ const r = /* @__PURE__ */ new Set();
669
+ for (const e of t) {
670
+ if (U(e.key, "Filter dimension"), r.has(e.key))
671
+ throw new Error(`Duplicate filter dimension: ${e.key}`);
672
+ if (r.add(e.key), !Array.isArray(e.options))
673
+ throw new TypeError(`Filter dimension ${e.key} options must be an array`);
674
+ const a = /* @__PURE__ */ new Set();
675
+ for (const i of e.options) {
676
+ if (U(i.key, `Filter option in ${e.key}`), a.has(i.key))
677
+ throw new Error(`Duplicate filter option: ${e.key}.${i.key}`);
678
+ if (a.add(i.key), typeof i.matches != "function")
679
+ throw new TypeError(`Filter matcher ${e.key}.${i.key} must be a function`);
680
+ }
681
+ }
682
+ }
683
+ function U(t, r) {
684
+ if (t.length === 0 || t === "__proto__" || t === "prototype" || t === "constructor")
685
+ throw new TypeError(`${r} key is not safe for persisted state`);
686
+ }
687
+ function Q(t) {
688
+ return t != null && typeof t == "object" && !Array.isArray(t);
689
+ }
690
+ class Be {
691
+ constructor({
692
+ getItems: r,
693
+ getKey: e = we,
694
+ selectedItemsEmitter: a,
695
+ owner: i = null
696
+ }) {
697
+ s(this, "getItems");
698
+ s(this, "getKey");
699
+ s(this, "selectedItemsEmitter");
700
+ s(this, "selectedItems$");
701
+ s(this, "ownsSelectedItemsEmitter");
702
+ s(this, "rows", []);
703
+ s(this, "rowCleanups", []);
704
+ s(this, "activeIndex", 0);
705
+ s(this, "anchorIndex", null);
706
+ s(this, "dragStartIndex", null);
707
+ s(this, "dragOriginEvent", null);
708
+ s(this, "dragMoved", !1);
709
+ s(this, "dragCleanup", null);
710
+ s(this, "suppressNextClick", !1);
711
+ s(this, "suppressClickTimer", null);
712
+ s(this, "destroyed", !1);
713
+ s(this, "ownedSelectedItemsEmitter");
714
+ if (typeof r != "function")
715
+ throw new TypeError("Selection handler getItems must be a function");
716
+ if (typeof e != "function")
717
+ throw new TypeError("Selection handler getKey must be a function");
718
+ this.getItems = r, this.getKey = e, this.ownedSelectedItemsEmitter = a == null ? new I([], { owner: i, purpose: "selected items" }) : null, this.selectedItemsEmitter = a ?? this.ownedSelectedItemsEmitter, this.selectedItems$ = this.selectedItemsEmitter, this.ownsSelectedItemsEmitter = this.ownedSelectedItemsEmitter != null;
719
+ }
720
+ rowsUpdated(r) {
721
+ this.destroyed || (this.releaseRows(), this.rows = Array.from(r ?? []), this.rows.forEach((e, a) => this.wireRow(e, a)), this.activeIndex = lt(this.activeIndex, this.rows.length), this.reconcileSelectedItems(), this.syncRows());
722
+ }
723
+ wireRow(r, e) {
724
+ const a = (l) => this.handleClick(e, l), i = (l) => this.handleKeyDown(e, l), n = (l) => this.handleMouseDown(e, l, r), o = (l) => this.handleMouseEnter(e, l);
725
+ r.addEventListener("click", a), r.addEventListener("keydown", i), r.addEventListener("mousedown", n), r.addEventListener("mouseenter", o), this.rowCleanups.push(() => {
726
+ r.removeEventListener("click", a), r.removeEventListener("keydown", i), r.removeEventListener("mousedown", n), r.removeEventListener("mouseenter", o);
727
+ });
728
+ }
729
+ handleClick(r, e) {
730
+ var a;
731
+ if (e.preventDefault(), this.suppressNextClick) {
732
+ this.clearClickSuppression();
733
+ return;
734
+ }
735
+ this.activeIndex = r, this.selectIndex(r, e), (a = this.rows[r]) == null || a.focus();
736
+ }
737
+ handleMouseDown(r, e, a) {
738
+ if (e.button !== 0 || !this.supportsDragSelection()) return;
739
+ this.finishDrag(!1), this.clearClickSuppression(), this.dragStartIndex = r, this.dragOriginEvent = e, this.dragMoved = !1;
740
+ const i = a.ownerDocument, n = () => this.finishDrag(this.dragMoved);
741
+ i.addEventListener("mouseup", n), this.dragCleanup = () => i.removeEventListener("mouseup", n);
742
+ }
743
+ handleMouseEnter(r, e) {
744
+ var a;
745
+ this.dragStartIndex != null && (r === this.dragStartIndex && !this.dragMoved || r === this.activeIndex && this.dragMoved || (e.preventDefault(), this.dragMoved = !0, this.activeIndex = r, this.selectDragRange(this.dragStartIndex, r, this.dragOriginEvent ?? e), (a = this.rows[r]) == null || a.focus()));
746
+ }
747
+ handleKeyDown(r, e) {
748
+ var n;
749
+ const a = this.rows.length - 1;
750
+ let i;
751
+ if (e.key === "ArrowDown") i = Math.min(r + 1, a);
752
+ else if (e.key === "ArrowUp") i = Math.max(r - 1, 0);
753
+ else if (e.key === "Home") i = 0;
754
+ else if (e.key === "End") i = a;
755
+ else if (e.key === " " || e.key === "Enter") {
756
+ e.preventDefault(), this.activeIndex = r, this.selectIndex(r, e);
757
+ return;
758
+ } else return;
759
+ e.preventDefault(), this.activeIndex = i, this.onKeyboardMove(i, e), this.syncRows(), (n = this.rows[i]) == null || n.focus();
760
+ }
761
+ onKeyboardMove(r, e) {
762
+ this.selectIndex(r, e);
763
+ }
764
+ supportsDragSelection() {
765
+ return !1;
766
+ }
767
+ selectDragRange(r, e, a) {
768
+ }
769
+ selectIndex(r, e) {
770
+ }
771
+ setSelectedItems(r, e = "selection changed") {
772
+ this.selectedItemsEmitter.set(r, e), this.syncRows();
773
+ }
774
+ getSelectedItems() {
775
+ return this.selectedItemsEmitter.get() ?? [];
776
+ }
777
+ getSelectedItemsEmitter() {
778
+ return this.selectedItemsEmitter;
779
+ }
780
+ reconcileSelectedItems() {
781
+ const r = this.getSelectedItems();
782
+ if (r.length === 0) return;
783
+ const e = new Set(r.map((i, n) => this.getKey(i, n))), a = this.getItems().filter((i, n) => e.has(this.getKey(i, n)));
784
+ (a.length !== r.length || a.some((i, n) => !Object.is(i, r[n]))) && this.selectedItemsEmitter.set([...a], "selection reconciled with rows");
785
+ }
786
+ syncRows() {
787
+ const r = new Set(this.getSelectedItems().map((a, i) => this.getKey(a, i))), e = this.getItems();
788
+ this.rows.forEach((a, i) => {
789
+ const n = e[i], o = n !== void 0 && r.has(this.getKey(n, i));
790
+ a.classList.toggle("selected", o), a.setAttribute("aria-selected", String(o)), a.tabIndex = i === this.activeIndex ? 0 : -1;
791
+ });
792
+ }
793
+ releaseRows() {
794
+ for (const r of this.rowCleanups.splice(0)) r();
795
+ this.rows = [];
796
+ }
797
+ finishDrag(r) {
798
+ var e;
799
+ (e = this.dragCleanup) == null || e.call(this), this.dragCleanup = null, this.dragStartIndex = null, this.dragOriginEvent = null, this.dragMoved = !1, r && (this.suppressNextClick = !0, this.suppressClickTimer != null && clearTimeout(this.suppressClickTimer), this.suppressClickTimer = setTimeout(() => this.clearClickSuppression(), 0));
800
+ }
801
+ clearClickSuppression() {
802
+ this.suppressNextClick = !1, this.suppressClickTimer != null && clearTimeout(this.suppressClickTimer), this.suppressClickTimer = null;
803
+ }
804
+ destroy() {
805
+ var r;
806
+ this.destroyed || (this.destroyed = !0, this.finishDrag(!1), this.clearClickSuppression(), this.releaseRows(), (r = this.ownedSelectedItemsEmitter) == null || r.dispose());
807
+ }
808
+ }
809
+ class ge extends Be {
810
+ constructor(e) {
811
+ const a = e.selectedItemEmitter == null ? new I(null, {
812
+ owner: e.owner,
813
+ purpose: "selected item"
814
+ }) : null, i = e.selectedItemEmitter ?? a;
815
+ super({
816
+ getItems: e.getItems,
817
+ ...e.getKey == null ? {} : { getKey: e.getKey },
818
+ ...e.owner === void 0 ? {} : { owner: e.owner },
819
+ selectedItemsEmitter: new ot(i)
820
+ });
821
+ s(this, "selectedItemEmitter");
822
+ s(this, "selectedItem$");
823
+ s(this, "ownedSelectedItemEmitter");
824
+ this.ownedSelectedItemEmitter = a, this.selectedItemEmitter = i, this.selectedItem$ = i;
825
+ }
826
+ selectIndex(e) {
827
+ const a = this.getItems()[e];
828
+ a !== void 0 && (this.anchorIndex = e, this.setSelectedItems([a], "single selection changed"));
829
+ }
830
+ getSelectedItem() {
831
+ return this.selectedItemEmitter.get();
832
+ }
833
+ destroy() {
527
834
  var e;
528
- super(t);
529
- a(this, "inputId");
530
- a(this, "errorId");
531
- a(this, "optionsEmitter");
532
- a(this, "valueEmitter");
533
- a(this, "ownsOptionsEmitter");
534
- this.inputId = x("dropdown", t.id), this.errorId = `${this.inputId}-error`;
535
- const r = t.options ?? [];
536
- dt(r) ? (this.optionsEmitter = r, this.ownsOptionsEmitter = !1) : (B(r), this.optionsEmitter = new ot(r, {
835
+ super.destroy(), (e = this.ownedSelectedItemEmitter) == null || e.dispose();
836
+ }
837
+ }
838
+ class st extends Be {
839
+ selectIndex(r, e) {
840
+ const a = this.getItems(), i = a[r];
841
+ if (i !== void 0) {
842
+ if (e.shiftKey && this.anchorIndex != null) {
843
+ const n = Math.min(this.anchorIndex, r), o = Math.max(this.anchorIndex, r), l = a.slice(n, o + 1), d = ue(e) ? Re(this.getSelectedItems(), l, this.getKey) : [...l];
844
+ this.setSelectedItems(d, "range selection changed");
845
+ return;
846
+ }
847
+ if (ue(e) || "key" in e && e.key === " ") {
848
+ const n = this.getSelectedItems(), o = this.getKey(i, r), d = n.some((h, f) => Object.is(this.getKey(h, f), o)) ? n.filter((h, f) => !Object.is(this.getKey(h, f), o)) : [...n, i];
849
+ this.anchorIndex = r, this.setSelectedItems(d, "multi selection toggled");
850
+ return;
851
+ }
852
+ this.anchorIndex = r, this.setSelectedItems([i], "multi selection changed");
853
+ }
854
+ }
855
+ onKeyboardMove(r, e) {
856
+ e.shiftKey && this.selectIndex(r, e);
857
+ }
858
+ supportsDragSelection() {
859
+ return !0;
860
+ }
861
+ selectDragRange(r, e, a) {
862
+ const i = this.getItems(), n = Math.min(r, e), o = Math.max(r, e), l = i.slice(n, o + 1), d = ue(a) ? Re(this.getSelectedItems(), l, this.getKey) : [...l];
863
+ this.anchorIndex = r, this.setSelectedItems(d, "drag selection changed");
864
+ }
865
+ }
866
+ function ne(t) {
867
+ return t.multiSelect ? new st(t) : new ge(t);
868
+ }
869
+ class ot {
870
+ constructor(r) {
871
+ this.source = r;
872
+ }
873
+ get() {
874
+ const r = this.source.get();
875
+ return r == null ? [] : [r];
876
+ }
877
+ getError() {
878
+ return this.source.getError();
879
+ }
880
+ getFetchState() {
881
+ return this.source.getFetchState();
882
+ }
883
+ set(r, e) {
884
+ return this.source.set(r[0] ?? null, e);
885
+ }
886
+ subscribe(r, e) {
887
+ return this.source.subscribe((a) => r({
888
+ ...a,
889
+ value: a.value == null ? [] : [a.value]
890
+ }), e);
891
+ }
892
+ }
893
+ function we(t, r) {
894
+ if (t != null && typeof t == "object") {
895
+ const e = Reflect.get(t, "id");
896
+ if (e != null) return e;
897
+ }
898
+ if (typeof t == "string" || typeof t == "number") return t;
899
+ throw new TypeError(
900
+ `Selection item at index ${r} needs an id or an explicit itemKey/rowKey`
901
+ );
902
+ }
903
+ function ue(t) {
904
+ return !!(t.ctrlKey || t.metaKey);
905
+ }
906
+ function lt(t, r) {
907
+ return r <= 0 ? 0 : Math.min(Math.max(t, 0), r - 1);
908
+ }
909
+ function Re(t, r, e) {
910
+ const a = [...t], i = new Set(t.map((n, o) => e(n, o)));
911
+ for (const n of r) {
912
+ const o = e(n, a.length);
913
+ i.has(o) || (i.add(o), a.push(n));
914
+ }
915
+ return a;
916
+ }
917
+ class G extends g {
918
+ constructor(e = {}) {
919
+ super(e);
920
+ s(this, "itemsEmitter");
921
+ s(this, "items$");
922
+ s(this, "selectedItemsEmitter");
923
+ s(this, "selectedItems$");
924
+ s(this, "selectedItemEmitter");
925
+ s(this, "selectedItem$");
926
+ s(this, "getItemKey");
927
+ s(this, "selectionHandler");
928
+ s(this, "ownedItemsEmitter");
929
+ ct(e.items) ? (this.itemsEmitter = e.items, this.ownedItemsEmitter = null) : (this.ownedItemsEmitter = new I(e.items ?? [], {
537
930
  owner: this,
538
- purpose: "dropdown options"
539
- }), this.ownsOptionsEmitter = !0);
540
- const i = ((e = this.optionsEmitter.get()[0]) == null ? void 0 : e.value) ?? "";
541
- this.valueEmitter = T(this, t, i, "dropdown value");
931
+ purpose: "list items"
932
+ }), this.itemsEmitter = this.ownedItemsEmitter), this.items$ = this.itemsEmitter, this.getItemKey = dt(e.itemKey), this.selectionHandler = e.multiSelect === !0 ? ne({
933
+ owner: this,
934
+ multiSelect: !0,
935
+ ...e.selectedItemsEmitter == null ? {} : { selectedItemsEmitter: e.selectedItemsEmitter },
936
+ getItems: () => this.itemsEmitter.get(),
937
+ getKey: this.getItemKey
938
+ }) : ne({
939
+ owner: this,
940
+ ...e.selectedItemEmitter == null ? {} : { selectedItemEmitter: e.selectedItemEmitter },
941
+ getItems: () => this.itemsEmitter.get(),
942
+ getKey: this.getItemKey
943
+ }), this.selectedItemsEmitter = this.selectionHandler.selectedItemsEmitter, this.selectedItems$ = this.selectedItemsEmitter, this.selectedItemEmitter = this.selectionHandler instanceof ge ? this.selectionHandler.selectedItemEmitter : null, this.selectedItem$ = this.selectedItemEmitter;
542
944
  }
543
945
  initialize() {
544
- this.watch(this.valueEmitter, this.optionsEmitter);
946
+ this.watch(this.itemsEmitter, this.selectedItemsEmitter);
545
947
  }
546
948
  render() {
547
- const {
548
- label: t,
549
- name: r,
550
- disabled: i = !1,
551
- required: e = !1,
552
- error: l = null,
553
- placeholder: o = "Select…",
554
- ariaLabel: d,
555
- onChange: u
556
- } = this.props, y = this.optionsEmitter.get() ?? [];
557
- B(y);
558
- const f = this.valueEmitter.get(), k = this.Host;
559
- return /* @__PURE__ */ g(
560
- k,
949
+ const e = this.itemsEmitter.get();
950
+ if (!Array.isArray(e)) throw new TypeError("ListView items must be an array");
951
+ const a = this.itemsEmitter.getFetchState(), i = this.itemsEmitter.getError(), n = a === k.Initial || a === k.Loading, o = new Set(this.selectedItemsEmitter.get().map((d, h) => this.getItemKey(d, h))), l = this.Host;
952
+ return /* @__PURE__ */ w(
953
+ l,
561
954
  {
562
- className: b(this.props) || null,
563
- "data-disabled": i ? "" : null,
564
- "data-required": e ? "" : null,
565
- "data-error": l == null ? null : "",
955
+ className: E(this.props) || null,
566
956
  children: [
567
- t == null ? null : /* @__PURE__ */ c("label", { htmlFor: this.inputId, children: t }),
568
- /* @__PURE__ */ g(
569
- "select",
570
- {
571
- id: this.inputId,
572
- name: r,
573
- value: f == null ? "" : String(f),
574
- disabled: i,
575
- required: e,
576
- "aria-label": t == null ? d : null,
577
- "aria-invalid": l == null ? null : "true",
578
- "aria-describedby": l == null ? null : this.errorId,
579
- onChange: (h) => {
580
- const A = ct(h, "dropdown change"), N = y.find(({ value: D }) => String(D) === A), R = (N == null ? void 0 : N.value) ?? A;
581
- this.valueEmitter.set(R, "dropdown selection"), H(u, R, h);
582
- },
583
- children: [
584
- f == null || f === "" ? /* @__PURE__ */ c("option", { value: "", disabled: e, selected: !0, children: o }) : null,
585
- y.map((h) => {
586
- if (h == null || !Object.hasOwn(h, "value"))
587
- throw new TypeError("Dropdown options require value and label fields");
588
- return /* @__PURE__ */ c(
589
- "option",
590
- {
591
- value: String(h.value),
592
- disabled: !!h.disabled,
593
- selected: Object.is(f, h.value),
594
- children: h.label ?? String(h.value)
595
- },
596
- String(h.value)
597
- );
598
- })
599
- ]
600
- }
601
- ),
602
- l == null ? null : /* @__PURE__ */ c(
603
- "p",
957
+ a === k.Error ? /* @__PURE__ */ u("p", { role: "alert", "data-part": "error", children: ft(i, "Unable to load items") }) : null,
958
+ n && e.length === 0 ? /* @__PURE__ */ w("div", { role: "status", "data-part": "loading", children: [
959
+ /* @__PURE__ */ u("span", { children: "Loading items…" }),
960
+ Array.from({ length: this.props.placeholderCount ?? 5 }, (d, h) => /* @__PURE__ */ u("div", { "data-part": "placeholder-row", children: /* @__PURE__ */ u(H, { width: 45 + h * 7 }) }, `placeholder-${h}`))
961
+ ] }) : null,
962
+ a === k.Ready && e.length === 0 ? /* @__PURE__ */ u("p", { role: "status", "data-part": "empty", children: "No items" }) : null,
963
+ e.length > 0 ? /* @__PURE__ */ u(
964
+ "div",
604
965
  {
605
- id: this.errorId,
606
- "data-part": "error",
607
- role: "alert",
608
- children: String(l)
966
+ role: "listbox",
967
+ "data-part": "list",
968
+ "aria-label": this.props.label ?? "Items",
969
+ "aria-busy": n ? "true" : null,
970
+ "aria-multiselectable": this.props.multiSelect ? "true" : null,
971
+ children: e.map((d, h) => {
972
+ const f = this.getItemKey(d, h), p = o.has(f), m = this.props.renderItem ? this.props.renderItem(d, h) : ut(d);
973
+ return /* @__PURE__ */ u(
974
+ "div",
975
+ {
976
+ role: "option",
977
+ "data-part": "row",
978
+ "data-fray-selectable-row": "",
979
+ "data-index": h,
980
+ "aria-selected": String(p),
981
+ tabIndex: h === 0 ? 0 : -1,
982
+ children: m
983
+ },
984
+ String(f)
985
+ );
986
+ })
609
987
  }
610
- )
988
+ ) : null
611
989
  ]
612
990
  }
613
991
  );
614
992
  }
993
+ afterUpdate(e) {
994
+ const a = e instanceof Element ? e.querySelectorAll("[data-fray-selectable-row]") : [];
995
+ this.selectionHandler.rowsUpdated(a);
996
+ }
997
+ getSelectedItems() {
998
+ return this.selectionHandler.getSelectedItems();
999
+ }
1000
+ getSelectedItemsEmitter() {
1001
+ return this.selectedItemsEmitter;
1002
+ }
1003
+ getSelectedItem() {
1004
+ var e;
1005
+ return ((e = this.selectedItemEmitter) == null ? void 0 : e.get()) ?? null;
1006
+ }
1007
+ getSelectedItemEmitter() {
1008
+ return this.selectedItemEmitter;
1009
+ }
1010
+ onDestroy() {
1011
+ var e;
1012
+ this.selectionHandler.destroy(), (e = this.ownedItemsEmitter) == null || e.dispose();
1013
+ }
615
1014
  }
616
- a(j, "hostName", "dropdown"), a(j, "standaloneHostName", "drop-down"), a(j, "baseStyles", [
617
- ["&", ["labeledinput", "inputline"]],
618
- ["& > label", ["label"]],
619
- ["& > select", ["input", "inputline"]],
620
- ["&[data-disabled]", ["disabled"]],
621
- ["&[data-error]", ["error"]]
622
- ]), a(j, "css", m`
1015
+ s(G, "dependencies", [H]), s(G, "hostName", "list-view"), s(G, "standaloneHostName", "list-view"), s(G, "baseStyles", [
1016
+ ["&", "inputlike"],
1017
+ ['& > [data-part="list"] > [data-part="row"]', "inputline"]
1018
+ ]), s(G, "css", v`
623
1019
  & {
624
- position: relative;
1020
+ display: flex;
1021
+ flex-direction: column;
1022
+ overflow-y: auto;
1023
+ min-height: 0;
1024
+ }
1025
+
1026
+ & > [data-part="list"],
1027
+ & > [data-part="loading"] {
1028
+ display: flex;
1029
+ flex-direction: column;
1030
+ }
1031
+
1032
+ & > [data-part="list"] > [data-part="row"] {
1033
+ cursor: default;
1034
+ user-select: none;
1035
+ }
1036
+
1037
+ & > [data-part="list"] > [data-part="row"]:hover,
1038
+ & > [data-part="list"] > [data-part="row"]:focus-visible {
1039
+ background: var(--button-background-hover);
1040
+ outline: 2px solid var(--ui-accent-color);
1041
+ outline-offset: -2px;
1042
+ }
1043
+
1044
+ & > [data-part="list"] > [data-part="row"][aria-selected="true"] {
1045
+ color: var(--toggle-selected-text);
1046
+ background: var(--toggle-selected-bg);
1047
+ }
1048
+
1049
+ & > [data-part="empty"],
1050
+ & > [data-part="error"] {
1051
+ margin: 0;
1052
+ padding: var(--ui-padding);
1053
+ }
1054
+
1055
+ & > [data-part="error"] {
1056
+ color: var(--error-color);
625
1057
  }
626
1058
  `);
627
- function dt(n) {
628
- return n != null && (typeof n == "object" || typeof n == "function") && typeof Reflect.get(n, "get") == "function" && typeof Reflect.get(n, "subscribe") == "function";
629
- }
630
- function ct(n, s) {
631
- const t = n.currentTarget;
632
- if (t == null || typeof Reflect.get(t, "value") != "string")
633
- throw new TypeError(`${s} requires a value-bearing event target`);
634
- return Reflect.get(t, "value");
635
- }
636
- class q extends p {
637
- constructor(t = {}) {
638
- super(t);
639
- a(this, "inputId");
640
- a(this, "errorId");
641
- a(this, "valueEmitter");
642
- this.inputId = x("textbox", t.id), this.errorId = `${this.inputId}-error`, this.valueEmitter = T(this, t, "", "textbox value");
1059
+ function dt(t) {
1060
+ if (t == null) return we;
1061
+ if (typeof t == "function") return t;
1062
+ if (typeof t == "string" && t.length > 0)
1063
+ return (r, e) => {
1064
+ if (r == null || typeof r != "object" && typeof r != "function")
1065
+ throw new TypeError(`ListView item at index ${e} lacks ${t}`);
1066
+ const a = Reflect.get(r, t);
1067
+ if (a == null)
1068
+ throw new TypeError(`ListView item at index ${e} lacks ${t}`);
1069
+ return a;
1070
+ };
1071
+ throw new TypeError("ListView itemKey must be a function or property name");
1072
+ }
1073
+ function ct(t) {
1074
+ return t != null && (typeof t == "object" || typeof t == "function") && typeof Reflect.get(t, "get") == "function" && typeof Reflect.get(t, "subscribe") == "function";
1075
+ }
1076
+ function ut(t) {
1077
+ if (t != null && (typeof t == "object" || typeof t == "function")) {
1078
+ const r = Reflect.get(t, "label");
1079
+ if (ht(r)) return r;
1080
+ }
1081
+ return String(t);
1082
+ }
1083
+ function ht(t) {
1084
+ return t == null || typeof t == "string" || typeof t == "number";
1085
+ }
1086
+ function ft(t, r) {
1087
+ return t instanceof Error ? t.message : t == null ? r : String(t);
1088
+ }
1089
+ class D extends g {
1090
+ constructor(e = {}) {
1091
+ super(e);
1092
+ s(this, "symbols");
1093
+ s(this, "valueEmitter");
1094
+ s(this, "semanticStateEmitter");
1095
+ const a = this.constructor;
1096
+ this.symbols = e.symbols ?? a.symbols, pt(this.symbols);
1097
+ const i = e.initialSemanticState ?? a.defaultSemanticState ?? this.symbols[0][1], n = { ...e };
1098
+ n.defaultValue == null && e.initialSemanticState != null && (n.defaultValue = e.initialSemanticState), this.valueEmitter = M(
1099
+ this,
1100
+ n,
1101
+ i,
1102
+ "checkbox semantic state"
1103
+ ), this.semanticStateEmitter = this.valueEmitter;
643
1104
  }
644
1105
  initialize() {
645
1106
  this.watch(this.valueEmitter);
646
1107
  }
1108
+ cycleState(e = 1, a = null) {
1109
+ if (this.props.disabled) return;
1110
+ const i = this.symbols.findIndex(([, d]) => Object.is(d, this.valueEmitter.get())), o = ((i < 0 ? 0 : i) + e + this.symbols.length) % this.symbols.length, l = this.symbols[o][1];
1111
+ this.valueEmitter.set(l, "checkbox state changed"), C(this.props.onChange, l, a);
1112
+ }
647
1113
  render() {
648
1114
  const {
649
- label: t,
650
- placeholder: r,
651
- type: i = "text",
652
- name: e,
653
- disabled: l = !1,
654
- required: o = !1,
655
- readOnly: d = !1,
656
- error: u = null,
657
- autoComplete: y,
658
- inputMode: f,
659
- minLength: k,
660
- maxLength: h,
661
- pattern: A,
662
- ariaLabel: N,
663
- inputRef: R,
664
- onInput: D,
665
- onChange: it
666
- } = this.props, rt = this.valueEmitter.get() ?? "", lt = this.Host;
667
- return /* @__PURE__ */ g(
668
- lt,
1115
+ label: e = this.props.value ?? "Option",
1116
+ disabled: a = !1,
1117
+ required: i = !1,
1118
+ name: n,
1119
+ value: o
1120
+ } = this.props, l = this.valueEmitter.get(), [d] = this.symbols.find(([, m]) => Object.is(m, l)) ?? ["?", l], h = rt(l), f = l === y.Prefer || l === y.Require, p = this.Host;
1121
+ return /* @__PURE__ */ u(
1122
+ p,
669
1123
  {
670
- className: b(this.props) || null,
671
- "data-disabled": l ? "" : null,
672
- "data-required": o ? "" : null,
673
- "data-error": u == null ? null : "",
674
- children: [
675
- t == null ? null : /* @__PURE__ */ c("label", { htmlFor: this.inputId, children: t }),
676
- /* @__PURE__ */ c(
677
- "input",
678
- {
679
- id: this.inputId,
680
- name: e,
681
- type: i,
682
- value: rt,
683
- placeholder: r,
684
- disabled: l,
685
- required: o,
686
- readOnly: d,
687
- autoComplete: y,
688
- inputMode: f,
689
- minLength: k,
690
- maxLength: h,
691
- pattern: A,
692
- ref: R,
693
- "aria-label": t == null ? N : null,
694
- "aria-invalid": u == null ? null : "true",
695
- "aria-describedby": u == null ? null : this.errorId,
696
- onInput: (S) => {
697
- const L = W(S, "textbox input");
698
- this.valueEmitter.set(L, "textbox input"), H(D, L, S);
699
- },
700
- onChange: (S) => H(
701
- it,
702
- W(S, "textbox change"),
703
- S
704
- )
705
- }
706
- ),
707
- u == null ? null : /* @__PURE__ */ c(
708
- "p",
709
- {
710
- id: this.errorId,
711
- "data-part": "error",
712
- role: "alert",
713
- children: String(u)
714
- }
715
- )
716
- ]
1124
+ className: E(this.props) || null,
1125
+ "data-disabled": a ? "" : null,
1126
+ "data-required": i ? "" : null,
1127
+ "data-state": h,
1128
+ children: /* @__PURE__ */ w(
1129
+ "button",
1130
+ {
1131
+ type: "button",
1132
+ role: "checkbox",
1133
+ disabled: a,
1134
+ name: n,
1135
+ value: o == null ? void 0 : String(o),
1136
+ "data-part": "control",
1137
+ "aria-checked": f ? "true" : "false",
1138
+ "aria-required": i ? "true" : null,
1139
+ "aria-label": `${e}: ${h}`,
1140
+ onClick: (m) => this.cycleState(1, m),
1141
+ onKeyDown: (m) => {
1142
+ m.key === "ArrowRight" || m.key === "ArrowDown" ? (m.preventDefault(), this.cycleState(1, m)) : (m.key === "ArrowLeft" || m.key === "ArrowUp") && (m.preventDefault(), this.cycleState(-1, m));
1143
+ },
1144
+ children: [
1145
+ /* @__PURE__ */ u("span", { "data-part": "symbol", "aria-hidden": "true", children: d }),
1146
+ /* @__PURE__ */ u("span", { "data-part": "label", children: e })
1147
+ ]
1148
+ }
1149
+ )
717
1150
  }
718
1151
  );
719
1152
  }
720
1153
  }
721
- a(q, "hostName", "textbox"), a(q, "standaloneHostName", "text-box"), a(q, "baseStyles", [
722
- ["&", ["labeledinput", "inputline"]],
723
- ["& > label", ["label"]],
724
- ["& > input", ["input", "inputline"]],
725
- ["&[data-disabled]", ["disabled"]],
726
- ["&[data-error]", ["error"]]
727
- ]), a(q, "css", m`
728
- & input {
729
- cursor: text;
1154
+ s(D, "symbols", [
1155
+ ["", y.Neutral],
1156
+ ["", y.Prefer]
1157
+ ]), s(D, "defaultSemanticState", y.Neutral), s(D, "hostName", "checkbox"), s(D, "standaloneHostName", "check-box"), s(D, "baseStyles", [
1158
+ ["&", ["inputline"]],
1159
+ ['& > [data-part="control"]', ["input", "inputline"]],
1160
+ ["&[data-disabled]", ["disabled"]]
1161
+ ]), s(D, "css", v`
1162
+ & > [data-part="control"] {
1163
+ display: inline-flex;
1164
+ align-items: center;
1165
+ gap: 0.35em;
1166
+ width: auto;
1167
+ font-family: inherit;
730
1168
  }
731
1169
 
732
- & > [data-part="error"] {
733
- margin: 0;
734
- color: var(--error-color, #b00020);
1170
+ & [data-part="symbol"] {
1171
+ display: inline-grid;
1172
+ width: 1em;
1173
+ height: 1em;
1174
+ line-height: 1;
1175
+ place-items: center;
1176
+ color: var(--fray-checkbox-symbol-color, currentColor);
1177
+ background: var(--fray-checkbox-box-background, transparent);
1178
+ border: var(--fray-checkbox-box-border, var(--cbx-o-border));
1179
+ border-radius: var(--cbx-border-radius, var(--fray-radius-sm));
1180
+ }
1181
+
1182
+ & [data-part="control"][aria-checked="true"] [data-part="symbol"] {
1183
+ background: var(
1184
+ --fray-checkbox-box-background-checked,
1185
+ var(--fray-selection-background)
1186
+ );
735
1187
  }
736
1188
  `);
737
- function W(n, s) {
738
- const t = n.currentTarget;
739
- if (t == null || typeof Reflect.get(t, "value") != "string")
740
- throw new TypeError(`${s} requires a value-bearing event target`);
741
- return Reflect.get(t, "value");
742
- }
743
- class X extends p {
744
- constructor(t = {}) {
745
- var e;
746
- super(t);
747
- a(this, "valueEmitter");
748
- a(this, "groupId");
749
- a(this, "legendId");
750
- const r = t.options ?? [];
751
- Y(r);
752
- const i = ((e = r[0]) == null ? void 0 : e[0]) ?? null;
753
- this.valueEmitter = T(
754
- this,
755
- t,
756
- i ?? null,
757
- "toggle value"
758
- ), this.groupId = x("toggle", t.id), this.legendId = `${this.groupId}-label`;
1189
+ function pt(t) {
1190
+ if (!Array.isArray(t) || t.length === 0)
1191
+ throw new TypeError("Checkbox symbols must be a non-empty tuple array");
1192
+ for (const r of t)
1193
+ if (!Array.isArray(r) || r.length < 2)
1194
+ throw new TypeError("Checkbox symbols must be [symbol, state] tuples");
1195
+ }
1196
+ class V extends g {
1197
+ constructor(e = {}) {
1198
+ super(e);
1199
+ s(this, "optionsEmitter");
1200
+ s(this, "optionStateEmitters", /* @__PURE__ */ new Map());
1201
+ s(this, "staleOptionValues", /* @__PURE__ */ new Set());
1202
+ s(this, "placementTimer", null);
1203
+ this.optionsEmitter = wt(e.options) ? e.options : null;
759
1204
  }
760
1205
  initialize() {
761
- this.watch(this.valueEmitter);
762
- }
763
- selectOption(t, r = null) {
764
- this.props.disabled || (this.valueEmitter.set(t, "toggle option selected"), H(this.props.onChange, t, r));
1206
+ this.optionsEmitter && this.watch(this.optionsEmitter);
765
1207
  }
766
1208
  render() {
767
- const {
768
- options: t = [],
769
- label: r,
770
- disabled: i = !1,
771
- required: e = !1
772
- } = this.props;
773
- Y(t);
774
- const l = this.valueEmitter.get(), o = Math.max(
775
- 0,
776
- t.findIndex(([d]) => Object.is(d, l))
1209
+ var f, p, m;
1210
+ const e = ((f = this.optionsEmitter) == null ? void 0 : f.get()) ?? (Array.isArray(this.props.options) ? this.props.options : []);
1211
+ if (!Array.isArray(e))
1212
+ throw new TypeError("FilterPanel options must be an array or emitter of arrays");
1213
+ const a = ((p = this.optionsEmitter) == null ? void 0 : p.getFetchState()) ?? k.Ready, i = (m = this.optionsEmitter) == null ? void 0 : m.getError(), n = Ne(this.props.filters), o = this.props.filterModes ?? D.symbols, l = this.props.defaultSemanticState ?? y.Neutral, d = new Set(e.map(pe));
1214
+ this.staleOptionValues = new Set(
1215
+ [...this.optionStateEmitters.keys()].filter((b) => !d.has(b))
777
1216
  );
778
- return /* @__PURE__ */ g(
779
- "fieldset",
1217
+ const h = this.Host;
1218
+ return a === k.Error ? /* @__PURE__ */ u(
1219
+ h,
780
1220
  {
781
- id: this.groupId,
782
- disabled: i,
783
- className: b(this.props) || void 0,
784
- "data-fray-component": "toggle",
785
- "data-disabled": i ? "" : null,
786
- "aria-required": e ? "true" : null,
787
- children: [
788
- r == null ? null : /* @__PURE__ */ c("legend", { id: this.legendId, children: r }),
789
- /* @__PURE__ */ c(
790
- "div",
1221
+ className: E(this.props) || null,
1222
+ role: "alert",
1223
+ "data-state": "error",
1224
+ children: Et(i, "Unable to load filter options")
1225
+ }
1226
+ ) : (a === k.Initial || a === k.Loading) && e.length === 0 ? /* @__PURE__ */ u(
1227
+ h,
1228
+ {
1229
+ className: E(this.props) || null,
1230
+ role: "status",
1231
+ "data-state": "loading",
1232
+ children: "Loading filter options…"
1233
+ }
1234
+ ) : /* @__PURE__ */ u(
1235
+ h,
1236
+ {
1237
+ className: E(this.props) || null,
1238
+ role: "group",
1239
+ "aria-label": this.props.label ?? "Filter options",
1240
+ children: e.length === 0 ? /* @__PURE__ */ u("span", { children: "No filter options" }) : e.map((b) => {
1241
+ const S = pe(b), x = bt(b), O = n.get(S) ?? l, $ = this.optionEmitter(S, O);
1242
+ return /* @__PURE__ */ u(
1243
+ mt,
791
1244
  {
792
- "data-part": "options",
793
- role: "radiogroup",
794
- "aria-label": r == null ? this.props.ariaLabel : null,
795
- "aria-labelledby": r == null ? null : this.legendId,
796
- children: t.map(([d, u], y) => /* @__PURE__ */ c(
797
- "button",
798
- {
799
- type: "button",
800
- role: "radio",
801
- disabled: i,
802
- "data-part": "option",
803
- "aria-checked": Object.is(l, d) ? "true" : "false",
804
- "data-value": String(d),
805
- tabIndex: y === o ? 0 : -1,
806
- onClick: (f) => this.selectOption(d, f),
807
- onKeyDown: (f) => this.handleKeyDown(f, y, t),
808
- children: u
809
- },
810
- String(d)
811
- ))
812
- }
813
- )
814
- ]
1245
+ label: x,
1246
+ valueEmitter: $,
1247
+ symbols: o,
1248
+ onChange: (K, A) => {
1249
+ var T, B;
1250
+ A == null || A.stopPropagation();
1251
+ const F = Ne(this.props.filters);
1252
+ K === y.Neutral ? F.delete(S) : F.set(S, K), (B = (T = this.props).onChange) == null || B.call(T, F, A);
1253
+ }
1254
+ },
1255
+ yt(S)
1256
+ );
1257
+ })
815
1258
  }
816
1259
  );
817
1260
  }
818
- handleKeyDown(t, r, i) {
819
- const { key: e } = t;
820
- let l;
821
- if (e === "ArrowRight" || e === "ArrowDown") l = (r + 1) % i.length;
822
- else if (e === "ArrowLeft" || e === "ArrowUp")
823
- l = (r - 1 + i.length) % i.length;
824
- else if (e === "Home") l = 0;
825
- else if (e === "End") l = i.length - 1;
826
- else return;
827
- t.preventDefault();
828
- const o = i[l];
829
- if (o != null && (this.selectOption(o[0], t), this.dom instanceof Element)) {
830
- const d = this.dom.querySelectorAll('[role="radio"]')[l];
1261
+ afterUpdate(e) {
1262
+ var a;
1263
+ for (const i of this.staleOptionValues)
1264
+ (a = this.optionStateEmitters.get(i)) == null || a.dispose(), this.optionStateEmitters.delete(i);
1265
+ this.staleOptionValues.clear(), this.placementTimer != null && clearTimeout(this.placementTimer), this.placementTimer = setTimeout(() => {
1266
+ this.placementTimer = null, this.placeInsideViewport(e);
1267
+ }, 0);
1268
+ }
1269
+ onDestroy() {
1270
+ this.placementTimer != null && clearTimeout(this.placementTimer), this.placementTimer = null;
1271
+ for (const e of this.optionStateEmitters.values()) e.dispose();
1272
+ this.optionStateEmitters.clear();
1273
+ }
1274
+ optionEmitter(e, a) {
1275
+ const i = this.optionStateEmitters.get(e);
1276
+ if (i != null)
1277
+ return i.get() !== a && i.set(a, "filter option synchronized"), i;
1278
+ const n = new I(a, { owner: this, purpose: `filter option ${String(e)}` });
1279
+ return this.optionStateEmitters.set(e, n), n;
1280
+ }
1281
+ placeInsideViewport(e) {
1282
+ if (!(e instanceof HTMLElement) || e.parentElement == null) return;
1283
+ const a = e.ownerDocument.defaultView;
1284
+ if (a == null || a.innerHeight <= 0) return;
1285
+ const i = e.parentElement.getBoundingClientRect();
1286
+ e.style.removeProperty("max-height");
1287
+ const n = e.getBoundingClientRect(), o = i.top, l = Math.max(0, a.innerHeight - i.bottom), d = n.height > l && o > l;
1288
+ d ? (e.dataset.placement = "above", e.style.insetBlockStart = `${Math.max(8, i.top - n.height)}px`) : (delete e.dataset.placement, e.style.insetBlockStart = `${i.bottom}px`), e.style.insetInlineEnd = `${Math.max(8, a.innerWidth - i.right)}px`;
1289
+ const h = d ? o : l;
1290
+ e.style.maxHeight = `${Math.max(48, h - 8)}px`;
1291
+ }
1292
+ }
1293
+ s(V, "dependencies", [D]), s(V, "hostName", "filter-panel"), s(V, "standaloneHostName", "filter-panel"), s(V, "css", v`
1294
+ & {
1295
+ position: fixed;
1296
+ z-index: 1100;
1297
+ inset-block-start: 0;
1298
+ inset-inline-end: 0;
1299
+ display: flex;
1300
+ min-width: 12rem;
1301
+ padding: var(--ui-padding);
1302
+ flex-flow: column nowrap;
1303
+ align-items: stretch;
1304
+ color: var(--panel-color);
1305
+ background: var(--panel-bg);
1306
+ border: var(--panel-border);
1307
+ border-radius: var(--panel-radius);
1308
+ box-shadow: var(--panel-shadow);
1309
+ overflow-y: auto;
1310
+ }
1311
+
1312
+ `);
1313
+ const mt = D;
1314
+ function Ne(t) {
1315
+ if (t == null) return /* @__PURE__ */ new Map();
1316
+ if (t instanceof Map) return new Map(t);
1317
+ if (Array.isArray(t)) return new Map(t);
1318
+ throw new TypeError("FilterPanel filters must be a Map or tuple array");
1319
+ }
1320
+ function pe(t) {
1321
+ if (typeof t == "string" || typeof t == "number") return t;
1322
+ if (t != null && typeof t == "object") {
1323
+ const r = Reflect.get(t, "value");
1324
+ if (typeof r == "string" || typeof r == "number") return r;
1325
+ }
1326
+ throw new TypeError("Filter options must be strings, numbers, or value/label objects");
1327
+ }
1328
+ function bt(t) {
1329
+ if (t != null && typeof t == "object") {
1330
+ const r = Reflect.get(t, "label");
1331
+ if (r != null) return gt(r) ? r : String(r);
1332
+ }
1333
+ return String(pe(t));
1334
+ }
1335
+ function yt(t) {
1336
+ return `${typeof t}:${String(t)}`;
1337
+ }
1338
+ function gt(t) {
1339
+ return typeof t == "string" || typeof t == "number";
1340
+ }
1341
+ function wt(t) {
1342
+ return t != null && (typeof t == "object" || typeof t == "function") && typeof Reflect.get(t, "get") == "function" && typeof Reflect.get(t, "subscribe") == "function";
1343
+ }
1344
+ function Et(t, r) {
1345
+ return t instanceof Error ? t.message : t == null ? r : String(t);
1346
+ }
1347
+ class W extends g {
1348
+ constructor() {
1349
+ super(...arguments);
1350
+ s(this, "filterVisible", !1);
1351
+ s(this, "onGlobalClick", (e) => {
1352
+ this.filterVisible && this.dom instanceof Node && e.target instanceof Node && !this.dom.contains(e.target) && (this.filterVisible = !1, this.update());
1353
+ });
1354
+ }
1355
+ initialize() {
1356
+ this.watch(this.props.sortEmitter, this.props.filtersEmitter), this.props.filterOptions != null && this.listen(document, "click", this.onGlobalClick);
1357
+ }
1358
+ toggleSort() {
1359
+ if (!this.props.sortable) return;
1360
+ const e = this.props.sortEmitter.get();
1361
+ let a;
1362
+ (e == null ? void 0 : e.field) !== this.props.field ? a = { field: this.props.field, direction: "asc" } : e.direction === "asc" ? a = { field: this.props.field, direction: "desc" } : a = null, this.props.sortEmitter.set(a, "table sort changed");
1363
+ }
1364
+ toggleFilterPanel(e) {
1365
+ e.stopPropagation(), this.filterVisible = !this.filterVisible, this.update();
1366
+ }
1367
+ updateFilters(e, a) {
1368
+ var n, o;
1369
+ const i = { ...this.props.filtersEmitter.get() };
1370
+ e.size === 0 ? delete i[this.props.field] : i[this.props.field] = [...e.entries()], this.props.filtersEmitter.set(i, "table filters changed"), (o = (n = this.props).onFilterChange) == null || o.call(n, i, a);
1371
+ }
1372
+ render() {
1373
+ const e = this.props.sortEmitter.get(), a = (e == null ? void 0 : e.field) === this.props.field ? e.direction : null, i = new Map(
1374
+ (this.props.filtersEmitter.get()[this.props.field] ?? []).filter(vt)
1375
+ ), n = this.props.label ?? String(this.props.field), o = `Filter ${String(n)}`;
1376
+ let l = null;
1377
+ return this.filterVisible && this.props.filterOptions != null && (l = /* @__PURE__ */ u(
1378
+ V,
1379
+ {
1380
+ label: o,
1381
+ options: this.props.filterOptions,
1382
+ filters: i,
1383
+ onChange: (d, h) => this.updateFilters(d, h),
1384
+ ...this.props.filterModes == null ? {} : { filterModes: this.props.filterModes },
1385
+ ...this.props.defaultSemanticState == null ? {} : { defaultSemanticState: this.props.defaultSemanticState }
1386
+ },
1387
+ "filter-panel"
1388
+ )), /* @__PURE__ */ w(
1389
+ "th",
1390
+ {
1391
+ scope: "col",
1392
+ "data-fray-component": "table-header-cell",
1393
+ "aria-sort": a === "asc" ? "ascending" : a === "desc" ? "descending" : "none",
1394
+ style: { zIndex: this.filterVisible ? 1200 : null },
1395
+ children: [
1396
+ this.props.sortable ? /* @__PURE__ */ w(
1397
+ "button",
1398
+ {
1399
+ type: "button",
1400
+ "data-part": "sort",
1401
+ onClick: () => this.toggleSort(),
1402
+ children: [
1403
+ n,
1404
+ a === "asc" ? " ▲" : a === "desc" ? " ▼" : ""
1405
+ ]
1406
+ }
1407
+ ) : /* @__PURE__ */ u("span", { "data-part": "label", children: n }),
1408
+ this.props.filterOptions == null ? null : /* @__PURE__ */ u(
1409
+ "button",
1410
+ {
1411
+ type: "button",
1412
+ "data-part": "filter-toggle",
1413
+ "aria-label": o,
1414
+ "aria-expanded": String(this.filterVisible),
1415
+ onClick: (d) => this.toggleFilterPanel(d),
1416
+ children: "Filter"
1417
+ }
1418
+ ),
1419
+ l
1420
+ ]
1421
+ }
1422
+ );
1423
+ }
1424
+ }
1425
+ s(W, "dependencies", [V]), s(W, "baseStyles", [
1426
+ ['th[data-fray-component="table-header-cell"]', "noselect"],
1427
+ ['th[data-fray-component="table-header-cell"] > [data-part="sort"]', ["uiline", "button"]],
1428
+ ['th[data-fray-component="table-header-cell"] > [data-part="filter-toggle"]', ["uiline", "button"]]
1429
+ ]), s(W, "css", v`
1430
+ th[data-fray-component="table-header-cell"] {
1431
+ position: relative;
1432
+ text-align: start;
1433
+ color: var(
1434
+ --fray-table-header-color,
1435
+ var(--fray-section-header-color, var(--fray-header-color))
1436
+ );
1437
+ background: var(
1438
+ --fray-table-header-background,
1439
+ var(--fray-section-header-background, var(--fray-header-background))
1440
+ );
1441
+ border-block-end: var(--fray-section-header-border, var(--fray-header-border));
1442
+ box-shadow: var(--fray-section-header-shadow, var(--fray-header-shadow));
1443
+ }
1444
+
1445
+ th[data-fray-component="table-header-cell"] > [data-part="sort"],
1446
+ th[data-fray-component="table-header-cell"] > [data-part="filter-toggle"] {
1447
+ width: auto;
1448
+ font-family: inherit;
1449
+ color: inherit;
1450
+ background: var(
1451
+ --fray-table-header-button-background,
1452
+ var(--fray-button-background)
1453
+ );
1454
+ }
1455
+
1456
+ th[data-fray-component="table-header-cell"] > [data-part="filter-toggle"] {
1457
+ margin-inline-start: var(--ui-padding-h);
1458
+ font-size: 0.75em;
1459
+ }
1460
+ `);
1461
+ function vt(t) {
1462
+ return typeof t[0] == "string" || typeof t[0] == "number";
1463
+ }
1464
+ class me extends g {
1465
+ render() {
1466
+ return /* @__PURE__ */ u("thead", { "data-fray-component": "table-header", children: /* @__PURE__ */ u("tr", { children: this.props.columns.map((r) => /* @__PURE__ */ u(
1467
+ W,
1468
+ {
1469
+ field: r.field,
1470
+ sortEmitter: this.props.sortEmitter,
1471
+ filtersEmitter: this.props.filtersEmitter,
1472
+ ...r.label == null ? {} : { label: r.label },
1473
+ ...r.sortable == null ? {} : { sortable: r.sortable },
1474
+ ...r.filterOptions == null ? {} : { filterOptions: r.filterOptions },
1475
+ ...this.props.filterModes == null ? {} : { filterModes: this.props.filterModes },
1476
+ ...this.props.defaultSemanticState == null ? {} : { defaultSemanticState: this.props.defaultSemanticState },
1477
+ ...this.props.onFilterChange == null ? {} : { onFilterChange: this.props.onFilterChange }
1478
+ },
1479
+ String(r.field)
1480
+ )) }) });
1481
+ }
1482
+ }
1483
+ s(me, "dependencies", [W]);
1484
+ const St = {
1485
+ [y.Neutral]: "☐",
1486
+ [y.Prefer]: "",
1487
+ [y.Require]: "_",
1488
+ [y.Deny]: "!"
1489
+ };
1490
+ function kt(t, { sort: r = null, filters: e = {} } = {}) {
1491
+ Nt(t), r != null && (Ge(r), t.searchParams.set("sort", `${r.field}:${r.direction}`));
1492
+ for (const [a, i] of Object.entries(e))
1493
+ for (const [n, o] of i) {
1494
+ if (!de(o))
1495
+ throw new TypeError(`Unknown filter mode for ${a}: ${String(o)}`);
1496
+ t.searchParams.append(
1497
+ "filter",
1498
+ `${a}:${St[o]}:${JSON.stringify(n)}`
1499
+ );
1500
+ }
1501
+ return t;
1502
+ }
1503
+ function It(t, r, e) {
1504
+ if (!Array.isArray(t)) throw new TypeError("Local table data must be an array");
1505
+ const a = t.filter((n) => xt(n, e));
1506
+ if (r == null) return a;
1507
+ Ge(r);
1508
+ const i = r.direction === "asc" ? 1 : -1;
1509
+ return [...a].sort((n, o) => Rt(be(n, r.field), be(o, r.field)) * i);
1510
+ }
1511
+ function xt(t, r) {
1512
+ for (const [e, a] of Object.entries(r)) {
1513
+ const i = be(t, e);
1514
+ if (a.filter(([, d]) => d === y.Deny).some(([d]) => Object.is(d, i))) return !1;
1515
+ const o = a.filter(([, d]) => d === y.Require);
1516
+ if (o.length > 0 && !o.some(([d]) => Object.is(d, i))) return !1;
1517
+ const l = a.filter(([, d]) => d === y.Prefer);
1518
+ if (l.length > 0 && !l.some(([d]) => Object.is(d, i))) return !1;
1519
+ }
1520
+ return !0;
1521
+ }
1522
+ function Ge(t) {
1523
+ if (t == null || typeof t != "object" || typeof Reflect.get(t, "field") != "string" || !Tt(Reflect.get(t, "direction")))
1524
+ throw new TypeError("Table sort must contain a field and asc/desc direction");
1525
+ }
1526
+ function Tt(t) {
1527
+ return t === "asc" || t === "desc";
1528
+ }
1529
+ function Rt(t, r) {
1530
+ return Object.is(t, r) ? 0 : t == null ? -1 : r == null ? 1 : typeof t == "number" && typeof r == "number" ? t - r : String(t).localeCompare(String(r));
1531
+ }
1532
+ function be(t, r) {
1533
+ if (!(t == null || typeof t != "object" && typeof t != "function"))
1534
+ return Reflect.get(t, r);
1535
+ }
1536
+ function Nt(t) {
1537
+ if (t == null || typeof t != "object" && typeof t != "function" || typeof Reflect.get(t, "toString") != "function")
1538
+ throw new TypeError("Table serializer requires a URL");
1539
+ const r = Reflect.get(t, "searchParams");
1540
+ if (r == null || typeof Reflect.get(r, "set") != "function" || typeof Reflect.get(r, "append") != "function")
1541
+ throw new TypeError("Table serializer requires URL search parameters");
1542
+ }
1543
+ function Dt(t) {
1544
+ const r = ve(t), e = Qe(t.data) ? null : new I(t.data, {
1545
+ owner: t.owner,
1546
+ purpose: "local table data"
1547
+ }), a = e ?? t.data, i = new le(
1548
+ [a, r.sortEmitter, r.filtersEmitter],
1549
+ ([n, o, l]) => It(n, o, l),
1550
+ { owner: t.owner, purpose: "local table view" }
1551
+ );
1552
+ return new Ee(i, r, () => {
1553
+ i.dispose(), e == null || e.dispose();
1554
+ });
1555
+ }
1556
+ function or(t) {
1557
+ Ct(t.query);
1558
+ const r = ve(t);
1559
+ return new Ee(t.query, r);
1560
+ }
1561
+ function Ot(t) {
1562
+ if (t.handler == null || typeof t.handler.fetch != "function")
1563
+ throw new TypeError("Table data-source handler must implement fetch");
1564
+ const r = ve(t), e = new ke("sort", r.sortEmitter, {
1565
+ owner: t.owner,
1566
+ purpose: "table sort argument"
1567
+ }), a = new ke("filters", r.filtersEmitter, {
1568
+ owner: t.owner,
1569
+ purpose: "table filters argument"
1570
+ }), i = new Xe({
1571
+ handler: t.handler,
1572
+ args: { sort: e, filters: a },
1573
+ owner: t.owner,
1574
+ purpose: "table query",
1575
+ keepPreviousValue: !0
1576
+ });
1577
+ return new Ee(i, r, () => {
1578
+ i.dispose(), e.dispose(), a.dispose();
1579
+ });
1580
+ }
1581
+ function $t(t) {
1582
+ if (typeof t.url != "string" || t.url.length === 0)
1583
+ throw new TypeError("REST table data source requires a URL");
1584
+ const r = {
1585
+ url: t.url,
1586
+ serialize: t.serializeQuery ?? kt
1587
+ };
1588
+ return t.baseUrl != null && (r.baseUrl = t.baseUrl), t.fetch != null && (r.fetch = t.fetch), Ot({
1589
+ handler: new Ze(r),
1590
+ ...t.sortEmitter == null ? {} : { sortEmitter: t.sortEmitter },
1591
+ ...t.filtersEmitter == null ? {} : { filtersEmitter: t.filtersEmitter },
1592
+ ...t.owner === void 0 ? {} : { owner: t.owner }
1593
+ });
1594
+ }
1595
+ class Ee {
1596
+ constructor(r, e, a = null) {
1597
+ s(this, "sortEmitter");
1598
+ s(this, "filtersEmitter");
1599
+ s(this, "retry");
1600
+ s(this, "disposed", !1);
1601
+ this.query = r, this.state = e, this.disposeQuery = a, this.sortEmitter = e.sortEmitter, this.filtersEmitter = e.filtersEmitter, r.retry != null && (this.retry = (i) => {
1602
+ var n;
1603
+ return (n = r.retry) == null ? void 0 : n.call(r, i);
1604
+ });
1605
+ }
1606
+ dispose() {
1607
+ var r, e, a;
1608
+ this.disposed || (this.disposed = !0, (r = this.disposeQuery) == null || r.call(this), (e = this.state.ownedSortEmitter) == null || e.dispose(), (a = this.state.ownedFiltersEmitter) == null || a.dispose());
1609
+ }
1610
+ }
1611
+ function ve(t) {
1612
+ const r = t.sortEmitter == null ? new I(null, {
1613
+ owner: t.owner,
1614
+ purpose: "table sort"
1615
+ }) : null, e = t.filtersEmitter == null ? new I({}, {
1616
+ owner: t.owner,
1617
+ purpose: "table filters"
1618
+ }) : null;
1619
+ return {
1620
+ sortEmitter: t.sortEmitter ?? r,
1621
+ filtersEmitter: t.filtersEmitter ?? e,
1622
+ ownedSortEmitter: r,
1623
+ ownedFiltersEmitter: e
1624
+ };
1625
+ }
1626
+ function Qe(t) {
1627
+ return t != null && (typeof t == "object" || typeof t == "function") && typeof Reflect.get(t, "get") == "function" && typeof Reflect.get(t, "subscribe") == "function" && typeof Reflect.get(t, "getFetchState") == "function" && typeof Reflect.get(t, "getError") == "function";
1628
+ }
1629
+ function Ct(t) {
1630
+ if (!Qe(t))
1631
+ throw new TypeError("Table query must be an emitter");
1632
+ }
1633
+ class X extends g {
1634
+ constructor(e) {
1635
+ var a, i;
1636
+ super(e);
1637
+ s(this, "columns");
1638
+ s(this, "rowKey");
1639
+ s(this, "sortEmitter");
1640
+ s(this, "filtersEmitter");
1641
+ s(this, "selectedItemsEmitter");
1642
+ s(this, "selectedItemEmitter");
1643
+ s(this, "selectionHandler");
1644
+ s(this, "query", null);
1645
+ s(this, "dataSource", null);
1646
+ s(this, "suppliedDataSource");
1647
+ s(this, "ownedSortEmitter");
1648
+ s(this, "ownedFiltersEmitter");
1649
+ s(this, "ownedDataSource", null);
1650
+ At(e), this.columns = Kt(e.columns), this.rowKey = jt(e.rowKey), this.suppliedDataSource = e.dataSource ?? null, this.ownedSortEmitter = this.suppliedDataSource == null ? new I(null, { owner: this, purpose: "table sort" }) : null, this.ownedFiltersEmitter = this.suppliedDataSource == null ? new I({}, { owner: this, purpose: "table filters" }) : null, this.sortEmitter = ((a = this.suppliedDataSource) == null ? void 0 : a.sortEmitter) ?? this.ownedSortEmitter, this.filtersEmitter = ((i = this.suppliedDataSource) == null ? void 0 : i.filtersEmitter) ?? this.ownedFiltersEmitter, this.selectionHandler = e.multiSelect === !0 ? ne({
1651
+ owner: this,
1652
+ multiSelect: !0,
1653
+ ...e.selectedItemsEmitter == null ? {} : { selectedItemsEmitter: e.selectedItemsEmitter },
1654
+ getItems: () => {
1655
+ var n;
1656
+ return ((n = this.query) == null ? void 0 : n.get()) ?? [];
1657
+ },
1658
+ getKey: this.rowKey
1659
+ }) : ne({
1660
+ owner: this,
1661
+ ...e.selectedItemEmitter == null ? {} : { selectedItemEmitter: e.selectedItemEmitter },
1662
+ getItems: () => {
1663
+ var n;
1664
+ return ((n = this.query) == null ? void 0 : n.get()) ?? [];
1665
+ },
1666
+ getKey: this.rowKey
1667
+ }), this.selectedItemsEmitter = this.selectionHandler.selectedItemsEmitter, this.selectedItemEmitter = this.selectionHandler instanceof ge ? this.selectionHandler.selectedItemEmitter : null;
1668
+ }
1669
+ initialize() {
1670
+ this.suppliedDataSource != null ? this.dataSource = this.suppliedDataSource : this.props.rest != null ? (this.ownedDataSource = $t({
1671
+ ...this.props.rest,
1672
+ sortEmitter: this.sortEmitter,
1673
+ filtersEmitter: this.filtersEmitter,
1674
+ owner: this
1675
+ }), this.dataSource = this.ownedDataSource) : (this.ownedDataSource = Dt({
1676
+ data: this.props.data ?? [],
1677
+ sortEmitter: this.sortEmitter,
1678
+ filtersEmitter: this.filtersEmitter,
1679
+ owner: this
1680
+ }), this.dataSource = this.ownedDataSource), this.query = this.dataSource.query, this.watch(this.query, this.selectedItemsEmitter);
1681
+ }
1682
+ render() {
1683
+ var d, h, f, p;
1684
+ const e = ((d = this.query) == null ? void 0 : d.get()) ?? [];
1685
+ if (!Array.isArray(e)) throw new TypeError("DataTable query value must be an array");
1686
+ const a = ((h = this.query) == null ? void 0 : h.getFetchState()) ?? k.Initial, i = (f = this.query) == null ? void 0 : f.getError(), n = a === k.Initial || a === k.Loading, o = new Set(
1687
+ this.selectedItemsEmitter.get().map((m, b) => this.rowKey(m, b))
1688
+ ), l = this.Host;
1689
+ return /* @__PURE__ */ w(
1690
+ l,
1691
+ {
1692
+ className: E(this.props) || null,
1693
+ "data-loading": n ? "" : null,
1694
+ "data-error": a === k.Error ? "" : null,
1695
+ children: [
1696
+ n ? /* @__PURE__ */ u("p", { role: "status", "data-part": "status", children: "Loading rows…" }) : null,
1697
+ a === k.Error ? /* @__PURE__ */ w("div", { "data-part": "error", role: "alert", children: [
1698
+ /* @__PURE__ */ u("span", { children: Ht(i, "Unable to load rows") }),
1699
+ typeof ((p = this.dataSource) == null ? void 0 : p.retry) == "function" ? /* @__PURE__ */ u(
1700
+ "button",
1701
+ {
1702
+ type: "button",
1703
+ onClick: () => {
1704
+ var m, b;
1705
+ return (b = (m = this.dataSource) == null ? void 0 : m.retry) == null ? void 0 : b.call(m, "table retry");
1706
+ },
1707
+ children: "Retry"
1708
+ }
1709
+ ) : null
1710
+ ] }) : null,
1711
+ /* @__PURE__ */ w("table", { "data-part": "table", "aria-busy": n ? "true" : null, children: [
1712
+ this.props.caption == null ? null : /* @__PURE__ */ u("caption", { children: this.props.caption }),
1713
+ /* @__PURE__ */ u(
1714
+ me,
1715
+ {
1716
+ columns: this.columns,
1717
+ sortEmitter: this.sortEmitter,
1718
+ filtersEmitter: this.filtersEmitter,
1719
+ ...this.props.filterModes == null ? {} : { filterModes: this.props.filterModes },
1720
+ ...this.props.defaultSemanticState == null ? {} : { defaultSemanticState: this.props.defaultSemanticState },
1721
+ ...this.props.onFilterChange == null ? {} : { onFilterChange: this.props.onFilterChange }
1722
+ },
1723
+ "header"
1724
+ ),
1725
+ /* @__PURE__ */ u("tbody", { children: e.length > 0 ? e.map((m, b) => this.renderRow(m, b, o)) : n ? this.renderPlaceholders() : a === k.Error ? null : /* @__PURE__ */ u("tr", { children: /* @__PURE__ */ u("td", { colSpan: this.columns.length, children: this.props.emptyMessage ?? "No rows" }) }, "empty") })
1726
+ ] })
1727
+ ]
1728
+ }
1729
+ );
1730
+ }
1731
+ renderRow(e, a, i) {
1732
+ const n = this.rowKey(e, a), o = i.has(n);
1733
+ return /* @__PURE__ */ u(
1734
+ "tr",
1735
+ {
1736
+ "data-fray-selectable-row": "",
1737
+ "data-index": a,
1738
+ "aria-selected": String(o),
1739
+ tabIndex: a === 0 ? 0 : -1,
1740
+ children: this.columns.map((l) => /* @__PURE__ */ u("td", { children: l.render ? l.render(e, a) : Ft(e[l.field]) }, String(l.field)))
1741
+ },
1742
+ String(n)
1743
+ );
1744
+ }
1745
+ renderPlaceholders() {
1746
+ const e = this.props.placeholderCount ?? 5;
1747
+ return Array.from({ length: e }, (a, i) => /* @__PURE__ */ u("tr", { children: this.columns.map((n, o) => /* @__PURE__ */ u("td", { children: /* @__PURE__ */ u(
1748
+ H,
1749
+ {
1750
+ width: 45 + (i + o) % 6 * 8
1751
+ }
1752
+ ) }, String(n.field))) }, `placeholder-${i}`));
1753
+ }
1754
+ afterUpdate(e) {
1755
+ const a = e instanceof Element ? e.querySelectorAll("tbody [data-fray-selectable-row]") : [];
1756
+ this.selectionHandler.rowsUpdated(a);
1757
+ }
1758
+ getSelectedRows() {
1759
+ return this.selectionHandler.getSelectedItems();
1760
+ }
1761
+ getSelectedRowsEmitter() {
1762
+ return this.selectedItemsEmitter;
1763
+ }
1764
+ getSelectedRow() {
1765
+ var e;
1766
+ return ((e = this.selectedItemEmitter) == null ? void 0 : e.get()) ?? null;
1767
+ }
1768
+ getSelectedRowEmitter() {
1769
+ return this.selectedItemEmitter;
1770
+ }
1771
+ onDestroy() {
1772
+ var e, a, i;
1773
+ this.selectionHandler.destroy(), (e = this.ownedDataSource) == null || e.dispose(), (a = this.ownedSortEmitter) == null || a.dispose(), (i = this.ownedFiltersEmitter) == null || i.dispose();
1774
+ }
1775
+ }
1776
+ s(X, "dependencies", [H, me]), s(X, "hostName", "data-table"), s(X, "standaloneHostName", "data-table"), s(X, "css", v`
1777
+ & {
1778
+ overflow: auto;
1779
+ color: var(--ui-text-color);
1780
+ }
1781
+
1782
+ & > table {
1783
+ width: 100%;
1784
+ border-collapse: collapse;
1785
+ }
1786
+
1787
+ & thead:has([data-fray-component="filter-panel"]) {
1788
+ position: relative;
1789
+ z-index: 1100;
1790
+ }
1791
+
1792
+ & th,
1793
+ & td {
1794
+ padding: var(--ui-padding-v) var(--ui-padding-h);
1795
+ text-align: start;
1796
+ }
1797
+
1798
+ & tbody tr[data-fray-selectable-row] {
1799
+ cursor: default;
1800
+ user-select: none;
1801
+ }
1802
+
1803
+ & tbody tr:nth-child(odd) {
1804
+ background: var(--fray-table-row-background, transparent);
1805
+ }
1806
+
1807
+ & tbody tr:nth-child(even) {
1808
+ background: var(--fray-table-row-alt-background, transparent);
1809
+ }
1810
+
1811
+ & tbody tr[data-fray-selectable-row]:hover {
1812
+ background: var(--fray-row-hover-background, var(--button-background-hover));
1813
+ }
1814
+
1815
+ & tbody tr[data-fray-selectable-row]:focus-visible {
1816
+ outline: 2px solid var(--fray-color-focus, var(--ui-accent-color));
1817
+ outline-offset: -2px;
1818
+ }
1819
+
1820
+ & tbody tr[data-fray-selectable-row][aria-selected="true"] {
1821
+ color: var(--fray-selection-color, var(--toggle-selected-text));
1822
+ background: var(--fray-selection-background, var(--toggle-selected-bg));
1823
+ }
1824
+
1825
+ & > [data-part="error"] {
1826
+ color: var(--error-color);
1827
+ }
1828
+ `);
1829
+ function Kt(t) {
1830
+ if (!Array.isArray(t) || t.length === 0)
1831
+ throw new TypeError("DataTable columns must be a non-empty array");
1832
+ const r = /* @__PURE__ */ new Set();
1833
+ return t.map((e) => {
1834
+ if (e == null || typeof e != "object")
1835
+ throw new TypeError("Every DataTable column requires a field");
1836
+ const a = Reflect.get(e, "field");
1837
+ if (typeof a != "string" || a.length === 0)
1838
+ throw new TypeError("Every DataTable column requires a field");
1839
+ if (r.has(a)) throw new Error(`Duplicate DataTable column: ${a}`);
1840
+ r.add(a);
1841
+ const i = Reflect.get(e, "render");
1842
+ if (i != null && typeof i != "function")
1843
+ throw new TypeError(`DataTable column ${a} render must be a function`);
1844
+ return e;
1845
+ });
1846
+ }
1847
+ function At(t) {
1848
+ var o, l;
1849
+ const e = [
1850
+ "mode",
1851
+ "query",
1852
+ "queryHandler",
1853
+ "queryUrl",
1854
+ "baseUrl",
1855
+ "fetch",
1856
+ "serializeQuery"
1857
+ ].find((d) => Object.hasOwn(t, d));
1858
+ if (e != null)
1859
+ throw new TypeError(
1860
+ `DataTable ${e} moved to dataSource/rest; see the 0.3 migration guide`
1861
+ );
1862
+ const a = t.data !== void 0, i = t.dataSource !== void 0, n = t.rest !== void 0;
1863
+ if (Number(a) + Number(i) + Number(n) > 1)
1864
+ throw new TypeError("DataTable accepts exactly one of data, dataSource, or rest");
1865
+ if (i) {
1866
+ const d = t.dataSource;
1867
+ if (d == null || typeof d != "object" || d.query == null || typeof ((o = d.sortEmitter) == null ? void 0 : o.set) != "function" || typeof ((l = d.filtersEmitter) == null ? void 0 : l.set) != "function" || typeof d.dispose != "function")
1868
+ throw new TypeError("DataTable dataSource must implement the table data-source contract");
1869
+ }
1870
+ }
1871
+ function jt(t) {
1872
+ if (t == null) return we;
1873
+ if (typeof t == "function") return t;
1874
+ if (typeof t == "string" && t.length > 0)
1875
+ return (r, e) => {
1876
+ const a = r[t];
1877
+ if (a == null)
1878
+ throw new TypeError(`DataTable row at index ${e} lacks ${t}`);
1879
+ return a;
1880
+ };
1881
+ throw new TypeError("DataTable rowKey must be a function or property name");
1882
+ }
1883
+ function Ft(t) {
1884
+ return t == null || typeof t == "string" || typeof t == "number" ? t : String(t);
1885
+ }
1886
+ function Ht(t, r) {
1887
+ return t instanceof Error ? t.message : t == null ? r : String(t);
1888
+ }
1889
+ class We extends g {
1890
+ render() {
1891
+ return this.props.children ?? [];
1892
+ }
1893
+ }
1894
+ function P(t) {
1895
+ if (!Array.isArray(t)) throw new TypeError("Tree nodes must be an array");
1896
+ const r = /* @__PURE__ */ new Set(), e = (a) => {
1897
+ for (const i of a) {
1898
+ if (i == null || typeof i != "object" || i.id == null)
1899
+ throw new TypeError("Each tree node requires an id");
1900
+ if (r.has(i.id)) throw new Error(`Duplicate tree item id: ${String(i.id)}`);
1901
+ if (r.add(i.id), !Array.isArray(i.children ?? []))
1902
+ throw new TypeError(`Tree node ${String(i.id)} children must be an array`);
1903
+ e(i.children ?? []);
1904
+ }
1905
+ };
1906
+ e(t);
1907
+ }
1908
+ function lr(t, r) {
1909
+ return P(t), Se(t, r);
1910
+ }
1911
+ function dr(t, r, e = null) {
1912
+ return new le(
1913
+ [t, r],
1914
+ ([a, i]) => (P(a), i == null ? null : Se(a, i)),
1915
+ { owner: e, purpose: "tree node projection" }
1916
+ );
1917
+ }
1918
+ function Mt(t, r, e) {
1919
+ if (P(t), typeof e != "function") throw new TypeError("Tree node update must be a function");
1920
+ const a = (n) => {
1921
+ for (let o = 0; o < n.length; o += 1) {
1922
+ const l = n[o];
1923
+ if (Object.is(l.id, r)) {
1924
+ const f = e(l);
1925
+ if (f == null || typeof f != "object")
1926
+ throw new TypeError("Tree node update must return a tree node");
1927
+ if (!Object.is(f.id, l.id))
1928
+ throw new Error("Tree node update cannot change the stable id");
1929
+ if (Object.is(f, l)) return n;
1930
+ const p = [...n];
1931
+ return p[o] = f, p;
1932
+ }
1933
+ const d = l.children ?? [], h = a(d);
1934
+ if (!Object.is(h, d)) {
1935
+ const f = [...n];
1936
+ return f[o] = { ...l, children: h }, f;
1937
+ }
1938
+ }
1939
+ return n;
1940
+ }, i = a(t);
1941
+ return Object.is(i, t) || P(i), i;
1942
+ }
1943
+ function cr(t, r, e, a = "tree node updated") {
1944
+ const i = t.get(), n = Mt(i, r, e);
1945
+ return Object.is(n, i) ? !1 : t.set(n, a);
1946
+ }
1947
+ function Se(t, r) {
1948
+ for (const e of t) {
1949
+ if (Object.is(e.id, r)) return e;
1950
+ const a = Se(e.children ?? [], r);
1951
+ if (a != null) return a;
1952
+ }
1953
+ return null;
1954
+ }
1955
+ class Z extends g {
1956
+ constructor(e) {
1957
+ super(e);
1958
+ s(this, "nodesEmitter");
1959
+ s(this, "selectedKeyEmitter");
1960
+ s(this, "expandedKeysEmitter");
1961
+ s(this, "ownedNodesEmitter");
1962
+ s(this, "ownedSelectedEmitter");
1963
+ s(this, "ownedExpandedEmitter");
1964
+ s(this, "focusedKey", null);
1965
+ s(this, "typeahead", "");
1966
+ s(this, "typeaheadTimer", null);
1967
+ if (Vt(e.nodes))
1968
+ this.nodesEmitter = e.nodes, this.ownedNodesEmitter = null;
1969
+ else {
1970
+ const a = e.nodes ?? Je(e.children);
1971
+ this.ownedNodesEmitter = new I(a, {
1972
+ owner: this,
1973
+ purpose: "tree nodes"
1974
+ }), this.nodesEmitter = this.ownedNodesEmitter;
1975
+ }
1976
+ this.ownedSelectedEmitter = e.selectedKeyEmitter == null ? new I(null, { owner: this, purpose: "selected tree key" }) : null, this.selectedKeyEmitter = e.selectedKeyEmitter ?? this.ownedSelectedEmitter, this.ownedExpandedEmitter = e.expandedKeysEmitter == null ? new I([], { owner: this, purpose: "expanded tree keys" }) : null, this.expandedKeysEmitter = e.expandedKeysEmitter ?? this.ownedExpandedEmitter;
1977
+ }
1978
+ initialize() {
1979
+ this.reconcile(this.nodesEmitter.get()), this.watch(this.nodesEmitter, this.selectedKeyEmitter, this.expandedKeysEmitter), this.onCleanup(this.nodesEmitter.subscribe(({ value: e }) => this.reconcile(e), {
1980
+ emitCurrent: !1
1981
+ }));
1982
+ }
1983
+ render() {
1984
+ const e = this.nodesEmitter.get();
1985
+ P(e);
1986
+ const a = new Set(this.expandedKeysEmitter.get()), i = De(e, a), n = this.selectedKeyEmitter.get(), o = i.find(({ node: d }) => Object.is(d.id, this.focusedKey)) ?? i.find(({ node: d }) => Object.is(d.id, n)) ?? i[0] ?? null;
1987
+ this.focusedKey = (o == null ? void 0 : o.node.id) ?? null;
1988
+ const l = this.Host;
1989
+ return /* @__PURE__ */ u(l, { className: E(this.props) || null, children: i.length === 0 ? /* @__PURE__ */ u("p", { role: "status", "data-part": "empty", children: "No tree items" }) : /* @__PURE__ */ u("div", { role: "tree", "aria-label": this.props.label, "data-part": "tree", children: i.map((d, h) => {
1990
+ var K, A, F;
1991
+ const { node: f, depth: p, position: m, setSize: b } = d, S = (((K = f.children) == null ? void 0 : K.length) ?? 0) > 0, x = S && a.has(f.id), O = Object.is(f.id, n), $ = ((F = (A = this.props).renderItem) == null ? void 0 : F.call(A, f, p)) ?? f.label;
1992
+ return /* @__PURE__ */ w(
1993
+ "div",
1994
+ {
1995
+ role: "treeitem",
1996
+ "data-part": "item",
1997
+ "data-index": h,
1998
+ "data-depth": p,
1999
+ "aria-level": p + 1,
2000
+ "aria-posinset": m,
2001
+ "aria-setsize": b,
2002
+ "aria-expanded": S ? String(x) : null,
2003
+ "aria-selected": String(O),
2004
+ tabIndex: Object.is(f.id, o == null ? void 0 : o.node.id) ? 0 : -1,
2005
+ style: { "--tree-depth": p },
2006
+ onClick: (T) => {
2007
+ if (this.focusedKey = f.id, Ut(T.target) && S) {
2008
+ this.toggleExpanded(f.id), this.focusRow(f.id);
2009
+ return;
2010
+ }
2011
+ this.selectNode(f, T);
2012
+ },
2013
+ onFocus: () => this.focusedKey = f.id,
2014
+ onKeyDown: (T) => this.handleKeyDown(T, h, i),
2015
+ children: [
2016
+ /* @__PURE__ */ u(
2017
+ "span",
2018
+ {
2019
+ "data-part": "expander",
2020
+ "data-expandable": S ? "" : null,
2021
+ "aria-hidden": "true",
2022
+ children: S ? x ? "▾" : "▸" : "•"
2023
+ }
2024
+ ),
2025
+ /* @__PURE__ */ u("span", { "data-part": "label", children: $ })
2026
+ ]
2027
+ },
2028
+ f.id
2029
+ );
2030
+ }) }) });
2031
+ }
2032
+ onDestroy() {
2033
+ var e, a, i;
2034
+ this.typeaheadTimer != null && clearTimeout(this.typeaheadTimer), (e = this.ownedNodesEmitter) == null || e.dispose(), (a = this.ownedSelectedEmitter) == null || a.dispose(), (i = this.ownedExpandedEmitter) == null || i.dispose();
2035
+ }
2036
+ reconcile(e) {
2037
+ P(e);
2038
+ const a = new Set(zt(e).map(({ node: l }) => l.id)), i = this.selectedKeyEmitter.get();
2039
+ this.ownedSelectedEmitter != null && i != null && !a.has(i) && this.selectedKeyEmitter.set(null, "selected tree item removed");
2040
+ const n = this.expandedKeysEmitter.get(), o = n.filter((l) => a.has(l));
2041
+ this.ownedExpandedEmitter != null && !Lt(n, o) && this.expandedKeysEmitter.set(o, "removed tree expansions reconciled"), this.focusedKey != null && !a.has(this.focusedKey) && (this.focusedKey = null);
2042
+ }
2043
+ selectNode(e, a) {
2044
+ this.selectedKeyEmitter.set(e.id, "tree item selected"), C(this.props.onSelect, e, a), this.focusRow(e.id);
2045
+ }
2046
+ toggleExpanded(e) {
2047
+ const a = this.expandedKeysEmitter.get(), i = a.some((n) => Object.is(n, e));
2048
+ this.expandedKeysEmitter.set(
2049
+ i ? a.filter((n) => !Object.is(n, e)) : [...a, e],
2050
+ i ? "tree item collapsed" : "tree item expanded"
2051
+ );
2052
+ }
2053
+ handleKeyDown(e, a, i) {
2054
+ var o, l, d, h;
2055
+ const n = i[a];
2056
+ if (n != null) {
2057
+ if (e.key === "ArrowDown") return this.move(e, (o = i[a + 1]) == null ? void 0 : o.node.id);
2058
+ if (e.key === "ArrowUp") return this.move(e, (l = i[a - 1]) == null ? void 0 : l.node.id);
2059
+ if (e.key === "Home") return this.move(e, (d = i[0]) == null ? void 0 : d.node.id);
2060
+ if (e.key === "End") return this.move(e, (h = i.at(-1)) == null ? void 0 : h.node.id);
2061
+ if (e.key === "ArrowRight") {
2062
+ e.preventDefault();
2063
+ const f = n.node.children ?? [];
2064
+ if (f.length === 0) return;
2065
+ this.expandedKeysEmitter.get().some((m) => Object.is(m, n.node.id)) ? this.focusRow(f[0].id) : this.toggleExpanded(n.node.id);
2066
+ return;
2067
+ }
2068
+ if (e.key === "ArrowLeft") {
2069
+ e.preventDefault(), this.expandedKeysEmitter.get().some((p) => Object.is(p, n.node.id)) ? this.toggleExpanded(n.node.id) : n.parentId != null && this.focusRow(n.parentId);
2070
+ return;
2071
+ }
2072
+ if (e.key === "Enter" || e.key === " ") {
2073
+ e.preventDefault(), this.selectNode(n.node, e);
2074
+ return;
2075
+ }
2076
+ e.key.length === 1 && !e.altKey && !e.ctrlKey && !e.metaKey && this.handleTypeahead(e, i, a);
2077
+ }
2078
+ }
2079
+ move(e, a) {
2080
+ a !== void 0 && (e.preventDefault(), this.focusRow(a));
2081
+ }
2082
+ focusRow(e) {
2083
+ var i;
2084
+ this.focusedKey = e;
2085
+ const a = this.dom instanceof Element ? [...this.dom.querySelectorAll('[role="treeitem"]')] : [];
2086
+ for (const n of a) {
2087
+ const o = Number(n.dataset.index), l = De(
2088
+ this.nodesEmitter.get(),
2089
+ new Set(this.expandedKeysEmitter.get())
2090
+ ), d = Object.is((i = l[o]) == null ? void 0 : i.node.id, e);
2091
+ n.tabIndex = d ? 0 : -1, d && n.focus();
2092
+ }
2093
+ }
2094
+ handleTypeahead(e, a, i) {
2095
+ e.preventDefault(), this.typeaheadTimer != null && clearTimeout(this.typeaheadTimer), this.typeahead += e.key.toLocaleLowerCase(), this.typeaheadTimer = setTimeout(() => {
2096
+ this.typeahead = "", this.typeaheadTimer = null;
2097
+ }, 650);
2098
+ const o = [...a.slice(i + 1), ...a.slice(0, i + 1)].find(({ node: l }) => qt(l).toLocaleLowerCase().startsWith(this.typeahead));
2099
+ o != null && this.focusRow(o.node.id);
2100
+ }
2101
+ }
2102
+ s(Z, "dependencies", [We]), s(Z, "hostName", "tree-view"), s(Z, "standaloneHostName", "tree-view"), s(Z, "css", v`
2103
+ & {
2104
+ display: flex;
2105
+ flex-direction: column;
2106
+ min-width: 0;
2107
+ min-height: 0;
2108
+ overflow: auto;
2109
+ }
2110
+
2111
+ & > [data-part="tree"] {
2112
+ display: grid;
2113
+ align-content: start;
2114
+ }
2115
+
2116
+ & [data-part="item"] {
2117
+ display: flex;
2118
+ align-items: flex-start;
2119
+ gap: 0.35rem;
2120
+ min-width: 0;
2121
+ padding: 0.38rem 0.5rem;
2122
+ padding-inline-start: calc(0.5rem + var(--tree-depth) * 1.1rem);
2123
+ cursor: default;
2124
+ user-select: none;
2125
+ }
2126
+
2127
+ & [data-part="item"]:hover {
2128
+ background: var(--button-background-hover);
2129
+ }
2130
+
2131
+ & [data-part="item"]:focus-visible {
2132
+ outline: 2px solid var(--ui-accent-color);
2133
+ outline-offset: -2px;
2134
+ }
2135
+
2136
+ & [data-part="item"][aria-selected="true"] {
2137
+ color: var(--toggle-selected-text);
2138
+ background: var(--toggle-selected-bg);
2139
+ }
2140
+
2141
+ & [data-part="expander"] {
2142
+ flex: 0 0 1rem;
2143
+ text-align: center;
2144
+ }
2145
+
2146
+ & [data-part="expander"][data-expandable] {
2147
+ cursor: pointer;
2148
+ }
2149
+
2150
+ & [data-part="label"] {
2151
+ min-width: 0;
2152
+ overflow-wrap: anywhere;
2153
+ }
2154
+
2155
+ & > [data-part="empty"] {
2156
+ margin: 0;
2157
+ padding: var(--ui-padding, 0.75rem);
2158
+ }
2159
+
2160
+ @media (forced-colors: active) {
2161
+ & [data-part="item"][aria-selected="true"] {
2162
+ outline: 2px solid Highlight;
2163
+ forced-color-adjust: auto;
2164
+ }
2165
+ }
2166
+ `);
2167
+ function Je(t) {
2168
+ return (Array.isArray(t) ? t : t == null ? [] : [t]).filter((e) => ie(e) && e.type === We).map((e) => {
2169
+ if (!ie(e)) throw new TypeError("TreeView children must be TreeItem nodes");
2170
+ const a = e.props;
2171
+ return {
2172
+ id: a.id,
2173
+ label: a.label,
2174
+ ...a.textValue == null ? {} : { textValue: a.textValue },
2175
+ ...a.value === void 0 ? {} : { value: a.value },
2176
+ children: Je(a.children)
2177
+ };
2178
+ });
2179
+ }
2180
+ function De(t, r) {
2181
+ const e = [], a = (i, n, o) => {
2182
+ i.forEach((l, d) => {
2183
+ var h;
2184
+ e.push({ node: l, depth: n, parentId: o, position: d + 1, setSize: i.length }), (((h = l.children) == null ? void 0 : h.length) ?? 0) > 0 && r.has(l.id) && a(l.children ?? [], n + 1, l.id);
2185
+ });
2186
+ };
2187
+ return a(t, 0, null), e;
2188
+ }
2189
+ function zt(t) {
2190
+ const r = /* @__PURE__ */ new Set(), e = [], a = (i, n, o) => {
2191
+ i.forEach((l, d) => {
2192
+ if (r.has(l.id)) throw new Error(`Duplicate tree item id: ${String(l.id)}`);
2193
+ r.add(l.id), e.push({ node: l, depth: n, parentId: o, position: d + 1, setSize: i.length }), a(l.children ?? [], n + 1, l.id);
2194
+ });
2195
+ };
2196
+ return a(t, 0, null), e;
2197
+ }
2198
+ function qt(t) {
2199
+ return t.textValue != null ? t.textValue : typeof t.label == "string" || typeof t.label == "number" ? String(t.label) : String(t.id);
2200
+ }
2201
+ function Lt(t, r) {
2202
+ return t.length === r.length && t.every((e, a) => Object.is(e, r[a]));
2203
+ }
2204
+ function Vt(t) {
2205
+ return t != null && (typeof t == "object" || typeof t == "function") && typeof Reflect.get(t, "get") == "function" && typeof Reflect.get(t, "subscribe") == "function";
2206
+ }
2207
+ function Ut(t) {
2208
+ return t instanceof Element && t.closest('[data-part="expander"]') != null;
2209
+ }
2210
+ class se extends g {
2211
+ constructor(r = {}) {
2212
+ if (super(r), r.onClick != null && typeof r.onClick != "function")
2213
+ throw new TypeError("Button onClick must be a function");
2214
+ }
2215
+ render() {
2216
+ const {
2217
+ children: r = [],
2218
+ label: e,
2219
+ type: a = "button",
2220
+ disabled: i = !1,
2221
+ pressed: n,
2222
+ busy: o = !1,
2223
+ busyLabel: l,
2224
+ id: d,
2225
+ name: h,
2226
+ value: f,
2227
+ title: p,
2228
+ ariaLabel: m,
2229
+ onClick: b
2230
+ } = this.props, x = (Array.isArray(r) ? r.length > 0 : r != null && typeof r != "boolean") ? r : e ?? "", O = o ? l ?? x : x, $ = i || o;
2231
+ return /* @__PURE__ */ u(
2232
+ "button",
2233
+ {
2234
+ id: d,
2235
+ name: h,
2236
+ value: f == null ? void 0 : String(f),
2237
+ title: p,
2238
+ type: a,
2239
+ disabled: $,
2240
+ className: E(this.props) || void 0,
2241
+ "data-fray-component": "button",
2242
+ "aria-label": m,
2243
+ "aria-pressed": n == null ? null : String(!!n),
2244
+ "aria-busy": o ? "true" : null,
2245
+ onClick: (K) => {
2246
+ $ || C(b, K);
2247
+ },
2248
+ children: O
2249
+ }
2250
+ );
2251
+ }
2252
+ }
2253
+ s(se, "baseStyles", [
2254
+ ['button[data-fray-component="button"]', ["uiline", "button"]]
2255
+ ]), s(se, "css", v`
2256
+ button[data-fray-component="button"] {
2257
+ font-family: inherit;
2258
+ }
2259
+ `);
2260
+ class Oe extends g {
2261
+ constructor(e) {
2262
+ super(e);
2263
+ s(this, "openEmitter");
2264
+ s(this, "dialogId");
2265
+ s(this, "titleId");
2266
+ s(this, "descriptionId");
2267
+ s(this, "dialogElement", null);
2268
+ s(this, "restoreFocusTo", null);
2269
+ s(this, "synchronizedOpen", !1);
2270
+ this.openEmitter = M(this, e, !1, "dialog open state"), this.dialogId = j("dialog", e.id), this.titleId = `${this.dialogId}-title`, this.descriptionId = `${this.dialogId}-description`;
2271
+ }
2272
+ initialize() {
2273
+ this.watch(this.openEmitter);
2274
+ }
2275
+ render() {
2276
+ const {
2277
+ title: e,
2278
+ description: a,
2279
+ actions: i,
2280
+ closeLabel: n = "Close",
2281
+ showCloseButton: o = !0,
2282
+ children: l = []
2283
+ } = this.props;
2284
+ return /* @__PURE__ */ w(
2285
+ "dialog",
2286
+ {
2287
+ id: this.dialogId,
2288
+ className: E(this.props) || void 0,
2289
+ "data-fray-component": "dialog",
2290
+ "aria-labelledby": this.titleId,
2291
+ "aria-describedby": a == null ? null : this.descriptionId,
2292
+ "aria-modal": "true",
2293
+ ref: (d) => this.dialogElement = d,
2294
+ children: [
2295
+ /* @__PURE__ */ u("header", { "data-part": "header", children: /* @__PURE__ */ u("h2", { id: this.titleId, children: e }) }),
2296
+ a == null ? null : /* @__PURE__ */ u("p", { id: this.descriptionId, "data-part": "description", children: a }),
2297
+ /* @__PURE__ */ u("div", { "data-part": "content", children: l }),
2298
+ i == null && !o ? null : /* @__PURE__ */ w("footer", { "data-part": "actions", children: [
2299
+ i,
2300
+ o ? /* @__PURE__ */ u(
2301
+ se,
2302
+ {
2303
+ label: n,
2304
+ onClick: () => this.requestClose()
2305
+ }
2306
+ ) : null
2307
+ ] })
2308
+ ]
2309
+ }
2310
+ );
2311
+ }
2312
+ afterMount() {
2313
+ const e = this.dialogElement;
2314
+ e != null && (this.listen(e, "cancel", (a) => {
2315
+ a.preventDefault(), this.requestClose();
2316
+ }), this.listen(e, "close", () => {
2317
+ this.openEmitter.get() && this.openEmitter.set(!1, "native dialog closed"), this.finishClose();
2318
+ }), this.syncOpenState());
2319
+ }
2320
+ afterUpdate() {
2321
+ this.syncOpenState();
2322
+ }
2323
+ close() {
2324
+ this.requestClose();
2325
+ }
2326
+ onDestroy() {
2327
+ const e = this.dialogElement;
2328
+ (e == null ? void 0 : e.open) === !0 && typeof e.close == "function" && e.close(), this.finishClose(), this.dialogElement = null;
2329
+ }
2330
+ requestClose() {
2331
+ this.openEmitter.get() && this.openEmitter.set(!1, "dialog close requested");
2332
+ }
2333
+ syncOpenState() {
2334
+ const e = this.dialogElement;
2335
+ if (e == null) return;
2336
+ const a = this.openEmitter.get();
2337
+ if (a && !this.synchronizedOpen) {
2338
+ const i = document.activeElement;
2339
+ this.restoreFocusTo = i instanceof HTMLElement ? i : null, Pt(e), this.synchronizedOpen = !0, Bt(e, this.props.initialFocusRef);
2340
+ return;
2341
+ }
2342
+ !a && this.synchronizedOpen && (e.open && typeof e.close == "function" ? e.close() : e.removeAttribute("open"), this.finishClose());
2343
+ }
2344
+ finishClose() {
2345
+ if (!this.synchronizedOpen && this.restoreFocusTo == null) return;
2346
+ this.synchronizedOpen = !1;
2347
+ const e = this.restoreFocusTo;
2348
+ this.restoreFocusTo = null, (e == null ? void 0 : e.isConnected) === !0 && e.focus(), C(this.props.onClose);
2349
+ }
2350
+ }
2351
+ s(Oe, "dependencies", [se]), s(Oe, "css", v`
2352
+ dialog[data-fray-component="dialog"] {
2353
+ width: min(38rem, calc(100vw - 2rem));
2354
+ max-height: min(42rem, calc(100dvh - 2rem));
2355
+ padding: 0;
2356
+ color: var(--fray-panel-color, var(--ui-text-color));
2357
+ background: var(--fray-panel-background, var(--panel-bg));
2358
+ border: var(--fray-panel-border, var(--panel-border));
2359
+ border-radius: var(--fray-panel-radius, var(--panel-radius));
2360
+ box-shadow: var(--fray-dialog-shadow, var(--fray-panel-shadow));
2361
+ }
2362
+
2363
+ dialog[data-fray-component="dialog"]::backdrop {
2364
+ background: var(--fray-dialog-backdrop-background);
2365
+ }
2366
+
2367
+ dialog[data-fray-component="dialog"] > [data-part] {
2368
+ padding: var(--panel-padding, 0.75rem);
2369
+ }
2370
+
2371
+ dialog[data-fray-component="dialog"] > [data-part="header"] {
2372
+ color: var(
2373
+ --fray-dialog-header-color,
2374
+ var(--fray-section-header-color, var(--fray-header-color))
2375
+ );
2376
+ background: var(
2377
+ --fray-dialog-header-background,
2378
+ var(--fray-section-header-background, var(--fray-header-background))
2379
+ );
2380
+ border-block-end: var(
2381
+ --fray-section-header-border,
2382
+ var(--fray-header-border)
2383
+ );
2384
+ }
2385
+
2386
+ dialog[data-fray-component="dialog"] > [data-part="header"] h2,
2387
+ dialog[data-fray-component="dialog"] > [data-part="description"] {
2388
+ margin: 0;
2389
+ }
2390
+
2391
+ dialog[data-fray-component="dialog"] > [data-part="content"] {
2392
+ overflow: auto;
2393
+ }
2394
+
2395
+ dialog[data-fray-component="dialog"] > [data-part="actions"] {
2396
+ display: flex;
2397
+ justify-content: flex-end;
2398
+ gap: var(--spacing-small, 0.5rem);
2399
+ border-block-start: 1px solid var(--ui-border-color);
2400
+ }
2401
+
2402
+ @media (prefers-reduced-motion: no-preference) {
2403
+ dialog[data-fray-component="dialog"][open] {
2404
+ animation: fray-dialog-enter 120ms ease-out;
2405
+ }
2406
+ }
2407
+
2408
+ @keyframes fray-dialog-enter {
2409
+ from {
2410
+ transform: translateY(0.4rem);
2411
+ }
2412
+ }
2413
+
2414
+ @media (forced-colors: active) {
2415
+ dialog[data-fray-component="dialog"] {
2416
+ border: 2px solid CanvasText;
2417
+ }
2418
+ }
2419
+ `);
2420
+ function Pt(t) {
2421
+ if (!t.open) {
2422
+ if (typeof t.showModal == "function") {
2423
+ t.showModal();
2424
+ return;
2425
+ }
2426
+ t.setAttribute("open", "");
2427
+ }
2428
+ }
2429
+ function Bt(t, r) {
2430
+ const a = (r == null || typeof r == "function" ? null : r.current) ?? t.querySelector(
2431
+ '[autofocus], button, input, select, textarea, [tabindex]:not([tabindex="-1"])'
2432
+ );
2433
+ a == null || a.focus();
2434
+ }
2435
+ const z = class z extends D {
2436
+ constructor(r = {}) {
2437
+ super({ ...r, symbols: z.symbols });
2438
+ }
2439
+ };
2440
+ s(z, "hostName", "quad-checkbox"), s(z, "standaloneHostName", "quad-checkbox"), s(z, "symbols", [
2441
+ ["✖", y.Deny],
2442
+ ["☐", y.Neutral],
2443
+ ["✓", y.Prefer],
2444
+ ["+", y.Require]
2445
+ ]), s(z, "defaultSemanticState", y.Neutral);
2446
+ let $e = z;
2447
+ const q = class q extends D {
2448
+ constructor(r = {}) {
2449
+ super({ ...r, symbols: q.symbols });
2450
+ }
2451
+ };
2452
+ s(q, "hostName", "tri-checkbox"), s(q, "standaloneHostName", "tri-checkbox"), s(q, "symbols", [
2453
+ ["✖", y.Deny],
2454
+ ["☐", y.Neutral],
2455
+ ["✓", y.Prefer]
2456
+ ]), s(q, "defaultSemanticState", y.Neutral);
2457
+ let Ce = q;
2458
+ class ee extends g {
2459
+ constructor(e = {}) {
2460
+ var n;
2461
+ super(e);
2462
+ s(this, "inputId");
2463
+ s(this, "errorId");
2464
+ s(this, "optionsEmitter");
2465
+ s(this, "valueEmitter");
2466
+ s(this, "ownsOptionsEmitter");
2467
+ this.inputId = j("dropdown", e.id), this.errorId = `${this.inputId}-error`;
2468
+ const a = e.options ?? [];
2469
+ Gt(a) ? (this.optionsEmitter = a, this.ownsOptionsEmitter = !1) : (fe(a), this.optionsEmitter = new I(a, {
2470
+ owner: this,
2471
+ purpose: "dropdown options"
2472
+ }), this.ownsOptionsEmitter = !0);
2473
+ const i = ((n = this.optionsEmitter.get()[0]) == null ? void 0 : n.value) ?? "";
2474
+ this.valueEmitter = M(this, e, i, "dropdown value");
2475
+ }
2476
+ initialize() {
2477
+ this.watch(this.valueEmitter, this.optionsEmitter);
2478
+ }
2479
+ render() {
2480
+ const {
2481
+ label: e,
2482
+ name: a,
2483
+ disabled: i = !1,
2484
+ required: n = !1,
2485
+ error: o = null,
2486
+ placeholder: l = "Select…",
2487
+ ariaLabel: d,
2488
+ onChange: h
2489
+ } = this.props, f = this.optionsEmitter.get() ?? [];
2490
+ fe(f);
2491
+ const p = this.valueEmitter.get(), m = this.Host;
2492
+ return /* @__PURE__ */ w(
2493
+ m,
2494
+ {
2495
+ className: E(this.props) || null,
2496
+ "data-disabled": i ? "" : null,
2497
+ "data-required": n ? "" : null,
2498
+ "data-error": o == null ? null : "",
2499
+ children: [
2500
+ e == null ? null : /* @__PURE__ */ u("label", { htmlFor: this.inputId, children: e }),
2501
+ /* @__PURE__ */ w(
2502
+ "select",
2503
+ {
2504
+ id: this.inputId,
2505
+ name: a,
2506
+ value: p == null ? "" : String(p),
2507
+ disabled: i,
2508
+ required: n,
2509
+ "aria-label": e == null ? d : null,
2510
+ "aria-invalid": o == null ? null : "true",
2511
+ "aria-describedby": o == null ? null : this.errorId,
2512
+ onChange: (b) => {
2513
+ const S = Qt(b, "dropdown change"), x = f.find(({ value: $ }) => String($) === S), O = (x == null ? void 0 : x.value) ?? S;
2514
+ this.valueEmitter.set(O, "dropdown selection"), C(h, O, b);
2515
+ },
2516
+ children: [
2517
+ p == null || p === "" ? /* @__PURE__ */ u("option", { value: "", disabled: n, selected: !0, children: l }) : null,
2518
+ f.map((b) => {
2519
+ if (b == null || !Object.hasOwn(b, "value"))
2520
+ throw new TypeError("Dropdown options require value and label fields");
2521
+ return /* @__PURE__ */ u(
2522
+ "option",
2523
+ {
2524
+ value: String(b.value),
2525
+ disabled: !!b.disabled,
2526
+ selected: Object.is(p, b.value),
2527
+ children: b.label ?? String(b.value)
2528
+ },
2529
+ String(b.value)
2530
+ );
2531
+ })
2532
+ ]
2533
+ }
2534
+ ),
2535
+ o == null ? null : /* @__PURE__ */ u(
2536
+ "p",
2537
+ {
2538
+ id: this.errorId,
2539
+ "data-part": "error",
2540
+ role: "alert",
2541
+ children: String(o)
2542
+ }
2543
+ )
2544
+ ]
2545
+ }
2546
+ );
2547
+ }
2548
+ }
2549
+ s(ee, "hostName", "dropdown"), s(ee, "standaloneHostName", "drop-down"), s(ee, "baseStyles", [
2550
+ ["&", ["labeledinput", "inputline"]],
2551
+ ["& > label", ["label"]],
2552
+ ["& > select", ["input", "inputline"]],
2553
+ ["&[data-disabled]", ["disabled"]],
2554
+ ["&[data-error]", ["error"]]
2555
+ ]), s(ee, "css", v`
2556
+ & {
2557
+ position: relative;
2558
+ }
2559
+ `);
2560
+ function Gt(t) {
2561
+ return t != null && (typeof t == "object" || typeof t == "function") && typeof Reflect.get(t, "get") == "function" && typeof Reflect.get(t, "subscribe") == "function";
2562
+ }
2563
+ function Qt(t, r) {
2564
+ const e = t.currentTarget;
2565
+ if (e == null || typeof Reflect.get(e, "value") != "string")
2566
+ throw new TypeError(`${r} requires a value-bearing event target`);
2567
+ return Reflect.get(e, "value");
2568
+ }
2569
+ class te extends g {
2570
+ constructor(e = {}) {
2571
+ super(e);
2572
+ s(this, "inputId");
2573
+ s(this, "errorId");
2574
+ s(this, "valueEmitter");
2575
+ this.inputId = j("textbox", e.id), this.errorId = `${this.inputId}-error`, this.valueEmitter = M(this, e, "", "textbox value");
2576
+ }
2577
+ initialize() {
2578
+ this.watch(this.valueEmitter);
2579
+ }
2580
+ render() {
2581
+ const {
2582
+ label: e,
2583
+ placeholder: a,
2584
+ type: i = "text",
2585
+ name: n,
2586
+ disabled: o = !1,
2587
+ required: l = !1,
2588
+ readOnly: d = !1,
2589
+ error: h = null,
2590
+ autoComplete: f,
2591
+ inputMode: p,
2592
+ minLength: m,
2593
+ maxLength: b,
2594
+ pattern: S,
2595
+ ariaLabel: x,
2596
+ inputRef: O,
2597
+ onInput: $,
2598
+ onChange: K
2599
+ } = this.props, A = this.valueEmitter.get() ?? "", F = this.Host;
2600
+ return /* @__PURE__ */ w(
2601
+ F,
2602
+ {
2603
+ className: E(this.props) || null,
2604
+ "data-disabled": o ? "" : null,
2605
+ "data-required": l ? "" : null,
2606
+ "data-error": h == null ? null : "",
2607
+ children: [
2608
+ e == null ? null : /* @__PURE__ */ u("label", { htmlFor: this.inputId, children: e }),
2609
+ /* @__PURE__ */ u(
2610
+ "input",
2611
+ {
2612
+ id: this.inputId,
2613
+ name: n,
2614
+ type: i,
2615
+ value: A,
2616
+ placeholder: a,
2617
+ disabled: o,
2618
+ required: l,
2619
+ readOnly: d,
2620
+ autoComplete: f,
2621
+ inputMode: p,
2622
+ minLength: m,
2623
+ maxLength: b,
2624
+ pattern: S,
2625
+ ref: O,
2626
+ "aria-label": e == null ? x : null,
2627
+ "aria-invalid": h == null ? null : "true",
2628
+ "aria-describedby": h == null ? null : this.errorId,
2629
+ onInput: (T) => {
2630
+ const B = Ke(T, "textbox input");
2631
+ this.valueEmitter.set(B, "textbox input"), C($, B, T);
2632
+ },
2633
+ onChange: (T) => C(
2634
+ K,
2635
+ Ke(T, "textbox change"),
2636
+ T
2637
+ )
2638
+ }
2639
+ ),
2640
+ h == null ? null : /* @__PURE__ */ u(
2641
+ "p",
2642
+ {
2643
+ id: this.errorId,
2644
+ "data-part": "error",
2645
+ role: "alert",
2646
+ children: String(h)
2647
+ }
2648
+ )
2649
+ ]
2650
+ }
2651
+ );
2652
+ }
2653
+ }
2654
+ s(te, "hostName", "textbox"), s(te, "standaloneHostName", "text-box"), s(te, "baseStyles", [
2655
+ ["&", ["labeledinput", "inputline"]],
2656
+ ["& > label", ["label"]],
2657
+ ["& > input", ["input", "inputline"]],
2658
+ ["&[data-disabled]", ["disabled"]],
2659
+ ["&[data-error]", ["error"]]
2660
+ ]), s(te, "css", v`
2661
+ & input {
2662
+ cursor: text;
2663
+ }
2664
+
2665
+ & > [data-part="error"] {
2666
+ margin: 0;
2667
+ color: var(--fray-color-error, var(--error-color));
2668
+ }
2669
+ `);
2670
+ function Ke(t, r) {
2671
+ const e = t.currentTarget;
2672
+ if (e == null || typeof Reflect.get(e, "value") != "string")
2673
+ throw new TypeError(`${r} requires a value-bearing event target`);
2674
+ return Reflect.get(e, "value");
2675
+ }
2676
+ class Ae extends g {
2677
+ constructor(e = {}) {
2678
+ var n;
2679
+ super(e);
2680
+ s(this, "valueEmitter");
2681
+ s(this, "groupId");
2682
+ s(this, "legendId");
2683
+ const a = e.options ?? [];
2684
+ je(a);
2685
+ const i = ((n = a[0]) == null ? void 0 : n[0]) ?? null;
2686
+ this.valueEmitter = M(
2687
+ this,
2688
+ e,
2689
+ i ?? null,
2690
+ "toggle value"
2691
+ ), this.groupId = j("toggle", e.id), this.legendId = `${this.groupId}-label`;
2692
+ }
2693
+ initialize() {
2694
+ this.watch(this.valueEmitter);
2695
+ }
2696
+ selectOption(e, a = null) {
2697
+ this.props.disabled || (this.valueEmitter.set(e, "toggle option selected"), C(this.props.onChange, e, a));
2698
+ }
2699
+ render() {
2700
+ const {
2701
+ options: e = [],
2702
+ label: a,
2703
+ disabled: i = !1,
2704
+ required: n = !1
2705
+ } = this.props;
2706
+ je(e);
2707
+ const o = this.valueEmitter.get(), l = Math.max(
2708
+ 0,
2709
+ e.findIndex(([d]) => Object.is(d, o))
2710
+ );
2711
+ return /* @__PURE__ */ w(
2712
+ "fieldset",
2713
+ {
2714
+ id: this.groupId,
2715
+ disabled: i,
2716
+ className: E(this.props) || void 0,
2717
+ "data-fray-component": "toggle",
2718
+ "data-disabled": i ? "" : null,
2719
+ "aria-required": n ? "true" : null,
2720
+ children: [
2721
+ a == null ? null : /* @__PURE__ */ u("legend", { id: this.legendId, children: a }),
2722
+ /* @__PURE__ */ u(
2723
+ "div",
2724
+ {
2725
+ "data-part": "options",
2726
+ role: "radiogroup",
2727
+ "aria-label": a == null ? this.props.ariaLabel : null,
2728
+ "aria-labelledby": a == null ? null : this.legendId,
2729
+ children: e.map(([d, h], f) => /* @__PURE__ */ u(
2730
+ "button",
2731
+ {
2732
+ type: "button",
2733
+ role: "radio",
2734
+ disabled: i,
2735
+ "data-part": "option",
2736
+ "aria-checked": Object.is(o, d) ? "true" : "false",
2737
+ "data-value": String(d),
2738
+ tabIndex: f === l ? 0 : -1,
2739
+ onClick: (p) => this.selectOption(d, p),
2740
+ onKeyDown: (p) => this.handleKeyDown(p, f, e),
2741
+ children: h
2742
+ },
2743
+ String(d)
2744
+ ))
2745
+ }
2746
+ )
2747
+ ]
2748
+ }
2749
+ );
2750
+ }
2751
+ handleKeyDown(e, a, i) {
2752
+ const { key: n } = e;
2753
+ let o;
2754
+ if (n === "ArrowRight" || n === "ArrowDown") o = (a + 1) % i.length;
2755
+ else if (n === "ArrowLeft" || n === "ArrowUp")
2756
+ o = (a - 1 + i.length) % i.length;
2757
+ else if (n === "Home") o = 0;
2758
+ else if (n === "End") o = i.length - 1;
2759
+ else return;
2760
+ e.preventDefault();
2761
+ const l = i[o];
2762
+ if (l != null && (this.selectOption(l[0], e), this.dom instanceof Element)) {
2763
+ const d = this.dom.querySelectorAll('[role="radio"]')[o];
831
2764
  d == null || d.focus();
832
2765
  }
833
2766
  }
834
2767
  }
835
- a(X, "baseStyles", [
2768
+ s(Ae, "baseStyles", [
836
2769
  ['fieldset[data-fray-component="toggle"] > [data-part="options"]', ["uiline"]],
837
2770
  ['fieldset[data-fray-component="toggle"] [data-part="option"]', ["uiline", "button"]]
838
- ]), a(X, "css", m`
2771
+ ]), s(Ae, "css", v`
839
2772
  fieldset[data-fray-component="toggle"] {
840
2773
  margin: 0;
841
2774
  padding: 0;
@@ -848,6 +2781,7 @@ a(X, "baseStyles", [
848
2781
  }
849
2782
 
850
2783
  fieldset[data-fray-component="toggle"] [data-part="option"] {
2784
+ background: var(--fray-toggle-button-background, var(--fray-button-background));
851
2785
  border-radius: 0;
852
2786
  }
853
2787
 
@@ -860,44 +2794,47 @@ a(X, "baseStyles", [
860
2794
  }
861
2795
 
862
2796
  fieldset[data-fray-component="toggle"] [data-part="option"][aria-checked="true"] {
863
- background: var(--toggle-selected-bg, var(--ui-accent-color));
864
- color: var(--toggle-selected-text, white);
2797
+ background: var(
2798
+ --fray-toggle-button-background-checked,
2799
+ var(--fray-selection-background, var(--toggle-selected-bg))
2800
+ );
2801
+ color: var(--fray-selection-color, var(--toggle-selected-text));
865
2802
  }
866
2803
  `);
867
- function Y(n) {
868
- B(n);
869
- for (const s of n)
870
- if (!Array.isArray(s) || s.length < 2)
2804
+ function je(t) {
2805
+ fe(t);
2806
+ for (const r of t)
2807
+ if (!Array.isArray(r) || r.length < 2)
871
2808
  throw new TypeError("Toggle options must be [value, label] tuples");
872
2809
  }
873
- class V extends p {
2810
+ class re extends g {
874
2811
  render() {
875
2812
  const {
876
- children: s = [],
877
- id: t,
878
- label: r = "Actions",
2813
+ children: r = [],
2814
+ id: e,
2815
+ label: a = "Actions",
879
2816
  orientation: i = "horizontal"
880
2817
  } = this.props;
881
2818
  if (!["horizontal", "vertical"].includes(i))
882
2819
  throw new TypeError("Toolbar orientation must be horizontal or vertical");
883
- const e = this.Host;
884
- return /* @__PURE__ */ c(
885
- e,
2820
+ const n = this.Host;
2821
+ return /* @__PURE__ */ u(
2822
+ n,
886
2823
  {
887
- id: t,
2824
+ id: e,
888
2825
  role: "toolbar",
889
- className: b(this.props) || null,
2826
+ className: E(this.props) || null,
890
2827
  "data-orientation": i,
891
- "aria-label": r,
2828
+ "aria-label": a,
892
2829
  "aria-orientation": i,
893
- children: s
2830
+ children: r
894
2831
  }
895
2832
  );
896
2833
  }
897
2834
  }
898
- a(V, "hostName", "toolbar"), a(V, "standaloneHostName", "tool-bar"), a(V, "baseStyles", [
2835
+ s(re, "hostName", "toolbar"), s(re, "standaloneHostName", "tool-bar"), s(re, "baseStyles", [
899
2836
  ["&", ["toolbar"]]
900
- ]), a(V, "css", m`
2837
+ ]), s(re, "css", v`
901
2838
  & {
902
2839
  display: flex;
903
2840
  flex-wrap: wrap;
@@ -911,40 +2848,40 @@ a(V, "hostName", "toolbar"), a(V, "standaloneHostName", "tool-bar"), a(V, "baseS
911
2848
  align-items: stretch;
912
2849
  }
913
2850
  `);
914
- class C extends p {
915
- constructor(t) {
916
- super(t);
917
- a(this, "progressId");
918
- if (this.progressId = x("progress", t.id), t.valueEmitter != null && !ut(t.valueEmitter))
2851
+ class he extends g {
2852
+ constructor(e) {
2853
+ super(e);
2854
+ s(this, "progressId");
2855
+ if (this.progressId = j("progress", e.id), e.valueEmitter != null && !Wt(e.valueEmitter))
919
2856
  throw new TypeError("ProgressBar valueEmitter must be a readable emitter");
920
2857
  }
921
2858
  render() {
922
- const t = this.props.max ?? 100;
923
- if (!Number.isFinite(t) || t <= 0)
2859
+ const e = this.props.max ?? 100;
2860
+ if (!Number.isFinite(e) || e <= 0)
924
2861
  throw new RangeError("ProgressBar max must be a positive finite number");
925
- const r = this.props.valueEmitter == null ? this.props.value ?? null : this.read(this.props.valueEmitter);
926
- if (r != null && (!Number.isFinite(r) || r < 0))
2862
+ const a = this.props.valueEmitter == null ? this.props.value ?? null : this.read(this.props.valueEmitter);
2863
+ if (a != null && (!Number.isFinite(a) || a < 0))
927
2864
  throw new RangeError("ProgressBar value must be null or a non-negative finite number");
928
- const i = r == null ? null : Math.min(r, t), e = this.props.valueText ?? (i == null ? "In progress" : `${Math.round(i / t * 100)}%`), l = this.Host;
929
- return /* @__PURE__ */ g(l, { className: b(this.props) || null, children: [
930
- /* @__PURE__ */ g("div", { "data-part": "label-line", children: [
931
- /* @__PURE__ */ c("label", { htmlFor: this.progressId, children: this.props.label }),
932
- /* @__PURE__ */ c("span", { "data-part": "value", children: e })
2865
+ const i = a == null ? null : Math.min(a, e), n = this.props.valueText ?? (i == null ? "In progress" : `${Math.round(i / e * 100)}%`), o = this.Host;
2866
+ return /* @__PURE__ */ w(o, { className: E(this.props) || null, children: [
2867
+ /* @__PURE__ */ w("div", { "data-part": "label-line", children: [
2868
+ /* @__PURE__ */ u("label", { htmlFor: this.progressId, children: this.props.label }),
2869
+ /* @__PURE__ */ u("span", { "data-part": "value", children: n })
933
2870
  ] }),
934
- /* @__PURE__ */ c(
2871
+ /* @__PURE__ */ u(
935
2872
  "progress",
936
2873
  {
937
2874
  id: this.progressId,
938
2875
  value: i ?? void 0,
939
- max: t,
940
- "aria-valuetext": e,
941
- children: e
2876
+ max: e,
2877
+ "aria-valuetext": n,
2878
+ children: n
942
2879
  }
943
2880
  )
944
2881
  ] });
945
2882
  }
946
2883
  }
947
- a(C, "hostName", "progress-bar"), a(C, "standaloneHostName", "progress-bar"), a(C, "css", m`
2884
+ s(he, "hostName", "progress-bar"), s(he, "standaloneHostName", "progress-bar"), s(he, "css", v`
948
2885
  & {
949
2886
  display: grid;
950
2887
  gap: var(--spacing-small, 0.5rem);
@@ -963,7 +2900,9 @@ a(C, "hostName", "progress-bar"), a(C, "standaloneHostName", "progress-bar"), a(
963
2900
  & > progress {
964
2901
  width: 100%;
965
2902
  min-height: 0.8rem;
966
- accent-color: var(--ui-accent-color);
2903
+ color: var(--fray-progress-value-background, var(--ui-accent-color));
2904
+ background: var(--fray-progress-track-background, transparent);
2905
+ accent-color: var(--fray-color-primary, var(--ui-accent-color));
967
2906
  }
968
2907
 
969
2908
  @media (forced-colors: active) {
@@ -972,43 +2911,352 @@ a(C, "hostName", "progress-bar"), a(C, "standaloneHostName", "progress-bar"), a(
972
2911
  }
973
2912
  }
974
2913
  `);
975
- function ut(n) {
976
- return n != null && (typeof n == "object" || typeof n == "function") && typeof Reflect.get(n, "get") == "function" && typeof Reflect.get(n, "subscribe") == "function";
2914
+ function Wt(t) {
2915
+ return t != null && (typeof t == "object" || typeof t == "function") && typeof Reflect.get(t, "get") == "function" && typeof Reflect.get(t, "subscribe") == "function";
2916
+ }
2917
+ const ur = Object.freeze([
2918
+ c("--fray-color-canvas", "color", "palette", "color", "Application canvas"),
2919
+ c("--fray-color-surface", "color", "palette", "color", "Primary surface"),
2920
+ c("--fray-color-surface-muted", "color", "palette", "color", "Subdued surface"),
2921
+ c("--fray-color-surface-raised", "color", "palette", "color", "Raised surface"),
2922
+ c("--fray-color-surface-inset", "color", "palette", "color", "Inset surface"),
2923
+ c("--fray-color-text", "color", "palette", "color", "Primary text"),
2924
+ c("--fray-color-text-muted", "color", "palette", "color", "Secondary text"),
2925
+ c("--fray-color-border", "color", "palette", "color", "Ordinary border"),
2926
+ c("--fray-color-border-strong", "color", "palette", "color", "Emphasized border"),
2927
+ c("--fray-color-primary", "color", "palette", "color", "Primary accent"),
2928
+ c("--fray-color-primary-hover", "color", "palette", "color", "Hovered accent"),
2929
+ c("--fray-color-primary-active", "color", "palette", "color", "Active accent"),
2930
+ c("--fray-color-primary-soft", "color", "palette", "color", "Subtle accent surface"),
2931
+ c("--fray-color-on-primary", "color", "palette", "color", "Content on primary accent"),
2932
+ c("--fray-color-focus", "color", "palette", "color", "Keyboard focus indication"),
2933
+ c("--fray-color-selection", "color", "palette", "color", "Selected item surface"),
2934
+ c("--fray-color-on-selection", "color", "palette", "color", "Content on selection"),
2935
+ c("--fray-color-disabled", "color", "palette", "color", "Disabled surface"),
2936
+ c("--fray-color-on-disabled", "color", "palette", "color", "Disabled content"),
2937
+ c("--fray-color-error", "color", "status", "color", "Error state"),
2938
+ c("--fray-color-on-error", "color", "status", "color", "Content on error"),
2939
+ c("--fray-color-success", "color", "status", "color", "Success state"),
2940
+ c("--fray-color-on-success", "color", "status", "color", "Content on success"),
2941
+ c("--fray-color-highlight", "color", "palette", "color", "Light reflection/highlight"),
2942
+ c("--fray-color-shadow", "color", "palette", "color", "Shadow tint"),
2943
+ c("--fray-font-family", "theme", "typography", "font", "UI font stack"),
2944
+ c("--fray-font-size", "theme", "typography", "dimension", "Base UI font size"),
2945
+ c("--fray-line-height", "theme", "typography", "dimension", "Base UI line height"),
2946
+ c("--fray-control-min-height", "theme", "control", "dimension", "Minimum control height"),
2947
+ c("--fray-space-xs", "theme", "spacing", "dimension", "Extra-small spacing"),
2948
+ c("--fray-space-sm", "theme", "spacing", "dimension", "Small spacing"),
2949
+ c("--fray-space-md", "theme", "spacing", "dimension", "Medium spacing"),
2950
+ c("--fray-space-lg", "theme", "spacing", "dimension", "Large spacing"),
2951
+ c("--fray-radius-sm", "theme", "shape", "radius", "Small corner radius"),
2952
+ c("--fray-radius-md", "theme", "shape", "radius", "Ordinary corner radius"),
2953
+ c("--fray-radius-lg", "theme", "shape", "radius", "Large corner radius"),
2954
+ c("--fray-motion-fast", "theme", "motion", "duration", "Fast interaction transition"),
2955
+ c("--fray-ui-background", "theme", "surface", "background", "Default UI background"),
2956
+ c("--fray-ui-color", "theme", "surface", "color", "Default UI text"),
2957
+ c("--fray-ui-border", "theme", "surface", "border", "Default UI border"),
2958
+ c("--fray-ui-shadow", "theme", "surface", "shadow", "Default raised shadow"),
2959
+ c("--fray-focus-ring", "theme", "focus", "shadow", "Keyboard focus ring"),
2960
+ c("--fray-panel-background", "theme", "panel", "background", "Panel surface", "--fray-ui-background"),
2961
+ c("--fray-panel-color", "theme", "panel", "color", "Panel content", "--fray-ui-color"),
2962
+ c("--fray-panel-border", "theme", "panel", "border", "Panel border", "--fray-ui-border"),
2963
+ c("--fray-panel-shadow", "theme", "panel", "shadow", "Panel shadow", "--fray-ui-shadow"),
2964
+ c("--fray-panel-radius", "theme", "panel", "radius", "Panel radius", "--fray-radius-md"),
2965
+ c("--fray-dialog-shadow", "theme", "dialog", "shadow", "Modal dialog shadow", "--fray-panel-shadow"),
2966
+ c("--fray-dialog-backdrop-background", "theme", "dialog", "background", "Modal backdrop"),
2967
+ c("--fray-header-background", "theme", "header", "background", "Generic header surface"),
2968
+ c("--fray-header-color", "theme", "header", "color", "Generic header content"),
2969
+ c("--fray-header-border", "theme", "header", "border", "Generic header border"),
2970
+ c("--fray-header-shadow", "theme", "header", "shadow", "Generic header shadow"),
2971
+ c("--fray-section-header-background", "theme", "header", "background", "Section header surface", "--fray-header-background"),
2972
+ c("--fray-section-header-color", "theme", "header", "color", "Section header content", "--fray-header-color"),
2973
+ c("--fray-section-header-border", "theme", "header", "border", "Section header border", "--fray-header-border"),
2974
+ c("--fray-section-header-shadow", "theme", "header", "shadow", "Section header shadow", "--fray-header-shadow"),
2975
+ c("--fray-panel-header-background", "theme", "header", "background", "Panel header surface", "--fray-section-header-background"),
2976
+ c("--fray-panel-header-color", "theme", "header", "color", "Panel header content", "--fray-section-header-color"),
2977
+ c("--fray-table-header-background", "theme", "header", "background", "Table header surface", "--fray-section-header-background"),
2978
+ c("--fray-table-header-color", "theme", "header", "color", "Table header content", "--fray-section-header-color"),
2979
+ c("--fray-dialog-header-background", "theme", "header", "background", "Dialog header surface", "--fray-section-header-background"),
2980
+ c("--fray-dialog-header-color", "theme", "header", "color", "Dialog header content", "--fray-section-header-color"),
2981
+ c("--fray-button-background", "theme", "button", "background", "Generic button surface"),
2982
+ c("--fray-button-background-hover", "theme", "button", "background", "Hovered button surface"),
2983
+ c("--fray-button-background-active", "theme", "button", "background", "Pressed button surface"),
2984
+ c("--fray-button-background-disabled", "theme", "button", "background", "Disabled button surface"),
2985
+ c("--fray-button-color", "theme", "button", "color", "Generic button content"),
2986
+ c("--fray-button-border", "theme", "button", "border", "Generic button border"),
2987
+ c("--fray-button-shadow", "theme", "button", "shadow", "Generic button shadow"),
2988
+ c("--fray-button-shadow-active", "theme", "button", "shadow", "Pressed button shadow"),
2989
+ c("--fray-toggle-button-background", "theme", "button", "background", "Toggle option surface", "--fray-button-background"),
2990
+ c("--fray-toggle-button-background-checked", "theme", "button", "background", "Selected toggle option", "--fray-selection-background"),
2991
+ c("--fray-tab-button-background", "theme", "button", "background", "Tab surface", "--fray-button-background"),
2992
+ c("--fray-tab-button-background-active", "theme", "button", "background", "Active tab surface", "--fray-tab-active-background"),
2993
+ c("--fray-menu-button-background", "theme", "button", "background", "Menu action surface", "--fray-button-background"),
2994
+ c("--fray-dropdown-trigger-background", "theme", "button", "background", "Dropdown arrow/trigger surface", "--fray-button-background"),
2995
+ c("--fray-table-header-button-background", "theme", "button", "background", "Table-header action surface", "--fray-button-background"),
2996
+ c("--fray-input-background", "theme", "input", "background", "Input surface"),
2997
+ c("--fray-input-color", "theme", "input", "color", "Input content"),
2998
+ c("--fray-input-border", "theme", "input", "border", "Input border"),
2999
+ c("--fray-input-shadow", "theme", "input", "shadow", "Input shadow"),
3000
+ c("--fray-input-background-disabled", "theme", "input", "background", "Disabled input surface"),
3001
+ c("--fray-input-color-disabled", "theme", "input", "color", "Disabled input content"),
3002
+ c("--fray-selection-background", "theme", "selection", "background", "Selected item surface"),
3003
+ c("--fray-selection-color", "theme", "selection", "color", "Selected item content"),
3004
+ c("--fray-row-hover-background", "theme", "row", "background", "Hovered list/table/tree row"),
3005
+ c("--fray-table-row-background", "theme", "table", "background", "Odd table row surface"),
3006
+ c("--fray-table-row-alt-background", "theme", "table", "background", "Even table row surface"),
3007
+ c("--fray-checkbox-box-background", "theme", "checkbox", "background", "Unchecked checkbox box", "--fray-input-background"),
3008
+ c("--fray-checkbox-box-background-checked", "theme", "checkbox", "background", "Checked checkbox box", "--fray-selection-background"),
3009
+ c("--fray-checkbox-box-border", "theme", "checkbox", "border", "Checkbox box border", "--fray-input-border"),
3010
+ c("--fray-checkbox-symbol-color", "theme", "checkbox", "color", "Checkbox symbol", "--fray-selection-color"),
3011
+ c("--fray-radio-background", "theme", "radio", "background", "Radio/toggle option surface", "--fray-toggle-button-background"),
3012
+ c("--fray-radio-background-checked", "theme", "radio", "background", "Selected radio/toggle option", "--fray-selection-background"),
3013
+ c("--fray-toolbar-background", "theme", "toolbar", "background", "Toolbar surface", "--fray-panel-background"),
3014
+ c("--fray-toolbar-color", "theme", "toolbar", "color", "Toolbar content", "--fray-panel-color"),
3015
+ c("--fray-toolbar-border", "theme", "toolbar", "border", "Toolbar border", "--fray-panel-border"),
3016
+ c("--fray-toolbar-shadow", "theme", "toolbar", "shadow", "Toolbar shadow", "--fray-panel-shadow"),
3017
+ c("--fray-tabline-background", "theme", "tabs", "background", "Tab strip surface", "--fray-panel-background"),
3018
+ c("--fray-tab-active-background", "theme", "tabs", "background", "Active tab surface", "--fray-panel-background"),
3019
+ c("--fray-progress-track-background", "theme", "progress", "background", "Progress track"),
3020
+ c("--fray-progress-value-background", "theme", "progress", "background", "Progress value"),
3021
+ c("--fray-working-background-image", "theme", "status", "background", "Indeterminate/loading texture")
3022
+ ]), Jt = Object.freeze([
3023
+ R("shiny", "Shiny", N("themes/shiny/theme.css")),
3024
+ R("java", "Java", N("themes/java/theme.css")),
3025
+ R("minimal", "Minimal", N("themes/minimal/theme.css"))
3026
+ ]), Yt = Object.freeze([
3027
+ R("iceblue", "Ice blue", N("colors/iceblue/colors.css")),
3028
+ R("ocean", "Ocean", N("colors/ocean/colors.css")),
3029
+ R("green", "Green", N("colors/green/colors.css")),
3030
+ R("gray", "Gray", N("colors/gray/colors.css")),
3031
+ R("orange", "Orange", N("colors/orange/colors.css")),
3032
+ R("purple", "Purple", N("colors/purple/colors.css")),
3033
+ R("red", "Red", N("colors/red/colors.css")),
3034
+ R("yellow", "Yellow", N("colors/yellow/colors.css"))
3035
+ ]);
3036
+ function _t(t, r, e = globalThis.document) {
3037
+ if (Xt(r), (e == null ? void 0 : e.head) == null || e.documentElement == null)
3038
+ throw new TypeError("replaceFrayStylesheet requires a document with a head and root");
3039
+ const a = `link[data-fray-stylesheet="${t}"]`;
3040
+ let i = e.head.querySelector(a);
3041
+ return i == null && (i = e.createElement("link"), i.rel = "stylesheet", i.dataset.frayStylesheet = t, e.head.append(i)), i.dataset.fraySelection = r.value, i.getAttribute("href") !== r.href && i.setAttribute("href", r.href), t === "theme" ? e.documentElement.dataset.frayTheme = r.value : e.documentElement.dataset.frayColor = r.value, i;
3042
+ }
3043
+ function ae(t, r) {
3044
+ const e = t.find((a) => a.value === r);
3045
+ if (e == null) throw new RangeError(`Unknown Fray stylesheet selection: ${r}`);
3046
+ return e;
3047
+ }
3048
+ function c(t, r, e, a, i, n) {
3049
+ return n == null ? Object.freeze({ name: t, layer: r, family: e, value: a, description: i }) : Object.freeze({ name: t, layer: r, family: e, value: a, description: i, fallback: n });
3050
+ }
3051
+ function R(t, r, e) {
3052
+ return Object.freeze({ value: t, label: r, href: e });
3053
+ }
3054
+ function N(t) {
3055
+ const r = import.meta.url.includes("/src/styling/") ? `../../${t}` : `../${t}`;
3056
+ return new URL(r, import.meta.url).href;
3057
+ }
3058
+ function Xt(t) {
3059
+ if (t == null || typeof t != "object")
3060
+ throw new TypeError("Fray stylesheet selection must be an option");
3061
+ for (const r of ["value", "label", "href"])
3062
+ if (typeof Reflect.get(t, r) != "string" || String(Reflect.get(t, r)).length === 0)
3063
+ throw new TypeError(`Fray stylesheet option ${r} must be a non-empty string`);
3064
+ }
3065
+ class oe extends g {
3066
+ constructor(e, a, i) {
3067
+ var l;
3068
+ super(e);
3069
+ s(this, "valueEmitter");
3070
+ s(this, "inputId");
3071
+ s(this, "kind");
3072
+ s(this, "defaults");
3073
+ const n = e.options ?? i;
3074
+ Me(n);
3075
+ const o = (l = n[0]) == null ? void 0 : l.value;
3076
+ if (o == null) throw new TypeError(`${a} picker requires at least one option`);
3077
+ this.kind = a, this.defaults = i, this.inputId = j(`${a}-picker`, e.id), this.valueEmitter = M(this, e, o, `${a} selection`), ae(n, this.valueEmitter.get());
3078
+ }
3079
+ initialize() {
3080
+ this.watch(this.valueEmitter);
3081
+ }
3082
+ render() {
3083
+ const e = this.options, a = ae(e, this.valueEmitter.get()), { label: i, ariaLabel: n, disabled: o = !1, onChange: l } = this.props, d = this.Host;
3084
+ return /* @__PURE__ */ w(
3085
+ d,
3086
+ {
3087
+ className: E(this.props) || null,
3088
+ "data-kind": this.kind,
3089
+ "data-disabled": o ? "" : null,
3090
+ children: [
3091
+ i == null ? null : /* @__PURE__ */ u("label", { htmlFor: this.inputId, children: i }),
3092
+ /* @__PURE__ */ u(
3093
+ "select",
3094
+ {
3095
+ id: this.inputId,
3096
+ "data-part": "control",
3097
+ value: a.value,
3098
+ disabled: o,
3099
+ "aria-label": i == null ? n : null,
3100
+ onChange: (h) => {
3101
+ const f = Zt(h), p = ae(e, f);
3102
+ this.valueEmitter.set(f, `${this.kind} selected`), C(l, f, p, h);
3103
+ },
3104
+ children: e.map((h) => /* @__PURE__ */ u(
3105
+ "option",
3106
+ {
3107
+ value: h.value,
3108
+ selected: h.value === a.value,
3109
+ children: h.label
3110
+ },
3111
+ h.value
3112
+ ))
3113
+ }
3114
+ )
3115
+ ]
3116
+ }
3117
+ );
3118
+ }
3119
+ afterMount() {
3120
+ this.applySelection();
3121
+ }
3122
+ afterUpdate() {
3123
+ this.applySelection();
3124
+ }
3125
+ get options() {
3126
+ const e = this.props.options ?? this.defaults;
3127
+ return Me(e), e;
3128
+ }
3129
+ applySelection() {
3130
+ const e = this.props.targetDocument ?? (typeof document > "u" ? null : document);
3131
+ e != null && _t(
3132
+ this.kind,
3133
+ ae(this.options, this.valueEmitter.get()),
3134
+ e
3135
+ );
3136
+ }
3137
+ }
3138
+ s(oe, "baseStyles", [
3139
+ ["&", ["labeledinput", "inputline"]],
3140
+ ["& > label", ["label"]],
3141
+ ["& > select", ["input", "inputline"]],
3142
+ ["&[data-disabled]", ["disabled"]]
3143
+ ]), s(oe, "css", v`
3144
+ & {
3145
+ position: relative;
3146
+ }
3147
+
3148
+ & > select {
3149
+ min-width: 8rem;
3150
+ }
3151
+ `);
3152
+ class Fe extends oe {
3153
+ constructor(r = {}) {
3154
+ super(r, "theme", Jt);
3155
+ }
3156
+ }
3157
+ s(Fe, "hostName", "theme-picker"), s(Fe, "standaloneHostName", "theme-picker");
3158
+ class He extends oe {
3159
+ constructor(r = {}) {
3160
+ super(r, "colors", Yt);
3161
+ }
3162
+ }
3163
+ s(He, "hostName", "color-picker"), s(He, "standaloneHostName", "color-picker");
3164
+ function Me(t) {
3165
+ if (!Array.isArray(t) || t.length === 0)
3166
+ throw new TypeError("Stylesheet picker options must be a non-empty array");
3167
+ const r = /* @__PURE__ */ new Set();
3168
+ for (const e of t) {
3169
+ if (e == null || typeof e != "object")
3170
+ throw new TypeError("Stylesheet picker options must be objects");
3171
+ for (const a of ["value", "label", "href"])
3172
+ if (typeof e[a] != "string" || e[a].length === 0)
3173
+ throw new TypeError(`Stylesheet picker option ${a} must be a string`);
3174
+ if (r.has(e.value))
3175
+ throw new Error(`Duplicate stylesheet picker value: ${e.value}`);
3176
+ r.add(e.value);
3177
+ }
3178
+ }
3179
+ function Zt(t) {
3180
+ const r = t.currentTarget == null ? null : Reflect.get(t.currentTarget, "value");
3181
+ if (typeof r != "string")
3182
+ throw new TypeError("Stylesheet picker change requires a select element");
3183
+ return r;
977
3184
  }
978
3185
  export {
979
- Rt as Button,
980
- Z as Checkbox,
981
- p as Component,
982
- at as DescriptionItem,
983
- U as DescriptionList,
984
- j as Dropdown,
985
- v as FilterMode,
986
- vt as Fragment,
987
- yt as FrayRuntime,
988
- $ as Panel,
989
- C as ProgressBar,
990
- G as QuadCheckbox,
991
- P as Sidebar,
992
- F as SplitView,
993
- wt as StyleRegistry,
994
- Q as Tab,
995
- I as TabLine,
996
- z as TabPanel,
997
- q as Textbox,
998
- X as Toggle,
999
- V as Toolbar,
1000
- J as TriCheckbox,
1001
- Et as createFrayRuntime,
1002
- xt as createStyleRegistry,
1003
- m as css,
1004
- It as defaultFrayRuntime,
1005
- Nt as h,
1006
- c as jsx,
1007
- St as jsxDEV,
1008
- g as jsxs,
1009
- Ht as live,
1010
- Tt as styleRegistry,
1011
- _ as tabButtonId,
1012
- tt as tabPanelId
3186
+ Be as BaseSelectionHandler,
3187
+ se as Button,
3188
+ D as Checkbox,
3189
+ He as ColorPicker,
3190
+ g as Component,
3191
+ X as DataTable,
3192
+ St as DefaultTableFilterEncoding,
3193
+ Ue as DescriptionItem,
3194
+ Te as DescriptionList,
3195
+ Oe as Dialog,
3196
+ ee as Dropdown,
3197
+ y as FilterMode,
3198
+ V as FilterPanel,
3199
+ pr as Fragment,
3200
+ mr as FrayRuntime,
3201
+ G as ListView,
3202
+ st as MultiSelectionHandler,
3203
+ _ as Panel,
3204
+ H as Placeholder,
3205
+ he as ProgressBar,
3206
+ $e as QuadCheckbox,
3207
+ xe as Sidebar,
3208
+ ge as SingleSelectionHandler,
3209
+ ce as SplitView,
3210
+ br as StyleRegistry,
3211
+ ze as Tab,
3212
+ L as TabLine,
3213
+ J as TabPanel,
3214
+ me as TableHeader,
3215
+ W as TableHeaderCell,
3216
+ te as Textbox,
3217
+ Fe as ThemePicker,
3218
+ Ae as Toggle,
3219
+ re as Toolbar,
3220
+ We as TreeItem,
3221
+ Z as TreeView,
3222
+ Ce as TriCheckbox,
3223
+ It as applyLocalTableState,
3224
+ Ge as assertSort,
3225
+ P as assertTreeNodes,
3226
+ yr as createFrayRuntime,
3227
+ Ot as createHandlerTableDataSource,
3228
+ Dt as createLocalTableDataSource,
3229
+ or as createQueryTableDataSource,
3230
+ $t as createRestTableDataSource,
3231
+ ne as createSelectionHandler,
3232
+ gr as createStyleRegistry,
3233
+ v as css,
3234
+ wr as defaultFrayRuntime,
3235
+ we as defaultItemKey,
3236
+ ar as deriveFilterPredicate,
3237
+ ir as deriveFilteredItems,
3238
+ dr as deriveTreeNode,
3239
+ it as filterByState,
3240
+ ae as findFrayStylesheetOption,
3241
+ lr as findTreeNode,
3242
+ Yt as frayColorOptions,
3243
+ Jt as frayThemeOptions,
3244
+ ur as frayThemeVariableCatalog,
3245
+ Er as h,
3246
+ de as isFilterMode,
3247
+ u as jsx,
3248
+ vr as jsxDEV,
3249
+ w as jsxs,
3250
+ Sr as live,
3251
+ Pe as matchesFilterState,
3252
+ sr as parseFilterState,
3253
+ _t as replaceFrayStylesheet,
3254
+ nr as serializeFilterState,
3255
+ kt as serializeTableQuery,
3256
+ kr as styleRegistry,
3257
+ qe as tabButtonId,
3258
+ Le as tabPanelId,
3259
+ Mt as updateTreeNode,
3260
+ cr as updateWritableTreeNode
1013
3261
  };
1014
3262
  //# sourceMappingURL=index.js.map