@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
@@ -1,3 +1,4 @@
1
+ import { hyIconSvg } from '../../portable/icons.js';
1
2
  import { HYButtonController, HYToggleController, HYSliderController } from '../../core/actions.js';
2
3
  import { HYSelectionController } from '../../core/selection.js';
3
4
  import { HYTextController } from '../../core/text.js';
@@ -29,6 +30,7 @@ export function definePortableWebComponents() {
29
30
  defineDialogComponents();
30
31
  }
31
32
  export const componentTags = Object.freeze({ Checkbox: 'hy-checkbox', RadioGroup: 'div', Rate: 'hy-rate', Badge: 'hy-badge', Divider: 'hy-divider', Button: 'hy-button', Toggle: 'hy-checkbox', Select: 'hy-select', Tabs: 'hy-tabs', TextInput: 'hy-input', Slider: 'hy-range', Dialog: 'hy-dialog' });
33
+ const selectionProps = ({ value, options, disabled }) => ({ value, options, ...(disabled === undefined ? {} : { disabled }) });
32
34
  let radioGroupSequence = 0;
33
35
  function toggleProps(node) { const { checked, disabled, visible } = node.props; return { checked, ...(disabled === undefined ? {} : { disabled }), ...(visible === undefined ? {} : { visible }) }; }
34
36
  export function createControl(node, context, revision) {
@@ -43,7 +45,7 @@ export function createControl(node, context, revision) {
43
45
  } ; if (next.kind === 'Divider')
44
46
  attribute(host, 'label', next.props.text); }, focus() { }, dispose() { } };
45
47
  if (node.kind === 'RadioGroup') {
46
- const controller = new HYSelectionController(node.key, node.props, emit);
48
+ const controller = new HYSelectionController(node.key, selectionProps(node.props), emit);
47
49
  let props = node.props;
48
50
  const buttons = new Map(), groupName = `hy-portable-radio-${++radioGroupSequence}`;
49
51
  host.setAttribute('role', 'radiogroup');
@@ -57,7 +59,7 @@ export function createControl(node, context, revision) {
57
59
  if (next.kind !== 'RadioGroup')
58
60
  return;
59
61
  props = next.props;
60
- controller.update(props);
62
+ controller.update(selectionProps(props));
61
63
  for (const [value, button] of buttons)
62
64
  if (!props.options.some(o => o.value === value)) {
63
65
  button.remove();
@@ -106,6 +108,10 @@ export function createControl(node, context, revision) {
106
108
  const label = document.createElement('span');
107
109
  label.dataset.hyButtonLabel = '';
108
110
  button.append(label);
111
+ const icon = document.createElement('span');
112
+ icon.slot = 'icon';
113
+ icon.setAttribute('aria-hidden', 'true');
114
+ let lastIcon;
109
115
  const controller = new HYButtonController(node.key, node.props, emit);
110
116
  listen(button, 'click', () => controller.activate(reason));
111
117
  return {
@@ -115,6 +121,20 @@ export function createControl(node, context, revision) {
115
121
  controller.update(next.props);
116
122
  if (label.textContent !== next.props.text)
117
123
  label.textContent = next.props.text;
124
+ attribute(button, 'data-hy-variant', next.props.variant ?? 'secondary');
125
+ attribute(button, 'data-hy-size', next.props.size ?? 'regular');
126
+ if (lastIcon !== next.props.icon) {
127
+ icon.innerHTML = next.props.icon ? hyIconSvg(next.props.icon) : '';
128
+ lastIcon = next.props.icon;
129
+ }
130
+ if (next.props.icon) {
131
+ if (!icon.parentNode)
132
+ button.append(icon);
133
+ }
134
+ else
135
+ icon.remove();
136
+ flag(button, 'icon-only', !!next.props.icon && !next.props.text);
137
+ flag(button, 'loading', !!next.props.busy);
118
138
  flag(button, 'disabled', !!next.props.disabled || !!next.props.busy);
119
139
  attribute(button, 'aria-busy', next.props.busy ? 'true' : undefined);
120
140
  },
@@ -144,7 +164,7 @@ export function createControl(node, context, revision) {
144
164
  const select = host;
145
165
  if (select instanceof HYTabs)
146
166
  select.controlled = true;
147
- const controller = new HYSelectionController(node.key, node.props, emit);
167
+ const controller = new HYSelectionController(node.key, selectionProps(node.props), emit);
148
168
  let previous;
149
169
  controller.attach({
150
170
  apply(props) {
@@ -180,8 +200,11 @@ export function createControl(node, context, revision) {
180
200
  const target = [...select.shadowRoot.querySelectorAll('button')].find(item => item.dataset.value === select.value);
181
201
  target?.focus();
182
202
  }, true);
183
- return { update(next) { if (next.kind === 'Select' || next.kind === 'Tabs')
184
- controller.update(next.props); },
203
+ return { update(next) { if (next.kind === 'Select' || next.kind === 'Tabs') {
204
+ if (next.kind === 'Tabs')
205
+ attribute(host, 'data-hy-variant', next.props.variant ?? 'underline');
206
+ controller.update(selectionProps(next.props));
207
+ } },
185
208
  focus() { if (select instanceof HYSelect)
186
209
  select.shadowRoot.querySelector('select').focus();
187
210
  else
@@ -192,11 +192,15 @@ export class HYWebRenderer {
192
192
  }
193
193
  if (node.kind === 'FormGroup') {
194
194
  entry.label = document.createElement('legend');
195
+ entry.help = document.createElement('span');
196
+ entry.help.dataset.hyHelp = '';
197
+ element.append(entry.help);
195
198
  entry.error = document.createElement('span');
196
199
  entry.error.dataset.hyError = '';
197
200
  entry.label.id = `${entry.id}-label`;
198
201
  entry.error.id = `${entry.id}-error`;
199
- element.append(entry.label, entry.error);
202
+ element.prepend(entry.label);
203
+ element.append(entry.error);
200
204
  }
201
205
  if (node.kind === 'PlatformView') {
202
206
  const factory = this.options.platformViews?.[node.props.slot];
@@ -218,6 +222,8 @@ export class HYWebRenderer {
218
222
  flag(element, 'hidden', node.props.visible === false);
219
223
  entry.control?.update(node, revision);
220
224
  if (node.kind === 'Text') {
225
+ attribute(element, 'data-hy-text-style', node.props.textStyle ?? 'body');
226
+ attribute(element, 'data-hy-tone', node.props.tone ?? 'default');
221
227
  if (element.textContent !== node.props.text)
222
228
  element.textContent = node.props.text;
223
229
  element.style.whiteSpace = node.props.wrap === false ? 'pre' : 'pre-wrap';
@@ -242,6 +248,8 @@ export class HYWebRenderer {
242
248
  }
243
249
  if (node.kind === 'FormGroup') {
244
250
  entry.label.textContent = node.props.label;
251
+ entry.help.textContent = node.props.description ?? '';
252
+ entry.help.hidden = !node.props.description;
245
253
  entry.error.textContent = node.props.error ?? '';
246
254
  entry.error.hidden = !node.props.error;
247
255
  }
@@ -323,7 +331,7 @@ export class HYWebRenderer {
323
331
  group = group.parent ? this.#nodes.get(group.parent) : undefined;
324
332
  const groupProps = group?.node.kind === 'FormGroup' ? group.node.props : undefined;
325
333
  const label = node.props.a11y?.label ?? (entry.control || node.kind === 'TextArea' ? groupProps?.label : undefined);
326
- const description = [node.props.a11y?.description, node.props.a11y?.error ?? groupProps?.error].filter(Boolean).join('. ');
334
+ const description = [node.props.a11y?.description, groupProps?.description, node.props.a11y?.error ?? groupProps?.error].filter(Boolean).join('. ');
327
335
  const a11y = label === undefined ? undefined : { ...node.props.a11y, label, ...(groupProps?.error && !node.props.a11y?.error ? { error: groupProps.error } : {}) };
328
336
  applyAccessibility(element, a11y);
329
337
  const targets = element instanceof HYTabs ? [...element.shadowRoot.querySelectorAll('[role=tablist],button')]
@@ -455,14 +463,7 @@ export class HYWebRenderer {
455
463
  this.#themeKeys.push(key);
456
464
  }
457
465
  }
458
- else if (environment.fontScale !== undefined) {
459
- const inherited = getComputedStyle(this.host);
460
- for (const [key, fallback] of [['--hy-font-size', 14], ['--hy-line-height', 22]]) {
461
- const base = parseFloat(inherited.getPropertyValue(key)) || fallback;
462
- this.#root.style.setProperty(key, `${base * fontScale}px`);
463
- this.#themeKeys.push(key);
464
- }
465
- }
466
+ this.#root.style.setProperty('--_hy-web-font-scale', String(theme ? 1 : fontScale));
466
467
  this.#root.dir = direction;
467
468
  flag(this.#root, 'data-hy-reduced-motion', !!environment.reducedMotion);
468
469
  this.#root.style.padding = safeArea === 'environment' ? ['top', 'right', 'bottom', 'left'].map(side => `env(safe-area-inset-${side}, 0px)`).join(' ') : safeArea.map(value => `${value}px`).join(' ');
@@ -1,3 +1,2 @@
1
- /** Only the renderer-owned wrapper and owned ShadowRoots receive these rules. */
2
- export declare const rootCSS = "\n[data-hy-portable-root] { box-sizing:border-box; min-width:0; min-height:0; width:100%; height:100%;\n color:var(--hy-text-color,#d8e2f2); background:var(--hy-surface-color,#171d28);\n font:var(--hy-font-size,14px)/var(--hy-line-height,22px) system-ui,sans-serif; }\n[data-hy-portable-root] [data-hy-key] { box-sizing:border-box; min-width:0; min-height:0; }\n[data-hy-portable-root] [data-hy-key][hidden] { display:none !important; }\n[data-hy-portable-root] [data-hy-kind=Row] { display:flex; flex-direction:row; }\n[data-hy-portable-root] [data-hy-kind=RadioGroup] { display:flex; flex-wrap:wrap; gap:var(--hy-gap,8px); }\n[data-hy-portable-root] [data-hy-kind=RadioGroup] hy-radio { font:inherit; min-height:44px; }\n[data-hy-portable-root] [data-hy-kind=Column] { display:flex; flex-direction:column; }\n[data-hy-portable-root] [data-hy-kind=Grid], [data-hy-portable-root] [data-hy-kind=Overlay] { display:grid; }\n[data-hy-portable-root] [data-hy-kind=Text] { display:block; overflow-wrap:anywhere; white-space:pre-wrap; }\n[data-hy-portable-root] [data-hy-kind=Icon] { width:1.25em; height:1.25em; object-fit:contain; }\n[data-hy-portable-root] [data-hy-kind=FormGroup] { border:0; margin:0; padding:0; display:flex; flex-direction:column; gap:var(--hy-gap,8px); }\n[data-hy-portable-root] [data-hy-kind=FormGroup] > legend { padding:0; }\n[data-hy-portable-root] [data-hy-error] { color:var(--hy-invalid-border-color,#d65c7c); font-size:.9em; }\n[data-hy-portable-root] textarea { box-sizing:border-box; width:100%; min-height:5em; resize:vertical; padding:8px;\n color:var(--hy-text-color,#d8e2f2); background:var(--hy-input-bg-color,#121822); border:1px solid var(--hy-border-color,#303746);\n border-radius:var(--hy-radius,4px); font:inherit; }\n[data-hy-portable-root] textarea:focus-visible { outline:2px solid var(--hy-focus-ring-color,#8177f2); outline-offset:1px; }\n[data-hy-portable-root] [data-hy-slot-group] { display:contents; }\n[data-hy-portable-root][data-hy-reduced-motion] { --hy-portable-transition:none; }\n@media(prefers-reduced-motion:reduce) { [data-hy-portable-root] { --hy-portable-transition:none; } }\n";
3
- export declare const componentCSS = "\n:host { --hy-input-font:var(--hy-font-size,14px)/var(--hy-line-height,22px) system-ui,sans-serif; font:inherit;\n --hy-panel-bg-color:var(--hy-surface-color,#171d28); --hy-surface-elevated-color:var(--hy-surface-color,#171d28);\n --hy-menu-bg-color:var(--hy-surface-color,#171d28); --hy-dialog-bg-color:var(--hy-surface-color,#171d28);\n --hy-dialog-body-color:var(--hy-text-color,#d8e2f2); --hy-dialog-footer-bg-color:var(--hy-surface-color,#171d28);\n --hy-accent-strong-color:var(--hy-accent-color,#8177f2); --hy-selected-bg-color:var(--hy-accent-color,#8177f2);\n --hy-active-text-color:var(--hy-text-color,#d8e2f2); --hy-hover-bg-color:var(--hy-input-bg-color,#121822);\n --hy-focus-border-color:var(--hy-focus-ring-color,#8177f2); --hy-dialog-radius:var(--hy-radius,8px); }\nbutton, input, select { font:inherit; min-height:2em; border-radius:var(--hy-radius,4px); }\n/* The semantic host owns the touch target. Its actual interactive element\n must fill it too; otherwise a 44px portable Button still paints at 28px. */\n:host(hy-button), :host(hy-input), :host(hy-select) { display:inline-flex; }\n:host(hy-button) button, :host(hy-input) input, :host(hy-select) select {\n box-sizing:border-box; width:100%; min-height:inherit; height:100%; padding-inline:12px;\n}\n:host(hy-select) .wrap, :host(hy-input) .control { width:100%; min-height:inherit; height:100%; box-sizing:border-box; }\n:host(hy-input) input { min-height:0; }\nselect { height:auto; padding-block:4px; }\ninput { height:var(--hy-input-height,auto); padding-block:4px; }\n.box, .box::after, .handle { transition:var(--hy-portable-transition,background .12s ease); }\n:host(hy-checkbox) { width:auto; }\n:host(hy-checkbox) label, :host(hy-checkbox) .label { white-space:normal; }\n:host(hy-checkbox) input { min-height:0; }\n:host(hy-tabs) { height:auto; grid-template-rows:auto minmax(0,1fr); }\n:host(hy-tabs) .tabs { align-items:stretch; }\n:host(hy-tabs) button { height:auto; white-space:normal; }\n:host(hy-range) .handle { min-height:0; }\n:host(hy-dialog) .header { padding:16px 20px; }\n:host(hy-dialog) h2 { font-size:calc(var(--hy-font-size,14px) + 6px); }\n:host(hy-dialog) .body { display:flex; flex-direction:column; gap:var(--hy-gap,8px); padding:20px; }\n:host(hy-dialog) .body > slot { display:contents; }\n:host(hy-dialog) .footer { box-sizing:border-box; min-height:0; padding:12px 20px; }\n\nbutton:focus-visible, select:focus-visible, input:focus-visible { outline:2px solid var(--hy-focus-ring-color,#8177f2); outline-offset:1px; }\n[aria-invalid=true] { border-color:var(--hy-invalid-border-color,#d65c7c); }\n";
1
+ export declare const rootCSS = "\n[data-hy-portable-root] { box-sizing:border-box; min-width:0; min-height:0; width:100%; height:100%;\n color:var(--hy-text-color,#d8e2f2); background:var(--hy-surface-color,#171d28);\n font:calc(var(--hy-font-size,var(--hy-font-size-md, 14px)) * var(--_hy-web-font-scale, 1))/calc(var(--hy-line-height,22px) * var(--_hy-web-font-scale, 1)) var(--hy-font-family, system-ui, sans-serif); }\n[data-hy-portable-root] [data-hy-key] { box-sizing:border-box; min-width:0; min-height:0; }\n[data-hy-portable-root] [data-hy-key][hidden] { display:none !important; }\n[data-hy-portable-root] [data-hy-kind=Row] { display:flex; flex-direction:row; }\n[data-hy-portable-root] [data-hy-kind=RadioGroup] { display:flex; flex-wrap:wrap; gap:var(--hy-gap,var(--hy-space-4, 8px)); }\n[data-hy-portable-root] [data-hy-kind=RadioGroup] hy-radio { font:inherit; min-height:44px; }\n[data-hy-portable-root] [data-hy-kind=Column] { display:flex; flex-direction:column; }\n[data-hy-portable-root] [data-hy-kind=Grid], [data-hy-portable-root] [data-hy-kind=Overlay] { display:grid; }\n[data-hy-portable-root] [data-hy-kind=Text] { display:block; overflow-wrap:anywhere; white-space:pre-wrap; }\n[data-hy-portable-root] [data-hy-kind=Icon] { width:1.25em; height:1.25em; object-fit:contain; }\n[data-hy-portable-root] [data-hy-kind=FormGroup] { border:0; margin:0; padding:0; display:flex; flex-direction:column; gap:var(--hy-gap,var(--hy-space-4, 8px)); }\n[data-hy-portable-root] [data-hy-kind=FormGroup] > legend { padding:0; }\n[data-hy-portable-root] [data-hy-help] { color:var(--hy-secondary-text-color); font-size:var(--hy-caption-font-size,var(--hy-font-size-sm, 12px)); line-height:var(--hy-caption-line-height,18px); }\n[data-hy-portable-root] [data-hy-error] { color:var(--hy-invalid-border-color,#d65c7c); font-size:.9em; }\n[data-hy-portable-root] textarea { box-sizing:border-box; width:100%; min-height:5em; resize:vertical; padding:var(--hy-space-4, 8px);\n color:var(--hy-text-color,#d8e2f2); background:var(--hy-input-bg-color,#121822); border:1px solid var(--hy-border-color,#303746);\n border-radius:var(--hy-radius,var(--hy-radius-sm, 4px)); font:inherit; }\n[data-hy-portable-root] textarea:focus-visible { outline:2px solid var(--hy-focus-ring-color,#8177f2); outline-offset:1px; }\n[data-hy-portable-root] [data-hy-text-style=title] { font-size:var(--hy-title-font-size,calc(var(--hy-font-size-xl, 20px) + 2px)); line-height:var(--hy-title-line-height,30px); font-weight:var(--hy-title-font-weight,var(--hy-font-weight-bold, 700)); }\n[data-hy-portable-root] [data-hy-text-style=caption] { font-size:var(--hy-caption-font-size,var(--hy-font-size-sm, 12px)); line-height:var(--hy-caption-line-height,18px); font-weight:var(--hy-caption-font-weight,var(--hy-font-weight-normal, 400)); }\n[data-hy-portable-root] [data-hy-text-style=body] { font-size:var(--hy-body-font-size,calc(var(--hy-font-size,var(--hy-font-size-md, 14px)) * var(--_hy-web-font-scale, 1))); line-height:var(--hy-body-line-height,calc(var(--hy-line-height,22px) * var(--_hy-web-font-scale, 1))); font-weight:var(--hy-body-font-weight,var(--hy-font-weight-normal, 400)); }\n[data-hy-portable-root] [data-hy-tone=muted] { color:var(--hy-secondary-text-color); }\n[data-hy-portable-root] [data-hy-tone=danger] { color:var(--hy-invalid-border-color); }\n[data-hy-portable-root] [data-hy-kind=Button] [slot=icon] svg { display:block; width:20px; height:20px; }\n[data-hy-portable-root] [data-hy-slot-group] { display:contents; }\n[data-hy-portable-root][data-hy-reduced-motion] { --hy-portable-transition:none; }\n@media(prefers-reduced-motion:reduce) { [data-hy-portable-root] { --hy-portable-transition:none; } }\n";
2
+ export declare const componentCSS = "\n:host { --hy-input-font:calc(var(--hy-font-size,var(--hy-font-size-md, 14px)) * var(--_hy-web-font-scale, 1))/calc(var(--hy-line-height,22px) * var(--_hy-web-font-scale, 1)) var(--hy-font-family, system-ui, sans-serif); --hy-input-radius:var(--hy-radius,var(--hy-radius-lg, 8px)); font:inherit;\n --hy-panel-bg-color:var(--hy-surface-color,#171d28);\n --hy-menu-bg-color:var(--hy-surface-color,#171d28); --hy-dialog-bg-color:var(--hy-surface-color,#171d28);\n --hy-dialog-body-color:var(--hy-text-color,#d8e2f2); --hy-dialog-footer-bg-color:var(--hy-surface-color,#171d28);\n --hy-accent-strong-color:var(--hy-accent-color,#8177f2);\n --hy-active-text-color:var(--hy-text-color,#d8e2f2); --hy-hover-bg-color:var(--hy-input-bg-color,#121822);\n --hy-focus-border-color:var(--hy-focus-ring-color,#8177f2); --hy-dialog-radius:var(--hy-radius,var(--hy-radius-lg, 8px)); }\nbutton, input, select { font:inherit; min-height:2em; border-radius:var(--hy-radius,var(--hy-radius-sm, 4px)); }\n/* The semantic host owns the touch target. Its actual interactive element\n must fill it too; otherwise a 44px portable Button still paints at 28px. */\n:host(hy-button), :host(hy-input), :host(hy-select) { display:inline-flex; }\n:host(hy-button) button, :host(hy-input) input, :host(hy-select) select {\n box-sizing:border-box; width:100%; min-height:inherit; height:100%; padding-inline:var(--hy-space-6, 12px);\n}\n:host(hy-select) .wrap, :host(hy-input) .control { width:100%; min-height:inherit; height:100%; box-sizing:border-box; }\n:host(hy-input) input { min-height:0; }\nselect { height:auto; padding-block:var(--hy-space-2, 4px); }\n:host(hy-input) input { height:auto; align-self:stretch; padding-block:0; border-radius:0; outline:none; }\n.box, .box::after, .handle { transition:var(--hy-portable-transition,background .12s ease); }\n:host(hy-checkbox) { width:auto; }\n:host(hy-checkbox) label, :host(hy-checkbox) .label { white-space:normal; }\n:host(hy-checkbox) input { min-height:0; }\n:host(hy-tabs) { height:auto; grid-template-rows:auto minmax(0,1fr); }\n:host(hy-tabs) .tabs { align-items:stretch; }\n:host(hy-tabs) button { height:auto; white-space:normal; }\n:host(hy-range) .handle { min-height:0; }\n:host(hy-dialog) .header { padding:var(--hy-space-8, 16px) var(--hy-space-10, 20px); }\n:host(hy-dialog) h2 { font-size:calc(calc(var(--hy-font-size,var(--hy-font-size-md, 14px)) * var(--_hy-web-font-scale, 1)) + 6px); }\n:host(hy-dialog) .body { display:flex; flex-direction:column; gap:var(--hy-gap,var(--hy-space-4, 8px)); padding:var(--hy-space-10, 20px); }\n:host(hy-dialog) .body > slot { display:contents; }\n:host(hy-dialog) .footer { box-sizing:border-box; min-height:0; padding:var(--hy-space-6, 12px) var(--hy-space-10, 20px); }\n\n/* Portable variants leave individual Web Component APIs unchanged. */\n:host(hy-button) button { border:1px solid var(--hy-border-color); background:var(--hy-surface-color); color:var(--hy-text-color); border-radius:var(--hy-radius,var(--hy-radius-lg, 8px)); transition:background .12s ease; }\n:host(hy-button[data-hy-variant=primary]) button { background:var(--hy-accent-color); border-color:transparent; color:var(--hy-on-accent-color,#fff); }\n:host(hy-button[data-hy-variant=danger]) button { background:var(--hy-invalid-border-color); border-color:transparent; color:var(--hy-on-accent-color,#fff); }\n:host(hy-button[data-hy-variant=quiet]) button { background:transparent; border-color:transparent; }\n:host(hy-button) button:hover:not(:disabled), :host(hy-button) button:active:not(:disabled) { background:var(--hy-pressed-bg-color,var(--hy-selected-bg-color)); }\n:host(hy-button:is([data-hy-variant=primary], [data-hy-variant=danger])) button:is(:hover, :active):not(:disabled) { color:var(--hy-selected-text-color,var(--hy-on-accent-color,#fff)); }\n:host(hy-button) button:disabled { opacity:.45; }\n:host(hy-button[data-hy-size=compact]) button { padding-inline:var(--hy-space-4, 8px); }\n:host(hy-button[icon-only]) button { padding:0; width:100%; }\n:host(hy-tabs) button { min-height:44px; padding:var(--hy-space-4, 8px) var(--hy-space-7, 14px); border:0; border-radius:0; background:transparent; color:var(--hy-secondary-text-color); border-bottom:2px solid transparent; }\n:host(hy-tabs) button[aria-selected=true] { color:var(--hy-text-color); border-bottom-color:var(--hy-accent-color); }\n:host(hy-tabs[data-hy-variant=segmented]) .tabs { padding:var(--hy-space-2, 4px); gap:var(--hy-space-2, 4px); border-radius:var(--hy-radius,var(--hy-radius-lg, 8px)); background:var(--hy-input-bg-color); }\n:host(hy-tabs[data-hy-variant=segmented]) button { border:0; border-radius:var(--hy-radius,var(--hy-radius-lg, 8px)); }\n:host(hy-tabs[data-hy-variant=segmented]) button[aria-selected=true] { background:var(--hy-selected-bg-color,var(--hy-accent-color)); }\nbutton:focus-visible, select:focus-visible { outline:2px solid var(--hy-focus-ring-color,#8177f2); outline-offset:1px; }\n[aria-invalid=true] { border-color:var(--hy-invalid-border-color,#d65c7c); }\n";
@@ -1,47 +1,56 @@
1
1
  /** Only the renderer-owned wrapper and owned ShadowRoots receive these rules. */
2
+ const fontSize = 'calc(var(--hy-font-size,var(--hy-font-size-md, 14px)) * var(--_hy-web-font-scale, 1))';
3
+ const lineHeight = 'calc(var(--hy-line-height,22px) * var(--_hy-web-font-scale, 1))';
2
4
  export const rootCSS = `
3
5
  [data-hy-portable-root] { box-sizing:border-box; min-width:0; min-height:0; width:100%; height:100%;
4
6
  color:var(--hy-text-color,#d8e2f2); background:var(--hy-surface-color,#171d28);
5
- font:var(--hy-font-size,14px)/var(--hy-line-height,22px) system-ui,sans-serif; }
7
+ font:${fontSize}/${lineHeight} var(--hy-font-family, system-ui, sans-serif); }
6
8
  [data-hy-portable-root] [data-hy-key] { box-sizing:border-box; min-width:0; min-height:0; }
7
9
  [data-hy-portable-root] [data-hy-key][hidden] { display:none !important; }
8
10
  [data-hy-portable-root] [data-hy-kind=Row] { display:flex; flex-direction:row; }
9
- [data-hy-portable-root] [data-hy-kind=RadioGroup] { display:flex; flex-wrap:wrap; gap:var(--hy-gap,8px); }
11
+ [data-hy-portable-root] [data-hy-kind=RadioGroup] { display:flex; flex-wrap:wrap; gap:var(--hy-gap,var(--hy-space-4, 8px)); }
10
12
  [data-hy-portable-root] [data-hy-kind=RadioGroup] hy-radio { font:inherit; min-height:44px; }
11
13
  [data-hy-portable-root] [data-hy-kind=Column] { display:flex; flex-direction:column; }
12
14
  [data-hy-portable-root] [data-hy-kind=Grid], [data-hy-portable-root] [data-hy-kind=Overlay] { display:grid; }
13
15
  [data-hy-portable-root] [data-hy-kind=Text] { display:block; overflow-wrap:anywhere; white-space:pre-wrap; }
14
16
  [data-hy-portable-root] [data-hy-kind=Icon] { width:1.25em; height:1.25em; object-fit:contain; }
15
- [data-hy-portable-root] [data-hy-kind=FormGroup] { border:0; margin:0; padding:0; display:flex; flex-direction:column; gap:var(--hy-gap,8px); }
17
+ [data-hy-portable-root] [data-hy-kind=FormGroup] { border:0; margin:0; padding:0; display:flex; flex-direction:column; gap:var(--hy-gap,var(--hy-space-4, 8px)); }
16
18
  [data-hy-portable-root] [data-hy-kind=FormGroup] > legend { padding:0; }
19
+ [data-hy-portable-root] [data-hy-help] { color:var(--hy-secondary-text-color); font-size:var(--hy-caption-font-size,var(--hy-font-size-sm, 12px)); line-height:var(--hy-caption-line-height,18px); }
17
20
  [data-hy-portable-root] [data-hy-error] { color:var(--hy-invalid-border-color,#d65c7c); font-size:.9em; }
18
- [data-hy-portable-root] textarea { box-sizing:border-box; width:100%; min-height:5em; resize:vertical; padding:8px;
21
+ [data-hy-portable-root] textarea { box-sizing:border-box; width:100%; min-height:5em; resize:vertical; padding:var(--hy-space-4, 8px);
19
22
  color:var(--hy-text-color,#d8e2f2); background:var(--hy-input-bg-color,#121822); border:1px solid var(--hy-border-color,#303746);
20
- border-radius:var(--hy-radius,4px); font:inherit; }
23
+ border-radius:var(--hy-radius,var(--hy-radius-sm, 4px)); font:inherit; }
21
24
  [data-hy-portable-root] textarea:focus-visible { outline:2px solid var(--hy-focus-ring-color,#8177f2); outline-offset:1px; }
25
+ [data-hy-portable-root] [data-hy-text-style=title] { font-size:var(--hy-title-font-size,calc(var(--hy-font-size-xl, 20px) + 2px)); line-height:var(--hy-title-line-height,30px); font-weight:var(--hy-title-font-weight,var(--hy-font-weight-bold, 700)); }
26
+ [data-hy-portable-root] [data-hy-text-style=caption] { font-size:var(--hy-caption-font-size,var(--hy-font-size-sm, 12px)); line-height:var(--hy-caption-line-height,18px); font-weight:var(--hy-caption-font-weight,var(--hy-font-weight-normal, 400)); }
27
+ [data-hy-portable-root] [data-hy-text-style=body] { font-size:var(--hy-body-font-size,${fontSize}); line-height:var(--hy-body-line-height,${lineHeight}); font-weight:var(--hy-body-font-weight,var(--hy-font-weight-normal, 400)); }
28
+ [data-hy-portable-root] [data-hy-tone=muted] { color:var(--hy-secondary-text-color); }
29
+ [data-hy-portable-root] [data-hy-tone=danger] { color:var(--hy-invalid-border-color); }
30
+ [data-hy-portable-root] [data-hy-kind=Button] [slot=icon] svg { display:block; width:20px; height:20px; }
22
31
  [data-hy-portable-root] [data-hy-slot-group] { display:contents; }
23
32
  [data-hy-portable-root][data-hy-reduced-motion] { --hy-portable-transition:none; }
24
33
  @media(prefers-reduced-motion:reduce) { [data-hy-portable-root] { --hy-portable-transition:none; } }
25
34
  `;
26
35
  export const componentCSS = `
27
- :host { --hy-input-font:var(--hy-font-size,14px)/var(--hy-line-height,22px) system-ui,sans-serif; font:inherit;
28
- --hy-panel-bg-color:var(--hy-surface-color,#171d28); --hy-surface-elevated-color:var(--hy-surface-color,#171d28);
36
+ :host { --hy-input-font:${fontSize}/${lineHeight} var(--hy-font-family, system-ui, sans-serif); --hy-input-radius:var(--hy-radius,var(--hy-radius-lg, 8px)); font:inherit;
37
+ --hy-panel-bg-color:var(--hy-surface-color,#171d28);
29
38
  --hy-menu-bg-color:var(--hy-surface-color,#171d28); --hy-dialog-bg-color:var(--hy-surface-color,#171d28);
30
39
  --hy-dialog-body-color:var(--hy-text-color,#d8e2f2); --hy-dialog-footer-bg-color:var(--hy-surface-color,#171d28);
31
- --hy-accent-strong-color:var(--hy-accent-color,#8177f2); --hy-selected-bg-color:var(--hy-accent-color,#8177f2);
40
+ --hy-accent-strong-color:var(--hy-accent-color,#8177f2);
32
41
  --hy-active-text-color:var(--hy-text-color,#d8e2f2); --hy-hover-bg-color:var(--hy-input-bg-color,#121822);
33
- --hy-focus-border-color:var(--hy-focus-ring-color,#8177f2); --hy-dialog-radius:var(--hy-radius,8px); }
34
- button, input, select { font:inherit; min-height:2em; border-radius:var(--hy-radius,4px); }
42
+ --hy-focus-border-color:var(--hy-focus-ring-color,#8177f2); --hy-dialog-radius:var(--hy-radius,var(--hy-radius-lg, 8px)); }
43
+ button, input, select { font:inherit; min-height:2em; border-radius:var(--hy-radius,var(--hy-radius-sm, 4px)); }
35
44
  /* The semantic host owns the touch target. Its actual interactive element
36
45
  must fill it too; otherwise a 44px portable Button still paints at 28px. */
37
46
  :host(hy-button), :host(hy-input), :host(hy-select) { display:inline-flex; }
38
47
  :host(hy-button) button, :host(hy-input) input, :host(hy-select) select {
39
- box-sizing:border-box; width:100%; min-height:inherit; height:100%; padding-inline:12px;
48
+ box-sizing:border-box; width:100%; min-height:inherit; height:100%; padding-inline:var(--hy-space-6, 12px);
40
49
  }
41
50
  :host(hy-select) .wrap, :host(hy-input) .control { width:100%; min-height:inherit; height:100%; box-sizing:border-box; }
42
51
  :host(hy-input) input { min-height:0; }
43
- select { height:auto; padding-block:4px; }
44
- input { height:var(--hy-input-height,auto); padding-block:4px; }
52
+ select { height:auto; padding-block:var(--hy-space-2, 4px); }
53
+ :host(hy-input) input { height:auto; align-self:stretch; padding-block:0; border-radius:0; outline:none; }
45
54
  .box, .box::after, .handle { transition:var(--hy-portable-transition,background .12s ease); }
46
55
  :host(hy-checkbox) { width:auto; }
47
56
  :host(hy-checkbox) label, :host(hy-checkbox) .label { white-space:normal; }
@@ -50,13 +59,28 @@ input { height:var(--hy-input-height,auto); padding-block:4px; }
50
59
  :host(hy-tabs) .tabs { align-items:stretch; }
51
60
  :host(hy-tabs) button { height:auto; white-space:normal; }
52
61
  :host(hy-range) .handle { min-height:0; }
53
- :host(hy-dialog) .header { padding:16px 20px; }
54
- :host(hy-dialog) h2 { font-size:calc(var(--hy-font-size,14px) + 6px); }
55
- :host(hy-dialog) .body { display:flex; flex-direction:column; gap:var(--hy-gap,8px); padding:20px; }
62
+ :host(hy-dialog) .header { padding:var(--hy-space-8, 16px) var(--hy-space-10, 20px); }
63
+ :host(hy-dialog) h2 { font-size:calc(${fontSize} + 6px); }
64
+ :host(hy-dialog) .body { display:flex; flex-direction:column; gap:var(--hy-gap,var(--hy-space-4, 8px)); padding:var(--hy-space-10, 20px); }
56
65
  :host(hy-dialog) .body > slot { display:contents; }
57
- :host(hy-dialog) .footer { box-sizing:border-box; min-height:0; padding:12px 20px; }
66
+ :host(hy-dialog) .footer { box-sizing:border-box; min-height:0; padding:var(--hy-space-6, 12px) var(--hy-space-10, 20px); }
58
67
 
59
- button:focus-visible, select:focus-visible, input:focus-visible { outline:2px solid var(--hy-focus-ring-color,#8177f2); outline-offset:1px; }
68
+ /* Portable variants leave individual Web Component APIs unchanged. */
69
+ :host(hy-button) button { border:1px solid var(--hy-border-color); background:var(--hy-surface-color); color:var(--hy-text-color); border-radius:var(--hy-radius,var(--hy-radius-lg, 8px)); transition:background .12s ease; }
70
+ :host(hy-button[data-hy-variant=primary]) button { background:var(--hy-accent-color); border-color:transparent; color:var(--hy-on-accent-color,#fff); }
71
+ :host(hy-button[data-hy-variant=danger]) button { background:var(--hy-invalid-border-color); border-color:transparent; color:var(--hy-on-accent-color,#fff); }
72
+ :host(hy-button[data-hy-variant=quiet]) button { background:transparent; border-color:transparent; }
73
+ :host(hy-button) button:hover:not(:disabled), :host(hy-button) button:active:not(:disabled) { background:var(--hy-pressed-bg-color,var(--hy-selected-bg-color)); }
74
+ :host(hy-button:is([data-hy-variant=primary], [data-hy-variant=danger])) button:is(:hover, :active):not(:disabled) { color:var(--hy-selected-text-color,var(--hy-on-accent-color,#fff)); }
75
+ :host(hy-button) button:disabled { opacity:.45; }
76
+ :host(hy-button[data-hy-size=compact]) button { padding-inline:var(--hy-space-4, 8px); }
77
+ :host(hy-button[icon-only]) button { padding:0; width:100%; }
78
+ :host(hy-tabs) button { min-height:44px; padding:var(--hy-space-4, 8px) var(--hy-space-7, 14px); border:0; border-radius:0; background:transparent; color:var(--hy-secondary-text-color); border-bottom:2px solid transparent; }
79
+ :host(hy-tabs) button[aria-selected=true] { color:var(--hy-text-color); border-bottom-color:var(--hy-accent-color); }
80
+ :host(hy-tabs[data-hy-variant=segmented]) .tabs { padding:var(--hy-space-2, 4px); gap:var(--hy-space-2, 4px); border-radius:var(--hy-radius,var(--hy-radius-lg, 8px)); background:var(--hy-input-bg-color); }
81
+ :host(hy-tabs[data-hy-variant=segmented]) button { border:0; border-radius:var(--hy-radius,var(--hy-radius-lg, 8px)); }
82
+ :host(hy-tabs[data-hy-variant=segmented]) button[aria-selected=true] { background:var(--hy-selected-bg-color,var(--hy-accent-color)); }
83
+ button:focus-visible, select:focus-visible { outline:2px solid var(--hy-focus-ring-color,#8177f2); outline-offset:1px; }
60
84
  [aria-invalid=true] { border-color:var(--hy-invalid-border-color,#d65c7c); }
61
85
  `;
62
86
  //# sourceMappingURL=styles.js.map
@@ -0,0 +1,39 @@
1
+ export type HYAlertType = 'success' | 'info' | 'warning' | 'error';
2
+ export interface HYAlertCloseDetail {
3
+ readonly type: HYAlertType;
4
+ readonly message: string;
5
+ }
6
+ /** A semantic, optionally dismissible status message. */
7
+ export declare class HYAlert extends HTMLElement {
8
+ private readonly _surface;
9
+ private readonly _icon;
10
+ private readonly _content;
11
+ private readonly _messageSlot;
12
+ private readonly _descriptionSlot;
13
+ private readonly _actionSlot;
14
+ private readonly _close;
15
+ static get observedAttributes(): string[];
16
+ constructor();
17
+ connectedCallback(): void;
18
+ disconnectedCallback(): void;
19
+ attributeChangedCallback(): void;
20
+ get type(): HYAlertType;
21
+ set type(value: HYAlertType);
22
+ get message(): string;
23
+ set message(value: string);
24
+ get description(): string;
25
+ set description(value: string);
26
+ get showIcon(): boolean;
27
+ set showIcon(value: boolean);
28
+ get closable(): boolean;
29
+ set closable(value: boolean);
30
+ get closeText(): string;
31
+ set closeText(value: string);
32
+ get banner(): boolean;
33
+ set banner(value: boolean);
34
+ close(): boolean;
35
+ private readonly _onClose;
36
+ private readonly _syncSlotState;
37
+ private _render;
38
+ }
39
+ export declare function defineAlertComponents(): void;
package/dist/alert.js ADDED
@@ -0,0 +1,144 @@
1
+ const ALERT_ICONS = {
2
+ success: '✓',
3
+ info: 'i',
4
+ warning: '!',
5
+ error: '×',
6
+ };
7
+ /** A semantic, optionally dismissible status message. */
8
+ export class HYAlert extends HTMLElement {
9
+ _surface = document.createElement('div');
10
+ _icon = document.createElement('span');
11
+ _content = document.createElement('div');
12
+ _messageSlot = document.createElement('slot');
13
+ _descriptionSlot = document.createElement('slot');
14
+ _actionSlot = document.createElement('slot');
15
+ _close = document.createElement('button');
16
+ static get observedAttributes() {
17
+ return ['type', 'message', 'description', 'show-icon', 'closable', 'close-text', 'banner'];
18
+ }
19
+ constructor() {
20
+ super();
21
+ const root = this.attachShadow({ mode: 'open' });
22
+ const style = document.createElement('style');
23
+ style.textContent = `
24
+ :host { display: block; min-width: 0; color: var(--hy-text-color, #d8e2f2); font: var(--hy-font-size-sm, 12px)/var(--hy-line-height-relaxed, 1.5) var(--hy-font-family, system-ui, sans-serif); }
25
+ :host([hidden]) { display: none; }
26
+ .alert { --_tone: var(--hy-info-color, #4ba3d3); --_tone-bg: var(--hy-alert-info-bg, color-mix(in srgb, var(--_tone) 13%, var(--hy-surface-color, #121822))); display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: var(--hy-space-5, 10px); align-items: start; box-sizing: border-box; min-height: 42px; padding: var(--hy-space-5, 10px) var(--hy-space-6, 12px); border: 1px solid color-mix(in srgb, var(--_tone) 42%, var(--hy-border-color, #303746)); border-radius: var(--hy-alert-radius, var(--hy-radius-md, 6px)); background: var(--_tone-bg); }
27
+ .alert.success { --_tone: var(--hy-success-color, #45b883); --_tone-bg: var(--hy-alert-success-bg, color-mix(in srgb, var(--_tone) 13%, var(--hy-surface-color, #121822))); }
28
+ .alert.warning { --_tone: var(--hy-warning-color, #d5a642); --_tone-bg: var(--hy-alert-warning-bg, color-mix(in srgb, var(--_tone) 14%, var(--hy-surface-color, #121822))); }
29
+ .alert.error { --_tone: var(--hy-error-color, #e06b72); --_tone-bg: var(--hy-alert-error-bg, color-mix(in srgb, var(--_tone) 13%, var(--hy-surface-color, #121822))); }
30
+ :host([banner]) .alert { border-inline: 0; border-radius: 0; }
31
+ .icon { display: none; width: 18px; height: 18px; place-items: center; margin-top: 1px; border-radius: 50%; color: var(--hy-alert-icon-text-color, var(--hy-on-status-color, #fff)); background: var(--_tone); font-size: calc(var(--hy-font-size-xs, 10px) + 1px); font-weight: var(--hy-font-weight-heavy, 800); line-height: var(--hy-line-height-tight, 1); }
32
+ .icon.visible { display: grid; }
33
+ .content { min-width: 0; }
34
+ .message { display: block; color: var(--hy-alert-message-color, var(--hy-text-color, #d8e2f2)); font-weight: var(--hy-font-weight-semibold, 600); overflow-wrap: anywhere; }
35
+ .description { display: block; margin-top: var(--hy-space-1, 2px); color: var(--hy-alert-description-color, var(--hy-secondary-text-color, #8fa7c8)); overflow-wrap: anywhere; }
36
+ .description.empty { display: none; }
37
+ .action { align-self: center; }
38
+ .action.empty { display: none; }
39
+ button { min-width: var(--hy-control-height-xs, 24px); height: var(--hy-control-height-xs, 24px); margin: calc(-1 * var(--hy-space-1, 2px)) calc(-1 * var(--hy-space-2, 4px)) calc(-1 * var(--hy-space-1, 2px)) 0; padding: 0 calc(var(--hy-space-2, 4px) + 1px); border: 0; border-radius: var(--hy-radius-sm, 4px); color: var(--hy-alert-close-color, var(--hy-secondary-text-color, #8fa7c8)); background: transparent; font: inherit; cursor: pointer; }
40
+ button:hover { color: var(--hy-alert-close-hover-color, var(--hy-text-color, #d8e2f2)); background: color-mix(in srgb, var(--_tone) 14%, transparent); }
41
+ button:focus-visible { outline: 2px solid var(--hy-focus-border-color, #3d6fa8); outline-offset: 1px; }
42
+ button[hidden] { display: none; }
43
+ ::slotted([slot="icon"]) { color: var(--_tone); }
44
+ `;
45
+ this._surface.className = 'alert info';
46
+ this._surface.part.add('alert');
47
+ this._surface.setAttribute('role', 'alert');
48
+ this._icon.className = 'icon';
49
+ this._icon.part.add('icon');
50
+ const iconSlot = document.createElement('slot');
51
+ iconSlot.name = 'icon';
52
+ this._icon.append(iconSlot);
53
+ this._content.className = 'content';
54
+ this._content.part.add('content');
55
+ this._messageSlot.name = 'message';
56
+ this._messageSlot.className = 'message';
57
+ this._messageSlot.part.add('message');
58
+ this._descriptionSlot.className = 'description';
59
+ this._descriptionSlot.part.add('description');
60
+ this._actionSlot.name = 'action';
61
+ this._actionSlot.className = 'action';
62
+ this._actionSlot.part.add('action');
63
+ this._content.append(this._messageSlot, this._descriptionSlot);
64
+ this._close.type = 'button';
65
+ this._close.part.add('close-button');
66
+ this._surface.append(this._icon, this._content, this._actionSlot, this._close);
67
+ root.append(style, this._surface);
68
+ }
69
+ connectedCallback() {
70
+ this._close.addEventListener('click', this._onClose);
71
+ this._descriptionSlot.addEventListener('slotchange', this._syncSlotState);
72
+ this._actionSlot.addEventListener('slotchange', this._syncSlotState);
73
+ this._render();
74
+ }
75
+ disconnectedCallback() {
76
+ this._close.removeEventListener('click', this._onClose);
77
+ this._descriptionSlot.removeEventListener('slotchange', this._syncSlotState);
78
+ this._actionSlot.removeEventListener('slotchange', this._syncSlotState);
79
+ }
80
+ attributeChangedCallback() { this._render(); }
81
+ get type() {
82
+ const value = this.getAttribute('type');
83
+ return value === 'success' || value === 'warning' || value === 'error' ? value : 'info';
84
+ }
85
+ set type(value) { this.setAttribute('type', value); }
86
+ get message() { return this.getAttribute('message') ?? ''; }
87
+ set message(value) { if (value)
88
+ this.setAttribute('message', value);
89
+ else
90
+ this.removeAttribute('message'); }
91
+ get description() { return this.getAttribute('description') ?? ''; }
92
+ set description(value) { if (value)
93
+ this.setAttribute('description', value);
94
+ else
95
+ this.removeAttribute('description'); }
96
+ get showIcon() { return this.hasAttribute('show-icon'); }
97
+ set showIcon(value) { this.toggleAttribute('show-icon', Boolean(value)); }
98
+ get closable() { return this.hasAttribute('closable'); }
99
+ set closable(value) { this.toggleAttribute('closable', Boolean(value)); }
100
+ get closeText() { return this.getAttribute('close-text') ?? ''; }
101
+ set closeText(value) { if (value)
102
+ this.setAttribute('close-text', value);
103
+ else
104
+ this.removeAttribute('close-text'); }
105
+ get banner() { return this.hasAttribute('banner'); }
106
+ set banner(value) { this.toggleAttribute('banner', Boolean(value)); }
107
+ close() {
108
+ const event = new CustomEvent('alert-close', {
109
+ detail: { type: this.type, message: this.message },
110
+ bubbles: true,
111
+ composed: true,
112
+ cancelable: true,
113
+ });
114
+ if (!this.dispatchEvent(event))
115
+ return false;
116
+ this.hidden = true;
117
+ return true;
118
+ }
119
+ _onClose = () => { this.close(); };
120
+ _syncSlotState = () => {
121
+ const hasDescription = Boolean(this.description) || this._descriptionSlot.assignedNodes({ flatten: true }).some(node => node.textContent?.trim());
122
+ const hasAction = this._actionSlot.assignedNodes({ flatten: true }).some(node => node.nodeType !== Node.TEXT_NODE || node.textContent?.trim());
123
+ this._descriptionSlot.classList.toggle('empty', !hasDescription);
124
+ this._actionSlot.classList.toggle('empty', !hasAction);
125
+ };
126
+ _render() {
127
+ this._surface.className = `alert ${this.type}`;
128
+ this._messageSlot.textContent = this.message;
129
+ this._descriptionSlot.textContent = this.description;
130
+ this._icon.classList.toggle('visible', this.showIcon || this.banner);
131
+ const iconSlot = this._icon.querySelector('slot');
132
+ if (iconSlot)
133
+ iconSlot.textContent = ALERT_ICONS[this.type];
134
+ this._close.hidden = !this.closable;
135
+ this._close.textContent = this.closeText || '×';
136
+ this._close.setAttribute('aria-label', this.closeText || 'Close alert');
137
+ this._syncSlotState();
138
+ }
139
+ }
140
+ export function defineAlertComponents() {
141
+ if (!customElements.get('hy-alert'))
142
+ customElements.define('hy-alert', HYAlert);
143
+ }
144
+ //# sourceMappingURL=alert.js.map
@@ -0,0 +1,60 @@
1
+ export type HYAnchorDirection = 'vertical' | 'horizontal';
2
+ export interface HYAnchorItem {
3
+ readonly href: string;
4
+ readonly title: string;
5
+ readonly key?: string;
6
+ readonly disabled?: boolean;
7
+ readonly children?: readonly HYAnchorItem[];
8
+ }
9
+ export interface HYAnchorChangeDetail {
10
+ readonly href: string;
11
+ readonly item: HYAnchorItem | null;
12
+ }
13
+ export interface HYAnchorClickDetail extends HYAnchorChangeDetail {
14
+ readonly nativeEvent: MouseEvent;
15
+ }
16
+ /** Hash-link navigation that tracks targets inside the viewport or an owned scroll container. */
17
+ export declare class HYAnchor extends HTMLElement {
18
+ private readonly _nav;
19
+ private readonly _list;
20
+ private _items;
21
+ private _scrollContainer;
22
+ private _listeners;
23
+ private _frame;
24
+ private _programmaticHref;
25
+ private _scrollEndTimer;
26
+ static get observedAttributes(): string[];
27
+ constructor();
28
+ connectedCallback(): void;
29
+ disconnectedCallback(): void;
30
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
31
+ get items(): HYAnchorItem[];
32
+ set items(value: HYAnchorItem[]);
33
+ get activeHref(): string;
34
+ set activeHref(value: string);
35
+ get offsetTop(): number;
36
+ set offsetTop(value: number);
37
+ get bounds(): number;
38
+ set bounds(value: number);
39
+ get direction(): HYAnchorDirection;
40
+ set direction(value: HYAnchorDirection);
41
+ get smooth(): boolean;
42
+ set smooth(value: boolean);
43
+ get scrollContainer(): HTMLElement | Window | null;
44
+ set scrollContainer(value: HTMLElement | Window | null);
45
+ scrollToAnchor(href: string): boolean;
46
+ refresh(): void;
47
+ private _normalizeItems;
48
+ private _readItemsAttribute;
49
+ private _flatten;
50
+ private _render;
51
+ private _onClick;
52
+ private _resolveTarget;
53
+ private _connect;
54
+ private _disconnect;
55
+ private _measure;
56
+ private _scheduleScrollEnd;
57
+ private _finishProgrammaticScroll;
58
+ private _setActive;
59
+ }
60
+ export declare function defineAnchorComponents(): void;