@20baht/spreadsheet 0.3.1 → 0.3.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.
|
@@ -251,6 +251,17 @@
|
|
|
251
251
|
"privacy": "private",
|
|
252
252
|
"readonly": true
|
|
253
253
|
},
|
|
254
|
+
{
|
|
255
|
+
"kind": "method",
|
|
256
|
+
"name": "placeMenu",
|
|
257
|
+
"privacy": "private",
|
|
258
|
+
"return": {
|
|
259
|
+
"type": {
|
|
260
|
+
"text": "void"
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
"description": "The menu opens at the pointer, and turns back over it where it would leave the element\n(which clips it): near the right edge it opens to the left, near the bottom upwards. It\ngrows from the corner at the pointer, so the origin follows the side it turned to."
|
|
264
|
+
},
|
|
254
265
|
{
|
|
255
266
|
"kind": "method",
|
|
256
267
|
"name": "barFocused",
|
|
@@ -101,6 +101,12 @@ export declare class BahtSpreadsheet extends BahtElement {
|
|
|
101
101
|
private get values();
|
|
102
102
|
protected willUpdate(changed: PropertyValues<this>): void;
|
|
103
103
|
protected updated(): void;
|
|
104
|
+
/**
|
|
105
|
+
* The menu opens at the pointer, and turns back over it where it would leave the element
|
|
106
|
+
* (which clips it): near the right edge it opens to the left, near the bottom upwards. It
|
|
107
|
+
* grows from the corner at the pointer, so the origin follows the side it turned to.
|
|
108
|
+
*/
|
|
109
|
+
private placeMenu;
|
|
104
110
|
private barFocused;
|
|
105
111
|
private send;
|
|
106
112
|
private grid;
|
|
@@ -366,6 +366,22 @@ let BahtSpreadsheet = class BahtSpreadsheet extends BahtElement {
|
|
|
366
366
|
editor.focus();
|
|
367
367
|
editor.setSelectionRange(editor.value.length, editor.value.length);
|
|
368
368
|
}
|
|
369
|
+
this.placeMenu();
|
|
370
|
+
}
|
|
371
|
+
placeMenu() {
|
|
372
|
+
const box = this.querySelector('.baht-spreadsheet-menu');
|
|
373
|
+
if (!box || !this.menu)
|
|
374
|
+
return;
|
|
375
|
+
const at = `${this.menu.x},${this.menu.y}`;
|
|
376
|
+
if (box.dataset.at === at)
|
|
377
|
+
return;
|
|
378
|
+
box.dataset.at = at;
|
|
379
|
+
const { x, y } = this.menu;
|
|
380
|
+
const left = x + box.offsetWidth > this.clientWidth;
|
|
381
|
+
const up = y + box.offsetHeight > this.clientHeight;
|
|
382
|
+
box.style.left = `${left ? Math.max(0, x - box.offsetWidth) : x}px`;
|
|
383
|
+
box.style.top = `${up ? Math.max(0, y - box.offsetHeight) : y}px`;
|
|
384
|
+
box.style.transformOrigin = `${left ? 'right' : 'left'} ${up ? 'bottom' : 'top'}`;
|
|
369
385
|
}
|
|
370
386
|
barFocused() {
|
|
371
387
|
return document.activeElement?.classList.contains('baht-spreadsheet-bar-input') === true;
|
|
@@ -712,7 +728,12 @@ let BahtSpreadsheet = class BahtSpreadsheet extends BahtElement {
|
|
|
712
728
|
: failed
|
|
713
729
|
? words.loadFailed
|
|
714
730
|
: words.readOnlyData;
|
|
715
|
-
return html `<div
|
|
731
|
+
return html `<div
|
|
732
|
+
class="baht-spreadsheet-notice"
|
|
733
|
+
role="status"
|
|
734
|
+
?data-failed=${failed}
|
|
735
|
+
?data-loading=${this.pending.has(sheet.key)}
|
|
736
|
+
>
|
|
716
737
|
<span>${text}</span>
|
|
717
738
|
<button
|
|
718
739
|
type="button"
|
package/dist/spreadsheet.css
CHANGED
|
@@ -18,6 +18,8 @@ baht-spreadsheet {
|
|
|
18
18
|
color: var(--baht-color-text, #1a2233);
|
|
19
19
|
overflow: hidden;
|
|
20
20
|
position: relative;
|
|
21
|
+
/* the library's own ease: quick start, gentle settle */
|
|
22
|
+
--baht-spreadsheet-ease: var(--baht-ease, cubic-bezier(0.23, 1, 0.32, 1));
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
/* ---- tools ---- */
|
|
@@ -49,9 +51,37 @@ baht-spreadsheet {
|
|
|
49
51
|
font: inherit;
|
|
50
52
|
color: inherit;
|
|
51
53
|
cursor: pointer;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
transition:
|
|
55
|
+
background-color 120ms ease,
|
|
56
|
+
color 120ms ease,
|
|
57
|
+
transform 160ms var(--baht-spreadsheet-ease);
|
|
58
|
+
}
|
|
59
|
+
@media (hover: hover) and (pointer: fine) {
|
|
60
|
+
.baht-spreadsheet-tool:hover:not(:disabled),
|
|
61
|
+
.baht-spreadsheet-colour:hover {
|
|
62
|
+
background: var(--baht-color-primary-wash, #eef4ff);
|
|
63
|
+
}
|
|
64
|
+
.baht-spreadsheet-format:hover:not(:disabled) {
|
|
65
|
+
border-color: var(--baht-color-text-muted, #5b6679);
|
|
66
|
+
}
|
|
67
|
+
.baht-spreadsheet-tab:hover:not([aria-selected='true']) {
|
|
68
|
+
color: var(--baht-color-text, #1a2233);
|
|
69
|
+
background: color-mix(in srgb, var(--baht-color-surface, #fff) 60%, transparent);
|
|
70
|
+
}
|
|
71
|
+
/* a heading says it can be clicked, before it is */
|
|
72
|
+
.baht-spreadsheet-grid th:not([data-selected]):hover {
|
|
73
|
+
background: color-mix(
|
|
74
|
+
in srgb,
|
|
75
|
+
var(--baht-color-text, #1a2233) 6%,
|
|
76
|
+
var(--baht-color-surface-alt, #f3f5f9)
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/* pressed: the button gives a little under the pointer */
|
|
81
|
+
.baht-spreadsheet-tool:active:not(:disabled),
|
|
82
|
+
.baht-spreadsheet-colour:active {
|
|
83
|
+
transform: scale(0.94);
|
|
84
|
+
background: var(--baht-color-primary-wash-active, #e2e9f5);
|
|
55
85
|
}
|
|
56
86
|
.baht-spreadsheet-tool[aria-pressed='true'] {
|
|
57
87
|
border-color: var(--baht-color-primary, #0755d9);
|
|
@@ -88,8 +118,19 @@ baht-spreadsheet {
|
|
|
88
118
|
border-radius: var(--baht-radius-sm, 6px);
|
|
89
119
|
cursor: pointer;
|
|
90
120
|
}
|
|
91
|
-
.baht-spreadsheet-colour
|
|
92
|
-
|
|
121
|
+
.baht-spreadsheet-colour {
|
|
122
|
+
transition:
|
|
123
|
+
background-color 120ms ease,
|
|
124
|
+
transform 160ms var(--baht-spreadsheet-ease);
|
|
125
|
+
}
|
|
126
|
+
/* the colour input is invisible: its label carries the keyboard's ring */
|
|
127
|
+
.baht-spreadsheet-colour:has(input:focus-visible) {
|
|
128
|
+
outline: 2px solid var(--baht-color-primary, #0755d9);
|
|
129
|
+
outline-offset: 1px;
|
|
130
|
+
}
|
|
131
|
+
.baht-spreadsheet-colour:has(input:disabled) {
|
|
132
|
+
opacity: 0.4;
|
|
133
|
+
pointer-events: none;
|
|
93
134
|
}
|
|
94
135
|
.baht-spreadsheet-colour input {
|
|
95
136
|
position: absolute;
|
|
@@ -121,6 +162,12 @@ baht-spreadsheet {
|
|
|
121
162
|
font: inherit;
|
|
122
163
|
font-size: var(--baht-text-xs, 12px);
|
|
123
164
|
color: inherit;
|
|
165
|
+
cursor: pointer;
|
|
166
|
+
transition: border-color 120ms ease;
|
|
167
|
+
}
|
|
168
|
+
.baht-spreadsheet-format:disabled {
|
|
169
|
+
opacity: 0.4;
|
|
170
|
+
cursor: default;
|
|
124
171
|
}
|
|
125
172
|
|
|
126
173
|
/* ---- the formula bar ---- */
|
|
@@ -133,6 +180,8 @@ baht-spreadsheet {
|
|
|
133
180
|
}
|
|
134
181
|
.baht-spreadsheet-name {
|
|
135
182
|
min-width: 72px;
|
|
183
|
+
padding-right: var(--baht-space-2, 8px);
|
|
184
|
+
border-right: 1px solid var(--baht-color-border, #d6dce8);
|
|
136
185
|
font-size: var(--baht-text-xs, 12px);
|
|
137
186
|
font-variant-numeric: tabular-nums;
|
|
138
187
|
color: var(--baht-color-text-muted, #5b6679);
|
|
@@ -153,6 +202,14 @@ baht-spreadsheet {
|
|
|
153
202
|
font: inherit;
|
|
154
203
|
color: inherit;
|
|
155
204
|
}
|
|
205
|
+
.baht-spreadsheet-bar-input {
|
|
206
|
+
transition: border-color 120ms ease;
|
|
207
|
+
}
|
|
208
|
+
@media (hover: hover) and (pointer: fine) {
|
|
209
|
+
.baht-spreadsheet-bar-input:not(:read-only):hover {
|
|
210
|
+
border-color: var(--baht-color-border, #d6dce8);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
156
213
|
.baht-spreadsheet-bar-input:focus {
|
|
157
214
|
outline: none;
|
|
158
215
|
border-color: var(--baht-color-primary, #0755d9);
|
|
@@ -168,14 +225,56 @@ baht-spreadsheet {
|
|
|
168
225
|
background: var(--baht-color-primary-wash, #eef4ff);
|
|
169
226
|
font-size: var(--baht-text-xs, 12px);
|
|
170
227
|
}
|
|
228
|
+
.baht-spreadsheet-notice {
|
|
229
|
+
position: relative;
|
|
230
|
+
}
|
|
231
|
+
/* loading: a thin bar runs along the notice's foot while the rows come in */
|
|
232
|
+
.baht-spreadsheet-notice[data-loading]::after {
|
|
233
|
+
content: '';
|
|
234
|
+
position: absolute;
|
|
235
|
+
left: 0;
|
|
236
|
+
bottom: -1px;
|
|
237
|
+
width: 30%;
|
|
238
|
+
height: 2px;
|
|
239
|
+
background: var(--baht-color-primary, #0755d9);
|
|
240
|
+
animation: baht-spreadsheet-loading 1.1s linear infinite;
|
|
241
|
+
}
|
|
242
|
+
@keyframes baht-spreadsheet-loading {
|
|
243
|
+
from {
|
|
244
|
+
transform: translateX(-100%);
|
|
245
|
+
}
|
|
246
|
+
to {
|
|
247
|
+
transform: translateX(340%);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
@media (prefers-reduced-motion: reduce) {
|
|
251
|
+
.baht-spreadsheet-notice[data-loading]::after {
|
|
252
|
+
width: 100%;
|
|
253
|
+
animation: baht-spreadsheet-breathe 1.6s ease-in-out infinite alternate;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
@keyframes baht-spreadsheet-breathe {
|
|
257
|
+
from {
|
|
258
|
+
opacity: 0.25;
|
|
259
|
+
}
|
|
260
|
+
to {
|
|
261
|
+
opacity: 0.8;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
171
264
|
.baht-spreadsheet-notice[data-failed] {
|
|
172
265
|
background: color-mix(in srgb, var(--baht-color-danger, #b42318) 12%, transparent);
|
|
173
266
|
color: var(--baht-color-danger, #b42318);
|
|
174
267
|
}
|
|
175
268
|
.baht-spreadsheet-notice .baht-spreadsheet-tool {
|
|
176
|
-
|
|
269
|
+
height: 24px;
|
|
270
|
+
padding: 0 var(--baht-space-2, 8px);
|
|
271
|
+
border-color: var(--baht-color-border, #d6dce8);
|
|
272
|
+
background: var(--baht-color-surface, #fff);
|
|
177
273
|
font-size: var(--baht-text-xs, 12px);
|
|
178
274
|
}
|
|
275
|
+
.baht-spreadsheet-notice[data-failed] .baht-spreadsheet-tool {
|
|
276
|
+
border-color: currentColor;
|
|
277
|
+
}
|
|
179
278
|
|
|
180
279
|
/* ---- the grid ---- */
|
|
181
280
|
.baht-spreadsheet-scroll {
|
|
@@ -273,6 +372,12 @@ baht-spreadsheet {
|
|
|
273
372
|
cursor: crosshair;
|
|
274
373
|
touch-action: none;
|
|
275
374
|
}
|
|
375
|
+
/* an 8px square to see, a 16px one to hit */
|
|
376
|
+
.baht-spreadsheet-handle::before {
|
|
377
|
+
content: '';
|
|
378
|
+
position: absolute;
|
|
379
|
+
inset: -5px;
|
|
380
|
+
}
|
|
276
381
|
.baht-spreadsheet-grid td[data-error] {
|
|
277
382
|
color: var(--baht-color-danger, #b42318);
|
|
278
383
|
}
|
|
@@ -290,6 +395,27 @@ baht-spreadsheet {
|
|
|
290
395
|
cursor: col-resize;
|
|
291
396
|
touch-action: none;
|
|
292
397
|
}
|
|
398
|
+
/* the column's edge lights up where it can be dragged, and while it is */
|
|
399
|
+
.baht-spreadsheet-resize::after {
|
|
400
|
+
content: '';
|
|
401
|
+
position: absolute;
|
|
402
|
+
top: 3px;
|
|
403
|
+
bottom: 3px;
|
|
404
|
+
left: 2px;
|
|
405
|
+
width: 3px;
|
|
406
|
+
border-radius: 2px;
|
|
407
|
+
background: var(--baht-color-primary, #0755d9);
|
|
408
|
+
opacity: 0;
|
|
409
|
+
transition: opacity 120ms ease;
|
|
410
|
+
}
|
|
411
|
+
.baht-spreadsheet-resize:active::after {
|
|
412
|
+
opacity: 1;
|
|
413
|
+
}
|
|
414
|
+
@media (hover: hover) and (pointer: fine) {
|
|
415
|
+
.baht-spreadsheet-resize:hover::after {
|
|
416
|
+
opacity: 1;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
293
419
|
.baht-spreadsheet-editor {
|
|
294
420
|
position: absolute;
|
|
295
421
|
inset: 0;
|
|
@@ -311,7 +437,7 @@ baht-spreadsheet {
|
|
|
311
437
|
flex-wrap: wrap;
|
|
312
438
|
align-items: center;
|
|
313
439
|
gap: 2px;
|
|
314
|
-
padding:
|
|
440
|
+
padding: 0 var(--baht-space-2, 8px) 2px;
|
|
315
441
|
border-top: 1px solid var(--baht-color-border, #d6dce8);
|
|
316
442
|
background: var(--baht-color-surface-alt, #f3f5f9);
|
|
317
443
|
}
|
|
@@ -320,16 +446,24 @@ baht-spreadsheet {
|
|
|
320
446
|
display: inline-flex;
|
|
321
447
|
align-items: center;
|
|
322
448
|
gap: 6px;
|
|
323
|
-
|
|
449
|
+
height: 30px;
|
|
450
|
+
padding: 0 var(--baht-space-3, 12px);
|
|
324
451
|
border: 0;
|
|
325
|
-
border-
|
|
452
|
+
border-radius: 0 0 var(--baht-radius-sm, 6px) var(--baht-radius-sm, 6px);
|
|
326
453
|
background: none;
|
|
327
454
|
font: inherit;
|
|
328
455
|
color: var(--baht-color-text-muted, #5b6679);
|
|
329
456
|
cursor: pointer;
|
|
457
|
+
transition:
|
|
458
|
+
background-color 120ms ease,
|
|
459
|
+
color 120ms ease;
|
|
330
460
|
}
|
|
461
|
+
/* the shown sheet hangs from the grid: white like it, its mark on the edge they share */
|
|
331
462
|
.baht-spreadsheet-tab[aria-selected='true'] {
|
|
332
|
-
|
|
463
|
+
margin-top: -1px;
|
|
464
|
+
box-shadow:
|
|
465
|
+
inset 0 2px 0 var(--baht-color-primary, #0755d9),
|
|
466
|
+
0 1px 2px rgba(var(--baht-color-shadow-ink, 0, 0, 0), 0.06);
|
|
333
467
|
background: var(--baht-color-surface, #fff);
|
|
334
468
|
color: var(--baht-color-text, #1a2233);
|
|
335
469
|
font-weight: 600;
|
|
@@ -347,6 +481,9 @@ baht-spreadsheet {
|
|
|
347
481
|
.baht-spreadsheet-rename {
|
|
348
482
|
width: 120px;
|
|
349
483
|
height: 26px;
|
|
484
|
+
margin: 2px 0 0;
|
|
485
|
+
outline: none;
|
|
486
|
+
box-shadow: 0 0 0 3px var(--baht-color-primary-wash, #eef4ff);
|
|
350
487
|
padding: 0 var(--baht-space-2, 8px);
|
|
351
488
|
border: 1px solid var(--baht-color-primary, #0755d9);
|
|
352
489
|
border-radius: var(--baht-radius-sm, 6px);
|
|
@@ -363,7 +500,24 @@ baht-spreadsheet {
|
|
|
363
500
|
border: 1px solid var(--baht-color-border, #d6dce8);
|
|
364
501
|
border-radius: var(--baht-radius-md, 8px);
|
|
365
502
|
background: var(--baht-color-surface, #fff);
|
|
366
|
-
box-shadow: 0 8px 24px rgb(0 0 0 / 18%);
|
|
503
|
+
box-shadow: var(--baht-shadow-float, 0 8px 24px rgb(0 0 0 / 18%));
|
|
504
|
+
/* it grows from the pointer (placeMenu sets the corner); quick, it is opened often */
|
|
505
|
+
transform-origin: left top;
|
|
506
|
+
transition:
|
|
507
|
+
opacity 120ms var(--baht-spreadsheet-ease),
|
|
508
|
+
transform 140ms var(--baht-spreadsheet-ease);
|
|
509
|
+
@starting-style {
|
|
510
|
+
opacity: 0;
|
|
511
|
+
transform: scale(0.96);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
@media (prefers-reduced-motion: reduce) {
|
|
515
|
+
.baht-spreadsheet-menu {
|
|
516
|
+
transition: opacity 120ms ease;
|
|
517
|
+
@starting-style {
|
|
518
|
+
transform: none;
|
|
519
|
+
}
|
|
520
|
+
}
|
|
367
521
|
}
|
|
368
522
|
.baht-spreadsheet-menu button {
|
|
369
523
|
appearance: none;
|
|
@@ -384,3 +538,10 @@ baht-spreadsheet {
|
|
|
384
538
|
background: var(--baht-color-primary-wash, #eef4ff);
|
|
385
539
|
outline: none;
|
|
386
540
|
}
|
|
541
|
+
.baht-spreadsheet-menu button:active {
|
|
542
|
+
background: var(--baht-color-primary-wash-active, #e2e9f5);
|
|
543
|
+
}
|
|
544
|
+
.baht-spreadsheet-menu svg {
|
|
545
|
+
flex: none;
|
|
546
|
+
color: var(--baht-color-text-muted, #5b6679);
|
|
547
|
+
}
|