@haiyue/ui 0.2.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +506 -2
  3. package/dist/adapters/web/renderer.js +1 -8
  4. package/dist/adapters/web/styles.d.ts +2 -3
  5. package/dist/adapters/web/styles.js +26 -23
  6. package/dist/alert.d.ts +39 -0
  7. package/dist/alert.js +144 -0
  8. package/dist/anchor.d.ts +60 -0
  9. package/dist/anchor.js +274 -0
  10. package/dist/auto-complete.d.ts +83 -0
  11. package/dist/auto-complete.js +267 -0
  12. package/dist/avatar.d.ts +45 -0
  13. package/dist/avatar.js +135 -0
  14. package/dist/badge.js +5 -5
  15. package/dist/border-beam.js +1 -1
  16. package/dist/breadcrumb.js +5 -5
  17. package/dist/button-group.js +8 -8
  18. package/dist/button.js +10 -10
  19. package/dist/card.d.ts +29 -0
  20. package/dist/card.js +101 -0
  21. package/dist/carousel.js +6 -6
  22. package/dist/cascader.js +12 -12
  23. package/dist/checkbox.d.ts +12 -0
  24. package/dist/checkbox.js +22 -6
  25. package/dist/collapse.js +6 -6
  26. package/dist/context-menu.js +3 -3
  27. package/dist/date-picker.js +13 -13
  28. package/dist/descriptions.d.ts +44 -0
  29. package/dist/descriptions.js +169 -0
  30. package/dist/dialog.js +11 -11
  31. package/dist/divider.js +2 -2
  32. package/dist/draggable.js +1 -1
  33. package/dist/drawer.js +12 -12
  34. package/dist/dropdown.js +3 -3
  35. package/dist/empty.d.ts +20 -0
  36. package/dist/empty.js +58 -0
  37. package/dist/expandable.js +4 -4
  38. package/dist/form-item.d.ts +60 -0
  39. package/dist/form-item.js +212 -0
  40. package/dist/form.d.ts +41 -0
  41. package/dist/form.js +154 -0
  42. package/dist/history-controls.js +5 -5
  43. package/dist/image-preview.d.ts +22 -0
  44. package/dist/image-preview.js +38 -0
  45. package/dist/image.d.ts +52 -0
  46. package/dist/image.js +152 -0
  47. package/dist/index.d.ts +48 -0
  48. package/dist/index.js +72 -0
  49. package/dist/input.d.ts +11 -0
  50. package/dist/input.js +29 -15
  51. package/dist/internal/anchored-popup.d.ts +19 -0
  52. package/dist/internal/anchored-popup.js +89 -0
  53. package/dist/internal/form-control.d.ts +22 -0
  54. package/dist/internal/form-control.js +52 -0
  55. package/dist/internal/image-viewer.d.ts +51 -0
  56. package/dist/internal/image-viewer.js +210 -0
  57. package/dist/internal/pagination.d.ts +35 -0
  58. package/dist/internal/pagination.js +169 -0
  59. package/dist/internal/popover-base.d.ts +87 -0
  60. package/dist/internal/popover-base.js +365 -0
  61. package/dist/internal/presentation.d.ts +2 -0
  62. package/dist/internal/presentation.js +28 -0
  63. package/dist/mentions.d.ts +115 -0
  64. package/dist/mentions.js +485 -0
  65. package/dist/menu-shared.d.ts +1 -1
  66. package/dist/menu-shared.js +3 -3
  67. package/dist/menu.d.ts +63 -0
  68. package/dist/menu.js +339 -0
  69. package/dist/modal.js +10 -10
  70. package/dist/notification.js +9 -9
  71. package/dist/pagination.d.ts +34 -0
  72. package/dist/pagination.js +73 -0
  73. package/dist/popconfirm.d.ts +6 -0
  74. package/dist/popconfirm.js +7 -0
  75. package/dist/popover.d.ts +6 -0
  76. package/dist/popover.js +7 -0
  77. package/dist/progress.d.ts +30 -0
  78. package/dist/progress.js +102 -0
  79. package/dist/qr-code.js +3 -3
  80. package/dist/radio.d.ts +10 -0
  81. package/dist/radio.js +18 -5
  82. package/dist/range.js +7 -7
  83. package/dist/rate.js +3 -3
  84. package/dist/resizable.js +4 -4
  85. package/dist/result.d.ts +22 -0
  86. package/dist/result.js +88 -0
  87. package/dist/ribbon.d.ts +19 -0
  88. package/dist/ribbon.js +106 -0
  89. package/dist/segmented.d.ts +39 -0
  90. package/dist/segmented.js +192 -0
  91. package/dist/select.d.ts +12 -0
  92. package/dist/select.js +31 -13
  93. package/dist/skeleton.js +10 -10
  94. package/dist/spin.d.ts +26 -0
  95. package/dist/spin.js +80 -0
  96. package/dist/steps.js +13 -13
  97. package/dist/switch.d.ts +44 -0
  98. package/dist/switch.js +104 -0
  99. package/dist/table.d.ts +0 -2
  100. package/dist/table.js +46 -87
  101. package/dist/tabs.js +7 -7
  102. package/dist/tag.js +8 -8
  103. package/dist/time-picker.js +10 -10
  104. package/dist/timeline.js +12 -12
  105. package/dist/toast.js +9 -9
  106. package/dist/tooltip.js +4 -4
  107. package/dist/tour.js +11 -11
  108. package/dist/tree-node.js +2 -2
  109. package/dist/tree-select.d.ts +94 -0
  110. package/dist/tree-select.js +398 -0
  111. package/dist/tree.js +6 -5
  112. package/dist/upload.d.ts +107 -0
  113. package/dist/upload.js +353 -0
  114. package/dist/virtual-keyboard.js +5 -5
  115. package/dist/virtual-list.js +4 -4
  116. package/dist/virtual-mouse.js +5 -5
  117. package/package.json +82 -1
  118. package/themes/haiyue-dark.css +51 -0
  119. package/themes/haiyue-light.css +51 -0
@@ -0,0 +1,192 @@
1
+ /** A compact single-choice control with roving keyboard focus. */
2
+ export class HYSegmented extends HTMLElement {
3
+ _group = document.createElement('div');
4
+ _options = [];
5
+ _pendingFocus = null;
6
+ static get observedAttributes() {
7
+ return ['options', 'value', 'size', 'block', 'disabled', 'aria-label'];
8
+ }
9
+ constructor() {
10
+ super();
11
+ const root = this.attachShadow({ mode: 'open' });
12
+ const style = document.createElement('style');
13
+ style.textContent = `
14
+ :host { display: inline-block; max-width: 100%; color: var(--hy-text-color, #d8e2f2); font: var(--hy-font-size-sm, 12px) var(--hy-font-family, system-ui, sans-serif); }
15
+ :host([block]) { display: block; width: 100%; }
16
+ .group { display: inline-flex; box-sizing: border-box; max-width: 100%; gap: var(--hy-space-1, 2px); padding: calc(var(--hy-space-1, 2px) + 1px); border: 1px solid var(--hy-segmented-border-color, transparent); border-radius: var(--hy-segmented-radius, calc(var(--hy-radius-md, 6px) + 1px)); background: var(--hy-segmented-bg-color, var(--hy-input-bg-color, #121822)); }
17
+ :host([block]) .group { display: flex; width: 100%; }
18
+ button { display: inline-flex; min-width: 0; height: var(--hy-control-height-sm, 28px); align-items: center; justify-content: center; gap: var(--hy-space-3, 6px); padding: 0 var(--hy-space-6, 12px); border: 0; border-radius: calc(var(--hy-segmented-radius, calc(var(--hy-radius-md, 6px) + 1px)) - 2px); color: var(--hy-segmented-text-color, var(--hy-secondary-text-color, #8fa7c8)); background: transparent; font: inherit; white-space: nowrap; cursor: pointer; transition: color 120ms ease, background 120ms ease, box-shadow 120ms ease; }
19
+ :host([block]) button { flex: 1 1 0; }
20
+ :host([size="small"]) button { height: calc(var(--hy-control-height-xs, 24px) - 2px); padding-inline: var(--hy-space-4, 8px); font-size: calc(var(--hy-font-size-xs, 10px) + 1px); }
21
+ :host([size="large"]) button { height: var(--hy-control-height-md, 34px); padding-inline: var(--hy-space-8, 16px); font-size: calc(var(--hy-font-size-sm, 12px) + 1px); }
22
+ button:hover:not(:disabled):not(.selected) { color: var(--hy-text-color, #d8e2f2); background: var(--hy-hover-bg-color, #222b3a); }
23
+ button.selected { color: var(--hy-segmented-selected-text-color, var(--hy-active-text-color, #eef3ff)); background: var(--hy-segmented-selected-bg-color, var(--hy-surface-elevated-color, #1b2230)); box-shadow: var(--hy-segmented-selected-shadow, 0 1px 3px var(--hy-shadow-color, rgba(0, 0, 0, 0.24))); }
24
+ button:focus-visible { outline: 2px solid var(--hy-focus-border-color, #3d6fa8); outline-offset: 1px; }
25
+ button:disabled { opacity: 0.42; cursor: default; }
26
+ .icon { flex: none; line-height: var(--hy-line-height-tight, 1); }
27
+ .label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
28
+ @media (prefers-reduced-motion: reduce) { button { transition: none; } }
29
+ `;
30
+ this._group.className = 'group';
31
+ this._group.part.add('group');
32
+ this._group.setAttribute('role', 'radiogroup');
33
+ root.append(style, this._group);
34
+ }
35
+ connectedCallback() {
36
+ if (this.hasAttribute('options'))
37
+ this._readOptionsAttribute();
38
+ this._normalizeValue();
39
+ this._render();
40
+ }
41
+ attributeChangedCallback(name, oldValue, newValue) {
42
+ if (oldValue === newValue)
43
+ return;
44
+ if (name === 'options')
45
+ this._readOptionsAttribute();
46
+ if ((name === 'options' || name === 'value') && this.isConnected)
47
+ this._normalizeValue();
48
+ this._render();
49
+ }
50
+ get options() { return this._options; }
51
+ set options(value) {
52
+ this._options = Array.isArray(value) ? value.map(item => {
53
+ if (typeof item === 'string' || typeof item === 'number')
54
+ return { label: String(item), value: String(item) };
55
+ const normalized = {
56
+ label: String(item.label ?? item.value ?? ''),
57
+ value: String(item.value ?? item.label ?? ''),
58
+ disabled: Boolean(item.disabled),
59
+ };
60
+ return item.icon == null ? normalized : { ...normalized, icon: String(item.icon) };
61
+ }) : [];
62
+ this._normalizeValue();
63
+ this._render();
64
+ }
65
+ get value() { return this.getAttribute('value') ?? ''; }
66
+ set value(value) { if (value)
67
+ this.setAttribute('value', value);
68
+ else
69
+ this.removeAttribute('value'); }
70
+ get size() {
71
+ const value = this.getAttribute('size');
72
+ return value === 'small' || value === 'large' ? value : 'medium';
73
+ }
74
+ set size(value) { this.setAttribute('size', value); }
75
+ get block() { return this.hasAttribute('block'); }
76
+ set block(value) { this.toggleAttribute('block', Boolean(value)); }
77
+ get disabled() { return this.hasAttribute('disabled'); }
78
+ set disabled(value) { this.toggleAttribute('disabled', Boolean(value)); }
79
+ select(value) {
80
+ const option = this._options.find(item => item.value === value && !item.disabled) ?? null;
81
+ if (!option || this.disabled || value === this.value)
82
+ return false;
83
+ this.value = value;
84
+ this.dispatchEvent(new CustomEvent('value-change', {
85
+ detail: { value, option }, bubbles: true, composed: true,
86
+ }));
87
+ return true;
88
+ }
89
+ _readOptionsAttribute() {
90
+ const raw = this.getAttribute('options');
91
+ if (!raw) {
92
+ this._options = [];
93
+ return;
94
+ }
95
+ try {
96
+ const parsed = JSON.parse(raw);
97
+ this._options = Array.isArray(parsed) ? parsed.map(item => {
98
+ if (typeof item === 'string' || typeof item === 'number')
99
+ return { label: String(item), value: String(item) };
100
+ const record = item && typeof item === 'object' ? item : {};
101
+ const normalized = {
102
+ label: String(record.label ?? record.value ?? ''), value: String(record.value ?? record.label ?? ''),
103
+ disabled: Boolean(record.disabled),
104
+ };
105
+ return record.icon == null ? normalized : { ...normalized, icon: String(record.icon) };
106
+ }) : [];
107
+ }
108
+ catch (error) {
109
+ console.warn('Invalid hy-segmented options attribute.', error);
110
+ this._options = [];
111
+ }
112
+ }
113
+ _normalizeValue() {
114
+ if (this._options.some(item => item.value === this.value && !item.disabled))
115
+ return;
116
+ const value = this._options.find(item => !item.disabled)?.value ?? '';
117
+ if (value === this.value)
118
+ return;
119
+ if (value)
120
+ this.setAttribute('value', value);
121
+ else
122
+ this.removeAttribute('value');
123
+ }
124
+ _render() {
125
+ if (!this._group)
126
+ return;
127
+ const focused = this._pendingFocus ?? [...this._group.querySelectorAll('button')]
128
+ .find(button => button === this.shadowRoot?.activeElement)?.dataset.value ?? null;
129
+ this._pendingFocus = null;
130
+ this._group.replaceChildren();
131
+ this._group.setAttribute('aria-label', this.getAttribute('aria-label') ?? 'Segmented control');
132
+ this._group.setAttribute('aria-disabled', String(this.disabled));
133
+ const enabled = this._options.filter(item => !item.disabled);
134
+ const tabValue = enabled.some(item => item.value === this.value) ? this.value : enabled[0]?.value;
135
+ for (const option of this._options) {
136
+ const button = document.createElement('button');
137
+ button.type = 'button';
138
+ button.part.add('item');
139
+ button.dataset.value = option.value;
140
+ button.setAttribute('role', 'radio');
141
+ button.setAttribute('aria-checked', String(option.value === this.value));
142
+ button.classList.toggle('selected', option.value === this.value);
143
+ button.disabled = this.disabled || Boolean(option.disabled);
144
+ button.tabIndex = !button.disabled && option.value === tabValue ? 0 : -1;
145
+ if (option.icon) {
146
+ const icon = document.createElement('span');
147
+ icon.className = 'icon';
148
+ icon.part.add('icon');
149
+ icon.textContent = option.icon;
150
+ button.append(icon);
151
+ }
152
+ const label = document.createElement('span');
153
+ label.className = 'label';
154
+ label.part.add('label');
155
+ label.textContent = option.label;
156
+ button.append(label);
157
+ button.addEventListener('click', () => this.select(option.value));
158
+ button.addEventListener('keydown', event => this._onKeyDown(event, option, enabled));
159
+ this._group.append(button);
160
+ }
161
+ if (focused)
162
+ queueMicrotask(() => this._focus(enabled.some(item => item.value === focused) ? focused : tabValue ?? ''));
163
+ }
164
+ _onKeyDown(event, option, enabled) {
165
+ if (!enabled.length || !['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'Home', 'End'].includes(event.key))
166
+ return;
167
+ event.preventDefault();
168
+ const position = Math.max(0, enabled.findIndex(item => item.value === option.value));
169
+ const direction = getComputedStyle(this).direction === 'rtl' ? -1 : 1;
170
+ let next = position;
171
+ if (event.key === 'Home')
172
+ next = 0;
173
+ else if (event.key === 'End')
174
+ next = enabled.length - 1;
175
+ else {
176
+ const forward = event.key === 'ArrowRight' || event.key === 'ArrowDown';
177
+ const delta = (forward ? 1 : -1) * (event.key === 'ArrowLeft' || event.key === 'ArrowRight' ? direction : 1);
178
+ next = (position + delta + enabled.length) % enabled.length;
179
+ }
180
+ this._pendingFocus = enabled[next].value;
181
+ if (!this.select(enabled[next].value))
182
+ this._render();
183
+ }
184
+ _focus(value) {
185
+ [...this._group.querySelectorAll('button')].find(button => button.dataset.value === value)?.focus();
186
+ }
187
+ }
188
+ export function defineSegmentedComponents() {
189
+ if (!customElements.get('hy-segmented'))
190
+ customElements.define('hy-segmented', HYSegmented);
191
+ }
192
+ //# sourceMappingURL=segmented.js.map
package/dist/select.d.ts CHANGED
@@ -8,11 +8,13 @@ export interface HYSelectChangeDetail {
8
8
  option: HYSelectOption | null;
9
9
  }
10
10
  export declare class HYSelect extends HTMLElement {
11
+ static readonly formAssociated = true;
11
12
  private readonly _wrap;
12
13
  private readonly _search;
13
14
  private readonly _select;
14
15
  private _options;
15
16
  private _filterText;
17
+ private readonly _formControl;
16
18
  static get observedAttributes(): string[];
17
19
  constructor();
18
20
  connectedCallback(): void;
@@ -32,6 +34,16 @@ export declare class HYSelect extends HTMLElement {
32
34
  private _readOptionsAttribute;
33
35
  private _render;
34
36
  private _syncDisabled;
37
+ get form(): HTMLFormElement | null;
38
+ get validity(): ValidityState;
39
+ get validationMessage(): string;
40
+ checkValidity(): boolean;
41
+ reportValidity(): boolean;
42
+ setCustomValidity(message: string): void;
43
+ formDisabledCallback(disabled: boolean): void;
44
+ formResetCallback(): void;
45
+ formStateRestoreCallback(state: string | File | FormData | null): void;
46
+ focus(options?: FocusOptions): void;
35
47
  private _syncAriaLabel;
36
48
  private _matchesFilter;
37
49
  private _onChange;
package/dist/select.js CHANGED
@@ -1,11 +1,14 @@
1
+ import { HYFormControl } from './internal/form-control.js';
1
2
  export class HYSelect extends HTMLElement {
3
+ static formAssociated = true;
2
4
  _wrap = document.createElement('div');
3
5
  _search = document.createElement('input');
4
6
  _select = document.createElement('select');
5
7
  _options = [];
6
8
  _filterText = '';
9
+ _formControl = new HYFormControl(this, this._select);
7
10
  static get observedAttributes() {
8
- return ['options', 'value', 'disabled', 'searchable', 'aria-label', 'label'];
11
+ return ['options', 'value', 'disabled', 'searchable', 'aria-label', 'label', 'name', 'required'];
9
12
  }
10
13
  constructor() {
11
14
  super();
@@ -19,7 +22,7 @@ export class HYSelect extends HTMLElement {
19
22
  }
20
23
  .wrap {
21
24
  display: grid;
22
- gap: 4px;
25
+ gap: var(--hy-space-2, 4px);
23
26
  width: 100%;
24
27
  min-width: 0;
25
28
  }
@@ -27,14 +30,14 @@ export class HYSelect extends HTMLElement {
27
30
  select {
28
31
  box-sizing: border-box;
29
32
  width: 100%;
30
- height: 28px;
33
+ height: var(--hy-control-height-sm, 28px);
31
34
  min-width: 0;
32
- padding: 0 28px 0 8px;
35
+ padding: 0 calc(var(--hy-space-12, 24px) + 4px) 0 var(--hy-space-4, 8px);
33
36
  border: 1px solid var(--hy-border-color, #303746);
34
- border-radius: 4px;
37
+ border-radius: var(--hy-radius-sm, 4px);
35
38
  color: var(--hy-text-color, #d8e2f2);
36
39
  background-color: var(--hy-input-bg-color, var(--hy-surface-color, #121822));
37
- font: 12px system-ui, sans-serif;
40
+ font: var(--hy-font-size-sm, 12px) var(--hy-font-family, system-ui, sans-serif);
38
41
  outline: none;
39
42
  color-scheme: inherit;
40
43
  }
@@ -45,8 +48,8 @@ export class HYSelect extends HTMLElement {
45
48
  linear-gradient(45deg, transparent 50%, var(--hy-select-arrow-color, var(--hy-secondary-text-color, #8fa7c8)) 50%),
46
49
  linear-gradient(135deg, var(--hy-select-arrow-color, var(--hy-secondary-text-color, #8fa7c8)) 50%, transparent 50%);
47
50
  background-position:
48
- calc(100% - 15px) 11px,
49
- calc(100% - 10px) 11px;
51
+ calc(100% - var(--hy-space-5, 10px) - 5px) center,
52
+ calc(100% - var(--hy-space-5, 10px)) center;
50
53
  background-size: 5px 5px, 5px 5px;
51
54
  background-repeat: no-repeat;
52
55
  }
@@ -55,11 +58,11 @@ export class HYSelect extends HTMLElement {
55
58
  background-color: var(--hy-select-hover-bg-color, var(--hy-input-bg-color, #151d2a));
56
59
  }
57
60
  option {
58
- min-height: 28px;
59
- padding: 6px 8px;
61
+ min-height: var(--hy-control-height-sm, 28px);
62
+ padding: var(--hy-space-3, 6px) var(--hy-space-4, 8px);
60
63
  color: var(--hy-select-option-text-color, var(--hy-text-color, #d8e2f2));
61
64
  background: var(--hy-select-option-bg-color, var(--hy-menu-bg-color, #1b2230));
62
- font: 12px system-ui, sans-serif;
65
+ font: var(--hy-font-size-sm, 12px) var(--hy-font-family, system-ui, sans-serif);
63
66
  }
64
67
  option:checked {
65
68
  color: var(--hy-select-option-selected-text-color, var(--hy-selected-text-color, #ffffff));
@@ -98,6 +101,7 @@ export class HYSelect extends HTMLElement {
98
101
  this._search.addEventListener('input', this._onSearchInput);
99
102
  this._syncFromAttributes();
100
103
  this._render();
104
+ this._formControl.connect();
101
105
  }
102
106
  disconnectedCallback() {
103
107
  this._select.removeEventListener('change', this._onChange);
@@ -116,6 +120,8 @@ export class HYSelect extends HTMLElement {
116
120
  this._syncAriaLabel();
117
121
  if (name === 'options' || name === 'searchable')
118
122
  this._render();
123
+ this._select.required = this.hasAttribute('required');
124
+ this._formControl.sync();
119
125
  }
120
126
  get options() {
121
127
  return this._options;
@@ -203,9 +209,21 @@ export class HYSelect extends HTMLElement {
203
209
  this._syncDisabled();
204
210
  }
205
211
  _syncDisabled() {
206
- this._select.disabled = this.disabled;
207
- this._search.disabled = this.disabled;
212
+ this._select.disabled = this.disabled || this._formControl.disabled;
213
+ this._search.disabled = this.disabled || this._formControl.disabled;
214
+ this._select.required = this.hasAttribute('required');
215
+ this._formControl.sync();
208
216
  }
217
+ get form() { return this._formControl.internals.form; }
218
+ get validity() { return this._formControl.internals.validity; }
219
+ get validationMessage() { return this._formControl.internals.validationMessage; }
220
+ checkValidity() { return this._formControl.internals.checkValidity(); }
221
+ reportValidity() { return this._formControl.internals.reportValidity(); }
222
+ setCustomValidity(message) { this._formControl.setCustomValidity(message); }
223
+ formDisabledCallback(disabled) { this._formControl.disabled = disabled; this._syncDisabled(); }
224
+ formResetCallback() { this._formControl.reset(); }
225
+ formStateRestoreCallback(state) { this._formControl.restore(state); }
226
+ focus(options) { (this.searchable ? this._search : this._select).focus(options); }
209
227
  _syncAriaLabel() {
210
228
  const label = this.getAttribute('aria-label') ?? this.getAttribute('label') ?? '';
211
229
  if (label) {
package/dist/skeleton.js CHANGED
@@ -20,19 +20,19 @@ export class HYSkeleton extends HTMLElement {
20
20
  const root = this.attachShadow({ mode: 'open' });
21
21
  const style = document.createElement('style');
22
22
  style.textContent = `
23
- :host { display: block; min-width: 0; font: 12px/1.4 system-ui, sans-serif; }
24
- .placeholder { display: flex; min-width: 0; align-items: flex-start; gap: var(--hy-skeleton-gap, 14px); }
23
+ :host { display: block; min-width: 0; font: var(--hy-font-size-sm, 12px)/var(--hy-line-height-snug, 1.4) var(--hy-font-family, system-ui, sans-serif); }
24
+ .placeholder { display: flex; min-width: 0; align-items: flex-start; gap: var(--hy-skeleton-gap, var(--hy-space-7, 14px)); }
25
25
  .placeholder[hidden], .content[hidden] { display: none; }
26
- .body { flex: 1; min-width: 0; padding-top: var(--hy-skeleton-body-offset, 2px); }
26
+ .body { flex: 1; min-width: 0; padding-top: var(--hy-skeleton-body-offset, var(--hy-space-1, 2px)); }
27
27
  .block { position: relative; overflow: hidden; background: var(--hy-skeleton-color, color-mix(in srgb, var(--hy-text-color, #eef3ff) 11%, transparent)); }
28
28
  .avatar { flex: 0 0 auto; width: var(--_avatar-size); height: var(--_avatar-size); border-radius: 50%; }
29
- :host([avatar-shape="square"]) .avatar { border-radius: var(--hy-skeleton-avatar-radius, 7px); }
30
- .title { height: var(--hy-skeleton-title-height, 15px); margin-bottom: var(--hy-skeleton-title-gap, 17px); border-radius: var(--hy-skeleton-radius, 5px); }
31
- .paragraph { display: grid; gap: var(--hy-skeleton-row-gap, 11px); }
32
- .row { height: var(--hy-skeleton-row-height, 11px); border-radius: var(--hy-skeleton-radius, 5px); }
33
- :host([round]) .title, :host([round]) .row { border-radius: 999px; }
34
- :host([size="small"]) { --hy-skeleton-title-height: 12px; --hy-skeleton-row-height: 8px; --hy-skeleton-row-gap: 9px; --hy-skeleton-gap: 11px; }
35
- :host([size="large"]) { --hy-skeleton-title-height: 18px; --hy-skeleton-row-height: 14px; --hy-skeleton-row-gap: 13px; --hy-skeleton-gap: 17px; }
29
+ :host([avatar-shape="square"]) .avatar { border-radius: var(--hy-skeleton-avatar-radius, calc(var(--hy-radius-md, 6px) + 1px)); }
30
+ .title { height: var(--hy-skeleton-title-height, 15px); margin-bottom: var(--hy-skeleton-title-gap, calc(var(--hy-space-8, 16px) + 1px)); border-radius: var(--hy-skeleton-radius, calc(var(--hy-radius-sm, 4px) + 1px)); }
31
+ .paragraph { display: grid; gap: var(--hy-skeleton-row-gap, calc(var(--hy-space-5, 10px) + 1px)); }
32
+ .row { height: var(--hy-skeleton-row-height, 11px); border-radius: var(--hy-skeleton-radius, calc(var(--hy-radius-sm, 4px) + 1px)); }
33
+ :host([round]) .title, :host([round]) .row { border-radius: var(--hy-radius-full, 999px); }
34
+ :host([size="small"]) { --hy-skeleton-title-height: 12px; --hy-skeleton-row-height: 8px; --hy-skeleton-row-gap: calc(var(--hy-space-4, 8px) + 1px); --hy-skeleton-gap: calc(var(--hy-space-5, 10px) + 1px); }
35
+ :host([size="large"]) { --hy-skeleton-title-height: 18px; --hy-skeleton-row-height: 14px; --hy-skeleton-row-gap: calc(var(--hy-space-6, 12px) + 1px); --hy-skeleton-gap: calc(var(--hy-space-8, 16px) + 1px); }
36
36
  :host([active]) .block::after { position: absolute; inset: 0; background: linear-gradient(90deg, transparent 0%, var(--hy-skeleton-highlight-color, color-mix(in srgb, var(--hy-text-color, #eef3ff) 12%, transparent)) 45%, transparent 85%); content: ''; transform: translateX(-100%); animation: hy-skeleton-wave var(--hy-skeleton-duration, 1.5s) ease-in-out infinite; }
37
37
  @keyframes hy-skeleton-wave { to { transform: translateX(100%); } }
38
38
  @media (prefers-reduced-motion: reduce) { :host([active]) .block::after { animation: none; } }
package/dist/spin.d.ts ADDED
@@ -0,0 +1,26 @@
1
+ export type HYSpinSize = 'small' | 'default' | 'large';
2
+ export declare class HYSpin extends HTMLElement {
3
+ private readonly _content;
4
+ private readonly _slot;
5
+ private readonly _indicator;
6
+ private readonly _tip;
7
+ private _timer;
8
+ private _visible;
9
+ static get observedAttributes(): string[];
10
+ constructor();
11
+ connectedCallback(): void;
12
+ disconnectedCallback(): void;
13
+ attributeChangedCallback(name: string, previous: string | null, next: string | null): void;
14
+ get spinning(): boolean;
15
+ set spinning(value: boolean);
16
+ get delay(): number;
17
+ set delay(value: number);
18
+ get tip(): string;
19
+ set tip(value: string);
20
+ get size(): HYSpinSize;
21
+ set size(value: HYSpinSize);
22
+ private _schedule;
23
+ private _clearTimer;
24
+ private _render;
25
+ }
26
+ export declare function defineSpinComponents(): void;
package/dist/spin.js ADDED
@@ -0,0 +1,80 @@
1
+ export class HYSpin extends HTMLElement {
2
+ _content = document.createElement('div');
3
+ _slot = document.createElement('slot');
4
+ _indicator = document.createElement('div');
5
+ _tip = document.createElement('span');
6
+ _timer = null;
7
+ _visible = false;
8
+ static get observedAttributes() { return ['spinning', 'delay', 'tip', 'size', 'aria-label']; }
9
+ constructor() {
10
+ super();
11
+ const root = this.attachShadow({ mode: 'open' });
12
+ const style = document.createElement('style');
13
+ style.textContent = `
14
+ :host { position: relative; 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); }
15
+ :host(.has-content) { display: block; } .content.busy { opacity: .45; }
16
+ .indicator { display: inline-flex; flex-direction: column; justify-content: center; align-items: center; gap: var(--hy-space-4, 8px); color: var(--hy-accent-color, #8177f2); }
17
+ :host(.has-content) .indicator { position: absolute; inset: 0; z-index: 1; background: var(--hy-spin-mask-color, transparent); }
18
+ .spinner { width: var(--hy-spin-size, 24px); height: var(--hy-spin-size, 24px); box-sizing: border-box; border: 3px solid color-mix(in srgb, currentColor 22%, transparent); border-top-color: currentColor; border-radius: 50%; animation: hy-spin 0.8s linear infinite; }
19
+ :host([size="small"]) .spinner { width: 16px; height: 16px; border-width: 2px; } :host([size="large"]) .spinner { width: 36px; height: 36px; border-width: 4px; }
20
+ [hidden] { display: none !important; } @keyframes hy-spin { to { transform: rotate(360deg); } }
21
+ @media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
22
+ `;
23
+ this._content.className = 'content';
24
+ this._content.part.add('content');
25
+ this._content.append(this._slot);
26
+ this._indicator.className = 'indicator';
27
+ this._indicator.part.add('indicator');
28
+ this._indicator.setAttribute('role', 'status');
29
+ const spinner = document.createElement('span');
30
+ spinner.className = 'spinner';
31
+ spinner.part.add('spinner');
32
+ spinner.setAttribute('aria-hidden', 'true');
33
+ this._tip.part.add('tip');
34
+ this._indicator.append(spinner, this._tip);
35
+ this._indicator.hidden = true;
36
+ root.append(style, this._content, this._indicator);
37
+ }
38
+ connectedCallback() { this._slot.addEventListener('slotchange', this._render); this._schedule(); }
39
+ disconnectedCallback() { this._clearTimer(); this._slot.removeEventListener('slotchange', this._render); this._visible = false; this._content.inert = false; }
40
+ attributeChangedCallback(name, previous, next) { if (previous !== next) {
41
+ if (name === 'spinning' || name === 'delay')
42
+ this._schedule();
43
+ else
44
+ this._render();
45
+ } }
46
+ get spinning() { return this.getAttribute('spinning') !== 'false'; }
47
+ set spinning(value) { this.setAttribute('spinning', String(value)); }
48
+ get delay() { const value = Number(this.getAttribute('delay')); return Number.isFinite(value) ? Math.max(0, Math.min(value, 60000)) : 0; }
49
+ set delay(value) { this.setAttribute('delay', String(value)); }
50
+ get tip() { return this.getAttribute('tip') ?? ''; }
51
+ set tip(value) { this.setAttribute('tip', value); }
52
+ get size() { const value = this.getAttribute('size'); return value === 'small' || value === 'large' ? value : 'default'; }
53
+ set size(value) { this.setAttribute('size', value); }
54
+ _schedule() {
55
+ this._clearTimer();
56
+ if (!this.isConnected)
57
+ return;
58
+ this._visible = this.spinning && this.delay === 0;
59
+ if (this.spinning && this.delay > 0)
60
+ this._timer = setTimeout(() => { this._timer = null; this._visible = this.spinning; this._render(); }, this.delay);
61
+ this._render();
62
+ }
63
+ _clearTimer() { if (this._timer !== null)
64
+ clearTimeout(this._timer); this._timer = null; }
65
+ _render = () => {
66
+ const hasContent = this._slot.assignedNodes().some(node => node.nodeType === Node.ELEMENT_NODE || Boolean(node.textContent?.trim()));
67
+ if (this.isConnected)
68
+ this.classList.toggle('has-content', hasContent);
69
+ this._content.inert = this.spinning;
70
+ this._content.setAttribute('aria-busy', String(this.spinning));
71
+ this._content.classList.toggle('busy', this._visible);
72
+ this._indicator.hidden = !this._visible;
73
+ this._indicator.setAttribute('aria-label', this.getAttribute('aria-label') || this.tip || 'Loading');
74
+ this._tip.textContent = this.tip;
75
+ this._tip.hidden = !this.tip;
76
+ };
77
+ }
78
+ export function defineSpinComponents() { if (!customElements.get('hy-spin'))
79
+ customElements.define('hy-spin', HYSpin); }
80
+ //# sourceMappingURL=spin.js.map
package/dist/steps.js CHANGED
@@ -37,24 +37,24 @@ export class HYSteps extends HTMLElement {
37
37
  const root = this.attachShadow({ mode: 'open' });
38
38
  const style = document.createElement('style');
39
39
  style.textContent = `
40
- :host { display: block; min-width: 0; color: var(--hy-text-color, #eef3ff); font: 12px/1.45 system-ui, sans-serif; }
40
+ :host { display: block; min-width: 0; color: var(--hy-text-color, #eef3ff); font: var(--hy-font-size-sm, 12px)/calc(var(--hy-line-height-snug, 1.4) + 0.05) var(--hy-font-family, system-ui, sans-serif); }
41
41
  .steps { display: flex; width: 100%; margin: 0; padding: 0; list-style: none; }
42
42
  .item { position: relative; flex: 1 1 0; min-width: 0; text-align: center; }
43
- .step { display: flex; width: 100%; min-width: 0; flex-direction: column; align-items: center; padding: 0 10px; border: 0; color: inherit; background: transparent; font: inherit; text-align: center; }
43
+ .step { display: flex; width: 100%; min-width: 0; flex-direction: column; align-items: center; padding: 0 var(--hy-space-5, 10px); border: 0; color: inherit; background: transparent; font: inherit; text-align: center; }
44
44
  button.step { cursor: pointer; }
45
45
  button.step:hover .icon { transform: scale(1.08); }
46
46
  button.step:focus-visible { outline: none; }
47
47
  button.step:focus-visible .icon { box-shadow: 0 0 0 3px var(--hy-focus-ring-color, rgba(121, 168, 255, .22)); }
48
48
  button.step:disabled { cursor: not-allowed; opacity: .45; }
49
49
  .head { position: relative; z-index: 1; display: grid; place-items: center; }
50
- .icon { display: grid; width: var(--hy-steps-icon-size, 30px); height: var(--hy-steps-icon-size, 30px); box-sizing: border-box; place-items: center; border: 1px solid var(--_step-color, var(--hy-muted-color, #788697)); border-radius: 50%; color: var(--_step-color, var(--hy-muted-color, #788697)); background: var(--hy-surface-color, #111722); font-weight: 650; transition: transform 120ms ease, box-shadow 120ms ease; }
50
+ .icon { display: grid; width: var(--hy-steps-icon-size, 30px); height: var(--hy-steps-icon-size, 30px); box-sizing: border-box; place-items: center; border: 1px solid var(--_step-color, var(--hy-muted-color, #788697)); border-radius: 50%; color: var(--_step-color, var(--hy-muted-color, #788697)); background: var(--hy-surface-color, #111722); font-weight: calc(var(--hy-font-weight-semibold, 600) + 50); transition: transform 120ms ease, box-shadow 120ms ease; }
51
51
  .tail { position: absolute; z-index: 0; top: calc(var(--hy-steps-icon-size, 30px) / 2); right: calc(-50% + var(--hy-steps-icon-size, 30px) / 2 + 10px); left: calc(50% + var(--hy-steps-icon-size, 30px) / 2 + 10px); height: var(--hy-steps-line-width, 1px); background: var(--hy-steps-line-color, var(--hy-border-color, #3d4654)); }
52
52
  .item:last-child .tail { display: none; }
53
- .body { min-width: 0; margin-top: 9px; }
54
- .title-row { display: flex; min-width: 0; justify-content: center; gap: 6px; }
55
- .title { overflow: hidden; color: var(--hy-secondary-text-color, #aebbd0); font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
56
- .subtitle { flex: 0 0 auto; color: var(--hy-muted-color, #788697); font-size: 10px; }
57
- .description { max-width: 30ch; margin: 4px auto 0; color: var(--hy-muted-color, #788697); font-size: 11px; }
53
+ .body { min-width: 0; margin-top: calc(var(--hy-space-4, 8px) + 1px); }
54
+ .title-row { display: flex; min-width: 0; justify-content: center; gap: var(--hy-space-3, 6px); }
55
+ .title { overflow: hidden; color: var(--hy-secondary-text-color, #aebbd0); font-weight: calc(var(--hy-font-weight-semibold, 600) + 50); text-overflow: ellipsis; white-space: nowrap; }
56
+ .subtitle { flex: 0 0 auto; color: var(--hy-muted-color, #788697); font-size: var(--hy-font-size-xs, 10px); }
57
+ .description { max-width: 30ch; margin: var(--hy-space-2, 4px) auto 0; color: var(--hy-muted-color, #788697); font-size: calc(var(--hy-font-size-xs, 10px) + 1px); }
58
58
  .status-finish { --_step-color: var(--hy-success-color, #4ade80); }
59
59
  .status-process { --_step-color: var(--hy-accent-color, #79a8ff); }
60
60
  .status-error { --_step-color: var(--hy-error-color, #fb7185); }
@@ -63,15 +63,15 @@ export class HYSteps extends HTMLElement {
63
63
  .status-error .icon { color: var(--hy-selected-text-color, #fff); background: var(--_step-color); }
64
64
  .status-process .title, .status-finish .title, .status-error .title { color: var(--hy-text-color, #eef3ff); }
65
65
  :host([size="small"]) { --hy-steps-icon-size: 22px; }
66
- :host([size="small"]) .step { padding-inline: 7px; }
67
- :host([size="small"]) .body { margin-top: 6px; }
66
+ :host([size="small"]) .step { padding-inline: calc(var(--hy-space-3, 6px) + 1px); }
67
+ :host([size="small"]) .body { margin-top: var(--hy-space-3, 6px); }
68
68
  :host([direction="vertical"]) .steps { flex-direction: column; }
69
69
  :host([direction="vertical"]) .item { flex: none; min-height: var(--hy-steps-vertical-item-height, 78px); text-align: left; }
70
- :host([direction="vertical"]) .step { display: grid; grid-template-columns: var(--hy-steps-icon-size, 30px) minmax(0, 1fr); align-items: start; gap: 12px; padding: 0 0 20px; text-align: left; }
70
+ :host([direction="vertical"]) .step { display: grid; grid-template-columns: var(--hy-steps-icon-size, 30px) minmax(0, 1fr); align-items: start; gap: var(--hy-space-6, 12px); padding: 0 0 var(--hy-space-10, 20px); text-align: left; }
71
71
  :host([direction="vertical"]) .head { grid-column: 1; grid-row: 1; }
72
- :host([direction="vertical"]) .body { grid-column: 2; grid-row: 1; margin-top: 4px; }
72
+ :host([direction="vertical"]) .body { grid-column: 2; grid-row: 1; margin-top: var(--hy-space-2, 4px); }
73
73
  :host([direction="vertical"]) .title-row { justify-content: flex-start; }
74
- :host([direction="vertical"]) .description { margin: 4px 0 0; }
74
+ :host([direction="vertical"]) .description { margin: var(--hy-space-2, 4px) 0 0; }
75
75
  :host([direction="vertical"]) .tail { top: calc(var(--hy-steps-icon-size, 30px) + 5px); bottom: 5px; left: calc(var(--hy-steps-icon-size, 30px) / 2); width: var(--hy-steps-line-width, 1px); height: auto; }
76
76
  @media (prefers-reduced-motion: reduce) { .icon { transition: none; } }
77
77
  `;
@@ -0,0 +1,44 @@
1
+ export interface HYSwitchChangeDetail {
2
+ checked: boolean;
3
+ value: string;
4
+ }
5
+ export type HYSwitchSize = 'small' | 'default';
6
+ export declare class HYSwitch extends HTMLElement {
7
+ static readonly formAssociated = true;
8
+ private readonly _input;
9
+ private readonly _text;
10
+ private readonly _labelSlot;
11
+ private readonly _formControl;
12
+ static get observedAttributes(): string[];
13
+ constructor();
14
+ connectedCallback(): void;
15
+ disconnectedCallback(): void;
16
+ attributeChangedCallback(): void;
17
+ get checked(): boolean;
18
+ set checked(value: boolean);
19
+ get disabled(): boolean;
20
+ set disabled(value: boolean);
21
+ get loading(): boolean;
22
+ set loading(value: boolean);
23
+ get value(): string;
24
+ set value(value: string);
25
+ get name(): string;
26
+ set name(value: string);
27
+ get label(): string;
28
+ set label(value: string);
29
+ get size(): HYSwitchSize;
30
+ set size(value: HYSwitchSize);
31
+ get form(): HTMLFormElement | null;
32
+ checkValidity(): boolean;
33
+ reportValidity(): boolean;
34
+ setCustomValidity(message: string): void;
35
+ formDisabledCallback(disabled: boolean): void;
36
+ formResetCallback(): void;
37
+ formStateRestoreCallback(state: string | File | FormData | null): void;
38
+ focus(options?: FocusOptions): void;
39
+ click(): void;
40
+ private _sync;
41
+ private _onChange;
42
+ private _onKeydown;
43
+ }
44
+ export declare function defineSwitchComponents(): void;