@bccampus/ui-components 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AbstractFocusProvider-CxvlcEki.js +29 -0
- package/dist/AbstractSelectionProvider-BtaROstC.js +30 -0
- package/dist/CompositeDataItem-DuHOHCWy.js +158 -0
- package/dist/ListboxFocusProvider.d.ts +149 -0
- package/dist/ListboxFocusProvider.js +53 -0
- package/dist/MultipleSelectionProvider.d.ts +141 -0
- package/dist/MultipleSelectionProvider.js +19 -0
- package/dist/SingleSelectionProvider.d.ts +141 -0
- package/dist/SingleSelectionProvider.js +23 -0
- package/dist/composite-component-DSUbd1XS.js +122 -0
- package/dist/composite.d.ts +108 -51
- package/dist/composite.js +57 -447
- package/dist/icon-generator-tuhuqdpL.js +76 -0
- package/dist/icon-generator.d.ts +11 -4
- package/dist/icon-generator.js +4 -74
- package/dist/listbox.d.ts +171 -0
- package/dist/listbox.js +76 -0
- package/dist/masked-image-generator.js +7 -7
- package/dist/ui-components.js +5 -5
- package/package.json +5 -1
- package/src/components/ui/composite/CompositeData.ts +22 -114
- package/src/components/ui/composite/FocusProvider/AbstractFocusProvider.ts +83 -0
- package/src/components/ui/composite/FocusProvider/ListboxFocusProvider.ts +74 -0
- package/src/components/ui/composite/SelectionProvider/AbstractSelectionProvider.ts +45 -0
- package/src/components/ui/composite/SelectionProvider/MultipleSelectionProvider.ts +28 -0
- package/src/components/ui/composite/SelectionProvider/SingleSelectionProvider.ts +37 -0
- package/src/components/ui/composite/composite-component-item.tsx +12 -10
- package/src/components/ui/composite/composite-component.tsx +39 -68
- package/src/components/ui/composite/index.ts +4 -1
- package/src/components/ui/composite/listbox.tsx +61 -0
- package/src/components/ui/composite/types.ts +51 -30
- package/src/components/ui/icon-generator/index.ts +2 -0
- package/src/hooks/use-keyboard-event.ts +31 -42
- package/vite.config.ts +6 -2
- package/src/components/ui/composite/composite-data-context.tsx +0 -31
- /package/dist/{igenerate-tiles.d.ts → generate-tiles.d.ts} +0 -0
- /package/dist/{igenerate-tiles.js → generate-tiles.js} +0 -0
package/dist/composite.js
CHANGED
|
@@ -1,472 +1,82 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
if (l) {
|
|
8
|
-
const i = n.reduce((r, d) => r && d in r ? r[d] : void 0, e);
|
|
9
|
-
i && l in i && delete i[l];
|
|
10
|
-
}
|
|
11
|
-
}), e;
|
|
12
|
-
};
|
|
13
|
-
let R = Symbol("clean"), c = [], f = 0;
|
|
14
|
-
const g = 4;
|
|
15
|
-
let K = (o) => {
|
|
16
|
-
let t = [], e = {
|
|
17
|
-
get() {
|
|
18
|
-
return e.lc || e.listen(() => {
|
|
19
|
-
})(), e.value;
|
|
20
|
-
},
|
|
21
|
-
lc: 0,
|
|
22
|
-
listen(s) {
|
|
23
|
-
return e.lc = t.push(s), () => {
|
|
24
|
-
for (let l = f + g; l < c.length; )
|
|
25
|
-
c[l] === s ? c.splice(l, g) : l += g;
|
|
26
|
-
let n = t.indexOf(s);
|
|
27
|
-
~n && (t.splice(n, 1), --e.lc || e.off());
|
|
28
|
-
};
|
|
29
|
-
},
|
|
30
|
-
notify(s, n) {
|
|
31
|
-
let l = !c.length;
|
|
32
|
-
for (let i of t)
|
|
33
|
-
c.push(i, e.value, s, n);
|
|
34
|
-
if (l) {
|
|
35
|
-
for (f = 0; f < c.length; f += g)
|
|
36
|
-
c[f](
|
|
37
|
-
c[f + 1],
|
|
38
|
-
c[f + 2],
|
|
39
|
-
c[f + 3]
|
|
40
|
-
);
|
|
41
|
-
c.length = 0;
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
/* It will be called on last listener unsubscribing.
|
|
45
|
-
We will redefine it in onMount and onStop. */
|
|
46
|
-
off() {
|
|
47
|
-
},
|
|
48
|
-
set(s) {
|
|
49
|
-
let n = e.value;
|
|
50
|
-
n !== s && (e.value = s, e.notify(n));
|
|
51
|
-
},
|
|
52
|
-
subscribe(s) {
|
|
53
|
-
let n = e.listen(s);
|
|
54
|
-
return s(e.value), n;
|
|
55
|
-
},
|
|
56
|
-
value: o
|
|
57
|
-
};
|
|
58
|
-
return process.env.NODE_ENV !== "production" && (e[R] = () => {
|
|
59
|
-
t = [], e.lc = 0, e.off();
|
|
60
|
-
}), e;
|
|
61
|
-
};
|
|
62
|
-
function U(o, t, e) {
|
|
63
|
-
let s = new Set(t).add(void 0);
|
|
64
|
-
return o.listen((n, l, i) => {
|
|
65
|
-
s.has(i) && e(n, l, i);
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
let S = (o = {}) => {
|
|
69
|
-
let t = K(o);
|
|
70
|
-
return t.setKey = function(e, s) {
|
|
71
|
-
let n = t.value;
|
|
72
|
-
typeof s > "u" && e in t.value ? (t.value = { ...t.value }, delete t.value[e], t.notify(n, e)) : t.value[e] !== s && (t.value = {
|
|
73
|
-
...t.value,
|
|
74
|
-
[e]: s
|
|
75
|
-
}, t.notify(n, e));
|
|
76
|
-
}, t;
|
|
77
|
-
};
|
|
78
|
-
class u {
|
|
79
|
-
#e;
|
|
80
|
-
parent = null;
|
|
81
|
-
children;
|
|
82
|
-
level;
|
|
83
|
-
data;
|
|
84
|
-
state;
|
|
85
|
-
pointers;
|
|
86
|
-
childrenProp;
|
|
87
|
-
constructor(t, e, s) {
|
|
88
|
-
this.#e = e.getItemKey(t), this.data = S(O(t, [e.itemChildrenProp])), this.state = S({
|
|
89
|
-
focused: !1,
|
|
90
|
-
selected: !1,
|
|
91
|
-
disabled: !1,
|
|
92
|
-
...e.initialState
|
|
93
|
-
}), this.pointers = {}, this.parent = s, this.level = s ? s.level + 1 : 0, this.childrenProp = e.itemChildrenProp;
|
|
94
|
-
const n = e.getItemChildren(t);
|
|
95
|
-
n && (this.children = n.map((l) => new u(l, e, this)));
|
|
96
|
-
}
|
|
97
|
-
get key() {
|
|
98
|
-
return this.#e;
|
|
99
|
-
}
|
|
100
|
-
*[Symbol.iterator]() {
|
|
101
|
-
if (this.key !== "ALL" && (yield this), this.children)
|
|
102
|
-
for (const t of this.children)
|
|
103
|
-
for (const e of t) yield e;
|
|
104
|
-
}
|
|
105
|
-
toJSON() {
|
|
106
|
-
const t = { ...this.data.get() };
|
|
107
|
-
if (this.children) {
|
|
108
|
-
t[this.childrenProp] = [];
|
|
109
|
-
for (const e of this.children)
|
|
110
|
-
t[this.childrenProp].push(e.toJSON());
|
|
111
|
-
}
|
|
112
|
-
return t;
|
|
113
|
-
}
|
|
114
|
-
descendants() {
|
|
115
|
-
if (!this.children) return [];
|
|
116
|
-
const t = [];
|
|
117
|
-
return this.children.forEach(
|
|
118
|
-
(e) => {
|
|
119
|
-
t.push(e);
|
|
120
|
-
const s = e.descendants();
|
|
121
|
-
s && t.push(...s);
|
|
122
|
-
}
|
|
123
|
-
), t;
|
|
124
|
-
}
|
|
125
|
-
ancestors() {
|
|
126
|
-
const t = [];
|
|
127
|
-
let e = this.parent;
|
|
128
|
-
for (; e; )
|
|
129
|
-
t.push(e), e = e.parent;
|
|
130
|
-
return t;
|
|
131
|
-
}
|
|
132
|
-
toggleSelect(t = !1) {
|
|
133
|
-
this.state.get().selected ? this.deselect(t) : this.select(t);
|
|
134
|
-
}
|
|
135
|
-
select(t = !1) {
|
|
136
|
-
if (this.state.setKey("selected", !0), t && this.children) {
|
|
137
|
-
const e = this.children.map((s) => s.select(!0)).flat();
|
|
138
|
-
return [this.key, ...e];
|
|
139
|
-
}
|
|
140
|
-
return [this.key];
|
|
141
|
-
}
|
|
142
|
-
deselect(t = !1) {
|
|
143
|
-
if (this.state.setKey("selected", !1), t && this.children) {
|
|
144
|
-
const e = this.children.map((s) => s.deselect(!0)).flat();
|
|
145
|
-
return [this.key, ...e];
|
|
146
|
-
}
|
|
147
|
-
return [this.key];
|
|
148
|
-
}
|
|
149
|
-
disable(t = !1) {
|
|
150
|
-
if (this.state.setKey("disabled", !0), t && this.children) {
|
|
151
|
-
const e = this.children.map((s) => s.disable(!0)).flat();
|
|
152
|
-
return [this.key, ...e];
|
|
153
|
-
}
|
|
154
|
-
return [this.key];
|
|
155
|
-
}
|
|
156
|
-
enable(t = !1) {
|
|
157
|
-
if (this.state.setKey("disabled", !1), t && this.children) {
|
|
158
|
-
const e = this.children.map((s) => s.enable(!0)).flat();
|
|
159
|
-
return [this.key, ...e];
|
|
160
|
-
}
|
|
161
|
-
return [this.key];
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
const j = /* @__PURE__ */ new Set(["ctrl", "shift", "alt", "meta"]), C = {
|
|
165
|
-
" ": "space"
|
|
166
|
-
};
|
|
167
|
-
function J(o, t) {
|
|
168
|
-
if (o.size !== t.size) return !1;
|
|
169
|
-
for (const e of t)
|
|
170
|
-
if (!o.has(e)) return !1;
|
|
171
|
-
return !0;
|
|
172
|
-
}
|
|
173
|
-
function Q(o) {
|
|
174
|
-
const t = [];
|
|
175
|
-
for (const [e, s] of Object.entries(o)) {
|
|
176
|
-
const n = e.toLowerCase().trim().split(/\s*\+\s*/);
|
|
177
|
-
n.length === 1 && j.has(n[0]) ? console.error(`[useKeyboardEvent] \`${e}\`: A key sequence cannot be only a modifier key.`) : n.includes("") ? console.error(`[useKeyboardEvent] \`${e}\`: Unknown key defined in the sequence.`) : t.push({
|
|
178
|
-
sequence: new Set(n),
|
|
179
|
-
handler: s
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
return t;
|
|
183
|
-
}
|
|
184
|
-
const v = {
|
|
185
|
-
eventKeyProp: "key"
|
|
186
|
-
};
|
|
187
|
-
function z(o, t = v) {
|
|
188
|
-
const e = { ...t, ...v }, s = Q(o);
|
|
189
|
-
return (n) => {
|
|
190
|
-
const l = /* @__PURE__ */ new Set(), i = n[e.eventKeyProp];
|
|
191
|
-
n.ctrlKey && l.add("ctrl"), n.shiftKey && l.add("shift"), n.altKey && l.add("alt"), n.metaKey && l.add("meta"), C[i] ? l.add(C[i]) : l.add(i.toLowerCase());
|
|
192
|
-
const r = s.find((d) => J(l, d.sequence));
|
|
193
|
-
r && (n.preventDefault(), n.stopPropagation(), r.handler(n));
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
function T(o, t) {
|
|
197
|
-
return w(() => z(o, t), [o, t]);
|
|
198
|
-
}
|
|
199
|
-
function I(o, t) {
|
|
200
|
-
const e = new Set(o);
|
|
201
|
-
for (const s of t)
|
|
202
|
-
e.add(s);
|
|
203
|
-
return e;
|
|
204
|
-
}
|
|
205
|
-
function Y(o, t) {
|
|
206
|
-
const e = new Set(o);
|
|
207
|
-
for (const s of t)
|
|
208
|
-
e.delete(s);
|
|
209
|
-
return e;
|
|
210
|
-
}
|
|
211
|
-
class G {
|
|
1
|
+
import { C as m, a as u } from "./composite-component-DSUbd1XS.js";
|
|
2
|
+
import { C as s } from "./CompositeDataItem-DuHOHCWy.js";
|
|
3
|
+
import { u as n } from "./AbstractSelectionProvider-BtaROstC.js";
|
|
4
|
+
import { A as P } from "./AbstractSelectionProvider-BtaROstC.js";
|
|
5
|
+
import { A as v } from "./AbstractFocusProvider-CxvlcEki.js";
|
|
6
|
+
class l {
|
|
212
7
|
#e;
|
|
213
8
|
lookup = /* @__PURE__ */ new Map();
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
disabledKeys =
|
|
217
|
-
selectedKeys = K(/* @__PURE__ */ new Set());
|
|
9
|
+
focusProvider;
|
|
10
|
+
selectionProvider;
|
|
11
|
+
disabledKeys = /* @__PURE__ */ new Set();
|
|
218
12
|
root;
|
|
219
|
-
constructor(t,
|
|
13
|
+
constructor(e, t, i) {
|
|
220
14
|
this.#e = {
|
|
221
15
|
itemKeyProp: "key",
|
|
222
16
|
itemChildrenProp: "children",
|
|
223
17
|
disabledKeys: [],
|
|
224
18
|
selectedKeys: [],
|
|
225
19
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
226
|
-
getItemKey: (
|
|
20
|
+
getItemKey: (o) => o[this.#e.itemKeyProp],
|
|
227
21
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
228
|
-
getItemChildren: (
|
|
229
|
-
...
|
|
230
|
-
}, this.init(
|
|
22
|
+
getItemChildren: (o) => o[this.#e.itemChildrenProp] ? o[this.#e.itemChildrenProp] : void 0,
|
|
23
|
+
...i
|
|
24
|
+
}, this.focusProvider = t.focusProvider, this.selectionProvider = t.selectionProvider, this.init(e);
|
|
231
25
|
}
|
|
232
26
|
*[Symbol.iterator]() {
|
|
233
27
|
if (this.root.children)
|
|
234
|
-
for (const
|
|
235
|
-
yield
|
|
28
|
+
for (const e of this.root.children)
|
|
29
|
+
yield e;
|
|
236
30
|
}
|
|
237
31
|
toJSON() {
|
|
238
32
|
return this.root.toJSON()[this.#e.itemChildrenProp];
|
|
239
33
|
}
|
|
240
|
-
init(
|
|
241
|
-
this.root = new
|
|
242
|
-
{ [this.#e.itemKeyProp]: "ALL", [this.#e.itemChildrenProp]:
|
|
34
|
+
init(e) {
|
|
35
|
+
this.root = new s(
|
|
36
|
+
{ [this.#e.itemKeyProp]: "ALL", [this.#e.itemChildrenProp]: e },
|
|
243
37
|
this.#e,
|
|
244
38
|
null
|
|
245
|
-
), this.lookup = new Map([...this.root].map((
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
39
|
+
), this.lookup = new Map([...this.root].map((t) => [t.key, t])), this.#e.disabledKeys.forEach((t) => this.#t(t)), this.selectionProvider && this.selectionProvider.init(this, this.#e), this.focusProvider.init(this, this.#e);
|
|
40
|
+
}
|
|
41
|
+
item(e) {
|
|
42
|
+
return this.lookup.get(e);
|
|
43
|
+
}
|
|
44
|
+
descendants(e) {
|
|
45
|
+
const t = this.lookup.get(e);
|
|
46
|
+
if (t)
|
|
47
|
+
return t.descendants();
|
|
48
|
+
}
|
|
49
|
+
ancestors(e) {
|
|
50
|
+
const t = this.lookup.get(e);
|
|
51
|
+
if (t)
|
|
52
|
+
return t.ancestors();
|
|
53
|
+
}
|
|
54
|
+
#t(e, t = !1) {
|
|
55
|
+
const i = e instanceof s ? e : this.lookup.get(e);
|
|
56
|
+
if (!i) return;
|
|
57
|
+
const o = i.disable(t);
|
|
58
|
+
this.disabledKeys = n(this.disabledKeys, o);
|
|
59
|
+
}
|
|
60
|
+
updateItem(e, t) {
|
|
61
|
+
const i = this.lookup.get(e);
|
|
62
|
+
if (i) {
|
|
63
|
+
const o = {
|
|
64
|
+
...i.data.get(),
|
|
65
|
+
...typeof t == "function" ? t(i.data.get()) : t
|
|
66
|
+
}, r = this.#e.getItemKey(o);
|
|
67
|
+
if (i.key !== r) throw "Item key cannot be updated!";
|
|
68
|
+
this.#i(e), i.data.set(o);
|
|
255
69
|
}
|
|
256
70
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
}
|
|
260
|
-
getFirstFocusableItem() {
|
|
261
|
-
let t = this.lookup.values().next();
|
|
262
|
-
for (; t.value && !this.isFocusable(t.value); )
|
|
263
|
-
t = this.lookup.values().next();
|
|
264
|
-
return t.value;
|
|
265
|
-
}
|
|
266
|
-
item(t) {
|
|
267
|
-
return this.lookup.get(t);
|
|
268
|
-
}
|
|
269
|
-
descendants(t) {
|
|
270
|
-
const e = this.lookup.get(t);
|
|
271
|
-
if (e)
|
|
272
|
-
return e.descendants();
|
|
273
|
-
}
|
|
274
|
-
ancestors(t) {
|
|
275
|
-
const e = this.lookup.get(t);
|
|
276
|
-
if (e)
|
|
277
|
-
return e.ancestors();
|
|
278
|
-
}
|
|
279
|
-
focus(t) {
|
|
280
|
-
const e = t instanceof u ? t : this.lookup.get(t);
|
|
281
|
-
if (e) {
|
|
282
|
-
if (this.focusedItem.get()) {
|
|
283
|
-
if (e.key === this.focusedItem.get()?.key) return;
|
|
284
|
-
this.focusedItem.get().state.setKey("focused", !1);
|
|
285
|
-
}
|
|
286
|
-
e.state.setKey("focused", !0), this.focusedItem.set(e);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
toggleSelect(t, e = !1) {
|
|
290
|
-
const s = t instanceof u ? t : this.lookup.get(t);
|
|
291
|
-
s && (s.state.get().selected ? this.deselect(s, e) : this.select(s, e));
|
|
292
|
-
}
|
|
293
|
-
select(t, e = !1) {
|
|
294
|
-
const s = t instanceof u ? t : this.lookup.get(t);
|
|
295
|
-
if (!s) return;
|
|
296
|
-
const n = s.select(e);
|
|
297
|
-
this.selectedKeys.set(I(this.selectedKeys.get(), n));
|
|
298
|
-
}
|
|
299
|
-
deselect(t, e = !1) {
|
|
300
|
-
const s = t instanceof u ? t : this.lookup.get(t);
|
|
301
|
-
if (!s) return;
|
|
302
|
-
const n = s.deselect(e);
|
|
303
|
-
this.selectedKeys.set(Y(this.selectedKeys.get(), n));
|
|
304
|
-
}
|
|
305
|
-
disable(t, e = !1) {
|
|
306
|
-
const s = t instanceof u ? t : this.lookup.get(t);
|
|
307
|
-
if (!s) return;
|
|
308
|
-
const n = s.disable(e);
|
|
309
|
-
this.disabledKeys.set(I(this.selectedKeys.get(), n));
|
|
71
|
+
#i(e) {
|
|
72
|
+
this.selectionProvider && this.selectionProvider.selectedKeys.get().has(e) && this.selectionProvider.selectedKeys.set(/* @__PURE__ */ new Set([...this.selectionProvider.selectedKeys.get()]));
|
|
310
73
|
}
|
|
311
|
-
enable(t, e = !1) {
|
|
312
|
-
const s = t instanceof u ? t : this.lookup.get(t);
|
|
313
|
-
if (!s) return;
|
|
314
|
-
const n = s.enable(e);
|
|
315
|
-
this.disabledKeys.set(I(this.selectedKeys.get(), n));
|
|
316
|
-
}
|
|
317
|
-
updateItem(t, e) {
|
|
318
|
-
const s = this.lookup.get(t);
|
|
319
|
-
if (s) {
|
|
320
|
-
const n = {
|
|
321
|
-
...s.data.get(),
|
|
322
|
-
...typeof e == "function" ? e(s.data.get()) : e
|
|
323
|
-
}, l = this.#e.getItemKey(n);
|
|
324
|
-
if (s.key !== l) throw "Item key cannot be updated!";
|
|
325
|
-
this.#t(t), s.data.set(n);
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
#t(t) {
|
|
329
|
-
this.selectedKeys.get().has(t) && this.selectedKeys.set(/* @__PURE__ */ new Set([...this.selectedKeys.get()]));
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
const P = L(void 0);
|
|
333
|
-
function H() {
|
|
334
|
-
const o = N(P);
|
|
335
|
-
if (!o)
|
|
336
|
-
throw new Error("No CompositeDataContext has been set, use CompositeDataContext to provide a context");
|
|
337
|
-
return o;
|
|
338
|
-
}
|
|
339
|
-
function X({
|
|
340
|
-
data: o,
|
|
341
|
-
children: t,
|
|
342
|
-
...e
|
|
343
|
-
}) {
|
|
344
|
-
const s = w(() => new G(o, e), [o, e]);
|
|
345
|
-
return /* @__PURE__ */ b(P, { value: s, children: t });
|
|
346
|
-
}
|
|
347
|
-
let k = (o, t) => (e) => {
|
|
348
|
-
o.current !== e && (o.current = e, t());
|
|
349
|
-
};
|
|
350
|
-
function x(o, { keys: t, deps: e = [o, t] } = {}) {
|
|
351
|
-
let s = E();
|
|
352
|
-
s.current = o.get();
|
|
353
|
-
let n = p((i) => (k(s, i)(o.value), t?.length > 0 ? U(o, t, k(s, i)) : o.listen(k(s, i))), e), l = () => s.current;
|
|
354
|
-
return $(n, l, l);
|
|
355
|
-
}
|
|
356
|
-
function D({
|
|
357
|
-
id: o,
|
|
358
|
-
className: t,
|
|
359
|
-
item: e,
|
|
360
|
-
mouseEventHandler: s,
|
|
361
|
-
keyboardEventHandler: n,
|
|
362
|
-
render: l
|
|
363
|
-
}) {
|
|
364
|
-
const i = x(e.data), r = x(e.state), d = w(() => r.disabled ? {} : {
|
|
365
|
-
mouseEventHandler: () => s?.(e),
|
|
366
|
-
keyboardEventHandler: () => n?.(e)
|
|
367
|
-
}, [r.disabled, e, n, s]);
|
|
368
|
-
return /* @__PURE__ */ q(
|
|
369
|
-
"div",
|
|
370
|
-
{
|
|
371
|
-
id: o,
|
|
372
|
-
role: "option",
|
|
373
|
-
"aria-disabled": r.disabled,
|
|
374
|
-
"data-key": e.key,
|
|
375
|
-
tabIndex: r.disabled ? void 0 : r.focused ? 0 : -1,
|
|
376
|
-
className: t,
|
|
377
|
-
children: [
|
|
378
|
-
l({ data: i, key: e.key, level: e.level }, r, d),
|
|
379
|
-
e.children && e.children.length > 0 && [...e.children].map((a) => /* @__PURE__ */ b(
|
|
380
|
-
D,
|
|
381
|
-
{
|
|
382
|
-
id: `${o}-${e.key}`,
|
|
383
|
-
item: a,
|
|
384
|
-
render: l,
|
|
385
|
-
className: t,
|
|
386
|
-
mouseEventHandler: s,
|
|
387
|
-
keyboardEventHandler: n
|
|
388
|
-
},
|
|
389
|
-
a.key
|
|
390
|
-
))
|
|
391
|
-
]
|
|
392
|
-
}
|
|
393
|
-
);
|
|
394
|
-
}
|
|
395
|
-
function V(o) {
|
|
396
|
-
return o ?? M();
|
|
397
|
-
}
|
|
398
|
-
function Z({
|
|
399
|
-
renderItem: o,
|
|
400
|
-
className: t,
|
|
401
|
-
itemClassName: e,
|
|
402
|
-
ref: s,
|
|
403
|
-
id: n,
|
|
404
|
-
...l
|
|
405
|
-
}) {
|
|
406
|
-
const i = H(), r = E(null), d = V(n), a = p(
|
|
407
|
-
(h) => {
|
|
408
|
-
i.focus(h);
|
|
409
|
-
},
|
|
410
|
-
[i]
|
|
411
|
-
), y = p(() => {
|
|
412
|
-
i.focusedItem.get()?.pointers.down && a(i.focusedItem.get().pointers.down);
|
|
413
|
-
}, [i, a]), m = p(() => {
|
|
414
|
-
i.focusedItem.get()?.pointers.up && a(i.focusedItem.get().pointers.up);
|
|
415
|
-
}, [i, a]), F = T({
|
|
416
|
-
ArrowUp: m,
|
|
417
|
-
ArrowLeft: m,
|
|
418
|
-
ArrowDown: y,
|
|
419
|
-
ArrowRight: y,
|
|
420
|
-
Space: () => {
|
|
421
|
-
i.focusedItem.get() && i.toggleSelect(i.focusedItem.get());
|
|
422
|
-
}
|
|
423
|
-
}), _ = p(
|
|
424
|
-
(h) => {
|
|
425
|
-
a(h.key), i.toggleSelect(h);
|
|
426
|
-
},
|
|
427
|
-
[i, a]
|
|
428
|
-
);
|
|
429
|
-
return A(
|
|
430
|
-
s,
|
|
431
|
-
() => ({
|
|
432
|
-
focusDown() {
|
|
433
|
-
y();
|
|
434
|
-
},
|
|
435
|
-
focusUp() {
|
|
436
|
-
m();
|
|
437
|
-
},
|
|
438
|
-
select() {
|
|
439
|
-
i.focusedItem.get() && i.toggleSelect(i.focusedItem.get());
|
|
440
|
-
}
|
|
441
|
-
}),
|
|
442
|
-
[i, y, m]
|
|
443
|
-
), /* @__PURE__ */ b(
|
|
444
|
-
"div",
|
|
445
|
-
{
|
|
446
|
-
ref: r,
|
|
447
|
-
id: d,
|
|
448
|
-
className: t,
|
|
449
|
-
tabIndex: -1,
|
|
450
|
-
role: "listbox",
|
|
451
|
-
onKeyDown: F,
|
|
452
|
-
...l,
|
|
453
|
-
children: [...i].map((h) => /* @__PURE__ */ b(
|
|
454
|
-
D,
|
|
455
|
-
{
|
|
456
|
-
className: e,
|
|
457
|
-
id: `${d}-${h.key}`,
|
|
458
|
-
item: h,
|
|
459
|
-
render: o,
|
|
460
|
-
mouseEventHandler: _
|
|
461
|
-
},
|
|
462
|
-
h.key
|
|
463
|
-
))
|
|
464
|
-
}
|
|
465
|
-
);
|
|
466
74
|
}
|
|
467
75
|
export {
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
76
|
+
v as AbstractFocusProvider,
|
|
77
|
+
P as AbstractSelectionProvider,
|
|
78
|
+
m as CompositeComponent,
|
|
79
|
+
u as CompositeComponentItem,
|
|
80
|
+
l as CompositeData,
|
|
81
|
+
s as CompositeDataItem
|
|
472
82
|
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { jsx as u } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as r } from "react";
|
|
3
|
+
import { T as o, g as l } from "./generate-tiles-DuagGD1d.js";
|
|
4
|
+
import { c as m } from "./utils-CRiPKpXj.js";
|
|
5
|
+
const k = [
|
|
6
|
+
[o.PieRand, o.PieRand],
|
|
7
|
+
[o.PieRand, o.PieRand]
|
|
8
|
+
];
|
|
9
|
+
function b({
|
|
10
|
+
pattern: e = k,
|
|
11
|
+
tileSize: h = 64,
|
|
12
|
+
tileClassName: c,
|
|
13
|
+
tileBgClassName: s,
|
|
14
|
+
renderChildren: d,
|
|
15
|
+
fit: i = "none",
|
|
16
|
+
...g
|
|
17
|
+
}) {
|
|
18
|
+
const t = r(
|
|
19
|
+
() => ({
|
|
20
|
+
width: e.reduce((n, v) => Math.max(n, v.length), 0) * h,
|
|
21
|
+
height: e.length * h
|
|
22
|
+
}),
|
|
23
|
+
[e, h]
|
|
24
|
+
), a = r(() => {
|
|
25
|
+
const n = l(e, h, c);
|
|
26
|
+
return s && n.unshift(
|
|
27
|
+
/* @__PURE__ */ u(
|
|
28
|
+
"rect",
|
|
29
|
+
{
|
|
30
|
+
x: 0,
|
|
31
|
+
y: 0,
|
|
32
|
+
width: t.width,
|
|
33
|
+
height: t.height,
|
|
34
|
+
className: m("fill-black stroke-2 stroke-black", s)
|
|
35
|
+
},
|
|
36
|
+
"svg-mask-invert"
|
|
37
|
+
)
|
|
38
|
+
), n;
|
|
39
|
+
}, [e, t, c, s, h]), w = r(() => {
|
|
40
|
+
switch (i) {
|
|
41
|
+
case "fill":
|
|
42
|
+
return t.width <= t.height ? "100%" : void 0;
|
|
43
|
+
case "width":
|
|
44
|
+
return "100%";
|
|
45
|
+
case "none":
|
|
46
|
+
return t.width;
|
|
47
|
+
default:
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
}, [i, t]), f = r(() => {
|
|
51
|
+
switch (i) {
|
|
52
|
+
case "fill":
|
|
53
|
+
return t.height < t.width ? "100%" : void 0;
|
|
54
|
+
case "height":
|
|
55
|
+
return "100%";
|
|
56
|
+
case "none":
|
|
57
|
+
return t.height;
|
|
58
|
+
default:
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
}, [i, t]);
|
|
62
|
+
return /* @__PURE__ */ u(
|
|
63
|
+
"svg",
|
|
64
|
+
{
|
|
65
|
+
width: w,
|
|
66
|
+
height: f,
|
|
67
|
+
viewBox: `0 0 ${t.width} ${t.height}`,
|
|
68
|
+
overflow: "visible",
|
|
69
|
+
...g,
|
|
70
|
+
children: d ? d(a, t.width, t.height) : a
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
export {
|
|
75
|
+
b as I
|
|
76
|
+
};
|
package/dist/icon-generator.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
|
3
3
|
|
|
4
4
|
export declare function IconGenerator({ pattern, tileSize, tileClassName, tileBgClassName, renderChildren, fit, ...props }: IconGeneratorProps): JSX_2.Element;
|
|
5
5
|
|
|
6
|
-
declare interface IconGeneratorProps extends Omit<React.ComponentProps<"svg">, "children" | "width" | "height" | "overflow"> {
|
|
6
|
+
export declare interface IconGeneratorProps extends Omit<React.ComponentProps<"svg">, "children" | "width" | "height" | "overflow"> {
|
|
7
7
|
pattern?: (TileShape | TileConfig)[][];
|
|
8
8
|
tileSize?: number;
|
|
9
9
|
tileClassName?: string;
|
|
@@ -12,13 +12,20 @@ declare interface IconGeneratorProps extends Omit<React.ComponentProps<"svg">, "
|
|
|
12
12
|
renderChildren?: (paths: (JSX.Element | null)[], width: number, height: number) => React.ReactNode;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
declare interface
|
|
15
|
+
export declare interface MaskedImageGeneratorProps extends IconGeneratorProps {
|
|
16
|
+
src: string;
|
|
17
|
+
imageFit?: "cover" | "contain" | "fill";
|
|
18
|
+
imagePosition?: "top" | "center" | "bottom";
|
|
19
|
+
maskType?: "alpha" | "luminance";
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export declare interface TileConfig {
|
|
16
23
|
shape: TileShape;
|
|
17
24
|
scale?: number;
|
|
18
25
|
className?: string;
|
|
19
26
|
}
|
|
20
27
|
|
|
21
|
-
declare const TileShape: {
|
|
28
|
+
export declare const TileShape: {
|
|
22
29
|
readonly Blank: 0;
|
|
23
30
|
readonly Rand: 1;
|
|
24
31
|
readonly Mosaic: 2;
|
|
@@ -46,6 +53,6 @@ declare const TileShape: {
|
|
|
46
53
|
readonly PieRand: 25;
|
|
47
54
|
};
|
|
48
55
|
|
|
49
|
-
declare type TileShape = (typeof TileShape)[keyof typeof TileShape];
|
|
56
|
+
export declare type TileShape = (typeof TileShape)[keyof typeof TileShape];
|
|
50
57
|
|
|
51
58
|
export { }
|