@chocbite/ts-lib-ui 1.1.0 → 1.1.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/AGENTS.md +13 -5
- package/SOURCE.md +201 -45
- package/base/index.d.mts +1 -1
- package/canvas/index.d.mts +1 -1
- package/canvas/index.mjs +1 -1
- package/context-menu/index.d.mts +1 -1
- package/context-menu/index.mjs +1 -1
- package/{context-menu-DE3EUtY8.mjs → context-menu-hHRJ33Lu.mjs} +2 -2
- package/{context-menu-DE3EUtY8.mjs.map → context-menu-hHRJ33Lu.mjs.map} +1 -1
- package/form/index.d.mts +3 -3
- package/form/index.mjs +2 -2
- package/icons/index.d.mts +1 -1
- package/{index-YNZjMIO7.d.mts → index-76zZKjTH.d.mts} +2 -2
- package/{index-BDWg5GX2.d.mts → index-ClIBfrHy.d.mts} +2 -2
- package/{index-CvzH3M_5.d.mts → index-ClfL2SQR.d.mts} +2 -2
- package/{index-Cw4AcuUl.d.mts → index-D6L_jK1x.d.mts} +20 -6
- package/keyboard/index.d.mts +1 -1
- package/keyboard/index.mjs +1 -1
- package/list/index.d.mts +1 -1
- package/list/index.mjs +1 -1
- package/{list-D08epOjk.mjs → list-Bic1UzeC.mjs} +106 -32
- package/list-Bic1UzeC.mjs.map +1 -0
- package/package.json +2 -2
- package/spinner/index.d.mts +1 -1
- package/spinner/index.mjs +1 -1
- package/style.css +43 -1
- package/svg/index.d.mts +1 -1
- package/test/index.d.mts +1 -1
- package/theme/index.d.mts +1 -1
- package/theme/index.mjs +1 -1
- package/{theme-BJS5z1iW.mjs → theme-DilOXXDu.mjs} +2 -2
- package/{theme-BJS5z1iW.mjs.map → theme-DilOXXDu.mjs.map} +1 -1
- package/list-D08epOjk.mjs.map +0 -1
package/AGENTS.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @chocbite/ts-lib-ui, notes for agents
|
|
2
2
|
|
|
3
|
-
@chocbite/ts-lib-ui 1.1.
|
|
3
|
+
@chocbite/ts-lib-ui 1.1.1, built from ssh://git@forgejo.nsns.dk:2222/chocbite/ts-lib.git at commit e330083, with uncommitted changes.
|
|
4
4
|
|
|
5
5
|
Read the sections for the modules you use before using them. The full source of this version is in `SOURCE.md` next to this file, every file under a `## <repo path>` heading, e.g. search it for `## package-ui/<module>/` to find a module.
|
|
6
6
|
|
|
@@ -361,13 +361,21 @@ Row options besides `values`: `openable`, `opened`, `sub_rows` (with the `sub_ro
|
|
|
361
361
|
|
|
362
362
|
With sub rows, add rows and error texts sit in the key field after the tree lines and run from the key column to the end of the row. A list can therefore have no value columns at all, `{}` as columns with the names as key field text.
|
|
363
363
|
|
|
364
|
+
#### Opening and closing all rows
|
|
365
|
+
|
|
366
|
+
With sub rows the key column header has an open all and a close all button, also in its context menu. While a row is open, every row menu has "Close all", so lists without a header can close all too. `container.open_all()` and `container.close_all()` do the same for buttons of the app.
|
|
367
|
+
|
|
368
|
+
Open all opens level by level, so the upper levels are open first. It stops after opening 1000 rows and warns at the key column header, opening all again continues. That keeps a mistake that makes the sub rows recursive from freezing the app. Rows whose sub rows come from a state that delivers later open with what they have.
|
|
369
|
+
|
|
364
370
|
#### Resizing columns
|
|
365
371
|
|
|
366
|
-
Columns without a `fixed_width` get a handle at the right of their header, a double click on it resets the column. The first resize gives every auto width column the width it has, so only the dragged column changes. The key field column of sub rows never gets smaller than its widest key field needs for the indent, the opener, the icon and 4rem of the text, so it grows when deeper sub rows open. Text that does not fit wraps.
|
|
372
|
+
Columns without a `fixed_width` get a handle at the right of their header, a double click on it resets the column. The first resize gives every auto width column the width it has, so only the dragged column changes. The key field column of sub rows never gets smaller than its widest key field needs for the indent, the opener, the icon and 4rem of the text, so it grows when deeper sub rows open. Text that does not fit wraps. A list without value columns has its key column fill the list until it is resized.
|
|
373
|
+
|
|
374
|
+
A `headless` list has no handles, so `init_width` does not apply and columns without a `fixed_width` get an automatic width.
|
|
367
375
|
|
|
368
376
|
#### Selection
|
|
369
377
|
|
|
370
|
-
The `selection` option lets the user select rows. It adds a column in front of the rows, with radio buttons in single mode and checkboxes in multi mode, so selection works on touch without modifier keys.
|
|
378
|
+
The `selection` option lets the user select rows. It adds a column in front of the rows, with radio buttons in single mode and checkboxes in multi mode, so selection works on touch without modifier keys. Single mode with sub rows has no such column, a click on the row selects it and the key field takes the keyboard, so radio buttons would only take space.
|
|
371
379
|
|
|
372
380
|
The selection is an array state of keys owned by the app, given to the list with `bind`, the same way form elements take their value. Several lists, or any other element, can share one state.
|
|
373
381
|
|
|
@@ -385,10 +393,10 @@ selected.write([1, 4]); // selects the rows with these keys
|
|
|
385
393
|
|
|
386
394
|
Options:
|
|
387
395
|
|
|
388
|
-
- `mode`: `"single"` (radio buttons) or `"multi"` (checkboxes). In multi mode the header checkbox selects all rows or clears, and shows whether some or all rows are selected. Right click (or long press) on it opens a menu with "Select all" and "Deselect all". In single mode the header cell is empty.
|
|
396
|
+
- `mode`: `"single"` (radio buttons, none with sub rows) or `"multi"` (checkboxes). In multi mode the header checkbox selects all rows or clears, and shows whether some or all rows are selected. Right click (or long press) on it opens a menu with "Select all" and "Deselect all". In single mode the header cell is empty.
|
|
389
397
|
- `key`: the identity of the data of a row. Defaults to the data itself. Give a key whenever the data can be equal between rows, like primitives, or is replaced by new objects on updates. Keys must be unique among all rows, sub rows included.
|
|
390
398
|
|
|
391
|
-
A row with `selectable: false` in its row options, or an invalid row, can not be selected. Its radio button or checkbox cell is empty.
|
|
399
|
+
A row with `selectable: false` in its row options, or an invalid row, can not be selected. Its radio button or checkbox cell is empty, and trying to select it shows "This row cannot be selected" at the row.
|
|
392
400
|
|
|
393
401
|
##### The state
|
|
394
402
|
|
package/SOURCE.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @chocbite/ts-lib-ui source
|
|
2
2
|
|
|
3
|
-
@chocbite/ts-lib-ui 1.1.
|
|
3
|
+
@chocbite/ts-lib-ui 1.1.1, built from ssh://git@forgejo.nsns.dk:2222/chocbite/ts-lib.git at commit e330083, with uncommitted changes.
|
|
4
4
|
|
|
5
5
|
Every source file of the package, tests excluded, under a heading with its path in the repo. Usage notes are in `AGENTS.md` next to this file.
|
|
6
6
|
|
|
@@ -12920,6 +12920,8 @@ define_element(ListAddRow);
|
|
|
12920
12920
|
## package-ui/list/container.scss
|
|
12921
12921
|
|
|
12922
12922
|
```scss
|
|
12923
|
+
@use "../icons/mixins" as icons;
|
|
12924
|
+
|
|
12923
12925
|
list-container {
|
|
12924
12926
|
$sizer_width: 0.5rem;
|
|
12925
12927
|
$sizer_touch_width: 1.5rem;
|
|
@@ -13040,12 +13042,49 @@ list-container {
|
|
|
13040
13042
|
}
|
|
13041
13043
|
}
|
|
13042
13044
|
|
|
13045
|
+
//Open all and close all buttons in the header of the key column, glyphs of the icon font like the opener
|
|
13046
|
+
list-container > div > list-headerrow > .key > div > span {
|
|
13047
|
+
justify-content: flex-start;
|
|
13048
|
+
|
|
13049
|
+
> span {
|
|
13050
|
+
@include icons.material-symbols-rounded;
|
|
13051
|
+
display: flex;
|
|
13052
|
+
align-items: center;
|
|
13053
|
+
justify-content: center;
|
|
13054
|
+
flex-shrink: 0;
|
|
13055
|
+
width: var(--list-size-row_min);
|
|
13056
|
+
height: var(--list-size-row_min);
|
|
13057
|
+
border-radius: 0.2rem;
|
|
13058
|
+
font-size: 1.2rem;
|
|
13059
|
+
cursor: pointer;
|
|
13060
|
+
color: var(--list-colors-icon-sub_opener);
|
|
13061
|
+
|
|
13062
|
+
.touch & {
|
|
13063
|
+
width: var(--list-size-touch_row_min);
|
|
13064
|
+
height: var(--list-size-touch_row_min);
|
|
13065
|
+
font-size: 2rem;
|
|
13066
|
+
}
|
|
13067
|
+
|
|
13068
|
+
&:hover {
|
|
13069
|
+
background-color: var(--list-colors-background-row_hover);
|
|
13070
|
+
}
|
|
13071
|
+
}
|
|
13072
|
+
> .list-open-all::before {
|
|
13073
|
+
content: "\e5d7";
|
|
13074
|
+
}
|
|
13075
|
+
> .list-close-all::before {
|
|
13076
|
+
content: "\e5d6";
|
|
13077
|
+
}
|
|
13078
|
+
}
|
|
13079
|
+
|
|
13043
13080
|
//Hidden input showing write errors with the validation message of the browser, placed over a row by the list
|
|
13044
13081
|
list-container > input.list-warn {
|
|
13045
13082
|
all: unset;
|
|
13046
13083
|
visibility: hidden;
|
|
13047
13084
|
position: absolute;
|
|
13048
13085
|
pointer-events: none;
|
|
13086
|
+
height: 0px;
|
|
13087
|
+
width: 0px;
|
|
13049
13088
|
}
|
|
13050
13089
|
|
|
13051
13090
|
// _ ______ _____
|
|
@@ -13151,6 +13190,9 @@ import type {
|
|
|
13151
13190
|
ListTypeExtract,
|
|
13152
13191
|
} from "./types.ts";
|
|
13153
13192
|
|
|
13193
|
+
/**Most rows open all opens at a time, a mistake making the sub rows recursive would otherwise never end */
|
|
13194
|
+
const OPEN_ALL_LIMIT = 1000;
|
|
13195
|
+
|
|
13154
13196
|
class HeaderField extends Base {
|
|
13155
13197
|
static element_name() {
|
|
13156
13198
|
return "headerfield";
|
|
@@ -13168,6 +13210,11 @@ class HeaderField extends Base {
|
|
|
13168
13210
|
if (text) this.text = text;
|
|
13169
13211
|
}
|
|
13170
13212
|
|
|
13213
|
+
/**Elements shown instead of the text */
|
|
13214
|
+
set nodes(nodes: Node[]) {
|
|
13215
|
+
this.#text.replaceChildren(...nodes);
|
|
13216
|
+
}
|
|
13217
|
+
|
|
13171
13218
|
set text(value: string) {
|
|
13172
13219
|
this.#text.textContent = value;
|
|
13173
13220
|
}
|
|
@@ -13236,6 +13283,11 @@ class HeaderRow<
|
|
|
13236
13283
|
this.replaceChildren(...lead, ...fields);
|
|
13237
13284
|
}
|
|
13238
13285
|
|
|
13286
|
+
/**Header of the key field column, only with sub rows */
|
|
13287
|
+
get key_header(): HTMLElement | undefined {
|
|
13288
|
+
return this.#key_header;
|
|
13289
|
+
}
|
|
13290
|
+
|
|
13239
13291
|
/**Header of the key field column, only with sub rows */
|
|
13240
13292
|
#key_header?: HeaderField;
|
|
13241
13293
|
/**Empty header of the drag handle column */
|
|
@@ -13249,13 +13301,30 @@ class HeaderRow<
|
|
|
13249
13301
|
) {
|
|
13250
13302
|
super();
|
|
13251
13303
|
if (root.sub_rows) {
|
|
13252
|
-
this.#key_header = new HeaderField();
|
|
13253
|
-
|
|
13254
|
-
|
|
13304
|
+
const key = (this.#key_header = new HeaderField());
|
|
13305
|
+
key.classList.add("key");
|
|
13306
|
+
const button = (kind: string, action: () => void) => {
|
|
13307
|
+
const span = document.createElement("span");
|
|
13308
|
+
span.className = `list-${kind}-all`;
|
|
13309
|
+
span.onclick = action;
|
|
13310
|
+
return span;
|
|
13311
|
+
};
|
|
13312
|
+
key.nodes = [
|
|
13313
|
+
button("close", () => root.close_all()),
|
|
13314
|
+
button("open", () => root.open_all()),
|
|
13315
|
+
];
|
|
13316
|
+
ctm.attach(
|
|
13317
|
+
key,
|
|
13318
|
+
ctm.menu([
|
|
13319
|
+
ctm.line("Open all", () => root.open_all()),
|
|
13320
|
+
ctm.line("Close all", () => root.close_all()),
|
|
13321
|
+
]),
|
|
13322
|
+
);
|
|
13323
|
+
key.sizable(true, key_sizer);
|
|
13255
13324
|
}
|
|
13256
13325
|
if (root.reorder) this.#drag_header = new ListDragField();
|
|
13257
13326
|
const selection = root.selection;
|
|
13258
|
-
if (selection) this.#check_header = new ListCheckField();
|
|
13327
|
+
if (selection?.column) this.#check_header = new ListCheckField();
|
|
13259
13328
|
if (selection?.multi) {
|
|
13260
13329
|
const check = this.#check_header!;
|
|
13261
13330
|
check.onclick = () => {
|
|
@@ -13328,6 +13397,8 @@ class Container<
|
|
|
13328
13397
|
#state_sub?: StateInferSub<State<R[]>>;
|
|
13329
13398
|
/**Width of the key field column in rem set by resizing, fits the key fields when undefined */
|
|
13330
13399
|
#key_width?: number;
|
|
13400
|
+
/**Shows why a write failed, or that open all stopped */
|
|
13401
|
+
#warn?: ListWarn;
|
|
13331
13402
|
|
|
13332
13403
|
constructor(
|
|
13333
13404
|
columns: { [C in keyof T]: ListColumnOptions<T[C], any> },
|
|
@@ -13342,6 +13413,9 @@ class Container<
|
|
|
13342
13413
|
columns_visible: [],
|
|
13343
13414
|
transform,
|
|
13344
13415
|
observer: options?.observer,
|
|
13416
|
+
open_all: () => this.open_all(),
|
|
13417
|
+
close_all: () => this.close_all(),
|
|
13418
|
+
any_open: () => this.#open_rows().length > 0,
|
|
13345
13419
|
};
|
|
13346
13420
|
this.#parent = {
|
|
13347
13421
|
depth: -1,
|
|
@@ -13353,24 +13427,30 @@ class Container<
|
|
|
13353
13427
|
this.#child_box = document.createElement("div");
|
|
13354
13428
|
//Shows why a write of the selection or a move failed
|
|
13355
13429
|
const warn =
|
|
13356
|
-
options?.selection || options?.reorder
|
|
13430
|
+
options?.selection || options?.reorder || options?.sub_rows
|
|
13431
|
+
? new ListWarn(this)
|
|
13432
|
+
: undefined;
|
|
13433
|
+
this.#warn = warn;
|
|
13357
13434
|
if (options?.reorder) {
|
|
13358
13435
|
this.#root.reorder = new ListReorder(this, options.reorder, warn!);
|
|
13359
13436
|
this.#box.classList.add("drag");
|
|
13360
13437
|
}
|
|
13361
13438
|
if (options?.selection) {
|
|
13362
|
-
this.#selection = new ListSelection(
|
|
13363
|
-
|
|
13364
|
-
|
|
13365
|
-
|
|
13366
|
-
this.#selection.multi ? "multi" : "single",
|
|
13439
|
+
this.#selection = new ListSelection(
|
|
13440
|
+
options.selection,
|
|
13441
|
+
this.#child_box,
|
|
13442
|
+
Boolean(options.sub_rows),
|
|
13367
13443
|
);
|
|
13444
|
+
this.#root.selection = this.#selection;
|
|
13445
|
+
if (this.#selection.column) this.#box.classList.add("check");
|
|
13446
|
+
this.#box.classList.add(this.#selection.multi ? "multi" : "single");
|
|
13368
13447
|
this.#selection.on_error = (row, message) =>
|
|
13369
13448
|
warn!.show(row?.anchor ?? this.#header ?? this.#box, message);
|
|
13370
13449
|
}
|
|
13371
13450
|
//Columns in front of the key field column, the error and add rows start after them
|
|
13372
13451
|
const lead =
|
|
13373
|
-
Number(Boolean(options?.reorder)) +
|
|
13452
|
+
Number(Boolean(options?.reorder)) +
|
|
13453
|
+
Number(Boolean(this.#selection?.column));
|
|
13374
13454
|
if (lead) this.#box.classList.add("lead-" + lead);
|
|
13375
13455
|
|
|
13376
13456
|
if (!options?.headless)
|
|
@@ -13439,10 +13519,51 @@ class Container<
|
|
|
13439
13519
|
});
|
|
13440
13520
|
}
|
|
13441
13521
|
|
|
13522
|
+
/**Opens every openable row, level by level so the upper levels are open first
|
|
13523
|
+
* Stops with a warning after opening OPEN_ALL_LIMIT rows, against huge or recursive sub rows, opening all again continues */
|
|
13524
|
+
open_all() {
|
|
13525
|
+
let opened = 0;
|
|
13526
|
+
let level = this.#top_rows();
|
|
13527
|
+
while (level.length) {
|
|
13528
|
+
const next: ListRow<R, T, A, S>[] = [];
|
|
13529
|
+
for (const row of level) {
|
|
13530
|
+
if (row.openable && !row.open) {
|
|
13531
|
+
if (opened >= OPEN_ALL_LIMIT) {
|
|
13532
|
+
this.#warn?.show(
|
|
13533
|
+
this.#header?.key_header ?? this.#box,
|
|
13534
|
+
`Stopped after opening ${OPEN_ALL_LIMIT} rows, open all again for more`,
|
|
13535
|
+
);
|
|
13536
|
+
return;
|
|
13537
|
+
}
|
|
13538
|
+
row.open = true;
|
|
13539
|
+
opened += row.amount_rows();
|
|
13540
|
+
}
|
|
13541
|
+
for (let sub = row.first_sub_row; sub; sub = sub.next_row)
|
|
13542
|
+
next.push(sub);
|
|
13543
|
+
}
|
|
13544
|
+
level = next;
|
|
13545
|
+
}
|
|
13546
|
+
}
|
|
13547
|
+
|
|
13548
|
+
/**Closes every open row, closing the top rows removes everything below them */
|
|
13549
|
+
close_all() {
|
|
13550
|
+
for (const row of this.#open_rows()) row.open = false;
|
|
13551
|
+
}
|
|
13552
|
+
|
|
13553
|
+
#top_rows(): ListRow<R, T, A, S>[] {
|
|
13554
|
+
return [...this.#child_box.children] as ListRow<R, T, A, S>[];
|
|
13555
|
+
}
|
|
13556
|
+
|
|
13557
|
+
#open_rows(): ListRow<R, T, A, S>[] {
|
|
13558
|
+
return this.#top_rows().filter((row) => row.open);
|
|
13559
|
+
}
|
|
13560
|
+
|
|
13442
13561
|
#update_column_widths() {
|
|
13443
13562
|
const widths: string[] = this.#root.columns_visible.map((key) => {
|
|
13444
13563
|
const col = this.#root.columns.get(key)!;
|
|
13445
|
-
|
|
13564
|
+
//Without a header nothing can resize, so init_width, the start of a resize, does not apply
|
|
13565
|
+
const width =
|
|
13566
|
+
col.fixed_width ?? (this.#header ? col.init_width : undefined);
|
|
13446
13567
|
if (width) {
|
|
13447
13568
|
if (width === "min") return "min-content";
|
|
13448
13569
|
else if (width === "max") return "max-content";
|
|
@@ -13451,7 +13572,9 @@ class Container<
|
|
|
13451
13572
|
return "auto";
|
|
13452
13573
|
});
|
|
13453
13574
|
//The key fields get the width instead of the column, so it never gets smaller than its widest key field minimum
|
|
13454
|
-
|
|
13575
|
+
//Without value columns it fills the list unless resized
|
|
13576
|
+
if (this.#root.sub_rows)
|
|
13577
|
+
widths.unshift(widths.length || this.#key_width ? "max-content" : "auto");
|
|
13455
13578
|
this.#box.classList.toggle("key-sized", Boolean(this.#key_width));
|
|
13456
13579
|
if (this.#key_width)
|
|
13457
13580
|
this.#box.style.setProperty(
|
|
@@ -13459,7 +13582,7 @@ class Container<
|
|
|
13459
13582
|
`${Math.max(this.#key_width, 1)}rem`,
|
|
13460
13583
|
);
|
|
13461
13584
|
else this.#box.style.removeProperty("--list-key-width");
|
|
13462
|
-
if (this.#selection) widths.unshift("var(--list-check-width)");
|
|
13585
|
+
if (this.#selection?.column) widths.unshift("var(--list-check-width)");
|
|
13463
13586
|
if (this.#root.reorder) widths.unshift("var(--list-drag-width)");
|
|
13464
13587
|
this.#box.style.gridTemplateColumns = widths.join(" ");
|
|
13465
13588
|
}
|
|
@@ -14466,9 +14589,10 @@ list-keyfield {
|
|
|
14466
14589
|
border-right: 1px solid var(--list-colors-border-column);
|
|
14467
14590
|
|
|
14468
14591
|
list-addrow > &,
|
|
14469
|
-
list-rowserror > &,
|
|
14470
|
-
list-row:not(.addrow) >
|
|
14471
|
-
|
|
14592
|
+
div:not(.addrow) > list-rowserror > &,
|
|
14593
|
+
list-row:not(.addrow) > list-rowserror > &,
|
|
14594
|
+
list-row:not(.addrow) > span > list-row:last-child > div > &,
|
|
14595
|
+
div:not(.addrow) > div > list-row:last-child > div > & {
|
|
14472
14596
|
height: 50%;
|
|
14473
14597
|
}
|
|
14474
14598
|
}
|
|
@@ -14804,6 +14928,9 @@ import type {
|
|
|
14804
14928
|
ListType,
|
|
14805
14929
|
} from "./types";
|
|
14806
14930
|
|
|
14931
|
+
/**Shown when the user tries to select a row that can not be selected */
|
|
14932
|
+
const NOT_SELECTABLE = "This row cannot be selected";
|
|
14933
|
+
|
|
14807
14934
|
export type ListSubRows<R> = () => R[] | State<R[]>;
|
|
14808
14935
|
|
|
14809
14936
|
export interface ListRowOptions<R, T extends {}, S extends boolean> {
|
|
@@ -15004,7 +15131,12 @@ export class ListRow<R, T extends {}, A extends ListType<R>, S extends boolean>
|
|
|
15004
15131
|
selection.focus_moved(focused.selection_key, e);
|
|
15005
15132
|
return true;
|
|
15006
15133
|
}
|
|
15007
|
-
|
|
15134
|
+
if (!selection) return false;
|
|
15135
|
+
if (e.key === " " && this.selection_key === undefined) {
|
|
15136
|
+
selection.on_error?.(this, NOT_SELECTABLE);
|
|
15137
|
+
return true;
|
|
15138
|
+
}
|
|
15139
|
+
return selection.key_down(this.selection_key, e);
|
|
15008
15140
|
}
|
|
15009
15141
|
|
|
15010
15142
|
// _____ _______
|
|
@@ -15072,11 +15204,10 @@ export class ListRow<R, T extends {}, A extends ListType<R>, S extends boolean>
|
|
|
15072
15204
|
//Setup context menu, blocked for right clicks bubbling up from sub rows
|
|
15073
15205
|
ctm.detach(this);
|
|
15074
15206
|
this.#sub_row_menu = false;
|
|
15075
|
-
//
|
|
15076
|
-
//Openable can be a state, the lines are made when the menu opens
|
|
15077
|
-
const openable = this.#root.sub_rows && Boolean(row_options.openable);
|
|
15207
|
+
//With sub rows a row gets open, close and close all lines and a selectable row select lines, in front of its own menu
|
|
15208
|
+
//Openable can be a state and rows open and close, the lines are made when the menu opens
|
|
15078
15209
|
const menu =
|
|
15079
|
-
|
|
15210
|
+
this.#root.sub_rows || this.selection_key !== undefined
|
|
15080
15211
|
? ctm.combine(
|
|
15081
15212
|
() => this.#open_lines(),
|
|
15082
15213
|
() => this.#selection_lines(),
|
|
@@ -15215,27 +15346,33 @@ export class ListRow<R, T extends {}, A extends ListType<R>, S extends boolean>
|
|
|
15215
15346
|
#selection_setup(selection: ListSelection<unknown>) {
|
|
15216
15347
|
const clear_click_focus = (e: Event) =>
|
|
15217
15348
|
(e.currentTarget as HTMLElement).classList.remove("click-focus");
|
|
15218
|
-
|
|
15219
|
-
|
|
15220
|
-
|
|
15221
|
-
|
|
15222
|
-
|
|
15223
|
-
|
|
15349
|
+
if (selection.column) {
|
|
15350
|
+
this.#check = new ListCheckField();
|
|
15351
|
+
//The key field is the keyboard cell when there is one
|
|
15352
|
+
if (!this.#key_field) this.#check.tabIndex = 0;
|
|
15353
|
+
this.#check.onkeydown = (e) => {
|
|
15354
|
+
if (this.key_down(e)) e.preventDefault();
|
|
15355
|
+
};
|
|
15356
|
+
this.#check.onclick = (e) => {
|
|
15357
|
+
e.stopPropagation();
|
|
15358
|
+
//Focus first, moving the focus after the warning would close it
|
|
15359
|
+
this.#focus_after_click();
|
|
15360
|
+
if (this.selection_key !== undefined)
|
|
15361
|
+
selection.check_click(this.selection_key);
|
|
15362
|
+
else selection.on_error?.(this, NOT_SELECTABLE);
|
|
15363
|
+
};
|
|
15364
|
+
}
|
|
15224
15365
|
for (const cell of [this.#check, this.#key_field])
|
|
15225
15366
|
if (cell) {
|
|
15226
15367
|
cell.addEventListener("keydown", clear_click_focus);
|
|
15227
15368
|
cell.addEventListener("blur", clear_click_focus);
|
|
15228
15369
|
}
|
|
15229
|
-
this.#check.onclick = (e) => {
|
|
15230
|
-
e.stopPropagation();
|
|
15231
|
-
if (this.selection_key !== undefined)
|
|
15232
|
-
selection.check_click(this.selection_key);
|
|
15233
|
-
this.#focus_after_click();
|
|
15234
|
-
};
|
|
15235
15370
|
this.#field_box.onclick = (e) => {
|
|
15371
|
+
//Focus first, moving the focus after the warning would close it
|
|
15372
|
+
this.#focus_after_click();
|
|
15236
15373
|
if (this.selection_key !== undefined)
|
|
15237
15374
|
selection.click(this.selection_key, e);
|
|
15238
|
-
this
|
|
15375
|
+
else selection.on_error?.(this, NOT_SELECTABLE);
|
|
15239
15376
|
};
|
|
15240
15377
|
//Shift click would select text between the rows
|
|
15241
15378
|
this.#field_box.onmousedown = (e) => {
|
|
@@ -15256,14 +15393,19 @@ export class ListRow<R, T extends {}, A extends ListType<R>, S extends boolean>
|
|
|
15256
15393
|
this.classList.toggle("selectable", key !== undefined);
|
|
15257
15394
|
}
|
|
15258
15395
|
|
|
15259
|
-
/**Context menu
|
|
15396
|
+
/**Context menu lines to open or close the sub rows of an openable row, and to close all rows while one is open
|
|
15397
|
+
* Close all is on every row, so a list without header can close all */
|
|
15260
15398
|
#open_lines(): ContextMenuLines {
|
|
15261
|
-
|
|
15262
|
-
|
|
15263
|
-
|
|
15264
|
-
|
|
15265
|
-
|
|
15266
|
-
|
|
15399
|
+
const lines: ContextMenuLines = [];
|
|
15400
|
+
if (this.openable)
|
|
15401
|
+
lines.push(
|
|
15402
|
+
this.open
|
|
15403
|
+
? ctm.line("Close", () => (this.open = false))
|
|
15404
|
+
: ctm.line("Open", () => (this.open = true)),
|
|
15405
|
+
);
|
|
15406
|
+
if (this.#root.any_open())
|
|
15407
|
+
lines.push(ctm.line("Close all", () => this.#root.close_all()));
|
|
15408
|
+
return lines;
|
|
15267
15409
|
}
|
|
15268
15410
|
|
|
15269
15411
|
/**Context menu lines to select or deselect the row, and in multi mode all rows
|
|
@@ -15505,6 +15647,9 @@ export interface ListSelectionRow {
|
|
|
15505
15647
|
* keys of rows it does not show are left alone, except by select all and deselect all which replace the selection */
|
|
15506
15648
|
export class ListSelection<K> {
|
|
15507
15649
|
readonly multi: boolean;
|
|
15650
|
+
/**Whether the rows get a checkbox or radio button column
|
|
15651
|
+
* Left out in single mode with a key column, a click on the row selects and the key field is the keyboard cell */
|
|
15652
|
+
readonly column: boolean;
|
|
15508
15653
|
readonly key: (data: any) => K;
|
|
15509
15654
|
/**Called after a change of the shown selection or of the selectable rows */
|
|
15510
15655
|
on_change?: () => void;
|
|
@@ -15526,8 +15671,13 @@ export class ListSelection<K> {
|
|
|
15526
15671
|
#batch = 0;
|
|
15527
15672
|
#changed = false;
|
|
15528
15673
|
|
|
15529
|
-
constructor(
|
|
15674
|
+
constructor(
|
|
15675
|
+
options: ListSelectionOptions<any, K>,
|
|
15676
|
+
box: Element,
|
|
15677
|
+
key_column: boolean,
|
|
15678
|
+
) {
|
|
15530
15679
|
this.multi = options.mode === "multi";
|
|
15680
|
+
this.column = this.multi || !key_column;
|
|
15531
15681
|
this.key = options.key ?? ((data) => data as K);
|
|
15532
15682
|
this.#box = box;
|
|
15533
15683
|
}
|
|
@@ -16238,7 +16388,7 @@ export type ListDataType = (typeof ListDataType)[keyof typeof ListDataType];
|
|
|
16238
16388
|
export type ListColumnAlign = "left" | "center" | "right";
|
|
16239
16389
|
|
|
16240
16390
|
export interface ListColumnOptions<V, C extends ListField> {
|
|
16241
|
-
/**Initial width of the column in rem, auto when undefined*/
|
|
16391
|
+
/**Initial width of the column in rem, auto when undefined, ignored in a headless list as nothing can resize it*/
|
|
16242
16392
|
init_width?: number;
|
|
16243
16393
|
/**If the column has a fixed width in rem, overrides init_width and disables resizing*/
|
|
16244
16394
|
fixed_width?: number | "min" | "max";
|
|
@@ -16318,6 +16468,12 @@ export interface ListRoot<
|
|
|
16318
16468
|
selection?: ListSelection<any>;
|
|
16319
16469
|
/**Moving of rows, when enabled */
|
|
16320
16470
|
reorder?: ListReorder<R>;
|
|
16471
|
+
/**Opens every openable row, a limited amount of rows at a time */
|
|
16472
|
+
open_all(): void;
|
|
16473
|
+
/**Closes every open row */
|
|
16474
|
+
close_all(): void;
|
|
16475
|
+
/**Whether any row is open */
|
|
16476
|
+
any_open(): boolean;
|
|
16321
16477
|
}
|
|
16322
16478
|
|
|
16323
16479
|
export interface ListRowParent<A extends ListType<any>> {
|
package/base/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import '../style.css';
|
|
2
|
-
import { a as validate_element_name, c as base_loop, d as BaseIntersectObserverOptions, f as ACCESSTYPESINFO, i as set_base_element_global_namespace, l as Base, n as base_element_name, o as BaseSVG, p as AccessTypes, r as define_element, s as Loop, t as ELEMENT_LIST, u as BaseIntersectObserver } from "../index-
|
|
2
|
+
import { a as validate_element_name, c as base_loop, d as BaseIntersectObserverOptions, f as ACCESSTYPESINFO, i as set_base_element_global_namespace, l as Base, n as base_element_name, o as BaseSVG, p as AccessTypes, r as define_element, s as Loop, t as ELEMENT_LIST, u as BaseIntersectObserver } from "../index-ClfL2SQR.mjs";
|
|
3
3
|
export { ACCESSTYPESINFO, AccessTypes, Base, BaseIntersectObserver, BaseIntersectObserverOptions, BaseSVG, ELEMENT_LIST, Loop, base_element_name, base_loop, define_element, set_base_element_global_namespace, validate_element_name };
|
package/canvas/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import '../style.css';
|
|
2
|
-
import { l as Base } from "../index-
|
|
2
|
+
import { l as Base } from "../index-ClfL2SQR.mjs";
|
|
3
3
|
/**Event dispatched on a widget when its position, size or rotation changes */
|
|
4
4
|
export declare const WIDGET_TRANSFORM_EVENT = "widget_transform";
|
|
5
5
|
/**Shared class for widgets placed at a fixed position in a viewport
|
package/canvas/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "../style.css";
|
|
2
2
|
import { Base, define_element } from "../base/index.mjs";
|
|
3
|
-
import { i as theme_init_variable_root } from "../theme-
|
|
3
|
+
import { i as theme_init_variable_root } from "../theme-DilOXXDu.mjs";
|
|
4
4
|
import { $q as material_open_with_rounded, ha as material_arrow_range_rounded, r2 as material_rotate_right_rounded } from "../icons-B88i-7MC.mjs";
|
|
5
5
|
import { BLUE, GREY } from "@chocbite/ts-lib/colors";
|
|
6
6
|
// canvas/shared.ts
|
package/context-menu/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import '../style.css';
|
|
2
|
-
import { i as ContextMenuLines, n as ContextMenuGroup, r as ContextMenu, t as ctm } from "../index-
|
|
2
|
+
import { i as ContextMenuLines, n as ContextMenuGroup, r as ContextMenu, t as ctm } from "../index-76zZKjTH.mjs";
|
|
3
3
|
export { type ContextMenu, type ContextMenuGroup, type ContextMenuLines, ctm, ctm as default };
|
package/context-menu/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import "../style.css";
|
|
2
|
-
export { t as ctm, t as default } from "../context-menu-
|
|
2
|
+
export { t as ctm, t as default } from "../context-menu-hHRJ33Lu.mjs";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./style.css";
|
|
2
2
|
import { Base, define_element } from "./base/index.mjs";
|
|
3
|
-
import { i as theme_init_variable_root } from "./theme-
|
|
3
|
+
import { i as theme_init_variable_root } from "./theme-DilOXXDu.mjs";
|
|
4
4
|
import { Fm as material_chevron_right_rounded, xh as material_close_rounded } from "./icons-B88i-7MC.mjs";
|
|
5
5
|
import { Spinner } from "./spinner/index.mjs";
|
|
6
6
|
import { DOCUMENT_HANDLER } from "./document/index.mjs";
|
|
@@ -596,4 +596,4 @@ const ctm = {
|
|
|
596
596
|
};
|
|
597
597
|
export { ctm as t };
|
|
598
598
|
|
|
599
|
-
//# sourceMappingURL=context-menu-
|
|
599
|
+
//# sourceMappingURL=context-menu-hHRJ33Lu.mjs.map
|