@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.
- package/CHANGELOG.md +42 -0
- package/README.md +523 -4
- package/dist/adapters/web/controls.js +48 -8
- package/dist/adapters/web/renderer.js +9 -11
- package/dist/adapters/web/styles.d.ts +2 -3
- package/dist/adapters/web/styles.js +26 -23
- package/dist/alert.d.ts +39 -0
- package/dist/alert.js +144 -0
- package/dist/anchor.d.ts +62 -0
- package/dist/anchor.js +293 -0
- package/dist/auto-complete.d.ts +83 -0
- package/dist/auto-complete.js +267 -0
- package/dist/avatar.d.ts +45 -0
- package/dist/avatar.js +135 -0
- package/dist/badge.js +5 -5
- package/dist/border-beam.js +3 -2
- package/dist/breadcrumb.js +5 -5
- package/dist/button-group.js +8 -8
- package/dist/button.js +10 -10
- package/dist/card.d.ts +29 -0
- package/dist/card.js +101 -0
- package/dist/carousel.js +6 -6
- package/dist/cascader.js +19 -13
- package/dist/checkbox.d.ts +12 -0
- package/dist/checkbox.js +22 -6
- package/dist/collapse.js +6 -6
- package/dist/context-menu.js +3 -4
- package/dist/core/actions.js +7 -8
- package/dist/core/data.d.ts +1 -1
- package/dist/core/data.js +44 -10
- package/dist/core/platform-view.js +8 -2
- package/dist/core/selection.js +4 -4
- package/dist/core/semantics.d.ts +26 -0
- package/dist/core/semantics.js +8 -0
- package/dist/core/text.js +3 -3
- package/dist/core/validation.d.ts +3 -1
- package/dist/core/validation.js +23 -5
- package/dist/date-picker.js +19 -13
- package/dist/descriptions.d.ts +44 -0
- package/dist/descriptions.js +169 -0
- package/dist/dialog.d.ts +4 -0
- package/dist/dialog.js +48 -27
- package/dist/divider.js +2 -2
- package/dist/draggable.js +5 -3
- package/dist/drawer.js +16 -24
- package/dist/dropdown.js +3 -4
- package/dist/empty.d.ts +20 -0
- package/dist/empty.js +58 -0
- package/dist/expandable.js +4 -4
- package/dist/form-item.d.ts +60 -0
- package/dist/form-item.js +212 -0
- package/dist/form.d.ts +41 -0
- package/dist/form.js +154 -0
- package/dist/history-controls.js +5 -5
- package/dist/image-preview.d.ts +22 -0
- package/dist/image-preview.js +38 -0
- package/dist/image.d.ts +52 -0
- package/dist/image.js +152 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.js +72 -0
- package/dist/input.d.ts +11 -0
- package/dist/input.js +32 -18
- package/dist/internal/anchored-popup.d.ts +19 -0
- package/dist/internal/anchored-popup.js +89 -0
- package/dist/internal/focus.d.ts +2 -0
- package/dist/internal/focus.js +31 -0
- package/dist/internal/form-control.d.ts +22 -0
- package/dist/internal/form-control.js +52 -0
- package/dist/internal/image-viewer.d.ts +51 -0
- package/dist/internal/image-viewer.js +210 -0
- package/dist/internal/keyboard.d.ts +2 -0
- package/dist/internal/keyboard.js +12 -0
- package/dist/internal/numbers.d.ts +2 -0
- package/dist/internal/numbers.js +8 -0
- package/dist/internal/pagination.d.ts +35 -0
- package/dist/internal/pagination.js +169 -0
- package/dist/internal/popover-base.d.ts +87 -0
- package/dist/internal/popover-base.js +365 -0
- package/dist/internal/presentation.d.ts +2 -0
- package/dist/internal/presentation.js +28 -0
- package/dist/mentions.d.ts +115 -0
- package/dist/mentions.js +485 -0
- package/dist/menu-shared.d.ts +1 -1
- package/dist/menu-shared.js +3 -3
- package/dist/menu.d.ts +63 -0
- package/dist/menu.js +339 -0
- package/dist/modal.js +11 -40
- package/dist/notification.js +11 -10
- package/dist/pagination.d.ts +34 -0
- package/dist/pagination.js +73 -0
- package/dist/popconfirm.d.ts +6 -0
- package/dist/popconfirm.js +7 -0
- package/dist/popover.d.ts +6 -0
- package/dist/popover.js +7 -0
- package/dist/portable/page.js +25 -14
- package/dist/progress.d.ts +30 -0
- package/dist/progress.js +102 -0
- package/dist/qr-code.js +3 -3
- package/dist/radio.d.ts +10 -0
- package/dist/radio.js +18 -5
- package/dist/range.js +7 -7
- package/dist/rate.js +3 -3
- package/dist/resizable.js +8 -5
- package/dist/result.d.ts +22 -0
- package/dist/result.js +88 -0
- package/dist/ribbon.d.ts +19 -0
- package/dist/ribbon.js +106 -0
- package/dist/segmented.d.ts +39 -0
- package/dist/segmented.js +192 -0
- package/dist/select.d.ts +12 -0
- package/dist/select.js +31 -13
- package/dist/skeleton.js +10 -10
- package/dist/spin.d.ts +26 -0
- package/dist/spin.js +80 -0
- package/dist/steps.js +13 -13
- package/dist/switch.d.ts +44 -0
- package/dist/switch.js +104 -0
- package/dist/table.d.ts +3 -3
- package/dist/table.js +110 -128
- package/dist/tabs.js +7 -7
- package/dist/tag.js +8 -8
- package/dist/time-picker.js +16 -10
- package/dist/timeline.js +12 -12
- package/dist/toast.js +12 -11
- package/dist/tooltip.d.ts +6 -0
- package/dist/tooltip.js +107 -6
- package/dist/tour.js +26 -17
- package/dist/tree-model.d.ts +2 -0
- package/dist/tree-model.js +32 -11
- package/dist/tree-node.js +2 -2
- package/dist/tree-select.d.ts +94 -0
- package/dist/tree-select.js +398 -0
- package/dist/tree.d.ts +0 -2
- package/dist/tree.js +14 -29
- package/dist/upload.d.ts +108 -0
- package/dist/upload.js +358 -0
- package/dist/virtual-keyboard.d.ts +1 -0
- package/dist/virtual-keyboard.js +72 -41
- package/dist/virtual-list.d.ts +1 -0
- package/dist/virtual-list.js +25 -8
- package/dist/virtual-mouse.js +7 -6
- package/dist/watermark.js +2 -1
- package/package.json +82 -1
- package/themes/haiyue-dark.css +51 -0
- package/themes/haiyue-light.css +51 -0
package/dist/portable/page.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { HYUIError, hyValidateCapabilities, hyValidateNode, hyValidateProps, snapshotValidatedProps } from '../core/validation.js';
|
|
2
|
-
import { equalData
|
|
1
|
+
import { HYUIError, hyValidateCapabilities, hyValidateNode, hyValidateProps, snapshotValidatedProps, snapshotProtocolData } from '../core/validation.js';
|
|
2
|
+
import { equalData } from '../core/data.js';
|
|
3
|
+
import { componentInteraction } from '../core/semantics.js';
|
|
3
4
|
import { diff, flatten } from './tree.js';
|
|
4
|
-
const interactive = new Set(['Button', 'Toggle', 'Select', 'Tabs', 'TextInput', 'TextArea', 'Slider', 'PlatformView']);
|
|
5
5
|
/** A synchronous, bounded page reconciler. It owns bindings/rendering, never the application store. */
|
|
6
6
|
export class HYPage {
|
|
7
7
|
options;
|
|
@@ -21,13 +21,15 @@ export class HYPage {
|
|
|
21
21
|
#subscriptions = new Set();
|
|
22
22
|
#focused;
|
|
23
23
|
#boundStores = new Set();
|
|
24
|
+
#frames = [];
|
|
24
25
|
#openers = new Map();
|
|
25
26
|
#cancelTransaction = 0;
|
|
26
27
|
constructor(renderer, options = {}) {
|
|
27
28
|
this.options = options;
|
|
28
|
-
|
|
29
|
+
const capabilities = snapshotProtocolData(renderer.capabilities, { property: 'capabilities' });
|
|
30
|
+
hyValidateCapabilities(capabilities);
|
|
29
31
|
this.#renderer = renderer;
|
|
30
|
-
this.#capabilities =
|
|
32
|
+
this.#capabilities = capabilities;
|
|
31
33
|
}
|
|
32
34
|
get status() { return this.#status; }
|
|
33
35
|
get revision() { return this.#revision; }
|
|
@@ -73,9 +75,12 @@ export class HYPage {
|
|
|
73
75
|
throw new HYUIError('invalid-props', 'Binding target missing or kind changed', { key });
|
|
74
76
|
const context = { key, ...(entry.node.source ? { source: entry.node.source } : {}) };
|
|
75
77
|
const accepted = snapshotValidatedProps(kind, props, context, this.#capabilities);
|
|
76
|
-
if (equalData(entry.node.props,
|
|
78
|
+
if (equalData(entry.node.props, accepted))
|
|
77
79
|
return;
|
|
78
|
-
const
|
|
80
|
+
const frame = this.#frames.at(-1);
|
|
81
|
+
const next = frame?.draft === this.#desired ? frame.draft : new Map(this.#desired);
|
|
82
|
+
if (frame)
|
|
83
|
+
frame.draft = next;
|
|
79
84
|
next.set(key, { ...entry, node: Object.freeze({ ...entry.node, props: accepted }) });
|
|
80
85
|
this.#desired = next;
|
|
81
86
|
this.#updates?.add(key);
|
|
@@ -85,6 +90,7 @@ export class HYPage {
|
|
|
85
90
|
this.#assertMutable();
|
|
86
91
|
const before = this.#desired, updates = this.#updates && new Set(this.#updates);
|
|
87
92
|
this.#depth++;
|
|
93
|
+
this.#frames.push({});
|
|
88
94
|
try {
|
|
89
95
|
const result = run();
|
|
90
96
|
if (result && typeof result.then === 'function')
|
|
@@ -97,7 +103,11 @@ export class HYPage {
|
|
|
97
103
|
}
|
|
98
104
|
finally {
|
|
99
105
|
this.#depth--;
|
|
106
|
+
this.#frames.pop();
|
|
100
107
|
}
|
|
108
|
+
const parent = this.#frames.at(-1);
|
|
109
|
+
if (parent && this.#desired !== before)
|
|
110
|
+
parent.draft = this.#desired;
|
|
101
111
|
this.#flush();
|
|
102
112
|
}
|
|
103
113
|
/** One store subscription: a store transaction produces one final page batch across all bindings. */
|
|
@@ -108,7 +118,7 @@ export class HYPage {
|
|
|
108
118
|
const definitions = [...bindings];
|
|
109
119
|
if (new Set(definitions.map(b => b.key)).size !== definitions.length)
|
|
110
120
|
throw new HYUIError('duplicate-key', 'Duplicate binding target');
|
|
111
|
-
const select = (state) => definitions.map(b => b.select(state));
|
|
121
|
+
const select = (state) => definitions.map(b => snapshotValidatedProps(b.kind, b.select(state), { key: b.key }, this.#capabilities));
|
|
112
122
|
const equal = (a, b) => a.every((p, i) => (definitions[i].equal ?? equalData)(p, b[i]));
|
|
113
123
|
let applied = [];
|
|
114
124
|
const apply = (props) => {
|
|
@@ -119,7 +129,7 @@ export class HYPage {
|
|
|
119
129
|
// A grouped subscription does not make every binding dirty. Reuse a
|
|
120
130
|
// previously validated result only while its target is still unchanged.
|
|
121
131
|
// External render/setProps and failed transactions invalidate this path.
|
|
122
|
-
if (node === applied[i] && node && equalData(node.props, props[i]))
|
|
132
|
+
if (node === applied[i] && node && (binding.equal ?? equalData)(node.props, props[i]))
|
|
123
133
|
return;
|
|
124
134
|
this.setProps(binding.key, binding.kind, props[i]);
|
|
125
135
|
}));
|
|
@@ -217,7 +227,7 @@ export class HYPage {
|
|
|
217
227
|
}
|
|
218
228
|
#inside(key, parent) { return key === parent || key.startsWith(`${parent}/`); }
|
|
219
229
|
#dialogTarget(key) {
|
|
220
|
-
return [...this.#rendered].find(([id, entry]) => this.#inside(id, key) &&
|
|
230
|
+
return [...this.#rendered].find(([id, entry]) => this.#inside(id, key) && componentInteraction[entry.node.kind] && this.#available(id))?.[0] ?? key;
|
|
221
231
|
}
|
|
222
232
|
#restoreFocus(previous) {
|
|
223
233
|
const oldDialogs = this.#dialogs(previous), dialogs = this.#dialogs(this.#rendered);
|
|
@@ -309,17 +319,18 @@ export class HYPage {
|
|
|
309
319
|
throw new HYUIError('lifecycle', 'Only a faulted page may rebuild');
|
|
310
320
|
if (renderer === this.#renderer)
|
|
311
321
|
throw new HYUIError('lifecycle', 'Rebuild needs a fresh renderer');
|
|
312
|
-
|
|
322
|
+
const capabilities = snapshotProtocolData(renderer.capabilities, { property: 'capabilities' });
|
|
323
|
+
hyValidateCapabilities(capabilities);
|
|
313
324
|
for (const [key, entry] of this.#desired) {
|
|
314
|
-
hyValidateProps(entry.node.kind, entry.node.props, { key },
|
|
325
|
+
hyValidateProps(entry.node.kind, entry.node.props, { key }, capabilities);
|
|
315
326
|
for (const feature of entry.node.requires ?? [])
|
|
316
|
-
if (!
|
|
327
|
+
if (!capabilities.features.includes(feature))
|
|
317
328
|
throw new HYUIError('capability', `Missing capability ${feature}`, { key });
|
|
318
329
|
}
|
|
319
330
|
++this.#epoch;
|
|
320
331
|
this.#renderer.dispose();
|
|
321
332
|
this.#renderer = renderer;
|
|
322
|
-
this.#capabilities =
|
|
333
|
+
this.#capabilities = capabilities;
|
|
323
334
|
this.#rendered = new Map();
|
|
324
335
|
this.#updates = undefined;
|
|
325
336
|
this.#order.clear();
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export type HYProgressType = 'line' | 'circle';
|
|
2
|
+
export type HYProgressStatus = 'normal' | 'active' | 'success' | 'exception';
|
|
3
|
+
export declare class HYProgress extends HTMLElement {
|
|
4
|
+
private readonly _meter;
|
|
5
|
+
private readonly _line;
|
|
6
|
+
private readonly _fill;
|
|
7
|
+
private readonly _svg;
|
|
8
|
+
private readonly _circle;
|
|
9
|
+
private readonly _info;
|
|
10
|
+
static get observedAttributes(): string[];
|
|
11
|
+
constructor();
|
|
12
|
+
connectedCallback(): void;
|
|
13
|
+
attributeChangedCallback(): void;
|
|
14
|
+
get percent(): number;
|
|
15
|
+
set percent(value: number);
|
|
16
|
+
get type(): HYProgressType;
|
|
17
|
+
set type(value: HYProgressType);
|
|
18
|
+
get status(): HYProgressStatus;
|
|
19
|
+
set status(value: HYProgressStatus);
|
|
20
|
+
get indeterminate(): boolean;
|
|
21
|
+
set indeterminate(value: boolean);
|
|
22
|
+
get showInfo(): boolean;
|
|
23
|
+
set showInfo(value: boolean);
|
|
24
|
+
get strokeWidth(): number;
|
|
25
|
+
set strokeWidth(value: number);
|
|
26
|
+
get size(): number;
|
|
27
|
+
set size(value: number);
|
|
28
|
+
private _sync;
|
|
29
|
+
}
|
|
30
|
+
export declare function defineProgressComponents(): void;
|
package/dist/progress.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
export class HYProgress extends HTMLElement {
|
|
2
|
+
_meter = document.createElement('div');
|
|
3
|
+
_line = document.createElement('div');
|
|
4
|
+
_fill = document.createElement('div');
|
|
5
|
+
_svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
6
|
+
_circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle');
|
|
7
|
+
_info = document.createElement('span');
|
|
8
|
+
static get observedAttributes() { return ['percent', 'type', 'status', 'indeterminate', 'show-info', 'stroke-width', 'size', 'aria-label']; }
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
const root = this.attachShadow({ mode: 'open' });
|
|
12
|
+
const style = document.createElement('style');
|
|
13
|
+
style.textContent = `
|
|
14
|
+
:host { display: block; min-width: 0; color: var(--hy-text-color, #d8e2f2); font: var(--hy-font-size-sm, 12px)/1.5 var(--hy-font-family, system-ui, sans-serif); }
|
|
15
|
+
.meter { --_color: var(--hy-progress-color, var(--hy-accent-color, #8177f2)); display: flex; align-items: center; gap: var(--hy-space-4, 8px); }
|
|
16
|
+
.meter.success { --_color: var(--hy-success-color, #3ea67a); } .meter.exception { --_color: var(--hy-error-color, #d95d72); }
|
|
17
|
+
.line { flex: 1; overflow: hidden; height: var(--_stroke, 6px); border-radius: 999px; background: var(--hy-progress-trail-color, var(--hy-border-color, #303746)); }
|
|
18
|
+
.fill { height: 100%; border-radius: inherit; background: var(--_color); transition: width 150ms ease; }
|
|
19
|
+
.active .fill { background-image: linear-gradient(90deg, transparent, color-mix(in srgb, var(--hy-selected-text-color, #fff) 35%, transparent), transparent); background-size: 200% 100%; animation: hy-progress-active 1.5s linear infinite; }
|
|
20
|
+
.indeterminate .fill { width: 35% !important; animation: hy-progress-unknown 1.3s ease-in-out infinite; }
|
|
21
|
+
svg { display: block; width: var(--_size, 96px); height: var(--_size, 96px); transform: rotate(-90deg); }
|
|
22
|
+
circle { fill: none; stroke-width: var(--_circle-stroke, 6); } .trail { stroke: var(--hy-progress-trail-color, var(--hy-border-color, #303746)); }
|
|
23
|
+
.arc { stroke: var(--_color); stroke-linecap: round; transition: stroke-dashoffset 150ms ease; }
|
|
24
|
+
.circle { position: relative; display: inline-grid; place-items: center; } .circle .info { position: absolute; max-width: 80%; text-align: center; }
|
|
25
|
+
.circle.indeterminate svg { animation: hy-progress-rotate 1s linear infinite; }
|
|
26
|
+
[hidden] { display: none !important; } .info { flex: 0 0 auto; }
|
|
27
|
+
@keyframes hy-progress-active { to { background-position: -200% 0; } }
|
|
28
|
+
@keyframes hy-progress-unknown { from { transform: translateX(-100%); } to { transform: translateX(385%); } }
|
|
29
|
+
@keyframes hy-progress-rotate { to { transform: rotate(270deg); } }
|
|
30
|
+
@media (prefers-reduced-motion: reduce) { .fill, .arc { transition: none; } .active .fill, .indeterminate .fill, .circle.indeterminate svg { animation: none; } }
|
|
31
|
+
`;
|
|
32
|
+
this._meter.className = 'meter';
|
|
33
|
+
this._meter.part.add('meter');
|
|
34
|
+
this._meter.setAttribute('role', 'progressbar');
|
|
35
|
+
this._line.className = 'line';
|
|
36
|
+
this._line.part.add('trail');
|
|
37
|
+
this._fill.className = 'fill';
|
|
38
|
+
this._fill.part.add('fill');
|
|
39
|
+
this._line.append(this._fill);
|
|
40
|
+
this._svg.setAttribute('viewBox', '0 0 100 100');
|
|
41
|
+
this._svg.setAttribute('aria-hidden', 'true');
|
|
42
|
+
this._svg.part.add('circle');
|
|
43
|
+
const trail = this._circle.cloneNode();
|
|
44
|
+
for (const circle of [trail, this._circle]) {
|
|
45
|
+
circle.setAttribute('cx', '50');
|
|
46
|
+
circle.setAttribute('cy', '50');
|
|
47
|
+
circle.setAttribute('r', '44');
|
|
48
|
+
circle.setAttribute('pathLength', '100');
|
|
49
|
+
}
|
|
50
|
+
trail.classList.add('trail');
|
|
51
|
+
this._circle.classList.add('arc');
|
|
52
|
+
this._circle.setAttribute('stroke-dasharray', '100');
|
|
53
|
+
this._svg.append(trail, this._circle);
|
|
54
|
+
this._info.className = 'info';
|
|
55
|
+
this._info.part.add('info');
|
|
56
|
+
this._meter.append(this._line, this._svg, this._info);
|
|
57
|
+
root.append(style, this._meter);
|
|
58
|
+
}
|
|
59
|
+
connectedCallback() { this._sync(); }
|
|
60
|
+
attributeChangedCallback() { this._sync(); }
|
|
61
|
+
get percent() { return boundedNumber(this.getAttribute('percent'), 0, 100, 0); }
|
|
62
|
+
set percent(value) { this.setAttribute('percent', String(value)); }
|
|
63
|
+
get type() { return this.getAttribute('type') === 'circle' ? 'circle' : 'line'; }
|
|
64
|
+
set type(value) { this.setAttribute('type', value); }
|
|
65
|
+
get status() { const value = this.getAttribute('status'); return value === 'active' || value === 'success' || value === 'exception' ? value : 'normal'; }
|
|
66
|
+
set status(value) { this.setAttribute('status', value); }
|
|
67
|
+
get indeterminate() { return this.hasAttribute('indeterminate'); }
|
|
68
|
+
set indeterminate(value) { this.toggleAttribute('indeterminate', value); }
|
|
69
|
+
get showInfo() { return this.getAttribute('show-info') !== 'false'; }
|
|
70
|
+
set showInfo(value) { this.setAttribute('show-info', String(value)); }
|
|
71
|
+
get strokeWidth() { return boundedNumber(this.getAttribute('stroke-width'), 1, 20, 6); }
|
|
72
|
+
set strokeWidth(value) { this.setAttribute('stroke-width', String(value)); }
|
|
73
|
+
get size() { return boundedNumber(this.getAttribute('size'), 24, 1000, 96); }
|
|
74
|
+
set size(value) { this.setAttribute('size', String(value)); }
|
|
75
|
+
_sync() {
|
|
76
|
+
const circle = this.type === 'circle';
|
|
77
|
+
this._meter.className = `meter ${this.status}${circle ? ' circle' : ''}${this.indeterminate ? ' indeterminate' : ''}`;
|
|
78
|
+
this._meter.setAttribute('aria-valuemin', '0');
|
|
79
|
+
this._meter.setAttribute('aria-valuemax', '100');
|
|
80
|
+
if (this.indeterminate)
|
|
81
|
+
this._meter.removeAttribute('aria-valuenow');
|
|
82
|
+
else
|
|
83
|
+
this._meter.setAttribute('aria-valuenow', String(this.percent));
|
|
84
|
+
this._meter.setAttribute('aria-label', this.getAttribute('aria-label') || 'Progress');
|
|
85
|
+
this._meter.setAttribute('aria-valuetext', this.indeterminate ? 'In progress' : `${this.percent}%${this.status === 'exception' ? ' Failed' : this.status === 'success' ? ' Complete' : ''}`);
|
|
86
|
+
this._meter.style.setProperty('--_stroke', `${this.strokeWidth}px`);
|
|
87
|
+
this._meter.style.setProperty('--_circle-stroke', String(this.strokeWidth));
|
|
88
|
+
this._meter.style.setProperty('--_size', `${this.size}px`);
|
|
89
|
+
this._line.hidden = circle;
|
|
90
|
+
this._svg.style.display = circle ? '' : 'none';
|
|
91
|
+
this._fill.style.width = `${this.percent}%`;
|
|
92
|
+
this._circle.setAttribute('r', String(50 - this.strokeWidth / 2 - 1));
|
|
93
|
+
this._svg.querySelector('.trail')?.setAttribute('r', String(50 - this.strokeWidth / 2 - 1));
|
|
94
|
+
this._circle.setAttribute('stroke-dashoffset', String(this.indeterminate ? 65 : 100 - this.percent));
|
|
95
|
+
this._info.hidden = !this.showInfo;
|
|
96
|
+
this._info.textContent = this.indeterminate ? '…' : `${this.percent}%`;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function boundedNumber(raw, min, max, fallback) { const value = raw === null ? NaN : Number(raw); return Number.isFinite(value) ? Math.min(max, Math.max(min, value)) : fallback; }
|
|
100
|
+
export function defineProgressComponents() { if (!customElements.get('hy-progress'))
|
|
101
|
+
customElements.define('hy-progress', HYProgress); }
|
|
102
|
+
//# sourceMappingURL=progress.js.map
|
package/dist/qr-code.js
CHANGED
|
@@ -31,15 +31,15 @@ export class HYQRCode extends HTMLElement {
|
|
|
31
31
|
const root = this.attachShadow({ mode: 'open' });
|
|
32
32
|
const style = document.createElement('style');
|
|
33
33
|
style.textContent = `
|
|
34
|
-
:host { display: inline-block; max-width: 100%; vertical-align: middle; color: var(--hy-text-color, #eef0ff); font: 12px/1.5 system-ui, sans-serif; }
|
|
34
|
+
:host { display: inline-block; max-width: 100%; vertical-align: middle; color: var(--hy-text-color, #eef0ff); font: var(--hy-font-size-sm, 12px)/var(--hy-line-height-relaxed, 1.5) var(--hy-font-family, system-ui, sans-serif); }
|
|
35
35
|
:host([hidden]), [hidden] { display: none !important; }
|
|
36
36
|
.frame { position: relative; box-sizing: border-box; max-width: 100%; aspect-ratio: 1; }
|
|
37
37
|
svg { display: block; width: 100%; height: 100%; }
|
|
38
|
-
.icon { position: absolute; box-sizing: border-box; inset: 50% auto auto 50%; transform: translate(-50%, -50%); display: grid; place-items: center; background: var(--_qr-background); border-radius: var(--hy-qr-code-icon-radius, 4px); pointer-events: none; overflow: hidden; }
|
|
38
|
+
.icon { position: absolute; box-sizing: border-box; inset: 50% auto auto 50%; transform: translate(-50%, -50%); display: grid; place-items: center; background: var(--_qr-background); border-radius: var(--hy-qr-code-icon-radius, var(--hy-radius-sm, 4px)); pointer-events: none; overflow: hidden; }
|
|
39
39
|
img { display: block; width: 100%; height: 100%; min-width: 0; min-height: 0; object-fit: contain; }
|
|
40
40
|
slot { display: contents; }
|
|
41
41
|
::slotted([slot="icon"]) { display: block; box-sizing: border-box; width: 100%; height: 100%; min-width: 0; min-height: 0; object-fit: contain; overflow: hidden; }
|
|
42
|
-
.message { position: absolute; inset: 0; display: grid; place-items: center; box-sizing: border-box; padding: 12px; text-align: center; color: var(--hy-secondary-text-color, #a9add4); background: var(--hy-surface-color, #10132f); border: 1px solid var(--hy-border-color, #343765); border-radius: var(--hy-qr-code-radius, 8px); }
|
|
42
|
+
.message { position: absolute; inset: 0; display: grid; place-items: center; box-sizing: border-box; padding: var(--hy-space-6, 12px); text-align: center; color: var(--hy-secondary-text-color, #a9add4); background: var(--hy-surface-color, #10132f); border: 1px solid var(--hy-border-color, #343765); border-radius: var(--hy-qr-code-radius, var(--hy-radius-lg, 8px)); }
|
|
43
43
|
`;
|
|
44
44
|
this._frame.className = 'frame';
|
|
45
45
|
this._frame.part.add('frame');
|
package/dist/radio.d.ts
CHANGED
|
@@ -4,10 +4,12 @@ export interface HYRadioChangeDetail {
|
|
|
4
4
|
name: string;
|
|
5
5
|
}
|
|
6
6
|
export declare class HYRadio extends HTMLElement {
|
|
7
|
+
static readonly formAssociated = true;
|
|
7
8
|
private readonly _input;
|
|
8
9
|
private readonly _marker;
|
|
9
10
|
private readonly _label;
|
|
10
11
|
private readonly _slot;
|
|
12
|
+
private readonly _formControl;
|
|
11
13
|
static get observedAttributes(): string[];
|
|
12
14
|
constructor();
|
|
13
15
|
connectedCallback(): void;
|
|
@@ -24,6 +26,14 @@ export declare class HYRadio extends HTMLElement {
|
|
|
24
26
|
get name(): string;
|
|
25
27
|
set name(value: string);
|
|
26
28
|
private _sync;
|
|
29
|
+
get form(): HTMLFormElement | null;
|
|
30
|
+
checkValidity(): boolean;
|
|
31
|
+
reportValidity(): boolean;
|
|
32
|
+
setCustomValidity(message: string): void;
|
|
33
|
+
formDisabledCallback(disabled: boolean): void;
|
|
34
|
+
formResetCallback(): void;
|
|
35
|
+
formStateRestoreCallback(state: string | File | FormData | null): void;
|
|
36
|
+
focus(options?: FocusOptions): void;
|
|
27
37
|
private _onChange;
|
|
28
38
|
private _uncheckNamedPeers;
|
|
29
39
|
}
|
package/dist/radio.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { HYFormControl } from './internal/form-control.js';
|
|
1
2
|
export class HYRadio extends HTMLElement {
|
|
3
|
+
static formAssociated = true;
|
|
2
4
|
_input = document.createElement('input');
|
|
3
5
|
_marker = document.createElement('span');
|
|
4
6
|
_label = document.createElement('span');
|
|
5
7
|
_slot = document.createElement('slot');
|
|
8
|
+
_formControl = new HYFormControl(this, this._input);
|
|
6
9
|
static get observedAttributes() {
|
|
7
10
|
return ['checked', 'disabled', 'label', 'value', 'name', 'aria-label'];
|
|
8
11
|
}
|
|
@@ -16,7 +19,7 @@ export class HYRadio extends HTMLElement {
|
|
|
16
19
|
width: max-content;
|
|
17
20
|
min-width: 0;
|
|
18
21
|
color: var(--hy-radio-text-color, var(--hy-text-color, #d8e2f2));
|
|
19
|
-
font: 12px system-ui, sans-serif;
|
|
22
|
+
font: var(--hy-font-size-sm, 12px) var(--hy-font-family, system-ui, sans-serif);
|
|
20
23
|
}
|
|
21
24
|
:host([disabled]) {
|
|
22
25
|
opacity: 0.55;
|
|
@@ -25,7 +28,7 @@ export class HYRadio extends HTMLElement {
|
|
|
25
28
|
label {
|
|
26
29
|
display: inline-flex;
|
|
27
30
|
align-items: center;
|
|
28
|
-
gap: 8px;
|
|
31
|
+
gap: var(--hy-space-4, 8px);
|
|
29
32
|
min-width: 0;
|
|
30
33
|
cursor: pointer;
|
|
31
34
|
user-select: none;
|
|
@@ -96,6 +99,7 @@ export class HYRadio extends HTMLElement {
|
|
|
96
99
|
connectedCallback() {
|
|
97
100
|
this._input.addEventListener('change', this._onChange);
|
|
98
101
|
this._sync();
|
|
102
|
+
this._formControl.connect();
|
|
99
103
|
if (this.checked)
|
|
100
104
|
this._uncheckNamedPeers();
|
|
101
105
|
}
|
|
@@ -152,7 +156,7 @@ export class HYRadio extends HTMLElement {
|
|
|
152
156
|
}
|
|
153
157
|
_sync() {
|
|
154
158
|
this._input.checked = this.checked;
|
|
155
|
-
this._input.disabled = this.disabled;
|
|
159
|
+
this._input.disabled = this.disabled || this._formControl.disabled;
|
|
156
160
|
this._input.value = this.value;
|
|
157
161
|
this._input.name = this.name;
|
|
158
162
|
const label = this.getAttribute('label');
|
|
@@ -165,7 +169,16 @@ export class HYRadio extends HTMLElement {
|
|
|
165
169
|
this._input.setAttribute('aria-label', ariaLabel);
|
|
166
170
|
else
|
|
167
171
|
this._input.removeAttribute('aria-label');
|
|
168
|
-
|
|
172
|
+
this._formControl.sync();
|
|
173
|
+
}
|
|
174
|
+
get form() { return this._formControl.internals.form; }
|
|
175
|
+
checkValidity() { return this._formControl.internals.checkValidity(); }
|
|
176
|
+
reportValidity() { return this._formControl.internals.reportValidity(); }
|
|
177
|
+
setCustomValidity(message) { this._formControl.setCustomValidity(message); }
|
|
178
|
+
formDisabledCallback(disabled) { this._formControl.disabled = disabled; this._sync(); }
|
|
179
|
+
formResetCallback() { this._formControl.reset(); }
|
|
180
|
+
formStateRestoreCallback(state) { this._formControl.restore(state); }
|
|
181
|
+
focus(options) { this._input.focus(options); }
|
|
169
182
|
_onChange = () => {
|
|
170
183
|
if (!this._input.checked)
|
|
171
184
|
return;
|
|
@@ -186,7 +199,7 @@ export class HYRadio extends HTMLElement {
|
|
|
186
199
|
? root.querySelectorAll(`hy-radio[name="${cssEscape(this.name)}"]`)
|
|
187
200
|
: [];
|
|
188
201
|
for (const peer of peers) {
|
|
189
|
-
if (peer === this || peer.
|
|
202
|
+
if (peer === this || peer.form !== this.form)
|
|
190
203
|
continue;
|
|
191
204
|
peer.removeAttribute('checked');
|
|
192
205
|
}
|
package/dist/range.js
CHANGED
|
@@ -30,7 +30,7 @@ export class HYRange extends HTMLElement {
|
|
|
30
30
|
width: var(--hy-range-width, 280px);
|
|
31
31
|
min-width: 120px;
|
|
32
32
|
color: var(--hy-text-color, #e8effa);
|
|
33
|
-
font:
|
|
33
|
+
font: calc(var(--hy-font-size-xs, 10px) + 1px)/calc(var(--hy-line-height-snug, 1.4) - 0.1) var(--hy-font-family, system-ui, sans-serif);
|
|
34
34
|
--_handle-size: var(--hy-range-handle-size, 18px);
|
|
35
35
|
--_rail-height: var(--hy-range-rail-height, 5px);
|
|
36
36
|
}
|
|
@@ -49,7 +49,7 @@ export class HYRange extends HTMLElement {
|
|
|
49
49
|
right: 0;
|
|
50
50
|
left: 0;
|
|
51
51
|
height: var(--_rail-height);
|
|
52
|
-
border-radius: var(--hy-range-rail-radius, 999px);
|
|
52
|
+
border-radius: var(--hy-range-rail-radius, var(--hy-radius-full, 999px));
|
|
53
53
|
transform: translateY(-50%);
|
|
54
54
|
}
|
|
55
55
|
.rail {
|
|
@@ -76,7 +76,7 @@ export class HYRange extends HTMLElement {
|
|
|
76
76
|
outline: none;
|
|
77
77
|
color: var(--hy-text-color, #e8effa);
|
|
78
78
|
background: var(--hy-range-handle-color, var(--hy-surface-elevated-color, #171e2a));
|
|
79
|
-
box-shadow: var(--hy-range-handle-shadow, 0 2px 8px rgba(0, 0, 0, 0.28));
|
|
79
|
+
box-shadow: var(--hy-range-handle-shadow, 0 2px 8px var(--hy-shadow-color, rgba(0, 0, 0, 0.28)));
|
|
80
80
|
cursor: grab;
|
|
81
81
|
transform: translate(-50%, -50%);
|
|
82
82
|
transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
|
|
@@ -97,14 +97,14 @@ export class HYRange extends HTMLElement {
|
|
|
97
97
|
bottom: calc(100% + 8px);
|
|
98
98
|
display: none;
|
|
99
99
|
min-width: 24px;
|
|
100
|
-
padding:
|
|
100
|
+
padding: calc(var(--hy-space-1, 2px) + 1px) var(--hy-space-3, 6px);
|
|
101
101
|
border: 1px solid var(--hy-border-color, #303746);
|
|
102
|
-
border-radius: 4px;
|
|
102
|
+
border-radius: var(--hy-radius-sm, 4px);
|
|
103
103
|
pointer-events: none;
|
|
104
104
|
color: var(--hy-text-color, #e8effa);
|
|
105
105
|
background: var(--hy-surface-elevated-color, #171e2a);
|
|
106
|
-
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
|
|
107
|
-
font: 10px/1.2 ui-monospace, monospace;
|
|
106
|
+
box-shadow: 0 4px 12px var(--hy-shadow-color, rgba(0, 0, 0, 0.22));
|
|
107
|
+
font: var(--hy-font-size-xs, 10px)/var(--hy-line-height-compact, 1.2) var(--hy-font-family-mono, ui-monospace, monospace);
|
|
108
108
|
white-space: nowrap;
|
|
109
109
|
}
|
|
110
110
|
:host([show-value]) .bubble { display: block; }
|
package/dist/rate.js
CHANGED
|
@@ -19,10 +19,10 @@ export class HYRate extends HTMLElement {
|
|
|
19
19
|
const root = this.attachShadow({ mode: 'open' });
|
|
20
20
|
const style = document.createElement('style');
|
|
21
21
|
style.textContent = `
|
|
22
|
-
:host { display: inline-block; color: var(--hy-text-color, #eef3ff); font: 12px/1 system-ui, sans-serif; }
|
|
23
|
-
.group { display: inline-flex; align-items: center; gap: var(--hy-rate-gap,
|
|
22
|
+
:host { display: inline-block; color: var(--hy-text-color, #eef3ff); font: var(--hy-font-size-sm, 12px)/var(--hy-line-height-tight, 1) var(--hy-font-family, system-ui, sans-serif); }
|
|
23
|
+
.group { display: inline-flex; align-items: center; gap: var(--hy-rate-gap, calc(var(--hy-space-2, 4px) + 1px)); border-radius: var(--hy-rate-focus-radius, calc(var(--hy-radius-sm, 4px) + 1px)); }
|
|
24
24
|
.group:focus-visible { outline: 2px solid var(--hy-focus-border-color, #79a8ff); outline-offset: 3px; }
|
|
25
|
-
.star { position: relative; width: 1em; height: 1em; padding: 0; overflow: hidden; border: 0; color: inherit; background: transparent; cursor: pointer; font: var(--hy-rate-font-size,
|
|
25
|
+
.star { position: relative; width: 1em; height: 1em; padding: 0; overflow: hidden; border: 0; color: inherit; background: transparent; cursor: pointer; font: var(--hy-rate-font-size, calc(var(--hy-font-size-2xl, 24px) + 1px))/var(--hy-line-height-tight, 1) var(--hy-font-family, system-ui, sans-serif); transition: transform 120ms ease; }
|
|
26
26
|
.star:hover { transform: scale(1.12); }
|
|
27
27
|
.empty, .fill-inner { display: block; width: 1em; height: 1em; }
|
|
28
28
|
.empty { color: var(--hy-rate-empty-color, color-mix(in srgb, var(--hy-text-color, #eef3ff) 16%, transparent)); }
|
package/dist/resizable.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isKeyboardControlEvent } from './internal/keyboard.js';
|
|
1
2
|
const HANDLES = ['n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw'];
|
|
2
3
|
const DEFAULT_CANCEL = 'input, textarea, select, button, a, [contenteditable="true"], [data-no-move]';
|
|
3
4
|
function finiteNumber(value, fallback) {
|
|
@@ -65,12 +66,12 @@ export class HYResizable extends HTMLElement {
|
|
|
65
66
|
z-index: 2;
|
|
66
67
|
inset: 0;
|
|
67
68
|
border: var(--hy-resizable-border-width, 1px) var(--hy-resizable-border-style, solid) var(--hy-resizable-border-color, var(--hy-accent-color, #79a8ff));
|
|
68
|
-
border-radius: var(--hy-resizable-radius,
|
|
69
|
+
border-radius: var(--hy-resizable-radius, calc(var(--hy-radius-sm, 4px) + 1px));
|
|
69
70
|
pointer-events: none;
|
|
70
71
|
content: '';
|
|
71
72
|
}
|
|
72
73
|
.frame:focus-visible { outline: 2px solid var(--hy-focus-border-color, #79a8ff); outline-offset: 3px; }
|
|
73
|
-
.content { width: 100%; height: 100%; overflow: var(--hy-resizable-content-overflow, hidden); border-radius: var(--hy-resizable-radius,
|
|
74
|
+
.content { width: 100%; height: 100%; overflow: var(--hy-resizable-content-overflow, hidden); border-radius: var(--hy-resizable-radius, calc(var(--hy-radius-sm, 4px) + 1px)); }
|
|
74
75
|
:host(:not([disabled])) .content { cursor: var(--hy-resizable-move-cursor, move); }
|
|
75
76
|
:host([movable="false"]) .content, :host([disabled]) .content { cursor: default; }
|
|
76
77
|
.handle { position: absolute; z-index: 3; box-sizing: border-box; touch-action: none; outline: none; }
|
|
@@ -97,9 +98,9 @@ export class HYResizable extends HTMLElement {
|
|
|
97
98
|
height: var(--hy-resizable-corner-size, 10px);
|
|
98
99
|
box-sizing: border-box;
|
|
99
100
|
border: 1px solid var(--hy-resizable-handle-border-color, #dbeeff);
|
|
100
|
-
border-radius: var(--hy-resizable-handle-radius, 2px);
|
|
101
|
+
border-radius: var(--hy-resizable-handle-radius, var(--hy-radius-xs, 2px));
|
|
101
102
|
background: var(--hy-resizable-handle-color, var(--hy-accent-color, #79a8ff));
|
|
102
|
-
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.28);
|
|
103
|
+
box-shadow: 0 1px 4px var(--hy-shadow-color, rgba(0, 0, 0, 0.28));
|
|
103
104
|
content: '';
|
|
104
105
|
}
|
|
105
106
|
.handle.n::after, .handle.s::after { left: 50%; top: 50%; translate: -50% -50%; }
|
|
@@ -257,9 +258,11 @@ export class HYResizable extends HTMLElement {
|
|
|
257
258
|
this._finishPointer(this._pointerId, cancelled);
|
|
258
259
|
}
|
|
259
260
|
_handleKeydown(event) {
|
|
260
|
-
if (this.disabled || !this.keyboard)
|
|
261
|
+
if (this.disabled || !this.keyboard || event.defaultPrevented || isKeyboardControlEvent(event, this._frame))
|
|
261
262
|
return;
|
|
262
263
|
const handle = event.composedPath().find((node) => node instanceof HTMLElement && Boolean(node.dataset.resizeHandle))?.dataset.resizeHandle ?? 'move';
|
|
264
|
+
if (handle === 'move' && !this.movable)
|
|
265
|
+
return;
|
|
263
266
|
const step = this.grid * (event.shiftKey ? 10 : 1);
|
|
264
267
|
let deltaX = 0;
|
|
265
268
|
let deltaY = 0;
|
package/dist/result.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type HYResultStatus = 'success' | 'info' | 'warning' | 'error' | '403' | '404' | '500';
|
|
2
|
+
/** Outcome page with semantic status, details and custom actions. */
|
|
3
|
+
export declare class HYResult extends HTMLElement {
|
|
4
|
+
private readonly _surface;
|
|
5
|
+
private readonly _icon;
|
|
6
|
+
private readonly _heading;
|
|
7
|
+
private readonly _description;
|
|
8
|
+
private readonly _content;
|
|
9
|
+
private readonly _extra;
|
|
10
|
+
static get observedAttributes(): string[];
|
|
11
|
+
constructor();
|
|
12
|
+
connectedCallback(): void;
|
|
13
|
+
attributeChangedCallback(): void;
|
|
14
|
+
get status(): HYResultStatus;
|
|
15
|
+
set status(value: HYResultStatus);
|
|
16
|
+
get heading(): string;
|
|
17
|
+
set heading(value: string);
|
|
18
|
+
get description(): string;
|
|
19
|
+
set description(value: string);
|
|
20
|
+
private _render;
|
|
21
|
+
}
|
|
22
|
+
export declare function defineResultComponents(): void;
|
package/dist/result.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { hasSlotContent, presentationIcon } from './internal/presentation.js';
|
|
2
|
+
const headings = { success: 'Completed', info: 'Information', warning: 'Please check', error: 'Something went wrong', '403': '403', '404': '404', '500': '500' };
|
|
3
|
+
/** Outcome page with semantic status, details and custom actions. */
|
|
4
|
+
export class HYResult extends HTMLElement {
|
|
5
|
+
_surface = document.createElement('section');
|
|
6
|
+
_icon = document.createElement('slot');
|
|
7
|
+
_heading = document.createElement('slot');
|
|
8
|
+
_description = document.createElement('slot');
|
|
9
|
+
_content = document.createElement('slot');
|
|
10
|
+
_extra = document.createElement('slot');
|
|
11
|
+
static get observedAttributes() { return ['status', 'heading', 'description', 'aria-label']; }
|
|
12
|
+
constructor() {
|
|
13
|
+
super();
|
|
14
|
+
const root = this.attachShadow({ mode: 'open' });
|
|
15
|
+
const style = document.createElement('style');
|
|
16
|
+
style.textContent = `
|
|
17
|
+
:host { display: block; min-width: 0; color: var(--hy-text-color, #eef0ff); font: var(--hy-font-size-sm, 12px)/var(--hy-line-height-relaxed, 1.5) var(--hy-font-family, system-ui, sans-serif); }
|
|
18
|
+
.result { display: flex; align-items: center; flex-direction: column; gap: var(--hy-space-6, 12px); padding: var(--hy-result-padding, var(--hy-space-16, 32px) var(--hy-space-10, 20px)); text-align: center; overflow-wrap: anywhere; }
|
|
19
|
+
.icon { display: block; width: var(--hy-result-icon-size, 64px); max-width: 100%; color: var(--hy-result-status-color, var(--hy-info-color, #55b4da)); }
|
|
20
|
+
.icon svg, .icon::slotted(*) { display: block; width: 100%; height: auto; }
|
|
21
|
+
.icon.code { width: auto; font-size: var(--hy-result-code-size, 64px); font-weight: var(--hy-font-weight-bold, 700); line-height: var(--hy-line-height-compact, 1.2); }
|
|
22
|
+
.success { --hy-result-status-color: var(--hy-success-color, #51b88b); } .warning { --hy-result-status-color: var(--hy-warning-color, #e1b952); } .error { --hy-result-status-color: var(--hy-error-color, #e47689); }
|
|
23
|
+
h2 { max-width: 100%; margin: 0; font-size: var(--hy-font-size-2xl, 24px); font-weight: var(--hy-font-weight-semibold, 600); }
|
|
24
|
+
.description { display: block; max-width: 64ch; color: var(--hy-secondary-text-color, #a9add4); }
|
|
25
|
+
.content { display: block; width: 100%; box-sizing: border-box; padding: var(--hy-space-8, 16px); border-radius: var(--hy-radius-md, 6px); color: var(--hy-secondary-text-color, #a9add4); background: var(--hy-surface-color, #10132f); text-align: start; }
|
|
26
|
+
.extra { display: flex; justify-content: center; flex-wrap: wrap; gap: var(--hy-space-4, 8px); max-width: 100%; }
|
|
27
|
+
[hidden] { display: none !important; }
|
|
28
|
+
`;
|
|
29
|
+
this._surface.className = 'result';
|
|
30
|
+
this._surface.part.add('result');
|
|
31
|
+
this._surface.setAttribute('aria-labelledby', 'result-heading');
|
|
32
|
+
this._icon.name = 'icon';
|
|
33
|
+
this._icon.className = 'icon';
|
|
34
|
+
this._icon.part.add('icon');
|
|
35
|
+
this._icon.setAttribute('aria-hidden', 'true');
|
|
36
|
+
const heading = document.createElement('h2');
|
|
37
|
+
heading.id = 'result-heading';
|
|
38
|
+
heading.part.add('heading');
|
|
39
|
+
this._heading.name = 'heading';
|
|
40
|
+
heading.append(this._heading);
|
|
41
|
+
this._description.name = 'description';
|
|
42
|
+
this._description.className = 'description';
|
|
43
|
+
this._description.part.add('description');
|
|
44
|
+
this._content.className = 'content';
|
|
45
|
+
this._content.part.add('content');
|
|
46
|
+
this._extra.name = 'extra';
|
|
47
|
+
this._extra.className = 'extra';
|
|
48
|
+
this._extra.part.add('extra');
|
|
49
|
+
this._surface.append(this._icon, heading, this._description, this._content, this._extra);
|
|
50
|
+
root.append(style, this._surface);
|
|
51
|
+
for (const slot of [this._description, this._content, this._extra])
|
|
52
|
+
slot.addEventListener('slotchange', this._render);
|
|
53
|
+
}
|
|
54
|
+
connectedCallback() { this._render(); }
|
|
55
|
+
attributeChangedCallback() { this._render(); }
|
|
56
|
+
get status() { const value = this.getAttribute('status'); return Object.hasOwn(headings, value) ? value : 'info'; }
|
|
57
|
+
set status(value) { this.setAttribute('status', value); }
|
|
58
|
+
get heading() { return this.getAttribute('heading') ?? headings[this.status]; }
|
|
59
|
+
set heading(value) { this.setAttribute('heading', value); }
|
|
60
|
+
get description() { return this.getAttribute('description') ?? ''; }
|
|
61
|
+
set description(value) { this.setAttribute('description', value); }
|
|
62
|
+
_render = () => {
|
|
63
|
+
const status = this.status;
|
|
64
|
+
const code = /^\d/.test(status);
|
|
65
|
+
this._surface.className = `result ${code ? 'info' : status}`;
|
|
66
|
+
this._icon.className = code ? 'icon code' : 'icon';
|
|
67
|
+
this._icon.replaceChildren(code ? document.createTextNode(status) : presentationIcon(status));
|
|
68
|
+
if (this._heading.textContent !== this.heading)
|
|
69
|
+
this._heading.textContent = this.heading;
|
|
70
|
+
if (this._description.textContent !== this.description)
|
|
71
|
+
this._description.textContent = this.description;
|
|
72
|
+
this._description.hidden = !this.description && !hasSlotContent(this._description);
|
|
73
|
+
this._content.hidden = !hasSlotContent(this._content);
|
|
74
|
+
this._extra.hidden = !hasSlotContent(this._extra);
|
|
75
|
+
const label = this.getAttribute('aria-label');
|
|
76
|
+
if (label) {
|
|
77
|
+
this._surface.setAttribute('aria-label', label);
|
|
78
|
+
this._surface.removeAttribute('aria-labelledby');
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
this._surface.removeAttribute('aria-label');
|
|
82
|
+
this._surface.setAttribute('aria-labelledby', 'result-heading');
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
export function defineResultComponents() { if (!customElements.get('hy-result'))
|
|
87
|
+
customElements.define('hy-result', HYResult); }
|
|
88
|
+
//# sourceMappingURL=result.js.map
|
package/dist/ribbon.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type HYRibbonPlacement = 'start' | 'end';
|
|
2
|
+
/** Folded ribbon decorating content in the default slot. */
|
|
3
|
+
export declare class HYRibbon extends HTMLElement {
|
|
4
|
+
private readonly _ribbon;
|
|
5
|
+
private readonly _text;
|
|
6
|
+
private readonly _fallback;
|
|
7
|
+
static get observedAttributes(): string[];
|
|
8
|
+
constructor();
|
|
9
|
+
connectedCallback(): void;
|
|
10
|
+
attributeChangedCallback(): void;
|
|
11
|
+
get text(): string;
|
|
12
|
+
set text(value: string);
|
|
13
|
+
get color(): string;
|
|
14
|
+
set color(value: string);
|
|
15
|
+
get placement(): HYRibbonPlacement;
|
|
16
|
+
set placement(value: HYRibbonPlacement);
|
|
17
|
+
private _render;
|
|
18
|
+
}
|
|
19
|
+
export declare function defineRibbonComponents(): void;
|