@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,102 @@
1
+ export class HYProgress extends HTMLElement {
2
+ _meter = document.createElement('div');
3
+ _line = document.createElement('div');
4
+ _fill = document.createElement('div');
5
+ _svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
6
+ _circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle');
7
+ _info = document.createElement('span');
8
+ static get observedAttributes() { return ['percent', 'type', 'status', 'indeterminate', 'show-info', 'stroke-width', '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 { display: block; min-width: 0; color: var(--hy-text-color, #d8e2f2); font: var(--hy-font-size-sm, 12px)/1.5 var(--hy-font-family, system-ui, sans-serif); }
15
+ .meter { --_color: var(--hy-progress-color, var(--hy-accent-color, #8177f2)); display: flex; align-items: center; gap: var(--hy-space-4, 8px); }
16
+ .meter.success { --_color: var(--hy-success-color, #3ea67a); } .meter.exception { --_color: var(--hy-error-color, #d95d72); }
17
+ .line { flex: 1; overflow: hidden; height: var(--_stroke, 6px); border-radius: 999px; background: var(--hy-progress-trail-color, var(--hy-border-color, #303746)); }
18
+ .fill { height: 100%; border-radius: inherit; background: var(--_color); transition: width 150ms ease; }
19
+ .active .fill { background-image: linear-gradient(90deg, transparent, color-mix(in srgb, var(--hy-selected-text-color, #fff) 35%, transparent), transparent); background-size: 200% 100%; animation: hy-progress-active 1.5s linear infinite; }
20
+ .indeterminate .fill { width: 35% !important; animation: hy-progress-unknown 1.3s ease-in-out infinite; }
21
+ svg { display: block; width: var(--_size, 96px); height: var(--_size, 96px); transform: rotate(-90deg); }
22
+ circle { fill: none; stroke-width: var(--_circle-stroke, 6); } .trail { stroke: var(--hy-progress-trail-color, var(--hy-border-color, #303746)); }
23
+ .arc { stroke: var(--_color); stroke-linecap: round; transition: stroke-dashoffset 150ms ease; }
24
+ .circle { position: relative; display: inline-grid; place-items: center; } .circle .info { position: absolute; max-width: 80%; text-align: center; }
25
+ .circle.indeterminate svg { animation: hy-progress-rotate 1s linear infinite; }
26
+ [hidden] { display: none !important; } .info { flex: 0 0 auto; }
27
+ @keyframes hy-progress-active { to { background-position: -200% 0; } }
28
+ @keyframes hy-progress-unknown { from { transform: translateX(-100%); } to { transform: translateX(385%); } }
29
+ @keyframes hy-progress-rotate { to { transform: rotate(270deg); } }
30
+ @media (prefers-reduced-motion: reduce) { .fill, .arc { transition: none; } .active .fill, .indeterminate .fill, .circle.indeterminate svg { animation: none; } }
31
+ `;
32
+ this._meter.className = 'meter';
33
+ this._meter.part.add('meter');
34
+ this._meter.setAttribute('role', 'progressbar');
35
+ this._line.className = 'line';
36
+ this._line.part.add('trail');
37
+ this._fill.className = 'fill';
38
+ this._fill.part.add('fill');
39
+ this._line.append(this._fill);
40
+ this._svg.setAttribute('viewBox', '0 0 100 100');
41
+ this._svg.setAttribute('aria-hidden', 'true');
42
+ this._svg.part.add('circle');
43
+ const trail = this._circle.cloneNode();
44
+ for (const circle of [trail, this._circle]) {
45
+ circle.setAttribute('cx', '50');
46
+ circle.setAttribute('cy', '50');
47
+ circle.setAttribute('r', '44');
48
+ circle.setAttribute('pathLength', '100');
49
+ }
50
+ trail.classList.add('trail');
51
+ this._circle.classList.add('arc');
52
+ this._circle.setAttribute('stroke-dasharray', '100');
53
+ this._svg.append(trail, this._circle);
54
+ this._info.className = 'info';
55
+ this._info.part.add('info');
56
+ this._meter.append(this._line, this._svg, this._info);
57
+ root.append(style, this._meter);
58
+ }
59
+ connectedCallback() { this._sync(); }
60
+ attributeChangedCallback() { this._sync(); }
61
+ get percent() { return boundedNumber(this.getAttribute('percent'), 0, 100, 0); }
62
+ set percent(value) { this.setAttribute('percent', String(value)); }
63
+ get type() { return this.getAttribute('type') === 'circle' ? 'circle' : 'line'; }
64
+ set type(value) { this.setAttribute('type', value); }
65
+ get status() { const value = this.getAttribute('status'); return value === 'active' || value === 'success' || value === 'exception' ? value : 'normal'; }
66
+ set status(value) { this.setAttribute('status', value); }
67
+ get indeterminate() { return this.hasAttribute('indeterminate'); }
68
+ set indeterminate(value) { this.toggleAttribute('indeterminate', value); }
69
+ get showInfo() { return this.getAttribute('show-info') !== 'false'; }
70
+ set showInfo(value) { this.setAttribute('show-info', String(value)); }
71
+ get strokeWidth() { return boundedNumber(this.getAttribute('stroke-width'), 1, 20, 6); }
72
+ set strokeWidth(value) { this.setAttribute('stroke-width', String(value)); }
73
+ get size() { return boundedNumber(this.getAttribute('size'), 24, 1000, 96); }
74
+ set size(value) { this.setAttribute('size', String(value)); }
75
+ _sync() {
76
+ const circle = this.type === 'circle';
77
+ this._meter.className = `meter ${this.status}${circle ? ' circle' : ''}${this.indeterminate ? ' indeterminate' : ''}`;
78
+ this._meter.setAttribute('aria-valuemin', '0');
79
+ this._meter.setAttribute('aria-valuemax', '100');
80
+ if (this.indeterminate)
81
+ this._meter.removeAttribute('aria-valuenow');
82
+ else
83
+ this._meter.setAttribute('aria-valuenow', String(this.percent));
84
+ this._meter.setAttribute('aria-label', this.getAttribute('aria-label') || 'Progress');
85
+ this._meter.setAttribute('aria-valuetext', this.indeterminate ? 'In progress' : `${this.percent}%${this.status === 'exception' ? ' Failed' : this.status === 'success' ? ' Complete' : ''}`);
86
+ this._meter.style.setProperty('--_stroke', `${this.strokeWidth}px`);
87
+ this._meter.style.setProperty('--_circle-stroke', String(this.strokeWidth));
88
+ this._meter.style.setProperty('--_size', `${this.size}px`);
89
+ this._line.hidden = circle;
90
+ this._svg.style.display = circle ? '' : 'none';
91
+ this._fill.style.width = `${this.percent}%`;
92
+ this._circle.setAttribute('r', String(50 - this.strokeWidth / 2 - 1));
93
+ this._svg.querySelector('.trail')?.setAttribute('r', String(50 - this.strokeWidth / 2 - 1));
94
+ this._circle.setAttribute('stroke-dashoffset', String(this.indeterminate ? 65 : 100 - this.percent));
95
+ this._info.hidden = !this.showInfo;
96
+ this._info.textContent = this.indeterminate ? '…' : `${this.percent}%`;
97
+ }
98
+ }
99
+ function boundedNumber(raw, min, max, fallback) { const value = raw === null ? NaN : Number(raw); return Number.isFinite(value) ? Math.min(max, Math.max(min, value)) : fallback; }
100
+ export function defineProgressComponents() { if (!customElements.get('hy-progress'))
101
+ customElements.define('hy-progress', HYProgress); }
102
+ //# sourceMappingURL=progress.js.map
package/dist/qr-code.js CHANGED
@@ -31,15 +31,15 @@ export class HYQRCode extends HTMLElement {
31
31
  const root = this.attachShadow({ mode: 'open' });
32
32
  const style = document.createElement('style');
33
33
  style.textContent = `
34
- :host { display: inline-block; max-width: 100%; vertical-align: middle; color: var(--hy-text-color, #eef0ff); font: 12px/1.5 system-ui, sans-serif; }
34
+ :host { display: inline-block; max-width: 100%; vertical-align: middle; 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); }
35
35
  :host([hidden]), [hidden] { display: none !important; }
36
36
  .frame { position: relative; box-sizing: border-box; max-width: 100%; aspect-ratio: 1; }
37
37
  svg { display: block; width: 100%; height: 100%; }
38
- .icon { position: absolute; box-sizing: border-box; inset: 50% auto auto 50%; transform: translate(-50%, -50%); display: grid; place-items: center; background: var(--_qr-background); border-radius: var(--hy-qr-code-icon-radius, 4px); pointer-events: none; overflow: hidden; }
38
+ .icon { position: absolute; box-sizing: border-box; inset: 50% auto auto 50%; transform: translate(-50%, -50%); display: grid; place-items: center; background: var(--_qr-background); border-radius: var(--hy-qr-code-icon-radius, var(--hy-radius-sm, 4px)); pointer-events: none; overflow: hidden; }
39
39
  img { display: block; width: 100%; height: 100%; min-width: 0; min-height: 0; object-fit: contain; }
40
40
  slot { display: contents; }
41
41
  ::slotted([slot="icon"]) { display: block; box-sizing: border-box; width: 100%; height: 100%; min-width: 0; min-height: 0; object-fit: contain; overflow: hidden; }
42
- .message { position: absolute; inset: 0; display: grid; place-items: center; box-sizing: border-box; padding: 12px; text-align: center; color: var(--hy-secondary-text-color, #a9add4); background: var(--hy-surface-color, #10132f); border: 1px solid var(--hy-border-color, #343765); border-radius: var(--hy-qr-code-radius, 8px); }
42
+ .message { position: absolute; inset: 0; display: grid; place-items: center; box-sizing: border-box; padding: var(--hy-space-6, 12px); text-align: center; color: var(--hy-secondary-text-color, #a9add4); background: var(--hy-surface-color, #10132f); border: 1px solid var(--hy-border-color, #343765); border-radius: var(--hy-qr-code-radius, var(--hy-radius-lg, 8px)); }
43
43
  `;
44
44
  this._frame.className = 'frame';
45
45
  this._frame.part.add('frame');
package/dist/radio.d.ts CHANGED
@@ -4,10 +4,12 @@ export interface HYRadioChangeDetail {
4
4
  name: string;
5
5
  }
6
6
  export declare class HYRadio extends HTMLElement {
7
+ static readonly formAssociated = true;
7
8
  private readonly _input;
8
9
  private readonly _marker;
9
10
  private readonly _label;
10
11
  private readonly _slot;
12
+ private readonly _formControl;
11
13
  static get observedAttributes(): string[];
12
14
  constructor();
13
15
  connectedCallback(): void;
@@ -24,6 +26,14 @@ export declare class HYRadio extends HTMLElement {
24
26
  get name(): string;
25
27
  set name(value: string);
26
28
  private _sync;
29
+ get form(): HTMLFormElement | null;
30
+ checkValidity(): boolean;
31
+ reportValidity(): boolean;
32
+ setCustomValidity(message: string): void;
33
+ formDisabledCallback(disabled: boolean): void;
34
+ formResetCallback(): void;
35
+ formStateRestoreCallback(state: string | File | FormData | null): void;
36
+ focus(options?: FocusOptions): void;
27
37
  private _onChange;
28
38
  private _uncheckNamedPeers;
29
39
  }
package/dist/radio.js CHANGED
@@ -1,8 +1,11 @@
1
+ import { HYFormControl } from './internal/form-control.js';
1
2
  export class HYRadio extends HTMLElement {
3
+ static formAssociated = true;
2
4
  _input = document.createElement('input');
3
5
  _marker = 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
10
  return ['checked', 'disabled', 'label', 'value', 'name', 'aria-label'];
8
11
  }
@@ -16,7 +19,7 @@ export class HYRadio extends HTMLElement {
16
19
  width: max-content;
17
20
  min-width: 0;
18
21
  color: var(--hy-radio-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 HYRadio 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;
@@ -96,6 +99,7 @@ export class HYRadio extends HTMLElement {
96
99
  connectedCallback() {
97
100
  this._input.addEventListener('change', this._onChange);
98
101
  this._sync();
102
+ this._formControl.connect();
99
103
  if (this.checked)
100
104
  this._uncheckNamedPeers();
101
105
  }
@@ -152,7 +156,7 @@ export class HYRadio extends HTMLElement {
152
156
  }
153
157
  _sync() {
154
158
  this._input.checked = this.checked;
155
- this._input.disabled = this.disabled;
159
+ this._input.disabled = this.disabled || this._formControl.disabled;
156
160
  this._input.value = this.value;
157
161
  this._input.name = this.name;
158
162
  const label = this.getAttribute('label');
@@ -165,7 +169,16 @@ export class HYRadio extends HTMLElement {
165
169
  this._input.setAttribute('aria-label', ariaLabel);
166
170
  else
167
171
  this._input.removeAttribute('aria-label');
168
- }
172
+ this._formControl.sync();
173
+ }
174
+ get form() { return this._formControl.internals.form; }
175
+ checkValidity() { return this._formControl.internals.checkValidity(); }
176
+ reportValidity() { return this._formControl.internals.reportValidity(); }
177
+ setCustomValidity(message) { this._formControl.setCustomValidity(message); }
178
+ formDisabledCallback(disabled) { this._formControl.disabled = disabled; this._sync(); }
179
+ formResetCallback() { this._formControl.reset(); }
180
+ formStateRestoreCallback(state) { this._formControl.restore(state); }
181
+ focus(options) { this._input.focus(options); }
169
182
  _onChange = () => {
170
183
  if (!this._input.checked)
171
184
  return;
@@ -186,7 +199,7 @@ export class HYRadio extends HTMLElement {
186
199
  ? root.querySelectorAll(`hy-radio[name="${cssEscape(this.name)}"]`)
187
200
  : [];
188
201
  for (const peer of peers) {
189
- if (peer === this || peer.disabled)
202
+ if (peer === this || peer.disabled || peer.form !== this.form)
190
203
  continue;
191
204
  peer.removeAttribute('checked');
192
205
  }
package/dist/range.js CHANGED
@@ -30,7 +30,7 @@ export class HYRange extends HTMLElement {
30
30
  width: var(--hy-range-width, 280px);
31
31
  min-width: 120px;
32
32
  color: var(--hy-text-color, #e8effa);
33
- font: 11px/1.3 system-ui, sans-serif;
33
+ font: calc(var(--hy-font-size-xs, 10px) + 1px)/calc(var(--hy-line-height-snug, 1.4) - 0.1) var(--hy-font-family, system-ui, sans-serif);
34
34
  --_handle-size: var(--hy-range-handle-size, 18px);
35
35
  --_rail-height: var(--hy-range-rail-height, 5px);
36
36
  }
@@ -49,7 +49,7 @@ export class HYRange extends HTMLElement {
49
49
  right: 0;
50
50
  left: 0;
51
51
  height: var(--_rail-height);
52
- border-radius: var(--hy-range-rail-radius, 999px);
52
+ border-radius: var(--hy-range-rail-radius, var(--hy-radius-full, 999px));
53
53
  transform: translateY(-50%);
54
54
  }
55
55
  .rail {
@@ -76,7 +76,7 @@ export class HYRange extends HTMLElement {
76
76
  outline: none;
77
77
  color: var(--hy-text-color, #e8effa);
78
78
  background: var(--hy-range-handle-color, var(--hy-surface-elevated-color, #171e2a));
79
- box-shadow: var(--hy-range-handle-shadow, 0 2px 8px rgba(0, 0, 0, 0.28));
79
+ box-shadow: var(--hy-range-handle-shadow, 0 2px 8px var(--hy-shadow-color, rgba(0, 0, 0, 0.28)));
80
80
  cursor: grab;
81
81
  transform: translate(-50%, -50%);
82
82
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
@@ -97,14 +97,14 @@ export class HYRange extends HTMLElement {
97
97
  bottom: calc(100% + 8px);
98
98
  display: none;
99
99
  min-width: 24px;
100
- padding: 3px 6px;
100
+ padding: calc(var(--hy-space-1, 2px) + 1px) var(--hy-space-3, 6px);
101
101
  border: 1px solid var(--hy-border-color, #303746);
102
- border-radius: 4px;
102
+ border-radius: var(--hy-radius-sm, 4px);
103
103
  pointer-events: none;
104
104
  color: var(--hy-text-color, #e8effa);
105
105
  background: var(--hy-surface-elevated-color, #171e2a);
106
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
107
- font: 10px/1.2 ui-monospace, monospace;
106
+ box-shadow: 0 4px 12px var(--hy-shadow-color, rgba(0, 0, 0, 0.22));
107
+ font: var(--hy-font-size-xs, 10px)/var(--hy-line-height-compact, 1.2) var(--hy-font-family-mono, ui-monospace, monospace);
108
108
  white-space: nowrap;
109
109
  }
110
110
  :host([show-value]) .bubble { display: block; }
package/dist/rate.js CHANGED
@@ -19,10 +19,10 @@ export class HYRate extends HTMLElement {
19
19
  const root = this.attachShadow({ mode: 'open' });
20
20
  const style = document.createElement('style');
21
21
  style.textContent = `
22
- :host { display: inline-block; color: var(--hy-text-color, #eef3ff); font: 12px/1 system-ui, sans-serif; }
23
- .group { display: inline-flex; align-items: center; gap: var(--hy-rate-gap, 5px); border-radius: var(--hy-rate-focus-radius, 5px); }
22
+ :host { display: inline-block; color: var(--hy-text-color, #eef3ff); font: var(--hy-font-size-sm, 12px)/var(--hy-line-height-tight, 1) var(--hy-font-family, system-ui, sans-serif); }
23
+ .group { display: inline-flex; align-items: center; gap: var(--hy-rate-gap, calc(var(--hy-space-2, 4px) + 1px)); border-radius: var(--hy-rate-focus-radius, calc(var(--hy-radius-sm, 4px) + 1px)); }
24
24
  .group:focus-visible { outline: 2px solid var(--hy-focus-border-color, #79a8ff); outline-offset: 3px; }
25
- .star { position: relative; width: 1em; height: 1em; padding: 0; overflow: hidden; border: 0; color: inherit; background: transparent; cursor: pointer; font: var(--hy-rate-font-size, 25px)/1 system-ui, sans-serif; transition: transform 120ms ease; }
25
+ .star { position: relative; width: 1em; height: 1em; padding: 0; overflow: hidden; border: 0; color: inherit; background: transparent; cursor: pointer; font: var(--hy-rate-font-size, calc(var(--hy-font-size-2xl, 24px) + 1px))/var(--hy-line-height-tight, 1) var(--hy-font-family, system-ui, sans-serif); transition: transform 120ms ease; }
26
26
  .star:hover { transform: scale(1.12); }
27
27
  .empty, .fill-inner { display: block; width: 1em; height: 1em; }
28
28
  .empty { color: var(--hy-rate-empty-color, color-mix(in srgb, var(--hy-text-color, #eef3ff) 16%, transparent)); }
package/dist/resizable.js CHANGED
@@ -65,12 +65,12 @@ export class HYResizable extends HTMLElement {
65
65
  z-index: 2;
66
66
  inset: 0;
67
67
  border: var(--hy-resizable-border-width, 1px) var(--hy-resizable-border-style, solid) var(--hy-resizable-border-color, var(--hy-accent-color, #79a8ff));
68
- border-radius: var(--hy-resizable-radius, 5px);
68
+ border-radius: var(--hy-resizable-radius, calc(var(--hy-radius-sm, 4px) + 1px));
69
69
  pointer-events: none;
70
70
  content: '';
71
71
  }
72
72
  .frame:focus-visible { outline: 2px solid var(--hy-focus-border-color, #79a8ff); outline-offset: 3px; }
73
- .content { width: 100%; height: 100%; overflow: var(--hy-resizable-content-overflow, hidden); border-radius: var(--hy-resizable-radius, 5px); }
73
+ .content { width: 100%; height: 100%; overflow: var(--hy-resizable-content-overflow, hidden); border-radius: var(--hy-resizable-radius, calc(var(--hy-radius-sm, 4px) + 1px)); }
74
74
  :host(:not([disabled])) .content { cursor: var(--hy-resizable-move-cursor, move); }
75
75
  :host([movable="false"]) .content, :host([disabled]) .content { cursor: default; }
76
76
  .handle { position: absolute; z-index: 3; box-sizing: border-box; touch-action: none; outline: none; }
@@ -97,9 +97,9 @@ export class HYResizable extends HTMLElement {
97
97
  height: var(--hy-resizable-corner-size, 10px);
98
98
  box-sizing: border-box;
99
99
  border: 1px solid var(--hy-resizable-handle-border-color, #dbeeff);
100
- border-radius: var(--hy-resizable-handle-radius, 2px);
100
+ border-radius: var(--hy-resizable-handle-radius, var(--hy-radius-xs, 2px));
101
101
  background: var(--hy-resizable-handle-color, var(--hy-accent-color, #79a8ff));
102
- box-shadow: 0 1px 4px rgba(0, 0, 0, 0.28);
102
+ box-shadow: 0 1px 4px var(--hy-shadow-color, rgba(0, 0, 0, 0.28));
103
103
  content: '';
104
104
  }
105
105
  .handle.n::after, .handle.s::after { left: 50%; top: 50%; translate: -50% -50%; }
@@ -0,0 +1,22 @@
1
+ export type HYResultStatus = 'success' | 'info' | 'warning' | 'error' | '403' | '404' | '500';
2
+ /** Outcome page with semantic status, details and custom actions. */
3
+ export declare class HYResult extends HTMLElement {
4
+ private readonly _surface;
5
+ private readonly _icon;
6
+ private readonly _heading;
7
+ private readonly _description;
8
+ private readonly _content;
9
+ private readonly _extra;
10
+ static get observedAttributes(): string[];
11
+ constructor();
12
+ connectedCallback(): void;
13
+ attributeChangedCallback(): void;
14
+ get status(): HYResultStatus;
15
+ set status(value: HYResultStatus);
16
+ get heading(): string;
17
+ set heading(value: string);
18
+ get description(): string;
19
+ set description(value: string);
20
+ private _render;
21
+ }
22
+ export declare function defineResultComponents(): void;
package/dist/result.js ADDED
@@ -0,0 +1,88 @@
1
+ import { hasSlotContent, presentationIcon } from './internal/presentation.js';
2
+ const headings = { success: 'Completed', info: 'Information', warning: 'Please check', error: 'Something went wrong', '403': '403', '404': '404', '500': '500' };
3
+ /** Outcome page with semantic status, details and custom actions. */
4
+ export class HYResult extends HTMLElement {
5
+ _surface = document.createElement('section');
6
+ _icon = document.createElement('slot');
7
+ _heading = document.createElement('slot');
8
+ _description = document.createElement('slot');
9
+ _content = document.createElement('slot');
10
+ _extra = document.createElement('slot');
11
+ static get observedAttributes() { return ['status', 'heading', 'description', 'aria-label']; }
12
+ constructor() {
13
+ super();
14
+ const root = this.attachShadow({ mode: 'open' });
15
+ const style = document.createElement('style');
16
+ style.textContent = `
17
+ :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); }
18
+ .result { display: flex; align-items: center; flex-direction: column; gap: var(--hy-space-6, 12px); padding: var(--hy-result-padding, var(--hy-space-16, 32px) var(--hy-space-10, 20px)); text-align: center; overflow-wrap: anywhere; }
19
+ .icon { display: block; width: var(--hy-result-icon-size, 64px); max-width: 100%; color: var(--hy-result-status-color, var(--hy-info-color, #55b4da)); }
20
+ .icon svg, .icon::slotted(*) { display: block; width: 100%; height: auto; }
21
+ .icon.code { width: auto; font-size: var(--hy-result-code-size, 64px); font-weight: var(--hy-font-weight-bold, 700); line-height: var(--hy-line-height-compact, 1.2); }
22
+ .success { --hy-result-status-color: var(--hy-success-color, #51b88b); } .warning { --hy-result-status-color: var(--hy-warning-color, #e1b952); } .error { --hy-result-status-color: var(--hy-error-color, #e47689); }
23
+ h2 { max-width: 100%; margin: 0; font-size: var(--hy-font-size-2xl, 24px); font-weight: var(--hy-font-weight-semibold, 600); }
24
+ .description { display: block; max-width: 64ch; color: var(--hy-secondary-text-color, #a9add4); }
25
+ .content { display: block; width: 100%; box-sizing: border-box; padding: var(--hy-space-8, 16px); border-radius: var(--hy-radius-md, 6px); color: var(--hy-secondary-text-color, #a9add4); background: var(--hy-surface-color, #10132f); text-align: start; }
26
+ .extra { display: flex; justify-content: center; flex-wrap: wrap; gap: var(--hy-space-4, 8px); max-width: 100%; }
27
+ [hidden] { display: none !important; }
28
+ `;
29
+ this._surface.className = 'result';
30
+ this._surface.part.add('result');
31
+ this._surface.setAttribute('aria-labelledby', 'result-heading');
32
+ this._icon.name = 'icon';
33
+ this._icon.className = 'icon';
34
+ this._icon.part.add('icon');
35
+ this._icon.setAttribute('aria-hidden', 'true');
36
+ const heading = document.createElement('h2');
37
+ heading.id = 'result-heading';
38
+ heading.part.add('heading');
39
+ this._heading.name = 'heading';
40
+ heading.append(this._heading);
41
+ this._description.name = 'description';
42
+ this._description.className = 'description';
43
+ this._description.part.add('description');
44
+ this._content.className = 'content';
45
+ this._content.part.add('content');
46
+ this._extra.name = 'extra';
47
+ this._extra.className = 'extra';
48
+ this._extra.part.add('extra');
49
+ this._surface.append(this._icon, heading, this._description, this._content, this._extra);
50
+ root.append(style, this._surface);
51
+ for (const slot of [this._description, this._content, this._extra])
52
+ slot.addEventListener('slotchange', this._render);
53
+ }
54
+ connectedCallback() { this._render(); }
55
+ attributeChangedCallback() { this._render(); }
56
+ get status() { const value = this.getAttribute('status'); return Object.hasOwn(headings, value) ? value : 'info'; }
57
+ set status(value) { this.setAttribute('status', value); }
58
+ get heading() { return this.getAttribute('heading') ?? headings[this.status]; }
59
+ set heading(value) { this.setAttribute('heading', value); }
60
+ get description() { return this.getAttribute('description') ?? ''; }
61
+ set description(value) { this.setAttribute('description', value); }
62
+ _render = () => {
63
+ const status = this.status;
64
+ const code = /^\d/.test(status);
65
+ this._surface.className = `result ${code ? 'info' : status}`;
66
+ this._icon.className = code ? 'icon code' : 'icon';
67
+ this._icon.replaceChildren(code ? document.createTextNode(status) : presentationIcon(status));
68
+ if (this._heading.textContent !== this.heading)
69
+ this._heading.textContent = this.heading;
70
+ if (this._description.textContent !== this.description)
71
+ this._description.textContent = this.description;
72
+ this._description.hidden = !this.description && !hasSlotContent(this._description);
73
+ this._content.hidden = !hasSlotContent(this._content);
74
+ this._extra.hidden = !hasSlotContent(this._extra);
75
+ const label = this.getAttribute('aria-label');
76
+ if (label) {
77
+ this._surface.setAttribute('aria-label', label);
78
+ this._surface.removeAttribute('aria-labelledby');
79
+ }
80
+ else {
81
+ this._surface.removeAttribute('aria-label');
82
+ this._surface.setAttribute('aria-labelledby', 'result-heading');
83
+ }
84
+ };
85
+ }
86
+ export function defineResultComponents() { if (!customElements.get('hy-result'))
87
+ customElements.define('hy-result', HYResult); }
88
+ //# sourceMappingURL=result.js.map
@@ -0,0 +1,19 @@
1
+ export type HYRibbonPlacement = 'start' | 'end';
2
+ /** Folded ribbon decorating content in the default slot. */
3
+ export declare class HYRibbon extends HTMLElement {
4
+ private readonly _ribbon;
5
+ private readonly _text;
6
+ private readonly _fallback;
7
+ static get observedAttributes(): string[];
8
+ constructor();
9
+ connectedCallback(): void;
10
+ attributeChangedCallback(): void;
11
+ get text(): string;
12
+ set text(value: string);
13
+ get color(): string;
14
+ set color(value: string);
15
+ get placement(): HYRibbonPlacement;
16
+ set placement(value: HYRibbonPlacement);
17
+ private _render;
18
+ }
19
+ export declare function defineRibbonComponents(): void;
package/dist/ribbon.js ADDED
@@ -0,0 +1,106 @@
1
+ import { hasSlotContent } from './internal/presentation.js';
2
+ /** Folded ribbon decorating content in the default slot. */
3
+ export class HYRibbon extends HTMLElement {
4
+ _ribbon = document.createElement('div');
5
+ _text = document.createElement('slot');
6
+ _fallback = document.createTextNode('');
7
+ static get observedAttributes() {
8
+ return ['text', 'color', 'placement'];
9
+ }
10
+ constructor() {
11
+ super();
12
+ const root = this.attachShadow({ mode: 'open' });
13
+ const style = document.createElement('style');
14
+ style.textContent = `
15
+ :host {
16
+ display: block;
17
+ min-width: 0;
18
+ color: var(--hy-text-color, #eef0ff);
19
+ font: var(--hy-font-size-sm, 12px)/var(--hy-line-height-relaxed, 1.5) var(--hy-font-family, system-ui, sans-serif);
20
+ }
21
+ :host([hidden]), [hidden] { display: none !important; }
22
+ .wrapper { position: relative; display: flow-root; min-width: 0; }
23
+ .ribbon {
24
+ position: absolute;
25
+ z-index: 1;
26
+ inset-block-start: var(--hy-ribbon-offset, var(--hy-space-6, 12px));
27
+ inset-inline-end: calc(-1 * var(--hy-ribbon-fold-size, var(--hy-space-4, 8px)));
28
+ display: flex;
29
+ align-items: center;
30
+ box-sizing: border-box;
31
+ max-inline-size: calc(100% + 2 * var(--hy-ribbon-fold-size, var(--hy-space-4, 8px)));
32
+ min-block-size: var(--hy-ribbon-height, var(--hy-control-height-xs, 24px));
33
+ padding: var(--hy-ribbon-padding, var(--hy-space-2, 4px) var(--hy-space-6, 12px));
34
+ border-radius: var(--hy-ribbon-radius, var(--hy-radius-sm, 4px));
35
+ color: var(--hy-ribbon-text-color, var(--hy-on-accent-color, #fff));
36
+ background: var(--_hy-ribbon-color, var(--hy-ribbon-bg-color, var(--hy-accent-color, #8177f2)));
37
+ font-size: var(--hy-ribbon-font-size, var(--hy-font-size-sm, 12px));
38
+ }
39
+ .text { display: block; min-width: 0; overflow-wrap: anywhere; }
40
+ .fold {
41
+ position: absolute;
42
+ inset-block-start: 100%;
43
+ inset-inline-end: 0;
44
+ inline-size: var(--hy-ribbon-fold-size, var(--hy-space-4, 8px));
45
+ block-size: var(--hy-ribbon-fold-size, var(--hy-space-4, 8px));
46
+ background: color-mix(in srgb, var(--_hy-ribbon-color, var(--hy-ribbon-bg-color, var(--hy-accent-color, #8177f2))) 70%, #000);
47
+ clip-path: polygon(0 0, 100% 0, 0 100%);
48
+ pointer-events: none;
49
+ }
50
+ :host([placement="start"]) .ribbon {
51
+ inset-inline-start: calc(-1 * var(--hy-ribbon-fold-size, var(--hy-space-4, 8px)));
52
+ inset-inline-end: auto;
53
+ }
54
+ :host([placement="start"]) .fold { inset-inline-start: 0; inset-inline-end: auto; transform: scaleX(-1); }
55
+ :host(:dir(rtl)) .fold { transform: scaleX(-1); }
56
+ :host([placement="start"]:dir(rtl)) .fold { transform: none; }
57
+ `;
58
+ const wrapper = document.createElement('div');
59
+ wrapper.className = 'wrapper';
60
+ wrapper.part.add('wrapper');
61
+ const content = document.createElement('div');
62
+ content.part.add('content');
63
+ content.append(document.createElement('slot'));
64
+ this._ribbon.className = 'ribbon';
65
+ this._ribbon.part.add('ribbon');
66
+ this._text.name = 'text';
67
+ this._text.className = 'text';
68
+ this._text.part.add('text');
69
+ this._text.append(this._fallback);
70
+ const fold = document.createElement('span');
71
+ fold.className = 'fold';
72
+ fold.part.add('fold');
73
+ fold.setAttribute('aria-hidden', 'true');
74
+ this._ribbon.append(this._text, fold);
75
+ wrapper.append(content, this._ribbon);
76
+ root.append(style, wrapper);
77
+ this._text.addEventListener('slotchange', this._render);
78
+ }
79
+ connectedCallback() { this._render(); }
80
+ attributeChangedCallback() { this._render(); }
81
+ get text() { return this.getAttribute('text') ?? ''; }
82
+ set text(value) { this.setAttribute('text', value); }
83
+ get color() { return this.getAttribute('color')?.trim() ?? ''; }
84
+ set color(value) {
85
+ if (value.trim())
86
+ this.setAttribute('color', value.trim());
87
+ else
88
+ this.removeAttribute('color');
89
+ }
90
+ get placement() { return this.getAttribute('placement') === 'start' ? 'start' : 'end'; }
91
+ set placement(value) { this.setAttribute('placement', value === 'start' ? 'start' : 'end'); }
92
+ _render = () => {
93
+ if (this._fallback.textContent !== this.text)
94
+ this._fallback.textContent = this.text;
95
+ this._ribbon.hidden = !this.text.trim() && !hasSlotContent(this._text);
96
+ if (this.color && CSS.supports('color', this.color))
97
+ this._ribbon.style.setProperty('--_hy-ribbon-color', this.color);
98
+ else
99
+ this._ribbon.style.removeProperty('--_hy-ribbon-color');
100
+ };
101
+ }
102
+ export function defineRibbonComponents() {
103
+ if (!customElements.get('hy-ribbon'))
104
+ customElements.define('hy-ribbon', HYRibbon);
105
+ }
106
+ //# sourceMappingURL=ribbon.js.map
@@ -0,0 +1,39 @@
1
+ export type HYSegmentedSize = 'small' | 'medium' | 'large';
2
+ export interface HYSegmentedOption {
3
+ readonly label: string;
4
+ readonly value: string;
5
+ readonly icon?: string;
6
+ readonly disabled?: boolean;
7
+ }
8
+ export type HYSegmentedOptionInput = HYSegmentedOption | string | number;
9
+ export interface HYSegmentedChangeDetail {
10
+ readonly value: string;
11
+ readonly option: HYSegmentedOption | null;
12
+ }
13
+ /** A compact single-choice control with roving keyboard focus. */
14
+ export declare class HYSegmented extends HTMLElement {
15
+ private readonly _group;
16
+ private _options;
17
+ private _pendingFocus;
18
+ static get observedAttributes(): string[];
19
+ constructor();
20
+ connectedCallback(): void;
21
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
22
+ get options(): HYSegmentedOption[];
23
+ set options(value: readonly HYSegmentedOptionInput[]);
24
+ get value(): string;
25
+ set value(value: string);
26
+ get size(): HYSegmentedSize;
27
+ set size(value: HYSegmentedSize);
28
+ get block(): boolean;
29
+ set block(value: boolean);
30
+ get disabled(): boolean;
31
+ set disabled(value: boolean);
32
+ select(value: string): boolean;
33
+ private _readOptionsAttribute;
34
+ private _normalizeValue;
35
+ private _render;
36
+ private _onKeyDown;
37
+ private _focus;
38
+ }
39
+ export declare function defineSegmentedComponents(): void;