@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
package/dist/checkbox.js CHANGED
@@ -1,10 +1,13 @@
1
+ import { HYFormControl } from './internal/form-control.js';
1
2
  export class HYCheckbox extends HTMLElement {
3
+ static formAssociated = true;
2
4
  _input = document.createElement('input');
3
5
  _box = document.createElement('span');
4
6
  _label = document.createElement('span');
5
7
  _slot = document.createElement('slot');
8
+ _formControl = new HYFormControl(this, this._input);
6
9
  static get observedAttributes() {
7
- return ['checked', 'disabled', 'indeterminate', 'label', 'value', 'name', 'aria-label'];
10
+ return ['checked', 'disabled', 'indeterminate', 'label', 'value', 'name', 'aria-label', 'required'];
8
11
  }
9
12
  constructor() {
10
13
  super();
@@ -16,7 +19,7 @@ export class HYCheckbox extends HTMLElement {
16
19
  width: max-content;
17
20
  min-width: 0;
18
21
  color: var(--hy-checkbox-text-color, var(--hy-text-color, #d8e2f2));
19
- font: 12px system-ui, sans-serif;
22
+ font: var(--hy-font-size-sm, 12px) var(--hy-font-family, system-ui, sans-serif);
20
23
  }
21
24
  :host([disabled]) {
22
25
  opacity: 0.55;
@@ -25,7 +28,7 @@ export class HYCheckbox extends HTMLElement {
25
28
  label {
26
29
  display: inline-flex;
27
30
  align-items: center;
28
- gap: 8px;
31
+ gap: var(--hy-space-4, 8px);
29
32
  min-width: 0;
30
33
  cursor: pointer;
31
34
  user-select: none;
@@ -52,7 +55,7 @@ export class HYCheckbox extends HTMLElement {
52
55
  display: inline-grid;
53
56
  place-items: center;
54
57
  border: 1px solid var(--hy-checkbox-border-color, var(--hy-border-color, #303746));
55
- border-radius: 3px;
58
+ border-radius: calc(var(--hy-radius-xs, 2px) + 1px);
56
59
  background: var(--hy-checkbox-bg-color, var(--hy-input-bg-color, #121822));
57
60
  color: var(--hy-checkbox-mark-color, var(--hy-selected-text-color, #ffffff));
58
61
  transition: background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
@@ -107,6 +110,7 @@ export class HYCheckbox extends HTMLElement {
107
110
  connectedCallback() {
108
111
  this._input.addEventListener('change', this._onChange);
109
112
  this._sync();
113
+ this._formControl.connect();
110
114
  }
111
115
  disconnectedCallback() {
112
116
  this._input.removeEventListener('change', this._onChange);
@@ -167,7 +171,8 @@ export class HYCheckbox extends HTMLElement {
167
171
  }
168
172
  _sync() {
169
173
  this._input.checked = this.checked;
170
- this._input.disabled = this.disabled;
174
+ this._input.disabled = this.disabled || this._formControl.disabled;
175
+ this._input.required = this.hasAttribute('required');
171
176
  this._input.indeterminate = this.indeterminate;
172
177
  this._input.value = this.value;
173
178
  this._input.name = this.name;
@@ -181,7 +186,18 @@ export class HYCheckbox extends HTMLElement {
181
186
  this._input.setAttribute('aria-label', ariaLabel);
182
187
  else
183
188
  this._input.removeAttribute('aria-label');
184
- }
189
+ this._formControl.sync();
190
+ }
191
+ get form() { return this._formControl.internals.form; }
192
+ get validity() { return this._formControl.internals.validity; }
193
+ get validationMessage() { return this._formControl.internals.validationMessage; }
194
+ checkValidity() { return this._formControl.internals.checkValidity(); }
195
+ reportValidity() { return this._formControl.internals.reportValidity(); }
196
+ setCustomValidity(message) { this._formControl.setCustomValidity(message); }
197
+ formDisabledCallback(disabled) { this._formControl.disabled = disabled; this._sync(); }
198
+ formResetCallback() { this._formControl.reset(); }
199
+ formStateRestoreCallback(state) { this._formControl.restore(state); }
200
+ focus(options) { this._input.focus(options); }
185
201
  _onChange = () => {
186
202
  if (this._input.checked)
187
203
  this.setAttribute('checked', '');
@@ -23,9 +23,12 @@ export declare class HYCollapse extends HTMLElement {
23
23
  private _itemsAssigned;
24
24
  private _activeKeys;
25
25
  private _panels;
26
+ private readonly _motion;
27
+ private readonly _resizeObserver;
26
28
  static get observedAttributes(): string[];
27
29
  constructor();
28
30
  connectedCallback(): void;
31
+ disconnectedCallback(): void;
29
32
  attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
30
33
  get items(): readonly HYCollapseItem[];
31
34
  set items(value: readonly HYCollapseItem[]);
@@ -43,10 +46,20 @@ export declare class HYCollapse extends HTMLElement {
43
46
  set collapsible(value: HYCollapseTrigger);
44
47
  get destroyOnHidden(): boolean;
45
48
  set destroyOnHidden(value: boolean);
49
+ /** Opt-in height and arrow transitions. Initial rendering is always immediate. */
50
+ get animated(): boolean;
51
+ set animated(value: boolean);
52
+ /** Milliseconds; zero disables animation. Defaults to 200 (or the inherited duration token). */
53
+ get animationDuration(): number;
54
+ set animationDuration(value: number);
46
55
  toggle(key: HYCollapseKey, expanded?: boolean): void;
47
56
  private _readItemsAttribute;
48
57
  private _syncItems;
49
58
  private _syncExpanded;
59
+ private _duration;
60
+ private _transition;
61
+ private _finishTransition;
62
+ private _onMotionChange;
50
63
  private _renderContent;
51
64
  private _normalizeActiveKeys;
52
65
  private _reflectActiveKeys;
package/dist/collapse.js CHANGED
@@ -18,29 +18,37 @@ export class HYCollapse extends HTMLElement {
18
18
  _itemsAssigned = false;
19
19
  _activeKeys = [];
20
20
  _panels = new Map();
21
+ _motion = window.matchMedia('(prefers-reduced-motion: reduce)');
22
+ _resizeObserver = new ResizeObserver(() => {
23
+ for (const panel of this._panels.values()) {
24
+ if (panel.animation && panel.expanded && panel.targetHeight !== panel.body.offsetHeight) {
25
+ this._transition(panel, Number.parseFloat(getComputedStyle(panel.region).height), this._duration());
26
+ }
27
+ }
28
+ });
21
29
  static get observedAttributes() {
22
- return ['items', 'active-keys', 'default-active-keys', 'accordion', 'bordered', 'ghost', 'icon-position', 'collapsible', 'destroy-on-hidden', 'aria-label'];
30
+ return ['items', 'active-keys', 'default-active-keys', 'accordion', 'bordered', 'ghost', 'icon-position', 'collapsible', 'destroy-on-hidden', 'animated', 'animation-duration', 'aria-label'];
23
31
  }
24
32
  constructor() {
25
33
  super();
26
34
  const root = this.attachShadow({ mode: 'open' });
27
35
  const style = document.createElement('style');
28
36
  style.textContent = `
29
- :host { display: block; min-width: 0; color: var(--hy-text-color, #eef3ff); font: 12px/1.5 system-ui, sans-serif; }
30
- .collapse { overflow: hidden; border: 1px solid var(--hy-border-color, #3d4654); border-radius: var(--hy-collapse-radius, 8px); background: var(--hy-surface-color, #111722); }
37
+ :host { display: block; min-width: 0; color: var(--hy-text-color, #eef3ff); font: var(--hy-font-size-sm, 12px)/var(--hy-line-height-relaxed, 1.5) var(--hy-font-family, system-ui, sans-serif); }
38
+ .collapse { overflow: hidden; border: 1px solid var(--hy-border-color, #3d4654); border-radius: var(--hy-collapse-radius, var(--hy-radius-lg, 8px)); background: var(--hy-surface-color, #111722); }
31
39
  .panel + .panel { border-top: 1px solid var(--hy-border-color, #3d4654); }
32
- .header { display: flex; min-height: var(--hy-collapse-header-height, 44px); align-items: center; background: var(--hy-collapse-header-bg, color-mix(in srgb, var(--hy-surface-elevated-color, #171d27) 82%, transparent)); }
33
- .trigger { display: flex; min-width: 0; min-height: inherit; flex: 1 1 auto; align-items: center; gap: 10px; padding: 9px 14px; border: 0; color: inherit; background: transparent; cursor: pointer; font: inherit; text-align: start; }
40
+ .header { display: flex; min-height: var(--hy-collapse-header-height, var(--hy-control-height-lg, 44px)); align-items: center; background: var(--hy-collapse-header-bg, color-mix(in srgb, var(--hy-surface-elevated-color, #171d27) 82%, transparent)); }
41
+ .trigger { display: flex; min-width: 0; min-height: inherit; flex: 1 1 auto; align-items: center; gap: var(--hy-space-5, 10px); padding: calc(var(--hy-space-4, 8px) + 1px) var(--hy-space-7, 14px); border: 0; color: inherit; background: transparent; cursor: pointer; font: inherit; text-align: start; }
34
42
  .trigger:hover:not(:disabled) { background: var(--hy-hover-bg-color, #273241); }
35
43
  .trigger:focus-visible { position: relative; z-index: 1; outline: 2px solid var(--hy-focus-border-color, #79a8ff); outline-offset: -2px; }
36
44
  .trigger:disabled { color: var(--hy-muted-color, #788697); cursor: not-allowed; }
37
- .arrow { display: grid; width: 16px; height: 16px; flex: 0 0 auto; place-items: center; color: var(--hy-muted-color, #788697); transition: transform 160ms ease; }
45
+ .arrow { display: grid; width: 16px; height: 16px; flex: 0 0 auto; place-items: center; color: var(--hy-muted-color, #788697); transition: transform var(--hy-collapse-animation-duration, 200ms) var(--hy-collapse-animation-easing, ease); }
38
46
  .arrow::before { content: ''; width: 6px; height: 6px; border-block-start: 1.5px solid currentColor; border-inline-end: 1.5px solid currentColor; transform: rotate(45deg); }
39
47
  .panel.expanded .arrow { transform: rotate(90deg); }
40
48
  .title { min-width: 0; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
41
- .extra { flex: 0 0 auto; padding-inline: var(--hy-collapse-extra-gap, 10px) 14px; color: var(--hy-muted-color, #788697); font-size: 10px; }
49
+ .extra { flex: 0 0 auto; padding-inline: var(--hy-collapse-extra-gap, var(--hy-space-5, 10px)) var(--hy-space-7, 14px); color: var(--hy-muted-color, #788697); font-size: var(--hy-font-size-xs, 10px); }
42
50
  .region[hidden] { display: none; }
43
- .body { padding: var(--hy-collapse-content-padding, 16px); border-top: 1px solid var(--hy-border-color, #3d4654); color: var(--hy-secondary-text-color, #aebbd0); background: var(--hy-collapse-content-bg, transparent); }
51
+ .body { padding: var(--hy-collapse-content-padding, var(--hy-space-8, 16px)); border-top: 1px solid var(--hy-border-color, #3d4654); color: var(--hy-secondary-text-color, #aebbd0); background: var(--hy-collapse-content-bg, transparent); }
44
52
  :host([icon-position="end"]) .arrow { order: 2; }
45
53
  :host([bordered="false"]) .collapse { border: 0; border-radius: 0; }
46
54
  :host([ghost]) .collapse { border: 0; background: transparent; }
@@ -54,6 +62,7 @@ export class HYCollapse extends HTMLElement {
54
62
  root.append(style, this._container);
55
63
  }
56
64
  connectedCallback() {
65
+ this._motion.addEventListener('change', this._onMotionChange);
57
66
  if (!this._itemsAssigned && this.hasAttribute('items'))
58
67
  this._readItemsAttribute();
59
68
  this._activeKeys = this.hasAttribute('active-keys') ? parseKeys(this.getAttribute('active-keys')) : parseKeys(this.getAttribute('default-active-keys'));
@@ -61,6 +70,12 @@ export class HYCollapse extends HTMLElement {
61
70
  this._syncItems();
62
71
  this._syncLabel();
63
72
  }
73
+ disconnectedCallback() {
74
+ this._motion.removeEventListener('change', this._onMotionChange);
75
+ this._resizeObserver.disconnect();
76
+ for (const panel of this._panels.values())
77
+ this._finishTransition(panel);
78
+ }
64
79
  attributeChangedCallback(name, oldValue, newValue) {
65
80
  if (oldValue === newValue)
66
81
  return;
@@ -120,6 +135,18 @@ export class HYCollapse extends HTMLElement {
120
135
  set collapsible(value) { this.setAttribute('collapsible', value === 'icon' || value === 'disabled' ? value : 'header'); }
121
136
  get destroyOnHidden() { return this.hasAttribute('destroy-on-hidden'); }
122
137
  set destroyOnHidden(value) { this.toggleAttribute('destroy-on-hidden', Boolean(value)); }
138
+ /** Opt-in height and arrow transitions. Initial rendering is always immediate. */
139
+ get animated() { return this.hasAttribute('animated') && this.getAttribute('animated') !== 'false'; }
140
+ set animated(value) { if (value)
141
+ this.setAttribute('animated', '');
142
+ else
143
+ this.removeAttribute('animated'); }
144
+ /** Milliseconds; zero disables animation. Defaults to 200 (or the inherited duration token). */
145
+ get animationDuration() {
146
+ const value = Number(this.getAttribute('animation-duration') ?? 200);
147
+ return Number.isFinite(value) ? Math.max(0, Math.min(10_000, value)) : 200;
148
+ }
149
+ set animationDuration(value) { this.setAttribute('animation-duration', String(Number.isFinite(value) ? Math.max(0, Math.min(10_000, value)) : 200)); }
123
150
  toggle(key, expanded) {
124
151
  const normalized = String(key);
125
152
  const panel = this._panels.get(normalized);
@@ -153,6 +180,9 @@ export class HYCollapse extends HTMLElement {
153
180
  _syncItems() {
154
181
  if (!this.isConnected)
155
182
  return;
183
+ this._resizeObserver.disconnect();
184
+ for (const panel of this._panels.values())
185
+ this._finishTransition(panel);
156
186
  this._panels.clear();
157
187
  const sections = [];
158
188
  this._items.forEach((item, index) => {
@@ -197,9 +227,10 @@ export class HYCollapse extends HTMLElement {
197
227
  body.part.add('body');
198
228
  region.append(body);
199
229
  section.append(header, region);
200
- const record = { item, section, button, arrow, region, body, rendered: false };
230
+ const record = { item, section, button, arrow, region, body, rendered: false, expanded: null, animation: null, targetHeight: 0 };
201
231
  this._panels.set(item.key, record);
202
232
  sections.push(section);
233
+ this._resizeObserver.observe(body, { box: 'border-box' });
203
234
  button.addEventListener('click', event => { if (this.collapsible === 'icon' && event.detail !== 0 && !event.composedPath()[0]?.closest?.('.arrow'))
204
235
  return; this.toggle(item.key); });
205
236
  });
@@ -209,6 +240,7 @@ export class HYCollapse extends HTMLElement {
209
240
  _syncExpanded() {
210
241
  if (!this.isConnected)
211
242
  return;
243
+ const duration = this._duration();
212
244
  for (const [key, panel] of this._panels) {
213
245
  const expanded = this._activeKeys.includes(key);
214
246
  const disabled = Boolean(panel.item.disabled) || this.collapsible === 'disabled';
@@ -216,15 +248,70 @@ export class HYCollapse extends HTMLElement {
216
248
  panel.section.toggleAttribute('data-disabled', disabled);
217
249
  panel.button.disabled = disabled;
218
250
  panel.button.setAttribute('aria-expanded', String(expanded));
219
- panel.region.hidden = !expanded;
251
+ panel.arrow.style.transitionDuration = `${duration}ms`;
252
+ if (!expanded && panel.region.matches(':focus-within'))
253
+ panel.button.focus({ preventScroll: true });
254
+ panel.region.inert = !expanded;
255
+ panel.region.setAttribute('aria-hidden', String(!expanded));
220
256
  if (expanded && !panel.rendered)
221
257
  this._renderContent(panel);
222
- else if (!expanded && this.destroyOnHidden && panel.rendered) {
223
- panel.body.replaceChildren();
224
- panel.rendered = false;
258
+ if (panel.expanded !== expanded) {
259
+ const from = panel.animation ? Number.parseFloat(getComputedStyle(panel.region).height) : expanded ? 0 : panel.region.offsetHeight;
260
+ const animate = panel.expanded !== null && duration > 0;
261
+ panel.expanded = expanded;
262
+ if (animate)
263
+ this._transition(panel, from, duration);
264
+ else
265
+ this._finishTransition(panel);
225
266
  }
267
+ else if (!panel.animation || duration === 0)
268
+ this._finishTransition(panel);
269
+ }
270
+ }
271
+ _duration() {
272
+ if (!this.animated || this._motion.matches)
273
+ return 0;
274
+ if (this.hasAttribute('animation-duration'))
275
+ return this.animationDuration;
276
+ const token = getComputedStyle(this).getPropertyValue('--hy-collapse-animation-duration').trim();
277
+ if (!token)
278
+ return 200;
279
+ const value = Number.parseFloat(token) * (token.endsWith('ms') ? 1 : 1000);
280
+ return Number.isFinite(value) ? Math.max(0, Math.min(10_000, value)) : 200;
281
+ }
282
+ _transition(panel, from, duration) {
283
+ if (!Number.isFinite(from))
284
+ from = 0;
285
+ panel.animation?.cancel();
286
+ panel.animation = null;
287
+ panel.region.hidden = false;
288
+ const to = panel.expanded ? panel.body.offsetHeight : 0;
289
+ panel.targetHeight = to;
290
+ if (!duration || from === to) {
291
+ this._finishTransition(panel);
292
+ return;
293
+ }
294
+ panel.region.style.overflow = 'hidden';
295
+ const token = getComputedStyle(this).getPropertyValue('--hy-collapse-animation-easing').trim() || 'ease';
296
+ const easing = CSS.supports('transition-timing-function', token) ? token : 'ease';
297
+ const animation = panel.region.animate([{ height: `${from}px` }, { height: `${to}px` }], { duration, easing, fill: 'both' });
298
+ panel.animation = animation;
299
+ void animation.finished.then(() => {
300
+ if (panel.animation === animation)
301
+ this._finishTransition(panel);
302
+ }, () => { });
303
+ }
304
+ _finishTransition(panel) {
305
+ panel.animation?.cancel();
306
+ panel.animation = null;
307
+ panel.region.style.removeProperty('overflow');
308
+ panel.region.hidden = !panel.expanded;
309
+ if (!panel.expanded && this.destroyOnHidden && panel.rendered) {
310
+ panel.body.replaceChildren();
311
+ panel.rendered = false;
226
312
  }
227
313
  }
314
+ _onMotionChange = () => { this._syncExpanded(); };
228
315
  _renderContent(panel) {
229
316
  const source = typeof panel.item.content === 'function' ? panel.item.content() : panel.item.content;
230
317
  if (source instanceof Node)
@@ -19,7 +19,7 @@ export class HYContextMenu extends HTMLElement {
19
19
  display: none;
20
20
  min-width: 132px;
21
21
  color: var(--hy-text-color, #d8e2f2);
22
- font: 12px system-ui, sans-serif;
22
+ font: var(--hy-font-size-sm, 12px) var(--hy-font-family, system-ui, sans-serif);
23
23
  }
24
24
  :host([open]) {
25
25
  display: block;
@@ -27,9 +27,9 @@ export class HYContextMenu extends HTMLElement {
27
27
  .menu {
28
28
  box-sizing: border-box;
29
29
  min-width: 132px;
30
- padding: 4px;
30
+ padding: var(--hy-space-2, 4px);
31
31
  border: 1px solid var(--hy-border-color, #303746);
32
- border-radius: 4px;
32
+ border-radius: var(--hy-radius-sm, 4px);
33
33
  background: var(--hy-menu-bg-color, var(--hy-surface-elevated-color, #1b2230));
34
34
  box-shadow: 0 10px 26px var(--hy-menu-shadow-color, rgba(0, 0, 0, 0.36));
35
35
  }
@@ -68,6 +68,14 @@ export interface HYAccessibility {
68
68
  readonly error?: string;
69
69
  readonly role?: 'button' | 'text' | 'textbox' | 'checkbox' | 'tab' | 'dialog' | 'image' | 'slider' | 'list' | 'tree';
70
70
  }
71
+ export type HYIconName = 'save' | 'export' | 'play' | 'pause' | 'reset' | 'step' | 'settings' | 'back' | 'chevronDown' | 'check' | 'close' | 'add';
72
+ export type HYButtonVariant = 'primary' | 'secondary' | 'quiet' | 'danger';
73
+ export type HYTextStyle = 'title' | 'body' | 'caption';
74
+ export interface HYTypography {
75
+ readonly fontSize: number;
76
+ readonly lineHeight: number;
77
+ readonly weight?: 'normal' | 'medium' | 'bold';
78
+ }
71
79
  export interface HYCommonProps {
72
80
  readonly layout?: HYLayout;
73
81
  readonly a11y?: HYAccessibility;
@@ -95,6 +103,8 @@ export interface HYComponentProps {
95
103
  Text: HYCommonProps & {
96
104
  readonly text: string;
97
105
  readonly wrap?: boolean;
106
+ readonly textStyle?: HYTextStyle;
107
+ readonly tone?: 'default' | 'muted' | 'danger';
98
108
  };
99
109
  Image: HYCommonProps & {
100
110
  readonly resource: HYResource;
@@ -108,6 +118,9 @@ export interface HYComponentProps {
108
118
  readonly text: string;
109
119
  readonly disabled?: boolean;
110
120
  readonly busy?: boolean;
121
+ readonly icon?: HYIconName;
122
+ readonly variant?: HYButtonVariant;
123
+ readonly size?: 'regular' | 'compact';
111
124
  };
112
125
  Checkbox: HYCommonProps & {
113
126
  readonly checked: boolean;
@@ -131,8 +144,12 @@ export interface HYComponentProps {
131
144
  readonly checked: boolean;
132
145
  readonly disabled?: boolean;
133
146
  };
134
- Select: HYCommonProps & HYSelectionProps;
135
- Tabs: HYCommonProps & HYSelectionProps;
147
+ Select: HYCommonProps & HYSelectionProps & {
148
+ readonly presentation?: 'auto' | 'popover' | 'sheet';
149
+ };
150
+ Tabs: HYCommonProps & HYSelectionProps & {
151
+ readonly variant?: 'underline' | 'segmented';
152
+ };
136
153
  TextInput: HYCommonProps & HYTextProps;
137
154
  TextArea: HYCommonProps & Omit<HYTextProps, 'secure'>;
138
155
  Slider: HYCommonProps & {
@@ -149,6 +166,7 @@ export interface HYComponentProps {
149
166
  };
150
167
  FormGroup: HYCommonProps & {
151
168
  readonly label: string;
169
+ readonly description?: string;
152
170
  readonly error?: string;
153
171
  };
154
172
  PlatformView: HYCommonProps & {
@@ -222,11 +240,12 @@ export interface HYPlatformView {
222
240
  dispose(): void;
223
241
  }
224
242
  export interface HYTheme {
225
- readonly color: Readonly<Record<'text' | 'muted' | 'surface' | 'input' | 'accent' | 'danger' | 'border' | 'focus', string>>;
243
+ readonly color: Readonly<Record<'text' | 'muted' | 'surface' | 'input' | 'accent' | 'danger' | 'border' | 'focus', string> & Partial<Record<'selected' | 'pressed' | 'disabled' | 'elevated' | 'onAccent', string>>>;
226
244
  readonly fontSize: number;
227
245
  readonly lineHeight: number;
228
246
  readonly gap: number;
229
247
  readonly radius: number;
248
+ readonly typography?: Readonly<Partial<Record<HYTextStyle, HYTypography>>>;
230
249
  }
231
250
  export interface HYSourceLocation {
232
251
  readonly file: string;
@@ -80,20 +80,20 @@ const text = { value: string, disabled: boolean, readOnly: boolean, placeholder:
80
80
  const schemas = {
81
81
  Row: shape(common), Column: shape(common), Grid: shape(common), Overlay: shape(common),
82
82
  Scroll: shape({ ...common, axis: choice('horizontal', 'vertical') }, ['axis']),
83
- Text: shape({ ...common, text: string, wrap: boolean }, ['text']),
83
+ Text: shape({ ...common, text: string, wrap: boolean, textStyle: choice('title', 'body', 'caption'), tone: choice('default', 'muted', 'danger') }, ['text']),
84
84
  Image: shape({ ...common, resource, fit: choice('contain', 'cover') }, ['resource']),
85
85
  Icon: shape({ ...common, resource, systemName: name }, ['resource']),
86
- Button: shape({ ...common, text: string, disabled: boolean, busy: boolean }, ['text']),
86
+ Button: shape({ ...common, text: string, disabled: boolean, busy: boolean, icon: choice('save', 'export', 'play', 'pause', 'reset', 'step', 'settings', 'back', 'chevronDown', 'check', 'close', 'add'), variant: choice('primary', 'secondary', 'quiet', 'danger'), size: choice('regular', 'compact') }, ['text']),
87
87
  Checkbox: shape({ ...common, checked: boolean, disabled: boolean, text: string }, ['checked', 'text']),
88
88
  RadioGroup: shape({ ...common, ...selection }, ['value', 'options']),
89
89
  Rate: shape({ ...common, value: integer, count: check(v => Number.isInteger(v) && v >= 1 && v <= 10, 'Expected count 1–10'), disabled: boolean, readOnly: boolean }, ['value', 'count']),
90
90
  Badge: shape({ ...common, text: string }, ['text']), Divider: shape({ ...common, text: string }),
91
91
  Toggle: shape({ ...common, checked: boolean, disabled: boolean }, ['checked']),
92
- Select: shape({ ...common, ...selection }, ['value', 'options']), Tabs: shape({ ...common, ...selection }, ['value', 'options']),
92
+ Select: shape({ ...common, ...selection, presentation: choice('auto', 'popover', 'sheet') }, ['value', 'options']), Tabs: shape({ ...common, ...selection, variant: choice('underline', 'segmented') }, ['value', 'options']),
93
93
  TextInput: shape({ ...common, ...text, secure: boolean }, ['value']), TextArea: shape({ ...common, ...text }, ['value']),
94
94
  Slider: shape({ ...common, value: number, min: number, max: number, step: positive, disabled: boolean }, ['value', 'min', 'max', 'step']),
95
95
  Dialog: shape({ ...common, open: boolean, title: string, dismissible: boolean }, ['open', 'title']),
96
- FormGroup: shape({ ...common, label: string, error: string }, ['label']),
96
+ FormGroup: shape({ ...common, label: string, description: string, error: string }, ['label']),
97
97
  PlatformView: shape({ ...common, slot: name, resourceId: name }, ['slot', 'resourceId']),
98
98
  };
99
99
  export const HY_COMPONENTS = Object.freeze(Object.keys(schemas));
@@ -140,6 +140,11 @@ export function hyValidateProps(kind, props, context = {}, capabilities) {
140
140
  if (!p.options.some(o => o.value === p.value))
141
141
  fail('Unknown controlled value', field(context, 'value'));
142
142
  }
143
+ if (kind === 'Button') {
144
+ const p = props;
145
+ if (p.icon && !p.text.trim() && !p.a11y?.label.trim())
146
+ fail('Icon-only button needs an accessible label', field(context, 'a11y.label'));
147
+ }
143
148
  if (kind === 'Rate' && props.value > props.count)
144
149
  fail('Rating exceeds count', context);
145
150
  if (kind === 'Slider') {
@@ -43,38 +43,38 @@ export class HYDatePicker extends HTMLElement {
43
43
  const root = this.attachShadow({ mode: 'open' });
44
44
  const style = document.createElement('style');
45
45
  style.textContent = `
46
- :host { position: relative; display: inline-block; min-width: 180px; color: var(--hy-text-color, #eef3ff); font: 12px/1.4 system-ui, sans-serif; }
47
- .control { display: grid; grid-template-columns: minmax(0, 1fr) auto; height: var(--hy-date-picker-height, 34px); box-sizing: border-box; border: 1px solid var(--hy-border-color, #3d4654); border-radius: var(--hy-date-picker-radius, 6px); background: var(--hy-input-bg-color, #111722); }
46
+ :host { position: relative; display: inline-block; min-width: 180px; color: var(--hy-text-color, #eef3ff); font: var(--hy-font-size-sm, 12px)/var(--hy-line-height-snug, 1.4) var(--hy-font-family, system-ui, sans-serif); }
47
+ .control { display: grid; grid-template-columns: minmax(0, 1fr) auto; height: var(--hy-date-picker-height, var(--hy-control-height-md, 34px)); box-sizing: border-box; border: 1px solid var(--hy-border-color, #3d4654); border-radius: var(--hy-date-picker-radius, var(--hy-radius-md, 6px)); background: var(--hy-input-bg-color, #111722); }
48
48
  :host(:not([disabled])) .control:hover { border-color: var(--hy-hover-border-color, #596779); }
49
49
  :host(:focus-within) .control, :host([open]) .control { border-color: var(--hy-focus-border-color, #79a8ff); box-shadow: 0 0 0 2px var(--hy-focus-ring-color, rgba(121, 168, 255, 0.22)); }
50
- .trigger { display: flex; align-items: center; min-width: 0; gap: 8px; padding: 0 8px 0 10px; overflow: hidden; border: 0; color: inherit; background: transparent; cursor: pointer; font: inherit; text-align: left; }
50
+ .trigger { display: flex; align-items: center; min-width: 0; gap: var(--hy-space-4, 8px); padding: 0 var(--hy-space-4, 8px) 0 var(--hy-space-5, 10px); overflow: hidden; border: 0; color: inherit; background: transparent; cursor: pointer; font: inherit; text-align: left; }
51
51
  .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
52
52
  .label.placeholder { color: var(--hy-muted-color, #788697); }
53
- .arrow { flex: 0 0 auto; color: var(--hy-muted-color, #788697); font-size: 14px; }
54
- .clear { width: 28px; padding: 0; border: 0; color: var(--hy-muted-color, #788697); background: transparent; cursor: pointer; font: 15px/1 system-ui, sans-serif; }
53
+ .arrow { flex: 0 0 auto; color: var(--hy-muted-color, #788697); font-size: var(--hy-font-size-md, 14px); }
54
+ .clear { width: 28px; padding: 0; border: 0; color: var(--hy-muted-color, #788697); background: transparent; cursor: pointer; font: calc(var(--hy-font-size-md, 14px) + 1px)/var(--hy-line-height-tight, 1) var(--hy-font-family, system-ui, sans-serif); }
55
55
  .clear:hover { color: var(--hy-text-color, #eef3ff); }
56
56
  .clear[hidden] { display: none; }
57
57
  .trigger:focus-visible, .clear:focus-visible { outline: none; }
58
58
  :host([disabled]) { opacity: 0.52; }
59
59
  :host([disabled]) .trigger, :host([disabled]) .clear { cursor: not-allowed; }
60
- .panel { position: absolute; z-index: var(--hy-date-picker-z-index, 50); top: calc(100% + 6px); left: 0; width: var(--hy-date-picker-panel-width, 286px); box-sizing: border-box; padding: 10px; border: 1px solid var(--hy-border-color, #3d4654); border-radius: var(--hy-date-picker-panel-radius, 8px); background: var(--hy-menu-bg-color, var(--hy-surface-elevated-color, #171d27)); box-shadow: 0 12px 32px var(--hy-menu-shadow-color, rgba(0, 0, 0, 0.36)); }
60
+ .panel { position: absolute; z-index: var(--hy-date-picker-z-index, 50); top: calc(100% + 6px); left: 0; width: var(--hy-date-picker-panel-width, 286px); box-sizing: border-box; padding: var(--hy-space-5, 10px); border: 1px solid var(--hy-border-color, #3d4654); border-radius: var(--hy-date-picker-panel-radius, var(--hy-radius-lg, 8px)); background: var(--hy-menu-bg-color, var(--hy-surface-elevated-color, #171d27)); box-shadow: 0 12px 32px var(--hy-menu-shadow-color, rgba(0, 0, 0, 0.36)); }
61
61
  .panel[hidden] { display: none; }
62
- .calendar-header { display: grid; grid-template-columns: 30px 1fr 30px; align-items: center; margin-bottom: 7px; }
63
- .month-label { color: var(--hy-text-color, #eef3ff); font-weight: 650; text-align: center; }
64
- .month-button, .footer button { height: 28px; border: 1px solid transparent; border-radius: 4px; color: var(--hy-secondary-text-color, #aebbd0); background: transparent; cursor: pointer; font: inherit; }
62
+ .calendar-header { display: grid; grid-template-columns: 30px 1fr 30px; align-items: center; margin-bottom: calc(var(--hy-space-3, 6px) + 1px); }
63
+ .month-label { color: var(--hy-text-color, #eef3ff); font-weight: calc(var(--hy-font-weight-semibold, 600) + 50); text-align: center; }
64
+ .month-button, .footer button { height: var(--hy-control-height-sm, 28px); border: 1px solid transparent; border-radius: var(--hy-radius-sm, 4px); color: var(--hy-secondary-text-color, #aebbd0); background: transparent; cursor: pointer; font: inherit; }
65
65
  .month-button:hover:not(:disabled), .footer button:hover:not(:disabled) { color: var(--hy-accent-color, #79a8ff); background: var(--hy-hover-bg-color, #273241); }
66
66
  .month-button:focus-visible, .footer button:focus-visible { outline: 2px solid var(--hy-focus-border-color, #79a8ff); outline-offset: 1px; }
67
67
  .month-button:disabled, .footer button:disabled { cursor: not-allowed; opacity: 0.35; }
68
- .weekdays, .days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
69
- .weekday { padding: 4px 0; color: var(--hy-muted-color, #788697); font-size: 10px; text-align: center; }
68
+ .weekdays, .days { display: grid; grid-template-columns: repeat(7, 1fr); gap: var(--hy-space-1, 2px); }
69
+ .weekday { padding: var(--hy-space-2, 4px) 0; color: var(--hy-muted-color, #788697); font-size: var(--hy-font-size-xs, 10px); text-align: center; }
70
70
  .day { position: relative; width: 100%; aspect-ratio: 1; min-height: 31px; padding: 0; border: 1px solid transparent; border-radius: var(--hy-date-picker-day-radius, 50%); color: var(--hy-secondary-text-color, #aebbd0); background: transparent; cursor: pointer; font: inherit; }
71
71
  .day:hover:not(:disabled), .day:focus-visible { outline: none; color: var(--hy-text-color, #eef3ff); border-color: var(--hy-hover-border-color, #596779); background: var(--hy-hover-bg-color, #273241); }
72
72
  .day.outside { color: var(--hy-muted-color, #788697); opacity: 0.6; }
73
73
  .day.today::after { position: absolute; right: 50%; bottom: 3px; width: 3px; height: 3px; border-radius: 50%; background: var(--hy-accent-color, #79a8ff); content: ''; transform: translateX(50%); }
74
74
  .day[aria-selected="true"] { color: var(--hy-selected-text-color, #fff); border-color: var(--hy-selected-bg-color, #554cc6); background: var(--hy-selected-bg-color, #554cc6); }
75
75
  .day:disabled { cursor: not-allowed; opacity: 0.24; }
76
- .footer { display: flex; justify-content: flex-end; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--hy-border-color, #3d4654); }
77
- .footer button { padding: 0 9px; color: var(--hy-accent-color, #79a8ff); }
76
+ .footer { display: flex; justify-content: flex-end; margin-top: var(--hy-space-4, 8px); padding-top: var(--hy-space-4, 8px); border-top: 1px solid var(--hy-border-color, #3d4654); }
77
+ .footer button { padding: 0 calc(var(--hy-space-4, 8px) + 1px); color: var(--hy-accent-color, #79a8ff); }
78
78
  `;
79
79
  this._control.className = 'control';
80
80
  this._control.part.add('control');
@@ -0,0 +1,44 @@
1
+ export type HYDescriptionsLayout = 'horizontal' | 'vertical';
2
+ export type HYDescriptionsSize = 'small' | 'default';
3
+ export interface HYDescriptionItem {
4
+ key?: string;
5
+ label: string;
6
+ value?: string | number | boolean | null;
7
+ span?: number | 'filled';
8
+ }
9
+ /** Semantic definition list with responsive columns, spans and rich value slots. */
10
+ export declare class HYDescriptions extends HTMLElement {
11
+ private readonly _header;
12
+ private readonly _heading;
13
+ private readonly _extra;
14
+ private readonly _list;
15
+ private readonly _rows;
16
+ private _items;
17
+ private _observer;
18
+ private _width;
19
+ static get observedAttributes(): string[];
20
+ constructor();
21
+ connectedCallback(): void;
22
+ disconnectedCallback(): void;
23
+ attributeChangedCallback(name: string): void;
24
+ get items(): HYDescriptionItem[];
25
+ set items(value: readonly HYDescriptionItem[]);
26
+ get heading(): string;
27
+ set heading(value: string);
28
+ get column(): number;
29
+ set column(value: number);
30
+ get layout(): HYDescriptionsLayout;
31
+ set layout(value: HYDescriptionsLayout);
32
+ get bordered(): boolean;
33
+ set bordered(value: boolean);
34
+ get size(): HYDescriptionsSize;
35
+ set size(value: HYDescriptionsSize);
36
+ get responsive(): boolean;
37
+ set responsive(value: boolean);
38
+ get emptyText(): string;
39
+ set emptyText(value: string);
40
+ private _normalize;
41
+ private _layout;
42
+ private _render;
43
+ }
44
+ export declare function defineDescriptionsComponents(): void;