@haiyue/ui 0.2.2 → 0.3.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/CHANGELOG.md +42 -0
- package/README.md +523 -4
- package/dist/adapters/web/controls.js +48 -8
- package/dist/adapters/web/renderer.js +9 -11
- package/dist/adapters/web/styles.d.ts +2 -3
- package/dist/adapters/web/styles.js +26 -23
- package/dist/alert.d.ts +39 -0
- package/dist/alert.js +144 -0
- package/dist/anchor.d.ts +62 -0
- package/dist/anchor.js +293 -0
- package/dist/auto-complete.d.ts +83 -0
- package/dist/auto-complete.js +267 -0
- package/dist/avatar.d.ts +45 -0
- package/dist/avatar.js +135 -0
- package/dist/badge.js +5 -5
- package/dist/border-beam.js +3 -2
- package/dist/breadcrumb.js +5 -5
- package/dist/button-group.js +8 -8
- package/dist/button.js +10 -10
- package/dist/card.d.ts +29 -0
- package/dist/card.js +101 -0
- package/dist/carousel.js +6 -6
- package/dist/cascader.js +19 -13
- package/dist/checkbox.d.ts +12 -0
- package/dist/checkbox.js +22 -6
- package/dist/collapse.js +6 -6
- package/dist/context-menu.js +3 -4
- package/dist/core/actions.js +7 -8
- package/dist/core/data.d.ts +1 -1
- package/dist/core/data.js +44 -10
- package/dist/core/platform-view.js +8 -2
- package/dist/core/selection.js +4 -4
- package/dist/core/semantics.d.ts +26 -0
- package/dist/core/semantics.js +8 -0
- package/dist/core/text.js +3 -3
- package/dist/core/validation.d.ts +3 -1
- package/dist/core/validation.js +23 -5
- package/dist/date-picker.js +19 -13
- package/dist/descriptions.d.ts +44 -0
- package/dist/descriptions.js +169 -0
- package/dist/dialog.d.ts +4 -0
- package/dist/dialog.js +48 -27
- package/dist/divider.js +2 -2
- package/dist/draggable.js +5 -3
- package/dist/drawer.js +16 -24
- package/dist/dropdown.js +3 -4
- package/dist/empty.d.ts +20 -0
- package/dist/empty.js +58 -0
- package/dist/expandable.js +4 -4
- package/dist/form-item.d.ts +60 -0
- package/dist/form-item.js +212 -0
- package/dist/form.d.ts +41 -0
- package/dist/form.js +154 -0
- package/dist/history-controls.js +5 -5
- package/dist/image-preview.d.ts +22 -0
- package/dist/image-preview.js +38 -0
- package/dist/image.d.ts +52 -0
- package/dist/image.js +152 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.js +72 -0
- package/dist/input.d.ts +11 -0
- package/dist/input.js +32 -18
- package/dist/internal/anchored-popup.d.ts +19 -0
- package/dist/internal/anchored-popup.js +89 -0
- package/dist/internal/focus.d.ts +2 -0
- package/dist/internal/focus.js +31 -0
- package/dist/internal/form-control.d.ts +22 -0
- package/dist/internal/form-control.js +52 -0
- package/dist/internal/image-viewer.d.ts +51 -0
- package/dist/internal/image-viewer.js +210 -0
- package/dist/internal/keyboard.d.ts +2 -0
- package/dist/internal/keyboard.js +12 -0
- package/dist/internal/numbers.d.ts +2 -0
- package/dist/internal/numbers.js +8 -0
- package/dist/internal/pagination.d.ts +35 -0
- package/dist/internal/pagination.js +169 -0
- package/dist/internal/popover-base.d.ts +87 -0
- package/dist/internal/popover-base.js +365 -0
- package/dist/internal/presentation.d.ts +2 -0
- package/dist/internal/presentation.js +28 -0
- package/dist/mentions.d.ts +115 -0
- package/dist/mentions.js +485 -0
- package/dist/menu-shared.d.ts +1 -1
- package/dist/menu-shared.js +3 -3
- package/dist/menu.d.ts +63 -0
- package/dist/menu.js +339 -0
- package/dist/modal.js +11 -40
- package/dist/notification.js +11 -10
- package/dist/pagination.d.ts +34 -0
- package/dist/pagination.js +73 -0
- package/dist/popconfirm.d.ts +6 -0
- package/dist/popconfirm.js +7 -0
- package/dist/popover.d.ts +6 -0
- package/dist/popover.js +7 -0
- package/dist/portable/page.js +25 -14
- package/dist/progress.d.ts +30 -0
- package/dist/progress.js +102 -0
- package/dist/qr-code.js +3 -3
- package/dist/radio.d.ts +10 -0
- package/dist/radio.js +18 -5
- package/dist/range.js +7 -7
- package/dist/rate.js +3 -3
- package/dist/resizable.js +8 -5
- package/dist/result.d.ts +22 -0
- package/dist/result.js +88 -0
- package/dist/ribbon.d.ts +19 -0
- package/dist/ribbon.js +106 -0
- package/dist/segmented.d.ts +39 -0
- package/dist/segmented.js +192 -0
- package/dist/select.d.ts +12 -0
- package/dist/select.js +31 -13
- package/dist/skeleton.js +10 -10
- package/dist/spin.d.ts +26 -0
- package/dist/spin.js +80 -0
- package/dist/steps.js +13 -13
- package/dist/switch.d.ts +44 -0
- package/dist/switch.js +104 -0
- package/dist/table.d.ts +3 -3
- package/dist/table.js +110 -128
- package/dist/tabs.js +7 -7
- package/dist/tag.js +8 -8
- package/dist/time-picker.js +16 -10
- package/dist/timeline.js +12 -12
- package/dist/toast.js +12 -11
- package/dist/tooltip.d.ts +6 -0
- package/dist/tooltip.js +107 -6
- package/dist/tour.js +26 -17
- package/dist/tree-model.d.ts +2 -0
- package/dist/tree-model.js +32 -11
- package/dist/tree-node.js +2 -2
- package/dist/tree-select.d.ts +94 -0
- package/dist/tree-select.js +398 -0
- package/dist/tree.d.ts +0 -2
- package/dist/tree.js +14 -29
- package/dist/upload.d.ts +108 -0
- package/dist/upload.js +358 -0
- package/dist/virtual-keyboard.d.ts +1 -0
- package/dist/virtual-keyboard.js +72 -41
- package/dist/virtual-list.d.ts +1 -0
- package/dist/virtual-list.js +25 -8
- package/dist/virtual-mouse.js +7 -6
- package/dist/watermark.js +2 -1
- package/package.json +82 -1
- package/themes/haiyue-dark.css +51 -0
- package/themes/haiyue-light.css +51 -0
package/dist/timeline.js
CHANGED
|
@@ -34,24 +34,24 @@ export class HYTimeline extends HTMLElement {
|
|
|
34
34
|
const root = this.attachShadow({ mode: 'open' });
|
|
35
35
|
const style = document.createElement('style');
|
|
36
36
|
style.textContent = `
|
|
37
|
-
:host { display: block; min-width: 0; color: var(--hy-text-color, #eef3ff); font: 12px/1.5 system-ui, sans-serif; }
|
|
37
|
+
:host { display: block; min-width: 0; color: var(--hy-text-color, #eef3ff); font: var(--hy-font-size-sm, 12px)/var(--hy-line-height-relaxed, 1.5) var(--hy-font-family, system-ui, sans-serif); }
|
|
38
38
|
.timeline { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
|
|
39
39
|
.item { display: grid; grid-template-columns: minmax(0, 1fr) var(--hy-timeline-axis-width, 30px) minmax(0, 1fr); min-height: var(--hy-timeline-item-min-height, 72px); margin: 0; padding: 0; }
|
|
40
|
-
.label { grid-column: 1; padding: 1px 14px
|
|
40
|
+
.label { grid-column: 1; padding: 1px var(--hy-space-7, 14px) calc(var(--hy-space-10, 20px) + 2px) 0; color: var(--hy-muted-color, #788697); text-align: right; }
|
|
41
41
|
.axis { position: relative; grid-column: 2; grid-row: 1; display: flex; justify-content: center; }
|
|
42
42
|
.axis::after { position: absolute; top: 16px; bottom: 0; width: var(--hy-timeline-line-width, 1px); background: var(--hy-timeline-line-color, var(--hy-border-color, #3d4654)); content: ''; }
|
|
43
43
|
.item:last-child .axis::after { display: none; }
|
|
44
|
-
.dot { position: relative; z-index: 1; display: grid; width: var(--hy-timeline-dot-size, 10px); height: var(--hy-timeline-dot-size, 10px); box-sizing: border-box; place-items: center; margin-top: 4px; border: 2px solid var(--_dot-color, var(--hy-muted-color, #788697)); border-radius: 50%; color: var(--_dot-color, var(--hy-muted-color, #788697)); background: var(--hy-surface-color, #111722); font-size:
|
|
45
|
-
.dot.custom { width: var(--hy-timeline-custom-dot-size, 22px); height: var(--hy-timeline-custom-dot-size, 22px); margin-top: -2px; border-width: 1px; background: var(--hy-surface-elevated-color, #171d27); }
|
|
44
|
+
.dot { position: relative; z-index: 1; display: grid; width: var(--hy-timeline-dot-size, 10px); height: var(--hy-timeline-dot-size, 10px); box-sizing: border-box; place-items: center; margin-top: var(--hy-space-2, 4px); border: 2px solid var(--_dot-color, var(--hy-muted-color, #788697)); border-radius: 50%; color: var(--_dot-color, var(--hy-muted-color, #788697)); background: var(--hy-surface-color, #111722); font-size: calc(var(--hy-font-size-xs, 10px) - 1px); line-height: var(--hy-line-height-tight, 1); }
|
|
45
|
+
.dot.custom { width: var(--hy-timeline-custom-dot-size, 22px); height: var(--hy-timeline-custom-dot-size, 22px); margin-top: calc(-1 * var(--hy-space-1, 2px)); border-width: 1px; background: var(--hy-surface-elevated-color, #171d27); }
|
|
46
46
|
.status-success { --_dot-color: var(--hy-success-color, #4ade80); }
|
|
47
47
|
.status-info { --_dot-color: var(--hy-info-color, var(--hy-accent-color, #79a8ff)); }
|
|
48
48
|
.status-warning { --_dot-color: var(--hy-warning-color, #fbbf24); }
|
|
49
49
|
.status-error { --_dot-color: var(--hy-error-color, #fb7185); }
|
|
50
|
-
.card { grid-column: 3; min-width: 0; padding: 0 0
|
|
51
|
-
.title { color: var(--hy-text-color, #eef3ff); font-weight:
|
|
52
|
-
.description { margin-top: 4px; color: var(--hy-secondary-text-color, #aebbd0); }
|
|
53
|
-
.content-left .card { grid-column: 1; padding: 0 14px
|
|
54
|
-
.content-left .label { grid-column: 3; padding: 1px 0
|
|
50
|
+
.card { grid-column: 3; min-width: 0; padding: 0 0 calc(var(--hy-space-10, 20px) + 2px) var(--hy-space-7, 14px); }
|
|
51
|
+
.title { color: var(--hy-text-color, #eef3ff); font-weight: calc(var(--hy-font-weight-semibold, 600) + 50); }
|
|
52
|
+
.description { margin-top: var(--hy-space-2, 4px); color: var(--hy-secondary-text-color, #aebbd0); }
|
|
53
|
+
.content-left .card { grid-column: 1; padding: 0 var(--hy-space-7, 14px) calc(var(--hy-space-10, 20px) + 2px) 0; text-align: right; }
|
|
54
|
+
.content-left .label { grid-column: 3; padding: 1px 0 calc(var(--hy-space-10, 20px) + 2px) var(--hy-space-7, 14px); text-align: left; }
|
|
55
55
|
.pending .dot { border-style: dashed; animation: hy-timeline-spin 1.2s linear infinite; }
|
|
56
56
|
.pending .dot.custom { animation: none; }
|
|
57
57
|
@keyframes hy-timeline-spin { to { transform: rotate(360deg); } }
|
|
@@ -59,9 +59,9 @@ export class HYTimeline extends HTMLElement {
|
|
|
59
59
|
@media (max-width: 560px) {
|
|
60
60
|
.item, .item.content-left { grid-template-columns: var(--hy-timeline-axis-width, 30px) minmax(0, 1fr); }
|
|
61
61
|
.axis, .item.content-left .axis { grid-column: 1; }
|
|
62
|
-
.card, .item.content-left .card { grid-column: 2; padding: 0 0
|
|
63
|
-
.label, .item.content-left .label { grid-column: 2; grid-row: 1; justify-self: end; padding: 1px 0 0 12px; text-align: right; }
|
|
64
|
-
.label + .axis + .card { padding-top:
|
|
62
|
+
.card, .item.content-left .card { grid-column: 2; padding: 0 0 calc(var(--hy-space-10, 20px) + 2px) var(--hy-space-6, 12px); text-align: left; }
|
|
63
|
+
.label, .item.content-left .label { grid-column: 2; grid-row: 1; justify-self: end; padding: 1px 0 0 var(--hy-space-6, 12px); text-align: right; }
|
|
64
|
+
.label + .axis + .card { padding-top: calc(var(--hy-space-10, 20px) + 2px); }
|
|
65
65
|
}
|
|
66
66
|
`;
|
|
67
67
|
this._list.className = 'timeline';
|
package/dist/toast.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { finiteNumber } from './internal/numbers.js';
|
|
1
2
|
const TYPES = ['success', 'info', 'warning', 'error', 'loading'];
|
|
2
3
|
const PLACEMENTS = ['top', 'center', 'bottom'];
|
|
3
4
|
const DEFAULT_DURATION = 3;
|
|
@@ -9,7 +10,7 @@ function isPlacement(value) {
|
|
|
9
10
|
return typeof value === 'string' && PLACEMENTS.includes(value);
|
|
10
11
|
}
|
|
11
12
|
function finiteNonNegative(value, fallback) {
|
|
12
|
-
const number =
|
|
13
|
+
const number = finiteNumber(value, fallback);
|
|
13
14
|
return Number.isFinite(number) && number >= 0 ? number : fallback;
|
|
14
15
|
}
|
|
15
16
|
/** Lightweight imperative feedback center for short, transient messages. */
|
|
@@ -24,7 +25,7 @@ export class HYToast extends HTMLElement {
|
|
|
24
25
|
const style = document.createElement('style');
|
|
25
26
|
style.textContent = `
|
|
26
27
|
:host { position: fixed; z-index: var(--hy-toast-z-index, 1200); inset: 0; display: block; pointer-events: none; }
|
|
27
|
-
.container { position: fixed; left: 50%; display: flex; width: min(var(--hy-toast-width, 420px), calc(100vw - 32px)); flex-direction: column; align-items: center; gap: var(--hy-toast-gap,
|
|
28
|
+
.container { position: fixed; left: 50%; display: flex; width: min(var(--hy-toast-width, 420px), calc(100vw - 32px)); flex-direction: column; align-items: center; gap: var(--hy-toast-gap, calc(var(--hy-space-4, 8px) + 1px)); pointer-events: none; transform: translateX(-50%); }
|
|
28
29
|
.container[data-placement="top"] { top: var(--hy-toast-offset, 24px); }
|
|
29
30
|
.container[data-placement="center"] { top: 50%; transform: translate(-50%, -50%); }
|
|
30
31
|
.container[data-placement="bottom"] { bottom: var(--hy-toast-offset, 24px); flex-direction: column-reverse; }
|
|
@@ -32,19 +33,19 @@ export class HYToast extends HTMLElement {
|
|
|
32
33
|
--_tone: var(--hy-info-color, var(--hy-accent-color, #79a8ff));
|
|
33
34
|
display: grid;
|
|
34
35
|
grid-template-columns: 20px minmax(0, 1fr) auto;
|
|
35
|
-
gap:
|
|
36
|
+
gap: calc(var(--hy-space-4, 8px) + 1px);
|
|
36
37
|
min-width: min(240px, calc(100vw - 32px));
|
|
37
38
|
max-width: 100%;
|
|
38
39
|
box-sizing: border-box;
|
|
39
40
|
align-items: center;
|
|
40
|
-
padding: 10px 12px;
|
|
41
|
+
padding: var(--hy-space-5, 10px) var(--hy-space-6, 12px);
|
|
41
42
|
border: 1px solid color-mix(in srgb, var(--_tone) 28%, var(--hy-border-color, #303746));
|
|
42
|
-
border-radius: var(--hy-toast-radius, 8px);
|
|
43
|
+
border-radius: var(--hy-toast-radius, var(--hy-radius-lg, 8px));
|
|
43
44
|
color: var(--hy-text-color, #e8effa);
|
|
44
45
|
background: var(--hy-toast-bg-color, var(--hy-surface-elevated-color, #171e2a));
|
|
45
|
-
box-shadow: 0 10px 30px var(--hy-toast-shadow-color, rgba(0, 0, 0, .3));
|
|
46
|
+
box-shadow: 0 10px 30px var(--hy-toast-shadow-color, var(--hy-shadow-color, rgba(0, 0, 0, .3)));
|
|
46
47
|
pointer-events: auto;
|
|
47
|
-
font: 12px/1.
|
|
48
|
+
font: var(--hy-font-size-sm, 12px)/calc(var(--hy-line-height-snug, 1.4) + 0.05) var(--hy-font-family, system-ui, sans-serif);
|
|
48
49
|
animation: hy-toast-enter 160ms cubic-bezier(.22, 1, .36, 1);
|
|
49
50
|
transition: opacity 140ms ease, transform 140ms ease;
|
|
50
51
|
}
|
|
@@ -54,10 +55,10 @@ export class HYToast extends HTMLElement {
|
|
|
54
55
|
.toast[data-type="loading"] { --_tone: var(--hy-accent-color, #79a8ff); }
|
|
55
56
|
.toast.closing { opacity: 0; transform: translateY(-6px) scale(.97); }
|
|
56
57
|
.container[data-placement="bottom"] .toast.closing { transform: translateY(6px) scale(.97); }
|
|
57
|
-
.icon { display: grid; width: 20px; height: 20px; place-items: center; color: var(--_tone); font-weight: 800; }
|
|
58
|
-
.toast[data-type="loading"] .icon { width: 15px; height: 15px; margin: 2px; border: 2px solid color-mix(in srgb, var(--_tone) 25%, transparent); border-top-color: var(--_tone); border-radius: 50%; animation: hy-toast-spin .75s linear infinite; font-size: 0; }
|
|
58
|
+
.icon { display: grid; width: 20px; height: 20px; place-items: center; color: var(--_tone); font-weight: var(--hy-font-weight-heavy, 800); }
|
|
59
|
+
.toast[data-type="loading"] .icon { width: 15px; height: 15px; margin: var(--hy-space-1, 2px); border: 2px solid color-mix(in srgb, var(--_tone) 25%, transparent); border-top-color: var(--_tone); border-radius: 50%; animation: hy-toast-spin .75s linear infinite; font-size: 0; }
|
|
59
60
|
.message { min-width: 0; overflow-wrap: anywhere; }
|
|
60
|
-
.close { display: grid; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 4px; place-items: center; color: var(--hy-secondary-text-color, #9aa8ba); background: transparent; cursor: pointer; font: 16px/1 system-ui, sans-serif; }
|
|
61
|
+
.close { display: grid; width: 20px; height: 20px; padding: 0; border: 0; border-radius: var(--hy-radius-sm, 4px); place-items: center; color: var(--hy-secondary-text-color, #9aa8ba); background: transparent; cursor: pointer; font: var(--hy-font-size-lg, 16px)/var(--hy-line-height-tight, 1) var(--hy-font-family, system-ui, sans-serif); }
|
|
61
62
|
.close:hover { color: inherit; background: var(--hy-hover-bg-color, #242d3b); }
|
|
62
63
|
.close:focus-visible { outline: 2px solid var(--hy-focus-border-color, #79a8ff); outline-offset: 1px; }
|
|
63
64
|
@keyframes hy-toast-enter { from { opacity: 0; transform: translateY(-7px) scale(.97); } }
|
|
@@ -87,7 +88,7 @@ export class HYToast extends HTMLElement {
|
|
|
87
88
|
get duration() { return finiteNonNegative(this.getAttribute('duration'), DEFAULT_DURATION); }
|
|
88
89
|
set duration(value) { this.setAttribute('duration', String(finiteNonNegative(value, DEFAULT_DURATION))); }
|
|
89
90
|
get maxCount() {
|
|
90
|
-
const value = Math.floor(
|
|
91
|
+
const value = Math.floor(finiteNumber(this.getAttribute('max-count'), 5));
|
|
91
92
|
return Number.isFinite(value) ? Math.min(20, Math.max(1, value)) : 5;
|
|
92
93
|
}
|
|
93
94
|
set maxCount(value) {
|
package/dist/tooltip.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export type HYTooltipPlacement = 'top' | 'topLeft' | 'topRight' | 'bottom' | 'bottomLeft' | 'bottomRight' | 'left' | 'leftTop' | 'leftBottom' | 'right' | 'rightTop' | 'rightBottom';
|
|
2
2
|
export declare class HYTooltip extends HTMLElement {
|
|
3
|
+
private static _descriptionSequence;
|
|
3
4
|
private readonly _root;
|
|
4
5
|
private readonly _style;
|
|
5
6
|
private readonly _slot;
|
|
@@ -8,6 +9,8 @@ export declare class HYTooltip extends HTMLElement {
|
|
|
8
9
|
private readonly _arrow;
|
|
9
10
|
private _showTimer;
|
|
10
11
|
private _visible;
|
|
12
|
+
private readonly _descriptions;
|
|
13
|
+
private readonly _observer;
|
|
11
14
|
static get observedAttributes(): string[];
|
|
12
15
|
constructor();
|
|
13
16
|
connectedCallback(): void;
|
|
@@ -28,6 +31,9 @@ export declare class HYTooltip extends HTMLElement {
|
|
|
28
31
|
private _hide;
|
|
29
32
|
private _onViewportChange;
|
|
30
33
|
private _syncLabel;
|
|
34
|
+
private _removeDescription;
|
|
35
|
+
private _clearDescriptions;
|
|
36
|
+
private _syncDescriptions;
|
|
31
37
|
private _syncArrow;
|
|
32
38
|
private _syncPosition;
|
|
33
39
|
private _syncArrowPosition;
|
package/dist/tooltip.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { finiteNumber } from './internal/numbers.js';
|
|
1
2
|
const DEFAULT_DELAY = 1000;
|
|
2
3
|
const VIEWPORT_PADDING = 8;
|
|
3
4
|
const TRIGGER_GAP = 8;
|
|
@@ -18,6 +19,7 @@ const TOOLTIP_PLACEMENTS = new Set([
|
|
|
18
19
|
'rightBottom',
|
|
19
20
|
]);
|
|
20
21
|
export class HYTooltip extends HTMLElement {
|
|
22
|
+
static _descriptionSequence = 0;
|
|
21
23
|
_root;
|
|
22
24
|
_style = document.createElement('style');
|
|
23
25
|
_slot = document.createElement('slot');
|
|
@@ -26,6 +28,8 @@ export class HYTooltip extends HTMLElement {
|
|
|
26
28
|
_arrow = document.createElement('span');
|
|
27
29
|
_showTimer = null;
|
|
28
30
|
_visible = false;
|
|
31
|
+
_descriptions = new Map();
|
|
32
|
+
_observer = new MutationObserver(() => this._syncDescriptions());
|
|
29
33
|
static get observedAttributes() {
|
|
30
34
|
return ['label', 'placement', 'delay', 'disabled', 'arrow', 'no-arrow'];
|
|
31
35
|
}
|
|
@@ -43,19 +47,20 @@ export class HYTooltip extends HTMLElement {
|
|
|
43
47
|
z-index: 10001;
|
|
44
48
|
box-sizing: border-box;
|
|
45
49
|
max-width: min(280px, calc(100vw - 16px));
|
|
46
|
-
padding:
|
|
47
|
-
border-radius: 4px;
|
|
50
|
+
padding: calc(var(--hy-space-2, 4px) + 1px) var(--hy-space-4, 8px);
|
|
51
|
+
border-radius: var(--hy-radius-sm, 4px);
|
|
48
52
|
color: var(--hy-tooltip-text-color, #f4f7fb);
|
|
49
53
|
background: var(--hy-tooltip-bg-color, #0f141c);
|
|
50
54
|
border: 1px solid var(--hy-tooltip-border-color, rgba(255, 255, 255, 0.08));
|
|
51
55
|
box-shadow: 0 8px 24px var(--hy-tooltip-shadow-color, rgba(0, 0, 0, 0.35));
|
|
52
|
-
font: 12px system-ui, sans-serif;
|
|
53
|
-
line-height: 1.
|
|
56
|
+
font: var(--hy-font-size-sm, 12px) var(--hy-font-family, system-ui, sans-serif);
|
|
57
|
+
line-height: calc(var(--hy-line-height-snug, 1.4) - 0.05);
|
|
54
58
|
width: max-content;
|
|
55
59
|
white-space: normal;
|
|
56
60
|
overflow-wrap: anywhere;
|
|
57
61
|
pointer-events: none;
|
|
58
62
|
opacity: 0;
|
|
63
|
+
visibility: hidden;
|
|
59
64
|
transform: translate3d(0, -2px, 0);
|
|
60
65
|
transition: opacity 0.12s ease, transform 0.12s ease;
|
|
61
66
|
}
|
|
@@ -73,15 +78,18 @@ export class HYTooltip extends HTMLElement {
|
|
|
73
78
|
}
|
|
74
79
|
.tooltip.visible {
|
|
75
80
|
opacity: 1;
|
|
81
|
+
visibility: visible;
|
|
76
82
|
transform: translate3d(0, 0, 0);
|
|
77
83
|
}
|
|
78
84
|
`;
|
|
79
85
|
this._tooltip.className = 'tooltip';
|
|
80
86
|
this._tooltip.setAttribute('role', 'tooltip');
|
|
87
|
+
this._tooltip.setAttribute('aria-hidden', 'true');
|
|
81
88
|
this._content.className = 'content';
|
|
82
89
|
this._arrow.className = 'arrow';
|
|
83
90
|
this._tooltip.append(this._content, this._arrow);
|
|
84
91
|
this._root.append(this._style, this._slot, this._tooltip);
|
|
92
|
+
this._slot.addEventListener('slotchange', () => this._syncDescriptions());
|
|
85
93
|
}
|
|
86
94
|
connectedCallback() {
|
|
87
95
|
this.addEventListener('pointerenter', this._onEnter);
|
|
@@ -89,6 +97,7 @@ export class HYTooltip extends HTMLElement {
|
|
|
89
97
|
this.addEventListener('focusin', this._onEnter);
|
|
90
98
|
this.addEventListener('focusout', this._onLeave);
|
|
91
99
|
this.addEventListener('keydown', this._onKeyDown);
|
|
100
|
+
this._observer.observe(this, { childList: true, subtree: true });
|
|
92
101
|
this._syncLabel();
|
|
93
102
|
}
|
|
94
103
|
disconnectedCallback() {
|
|
@@ -99,10 +108,17 @@ export class HYTooltip extends HTMLElement {
|
|
|
99
108
|
this.removeEventListener('keydown', this._onKeyDown);
|
|
100
109
|
this._clearShowTimer();
|
|
101
110
|
this._hide();
|
|
111
|
+
this._observer.disconnect();
|
|
112
|
+
this._clearDescriptions();
|
|
102
113
|
}
|
|
103
114
|
attributeChangedCallback(name) {
|
|
104
115
|
if (name === 'label')
|
|
105
116
|
this._syncLabel();
|
|
117
|
+
if (name === 'disabled') {
|
|
118
|
+
this._clearShowTimer();
|
|
119
|
+
this._hide();
|
|
120
|
+
this._syncDescriptions();
|
|
121
|
+
}
|
|
106
122
|
if (name === 'arrow' || name === 'no-arrow')
|
|
107
123
|
this._syncArrow();
|
|
108
124
|
if ((name === 'placement' || name === 'disabled' || name === 'arrow' || name === 'no-arrow') && this._visible) {
|
|
@@ -125,7 +141,7 @@ export class HYTooltip extends HTMLElement {
|
|
|
125
141
|
this.setAttribute('placement', value);
|
|
126
142
|
}
|
|
127
143
|
get delay() {
|
|
128
|
-
const value =
|
|
144
|
+
const value = finiteNumber(this.getAttribute('delay'), DEFAULT_DELAY);
|
|
129
145
|
return Number.isFinite(value) && value >= 0 ? value : DEFAULT_DELAY;
|
|
130
146
|
}
|
|
131
147
|
set delay(value) {
|
|
@@ -149,6 +165,7 @@ export class HYTooltip extends HTMLElement {
|
|
|
149
165
|
_onEnter = () => {
|
|
150
166
|
if (this.hasAttribute('disabled') || !this.label)
|
|
151
167
|
return;
|
|
168
|
+
this._syncDescriptions();
|
|
152
169
|
this._clearShowTimer();
|
|
153
170
|
this._showTimer = window.setTimeout(() => this._show(), this.delay);
|
|
154
171
|
};
|
|
@@ -157,14 +174,17 @@ export class HYTooltip extends HTMLElement {
|
|
|
157
174
|
this._hide();
|
|
158
175
|
};
|
|
159
176
|
_onKeyDown = (event) => {
|
|
160
|
-
if (event.key === 'Escape')
|
|
177
|
+
if (event.key === 'Escape') {
|
|
178
|
+
this._clearShowTimer();
|
|
161
179
|
this._hide();
|
|
180
|
+
}
|
|
162
181
|
};
|
|
163
182
|
_show() {
|
|
164
183
|
this._showTimer = null;
|
|
165
184
|
if (!this.isConnected || this.hasAttribute('disabled') || !this.label)
|
|
166
185
|
return;
|
|
167
186
|
this._visible = true;
|
|
187
|
+
this._tooltip.setAttribute('aria-hidden', 'false');
|
|
168
188
|
this._syncArrow();
|
|
169
189
|
this._syncPosition();
|
|
170
190
|
this._tooltip.classList.add('visible');
|
|
@@ -172,6 +192,7 @@ export class HYTooltip extends HTMLElement {
|
|
|
172
192
|
window.addEventListener('resize', this._onViewportChange);
|
|
173
193
|
}
|
|
174
194
|
_hide() {
|
|
195
|
+
this._tooltip.setAttribute('aria-hidden', 'true');
|
|
175
196
|
if (!this._visible)
|
|
176
197
|
return;
|
|
177
198
|
this._visible = false;
|
|
@@ -185,6 +206,86 @@ export class HYTooltip extends HTMLElement {
|
|
|
185
206
|
};
|
|
186
207
|
_syncLabel() {
|
|
187
208
|
this._content.textContent = this.label;
|
|
209
|
+
if (!this.label) {
|
|
210
|
+
this._clearShowTimer();
|
|
211
|
+
this._hide();
|
|
212
|
+
}
|
|
213
|
+
this._syncDescriptions();
|
|
214
|
+
}
|
|
215
|
+
_removeDescription(target) {
|
|
216
|
+
const record = this._descriptions.get(target);
|
|
217
|
+
if (!record)
|
|
218
|
+
return;
|
|
219
|
+
const ids = (target.getAttribute('aria-describedby') ?? '').split(/\s+/).filter(id => id && id !== record.id);
|
|
220
|
+
if (ids.length)
|
|
221
|
+
target.setAttribute('aria-describedby', ids.join(' '));
|
|
222
|
+
else
|
|
223
|
+
target.removeAttribute('aria-describedby');
|
|
224
|
+
record.node.remove();
|
|
225
|
+
this._descriptions.delete(target);
|
|
226
|
+
}
|
|
227
|
+
_clearDescriptions() {
|
|
228
|
+
for (const target of [...this._descriptions.keys()])
|
|
229
|
+
this._removeDescription(target);
|
|
230
|
+
}
|
|
231
|
+
_syncDescriptions() {
|
|
232
|
+
if (!this.isConnected || this.hasAttribute('disabled') || !this.label) {
|
|
233
|
+
this._clearDescriptions();
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
const targets = new Set();
|
|
237
|
+
const visit = (element) => {
|
|
238
|
+
if (element instanceof HTMLElement && (element.hidden || element.inert || element.getAttribute('aria-hidden') === 'true'))
|
|
239
|
+
return;
|
|
240
|
+
if (element instanceof HTMLSlotElement) {
|
|
241
|
+
for (const child of element.assignedElements({ flatten: true }))
|
|
242
|
+
visit(child);
|
|
243
|
+
}
|
|
244
|
+
else if (element.shadowRoot) {
|
|
245
|
+
for (const child of element.shadowRoot.children)
|
|
246
|
+
visit(child);
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
if (element instanceof HTMLElement && (element.isContentEditable || element.matches('button,input,select,textarea,a[href],[tabindex],[role="button"],[role="textbox"],[role="slider"]')))
|
|
250
|
+
targets.add(element);
|
|
251
|
+
for (const child of element.children)
|
|
252
|
+
visit(child);
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
for (const element of this._slot.assignedElements({ flatten: true })) {
|
|
256
|
+
const before = targets.size;
|
|
257
|
+
visit(element);
|
|
258
|
+
if (targets.size === before && element instanceof HTMLElement && !element.hidden && !element.inert)
|
|
259
|
+
targets.add(element);
|
|
260
|
+
}
|
|
261
|
+
for (const target of [...this._descriptions.keys()]) {
|
|
262
|
+
const record = this._descriptions.get(target);
|
|
263
|
+
if (!targets.has(target) || record.node.getRootNode() !== target.getRootNode())
|
|
264
|
+
this._removeDescription(target);
|
|
265
|
+
}
|
|
266
|
+
for (const target of targets) {
|
|
267
|
+
let record = this._descriptions.get(target);
|
|
268
|
+
if (!record) {
|
|
269
|
+
const node = document.createElement('span');
|
|
270
|
+
node.hidden = true;
|
|
271
|
+
const id = `hy-tooltip-description-${++HYTooltip._descriptionSequence}`;
|
|
272
|
+
node.id = id;
|
|
273
|
+
const scope = target.getRootNode();
|
|
274
|
+
if (scope instanceof ShadowRoot)
|
|
275
|
+
scope.append(node);
|
|
276
|
+
else
|
|
277
|
+
(target.ownerDocument.body ?? target.ownerDocument.documentElement).append(node);
|
|
278
|
+
record = { node, id };
|
|
279
|
+
this._descriptions.set(target, record);
|
|
280
|
+
}
|
|
281
|
+
if (record.node.textContent !== this.label)
|
|
282
|
+
record.node.textContent = this.label;
|
|
283
|
+
const ids = new Set((target.getAttribute('aria-describedby') ?? '').split(/\s+/).filter(Boolean));
|
|
284
|
+
ids.add(record.id);
|
|
285
|
+
const description = [...ids].join(' ');
|
|
286
|
+
if (target.getAttribute('aria-describedby') !== description)
|
|
287
|
+
target.setAttribute('aria-describedby', description);
|
|
288
|
+
}
|
|
188
289
|
}
|
|
189
290
|
_syncArrow() {
|
|
190
291
|
this._tooltip.classList.toggle('no-arrow', !this.arrow);
|
package/dist/tour.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { finiteNumber } from './internal/numbers.js';
|
|
1
2
|
function normalizeSteps(value) {
|
|
2
3
|
if (!Array.isArray(value))
|
|
3
4
|
return [];
|
|
@@ -47,20 +48,20 @@ export class HYTour extends HTMLElement {
|
|
|
47
48
|
const header = document.createElement('header');
|
|
48
49
|
const footer = document.createElement('footer');
|
|
49
50
|
style.textContent = `
|
|
50
|
-
:host { position: fixed; z-index: var(--_hy-tour-z-index, 1000); inset: 0; display: block; visibility: hidden; pointer-events: none; color: var(--hy-text-color, #eef3ff); font: 12px/1.5 system-ui, sans-serif; }
|
|
51
|
+
:host { position: fixed; z-index: var(--_hy-tour-z-index, 1000); inset: 0; display: block; visibility: hidden; pointer-events: none; color: var(--hy-text-color, #eef3ff); font: var(--hy-font-size-sm, 12px)/var(--hy-line-height-relaxed, 1.5) var(--hy-font-family, system-ui, sans-serif); }
|
|
51
52
|
:host([open]) { visibility: visible; }
|
|
52
|
-
.mask { position: absolute; background: var(--hy-tour-mask-color, rgba(3, 7, 18, .68)); pointer-events: auto; }
|
|
53
|
+
.mask { position: absolute; background: var(--hy-tour-mask-color, var(--hy-dialog-backdrop-color, rgba(3, 7, 18, .68))); pointer-events: auto; }
|
|
53
54
|
.mask[hidden], .highlight[hidden] { display: none; }
|
|
54
|
-
.highlight { position: absolute; box-sizing: border-box; border: 1px solid var(--hy-tour-highlight-color, var(--hy-accent-color, #79a8ff)); border-radius: var(--hy-tour-highlight-radius, 8px); box-shadow: 0 0 0 3px var(--hy-focus-ring-color, rgba(121, 168, 255, .22)); pointer-events: none; }
|
|
55
|
-
.popover { position: absolute; width: min(var(--hy-tour-width, 310px), calc(100vw - 24px)); box-sizing: border-box; padding:
|
|
56
|
-
header { display: flex; align-items: flex-start; gap: 12px; }
|
|
57
|
-
h2 { flex: 1; margin: 0; color: var(--hy-text-color, #eef3ff); font:
|
|
58
|
-
.close { width: 24px; height: 24px; padding: 0; border: 0; border-radius: 4px; color: var(--hy-muted-color, #788697); background: transparent; cursor: pointer; font:
|
|
55
|
+
.highlight { position: absolute; box-sizing: border-box; border: 1px solid var(--hy-tour-highlight-color, var(--hy-accent-color, #79a8ff)); border-radius: var(--hy-tour-highlight-radius, var(--hy-radius-lg, 8px)); box-shadow: 0 0 0 3px var(--hy-focus-ring-color, rgba(121, 168, 255, .22)); pointer-events: none; }
|
|
56
|
+
.popover { position: absolute; width: min(var(--hy-tour-width, 310px), calc(100vw - 24px)); box-sizing: border-box; padding: calc(var(--hy-space-7, 14px) + 1px); border: 1px solid var(--hy-border-color, #3d4654); border-radius: var(--hy-tour-radius, calc(var(--hy-radius-lg, 8px) + 2px)); outline: none; background: var(--hy-surface-elevated-color, #171d27); box-shadow: 0 18px 48px var(--hy-menu-shadow-color, rgba(0, 0, 0, .4)); pointer-events: auto; }
|
|
57
|
+
header { display: flex; align-items: flex-start; gap: var(--hy-space-6, 12px); }
|
|
58
|
+
h2 { flex: 1; margin: 0; color: var(--hy-text-color, #eef3ff); font: calc(var(--hy-font-weight-semibold, 600) + 50) var(--hy-font-size-md, 14px)/var(--hy-line-height-snug, 1.4) var(--hy-font-family, system-ui, sans-serif); }
|
|
59
|
+
.close { width: 24px; height: 24px; padding: 0; border: 0; border-radius: var(--hy-radius-sm, 4px); color: var(--hy-muted-color, #788697); background: transparent; cursor: pointer; font: calc(var(--hy-font-size-lg, 16px) + 1px)/var(--hy-line-height-tight, 1) var(--hy-font-family, system-ui, sans-serif); }
|
|
59
60
|
.close:hover { color: var(--hy-text-color, #eef3ff); background: var(--hy-hover-bg-color, #273241); }
|
|
60
|
-
.description { margin-top: 8px; color: var(--hy-secondary-text-color, #aebbd0); }
|
|
61
|
-
footer { display: flex; align-items: center; gap: 8px; margin-top: 16px; }
|
|
62
|
-
.counter { flex: 1; color: var(--hy-muted-color, #788697); font: 10px/1 ui-monospace, monospace; }
|
|
63
|
-
footer button { min-width: 58px; height: 29px; padding: 0 10px; border: 1px solid var(--hy-border-color, #3d4654); border-radius:
|
|
61
|
+
.description { margin-top: var(--hy-space-4, 8px); color: var(--hy-secondary-text-color, #aebbd0); }
|
|
62
|
+
footer { display: flex; align-items: center; gap: var(--hy-space-4, 8px); margin-top: var(--hy-space-8, 16px); }
|
|
63
|
+
.counter { flex: 1; color: var(--hy-muted-color, #788697); font: var(--hy-font-size-xs, 10px)/var(--hy-line-height-tight, 1) var(--hy-font-family-mono, ui-monospace, monospace); }
|
|
64
|
+
footer button { min-width: 58px; height: 29px; padding: 0 var(--hy-space-5, 10px); border: 1px solid var(--hy-border-color, #3d4654); border-radius: calc(var(--hy-radius-sm, 4px) + 1px); color: var(--hy-secondary-text-color, #aebbd0); background: transparent; cursor: pointer; font: inherit; }
|
|
64
65
|
footer button:hover:not(:disabled) { color: var(--hy-text-color, #eef3ff); border-color: var(--hy-hover-border-color, #596779); background: var(--hy-hover-bg-color, #273241); }
|
|
65
66
|
footer .next { color: var(--hy-selected-text-color, #fff); border-color: var(--hy-selected-bg-color, #554cc6); background: var(--hy-selected-bg-color, #554cc6); }
|
|
66
67
|
footer button:disabled { visibility: hidden; }
|
|
@@ -129,10 +130,10 @@ export class HYTour extends HTMLElement {
|
|
|
129
130
|
set closeOnEscape(value) { this.setAttribute('close-on-escape', String(Boolean(value))); }
|
|
130
131
|
get autoScroll() { return this.getAttribute('scroll-into-view') !== 'false'; }
|
|
131
132
|
set autoScroll(value) { this.setAttribute('scroll-into-view', String(Boolean(value))); }
|
|
132
|
-
get gap() { const number =
|
|
133
|
+
get gap() { const number = finiteNumber(this.getAttribute('gap'), 8); return Number.isFinite(number) ? Math.min(80, Math.max(0, number)) : 8; }
|
|
133
134
|
set gap(value) { const number = Number(value); this.setAttribute('gap', String(Number.isFinite(number) ? Math.min(80, Math.max(0, number)) : 8)); }
|
|
134
|
-
get zIndex() { const number =
|
|
135
|
-
set zIndex(value) { this.setAttribute('z-index', String(Math.round(
|
|
135
|
+
get zIndex() { const number = finiteNumber(this.getAttribute('z-index'), 1000); return Number.isFinite(number) ? Math.round(number) : 1000; }
|
|
136
|
+
set zIndex(value) { this.setAttribute('z-index', String(Math.round(finiteNumber(value, 1000)))); }
|
|
136
137
|
start(current = 0) { if (!this._steps.length)
|
|
137
138
|
return; this.current = current; this.open = true; }
|
|
138
139
|
next() {
|
|
@@ -163,6 +164,10 @@ export class HYTour extends HTMLElement {
|
|
|
163
164
|
if (!this.isConnected)
|
|
164
165
|
return;
|
|
165
166
|
this.style.setProperty('--_hy-tour-z-index', String(this.zIndex));
|
|
167
|
+
if (this.open && !this._steps.length) {
|
|
168
|
+
this.close('programmatic');
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
166
171
|
if (!this.open || !this._steps.length) {
|
|
167
172
|
this._teardown();
|
|
168
173
|
this._returnFocus?.focus({ preventScroll: true });
|
|
@@ -187,8 +192,11 @@ export class HYTour extends HTMLElement {
|
|
|
187
192
|
_teardown() { this._documentAbort?.abort(); this._documentAbort = null; this._resizeObserver?.disconnect(); this._resizeObserver = null; cancelAnimationFrame(this._frame); this._frame = 0; this._target = null; this._scrolledStep = -1; }
|
|
188
193
|
_renderStep() {
|
|
189
194
|
const step = this._steps[this.current];
|
|
190
|
-
if (!step)
|
|
195
|
+
if (!step) {
|
|
196
|
+
if (this.open)
|
|
197
|
+
this.close('programmatic');
|
|
191
198
|
return;
|
|
199
|
+
}
|
|
192
200
|
this._title.textContent = step.title;
|
|
193
201
|
this._description.textContent = step.description ?? '';
|
|
194
202
|
this._description.hidden = !step.description;
|
|
@@ -211,7 +219,8 @@ export class HYTour extends HTMLElement {
|
|
|
211
219
|
this._resizeObserver.observe(this._target);
|
|
212
220
|
}
|
|
213
221
|
this._schedulePosition();
|
|
214
|
-
queueMicrotask(() => this.
|
|
222
|
+
queueMicrotask(() => { if (this.open && this.isConnected)
|
|
223
|
+
this._popover.focus({ preventScroll: true }); });
|
|
215
224
|
}
|
|
216
225
|
_resolveTarget(target) { if (typeof target === 'function')
|
|
217
226
|
return target(); if (typeof target === 'string') {
|
|
@@ -234,7 +243,7 @@ export class HYTour extends HTMLElement {
|
|
|
234
243
|
const margin = 12;
|
|
235
244
|
const gap = this.gap;
|
|
236
245
|
const mask = step.mask ?? this.mask;
|
|
237
|
-
this._popover.
|
|
246
|
+
this._popover.removeAttribute('aria-modal');
|
|
238
247
|
if (!this._target) {
|
|
239
248
|
this._masks.forEach(piece => { piece.hidden = !mask; piece.style.cssText = mask ? 'inset:0' : ''; });
|
|
240
249
|
this._highlight.hidden = true;
|
package/dist/tree-model.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export declare class HYTreeModel {
|
|
|
24
24
|
} | null;
|
|
25
25
|
topLevelSelection(ids: Iterable<string>): string[];
|
|
26
26
|
removeNode(id: string): boolean;
|
|
27
|
+
removeNodes(ids: Iterable<string>): string[];
|
|
27
28
|
moveNode(sourceId: string, targetId: string, position: HYTreeDropPosition): boolean;
|
|
28
29
|
private _createMovePlan;
|
|
29
30
|
private _visibleRange;
|
|
@@ -37,6 +38,7 @@ export declare class HYTreeModel {
|
|
|
37
38
|
private _resolveVisibleInsertAt;
|
|
38
39
|
private _insertVisibleSubtrees;
|
|
39
40
|
private _collectVisibleSubtree;
|
|
41
|
+
private _insertMany;
|
|
40
42
|
private _visibleSubtreeEnd;
|
|
41
43
|
private _refreshVisibleIndexes;
|
|
42
44
|
private _ensureIndex;
|
package/dist/tree-model.js
CHANGED
|
@@ -73,16 +73,29 @@ export class HYTreeModel {
|
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
removeNode(id) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
76
|
+
return this.removeNodes([id]).length !== 0;
|
|
77
|
+
}
|
|
78
|
+
removeNodes(ids) {
|
|
79
|
+
const selected = this.topLevelSelection(ids);
|
|
80
|
+
if (!selected.length)
|
|
81
|
+
return [];
|
|
82
|
+
const groups = new Map();
|
|
83
|
+
for (const id of selected) {
|
|
84
|
+
const indexed = this._nodeIndex.get(id);
|
|
85
|
+
const list = indexed.parent?.children ?? this._data;
|
|
86
|
+
if (!groups.has(list))
|
|
87
|
+
groups.set(list, new Set());
|
|
88
|
+
groups.get(list).add(indexed.index);
|
|
89
|
+
}
|
|
90
|
+
for (const [list, removed] of groups) {
|
|
91
|
+
let write = 0;
|
|
92
|
+
for (let read = 0; read < list.length; read++)
|
|
93
|
+
if (!removed.has(read))
|
|
94
|
+
list[write++] = list[read];
|
|
95
|
+
list.length = write;
|
|
96
|
+
}
|
|
84
97
|
this.setData(this._data);
|
|
85
|
-
return
|
|
98
|
+
return selected;
|
|
86
99
|
}
|
|
87
100
|
moveNode(sourceId, targetId, position) {
|
|
88
101
|
this._ensureIndex();
|
|
@@ -225,8 +238,8 @@ export class HYTreeModel {
|
|
|
225
238
|
this._collectVisibleSubtree(root, moved);
|
|
226
239
|
if (moved.length === 0)
|
|
227
240
|
return;
|
|
228
|
-
this._visibleNodes
|
|
229
|
-
this._visibleIds
|
|
241
|
+
this._insertMany(this._visibleNodes, insertAt, moved);
|
|
242
|
+
this._insertMany(this._visibleIds, insertAt, moved.map(item => item.node.id));
|
|
230
243
|
this._refreshVisibleIndexes(insertAt);
|
|
231
244
|
}
|
|
232
245
|
_collectVisibleSubtree(node, result) {
|
|
@@ -239,6 +252,14 @@ export class HYTreeModel {
|
|
|
239
252
|
for (const child of node.children ?? [])
|
|
240
253
|
this._collectVisibleSubtree(child, result);
|
|
241
254
|
}
|
|
255
|
+
_insertMany(list, index, items) {
|
|
256
|
+
const length = list.length;
|
|
257
|
+
list.length += items.length;
|
|
258
|
+
for (let i = length - 1; i >= index; i--)
|
|
259
|
+
list[i + items.length] = list[i];
|
|
260
|
+
for (let i = 0; i < items.length; i++)
|
|
261
|
+
list[index + i] = items[i];
|
|
262
|
+
}
|
|
242
263
|
_visibleSubtreeEnd(id) {
|
|
243
264
|
if (!id)
|
|
244
265
|
return -1;
|
package/dist/tree-node.js
CHANGED
|
@@ -13,7 +13,7 @@ export class HYTreeNode extends HTMLElement {
|
|
|
13
13
|
display: flex;
|
|
14
14
|
align-items: center;
|
|
15
15
|
min-width: 0;
|
|
16
|
-
gap: 6px;
|
|
16
|
+
gap: var(--hy-space-3, 6px);
|
|
17
17
|
color: inherit;
|
|
18
18
|
font: inherit;
|
|
19
19
|
}
|
|
@@ -23,7 +23,7 @@ export class HYTreeNode extends HTMLElement {
|
|
|
23
23
|
display: inline-grid;
|
|
24
24
|
place-items: center;
|
|
25
25
|
color: var(--hy-tree-icon-color, var(--hy-secondary-text-color, #8fa7c8));
|
|
26
|
-
font-size: 12px;
|
|
26
|
+
font-size: var(--hy-font-size-sm, 12px);
|
|
27
27
|
}
|
|
28
28
|
.label {
|
|
29
29
|
min-width: 0;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
export interface HYTreeSelectOption {
|
|
2
|
+
value: string;
|
|
3
|
+
label: string;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
selectable?: boolean;
|
|
6
|
+
expanded?: boolean;
|
|
7
|
+
children?: HYTreeSelectOption[];
|
|
8
|
+
}
|
|
9
|
+
export interface HYTreeSelectChangeDetail {
|
|
10
|
+
value: string | string[];
|
|
11
|
+
values: string[];
|
|
12
|
+
options: HYTreeSelectOption[];
|
|
13
|
+
}
|
|
14
|
+
export interface HYTreeSelectExpandDetail {
|
|
15
|
+
expandedKeys: string[];
|
|
16
|
+
}
|
|
17
|
+
export declare class HYTreeSelect extends HTMLElement {
|
|
18
|
+
static readonly formAssociated = true;
|
|
19
|
+
private readonly _internals;
|
|
20
|
+
private readonly _control;
|
|
21
|
+
private readonly _tags;
|
|
22
|
+
private readonly _input;
|
|
23
|
+
private readonly _clear;
|
|
24
|
+
private readonly _panel;
|
|
25
|
+
private readonly _tree;
|
|
26
|
+
private readonly _status;
|
|
27
|
+
private readonly _id;
|
|
28
|
+
private readonly _popup;
|
|
29
|
+
private _options;
|
|
30
|
+
private _entries;
|
|
31
|
+
private _expanded;
|
|
32
|
+
private _visible;
|
|
33
|
+
private _active;
|
|
34
|
+
private _query;
|
|
35
|
+
private _composing;
|
|
36
|
+
private _formDisabled;
|
|
37
|
+
private _initialValues;
|
|
38
|
+
private _listeners;
|
|
39
|
+
private _customError;
|
|
40
|
+
static get observedAttributes(): string[];
|
|
41
|
+
constructor();
|
|
42
|
+
connectedCallback(): void;
|
|
43
|
+
disconnectedCallback(): void;
|
|
44
|
+
attributeChangedCallback(name: string, previous: string | null, next: string | null): void;
|
|
45
|
+
get options(): HYTreeSelectOption[];
|
|
46
|
+
set options(value: HYTreeSelectOption[]);
|
|
47
|
+
get values(): string[];
|
|
48
|
+
set values(value: string[]);
|
|
49
|
+
get value(): string | string[];
|
|
50
|
+
set value(value: string | readonly string[]);
|
|
51
|
+
get multiple(): boolean;
|
|
52
|
+
set multiple(value: boolean);
|
|
53
|
+
get disabled(): boolean;
|
|
54
|
+
set disabled(value: boolean);
|
|
55
|
+
get readOnly(): boolean;
|
|
56
|
+
set readOnly(value: boolean);
|
|
57
|
+
get searchable(): boolean;
|
|
58
|
+
set searchable(value: boolean);
|
|
59
|
+
get clearable(): boolean;
|
|
60
|
+
set clearable(value: boolean);
|
|
61
|
+
get loading(): boolean;
|
|
62
|
+
set loading(value: boolean);
|
|
63
|
+
get open(): boolean;
|
|
64
|
+
set open(value: boolean);
|
|
65
|
+
get expandedKeys(): string[];
|
|
66
|
+
set expandedKeys(value: string[]);
|
|
67
|
+
get placeholder(): string;
|
|
68
|
+
set placeholder(value: string);
|
|
69
|
+
get form(): HTMLFormElement | null;
|
|
70
|
+
get validity(): ValidityState;
|
|
71
|
+
get validationMessage(): string;
|
|
72
|
+
checkValidity(): boolean;
|
|
73
|
+
reportValidity(): boolean;
|
|
74
|
+
setCustomValidity(message: string): void;
|
|
75
|
+
formDisabledCallback(disabled: boolean): void;
|
|
76
|
+
formResetCallback(): void;
|
|
77
|
+
formStateRestoreCallback(state: string | File | FormData | null): void;
|
|
78
|
+
focus(options?: FocusOptions): void;
|
|
79
|
+
blur(): void;
|
|
80
|
+
private get _disabled();
|
|
81
|
+
private _setOptions;
|
|
82
|
+
private _sync;
|
|
83
|
+
private _syncForm;
|
|
84
|
+
private _render;
|
|
85
|
+
private _syncActive;
|
|
86
|
+
private _setOpen;
|
|
87
|
+
private _emitSearch;
|
|
88
|
+
private _commit;
|
|
89
|
+
private _select;
|
|
90
|
+
private _toggle;
|
|
91
|
+
private _onTreeClick;
|
|
92
|
+
private _onKeydown;
|
|
93
|
+
}
|
|
94
|
+
export declare function defineTreeSelectComponents(): void;
|