@haiyue/ui 0.2.2 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +42 -0
- package/README.md +523 -4
- package/dist/adapters/web/controls.js +48 -8
- package/dist/adapters/web/renderer.js +9 -11
- package/dist/adapters/web/styles.d.ts +2 -3
- package/dist/adapters/web/styles.js +26 -23
- package/dist/alert.d.ts +39 -0
- package/dist/alert.js +144 -0
- package/dist/anchor.d.ts +62 -0
- package/dist/anchor.js +293 -0
- package/dist/auto-complete.d.ts +83 -0
- package/dist/auto-complete.js +267 -0
- package/dist/avatar.d.ts +45 -0
- package/dist/avatar.js +135 -0
- package/dist/badge.js +5 -5
- package/dist/border-beam.js +3 -2
- package/dist/breadcrumb.js +5 -5
- package/dist/button-group.js +8 -8
- package/dist/button.js +10 -10
- package/dist/card.d.ts +29 -0
- package/dist/card.js +101 -0
- package/dist/carousel.js +6 -6
- package/dist/cascader.js +19 -13
- package/dist/checkbox.d.ts +12 -0
- package/dist/checkbox.js +22 -6
- package/dist/collapse.js +6 -6
- package/dist/context-menu.js +3 -4
- package/dist/core/actions.js +7 -8
- package/dist/core/data.d.ts +1 -1
- package/dist/core/data.js +44 -10
- package/dist/core/platform-view.js +8 -2
- package/dist/core/selection.js +4 -4
- package/dist/core/semantics.d.ts +26 -0
- package/dist/core/semantics.js +8 -0
- package/dist/core/text.js +3 -3
- package/dist/core/validation.d.ts +3 -1
- package/dist/core/validation.js +23 -5
- package/dist/date-picker.js +19 -13
- package/dist/descriptions.d.ts +44 -0
- package/dist/descriptions.js +169 -0
- package/dist/dialog.d.ts +4 -0
- package/dist/dialog.js +48 -27
- package/dist/divider.js +2 -2
- package/dist/draggable.js +5 -3
- package/dist/drawer.js +16 -24
- package/dist/dropdown.js +3 -4
- package/dist/empty.d.ts +20 -0
- package/dist/empty.js +58 -0
- package/dist/expandable.js +4 -4
- package/dist/form-item.d.ts +60 -0
- package/dist/form-item.js +212 -0
- package/dist/form.d.ts +41 -0
- package/dist/form.js +154 -0
- package/dist/history-controls.js +5 -5
- package/dist/image-preview.d.ts +22 -0
- package/dist/image-preview.js +38 -0
- package/dist/image.d.ts +52 -0
- package/dist/image.js +152 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.js +72 -0
- package/dist/input.d.ts +11 -0
- package/dist/input.js +32 -18
- package/dist/internal/anchored-popup.d.ts +19 -0
- package/dist/internal/anchored-popup.js +89 -0
- package/dist/internal/focus.d.ts +2 -0
- package/dist/internal/focus.js +31 -0
- package/dist/internal/form-control.d.ts +22 -0
- package/dist/internal/form-control.js +52 -0
- package/dist/internal/image-viewer.d.ts +51 -0
- package/dist/internal/image-viewer.js +210 -0
- package/dist/internal/keyboard.d.ts +2 -0
- package/dist/internal/keyboard.js +12 -0
- package/dist/internal/numbers.d.ts +2 -0
- package/dist/internal/numbers.js +8 -0
- package/dist/internal/pagination.d.ts +35 -0
- package/dist/internal/pagination.js +169 -0
- package/dist/internal/popover-base.d.ts +87 -0
- package/dist/internal/popover-base.js +365 -0
- package/dist/internal/presentation.d.ts +2 -0
- package/dist/internal/presentation.js +28 -0
- package/dist/mentions.d.ts +115 -0
- package/dist/mentions.js +485 -0
- package/dist/menu-shared.d.ts +1 -1
- package/dist/menu-shared.js +3 -3
- package/dist/menu.d.ts +63 -0
- package/dist/menu.js +339 -0
- package/dist/modal.js +11 -40
- package/dist/notification.js +11 -10
- package/dist/pagination.d.ts +34 -0
- package/dist/pagination.js +73 -0
- package/dist/popconfirm.d.ts +6 -0
- package/dist/popconfirm.js +7 -0
- package/dist/popover.d.ts +6 -0
- package/dist/popover.js +7 -0
- package/dist/portable/page.js +25 -14
- package/dist/progress.d.ts +30 -0
- package/dist/progress.js +102 -0
- package/dist/qr-code.js +3 -3
- package/dist/radio.d.ts +10 -0
- package/dist/radio.js +18 -5
- package/dist/range.js +7 -7
- package/dist/rate.js +3 -3
- package/dist/resizable.js +8 -5
- package/dist/result.d.ts +22 -0
- package/dist/result.js +88 -0
- package/dist/ribbon.d.ts +19 -0
- package/dist/ribbon.js +106 -0
- package/dist/segmented.d.ts +39 -0
- package/dist/segmented.js +192 -0
- package/dist/select.d.ts +12 -0
- package/dist/select.js +31 -13
- package/dist/skeleton.js +10 -10
- package/dist/spin.d.ts +26 -0
- package/dist/spin.js +80 -0
- package/dist/steps.js +13 -13
- package/dist/switch.d.ts +44 -0
- package/dist/switch.js +104 -0
- package/dist/table.d.ts +3 -3
- package/dist/table.js +110 -128
- package/dist/tabs.js +7 -7
- package/dist/tag.js +8 -8
- package/dist/time-picker.js +16 -10
- package/dist/timeline.js +12 -12
- package/dist/toast.js +12 -11
- package/dist/tooltip.d.ts +6 -0
- package/dist/tooltip.js +107 -6
- package/dist/tour.js +26 -17
- package/dist/tree-model.d.ts +2 -0
- package/dist/tree-model.js +32 -11
- package/dist/tree-node.js +2 -2
- package/dist/tree-select.d.ts +94 -0
- package/dist/tree-select.js +398 -0
- package/dist/tree.d.ts +0 -2
- package/dist/tree.js +14 -29
- package/dist/upload.d.ts +108 -0
- package/dist/upload.js +358 -0
- package/dist/virtual-keyboard.d.ts +1 -0
- package/dist/virtual-keyboard.js +72 -41
- package/dist/virtual-list.d.ts +1 -0
- package/dist/virtual-list.js +25 -8
- package/dist/virtual-mouse.js +7 -6
- package/dist/watermark.js +2 -1
- package/package.json +82 -1
- package/themes/haiyue-dark.css +51 -0
- package/themes/haiyue-light.css +51 -0
package/dist/image.js
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { HYImageViewer } from './internal/image-viewer.js';
|
|
2
|
+
export class HYImage extends HTMLElement {
|
|
3
|
+
_frame = document.createElement('div');
|
|
4
|
+
_imageHost = document.createElement('span');
|
|
5
|
+
_placeholder = document.createElement('slot');
|
|
6
|
+
_error = document.createElement('slot');
|
|
7
|
+
_preview = document.createElement('button');
|
|
8
|
+
_viewer;
|
|
9
|
+
_image = null;
|
|
10
|
+
_loadListeners = null;
|
|
11
|
+
_status = 'empty';
|
|
12
|
+
_sourceKey = '';
|
|
13
|
+
_usedFallback = false;
|
|
14
|
+
static get observedAttributes() { return ['src', 'srcset', 'sizes', 'alt', 'fallback', 'width', 'height', 'fit', 'loading', 'preview', 'preview-src', '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: inline-block; max-width: 100%; vertical-align: middle; color: var(--hy-text-color, #d8e2f2); font: var(--hy-font-size-sm, 12px)/1.5 var(--hy-font-family, system-ui, sans-serif); }
|
|
21
|
+
.frame { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); position: relative; width: 100%; height: 100%; max-width: 100%; min-width: 32px; min-height: 32px; overflow: hidden; border-radius: var(--hy-image-radius, var(--hy-radius-sm, 4px)); background: var(--hy-image-bg, var(--hy-surface-color, #121822)); }
|
|
22
|
+
.image-host { display: contents; } .image { display: block; width: 100%; height: 100%; min-width: 0; min-height: 0; max-width: 100%; object-fit: var(--_fit, contain); }
|
|
23
|
+
.placeholder, .error { position: absolute; inset: 0; display: grid; place-items: center; padding: 8px; text-align: center; color: var(--hy-muted-text-color, #8290a3); background: var(--hy-image-bg, var(--hy-surface-color, #121822)); }
|
|
24
|
+
.preview-trigger { position: absolute; inset: 0; width: 100%; padding: 0; border: 0; border-radius: inherit; color: var(--hy-selected-text-color, #fff); background: transparent; cursor: zoom-in; font: inherit; }
|
|
25
|
+
.preview-trigger span { opacity: 0; padding: 5px 10px; border-radius: var(--hy-radius-sm, 4px); background: var(--hy-image-preview-mask-color, rgba(0,0,0,.6)); }
|
|
26
|
+
.preview-trigger:hover span, .preview-trigger:focus-visible span { opacity: 1; } .preview-trigger:focus-visible { outline: 2px solid var(--hy-focus-border-color, #79a8ff); outline-offset: -2px; } [hidden] { display: none !important; }
|
|
27
|
+
`;
|
|
28
|
+
this._frame.className = 'frame';
|
|
29
|
+
this._frame.part.add('frame');
|
|
30
|
+
this._imageHost.className = 'image-host';
|
|
31
|
+
this._placeholder.name = 'placeholder';
|
|
32
|
+
this._placeholder.className = 'placeholder';
|
|
33
|
+
this._placeholder.part.add('placeholder');
|
|
34
|
+
this._placeholder.textContent = 'Loading…';
|
|
35
|
+
this._placeholder.setAttribute('role', 'status');
|
|
36
|
+
this._error.name = 'fallback';
|
|
37
|
+
this._error.className = 'error';
|
|
38
|
+
this._error.part.add('error');
|
|
39
|
+
this._error.textContent = 'Image unavailable';
|
|
40
|
+
this._error.setAttribute('role', 'img');
|
|
41
|
+
this._preview.type = 'button';
|
|
42
|
+
this._preview.className = 'preview-trigger';
|
|
43
|
+
this._preview.part.add('preview-trigger');
|
|
44
|
+
const label = document.createElement('span');
|
|
45
|
+
label.textContent = 'Preview';
|
|
46
|
+
this._preview.append(label);
|
|
47
|
+
this._frame.append(this._imageHost, this._placeholder, this._error, this._preview);
|
|
48
|
+
root.append(style, this._frame);
|
|
49
|
+
this._viewer = new HYImageViewer(this, root, detail => this.dispatchEvent(new CustomEvent('preview-open-change', { detail, bubbles: true, composed: true })), () => { });
|
|
50
|
+
this._preview.addEventListener('click', () => this.showPreview());
|
|
51
|
+
}
|
|
52
|
+
connectedCallback() { this._sourceKey = ''; this._sync(); }
|
|
53
|
+
disconnectedCallback() { this._loadListeners?.abort(); this._loadListeners = null; this._viewer.dispose(); }
|
|
54
|
+
attributeChangedCallback() { this._sync(); }
|
|
55
|
+
get src() { return this.getAttribute('src') ?? ''; }
|
|
56
|
+
set src(value) { this.setAttribute('src', value); }
|
|
57
|
+
get alt() { return this.getAttribute('alt') ?? ''; }
|
|
58
|
+
set alt(value) { this.setAttribute('alt', value); }
|
|
59
|
+
get fallback() { return this.getAttribute('fallback') ?? ''; }
|
|
60
|
+
set fallback(value) { this.setAttribute('fallback', value); }
|
|
61
|
+
get preview() { return this.getAttribute('preview') !== 'false'; }
|
|
62
|
+
set preview(value) { this.setAttribute('preview', String(value)); }
|
|
63
|
+
get previewSrc() { return this.getAttribute('preview-src') || (this._usedFallback ? this.fallback : this._image?.currentSrc || this.src); }
|
|
64
|
+
set previewSrc(value) { this.setAttribute('preview-src', value); }
|
|
65
|
+
get width() { return this.getAttribute('width') ?? ''; }
|
|
66
|
+
set width(value) { this.setAttribute('width', String(value)); }
|
|
67
|
+
get height() { return this.getAttribute('height') ?? ''; }
|
|
68
|
+
set height(value) { this.setAttribute('height', String(value)); }
|
|
69
|
+
get fit() { return this.getAttribute('fit') ?? 'contain'; }
|
|
70
|
+
set fit(value) { this.setAttribute('fit', value); }
|
|
71
|
+
get loading() { return this.getAttribute('loading') === 'lazy' ? 'lazy' : 'eager'; }
|
|
72
|
+
set loading(value) { this.setAttribute('loading', value); }
|
|
73
|
+
get status() { return this._status; }
|
|
74
|
+
showPreview() { if (this._status === 'loaded' && this.preview && this.previewSrc) {
|
|
75
|
+
this._viewer.setItems([{ src: this.previewSrc, alt: this.alt }], 0);
|
|
76
|
+
this._viewer.show();
|
|
77
|
+
} }
|
|
78
|
+
hidePreview() { this._viewer.close(); }
|
|
79
|
+
_sync() {
|
|
80
|
+
for (const name of ['width', 'height']) {
|
|
81
|
+
const value = this.getAttribute(name) ?? '';
|
|
82
|
+
this._frame.style[name] = /^\d+(\.\d+)?$/u.test(value) ? `${value}px` : value && CSS.supports(name, value) ? value : '';
|
|
83
|
+
}
|
|
84
|
+
this._frame.style.setProperty('--_fit', ['contain', 'cover', 'fill', 'none', 'scale-down'].includes(this.fit) ? this.fit : 'contain');
|
|
85
|
+
const key = JSON.stringify([this.src, this.getAttribute('srcset'), this.getAttribute('sizes'), this.fallback]);
|
|
86
|
+
if (this.isConnected && key !== this._sourceKey) {
|
|
87
|
+
this._sourceKey = key;
|
|
88
|
+
this._usedFallback = false;
|
|
89
|
+
this._viewer.close();
|
|
90
|
+
this._load(this.src, false);
|
|
91
|
+
}
|
|
92
|
+
if (this._image) {
|
|
93
|
+
this._image.alt = this.alt;
|
|
94
|
+
this._image.loading = this.loading;
|
|
95
|
+
}
|
|
96
|
+
this._placeholder.hidden = this._status !== 'loading';
|
|
97
|
+
this._error.hidden = this._status !== 'error' && this._status !== 'empty';
|
|
98
|
+
this._error.setAttribute('aria-label', this.alt || 'Image unavailable');
|
|
99
|
+
this._preview.hidden = !this.preview || this._status !== 'loaded';
|
|
100
|
+
this._preview.setAttribute('aria-label', this.getAttribute('aria-label') || `Preview ${this.alt || 'image'}`);
|
|
101
|
+
this._frame.setAttribute('aria-busy', String(this._status === 'loading'));
|
|
102
|
+
if (!this.preview)
|
|
103
|
+
this._viewer.close();
|
|
104
|
+
}
|
|
105
|
+
_load(src, fallback) {
|
|
106
|
+
this._loadListeners?.abort();
|
|
107
|
+
this._loadListeners = new AbortController();
|
|
108
|
+
const { signal } = this._loadListeners;
|
|
109
|
+
this._imageHost.replaceChildren();
|
|
110
|
+
this._image = null;
|
|
111
|
+
if (!src && (fallback || !this.getAttribute('srcset'))) {
|
|
112
|
+
this._status = 'empty';
|
|
113
|
+
this._sync();
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
this._status = 'loading';
|
|
117
|
+
const image = document.createElement('img');
|
|
118
|
+
image.className = 'image';
|
|
119
|
+
image.part.add('image');
|
|
120
|
+
image.alt = this.alt;
|
|
121
|
+
image.loading = this.loading;
|
|
122
|
+
image.decoding = 'async';
|
|
123
|
+
this._image = image;
|
|
124
|
+
if (!fallback) {
|
|
125
|
+
image.srcset = this.getAttribute('srcset') ?? '';
|
|
126
|
+
image.sizes = this.getAttribute('sizes') ?? '';
|
|
127
|
+
}
|
|
128
|
+
image.addEventListener('load', () => { if (this._image !== image)
|
|
129
|
+
return; this._status = 'loaded'; this._sync(); this.dispatchEvent(new CustomEvent('image-load', { detail: { src: image.currentSrc || src, naturalWidth: image.naturalWidth, naturalHeight: image.naturalHeight }, bubbles: true, composed: true })); }, { signal });
|
|
130
|
+
image.addEventListener('error', () => {
|
|
131
|
+
this.dispatchEvent(new CustomEvent('image-error', { detail: { src, fallback }, bubbles: true, composed: true }));
|
|
132
|
+
if (this._image !== image)
|
|
133
|
+
return;
|
|
134
|
+
if (!fallback && this.fallback && this.fallback !== src) {
|
|
135
|
+
this._usedFallback = true;
|
|
136
|
+
this._load(this.fallback, true);
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
this._status = 'error';
|
|
140
|
+
image.hidden = true;
|
|
141
|
+
this._sync();
|
|
142
|
+
}
|
|
143
|
+
}, { signal });
|
|
144
|
+
this._imageHost.append(image);
|
|
145
|
+
if (src)
|
|
146
|
+
image.src = src;
|
|
147
|
+
this._sync();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
export function defineImageComponents() { if (!customElements.get('hy-image'))
|
|
151
|
+
customElements.define('hy-image', HYImage); }
|
|
152
|
+
//# sourceMappingURL=image.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -86,4 +86,52 @@ export type { HYInputChangeDetail, HYInputSearchDetail, HYInputSearchSource, HYI
|
|
|
86
86
|
export type { HYNotificationCloseDetail, HYNotificationCloseReason, HYNotificationMethodOptions, HYNotificationOpenDetail, HYNotificationOptions, HYNotificationPlacement, HYNotificationType, } from './notification.js';
|
|
87
87
|
export type { HYToastCloseDetail, HYToastCloseReason, HYToastMethodOptions, HYToastOpenDetail, HYToastOptions, HYToastPlacement, HYToastType, } from './toast.js';
|
|
88
88
|
export type { HYTreeDataChangeDetail, HYTreeDropPosition, HYTreeNodeContextMenuDetail, HYTreeNodeData, HYTreeSelectionChangeDetail, } from './tree.js';
|
|
89
|
+
export { defineAlertComponents, HYAlert } from './alert.js';
|
|
90
|
+
export type { HYAlertCloseDetail, HYAlertType } from './alert.js';
|
|
91
|
+
export { defineAnchorComponents, HYAnchor } from './anchor.js';
|
|
92
|
+
export type { HYAnchorChangeDetail, HYAnchorClickDetail, HYAnchorDirection, HYAnchorItem } from './anchor.js';
|
|
93
|
+
export { defineSegmentedComponents, HYSegmented } from './segmented.js';
|
|
94
|
+
export type { HYSegmentedChangeDetail, HYSegmentedOption, HYSegmentedOptionInput, HYSegmentedSize } from './segmented.js';
|
|
95
|
+
export { defineMentionsComponents, HYMentions } from './mentions.js';
|
|
96
|
+
export type { HYMentionsOption, HYMentionsChangeDetail, HYMentionsSearchDetail, HYMentionsSelectDetail, HYMentionsPlacement, HYMentionsFilter } from './mentions.js';
|
|
97
|
+
export { HYSwitch, defineSwitchComponents } from './switch.js';
|
|
98
|
+
export type { HYSwitchChangeDetail, HYSwitchSize } from './switch.js';
|
|
99
|
+
export { HYProgress, defineProgressComponents } from './progress.js';
|
|
100
|
+
export type { HYProgressType, HYProgressStatus } from './progress.js';
|
|
101
|
+
export { HYSpin, defineSpinComponents } from './spin.js';
|
|
102
|
+
export type { HYSpinSize } from './spin.js';
|
|
103
|
+
export { HYPopover, definePopoverComponents } from './popover.js';
|
|
104
|
+
export type { HYPopoverPlacement, HYPopoverTrigger, HYPopoverCloseReason, HYPopoverOpenChangeDetail } from './popover.js';
|
|
105
|
+
export { HYPopconfirm, definePopconfirmComponents } from './popconfirm.js';
|
|
106
|
+
export type { HYPopconfirmActionDetail } from './popconfirm.js';
|
|
107
|
+
export { HYForm, defineFormComponents } from './form.js';
|
|
108
|
+
export type { HYFormValue, HYFormSubmitDetail, HYFormInvalidDetail, HYFormLayout } from './form.js';
|
|
109
|
+
export { HYFormItem, defineFormItemComponents } from './form-item.js';
|
|
110
|
+
export type { HYFormRule, HYFormItemStatus, HYFormItemValidateDetail } from './form-item.js';
|
|
111
|
+
export { HYUpload, defineUploadComponents } from './upload.js';
|
|
112
|
+
export type { HYUploadStatus, HYUploadChangeReason, HYUploadRejectReason, HYUploadFile, HYUploadChangeDetail, HYUploadRejectDetail, HYUploadRemoveDetail, HYUploadRequestOptions, HYUploadRequest, HYUploadBeforeUpload } from './upload.js';
|
|
113
|
+
export { HYAutoComplete, defineAutoCompleteComponents } from './auto-complete.js';
|
|
114
|
+
export type { HYAutoCompleteOption, HYAutoCompleteChangeDetail, HYAutoCompleteSelectDetail, HYAutoCompleteFilter } from './auto-complete.js';
|
|
115
|
+
export { HYMenu, defineMenuComponents } from './menu.js';
|
|
116
|
+
export type { HYMenuItem, HYMenuMode, HYMenuSelectDetail, HYMenuOpenChangeDetail } from './menu.js';
|
|
117
|
+
export { HYPagination, definePaginationComponents } from './pagination.js';
|
|
118
|
+
export type { HYPaginationChangeDetail } from './pagination.js';
|
|
119
|
+
export { HYTreeSelect, defineTreeSelectComponents } from './tree-select.js';
|
|
120
|
+
export type { HYTreeSelectOption, HYTreeSelectChangeDetail, HYTreeSelectExpandDetail } from './tree-select.js';
|
|
121
|
+
export { HYImage, defineImageComponents } from './image.js';
|
|
122
|
+
export type { HYImageStatus, HYImageLoadDetail, HYImageErrorDetail } from './image.js';
|
|
123
|
+
export { HYImagePreview, defineImagePreviewComponents } from './image-preview.js';
|
|
124
|
+
export type { HYImagePreviewItem, HYImagePreviewOpenDetail, HYImagePreviewChangeDetail } from './image-preview.js';
|
|
125
|
+
export { HYEmpty, defineEmptyComponents } from './empty.js';
|
|
126
|
+
export type { HYEmptyImage, HYEmptySize } from './empty.js';
|
|
127
|
+
export { HYResult, defineResultComponents } from './result.js';
|
|
128
|
+
export type { HYResultStatus } from './result.js';
|
|
129
|
+
export { HYAvatar, defineAvatarComponents } from './avatar.js';
|
|
130
|
+
export type { HYAvatarShape, HYAvatarSize, HYAvatarFit, HYAvatarStatus, HYAvatarLoadDetail, HYAvatarErrorDetail } from './avatar.js';
|
|
131
|
+
export { HYCard, defineCardComponents } from './card.js';
|
|
132
|
+
export type { HYCardSize } from './card.js';
|
|
133
|
+
export { HYRibbon, defineRibbonComponents } from './ribbon.js';
|
|
134
|
+
export type { HYRibbonPlacement } from './ribbon.js';
|
|
135
|
+
export { HYDescriptions, defineDescriptionsComponents } from './descriptions.js';
|
|
136
|
+
export type { HYDescriptionItem, HYDescriptionsLayout, HYDescriptionsSize } from './descriptions.js';
|
|
89
137
|
export declare function defineHaiyueUI(): void;
|
package/dist/index.js
CHANGED
|
@@ -26,6 +26,26 @@ import { defineDialogComponents } from './dialog.js';
|
|
|
26
26
|
import { defineDrawerComponents } from './drawer.js';
|
|
27
27
|
import { defineDraggableComponents } from './draggable.js';
|
|
28
28
|
import { defineInputComponents } from './input.js';
|
|
29
|
+
import { defineMentionsComponents } from './mentions.js';
|
|
30
|
+
import { defineSwitchComponents } from './switch.js';
|
|
31
|
+
import { defineProgressComponents } from './progress.js';
|
|
32
|
+
import { defineSpinComponents } from './spin.js';
|
|
33
|
+
import { definePopoverComponents } from './popover.js';
|
|
34
|
+
import { definePopconfirmComponents } from './popconfirm.js';
|
|
35
|
+
import { defineFormComponents } from './form.js';
|
|
36
|
+
import { defineFormItemComponents } from './form-item.js';
|
|
37
|
+
import { defineUploadComponents } from './upload.js';
|
|
38
|
+
import { defineAutoCompleteComponents } from './auto-complete.js';
|
|
39
|
+
import { defineMenuComponents } from './menu.js';
|
|
40
|
+
import { definePaginationComponents } from './pagination.js';
|
|
41
|
+
import { defineTreeSelectComponents } from './tree-select.js';
|
|
42
|
+
import { defineImageComponents } from './image.js';
|
|
43
|
+
import { defineImagePreviewComponents } from './image-preview.js';
|
|
44
|
+
import { defineEmptyComponents } from './empty.js';
|
|
45
|
+
import { defineResultComponents } from './result.js';
|
|
46
|
+
import { defineAvatarComponents } from './avatar.js';
|
|
47
|
+
import { defineCardComponents } from './card.js';
|
|
48
|
+
import { defineDescriptionsComponents } from './descriptions.js';
|
|
29
49
|
import { defineNotificationComponents } from './notification.js';
|
|
30
50
|
import { defineToastComponents } from './toast.js';
|
|
31
51
|
import { defineHistoryControlsComponents } from './history-controls.js';
|
|
@@ -46,8 +66,12 @@ import { defineStepsComponents } from './steps.js';
|
|
|
46
66
|
import { defineAffixComponents } from './affix.js';
|
|
47
67
|
import { defineTourComponents } from './tour.js';
|
|
48
68
|
import { defineBadgeComponents } from './badge.js';
|
|
69
|
+
import { defineRibbonComponents } from './ribbon.js';
|
|
49
70
|
import { defineTagComponents } from './tag.js';
|
|
50
71
|
import { defineCollapseComponents } from './collapse.js';
|
|
72
|
+
import { defineAlertComponents } from './alert.js';
|
|
73
|
+
import { defineAnchorComponents } from './anchor.js';
|
|
74
|
+
import { defineSegmentedComponents } from './segmented.js';
|
|
51
75
|
export { defineButtonComponents, HYButton, } from './button.js';
|
|
52
76
|
export { defineButtonGroupComponents, HYButtonGroup, } from './button-group.js';
|
|
53
77
|
export { defineBorderBeamComponents, HYBorderBeam, } from './border-beam.js';
|
|
@@ -88,7 +112,52 @@ export { defineTourComponents, HYTour, } from './tour.js';
|
|
|
88
112
|
export { defineBadgeComponents, HYBadge, } from './badge.js';
|
|
89
113
|
export { defineTagComponents, HYTag, } from './tag.js';
|
|
90
114
|
export { defineCollapseComponents, HYCollapse, } from './collapse.js';
|
|
115
|
+
export { defineAlertComponents, HYAlert } from './alert.js';
|
|
116
|
+
export { defineAnchorComponents, HYAnchor } from './anchor.js';
|
|
117
|
+
export { defineSegmentedComponents, HYSegmented } from './segmented.js';
|
|
118
|
+
export { defineMentionsComponents, HYMentions } from './mentions.js';
|
|
119
|
+
export { HYSwitch, defineSwitchComponents } from './switch.js';
|
|
120
|
+
export { HYProgress, defineProgressComponents } from './progress.js';
|
|
121
|
+
export { HYSpin, defineSpinComponents } from './spin.js';
|
|
122
|
+
export { HYPopover, definePopoverComponents } from './popover.js';
|
|
123
|
+
export { HYPopconfirm, definePopconfirmComponents } from './popconfirm.js';
|
|
124
|
+
export { HYForm, defineFormComponents } from './form.js';
|
|
125
|
+
export { HYFormItem, defineFormItemComponents } from './form-item.js';
|
|
126
|
+
export { HYUpload, defineUploadComponents } from './upload.js';
|
|
127
|
+
export { HYAutoComplete, defineAutoCompleteComponents } from './auto-complete.js';
|
|
128
|
+
export { HYMenu, defineMenuComponents } from './menu.js';
|
|
129
|
+
export { HYPagination, definePaginationComponents } from './pagination.js';
|
|
130
|
+
export { HYTreeSelect, defineTreeSelectComponents } from './tree-select.js';
|
|
131
|
+
export { HYImage, defineImageComponents } from './image.js';
|
|
132
|
+
export { HYImagePreview, defineImagePreviewComponents } from './image-preview.js';
|
|
133
|
+
export { HYEmpty, defineEmptyComponents } from './empty.js';
|
|
134
|
+
export { HYResult, defineResultComponents } from './result.js';
|
|
135
|
+
export { HYAvatar, defineAvatarComponents } from './avatar.js';
|
|
136
|
+
export { HYCard, defineCardComponents } from './card.js';
|
|
137
|
+
export { HYRibbon, defineRibbonComponents } from './ribbon.js';
|
|
138
|
+
export { HYDescriptions, defineDescriptionsComponents } from './descriptions.js';
|
|
91
139
|
export function defineHaiyueUI() {
|
|
140
|
+
defineEmptyComponents();
|
|
141
|
+
defineResultComponents();
|
|
142
|
+
defineAvatarComponents();
|
|
143
|
+
defineCardComponents();
|
|
144
|
+
defineDescriptionsComponents();
|
|
145
|
+
defineAutoCompleteComponents();
|
|
146
|
+
defineMenuComponents();
|
|
147
|
+
definePaginationComponents();
|
|
148
|
+
defineTreeSelectComponents();
|
|
149
|
+
defineImageComponents();
|
|
150
|
+
defineImagePreviewComponents();
|
|
151
|
+
defineSwitchComponents();
|
|
152
|
+
defineProgressComponents();
|
|
153
|
+
defineSpinComponents();
|
|
154
|
+
definePopoverComponents();
|
|
155
|
+
definePopconfirmComponents();
|
|
156
|
+
defineFormComponents();
|
|
157
|
+
defineFormItemComponents();
|
|
158
|
+
defineUploadComponents();
|
|
159
|
+
defineAlertComponents();
|
|
160
|
+
defineAnchorComponents();
|
|
92
161
|
defineExpandableComponents();
|
|
93
162
|
defineBorderBeamComponents();
|
|
94
163
|
defineButtonComponents();
|
|
@@ -100,6 +169,7 @@ export function defineHaiyueUI() {
|
|
|
100
169
|
defineQRCodeComponents();
|
|
101
170
|
defineModalComponents();
|
|
102
171
|
defineSelectComponents();
|
|
172
|
+
defineSegmentedComponents();
|
|
103
173
|
defineTabsComponents();
|
|
104
174
|
defineContextMenuComponents();
|
|
105
175
|
defineDropdownComponents();
|
|
@@ -112,6 +182,7 @@ export function defineHaiyueUI() {
|
|
|
112
182
|
defineDrawerComponents();
|
|
113
183
|
defineDraggableComponents();
|
|
114
184
|
defineInputComponents();
|
|
185
|
+
defineMentionsComponents();
|
|
115
186
|
defineNotificationComponents();
|
|
116
187
|
defineToastComponents();
|
|
117
188
|
defineHistoryControlsComponents();
|
|
@@ -132,6 +203,7 @@ export function defineHaiyueUI() {
|
|
|
132
203
|
defineAffixComponents();
|
|
133
204
|
defineTourComponents();
|
|
134
205
|
defineBadgeComponents();
|
|
206
|
+
defineRibbonComponents();
|
|
135
207
|
defineTagComponents();
|
|
136
208
|
defineCollapseComponents();
|
|
137
209
|
}
|
package/dist/input.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export interface HYInputSearchDetail {
|
|
|
11
11
|
source: HYInputSearchSource;
|
|
12
12
|
}
|
|
13
13
|
export declare class HYInput extends HTMLElement {
|
|
14
|
+
static readonly formAssociated = true;
|
|
14
15
|
private readonly _control;
|
|
15
16
|
private readonly _prefix;
|
|
16
17
|
private readonly _prefixSlot;
|
|
@@ -20,6 +21,7 @@ export declare class HYInput extends HTMLElement {
|
|
|
20
21
|
private readonly _suffixSlot;
|
|
21
22
|
private readonly _suffixText;
|
|
22
23
|
private readonly _searchButton;
|
|
24
|
+
private readonly _formControl;
|
|
23
25
|
static get observedAttributes(): string[];
|
|
24
26
|
constructor();
|
|
25
27
|
connectedCallback(): void;
|
|
@@ -41,6 +43,15 @@ export declare class HYInput extends HTMLElement {
|
|
|
41
43
|
get readOnly(): boolean;
|
|
42
44
|
set readOnly(value: boolean);
|
|
43
45
|
get valid(): boolean;
|
|
46
|
+
get form(): HTMLFormElement | null;
|
|
47
|
+
get validity(): ValidityState;
|
|
48
|
+
get validationMessage(): string;
|
|
49
|
+
checkValidity(): boolean;
|
|
50
|
+
reportValidity(): boolean;
|
|
51
|
+
setCustomValidity(message: string): void;
|
|
52
|
+
formDisabledCallback(disabled: boolean): void;
|
|
53
|
+
formResetCallback(): void;
|
|
54
|
+
formStateRestoreCallback(state: string | File | FormData | null): void;
|
|
44
55
|
focus(options?: FocusOptions): void;
|
|
45
56
|
select(): void;
|
|
46
57
|
search(): boolean;
|
package/dist/input.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { HYFormControl } from './internal/form-control.js';
|
|
1
2
|
export class HYInput extends HTMLElement {
|
|
3
|
+
static formAssociated = true;
|
|
2
4
|
_control = document.createElement('div');
|
|
3
5
|
_prefix = document.createElement('span');
|
|
4
6
|
_prefixSlot = document.createElement('slot');
|
|
@@ -8,10 +10,11 @@ export class HYInput extends HTMLElement {
|
|
|
8
10
|
_suffixSlot = document.createElement('slot');
|
|
9
11
|
_suffixText = document.createElement('span');
|
|
10
12
|
_searchButton = document.createElement('button');
|
|
13
|
+
_formControl = new HYFormControl(this, this._input);
|
|
11
14
|
static get observedAttributes() {
|
|
12
15
|
return [
|
|
13
16
|
'type', 'value', 'min', 'max', 'step', 'placeholder', 'disabled', 'readonly',
|
|
14
|
-
'required', 'name', 'autocomplete', 'aria-label', 'title', 'prefix', 'suffix',
|
|
17
|
+
'required', 'name', 'autocomplete', 'aria-label', 'title', 'prefix', 'suffix', 'minlength', 'maxlength', 'pattern',
|
|
15
18
|
'search-label',
|
|
16
19
|
];
|
|
17
20
|
}
|
|
@@ -25,12 +28,12 @@ export class HYInput extends HTMLElement {
|
|
|
25
28
|
display: flex;
|
|
26
29
|
width: 100%;
|
|
27
30
|
min-width: 0;
|
|
28
|
-
height: var(--hy-input-height, 28px);
|
|
31
|
+
height: var(--hy-input-height, var(--hy-control-height-sm, 28px));
|
|
29
32
|
box-sizing: border-box;
|
|
30
33
|
align-items: stretch;
|
|
31
34
|
overflow: hidden;
|
|
32
35
|
border: 1px solid var(--hy-border-color, #303746);
|
|
33
|
-
border-radius: var(--hy-input-radius, 4px);
|
|
36
|
+
border-radius: var(--hy-input-radius, var(--hy-radius-sm, 4px));
|
|
34
37
|
color: var(--hy-text-color, #d8e2f2);
|
|
35
38
|
background: var(--hy-input-bg-color, var(--hy-surface-color, #121822));
|
|
36
39
|
transition: border-color 120ms ease, box-shadow 120ms ease;
|
|
@@ -44,28 +47,28 @@ export class HYInput extends HTMLElement {
|
|
|
44
47
|
width: 0;
|
|
45
48
|
min-width: 0;
|
|
46
49
|
box-sizing: border-box;
|
|
47
|
-
padding: 0 var(--hy-input-padding-inline, 8px);
|
|
50
|
+
padding: 0 var(--hy-input-padding-inline, var(--hy-space-4, 8px));
|
|
48
51
|
border: 0;
|
|
49
52
|
outline: none;
|
|
50
53
|
color: inherit;
|
|
51
54
|
background: transparent;
|
|
52
|
-
font: var(--hy-input-font, 12px system-ui, sans-serif);
|
|
55
|
+
font: var(--hy-input-font, var(--hy-font-size-sm, 12px) var(--hy-font-family, system-ui, sans-serif));
|
|
53
56
|
color-scheme: inherit;
|
|
54
57
|
}
|
|
55
58
|
input:disabled, input:read-only { cursor: default; }
|
|
56
|
-
input[type="color"] { min-width: 42px; padding:
|
|
59
|
+
input[type="color"] { min-width: 42px; padding: calc(var(--hy-space-1, 2px) + 1px); cursor: pointer; }
|
|
57
60
|
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
|
|
58
|
-
input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 2px; }
|
|
61
|
+
input[type="color"]::-webkit-color-swatch { border: 0; border-radius: var(--hy-radius-xs, 2px); }
|
|
59
62
|
input[type="search"]::-webkit-search-cancel-button { cursor: pointer; }
|
|
60
63
|
.affix {
|
|
61
64
|
display: inline-flex;
|
|
62
65
|
flex: 0 0 auto;
|
|
63
66
|
align-items: center;
|
|
64
67
|
max-width: 42%;
|
|
65
|
-
padding-inline: var(--hy-input-affix-padding, 8px);
|
|
68
|
+
padding-inline: var(--hy-input-affix-padding, var(--hy-space-4, 8px));
|
|
66
69
|
overflow: hidden;
|
|
67
|
-
color: var(--hy-input-affix-color, var(--hy-muted-text-color, #8290a3));
|
|
68
|
-
font: var(--hy-input-affix-font, 12px system-ui, sans-serif);
|
|
70
|
+
color: var(--hy-input-affix-color, var(--hy-muted-text-color, var(--hy-muted-color, #8290a3)));
|
|
71
|
+
font: var(--hy-input-affix-font, var(--hy-font-size-sm, 12px) var(--hy-font-family, system-ui, sans-serif));
|
|
69
72
|
text-overflow: ellipsis;
|
|
70
73
|
white-space: nowrap;
|
|
71
74
|
}
|
|
@@ -83,7 +86,7 @@ export class HYInput extends HTMLElement {
|
|
|
83
86
|
color: var(--hy-input-search-color, var(--hy-accent-color, #79a8ff));
|
|
84
87
|
background: var(--hy-input-search-bg, color-mix(in srgb, var(--hy-accent-color, #79a8ff) 11%, transparent));
|
|
85
88
|
cursor: pointer;
|
|
86
|
-
font: 16px/1 system-ui, sans-serif;
|
|
89
|
+
font: var(--hy-font-size-lg, 16px)/var(--hy-line-height-tight, 1) var(--hy-font-family, system-ui, sans-serif);
|
|
87
90
|
}
|
|
88
91
|
.search-button:hover:not(:disabled) { background: var(--hy-input-search-hover-bg, color-mix(in srgb, var(--hy-accent-color, #79a8ff) 20%, transparent)); }
|
|
89
92
|
.search-button:focus-visible { outline: 2px solid var(--hy-focus-border-color, #3d6fa8); outline-offset: -3px; }
|
|
@@ -118,6 +121,7 @@ export class HYInput extends HTMLElement {
|
|
|
118
121
|
this._prefixSlot.addEventListener('slotchange', this._onSlotChange);
|
|
119
122
|
this._suffixSlot.addEventListener('slotchange', this._onSlotChange);
|
|
120
123
|
this._sync();
|
|
124
|
+
this._formControl.connect();
|
|
121
125
|
}
|
|
122
126
|
disconnectedCallback() {
|
|
123
127
|
this._input.removeEventListener('input', this._onInput);
|
|
@@ -151,6 +155,15 @@ export class HYInput extends HTMLElement {
|
|
|
151
155
|
get readOnly() { return this.hasAttribute('readonly'); }
|
|
152
156
|
set readOnly(value) { this.toggleAttribute('readonly', value); }
|
|
153
157
|
get valid() { return this._input.validity.valid; }
|
|
158
|
+
get form() { return this._formControl.internals.form; }
|
|
159
|
+
get validity() { return this._formControl.internals.validity; }
|
|
160
|
+
get validationMessage() { return this._formControl.internals.validationMessage; }
|
|
161
|
+
checkValidity() { return this._formControl.internals.checkValidity(); }
|
|
162
|
+
reportValidity() { return this._formControl.internals.reportValidity(); }
|
|
163
|
+
setCustomValidity(message) { this._formControl.setCustomValidity(message); this._syncValidity(); }
|
|
164
|
+
formDisabledCallback(disabled) { this._formControl.disabled = disabled; this._sync(); }
|
|
165
|
+
formResetCallback() { this._formControl.reset(); this._syncValidity(); }
|
|
166
|
+
formStateRestoreCallback(state) { this._formControl.restore(state); }
|
|
154
167
|
focus(options) { this._input.focus(options); }
|
|
155
168
|
select() { this._input.select(); }
|
|
156
169
|
search() { return this._emitSearch('api'); }
|
|
@@ -161,7 +174,7 @@ export class HYInput extends HTMLElement {
|
|
|
161
174
|
const value = this.value;
|
|
162
175
|
if (this._input.value !== value)
|
|
163
176
|
this._input.value = type === 'color' && !/^#[0-9a-f]{6}$/iu.test(value) ? '#000000' : value;
|
|
164
|
-
for (const name of ['min', 'max', 'step', 'placeholder', 'name', 'autocomplete', 'aria-label', 'title']) {
|
|
177
|
+
for (const name of ['min', 'max', 'step', 'placeholder', 'name', 'autocomplete', 'aria-label', 'title', 'minlength', 'maxlength', 'pattern']) {
|
|
165
178
|
const attribute = this.getAttribute(name);
|
|
166
179
|
if (attribute === null) {
|
|
167
180
|
if (this._input.hasAttribute(name))
|
|
@@ -171,16 +184,17 @@ export class HYInput extends HTMLElement {
|
|
|
171
184
|
this._input.setAttribute(name, attribute);
|
|
172
185
|
}
|
|
173
186
|
// Reassigning even an unchanged placeholder or state can split Chromium's undo group.
|
|
174
|
-
|
|
175
|
-
|
|
187
|
+
const disabled = this.disabled || this._formControl.disabled;
|
|
188
|
+
if (this._input.disabled !== disabled)
|
|
189
|
+
this._input.disabled = disabled;
|
|
176
190
|
if (this._input.readOnly !== this.readOnly)
|
|
177
191
|
this._input.readOnly = this.readOnly;
|
|
178
192
|
if (this._input.required !== this.hasAttribute('required'))
|
|
179
193
|
this._input.required = this.hasAttribute('required');
|
|
180
194
|
this._searchButton.hidden = type !== 'search';
|
|
181
|
-
this._searchButton.disabled =
|
|
195
|
+
this._searchButton.disabled = disabled;
|
|
182
196
|
this._searchButton.setAttribute('aria-label', this.searchLabel);
|
|
183
|
-
this._control.classList.toggle('disabled',
|
|
197
|
+
this._control.classList.toggle('disabled', disabled);
|
|
184
198
|
this._control.classList.toggle('readonly', this.readOnly);
|
|
185
199
|
this._syncAffixes();
|
|
186
200
|
this._syncValidity();
|
|
@@ -195,7 +209,7 @@ export class HYInput extends HTMLElement {
|
|
|
195
209
|
fallback.hidden = hasAssignedContent || !text;
|
|
196
210
|
container.hidden = !hasAssignedContent && !text;
|
|
197
211
|
}
|
|
198
|
-
_syncValidity() { this._control.classList.toggle('invalid', !this.valid); }
|
|
212
|
+
_syncValidity() { this._control.classList.toggle('invalid', !this.valid); this._formControl.sync(); }
|
|
199
213
|
_setOptionalAttribute(name, value) {
|
|
200
214
|
const normalized = String(value ?? '').trim();
|
|
201
215
|
if (normalized)
|
|
@@ -223,7 +237,7 @@ export class HYInput extends HTMLElement {
|
|
|
223
237
|
};
|
|
224
238
|
_onSearchClick = () => { this._emitSearch('button'); };
|
|
225
239
|
_emitSearch(source) {
|
|
226
|
-
if (this.disabled || this.type !== 'search')
|
|
240
|
+
if (this.disabled || this._formControl.disabled || this.type !== 'search')
|
|
227
241
|
return false;
|
|
228
242
|
return this.dispatchEvent(new CustomEvent('search', {
|
|
229
243
|
detail: { value: this._input.value, valid: this.valid, source },
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const HY_COMBOBOX_STYLES = "\n :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); }\n .control { display: flex; align-items: center; gap: var(--hy-space-2, 4px); min-height: var(--hy-control-height-sm, 28px); box-sizing: border-box; padding: 0 var(--hy-space-4, 8px); border: 1px solid var(--hy-border-color, #303746); border-radius: var(--hy-radius-sm, 4px); background: var(--hy-input-bg-color, var(--hy-surface-color, #121822)); }\n .control:focus-within { border-color: var(--hy-focus-border-color, #79a8ff); box-shadow: 0 0 0 2px var(--hy-focus-ring-color, rgba(61,111,168,.24)); }\n .control.disabled { opacity: .55; } input { flex: 1; width: 0; min-width: 30px; min-height: inherit; box-sizing: border-box; padding: 3px 0; border: 0; outline: 0; color: inherit; background: transparent; font: inherit; }\n input::placeholder { color: var(--hy-muted-text-color, #8290a3); } input:disabled { cursor: not-allowed; }\n .clear { flex: 0 0 auto; padding: 0 3px; border: 0; color: var(--hy-muted-text-color, #8290a3); background: transparent; font: inherit; cursor: pointer; }\n .clear:focus-visible { outline: 2px solid var(--hy-focus-border-color, #79a8ff); } button:disabled { cursor: not-allowed; }\n .panel { position: fixed; inset: auto; margin: 0; box-sizing: border-box; max-width: calc(100vw - 16px); max-height: var(--hy-popup-max-height, 280px); overflow: auto; padding: var(--hy-space-2, 4px); border: 1px solid var(--hy-border-color, #303746); border-radius: var(--hy-radius-sm, 4px); color: var(--hy-text-color, #d8e2f2); background: var(--hy-menu-bg-color, var(--hy-surface-elevated-color, #1b2230)); box-shadow: var(--hy-popup-shadow, 0 8px 24px rgba(0,0,0,.24)); font: inherit; z-index: var(--hy-popup-z-index, 1050); }\n .option { padding: var(--hy-space-3, 6px) var(--hy-space-4, 8px); border-radius: var(--hy-radius-xs, 2px); overflow-wrap: anywhere; cursor: pointer; }\n .option.active { color: var(--hy-selected-text-color, #fff); background: var(--hy-selected-bg-color, #255a91); }\n .option[aria-disabled=\"true\"] { color: var(--hy-disabled-text-color, #65738a); cursor: not-allowed; }\n .status { padding: var(--hy-space-3, 6px) var(--hy-space-4, 8px); color: var(--hy-muted-text-color, #8290a3); } [hidden] { display: none !important; }\n";
|
|
2
|
+
/** Shared top-layer positioning and owned listeners, without public component dependencies. */
|
|
3
|
+
export declare class HYAnchoredPopup {
|
|
4
|
+
private readonly _host;
|
|
5
|
+
private readonly _anchor;
|
|
6
|
+
readonly panel: HTMLElement;
|
|
7
|
+
private readonly _dismiss;
|
|
8
|
+
private readonly _side;
|
|
9
|
+
private _listeners;
|
|
10
|
+
private _observer;
|
|
11
|
+
constructor(_host: HTMLElement, _anchor: HTMLElement, panel: HTMLElement, _dismiss: () => void, _side?: 'bottom' | 'right');
|
|
12
|
+
connect(): void;
|
|
13
|
+
dispose(): void;
|
|
14
|
+
show(): void;
|
|
15
|
+
hide(): void;
|
|
16
|
+
position: () => void;
|
|
17
|
+
private _outside;
|
|
18
|
+
private _scroll;
|
|
19
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
export const HY_COMBOBOX_STYLES = `
|
|
2
|
+
: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); }
|
|
3
|
+
.control { display: flex; align-items: center; gap: var(--hy-space-2, 4px); min-height: var(--hy-control-height-sm, 28px); box-sizing: border-box; padding: 0 var(--hy-space-4, 8px); border: 1px solid var(--hy-border-color, #303746); border-radius: var(--hy-radius-sm, 4px); background: var(--hy-input-bg-color, var(--hy-surface-color, #121822)); }
|
|
4
|
+
.control:focus-within { border-color: var(--hy-focus-border-color, #79a8ff); box-shadow: 0 0 0 2px var(--hy-focus-ring-color, rgba(61,111,168,.24)); }
|
|
5
|
+
.control.disabled { opacity: .55; } input { flex: 1; width: 0; min-width: 30px; min-height: inherit; box-sizing: border-box; padding: 3px 0; border: 0; outline: 0; color: inherit; background: transparent; font: inherit; }
|
|
6
|
+
input::placeholder { color: var(--hy-muted-text-color, #8290a3); } input:disabled { cursor: not-allowed; }
|
|
7
|
+
.clear { flex: 0 0 auto; padding: 0 3px; border: 0; color: var(--hy-muted-text-color, #8290a3); background: transparent; font: inherit; cursor: pointer; }
|
|
8
|
+
.clear:focus-visible { outline: 2px solid var(--hy-focus-border-color, #79a8ff); } button:disabled { cursor: not-allowed; }
|
|
9
|
+
.panel { position: fixed; inset: auto; margin: 0; box-sizing: border-box; max-width: calc(100vw - 16px); max-height: var(--hy-popup-max-height, 280px); overflow: auto; padding: var(--hy-space-2, 4px); border: 1px solid var(--hy-border-color, #303746); border-radius: var(--hy-radius-sm, 4px); color: var(--hy-text-color, #d8e2f2); background: var(--hy-menu-bg-color, var(--hy-surface-elevated-color, #1b2230)); box-shadow: var(--hy-popup-shadow, 0 8px 24px rgba(0,0,0,.24)); font: inherit; z-index: var(--hy-popup-z-index, 1050); }
|
|
10
|
+
.option { padding: var(--hy-space-3, 6px) var(--hy-space-4, 8px); border-radius: var(--hy-radius-xs, 2px); overflow-wrap: anywhere; cursor: pointer; }
|
|
11
|
+
.option.active { color: var(--hy-selected-text-color, #fff); background: var(--hy-selected-bg-color, #255a91); }
|
|
12
|
+
.option[aria-disabled="true"] { color: var(--hy-disabled-text-color, #65738a); cursor: not-allowed; }
|
|
13
|
+
.status { padding: var(--hy-space-3, 6px) var(--hy-space-4, 8px); color: var(--hy-muted-text-color, #8290a3); } [hidden] { display: none !important; }
|
|
14
|
+
`;
|
|
15
|
+
/** Shared top-layer positioning and owned listeners, without public component dependencies. */
|
|
16
|
+
export class HYAnchoredPopup {
|
|
17
|
+
_host;
|
|
18
|
+
_anchor;
|
|
19
|
+
panel;
|
|
20
|
+
_dismiss;
|
|
21
|
+
_side;
|
|
22
|
+
_listeners = null;
|
|
23
|
+
_observer = null;
|
|
24
|
+
constructor(_host, _anchor, panel, _dismiss, _side = 'bottom') {
|
|
25
|
+
this._host = _host;
|
|
26
|
+
this._anchor = _anchor;
|
|
27
|
+
this.panel = panel;
|
|
28
|
+
this._dismiss = _dismiss;
|
|
29
|
+
this._side = _side;
|
|
30
|
+
panel.setAttribute('popover', 'manual');
|
|
31
|
+
panel.hidden = true;
|
|
32
|
+
}
|
|
33
|
+
connect() {
|
|
34
|
+
this.dispose();
|
|
35
|
+
this._listeners = new AbortController();
|
|
36
|
+
const { signal } = this._listeners;
|
|
37
|
+
const document = this._host.ownerDocument;
|
|
38
|
+
document.addEventListener('pointerdown', this._outside, { capture: true, signal });
|
|
39
|
+
document.addEventListener('scroll', this._scroll, { capture: true, signal });
|
|
40
|
+
document.defaultView?.addEventListener('resize', this.position, { signal });
|
|
41
|
+
this._observer = new ResizeObserver(this.position);
|
|
42
|
+
this._observer.observe(this._anchor);
|
|
43
|
+
this._observer.observe(this.panel);
|
|
44
|
+
}
|
|
45
|
+
dispose() { this._listeners?.abort(); this._listeners = null; this._observer?.disconnect(); this._observer = null; this.hide(); }
|
|
46
|
+
show() {
|
|
47
|
+
if (!this._host.isConnected)
|
|
48
|
+
return;
|
|
49
|
+
this.panel.hidden = false;
|
|
50
|
+
if (this.panel.showPopover && !this.panel.matches(':popover-open'))
|
|
51
|
+
this.panel.showPopover();
|
|
52
|
+
this.position();
|
|
53
|
+
}
|
|
54
|
+
hide() { if (this.panel.hidePopover && this.panel.matches(':popover-open'))
|
|
55
|
+
this.panel.hidePopover(); this.panel.hidden = true; }
|
|
56
|
+
position = () => {
|
|
57
|
+
if (this.panel.hidden || !this._host.isConnected)
|
|
58
|
+
return;
|
|
59
|
+
const view = this._host.ownerDocument.defaultView;
|
|
60
|
+
if (!view)
|
|
61
|
+
return;
|
|
62
|
+
const anchor = this._anchor.getBoundingClientRect();
|
|
63
|
+
if (anchor.bottom < 0 || anchor.top > view.innerHeight || anchor.right < 0 || anchor.left > view.innerWidth) {
|
|
64
|
+
this._dismiss();
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const width = Math.min(Math.max(anchor.width, 180), view.innerWidth - 16);
|
|
68
|
+
if (this._side === 'bottom')
|
|
69
|
+
this.panel.style.width = `${width}px`;
|
|
70
|
+
const panel = this.panel.getBoundingClientRect();
|
|
71
|
+
let left = anchor.left;
|
|
72
|
+
let top = anchor.bottom + 4;
|
|
73
|
+
if (this._side === 'right') {
|
|
74
|
+
left = anchor.right + 4;
|
|
75
|
+
top = anchor.top;
|
|
76
|
+
if (left + panel.width > view.innerWidth - 8)
|
|
77
|
+
left = anchor.left - panel.width - 4;
|
|
78
|
+
}
|
|
79
|
+
else if (top + panel.height > view.innerHeight - 8 && anchor.top > view.innerHeight - anchor.bottom)
|
|
80
|
+
top = anchor.top - panel.height - 4;
|
|
81
|
+
this.panel.style.left = `${Math.max(8, Math.min(left, view.innerWidth - panel.width - 8))}px`;
|
|
82
|
+
this.panel.style.top = `${Math.max(8, Math.min(top, view.innerHeight - panel.height - 8))}px`;
|
|
83
|
+
};
|
|
84
|
+
_outside = (event) => { if (!this.panel.hidden && !event.composedPath().includes(this._host))
|
|
85
|
+
this._dismiss(); };
|
|
86
|
+
_scroll = (event) => { if (!event.composedPath().includes(this.panel))
|
|
87
|
+
this.position(); };
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=anchored-popup.js.map
|