@haiyue/ui 0.2.2 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/README.md +523 -4
  3. package/dist/adapters/web/controls.js +48 -8
  4. package/dist/adapters/web/renderer.js +9 -11
  5. package/dist/adapters/web/styles.d.ts +2 -3
  6. package/dist/adapters/web/styles.js +26 -23
  7. package/dist/alert.d.ts +39 -0
  8. package/dist/alert.js +144 -0
  9. package/dist/anchor.d.ts +62 -0
  10. package/dist/anchor.js +293 -0
  11. package/dist/auto-complete.d.ts +83 -0
  12. package/dist/auto-complete.js +267 -0
  13. package/dist/avatar.d.ts +45 -0
  14. package/dist/avatar.js +135 -0
  15. package/dist/badge.js +5 -5
  16. package/dist/border-beam.js +3 -2
  17. package/dist/breadcrumb.js +5 -5
  18. package/dist/button-group.js +8 -8
  19. package/dist/button.js +10 -10
  20. package/dist/card.d.ts +29 -0
  21. package/dist/card.js +101 -0
  22. package/dist/carousel.js +6 -6
  23. package/dist/cascader.js +19 -13
  24. package/dist/checkbox.d.ts +12 -0
  25. package/dist/checkbox.js +22 -6
  26. package/dist/collapse.js +6 -6
  27. package/dist/context-menu.js +3 -4
  28. package/dist/core/actions.js +7 -8
  29. package/dist/core/data.d.ts +1 -1
  30. package/dist/core/data.js +44 -10
  31. package/dist/core/platform-view.js +8 -2
  32. package/dist/core/selection.js +4 -4
  33. package/dist/core/semantics.d.ts +26 -0
  34. package/dist/core/semantics.js +8 -0
  35. package/dist/core/text.js +3 -3
  36. package/dist/core/validation.d.ts +3 -1
  37. package/dist/core/validation.js +23 -5
  38. package/dist/date-picker.js +19 -13
  39. package/dist/descriptions.d.ts +44 -0
  40. package/dist/descriptions.js +169 -0
  41. package/dist/dialog.d.ts +4 -0
  42. package/dist/dialog.js +48 -27
  43. package/dist/divider.js +2 -2
  44. package/dist/draggable.js +5 -3
  45. package/dist/drawer.js +16 -24
  46. package/dist/dropdown.js +3 -4
  47. package/dist/empty.d.ts +20 -0
  48. package/dist/empty.js +58 -0
  49. package/dist/expandable.js +4 -4
  50. package/dist/form-item.d.ts +60 -0
  51. package/dist/form-item.js +212 -0
  52. package/dist/form.d.ts +41 -0
  53. package/dist/form.js +154 -0
  54. package/dist/history-controls.js +5 -5
  55. package/dist/image-preview.d.ts +22 -0
  56. package/dist/image-preview.js +38 -0
  57. package/dist/image.d.ts +52 -0
  58. package/dist/image.js +152 -0
  59. package/dist/index.d.ts +48 -0
  60. package/dist/index.js +72 -0
  61. package/dist/input.d.ts +11 -0
  62. package/dist/input.js +32 -18
  63. package/dist/internal/anchored-popup.d.ts +19 -0
  64. package/dist/internal/anchored-popup.js +89 -0
  65. package/dist/internal/focus.d.ts +2 -0
  66. package/dist/internal/focus.js +31 -0
  67. package/dist/internal/form-control.d.ts +22 -0
  68. package/dist/internal/form-control.js +52 -0
  69. package/dist/internal/image-viewer.d.ts +51 -0
  70. package/dist/internal/image-viewer.js +210 -0
  71. package/dist/internal/keyboard.d.ts +2 -0
  72. package/dist/internal/keyboard.js +12 -0
  73. package/dist/internal/numbers.d.ts +2 -0
  74. package/dist/internal/numbers.js +8 -0
  75. package/dist/internal/pagination.d.ts +35 -0
  76. package/dist/internal/pagination.js +169 -0
  77. package/dist/internal/popover-base.d.ts +87 -0
  78. package/dist/internal/popover-base.js +365 -0
  79. package/dist/internal/presentation.d.ts +2 -0
  80. package/dist/internal/presentation.js +28 -0
  81. package/dist/mentions.d.ts +115 -0
  82. package/dist/mentions.js +485 -0
  83. package/dist/menu-shared.d.ts +1 -1
  84. package/dist/menu-shared.js +3 -3
  85. package/dist/menu.d.ts +63 -0
  86. package/dist/menu.js +339 -0
  87. package/dist/modal.js +11 -40
  88. package/dist/notification.js +11 -10
  89. package/dist/pagination.d.ts +34 -0
  90. package/dist/pagination.js +73 -0
  91. package/dist/popconfirm.d.ts +6 -0
  92. package/dist/popconfirm.js +7 -0
  93. package/dist/popover.d.ts +6 -0
  94. package/dist/popover.js +7 -0
  95. package/dist/portable/page.js +25 -14
  96. package/dist/progress.d.ts +30 -0
  97. package/dist/progress.js +102 -0
  98. package/dist/qr-code.js +3 -3
  99. package/dist/radio.d.ts +10 -0
  100. package/dist/radio.js +18 -5
  101. package/dist/range.js +7 -7
  102. package/dist/rate.js +3 -3
  103. package/dist/resizable.js +8 -5
  104. package/dist/result.d.ts +22 -0
  105. package/dist/result.js +88 -0
  106. package/dist/ribbon.d.ts +19 -0
  107. package/dist/ribbon.js +106 -0
  108. package/dist/segmented.d.ts +39 -0
  109. package/dist/segmented.js +192 -0
  110. package/dist/select.d.ts +12 -0
  111. package/dist/select.js +31 -13
  112. package/dist/skeleton.js +10 -10
  113. package/dist/spin.d.ts +26 -0
  114. package/dist/spin.js +80 -0
  115. package/dist/steps.js +13 -13
  116. package/dist/switch.d.ts +44 -0
  117. package/dist/switch.js +104 -0
  118. package/dist/table.d.ts +3 -3
  119. package/dist/table.js +110 -128
  120. package/dist/tabs.js +7 -7
  121. package/dist/tag.js +8 -8
  122. package/dist/time-picker.js +16 -10
  123. package/dist/timeline.js +12 -12
  124. package/dist/toast.js +12 -11
  125. package/dist/tooltip.d.ts +6 -0
  126. package/dist/tooltip.js +107 -6
  127. package/dist/tour.js +26 -17
  128. package/dist/tree-model.d.ts +2 -0
  129. package/dist/tree-model.js +32 -11
  130. package/dist/tree-node.js +2 -2
  131. package/dist/tree-select.d.ts +94 -0
  132. package/dist/tree-select.js +398 -0
  133. package/dist/tree.d.ts +0 -2
  134. package/dist/tree.js +14 -29
  135. package/dist/upload.d.ts +108 -0
  136. package/dist/upload.js +358 -0
  137. package/dist/virtual-keyboard.d.ts +1 -0
  138. package/dist/virtual-keyboard.js +72 -41
  139. package/dist/virtual-list.d.ts +1 -0
  140. package/dist/virtual-list.js +25 -8
  141. package/dist/virtual-mouse.js +7 -6
  142. package/dist/watermark.js +2 -1
  143. package/package.json +82 -1
  144. package/themes/haiyue-dark.css +51 -0
  145. package/themes/haiyue-light.css +51 -0
@@ -0,0 +1,87 @@
1
+ export type HYPopoverPlacement = 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end' | 'right' | 'right-start' | 'right-end';
2
+ export type HYPopoverTrigger = 'click' | 'hover' | 'focus' | 'manual';
3
+ export type HYPopoverCloseReason = 'api' | 'trigger' | 'outside' | 'escape' | 'blur' | 'confirm' | 'cancel' | 'disabled';
4
+ export interface HYPopoverOpenChangeDetail {
5
+ open: boolean;
6
+ reason: HYPopoverCloseReason;
7
+ }
8
+ export interface HYPopconfirmActionDetail {
9
+ source: 'button' | 'api';
10
+ }
11
+ /** Shared implementation for two isolated public entries; importing never registers elements. */
12
+ export declare class HYPopoverBase extends HTMLElement {
13
+ private readonly _confirmation;
14
+ private readonly _triggerSlot;
15
+ private readonly _panel;
16
+ private readonly _headingSlot;
17
+ private readonly _headingText;
18
+ private readonly _contentSlot;
19
+ private readonly _description;
20
+ private readonly _footer;
21
+ private readonly _cancel;
22
+ private readonly _confirm;
23
+ private readonly _panelId;
24
+ private _listeners;
25
+ private _observer;
26
+ private _timer;
27
+ private _focusTimer;
28
+ private _shown;
29
+ private _restoringFocus;
30
+ private _focusInside;
31
+ private _reflecting;
32
+ private _returnFocus;
33
+ private _reason;
34
+ private _triggerAttributes;
35
+ static get observedAttributes(): string[];
36
+ protected constructor(_confirmation: boolean);
37
+ connectedCallback(): void;
38
+ disconnectedCallback(): void;
39
+ attributeChangedCallback(name: string, previous: string | null, next: string | null): void;
40
+ get open(): boolean;
41
+ set open(value: boolean);
42
+ get disabled(): boolean;
43
+ set disabled(value: boolean);
44
+ get trigger(): HYPopoverTrigger;
45
+ set trigger(value: HYPopoverTrigger);
46
+ get placement(): HYPopoverPlacement;
47
+ set placement(value: HYPopoverPlacement);
48
+ get heading(): string;
49
+ set heading(value: string);
50
+ get content(): string;
51
+ set content(value: string);
52
+ get description(): string;
53
+ set description(value: string);
54
+ get confirmLoading(): boolean;
55
+ set confirmLoading(value: boolean);
56
+ get confirmDisabled(): boolean;
57
+ set confirmDisabled(value: boolean);
58
+ get okText(): string;
59
+ set okText(value: string);
60
+ get cancelText(): string;
61
+ set cancelText(value: string);
62
+ show(): void;
63
+ hide(): void;
64
+ confirm(): boolean;
65
+ cancel(): boolean;
66
+ private _setOpen;
67
+ private _sync;
68
+ private _showPanel;
69
+ private _hidePanel;
70
+ private _emitOpen;
71
+ private _syncTrigger;
72
+ private _restoreTrigger;
73
+ private _isTrigger;
74
+ private _onTriggerClick;
75
+ private _onKeydown;
76
+ private _onOutside;
77
+ private _onScroll;
78
+ private _onFocusIn;
79
+ private _onFocusOut;
80
+ private _onEnter;
81
+ private _onLeave;
82
+ private _schedule;
83
+ private _clearTimer;
84
+ private _clearFocusTimer;
85
+ private _act;
86
+ private _position;
87
+ }
@@ -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,2 @@
1
+ export declare function hasSlotContent(slot: HTMLSlotElement): boolean;
2
+ export declare function presentationIcon(kind: 'empty' | 'avatar' | 'success' | 'info' | 'warning' | 'error'): SVGSVGElement;
@@ -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,115 @@
1
+ export interface HYMentionsOption {
2
+ value: string;
3
+ label?: string;
4
+ disabled?: boolean;
5
+ }
6
+ export interface HYMentionsChangeDetail {
7
+ value: string;
8
+ }
9
+ export interface HYMentionsSearchDetail {
10
+ text: string;
11
+ prefix: string;
12
+ }
13
+ export interface HYMentionsSelectDetail {
14
+ value: string;
15
+ option: HYMentionsOption;
16
+ prefix: string;
17
+ }
18
+ export type HYMentionsPlacement = 'top' | 'bottom';
19
+ export type HYMentionsFilter = (text: string, option: HYMentionsOption) => boolean;
20
+ /** A multiline text input with caret-anchored mention suggestions. Registration is explicit. */
21
+ export declare class HYMentions extends HTMLElement {
22
+ static readonly formAssociated = true;
23
+ private readonly _textarea;
24
+ private readonly _formControl;
25
+ private readonly _panel;
26
+ private readonly _list;
27
+ private readonly _status;
28
+ private readonly _mirror;
29
+ private readonly _marker;
30
+ private readonly _mirrorBefore;
31
+ private readonly _mirrorAfter;
32
+ private readonly _markerText;
33
+ private readonly _listId;
34
+ private _options;
35
+ private _filtered;
36
+ private _items;
37
+ private _visibleItems;
38
+ private _filterOption;
39
+ private _search;
40
+ private _active;
41
+ private _dismissed;
42
+ private _composing;
43
+ private _committing;
44
+ private _listeners;
45
+ private _resizeObserver;
46
+ static get observedAttributes(): string[];
47
+ constructor();
48
+ connectedCallback(): void;
49
+ disconnectedCallback(): void;
50
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
51
+ get value(): string;
52
+ set value(value: string);
53
+ get options(): HYMentionsOption[];
54
+ set options(value: HYMentionsOption[]);
55
+ get prefix(): string;
56
+ set prefix(value: string);
57
+ get prefixes(): string[];
58
+ set prefixes(value: string[]);
59
+ get split(): string;
60
+ set split(value: string);
61
+ get placement(): HYMentionsPlacement;
62
+ set placement(value: HYMentionsPlacement);
63
+ get loading(): boolean;
64
+ set loading(value: boolean);
65
+ get disabled(): boolean;
66
+ set disabled(value: boolean);
67
+ get readOnly(): boolean;
68
+ set readOnly(value: boolean);
69
+ get placeholder(): string;
70
+ set placeholder(value: string);
71
+ get rows(): number;
72
+ set rows(value: number);
73
+ get notFoundContent(): string;
74
+ set notFoundContent(value: string);
75
+ get loadingText(): string;
76
+ set loadingText(value: string);
77
+ get filterOption(): HYMentionsFilter | false | null;
78
+ set filterOption(value: HYMentionsFilter | false | null);
79
+ get open(): boolean;
80
+ focus(options?: FocusOptions): void;
81
+ blur(): void;
82
+ get form(): HTMLFormElement | null;
83
+ get validity(): ValidityState;
84
+ get validationMessage(): string;
85
+ checkValidity(): boolean;
86
+ reportValidity(): boolean;
87
+ setCustomValidity(message: string): void;
88
+ formDisabledCallback(disabled: boolean): void;
89
+ formResetCallback(): void;
90
+ formStateRestoreCallback(state: string | File | FormData | null): void;
91
+ private _sync;
92
+ private _findSearch;
93
+ private _refreshSearch;
94
+ private _renderSuggestions;
95
+ private _setOptions;
96
+ private _syncActive;
97
+ private _close;
98
+ private _positionPanel;
99
+ private _commit;
100
+ private _onInput;
101
+ private _onFocus;
102
+ private _onBlur;
103
+ private _onCaretChange;
104
+ private _onCaretKeyup;
105
+ private _onCompositionStart;
106
+ private _onCompositionEnd;
107
+ private _onKeydown;
108
+ private _optionIndex;
109
+ private _onPanelPointerDown;
110
+ private _onPanelPointerMove;
111
+ private _onPanelClick;
112
+ private _onOutsidePointerDown;
113
+ private _onScroll;
114
+ }
115
+ export declare function defineMentionsComponents(): void;