@nanahoshi/mona-ui 0.40.0 → 0.41.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.
- package/docs/api/common.md +1 -1
- package/docs/api/i18n.md +34 -0
- package/docs/api/kanban.md +222 -0
- package/docs/api/locales.md +14 -14
- package/docs/api/sortable.md +189 -0
- package/docs/api/tabs.md +20 -0
- package/docs/kanban.md +293 -0
- package/docs/sortable.md +320 -0
- package/docs/tabs.md +59 -10
- package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +48 -0
- package/fesm2022/nanahoshi-mona-ui-kanban.mjs +660 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +9 -0
- package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +9 -0
- package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +9 -0
- package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +9 -0
- package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +9 -0
- package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +9 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +9 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +9 -0
- package/fesm2022/nanahoshi-mona-ui-locales-pl-pl.mjs +19 -0
- package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +9 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +19 -0
- package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +9 -0
- package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +9 -0
- package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +9 -0
- package/fesm2022/nanahoshi-mona-ui-sortable.mjs +733 -0
- package/fesm2022/nanahoshi-mona-ui-tabs.mjs +112 -5
- package/i18n/catalogs/en-US.messages.json +9 -0
- package/kanban/package.json +4 -0
- package/llms.txt +6 -2
- package/locales/ar-sa/ar-sa.messages.json +9 -0
- package/locales/de-de/de-de.messages.json +9 -0
- package/locales/es-es/es-es.messages.json +9 -0
- package/locales/fr-fr/fr-fr.messages.json +9 -0
- package/locales/id-id/id-id.messages.json +9 -0
- package/locales/it-it/it-it.messages.json +9 -0
- package/locales/ja-jp/ja-jp.messages.json +9 -0
- package/locales/ko-kr/ko-kr.messages.json +9 -0
- package/locales/pl-pl/pl-pl.messages.json +9 -0
- package/locales/pt-br/pt-br.messages.json +9 -0
- package/locales/ru-ru/ru-ru.messages.json +9 -0
- package/locales/tr-tr/tr-tr.messages.json +9 -0
- package/locales/zh-cn/zh-cn.messages.json +9 -0
- package/locales/zh-tw/zh-tw.messages.json +9 -0
- package/package.json +9 -1
- package/sortable/package.json +4 -0
- package/types/nanahoshi-mona-ui-i18n.d.ts +19 -0
- package/types/nanahoshi-mona-ui-kanban.d.ts +270 -0
- package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +9 -0
- package/types/nanahoshi-mona-ui-locales-de-de.d.ts +9 -0
- package/types/nanahoshi-mona-ui-locales-es-es.d.ts +9 -0
- package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +9 -0
- package/types/nanahoshi-mona-ui-locales-id-id.d.ts +9 -0
- package/types/nanahoshi-mona-ui-locales-it-it.d.ts +9 -0
- package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +9 -0
- package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +9 -0
- package/types/nanahoshi-mona-ui-locales-pl-pl.d.ts +9 -0
- package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +9 -0
- package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +9 -0
- package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +9 -0
- package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +9 -0
- package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +9 -0
- package/types/nanahoshi-mona-ui-sortable.d.ts +245 -0
- package/types/nanahoshi-mona-ui-tabs.d.ts +46 -0
|
@@ -0,0 +1,733 @@
|
|
|
1
|
+
import * as i1 from "@angular/cdk/drag-drop";
|
|
2
|
+
import { CdkDrag, CdkDragHandle, CdkDropList, CdkDropListGroup } from "@angular/cdk/drag-drop";
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
import { CSP_NONCE, DOCUMENT, DestroyRef, Directive, ElementRef, HostAttributeToken, Injector, afterNextRender, booleanAttribute, computed, effect, inject, input, output, signal } from "@angular/core";
|
|
5
|
+
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
|
6
|
+
import { MonaI18nService, formatNumber, injectComponentDirection } from "@nanahoshi/mona-ui/i18n";
|
|
7
|
+
import { injectLiveAnnouncer } from "@nanahoshi/mona-ui/internal/live-announcer";
|
|
8
|
+
import { PreventableEvent } from "@nanahoshi/mona-ui/common";
|
|
9
|
+
function localizeNumber(value, options) {
|
|
10
|
+
return formatNumber(value, "en-US", options);
|
|
11
|
+
}
|
|
12
|
+
const SORTABLE_DEFAULT_MESSAGES = {
|
|
13
|
+
itemMoved: (item, position, total) => `${item} moved to position ${localizeNumber(position)} of ${localizeNumber(total)}`,
|
|
14
|
+
itemMovedToList: (item, list, position, total) => `${item} moved to ${list}, position ${localizeNumber(position)} of ${localizeNumber(total)}`
|
|
15
|
+
};
|
|
16
|
+
var SortableMoveEvent = class extends PreventableEvent {
|
|
17
|
+
#options;
|
|
18
|
+
constructor(options, originalEvent) {
|
|
19
|
+
super("sortableMove", originalEvent);
|
|
20
|
+
this.#options = options;
|
|
21
|
+
}
|
|
22
|
+
get currentIndex() {
|
|
23
|
+
return this.#options.currentIndex;
|
|
24
|
+
}
|
|
25
|
+
get currentItems() {
|
|
26
|
+
return this.#options.currentItems;
|
|
27
|
+
}
|
|
28
|
+
get currentList() {
|
|
29
|
+
return this.#options.currentList;
|
|
30
|
+
}
|
|
31
|
+
get item() {
|
|
32
|
+
return this.#options.item;
|
|
33
|
+
}
|
|
34
|
+
get previousIndex() {
|
|
35
|
+
return this.#options.previousIndex;
|
|
36
|
+
}
|
|
37
|
+
get previousItems() {
|
|
38
|
+
return this.#options.previousItems;
|
|
39
|
+
}
|
|
40
|
+
get previousList() {
|
|
41
|
+
return this.#options.previousList;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const LAYER_ORDER_MARKER = "data-mona-cdk-resets";
|
|
45
|
+
function declareCdkResetsLayerFirst() {
|
|
46
|
+
const document = inject(DOCUMENT);
|
|
47
|
+
const head = document.head;
|
|
48
|
+
if (!head || head.querySelector(`style[${LAYER_ORDER_MARKER}]`)) return;
|
|
49
|
+
const style = document.createElement("style");
|
|
50
|
+
style.setAttribute(LAYER_ORDER_MARKER, "");
|
|
51
|
+
const nonce = inject(CSP_NONCE, { optional: true });
|
|
52
|
+
if (nonce) style.setAttribute("nonce", nonce);
|
|
53
|
+
style.textContent = "@layer cdk-resets;";
|
|
54
|
+
head.insertBefore(style, head.querySelector("link[rel~='stylesheet'], style"));
|
|
55
|
+
}
|
|
56
|
+
function moveItem(items, from, to) {
|
|
57
|
+
const result = [...items];
|
|
58
|
+
if (result.length === 0) return result;
|
|
59
|
+
const last = result.length - 1;
|
|
60
|
+
const start = Math.min(Math.max(Math.trunc(from), 0), last);
|
|
61
|
+
const end = Math.min(Math.max(Math.trunc(to), 0), last);
|
|
62
|
+
const [moved] = result.splice(start, 1);
|
|
63
|
+
result.splice(end, 0, moved);
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
const FOCUSABLE_SELECTOR = "[tabindex], a[href], button:not([disabled]), input:not([disabled]), select, textarea";
|
|
67
|
+
function readElementLabel(element, useText) {
|
|
68
|
+
const label = element.getAttribute("aria-label")?.trim();
|
|
69
|
+
if (label) return label;
|
|
70
|
+
const root = element.getRootNode();
|
|
71
|
+
const labelledBy = (element.getAttribute("aria-labelledby") ?? "").split(/\s+/).filter((id) => id.length > 0).map((id) => normalizeText(root.getElementById(id)?.textContent)).filter((text) => text.length > 0).join(" ");
|
|
72
|
+
if (labelledBy) return labelledBy;
|
|
73
|
+
return useText ? readVisibleText(element) : "";
|
|
74
|
+
}
|
|
75
|
+
function findFocusTarget(item) {
|
|
76
|
+
if (item.matches(FOCUSABLE_SELECTOR)) return item;
|
|
77
|
+
return item.querySelector(FOCUSABLE_SELECTOR);
|
|
78
|
+
}
|
|
79
|
+
function isTextEntryTarget(target) {
|
|
80
|
+
if (!(target instanceof HTMLElement)) return false;
|
|
81
|
+
if (target.isContentEditable || target instanceof HTMLTextAreaElement || target instanceof HTMLSelectElement) return true;
|
|
82
|
+
if (!(target instanceof HTMLInputElement)) return false;
|
|
83
|
+
return ![
|
|
84
|
+
"button",
|
|
85
|
+
"checkbox",
|
|
86
|
+
"color",
|
|
87
|
+
"file",
|
|
88
|
+
"image",
|
|
89
|
+
"radio",
|
|
90
|
+
"range",
|
|
91
|
+
"reset",
|
|
92
|
+
"submit"
|
|
93
|
+
].includes(target.type);
|
|
94
|
+
}
|
|
95
|
+
function findRowNeighbor(elements, from, step) {
|
|
96
|
+
const rects = elements.map((element) => element.getBoundingClientRect());
|
|
97
|
+
const current = rects[from];
|
|
98
|
+
const tolerance = current.height / 2;
|
|
99
|
+
const ahead = rects.map((rect, index) => ({
|
|
100
|
+
index,
|
|
101
|
+
rect
|
|
102
|
+
})).filter(({ rect }) => step > 0 ? rect.top >= current.bottom - 1 : rect.bottom <= current.top + 1);
|
|
103
|
+
if (ahead.length === 0) return from;
|
|
104
|
+
const rowEdge = step > 0 ? Math.min(...ahead.map(({ rect }) => rect.top)) : Math.max(...ahead.map(({ rect }) => rect.bottom));
|
|
105
|
+
const row = ahead.filter(({ rect }) => step > 0 ? rect.top < rowEdge + tolerance : rect.bottom > rowEdge - tolerance);
|
|
106
|
+
const middle = current.left + current.width / 2;
|
|
107
|
+
let nearest = row[0];
|
|
108
|
+
for (const candidate of row) if (Math.abs(candidate.rect.left + candidate.rect.width / 2 - middle) < Math.abs(nearest.rect.left + nearest.rect.width / 2 - middle)) nearest = candidate;
|
|
109
|
+
return nearest.index;
|
|
110
|
+
}
|
|
111
|
+
function readVisibleText(element) {
|
|
112
|
+
let text = "";
|
|
113
|
+
const visit = (node) => {
|
|
114
|
+
for (const child of Array.from(node.childNodes)) if (child.nodeType === Node.TEXT_NODE) text += child.textContent ?? "";
|
|
115
|
+
else if (child instanceof Element && child.getAttribute("aria-hidden") !== "true") {
|
|
116
|
+
text += " ";
|
|
117
|
+
visit(child);
|
|
118
|
+
text += " ";
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
visit(element);
|
|
122
|
+
return normalizeText(text);
|
|
123
|
+
}
|
|
124
|
+
function normalizeText(text) {
|
|
125
|
+
return (text ?? "").replace(/\s+/g, " ").trim();
|
|
126
|
+
}
|
|
127
|
+
var SortableGroupDirective = class SortableGroupDirective {
|
|
128
|
+
constructor() {
|
|
129
|
+
this.#lists = signal([], ...ngDevMode ? [{ debugName: "#lists" }] : /* istanbul ignore next */ []);
|
|
130
|
+
this.listCount = computed(() => this.#lists().length, ...ngDevMode ? [{ debugName: "listCount" }] : /* istanbul ignore next */ []);
|
|
131
|
+
}
|
|
132
|
+
#lists;
|
|
133
|
+
orderedLists() {
|
|
134
|
+
return [...this.#lists()].sort((first, second) => first.element.compareDocumentPosition(second.element) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1);
|
|
135
|
+
}
|
|
136
|
+
register(list) {
|
|
137
|
+
this.#lists.update((lists) => [...lists, list]);
|
|
138
|
+
}
|
|
139
|
+
unregister(list) {
|
|
140
|
+
this.#lists.update((lists) => lists.filter((candidate) => candidate !== list));
|
|
141
|
+
}
|
|
142
|
+
static {
|
|
143
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
144
|
+
minVersion: "12.0.0",
|
|
145
|
+
version: "22.2.6",
|
|
146
|
+
ngImport: i0,
|
|
147
|
+
type: SortableGroupDirective,
|
|
148
|
+
deps: [],
|
|
149
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
static {
|
|
153
|
+
this.ɵdir = i0.ɵɵngDeclareDirective({
|
|
154
|
+
minVersion: "14.0.0",
|
|
155
|
+
version: "22.2.6",
|
|
156
|
+
type: SortableGroupDirective,
|
|
157
|
+
isStandalone: true,
|
|
158
|
+
selector: "[monaSortableGroup]",
|
|
159
|
+
exportAs: ["monaSortableGroup"],
|
|
160
|
+
hostDirectives: [{ directive: i1.CdkDropListGroup }],
|
|
161
|
+
ngImport: i0
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
166
|
+
minVersion: "12.0.0",
|
|
167
|
+
version: "22.2.6",
|
|
168
|
+
ngImport: i0,
|
|
169
|
+
type: SortableGroupDirective,
|
|
170
|
+
decorators: [{
|
|
171
|
+
type: Directive,
|
|
172
|
+
args: [{
|
|
173
|
+
selector: "[monaSortableGroup]",
|
|
174
|
+
exportAs: "monaSortableGroup",
|
|
175
|
+
hostDirectives: [CdkDropListGroup]
|
|
176
|
+
}]
|
|
177
|
+
}]
|
|
178
|
+
});
|
|
179
|
+
var SortableDirective = class SortableDirective {
|
|
180
|
+
#announcer;
|
|
181
|
+
#direction;
|
|
182
|
+
#dropList;
|
|
183
|
+
#group;
|
|
184
|
+
#injector;
|
|
185
|
+
#messages;
|
|
186
|
+
constructor() {
|
|
187
|
+
this.#announcer = injectLiveAnnouncer();
|
|
188
|
+
this.#direction = injectComponentDirection();
|
|
189
|
+
this.#dropList = inject(CdkDropList);
|
|
190
|
+
this.#group = inject(SortableGroupDirective, { optional: true });
|
|
191
|
+
this.#injector = inject(Injector);
|
|
192
|
+
this.#messages = inject(MonaI18nService).componentMessages("sortable", SORTABLE_DEFAULT_MESSAGES);
|
|
193
|
+
this.canEnter = input(null, {
|
|
194
|
+
...ngDevMode ? { debugName: "canEnter" } : /* istanbul ignore next */ {},
|
|
195
|
+
alias: "sortableCanEnter"
|
|
196
|
+
});
|
|
197
|
+
this.disabled = input(false, {
|
|
198
|
+
...ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {},
|
|
199
|
+
alias: "sortableDisabled",
|
|
200
|
+
transform: booleanAttribute
|
|
201
|
+
});
|
|
202
|
+
this.dragAxis = computed(() => {
|
|
203
|
+
if (!this.lockAxis()) return null;
|
|
204
|
+
switch (this.orientation()) {
|
|
205
|
+
case "horizontal": return "x";
|
|
206
|
+
case "vertical": return "y";
|
|
207
|
+
default: return null;
|
|
208
|
+
}
|
|
209
|
+
}, ...ngDevMode ? [{ debugName: "dragAxis" }] : /* istanbul ignore next */ []);
|
|
210
|
+
this.element = inject(ElementRef).nativeElement;
|
|
211
|
+
this.items = input.required({
|
|
212
|
+
...ngDevMode ? { debugName: "items" } : /* istanbul ignore next */ {},
|
|
213
|
+
alias: "monaSortable"
|
|
214
|
+
});
|
|
215
|
+
this.keyShortcuts = computed(() => {
|
|
216
|
+
if (this.disabled()) return null;
|
|
217
|
+
const crossesLists = (this.#group?.listCount() ?? 0) > 1;
|
|
218
|
+
const vertical = ["ArrowUp", "ArrowDown"];
|
|
219
|
+
const horizontal = ["ArrowLeft", "ArrowRight"];
|
|
220
|
+
let keys;
|
|
221
|
+
switch (this.orientation()) {
|
|
222
|
+
case "horizontal":
|
|
223
|
+
keys = [
|
|
224
|
+
...horizontal,
|
|
225
|
+
"Home",
|
|
226
|
+
"End",
|
|
227
|
+
...crossesLists ? vertical : []
|
|
228
|
+
];
|
|
229
|
+
break;
|
|
230
|
+
case "mixed":
|
|
231
|
+
keys = [
|
|
232
|
+
...vertical,
|
|
233
|
+
...horizontal,
|
|
234
|
+
"Home",
|
|
235
|
+
"End"
|
|
236
|
+
];
|
|
237
|
+
break;
|
|
238
|
+
default: keys = [
|
|
239
|
+
...vertical,
|
|
240
|
+
"Home",
|
|
241
|
+
"End",
|
|
242
|
+
...crossesLists ? horizontal : []
|
|
243
|
+
];
|
|
244
|
+
}
|
|
245
|
+
return keys.map((key) => `Control+Shift+${key}`).join(" ");
|
|
246
|
+
}, ...ngDevMode ? [{ debugName: "keyShortcuts" }] : /* istanbul ignore next */ []);
|
|
247
|
+
this.label = input("", {
|
|
248
|
+
...ngDevMode ? { debugName: "label" } : /* istanbul ignore next */ {},
|
|
249
|
+
alias: "sortableLabel"
|
|
250
|
+
});
|
|
251
|
+
this.lockAxis = input(false, {
|
|
252
|
+
...ngDevMode ? { debugName: "lockAxis" } : /* istanbul ignore next */ {},
|
|
253
|
+
alias: "sortableLockAxis",
|
|
254
|
+
transform: booleanAttribute
|
|
255
|
+
});
|
|
256
|
+
this.monaSortableChange = output();
|
|
257
|
+
this.orientation = input("vertical", {
|
|
258
|
+
...ngDevMode ? { debugName: "orientation" } : /* istanbul ignore next */ {},
|
|
259
|
+
alias: "sortableOrientation"
|
|
260
|
+
});
|
|
261
|
+
this.sortableMove = output();
|
|
262
|
+
declareCdkResetsLayerFirst();
|
|
263
|
+
const dropList = this.#dropList;
|
|
264
|
+
dropList.data = this;
|
|
265
|
+
dropList.enterPredicate = (drag) => this.accepts(drag.data);
|
|
266
|
+
effect(() => {
|
|
267
|
+
dropList.disabled = this.disabled();
|
|
268
|
+
dropList.orientation = this.orientation();
|
|
269
|
+
dropList.lockAxis = this.dragAxis();
|
|
270
|
+
});
|
|
271
|
+
dropList.dropped.pipe(takeUntilDestroyed()).subscribe((drop) => {
|
|
272
|
+
if (drop.previousContainer !== drop.container || drop.previousIndex !== drop.currentIndex) this.applyMove(drop.item.data, drop.currentIndex, drop.event, false);
|
|
273
|
+
});
|
|
274
|
+
const group = this.#group;
|
|
275
|
+
if (group) {
|
|
276
|
+
afterNextRender(() => group.register(this));
|
|
277
|
+
inject(DestroyRef).onDestroy(() => group.unregister(this));
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
accepts(item) {
|
|
281
|
+
if (item.list === this) return true;
|
|
282
|
+
if (this.disabled()) return false;
|
|
283
|
+
const canEnter = this.canEnter();
|
|
284
|
+
return canEnter == null || canEnter(item.item());
|
|
285
|
+
}
|
|
286
|
+
applyMove(item, targetIndex, originalEvent, fromKeyboard) {
|
|
287
|
+
const source = item.list;
|
|
288
|
+
const value = item.item();
|
|
289
|
+
const sourceItems = source.items();
|
|
290
|
+
const previousIndex = sourceItems.indexOf(value);
|
|
291
|
+
if (previousIndex < 0) return false;
|
|
292
|
+
const sameList = source === this;
|
|
293
|
+
let currentItems;
|
|
294
|
+
let previousItems;
|
|
295
|
+
let currentIndex;
|
|
296
|
+
if (sameList) {
|
|
297
|
+
currentIndex = Math.min(Math.max(targetIndex, 0), sourceItems.length - 1);
|
|
298
|
+
currentItems = moveItem(sourceItems, previousIndex, currentIndex);
|
|
299
|
+
previousItems = currentItems;
|
|
300
|
+
} else {
|
|
301
|
+
currentItems = [...this.items()];
|
|
302
|
+
currentIndex = Math.min(Math.max(targetIndex, 0), currentItems.length);
|
|
303
|
+
currentItems.splice(currentIndex, 0, value);
|
|
304
|
+
previousItems = sourceItems.filter((_, index) => index !== previousIndex);
|
|
305
|
+
}
|
|
306
|
+
const itemLabel = item.labelText();
|
|
307
|
+
const listLabel = sameList ? "" : this.labelText();
|
|
308
|
+
const focused = fromKeyboard ? item.focusedElement() : null;
|
|
309
|
+
const event = new SortableMoveEvent({
|
|
310
|
+
currentIndex,
|
|
311
|
+
currentItems,
|
|
312
|
+
currentList: this,
|
|
313
|
+
item: value,
|
|
314
|
+
previousIndex,
|
|
315
|
+
previousItems,
|
|
316
|
+
previousList: source
|
|
317
|
+
}, originalEvent);
|
|
318
|
+
this.sortableMove.emit(event);
|
|
319
|
+
if (event.isDefaultPrevented()) return false;
|
|
320
|
+
if (!sameList) source.monaSortableChange.emit(previousItems);
|
|
321
|
+
this.monaSortableChange.emit(currentItems);
|
|
322
|
+
const messages = this.#messages();
|
|
323
|
+
const position = currentIndex + 1;
|
|
324
|
+
this.#announcer.announce(listLabel ? messages.itemMovedToList(itemLabel, listLabel, position, currentItems.length) : messages.itemMoved(itemLabel, position, currentItems.length));
|
|
325
|
+
if (fromKeyboard) this.restoreFocus(value, currentIndex, focused);
|
|
326
|
+
return true;
|
|
327
|
+
}
|
|
328
|
+
keyboardMove(item, key, event) {
|
|
329
|
+
if (this.disabled() || item.disabled()) return;
|
|
330
|
+
const items = this.sortedItems();
|
|
331
|
+
const from = items.indexOf(item);
|
|
332
|
+
if (from < 0) return;
|
|
333
|
+
const target = this.findMoveTarget(items, from, key);
|
|
334
|
+
if (target != null && (target.list !== this || target.index !== from)) target.list.applyMove(item, target.index, event, true);
|
|
335
|
+
}
|
|
336
|
+
labelText() {
|
|
337
|
+
return this.label() || readElementLabel(this.element, false);
|
|
338
|
+
}
|
|
339
|
+
sortedItems() {
|
|
340
|
+
return this.#dropList.getSortedItems().map((drag) => drag.data);
|
|
341
|
+
}
|
|
342
|
+
findAdjacentList(item, from, step) {
|
|
343
|
+
if (step === 0 || this.#group == null) return null;
|
|
344
|
+
const lists = this.#group.orderedLists();
|
|
345
|
+
for (let index = lists.indexOf(this) + step; index >= 0 && index < lists.length; index += step) {
|
|
346
|
+
const list = lists[index];
|
|
347
|
+
if (list.accepts(item)) return {
|
|
348
|
+
index: Math.min(from, list.items().length),
|
|
349
|
+
list
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
return null;
|
|
353
|
+
}
|
|
354
|
+
findMoveTarget(items, from, key) {
|
|
355
|
+
const last = items.length - 1;
|
|
356
|
+
if (key === "Home" || key === "End") return {
|
|
357
|
+
index: key === "Home" ? 0 : last,
|
|
358
|
+
list: this
|
|
359
|
+
};
|
|
360
|
+
const rightToLeft = this.#direction() === "rtl";
|
|
361
|
+
const across = (key === "ArrowRight" ? 1 : key === "ArrowLeft" ? -1 : 0) * (rightToLeft ? -1 : 1);
|
|
362
|
+
const down = key === "ArrowDown" ? 1 : key === "ArrowUp" ? -1 : 0;
|
|
363
|
+
const within = (step) => ({
|
|
364
|
+
index: Math.min(Math.max(from + step, 0), last),
|
|
365
|
+
list: this
|
|
366
|
+
});
|
|
367
|
+
switch (this.orientation()) {
|
|
368
|
+
case "horizontal": return across !== 0 ? within(across) : this.findAdjacentList(items[from], from, down);
|
|
369
|
+
case "mixed":
|
|
370
|
+
if (across !== 0) return within(across);
|
|
371
|
+
return {
|
|
372
|
+
index: findRowNeighbor(items.map((candidate) => candidate.element), from, down),
|
|
373
|
+
list: this
|
|
374
|
+
};
|
|
375
|
+
default: return down !== 0 ? within(down) : this.findAdjacentList(items[from], from, across);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
restoreFocus(value, index, focused) {
|
|
379
|
+
afterNextRender({ write: () => {
|
|
380
|
+
const items = this.sortedItems();
|
|
381
|
+
const item = items.find((candidate) => candidate.item() === value) ?? items[index];
|
|
382
|
+
if (item == null) return;
|
|
383
|
+
const target = focused != null && focused.isConnected && item.element.contains(focused) ? focused : findFocusTarget(item.element);
|
|
384
|
+
if (target != null && target.ownerDocument.activeElement !== target) target.focus();
|
|
385
|
+
} }, { injector: this.#injector });
|
|
386
|
+
}
|
|
387
|
+
static {
|
|
388
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
389
|
+
minVersion: "12.0.0",
|
|
390
|
+
version: "22.2.6",
|
|
391
|
+
ngImport: i0,
|
|
392
|
+
type: SortableDirective,
|
|
393
|
+
deps: [],
|
|
394
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
static {
|
|
398
|
+
this.ɵdir = i0.ɵɵngDeclareDirective({
|
|
399
|
+
minVersion: "17.1.0",
|
|
400
|
+
version: "22.2.6",
|
|
401
|
+
type: SortableDirective,
|
|
402
|
+
isStandalone: true,
|
|
403
|
+
selector: "[monaSortable]",
|
|
404
|
+
inputs: {
|
|
405
|
+
canEnter: {
|
|
406
|
+
classPropertyName: "canEnter",
|
|
407
|
+
publicName: "sortableCanEnter",
|
|
408
|
+
isSignal: true,
|
|
409
|
+
isRequired: false,
|
|
410
|
+
transformFunction: null
|
|
411
|
+
},
|
|
412
|
+
disabled: {
|
|
413
|
+
classPropertyName: "disabled",
|
|
414
|
+
publicName: "sortableDisabled",
|
|
415
|
+
isSignal: true,
|
|
416
|
+
isRequired: false,
|
|
417
|
+
transformFunction: null
|
|
418
|
+
},
|
|
419
|
+
items: {
|
|
420
|
+
classPropertyName: "items",
|
|
421
|
+
publicName: "monaSortable",
|
|
422
|
+
isSignal: true,
|
|
423
|
+
isRequired: true,
|
|
424
|
+
transformFunction: null
|
|
425
|
+
},
|
|
426
|
+
label: {
|
|
427
|
+
classPropertyName: "label",
|
|
428
|
+
publicName: "sortableLabel",
|
|
429
|
+
isSignal: true,
|
|
430
|
+
isRequired: false,
|
|
431
|
+
transformFunction: null
|
|
432
|
+
},
|
|
433
|
+
lockAxis: {
|
|
434
|
+
classPropertyName: "lockAxis",
|
|
435
|
+
publicName: "sortableLockAxis",
|
|
436
|
+
isSignal: true,
|
|
437
|
+
isRequired: false,
|
|
438
|
+
transformFunction: null
|
|
439
|
+
},
|
|
440
|
+
orientation: {
|
|
441
|
+
classPropertyName: "orientation",
|
|
442
|
+
publicName: "sortableOrientation",
|
|
443
|
+
isSignal: true,
|
|
444
|
+
isRequired: false,
|
|
445
|
+
transformFunction: null
|
|
446
|
+
}
|
|
447
|
+
},
|
|
448
|
+
outputs: {
|
|
449
|
+
monaSortableChange: "monaSortableChange",
|
|
450
|
+
sortableMove: "sortableMove"
|
|
451
|
+
},
|
|
452
|
+
exportAs: ["monaSortable"],
|
|
453
|
+
hostDirectives: [{ directive: i1.CdkDropList }],
|
|
454
|
+
ngImport: i0
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
};
|
|
458
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
459
|
+
minVersion: "12.0.0",
|
|
460
|
+
version: "22.2.6",
|
|
461
|
+
ngImport: i0,
|
|
462
|
+
type: SortableDirective,
|
|
463
|
+
decorators: [{
|
|
464
|
+
type: Directive,
|
|
465
|
+
args: [{
|
|
466
|
+
selector: "[monaSortable]",
|
|
467
|
+
exportAs: "monaSortable",
|
|
468
|
+
hostDirectives: [CdkDropList]
|
|
469
|
+
}]
|
|
470
|
+
}],
|
|
471
|
+
ctorParameters: () => [],
|
|
472
|
+
propDecorators: {
|
|
473
|
+
canEnter: [{
|
|
474
|
+
type: i0.Input,
|
|
475
|
+
args: [{
|
|
476
|
+
isSignal: true,
|
|
477
|
+
alias: "sortableCanEnter",
|
|
478
|
+
required: false
|
|
479
|
+
}]
|
|
480
|
+
}],
|
|
481
|
+
disabled: [{
|
|
482
|
+
type: i0.Input,
|
|
483
|
+
args: [{
|
|
484
|
+
isSignal: true,
|
|
485
|
+
alias: "sortableDisabled",
|
|
486
|
+
required: false
|
|
487
|
+
}]
|
|
488
|
+
}],
|
|
489
|
+
items: [{
|
|
490
|
+
type: i0.Input,
|
|
491
|
+
args: [{
|
|
492
|
+
isSignal: true,
|
|
493
|
+
alias: "monaSortable",
|
|
494
|
+
required: true
|
|
495
|
+
}]
|
|
496
|
+
}],
|
|
497
|
+
label: [{
|
|
498
|
+
type: i0.Input,
|
|
499
|
+
args: [{
|
|
500
|
+
isSignal: true,
|
|
501
|
+
alias: "sortableLabel",
|
|
502
|
+
required: false
|
|
503
|
+
}]
|
|
504
|
+
}],
|
|
505
|
+
lockAxis: [{
|
|
506
|
+
type: i0.Input,
|
|
507
|
+
args: [{
|
|
508
|
+
isSignal: true,
|
|
509
|
+
alias: "sortableLockAxis",
|
|
510
|
+
required: false
|
|
511
|
+
}]
|
|
512
|
+
}],
|
|
513
|
+
monaSortableChange: [{
|
|
514
|
+
type: i0.Output,
|
|
515
|
+
args: ["monaSortableChange"]
|
|
516
|
+
}],
|
|
517
|
+
orientation: [{
|
|
518
|
+
type: i0.Input,
|
|
519
|
+
args: [{
|
|
520
|
+
isSignal: true,
|
|
521
|
+
alias: "sortableOrientation",
|
|
522
|
+
required: false
|
|
523
|
+
}]
|
|
524
|
+
}],
|
|
525
|
+
sortableMove: [{
|
|
526
|
+
type: i0.Output,
|
|
527
|
+
args: ["sortableMove"]
|
|
528
|
+
}]
|
|
529
|
+
}
|
|
530
|
+
});
|
|
531
|
+
var SortableHandleDirective = class SortableHandleDirective {
|
|
532
|
+
static {
|
|
533
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
534
|
+
minVersion: "12.0.0",
|
|
535
|
+
version: "22.2.6",
|
|
536
|
+
ngImport: i0,
|
|
537
|
+
type: SortableHandleDirective,
|
|
538
|
+
deps: [],
|
|
539
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
static {
|
|
543
|
+
this.ɵdir = i0.ɵɵngDeclareDirective({
|
|
544
|
+
minVersion: "14.0.0",
|
|
545
|
+
version: "22.2.6",
|
|
546
|
+
type: SortableHandleDirective,
|
|
547
|
+
isStandalone: true,
|
|
548
|
+
selector: "[monaSortableHandle]",
|
|
549
|
+
host: { classAttribute: "cursor-grab active:cursor-grabbing" },
|
|
550
|
+
hostDirectives: [{ directive: i1.CdkDragHandle }],
|
|
551
|
+
ngImport: i0
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
};
|
|
555
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
556
|
+
minVersion: "12.0.0",
|
|
557
|
+
version: "22.2.6",
|
|
558
|
+
ngImport: i0,
|
|
559
|
+
type: SortableHandleDirective,
|
|
560
|
+
decorators: [{
|
|
561
|
+
type: Directive,
|
|
562
|
+
args: [{
|
|
563
|
+
selector: "[monaSortableHandle]",
|
|
564
|
+
hostDirectives: [CdkDragHandle],
|
|
565
|
+
host: { class: "cursor-grab active:cursor-grabbing" }
|
|
566
|
+
}]
|
|
567
|
+
}]
|
|
568
|
+
});
|
|
569
|
+
const SORTABLE_ITEM_CLASSES = `
|
|
570
|
+
[&.cdk-drag-placeholder]:opacity-40
|
|
571
|
+
[&.cdk-drag-preview]:shadow-(--shadow-overlay) [&.cdk-drag-preview]:backdrop-blur-sm
|
|
572
|
+
[.cdk-drop-list-dragging_&:not(.cdk-drag-placeholder)]:transition-transform
|
|
573
|
+
[.cdk-drop-list-dragging_&:not(.cdk-drag-placeholder)]:duration-200
|
|
574
|
+
[.cdk-drop-list-dragging_&:not(.cdk-drag-placeholder)]:ease-[cubic-bezier(0.2,0,0,1)]
|
|
575
|
+
motion-reduce:[.cdk-drop-list-dragging_&:not(.cdk-drag-placeholder)]:transition-none
|
|
576
|
+
[&.cdk-drag-animating]:transition-transform [&.cdk-drag-animating]:duration-200
|
|
577
|
+
[&.cdk-drag-animating]:ease-[cubic-bezier(0.2,0,0,1)]
|
|
578
|
+
motion-reduce:[&.cdk-drag-animating]:transition-none
|
|
579
|
+
`;
|
|
580
|
+
const MOVE_KEYS = /* @__PURE__ */ new Set([
|
|
581
|
+
"ArrowDown",
|
|
582
|
+
"ArrowLeft",
|
|
583
|
+
"ArrowRight",
|
|
584
|
+
"ArrowUp",
|
|
585
|
+
"End",
|
|
586
|
+
"Home"
|
|
587
|
+
]);
|
|
588
|
+
var SortableItemDirective = class SortableItemDirective {
|
|
589
|
+
#drag;
|
|
590
|
+
#presentational;
|
|
591
|
+
constructor() {
|
|
592
|
+
this.#drag = inject(CdkDrag);
|
|
593
|
+
this.#presentational = ["none", "presentation"].includes(inject(new HostAttributeToken("role"), { optional: true }) ?? "");
|
|
594
|
+
this.hostKeyShortcuts = computed(() => this.#presentational ? null : this.keyShortcuts(), ...ngDevMode ? [{ debugName: "hostKeyShortcuts" }] : /* istanbul ignore next */ []);
|
|
595
|
+
this.disabled = input(false, {
|
|
596
|
+
...ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {},
|
|
597
|
+
alias: "sortableDisabled",
|
|
598
|
+
transform: booleanAttribute
|
|
599
|
+
});
|
|
600
|
+
this.element = inject(ElementRef).nativeElement;
|
|
601
|
+
this.item = input.required({
|
|
602
|
+
...ngDevMode ? { debugName: "item" } : /* istanbul ignore next */ {},
|
|
603
|
+
alias: "monaSortableItem"
|
|
604
|
+
});
|
|
605
|
+
this.keyShortcuts = computed(() => this.disabled() ? null : this.list.keyShortcuts(), ...ngDevMode ? [{ debugName: "keyShortcuts" }] : /* istanbul ignore next */ []);
|
|
606
|
+
this.label = input("", {
|
|
607
|
+
...ngDevMode ? { debugName: "label" } : /* istanbul ignore next */ {},
|
|
608
|
+
alias: "sortableLabel"
|
|
609
|
+
});
|
|
610
|
+
this.list = inject(SortableDirective);
|
|
611
|
+
const drag = this.#drag;
|
|
612
|
+
drag.data = this;
|
|
613
|
+
drag.dragStartDelay = {
|
|
614
|
+
mouse: 0,
|
|
615
|
+
touch: 250
|
|
616
|
+
};
|
|
617
|
+
effect(() => {
|
|
618
|
+
drag.disabled = this.disabled();
|
|
619
|
+
drag.lockAxis = this.list.dragAxis();
|
|
620
|
+
});
|
|
621
|
+
}
|
|
622
|
+
focusedElement() {
|
|
623
|
+
const active = this.element.getRootNode().activeElement;
|
|
624
|
+
return active instanceof HTMLElement && this.element.contains(active) ? active : null;
|
|
625
|
+
}
|
|
626
|
+
labelText() {
|
|
627
|
+
return this.label() || readElementLabel(this.element, true);
|
|
628
|
+
}
|
|
629
|
+
onKeydown(event) {
|
|
630
|
+
if (event.defaultPrevented || !(event.ctrlKey || event.metaKey) || !event.shiftKey || event.altKey || !MOVE_KEYS.has(event.key) || isTextEntryTarget(event.target)) return;
|
|
631
|
+
event.preventDefault();
|
|
632
|
+
this.list.keyboardMove(this, event.key, event);
|
|
633
|
+
}
|
|
634
|
+
static {
|
|
635
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
636
|
+
minVersion: "12.0.0",
|
|
637
|
+
version: "22.2.6",
|
|
638
|
+
ngImport: i0,
|
|
639
|
+
type: SortableItemDirective,
|
|
640
|
+
deps: [],
|
|
641
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
static {
|
|
645
|
+
this.ɵdir = i0.ɵɵngDeclareDirective({
|
|
646
|
+
minVersion: "17.1.0",
|
|
647
|
+
version: "22.2.6",
|
|
648
|
+
type: SortableItemDirective,
|
|
649
|
+
isStandalone: true,
|
|
650
|
+
selector: "[monaSortableItem]",
|
|
651
|
+
inputs: {
|
|
652
|
+
disabled: {
|
|
653
|
+
classPropertyName: "disabled",
|
|
654
|
+
publicName: "sortableDisabled",
|
|
655
|
+
isSignal: true,
|
|
656
|
+
isRequired: false,
|
|
657
|
+
transformFunction: null
|
|
658
|
+
},
|
|
659
|
+
item: {
|
|
660
|
+
classPropertyName: "item",
|
|
661
|
+
publicName: "monaSortableItem",
|
|
662
|
+
isSignal: true,
|
|
663
|
+
isRequired: true,
|
|
664
|
+
transformFunction: null
|
|
665
|
+
},
|
|
666
|
+
label: {
|
|
667
|
+
classPropertyName: "label",
|
|
668
|
+
publicName: "sortableLabel",
|
|
669
|
+
isSignal: true,
|
|
670
|
+
isRequired: false,
|
|
671
|
+
transformFunction: null
|
|
672
|
+
}
|
|
673
|
+
},
|
|
674
|
+
host: {
|
|
675
|
+
listeners: { "keydown": "onKeydown($event)" },
|
|
676
|
+
properties: { "attr.aria-keyshortcuts": "hostKeyShortcuts()" },
|
|
677
|
+
classAttribute: "\n [&.cdk-drag-placeholder]:opacity-40\n [&.cdk-drag-preview]:shadow-(--shadow-overlay) [&.cdk-drag-preview]:backdrop-blur-sm\n [.cdk-drop-list-dragging_&:not(.cdk-drag-placeholder)]:transition-transform\n [.cdk-drop-list-dragging_&:not(.cdk-drag-placeholder)]:duration-200\n [.cdk-drop-list-dragging_&:not(.cdk-drag-placeholder)]:ease-[cubic-bezier(0.2,0,0,1)]\n motion-reduce:[.cdk-drop-list-dragging_&:not(.cdk-drag-placeholder)]:transition-none\n [&.cdk-drag-animating]:transition-transform [&.cdk-drag-animating]:duration-200\n [&.cdk-drag-animating]:ease-[cubic-bezier(0.2,0,0,1)]\n motion-reduce:[&.cdk-drag-animating]:transition-none\n"
|
|
678
|
+
},
|
|
679
|
+
exportAs: ["monaSortableItem"],
|
|
680
|
+
hostDirectives: [{ directive: i1.CdkDrag }],
|
|
681
|
+
ngImport: i0
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
};
|
|
685
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
686
|
+
minVersion: "12.0.0",
|
|
687
|
+
version: "22.2.6",
|
|
688
|
+
ngImport: i0,
|
|
689
|
+
type: SortableItemDirective,
|
|
690
|
+
decorators: [{
|
|
691
|
+
type: Directive,
|
|
692
|
+
args: [{
|
|
693
|
+
selector: "[monaSortableItem]",
|
|
694
|
+
exportAs: "monaSortableItem",
|
|
695
|
+
hostDirectives: [CdkDrag],
|
|
696
|
+
host: {
|
|
697
|
+
class: SORTABLE_ITEM_CLASSES,
|
|
698
|
+
"[attr.aria-keyshortcuts]": "hostKeyShortcuts()",
|
|
699
|
+
"(keydown)": "onKeydown($event)"
|
|
700
|
+
}
|
|
701
|
+
}]
|
|
702
|
+
}],
|
|
703
|
+
ctorParameters: () => [],
|
|
704
|
+
propDecorators: {
|
|
705
|
+
disabled: [{
|
|
706
|
+
type: i0.Input,
|
|
707
|
+
args: [{
|
|
708
|
+
isSignal: true,
|
|
709
|
+
alias: "sortableDisabled",
|
|
710
|
+
required: false
|
|
711
|
+
}]
|
|
712
|
+
}],
|
|
713
|
+
item: [{
|
|
714
|
+
type: i0.Input,
|
|
715
|
+
args: [{
|
|
716
|
+
isSignal: true,
|
|
717
|
+
alias: "monaSortableItem",
|
|
718
|
+
required: true
|
|
719
|
+
}]
|
|
720
|
+
}],
|
|
721
|
+
label: [{
|
|
722
|
+
type: i0.Input,
|
|
723
|
+
args: [{
|
|
724
|
+
isSignal: true,
|
|
725
|
+
alias: "sortableLabel",
|
|
726
|
+
required: false
|
|
727
|
+
}]
|
|
728
|
+
}]
|
|
729
|
+
}
|
|
730
|
+
});
|
|
731
|
+
export { SORTABLE_DEFAULT_MESSAGES, SortableDirective, SortableGroupDirective, SortableHandleDirective, SortableItemDirective, SortableMoveEvent, moveItem };
|
|
732
|
+
|
|
733
|
+
//# sourceMappingURL=nanahoshi-mona-ui-sortable.mjs.map
|