@rt-tools/ui-kit-v2 0.29.1 → 0.30.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/fesm2022/rt-tools-ui-kit-v2-autocomplete.mjs +23 -29
- package/fesm2022/rt-tools-ui-kit-v2-autocomplete.mjs.map +1 -1
- package/fesm2022/rt-tools-ui-kit-v2-calendar.mjs +2 -2
- package/fesm2022/rt-tools-ui-kit-v2-calendar.mjs.map +1 -1
- package/fesm2022/rt-tools-ui-kit-v2-core.mjs +223 -3
- package/fesm2022/rt-tools-ui-kit-v2-core.mjs.map +1 -1
- package/fesm2022/rt-tools-ui-kit-v2-data-list.mjs +2 -2
- package/fesm2022/rt-tools-ui-kit-v2-data-list.mjs.map +1 -1
- package/fesm2022/rt-tools-ui-kit-v2-draggable-tree.mjs +1 -2
- package/fesm2022/rt-tools-ui-kit-v2-draggable-tree.mjs.map +1 -1
- package/fesm2022/rt-tools-ui-kit-v2-dynamic-list.mjs +2 -2
- package/fesm2022/rt-tools-ui-kit-v2-dynamic-list.mjs.map +1 -1
- package/fesm2022/rt-tools-ui-kit-v2-dynamic-selector.mjs +277 -904
- package/fesm2022/rt-tools-ui-kit-v2-dynamic-selector.mjs.map +1 -1
- package/fesm2022/rt-tools-ui-kit-v2-filter-control.mjs +2 -2
- package/fesm2022/rt-tools-ui-kit-v2-filter-control.mjs.map +1 -1
- package/fesm2022/rt-tools-ui-kit-v2-hybrid-tree.mjs +1 -1
- package/fesm2022/rt-tools-ui-kit-v2-hybrid-tree.mjs.map +1 -1
- package/fesm2022/rt-tools-ui-kit-v2-multiselect.mjs +35 -48
- package/fesm2022/rt-tools-ui-kit-v2-multiselect.mjs.map +1 -1
- package/fesm2022/rt-tools-ui-kit-v2-page-header.mjs +2 -2
- package/fesm2022/rt-tools-ui-kit-v2-pdf-viewer.mjs +2 -2
- package/fesm2022/rt-tools-ui-kit-v2-pdf-viewer.mjs.map +1 -1
- package/fesm2022/rt-tools-ui-kit-v2-rich-editor.mjs +4 -4
- package/fesm2022/rt-tools-ui-kit-v2-rich-editor.mjs.map +1 -1
- package/fesm2022/rt-tools-ui-kit-v2-select.mjs +37 -181
- package/fesm2022/rt-tools-ui-kit-v2-select.mjs.map +1 -1
- package/fesm2022/rt-tools-ui-kit-v2-side-menu.mjs +5 -36
- package/fesm2022/rt-tools-ui-kit-v2-side-menu.mjs.map +1 -1
- package/fesm2022/rt-tools-ui-kit-v2-tag.mjs +2 -3
- package/fesm2022/rt-tools-ui-kit-v2-tag.mjs.map +1 -1
- package/fesm2022/rt-tools-ui-kit-v2-toolbar.mjs +2 -2
- package/fesm2022/rt-tools-ui-kit-v2-toolbar.mjs.map +1 -1
- package/fesm2022/rt-tools-ui-kit-v2-tree-selector.mjs +8 -13
- package/fesm2022/rt-tools-ui-kit-v2-tree-selector.mjs.map +1 -1
- package/fesm2022/rt-tools-ui-kit-v2-tree.mjs +12 -7
- package/fesm2022/rt-tools-ui-kit-v2-tree.mjs.map +1 -1
- package/fesm2022/rt-tools-ui-kit-v2-workspace.mjs +2 -2
- package/fesm2022/rt-tools-ui-kit-v2-workspace.mjs.map +1 -1
- package/package.json +1 -1
- package/src/lib/components/dynamic-selector/stories/component/test-dynamic-selector-popup-frame.component.scss +6 -0
- package/src/lib/components/page-header/rt-page-header.component.scss +4 -2
- package/src/lib/components/tree/CONTEXT.md +1 -1
- package/src/rich-editor/lib/components/ai-chat/CONTEXT.md +1 -1
- package/src/styles/_breakpoints.scss +37 -4
- package/src/styles/_index.scss +0 -4
- package/styles/tokens.css +0 -8
- package/types/rt-tools-ui-kit-v2-autocomplete.d.ts +4 -3
- package/types/rt-tools-ui-kit-v2-core.d.ts +155 -1
- package/types/rt-tools-ui-kit-v2-dynamic-selector.d.ts +51 -269
- package/types/rt-tools-ui-kit-v2-multiselect.d.ts +4 -3
- package/types/rt-tools-ui-kit-v2-select.d.ts +12 -74
- package/types/rt-tools-ui-kit-v2-side-menu.d.ts +5 -20
- package/types/rt-tools-ui-kit-v2-tag.d.ts +2 -3
- package/types/rt-tools-ui-kit-v2-tree-selector.d.ts +0 -2
- package/types/rt-tools-ui-kit-v2-tree.d.ts +7 -9
- package/src/styles/_place.scss +0 -7
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as i0 from "@angular/core";
|
|
2
|
-
import { DestroyRef, Directive, ElementRef, Injectable, InjectionToken, Injector, LOCALE_ID, Pipe, booleanAttribute, computed, effect, inject, input, makeEnvironmentProviders, output, signal } from "@angular/core";
|
|
2
|
+
import { DestroyRef, Directive, ElementRef, Injectable, InjectionToken, Injector, LOCALE_ID, Pipe, afterRenderEffect, booleanAttribute, computed, effect, inject, input, makeEnvironmentProviders, output, signal } from "@angular/core";
|
|
3
|
+
import { DOCUMENT, formatDate } from "@angular/common";
|
|
3
4
|
import { BreakpointObserver, Breakpoints } from "@angular/cdk/layout";
|
|
4
5
|
import { toSignal } from "@angular/core/rxjs-interop";
|
|
5
6
|
import { Subject, debounce, filter, map, timer } from "rxjs";
|
|
6
7
|
import { PlatformService, StorageService, WINDOW } from "@rt-tools/core";
|
|
7
|
-
import { DOCUMENT, formatDate } from "@angular/common";
|
|
8
8
|
const RT_KIT_CONFIG = new InjectionToken("RT_KIT_CONFIG", {
|
|
9
9
|
providedIn: "root",
|
|
10
10
|
factory: () => ({})
|
|
@@ -418,6 +418,226 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
418
418
|
}]
|
|
419
419
|
}]
|
|
420
420
|
});
|
|
421
|
+
function rtScrollActiveOptionIntoView(activeOptionId) {
|
|
422
|
+
const document = inject(DOCUMENT);
|
|
423
|
+
afterRenderEffect(() => {
|
|
424
|
+
const id = activeOptionId();
|
|
425
|
+
const option = id ? document.getElementById(id) : null;
|
|
426
|
+
if (typeof option?.scrollIntoView === "function") option.scrollIntoView({ block: "nearest" });
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
function rtSearchFold(text) {
|
|
430
|
+
return text.toLowerCase().replace(/ё/g, "е");
|
|
431
|
+
}
|
|
432
|
+
function rtSearchWords(query) {
|
|
433
|
+
return rtSearchFold(query).split(/\s+/).filter((word) => word !== "");
|
|
434
|
+
}
|
|
435
|
+
function rtSearchMatches(text, query) {
|
|
436
|
+
const folded = rtSearchFold(text);
|
|
437
|
+
return rtSearchWords(query).every((word) => folded.includes(word));
|
|
438
|
+
}
|
|
439
|
+
function markWord(marks, folded, word) {
|
|
440
|
+
for (let at = folded.indexOf(word); at !== -1; at = folded.indexOf(word, at + 1)) marks.fill(true, at, at + word.length);
|
|
441
|
+
}
|
|
442
|
+
function rtMatchParts(name, query) {
|
|
443
|
+
if (name === "") return [];
|
|
444
|
+
const words = rtSearchWords(query);
|
|
445
|
+
const folded = rtSearchFold(name);
|
|
446
|
+
if (words.length === 0 || folded.length !== name.length) return [{
|
|
447
|
+
text: name,
|
|
448
|
+
matched: false
|
|
449
|
+
}];
|
|
450
|
+
const marks = Array.from({ length: name.length }, () => false);
|
|
451
|
+
words.forEach((word) => markWord(marks, folded, word));
|
|
452
|
+
const parts = [];
|
|
453
|
+
let from = 0;
|
|
454
|
+
for (let at = 1; at <= name.length; at++) if (at === name.length || marks[at] !== marks[from]) {
|
|
455
|
+
parts.push({
|
|
456
|
+
text: name.slice(from, at),
|
|
457
|
+
matched: marks[from]
|
|
458
|
+
});
|
|
459
|
+
from = at;
|
|
460
|
+
}
|
|
461
|
+
return parts;
|
|
462
|
+
}
|
|
463
|
+
const OPEN_KEYS = /* @__PURE__ */ new Set([
|
|
464
|
+
"ArrowDown",
|
|
465
|
+
"ArrowUp",
|
|
466
|
+
"Enter",
|
|
467
|
+
" "
|
|
468
|
+
]);
|
|
469
|
+
const MOVE_KEYS = /* @__PURE__ */ new Map([["ArrowDown", "next"], ["ArrowUp", "previous"]]);
|
|
470
|
+
const EDGE_KEYS = /* @__PURE__ */ new Map([["Home", "first"], ["End", "last"]]);
|
|
471
|
+
const SIDE_KEYS = /* @__PURE__ */ new Set(["ArrowRight", "ArrowLeft"]);
|
|
472
|
+
var RtOptionList = class {
|
|
473
|
+
#config;
|
|
474
|
+
constructor(config) {
|
|
475
|
+
this.activeIndex = signal(-1, ...ngDevMode ? [{ debugName: "activeIndex" }] : /* istanbul ignore next */ []);
|
|
476
|
+
this.#config = config;
|
|
477
|
+
this.activeOptionId = computed(() => config.isOpen() && this.activeIndex() >= 0 ? `${config.panelId()}-opt-${this.activeIndex()}` : null, ...ngDevMode ? [{ debugName: "activeOptionId" }] : /* istanbul ignore next */ []);
|
|
478
|
+
rtScrollActiveOptionIntoView(this.activeOptionId);
|
|
479
|
+
}
|
|
480
|
+
opensBy(key) {
|
|
481
|
+
return OPEN_KEYS.has(key);
|
|
482
|
+
}
|
|
483
|
+
actionOf(key) {
|
|
484
|
+
const edge = this.#config.edgeKeys ? EDGE_KEYS.get(key) : void 0;
|
|
485
|
+
const fixed = MOVE_KEYS.get(key) ?? edge;
|
|
486
|
+
if (fixed !== void 0) return fixed;
|
|
487
|
+
if (this.#config.chooseKeys.has(key)) return "choose";
|
|
488
|
+
if (key === "Escape") return "close";
|
|
489
|
+
return this.#config.sideKeys && SIDE_KEYS.has(key) ? "side" : "none";
|
|
490
|
+
}
|
|
491
|
+
move(delta) {
|
|
492
|
+
const count = this.#config.count();
|
|
493
|
+
if (count === 0) {
|
|
494
|
+
this.activeIndex.set(-1);
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
let index = this.activeIndex();
|
|
498
|
+
for (let step = 0; step < count; step += 1) {
|
|
499
|
+
index = (index + delta + count) % count;
|
|
500
|
+
if (!this.#config.isDisabled?.(index)) {
|
|
501
|
+
this.activeIndex.set(index);
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
first() {
|
|
507
|
+
this.activeIndex.set(-1);
|
|
508
|
+
this.move(1);
|
|
509
|
+
}
|
|
510
|
+
last() {
|
|
511
|
+
this.activeIndex.set(0);
|
|
512
|
+
this.move(-1);
|
|
513
|
+
}
|
|
514
|
+
reset() {
|
|
515
|
+
this.activeIndex.set(-1);
|
|
516
|
+
}
|
|
517
|
+
};
|
|
518
|
+
function childrenOf(option) {
|
|
519
|
+
return option.children ?? [];
|
|
520
|
+
}
|
|
521
|
+
function isBranch(option) {
|
|
522
|
+
return childrenOf(option).length > 0;
|
|
523
|
+
}
|
|
524
|
+
function rtTreeIsTree(options) {
|
|
525
|
+
return options.some((option) => isBranch(option));
|
|
526
|
+
}
|
|
527
|
+
function rtTreeFind(options, value) {
|
|
528
|
+
for (const option of options) {
|
|
529
|
+
if (option.value === value) return option;
|
|
530
|
+
const found = rtTreeFind(childrenOf(option), value);
|
|
531
|
+
if (found) return found;
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
function rtTreeLeaves(option) {
|
|
535
|
+
if (option.disabled) return [];
|
|
536
|
+
if (!isBranch(option)) return [option.value];
|
|
537
|
+
return childrenOf(option).flatMap((child) => rtTreeLeaves(child));
|
|
538
|
+
}
|
|
539
|
+
function rtTreeBranchState(option, chosen) {
|
|
540
|
+
const leaves = rtTreeLeaves(option);
|
|
541
|
+
const count = leaves.filter((leaf) => chosen.includes(leaf)).length;
|
|
542
|
+
if (count === 0) return "none";
|
|
543
|
+
return count === leaves.length ? "all" : "some";
|
|
544
|
+
}
|
|
545
|
+
function holdsChosen(option, chosen) {
|
|
546
|
+
return childrenOf(option).some((child) => chosen.includes(child.value) || holdsChosen(child, chosen));
|
|
547
|
+
}
|
|
548
|
+
function collectOpen(list, chosen, open) {
|
|
549
|
+
for (const option of list) if (holdsChosen(option, chosen)) {
|
|
550
|
+
open.add(option.value);
|
|
551
|
+
collectOpen(childrenOf(option), chosen, open);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
function rtTreeOpenFor(options, chosen) {
|
|
555
|
+
const open = /* @__PURE__ */ new Set();
|
|
556
|
+
collectOpen(options, chosen, open);
|
|
557
|
+
return open;
|
|
558
|
+
}
|
|
559
|
+
function matches(option, term) {
|
|
560
|
+
return rtSearchMatches(option.label, term);
|
|
561
|
+
}
|
|
562
|
+
function descendantMatches(option, term) {
|
|
563
|
+
return childrenOf(option).some((child) => matches(child, term) || descendantMatches(child, term));
|
|
564
|
+
}
|
|
565
|
+
function placeOption(walk, option, place) {
|
|
566
|
+
const self = !place.filtered || matches(option, walk.term);
|
|
567
|
+
const below = place.filtered && descendantMatches(option, walk.term);
|
|
568
|
+
if (!self && !below) return null;
|
|
569
|
+
const branch = isBranch(option);
|
|
570
|
+
const openBySet = self && walk.open.has(option.value);
|
|
571
|
+
const open = branch && (openBySet || below);
|
|
572
|
+
walk.rows.push({
|
|
573
|
+
option,
|
|
574
|
+
branch,
|
|
575
|
+
open,
|
|
576
|
+
level: place.level,
|
|
577
|
+
parent: place.parent
|
|
578
|
+
});
|
|
579
|
+
return open ? {
|
|
580
|
+
level: place.level + 1,
|
|
581
|
+
parent: option.value,
|
|
582
|
+
filtered: place.filtered && !openBySet
|
|
583
|
+
} : null;
|
|
584
|
+
}
|
|
585
|
+
function walkRows(walk, list, place) {
|
|
586
|
+
for (const option of list) {
|
|
587
|
+
const childPlace = placeOption(walk, option, place);
|
|
588
|
+
if (childPlace) walkRows(walk, childrenOf(option), childPlace);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
function rtTreeRows(options, open, rawTerm = "") {
|
|
592
|
+
const term = rawTerm;
|
|
593
|
+
const walk = {
|
|
594
|
+
open,
|
|
595
|
+
term,
|
|
596
|
+
rows: []
|
|
597
|
+
};
|
|
598
|
+
walkRows(walk, options, {
|
|
599
|
+
level: 0,
|
|
600
|
+
parent: null,
|
|
601
|
+
filtered: rtSearchWords(term).length > 0
|
|
602
|
+
});
|
|
603
|
+
return walk.rows;
|
|
604
|
+
}
|
|
605
|
+
function sideRight(rows, row, index) {
|
|
606
|
+
if (row.branch && !row.open) return {
|
|
607
|
+
toggle: row.option.value,
|
|
608
|
+
index
|
|
609
|
+
};
|
|
610
|
+
return {
|
|
611
|
+
toggle: null,
|
|
612
|
+
index: row.branch && rows[index + 1]?.parent === row.option.value ? index + 1 : index
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
function sideLeft(rows, row, index) {
|
|
616
|
+
if (row.branch && row.open) return {
|
|
617
|
+
toggle: row.option.value,
|
|
618
|
+
index
|
|
619
|
+
};
|
|
620
|
+
const parentIndex = rows.findIndex((candidate) => candidate.option.value === row.parent);
|
|
621
|
+
return {
|
|
622
|
+
toggle: null,
|
|
623
|
+
index: parentIndex >= 0 ? parentIndex : index
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
function rtTreeSideKey(rows, index, key) {
|
|
627
|
+
const row = rows[index];
|
|
628
|
+
if (row && key === "ArrowRight") return sideRight(rows, row, index);
|
|
629
|
+
if (row && key === "ArrowLeft") return sideLeft(rows, row, index);
|
|
630
|
+
return {
|
|
631
|
+
toggle: null,
|
|
632
|
+
index
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
function rtTreeToggle(open, value) {
|
|
636
|
+
const next = new Set(open);
|
|
637
|
+
if (next.has(value)) next.delete(value);
|
|
638
|
+
else next.add(value);
|
|
639
|
+
return next;
|
|
640
|
+
}
|
|
421
641
|
const RT_NARROW_WIDTH = 1080;
|
|
422
642
|
const NARROW_VIEWPORT_QUERY = `(max-width: ${RT_NARROW_WIDTH}px)`;
|
|
423
643
|
function rtNarrowByWidth(placeWidth, viewportNarrow) {
|
|
@@ -2495,6 +2715,6 @@ const iconsName = [
|
|
|
2495
2715
|
"window-maximize",
|
|
2496
2716
|
"window-minimize"
|
|
2497
2717
|
];
|
|
2498
|
-
export { BreakpointsService, ERtDataTableCellColor, ERtDataTableColumnType, ERtDataTableFilterType, ERtMarkdownBlock, ERtMarkdownInline, ERtStorageKeys, MessageBus, NotificationBus, RT_CONSUMER_HANDLE_NAMES, RT_DATA_TABLE_PRESET_FROM_HOST, RT_DESIGN_TOKEN_NAMES, RT_KIT_CONFIG, RT_KIT_LABELS, RT_KIT_LABELS_EN, RT_KIT_LOCALE, RT_KIT_TRANSLATOR, RT_MATERIAL_PRESET_CLASS, RT_MATERIAL_PRESET_SELECTOR, RT_NARROW_WIDTH, RT_PRESET_MATERIAL_CLASS, RT_RADIUS_DEFAULT, RT_RADIUS_STEPS, RT_THEME_SCOPE_ATTRIBUTE, RtDayStampPipe, RtInfiniteScrollDirective, RtKitLabelPipe, RtThemeScopeDirective, SEARCH_DEBOUNCE_MS, ThemeService, breakNode, carryThemeScope, carryThemeScopeOfFocus, coerceQuillDeltaOutput, fileNameFromUrl, formatFileSize, iconsName, markdownToPlainText, materialPresetClassesOf, materialPresetClassesOfFocus, normalizeQuillDelta, parseInline, parseMarkdown, provideRtKit, provideRtKitLabels, rtKitDefault, rtKitLabel, rtNarrowByWidth, searchDebounce, themeScopeOf, themeScopeOfFocus };
|
|
2718
|
+
export { BreakpointsService, ERtDataTableCellColor, ERtDataTableColumnType, ERtDataTableFilterType, ERtMarkdownBlock, ERtMarkdownInline, ERtStorageKeys, MessageBus, NotificationBus, RT_CONSUMER_HANDLE_NAMES, RT_DATA_TABLE_PRESET_FROM_HOST, RT_DESIGN_TOKEN_NAMES, RT_KIT_CONFIG, RT_KIT_LABELS, RT_KIT_LABELS_EN, RT_KIT_LOCALE, RT_KIT_TRANSLATOR, RT_MATERIAL_PRESET_CLASS, RT_MATERIAL_PRESET_SELECTOR, RT_NARROW_WIDTH, RT_PRESET_MATERIAL_CLASS, RT_RADIUS_DEFAULT, RT_RADIUS_STEPS, RT_THEME_SCOPE_ATTRIBUTE, RtDayStampPipe, RtInfiniteScrollDirective, RtKitLabelPipe, RtOptionList, RtThemeScopeDirective, SEARCH_DEBOUNCE_MS, ThemeService, breakNode, carryThemeScope, carryThemeScopeOfFocus, coerceQuillDeltaOutput, fileNameFromUrl, formatFileSize, iconsName, markdownToPlainText, materialPresetClassesOf, materialPresetClassesOfFocus, normalizeQuillDelta, parseInline, parseMarkdown, provideRtKit, provideRtKitLabels, rtKitDefault, rtKitLabel, rtMatchParts, rtNarrowByWidth, rtScrollActiveOptionIntoView, rtSearchFold, rtSearchMatches, rtSearchWords, rtTreeBranchState, rtTreeFind, rtTreeIsTree, rtTreeLeaves, rtTreeOpenFor, rtTreeRows, rtTreeSideKey, rtTreeToggle, searchDebounce, themeScopeOf, themeScopeOfFocus };
|
|
2499
2719
|
|
|
2500
2720
|
//# sourceMappingURL=rt-tools-ui-kit-v2-core.mjs.map
|