@haiyue/ui 0.2.2 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/README.md +523 -4
  3. package/dist/adapters/web/controls.js +48 -8
  4. package/dist/adapters/web/renderer.js +9 -11
  5. package/dist/adapters/web/styles.d.ts +2 -3
  6. package/dist/adapters/web/styles.js +26 -23
  7. package/dist/alert.d.ts +39 -0
  8. package/dist/alert.js +144 -0
  9. package/dist/anchor.d.ts +62 -0
  10. package/dist/anchor.js +293 -0
  11. package/dist/auto-complete.d.ts +83 -0
  12. package/dist/auto-complete.js +267 -0
  13. package/dist/avatar.d.ts +45 -0
  14. package/dist/avatar.js +135 -0
  15. package/dist/badge.js +5 -5
  16. package/dist/border-beam.js +3 -2
  17. package/dist/breadcrumb.js +5 -5
  18. package/dist/button-group.js +8 -8
  19. package/dist/button.js +10 -10
  20. package/dist/card.d.ts +29 -0
  21. package/dist/card.js +101 -0
  22. package/dist/carousel.js +6 -6
  23. package/dist/cascader.js +19 -13
  24. package/dist/checkbox.d.ts +12 -0
  25. package/dist/checkbox.js +22 -6
  26. package/dist/collapse.js +6 -6
  27. package/dist/context-menu.js +3 -4
  28. package/dist/core/actions.js +7 -8
  29. package/dist/core/data.d.ts +1 -1
  30. package/dist/core/data.js +44 -10
  31. package/dist/core/platform-view.js +8 -2
  32. package/dist/core/selection.js +4 -4
  33. package/dist/core/semantics.d.ts +26 -0
  34. package/dist/core/semantics.js +8 -0
  35. package/dist/core/text.js +3 -3
  36. package/dist/core/validation.d.ts +3 -1
  37. package/dist/core/validation.js +23 -5
  38. package/dist/date-picker.js +19 -13
  39. package/dist/descriptions.d.ts +44 -0
  40. package/dist/descriptions.js +169 -0
  41. package/dist/dialog.d.ts +4 -0
  42. package/dist/dialog.js +48 -27
  43. package/dist/divider.js +2 -2
  44. package/dist/draggable.js +5 -3
  45. package/dist/drawer.js +16 -24
  46. package/dist/dropdown.js +3 -4
  47. package/dist/empty.d.ts +20 -0
  48. package/dist/empty.js +58 -0
  49. package/dist/expandable.js +4 -4
  50. package/dist/form-item.d.ts +60 -0
  51. package/dist/form-item.js +212 -0
  52. package/dist/form.d.ts +41 -0
  53. package/dist/form.js +154 -0
  54. package/dist/history-controls.js +5 -5
  55. package/dist/image-preview.d.ts +22 -0
  56. package/dist/image-preview.js +38 -0
  57. package/dist/image.d.ts +52 -0
  58. package/dist/image.js +152 -0
  59. package/dist/index.d.ts +48 -0
  60. package/dist/index.js +72 -0
  61. package/dist/input.d.ts +11 -0
  62. package/dist/input.js +32 -18
  63. package/dist/internal/anchored-popup.d.ts +19 -0
  64. package/dist/internal/anchored-popup.js +89 -0
  65. package/dist/internal/focus.d.ts +2 -0
  66. package/dist/internal/focus.js +31 -0
  67. package/dist/internal/form-control.d.ts +22 -0
  68. package/dist/internal/form-control.js +52 -0
  69. package/dist/internal/image-viewer.d.ts +51 -0
  70. package/dist/internal/image-viewer.js +210 -0
  71. package/dist/internal/keyboard.d.ts +2 -0
  72. package/dist/internal/keyboard.js +12 -0
  73. package/dist/internal/numbers.d.ts +2 -0
  74. package/dist/internal/numbers.js +8 -0
  75. package/dist/internal/pagination.d.ts +35 -0
  76. package/dist/internal/pagination.js +169 -0
  77. package/dist/internal/popover-base.d.ts +87 -0
  78. package/dist/internal/popover-base.js +365 -0
  79. package/dist/internal/presentation.d.ts +2 -0
  80. package/dist/internal/presentation.js +28 -0
  81. package/dist/mentions.d.ts +115 -0
  82. package/dist/mentions.js +485 -0
  83. package/dist/menu-shared.d.ts +1 -1
  84. package/dist/menu-shared.js +3 -3
  85. package/dist/menu.d.ts +63 -0
  86. package/dist/menu.js +339 -0
  87. package/dist/modal.js +11 -40
  88. package/dist/notification.js +11 -10
  89. package/dist/pagination.d.ts +34 -0
  90. package/dist/pagination.js +73 -0
  91. package/dist/popconfirm.d.ts +6 -0
  92. package/dist/popconfirm.js +7 -0
  93. package/dist/popover.d.ts +6 -0
  94. package/dist/popover.js +7 -0
  95. package/dist/portable/page.js +25 -14
  96. package/dist/progress.d.ts +30 -0
  97. package/dist/progress.js +102 -0
  98. package/dist/qr-code.js +3 -3
  99. package/dist/radio.d.ts +10 -0
  100. package/dist/radio.js +18 -5
  101. package/dist/range.js +7 -7
  102. package/dist/rate.js +3 -3
  103. package/dist/resizable.js +8 -5
  104. package/dist/result.d.ts +22 -0
  105. package/dist/result.js +88 -0
  106. package/dist/ribbon.d.ts +19 -0
  107. package/dist/ribbon.js +106 -0
  108. package/dist/segmented.d.ts +39 -0
  109. package/dist/segmented.js +192 -0
  110. package/dist/select.d.ts +12 -0
  111. package/dist/select.js +31 -13
  112. package/dist/skeleton.js +10 -10
  113. package/dist/spin.d.ts +26 -0
  114. package/dist/spin.js +80 -0
  115. package/dist/steps.js +13 -13
  116. package/dist/switch.d.ts +44 -0
  117. package/dist/switch.js +104 -0
  118. package/dist/table.d.ts +3 -3
  119. package/dist/table.js +110 -128
  120. package/dist/tabs.js +7 -7
  121. package/dist/tag.js +8 -8
  122. package/dist/time-picker.js +16 -10
  123. package/dist/timeline.js +12 -12
  124. package/dist/toast.js +12 -11
  125. package/dist/tooltip.d.ts +6 -0
  126. package/dist/tooltip.js +107 -6
  127. package/dist/tour.js +26 -17
  128. package/dist/tree-model.d.ts +2 -0
  129. package/dist/tree-model.js +32 -11
  130. package/dist/tree-node.js +2 -2
  131. package/dist/tree-select.d.ts +94 -0
  132. package/dist/tree-select.js +398 -0
  133. package/dist/tree.d.ts +0 -2
  134. package/dist/tree.js +14 -29
  135. package/dist/upload.d.ts +108 -0
  136. package/dist/upload.js +358 -0
  137. package/dist/virtual-keyboard.d.ts +1 -0
  138. package/dist/virtual-keyboard.js +72 -41
  139. package/dist/virtual-list.d.ts +1 -0
  140. package/dist/virtual-list.js +25 -8
  141. package/dist/virtual-mouse.js +7 -6
  142. package/dist/watermark.js +2 -1
  143. package/package.json +82 -1
  144. package/themes/haiyue-dark.css +51 -0
  145. package/themes/haiyue-light.css +51 -0
@@ -0,0 +1,45 @@
1
+ export type HYAvatarShape = 'circle' | 'square';
2
+ export type HYAvatarSize = 'small' | 'default' | 'large' | number;
3
+ export type HYAvatarStatus = 'empty' | 'loading' | 'loaded' | 'error';
4
+ export type HYAvatarFit = 'cover' | 'contain' | 'fill';
5
+ export interface HYAvatarLoadDetail {
6
+ src: string;
7
+ naturalWidth: number;
8
+ naturalHeight: number;
9
+ }
10
+ export interface HYAvatarErrorDetail {
11
+ src: string;
12
+ }
13
+ /** Image avatar with text or slotted fallback and stale-request protection. */
14
+ export declare class HYAvatar extends HTMLElement {
15
+ private readonly _frame;
16
+ private readonly _imageHost;
17
+ private readonly _fallback;
18
+ private readonly _text;
19
+ private readonly _icon;
20
+ private _image;
21
+ private _listeners;
22
+ private _key;
23
+ private _status;
24
+ static get observedAttributes(): string[];
25
+ constructor();
26
+ connectedCallback(): void;
27
+ disconnectedCallback(): void;
28
+ attributeChangedCallback(): void;
29
+ get src(): string;
30
+ set src(value: string);
31
+ get alt(): string;
32
+ set alt(value: string);
33
+ get text(): string;
34
+ set text(value: string);
35
+ get shape(): HYAvatarShape;
36
+ set shape(value: HYAvatarShape);
37
+ get size(): HYAvatarSize;
38
+ set size(value: HYAvatarSize);
39
+ get fit(): HYAvatarFit;
40
+ set fit(value: HYAvatarFit);
41
+ get status(): HYAvatarStatus;
42
+ private _syncSource;
43
+ private _render;
44
+ }
45
+ export declare function defineAvatarComponents(): void;
package/dist/avatar.js ADDED
@@ -0,0 +1,135 @@
1
+ import { presentationIcon } from './internal/presentation.js';
2
+ /** Image avatar with text or slotted fallback and stale-request protection. */
3
+ export class HYAvatar extends HTMLElement {
4
+ _frame = document.createElement('span');
5
+ _imageHost = document.createElement('span');
6
+ _fallback = document.createElement('slot');
7
+ _text = document.createElement('span');
8
+ _icon = presentationIcon('avatar');
9
+ _image = null;
10
+ _listeners = null;
11
+ _key = '';
12
+ _status = 'empty';
13
+ static get observedAttributes() { return ['src', 'srcset', 'sizes', 'alt', 'text', 'shape', 'size', 'fit', 'aria-label']; }
14
+ constructor() {
15
+ super();
16
+ const root = this.attachShadow({ mode: 'open' });
17
+ const style = document.createElement('style');
18
+ style.textContent = `
19
+ :host { display: inline-block; flex: 0 0 auto; vertical-align: middle; max-width: 100%; color: var(--hy-avatar-text-color, var(--hy-active-text-color, #eef0ff)); font-family: var(--hy-font-family, system-ui, sans-serif); }
20
+ .avatar { display: inline-grid; place-items: center; box-sizing: border-box; position: relative; width: var(--hy-avatar-size, var(--_size, 40px)); height: var(--hy-avatar-size, var(--_size, 40px)); max-width: 100%; overflow: hidden; border-radius: var(--hy-avatar-radius, 50%); background: var(--hy-avatar-bg-color, var(--hy-hover-bg-color, #242752)); line-height: 1; }
21
+ :host([shape="square"]) .avatar { border-radius: var(--hy-avatar-radius, var(--hy-radius-md, 6px)); }
22
+ .image-host { display: contents; } img { display: block; width: 100%; height: 100%; min-width: 0; min-height: 0; object-fit: var(--_fit, cover); }
23
+ .fallback { display: grid; place-items: center; width: 100%; height: 100%; min-width: 0; min-height: 0; max-height: 100%; font-size: var(--hy-avatar-font-size, var(--_font-size, 16px)); font-weight: var(--hy-font-weight-semibold, 600); }
24
+ .fallback svg { width: 64%; height: 64%; } .text { max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
25
+ .fallback::slotted(*) { max-width: 100%; max-height: 100%; } [hidden] { display: none !important; }
26
+ `;
27
+ this._frame.className = 'avatar';
28
+ this._frame.part.add('avatar');
29
+ this._imageHost.className = 'image-host';
30
+ this._fallback.className = 'fallback';
31
+ this._fallback.part.add('fallback');
32
+ this._text.className = 'text';
33
+ this._text.part.add('text');
34
+ this._fallback.append(this._text, this._icon);
35
+ this._frame.append(this._imageHost, this._fallback);
36
+ root.append(style, this._frame);
37
+ this._fallback.addEventListener('slotchange', this._render);
38
+ }
39
+ connectedCallback() { this._syncSource(); this._render(); }
40
+ disconnectedCallback() { this._listeners?.abort(); this._listeners = null; this._key = ''; }
41
+ attributeChangedCallback() { if (this.isConnected)
42
+ this._syncSource(); this._render(); }
43
+ get src() { return this.getAttribute('src') ?? ''; }
44
+ set src(value) { this.setAttribute('src', value); }
45
+ get alt() { return this.getAttribute('alt') ?? this.text; }
46
+ set alt(value) { this.setAttribute('alt', value); }
47
+ get text() { return this.getAttribute('text') ?? ''; }
48
+ set text(value) { this.setAttribute('text', value); }
49
+ get shape() { return this.getAttribute('shape') === 'square' ? 'square' : 'circle'; }
50
+ set shape(value) { this.setAttribute('shape', value); }
51
+ get size() {
52
+ const value = this.getAttribute('size');
53
+ if (value === 'small' || value === 'large')
54
+ return value;
55
+ if (value?.trim() && Number.isFinite(Number(value)))
56
+ return Math.max(16, Math.min(256, Number(value)));
57
+ return 'default';
58
+ }
59
+ set size(value) { this.setAttribute('size', String(value)); }
60
+ get fit() { const value = this.getAttribute('fit'); return value === 'contain' || value === 'fill' ? value : 'cover'; }
61
+ set fit(value) { this.setAttribute('fit', value); }
62
+ get status() { return this._status; }
63
+ _syncSource() {
64
+ const srcset = this.getAttribute('srcset') ?? '';
65
+ const sizes = this.getAttribute('sizes') ?? '';
66
+ const key = JSON.stringify([this.src, srcset, sizes]);
67
+ if (key === this._key)
68
+ return;
69
+ this._key = key;
70
+ this._listeners?.abort();
71
+ this._listeners = null;
72
+ this._imageHost.replaceChildren();
73
+ this._image = null;
74
+ if (!this.src && !srcset) {
75
+ this._status = 'empty';
76
+ return;
77
+ }
78
+ const image = document.createElement('img');
79
+ this._image = image;
80
+ this._status = 'loading';
81
+ image.alt = '';
82
+ image.part.add('image');
83
+ this._listeners = new AbortController();
84
+ const signal = this._listeners.signal;
85
+ image.addEventListener('load', () => {
86
+ if (this._image !== image || !this.isConnected)
87
+ return;
88
+ this._status = 'loaded';
89
+ this._render();
90
+ this.dispatchEvent(new CustomEvent('avatar-load', { bubbles: true, composed: true, detail: { src: image.currentSrc || this.src, naturalWidth: image.naturalWidth, naturalHeight: image.naturalHeight } }));
91
+ }, { signal });
92
+ image.addEventListener('error', () => {
93
+ if (this._image !== image || !this.isConnected)
94
+ return;
95
+ this._status = 'error';
96
+ this._render();
97
+ this.dispatchEvent(new CustomEvent('avatar-error', { bubbles: true, composed: true, detail: { src: this.src || srcset } }));
98
+ }, { signal });
99
+ this._imageHost.append(image);
100
+ if (sizes)
101
+ image.sizes = sizes;
102
+ if (srcset)
103
+ image.srcset = srcset;
104
+ if (this.src)
105
+ image.src = this.src;
106
+ }
107
+ _render = () => {
108
+ const size = typeof this.size === 'number' ? this.size : this.size === 'small' ? 28 : this.size === 'large' ? 56 : 40;
109
+ this._frame.style.setProperty('--_size', `${size}px`);
110
+ this._frame.style.setProperty('--_fit', this.fit);
111
+ const text = this.text || this._fallback.assignedNodes().map(node => node.textContent ?? '').join('').trim();
112
+ this._frame.style.setProperty('--_font-size', `${Math.max(8, Math.min(size * .4, size * .8 / Math.max(1, [...text].length)))}px`);
113
+ if (this._text.textContent !== this.text)
114
+ this._text.textContent = this.text;
115
+ this._text.hidden = !this.text;
116
+ this._icon.style.display = this.text ? 'none' : '';
117
+ if (this._image)
118
+ this._image.hidden = this._status !== 'loaded';
119
+ this._fallback.hidden = this._status === 'loaded';
120
+ const decorative = this.hasAttribute('alt') && this.alt === '' && !this.getAttribute('aria-label');
121
+ this._frame.toggleAttribute('aria-hidden', decorative);
122
+ if (decorative) {
123
+ this._frame.setAttribute('aria-hidden', 'true');
124
+ this._frame.removeAttribute('role');
125
+ this._frame.removeAttribute('aria-label');
126
+ }
127
+ else {
128
+ this._frame.setAttribute('role', 'img');
129
+ this._frame.setAttribute('aria-label', this.getAttribute('aria-label') || this.alt || text || 'Avatar');
130
+ }
131
+ };
132
+ }
133
+ export function defineAvatarComponents() { if (!customElements.get('hy-avatar'))
134
+ customElements.define('hy-avatar', HYAvatar); }
135
+ //# sourceMappingURL=avatar.js.map
package/dist/badge.js CHANGED
@@ -21,17 +21,17 @@ export class HYBadge extends HTMLElement {
21
21
  const root = this.attachShadow({ mode: 'open' });
22
22
  const style = document.createElement('style');
23
23
  style.textContent = `
24
- :host { display: inline-block; max-width: 100%; color: var(--hy-text-color, #eef3ff); font: 12px/1.4 system-ui, sans-serif; vertical-align: middle; }
24
+ :host { display: inline-block; max-width: 100%; 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); vertical-align: middle; }
25
25
  .wrapper { position: relative; display: inline-flex; max-width: 100%; align-items: center; }
26
- .badge { display: inline-flex; min-width: var(--hy-badge-height, 20px); height: var(--hy-badge-height, 20px); align-items: center; justify-content: center; box-sizing: border-box; margin: 0; padding: 0 var(--hy-badge-padding, 6px); border: var(--hy-badge-border-width, 2px) solid var(--hy-surface-color, #111722); border-radius: 999px; color: var(--hy-badge-text-color, #fff); background: var(--_badge-color, var(--hy-error-color, #ef5b72)); box-shadow: 0 0 0 1px color-mix(in srgb, var(--_badge-color, var(--hy-error-color, #ef5b72)) 12%, transparent); font: 650 var(--hy-badge-font-size, 11px)/1 system-ui, sans-serif; white-space: nowrap; }
26
+ .badge { display: inline-flex; min-width: var(--hy-badge-height, 20px); height: var(--hy-badge-height, 20px); align-items: center; justify-content: center; box-sizing: border-box; margin: 0; padding: 0 var(--hy-badge-padding, var(--hy-space-3, 6px)); border: var(--hy-badge-border-width, 2px) solid var(--hy-surface-color, #111722); border-radius: var(--hy-radius-full, 999px); color: var(--hy-badge-text-color, var(--hy-on-status-color, #fff)); background: var(--_badge-color, var(--hy-error-color, #ef5b72)); box-shadow: 0 0 0 1px color-mix(in srgb, var(--_badge-color, var(--hy-error-color, #ef5b72)) 12%, transparent); font: calc(var(--hy-font-weight-semibold, 600) + 50) var(--hy-badge-font-size, calc(var(--hy-font-size-xs, 10px) + 1px))/var(--hy-line-height-tight, 1) var(--hy-font-family, system-ui, sans-serif); white-space: nowrap; }
27
27
  .wrapper.has-content .badge { position: absolute; z-index: 1; inset-block-start: 0; inset-inline-end: 0; transform: translate(calc(50% + var(--_offset-x, 0px)), calc(-50% + var(--_offset-y, 0px))); transform-origin: 100% 0; }
28
28
  .badge.dot { min-width: var(--hy-badge-dot-size, 8px); width: var(--hy-badge-dot-size, 8px); height: var(--hy-badge-dot-size, 8px); padding: 0; border-width: var(--hy-badge-dot-border-width, 1px); }
29
29
  .badge[hidden], .status[hidden] { display: none; }
30
- .status { display: inline-flex; align-items: center; gap: var(--hy-badge-status-gap, 7px); color: var(--hy-secondary-text-color, #aebbd0); }
31
- .wrapper.has-content .status { margin-inline-start: 10px; }
30
+ .status { display: inline-flex; align-items: center; gap: var(--hy-badge-status-gap, calc(var(--hy-space-3, 6px) + 1px)); color: var(--hy-secondary-text-color, #aebbd0); }
31
+ .wrapper.has-content .status { margin-inline-start: var(--hy-space-5, 10px); }
32
32
  .status-dot { position: relative; width: var(--hy-badge-status-size, 8px); height: var(--hy-badge-status-size, 8px); flex: 0 0 auto; border-radius: 50%; background: var(--_badge-color, var(--hy-muted-color, #788697)); }
33
33
  .status.processing .status-dot::after { content: ''; position: absolute; inset: -3px; border: 1px solid var(--_badge-color, var(--hy-accent-color, #79a8ff)); border-radius: inherit; animation: hy-badge-pulse 1.5s ease-out infinite; }
34
- :host([size="small"]) .badge { --hy-badge-height: 16px; --hy-badge-padding: 4px; --hy-badge-font-size: 9px; }
34
+ :host([size="small"]) .badge { --hy-badge-height: 16px; --hy-badge-padding: var(--hy-space-2, 4px); --hy-badge-font-size: calc(var(--hy-font-size-xs, 10px) - 1px); }
35
35
  @keyframes hy-badge-pulse { 0% { opacity: .75; transform: scale(.55); } 100% { opacity: 0; transform: scale(1.35); } }
36
36
  @media (prefers-reduced-motion: reduce) { .status.processing .status-dot::after { animation: none; } }
37
37
  `;
@@ -1,10 +1,11 @@
1
+ import { finiteNumber as readFiniteNumber } from './internal/numbers.js';
1
2
  const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
2
3
  const DEFAULT_THICKNESS = 2;
3
4
  const DEFAULT_SPEED = 1;
4
5
  const DEFAULT_COUNT = 1;
5
6
  const BASE_DURATION_SECONDS = 6;
6
7
  function finiteNumber(value, fallback) {
7
- const number = Number(value);
8
+ const number = readFiniteNumber(value, fallback);
8
9
  return Number.isFinite(number) ? number : fallback;
9
10
  }
10
11
  /** Decorative animated border that follows the host's live rounded rectangle. */
@@ -26,7 +27,7 @@ export class HYBorderBeam extends HTMLElement {
26
27
  position: relative;
27
28
  display: block;
28
29
  min-width: 0;
29
- border-radius: var(--hy-border-beam-radius, 10px);
30
+ border-radius: var(--hy-border-beam-radius, calc(var(--hy-radius-lg, 8px) + 2px));
30
31
  isolation: isolate;
31
32
  --_beam-color: var(--hy-accent-color, #7dd3fc);
32
33
  }
@@ -19,7 +19,7 @@ export class HYBreadcrumb extends HTMLElement {
19
19
  display: block;
20
20
  min-width: 0;
21
21
  color: var(--hy-secondary-text-color, #aebbd0);
22
- font: 12px/1.4 system-ui, sans-serif;
22
+ font: var(--hy-font-size-sm, 12px)/var(--hy-line-height-snug, 1.4) var(--hy-font-family, system-ui, sans-serif);
23
23
  }
24
24
  nav { min-width: 0; }
25
25
  ol {
@@ -46,10 +46,10 @@ export class HYBreadcrumb extends HTMLElement {
46
46
  min-width: 0;
47
47
  max-width: var(--hy-breadcrumb-item-max-width, 240px);
48
48
  box-sizing: border-box;
49
- padding: var(--hy-breadcrumb-item-padding, 3px 5px);
49
+ padding: var(--hy-breadcrumb-item-padding, calc(var(--hy-space-1, 2px) + 1px) calc(var(--hy-space-2, 4px) + 1px));
50
50
  overflow: hidden;
51
51
  border: 0;
52
- border-radius: var(--hy-breadcrumb-radius, 4px);
52
+ border-radius: var(--hy-breadcrumb-radius, var(--hy-radius-sm, 4px));
53
53
  color: inherit;
54
54
  background: transparent;
55
55
  font: inherit;
@@ -68,7 +68,7 @@ export class HYBreadcrumb extends HTMLElement {
68
68
  }
69
69
  .current {
70
70
  color: var(--hy-text-color, #eef3ff);
71
- font-weight: 600;
71
+ font-weight: var(--hy-font-weight-semibold, 600);
72
72
  }
73
73
  .disabled { color: var(--hy-disabled-text-color, #657185); cursor: not-allowed; }
74
74
  .separator {
@@ -76,7 +76,7 @@ export class HYBreadcrumb extends HTMLElement {
76
76
  align-items: center;
77
77
  justify-content: center;
78
78
  min-width: 14px;
79
- padding: 0 var(--hy-breadcrumb-separator-gap, 3px);
79
+ padding: 0 var(--hy-breadcrumb-separator-gap, calc(var(--hy-space-1, 2px) + 1px));
80
80
  color: var(--hy-muted-color, #657185);
81
81
  user-select: none;
82
82
  }
@@ -18,21 +18,21 @@ export class HYButtonGroup extends HTMLElement {
18
18
  }
19
19
  :host(:not([orientation="vertical"])) ::slotted(hy-button:not(:first-child)) { margin-left: -1px; }
20
20
  :host(:not([orientation="vertical"])) ::slotted(hy-button:first-child) {
21
- --hy-button-radius-top-left: var(--hy-button-group-radius, 4px);
22
- --hy-button-radius-bottom-left: var(--hy-button-group-radius, 4px);
21
+ --hy-button-radius-top-left: var(--hy-button-group-radius, var(--hy-radius-sm, 4px));
22
+ --hy-button-radius-bottom-left: var(--hy-button-group-radius, var(--hy-radius-sm, 4px));
23
23
  }
24
24
  :host(:not([orientation="vertical"])) ::slotted(hy-button:last-child) {
25
- --hy-button-radius-top-right: var(--hy-button-group-radius, 4px);
26
- --hy-button-radius-bottom-right: var(--hy-button-group-radius, 4px);
25
+ --hy-button-radius-top-right: var(--hy-button-group-radius, var(--hy-radius-sm, 4px));
26
+ --hy-button-radius-bottom-right: var(--hy-button-group-radius, var(--hy-radius-sm, 4px));
27
27
  }
28
28
  :host([orientation="vertical"]) ::slotted(hy-button:not(:first-child)) { margin-top: -1px; }
29
29
  :host([orientation="vertical"]) ::slotted(hy-button:first-child) {
30
- --hy-button-radius-top-left: var(--hy-button-group-radius, 4px);
31
- --hy-button-radius-top-right: var(--hy-button-group-radius, 4px);
30
+ --hy-button-radius-top-left: var(--hy-button-group-radius, var(--hy-radius-sm, 4px));
31
+ --hy-button-radius-top-right: var(--hy-button-group-radius, var(--hy-radius-sm, 4px));
32
32
  }
33
33
  :host([orientation="vertical"]) ::slotted(hy-button:last-child) {
34
- --hy-button-radius-bottom-left: var(--hy-button-group-radius, 4px);
35
- --hy-button-radius-bottom-right: var(--hy-button-group-radius, 4px);
34
+ --hy-button-radius-bottom-left: var(--hy-button-group-radius, var(--hy-radius-sm, 4px));
35
+ --hy-button-radius-bottom-right: var(--hy-button-group-radius, var(--hy-radius-sm, 4px));
36
36
  }
37
37
  ::slotted(hy-button:hover), ::slotted(hy-button:focus-within) { z-index: 1; }
38
38
  `;
package/dist/button.js CHANGED
@@ -19,19 +19,19 @@ export class HYButton extends HTMLElement {
19
19
  display: inline-flex;
20
20
  align-items: center;
21
21
  justify-content: center;
22
- gap: var(--hy-button-icon-gap, 7px);
22
+ gap: var(--hy-button-icon-gap, calc(var(--hy-space-3, 6px) + 1px));
23
23
  width: 100%;
24
- min-height: 28px;
25
- padding: 0 10px;
24
+ min-height: var(--hy-control-height-sm, 28px);
25
+ padding: 0 var(--hy-space-5, 10px);
26
26
  border: 1px solid var(--hy-border-color, #3d4654);
27
27
  border-radius:
28
- var(--hy-button-radius-top-left, var(--hy-button-radius, 4px))
29
- var(--hy-button-radius-top-right, var(--hy-button-radius, 4px))
30
- var(--hy-button-radius-bottom-right, var(--hy-button-radius, 4px))
31
- var(--hy-button-radius-bottom-left, var(--hy-button-radius, 4px));
28
+ var(--hy-button-radius-top-left, var(--hy-button-radius, var(--hy-radius-sm, 4px)))
29
+ var(--hy-button-radius-top-right, var(--hy-button-radius, var(--hy-radius-sm, 4px)))
30
+ var(--hy-button-radius-bottom-right, var(--hy-button-radius, var(--hy-radius-sm, 4px)))
31
+ var(--hy-button-radius-bottom-left, var(--hy-button-radius, var(--hy-radius-sm, 4px)));
32
32
  background: var(--hy-surface-elevated-color, #202733);
33
33
  color: var(--hy-text-color, #eef3ff);
34
- font: 12px system-ui, sans-serif;
34
+ font: var(--hy-font-size-sm, 12px) var(--hy-font-family, system-ui, sans-serif);
35
35
  cursor: pointer;
36
36
  }
37
37
  button:hover:not(:disabled) {
@@ -43,11 +43,11 @@ export class HYButton extends HTMLElement {
43
43
  outline-offset: 1px;
44
44
  }
45
45
  button.icon-only {
46
- width: 28px;
46
+ width: var(--hy-control-height-sm, 28px);
47
47
  padding: 0;
48
48
  gap: 0;
49
49
  }
50
- .icon { display: inline-grid; flex: 0 0 auto; place-items: center; line-height: 1; }
50
+ .icon { display: inline-grid; flex: 0 0 auto; place-items: center; line-height: var(--hy-line-height-tight, 1); }
51
51
  button.icon-end .icon { order: 2; }
52
52
  .icon[hidden], .spinner[hidden] { display: none; }
53
53
  .spinner {
package/dist/card.d.ts ADDED
@@ -0,0 +1,29 @@
1
+ export type HYCardSize = 'small' | 'default';
2
+ /** Content surface with header, cover, body and footer slots. */
3
+ export declare class HYCard extends HTMLElement {
4
+ private readonly _surface;
5
+ private readonly _header;
6
+ private readonly _heading;
7
+ private readonly _title;
8
+ private readonly _extra;
9
+ private readonly _cover;
10
+ private readonly _body;
11
+ private readonly _loading;
12
+ private readonly _footer;
13
+ static get observedAttributes(): string[];
14
+ constructor();
15
+ connectedCallback(): void;
16
+ attributeChangedCallback(): void;
17
+ get heading(): string;
18
+ set heading(value: string);
19
+ get bordered(): boolean;
20
+ set bordered(value: boolean);
21
+ get hoverable(): boolean;
22
+ set hoverable(value: boolean);
23
+ get loading(): boolean;
24
+ set loading(value: boolean);
25
+ get size(): HYCardSize;
26
+ set size(value: HYCardSize);
27
+ private _render;
28
+ }
29
+ export declare function defineCardComponents(): void;
package/dist/card.js ADDED
@@ -0,0 +1,101 @@
1
+ import { hasSlotContent } from './internal/presentation.js';
2
+ /** Content surface with header, cover, body and footer slots. */
3
+ export class HYCard extends HTMLElement {
4
+ _surface = document.createElement('article');
5
+ _header = document.createElement('header');
6
+ _heading = document.createElement('slot');
7
+ _title = document.createElement('h3');
8
+ _extra = document.createElement('slot');
9
+ _cover = document.createElement('slot');
10
+ _body = document.createElement('div');
11
+ _loading = document.createElement('div');
12
+ _footer = document.createElement('slot');
13
+ static get observedAttributes() { return ['heading', 'bordered', 'hoverable', 'loading', 'size', 'aria-label']; }
14
+ constructor() {
15
+ super();
16
+ const root = this.attachShadow({ mode: 'open' });
17
+ const style = document.createElement('style');
18
+ style.textContent = `
19
+ :host { display: block; min-width: 0; color: var(--hy-text-color, #eef0ff); font: var(--hy-font-size-sm, 12px)/var(--hy-line-height-relaxed, 1.5) var(--hy-font-family, system-ui, sans-serif); }
20
+ .card { min-width: 0; box-sizing: border-box; overflow: hidden; border: 1px solid var(--hy-border-color, #343765); border-radius: var(--hy-card-radius, var(--hy-radius-lg, 8px)); background: var(--hy-card-bg-color, var(--hy-surface-elevated-color, #181a40)); transition: box-shadow 160ms ease, border-color 160ms ease; }
21
+ :host([bordered="false"]) .card { border-color: transparent; }
22
+ :host([hoverable]:hover) .card { border-color: var(--hy-hover-border-color, #777baf); box-shadow: 0 8px 24px var(--hy-shadow-color, #0003); }
23
+ header { display: flex; align-items: center; justify-content: space-between; gap: var(--hy-space-6, 12px); padding: var(--hy-card-header-padding, var(--hy-space-8, 16px) var(--hy-space-10, 20px)); border-bottom: 1px solid var(--hy-border-color, #343765); }
24
+ h3 { flex: 1; min-width: 0; margin: 0; overflow-wrap: anywhere; font-size: var(--hy-font-size-md, 14px); font-weight: var(--hy-font-weight-semibold, 600); }
25
+ .extra { flex: 0 0 auto; } .cover { display: block; } .cover::slotted(*) { display: block; max-width: 100%; } .cover::slotted(img) { width: 100%; object-fit: cover; }
26
+ .body, .loading { padding: var(--hy-card-body-padding, var(--hy-space-10, 20px)); overflow-wrap: anywhere; }
27
+ .footer { display: block; padding: var(--hy-space-6, 12px) var(--hy-space-10, 20px); border-top: 1px solid var(--hy-border-color, #343765); }
28
+ .loading span { display: block; height: 12px; margin-block: var(--hy-space-4, 8px); border-radius: var(--hy-radius-sm, 4px); background: var(--hy-hover-bg-color, #242752); } .loading span:first-child { width: 40%; } .loading span:last-child { width: 70%; }
29
+ :host([size="small"]) header, :host([size="small"]) .body, :host([size="small"]) .footer, :host([size="small"]) .loading { padding: var(--hy-space-6, 12px); }
30
+ [hidden] { display: none !important; } @media (prefers-reduced-motion: reduce) { .card { transition: none; } }
31
+ `;
32
+ this._surface.className = 'card';
33
+ this._surface.part.add('card');
34
+ this._header.part.add('header');
35
+ this._title.id = 'card-heading';
36
+ this._title.part.add('heading');
37
+ this._heading.name = 'heading';
38
+ this._title.append(this._heading);
39
+ this._extra.name = 'extra';
40
+ this._extra.className = 'extra';
41
+ this._extra.part.add('extra');
42
+ this._header.append(this._title, this._extra);
43
+ this._cover.name = 'cover';
44
+ this._cover.className = 'cover';
45
+ this._cover.part.add('cover');
46
+ this._body.className = 'body';
47
+ this._body.part.add('body');
48
+ this._body.append(document.createElement('slot'));
49
+ this._loading.className = 'loading';
50
+ this._loading.part.add('loading');
51
+ this._loading.setAttribute('aria-hidden', 'true');
52
+ this._loading.append(...Array.from({ length: 3 }, () => document.createElement('span')));
53
+ this._footer.name = 'footer';
54
+ this._footer.className = 'footer';
55
+ this._footer.part.add('footer');
56
+ this._surface.append(this._header, this._cover, this._body, this._loading, this._footer);
57
+ root.append(style, this._surface);
58
+ for (const slot of [this._heading, this._extra, this._cover, this._footer])
59
+ slot.addEventListener('slotchange', this._render);
60
+ }
61
+ connectedCallback() { this._render(); }
62
+ attributeChangedCallback() { this._render(); }
63
+ get heading() { return this.getAttribute('heading') ?? ''; }
64
+ set heading(value) { this.setAttribute('heading', value); }
65
+ get bordered() { return this.getAttribute('bordered') !== 'false'; }
66
+ set bordered(value) { this.setAttribute('bordered', String(value)); }
67
+ get hoverable() { return this.hasAttribute('hoverable'); }
68
+ set hoverable(value) { this.toggleAttribute('hoverable', Boolean(value)); }
69
+ get loading() { return this.hasAttribute('loading'); }
70
+ set loading(value) { this.toggleAttribute('loading', Boolean(value)); }
71
+ get size() { return this.getAttribute('size') === 'small' ? 'small' : 'default'; }
72
+ set size(value) { this.setAttribute('size', value); }
73
+ _render = () => {
74
+ if (this._heading.textContent !== this.heading)
75
+ this._heading.textContent = this.heading;
76
+ const heading = Boolean(this.heading) || hasSlotContent(this._heading);
77
+ this._title.hidden = !heading;
78
+ this._extra.hidden = !hasSlotContent(this._extra);
79
+ this._header.hidden = !heading && this._extra.hidden;
80
+ this._cover.hidden = !hasSlotContent(this._cover);
81
+ this._body.hidden = this.loading;
82
+ this._body.inert = this.loading;
83
+ this._loading.hidden = !this.loading;
84
+ this._footer.hidden = this.loading || !hasSlotContent(this._footer);
85
+ this._surface.setAttribute('aria-busy', String(this.loading));
86
+ if (heading)
87
+ this._surface.setAttribute('aria-labelledby', 'card-heading');
88
+ else
89
+ this._surface.removeAttribute('aria-labelledby');
90
+ const label = this.getAttribute('aria-label');
91
+ if (label) {
92
+ this._surface.setAttribute('aria-label', label);
93
+ this._surface.removeAttribute('aria-labelledby');
94
+ }
95
+ else
96
+ this._surface.removeAttribute('aria-label');
97
+ };
98
+ }
99
+ export function defineCardComponents() { if (!customElements.get('hy-card'))
100
+ customElements.define('hy-card', HYCard); }
101
+ //# sourceMappingURL=card.js.map
package/dist/carousel.js CHANGED
@@ -40,7 +40,7 @@ export class HYCarousel extends HTMLElement {
40
40
  style.textContent = `
41
41
  :host { display: block; position: relative; box-sizing: border-box; width: 100%; height: var(--hy-carousel-height, 240px); min-width: 0; min-height: 0; color: var(--hy-text-color, #eef0ff); font: inherit; }
42
42
  :host([hidden]), [hidden] { display: none !important; }
43
- .viewport { position: relative; width: 100%; height: 100%; overflow: hidden; border-radius: var(--hy-carousel-radius, 10px); background: var(--hy-carousel-bg-color, var(--hy-surface-color, #10132f)); touch-action: pan-y; }
43
+ .viewport { position: relative; width: 100%; height: 100%; overflow: hidden; border-radius: var(--hy-carousel-radius, calc(var(--hy-radius-lg, 8px) + 2px)); background: var(--hy-carousel-bg-color, var(--hy-surface-color, #10132f)); touch-action: pan-y; }
44
44
  :host([direction="vertical"]) .viewport { touch-action: pan-x; }
45
45
  :host([draggable="false"]) .viewport { touch-action: auto; }
46
46
  slot { display: contents; }
@@ -61,17 +61,17 @@ export class HYCarousel extends HTMLElement {
61
61
  :host(:not([direction="vertical"])[indicator-position="left"]) .arrow,
62
62
  :host(:not([direction="vertical"])[indicator-position="right"]) .arrow { top: auto; bottom: 12px; }
63
63
  :host([direction="vertical"]:not([indicator-position="left"]):not([indicator-position="right"])) .arrow { left: auto; right: auto; inset-inline-start: 12px; }
64
- .playback { top: 12px; inset-inline-end: 12px; font-size: 12px; }
65
- .indicators { position: absolute; z-index: 2; display: flex; align-items: center; max-width: calc(100% - 88px); overflow: auto; gap: var(--hy-carousel-indicator-gap, 4px); bottom: var(--hy-carousel-indicator-offset, 12px); left: 50%; transform: translateX(-50%); }
64
+ .playback { top: 12px; inset-inline-end: 12px; font-size: var(--hy-font-size-sm, 12px); }
65
+ .indicators { position: absolute; z-index: 2; display: flex; align-items: center; max-width: calc(100% - 88px); overflow: auto; gap: var(--hy-carousel-indicator-gap, var(--hy-space-2, 4px)); bottom: var(--hy-carousel-indicator-offset, 12px); left: 50%; transform: translateX(-50%); }
66
66
  :host([indicator-position="top"]) .indicators { top: var(--hy-carousel-indicator-offset, 12px); bottom: auto; }
67
67
  :host([indicator-position="left"]) .indicators, :host([indicator-position="right"]) .indicators { flex-direction: column; max-height: calc(100% - 88px); top: 50%; bottom: auto; transform: translateY(-50%); }
68
68
  :host([indicator-position="left"]) .indicators { left: var(--hy-carousel-indicator-offset, 12px); }
69
69
  :host([indicator-position="right"]) .indicators { left: auto; right: var(--hy-carousel-indicator-offset, 12px); }
70
- .indicator { display: grid; flex: 0 0 auto; place-items: center; min-width: 24px; min-height: 24px; padding: 4px; background: transparent; border-radius: 4px; }
70
+ .indicator { display: grid; flex: 0 0 auto; place-items: center; min-width: 24px; min-height: 24px; padding: var(--hy-space-2, 4px); background: transparent; border-radius: var(--hy-radius-sm, 4px); }
71
71
  .indicator-content { display: grid; place-items: center; width: var(--hy-carousel-indicator-size, 8px); height: var(--hy-carousel-indicator-size, 8px); border-radius: var(--hy-carousel-indicator-radius, 50%); background: var(--hy-carousel-indicator-color, var(--hy-muted-color, #747ba8)); }
72
72
  .indicator[aria-current="true"] .indicator-content { background: var(--hy-carousel-indicator-active-color, var(--hy-accent-color, #8177f2)); }
73
- :host([indicator-style="line"]) .indicator-content { width: var(--hy-carousel-indicator-width, 24px); height: var(--hy-carousel-indicator-thickness, 3px); border-radius: var(--hy-carousel-indicator-radius, 2px); }
74
- :host([indicator-style="number"]) .indicator-content { width: 24px; height: 24px; font-size: 12px; color: var(--hy-carousel-indicator-text-color, var(--hy-text-color, #eef0ff)); }
73
+ :host([indicator-style="line"]) .indicator-content { width: var(--hy-carousel-indicator-width, 24px); height: var(--hy-carousel-indicator-thickness, 3px); border-radius: var(--hy-carousel-indicator-radius, var(--hy-radius-xs, 2px)); }
74
+ :host([indicator-style="number"]) .indicator-content { width: 24px; height: 24px; font-size: var(--hy-font-size-sm, 12px); color: var(--hy-carousel-indicator-text-color, var(--hy-text-color, #eef0ff)); }
75
75
  .indicators.custom .indicator-content { width: auto; height: auto; background: transparent; }
76
76
  `;
77
77
  this._viewport.className = 'viewport';
package/dist/cascader.js CHANGED
@@ -47,16 +47,16 @@ export class HYCascader extends HTMLElement {
47
47
  display: inline-block;
48
48
  min-width: 180px;
49
49
  color: var(--hy-text-color, #eef3ff);
50
- font: 12px/1.4 system-ui, sans-serif;
50
+ font: var(--hy-font-size-sm, 12px)/var(--hy-line-height-snug, 1.4) var(--hy-font-family, system-ui, sans-serif);
51
51
  }
52
52
  .control {
53
53
  display: grid;
54
54
  grid-template-columns: minmax(0, 1fr) auto;
55
55
  min-width: 0;
56
- height: var(--hy-cascader-height, 34px);
56
+ height: var(--hy-cascader-height, var(--hy-control-height-md, 34px));
57
57
  box-sizing: border-box;
58
58
  border: 1px solid var(--hy-border-color, #3d4654);
59
- border-radius: var(--hy-cascader-radius, 6px);
59
+ border-radius: var(--hy-cascader-radius, var(--hy-radius-md, 6px));
60
60
  background: var(--hy-input-bg-color, #111722);
61
61
  }
62
62
  :host(:not([disabled])) .control:hover { border-color: var(--hy-hover-border-color, #596779); }
@@ -68,8 +68,8 @@ export class HYCascader extends HTMLElement {
68
68
  display: flex;
69
69
  align-items: center;
70
70
  min-width: 0;
71
- gap: 8px;
72
- padding: 0 8px 0 10px;
71
+ gap: var(--hy-space-4, 8px);
72
+ padding: 0 var(--hy-space-4, 8px) 0 var(--hy-space-5, 10px);
73
73
  overflow: hidden;
74
74
  border: 0;
75
75
  color: inherit;
@@ -89,7 +89,7 @@ export class HYCascader extends HTMLElement {
89
89
  color: var(--hy-muted-color, #788697);
90
90
  background: transparent;
91
91
  cursor: pointer;
92
- font: 15px/1 system-ui, sans-serif;
92
+ font: calc(var(--hy-font-size-md, 14px) + 1px)/var(--hy-line-height-tight, 1) var(--hy-font-family, system-ui, sans-serif);
93
93
  }
94
94
  .clear:hover { color: var(--hy-text-color, #eef3ff); }
95
95
  .clear[hidden] { display: none; }
@@ -105,7 +105,7 @@ export class HYCascader extends HTMLElement {
105
105
  max-width: min(720px, 90vw);
106
106
  overflow: auto;
107
107
  border: 1px solid var(--hy-border-color, #3d4654);
108
- border-radius: var(--hy-cascader-panel-radius, 7px);
108
+ border-radius: var(--hy-cascader-panel-radius, calc(var(--hy-radius-md, 6px) + 1px));
109
109
  background: var(--hy-menu-bg-color, var(--hy-surface-elevated-color, #171d27));
110
110
  box-shadow: 0 12px 32px var(--hy-menu-shadow-color, rgba(0, 0, 0, 0.36));
111
111
  }
@@ -116,7 +116,7 @@ export class HYCascader extends HTMLElement {
116
116
  max-height: var(--hy-cascader-panel-height, 260px);
117
117
  box-sizing: border-box;
118
118
  margin: 0;
119
- padding: 5px;
119
+ padding: calc(var(--hy-space-2, 4px) + 1px);
120
120
  overflow-y: auto;
121
121
  list-style: none;
122
122
  scrollbar-color: var(--hy-border-strong-color, #596779) transparent;
@@ -128,11 +128,11 @@ export class HYCascader extends HTMLElement {
128
128
  width: 100%;
129
129
  min-height: 32px;
130
130
  align-items: center;
131
- gap: 8px;
132
- padding: 6px 8px;
131
+ gap: var(--hy-space-4, 8px);
132
+ padding: var(--hy-space-3, 6px) var(--hy-space-4, 8px);
133
133
  overflow: hidden;
134
134
  border: 0;
135
- border-radius: 4px;
135
+ border-radius: var(--hy-radius-sm, 4px);
136
136
  color: var(--hy-secondary-text-color, #aebbd0);
137
137
  background: transparent;
138
138
  cursor: pointer;
@@ -148,7 +148,7 @@ export class HYCascader extends HTMLElement {
148
148
  }
149
149
  .option[aria-selected="true"] { color: var(--hy-accent-color, #79a8ff); }
150
150
  .option:disabled { cursor: not-allowed; opacity: 0.46; }
151
- .empty { min-width: 184px; padding: 28px 18px; color: var(--hy-muted-color, #788697); text-align: center; }
151
+ .empty { min-width: 184px; padding: calc(var(--hy-space-12, 24px) + 4px) calc(var(--hy-space-8, 16px) + 2px); color: var(--hy-muted-color, #788697); text-align: center; }
152
152
  `;
153
153
  this._control.className = 'control';
154
154
  this._control.part.add('control');
@@ -314,6 +314,10 @@ export class HYCascader extends HTMLElement {
314
314
  return resolved;
315
315
  }
316
316
  _render() {
317
+ if (this.disabled && this.open) {
318
+ this.open = false;
319
+ return;
320
+ }
317
321
  const selected = this._resolveOptions(this._value);
318
322
  const text = selected.map(option => option.label).join(this.displaySeparator);
319
323
  this._label.textContent = text || this.placeholder;
@@ -392,7 +396,7 @@ export class HYCascader extends HTMLElement {
392
396
  return row;
393
397
  }
394
398
  _activateOption(option, depth, focusNext = false) {
395
- if (option.disabled)
399
+ if (this.disabled || option.disabled)
396
400
  return;
397
401
  const next = [...this._activePath.slice(0, depth), option.value];
398
402
  this._activePath = next;
@@ -408,6 +412,8 @@ export class HYCascader extends HTMLElement {
408
412
  this._commit(next, true);
409
413
  }
410
414
  _commit(value, close) {
415
+ if (this.disabled)
416
+ return;
411
417
  this._value = this._normalizePath(value);
412
418
  this._activePath = [...this._value];
413
419
  this._reflectValue();