@haiyue/ui 0.2.1 → 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 +46 -0
- package/LICENSE +27 -0
- package/README.md +707 -5
- package/dist/adapters/web/controls.js +28 -5
- package/dist/adapters/web/renderer.js +11 -10
- package/dist/adapters/web/styles.d.ts +2 -3
- package/dist/adapters/web/styles.js +42 -18
- 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.d.ts +92 -0
- package/dist/carousel.js +509 -0
- package/dist/cascader.js +12 -12
- package/dist/checkbox.d.ts +12 -0
- package/dist/checkbox.js +22 -6
- package/dist/collapse.d.ts +13 -0
- package/dist/collapse.js +100 -13
- package/dist/context-menu.js +3 -3
- package/dist/core/types.d.ts +22 -3
- package/dist/core/validation.js +9 -4
- 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 +56 -0
- package/dist/index.js +84 -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/internal/qrcodegen.d.ts +94 -0
- package/dist/internal/qrcodegen.js +856 -0
- package/dist/masonry.d.ts +36 -0
- package/dist/masonry.js +171 -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.d.ts +73 -0
- package/dist/modal.js +361 -0
- 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/portable/icons.d.ts +5 -0
- package/dist/portable/icons.js +24 -0
- package/dist/portable/index.d.ts +3 -0
- package/dist/portable/index.js +2 -0
- package/dist/portable/responsive.d.ts +20 -0
- package/dist/portable/responsive.js +15 -0
- package/dist/portable/theme.d.ts +6 -1
- package/dist/portable/theme.js +23 -3
- package/dist/progress.d.ts +30 -0
- package/dist/progress.js +102 -0
- package/dist/qr-code.d.ts +62 -0
- package/dist/qr-code.js +224 -0
- 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 +99 -1
- package/themes/haiyue-dark.css +51 -0
- package/themes/haiyue-light.css +51 -0
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
let panelId = 0;
|
|
2
|
+
function deepestActive(document) {
|
|
3
|
+
let active = document.activeElement;
|
|
4
|
+
while (active?.shadowRoot?.activeElement)
|
|
5
|
+
active = active.shadowRoot.activeElement;
|
|
6
|
+
return active instanceof HTMLElement ? active : null;
|
|
7
|
+
}
|
|
8
|
+
function composedContains(container, node) {
|
|
9
|
+
while (node) {
|
|
10
|
+
if (node === container)
|
|
11
|
+
return true;
|
|
12
|
+
node = node instanceof Element && node.assignedSlot ? node.assignedSlot : node.parentNode ?? (node instanceof ShadowRoot ? node.host : null);
|
|
13
|
+
}
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
function firstFocusable(root) {
|
|
17
|
+
for (const element of root.children) {
|
|
18
|
+
if (element instanceof HTMLElement && (element.hidden || element.inert || element.matches(':disabled')))
|
|
19
|
+
continue;
|
|
20
|
+
if (element instanceof HTMLSlotElement) {
|
|
21
|
+
for (const assigned of element.assignedElements({ flatten: true })) {
|
|
22
|
+
if (assigned instanceof HTMLElement && assigned.tabIndex >= 0 && !assigned.matches(':disabled'))
|
|
23
|
+
return assigned;
|
|
24
|
+
const found = firstFocusable(assigned.shadowRoot ?? assigned);
|
|
25
|
+
if (found)
|
|
26
|
+
return found;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (element instanceof HTMLElement && element.tabIndex >= 0 && element.getClientRects().length)
|
|
30
|
+
return element;
|
|
31
|
+
const found = firstFocusable(element.shadowRoot ?? element);
|
|
32
|
+
if (found)
|
|
33
|
+
return found;
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
/** Shared implementation for two isolated public entries; importing never registers elements. */
|
|
38
|
+
export class HYPopoverBase extends HTMLElement {
|
|
39
|
+
_confirmation;
|
|
40
|
+
_triggerSlot = document.createElement('slot');
|
|
41
|
+
_panel = document.createElement('div');
|
|
42
|
+
_headingSlot = document.createElement('slot');
|
|
43
|
+
_headingText = document.createElement('span');
|
|
44
|
+
_contentSlot = document.createElement('slot');
|
|
45
|
+
_description = document.createElement('p');
|
|
46
|
+
_footer = document.createElement('div');
|
|
47
|
+
_cancel = document.createElement('button');
|
|
48
|
+
_confirm = document.createElement('button');
|
|
49
|
+
_panelId = `hy-popover-${++panelId}`;
|
|
50
|
+
_listeners = null;
|
|
51
|
+
_observer = null;
|
|
52
|
+
_timer = null;
|
|
53
|
+
_focusTimer = null;
|
|
54
|
+
_shown = false;
|
|
55
|
+
_restoringFocus = false;
|
|
56
|
+
_focusInside = false;
|
|
57
|
+
_reflecting = false;
|
|
58
|
+
_returnFocus = null;
|
|
59
|
+
_reason = 'api';
|
|
60
|
+
_triggerAttributes = new Map();
|
|
61
|
+
static get observedAttributes() { return ['open', 'disabled', 'trigger', 'placement', 'heading', 'content', 'description', 'aria-label', 'show-delay', 'hide-delay', 'confirm-loading', 'confirm-disabled', 'ok-text', 'cancel-text']; }
|
|
62
|
+
constructor(_confirmation) {
|
|
63
|
+
super();
|
|
64
|
+
this._confirmation = _confirmation;
|
|
65
|
+
const root = this.attachShadow({ mode: 'open' });
|
|
66
|
+
const style = document.createElement('style');
|
|
67
|
+
style.textContent = `
|
|
68
|
+
:host { display: inline-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); }
|
|
69
|
+
.panel { position: fixed; inset: auto; margin: 0; box-sizing: border-box; width: var(--hy-popover-width, 280px); max-width: calc(100vw - 16px); max-height: calc(100dvh - 16px); overflow: auto; padding: var(--hy-space-6, 12px); border: 1px solid var(--hy-border-color, #303746); border-radius: var(--hy-radius-md, 6px); color: var(--hy-text-color, #d8e2f2); background: var(--hy-surface-elevated-color, #1b2230); box-shadow: var(--hy-popover-shadow, 0 8px 28px rgba(0,0,0,.25)); z-index: var(--hy-popover-z-index, 1050); }
|
|
70
|
+
.panel:focus-visible { outline: 2px solid var(--hy-focus-border-color, #79a8ff); outline-offset: -2px; }
|
|
71
|
+
.heading { display: block; margin-bottom: var(--hy-space-3, 6px); font-weight: 600; overflow-wrap: anywhere; }
|
|
72
|
+
p { margin: 0 0 var(--hy-space-3, 6px); color: var(--hy-secondary-text-color, #aebbd0); overflow-wrap: anywhere; }
|
|
73
|
+
.footer { display: flex; justify-content: flex-end; gap: var(--hy-space-4, 8px); margin-top: var(--hy-space-6, 12px); }
|
|
74
|
+
button { min-height: var(--hy-control-height-sm, 28px); padding: 0 var(--hy-space-5, 10px); border: 1px solid var(--hy-border-color, #303746); border-radius: var(--hy-radius-sm, 4px); color: inherit; background: var(--hy-surface-color, #121822); cursor: pointer; font: inherit; }
|
|
75
|
+
button:hover:not(:disabled) { background: var(--hy-hover-bg-color, #273241); } button:focus-visible { outline: 2px solid var(--hy-focus-border-color, #79a8ff); outline-offset: 2px; }
|
|
76
|
+
.confirm { color: var(--hy-selected-text-color, #fff); background: var(--hy-accent-strong-color, #554cc6); border-color: transparent; }
|
|
77
|
+
button:disabled { opacity: .55; cursor: not-allowed; } [hidden] { display: none !important; }
|
|
78
|
+
`;
|
|
79
|
+
this._triggerSlot.name = 'trigger';
|
|
80
|
+
this._triggerSlot.part.add('trigger');
|
|
81
|
+
this._panel.id = this._panelId;
|
|
82
|
+
this._panel.className = 'panel';
|
|
83
|
+
this._panel.part.add('panel');
|
|
84
|
+
this._panel.hidden = true;
|
|
85
|
+
this._panel.setAttribute('popover', 'manual');
|
|
86
|
+
this._panel.setAttribute('role', 'dialog');
|
|
87
|
+
this._panel.tabIndex = -1;
|
|
88
|
+
this._headingSlot.name = 'heading';
|
|
89
|
+
this._headingSlot.className = 'heading';
|
|
90
|
+
this._headingSlot.part.add('heading');
|
|
91
|
+
this._headingSlot.append(this._headingText);
|
|
92
|
+
this._description.part.add('description');
|
|
93
|
+
this._contentSlot.part.add('content');
|
|
94
|
+
this._footer.className = 'footer';
|
|
95
|
+
this._footer.part.add('footer');
|
|
96
|
+
this._footer.hidden = !_confirmation;
|
|
97
|
+
this._cancel.type = this._confirm.type = 'button';
|
|
98
|
+
this._confirm.className = 'confirm';
|
|
99
|
+
this._confirm.part.add('confirm');
|
|
100
|
+
this._cancel.part.add('cancel');
|
|
101
|
+
this._footer.append(this._cancel, this._confirm);
|
|
102
|
+
this._panel.append(this._headingSlot, this._description, this._contentSlot, this._footer);
|
|
103
|
+
root.append(style, this._triggerSlot, this._panel);
|
|
104
|
+
}
|
|
105
|
+
connectedCallback() {
|
|
106
|
+
this._listeners?.abort();
|
|
107
|
+
this._listeners = new AbortController();
|
|
108
|
+
const { signal } = this._listeners;
|
|
109
|
+
this.addEventListener('click', this._onTriggerClick, { signal });
|
|
110
|
+
this.addEventListener('keydown', this._onKeydown, { signal });
|
|
111
|
+
this.addEventListener('pointerenter', this._onEnter, { signal });
|
|
112
|
+
this.addEventListener('pointerleave', this._onLeave, { signal });
|
|
113
|
+
this._panel.addEventListener('pointerenter', this._onEnter, { signal });
|
|
114
|
+
this._panel.addEventListener('pointerleave', this._onLeave, { signal });
|
|
115
|
+
this.addEventListener('focusin', this._onFocusIn, { signal });
|
|
116
|
+
this.addEventListener('focusout', this._onFocusOut, { signal });
|
|
117
|
+
this._triggerSlot.addEventListener('slotchange', this._syncTrigger, { signal });
|
|
118
|
+
this._headingSlot.addEventListener('slotchange', this._sync, { signal });
|
|
119
|
+
this._confirm.addEventListener('click', () => this._act('confirm', 'button'), { signal });
|
|
120
|
+
this._cancel.addEventListener('click', () => this._act('cancel', 'button'), { signal });
|
|
121
|
+
this.ownerDocument.addEventListener('pointerdown', this._onOutside, { capture: true, signal });
|
|
122
|
+
this.ownerDocument.addEventListener('scroll', this._onScroll, { capture: true, signal });
|
|
123
|
+
this.ownerDocument.defaultView?.addEventListener('resize', this._position, { signal });
|
|
124
|
+
this._observer = new ResizeObserver(this._position);
|
|
125
|
+
this._observer.observe(this._panel);
|
|
126
|
+
this._observer.observe(this);
|
|
127
|
+
this._sync();
|
|
128
|
+
this._syncTrigger();
|
|
129
|
+
}
|
|
130
|
+
disconnectedCallback() {
|
|
131
|
+
this._clearTimer();
|
|
132
|
+
this._clearFocusTimer();
|
|
133
|
+
this._listeners?.abort();
|
|
134
|
+
this._listeners = null;
|
|
135
|
+
this._observer?.disconnect();
|
|
136
|
+
this._observer = null;
|
|
137
|
+
this._hidePanel(false);
|
|
138
|
+
this._restoreTrigger();
|
|
139
|
+
}
|
|
140
|
+
attributeChangedCallback(name, previous, next) {
|
|
141
|
+
if (previous === next || this._reflecting)
|
|
142
|
+
return;
|
|
143
|
+
if (name === 'disabled' && this.disabled && this.open) {
|
|
144
|
+
this._setOpen(false, 'disabled');
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
this._sync();
|
|
148
|
+
}
|
|
149
|
+
get open() { return this.hasAttribute('open'); }
|
|
150
|
+
set open(value) { this._setOpen(Boolean(value), 'api'); }
|
|
151
|
+
get disabled() { return this.hasAttribute('disabled'); }
|
|
152
|
+
set disabled(value) { this.toggleAttribute('disabled', Boolean(value)); }
|
|
153
|
+
get trigger() { const value = this.getAttribute('trigger'); return value === 'hover' || value === 'focus' || value === 'manual' ? value : 'click'; }
|
|
154
|
+
set trigger(value) { this.setAttribute('trigger', value); }
|
|
155
|
+
get placement() { const value = this.getAttribute('placement') ?? 'bottom'; return /^(top|bottom|left|right)(-start|-end)?$/u.test(value) ? value : 'bottom'; }
|
|
156
|
+
set placement(value) { this.setAttribute('placement', value); }
|
|
157
|
+
get heading() { return this.getAttribute('heading') ?? ''; }
|
|
158
|
+
set heading(value) { this.setAttribute('heading', value); }
|
|
159
|
+
get content() { return this.getAttribute('content') ?? ''; }
|
|
160
|
+
set content(value) { this.setAttribute('content', value); }
|
|
161
|
+
get description() { return this.getAttribute('description') ?? ''; }
|
|
162
|
+
set description(value) { this.setAttribute('description', value); }
|
|
163
|
+
get confirmLoading() { return this.hasAttribute('confirm-loading'); }
|
|
164
|
+
set confirmLoading(value) { this.toggleAttribute('confirm-loading', value); }
|
|
165
|
+
get confirmDisabled() { return this.hasAttribute('confirm-disabled'); }
|
|
166
|
+
set confirmDisabled(value) { this.toggleAttribute('confirm-disabled', value); }
|
|
167
|
+
get okText() { return this.getAttribute('ok-text') ?? 'Confirm'; }
|
|
168
|
+
set okText(value) { this.setAttribute('ok-text', value); }
|
|
169
|
+
get cancelText() { return this.getAttribute('cancel-text') ?? 'Cancel'; }
|
|
170
|
+
set cancelText(value) { this.setAttribute('cancel-text', value); }
|
|
171
|
+
show() { this.open = true; }
|
|
172
|
+
hide() { this.open = false; }
|
|
173
|
+
confirm() { return this._act('confirm', 'api'); }
|
|
174
|
+
cancel() { return this._act('cancel', 'api'); }
|
|
175
|
+
_setOpen(open, reason) {
|
|
176
|
+
if ((open && this.disabled) || this.open === open)
|
|
177
|
+
return;
|
|
178
|
+
this._clearTimer();
|
|
179
|
+
this._reason = reason;
|
|
180
|
+
this.toggleAttribute('open', open);
|
|
181
|
+
}
|
|
182
|
+
_sync = () => {
|
|
183
|
+
if (this.disabled && this.open) {
|
|
184
|
+
this._reflecting = true;
|
|
185
|
+
this.removeAttribute('open');
|
|
186
|
+
this._reflecting = false;
|
|
187
|
+
}
|
|
188
|
+
this._headingText.textContent = this.heading;
|
|
189
|
+
this._headingSlot.hidden = !this.heading && !this._headingSlot.assignedNodes().length;
|
|
190
|
+
this._description.textContent = this.description;
|
|
191
|
+
this._description.hidden = !this.description;
|
|
192
|
+
this._contentSlot.textContent = this.content;
|
|
193
|
+
this._panel.setAttribute('aria-label', this.getAttribute('aria-label') || this.heading || (this._confirmation ? 'Confirmation' : 'Popover'));
|
|
194
|
+
this._confirm.textContent = this.confirmLoading ? `${this.okText}…` : this.okText;
|
|
195
|
+
this._confirm.disabled = this.confirmLoading || this.confirmDisabled;
|
|
196
|
+
this._cancel.textContent = this.cancelText;
|
|
197
|
+
this._cancel.disabled = this.confirmLoading;
|
|
198
|
+
this._panel.setAttribute('aria-busy', String(this.confirmLoading));
|
|
199
|
+
if (this.isConnected && this.open && !this.disabled)
|
|
200
|
+
this._showPanel();
|
|
201
|
+
else
|
|
202
|
+
this._hidePanel(this.isConnected);
|
|
203
|
+
this._syncTrigger();
|
|
204
|
+
};
|
|
205
|
+
_showPanel() {
|
|
206
|
+
if (!this._shown) {
|
|
207
|
+
this._shown = true;
|
|
208
|
+
this._returnFocus = deepestActive(this.ownerDocument);
|
|
209
|
+
this._panel.hidden = false;
|
|
210
|
+
if (this._panel.showPopover)
|
|
211
|
+
this._panel.showPopover();
|
|
212
|
+
this._emitOpen();
|
|
213
|
+
if (this.trigger === 'click' || this.trigger === 'manual')
|
|
214
|
+
queueMicrotask(() => {
|
|
215
|
+
if (this._shown && this.isConnected)
|
|
216
|
+
(this._confirmation ? this._cancel : firstFocusable(this._panel) ?? this._panel).focus({ preventScroll: true });
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
this._position();
|
|
220
|
+
}
|
|
221
|
+
_hidePanel(restoreFocus) {
|
|
222
|
+
if (!this._shown)
|
|
223
|
+
return;
|
|
224
|
+
const active = deepestActive(this.ownerDocument);
|
|
225
|
+
const hadFocus = composedContains(this._panel, active) || this._focusInside && (!active || active === this.ownerDocument.body);
|
|
226
|
+
this._shown = false;
|
|
227
|
+
this._clearFocusTimer();
|
|
228
|
+
this._restoringFocus = true;
|
|
229
|
+
try {
|
|
230
|
+
if (this._panel.hidePopover && this._panel.matches(':popover-open'))
|
|
231
|
+
this._panel.hidePopover();
|
|
232
|
+
this._panel.hidden = true;
|
|
233
|
+
if (restoreFocus && hadFocus && this._returnFocus?.isConnected)
|
|
234
|
+
this._returnFocus.focus({ preventScroll: true });
|
|
235
|
+
}
|
|
236
|
+
finally {
|
|
237
|
+
this._restoringFocus = false;
|
|
238
|
+
this._focusInside = false;
|
|
239
|
+
}
|
|
240
|
+
this._returnFocus = null;
|
|
241
|
+
if (this.isConnected)
|
|
242
|
+
this._emitOpen();
|
|
243
|
+
}
|
|
244
|
+
_emitOpen() {
|
|
245
|
+
const reason = this._reason;
|
|
246
|
+
this._reason = 'api';
|
|
247
|
+
this.dispatchEvent(new CustomEvent('open-change', { detail: { open: this._shown, reason }, bubbles: true, composed: true }));
|
|
248
|
+
}
|
|
249
|
+
_syncTrigger = () => {
|
|
250
|
+
if (!this.isConnected)
|
|
251
|
+
return;
|
|
252
|
+
const nodes = this._triggerSlot.assignedElements({ flatten: true }).map(element => element.shadowRoot?.querySelector('button,input,[tabindex]') ?? element).filter((element) => element instanceof HTMLElement);
|
|
253
|
+
for (const [node, attributes] of this._triggerAttributes)
|
|
254
|
+
if (!nodes.includes(node)) {
|
|
255
|
+
for (const [name, value] of attributes) {
|
|
256
|
+
if (value === null)
|
|
257
|
+
node.removeAttribute(name);
|
|
258
|
+
else
|
|
259
|
+
node.setAttribute(name, value);
|
|
260
|
+
}
|
|
261
|
+
this._triggerAttributes.delete(node);
|
|
262
|
+
}
|
|
263
|
+
for (const node of nodes) {
|
|
264
|
+
if (!this._triggerAttributes.has(node))
|
|
265
|
+
this._triggerAttributes.set(node, new Map(['aria-expanded', 'aria-haspopup'].map(name => [name, node.getAttribute(name)])));
|
|
266
|
+
node.setAttribute('aria-haspopup', 'dialog');
|
|
267
|
+
node.setAttribute('aria-expanded', String(this._shown));
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
_restoreTrigger() { for (const [node, attributes] of this._triggerAttributes)
|
|
271
|
+
for (const [name, value] of attributes) {
|
|
272
|
+
if (value === null)
|
|
273
|
+
node.removeAttribute(name);
|
|
274
|
+
else
|
|
275
|
+
node.setAttribute(name, value);
|
|
276
|
+
} this._triggerAttributes.clear(); }
|
|
277
|
+
_isTrigger(event) { return this._triggerSlot.assignedElements({ flatten: true }).some(element => event.composedPath().includes(element)); }
|
|
278
|
+
_onTriggerClick = (event) => { if (this.trigger === 'click' && this._isTrigger(event) && !event.defaultPrevented && !this.confirmLoading)
|
|
279
|
+
this._setOpen(!this.open, 'trigger'); };
|
|
280
|
+
_onKeydown = (event) => { if (event.key === 'Escape' && this._shown && !event.defaultPrevented && !this.confirmLoading) {
|
|
281
|
+
event.preventDefault();
|
|
282
|
+
event.stopPropagation();
|
|
283
|
+
this._setOpen(false, 'escape');
|
|
284
|
+
} };
|
|
285
|
+
_onOutside = (event) => { if (this._shown && !event.composedPath().includes(this) && !this.confirmLoading)
|
|
286
|
+
this._setOpen(false, 'outside'); };
|
|
287
|
+
_onScroll = (event) => { if (!event.composedPath().includes(this._panel))
|
|
288
|
+
this._position(); };
|
|
289
|
+
_onFocusIn = (event) => {
|
|
290
|
+
this._clearFocusTimer();
|
|
291
|
+
if (composedContains(this._panel, event.composedPath()[0]))
|
|
292
|
+
this._focusInside = true;
|
|
293
|
+
if (!this._restoringFocus && this._isTrigger(event) && (this.trigger === 'focus' || this.trigger === 'hover'))
|
|
294
|
+
this._setOpen(true, 'trigger');
|
|
295
|
+
};
|
|
296
|
+
_onFocusOut = (event) => {
|
|
297
|
+
if (!this._shown || event.relatedTarget instanceof Node && composedContains(this, event.relatedTarget))
|
|
298
|
+
return;
|
|
299
|
+
this._clearFocusTimer();
|
|
300
|
+
// Native focus transitions can perform a microtask checkpoint between blur and focus.
|
|
301
|
+
this._focusTimer = setTimeout(() => { this._focusTimer = null; if (this.isConnected && this._shown && !composedContains(this, deepestActive(this.ownerDocument)) && !this.confirmLoading)
|
|
302
|
+
this._setOpen(false, 'blur'); }, 0);
|
|
303
|
+
};
|
|
304
|
+
_onEnter = () => { if (this.trigger === 'hover')
|
|
305
|
+
this._schedule(true); };
|
|
306
|
+
_onLeave = () => { if (this.trigger === 'hover' && !composedContains(this, deepestActive(this.ownerDocument)))
|
|
307
|
+
this._schedule(false); };
|
|
308
|
+
_schedule(open) { this._clearTimer(); const raw = Number(this.getAttribute(open ? 'show-delay' : 'hide-delay') ?? (open ? 100 : 150)); const delay = Number.isFinite(raw) ? Math.max(0, Math.min(raw, 60000)) : 0; this._timer = setTimeout(() => { this._timer = null; if (this.isConnected)
|
|
309
|
+
this._setOpen(open, 'trigger'); }, delay); }
|
|
310
|
+
_clearTimer() { if (this._timer !== null)
|
|
311
|
+
clearTimeout(this._timer); this._timer = null; }
|
|
312
|
+
_clearFocusTimer() { if (this._focusTimer !== null)
|
|
313
|
+
clearTimeout(this._focusTimer); this._focusTimer = null; }
|
|
314
|
+
_act(action, source) {
|
|
315
|
+
if (!this._confirmation || !this._shown || this.disabled || this.confirmLoading || (action === 'confirm' && this.confirmDisabled))
|
|
316
|
+
return false;
|
|
317
|
+
if (!this.dispatchEvent(new CustomEvent(action, { detail: { source }, bubbles: true, composed: true, cancelable: true })))
|
|
318
|
+
return false;
|
|
319
|
+
this._setOpen(false, action);
|
|
320
|
+
return true;
|
|
321
|
+
}
|
|
322
|
+
_position = () => {
|
|
323
|
+
if (!this._shown || !this.isConnected)
|
|
324
|
+
return;
|
|
325
|
+
const anchor = this._triggerSlot.assignedElements({ flatten: true })[0];
|
|
326
|
+
const view = this.ownerDocument.defaultView;
|
|
327
|
+
if (!anchor || !view)
|
|
328
|
+
return;
|
|
329
|
+
const rect = anchor.getBoundingClientRect();
|
|
330
|
+
if (rect.bottom < 0 || rect.top > view.innerHeight || rect.right < 0 || rect.left > view.innerWidth) {
|
|
331
|
+
this._setOpen(false, 'outside');
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
const panel = this._panel.getBoundingClientRect();
|
|
335
|
+
const [preferred, alignment] = this.placement.split('-');
|
|
336
|
+
let side = preferred;
|
|
337
|
+
if (side === 'top' && rect.top < panel.height + 16 && view.innerHeight - rect.bottom > rect.top)
|
|
338
|
+
side = 'bottom';
|
|
339
|
+
else if (side === 'bottom' && view.innerHeight - rect.bottom < panel.height + 16 && rect.top > view.innerHeight - rect.bottom)
|
|
340
|
+
side = 'top';
|
|
341
|
+
else if (side === 'left' && rect.left < panel.width + 16 && view.innerWidth - rect.right > rect.left)
|
|
342
|
+
side = 'right';
|
|
343
|
+
else if (side === 'right' && view.innerWidth - rect.right < panel.width + 16 && rect.left > view.innerWidth - rect.right)
|
|
344
|
+
side = 'left';
|
|
345
|
+
let left = rect.left + (rect.width - panel.width) / 2;
|
|
346
|
+
let top = rect.top + (rect.height - panel.height) / 2;
|
|
347
|
+
if (side === 'top' || side === 'bottom') {
|
|
348
|
+
top = side === 'top' ? rect.top - panel.height - 8 : rect.bottom + 8;
|
|
349
|
+
if (alignment === 'start')
|
|
350
|
+
left = rect.left;
|
|
351
|
+
else if (alignment === 'end')
|
|
352
|
+
left = rect.right - panel.width;
|
|
353
|
+
}
|
|
354
|
+
else {
|
|
355
|
+
left = side === 'left' ? rect.left - panel.width - 8 : rect.right + 8;
|
|
356
|
+
if (alignment === 'start')
|
|
357
|
+
top = rect.top;
|
|
358
|
+
else if (alignment === 'end')
|
|
359
|
+
top = rect.bottom - panel.height;
|
|
360
|
+
}
|
|
361
|
+
this._panel.style.left = `${Math.max(8, Math.min(left, view.innerWidth - panel.width - 8))}px`;
|
|
362
|
+
this._panel.style.top = `${Math.max(8, Math.min(top, view.innerHeight - panel.height - 8))}px`;
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
//# sourceMappingURL=popover-base.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export function hasSlotContent(slot) {
|
|
2
|
+
return slot.assignedNodes({ flatten: true }).some(node => node.nodeType === Node.ELEMENT_NODE || Boolean(node.textContent?.trim()));
|
|
3
|
+
}
|
|
4
|
+
export function presentationIcon(kind) {
|
|
5
|
+
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
6
|
+
svg.setAttribute('viewBox', '0 0 48 48');
|
|
7
|
+
svg.setAttribute('fill', 'none');
|
|
8
|
+
svg.setAttribute('aria-hidden', 'true');
|
|
9
|
+
svg.setAttribute('stroke', 'currentColor');
|
|
10
|
+
svg.setAttribute('stroke-width', '2');
|
|
11
|
+
svg.setAttribute('stroke-linecap', 'round');
|
|
12
|
+
svg.setAttribute('stroke-linejoin', 'round');
|
|
13
|
+
const paths = {
|
|
14
|
+
empty: ['M8 18 16 8h16l8 10v20H8Z', 'M8 20h10l3 6h6l3-6h10', 'M18 36h12'],
|
|
15
|
+
avatar: ['M24 25a9 9 0 1 0 0-18 9 9 0 0 0 0 18Z', 'M7 43a17 17 0 0 1 34 0'],
|
|
16
|
+
success: ['M24 45a21 21 0 1 0 0-42 21 21 0 0 0 0 42Z', 'm14 24 7 7 14-15'],
|
|
17
|
+
info: ['M24 45a21 21 0 1 0 0-42 21 21 0 0 0 0 42Z', 'M24 22v13', 'M24 13v1'],
|
|
18
|
+
warning: ['M24 4 46 42H2Z', 'M24 18v12', 'M24 35v1'],
|
|
19
|
+
error: ['M24 45a21 21 0 1 0 0-42 21 21 0 0 0 0 42Z', 'm17 17 14 14', 'm31 17-14 14'],
|
|
20
|
+
};
|
|
21
|
+
for (const data of paths[kind]) {
|
|
22
|
+
const path = document.createElementNS(svg.namespaceURI, 'path');
|
|
23
|
+
path.setAttribute('d', data);
|
|
24
|
+
svg.append(path);
|
|
25
|
+
}
|
|
26
|
+
return svg;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=presentation.js.map
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
declare namespace qrcodegen {
|
|
2
|
+
type bit = number;
|
|
3
|
+
type byte = number;
|
|
4
|
+
type int = number;
|
|
5
|
+
export class QrCode {
|
|
6
|
+
readonly version: int;
|
|
7
|
+
readonly errorCorrectionLevel: QrCode.Ecc;
|
|
8
|
+
static encodeText(text: string, ecl: QrCode.Ecc): QrCode;
|
|
9
|
+
static encodeBinary(data: Readonly<Array<byte>>, ecl: QrCode.Ecc): QrCode;
|
|
10
|
+
static encodeSegments(segs: Readonly<Array<QrSegment>>, ecl: QrCode.Ecc, minVersion?: int, maxVersion?: int, mask?: int, boostEcl?: boolean): QrCode;
|
|
11
|
+
readonly size: int;
|
|
12
|
+
readonly mask: int;
|
|
13
|
+
private readonly modules;
|
|
14
|
+
private readonly isFunction;
|
|
15
|
+
constructor(version: int, errorCorrectionLevel: QrCode.Ecc, dataCodewords: Readonly<Array<byte>>, msk: int);
|
|
16
|
+
getModule(x: int, y: int): boolean;
|
|
17
|
+
private drawFunctionPatterns;
|
|
18
|
+
private drawFormatBits;
|
|
19
|
+
private drawVersion;
|
|
20
|
+
private drawFinderPattern;
|
|
21
|
+
private drawAlignmentPattern;
|
|
22
|
+
private setFunctionModule;
|
|
23
|
+
private addEccAndInterleave;
|
|
24
|
+
private drawCodewords;
|
|
25
|
+
private applyMask;
|
|
26
|
+
private getPenaltyScore;
|
|
27
|
+
private getAlignmentPatternPositions;
|
|
28
|
+
private static getNumRawDataModules;
|
|
29
|
+
private static getNumDataCodewords;
|
|
30
|
+
private static reedSolomonComputeDivisor;
|
|
31
|
+
private static reedSolomonComputeRemainder;
|
|
32
|
+
private static reedSolomonMultiply;
|
|
33
|
+
private finderPenaltyCountPatterns;
|
|
34
|
+
private finderPenaltyTerminateAndCount;
|
|
35
|
+
private finderPenaltyAddHistory;
|
|
36
|
+
static readonly MIN_VERSION: int;
|
|
37
|
+
static readonly MAX_VERSION: int;
|
|
38
|
+
private static readonly PENALTY_N1;
|
|
39
|
+
private static readonly PENALTY_N2;
|
|
40
|
+
private static readonly PENALTY_N3;
|
|
41
|
+
private static readonly PENALTY_N4;
|
|
42
|
+
private static readonly ECC_CODEWORDS_PER_BLOCK;
|
|
43
|
+
private static readonly NUM_ERROR_CORRECTION_BLOCKS;
|
|
44
|
+
}
|
|
45
|
+
export class QrSegment {
|
|
46
|
+
readonly mode: QrSegment.Mode;
|
|
47
|
+
readonly numChars: int;
|
|
48
|
+
private readonly bitData;
|
|
49
|
+
static makeBytes(data: Readonly<Array<byte>>): QrSegment;
|
|
50
|
+
static makeNumeric(digits: string): QrSegment;
|
|
51
|
+
static makeAlphanumeric(text: string): QrSegment;
|
|
52
|
+
static makeSegments(text: string): Array<QrSegment>;
|
|
53
|
+
static makeEci(assignVal: int): QrSegment;
|
|
54
|
+
static isNumeric(text: string): boolean;
|
|
55
|
+
static isAlphanumeric(text: string): boolean;
|
|
56
|
+
constructor(mode: QrSegment.Mode, numChars: int, bitData: Array<bit>);
|
|
57
|
+
getData(): Array<bit>;
|
|
58
|
+
static getTotalBits(segs: Readonly<Array<QrSegment>>, version: int): number;
|
|
59
|
+
private static toUtf8ByteArray;
|
|
60
|
+
private static readonly NUMERIC_REGEX;
|
|
61
|
+
private static readonly ALPHANUMERIC_REGEX;
|
|
62
|
+
private static readonly ALPHANUMERIC_CHARSET;
|
|
63
|
+
}
|
|
64
|
+
export {};
|
|
65
|
+
}
|
|
66
|
+
declare namespace qrcodegen.QrCode {
|
|
67
|
+
type int = number;
|
|
68
|
+
export class Ecc {
|
|
69
|
+
readonly ordinal: int;
|
|
70
|
+
readonly formatBits: int;
|
|
71
|
+
static readonly LOW: Ecc;
|
|
72
|
+
static readonly MEDIUM: Ecc;
|
|
73
|
+
static readonly QUARTILE: Ecc;
|
|
74
|
+
static readonly HIGH: Ecc;
|
|
75
|
+
private constructor();
|
|
76
|
+
}
|
|
77
|
+
export {};
|
|
78
|
+
}
|
|
79
|
+
declare namespace qrcodegen.QrSegment {
|
|
80
|
+
type int = number;
|
|
81
|
+
export class Mode {
|
|
82
|
+
readonly modeBits: int;
|
|
83
|
+
private readonly numBitsCharCount;
|
|
84
|
+
static readonly NUMERIC: Mode;
|
|
85
|
+
static readonly ALPHANUMERIC: Mode;
|
|
86
|
+
static readonly BYTE: Mode;
|
|
87
|
+
static readonly KANJI: Mode;
|
|
88
|
+
static readonly ECI: Mode;
|
|
89
|
+
private constructor();
|
|
90
|
+
numCharCountBits(ver: int): int;
|
|
91
|
+
}
|
|
92
|
+
export {};
|
|
93
|
+
}
|
|
94
|
+
export { qrcodegen };
|