@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.
Files changed (139) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/LICENSE +27 -0
  3. package/README.md +707 -5
  4. package/dist/adapters/web/controls.js +28 -5
  5. package/dist/adapters/web/renderer.js +11 -10
  6. package/dist/adapters/web/styles.d.ts +2 -3
  7. package/dist/adapters/web/styles.js +42 -18
  8. package/dist/alert.d.ts +39 -0
  9. package/dist/alert.js +144 -0
  10. package/dist/anchor.d.ts +60 -0
  11. package/dist/anchor.js +274 -0
  12. package/dist/auto-complete.d.ts +83 -0
  13. package/dist/auto-complete.js +267 -0
  14. package/dist/avatar.d.ts +45 -0
  15. package/dist/avatar.js +135 -0
  16. package/dist/badge.js +5 -5
  17. package/dist/border-beam.js +1 -1
  18. package/dist/breadcrumb.js +5 -5
  19. package/dist/button-group.js +8 -8
  20. package/dist/button.js +10 -10
  21. package/dist/card.d.ts +29 -0
  22. package/dist/card.js +101 -0
  23. package/dist/carousel.d.ts +92 -0
  24. package/dist/carousel.js +509 -0
  25. package/dist/cascader.js +12 -12
  26. package/dist/checkbox.d.ts +12 -0
  27. package/dist/checkbox.js +22 -6
  28. package/dist/collapse.d.ts +13 -0
  29. package/dist/collapse.js +100 -13
  30. package/dist/context-menu.js +3 -3
  31. package/dist/core/types.d.ts +22 -3
  32. package/dist/core/validation.js +9 -4
  33. package/dist/date-picker.js +13 -13
  34. package/dist/descriptions.d.ts +44 -0
  35. package/dist/descriptions.js +169 -0
  36. package/dist/dialog.js +11 -11
  37. package/dist/divider.js +2 -2
  38. package/dist/draggable.js +1 -1
  39. package/dist/drawer.js +12 -12
  40. package/dist/dropdown.js +3 -3
  41. package/dist/empty.d.ts +20 -0
  42. package/dist/empty.js +58 -0
  43. package/dist/expandable.js +4 -4
  44. package/dist/form-item.d.ts +60 -0
  45. package/dist/form-item.js +212 -0
  46. package/dist/form.d.ts +41 -0
  47. package/dist/form.js +154 -0
  48. package/dist/history-controls.js +5 -5
  49. package/dist/image-preview.d.ts +22 -0
  50. package/dist/image-preview.js +38 -0
  51. package/dist/image.d.ts +52 -0
  52. package/dist/image.js +152 -0
  53. package/dist/index.d.ts +56 -0
  54. package/dist/index.js +84 -0
  55. package/dist/input.d.ts +11 -0
  56. package/dist/input.js +29 -15
  57. package/dist/internal/anchored-popup.d.ts +19 -0
  58. package/dist/internal/anchored-popup.js +89 -0
  59. package/dist/internal/form-control.d.ts +22 -0
  60. package/dist/internal/form-control.js +52 -0
  61. package/dist/internal/image-viewer.d.ts +51 -0
  62. package/dist/internal/image-viewer.js +210 -0
  63. package/dist/internal/pagination.d.ts +35 -0
  64. package/dist/internal/pagination.js +169 -0
  65. package/dist/internal/popover-base.d.ts +87 -0
  66. package/dist/internal/popover-base.js +365 -0
  67. package/dist/internal/presentation.d.ts +2 -0
  68. package/dist/internal/presentation.js +28 -0
  69. package/dist/internal/qrcodegen.d.ts +94 -0
  70. package/dist/internal/qrcodegen.js +856 -0
  71. package/dist/masonry.d.ts +36 -0
  72. package/dist/masonry.js +171 -0
  73. package/dist/mentions.d.ts +115 -0
  74. package/dist/mentions.js +485 -0
  75. package/dist/menu-shared.d.ts +1 -1
  76. package/dist/menu-shared.js +3 -3
  77. package/dist/menu.d.ts +63 -0
  78. package/dist/menu.js +339 -0
  79. package/dist/modal.d.ts +73 -0
  80. package/dist/modal.js +361 -0
  81. package/dist/notification.js +9 -9
  82. package/dist/pagination.d.ts +34 -0
  83. package/dist/pagination.js +73 -0
  84. package/dist/popconfirm.d.ts +6 -0
  85. package/dist/popconfirm.js +7 -0
  86. package/dist/popover.d.ts +6 -0
  87. package/dist/popover.js +7 -0
  88. package/dist/portable/icons.d.ts +5 -0
  89. package/dist/portable/icons.js +24 -0
  90. package/dist/portable/index.d.ts +3 -0
  91. package/dist/portable/index.js +2 -0
  92. package/dist/portable/responsive.d.ts +20 -0
  93. package/dist/portable/responsive.js +15 -0
  94. package/dist/portable/theme.d.ts +6 -1
  95. package/dist/portable/theme.js +23 -3
  96. package/dist/progress.d.ts +30 -0
  97. package/dist/progress.js +102 -0
  98. package/dist/qr-code.d.ts +62 -0
  99. package/dist/qr-code.js +224 -0
  100. package/dist/radio.d.ts +10 -0
  101. package/dist/radio.js +18 -5
  102. package/dist/range.js +7 -7
  103. package/dist/rate.js +3 -3
  104. package/dist/resizable.js +4 -4
  105. package/dist/result.d.ts +22 -0
  106. package/dist/result.js +88 -0
  107. package/dist/ribbon.d.ts +19 -0
  108. package/dist/ribbon.js +106 -0
  109. package/dist/segmented.d.ts +39 -0
  110. package/dist/segmented.js +192 -0
  111. package/dist/select.d.ts +12 -0
  112. package/dist/select.js +31 -13
  113. package/dist/skeleton.js +10 -10
  114. package/dist/spin.d.ts +26 -0
  115. package/dist/spin.js +80 -0
  116. package/dist/steps.js +13 -13
  117. package/dist/switch.d.ts +44 -0
  118. package/dist/switch.js +104 -0
  119. package/dist/table.d.ts +0 -2
  120. package/dist/table.js +46 -87
  121. package/dist/tabs.js +7 -7
  122. package/dist/tag.js +8 -8
  123. package/dist/time-picker.js +10 -10
  124. package/dist/timeline.js +12 -12
  125. package/dist/toast.js +9 -9
  126. package/dist/tooltip.js +4 -4
  127. package/dist/tour.js +11 -11
  128. package/dist/tree-node.js +2 -2
  129. package/dist/tree-select.d.ts +94 -0
  130. package/dist/tree-select.js +398 -0
  131. package/dist/tree.js +6 -5
  132. package/dist/upload.d.ts +107 -0
  133. package/dist/upload.js +353 -0
  134. package/dist/virtual-keyboard.js +5 -5
  135. package/dist/virtual-list.js +4 -4
  136. package/dist/virtual-mouse.js +5 -5
  137. package/package.json +99 -1
  138. package/themes/haiyue-dark.css +51 -0
  139. package/themes/haiyue-light.css +51 -0
@@ -0,0 +1,36 @@
1
+ export interface HYMasonryLayoutChangeDetail {
2
+ columns: number;
3
+ itemCount: number;
4
+ height: number;
5
+ }
6
+ /** Places default-slot HTML elements into the shortest column without changing DOM/focus order. */
7
+ export declare class HYMasonry extends HTMLElement {
8
+ private readonly _layout;
9
+ private readonly _slot;
10
+ private readonly _resizeObserver;
11
+ private readonly _mutationObserver;
12
+ private readonly _items;
13
+ private _frame;
14
+ private _connected;
15
+ private _lastLayout;
16
+ static get observedAttributes(): string[];
17
+ constructor();
18
+ connectedCallback(): void;
19
+ disconnectedCallback(): void;
20
+ attributeChangedCallback(): void;
21
+ /** Zero (the default) selects as many columns as fit minColumnWidth. */
22
+ get columns(): number;
23
+ set columns(value: number);
24
+ /** Preferred minimum column width in CSS pixels; narrow containers still fit one column. */
25
+ get minColumnWidth(): number;
26
+ set minColumnWidth(value: number);
27
+ /** Horizontal and vertical spacing in CSS pixels. */
28
+ get gap(): number;
29
+ set gap(value: number);
30
+ /** Coalesces layout requests into the next animation frame. Safe while disconnected. */
31
+ refresh: () => void;
32
+ private _releaseItem;
33
+ private _setItemProperty;
34
+ private _updateLayout;
35
+ }
36
+ export declare function defineMasonryComponents(): void;
@@ -0,0 +1,171 @@
1
+ const itemProperties = ['--_hy-masonry-width', '--_hy-masonry-x', '--_hy-masonry-y'];
2
+ function numberOption(value, fallback, min, max) {
3
+ if (value === null || value === '')
4
+ return fallback;
5
+ const number = Number(value);
6
+ return Number.isFinite(number) ? Math.min(max, Math.max(min, number)) : fallback;
7
+ }
8
+ /** Places default-slot HTML elements into the shortest column without changing DOM/focus order. */
9
+ export class HYMasonry extends HTMLElement {
10
+ _layout = document.createElement('div');
11
+ _slot = document.createElement('slot');
12
+ _resizeObserver = new ResizeObserver(() => this.refresh());
13
+ _mutationObserver = new MutationObserver(() => this.refresh());
14
+ _items = new Map();
15
+ _frame = 0;
16
+ _connected = false;
17
+ _lastLayout = '';
18
+ static get observedAttributes() { return ['columns', 'min-column-width', 'gap']; }
19
+ constructor() {
20
+ super();
21
+ const root = this.attachShadow({ mode: 'open' });
22
+ const style = document.createElement('style');
23
+ style.textContent = `
24
+ :host { display: block; min-width: 0; }
25
+ :host([hidden]) { display: none; }
26
+ .layout { position: relative; min-width: 0; }
27
+ slot { display: contents; }
28
+ ::slotted(*) {
29
+ position: absolute;
30
+ box-sizing: border-box;
31
+ min-width: 0;
32
+ max-width: none;
33
+ width: var(--_hy-masonry-width);
34
+ inset-inline-start: var(--_hy-masonry-x);
35
+ top: var(--_hy-masonry-y);
36
+ margin: 0;
37
+ }
38
+ ::slotted([hidden]) { display: none !important; }
39
+ `;
40
+ this._layout.className = 'layout';
41
+ this._layout.part.add('layout');
42
+ this._layout.append(this._slot);
43
+ root.append(style, this._layout);
44
+ }
45
+ connectedCallback() {
46
+ if (this._connected)
47
+ return;
48
+ this._connected = true;
49
+ this._slot.addEventListener('slotchange', this.refresh);
50
+ this._resizeObserver.observe(this._layout);
51
+ this._mutationObserver.observe(this, {
52
+ childList: true, subtree: true, attributes: true,
53
+ attributeFilter: ['hidden', 'class', 'style', 'slot'],
54
+ });
55
+ this.refresh();
56
+ }
57
+ disconnectedCallback() {
58
+ this._connected = false;
59
+ this._slot.removeEventListener('slotchange', this.refresh);
60
+ this._resizeObserver.disconnect();
61
+ this._mutationObserver.disconnect();
62
+ if (this._frame)
63
+ cancelAnimationFrame(this._frame);
64
+ this._frame = 0;
65
+ for (const item of this._items.keys())
66
+ this._releaseItem(item);
67
+ this._layout.style.removeProperty('height');
68
+ this._lastLayout = '';
69
+ }
70
+ attributeChangedCallback() { this.refresh(); }
71
+ /** Zero (the default) selects as many columns as fit minColumnWidth. */
72
+ get columns() { return Math.floor(numberOption(this.getAttribute('columns'), 0, 0, 128)); }
73
+ set columns(value) { this.setAttribute('columns', String(Math.floor(numberOption(value, 0, 0, 128)))); }
74
+ /** Preferred minimum column width in CSS pixels; narrow containers still fit one column. */
75
+ get minColumnWidth() { return numberOption(this.getAttribute('min-column-width'), 240, 1, 100_000); }
76
+ set minColumnWidth(value) { this.setAttribute('min-column-width', String(numberOption(value, 240, 1, 100_000))); }
77
+ /** Horizontal and vertical spacing in CSS pixels. */
78
+ get gap() { return numberOption(this.getAttribute('gap'), 16, 0, 10_000); }
79
+ set gap(value) { this.setAttribute('gap', String(numberOption(value, 16, 0, 10_000))); }
80
+ /** Coalesces layout requests into the next animation frame. Safe while disconnected. */
81
+ refresh = () => {
82
+ if (!this._connected || this._frame)
83
+ return;
84
+ this._frame = requestAnimationFrame(() => {
85
+ this._frame = 0;
86
+ this._updateLayout();
87
+ });
88
+ };
89
+ _releaseItem(item) {
90
+ const saved = this._items.get(item);
91
+ if (!saved)
92
+ return;
93
+ itemProperties.forEach((property, index) => {
94
+ const { value, priority } = saved[index];
95
+ if (value)
96
+ item.style.setProperty(property, value, priority);
97
+ else
98
+ item.style.removeProperty(property);
99
+ });
100
+ this._resizeObserver.unobserve(item);
101
+ this._items.delete(item);
102
+ }
103
+ _setItemProperty(item, property, value) {
104
+ const text = `${value}px`;
105
+ if (item.style.getPropertyValue(property) !== text)
106
+ item.style.setProperty(property, text);
107
+ }
108
+ _updateLayout() {
109
+ const items = this._slot.assignedElements({ flatten: true }).filter((item) => item instanceof HTMLElement);
110
+ const current = new Set(items);
111
+ for (const item of this._items.keys())
112
+ if (!current.has(item))
113
+ this._releaseItem(item);
114
+ for (const item of items) {
115
+ if (this._items.has(item))
116
+ continue;
117
+ this._items.set(item, itemProperties.map(property => ({
118
+ value: item.style.getPropertyValue(property), priority: item.style.getPropertyPriority(property),
119
+ })));
120
+ this._resizeObserver.observe(item, { box: 'border-box' });
121
+ }
122
+ const width = this._layout.clientWidth;
123
+ if (width <= 0)
124
+ return; // A hidden container is measured again when ResizeObserver sees it.
125
+ const gap = this.gap;
126
+ const requested = this.columns || Math.max(1, Math.floor((width + gap) / (this.minColumnWidth + gap)));
127
+ const columns = Math.min(128, requested, Math.max(1, Math.floor((width + gap) / (1 + gap))));
128
+ const itemWidth = (width - gap * (columns - 1)) / columns;
129
+ const visible = items.filter(item => !item.hidden && getComputedStyle(item).display !== 'none');
130
+ for (const item of visible)
131
+ this._setItemProperty(item, itemProperties[0], itemWidth);
132
+ // Read used CSS sizes before writing positions. Unlike DOMRect, these are
133
+ // unaffected by transforms, and unlike offsetHeight they retain fractions.
134
+ const itemHeights = visible.map(item => {
135
+ const style = getComputedStyle(item);
136
+ const contentHeight = Number.parseFloat(style.height);
137
+ if (!Number.isFinite(contentHeight))
138
+ return item.offsetHeight;
139
+ return contentHeight + (style.boxSizing === 'border-box' ? 0 :
140
+ Number.parseFloat(style.paddingTop) + Number.parseFloat(style.paddingBottom) +
141
+ Number.parseFloat(style.borderTopWidth) + Number.parseFloat(style.borderBottomWidth));
142
+ });
143
+ const heights = Array(columns).fill(0);
144
+ const positions = [];
145
+ visible.forEach((item, index) => {
146
+ const column = heights.indexOf(Math.min(...heights));
147
+ const x = column * (itemWidth + gap);
148
+ const y = heights[column];
149
+ this._setItemProperty(item, itemProperties[1], x);
150
+ this._setItemProperty(item, itemProperties[2], y);
151
+ const height = itemHeights[index];
152
+ heights[column] = y + height + gap;
153
+ positions.push(x, y, height);
154
+ });
155
+ const height = visible.length ? Math.max(...heights) - gap : 0;
156
+ if (this._layout.style.height !== `${height}px`)
157
+ this._layout.style.height = `${height}px`;
158
+ const signature = JSON.stringify([columns, itemWidth, height, positions]);
159
+ if (signature === this._lastLayout)
160
+ return;
161
+ this._lastLayout = signature;
162
+ this.dispatchEvent(new CustomEvent('layout-change', {
163
+ detail: { columns, itemCount: visible.length, height }, bubbles: true, composed: true,
164
+ }));
165
+ }
166
+ }
167
+ export function defineMasonryComponents() {
168
+ if (!customElements.get('hy-masonry'))
169
+ customElements.define('hy-masonry', HYMasonry);
170
+ }
171
+ //# sourceMappingURL=masonry.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;