@haiyue/ui 0.1.0 → 0.1.2
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 +29 -0
- package/LICENSE +1 -1
- package/README.md +226 -2
- package/dist/border-beam.d.ts +26 -0
- package/dist/border-beam.js +174 -0
- package/dist/button.d.ts +10 -0
- package/dist/button.js +85 -0
- package/dist/checkbox.d.ts +2 -2
- package/dist/checkbox.js +11 -11
- package/dist/context-menu.d.ts +6 -6
- package/dist/context-menu.js +11 -9
- package/dist/dialog.d.ts +5 -5
- package/dist/dialog.js +18 -18
- package/dist/drawer.d.ts +49 -0
- package/dist/drawer.js +377 -0
- package/dist/dropdown.d.ts +9 -9
- package/dist/dropdown.js +9 -9
- package/dist/expandable.d.ts +32 -0
- package/dist/expandable.js +136 -0
- package/dist/history-controls.d.ts +40 -0
- package/dist/history-controls.js +123 -0
- package/dist/index.d.ts +36 -31
- package/dist/index.js +35 -85
- package/dist/input.d.ts +5 -5
- package/dist/input.js +13 -13
- package/dist/menu-shared.d.ts +4 -4
- package/dist/menu-shared.js +4 -4
- package/dist/notification.d.ts +55 -0
- package/dist/notification.js +357 -0
- package/dist/radio.d.ts +2 -2
- package/dist/radio.js +12 -12
- package/dist/range.d.ts +74 -0
- package/dist/range.js +393 -0
- package/dist/select.d.ts +6 -6
- package/dist/select.js +20 -20
- package/dist/split.d.ts +6 -6
- package/dist/split.js +14 -14
- package/dist/tabs.d.ts +10 -6
- package/dist/tabs.js +94 -30
- package/dist/tooltip.d.ts +4 -4
- package/dist/tooltip.js +9 -9
- package/dist/tree-model.d.ts +15 -7
- package/dist/tree-model.js +93 -80
- package/dist/tree-node.d.ts +3 -3
- package/dist/tree-node.js +3 -3
- package/dist/tree-types.d.ts +14 -14
- package/dist/tree.d.ts +9 -7
- package/dist/tree.js +68 -66
- package/dist/virtual-list.d.ts +61 -0
- package/dist/virtual-list.js +324 -0
- package/package.json +100 -7
- package/themes/haiyue-dark.css +46 -0
- package/themes/haiyue-light.css +46 -0
- package/src/checkbox.ts +0 -215
- package/src/context-menu.ts +0 -248
- package/src/dialog.ts +0 -195
- package/src/dropdown.ts +0 -249
- package/src/index.ts +0 -192
- package/src/input.ts +0 -150
- package/src/menu-shared.ts +0 -65
- package/src/radio.ts +0 -216
- package/src/select.ts +0 -271
- package/src/split.ts +0 -306
- package/src/tabs.ts +0 -182
- package/src/tooltip.ts +0 -321
- package/src/tree-model.ts +0 -305
- package/src/tree-node.ts +0 -67
- package/src/tree-types.ts +0 -47
- package/src/tree.ts +0 -1002
package/dist/range.js
ADDED
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
const DEFAULT_MIN = 0;
|
|
2
|
+
const DEFAULT_MAX = 100;
|
|
3
|
+
const DEFAULT_STEP = 1;
|
|
4
|
+
/** Accessible single-value or two-handle numeric range control. */
|
|
5
|
+
export class HYRange extends HTMLElement {
|
|
6
|
+
_stage = document.createElement('div');
|
|
7
|
+
_track = document.createElement('div');
|
|
8
|
+
_lowerHandle = document.createElement('button');
|
|
9
|
+
_upperHandle = document.createElement('button');
|
|
10
|
+
_lowerBubble = document.createElement('span');
|
|
11
|
+
_upperBubble = document.createElement('span');
|
|
12
|
+
_activeHandle = 'single';
|
|
13
|
+
_dragStartValue = '';
|
|
14
|
+
_pointerId = -1;
|
|
15
|
+
_dragAbort = null;
|
|
16
|
+
_connected = false;
|
|
17
|
+
static get observedAttributes() {
|
|
18
|
+
return [
|
|
19
|
+
'min', 'max', 'step', 'value', 'range', 'lower-value', 'upper-value',
|
|
20
|
+
'disabled', 'show-value', 'aria-label',
|
|
21
|
+
];
|
|
22
|
+
}
|
|
23
|
+
constructor() {
|
|
24
|
+
super();
|
|
25
|
+
const root = this.attachShadow({ mode: 'open' });
|
|
26
|
+
const style = document.createElement('style');
|
|
27
|
+
style.textContent = `
|
|
28
|
+
:host {
|
|
29
|
+
display: inline-block;
|
|
30
|
+
width: var(--hy-range-width, 280px);
|
|
31
|
+
min-width: 120px;
|
|
32
|
+
color: var(--hy-text-color, #e8effa);
|
|
33
|
+
font: 11px/1.3 system-ui, sans-serif;
|
|
34
|
+
--_handle-size: var(--hy-range-handle-size, 18px);
|
|
35
|
+
--_rail-height: var(--hy-range-rail-height, 5px);
|
|
36
|
+
}
|
|
37
|
+
:host([disabled]) { opacity: 0.5; }
|
|
38
|
+
.stage {
|
|
39
|
+
position: relative;
|
|
40
|
+
height: max(var(--_handle-size), 22px);
|
|
41
|
+
margin-inline: calc(var(--_handle-size) / 2);
|
|
42
|
+
touch-action: none;
|
|
43
|
+
user-select: none;
|
|
44
|
+
}
|
|
45
|
+
.rail,
|
|
46
|
+
.track {
|
|
47
|
+
position: absolute;
|
|
48
|
+
top: 50%;
|
|
49
|
+
right: 0;
|
|
50
|
+
left: 0;
|
|
51
|
+
height: var(--_rail-height);
|
|
52
|
+
border-radius: var(--hy-range-rail-radius, 999px);
|
|
53
|
+
transform: translateY(-50%);
|
|
54
|
+
}
|
|
55
|
+
.rail {
|
|
56
|
+
border: var(--hy-range-rail-border, 0);
|
|
57
|
+
background: var(--hy-range-rail-color, var(--hy-border-strong-color, #354154));
|
|
58
|
+
box-shadow: var(--hy-range-rail-shadow, none);
|
|
59
|
+
}
|
|
60
|
+
.track {
|
|
61
|
+
right: auto;
|
|
62
|
+
background: var(--hy-range-track-color, var(--hy-accent-color, #69bff4));
|
|
63
|
+
box-shadow: var(--hy-range-track-shadow, 0 0 9px color-mix(in srgb, var(--hy-range-track-color, var(--hy-accent-color, #69bff4)) 24%, transparent));
|
|
64
|
+
}
|
|
65
|
+
.handle {
|
|
66
|
+
position: absolute;
|
|
67
|
+
z-index: 2;
|
|
68
|
+
top: 50%;
|
|
69
|
+
display: grid;
|
|
70
|
+
width: var(--_handle-size);
|
|
71
|
+
height: var(--_handle-size);
|
|
72
|
+
padding: 0;
|
|
73
|
+
border: var(--hy-range-handle-border-width, 2px) solid var(--hy-range-handle-border-color, var(--hy-accent-color, #69bff4));
|
|
74
|
+
border-radius: var(--hy-range-handle-radius, 50%);
|
|
75
|
+
place-items: center;
|
|
76
|
+
outline: none;
|
|
77
|
+
color: var(--hy-text-color, #e8effa);
|
|
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));
|
|
80
|
+
cursor: grab;
|
|
81
|
+
transform: translate(-50%, -50%);
|
|
82
|
+
transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
|
|
83
|
+
box-sizing: border-box;
|
|
84
|
+
}
|
|
85
|
+
.handle:hover:not(:disabled) {
|
|
86
|
+
border-color: var(--hy-range-handle-hover-border-color, var(--hy-accent-strong-color, #88d8ff));
|
|
87
|
+
transform: translate(-50%, -50%) scale(1.08);
|
|
88
|
+
}
|
|
89
|
+
.handle:focus-visible {
|
|
90
|
+
box-shadow: var(--hy-range-handle-focus-shadow, 0 0 0 4px var(--hy-focus-ring-color, rgba(105, 191, 244, 0.24)));
|
|
91
|
+
}
|
|
92
|
+
.handle[data-active="true"] { z-index: 3; cursor: grabbing; }
|
|
93
|
+
.handle:disabled { cursor: default; }
|
|
94
|
+
:host(:not([range])) .lower { display: none; }
|
|
95
|
+
.bubble {
|
|
96
|
+
position: absolute;
|
|
97
|
+
bottom: calc(100% + 8px);
|
|
98
|
+
display: none;
|
|
99
|
+
min-width: 24px;
|
|
100
|
+
padding: 3px 6px;
|
|
101
|
+
border: 1px solid var(--hy-border-color, #303746);
|
|
102
|
+
border-radius: 4px;
|
|
103
|
+
pointer-events: none;
|
|
104
|
+
color: var(--hy-text-color, #e8effa);
|
|
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;
|
|
108
|
+
white-space: nowrap;
|
|
109
|
+
}
|
|
110
|
+
:host([show-value]) .bubble { display: block; }
|
|
111
|
+
`;
|
|
112
|
+
this._stage.className = 'stage';
|
|
113
|
+
this._stage.part.add('stage');
|
|
114
|
+
const rail = document.createElement('div');
|
|
115
|
+
rail.className = 'rail';
|
|
116
|
+
rail.part.add('rail');
|
|
117
|
+
this._track.className = 'track';
|
|
118
|
+
this._track.part.add('track');
|
|
119
|
+
this._configureHandle(this._lowerHandle, this._lowerBubble, 'lower');
|
|
120
|
+
this._configureHandle(this._upperHandle, this._upperBubble, 'upper');
|
|
121
|
+
this._stage.append(rail, this._track, this._lowerHandle, this._upperHandle);
|
|
122
|
+
root.append(style, this._stage);
|
|
123
|
+
}
|
|
124
|
+
connectedCallback() {
|
|
125
|
+
if (this._connected)
|
|
126
|
+
return;
|
|
127
|
+
this._connected = true;
|
|
128
|
+
this._stage.addEventListener('pointerdown', this._onPointerDown);
|
|
129
|
+
this._stage.addEventListener('keydown', this._onKeyDown);
|
|
130
|
+
this._render();
|
|
131
|
+
}
|
|
132
|
+
disconnectedCallback() {
|
|
133
|
+
if (!this._connected)
|
|
134
|
+
return;
|
|
135
|
+
this._connected = false;
|
|
136
|
+
this._stage.removeEventListener('pointerdown', this._onPointerDown);
|
|
137
|
+
this._stage.removeEventListener('keydown', this._onKeyDown);
|
|
138
|
+
this._stopDrag();
|
|
139
|
+
}
|
|
140
|
+
attributeChangedCallback() {
|
|
141
|
+
this._render();
|
|
142
|
+
}
|
|
143
|
+
get min() {
|
|
144
|
+
const value = Number(this.getAttribute('min'));
|
|
145
|
+
return Number.isFinite(value) ? value : DEFAULT_MIN;
|
|
146
|
+
}
|
|
147
|
+
set min(value) { this.setAttribute('min', String(finiteOr(value, DEFAULT_MIN))); }
|
|
148
|
+
get max() {
|
|
149
|
+
const value = Number(this.getAttribute('max'));
|
|
150
|
+
return Number.isFinite(value) && value > this.min ? value : Math.max(DEFAULT_MAX, this.min + DEFAULT_MAX);
|
|
151
|
+
}
|
|
152
|
+
set max(value) {
|
|
153
|
+
const next = finiteOr(value, DEFAULT_MAX);
|
|
154
|
+
this.setAttribute('max', String(next > this.min ? next : this.min + DEFAULT_MAX));
|
|
155
|
+
}
|
|
156
|
+
get step() {
|
|
157
|
+
const value = Number(this.getAttribute('step'));
|
|
158
|
+
return Number.isFinite(value) && value > 0 ? value : DEFAULT_STEP;
|
|
159
|
+
}
|
|
160
|
+
set step(value) {
|
|
161
|
+
const next = finiteOr(value, DEFAULT_STEP);
|
|
162
|
+
this.setAttribute('step', String(next > 0 ? next : DEFAULT_STEP));
|
|
163
|
+
}
|
|
164
|
+
get value() { return this._normalize(Number(this.getAttribute('value') ?? this.min)); }
|
|
165
|
+
set value(value) { this.setAttribute('value', String(this._normalize(value))); }
|
|
166
|
+
get range() { return this.hasAttribute('range'); }
|
|
167
|
+
set range(value) { this.toggleAttribute('range', Boolean(value)); }
|
|
168
|
+
get lowerValue() {
|
|
169
|
+
return Math.min(this._normalize(Number(this.getAttribute('lower-value') ?? this.min)), this.upperValue);
|
|
170
|
+
}
|
|
171
|
+
set lowerValue(value) {
|
|
172
|
+
this.setAttribute('lower-value', String(Math.min(this._normalize(value), this.upperValue)));
|
|
173
|
+
}
|
|
174
|
+
get upperValue() {
|
|
175
|
+
return Math.max(this._normalize(Number(this.getAttribute('upper-value') ?? this.max)), this._rawLowerValue());
|
|
176
|
+
}
|
|
177
|
+
set upperValue(value) {
|
|
178
|
+
this.setAttribute('upper-value', String(Math.max(this._normalize(value), this.lowerValue)));
|
|
179
|
+
}
|
|
180
|
+
get values() { return [this.lowerValue, this.upperValue]; }
|
|
181
|
+
set values(value) {
|
|
182
|
+
const lower = this._normalize(Number(value[0]));
|
|
183
|
+
const upper = this._normalize(Number(value[1]));
|
|
184
|
+
this.setAttribute('lower-value', String(Math.min(lower, upper)));
|
|
185
|
+
this.setAttribute('upper-value', String(Math.max(lower, upper)));
|
|
186
|
+
}
|
|
187
|
+
get disabled() { return this.hasAttribute('disabled'); }
|
|
188
|
+
set disabled(value) { this.toggleAttribute('disabled', Boolean(value)); }
|
|
189
|
+
get showValue() { return this.hasAttribute('show-value'); }
|
|
190
|
+
set showValue(value) { this.toggleAttribute('show-value', Boolean(value)); }
|
|
191
|
+
focus(options) {
|
|
192
|
+
this._upperHandle.focus(options);
|
|
193
|
+
}
|
|
194
|
+
_configureHandle(button, bubble, handle) {
|
|
195
|
+
button.className = `handle ${handle}`;
|
|
196
|
+
button.type = 'button';
|
|
197
|
+
button.dataset.handle = handle;
|
|
198
|
+
button.part.add('handle', `handle-${handle}`);
|
|
199
|
+
button.setAttribute('role', 'slider');
|
|
200
|
+
bubble.className = 'bubble';
|
|
201
|
+
bubble.setAttribute('aria-hidden', 'true');
|
|
202
|
+
button.append(bubble);
|
|
203
|
+
}
|
|
204
|
+
_render() {
|
|
205
|
+
const lower = this.range ? this.lowerValue : this.min;
|
|
206
|
+
const upper = this.range ? this.upperValue : this.value;
|
|
207
|
+
const lowerPercent = this._toPercent(lower);
|
|
208
|
+
const upperPercent = this._toPercent(upper);
|
|
209
|
+
this._lowerHandle.style.left = `${lowerPercent}%`;
|
|
210
|
+
this._upperHandle.style.left = `${upperPercent}%`;
|
|
211
|
+
this._track.style.left = `${lowerPercent}%`;
|
|
212
|
+
this._track.style.width = `${Math.max(0, upperPercent - lowerPercent)}%`;
|
|
213
|
+
this._lowerBubble.textContent = this._formatValue(lower);
|
|
214
|
+
this._upperBubble.textContent = this._formatValue(upper);
|
|
215
|
+
const label = this.getAttribute('aria-label');
|
|
216
|
+
this._syncHandle(this._lowerHandle, lower, label ? `${label} minimum` : 'Lower value');
|
|
217
|
+
this._syncHandle(this._upperHandle, upper, this._upperHandleLabel(label));
|
|
218
|
+
}
|
|
219
|
+
_upperHandleLabel(label) {
|
|
220
|
+
if (!this.range)
|
|
221
|
+
return label ?? 'Range value';
|
|
222
|
+
return label ? `${label} maximum` : 'Upper value';
|
|
223
|
+
}
|
|
224
|
+
_syncHandle(handle, value, fallbackLabel) {
|
|
225
|
+
handle.disabled = this.disabled;
|
|
226
|
+
handle.setAttribute('aria-orientation', 'horizontal');
|
|
227
|
+
handle.setAttribute('aria-valuemin', String(handle === this._upperHandle && this.range ? this.lowerValue : this.min));
|
|
228
|
+
handle.setAttribute('aria-valuemax', String(handle === this._lowerHandle && this.range ? this.upperValue : this.max));
|
|
229
|
+
handle.setAttribute('aria-valuenow', String(value));
|
|
230
|
+
handle.setAttribute('aria-valuetext', this._formatValue(value));
|
|
231
|
+
handle.setAttribute('aria-label', fallbackLabel);
|
|
232
|
+
}
|
|
233
|
+
_onPointerDown = (event) => {
|
|
234
|
+
if (this.disabled || event.button !== 0)
|
|
235
|
+
return;
|
|
236
|
+
event.preventDefault();
|
|
237
|
+
const target = event.target instanceof Element ? event.target.closest('.handle') : null;
|
|
238
|
+
const pointerValue = this._valueFromClientX(event.clientX);
|
|
239
|
+
const handle = this._resolvePointerHandle(target?.dataset.handle, pointerValue);
|
|
240
|
+
this._activeHandle = handle;
|
|
241
|
+
this._pointerId = event.pointerId;
|
|
242
|
+
this._dragStartValue = this._serializedValue();
|
|
243
|
+
this._setActiveHandle(handle, true);
|
|
244
|
+
(handle === 'lower' ? this._lowerHandle : this._upperHandle).focus();
|
|
245
|
+
this._setFromPointer(event.clientX, true);
|
|
246
|
+
this._dragAbort?.abort();
|
|
247
|
+
this._dragAbort = new AbortController();
|
|
248
|
+
const { signal } = this._dragAbort;
|
|
249
|
+
document.addEventListener('pointermove', this._onPointerMove, { signal });
|
|
250
|
+
document.addEventListener('pointerup', this._onPointerUp, { signal });
|
|
251
|
+
document.addEventListener('pointercancel', this._onPointerUp, { signal });
|
|
252
|
+
};
|
|
253
|
+
_onPointerMove = (event) => {
|
|
254
|
+
if (event.pointerId !== this._pointerId)
|
|
255
|
+
return;
|
|
256
|
+
event.preventDefault();
|
|
257
|
+
this._setFromPointer(event.clientX, true);
|
|
258
|
+
};
|
|
259
|
+
_onPointerUp = (event) => {
|
|
260
|
+
if (event.pointerId !== this._pointerId)
|
|
261
|
+
return;
|
|
262
|
+
const changed = this._dragStartValue !== this._serializedValue();
|
|
263
|
+
const handle = this._activeHandle;
|
|
264
|
+
this._stopDrag();
|
|
265
|
+
if (changed)
|
|
266
|
+
this._dispatchValueEvent('value-change', handle);
|
|
267
|
+
};
|
|
268
|
+
_onKeyDown = (event) => {
|
|
269
|
+
if (this.disabled || !(event.target instanceof HTMLButtonElement))
|
|
270
|
+
return;
|
|
271
|
+
const handle = this._resolveKeyboardHandle(event.target.dataset.handle);
|
|
272
|
+
const next = this._keyboardValue(event.key, this._valueForHandle(handle));
|
|
273
|
+
if (next === null)
|
|
274
|
+
return;
|
|
275
|
+
event.preventDefault();
|
|
276
|
+
this._commitValue(next, handle, true);
|
|
277
|
+
this._dispatchValueEvent('value-change', handle);
|
|
278
|
+
};
|
|
279
|
+
_resolvePointerHandle(rawHandle, pointerValue) {
|
|
280
|
+
if (rawHandle === 'lower')
|
|
281
|
+
return 'lower';
|
|
282
|
+
if (rawHandle === 'upper')
|
|
283
|
+
return this.range ? 'upper' : 'single';
|
|
284
|
+
return this._nearestHandle(pointerValue);
|
|
285
|
+
}
|
|
286
|
+
_resolveKeyboardHandle(rawHandle) {
|
|
287
|
+
if (rawHandle === 'lower')
|
|
288
|
+
return 'lower';
|
|
289
|
+
return this.range ? 'upper' : 'single';
|
|
290
|
+
}
|
|
291
|
+
_valueForHandle(handle) {
|
|
292
|
+
if (handle === 'lower')
|
|
293
|
+
return this.lowerValue;
|
|
294
|
+
return this.range ? this.upperValue : this.value;
|
|
295
|
+
}
|
|
296
|
+
_keyboardValue(key, current) {
|
|
297
|
+
if (key === 'ArrowLeft' || key === 'ArrowDown')
|
|
298
|
+
return current - this.step;
|
|
299
|
+
if (key === 'ArrowRight' || key === 'ArrowUp')
|
|
300
|
+
return current + this.step;
|
|
301
|
+
if (key === 'PageDown')
|
|
302
|
+
return current - this.step * 10;
|
|
303
|
+
if (key === 'PageUp')
|
|
304
|
+
return current + this.step * 10;
|
|
305
|
+
if (key === 'Home')
|
|
306
|
+
return this.min;
|
|
307
|
+
if (key === 'End')
|
|
308
|
+
return this.max;
|
|
309
|
+
return null;
|
|
310
|
+
}
|
|
311
|
+
_setFromPointer(clientX, emit) {
|
|
312
|
+
this._commitValue(this._valueFromClientX(clientX), this._activeHandle, emit);
|
|
313
|
+
}
|
|
314
|
+
_commitValue(value, handle, emit) {
|
|
315
|
+
const normalized = this._normalize(value);
|
|
316
|
+
if (handle === 'lower')
|
|
317
|
+
this.setAttribute('lower-value', String(Math.min(normalized, this.upperValue)));
|
|
318
|
+
else if (handle === 'upper')
|
|
319
|
+
this.setAttribute('upper-value', String(Math.max(normalized, this.lowerValue)));
|
|
320
|
+
else
|
|
321
|
+
this.setAttribute('value', String(normalized));
|
|
322
|
+
if (emit)
|
|
323
|
+
this._dispatchValueEvent('value-input', handle);
|
|
324
|
+
}
|
|
325
|
+
_dispatchValueEvent(type, handle) {
|
|
326
|
+
const lowerValue = this.range ? this.lowerValue : this.min;
|
|
327
|
+
const upperValue = this.range ? this.upperValue : this.value;
|
|
328
|
+
this.dispatchEvent(new CustomEvent(type, {
|
|
329
|
+
detail: {
|
|
330
|
+
value: this.range ? [lowerValue, upperValue] : upperValue,
|
|
331
|
+
lowerValue,
|
|
332
|
+
upperValue,
|
|
333
|
+
handle,
|
|
334
|
+
},
|
|
335
|
+
bubbles: true,
|
|
336
|
+
composed: true,
|
|
337
|
+
}));
|
|
338
|
+
}
|
|
339
|
+
_nearestHandle(value) {
|
|
340
|
+
if (!this.range)
|
|
341
|
+
return 'single';
|
|
342
|
+
return Math.abs(value - this.lowerValue) < Math.abs(value - this.upperValue) ? 'lower' : 'upper';
|
|
343
|
+
}
|
|
344
|
+
_valueFromClientX(clientX) {
|
|
345
|
+
const rect = this._stage.getBoundingClientRect();
|
|
346
|
+
const percent = rect.width > 0 ? (clientX - rect.left) / rect.width : 0;
|
|
347
|
+
return this._normalize(this.min + Math.max(0, Math.min(1, percent)) * (this.max - this.min));
|
|
348
|
+
}
|
|
349
|
+
_normalize(value) {
|
|
350
|
+
const finite = finiteOr(value, this.min);
|
|
351
|
+
const clamped = Math.max(this.min, Math.min(this.max, finite));
|
|
352
|
+
const stepped = this.min + Math.round((clamped - this.min) / this.step) * this.step;
|
|
353
|
+
return Number(Math.max(this.min, Math.min(this.max, stepped)).toFixed(this._precision()));
|
|
354
|
+
}
|
|
355
|
+
_precision() {
|
|
356
|
+
return Math.min(12, Math.max(numberPrecision(this.min), numberPrecision(this.max), numberPrecision(this.step)));
|
|
357
|
+
}
|
|
358
|
+
_rawLowerValue() {
|
|
359
|
+
return this._normalize(Number(this.getAttribute('lower-value') ?? this.min));
|
|
360
|
+
}
|
|
361
|
+
_toPercent(value) {
|
|
362
|
+
return (value - this.min) / (this.max - this.min) * 100;
|
|
363
|
+
}
|
|
364
|
+
_formatValue(value) {
|
|
365
|
+
return value.toFixed(this._precision());
|
|
366
|
+
}
|
|
367
|
+
_serializedValue() {
|
|
368
|
+
return this.range ? `${this.lowerValue}:${this.upperValue}` : String(this.value);
|
|
369
|
+
}
|
|
370
|
+
_setActiveHandle(handle, active) {
|
|
371
|
+
this._lowerHandle.dataset.active = String(active && handle === 'lower');
|
|
372
|
+
this._upperHandle.dataset.active = String(active && handle !== 'lower');
|
|
373
|
+
}
|
|
374
|
+
_stopDrag() {
|
|
375
|
+
this._dragAbort?.abort();
|
|
376
|
+
this._dragAbort = null;
|
|
377
|
+
this._pointerId = -1;
|
|
378
|
+
this._setActiveHandle(this._activeHandle, false);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
function finiteOr(value, fallback) {
|
|
382
|
+
return Number.isFinite(Number(value)) ? Number(value) : fallback;
|
|
383
|
+
}
|
|
384
|
+
function numberPrecision(value) {
|
|
385
|
+
const [coefficient = '', exponentText = '0'] = String(value).toLowerCase().split('e');
|
|
386
|
+
const decimals = coefficient.includes('.') ? coefficient.length - coefficient.indexOf('.') - 1 : 0;
|
|
387
|
+
return Math.max(0, decimals - Number(exponentText));
|
|
388
|
+
}
|
|
389
|
+
export function defineRangeComponents() {
|
|
390
|
+
if (!customElements.get('hy-range'))
|
|
391
|
+
customElements.define('hy-range', HYRange);
|
|
392
|
+
}
|
|
393
|
+
//# sourceMappingURL=range.js.map
|
package/dist/select.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface HYSelectOption {
|
|
2
2
|
label: string;
|
|
3
3
|
value: string;
|
|
4
4
|
disabled?: boolean;
|
|
5
5
|
}
|
|
6
|
-
export interface
|
|
6
|
+
export interface HYSelectChangeDetail {
|
|
7
7
|
value: string;
|
|
8
|
-
option:
|
|
8
|
+
option: HYSelectOption | null;
|
|
9
9
|
}
|
|
10
|
-
export declare class
|
|
10
|
+
export declare class HYSelect extends HTMLElement {
|
|
11
11
|
private readonly _wrap;
|
|
12
12
|
private readonly _search;
|
|
13
13
|
private readonly _select;
|
|
@@ -18,8 +18,8 @@ export declare class GESelect extends HTMLElement {
|
|
|
18
18
|
connectedCallback(): void;
|
|
19
19
|
disconnectedCallback(): void;
|
|
20
20
|
attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
|
|
21
|
-
get options():
|
|
22
|
-
set options(value:
|
|
21
|
+
get options(): HYSelectOption[];
|
|
22
|
+
set options(value: HYSelectOption[]);
|
|
23
23
|
get value(): string;
|
|
24
24
|
set value(value: string);
|
|
25
25
|
get disabled(): boolean;
|
package/dist/select.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export class
|
|
1
|
+
export class HYSelect extends HTMLElement {
|
|
2
2
|
_wrap = document.createElement('div');
|
|
3
3
|
_search = document.createElement('input');
|
|
4
4
|
_select = document.createElement('select');
|
|
@@ -30,20 +30,20 @@ export class GESelect extends HTMLElement {
|
|
|
30
30
|
height: 28px;
|
|
31
31
|
min-width: 0;
|
|
32
32
|
padding: 0 28px 0 8px;
|
|
33
|
-
border: 1px solid var(--
|
|
33
|
+
border: 1px solid var(--hy-border-color, #303746);
|
|
34
34
|
border-radius: 4px;
|
|
35
|
-
color: var(--
|
|
36
|
-
background-color: var(--
|
|
35
|
+
color: var(--hy-text-color, #d8e2f2);
|
|
36
|
+
background-color: var(--hy-input-bg-color, var(--hy-surface-color, #121822));
|
|
37
37
|
font: 12px system-ui, sans-serif;
|
|
38
38
|
outline: none;
|
|
39
|
-
color-scheme:
|
|
39
|
+
color-scheme: inherit;
|
|
40
40
|
}
|
|
41
41
|
select {
|
|
42
42
|
appearance: none;
|
|
43
43
|
cursor: pointer;
|
|
44
44
|
background-image:
|
|
45
|
-
linear-gradient(45deg, transparent 50%, var(--
|
|
46
|
-
linear-gradient(135deg, var(--
|
|
45
|
+
linear-gradient(45deg, transparent 50%, var(--hy-select-arrow-color, var(--hy-secondary-text-color, #8fa7c8)) 50%),
|
|
46
|
+
linear-gradient(135deg, var(--hy-select-arrow-color, var(--hy-secondary-text-color, #8fa7c8)) 50%, transparent 50%);
|
|
47
47
|
background-position:
|
|
48
48
|
calc(100% - 15px) 11px,
|
|
49
49
|
calc(100% - 10px) 11px;
|
|
@@ -51,23 +51,23 @@ export class GESelect extends HTMLElement {
|
|
|
51
51
|
background-repeat: no-repeat;
|
|
52
52
|
}
|
|
53
53
|
select:hover:not(:disabled) {
|
|
54
|
-
border-color: var(--
|
|
55
|
-
background-color: var(--
|
|
54
|
+
border-color: var(--hy-hover-border-color, #435268);
|
|
55
|
+
background-color: var(--hy-select-hover-bg-color, var(--hy-input-bg-color, #151d2a));
|
|
56
56
|
}
|
|
57
57
|
option {
|
|
58
58
|
min-height: 28px;
|
|
59
59
|
padding: 6px 8px;
|
|
60
|
-
color: var(--
|
|
61
|
-
background: var(--
|
|
60
|
+
color: var(--hy-select-option-text-color, var(--hy-text-color, #d8e2f2));
|
|
61
|
+
background: var(--hy-select-option-bg-color, var(--hy-menu-bg-color, #1b2230));
|
|
62
62
|
font: 12px system-ui, sans-serif;
|
|
63
63
|
}
|
|
64
64
|
option:checked {
|
|
65
|
-
color: var(--
|
|
66
|
-
background: var(--
|
|
65
|
+
color: var(--hy-select-option-selected-text-color, var(--hy-selected-text-color, #ffffff));
|
|
66
|
+
background: var(--hy-select-option-selected-bg-color, var(--hy-selected-bg-color, #255a91));
|
|
67
67
|
}
|
|
68
68
|
option:disabled {
|
|
69
|
-
color: var(--
|
|
70
|
-
background: var(--
|
|
69
|
+
color: var(--hy-disabled-text-color, #65738a);
|
|
70
|
+
background: var(--hy-select-option-bg-color, var(--hy-menu-bg-color, #1b2230));
|
|
71
71
|
}
|
|
72
72
|
input {
|
|
73
73
|
display: none;
|
|
@@ -77,8 +77,8 @@ export class GESelect extends HTMLElement {
|
|
|
77
77
|
}
|
|
78
78
|
input:focus,
|
|
79
79
|
select:focus {
|
|
80
|
-
border-color: var(--
|
|
81
|
-
box-shadow: 0 0 0 2px var(--
|
|
80
|
+
border-color: var(--hy-focus-border-color, #3d6fa8);
|
|
81
|
+
box-shadow: 0 0 0 2px var(--hy-focus-ring-color, rgba(61, 111, 168, 0.24));
|
|
82
82
|
}
|
|
83
83
|
input:disabled,
|
|
84
84
|
select:disabled {
|
|
@@ -184,7 +184,7 @@ export class GESelect extends HTMLElement {
|
|
|
184
184
|
: [];
|
|
185
185
|
}
|
|
186
186
|
catch (error) {
|
|
187
|
-
console.warn('Invalid
|
|
187
|
+
console.warn('Invalid hy-select options attribute.', error);
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
190
|
_render() {
|
|
@@ -246,8 +246,8 @@ export class GESelect extends HTMLElement {
|
|
|
246
246
|
};
|
|
247
247
|
}
|
|
248
248
|
export function defineSelectComponents() {
|
|
249
|
-
if (!customElements.get('
|
|
250
|
-
customElements.define('
|
|
249
|
+
if (!customElements.get('hy-select')) {
|
|
250
|
+
customElements.define('hy-select', HYSelect);
|
|
251
251
|
}
|
|
252
252
|
}
|
|
253
253
|
//# sourceMappingURL=select.js.map
|
package/dist/split.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export type
|
|
2
|
-
export interface
|
|
1
|
+
export type HYSplitDirection = 'horizontal' | 'vertical';
|
|
2
|
+
export interface HYSplitRatioChangeDetail {
|
|
3
3
|
ratio: number;
|
|
4
|
-
direction:
|
|
4
|
+
direction: HYSplitDirection;
|
|
5
5
|
}
|
|
6
|
-
export declare class
|
|
6
|
+
export declare class HYSplit extends HTMLElement {
|
|
7
7
|
private readonly _style;
|
|
8
8
|
private readonly _first;
|
|
9
9
|
private readonly _second;
|
|
@@ -17,8 +17,8 @@ export declare class GESplit extends HTMLElement {
|
|
|
17
17
|
connectedCallback(): void;
|
|
18
18
|
disconnectedCallback(): void;
|
|
19
19
|
attributeChangedCallback(): void;
|
|
20
|
-
get direction():
|
|
21
|
-
set direction(value:
|
|
20
|
+
get direction(): HYSplitDirection;
|
|
21
|
+
set direction(value: HYSplitDirection);
|
|
22
22
|
get ratio(): number;
|
|
23
23
|
set ratio(value: number);
|
|
24
24
|
get minFirst(): number;
|
package/dist/split.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const DEFAULT_BAR_SIZE = 6;
|
|
2
|
-
export class
|
|
2
|
+
export class HYSplit extends HTMLElement {
|
|
3
3
|
_style = document.createElement('style');
|
|
4
4
|
_first = document.createElement('div');
|
|
5
5
|
_second = document.createElement('div');
|
|
@@ -23,28 +23,28 @@ export class GESplit extends HTMLElement {
|
|
|
23
23
|
min-width: 0;
|
|
24
24
|
min-height: 0;
|
|
25
25
|
overflow: hidden;
|
|
26
|
-
color: var(--
|
|
27
|
-
background: var(--
|
|
26
|
+
color: var(--hy-split-text-color, var(--hy-text-color, #d8e2f2));
|
|
27
|
+
background: var(--hy-split-bg-color, var(--hy-surface-color, #121822));
|
|
28
28
|
}
|
|
29
29
|
.pane {
|
|
30
30
|
min-width: 0;
|
|
31
31
|
min-height: 0;
|
|
32
32
|
overflow: auto;
|
|
33
|
-
background: var(--
|
|
33
|
+
background: var(--hy-split-pane-bg-color, transparent);
|
|
34
34
|
}
|
|
35
35
|
.bar {
|
|
36
|
-
background: var(--
|
|
36
|
+
background: var(--hy-split-bar-color, var(--hy-border-strong-color, #273142));
|
|
37
37
|
position: relative;
|
|
38
38
|
z-index: 1;
|
|
39
|
-
transition: background var(--
|
|
39
|
+
transition: background var(--hy-split-bar-transition-duration, 0.12s) ease;
|
|
40
40
|
}
|
|
41
41
|
.bar:focus {
|
|
42
|
-
outline: var(--
|
|
42
|
+
outline: var(--hy-split-focus-ring-width, 1px) solid var(--hy-split-focus-ring-color, var(--hy-focus-border-color, var(--hy-accent-color, #3d6fa8)));
|
|
43
43
|
outline-offset: -1px;
|
|
44
44
|
}
|
|
45
45
|
.bar:hover,
|
|
46
46
|
.bar.dragging {
|
|
47
|
-
background: var(--
|
|
47
|
+
background: var(--hy-split-bar-active-color, var(--hy-accent-color, #3d6fa8));
|
|
48
48
|
}
|
|
49
49
|
:host([direction="vertical"]) .bar {
|
|
50
50
|
cursor: row-resize;
|
|
@@ -57,16 +57,16 @@ export class GESplit extends HTMLElement {
|
|
|
57
57
|
position: absolute;
|
|
58
58
|
left: 0;
|
|
59
59
|
right: 0;
|
|
60
|
-
top: calc(var(--
|
|
61
|
-
bottom: calc(var(--
|
|
60
|
+
top: calc(var(--hy-split-bar-hit-outset, 3px) * -1);
|
|
61
|
+
bottom: calc(var(--hy-split-bar-hit-outset, 3px) * -1);
|
|
62
62
|
}
|
|
63
63
|
:host(:not([direction="vertical"])) .bar::before {
|
|
64
64
|
content: "";
|
|
65
65
|
position: absolute;
|
|
66
66
|
top: 0;
|
|
67
67
|
bottom: 0;
|
|
68
|
-
left: calc(var(--
|
|
69
|
-
right: calc(var(--
|
|
68
|
+
left: calc(var(--hy-split-bar-hit-outset, 3px) * -1);
|
|
69
|
+
right: calc(var(--hy-split-bar-hit-outset, 3px) * -1);
|
|
70
70
|
}
|
|
71
71
|
`;
|
|
72
72
|
this._first.className = 'pane first';
|
|
@@ -270,8 +270,8 @@ export class GESplit extends HTMLElement {
|
|
|
270
270
|
}
|
|
271
271
|
}
|
|
272
272
|
export function defineSplitComponents() {
|
|
273
|
-
if (!customElements.get('
|
|
274
|
-
customElements.define('
|
|
273
|
+
if (!customElements.get('hy-split')) {
|
|
274
|
+
customElements.define('hy-split', HYSplit);
|
|
275
275
|
}
|
|
276
276
|
}
|
|
277
277
|
//# sourceMappingURL=split.js.map
|
package/dist/tabs.d.ts
CHANGED
|
@@ -1,28 +1,32 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface HYTabOption {
|
|
2
2
|
label: string;
|
|
3
3
|
value: string;
|
|
4
4
|
disabled?: boolean;
|
|
5
5
|
}
|
|
6
|
-
export interface
|
|
6
|
+
export interface HYTabChangeDetail {
|
|
7
7
|
value: string;
|
|
8
|
-
option:
|
|
8
|
+
option: HYTabOption | null;
|
|
9
9
|
}
|
|
10
|
-
export declare class
|
|
10
|
+
export declare class HYTabs extends HTMLElement {
|
|
11
11
|
private readonly _style;
|
|
12
12
|
private readonly _tabs;
|
|
13
13
|
private readonly _panels;
|
|
14
|
+
private readonly _instanceId;
|
|
14
15
|
private _options;
|
|
16
|
+
private _pendingFocusValue;
|
|
15
17
|
static get observedAttributes(): string[];
|
|
16
18
|
constructor();
|
|
17
19
|
connectedCallback(): void;
|
|
18
20
|
attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
|
|
19
|
-
get options():
|
|
20
|
-
set options(value:
|
|
21
|
+
get options(): HYTabOption[];
|
|
22
|
+
set options(value: HYTabOption[]);
|
|
21
23
|
get value(): string;
|
|
22
24
|
set value(value: string);
|
|
23
25
|
private _syncFromAttributes;
|
|
24
26
|
private _readOptionsAttribute;
|
|
25
27
|
private _render;
|
|
28
|
+
private _focusTab;
|
|
29
|
+
private _resolveValue;
|
|
26
30
|
private _select;
|
|
27
31
|
}
|
|
28
32
|
export declare function defineTabsComponents(): void;
|