@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
@@ -14,7 +14,7 @@ import { defineRadioComponents } from '../../radio.js';
14
14
  import { defineRateComponents } from '../../rate.js';
15
15
  import { defineBadgeComponents } from '../../badge.js';
16
16
  import { defineDividerComponents } from '../../divider.js';
17
- import { attribute, flag, focusable } from './dom.js';
17
+ import { attribute, flag, focusable, captureFocus } from './dom.js';
18
18
  /** Registration is explicit and limited to the reused components. */
19
19
  export function definePortableWebComponents() {
20
20
  defineButtonComponents();
@@ -49,12 +49,47 @@ export function createControl(node, context, revision) {
49
49
  let props = node.props;
50
50
  const buttons = new Map(), groupName = `hy-portable-radio-${++radioGroupSequence}`;
51
51
  host.setAttribute('role', 'radiogroup');
52
- const render = () => { for (const [value, button] of buttons) {
53
- flag(button, 'checked', props.value === value);
54
- flag(button, 'disabled', !!props.disabled || !!props.options.find(o => o.value === value)?.disabled);
55
- } };
52
+ const enabled = () => props.disabled ? [] : props.options.filter(option => !option.disabled);
53
+ const focusValue = () => enabled().find(option => option.value === props.value)?.value ?? enabled()[0]?.value;
54
+ const focus = () => buttons.get(focusValue() ?? '')?.shadowRoot?.querySelector('input')?.focus();
55
+ const render = () => {
56
+ const tabValue = focusValue();
57
+ for (const [value, button] of buttons) {
58
+ flag(button, 'checked', props.value === value);
59
+ flag(button, 'disabled', !!props.disabled || !!props.options.find(o => o.value === value)?.disabled);
60
+ const input = button.shadowRoot?.querySelector('input');
61
+ if (input)
62
+ input.tabIndex = value === tabValue ? 0 : -1;
63
+ }
64
+ };
56
65
  listen(host, 'checked-change', event => { const detail = event.detail; if (detail.checked)
57
66
  controller.choose(detail.value, reason); render(); });
67
+ listen(host, 'keydown', event => {
68
+ const key = event;
69
+ if (key.defaultPrevented || key.altKey || key.ctrlKey || key.metaKey)
70
+ return;
71
+ const options = enabled();
72
+ if (!options.length)
73
+ return;
74
+ const target = key.composedPath().find((node) => node instanceof HTMLElement && [...buttons.values()].includes(node));
75
+ const current = options.findIndex(option => buttons.get(option.value) === target);
76
+ const rtl = getComputedStyle(host).direction === 'rtl';
77
+ let next;
78
+ if (key.key === 'Home')
79
+ next = 0;
80
+ else if (key.key === 'End')
81
+ next = options.length - 1;
82
+ else if (['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'].includes(key.key)) {
83
+ const forward = key.key === 'ArrowDown' || key.key === (rtl ? 'ArrowLeft' : 'ArrowRight');
84
+ next = current < 0 ? 0 : (current + (forward ? 1 : -1) + options.length) % options.length;
85
+ }
86
+ else
87
+ return;
88
+ key.preventDefault();
89
+ controller.choose(options[next].value, 'keyboard');
90
+ render();
91
+ focus();
92
+ });
58
93
  return { update(next) {
59
94
  if (next.kind !== 'RadioGroup')
60
95
  return;
@@ -65,6 +100,8 @@ export function createControl(node, context, revision) {
65
100
  button.remove();
66
101
  buttons.delete(value);
67
102
  }
103
+ const restoreFocus = captureFocus(host.ownerDocument);
104
+ let cursor = host.firstElementChild;
68
105
  for (const option of props.options) {
69
106
  let button = buttons.get(option.value);
70
107
  if (!button) {
@@ -74,11 +111,14 @@ export function createControl(node, context, revision) {
74
111
  attribute(button, 'value', option.value);
75
112
  attribute(button, 'label', option.label);
76
113
  attribute(button, 'name', groupName);
77
- host.append(button);
114
+ if (button !== cursor)
115
+ host.insertBefore(button, cursor);
116
+ cursor = button.nextElementSibling;
78
117
  }
79
118
  render();
119
+ restoreFocus();
80
120
  },
81
- focus() { focusable(host)[0]?.focus(); }, dispose() { controller.dispose(); buttons.clear(); } };
121
+ focus, dispose() { controller.dispose(); buttons.clear(); } };
82
122
  }
83
123
  if (node.kind === 'Rate') {
84
124
  let props = node.props, disposed = false, choosing = false;
@@ -101,7 +141,7 @@ export function createControl(node, context, revision) {
101
141
  }
102
142
  });
103
143
  return { update(next) { if (next.kind !== 'Rate')
104
- return; props = next.props; attribute(host, 'count', String(props.count)); flag(host, 'disabled', !!props.disabled); flag(host, 'readonly', !!props.readOnly); restore(); }, focus() { focusable(host)[0]?.focus(); }, dispose() { disposed = true; } };
144
+ return; props = next.props; attribute(host, 'count', String(props.count)); flag(host, 'disabled', !!props.disabled); flag(host, 'readonly', !!props.readOnly); restore(); }, focus() { host.shadowRoot?.querySelector('[role="slider"]')?.focus(); }, dispose() { disposed = true; } };
105
145
  }
106
146
  if (node.kind === 'Button') {
107
147
  const button = host;
@@ -8,6 +8,10 @@ import { componentTags, createControl } from './controls.js';
8
8
  import { applyAccessibility, applyLayout, attribute, captureFocus, deepActive, flag, focusable } from './dom.js';
9
9
  import { componentCSS, rootCSS } from './styles.js';
10
10
  const tags = { Row: 'div', Column: 'div', Grid: 'div', Overlay: 'div', Scroll: 'div', Text: 'span', Image: 'img', Icon: 'img', TextArea: 'textarea', FormGroup: 'fieldset', PlatformView: 'div', ...componentTags };
11
+ const a11ySelectors = {
12
+ Row: null, Column: null, Grid: null, Overlay: null, Scroll: null, Text: null, Image: null, Icon: null, TextArea: null, FormGroup: null, PlatformView: null, Badge: null, Divider: null,
13
+ Button: 'button', Checkbox: 'input', Toggle: 'input', RadioGroup: 'input', Rate: '[role="slider"]', Select: 'select', Tabs: '[role="tablist"],button', TextInput: 'input', Slider: 'button.upper', Dialog: 'dialog',
14
+ };
11
15
  let rendererSequence = 0;
12
16
  /** Browser-only adapter. Explicit registration and an attached, same-realm mount point are required. */
13
17
  export class HYWebRenderer {
@@ -334,11 +338,12 @@ export class HYWebRenderer {
334
338
  const description = [node.props.a11y?.description, groupProps?.description, node.props.a11y?.error ?? groupProps?.error].filter(Boolean).join('. ');
335
339
  const a11y = label === undefined ? undefined : { ...node.props.a11y, label, ...(groupProps?.error && !node.props.a11y?.error ? { error: groupProps.error } : {}) };
336
340
  applyAccessibility(element, a11y);
337
- const targets = element instanceof HYTabs ? [...element.shadowRoot.querySelectorAll('[role=tablist],button')]
338
- : element.shadowRoot ? [element.shadowRoot.querySelector(node.kind === 'Slider' ? 'button.upper' : 'input:not([type=search]),select,button,dialog')].filter((el) => !!el) : [element];
341
+ const selector = a11ySelectors[node.kind];
342
+ const targets = node.kind === 'RadioGroup' ? [...element.querySelectorAll('hy-radio')].flatMap(radio => [...radio.shadowRoot.querySelectorAll('input')])
343
+ : selector && element.shadowRoot ? [...element.shadowRoot.querySelectorAll(selector)] : [element];
339
344
  for (const target of targets) {
340
345
  // Tabs label belongs to the tablist; each tab keeps its option name.
341
- if (!(element instanceof HYTabs) || target.getAttribute('role') === 'tablist')
346
+ if (node.kind !== 'RadioGroup' && (!(element instanceof HYTabs) || target.getAttribute('role') === 'tablist'))
342
347
  applyAccessibility(target, a11y);
343
348
  attribute(target, 'aria-description', description || undefined);
344
349
  attribute(target, 'aria-invalid', (node.props.a11y?.error ?? groupProps?.error) ? 'true' : undefined);
@@ -463,14 +468,7 @@ export class HYWebRenderer {
463
468
  this.#themeKeys.push(key);
464
469
  }
465
470
  }
466
- else if (environment.fontScale !== undefined) {
467
- const inherited = getComputedStyle(this.host);
468
- for (const [key, fallback] of [['--hy-font-size', 14], ['--hy-line-height', 22]]) {
469
- const base = parseFloat(inherited.getPropertyValue(key)) || fallback;
470
- this.#root.style.setProperty(key, `${base * fontScale}px`);
471
- this.#themeKeys.push(key);
472
- }
473
- }
471
+ this.#root.style.setProperty('--_hy-web-font-scale', String(theme ? 1 : fontScale));
474
472
  this.#root.dir = direction;
475
473
  flag(this.#root, 'data-hy-reduced-motion', !!environment.reducedMotion);
476
474
  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-help] { color:var(--hy-secondary-text-color); font-size:var(--hy-caption-font-size,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: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-text-style=title] { font-size:var(--hy-title-font-size,22px); line-height:var(--hy-title-line-height,30px); font-weight:var(--hy-title-font-weight,700); }\n[data-hy-portable-root] [data-hy-text-style=caption] { font-size:var(--hy-caption-font-size,12px); line-height:var(--hy-caption-line-height,18px); font-weight:var(--hy-caption-font-weight,400); }\n[data-hy-portable-root] [data-hy-text-style=body] { font-size:var(--hy-body-font-size,var(--hy-font-size,14px)); line-height:var(--hy-body-line-height,var(--hy-line-height,22px)); font-weight:var(--hy-body-font-weight,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";
3
- export declare const componentCSS = "\n:host { --hy-input-font:var(--hy-font-size,14px)/var(--hy-line-height,22px) system-ui,sans-serif; --hy-input-radius:var(--hy-radius,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,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; }\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: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\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,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) button:disabled { opacity:.45; }\n:host(hy-button[data-hy-size=compact]) button { padding-inline:8px; }\n:host(hy-button[icon-only]) button { padding:0; width:100%; }\n:host(hy-tabs) button { min-height:44px; padding:8px 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:4px; gap:4px; border-radius:var(--hy-radius,8px); background:var(--hy-input-bg-color); }\n:host(hy-tabs[data-hy-variant=segmented]) button { border:0; border-radius:var(--hy-radius,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
+ 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,28 +1,30 @@
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; }
17
- [data-hy-portable-root] [data-hy-help] { color:var(--hy-secondary-text-color); font-size:var(--hy-caption-font-size,12px); line-height:var(--hy-caption-line-height,18px); }
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); }
18
20
  [data-hy-portable-root] [data-hy-error] { color:var(--hy-invalid-border-color,#d65c7c); font-size:.9em; }
19
- [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);
20
22
  color:var(--hy-text-color,#d8e2f2); background:var(--hy-input-bg-color,#121822); border:1px solid var(--hy-border-color,#303746);
21
- border-radius:var(--hy-radius,4px); font:inherit; }
23
+ border-radius:var(--hy-radius,var(--hy-radius-sm, 4px)); font:inherit; }
22
24
  [data-hy-portable-root] textarea:focus-visible { outline:2px solid var(--hy-focus-ring-color,#8177f2); outline-offset:1px; }
23
- [data-hy-portable-root] [data-hy-text-style=title] { font-size:var(--hy-title-font-size,22px); line-height:var(--hy-title-line-height,30px); font-weight:var(--hy-title-font-weight,700); }
24
- [data-hy-portable-root] [data-hy-text-style=caption] { font-size:var(--hy-caption-font-size,12px); line-height:var(--hy-caption-line-height,18px); font-weight:var(--hy-caption-font-weight,400); }
25
- [data-hy-portable-root] [data-hy-text-style=body] { font-size:var(--hy-body-font-size,var(--hy-font-size,14px)); line-height:var(--hy-body-line-height,var(--hy-line-height,22px)); font-weight:var(--hy-body-font-weight,400); }
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)); }
26
28
  [data-hy-portable-root] [data-hy-tone=muted] { color:var(--hy-secondary-text-color); }
27
29
  [data-hy-portable-root] [data-hy-tone=danger] { color:var(--hy-invalid-border-color); }
28
30
  [data-hy-portable-root] [data-hy-kind=Button] [slot=icon] svg { display:block; width:20px; height:20px; }
@@ -31,23 +33,23 @@ export const rootCSS = `
31
33
  @media(prefers-reduced-motion:reduce) { [data-hy-portable-root] { --hy-portable-transition:none; } }
32
34
  `;
33
35
  export const componentCSS = `
34
- :host { --hy-input-font:var(--hy-font-size,14px)/var(--hy-line-height,22px) system-ui,sans-serif; --hy-input-radius:var(--hy-radius,8px); font:inherit;
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;
35
37
  --hy-panel-bg-color:var(--hy-surface-color,#171d28);
36
38
  --hy-menu-bg-color:var(--hy-surface-color,#171d28); --hy-dialog-bg-color:var(--hy-surface-color,#171d28);
37
39
  --hy-dialog-body-color:var(--hy-text-color,#d8e2f2); --hy-dialog-footer-bg-color:var(--hy-surface-color,#171d28);
38
40
  --hy-accent-strong-color:var(--hy-accent-color,#8177f2);
39
41
  --hy-active-text-color:var(--hy-text-color,#d8e2f2); --hy-hover-bg-color:var(--hy-input-bg-color,#121822);
40
- --hy-focus-border-color:var(--hy-focus-ring-color,#8177f2); --hy-dialog-radius:var(--hy-radius,8px); }
41
- 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)); }
42
44
  /* The semantic host owns the touch target. Its actual interactive element
43
45
  must fill it too; otherwise a 44px portable Button still paints at 28px. */
44
46
  :host(hy-button), :host(hy-input), :host(hy-select) { display:inline-flex; }
45
47
  :host(hy-button) button, :host(hy-input) input, :host(hy-select) select {
46
- 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);
47
49
  }
48
50
  :host(hy-select) .wrap, :host(hy-input) .control { width:100%; min-height:inherit; height:100%; box-sizing:border-box; }
49
51
  :host(hy-input) input { min-height:0; }
50
- select { height:auto; padding-block:4px; }
52
+ select { height:auto; padding-block:var(--hy-space-2, 4px); }
51
53
  :host(hy-input) input { height:auto; align-self:stretch; padding-block:0; border-radius:0; outline:none; }
52
54
  .box, .box::after, .handle { transition:var(--hy-portable-transition,background .12s ease); }
53
55
  :host(hy-checkbox) { width:auto; }
@@ -57,25 +59,26 @@ select { height:auto; padding-block:4px; }
57
59
  :host(hy-tabs) .tabs { align-items:stretch; }
58
60
  :host(hy-tabs) button { height:auto; white-space:normal; }
59
61
  :host(hy-range) .handle { min-height:0; }
60
- :host(hy-dialog) .header { padding:16px 20px; }
61
- :host(hy-dialog) h2 { font-size:calc(var(--hy-font-size,14px) + 6px); }
62
- :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); }
63
65
  :host(hy-dialog) .body > slot { display:contents; }
64
- :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); }
65
67
 
66
68
  /* Portable variants leave individual Web Component APIs unchanged. */
67
- :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,8px); transition:background .12s ease; }
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; }
68
70
  :host(hy-button[data-hy-variant=primary]) button { background:var(--hy-accent-color); border-color:transparent; color:var(--hy-on-accent-color,#fff); }
69
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); }
70
72
  :host(hy-button[data-hy-variant=quiet]) button { background:transparent; border-color:transparent; }
71
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)); }
72
75
  :host(hy-button) button:disabled { opacity:.45; }
73
- :host(hy-button[data-hy-size=compact]) button { padding-inline:8px; }
76
+ :host(hy-button[data-hy-size=compact]) button { padding-inline:var(--hy-space-4, 8px); }
74
77
  :host(hy-button[icon-only]) button { padding:0; width:100%; }
75
- :host(hy-tabs) button { min-height:44px; padding:8px 14px; border:0; border-radius:0; background:transparent; color:var(--hy-secondary-text-color); border-bottom:2px solid transparent; }
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; }
76
79
  :host(hy-tabs) button[aria-selected=true] { color:var(--hy-text-color); border-bottom-color:var(--hy-accent-color); }
77
- :host(hy-tabs[data-hy-variant=segmented]) .tabs { padding:4px; gap:4px; border-radius:var(--hy-radius,8px); background:var(--hy-input-bg-color); }
78
- :host(hy-tabs[data-hy-variant=segmented]) button { border:0; border-radius:var(--hy-radius,8px); }
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)); }
79
82
  :host(hy-tabs[data-hy-variant=segmented]) button[aria-selected=true] { background:var(--hy-selected-bg-color,var(--hy-accent-color)); }
80
83
  button:focus-visible, select:focus-visible { outline:2px solid var(--hy-focus-ring-color,#8177f2); outline-offset:1px; }
81
84
  [aria-invalid=true] { border-color:var(--hy-invalid-border-color,#d65c7c); }
@@ -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,62 @@
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 _syncLabel;
52
+ private _syncActive;
53
+ private _onClick;
54
+ private _resolveTarget;
55
+ private _connect;
56
+ private _disconnect;
57
+ private _measure;
58
+ private _scheduleScrollEnd;
59
+ private _finishProgrammaticScroll;
60
+ private _setActive;
61
+ }
62
+ export declare function defineAnchorComponents(): void;