@spartan-native/helm 0.0.0-stage → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +90 -0
- package/LICENSE +21 -0
- package/README.md +102 -2
- package/fesm2022/spartan-native-helm.mjs +691 -0
- package/fesm2022/spartan-native-helm.mjs.map +1 -0
- package/package.json +53 -3
- package/styles/_dialog-buttons.scss +50 -0
- package/styles/_selectable.scss +101 -0
- package/styles/spartan-native-helm.scss +14 -0
- package/types/spartan-native-helm.d.ts +234 -0
|
@@ -0,0 +1,691 @@
|
|
|
1
|
+
import { DOCUMENT } from "@angular/common";
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
import { DestroyRef, Directive, ElementRef, InjectionToken, afterNextRender, computed, contentChildren, effect, forwardRef, inject, input, model, output, signal, untracked } from "@angular/core";
|
|
4
|
+
import { injectSkin } from "@spartan-native/theme";
|
|
5
|
+
const SELECTION_PAGE_SIZE = 10;
|
|
6
|
+
const TYPEAHEAD_RESET_MS = 600;
|
|
7
|
+
const EMPTY_SELECTION = {
|
|
8
|
+
selected: [],
|
|
9
|
+
anchor: null,
|
|
10
|
+
active: null
|
|
11
|
+
};
|
|
12
|
+
function ordered(keys, selected) {
|
|
13
|
+
const set = new Set(selected);
|
|
14
|
+
return keys.filter((k) => set.has(k));
|
|
15
|
+
}
|
|
16
|
+
function range(keys, from, to) {
|
|
17
|
+
const a = from === null ? -1 : keys.indexOf(from);
|
|
18
|
+
const b = keys.indexOf(to);
|
|
19
|
+
if (a < 0) return [to];
|
|
20
|
+
return keys.slice(Math.min(a, b), Math.max(a, b) + 1);
|
|
21
|
+
}
|
|
22
|
+
function selectionClick(state, keys, key, mods = {}, multiple = true) {
|
|
23
|
+
if (!keys.includes(key)) return state;
|
|
24
|
+
if (!multiple) return {
|
|
25
|
+
selected: [key],
|
|
26
|
+
anchor: key,
|
|
27
|
+
active: key
|
|
28
|
+
};
|
|
29
|
+
if (mods.range) {
|
|
30
|
+
const span = range(keys, state.anchor, key);
|
|
31
|
+
return {
|
|
32
|
+
selected: mods.toggle ? ordered(keys, [...state.selected, ...span]) : span,
|
|
33
|
+
anchor: state.anchor ?? key,
|
|
34
|
+
active: key
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
if (mods.toggle) return {
|
|
38
|
+
selected: state.selected.includes(key) ? state.selected.filter((k) => k !== key) : ordered(keys, [...state.selected, key]),
|
|
39
|
+
anchor: key,
|
|
40
|
+
active: key
|
|
41
|
+
};
|
|
42
|
+
return {
|
|
43
|
+
selected: [key],
|
|
44
|
+
anchor: key,
|
|
45
|
+
active: key
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function selectionMoveTo(state, keys, index, mods = {}, multiple = true) {
|
|
49
|
+
if (keys.length === 0) return state;
|
|
50
|
+
const target = keys[Math.max(0, Math.min(keys.length - 1, index))];
|
|
51
|
+
if (!multiple) return {
|
|
52
|
+
selected: [target],
|
|
53
|
+
anchor: target,
|
|
54
|
+
active: target
|
|
55
|
+
};
|
|
56
|
+
if (mods.range) {
|
|
57
|
+
const span = range(keys, state.anchor ?? state.active, target);
|
|
58
|
+
return {
|
|
59
|
+
selected: mods.toggle ? ordered(keys, [...state.selected, ...span]) : span,
|
|
60
|
+
anchor: state.anchor ?? state.active ?? target,
|
|
61
|
+
active: target
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
if (mods.toggle) return {
|
|
65
|
+
...state,
|
|
66
|
+
active: target
|
|
67
|
+
};
|
|
68
|
+
return {
|
|
69
|
+
selected: [target],
|
|
70
|
+
anchor: target,
|
|
71
|
+
active: target
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function selectionMoveBy(state, keys, delta, mods = {}, multiple = true) {
|
|
75
|
+
const current = state.active === null ? -1 : keys.indexOf(state.active);
|
|
76
|
+
return selectionMoveTo(state, keys, (current < 0 ? delta > 0 ? -1 : keys.length : current) + delta, mods, multiple);
|
|
77
|
+
}
|
|
78
|
+
function selectionToggleActive(state, keys, mods = {}, multiple = true) {
|
|
79
|
+
if (state.active === null) return state;
|
|
80
|
+
return selectionClick(state, keys, state.active, { toggle: mods.toggle }, multiple);
|
|
81
|
+
}
|
|
82
|
+
function selectionAll(state, keys, multiple = true) {
|
|
83
|
+
if (!multiple) return state;
|
|
84
|
+
return {
|
|
85
|
+
selected: [...keys],
|
|
86
|
+
anchor: keys[0] ?? null,
|
|
87
|
+
active: state.active ?? keys[0] ?? null
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function selectionClear(state) {
|
|
91
|
+
return {
|
|
92
|
+
...state,
|
|
93
|
+
selected: []
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function selectionSync(state, keys) {
|
|
97
|
+
const has = (k) => k !== null && keys.includes(k);
|
|
98
|
+
return {
|
|
99
|
+
selected: ordered(keys, state.selected),
|
|
100
|
+
anchor: has(state.anchor) ? state.anchor : null,
|
|
101
|
+
active: has(state.active) ? state.active : null
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function typeaheadIndex(labels, query, fromIndex) {
|
|
105
|
+
if (!query || labels.length === 0) return -1;
|
|
106
|
+
const q = query.toLocaleLowerCase();
|
|
107
|
+
const cycling = [...q].every((c) => c === q[0]);
|
|
108
|
+
const needle = cycling ? q[0] : q;
|
|
109
|
+
const start = cycling ? fromIndex + 1 : Math.max(0, fromIndex);
|
|
110
|
+
for (let i = 0; i < labels.length; i++) {
|
|
111
|
+
const idx = (start + i) % labels.length;
|
|
112
|
+
if (labels[idx].toLocaleLowerCase().startsWith(needle)) return idx;
|
|
113
|
+
}
|
|
114
|
+
return -1;
|
|
115
|
+
}
|
|
116
|
+
let nextId = 0;
|
|
117
|
+
const SN_SELECTABLE = new InjectionToken("SN_SELECTABLE");
|
|
118
|
+
var SnSelectableItem = class SnSelectableItem {
|
|
119
|
+
parent = inject(SN_SELECTABLE);
|
|
120
|
+
element = inject(ElementRef).nativeElement;
|
|
121
|
+
value = input(void 0, ...ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []);
|
|
122
|
+
label = input(void 0, {
|
|
123
|
+
...ngDevMode ? { debugName: "label" } : /* istanbul ignore next */ {},
|
|
124
|
+
alias: "snSelectableLabel"
|
|
125
|
+
});
|
|
126
|
+
id = `sn-selectable-item-${nextId++}`;
|
|
127
|
+
selected = computed(() => this.parent.isSelected(this.value()), ...ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []);
|
|
128
|
+
active = computed(() => this.parent.isActive(this.value()), ...ngDevMode ? [{ debugName: "active" }] : /* istanbul ignore next */ []);
|
|
129
|
+
typeaheadLabel() {
|
|
130
|
+
return (this.label() ?? this.element.textContent ?? "").trim();
|
|
131
|
+
}
|
|
132
|
+
onMouseDown(event) {
|
|
133
|
+
if (event.shiftKey) event.preventDefault();
|
|
134
|
+
}
|
|
135
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
136
|
+
minVersion: "12.0.0",
|
|
137
|
+
version: "22.2.5",
|
|
138
|
+
ngImport: i0,
|
|
139
|
+
type: SnSelectableItem,
|
|
140
|
+
deps: [],
|
|
141
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
142
|
+
});
|
|
143
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
144
|
+
minVersion: "17.1.0",
|
|
145
|
+
version: "22.2.5",
|
|
146
|
+
type: SnSelectableItem,
|
|
147
|
+
isStandalone: true,
|
|
148
|
+
selector: "[snSelectableItem]",
|
|
149
|
+
inputs: {
|
|
150
|
+
value: {
|
|
151
|
+
classPropertyName: "value",
|
|
152
|
+
publicName: "value",
|
|
153
|
+
isSignal: true,
|
|
154
|
+
isRequired: false,
|
|
155
|
+
transformFunction: null
|
|
156
|
+
},
|
|
157
|
+
label: {
|
|
158
|
+
classPropertyName: "label",
|
|
159
|
+
publicName: "snSelectableLabel",
|
|
160
|
+
isSignal: true,
|
|
161
|
+
isRequired: false,
|
|
162
|
+
transformFunction: null
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
host: {
|
|
166
|
+
attributes: { "data-slot": "sn-selectable-item" },
|
|
167
|
+
listeners: {
|
|
168
|
+
"mousedown": "onMouseDown($event)",
|
|
169
|
+
"click": "parent.click(value(), $event)",
|
|
170
|
+
"dblclick": "parent.activate(value())"
|
|
171
|
+
},
|
|
172
|
+
properties: {
|
|
173
|
+
"id": "id",
|
|
174
|
+
"attr.role": "parent.role() === 'grid' ? 'row' : 'option'",
|
|
175
|
+
"attr.aria-selected": "selected()",
|
|
176
|
+
"attr.data-selected": "selected() ? '' : null",
|
|
177
|
+
"attr.data-active": "active() ? '' : null"
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
exportAs: ["snSelectableItem"],
|
|
181
|
+
ngImport: i0
|
|
182
|
+
});
|
|
183
|
+
};
|
|
184
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
185
|
+
minVersion: "12.0.0",
|
|
186
|
+
version: "22.2.5",
|
|
187
|
+
ngImport: i0,
|
|
188
|
+
type: SnSelectableItem,
|
|
189
|
+
decorators: [{
|
|
190
|
+
type: Directive,
|
|
191
|
+
args: [{
|
|
192
|
+
selector: "[snSelectableItem]",
|
|
193
|
+
exportAs: "snSelectableItem",
|
|
194
|
+
host: {
|
|
195
|
+
"data-slot": "sn-selectable-item",
|
|
196
|
+
"[id]": "id",
|
|
197
|
+
"[attr.role]": "parent.role() === 'grid' ? 'row' : 'option'",
|
|
198
|
+
"[attr.aria-selected]": "selected()",
|
|
199
|
+
"[attr.data-selected]": "selected() ? '' : null",
|
|
200
|
+
"[attr.data-active]": "active() ? '' : null",
|
|
201
|
+
"(mousedown)": "onMouseDown($event)",
|
|
202
|
+
"(click)": "parent.click(value(), $event)",
|
|
203
|
+
"(dblclick)": "parent.activate(value())"
|
|
204
|
+
}
|
|
205
|
+
}]
|
|
206
|
+
}],
|
|
207
|
+
propDecorators: {
|
|
208
|
+
value: [{
|
|
209
|
+
type: i0.Input,
|
|
210
|
+
args: [{
|
|
211
|
+
isSignal: true,
|
|
212
|
+
alias: "value",
|
|
213
|
+
required: false
|
|
214
|
+
}]
|
|
215
|
+
}],
|
|
216
|
+
label: [{
|
|
217
|
+
type: i0.Input,
|
|
218
|
+
args: [{
|
|
219
|
+
isSignal: true,
|
|
220
|
+
alias: "snSelectableLabel",
|
|
221
|
+
required: false
|
|
222
|
+
}]
|
|
223
|
+
}]
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
var SnSelectable = class SnSelectable {
|
|
227
|
+
doc = inject(DOCUMENT);
|
|
228
|
+
skin = injectSkin();
|
|
229
|
+
role = input("listbox", {
|
|
230
|
+
...ngDevMode ? { debugName: "role" } : /* istanbul ignore next */ {},
|
|
231
|
+
alias: "snSelectable",
|
|
232
|
+
transform: (v) => v === "grid" ? "grid" : "listbox"
|
|
233
|
+
});
|
|
234
|
+
multiple = input(true, ...ngDevMode ? [{ debugName: "multiple" }] : /* istanbul ignore next */ []);
|
|
235
|
+
selection = model([], ...ngDevMode ? [{ debugName: "selection" }] : /* istanbul ignore next */ []);
|
|
236
|
+
activated = output();
|
|
237
|
+
items = contentChildren(SnSelectableItem, {
|
|
238
|
+
...ngDevMode ? { debugName: "items" } : /* istanbul ignore next */ {},
|
|
239
|
+
descendants: true
|
|
240
|
+
});
|
|
241
|
+
keys = computed(() => this.items().map((i) => i.value()), ...ngDevMode ? [{ debugName: "keys" }] : /* istanbul ignore next */ []);
|
|
242
|
+
cursor = signal({
|
|
243
|
+
anchor: null,
|
|
244
|
+
active: null
|
|
245
|
+
}, ...ngDevMode ? [{ debugName: "cursor" }] : /* istanbul ignore next */ []);
|
|
246
|
+
selectedSet = computed(() => new Set(this.selection()), ...ngDevMode ? [{ debugName: "selectedSet" }] : /* istanbul ignore next */ []);
|
|
247
|
+
activeId = computed(() => {
|
|
248
|
+
const active = this.cursor().active;
|
|
249
|
+
return this.items().find((i) => i.value() === active)?.id ?? null;
|
|
250
|
+
}, ...ngDevMode ? [{ debugName: "activeId" }] : /* istanbul ignore next */ []);
|
|
251
|
+
typeahead = "";
|
|
252
|
+
typeaheadTimer;
|
|
253
|
+
constructor() {
|
|
254
|
+
effect(() => {
|
|
255
|
+
const keys = this.keys();
|
|
256
|
+
if (keys.some((k) => k == null)) return;
|
|
257
|
+
untracked(() => {
|
|
258
|
+
const synced = selectionSync(this.state(), keys);
|
|
259
|
+
if (synced.selected.length !== this.selection().length) this.selection.set(synced.selected);
|
|
260
|
+
this.cursor.set({
|
|
261
|
+
anchor: synced.anchor,
|
|
262
|
+
active: synced.active
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
effect(() => {
|
|
267
|
+
const id = this.activeId();
|
|
268
|
+
if (id) untracked(() => this.doc.getElementById(id)?.scrollIntoView?.({ block: "nearest" }));
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
isSelected(key) {
|
|
272
|
+
return this.selectedSet().has(key);
|
|
273
|
+
}
|
|
274
|
+
isActive(key) {
|
|
275
|
+
return this.cursor().active === key;
|
|
276
|
+
}
|
|
277
|
+
click(key, event) {
|
|
278
|
+
this.apply(selectionClick(this.state(), this.keys(), key, this.modifiers(event), this.multiple()));
|
|
279
|
+
}
|
|
280
|
+
activate(key) {
|
|
281
|
+
this.activated.emit(key);
|
|
282
|
+
}
|
|
283
|
+
onFocus() {
|
|
284
|
+
if (this.cursor().active === null) {
|
|
285
|
+
const first = this.selection()[0] ?? this.keys()[0] ?? null;
|
|
286
|
+
this.cursor.update((c) => ({
|
|
287
|
+
...c,
|
|
288
|
+
active: first
|
|
289
|
+
}));
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
onKeydown(event) {
|
|
293
|
+
if (isEditable(event.target, event.currentTarget)) return;
|
|
294
|
+
const keys = this.keys();
|
|
295
|
+
const mods = this.modifiers(event);
|
|
296
|
+
const multiple = this.multiple();
|
|
297
|
+
const state = this.state();
|
|
298
|
+
const mac = this.isMac();
|
|
299
|
+
let next;
|
|
300
|
+
switch (event.key) {
|
|
301
|
+
case "ArrowDown":
|
|
302
|
+
next = mac && event.metaKey ? selectionMoveTo(state, keys, keys.length - 1, { range: mods.range }, multiple) : selectionMoveBy(state, keys, 1, mods, multiple);
|
|
303
|
+
break;
|
|
304
|
+
case "ArrowUp":
|
|
305
|
+
next = mac && event.metaKey ? selectionMoveTo(state, keys, 0, { range: mods.range }, multiple) : selectionMoveBy(state, keys, -1, mods, multiple);
|
|
306
|
+
break;
|
|
307
|
+
case "Home":
|
|
308
|
+
next = selectionMoveTo(state, keys, 0, mods, multiple);
|
|
309
|
+
break;
|
|
310
|
+
case "End":
|
|
311
|
+
next = selectionMoveTo(state, keys, keys.length - 1, mods, multiple);
|
|
312
|
+
break;
|
|
313
|
+
case "PageDown":
|
|
314
|
+
next = selectionMoveBy(state, keys, 10, mods, multiple);
|
|
315
|
+
break;
|
|
316
|
+
case "PageUp":
|
|
317
|
+
next = selectionMoveBy(state, keys, -10, mods, multiple);
|
|
318
|
+
break;
|
|
319
|
+
case " ":
|
|
320
|
+
if (this.typeahead) return this.onTypeahead(event);
|
|
321
|
+
next = selectionToggleActive(state, keys, mods, multiple);
|
|
322
|
+
break;
|
|
323
|
+
case "Enter":
|
|
324
|
+
if (state.active !== null) {
|
|
325
|
+
event.preventDefault();
|
|
326
|
+
this.activated.emit(state.active);
|
|
327
|
+
}
|
|
328
|
+
return;
|
|
329
|
+
case "Escape":
|
|
330
|
+
if (state.selected.length === 0) return;
|
|
331
|
+
next = selectionClear(state);
|
|
332
|
+
break;
|
|
333
|
+
default:
|
|
334
|
+
if (mods.toggle && event.key.toLowerCase() === "a") {
|
|
335
|
+
next = selectionAll(state, keys, multiple);
|
|
336
|
+
break;
|
|
337
|
+
}
|
|
338
|
+
return this.onTypeahead(event);
|
|
339
|
+
}
|
|
340
|
+
event.preventDefault();
|
|
341
|
+
this.apply(next);
|
|
342
|
+
}
|
|
343
|
+
onTypeahead(event) {
|
|
344
|
+
if (event.key.length !== 1 || event.ctrlKey || event.metaKey || event.altKey) return;
|
|
345
|
+
event.preventDefault();
|
|
346
|
+
clearTimeout(this.typeaheadTimer);
|
|
347
|
+
this.typeahead += event.key;
|
|
348
|
+
this.typeaheadTimer = setTimeout(() => this.typeahead = "", 600);
|
|
349
|
+
const items = this.items();
|
|
350
|
+
const current = items.findIndex((i) => i.value() === this.cursor().active);
|
|
351
|
+
const index = typeaheadIndex(items.map((i) => i.typeaheadLabel()), this.typeahead, current);
|
|
352
|
+
if (index >= 0) this.apply(selectionMoveTo(this.state(), this.keys(), index, {}, this.multiple()));
|
|
353
|
+
}
|
|
354
|
+
state() {
|
|
355
|
+
return {
|
|
356
|
+
selected: this.selection(),
|
|
357
|
+
...this.cursor()
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
apply(next) {
|
|
361
|
+
this.cursor.set({
|
|
362
|
+
anchor: next.anchor,
|
|
363
|
+
active: next.active
|
|
364
|
+
});
|
|
365
|
+
const prev = this.selection();
|
|
366
|
+
if (prev.length !== next.selected.length || prev.some((k, i) => k !== next.selected[i])) this.selection.set(next.selected);
|
|
367
|
+
}
|
|
368
|
+
modifiers(event) {
|
|
369
|
+
return {
|
|
370
|
+
range: event.shiftKey,
|
|
371
|
+
toggle: this.isMac() ? event.metaKey : event.ctrlKey
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
isMac() {
|
|
375
|
+
const skin = this.skin();
|
|
376
|
+
return skin === "mac" || skin === "macc";
|
|
377
|
+
}
|
|
378
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
379
|
+
minVersion: "12.0.0",
|
|
380
|
+
version: "22.2.5",
|
|
381
|
+
ngImport: i0,
|
|
382
|
+
type: SnSelectable,
|
|
383
|
+
deps: [],
|
|
384
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
385
|
+
});
|
|
386
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
387
|
+
minVersion: "17.2.0",
|
|
388
|
+
version: "22.2.5",
|
|
389
|
+
type: SnSelectable,
|
|
390
|
+
isStandalone: true,
|
|
391
|
+
selector: "[snSelectable]",
|
|
392
|
+
inputs: {
|
|
393
|
+
role: {
|
|
394
|
+
classPropertyName: "role",
|
|
395
|
+
publicName: "snSelectable",
|
|
396
|
+
isSignal: true,
|
|
397
|
+
isRequired: false,
|
|
398
|
+
transformFunction: null
|
|
399
|
+
},
|
|
400
|
+
multiple: {
|
|
401
|
+
classPropertyName: "multiple",
|
|
402
|
+
publicName: "multiple",
|
|
403
|
+
isSignal: true,
|
|
404
|
+
isRequired: false,
|
|
405
|
+
transformFunction: null
|
|
406
|
+
},
|
|
407
|
+
selection: {
|
|
408
|
+
classPropertyName: "selection",
|
|
409
|
+
publicName: "selection",
|
|
410
|
+
isSignal: true,
|
|
411
|
+
isRequired: false,
|
|
412
|
+
transformFunction: null
|
|
413
|
+
}
|
|
414
|
+
},
|
|
415
|
+
outputs: {
|
|
416
|
+
selection: "selectionChange",
|
|
417
|
+
activated: "activated"
|
|
418
|
+
},
|
|
419
|
+
host: {
|
|
420
|
+
attributes: {
|
|
421
|
+
"data-slot": "sn-selectable",
|
|
422
|
+
"tabindex": "0"
|
|
423
|
+
},
|
|
424
|
+
listeners: {
|
|
425
|
+
"keydown": "onKeydown($event)",
|
|
426
|
+
"focus": "onFocus()"
|
|
427
|
+
},
|
|
428
|
+
properties: {
|
|
429
|
+
"attr.role": "role()",
|
|
430
|
+
"attr.aria-multiselectable": "multiple()",
|
|
431
|
+
"attr.aria-activedescendant": "activeId()"
|
|
432
|
+
}
|
|
433
|
+
},
|
|
434
|
+
providers: [{
|
|
435
|
+
provide: SN_SELECTABLE,
|
|
436
|
+
useExisting: forwardRef(() => SnSelectable)
|
|
437
|
+
}],
|
|
438
|
+
queries: [{
|
|
439
|
+
propertyName: "items",
|
|
440
|
+
predicate: SnSelectableItem,
|
|
441
|
+
descendants: true,
|
|
442
|
+
isSignal: true
|
|
443
|
+
}],
|
|
444
|
+
exportAs: ["snSelectable"],
|
|
445
|
+
ngImport: i0
|
|
446
|
+
});
|
|
447
|
+
};
|
|
448
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
449
|
+
minVersion: "12.0.0",
|
|
450
|
+
version: "22.2.5",
|
|
451
|
+
ngImport: i0,
|
|
452
|
+
type: SnSelectable,
|
|
453
|
+
decorators: [{
|
|
454
|
+
type: Directive,
|
|
455
|
+
args: [{
|
|
456
|
+
selector: "[snSelectable]",
|
|
457
|
+
exportAs: "snSelectable",
|
|
458
|
+
providers: [{
|
|
459
|
+
provide: SN_SELECTABLE,
|
|
460
|
+
useExisting: forwardRef(() => SnSelectable)
|
|
461
|
+
}],
|
|
462
|
+
host: {
|
|
463
|
+
"data-slot": "sn-selectable",
|
|
464
|
+
tabindex: "0",
|
|
465
|
+
"[attr.role]": "role()",
|
|
466
|
+
"[attr.aria-multiselectable]": "multiple()",
|
|
467
|
+
"[attr.aria-activedescendant]": "activeId()",
|
|
468
|
+
"(keydown)": "onKeydown($event)",
|
|
469
|
+
"(focus)": "onFocus()"
|
|
470
|
+
}
|
|
471
|
+
}]
|
|
472
|
+
}],
|
|
473
|
+
ctorParameters: () => [],
|
|
474
|
+
propDecorators: {
|
|
475
|
+
role: [{
|
|
476
|
+
type: i0.Input,
|
|
477
|
+
args: [{
|
|
478
|
+
isSignal: true,
|
|
479
|
+
alias: "snSelectable",
|
|
480
|
+
required: false
|
|
481
|
+
}]
|
|
482
|
+
}],
|
|
483
|
+
multiple: [{
|
|
484
|
+
type: i0.Input,
|
|
485
|
+
args: [{
|
|
486
|
+
isSignal: true,
|
|
487
|
+
alias: "multiple",
|
|
488
|
+
required: false
|
|
489
|
+
}]
|
|
490
|
+
}],
|
|
491
|
+
selection: [{
|
|
492
|
+
type: i0.Input,
|
|
493
|
+
args: [{
|
|
494
|
+
isSignal: true,
|
|
495
|
+
alias: "selection",
|
|
496
|
+
required: false
|
|
497
|
+
}]
|
|
498
|
+
}, {
|
|
499
|
+
type: i0.Output,
|
|
500
|
+
args: ["selectionChange"]
|
|
501
|
+
}],
|
|
502
|
+
activated: [{
|
|
503
|
+
type: i0.Output,
|
|
504
|
+
args: ["activated"]
|
|
505
|
+
}],
|
|
506
|
+
items: [{
|
|
507
|
+
type: i0.ContentChildren,
|
|
508
|
+
args: [i0.forwardRef(() => SnSelectableItem), {
|
|
509
|
+
descendants: true,
|
|
510
|
+
isSignal: true
|
|
511
|
+
}]
|
|
512
|
+
}]
|
|
513
|
+
}
|
|
514
|
+
});
|
|
515
|
+
function isEditable(target, host) {
|
|
516
|
+
if (!(target instanceof HTMLElement) || target === host) return false;
|
|
517
|
+
return target.isContentEditable || target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement || target instanceof HTMLSelectElement;
|
|
518
|
+
}
|
|
519
|
+
const SnSelectableImports = [SnSelectable, SnSelectableItem];
|
|
520
|
+
const SCOPE = "[snActionScope], [role=\"dialog\"], [role=\"alertdialog\"], form";
|
|
521
|
+
const OWNS_ENTER = "textarea, button, a[href], select, [contenteditable=\"\"], [contenteditable=\"true\"], [role=\"listbox\"], [role=\"grid\"], [role=\"menu\"], [role=\"tree\"]";
|
|
522
|
+
var SnActionScope = class SnActionScope {
|
|
523
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
524
|
+
minVersion: "12.0.0",
|
|
525
|
+
version: "22.2.5",
|
|
526
|
+
ngImport: i0,
|
|
527
|
+
type: SnActionScope,
|
|
528
|
+
deps: [],
|
|
529
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
530
|
+
});
|
|
531
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
532
|
+
minVersion: "14.0.0",
|
|
533
|
+
version: "22.2.5",
|
|
534
|
+
type: SnActionScope,
|
|
535
|
+
isStandalone: true,
|
|
536
|
+
selector: "[snActionScope]",
|
|
537
|
+
host: { attributes: { "data-slot": "sn-action-scope" } },
|
|
538
|
+
ngImport: i0
|
|
539
|
+
});
|
|
540
|
+
};
|
|
541
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
542
|
+
minVersion: "12.0.0",
|
|
543
|
+
version: "22.2.5",
|
|
544
|
+
ngImport: i0,
|
|
545
|
+
type: SnActionScope,
|
|
546
|
+
decorators: [{
|
|
547
|
+
type: Directive,
|
|
548
|
+
args: [{
|
|
549
|
+
selector: "[snActionScope]",
|
|
550
|
+
host: { "data-slot": "sn-action-scope" }
|
|
551
|
+
}]
|
|
552
|
+
}]
|
|
553
|
+
});
|
|
554
|
+
function listenInScope(key, onKey) {
|
|
555
|
+
const element = inject(ElementRef).nativeElement;
|
|
556
|
+
const destroyRef = inject(DestroyRef);
|
|
557
|
+
afterNextRender(() => {
|
|
558
|
+
const scope = element.closest(SCOPE) ?? element.ownerDocument;
|
|
559
|
+
const listener = (event) => {
|
|
560
|
+
const e = event;
|
|
561
|
+
if (e.key !== key || e.defaultPrevented || e.isComposing) return;
|
|
562
|
+
onKey(e);
|
|
563
|
+
};
|
|
564
|
+
scope.addEventListener("keydown", listener);
|
|
565
|
+
destroyRef.onDestroy(() => scope.removeEventListener("keydown", listener));
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
var SnDefaultAction = class SnDefaultAction {
|
|
569
|
+
button = inject(ElementRef).nativeElement;
|
|
570
|
+
constructor() {
|
|
571
|
+
listenInScope("Enter", (event) => {
|
|
572
|
+
const target = event.target;
|
|
573
|
+
if (this.button.disabled || target?.closest(OWNS_ENTER)) return;
|
|
574
|
+
event.preventDefault();
|
|
575
|
+
this.button.click();
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
579
|
+
minVersion: "12.0.0",
|
|
580
|
+
version: "22.2.5",
|
|
581
|
+
ngImport: i0,
|
|
582
|
+
type: SnDefaultAction,
|
|
583
|
+
deps: [],
|
|
584
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
585
|
+
});
|
|
586
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
587
|
+
minVersion: "14.0.0",
|
|
588
|
+
version: "22.2.5",
|
|
589
|
+
type: SnDefaultAction,
|
|
590
|
+
isStandalone: true,
|
|
591
|
+
selector: "button[snDefaultAction]",
|
|
592
|
+
host: { attributes: { "data-sn-default-action": "" } },
|
|
593
|
+
ngImport: i0
|
|
594
|
+
});
|
|
595
|
+
};
|
|
596
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
597
|
+
minVersion: "12.0.0",
|
|
598
|
+
version: "22.2.5",
|
|
599
|
+
ngImport: i0,
|
|
600
|
+
type: SnDefaultAction,
|
|
601
|
+
decorators: [{
|
|
602
|
+
type: Directive,
|
|
603
|
+
args: [{
|
|
604
|
+
selector: "button[snDefaultAction]",
|
|
605
|
+
host: { "data-sn-default-action": "" }
|
|
606
|
+
}]
|
|
607
|
+
}],
|
|
608
|
+
ctorParameters: () => []
|
|
609
|
+
});
|
|
610
|
+
var SnCancelAction = class SnCancelAction {
|
|
611
|
+
button = inject(ElementRef).nativeElement;
|
|
612
|
+
constructor() {
|
|
613
|
+
listenInScope("Escape", (event) => {
|
|
614
|
+
if (this.button.disabled) return;
|
|
615
|
+
event.preventDefault();
|
|
616
|
+
this.button.click();
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
620
|
+
minVersion: "12.0.0",
|
|
621
|
+
version: "22.2.5",
|
|
622
|
+
ngImport: i0,
|
|
623
|
+
type: SnCancelAction,
|
|
624
|
+
deps: [],
|
|
625
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
626
|
+
});
|
|
627
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
628
|
+
minVersion: "14.0.0",
|
|
629
|
+
version: "22.2.5",
|
|
630
|
+
type: SnCancelAction,
|
|
631
|
+
isStandalone: true,
|
|
632
|
+
selector: "button[snCancelAction]",
|
|
633
|
+
host: { attributes: { "data-sn-cancel-action": "" } },
|
|
634
|
+
ngImport: i0
|
|
635
|
+
});
|
|
636
|
+
};
|
|
637
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
638
|
+
minVersion: "12.0.0",
|
|
639
|
+
version: "22.2.5",
|
|
640
|
+
ngImport: i0,
|
|
641
|
+
type: SnCancelAction,
|
|
642
|
+
decorators: [{
|
|
643
|
+
type: Directive,
|
|
644
|
+
args: [{
|
|
645
|
+
selector: "button[snCancelAction]",
|
|
646
|
+
host: { "data-sn-cancel-action": "" }
|
|
647
|
+
}]
|
|
648
|
+
}],
|
|
649
|
+
ctorParameters: () => []
|
|
650
|
+
});
|
|
651
|
+
var SnDialogButtons = class SnDialogButtons {
|
|
652
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
653
|
+
minVersion: "12.0.0",
|
|
654
|
+
version: "22.2.5",
|
|
655
|
+
ngImport: i0,
|
|
656
|
+
type: SnDialogButtons,
|
|
657
|
+
deps: [],
|
|
658
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
659
|
+
});
|
|
660
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
661
|
+
minVersion: "14.0.0",
|
|
662
|
+
version: "22.2.5",
|
|
663
|
+
type: SnDialogButtons,
|
|
664
|
+
isStandalone: true,
|
|
665
|
+
selector: "[snDialogButtons]",
|
|
666
|
+
host: { attributes: { "data-sn-dialog-buttons": "" } },
|
|
667
|
+
ngImport: i0
|
|
668
|
+
});
|
|
669
|
+
};
|
|
670
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
671
|
+
minVersion: "12.0.0",
|
|
672
|
+
version: "22.2.5",
|
|
673
|
+
ngImport: i0,
|
|
674
|
+
type: SnDialogButtons,
|
|
675
|
+
decorators: [{
|
|
676
|
+
type: Directive,
|
|
677
|
+
args: [{
|
|
678
|
+
selector: "[snDialogButtons]",
|
|
679
|
+
host: { "data-sn-dialog-buttons": "" }
|
|
680
|
+
}]
|
|
681
|
+
}]
|
|
682
|
+
});
|
|
683
|
+
const SnDialogActionsImports = [
|
|
684
|
+
SnActionScope,
|
|
685
|
+
SnDefaultAction,
|
|
686
|
+
SnCancelAction,
|
|
687
|
+
SnDialogButtons
|
|
688
|
+
];
|
|
689
|
+
export { EMPTY_SELECTION, SELECTION_PAGE_SIZE, SnActionScope, SnCancelAction, SnDefaultAction, SnDialogActionsImports, SnDialogButtons, SnSelectable, SnSelectableImports, SnSelectableItem, TYPEAHEAD_RESET_MS, selectionAll, selectionClear, selectionClick, selectionMoveBy, selectionMoveTo, selectionSync, selectionToggleActive, typeaheadIndex };
|
|
690
|
+
|
|
691
|
+
//# sourceMappingURL=spartan-native-helm.mjs.map
|