@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/table.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { finiteNumber } from './internal/numbers.js';
|
|
2
|
+
import { HYPaginationControls, HY_PAGINATION_STYLES } from './internal/pagination.js';
|
|
1
3
|
const DEFAULT_PAGE_SIZE = 10;
|
|
2
4
|
const DEFAULT_PAGE_SIZE_OPTIONS = [5, 10, 20, 50];
|
|
3
5
|
const collator = new Intl.Collator(undefined, { numeric: true, sensitivity: 'base' });
|
|
4
6
|
function finiteInteger(value, fallback, minimum = 1) {
|
|
5
|
-
const number =
|
|
7
|
+
const number = finiteNumber(value, fallback);
|
|
6
8
|
return Number.isFinite(number) ? Math.max(minimum, Math.floor(number)) : fallback;
|
|
7
9
|
}
|
|
8
10
|
function positiveIntegerOptions(value) {
|
|
@@ -47,7 +49,12 @@ export class HYTable extends HTMLElement {
|
|
|
47
49
|
_table = document.createElement('table');
|
|
48
50
|
_head = document.createElement('thead');
|
|
49
51
|
_body = document.createElement('tbody');
|
|
50
|
-
_pagination =
|
|
52
|
+
_pagination = new HYPaginationControls((page, pageSize, source) => {
|
|
53
|
+
if (source === 'size')
|
|
54
|
+
this.pageSize = pageSize;
|
|
55
|
+
else
|
|
56
|
+
this.goToPage(page);
|
|
57
|
+
}, 'table');
|
|
51
58
|
_columns = [];
|
|
52
59
|
_dataSource = [];
|
|
53
60
|
_filters = {};
|
|
@@ -68,12 +75,12 @@ export class HYTable extends HTMLElement {
|
|
|
68
75
|
display: block;
|
|
69
76
|
min-width: 0;
|
|
70
77
|
color: var(--hy-text-color, #eef3ff);
|
|
71
|
-
font:
|
|
78
|
+
font: calc(var(--hy-font-size-sm, 12px) + 1px)/var(--hy-line-height-snug, 1.4) var(--hy-font-family, system-ui, sans-serif);
|
|
72
79
|
}
|
|
73
80
|
.scroller {
|
|
74
81
|
overflow: auto;
|
|
75
82
|
border: 1px solid var(--hy-border-color, #3d4654);
|
|
76
|
-
border-radius: var(--hy-table-radius,
|
|
83
|
+
border-radius: var(--hy-table-radius, calc(var(--hy-radius-md, 6px) + 1px));
|
|
77
84
|
background: var(--hy-surface-color, #171d27);
|
|
78
85
|
scrollbar-color: var(--hy-border-strong-color, #596779) var(--hy-input-bg-color, #111722);
|
|
79
86
|
scrollbar-width: thin;
|
|
@@ -82,7 +89,7 @@ export class HYTable extends HTMLElement {
|
|
|
82
89
|
th, td {
|
|
83
90
|
box-sizing: border-box;
|
|
84
91
|
min-width: 0;
|
|
85
|
-
padding: var(--hy-table-cell-padding,
|
|
92
|
+
padding: var(--hy-table-cell-padding, calc(var(--hy-space-5, 10px) + 1px) calc(var(--hy-space-6, 12px) + 1px));
|
|
86
93
|
border-bottom: 1px solid var(--hy-border-subtle-color, var(--hy-border-color, #3d4654));
|
|
87
94
|
overflow-wrap: anywhere;
|
|
88
95
|
}
|
|
@@ -90,8 +97,8 @@ export class HYTable extends HTMLElement {
|
|
|
90
97
|
position: relative;
|
|
91
98
|
color: var(--hy-secondary-text-color, #aebbd0);
|
|
92
99
|
background: var(--hy-table-header-background, var(--hy-input-bg-color, #111722));
|
|
93
|
-
font-size:
|
|
94
|
-
font-weight:
|
|
100
|
+
font-size: calc(var(--hy-font-size-xs, 10px) + 1px);
|
|
101
|
+
font-weight: calc(var(--hy-font-weight-semibold, 600) + 50);
|
|
95
102
|
text-align: left;
|
|
96
103
|
}
|
|
97
104
|
tbody tr { background: var(--hy-table-row-background, var(--hy-surface-color, #171d27)); }
|
|
@@ -99,12 +106,12 @@ export class HYTable extends HTMLElement {
|
|
|
99
106
|
tbody tr:last-child td { border-bottom: 0; }
|
|
100
107
|
thead { position: relative; z-index: 2; }
|
|
101
108
|
tbody { position: relative; z-index: 1; }
|
|
102
|
-
.header-content { display: flex; align-items: center; gap:
|
|
109
|
+
.header-content { display: flex; align-items: center; gap: calc(var(--hy-space-3, 6px) + 1px); min-width: 0; }
|
|
103
110
|
.header-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
104
111
|
.sort-button {
|
|
105
112
|
display: inline-flex;
|
|
106
113
|
align-items: center;
|
|
107
|
-
gap:
|
|
114
|
+
gap: calc(var(--hy-space-3, 6px) + 1px);
|
|
108
115
|
max-width: 100%;
|
|
109
116
|
padding: 0;
|
|
110
117
|
border: 0;
|
|
@@ -115,7 +122,7 @@ export class HYTable extends HTMLElement {
|
|
|
115
122
|
text-align: inherit;
|
|
116
123
|
}
|
|
117
124
|
.sort-button:hover, .sort-button:focus-visible { color: var(--hy-accent-color, #79a8ff); }
|
|
118
|
-
.sort-indicator { color: var(--hy-muted-text-color, #667587); font-size:
|
|
125
|
+
.sort-indicator { color: var(--hy-muted-text-color, var(--hy-muted-color, #667587)); font-size: calc(var(--hy-font-size-xs, 10px) - 1px); }
|
|
119
126
|
th[aria-sort="ascending"] .sort-indicator,
|
|
120
127
|
th[aria-sort="descending"] .sort-indicator { color: var(--hy-accent-color, #79a8ff); }
|
|
121
128
|
.filter-menu { position: relative; flex: 0 0 auto; }
|
|
@@ -127,8 +134,8 @@ export class HYTable extends HTMLElement {
|
|
|
127
134
|
place-items: center;
|
|
128
135
|
padding: 0;
|
|
129
136
|
border: 1px solid transparent;
|
|
130
|
-
border-radius: var(--hy-table-filter-radius,
|
|
131
|
-
color: var(--hy-muted-text-color, #667587);
|
|
137
|
+
border-radius: var(--hy-table-filter-radius, calc(var(--hy-radius-sm, 4px) + 1px));
|
|
138
|
+
color: var(--hy-muted-text-color, var(--hy-muted-color, #667587));
|
|
132
139
|
background: transparent;
|
|
133
140
|
cursor: pointer;
|
|
134
141
|
list-style: none;
|
|
@@ -151,11 +158,11 @@ export class HYTable extends HTMLElement {
|
|
|
151
158
|
width: max-content;
|
|
152
159
|
min-width: 184px;
|
|
153
160
|
max-width: min(280px, 70vw);
|
|
154
|
-
gap:
|
|
161
|
+
gap: calc(var(--hy-space-3, 6px) + 1px);
|
|
155
162
|
box-sizing: border-box;
|
|
156
|
-
padding:
|
|
163
|
+
padding: calc(var(--hy-space-4, 8px) + 1px);
|
|
157
164
|
border: 1px solid var(--hy-border-color, #3d4654);
|
|
158
|
-
border-radius: var(--hy-table-filter-panel-radius,
|
|
165
|
+
border-radius: var(--hy-table-filter-panel-radius, calc(var(--hy-radius-md, 6px) + 1px));
|
|
159
166
|
background: var(--hy-surface-elevated-color, var(--hy-surface-color, #171d27));
|
|
160
167
|
box-shadow: 0 10px 28px var(--hy-menu-shadow-color, rgba(0, 0, 0, 0.28));
|
|
161
168
|
}
|
|
@@ -167,73 +174,70 @@ export class HYTable extends HTMLElement {
|
|
|
167
174
|
min-width: 74px;
|
|
168
175
|
height: 30px;
|
|
169
176
|
box-sizing: border-box;
|
|
170
|
-
padding: 0
|
|
177
|
+
padding: 0 calc(var(--hy-space-4, 8px) + 1px);
|
|
171
178
|
border: 1px solid var(--hy-border-color, #3d4654);
|
|
172
|
-
border-radius: var(--hy-table-filter-radius,
|
|
179
|
+
border-radius: var(--hy-table-filter-radius, calc(var(--hy-radius-sm, 4px) + 1px));
|
|
173
180
|
outline: none;
|
|
174
181
|
color: var(--hy-text-color, #eef3ff);
|
|
175
182
|
background: var(--hy-input-bg-color, #111722);
|
|
176
|
-
font:
|
|
183
|
+
font: calc(var(--hy-font-size-xs, 10px) + 1px) var(--hy-font-family, system-ui, sans-serif);
|
|
177
184
|
}
|
|
178
185
|
.filter:focus { border-color: var(--hy-focus-border-color, #79a8ff); box-shadow: 0 0 0 2px var(--hy-focus-ring-color, rgba(121, 168, 255, 0.22)); }
|
|
179
186
|
.filter-clear {
|
|
180
187
|
flex: 0 0 auto;
|
|
181
188
|
height: 30px;
|
|
182
|
-
padding: 0
|
|
189
|
+
padding: 0 calc(var(--hy-space-4, 8px) + 1px);
|
|
183
190
|
border: 1px solid var(--hy-border-color, #3d4654);
|
|
184
|
-
border-radius: var(--hy-table-filter-radius,
|
|
191
|
+
border-radius: var(--hy-table-filter-radius, calc(var(--hy-radius-sm, 4px) + 1px));
|
|
185
192
|
color: var(--hy-secondary-text-color, #aebbd0);
|
|
186
193
|
background: var(--hy-surface-color, #171d27);
|
|
187
194
|
cursor: pointer;
|
|
188
|
-
font:
|
|
195
|
+
font: calc(var(--hy-font-size-xs, 10px) + 1px) var(--hy-font-family, system-ui, sans-serif);
|
|
189
196
|
}
|
|
190
197
|
.filter-clear:hover:not(:disabled) { border-color: var(--hy-accent-color, #79a8ff); color: var(--hy-accent-color, #79a8ff); }
|
|
191
198
|
.filter-clear:disabled { cursor: default; opacity: 0.45; }
|
|
192
|
-
.empty { height: 112px; color: var(--hy-muted-text-color, #788697); text-align: center; }
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
align-items: center;
|
|
199
|
+
.empty { height: 112px; color: var(--hy-muted-text-color, var(--hy-muted-color, #788697)); text-align: center; }
|
|
200
|
+
${HY_PAGINATION_STYLES}
|
|
201
|
+
.pagination-controls.pagination {
|
|
196
202
|
justify-content: flex-end;
|
|
197
|
-
gap: 6px;
|
|
198
|
-
padding:
|
|
203
|
+
gap: var(--hy-space-3, 6px);
|
|
204
|
+
padding: calc(var(--hy-space-5, 10px) + 1px) 0 0;
|
|
205
|
+
font: calc(var(--hy-font-size-xs, 10px) + 1px) var(--hy-font-family, system-ui, sans-serif);
|
|
199
206
|
}
|
|
200
|
-
.pagination
|
|
207
|
+
.pagination .pages { display: contents; }
|
|
201
208
|
.pagination button, .pagination select {
|
|
202
209
|
height: 30px;
|
|
203
|
-
|
|
204
|
-
border:
|
|
205
|
-
border-radius:
|
|
210
|
+
min-height: 0;
|
|
211
|
+
border-color: var(--hy-border-color, #3d4654);
|
|
212
|
+
border-radius: calc(var(--hy-radius-sm, 4px) + 1px);
|
|
206
213
|
color: var(--hy-secondary-text-color, #aebbd0);
|
|
207
214
|
background: var(--hy-surface-color, #171d27);
|
|
208
|
-
font: 11px system-ui, sans-serif;
|
|
209
215
|
}
|
|
210
|
-
.pagination button { min-width: 30px; padding: 0 8px;
|
|
216
|
+
.pagination button { min-width: 30px; padding: 0 var(--hy-space-4, 8px); }
|
|
211
217
|
.pagination button:hover:not(:disabled), .pagination button[aria-current="page"] { border-color: var(--hy-accent-color, #79a8ff); color: var(--hy-accent-color, #79a8ff); }
|
|
212
218
|
.pagination button:disabled { cursor: not-allowed; opacity: 0.45; }
|
|
213
|
-
.pagination select { margin-left: 6px; padding: 0
|
|
214
|
-
.summary { margin-
|
|
219
|
+
.pagination select { margin-left: var(--hy-space-3, 6px); padding: 0 calc(var(--hy-space-3, 6px) + 1px); }
|
|
220
|
+
.pagination .summary { margin-inline-end: auto; color: var(--hy-muted-text-color, var(--hy-muted-color, #788697)); font-size: var(--hy-font-size-xs, 10px); }
|
|
215
221
|
`;
|
|
216
222
|
this._scroller.className = 'scroller';
|
|
217
223
|
this._scroller.part.add('scroller');
|
|
218
224
|
this._table.part.add('table');
|
|
219
225
|
this._head.part.add('header');
|
|
220
226
|
this._body.part.add('body');
|
|
221
|
-
this._pagination.
|
|
222
|
-
this._pagination.part.add('pagination');
|
|
223
|
-
this._pagination.setAttribute('aria-label', 'Table pagination');
|
|
227
|
+
this._pagination.element.classList.add('pagination');
|
|
224
228
|
this._table.append(this._head, this._body);
|
|
225
229
|
this._scroller.append(this._table);
|
|
226
|
-
root.append(style, this._scroller, this._pagination);
|
|
230
|
+
root.append(style, this._scroller, this._pagination.element);
|
|
227
231
|
}
|
|
228
232
|
connectedCallback() {
|
|
229
233
|
this._syncAttributes();
|
|
230
|
-
this._render();
|
|
234
|
+
this._render(true);
|
|
231
235
|
}
|
|
232
|
-
attributeChangedCallback() {
|
|
236
|
+
attributeChangedCallback(name) {
|
|
233
237
|
if (this._reflecting)
|
|
234
238
|
return;
|
|
235
239
|
this._syncAttributes();
|
|
236
|
-
this._render();
|
|
240
|
+
this._render(name === undefined || name === 'show-filters');
|
|
237
241
|
}
|
|
238
242
|
get columns() { return this._columns; }
|
|
239
243
|
set columns(value) {
|
|
@@ -242,13 +246,11 @@ export class HYTable extends HTMLElement {
|
|
|
242
246
|
this._filters = Object.fromEntries(Object.entries(this._filters).filter(([key]) => keys.has(key)));
|
|
243
247
|
if (this._sort && !keys.has(this._sort.key))
|
|
244
248
|
this._sort = null;
|
|
245
|
-
this.
|
|
246
|
-
this._render();
|
|
249
|
+
this._render(true);
|
|
247
250
|
}
|
|
248
251
|
get dataSource() { return this._dataSource; }
|
|
249
252
|
set dataSource(value) {
|
|
250
253
|
this._dataSource = Array.isArray(value) ? [...value] : [];
|
|
251
|
-
this._clampPage();
|
|
252
254
|
this._renderBodyAndPagination();
|
|
253
255
|
}
|
|
254
256
|
get page() { return this._page; }
|
|
@@ -262,15 +264,13 @@ export class HYTable extends HTMLElement {
|
|
|
262
264
|
this._page = 1;
|
|
263
265
|
this._reflectNumber('page-size', next);
|
|
264
266
|
this._reflectNumber('page', 1);
|
|
265
|
-
this.
|
|
266
|
-
this._dispatchChange('paginate');
|
|
267
|
+
this._update('paginate');
|
|
267
268
|
}
|
|
268
269
|
get pageSizeOptions() { return this._pageSizeOptions; }
|
|
269
270
|
set pageSizeOptions(value) {
|
|
270
271
|
const options = positiveIntegerOptions(Array.isArray(value) ? value : []);
|
|
271
272
|
this._pageSizeOptions = options.length ? options : DEFAULT_PAGE_SIZE_OPTIONS;
|
|
272
273
|
this.setAttribute('page-size-options', this._pageSizeOptions.join(','));
|
|
273
|
-
this._renderPagination();
|
|
274
274
|
}
|
|
275
275
|
get pagination() { return this.getAttribute('pagination') !== 'false'; }
|
|
276
276
|
set pagination(value) { this.setAttribute('pagination', String(Boolean(value))); }
|
|
@@ -288,8 +288,7 @@ export class HYTable extends HTMLElement {
|
|
|
288
288
|
}
|
|
289
289
|
this._page = 1;
|
|
290
290
|
this._reflectNumber('page', 1);
|
|
291
|
-
this.
|
|
292
|
-
this._dispatchChange('sort');
|
|
291
|
+
this._update('sort');
|
|
293
292
|
}
|
|
294
293
|
get filters() { return { ...this._filters }; }
|
|
295
294
|
set filters(value) {
|
|
@@ -297,19 +296,20 @@ export class HYTable extends HTMLElement {
|
|
|
297
296
|
this._filters = Object.fromEntries(Object.entries(value ?? {}).filter(([key, filter]) => allowed.has(key) && String(filter).length > 0).map(([key, filter]) => [key, String(filter)]));
|
|
298
297
|
this._page = 1;
|
|
299
298
|
this._reflectNumber('page', 1);
|
|
300
|
-
this.
|
|
301
|
-
this._dispatchChange('filter');
|
|
299
|
+
this._update('filter');
|
|
302
300
|
}
|
|
303
301
|
get filteredData() { return this._processedRecords().map(item => item.record); }
|
|
304
302
|
get visibleData() { return this._visibleRecords().map(item => item.record); }
|
|
305
303
|
goToPage(value) {
|
|
306
|
-
const
|
|
304
|
+
const processed = this._processedRecords();
|
|
305
|
+
const count = this.pagination ? Math.max(1, Math.ceil(processed.length / this._pageSize)) : 1;
|
|
306
|
+
const next = Math.min(count, finiteInteger(value, 1));
|
|
307
307
|
if (next === this._page)
|
|
308
308
|
return;
|
|
309
309
|
this._page = next;
|
|
310
310
|
this._reflectNumber('page', next);
|
|
311
|
-
this._renderBodyAndPagination();
|
|
312
|
-
this._dispatchChange('paginate');
|
|
311
|
+
this._renderBodyAndPagination(processed);
|
|
312
|
+
this._dispatchChange('paginate', processed);
|
|
313
313
|
}
|
|
314
314
|
get pageCount() {
|
|
315
315
|
if (!this.pagination)
|
|
@@ -345,8 +345,7 @@ export class HYTable extends HTMLElement {
|
|
|
345
345
|
delete this._filters[key];
|
|
346
346
|
this._page = 1;
|
|
347
347
|
this._reflectNumber('page', 1);
|
|
348
|
-
this.
|
|
349
|
-
this._dispatchChange('filter');
|
|
348
|
+
this._update('filter');
|
|
350
349
|
}
|
|
351
350
|
clearFilters() {
|
|
352
351
|
if (Object.keys(this._filters).length === 0)
|
|
@@ -354,12 +353,11 @@ export class HYTable extends HTMLElement {
|
|
|
354
353
|
this._filters = {};
|
|
355
354
|
this._page = 1;
|
|
356
355
|
this._reflectNumber('page', 1);
|
|
357
|
-
this.
|
|
358
|
-
this._dispatchChange('filter');
|
|
356
|
+
this._update('filter');
|
|
359
357
|
}
|
|
360
358
|
_syncAttributes() {
|
|
361
|
-
this._pageSize = finiteInteger(this.getAttribute('page-size'),
|
|
362
|
-
this._page = finiteInteger(this.getAttribute('page'),
|
|
359
|
+
this._pageSize = finiteInteger(this.getAttribute('page-size'), DEFAULT_PAGE_SIZE);
|
|
360
|
+
this._page = finiteInteger(this.getAttribute('page'), 1);
|
|
363
361
|
if (this.hasAttribute('page-size-options')) {
|
|
364
362
|
const options = positiveIntegerOptions((this.getAttribute('page-size-options') ?? '').split(','));
|
|
365
363
|
if (options.length)
|
|
@@ -370,11 +368,42 @@ export class HYTable extends HTMLElement {
|
|
|
370
368
|
this._table.setAttribute('aria-label', label);
|
|
371
369
|
else
|
|
372
370
|
this._table.removeAttribute('aria-label');
|
|
373
|
-
this._clampPage();
|
|
374
371
|
}
|
|
375
|
-
|
|
376
|
-
this.
|
|
377
|
-
this.
|
|
372
|
+
_update(reason) {
|
|
373
|
+
const processed = this._processedRecords();
|
|
374
|
+
this._render(false, processed);
|
|
375
|
+
this._dispatchChange(reason, processed);
|
|
376
|
+
}
|
|
377
|
+
_render(rebuildHeader = false, processed = this._processedRecords()) {
|
|
378
|
+
if (rebuildHeader)
|
|
379
|
+
this._renderHeader();
|
|
380
|
+
this._syncHeaderState();
|
|
381
|
+
this._renderBodyAndPagination(processed);
|
|
382
|
+
}
|
|
383
|
+
_syncHeaderState() {
|
|
384
|
+
// Index alignment preserves duplicate column keys and each control's DOM identity.
|
|
385
|
+
const headers = this._head.querySelectorAll('th');
|
|
386
|
+
this._columns.forEach((column, index) => {
|
|
387
|
+
const header = headers[index];
|
|
388
|
+
if (!header)
|
|
389
|
+
return;
|
|
390
|
+
const indicator = header.querySelector('.sort-indicator');
|
|
391
|
+
if (indicator) {
|
|
392
|
+
const direction = this._sort?.key === column.key ? this._sort.direction : null;
|
|
393
|
+
indicator.textContent = direction === 'asc' ? '▲' : direction === 'desc' ? '▼' : '◆';
|
|
394
|
+
header.setAttribute('aria-sort', direction === 'asc' ? 'ascending' : direction === 'desc' ? 'descending' : 'none');
|
|
395
|
+
}
|
|
396
|
+
const value = this._filters[column.key] ?? '';
|
|
397
|
+
const control = header.querySelector('.filter');
|
|
398
|
+
if (control && control.value !== value)
|
|
399
|
+
control.value = value;
|
|
400
|
+
const trigger = header.querySelector('.filter-trigger');
|
|
401
|
+
if (trigger)
|
|
402
|
+
trigger.dataset.active = String(Boolean(value));
|
|
403
|
+
const clear = header.querySelector('.filter-clear');
|
|
404
|
+
if (clear)
|
|
405
|
+
clear.disabled = !value;
|
|
406
|
+
});
|
|
378
407
|
}
|
|
379
408
|
_renderHeader() {
|
|
380
409
|
const titleRow = document.createElement('tr');
|
|
@@ -504,12 +533,11 @@ export class HYTable extends HTMLElement {
|
|
|
504
533
|
delete this._filters[key];
|
|
505
534
|
this._page = 1;
|
|
506
535
|
this._reflectNumber('page', 1);
|
|
507
|
-
this.
|
|
508
|
-
this._dispatchChange('filter');
|
|
536
|
+
this._update('filter');
|
|
509
537
|
}
|
|
510
|
-
_renderBodyAndPagination() {
|
|
511
|
-
this._clampPage();
|
|
512
|
-
const rows = this._visibleRecords();
|
|
538
|
+
_renderBodyAndPagination(processed = this._processedRecords()) {
|
|
539
|
+
this._clampPage(processed);
|
|
540
|
+
const rows = this._visibleRecords(processed);
|
|
513
541
|
if (rows.length === 0) {
|
|
514
542
|
const row = document.createElement('tr');
|
|
515
543
|
row.part.add('empty-row');
|
|
@@ -527,7 +555,7 @@ export class HYTable extends HTMLElement {
|
|
|
527
555
|
else {
|
|
528
556
|
this._body.replaceChildren(...rows.map(item => this._createRow(item)));
|
|
529
557
|
}
|
|
530
|
-
this._renderPagination();
|
|
558
|
+
this._renderPagination(processed);
|
|
531
559
|
}
|
|
532
560
|
_createRow(item) {
|
|
533
561
|
const row = document.createElement('tr');
|
|
@@ -552,56 +580,12 @@ export class HYTable extends HTMLElement {
|
|
|
552
580
|
}
|
|
553
581
|
return row;
|
|
554
582
|
}
|
|
555
|
-
_renderPagination() {
|
|
556
|
-
|
|
557
|
-
this.
|
|
558
|
-
this.
|
|
559
|
-
|
|
560
|
-
}
|
|
561
|
-
this._pagination.hidden = false;
|
|
562
|
-
const processed = this._processedRecords();
|
|
563
|
-
const pageCount = Math.max(1, Math.ceil(processed.length / this._pageSize));
|
|
564
|
-
const summary = document.createElement('span');
|
|
565
|
-
summary.className = 'summary';
|
|
566
|
-
summary.part.add('summary');
|
|
567
|
-
const start = processed.length ? (this._page - 1) * this._pageSize + 1 : 0;
|
|
568
|
-
const end = Math.min(processed.length, this._page * this._pageSize);
|
|
569
|
-
summary.textContent = `${start}–${end} of ${processed.length}`;
|
|
570
|
-
const previous = this._pageButton('‹', 'Previous page', this._page - 1, this._page <= 1);
|
|
571
|
-
const pages = this._pageNumbers(pageCount).map(page => this._pageButton(String(page), `Page ${page}`, page, false, page === this._page));
|
|
572
|
-
const next = this._pageButton('›', 'Next page', this._page + 1, this._page >= pageCount);
|
|
573
|
-
const pageSize = document.createElement('select');
|
|
574
|
-
pageSize.part.add('page-size');
|
|
575
|
-
pageSize.setAttribute('aria-label', 'Rows per page');
|
|
576
|
-
const options = this._pageSizeOptions.includes(this._pageSize)
|
|
577
|
-
? this._pageSizeOptions
|
|
578
|
-
: [...this._pageSizeOptions, this._pageSize].sort((a, b) => a - b);
|
|
579
|
-
pageSize.append(...options.map(value => {
|
|
580
|
-
const option = document.createElement('option');
|
|
581
|
-
option.value = String(value);
|
|
582
|
-
option.textContent = `${value} / page`;
|
|
583
|
-
option.selected = value === this._pageSize;
|
|
584
|
-
return option;
|
|
585
|
-
}));
|
|
586
|
-
pageSize.addEventListener('change', () => { this.pageSize = Number(pageSize.value); });
|
|
587
|
-
this._pagination.replaceChildren(summary, previous, ...pages, next, pageSize);
|
|
588
|
-
}
|
|
589
|
-
_pageButton(text, label, page, disabled, current = false) {
|
|
590
|
-
const button = document.createElement('button');
|
|
591
|
-
button.type = 'button';
|
|
592
|
-
button.textContent = text;
|
|
593
|
-
button.disabled = disabled;
|
|
594
|
-
button.setAttribute('aria-label', label);
|
|
595
|
-
if (current)
|
|
596
|
-
button.setAttribute('aria-current', 'page');
|
|
597
|
-
button.addEventListener('click', () => this.goToPage(page));
|
|
598
|
-
return button;
|
|
599
|
-
}
|
|
600
|
-
_pageNumbers(pageCount) {
|
|
601
|
-
if (pageCount <= 7)
|
|
602
|
-
return Array.from({ length: pageCount }, (_, index) => index + 1);
|
|
603
|
-
const start = Math.max(1, Math.min(pageCount - 4, this._page - 2));
|
|
604
|
-
return Array.from({ length: 5 }, (_, index) => start + index);
|
|
583
|
+
_renderPagination(processed = this._processedRecords()) {
|
|
584
|
+
this._pagination.update({
|
|
585
|
+
page: this._page, pageSize: this._pageSize, total: processed.length,
|
|
586
|
+
pageSizeOptions: this._pageSizeOptions, label: 'Table pagination',
|
|
587
|
+
hidden: !this.pagination, showSizeChanger: true,
|
|
588
|
+
});
|
|
605
589
|
}
|
|
606
590
|
_processedRecords() {
|
|
607
591
|
let records = this._dataSource.map((record, index) => ({ record, index }));
|
|
@@ -633,15 +617,14 @@ export class HYTable extends HTMLElement {
|
|
|
633
617
|
}
|
|
634
618
|
return records;
|
|
635
619
|
}
|
|
636
|
-
_visibleRecords() {
|
|
637
|
-
const records = this._processedRecords();
|
|
620
|
+
_visibleRecords(records = this._processedRecords()) {
|
|
638
621
|
if (!this.pagination)
|
|
639
622
|
return records;
|
|
640
623
|
const start = (this._page - 1) * this._pageSize;
|
|
641
624
|
return records.slice(start, start + this._pageSize);
|
|
642
625
|
}
|
|
643
|
-
_clampPage() {
|
|
644
|
-
const total =
|
|
626
|
+
_clampPage(processed) {
|
|
627
|
+
const total = processed.length;
|
|
645
628
|
const pageCount = this.pagination ? Math.max(1, Math.ceil(total / this._pageSize)) : 1;
|
|
646
629
|
const next = Math.min(pageCount, Math.max(1, this._page));
|
|
647
630
|
if (next !== this._page) {
|
|
@@ -664,8 +647,7 @@ export class HYTable extends HTMLElement {
|
|
|
664
647
|
this.setAttribute(name, text);
|
|
665
648
|
this._reflecting = false;
|
|
666
649
|
}
|
|
667
|
-
_dispatchChange(reason) {
|
|
668
|
-
const processed = this._processedRecords();
|
|
650
|
+
_dispatchChange(reason, processed) {
|
|
669
651
|
const detail = {
|
|
670
652
|
reason,
|
|
671
653
|
page: this._page,
|
|
@@ -675,7 +657,7 @@ export class HYTable extends HTMLElement {
|
|
|
675
657
|
filteredTotal: processed.length,
|
|
676
658
|
sort: this.sort,
|
|
677
659
|
filters: this.filters,
|
|
678
|
-
visibleData: this.
|
|
660
|
+
visibleData: this._visibleRecords(processed).map(item => item.record),
|
|
679
661
|
};
|
|
680
662
|
this.dispatchEvent(new CustomEvent('table-change', {
|
|
681
663
|
bubbles: true, composed: true, detail,
|
package/dist/tabs.js
CHANGED
|
@@ -15,36 +15,36 @@ export class HYTabs extends HTMLElement {
|
|
|
15
15
|
:host {
|
|
16
16
|
box-sizing: border-box;
|
|
17
17
|
display: grid;
|
|
18
|
-
grid-template-rows:
|
|
18
|
+
grid-template-rows: calc(var(--hy-control-height-sm, 28px) + var(--hy-space-2, 4px)) minmax(0, 1fr);
|
|
19
19
|
width: 100%;
|
|
20
20
|
height: 100%;
|
|
21
21
|
min-width: 0;
|
|
22
22
|
min-height: 0;
|
|
23
23
|
color: var(--hy-text-color, #d8e2f2);
|
|
24
24
|
background: var(--hy-panel-bg-color, #171d28);
|
|
25
|
-
font: 12px system-ui, sans-serif;
|
|
25
|
+
font: var(--hy-font-size-sm, 12px) var(--hy-font-family, system-ui, sans-serif);
|
|
26
26
|
}
|
|
27
27
|
.tabs {
|
|
28
28
|
display: flex;
|
|
29
29
|
align-items: end;
|
|
30
|
-
gap: 2px;
|
|
30
|
+
gap: var(--hy-space-1, 2px);
|
|
31
31
|
min-width: 0;
|
|
32
32
|
overflow-x: auto;
|
|
33
33
|
overflow-y: hidden;
|
|
34
34
|
scrollbar-width: none;
|
|
35
|
-
padding: 4px 6px 0;
|
|
35
|
+
padding: var(--hy-space-2, 4px) var(--hy-space-3, 6px) 0;
|
|
36
36
|
border-bottom: 1px solid var(--hy-border-color, #303746);
|
|
37
37
|
background: var(--hy-tabs-bar-bg-color, var(--hy-menu-bg-color, var(--hy-surface-elevated-color, #1b2230)));
|
|
38
38
|
}
|
|
39
39
|
button {
|
|
40
|
-
height: 28px;
|
|
40
|
+
height: var(--hy-control-height-sm, 28px);
|
|
41
41
|
min-width: 0;
|
|
42
42
|
flex-shrink: 0;
|
|
43
43
|
white-space: nowrap;
|
|
44
|
-
padding: 0 10px;
|
|
44
|
+
padding: 0 var(--hy-space-5, 10px);
|
|
45
45
|
border: 1px solid transparent;
|
|
46
46
|
border-bottom: 0;
|
|
47
|
-
border-radius: 4px 4px 0 0;
|
|
47
|
+
border-radius: var(--hy-radius-sm, 4px) var(--hy-radius-sm, 4px) 0 0;
|
|
48
48
|
color: var(--hy-secondary-text-color, #8fa7c8);
|
|
49
49
|
background: transparent;
|
|
50
50
|
font: inherit;
|
package/dist/tag.js
CHANGED
|
@@ -34,13 +34,13 @@ export class HYTag extends HTMLElement {
|
|
|
34
34
|
min-height: var(--hy-tag-height, 24px);
|
|
35
35
|
box-sizing: border-box;
|
|
36
36
|
align-items: center;
|
|
37
|
-
gap: var(--hy-tag-gap,
|
|
38
|
-
padding: 2px var(--hy-tag-padding-inline, 8px);
|
|
37
|
+
gap: var(--hy-tag-gap, calc(var(--hy-space-2, 4px) + 1px));
|
|
38
|
+
padding: var(--hy-space-1, 2px) var(--hy-tag-padding-inline, var(--hy-space-4, 8px));
|
|
39
39
|
border: 1px solid color-mix(in srgb, var(--_tone) 42%, var(--hy-border-color, #303746));
|
|
40
|
-
border-radius: var(--hy-tag-radius,
|
|
40
|
+
border-radius: var(--hy-tag-radius, calc(var(--hy-radius-sm, 4px) + 1px));
|
|
41
41
|
color: var(--_tone);
|
|
42
42
|
background: var(--_surface);
|
|
43
|
-
font: 600 var(--hy-tag-font-size,
|
|
43
|
+
font: var(--hy-font-weight-semibold, 600) var(--hy-tag-font-size, calc(var(--hy-font-size-xs, 10px) + 1px))/calc(var(--hy-line-height-snug, 1.4) - 0.05) var(--hy-font-family, system-ui, sans-serif);
|
|
44
44
|
transition: border-color 120ms ease, box-shadow 120ms ease, color 120ms ease, background 120ms ease;
|
|
45
45
|
}
|
|
46
46
|
.tag[data-variant="primary"] { --_tone: var(--hy-accent-color, #79a8ff); }
|
|
@@ -56,8 +56,8 @@ export class HYTag extends HTMLElement {
|
|
|
56
56
|
:host(:focus-visible) { outline: none; }
|
|
57
57
|
:host(:focus-visible) .tag { box-shadow: 0 0 0 2px var(--hy-focus-ring-color, rgba(61, 111, 168, .24)); }
|
|
58
58
|
:host([disabled]) { pointer-events: none; opacity: .5; }
|
|
59
|
-
:host([size="small"]) .tag { --hy-tag-height: 20px; --hy-tag-padding-inline: 6px; --hy-tag-font-size: 10px; }
|
|
60
|
-
:host([size="large"]) .tag { --hy-tag-height: 30px; --hy-tag-padding-inline:
|
|
59
|
+
:host([size="small"]) .tag { --hy-tag-height: 20px; --hy-tag-padding-inline: var(--hy-space-3, 6px); --hy-tag-font-size: var(--hy-font-size-xs, 10px); }
|
|
60
|
+
:host([size="large"]) .tag { --hy-tag-height: 30px; --hy-tag-padding-inline: calc(var(--hy-space-5, 10px) + 1px); --hy-tag-font-size: var(--hy-font-size-sm, 12px); }
|
|
61
61
|
.icon { display: inline-flex; flex: 0 0 auto; align-items: center; justify-content: center; }
|
|
62
62
|
.icon[hidden] { display: none; }
|
|
63
63
|
.label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
@@ -65,7 +65,7 @@ export class HYTag extends HTMLElement {
|
|
|
65
65
|
display: none;
|
|
66
66
|
width: 16px;
|
|
67
67
|
height: 16px;
|
|
68
|
-
margin-inline-end: -
|
|
68
|
+
margin-inline-end: calc(-1 * calc(var(--hy-space-1, 2px) + 1px));
|
|
69
69
|
padding: 0;
|
|
70
70
|
border: 0;
|
|
71
71
|
border-radius: 50%;
|
|
@@ -73,7 +73,7 @@ export class HYTag extends HTMLElement {
|
|
|
73
73
|
color: currentColor;
|
|
74
74
|
background: transparent;
|
|
75
75
|
cursor: pointer;
|
|
76
|
-
font:
|
|
76
|
+
font: calc(var(--hy-font-size-md, 14px) + 1px)/var(--hy-line-height-tight, 1) var(--hy-font-family, system-ui, sans-serif);
|
|
77
77
|
}
|
|
78
78
|
:host([closable]) .close { display: grid; }
|
|
79
79
|
.close:hover { background: color-mix(in srgb, currentColor 16%, transparent); }
|
package/dist/time-picker.js
CHANGED
|
@@ -37,27 +37,27 @@ export class HYTimePicker extends HTMLElement {
|
|
|
37
37
|
const root = this.attachShadow({ mode: 'open' });
|
|
38
38
|
const style = document.createElement('style');
|
|
39
39
|
style.textContent = `
|
|
40
|
-
:host { position: relative; display: inline-block; min-width: 150px; color: var(--hy-text-color, #eef3ff); font: 12px/1.4 system-ui, sans-serif; }
|
|
41
|
-
.control { display: grid; grid-template-columns: minmax(0, 1fr) auto; height: var(--hy-time-picker-height, 34px); box-sizing: border-box; border: 1px solid var(--hy-border-color, #3d4654); border-radius: var(--hy-time-picker-radius, 6px); background: var(--hy-input-bg-color, #111722); }
|
|
40
|
+
:host { position: relative; display: inline-block; min-width: 150px; color: var(--hy-text-color, #eef3ff); font: var(--hy-font-size-sm, 12px)/var(--hy-line-height-snug, 1.4) var(--hy-font-family, system-ui, sans-serif); }
|
|
41
|
+
.control { display: grid; grid-template-columns: minmax(0, 1fr) auto; height: var(--hy-time-picker-height, var(--hy-control-height-md, 34px)); box-sizing: border-box; border: 1px solid var(--hy-border-color, #3d4654); border-radius: var(--hy-time-picker-radius, var(--hy-radius-md, 6px)); background: var(--hy-input-bg-color, #111722); }
|
|
42
42
|
:host(:not([disabled])) .control:hover { border-color: var(--hy-hover-border-color, #596779); }
|
|
43
43
|
:host(:focus-within) .control, :host([open]) .control { border-color: var(--hy-focus-border-color, #79a8ff); box-shadow: 0 0 0 2px var(--hy-focus-ring-color, rgba(121, 168, 255, .22)); }
|
|
44
|
-
.trigger { display: flex; min-width: 0; align-items: center; gap: 8px; padding: 0 8px 0 10px; overflow: hidden; border: 0; color: inherit; background: transparent; cursor: pointer; font: inherit; text-align: left; }
|
|
44
|
+
.trigger { display: flex; min-width: 0; align-items: center; gap: var(--hy-space-4, 8px); padding: 0 var(--hy-space-4, 8px) 0 var(--hy-space-5, 10px); overflow: hidden; border: 0; color: inherit; background: transparent; cursor: pointer; font: inherit; text-align: left; }
|
|
45
45
|
.label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
46
46
|
.label.placeholder { color: var(--hy-muted-color, #788697); }
|
|
47
|
-
.arrow { color: var(--hy-muted-color, #788697); font-size: 14px; }
|
|
48
|
-
.clear { width: 28px; padding: 0; border: 0; color: var(--hy-muted-color, #788697); background: transparent; cursor: pointer; font:
|
|
47
|
+
.arrow { color: var(--hy-muted-color, #788697); font-size: var(--hy-font-size-md, 14px); }
|
|
48
|
+
.clear { width: 28px; padding: 0; border: 0; color: var(--hy-muted-color, #788697); background: transparent; cursor: pointer; font: calc(var(--hy-font-size-md, 14px) + 1px)/var(--hy-line-height-tight, 1) var(--hy-font-family, system-ui, sans-serif); }
|
|
49
49
|
.clear:hover { color: var(--hy-text-color, #eef3ff); } .clear[hidden], .panel[hidden] { display: none; }
|
|
50
50
|
.trigger:focus-visible, .clear:focus-visible { outline: none; }
|
|
51
51
|
:host([disabled]) { opacity: .52; } :host([disabled]) .trigger, :host([disabled]) .clear { cursor: not-allowed; }
|
|
52
|
-
.panel { position: absolute; z-index: var(--hy-time-picker-z-index, 50); top: calc(100% + 6px); left: 0; width: max-content; min-width: 100%; box-sizing: border-box; border: 1px solid var(--hy-border-color, #3d4654); border-radius: var(--hy-time-picker-panel-radius, 8px); background: var(--hy-menu-bg-color, var(--hy-surface-elevated-color, #171d27)); box-shadow: 0 12px 32px var(--hy-menu-shadow-color, rgba(0, 0, 0, .36)); }
|
|
52
|
+
.panel { position: absolute; z-index: var(--hy-time-picker-z-index, 50); top: calc(100% + 6px); left: 0; width: max-content; min-width: 100%; box-sizing: border-box; border: 1px solid var(--hy-border-color, #3d4654); border-radius: var(--hy-time-picker-panel-radius, var(--hy-radius-lg, 8px)); background: var(--hy-menu-bg-color, var(--hy-surface-elevated-color, #171d27)); box-shadow: 0 12px 32px var(--hy-menu-shadow-color, rgba(0, 0, 0, .36)); }
|
|
53
53
|
.columns { display: flex; height: var(--hy-time-picker-panel-height, 196px); overflow: hidden; }
|
|
54
|
-
.column { width: var(--hy-time-picker-column-width, 58px); margin: 0; padding: 4px; overflow-y: auto; list-style: none; scrollbar-color: var(--hy-border-strong-color, #596779) transparent; scrollbar-width: thin; }
|
|
54
|
+
.column { width: var(--hy-time-picker-column-width, 58px); margin: 0; padding: var(--hy-space-2, 4px); overflow-y: auto; list-style: none; scrollbar-color: var(--hy-border-strong-color, #596779) transparent; scrollbar-width: thin; }
|
|
55
55
|
.column + .column { border-left: 1px solid var(--hy-border-color, #3d4654); }
|
|
56
|
-
.option { width: 100%; height: 30px; padding: 0; border: 0; border-radius: 4px; color: var(--hy-secondary-text-color, #aebbd0); background: transparent; cursor: pointer; font: inherit; }
|
|
56
|
+
.option { width: 100%; height: 30px; padding: 0; border: 0; border-radius: var(--hy-radius-sm, 4px); color: var(--hy-secondary-text-color, #aebbd0); background: transparent; cursor: pointer; font: inherit; }
|
|
57
57
|
.option:hover, .option:focus-visible { outline: none; color: var(--hy-text-color, #eef3ff); background: var(--hy-hover-bg-color, #273241); }
|
|
58
58
|
.option[aria-selected="true"] { color: var(--hy-selected-text-color, #fff); background: var(--hy-selected-bg-color, #554cc6); }
|
|
59
|
-
.footer { display: flex; justify-content: space-between; gap: 8px; padding:
|
|
60
|
-
.footer button { min-width: 42px; height: 27px; padding: 0 8px; border: 1px solid transparent; border-radius: 4px; color: var(--hy-accent-color, #79a8ff); background: transparent; cursor: pointer; font: inherit; }
|
|
59
|
+
.footer { display: flex; justify-content: space-between; gap: var(--hy-space-4, 8px); padding: calc(var(--hy-space-3, 6px) + 1px) var(--hy-space-4, 8px); border-top: 1px solid var(--hy-border-color, #3d4654); }
|
|
60
|
+
.footer button { min-width: 42px; height: 27px; padding: 0 var(--hy-space-4, 8px); border: 1px solid transparent; border-radius: var(--hy-radius-sm, 4px); color: var(--hy-accent-color, #79a8ff); background: transparent; cursor: pointer; font: inherit; }
|
|
61
61
|
.footer button:hover:not(:disabled) { background: var(--hy-hover-bg-color, #273241); }
|
|
62
62
|
.footer .confirm { color: var(--hy-selected-text-color, #fff); background: var(--hy-selected-bg-color, #554cc6); }
|
|
63
63
|
.footer button:focus-visible { outline: 2px solid var(--hy-focus-border-color, #79a8ff); outline-offset: 1px; }
|
|
@@ -169,6 +169,10 @@ export class HYTimePicker extends HTMLElement {
|
|
|
169
169
|
this._draft = { hour: now.getHours(), minute: Math.floor(now.getMinutes() / this.minuteStep) * this.minuteStep, second: Math.floor(now.getSeconds() / this.secondStep) * this.secondStep };
|
|
170
170
|
}
|
|
171
171
|
_render() {
|
|
172
|
+
if (this.disabled && this.open) {
|
|
173
|
+
this.open = false;
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
172
176
|
this._label.textContent = this._value || this.placeholder;
|
|
173
177
|
this._label.classList.toggle('placeholder', !this._value);
|
|
174
178
|
this._trigger.disabled = this.disabled;
|
|
@@ -276,6 +280,8 @@ export class HYTimePicker extends HTMLElement {
|
|
|
276
280
|
}
|
|
277
281
|
_focusSelected(columnIndex) { this._panel.querySelectorAll('.column')[columnIndex]?.querySelector('[aria-selected="true"]')?.focus(); }
|
|
278
282
|
_commit(value) {
|
|
283
|
+
if (this.disabled)
|
|
284
|
+
return;
|
|
279
285
|
this._value = this._normalizeValue(value);
|
|
280
286
|
this._reflectValue();
|
|
281
287
|
if (this.open)
|