@haiyue/ui 0.2.2 → 0.3.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/CHANGELOG.md +30 -0
- package/README.md +506 -2
- package/dist/adapters/web/renderer.js +1 -8
- 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 +60 -0
- package/dist/anchor.js +274 -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 +1 -1
- 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 +12 -12
- 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 -3
- package/dist/date-picker.js +13 -13
- package/dist/descriptions.d.ts +44 -0
- package/dist/descriptions.js +169 -0
- package/dist/dialog.js +11 -11
- package/dist/divider.js +2 -2
- package/dist/draggable.js +1 -1
- package/dist/drawer.js +12 -12
- package/dist/dropdown.js +3 -3
- 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 +29 -15
- package/dist/internal/anchored-popup.d.ts +19 -0
- package/dist/internal/anchored-popup.js +89 -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/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 +10 -10
- package/dist/notification.js +9 -9
- 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/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 +4 -4
- 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 +0 -2
- package/dist/table.js +46 -87
- package/dist/tabs.js +7 -7
- package/dist/tag.js +8 -8
- package/dist/time-picker.js +10 -10
- package/dist/timeline.js +12 -12
- package/dist/toast.js +9 -9
- package/dist/tooltip.js +4 -4
- package/dist/tour.js +11 -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.js +6 -5
- package/dist/upload.d.ts +107 -0
- package/dist/upload.js +353 -0
- package/dist/virtual-keyboard.js +5 -5
- package/dist/virtual-list.js +4 -4
- package/dist/virtual-mouse.js +5 -5
- package/package.json +82 -1
- package/themes/haiyue-dark.css +51 -0
- package/themes/haiyue-light.css +51 -0
package/dist/menu.js
ADDED
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import { HYAnchoredPopup } from './internal/anchored-popup.js';
|
|
2
|
+
let menuId = 0;
|
|
3
|
+
export class HYMenu extends HTMLElement {
|
|
4
|
+
_menu = document.createElement('ul');
|
|
5
|
+
_id = `hy-menu-${++menuId}`;
|
|
6
|
+
_items = [];
|
|
7
|
+
_entries = new Map();
|
|
8
|
+
_popups = [];
|
|
9
|
+
_pendingPopups = [];
|
|
10
|
+
_listeners = null;
|
|
11
|
+
_active = '';
|
|
12
|
+
_typeahead = '';
|
|
13
|
+
_typeTimer = null;
|
|
14
|
+
static get observedAttributes() { return ['items', 'mode', 'collapsed', 'disabled', 'multiple', 'selected-keys', 'open-keys', 'aria-label']; }
|
|
15
|
+
constructor() {
|
|
16
|
+
super();
|
|
17
|
+
const root = this.attachShadow({ mode: 'open' });
|
|
18
|
+
const style = document.createElement('style');
|
|
19
|
+
style.textContent = `
|
|
20
|
+
:host { display: block; width: var(--hy-menu-width, 220px); max-width: 100%; color: var(--hy-text-color, #d8e2f2); font: var(--hy-font-size-sm, 12px)/1.5 var(--hy-font-family, system-ui, sans-serif); }
|
|
21
|
+
:host([mode="horizontal"]) { width: auto; } :host([collapsed]) { width: var(--hy-menu-collapsed-width, 48px); }
|
|
22
|
+
ul { list-style: none; margin: 0; padding: var(--hy-space-2, 4px); box-sizing: border-box; background: var(--hy-menu-bg-color, var(--hy-surface-color, #121822)); }
|
|
23
|
+
.root { border: 1px solid var(--hy-border-color, #303746); border-radius: var(--hy-radius-sm, 4px); }
|
|
24
|
+
.root.horizontal { display: flex; flex-wrap: wrap; } li { margin: 0; padding: 0; }
|
|
25
|
+
.item { display: flex; align-items: center; gap: var(--hy-space-4, 8px); box-sizing: border-box; width: 100%; min-height: var(--hy-control-height-sm, 28px); padding: var(--hy-space-3, 6px) var(--hy-space-4, 8px); border: 0; border-radius: var(--hy-radius-sm, 4px); color: inherit; background: transparent; text-align: start; text-decoration: none; font: inherit; cursor: pointer; }
|
|
26
|
+
.item:hover:not([aria-disabled="true"]) { background: var(--hy-hover-bg-color, #273241); } .item.selected { color: var(--hy-selected-text-color, #fff); background: var(--hy-selected-bg-color, #255a91); }
|
|
27
|
+
.item:focus-visible { outline: 2px solid var(--hy-focus-border-color, #79a8ff); outline-offset: -2px; } .item[aria-disabled="true"] { color: var(--hy-disabled-text-color, #65738a); cursor: not-allowed; }
|
|
28
|
+
.label { flex: 1; min-width: 0; overflow-wrap: anywhere; } .icon { min-width: 16px; text-align: center; } .arrow { margin-inline-start: auto; }
|
|
29
|
+
.group { padding: var(--hy-space-3, 6px) var(--hy-space-4, 8px); color: var(--hy-muted-text-color, #8290a3); } .divider { margin: var(--hy-space-2, 4px) 0; border-top: 1px solid var(--hy-border-color, #303746); }
|
|
30
|
+
.submenu.inline { padding-inline-start: var(--hy-space-6, 12px); } .submenu.popup { position: fixed; inset: auto; margin: 0; min-width: var(--hy-menu-popup-width, 180px); max-width: calc(100vw - 16px); max-height: min(360px, calc(100dvh - 16px)); overflow: auto; border: 1px solid var(--hy-border-color, #303746); border-radius: var(--hy-radius-sm, 4px); color: var(--hy-text-color, #d8e2f2); font: inherit; box-shadow: var(--hy-popup-shadow, 0 8px 24px rgba(0,0,0,.24)); }
|
|
31
|
+
.horizontal > li > .item { width: auto; } :host([collapsed]) .root > li > .item .label, :host([collapsed]) .root > li > .item .arrow { display: none; }
|
|
32
|
+
[hidden] { display: none !important; }
|
|
33
|
+
`;
|
|
34
|
+
this._menu.className = 'root';
|
|
35
|
+
this._menu.part.add('menu');
|
|
36
|
+
root.append(style, this._menu);
|
|
37
|
+
}
|
|
38
|
+
connectedCallback() {
|
|
39
|
+
this._listeners?.abort();
|
|
40
|
+
this._listeners = new AbortController();
|
|
41
|
+
const { signal } = this._listeners;
|
|
42
|
+
this._menu.addEventListener('click', this._onClick, { signal });
|
|
43
|
+
this._menu.addEventListener('keydown', this._onKeydown, { signal });
|
|
44
|
+
this._menu.addEventListener('focusin', event => { const button = this._button(event); if (button) {
|
|
45
|
+
this._active = button.dataset.key;
|
|
46
|
+
this._syncTabStops();
|
|
47
|
+
} }, { signal });
|
|
48
|
+
this.ownerDocument.addEventListener('pointerdown', event => { if (!this._inline && !event.composedPath().includes(this) && this.openKeys.length)
|
|
49
|
+
this._setOpenKeys([], true); }, { capture: true, signal });
|
|
50
|
+
this._render();
|
|
51
|
+
}
|
|
52
|
+
disconnectedCallback() { this._listeners?.abort(); this._listeners = null; this._disposePopups(); if (this._typeTimer !== null)
|
|
53
|
+
clearTimeout(this._typeTimer); this._typeTimer = null; this._typeahead = ''; }
|
|
54
|
+
attributeChangedCallback(name, previous, next) { if (previous === next)
|
|
55
|
+
return; if (name === 'items') {
|
|
56
|
+
let items = [];
|
|
57
|
+
try {
|
|
58
|
+
items = JSON.parse(next ?? '[]');
|
|
59
|
+
}
|
|
60
|
+
catch { /* Empty invalid input. */ }
|
|
61
|
+
this._items = normalizeMenu(items);
|
|
62
|
+
} this._render(); }
|
|
63
|
+
get items() { return this._items.map(cloneMenuItem); }
|
|
64
|
+
set items(value) { this._items = normalizeMenu(value); this._render(); }
|
|
65
|
+
get mode() { const value = this.getAttribute('mode'); return value === 'vertical' || value === 'horizontal' ? value : 'inline'; }
|
|
66
|
+
set mode(value) { this.setAttribute('mode', value); }
|
|
67
|
+
get collapsed() { return this.hasAttribute('collapsed'); }
|
|
68
|
+
set collapsed(value) { this.toggleAttribute('collapsed', value); }
|
|
69
|
+
get disabled() { return this.hasAttribute('disabled'); }
|
|
70
|
+
set disabled(value) { this.toggleAttribute('disabled', value); }
|
|
71
|
+
get multiple() { return this.hasAttribute('multiple'); }
|
|
72
|
+
set multiple(value) { this.toggleAttribute('multiple', value); }
|
|
73
|
+
get selectedKeys() { const keys = readKeys(this.getAttribute('selected-keys')); return this.multiple ? keys : keys.slice(0, 1); }
|
|
74
|
+
set selectedKeys(value) { this.setAttribute('selected-keys', JSON.stringify(value)); }
|
|
75
|
+
get openKeys() { return readKeys(this.getAttribute('open-keys')); }
|
|
76
|
+
set openKeys(value) { this._setOpenKeys(value, false); }
|
|
77
|
+
focus(options) { (this._entries.get(this._active)?.button ?? this._allVisible()[0]?.button)?.focus(options); }
|
|
78
|
+
get _inline() { return this.mode === 'inline' && !this.collapsed; }
|
|
79
|
+
_disposePopups() { for (const popup of this._popups)
|
|
80
|
+
popup.dispose(); this._popups = []; }
|
|
81
|
+
_render() {
|
|
82
|
+
const focused = this.shadowRoot?.activeElement instanceof HTMLElement ? this.shadowRoot.activeElement.dataset.key : undefined;
|
|
83
|
+
this._disposePopups();
|
|
84
|
+
this._pendingPopups = [];
|
|
85
|
+
this._entries.clear();
|
|
86
|
+
this._menu.className = `root ${this.mode}`;
|
|
87
|
+
this._menu.setAttribute('role', this.mode === 'horizontal' ? 'menubar' : 'menu');
|
|
88
|
+
this._menu.setAttribute('aria-label', this.getAttribute('aria-label') || 'Menu');
|
|
89
|
+
this._menu.setAttribute('aria-orientation', this.mode === 'horizontal' ? 'horizontal' : 'vertical');
|
|
90
|
+
this._menu.replaceChildren(...this._build(this._items, this._menu, null, this.disabled));
|
|
91
|
+
for (const popup of this._pendingPopups.reverse()) {
|
|
92
|
+
popup.connect();
|
|
93
|
+
popup.show();
|
|
94
|
+
}
|
|
95
|
+
const visible = this._allVisible();
|
|
96
|
+
if (!visible.some(entry => entry.item.key === this._active))
|
|
97
|
+
this._active = visible.find(entry => this.selectedKeys.includes(entry.item.key))?.item.key ?? visible[0]?.item.key ?? '';
|
|
98
|
+
this._syncTabStops();
|
|
99
|
+
if (focused)
|
|
100
|
+
(visible.find(entry => entry.item.key === focused) ?? this._entries.get(this._active))?.button.focus({ preventScroll: true });
|
|
101
|
+
}
|
|
102
|
+
_build(items, list, parent, disabled) {
|
|
103
|
+
return items.map(item => {
|
|
104
|
+
const li = document.createElement('li');
|
|
105
|
+
li.setAttribute('role', 'none');
|
|
106
|
+
if (item.type === 'divider') {
|
|
107
|
+
li.className = 'divider';
|
|
108
|
+
li.setAttribute('role', 'separator');
|
|
109
|
+
return li;
|
|
110
|
+
}
|
|
111
|
+
if (item.type === 'group') {
|
|
112
|
+
const title = document.createElement('div');
|
|
113
|
+
title.className = 'group';
|
|
114
|
+
title.textContent = item.label ?? item.key;
|
|
115
|
+
const children = document.createElement('ul');
|
|
116
|
+
children.setAttribute('role', 'group');
|
|
117
|
+
children.setAttribute('aria-label', item.label ?? item.key);
|
|
118
|
+
children.append(...this._build(item.children ?? [], children, parent, disabled || Boolean(item.disabled)));
|
|
119
|
+
li.append(title, children);
|
|
120
|
+
return li;
|
|
121
|
+
}
|
|
122
|
+
const isDisabled = disabled || Boolean(item.disabled);
|
|
123
|
+
const hasChildren = Boolean(item.children?.length);
|
|
124
|
+
const href = !hasChildren ? safeHref(item.href, this.ownerDocument.baseURI) : null;
|
|
125
|
+
const button = href ? document.createElement('a') : document.createElement('button');
|
|
126
|
+
if (button instanceof HTMLAnchorElement)
|
|
127
|
+
button.href = href;
|
|
128
|
+
else {
|
|
129
|
+
button.type = 'button';
|
|
130
|
+
button.disabled = isDisabled;
|
|
131
|
+
}
|
|
132
|
+
button.className = 'item';
|
|
133
|
+
button.part.add('item');
|
|
134
|
+
button.dataset.key = item.key;
|
|
135
|
+
button.id = `${this._id}-${this._entries.size}`;
|
|
136
|
+
button.setAttribute('role', this.multiple && !hasChildren ? 'menuitemcheckbox' : 'menuitem');
|
|
137
|
+
button.setAttribute('aria-disabled', String(isDisabled));
|
|
138
|
+
button.setAttribute('aria-label', item.label ?? item.key);
|
|
139
|
+
button.tabIndex = -1;
|
|
140
|
+
const selected = this.selectedKeys.includes(item.key);
|
|
141
|
+
button.classList.toggle('selected', selected);
|
|
142
|
+
if (this.multiple && !hasChildren)
|
|
143
|
+
button.setAttribute('aria-checked', String(selected));
|
|
144
|
+
else if (selected)
|
|
145
|
+
button.setAttribute('aria-current', 'page');
|
|
146
|
+
const icon = document.createElement('span');
|
|
147
|
+
icon.className = 'icon';
|
|
148
|
+
icon.setAttribute('aria-hidden', 'true');
|
|
149
|
+
icon.textContent = item.icon ?? (this.collapsed && parent === null ? (item.label ?? item.key).slice(0, 1) : '');
|
|
150
|
+
icon.hidden = !icon.textContent;
|
|
151
|
+
const label = document.createElement('span');
|
|
152
|
+
label.className = 'label';
|
|
153
|
+
label.textContent = item.label ?? item.key;
|
|
154
|
+
button.append(icon, label);
|
|
155
|
+
li.append(button);
|
|
156
|
+
this._entries.set(item.key, { item, parent, disabled: isDisabled, button, list });
|
|
157
|
+
if (hasChildren) {
|
|
158
|
+
const arrow = document.createElement('span');
|
|
159
|
+
arrow.className = 'arrow';
|
|
160
|
+
arrow.textContent = this._inline ? '⌄' : '›';
|
|
161
|
+
arrow.setAttribute('aria-hidden', 'true');
|
|
162
|
+
button.append(arrow);
|
|
163
|
+
const children = document.createElement('ul');
|
|
164
|
+
children.className = `submenu ${this._inline ? 'inline' : 'popup'}`;
|
|
165
|
+
children.part.add('submenu');
|
|
166
|
+
children.id = `${button.id}-children`;
|
|
167
|
+
children.setAttribute('role', 'menu');
|
|
168
|
+
children.setAttribute('aria-label', item.label ?? item.key);
|
|
169
|
+
button.setAttribute('aria-controls', children.id);
|
|
170
|
+
button.setAttribute('aria-haspopup', 'menu');
|
|
171
|
+
const open = this.openKeys.includes(item.key) && !isDisabled && this._ancestorsOpen(parent);
|
|
172
|
+
button.setAttribute('aria-expanded', String(open));
|
|
173
|
+
children.append(...this._build(item.children, children, item.key, isDisabled));
|
|
174
|
+
li.append(children);
|
|
175
|
+
if (this._inline)
|
|
176
|
+
children.hidden = !open;
|
|
177
|
+
else {
|
|
178
|
+
const popup = new HYAnchoredPopup(this, button, children, () => this._setOpenKeys([], true), this.mode === 'horizontal' && parent === null ? 'bottom' : 'right');
|
|
179
|
+
this._popups.push(popup);
|
|
180
|
+
if (open && this.isConnected)
|
|
181
|
+
this._pendingPopups.push(popup);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return li;
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
_ancestorsOpen(key) { while (key) {
|
|
188
|
+
if (!this.openKeys.includes(key))
|
|
189
|
+
return false;
|
|
190
|
+
key = this._entries.get(key)?.parent ?? null;
|
|
191
|
+
} return true; }
|
|
192
|
+
_allVisible() { return [...this._entries.values()].filter(entry => !entry.disabled && this._ancestorsOpen(entry.parent)); }
|
|
193
|
+
_syncTabStops() { for (const entry of this._entries.values())
|
|
194
|
+
entry.button.tabIndex = !entry.disabled && entry.item.key === this._active && this._ancestorsOpen(entry.parent) ? 0 : -1; }
|
|
195
|
+
_setOpenKeys(keys, user) { const next = [...new Set(keys.filter(key => typeof key === 'string'))]; if (JSON.stringify(next) === JSON.stringify(this.openKeys))
|
|
196
|
+
return; this.setAttribute('open-keys', JSON.stringify(next)); if (user)
|
|
197
|
+
this.dispatchEvent(new CustomEvent('open-change', { detail: { openKeys: this.openKeys }, bubbles: true, composed: true })); }
|
|
198
|
+
_toggle(key, force) {
|
|
199
|
+
const entry = this._entries.get(key);
|
|
200
|
+
if (!entry || entry.disabled || !entry.item.children?.length)
|
|
201
|
+
return;
|
|
202
|
+
const open = force ?? !this.openKeys.includes(key);
|
|
203
|
+
let keys = this.openKeys;
|
|
204
|
+
if (open) {
|
|
205
|
+
if (!this._inline)
|
|
206
|
+
keys = keys.filter(value => this._entries.get(value)?.parent !== entry.parent);
|
|
207
|
+
keys.push(key);
|
|
208
|
+
}
|
|
209
|
+
else
|
|
210
|
+
keys = keys.filter(value => { let current = value; while (current) {
|
|
211
|
+
if (current === key)
|
|
212
|
+
return false;
|
|
213
|
+
current = this._entries.get(current)?.parent ?? null;
|
|
214
|
+
} return true; });
|
|
215
|
+
this._setOpenKeys(keys, true);
|
|
216
|
+
}
|
|
217
|
+
_button(event) { return event.target instanceof Element ? event.target.closest('.item[data-key]') : null; }
|
|
218
|
+
_onClick = (event) => {
|
|
219
|
+
const button = this._button(event);
|
|
220
|
+
if (!button)
|
|
221
|
+
return;
|
|
222
|
+
const entry = this._entries.get(button.dataset.key);
|
|
223
|
+
if (!entry)
|
|
224
|
+
return;
|
|
225
|
+
if (entry.disabled) {
|
|
226
|
+
event.preventDefault();
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
this._active = entry.item.key;
|
|
230
|
+
if (entry.item.children?.length) {
|
|
231
|
+
event.preventDefault();
|
|
232
|
+
this._toggle(entry.item.key);
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
const selected = this.multiple ? this.selectedKeys.includes(entry.item.key) ? this.selectedKeys.filter(key => key !== entry.item.key) : [...this.selectedKeys, entry.item.key] : [entry.item.key];
|
|
236
|
+
if (!this.dispatchEvent(new CustomEvent('menu-select', { detail: { key: entry.item.key, item: cloneMenuItem(entry.item), selectedKeys: selected }, bubbles: true, composed: true, cancelable: true }))) {
|
|
237
|
+
event.preventDefault();
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
let root = entry;
|
|
241
|
+
while (root.parent)
|
|
242
|
+
root = this._entries.get(root.parent) ?? root;
|
|
243
|
+
const returnKey = root.item.key;
|
|
244
|
+
this.selectedKeys = selected;
|
|
245
|
+
if (!this._inline) {
|
|
246
|
+
this._setOpenKeys([], true);
|
|
247
|
+
this._entries.get(returnKey)?.button.focus({ preventScroll: true });
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
_onKeydown = (event) => {
|
|
251
|
+
const button = this._button(event);
|
|
252
|
+
const entry = button ? this._entries.get(button.dataset.key) : undefined;
|
|
253
|
+
if (!entry || entry.disabled || event.isComposing)
|
|
254
|
+
return;
|
|
255
|
+
if (event.key === ' ' && button instanceof HTMLAnchorElement) {
|
|
256
|
+
event.preventDefault();
|
|
257
|
+
button.click();
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
const rootHorizontal = this.mode === 'horizontal' && entry.parent === null;
|
|
261
|
+
const forward = getComputedStyle(this).direction === 'rtl' ? 'ArrowLeft' : 'ArrowRight';
|
|
262
|
+
const backward = forward === 'ArrowLeft' ? 'ArrowRight' : 'ArrowLeft';
|
|
263
|
+
const siblings = this._allVisible().filter(item => item.list === entry.list);
|
|
264
|
+
const index = siblings.indexOf(entry);
|
|
265
|
+
let target;
|
|
266
|
+
if (event.key === 'Home')
|
|
267
|
+
target = siblings[0];
|
|
268
|
+
else if (event.key === 'End')
|
|
269
|
+
target = siblings.at(-1);
|
|
270
|
+
else if (event.key === (rootHorizontal ? forward : 'ArrowDown'))
|
|
271
|
+
target = siblings[(index + 1) % siblings.length];
|
|
272
|
+
else if (event.key === (rootHorizontal ? backward : 'ArrowUp'))
|
|
273
|
+
target = siblings[(index - 1 + siblings.length) % siblings.length];
|
|
274
|
+
else if (event.key === (rootHorizontal ? 'ArrowDown' : 'ArrowRight') && entry.item.children?.length) {
|
|
275
|
+
event.preventDefault();
|
|
276
|
+
this._toggle(entry.item.key, true);
|
|
277
|
+
target = this._allVisible().find(item => item.parent === entry.item.key);
|
|
278
|
+
}
|
|
279
|
+
else if ((event.key === 'ArrowLeft' || event.key === 'Escape') && entry.parent) {
|
|
280
|
+
event.preventDefault();
|
|
281
|
+
event.stopPropagation();
|
|
282
|
+
const parent = entry.parent;
|
|
283
|
+
this._toggle(parent, false);
|
|
284
|
+
target = this._entries.get(parent);
|
|
285
|
+
}
|
|
286
|
+
else if (event.key === 'Escape' && this.openKeys.length) {
|
|
287
|
+
event.preventDefault();
|
|
288
|
+
event.stopPropagation();
|
|
289
|
+
this._setOpenKeys([], true);
|
|
290
|
+
target = this._entries.get(entry.item.key);
|
|
291
|
+
}
|
|
292
|
+
else if (event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey && event.key !== ' ') {
|
|
293
|
+
this._typeahead += event.key.toLocaleLowerCase();
|
|
294
|
+
if (this._typeTimer !== null)
|
|
295
|
+
clearTimeout(this._typeTimer);
|
|
296
|
+
this._typeTimer = setTimeout(() => { this._typeahead = ''; this._typeTimer = null; }, 500);
|
|
297
|
+
target = [...siblings.slice(index + 1), ...siblings.slice(0, index + 1)].find(item => (item.item.label ?? item.item.key).toLocaleLowerCase().startsWith(this._typeahead));
|
|
298
|
+
}
|
|
299
|
+
if (target) {
|
|
300
|
+
event.preventDefault();
|
|
301
|
+
this._active = target.item.key;
|
|
302
|
+
this._syncTabStops();
|
|
303
|
+
target.button.focus();
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
function readKeys(raw) { try {
|
|
308
|
+
const value = JSON.parse(raw ?? '[]');
|
|
309
|
+
return Array.isArray(value) ? [...new Set(value.filter((key) => typeof key === 'string'))] : [];
|
|
310
|
+
}
|
|
311
|
+
catch {
|
|
312
|
+
return [];
|
|
313
|
+
} }
|
|
314
|
+
function cloneMenuItem(item) { return { ...item, ...(item.children ? { children: item.children.map(cloneMenuItem) } : {}) }; }
|
|
315
|
+
function normalizeMenu(value) {
|
|
316
|
+
const keys = new Set();
|
|
317
|
+
const visiting = new Set();
|
|
318
|
+
const visit = (items, depth) => !Array.isArray(items) || depth > 64 ? [] : items.flatMap(item => {
|
|
319
|
+
if (!item || typeof item !== 'object' || typeof item.key !== 'string' || !item.key || keys.has(item.key) || visiting.has(item))
|
|
320
|
+
return [];
|
|
321
|
+
keys.add(item.key);
|
|
322
|
+
visiting.add(item);
|
|
323
|
+
const children = visit(item.children, depth + 1);
|
|
324
|
+
visiting.delete(item);
|
|
325
|
+
return [{ key: item.key, ...(typeof item.label === 'string' ? { label: item.label } : {}), ...(typeof item.icon === 'string' ? { icon: item.icon } : {}), ...(typeof item.href === 'string' ? { href: item.href } : {}), ...(item.disabled ? { disabled: true } : {}), ...(item.type === 'group' || item.type === 'divider' ? { type: item.type } : {}), ...(children.length ? { children } : {}) }];
|
|
326
|
+
});
|
|
327
|
+
return visit(value, 0);
|
|
328
|
+
}
|
|
329
|
+
function safeHref(value, base) { if (!value)
|
|
330
|
+
return null; try {
|
|
331
|
+
const url = new URL(value, base);
|
|
332
|
+
return ['http:', 'https:', 'mailto:', 'tel:'].includes(url.protocol) ? value : null;
|
|
333
|
+
}
|
|
334
|
+
catch {
|
|
335
|
+
return null;
|
|
336
|
+
} }
|
|
337
|
+
export function defineMenuComponents() { if (!customElements.get('hy-menu'))
|
|
338
|
+
customElements.define('hy-menu', HYMenu); }
|
|
339
|
+
//# sourceMappingURL=menu.js.map
|
package/dist/modal.js
CHANGED
|
@@ -59,22 +59,22 @@ export class HYModal extends HTMLElement {
|
|
|
59
59
|
const root = this.attachShadow({ mode: 'open' });
|
|
60
60
|
const style = document.createElement('style');
|
|
61
61
|
style.textContent = `
|
|
62
|
-
:host { color: var(--hy-text-color, #eef0ff); font:
|
|
63
|
-
dialog { box-sizing: border-box; flex-direction: column; width: min(var(--_hy-modal-width, var(--hy-modal-width, 520px)), calc(100vw - 32px)); max-width: calc(100vw - 32px); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); margin: auto; padding: 0; overflow: hidden; border: 1px solid var(--hy-border-color, #343765); border-radius: var(--hy-modal-radius, 12px); color: inherit; background: var(--hy-modal-bg-color, var(--hy-surface-elevated-color, #181a40)); box-shadow: 0 24px 80px var(--hy-modal-shadow-color, rgba(0,0,0,.45)); }
|
|
62
|
+
:host { color: var(--hy-text-color, #eef0ff); font: calc(var(--hy-font-size-sm, 12px) + 1px)/var(--hy-line-height-relaxed, 1.5) var(--hy-font-family, system-ui, sans-serif); }
|
|
63
|
+
dialog { box-sizing: border-box; flex-direction: column; width: min(var(--_hy-modal-width, var(--hy-modal-width, 520px)), calc(100vw - 32px)); max-width: calc(100vw - 32px); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); margin: auto; padding: 0; overflow: hidden; border: 1px solid var(--hy-border-color, #343765); border-radius: var(--hy-modal-radius, var(--hy-radius-xl, 12px)); color: inherit; background: var(--hy-modal-bg-color, var(--hy-surface-elevated-color, #181a40)); box-shadow: 0 24px 80px var(--hy-modal-shadow-color, var(--hy-dialog-shadow-color, rgba(0,0,0,.45))); }
|
|
64
64
|
dialog:not([open]), [hidden] { display: none !important; }
|
|
65
65
|
dialog[open] { display: flex; animation: hy-modal-enter var(--hy-modal-duration, 160ms) ease-out; }
|
|
66
66
|
dialog::backdrop { background: var(--hy-modal-mask-color, var(--hy-dialog-backdrop-color, rgba(3,7,12,.66))); backdrop-filter: blur(var(--hy-modal-mask-blur, 2px)); }
|
|
67
|
-
:host([centered="false"]) dialog { margin: min(64px, 10vh) auto auto; max-height: calc(100vh - 96px); max-height: calc(100dvh - 96px); }
|
|
68
|
-
.header { display: flex; flex: 0 0 auto; align-items: center; gap: 12px; min-height: 56px; padding: 12px 16px 12px 20px; box-sizing: border-box; border-bottom: 1px solid var(--hy-border-color, #343765); }
|
|
69
|
-
h2 { flex: 1; min-width: 0; margin: 0; font-size: 16px; font-weight:
|
|
70
|
-
.body { flex: 1 1 auto; min-height: 0; padding: var(--hy-modal-body-padding, 20px); overflow: auto; color: var(--hy-secondary-text-color, #a9add4); }
|
|
71
|
-
.footer { flex: 0 0 auto; padding: 12px 20px; border-top: 1px solid var(--hy-border-color, #343765); background: var(--hy-modal-footer-bg-color, var(--hy-surface-color, #10132f)); }
|
|
72
|
-
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
|
|
73
|
-
button { box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 32px; padding: 6px 14px; border: 1px solid var(--hy-border-strong-color, #484b84); border-radius: var(--hy-modal-button-radius, 6px); color: var(--hy-text-color, #eef0ff); background: var(--hy-surface-elevated-color, #181a40); font: inherit; cursor: pointer; }
|
|
67
|
+
:host([centered="false"]) dialog { margin: min(var(--hy-space-32, 64px), 10vh) auto auto; max-height: calc(100vh - 96px); max-height: calc(100dvh - 96px); }
|
|
68
|
+
.header { display: flex; flex: 0 0 auto; align-items: center; gap: var(--hy-space-6, 12px); min-height: 56px; padding: var(--hy-space-6, 12px) var(--hy-space-8, 16px) var(--hy-space-6, 12px) var(--hy-space-10, 20px); box-sizing: border-box; border-bottom: 1px solid var(--hy-border-color, #343765); }
|
|
69
|
+
h2 { flex: 1; min-width: 0; margin: 0; font-size: var(--hy-font-size-lg, 16px); font-weight: calc(var(--hy-font-weight-semibold, 600) + 50); overflow-wrap: anywhere; }
|
|
70
|
+
.body { flex: 1 1 auto; min-height: 0; padding: var(--hy-modal-body-padding, var(--hy-space-10, 20px)); overflow: auto; color: var(--hy-secondary-text-color, #a9add4); }
|
|
71
|
+
.footer { flex: 0 0 auto; padding: var(--hy-space-6, 12px) var(--hy-space-10, 20px); border-top: 1px solid var(--hy-border-color, #343765); background: var(--hy-modal-footer-bg-color, var(--hy-surface-color, #10132f)); }
|
|
72
|
+
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--hy-space-4, 8px); }
|
|
73
|
+
button { box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; gap: var(--hy-space-4, 8px); min-height: 32px; padding: var(--hy-space-3, 6px) var(--hy-space-7, 14px); border: 1px solid var(--hy-border-strong-color, #484b84); border-radius: var(--hy-modal-button-radius, var(--hy-radius-md, 6px)); color: var(--hy-text-color, #eef0ff); background: var(--hy-surface-elevated-color, #181a40); font: inherit; cursor: pointer; }
|
|
74
74
|
button:hover:not(:disabled) { background: var(--hy-hover-bg-color, #242752); }
|
|
75
75
|
button:disabled { opacity: .5; cursor: default; }
|
|
76
76
|
button:focus-visible, dialog:focus-visible { outline: 2px solid var(--hy-focus-border-color, #9c8fff); outline-offset: -3px; }
|
|
77
|
-
.close { flex: 0 0 auto; width: 30px; height: 30px; min-height: 0; padding: 0; border: 0; background: transparent; color: var(--hy-secondary-text-color, #a9add4); font-size:
|
|
77
|
+
.close { flex: 0 0 auto; width: 30px; height: 30px; min-height: 0; padding: 0; border: 0; background: transparent; color: var(--hy-secondary-text-color, #a9add4); font-size: calc(var(--hy-font-size-xl, 20px) + 2px); }
|
|
78
78
|
.ok { border-color: transparent; color: var(--hy-selected-text-color, #fff); background: var(--hy-accent-strong-color, #554cc6); }
|
|
79
79
|
.ok:hover:not(:disabled) { background: var(--hy-accent-color, #8177f2); }
|
|
80
80
|
.spinner { width: 12px; height: 12px; border: 2px solid currentColor; border-inline-end-color: transparent; border-radius: 50%; animation: hy-modal-spin .7s linear infinite; }
|
package/dist/notification.js
CHANGED
|
@@ -23,7 +23,7 @@ const NOTIFICATION_STYLES = `
|
|
|
23
23
|
display: block;
|
|
24
24
|
pointer-events: none;
|
|
25
25
|
color: var(--hy-text-color, #e8effa);
|
|
26
|
-
font:
|
|
26
|
+
font: calc(var(--hy-font-size-sm, 12px) + 1px)/calc(var(--hy-line-height-snug, 1.4) + 0.05) var(--hy-font-family, system-ui, sans-serif);
|
|
27
27
|
}
|
|
28
28
|
.container {
|
|
29
29
|
position: fixed;
|
|
@@ -47,16 +47,16 @@ const NOTIFICATION_STYLES = `
|
|
|
47
47
|
inset: 0 0 auto;
|
|
48
48
|
display: grid;
|
|
49
49
|
grid-template-columns: 34px minmax(0, 1fr) 28px;
|
|
50
|
-
gap:
|
|
50
|
+
gap: calc(var(--hy-space-5, 10px) + 1px);
|
|
51
51
|
min-height: 82px;
|
|
52
|
-
padding:
|
|
52
|
+
padding: calc(var(--hy-space-7, 14px) + 1px) calc(var(--hy-space-6, 12px) + 1px) calc(var(--hy-space-7, 14px) + 1px) calc(var(--hy-space-7, 14px) + 1px);
|
|
53
53
|
overflow: hidden;
|
|
54
54
|
border: 1px solid color-mix(in srgb, var(--_tone) 30%, var(--hy-border-color, #303746));
|
|
55
|
-
border-radius: var(--hy-notification-radius,
|
|
55
|
+
border-radius: var(--hy-notification-radius, calc(var(--hy-radius-lg, 8px) + 1px));
|
|
56
56
|
pointer-events: auto;
|
|
57
57
|
color: var(--hy-text-color, #e8effa);
|
|
58
58
|
background: var(--hy-notification-bg-color, var(--hy-surface-elevated-color, #171e2a));
|
|
59
|
-
box-shadow: 0 14px 38px var(--hy-notification-shadow-color, rgba(0, 0, 0, 0.34));
|
|
59
|
+
box-shadow: 0 14px 38px var(--hy-notification-shadow-color, var(--hy-shadow-color, rgba(0, 0, 0, 0.34)));
|
|
60
60
|
transform: translate3d(0, calc(var(--_depth) * 10px), calc(var(--_depth) * -24px)) scale(calc(1 - var(--_depth) * 0.035));
|
|
61
61
|
transform-origin: top center;
|
|
62
62
|
transition: margin 180ms ease, opacity 160ms ease, transform 180ms cubic-bezier(0.22, 1, 0.36, 1);
|
|
@@ -99,20 +99,20 @@ const NOTIFICATION_STYLES = `
|
|
|
99
99
|
}
|
|
100
100
|
.icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2.2; }
|
|
101
101
|
.content { min-width: 0; padding-top: 1px; }
|
|
102
|
-
.message { margin: 0; color: inherit; font-size:
|
|
103
|
-
.description { margin: 4px 0 0; color: var(--hy-secondary-text-color, #9aa8ba); font-size:
|
|
102
|
+
.message { margin: 0; color: inherit; font-size: calc(var(--hy-font-size-sm, 12px) + 1px); font-weight: calc(var(--hy-font-weight-bold, 700) - 20); overflow-wrap: anywhere; }
|
|
103
|
+
.description { margin: var(--hy-space-2, 4px) 0 0; color: var(--hy-secondary-text-color, #9aa8ba); font-size: calc(var(--hy-font-size-xs, 10px) + 1px); overflow-wrap: anywhere; }
|
|
104
104
|
.close {
|
|
105
105
|
display: grid;
|
|
106
106
|
width: 26px;
|
|
107
107
|
height: 26px;
|
|
108
108
|
padding: 0;
|
|
109
109
|
border: 0;
|
|
110
|
-
border-radius:
|
|
110
|
+
border-radius: calc(var(--hy-radius-sm, 4px) + 1px);
|
|
111
111
|
place-items: center;
|
|
112
112
|
color: var(--hy-secondary-text-color, #8492a6);
|
|
113
113
|
background: transparent;
|
|
114
114
|
cursor: pointer;
|
|
115
|
-
font:
|
|
115
|
+
font: calc(var(--hy-font-size-lg, 16px) + 2px)/var(--hy-line-height-tight, 1) var(--hy-font-family, system-ui, sans-serif);
|
|
116
116
|
}
|
|
117
117
|
.close:hover { color: inherit; background: var(--hy-hover-bg-color, #242d3b); }
|
|
118
118
|
.close:focus-visible { outline: 2px solid var(--hy-focus-border-color, #79a8ff); outline-offset: 1px; }
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface HYPaginationChangeDetail {
|
|
2
|
+
page: number;
|
|
3
|
+
pageSize: number;
|
|
4
|
+
total: number;
|
|
5
|
+
source: 'page' | 'size' | 'jump';
|
|
6
|
+
}
|
|
7
|
+
export declare class HYPagination extends HTMLElement {
|
|
8
|
+
private readonly _controls;
|
|
9
|
+
private _reflecting;
|
|
10
|
+
static get observedAttributes(): string[];
|
|
11
|
+
constructor();
|
|
12
|
+
connectedCallback(): void;
|
|
13
|
+
attributeChangedCallback(): void;
|
|
14
|
+
get page(): number;
|
|
15
|
+
set page(value: number);
|
|
16
|
+
get pageSize(): number;
|
|
17
|
+
set pageSize(value: number);
|
|
18
|
+
get total(): number;
|
|
19
|
+
set total(value: number);
|
|
20
|
+
get pageCount(): number;
|
|
21
|
+
get disabled(): boolean;
|
|
22
|
+
set disabled(value: boolean);
|
|
23
|
+
get simple(): boolean;
|
|
24
|
+
set simple(value: boolean);
|
|
25
|
+
get showSizeChanger(): boolean;
|
|
26
|
+
set showSizeChanger(value: boolean);
|
|
27
|
+
get showQuickJumper(): boolean;
|
|
28
|
+
set showQuickJumper(value: boolean);
|
|
29
|
+
get pageSizeOptions(): number[];
|
|
30
|
+
set pageSizeOptions(value: number[]);
|
|
31
|
+
private _sync;
|
|
32
|
+
private _change;
|
|
33
|
+
}
|
|
34
|
+
export declare function definePaginationComponents(): void;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { HYPaginationControls, HY_PAGINATION_STYLES } from './internal/pagination.js';
|
|
2
|
+
export class HYPagination extends HTMLElement {
|
|
3
|
+
_controls = new HYPaginationControls((page, pageSize, source) => this._change(page, pageSize, source));
|
|
4
|
+
_reflecting = false;
|
|
5
|
+
static get observedAttributes() { return ['page', 'page-size', 'total', 'page-size-options', 'disabled', 'simple', 'show-size-changer', 'show-quick-jumper', 'show-total', 'hide-on-single-page', 'size', 'aria-label']; }
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
const root = this.attachShadow({ mode: 'open' });
|
|
9
|
+
const style = document.createElement('style');
|
|
10
|
+
style.textContent = `
|
|
11
|
+
:host { display: block; min-width: 0; color: var(--hy-text-color, #d8e2f2); font: var(--hy-font-size-sm, 12px)/1.5 var(--hy-font-family, system-ui, sans-serif); }
|
|
12
|
+
${HY_PAGINATION_STYLES}
|
|
13
|
+
:host([size="small"]) .pagination-controls :is(button,select,input) { min-height: 22px; padding: 0 5px; }
|
|
14
|
+
`;
|
|
15
|
+
root.append(style, this._controls.element);
|
|
16
|
+
}
|
|
17
|
+
connectedCallback() { this._sync(); }
|
|
18
|
+
attributeChangedCallback() { if (!this._reflecting)
|
|
19
|
+
this._sync(); }
|
|
20
|
+
get page() { return Math.min(this.pageCount, integer(this.getAttribute('page'), 1, 1)); }
|
|
21
|
+
set page(value) { this.setAttribute('page', String(value)); }
|
|
22
|
+
get pageSize() { return integer(this.getAttribute('page-size'), 10, 1); }
|
|
23
|
+
set pageSize(value) { this.setAttribute('page-size', String(value)); }
|
|
24
|
+
get total() { return integer(this.getAttribute('total'), 0, 0); }
|
|
25
|
+
set total(value) { this.setAttribute('total', String(value)); }
|
|
26
|
+
get pageCount() { return Math.max(1, Math.ceil(this.total / this.pageSize)); }
|
|
27
|
+
get disabled() { return this.hasAttribute('disabled'); }
|
|
28
|
+
set disabled(value) { this.toggleAttribute('disabled', value); }
|
|
29
|
+
get simple() { return this.hasAttribute('simple'); }
|
|
30
|
+
set simple(value) { this.toggleAttribute('simple', value); }
|
|
31
|
+
get showSizeChanger() { return this.hasAttribute('show-size-changer'); }
|
|
32
|
+
set showSizeChanger(value) { this.toggleAttribute('show-size-changer', value); }
|
|
33
|
+
get showQuickJumper() { return this.hasAttribute('show-quick-jumper'); }
|
|
34
|
+
set showQuickJumper(value) { this.toggleAttribute('show-quick-jumper', value); }
|
|
35
|
+
get pageSizeOptions() { const values = (this.getAttribute('page-size-options') ?? '10,20,50,100').replace(/[\[\]]/gu, '').split(',').map(Number).filter(value => Number.isSafeInteger(value) && value > 0); return [...new Set(values)].sort((a, b) => a - b); }
|
|
36
|
+
set pageSizeOptions(value) { this.setAttribute('page-size-options', value.join(',')); }
|
|
37
|
+
_sync() {
|
|
38
|
+
const page = this.page;
|
|
39
|
+
this._reflecting = true;
|
|
40
|
+
if (this.hasAttribute('page'))
|
|
41
|
+
this.setAttribute('page', String(page));
|
|
42
|
+
if (this.hasAttribute('page-size'))
|
|
43
|
+
this.setAttribute('page-size', String(this.pageSize));
|
|
44
|
+
this._reflecting = false;
|
|
45
|
+
this._controls.update({
|
|
46
|
+
page, pageSize: this.pageSize, total: this.total, pageSizeOptions: this.pageSizeOptions,
|
|
47
|
+
label: this.getAttribute('aria-label') || 'Pagination',
|
|
48
|
+
hidden: this.hasAttribute('hide-on-single-page') && this.pageCount === 1,
|
|
49
|
+
disabled: this.disabled, simple: this.simple, showTotal: this.getAttribute('show-total') !== 'false',
|
|
50
|
+
showSizeChanger: this.showSizeChanger, showQuickJumper: this.showQuickJumper,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
_change(page, size, source) {
|
|
54
|
+
if (this.disabled)
|
|
55
|
+
return;
|
|
56
|
+
size = integer(String(size), this.pageSize, 1);
|
|
57
|
+
page = Math.min(Math.max(1, integer(String(page), this.page, 1)), Math.max(1, Math.ceil(this.total / size)));
|
|
58
|
+
if (page === this.page && size === this.pageSize) {
|
|
59
|
+
this._sync();
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
this._reflecting = true;
|
|
63
|
+
this.setAttribute('page-size', String(size));
|
|
64
|
+
this.setAttribute('page', String(page));
|
|
65
|
+
this._reflecting = false;
|
|
66
|
+
this._sync();
|
|
67
|
+
this.dispatchEvent(new CustomEvent('page-change', { detail: { page, pageSize: size, total: this.total, source }, bubbles: true, composed: true }));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function integer(raw, fallback, min) { const value = raw === null ? NaN : Number(raw); return Number.isFinite(value) ? Math.max(min, Math.min(Number.MAX_SAFE_INTEGER, Math.floor(value))) : fallback; }
|
|
71
|
+
export function definePaginationComponents() { if (!customElements.get('hy-pagination'))
|
|
72
|
+
customElements.define('hy-pagination', HYPagination); }
|
|
73
|
+
//# sourceMappingURL=pagination.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { HYPopoverBase } from './internal/popover-base.js';
|
|
2
|
+
export type { HYPopconfirmActionDetail } from './internal/popover-base.js';
|
|
3
|
+
export declare class HYPopconfirm extends HYPopoverBase {
|
|
4
|
+
constructor();
|
|
5
|
+
}
|
|
6
|
+
export declare function definePopconfirmComponents(): void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { HYPopoverBase } from './internal/popover-base.js';
|
|
2
|
+
export class HYPopconfirm extends HYPopoverBase {
|
|
3
|
+
constructor() { super(true); }
|
|
4
|
+
}
|
|
5
|
+
export function definePopconfirmComponents() { if (!customElements.get('hy-popconfirm'))
|
|
6
|
+
customElements.define('hy-popconfirm', HYPopconfirm); }
|
|
7
|
+
//# sourceMappingURL=popconfirm.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { HYPopoverBase } from './internal/popover-base.js';
|
|
2
|
+
export type { HYPopoverPlacement, HYPopoverTrigger, HYPopoverCloseReason, HYPopoverOpenChangeDetail } from './internal/popover-base.js';
|
|
3
|
+
export declare class HYPopover extends HYPopoverBase {
|
|
4
|
+
constructor();
|
|
5
|
+
}
|
|
6
|
+
export declare function definePopoverComponents(): void;
|
package/dist/popover.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { HYPopoverBase } from './internal/popover-base.js';
|
|
2
|
+
export class HYPopover extends HYPopoverBase {
|
|
3
|
+
constructor() { super(false); }
|
|
4
|
+
}
|
|
5
|
+
export function definePopoverComponents() { if (!customElements.get('hy-popover'))
|
|
6
|
+
customElements.define('hy-popover', HYPopover); }
|
|
7
|
+
//# sourceMappingURL=popover.js.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export type HYProgressType = 'line' | 'circle';
|
|
2
|
+
export type HYProgressStatus = 'normal' | 'active' | 'success' | 'exception';
|
|
3
|
+
export declare class HYProgress extends HTMLElement {
|
|
4
|
+
private readonly _meter;
|
|
5
|
+
private readonly _line;
|
|
6
|
+
private readonly _fill;
|
|
7
|
+
private readonly _svg;
|
|
8
|
+
private readonly _circle;
|
|
9
|
+
private readonly _info;
|
|
10
|
+
static get observedAttributes(): string[];
|
|
11
|
+
constructor();
|
|
12
|
+
connectedCallback(): void;
|
|
13
|
+
attributeChangedCallback(): void;
|
|
14
|
+
get percent(): number;
|
|
15
|
+
set percent(value: number);
|
|
16
|
+
get type(): HYProgressType;
|
|
17
|
+
set type(value: HYProgressType);
|
|
18
|
+
get status(): HYProgressStatus;
|
|
19
|
+
set status(value: HYProgressStatus);
|
|
20
|
+
get indeterminate(): boolean;
|
|
21
|
+
set indeterminate(value: boolean);
|
|
22
|
+
get showInfo(): boolean;
|
|
23
|
+
set showInfo(value: boolean);
|
|
24
|
+
get strokeWidth(): number;
|
|
25
|
+
set strokeWidth(value: number);
|
|
26
|
+
get size(): number;
|
|
27
|
+
set size(value: number);
|
|
28
|
+
private _sync;
|
|
29
|
+
}
|
|
30
|
+
export declare function defineProgressComponents(): void;
|