@haiyue/ui 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/LICENSE +1 -1
- package/README.md +226 -2
- package/dist/border-beam.d.ts +26 -0
- package/dist/border-beam.js +174 -0
- package/dist/button.d.ts +10 -0
- package/dist/button.js +85 -0
- package/dist/checkbox.d.ts +2 -2
- package/dist/checkbox.js +11 -11
- package/dist/context-menu.d.ts +6 -6
- package/dist/context-menu.js +11 -9
- package/dist/dialog.d.ts +5 -5
- package/dist/dialog.js +18 -18
- package/dist/drawer.d.ts +49 -0
- package/dist/drawer.js +377 -0
- package/dist/dropdown.d.ts +9 -9
- package/dist/dropdown.js +9 -9
- package/dist/expandable.d.ts +32 -0
- package/dist/expandable.js +136 -0
- package/dist/history-controls.d.ts +40 -0
- package/dist/history-controls.js +123 -0
- package/dist/index.d.ts +36 -31
- package/dist/index.js +35 -85
- package/dist/input.d.ts +5 -5
- package/dist/input.js +13 -13
- package/dist/menu-shared.d.ts +4 -4
- package/dist/menu-shared.js +4 -4
- package/dist/notification.d.ts +55 -0
- package/dist/notification.js +357 -0
- package/dist/radio.d.ts +2 -2
- package/dist/radio.js +12 -12
- package/dist/range.d.ts +74 -0
- package/dist/range.js +393 -0
- package/dist/select.d.ts +6 -6
- package/dist/select.js +20 -20
- package/dist/split.d.ts +6 -6
- package/dist/split.js +14 -14
- package/dist/tabs.d.ts +10 -6
- package/dist/tabs.js +94 -30
- package/dist/tooltip.d.ts +4 -4
- package/dist/tooltip.js +9 -9
- package/dist/tree-model.d.ts +15 -7
- package/dist/tree-model.js +93 -80
- package/dist/tree-node.d.ts +3 -3
- package/dist/tree-node.js +3 -3
- package/dist/tree-types.d.ts +14 -14
- package/dist/tree.d.ts +9 -7
- package/dist/tree.js +68 -66
- package/dist/virtual-list.d.ts +61 -0
- package/dist/virtual-list.js +324 -0
- package/package.json +100 -7
- package/themes/haiyue-dark.css +46 -0
- package/themes/haiyue-light.css +46 -0
- package/src/checkbox.ts +0 -215
- package/src/context-menu.ts +0 -248
- package/src/dialog.ts +0 -195
- package/src/dropdown.ts +0 -249
- package/src/index.ts +0 -192
- package/src/input.ts +0 -150
- package/src/menu-shared.ts +0 -65
- package/src/radio.ts +0 -216
- package/src/select.ts +0 -271
- package/src/split.ts +0 -306
- package/src/tabs.ts +0 -182
- package/src/tooltip.ts +0 -321
- package/src/tree-model.ts +0 -305
- package/src/tree-node.ts +0 -67
- package/src/tree-types.ts +0 -47
- package/src/tree.ts +0 -1002
package/dist/dropdown.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GE_MENU_ITEM_STYLES, createMenuItemButton, createMenuSeparator } from './menu-shared.js';
|
|
2
|
-
export class
|
|
2
|
+
export class HYDropdown extends HTMLElement {
|
|
3
3
|
_root;
|
|
4
4
|
_style = document.createElement('style');
|
|
5
5
|
_triggerSlot = document.createElement('slot');
|
|
@@ -17,7 +17,7 @@ export class GEDropdown extends HTMLElement {
|
|
|
17
17
|
display: inline-block;
|
|
18
18
|
width: max-content;
|
|
19
19
|
min-width: 0;
|
|
20
|
-
color: var(--
|
|
20
|
+
color: var(--hy-text-color, #d8e2f2);
|
|
21
21
|
font: 12px system-ui, sans-serif;
|
|
22
22
|
}
|
|
23
23
|
:host([disabled]) {
|
|
@@ -33,11 +33,11 @@ export class GEDropdown extends HTMLElement {
|
|
|
33
33
|
overflow: auto;
|
|
34
34
|
display: none;
|
|
35
35
|
padding: 4px;
|
|
36
|
-
border: 1px solid var(--
|
|
36
|
+
border: 1px solid var(--hy-border-color, #303746);
|
|
37
37
|
border-radius: 4px;
|
|
38
|
-
color: var(--
|
|
39
|
-
background: var(--
|
|
40
|
-
box-shadow: 0 10px 26px var(--
|
|
38
|
+
color: var(--hy-text-color, #d8e2f2);
|
|
39
|
+
background: var(--hy-menu-bg-color, var(--hy-surface-elevated-color, #1b2230));
|
|
40
|
+
box-shadow: 0 10px 26px var(--hy-menu-shadow-color, rgba(0, 0, 0, 0.36));
|
|
41
41
|
}
|
|
42
42
|
:host([open]) .menu {
|
|
43
43
|
display: block;
|
|
@@ -137,7 +137,7 @@ ${GE_MENU_ITEM_STYLES}
|
|
|
137
137
|
: [];
|
|
138
138
|
}
|
|
139
139
|
catch (error) {
|
|
140
|
-
console.warn('Invalid
|
|
140
|
+
console.warn('Invalid hy-dropdown items attribute.', error);
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
_render() {
|
|
@@ -221,8 +221,8 @@ function getVisualViewportRect() {
|
|
|
221
221
|
: { left: 0, top: 0, width: window.innerWidth, height: window.innerHeight };
|
|
222
222
|
}
|
|
223
223
|
export function defineDropdownComponents() {
|
|
224
|
-
if (!customElements.get('
|
|
225
|
-
customElements.define('
|
|
224
|
+
if (!customElements.get('hy-dropdown')) {
|
|
225
|
+
customElements.define('hy-dropdown', HYDropdown);
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
228
|
//# sourceMappingURL=dropdown.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type HYExpandableButtonPosition = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
|
|
2
|
+
export interface HYExpandableChangeDetail {
|
|
3
|
+
expanded: boolean;
|
|
4
|
+
}
|
|
5
|
+
/** A non-modal, top-layer expansion of the same slotted content; no cloning or reparenting. */
|
|
6
|
+
export declare class HYExpandable extends HTMLElement {
|
|
7
|
+
static get observedAttributes(): string[];
|
|
8
|
+
private readonly panel;
|
|
9
|
+
private readonly placeholder;
|
|
10
|
+
private readonly button;
|
|
11
|
+
private readonly expandIcon;
|
|
12
|
+
private readonly restoreIcon;
|
|
13
|
+
private lifetime;
|
|
14
|
+
private active;
|
|
15
|
+
constructor();
|
|
16
|
+
get expanded(): boolean;
|
|
17
|
+
set expanded(value: boolean);
|
|
18
|
+
get expandedWidth(): string;
|
|
19
|
+
set expandedWidth(value: string);
|
|
20
|
+
get expandedHeight(): string;
|
|
21
|
+
set expandedHeight(value: string);
|
|
22
|
+
get buttonPosition(): HYExpandableButtonPosition;
|
|
23
|
+
set buttonPosition(value: HYExpandableButtonPosition);
|
|
24
|
+
toggle(): void;
|
|
25
|
+
connectedCallback(): void;
|
|
26
|
+
disconnectedCallback(): void;
|
|
27
|
+
attributeChangedCallback(): void;
|
|
28
|
+
private render;
|
|
29
|
+
private sync;
|
|
30
|
+
private closePanel;
|
|
31
|
+
}
|
|
32
|
+
export declare function defineExpandableComponents(): void;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/** A non-modal, top-layer expansion of the same slotted content; no cloning or reparenting. */
|
|
2
|
+
export class HYExpandable extends HTMLElement {
|
|
3
|
+
static get observedAttributes() { return ['expanded', 'expanded-width', 'expanded-height', 'button-position', 'expand-label', 'restore-label']; }
|
|
4
|
+
panel;
|
|
5
|
+
placeholder;
|
|
6
|
+
button;
|
|
7
|
+
expandIcon;
|
|
8
|
+
restoreIcon;
|
|
9
|
+
lifetime;
|
|
10
|
+
active = false;
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
|
+
const root = this.attachShadow({ mode: 'open' });
|
|
14
|
+
const style = document.createElement('style');
|
|
15
|
+
style.textContent = `
|
|
16
|
+
:host { display:block; position:relative; min-width:0; min-height:0; }
|
|
17
|
+
.placeholder { display:none; pointer-events:none; }
|
|
18
|
+
.panel { position:relative; display:grid; grid-template-columns:minmax(0,1fr); grid-template-rows:minmax(0,1fr); width:100%; height:100%; min-width:0; min-height:0; box-sizing:border-box; color:inherit; font:inherit; }
|
|
19
|
+
.panel:popover-open { position:fixed; inset:0; margin:auto; width:var(--_width,90vw); height:var(--_height,90dvh); max-width:calc(100vw - 2 * var(--hy-expandable-margin,16px)); max-height:calc(100dvh - 2 * var(--hy-expandable-margin,16px)); padding:var(--hy-expandable-padding,16px); border:1px solid var(--hy-border-color,#536074); border-radius:var(--hy-expandable-radius,10px); background:var(--hy-surface-color,#18202e); box-shadow:var(--hy-expandable-shadow,0 16px 64px #0006); }
|
|
20
|
+
.panel::backdrop { background:transparent; pointer-events:none; }
|
|
21
|
+
button { position:absolute; z-index:2; top:var(--hy-expandable-button-offset,8px); right:var(--hy-expandable-button-offset,8px); display:grid; place-items:center; width:var(--hy-expandable-button-size,32px); height:var(--hy-expandable-button-size,32px); padding:6px; border:1px solid var(--hy-border-color,#536074); border-radius:6px; color:var(--hy-text-color,inherit); background:var(--hy-surface-color,#18202e); cursor:pointer; }
|
|
22
|
+
button:hover { color:var(--hy-accent-color,#7dd3fc); }
|
|
23
|
+
button:focus-visible { outline:2px solid var(--hy-accent-color,#7dd3fc); outline-offset:2px; }
|
|
24
|
+
button[data-position$="left"] { left:var(--hy-expandable-button-offset,8px); right:auto; }
|
|
25
|
+
button[data-position^="bottom"] { bottom:var(--hy-expandable-button-offset,8px); top:auto; }
|
|
26
|
+
svg, ::slotted([slot="expand-icon"]), ::slotted([slot="restore-icon"]) { width:100%; height:100%; pointer-events:none; }
|
|
27
|
+
slot[hidden] { display:none; }
|
|
28
|
+
`;
|
|
29
|
+
this.placeholder = document.createElement('div');
|
|
30
|
+
this.placeholder.className = 'placeholder';
|
|
31
|
+
this.panel = document.createElement('div');
|
|
32
|
+
this.panel.className = 'panel';
|
|
33
|
+
this.panel.id = 'panel';
|
|
34
|
+
this.panel.part.add('panel');
|
|
35
|
+
this.button = document.createElement('button');
|
|
36
|
+
this.button.type = 'button';
|
|
37
|
+
this.button.part.add('toggle');
|
|
38
|
+
this.button.setAttribute('aria-controls', 'panel');
|
|
39
|
+
const icon = (name, path) => {
|
|
40
|
+
const slot = document.createElement('slot');
|
|
41
|
+
slot.name = name;
|
|
42
|
+
slot.setAttribute('aria-hidden', 'true');
|
|
43
|
+
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
44
|
+
svg.setAttribute('viewBox', '0 0 24 24');
|
|
45
|
+
svg.setAttribute('fill', 'none');
|
|
46
|
+
svg.setAttribute('stroke', 'currentColor');
|
|
47
|
+
svg.setAttribute('stroke-width', '1.8');
|
|
48
|
+
const shape = document.createElementNS(svg.namespaceURI, 'path');
|
|
49
|
+
shape.setAttribute('d', path);
|
|
50
|
+
svg.append(shape);
|
|
51
|
+
slot.append(svg);
|
|
52
|
+
return slot;
|
|
53
|
+
};
|
|
54
|
+
this.expandIcon = icon('expand-icon', 'M8 3H3v5m13-5h5v5M3 16v5h5m13-5v5h-5M3 3l6 6m12-6-6 6M3 21l6-6m12 6-6-6');
|
|
55
|
+
this.restoreIcon = icon('restore-icon', 'M3 9h6V3m6 0v6h6M9 21v-6H3m18 0h-6v6M3 3l6 6m12-6-6 6M3 21l6-6m12 6-6-6');
|
|
56
|
+
this.button.append(this.expandIcon, this.restoreIcon);
|
|
57
|
+
this.panel.append(document.createElement('slot'), this.button);
|
|
58
|
+
root.append(style, this.placeholder, this.panel);
|
|
59
|
+
this.button.addEventListener('click', () => this.toggle());
|
|
60
|
+
this.render();
|
|
61
|
+
}
|
|
62
|
+
get expanded() { return this.hasAttribute('expanded'); }
|
|
63
|
+
set expanded(value) { this.toggleAttribute('expanded', Boolean(value)); }
|
|
64
|
+
get expandedWidth() { return this.getAttribute('expanded-width') ?? '90vw'; }
|
|
65
|
+
set expandedWidth(value) { this.setAttribute('expanded-width', value); }
|
|
66
|
+
get expandedHeight() { return this.getAttribute('expanded-height') ?? '90dvh'; }
|
|
67
|
+
set expandedHeight(value) { this.setAttribute('expanded-height', value); }
|
|
68
|
+
get buttonPosition() {
|
|
69
|
+
const value = this.getAttribute('button-position');
|
|
70
|
+
return (['top-left', 'bottom-right', 'bottom-left'].includes(value ?? '') ? value : 'top-right');
|
|
71
|
+
}
|
|
72
|
+
set buttonPosition(value) { this.setAttribute('button-position', value); }
|
|
73
|
+
toggle() { this.expanded = !this.expanded; }
|
|
74
|
+
connectedCallback() {
|
|
75
|
+
this.lifetime?.abort();
|
|
76
|
+
this.lifetime = new AbortController();
|
|
77
|
+
this.addEventListener('keydown', event => {
|
|
78
|
+
// Bubbling follows the composed tree across shadow roots. Child menus and
|
|
79
|
+
// expanded containers consume Escape before it reaches their ancestors.
|
|
80
|
+
if (event.key === 'Escape' && !event.defaultPrevented && this.active) {
|
|
81
|
+
event.preventDefault();
|
|
82
|
+
this.expanded = false;
|
|
83
|
+
this.button.focus({ preventScroll: true });
|
|
84
|
+
}
|
|
85
|
+
}, { signal: this.lifetime.signal });
|
|
86
|
+
queueMicrotask(() => { if (this.isConnected)
|
|
87
|
+
this.sync(); });
|
|
88
|
+
}
|
|
89
|
+
disconnectedCallback() {
|
|
90
|
+
this.lifetime?.abort();
|
|
91
|
+
this.lifetime = undefined;
|
|
92
|
+
this.closePanel(); // Attribute remains available if the owner reconnects this element.
|
|
93
|
+
}
|
|
94
|
+
attributeChangedCallback() { this.render(); if (this.isConnected)
|
|
95
|
+
this.sync(); }
|
|
96
|
+
render() {
|
|
97
|
+
for (const [name, value] of [['width', this.expandedWidth], ['height', this.expandedHeight]]) {
|
|
98
|
+
this.panel.style.removeProperty(`--_${name}`);
|
|
99
|
+
if (CSS.supports(name, value))
|
|
100
|
+
this.panel.style.setProperty(`--_${name}`, value);
|
|
101
|
+
}
|
|
102
|
+
this.button.dataset.position = this.buttonPosition;
|
|
103
|
+
this.button.setAttribute('aria-expanded', String(this.expanded));
|
|
104
|
+
const label = this.getAttribute(this.expanded ? 'restore-label' : 'expand-label') ?? (this.expanded ? 'Restore size' : 'Expand');
|
|
105
|
+
this.button.setAttribute('aria-label', label);
|
|
106
|
+
this.button.title = label;
|
|
107
|
+
this.expandIcon.hidden = this.expanded;
|
|
108
|
+
this.restoreIcon.hidden = !this.expanded;
|
|
109
|
+
}
|
|
110
|
+
sync() {
|
|
111
|
+
if (this.expanded === this.active)
|
|
112
|
+
return;
|
|
113
|
+
if (this.expanded) {
|
|
114
|
+
this.placeholder.style.height = `${this.getBoundingClientRect().height}px`;
|
|
115
|
+
this.placeholder.style.display = 'block';
|
|
116
|
+
this.panel.setAttribute('popover', 'manual');
|
|
117
|
+
this.panel.showPopover();
|
|
118
|
+
this.active = true;
|
|
119
|
+
}
|
|
120
|
+
else
|
|
121
|
+
this.closePanel();
|
|
122
|
+
this.dispatchEvent(new CustomEvent('expanded-change', { detail: { expanded: this.active }, bubbles: true, composed: true }));
|
|
123
|
+
}
|
|
124
|
+
closePanel() {
|
|
125
|
+
if (this.panel.matches(':popover-open'))
|
|
126
|
+
this.panel.hidePopover();
|
|
127
|
+
this.panel.removeAttribute('popover');
|
|
128
|
+
this.placeholder.style.display = 'none';
|
|
129
|
+
this.active = false;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
export function defineExpandableComponents() {
|
|
133
|
+
if (!customElements.get('hy-expandable'))
|
|
134
|
+
customElements.define('hy-expandable', HYExpandable);
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=expandable.js.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface HYHistoryEntry {
|
|
2
|
+
readonly id: number;
|
|
3
|
+
readonly label: string;
|
|
4
|
+
}
|
|
5
|
+
export declare class HYHistoryControls extends HTMLElement {
|
|
6
|
+
private readonly _undo;
|
|
7
|
+
private readonly _redo;
|
|
8
|
+
private _canUndo;
|
|
9
|
+
private _canRedo;
|
|
10
|
+
private _undoLabel;
|
|
11
|
+
private _redoLabel;
|
|
12
|
+
private _busy;
|
|
13
|
+
private _entries;
|
|
14
|
+
private _connected;
|
|
15
|
+
private readonly _requestUndo;
|
|
16
|
+
private readonly _requestRedo;
|
|
17
|
+
static get observedAttributes(): string[];
|
|
18
|
+
constructor();
|
|
19
|
+
connectedCallback(): void;
|
|
20
|
+
disconnectedCallback(): void;
|
|
21
|
+
attributeChangedCallback(): void;
|
|
22
|
+
get canUndo(): boolean;
|
|
23
|
+
set canUndo(value: boolean);
|
|
24
|
+
get canRedo(): boolean;
|
|
25
|
+
set canRedo(value: boolean);
|
|
26
|
+
get undoLabel(): string;
|
|
27
|
+
set undoLabel(value: string);
|
|
28
|
+
get redoLabel(): string;
|
|
29
|
+
set redoLabel(value: string);
|
|
30
|
+
get busy(): boolean;
|
|
31
|
+
set busy(value: boolean);
|
|
32
|
+
get entries(): readonly HYHistoryEntry[];
|
|
33
|
+
set entries(value: readonly HYHistoryEntry[]);
|
|
34
|
+
private _syncAttributes;
|
|
35
|
+
private _render;
|
|
36
|
+
private _request;
|
|
37
|
+
private _reflectBoolean;
|
|
38
|
+
private _reflectString;
|
|
39
|
+
}
|
|
40
|
+
export declare function defineHistoryControlsComponents(): void;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
export class HYHistoryControls extends HTMLElement {
|
|
2
|
+
_undo = document.createElement('button');
|
|
3
|
+
_redo = document.createElement('button');
|
|
4
|
+
_canUndo = false;
|
|
5
|
+
_canRedo = false;
|
|
6
|
+
_undoLabel = '';
|
|
7
|
+
_redoLabel = '';
|
|
8
|
+
_busy = false;
|
|
9
|
+
_entries = Object.freeze([]);
|
|
10
|
+
_connected = false;
|
|
11
|
+
_requestUndo = () => this._request('undo-request');
|
|
12
|
+
_requestRedo = () => this._request('redo-request');
|
|
13
|
+
static get observedAttributes() {
|
|
14
|
+
return ['can-undo', 'can-redo', 'undo-label', 'redo-label', 'busy', 'locale'];
|
|
15
|
+
}
|
|
16
|
+
constructor() {
|
|
17
|
+
super();
|
|
18
|
+
const root = this.attachShadow({ mode: 'open' });
|
|
19
|
+
const style = document.createElement('style');
|
|
20
|
+
style.textContent = `
|
|
21
|
+
:host { display: inline-flex; }
|
|
22
|
+
[role="toolbar"] { display: inline-flex; gap: 2px; }
|
|
23
|
+
button {
|
|
24
|
+
width: 30px;
|
|
25
|
+
min-height: 28px;
|
|
26
|
+
border: 1px solid var(--hy-border-color, #3d4654);
|
|
27
|
+
background: var(--hy-surface-elevated-color, #202733);
|
|
28
|
+
color: var(--hy-text-color, #eef3ff);
|
|
29
|
+
font: 600 15px system-ui, sans-serif;
|
|
30
|
+
cursor: pointer;
|
|
31
|
+
}
|
|
32
|
+
button:first-child { border-radius: 4px 0 0 4px; }
|
|
33
|
+
button:last-child { border-radius: 0 4px 4px 0; }
|
|
34
|
+
button:hover:not(:disabled) { background: var(--hy-hover-bg-color, #273241); }
|
|
35
|
+
button:focus-visible { outline: 2px solid var(--hy-focus-border-color, #79a8ff); outline-offset: 1px; }
|
|
36
|
+
button:disabled { opacity: 0.45; cursor: default; }
|
|
37
|
+
`;
|
|
38
|
+
const toolbar = document.createElement('div');
|
|
39
|
+
toolbar.setAttribute('role', 'toolbar');
|
|
40
|
+
this._undo.type = 'button';
|
|
41
|
+
this._redo.type = 'button';
|
|
42
|
+
this._undo.textContent = '↶';
|
|
43
|
+
this._redo.textContent = '↷';
|
|
44
|
+
toolbar.append(this._undo, this._redo);
|
|
45
|
+
root.append(style, toolbar);
|
|
46
|
+
this._render();
|
|
47
|
+
}
|
|
48
|
+
connectedCallback() {
|
|
49
|
+
if (this._connected)
|
|
50
|
+
return;
|
|
51
|
+
this._connected = true;
|
|
52
|
+
this._undo.addEventListener('click', this._requestUndo);
|
|
53
|
+
this._redo.addEventListener('click', this._requestRedo);
|
|
54
|
+
this._syncAttributes();
|
|
55
|
+
}
|
|
56
|
+
disconnectedCallback() {
|
|
57
|
+
if (!this._connected)
|
|
58
|
+
return;
|
|
59
|
+
this._connected = false;
|
|
60
|
+
this._undo.removeEventListener('click', this._requestUndo);
|
|
61
|
+
this._redo.removeEventListener('click', this._requestRedo);
|
|
62
|
+
}
|
|
63
|
+
attributeChangedCallback() { this._syncAttributes(); }
|
|
64
|
+
get canUndo() { return this._canUndo; }
|
|
65
|
+
set canUndo(value) { this._canUndo = Boolean(value); this._reflectBoolean('can-undo', this._canUndo); this._render(); }
|
|
66
|
+
get canRedo() { return this._canRedo; }
|
|
67
|
+
set canRedo(value) { this._canRedo = Boolean(value); this._reflectBoolean('can-redo', this._canRedo); this._render(); }
|
|
68
|
+
get undoLabel() { return this._undoLabel; }
|
|
69
|
+
set undoLabel(value) { this._undoLabel = String(value); this._reflectString('undo-label', this._undoLabel); this._render(); }
|
|
70
|
+
get redoLabel() { return this._redoLabel; }
|
|
71
|
+
set redoLabel(value) { this._redoLabel = String(value); this._reflectString('redo-label', this._redoLabel); this._render(); }
|
|
72
|
+
get busy() { return this._busy; }
|
|
73
|
+
set busy(value) { this._busy = Boolean(value); this._reflectBoolean('busy', this._busy); this._render(); }
|
|
74
|
+
get entries() { return this._entries; }
|
|
75
|
+
set entries(value) {
|
|
76
|
+
this._entries = Object.freeze(value.map(entry => Object.freeze({ id: entry.id, label: entry.label })));
|
|
77
|
+
}
|
|
78
|
+
_syncAttributes() {
|
|
79
|
+
this._canUndo = this.hasAttribute('can-undo');
|
|
80
|
+
this._canRedo = this.hasAttribute('can-redo');
|
|
81
|
+
this._busy = this.hasAttribute('busy');
|
|
82
|
+
this._undoLabel = this.getAttribute('undo-label') ?? '';
|
|
83
|
+
this._redoLabel = this.getAttribute('redo-label') ?? '';
|
|
84
|
+
this._render();
|
|
85
|
+
}
|
|
86
|
+
_render() {
|
|
87
|
+
const chinese = (this.getAttribute('locale') ?? '').toLowerCase().startsWith('zh');
|
|
88
|
+
const undo = chinese ? '撤销' : 'Undo';
|
|
89
|
+
const redo = chinese ? '重做' : 'Redo';
|
|
90
|
+
const undoTitle = this._undoLabel ? `${undo}: ${this._undoLabel}` : undo;
|
|
91
|
+
const redoTitle = this._redoLabel ? `${redo}: ${this._redoLabel}` : redo;
|
|
92
|
+
this._undo.disabled = this._busy || !this._canUndo;
|
|
93
|
+
this._redo.disabled = this._busy || !this._canRedo;
|
|
94
|
+
this._undo.title = undoTitle;
|
|
95
|
+
this._redo.title = redoTitle;
|
|
96
|
+
this._undo.setAttribute('aria-label', undoTitle);
|
|
97
|
+
this._redo.setAttribute('aria-label', redoTitle);
|
|
98
|
+
this.setAttribute('aria-busy', String(this._busy));
|
|
99
|
+
}
|
|
100
|
+
_request(type) {
|
|
101
|
+
if (this._busy || (type === 'undo-request' ? !this._canUndo : !this._canRedo))
|
|
102
|
+
return;
|
|
103
|
+
this.dispatchEvent(new CustomEvent(type, { bubbles: true, composed: true }));
|
|
104
|
+
}
|
|
105
|
+
_reflectBoolean(name, value) {
|
|
106
|
+
if (value === this.hasAttribute(name))
|
|
107
|
+
return;
|
|
108
|
+
this.toggleAttribute(name, value);
|
|
109
|
+
}
|
|
110
|
+
_reflectString(name, value) {
|
|
111
|
+
if (this.getAttribute(name) === value)
|
|
112
|
+
return;
|
|
113
|
+
if (value)
|
|
114
|
+
this.setAttribute(name, value);
|
|
115
|
+
else
|
|
116
|
+
this.removeAttribute(name);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
export function defineHistoryControlsComponents() {
|
|
120
|
+
if (!customElements.get('hy-history-controls'))
|
|
121
|
+
customElements.define('hy-history-controls', HYHistoryControls);
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=history-controls.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,32 +1,37 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export
|
|
19
|
-
export
|
|
20
|
-
export type {
|
|
21
|
-
export
|
|
22
|
-
export type {
|
|
23
|
-
export
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
1
|
+
export { defineExpandableComponents, HYExpandable } from './expandable.js';
|
|
2
|
+
export type { HYExpandableButtonPosition, HYExpandableChangeDetail } from './expandable.js';
|
|
3
|
+
export { defineButtonComponents, HYButton, } from './button.js';
|
|
4
|
+
export { defineBorderBeamComponents, HYBorderBeam, } from './border-beam.js';
|
|
5
|
+
export { defineTreeComponents, HYTree, HYTreeNode, } from './tree.js';
|
|
6
|
+
export { defineSplitComponents, HYSplit, } from './split.js';
|
|
7
|
+
export { defineSelectComponents, HYSelect, } from './select.js';
|
|
8
|
+
export { defineTabsComponents, HYTabs, } from './tabs.js';
|
|
9
|
+
export { defineContextMenuComponents, HYContextMenu, } from './context-menu.js';
|
|
10
|
+
export { defineDropdownComponents, HYDropdown, } from './dropdown.js';
|
|
11
|
+
export { defineTooltipComponents, HYTooltip, } from './tooltip.js';
|
|
12
|
+
export { defineCheckboxComponents, HYCheckbox, } from './checkbox.js';
|
|
13
|
+
export { defineRadioComponents, HYRadio, } from './radio.js';
|
|
14
|
+
export { defineRangeComponents, HYRange, } from './range.js';
|
|
15
|
+
export { defineDialogComponents, HYDialog, } from './dialog.js';
|
|
16
|
+
export { defineDrawerComponents, HYDrawer, } from './drawer.js';
|
|
17
|
+
export { defineInputComponents, HYInput, } from './input.js';
|
|
18
|
+
export { defineNotificationComponents, HYNotification, } from './notification.js';
|
|
19
|
+
export { defineHistoryControlsComponents, HYHistoryControls, } from './history-controls.js';
|
|
20
|
+
export type { HYHistoryEntry, } from './history-controls.js';
|
|
21
|
+
export { calculateVirtualListRange, defineVirtualListComponents, HYVirtualList, } from './virtual-list.js';
|
|
22
|
+
export type { HYVirtualListAlign, HYVirtualListItemClickDetail, HYVirtualListItemRenderer, HYVirtualListRange, HYVirtualListRangeChangeDetail, } from './virtual-list.js';
|
|
23
|
+
export type { HYSplitDirection, HYSplitRatioChangeDetail, } from './split.js';
|
|
24
|
+
export type { HYSelectChangeDetail, HYSelectOption, } from './select.js';
|
|
25
|
+
export type { HYTabChangeDetail, HYTabOption, } from './tabs.js';
|
|
26
|
+
export type { HYContextMenuItem, HYContextMenuSelectDetail, } from './context-menu.js';
|
|
27
|
+
export type { HYDropdownItem, HYDropdownPlacement, HYDropdownSelectDetail, } from './dropdown.js';
|
|
28
|
+
export type { HYTooltipPlacement, } from './tooltip.js';
|
|
29
|
+
export type { HYCheckboxChangeDetail, } from './checkbox.js';
|
|
30
|
+
export type { HYRadioChangeDetail, } from './radio.js';
|
|
31
|
+
export type { HYRangeChangeDetail, HYRangeHandle, HYRangeValue, } from './range.js';
|
|
32
|
+
export type { HYDialogCloseDetail, HYDialogCloseReason, } from './dialog.js';
|
|
33
|
+
export type { HYDrawerCloseDetail, HYDrawerCloseReason, HYDrawerPlacement, } from './drawer.js';
|
|
34
|
+
export type { HYInputChangeDetail, HYInputType, } from './input.js';
|
|
35
|
+
export type { HYNotificationCloseDetail, HYNotificationCloseReason, HYNotificationMethodOptions, HYNotificationOpenDetail, HYNotificationOptions, HYNotificationPlacement, HYNotificationType, } from './notification.js';
|
|
36
|
+
export type { HYTreeDataChangeDetail, HYTreeDropPosition, HYTreeNodeContextMenuDetail, HYTreeNodeData, HYTreeSelectionChangeDetail, } from './tree.js';
|
|
32
37
|
export declare function defineHaiyueUI(): void;
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { defineExpandableComponents } from './expandable.js';
|
|
2
|
+
export { defineExpandableComponents, HYExpandable } from './expandable.js';
|
|
3
|
+
import { defineButtonComponents } from './button.js';
|
|
4
|
+
import { defineBorderBeamComponents } from './border-beam.js';
|
|
1
5
|
import { defineTreeComponents } from './tree.js';
|
|
2
6
|
import { defineSplitComponents } from './split.js';
|
|
3
7
|
import { defineSelectComponents } from './select.js';
|
|
@@ -7,94 +11,35 @@ import { defineDropdownComponents } from './dropdown.js';
|
|
|
7
11
|
import { defineTooltipComponents } from './tooltip.js';
|
|
8
12
|
import { defineCheckboxComponents } from './checkbox.js';
|
|
9
13
|
import { defineRadioComponents } from './radio.js';
|
|
14
|
+
import { defineRangeComponents } from './range.js';
|
|
10
15
|
import { defineDialogComponents } from './dialog.js';
|
|
16
|
+
import { defineDrawerComponents } from './drawer.js';
|
|
11
17
|
import { defineInputComponents } from './input.js';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export {
|
|
16
|
-
export {
|
|
17
|
-
export {
|
|
18
|
-
export {
|
|
19
|
-
export {
|
|
20
|
-
export {
|
|
21
|
-
export {
|
|
22
|
-
export {
|
|
23
|
-
export
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
style.textContent = `
|
|
34
|
-
:host { display: inline-block; }
|
|
35
|
-
button {
|
|
36
|
-
min-height: 28px;
|
|
37
|
-
padding: 0 10px;
|
|
38
|
-
border: 1px solid #3d4654;
|
|
39
|
-
border-radius: 4px;
|
|
40
|
-
background: #202733;
|
|
41
|
-
color: #eef3ff;
|
|
42
|
-
font: 12px system-ui, sans-serif;
|
|
43
|
-
cursor: pointer;
|
|
44
|
-
}
|
|
45
|
-
button.icon-only {
|
|
46
|
-
width: 28px;
|
|
47
|
-
padding: 0;
|
|
48
|
-
display: inline-grid;
|
|
49
|
-
place-items: center;
|
|
50
|
-
}
|
|
51
|
-
::slotted(svg) {
|
|
52
|
-
width: 16px;
|
|
53
|
-
height: 16px;
|
|
54
|
-
display: block;
|
|
55
|
-
fill: none;
|
|
56
|
-
stroke: currentColor;
|
|
57
|
-
stroke-width: 2;
|
|
58
|
-
stroke-linecap: round;
|
|
59
|
-
stroke-linejoin: round;
|
|
60
|
-
}
|
|
61
|
-
button:disabled {
|
|
62
|
-
opacity: 0.5;
|
|
63
|
-
cursor: default;
|
|
64
|
-
}
|
|
65
|
-
`;
|
|
66
|
-
root.append(style, this._button);
|
|
67
|
-
}
|
|
68
|
-
connectedCallback() {
|
|
69
|
-
this._sync();
|
|
70
|
-
}
|
|
71
|
-
attributeChangedCallback() {
|
|
72
|
-
this._sync();
|
|
73
|
-
}
|
|
74
|
-
_sync() {
|
|
75
|
-
const label = this.getAttribute('label');
|
|
76
|
-
if (label !== null) {
|
|
77
|
-
this._button.textContent = label;
|
|
78
|
-
this._button.classList.remove('icon-only');
|
|
79
|
-
this._button.removeAttribute('aria-label');
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
if (this._button.firstChild !== this._slot)
|
|
83
|
-
this._button.replaceChildren(this._slot);
|
|
84
|
-
this._button.classList.toggle('icon-only', this.hasAttribute('icon-only'));
|
|
85
|
-
const accessibleLabel = this.getAttribute('aria-label') ?? this.getAttribute('title') ?? '';
|
|
86
|
-
if (accessibleLabel)
|
|
87
|
-
this._button.setAttribute('aria-label', accessibleLabel);
|
|
88
|
-
else
|
|
89
|
-
this._button.removeAttribute('aria-label');
|
|
90
|
-
}
|
|
91
|
-
this._button.disabled = this.hasAttribute('disabled');
|
|
92
|
-
}
|
|
93
|
-
}
|
|
18
|
+
import { defineNotificationComponents } from './notification.js';
|
|
19
|
+
import { defineHistoryControlsComponents } from './history-controls.js';
|
|
20
|
+
import { defineVirtualListComponents } from './virtual-list.js';
|
|
21
|
+
export { defineButtonComponents, HYButton, } from './button.js';
|
|
22
|
+
export { defineBorderBeamComponents, HYBorderBeam, } from './border-beam.js';
|
|
23
|
+
export { defineTreeComponents, HYTree, HYTreeNode, } from './tree.js';
|
|
24
|
+
export { defineSplitComponents, HYSplit, } from './split.js';
|
|
25
|
+
export { defineSelectComponents, HYSelect, } from './select.js';
|
|
26
|
+
export { defineTabsComponents, HYTabs, } from './tabs.js';
|
|
27
|
+
export { defineContextMenuComponents, HYContextMenu, } from './context-menu.js';
|
|
28
|
+
export { defineDropdownComponents, HYDropdown, } from './dropdown.js';
|
|
29
|
+
export { defineTooltipComponents, HYTooltip, } from './tooltip.js';
|
|
30
|
+
export { defineCheckboxComponents, HYCheckbox, } from './checkbox.js';
|
|
31
|
+
export { defineRadioComponents, HYRadio, } from './radio.js';
|
|
32
|
+
export { defineRangeComponents, HYRange, } from './range.js';
|
|
33
|
+
export { defineDialogComponents, HYDialog, } from './dialog.js';
|
|
34
|
+
export { defineDrawerComponents, HYDrawer, } from './drawer.js';
|
|
35
|
+
export { defineInputComponents, HYInput, } from './input.js';
|
|
36
|
+
export { defineNotificationComponents, HYNotification, } from './notification.js';
|
|
37
|
+
export { defineHistoryControlsComponents, HYHistoryControls, } from './history-controls.js';
|
|
38
|
+
export { calculateVirtualListRange, defineVirtualListComponents, HYVirtualList, } from './virtual-list.js';
|
|
94
39
|
export function defineHaiyueUI() {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
40
|
+
defineExpandableComponents();
|
|
41
|
+
defineBorderBeamComponents();
|
|
42
|
+
defineButtonComponents();
|
|
98
43
|
defineTreeComponents();
|
|
99
44
|
defineSplitComponents();
|
|
100
45
|
defineSelectComponents();
|
|
@@ -104,7 +49,12 @@ export function defineHaiyueUI() {
|
|
|
104
49
|
defineTooltipComponents();
|
|
105
50
|
defineCheckboxComponents();
|
|
106
51
|
defineRadioComponents();
|
|
52
|
+
defineRangeComponents();
|
|
107
53
|
defineDialogComponents();
|
|
54
|
+
defineDrawerComponents();
|
|
108
55
|
defineInputComponents();
|
|
56
|
+
defineNotificationComponents();
|
|
57
|
+
defineHistoryControlsComponents();
|
|
58
|
+
defineVirtualListComponents();
|
|
109
59
|
}
|
|
110
60
|
//# sourceMappingURL=index.js.map
|
package/dist/input.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export type
|
|
2
|
-
export interface
|
|
1
|
+
export type HYInputType = 'text' | 'number' | 'color';
|
|
2
|
+
export interface HYInputChangeDetail {
|
|
3
3
|
value: string;
|
|
4
4
|
valueAsNumber: number | null;
|
|
5
5
|
valid: boolean;
|
|
6
6
|
}
|
|
7
|
-
export declare class
|
|
7
|
+
export declare class HYInput extends HTMLElement {
|
|
8
8
|
private readonly _input;
|
|
9
9
|
static get observedAttributes(): string[];
|
|
10
10
|
constructor();
|
|
11
11
|
connectedCallback(): void;
|
|
12
12
|
disconnectedCallback(): void;
|
|
13
13
|
attributeChangedCallback(): void;
|
|
14
|
-
get type():
|
|
15
|
-
set type(value:
|
|
14
|
+
get type(): HYInputType;
|
|
15
|
+
set type(value: HYInputType);
|
|
16
16
|
get value(): string;
|
|
17
17
|
set value(value: string);
|
|
18
18
|
get valueAsNumber(): number;
|