@chocbite/ts-lib-ui 1.0.6 → 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.
Files changed (53) hide show
  1. package/AGENTS.md +172 -3
  2. package/SOURCE.md +2161 -273
  3. package/base/index.mjs +7 -7
  4. package/base/index.mjs.map +1 -1
  5. package/canvas/index.mjs +8 -8
  6. package/canvas/index.mjs.map +1 -1
  7. package/context-menu/index.d.mts +2 -2
  8. package/context-menu/index.mjs +1 -1
  9. package/{context-menu-Bo8R6DmK.mjs → context-menu-hHRJ33Lu.mjs} +149 -111
  10. package/context-menu-hHRJ33Lu.mjs.map +1 -0
  11. package/document/index.mjs +1 -1
  12. package/document/index.mjs.map +1 -1
  13. package/dom/index.mjs +1 -1
  14. package/dom/index.mjs.map +1 -1
  15. package/form/index.d.mts +4 -3
  16. package/form/index.mjs +30 -29
  17. package/form/index.mjs.map +1 -1
  18. package/icons/index.mjs +1 -1
  19. package/{icons-e2J_Ojic.mjs → icons-B88i-7MC.mjs} +2 -2
  20. package/{index-Pr2sLv9e.d.mts → index-76zZKjTH.d.mts} +32 -16
  21. package/index-D6L_jK1x.d.mts +385 -0
  22. package/keyboard/index.mjs +12 -12
  23. package/keyboard/index.mjs.map +1 -1
  24. package/list/index.d.mts +2 -2
  25. package/list/index.mjs +1 -1
  26. package/list-Bic1UzeC.mjs +1640 -0
  27. package/list-Bic1UzeC.mjs.map +1 -0
  28. package/package.json +5 -80
  29. package/selection/index.mjs +1 -1
  30. package/selection/index.mjs.map +1 -1
  31. package/settings/index.mjs +1 -1
  32. package/settings/index.mjs.map +1 -1
  33. package/spinner/index.mjs +3 -3
  34. package/spinner/index.mjs.map +1 -1
  35. package/state_ui/index.mjs +1 -1
  36. package/{state_ui-Bm3TeKNL.mjs → state_ui-Dtm2y5RU.mjs} +3 -3
  37. package/state_ui-Dtm2y5RU.mjs.map +1 -0
  38. package/style.css +349 -63
  39. package/svg/index.mjs +1 -1
  40. package/{svg-1bp-yIPC.mjs → svg-Yz7elqnU.mjs} +16 -16
  41. package/svg-Yz7elqnU.mjs.map +1 -0
  42. package/test/index.mjs +1 -1
  43. package/test/index.mjs.map +1 -1
  44. package/theme/index.mjs +1 -1
  45. package/{theme-DgVtLDzP.mjs → theme-DilOXXDu.mjs} +9 -9
  46. package/theme-DilOXXDu.mjs.map +1 -0
  47. package/context-menu-Bo8R6DmK.mjs.map +0 -1
  48. package/index-BTUFkF9s.d.mts +0 -173
  49. package/list-DOXIQOEY.mjs +0 -715
  50. package/list-DOXIQOEY.mjs.map +0 -1
  51. package/state_ui-Bm3TeKNL.mjs.map +0 -1
  52. package/svg-1bp-yIPC.mjs.map +0 -1
  53. package/theme-DgVtLDzP.mjs.map +0 -1
package/SOURCE.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # @chocbite/ts-lib-ui source
2
2
 
3
- @chocbite/ts-lib-ui 1.0.6, built from ssh://git@forgejo.nsns.dk:2222/chocbite/ts-lib.git at commit ee07761, with uncommitted changes.
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
 
7
- ## package-ui/src/base/access.ts
7
+ ## package-ui/base/access.ts
8
8
 
9
9
  ```ts
10
10
  import { state } from "@chocbite/ts-lib/state";
@@ -28,7 +28,7 @@ export const ACCESSTYPESINFO = state.e.list<AccessTypes>({
28
28
  });
29
29
  ```
30
30
 
31
- ## package-ui/src/base/base.ts
31
+ ## package-ui/base/base.ts
32
32
 
33
33
  ```ts
34
34
  import { some, type Option } from "@chocbite/ts-lib/result";
@@ -548,10 +548,10 @@ export abstract class Base extends HTMLElement {
548
548
  }
549
549
  ```
550
550
 
551
- ## package-ui/src/base/base_loop.ts
551
+ ## package-ui/base/base_loop.ts
552
552
 
553
553
  ```ts
554
- import state_ui from "../state_ui";
554
+ import state_ui from "#state_ui";
555
555
  import { Base } from "./base";
556
556
  import { define_element } from "./define_element";
557
557
 
@@ -604,7 +604,7 @@ export function base_loop<T, N extends ChildNode>(
604
604
  }
605
605
  ```
606
606
 
607
- ## package-ui/src/base/base_svg.ts
607
+ ## package-ui/base/base_svg.ts
608
608
 
609
609
  ```ts
610
610
  import { Base } from "./base";
@@ -636,13 +636,13 @@ export abstract class BaseSVG extends Base {
636
636
  }
637
637
  ```
638
638
 
639
- ## package-ui/src/base/declarations.d.ts
639
+ ## package-ui/base/declarations.d.ts
640
640
 
641
641
  ```ts
642
642
  declare module "*.scss";
643
643
  ```
644
644
 
645
- ## package-ui/src/base/define_element.ts
645
+ ## package-ui/base/define_element.ts
646
646
 
647
647
  ```ts
648
648
  const RESERVED_NAMES = new Set([
@@ -772,7 +772,7 @@ export const define_element = (element: ElementConstructor) => {
772
772
  };
773
773
  ```
774
774
 
775
- ## package-ui/src/base/index.scss
775
+ ## package-ui/base/index.scss
776
776
 
777
777
  ```scss
778
778
  [inert="none"] {
@@ -780,7 +780,7 @@ export const define_element = (element: ElementConstructor) => {
780
780
  }
781
781
  ```
782
782
 
783
- ## package-ui/src/base/index.ts
783
+ ## package-ui/base/index.ts
784
784
 
785
785
  ```ts
786
786
  export * from "./access";
@@ -792,7 +792,7 @@ export * from "./intersect_observer";
792
792
  import "./index.scss";
793
793
  ```
794
794
 
795
- ## package-ui/src/base/intersect_observer.ts
795
+ ## package-ui/base/intersect_observer.ts
796
796
 
797
797
  ```ts
798
798
  import type { Base } from "./base";
@@ -883,7 +883,7 @@ export class BaseIntersectObserver extends IntersectionObserver {
883
883
  }
884
884
  ```
885
885
 
886
- ## package-ui/src/canvas/base.scss
886
+ ## package-ui/canvas/base.scss
887
887
 
888
888
  ```scss
889
889
  // _______ _ _ ______ __ __ ______ __ __ _____ _____
@@ -906,7 +906,7 @@ $transformer_color: var(--canvas-transformer-color);
906
906
  $transformer_handle_background: var(--canvas-transformer-handleBackground);
907
907
  ```
908
908
 
909
- ## package-ui/src/canvas/globals.d.ts
909
+ ## package-ui/canvas/globals.d.ts
910
910
 
911
911
  ```ts
912
912
  declare module "*.scss" {
@@ -915,7 +915,7 @@ declare module "*.scss" {
915
915
  }
916
916
  ```
917
917
 
918
- ## package-ui/src/canvas/index.ts
918
+ ## package-ui/canvas/index.ts
919
919
 
920
920
  ```ts
921
921
  import { canvas_page, Page, type CanvasPageOptions } from "./page";
@@ -939,7 +939,7 @@ export type { CanvasPageOptions, CanvasViewportOptions, Page, Viewport };
939
939
  export { WIDGET_TRANSFORM_EVENT, WidgetBase } from "./widget";
940
940
  ```
941
941
 
942
- ## package-ui/src/canvas/page.scss
942
+ ## package-ui/canvas/page.scss
943
943
 
944
944
  ```scss
945
945
  @use "./base";
@@ -952,7 +952,7 @@ canvas-page {
952
952
  }
953
953
  ```
954
954
 
955
- ## package-ui/src/canvas/page.ts
955
+ ## package-ui/canvas/page.ts
956
956
 
957
957
  ```ts
958
958
  import { Base, define_element } from "#base";
@@ -1036,7 +1036,7 @@ export const canvas_page = (options?: CanvasPageOptions): Page =>
1036
1036
  options ? new Page().opts(options) : new Page();
1037
1037
  ```
1038
1038
 
1039
- ## package-ui/src/canvas/shared.ts
1039
+ ## package-ui/canvas/shared.ts
1040
1040
 
1041
1041
  ```ts
1042
1042
  import { BLUE, GREY } from "@chocbite/ts-lib/colors";
@@ -1148,7 +1148,7 @@ transformer.make_variable(
1148
1148
  );
1149
1149
  ```
1150
1150
 
1151
- ## package-ui/src/canvas/transformer.scss
1151
+ ## package-ui/canvas/transformer.scss
1152
1152
 
1153
1153
  ```scss
1154
1154
  @use "sass:list";
@@ -1349,7 +1349,7 @@ canvas-transformer {
1349
1349
  }
1350
1350
  ```
1351
1351
 
1352
- ## package-ui/src/canvas/transformer.ts
1352
+ ## package-ui/canvas/transformer.ts
1353
1353
 
1354
1354
  ```ts
1355
1355
  import { Base, define_element } from "#base";
@@ -1652,7 +1652,7 @@ export class Transformer extends Base {
1652
1652
  define_element(Transformer);
1653
1653
  ```
1654
1654
 
1655
- ## package-ui/src/canvas/viewport.scss
1655
+ ## package-ui/canvas/viewport.scss
1656
1656
 
1657
1657
  ```scss
1658
1658
  @use "./base";
@@ -1693,7 +1693,7 @@ canvas-viewport {
1693
1693
  }
1694
1694
  ```
1695
1695
 
1696
- ## package-ui/src/canvas/viewport.ts
1696
+ ## package-ui/canvas/viewport.ts
1697
1697
 
1698
1698
  ```ts
1699
1699
  import { Base, define_element } from "#base";
@@ -2018,7 +2018,7 @@ export const canvas_viewport = (options?: CanvasViewportOptions): Viewport =>
2018
2018
  options ? new Viewport().opts(options) : new Viewport();
2019
2019
  ```
2020
2020
 
2021
- ## package-ui/src/canvas/widget.ts
2021
+ ## package-ui/canvas/widget.ts
2022
2022
 
2023
2023
  ```ts
2024
2024
  import { Base } from "#base";
@@ -2138,7 +2138,7 @@ export abstract class WidgetBase extends Base {
2138
2138
  }
2139
2139
  ```
2140
2140
 
2141
- ## package-ui/src/context-menu/buffer.scss
2141
+ ## package-ui/context-menu/buffer.scss
2142
2142
 
2143
2143
  ```scss
2144
2144
  @use "./line.scss" as line;
@@ -2176,7 +2176,7 @@ contextmenu-buffer {
2176
2176
  }
2177
2177
  ```
2178
2178
 
2179
- ## package-ui/src/context-menu/buffer.ts
2179
+ ## package-ui/context-menu/buffer.ts
2180
2180
 
2181
2181
  ```ts
2182
2182
  import { define_element } from "#base";
@@ -2206,7 +2206,68 @@ export class Buffer extends MenuLine {
2206
2206
  define_element(Buffer);
2207
2207
  ```
2208
2208
 
2209
- ## package-ui/src/context-menu/container.scss
2209
+ ## package-ui/context-menu/combine.ts
2210
+
2211
+ ```ts
2212
+ import result, { none, some, type Option } from "@chocbite/ts-lib/result";
2213
+ import { context_devider } from "./devider";
2214
+ import type { ContextMenuLine } from "./line";
2215
+ import { context_menu, ContextMenu } from "./menu";
2216
+
2217
+ type Lines = (ContextMenuLine | undefined)[];
2218
+
2219
+ /**A group for ctm.combine, undefined for no group
2220
+ * - lines, undefined lines are skipped like in ctm.menu
2221
+ * - a menu, its lines are taken when the combined menu opens
2222
+ * - a function called every time the combined menu opens, giving lines, a menu, or an option of a menu like ctm.attach takes*/
2223
+ export type ContextMenuGroup =
2224
+ | Lines
2225
+ | ContextMenu
2226
+ | (() => Lines | ContextMenu | Option<ContextMenu>)
2227
+ | undefined;
2228
+
2229
+ function group_lines(group: ContextMenuGroup): Lines | Promise<Lines> {
2230
+ let value = typeof group === "function" ? group() : group;
2231
+ if (result.is_option(value)) value = value.unwrap_or(undefined);
2232
+ if (value instanceof ContextMenu) return value.read_lines();
2233
+ return value ?? [];
2234
+ }
2235
+
2236
+ /**Joins groups with a devider between those with lines */
2237
+ function join(groups: Lines[]): ContextMenuLine[] {
2238
+ const lines: ContextMenuLine[] = [];
2239
+ for (const group of groups) {
2240
+ const group_lines = group.filter((line) => line !== undefined);
2241
+ if (group_lines.length === 0) continue;
2242
+ if (lines.length) lines.push(context_devider());
2243
+ lines.push(...group_lines);
2244
+ }
2245
+ return lines;
2246
+ }
2247
+
2248
+ /**Combines groups of lines and menus into one menu with a devider between groups, built every time the menu opens
2249
+ * Empty groups are left out with their devider, and when all groups are empty there is no menu
2250
+ * A group with promised lines makes the combined menu wait for all groups, showing a spinner, it then always opens
2251
+ * Give the result to ctm.attach, or anything else taking a menu factory
2252
+ * @param groups groups in menu order, see ContextMenuGroup*/
2253
+ export function context_combine(
2254
+ ...groups: ContextMenuGroup[]
2255
+ ): () => Option<ContextMenu> {
2256
+ return () => {
2257
+ const parts = groups.map(group_lines);
2258
+ if (parts.some((part) => part instanceof Promise))
2259
+ return some(
2260
+ context_menu(
2261
+ Promise.all(parts.map((part) => Promise.resolve(part))).then(join),
2262
+ ),
2263
+ );
2264
+ const lines = join(parts as Lines[]);
2265
+ return lines.length ? some(context_menu(lines)) : none();
2266
+ };
2267
+ }
2268
+ ```
2269
+
2270
+ ## package-ui/context-menu/container.scss
2210
2271
 
2211
2272
  ```scss
2212
2273
  contextmenu-container {
@@ -2222,7 +2283,7 @@ contextmenu-container {
2222
2283
  }
2223
2284
  ```
2224
2285
 
2225
- ## package-ui/src/context-menu/container.ts
2286
+ ## package-ui/context-menu/container.ts
2226
2287
 
2227
2288
  ```ts
2228
2289
  import { Base, define_element } from "#base";
@@ -2299,7 +2360,7 @@ export class Container extends Base {
2299
2360
  define_element(Container);
2300
2361
  ```
2301
2362
 
2302
- ## package-ui/src/context-menu/devider.scss
2363
+ ## package-ui/context-menu/devider.scss
2303
2364
 
2304
2365
  ```scss
2305
2366
  contextmenu-devider {
@@ -2319,7 +2380,7 @@ contextmenu-devider {
2319
2380
  }
2320
2381
  ```
2321
2382
 
2322
- ## package-ui/src/context-menu/devider.ts
2383
+ ## package-ui/context-menu/devider.ts
2323
2384
 
2324
2385
  ```ts
2325
2386
  import { define_element } from "#base";
@@ -2349,7 +2410,7 @@ export function context_devider(): ContextMenuDevider {
2349
2410
  }
2350
2411
  ```
2351
2412
 
2352
- ## package-ui/src/context-menu/engine.scss
2413
+ ## package-ui/context-menu/engine.scss
2353
2414
 
2354
2415
  ```scss
2355
2416
  html {
@@ -2357,7 +2418,7 @@ html {
2357
2418
  }
2358
2419
  ```
2359
2420
 
2360
- ## package-ui/src/context-menu/engine.ts
2421
+ ## package-ui/context-menu/engine.ts
2361
2422
 
2362
2423
  ```ts
2363
2424
  import { DOCUMENT_HANDLER } from "#document";
@@ -2487,7 +2548,7 @@ export function context_menu_default(
2487
2548
  }
2488
2549
  ```
2489
2550
 
2490
- ## package-ui/src/context-menu/globals.d.ts
2551
+ ## package-ui/context-menu/globals.d.ts
2491
2552
 
2492
2553
  ```ts
2493
2554
  declare module "*.scss" {
@@ -2496,9 +2557,10 @@ declare module "*.scss" {
2496
2557
  }
2497
2558
  ```
2498
2559
 
2499
- ## package-ui/src/context-menu/index.ts
2560
+ ## package-ui/context-menu/index.ts
2500
2561
 
2501
2562
  ```ts
2563
+ import { context_combine } from "./combine";
2502
2564
  import { context_devider } from "./devider";
2503
2565
  import {
2504
2566
  context_menu_attach,
@@ -2523,13 +2585,15 @@ export const ctm = {
2523
2585
  line: context_line,
2524
2586
  sub: context_sub,
2525
2587
  devider: context_devider,
2588
+ combine: context_combine,
2526
2589
  };
2527
2590
  export default ctm;
2528
2591
 
2592
+ export type { ContextMenuGroup } from "./combine";
2529
2593
  export type { ContextMenu, ContextMenuLines } from "./menu";
2530
2594
  ```
2531
2595
 
2532
- ## package-ui/src/context-menu/line.scss
2596
+ ## package-ui/context-menu/line.scss
2533
2597
 
2534
2598
  ```scss
2535
2599
  $menuMinWidth: 10rem;
@@ -2651,7 +2715,7 @@ $iconWidthTouch: 2.6rem;
2651
2715
  }
2652
2716
  ```
2653
2717
 
2654
- ## package-ui/src/context-menu/line.ts
2718
+ ## package-ui/context-menu/line.ts
2655
2719
 
2656
2720
  ```ts
2657
2721
  import { Base } from "#base";
@@ -2697,7 +2761,7 @@ export abstract class MenuLine extends Base implements ContextMenuLine {
2697
2761
  }
2698
2762
  ```
2699
2763
 
2700
- ## package-ui/src/context-menu/menu.scss
2764
+ ## package-ui/context-menu/menu.scss
2701
2765
 
2702
2766
  ```scss
2703
2767
  @use "./line.scss" as line;
@@ -2745,7 +2809,7 @@ contextmenu-menu {
2745
2809
  }
2746
2810
  ```
2747
2811
 
2748
- ## package-ui/src/context-menu/menu.ts
2812
+ ## package-ui/context-menu/menu.ts
2749
2813
 
2750
2814
  ```ts
2751
2815
  import { Base, define_element } from "#base";
@@ -2832,8 +2896,7 @@ export class ContextMenu extends Base {
2832
2896
 
2833
2897
  protected connectedCallback(): void {
2834
2898
  super.connectedCallback();
2835
- const lines =
2836
- typeof this.#lines === "function" ? this.#lines() : this.#lines;
2899
+ const lines = this.read_lines();
2837
2900
  this.#loading?.remove();
2838
2901
  if (lines instanceof Promise) {
2839
2902
  const buffer = (this.#loading = this.appendChild(new Buffer()));
@@ -2870,6 +2933,13 @@ export class ContextMenu extends Base {
2870
2933
  );
2871
2934
  }
2872
2935
 
2936
+ /**Gives the lines the menu shows when it opens, a lines function is called
2937
+ * The lines are elements in one menu at a time, ctm.combine moves them into its menu, this menu takes them back when it opens */
2938
+ read_lines():
2939
+ (ContextMenuLine | undefined)[] | Promise<(ContextMenuLine | undefined)[]> {
2940
+ return typeof this.#lines === "function" ? this.#lines() : this.#lines;
2941
+ }
2942
+
2873
2943
  /**Sets the lines of the context menu */
2874
2944
  set lines(lines: (ContextMenuLine | undefined)[]) {
2875
2945
  this.replaceChildren();
@@ -3010,7 +3080,7 @@ export function context_menu(
3010
3080
  }
3011
3081
  ```
3012
3082
 
3013
- ## package-ui/src/context-menu/option.scss
3083
+ ## package-ui/context-menu/option.scss
3014
3084
 
3015
3085
  ```scss
3016
3086
  @use "./line.scss" as line;
@@ -3024,7 +3094,7 @@ contextmenu-option {
3024
3094
  }
3025
3095
  ```
3026
3096
 
3027
- ## package-ui/src/context-menu/option.ts
3097
+ ## package-ui/context-menu/option.ts
3028
3098
 
3029
3099
  ```ts
3030
3100
  import { define_element } from "#base";
@@ -3110,7 +3180,7 @@ export function context_line(
3110
3180
  }
3111
3181
  ```
3112
3182
 
3113
- ## package-ui/src/context-menu/shared.ts
3183
+ ## package-ui/context-menu/shared.ts
3114
3184
 
3115
3185
  ```ts
3116
3186
  import { BLUE, GREY } from "@chocbite/ts-lib/colors";
@@ -3168,7 +3238,7 @@ variables.make_variable(
3168
3238
  );
3169
3239
  ```
3170
3240
 
3171
- ## package-ui/src/context-menu/submenu.scss
3241
+ ## package-ui/context-menu/submenu.scss
3172
3242
 
3173
3243
  ```scss
3174
3244
  @use "./line.scss" as line;
@@ -3198,7 +3268,7 @@ contextmenu-submenu {
3198
3268
  }
3199
3269
  ```
3200
3270
 
3201
- ## package-ui/src/context-menu/submenu.ts
3271
+ ## package-ui/context-menu/submenu.ts
3202
3272
 
3203
3273
  ```ts
3204
3274
  import { define_element } from "#base";
@@ -3331,7 +3401,7 @@ export function context_sub(
3331
3401
  }
3332
3402
  ```
3333
3403
 
3334
- ## package-ui/src/document/document.ts
3404
+ ## package-ui/document/document.ts
3335
3405
 
3336
3406
  ```ts
3337
3407
  import { EventHandler } from "@chocbite/ts-lib/event";
@@ -3408,13 +3478,13 @@ class DocumentHandler {
3408
3478
  export const DOCUMENT_HANDLER = new DocumentHandler(document);
3409
3479
  ```
3410
3480
 
3411
- ## package-ui/src/document/index.ts
3481
+ ## package-ui/document/index.ts
3412
3482
 
3413
3483
  ```ts
3414
3484
  export * from "./document";
3415
3485
  ```
3416
3486
 
3417
- ## package-ui/src/dom/index.ts
3487
+ ## package-ui/dom/index.ts
3418
3488
 
3419
3489
  ```ts
3420
3490
  export function node_clone<T extends Node>(node: T): T {
@@ -3422,7 +3492,7 @@ export function node_clone<T extends Node>(node: T): T {
3422
3492
  }
3423
3493
  ```
3424
3494
 
3425
- ## package-ui/src/form/base.scss
3495
+ ## package-ui/form/base.scss
3426
3496
 
3427
3497
  ```scss
3428
3498
  // _______ _ _ ______ __ __ ______ __ __ _____ _____
@@ -3625,13 +3695,13 @@ $touch_unit_width: $touch_unit_font_size * 5.6;
3625
3695
  }
3626
3696
  ```
3627
3697
 
3628
- ## package-ui/src/form/base.ts
3698
+ ## package-ui/form/base.ts
3629
3699
 
3630
3700
  ```ts
3631
3701
  import { Base } from "#base";
3632
3702
  import { sync_resolve } from "@chocbite/ts-lib/common";
3633
3703
  import { err, ok, type Option, type Result } from "@chocbite/ts-lib/result";
3634
- import type { State, StateREAW, StateSub } from "@chocbite/ts-lib/state";
3704
+ import type { State, StateREA, StateSub } from "@chocbite/ts-lib/state";
3635
3705
  import "./shared";
3636
3706
 
3637
3707
  export interface FormOptions {}
@@ -3723,7 +3793,8 @@ export abstract class FormValue<
3723
3793
  protected _state?: State<RT, Option<{}>, RT>;
3724
3794
  #func?: StateSub<Result<RT, string>>;
3725
3795
 
3726
- bind(opts: { value: StateREAW<RT, Option<{}>, RT> }): this {
3796
+ /**Binds the element to a state, a read only state is shown and changes to the element are refused with a warning*/
3797
+ bind(opts: { value: StateREA<RT, Option<{}>, RT> }): this {
3727
3798
  if (this.#func) {
3728
3799
  this.detach_state(this.#func);
3729
3800
  this.#func = undefined;
@@ -3946,7 +4017,7 @@ export abstract class FormValueWrite<
3946
4017
  }
3947
4018
  ```
3948
4019
 
3949
- ## package-ui/src/form/boolean/button/button.scss
4020
+ ## package-ui/form/boolean/button/button.scss
3950
4021
 
3951
4022
  ```scss
3952
4023
  @use "../../base";
@@ -4053,7 +4124,7 @@ form-button {
4053
4124
  }
4054
4125
  ```
4055
4126
 
4056
- ## package-ui/src/form/boolean/button/button.ts
4127
+ ## package-ui/form/boolean/button/button.ts
4057
4128
 
4058
4129
  ```ts
4059
4130
  import { define_element } from "#base";
@@ -4259,7 +4330,7 @@ export function form_button<ID extends string | undefined>(
4259
4330
  }
4260
4331
  ```
4261
4332
 
4262
- ## package-ui/src/form/boolean/lamp/lamp.scss
4333
+ ## package-ui/form/boolean/lamp/lamp.scss
4263
4334
 
4264
4335
  ```scss
4265
4336
  @use "../../base";
@@ -4355,7 +4426,7 @@ form-lamp {
4355
4426
  }
4356
4427
  ```
4357
4428
 
4358
- ## package-ui/src/form/boolean/lamp/lamp.ts
4429
+ ## package-ui/form/boolean/lamp/lamp.ts
4359
4430
 
4360
4431
  ```ts
4361
4432
  import { define_element } from "#base";
@@ -4477,7 +4548,7 @@ function from<
4477
4548
  export const form_lamp = from;
4478
4549
  ```
4479
4550
 
4480
- ## package-ui/src/form/boolean/switch/switch.scss
4551
+ ## package-ui/form/boolean/switch/switch.scss
4481
4552
 
4482
4553
  ```scss
4483
4554
  @use "../../base";
@@ -4623,7 +4694,7 @@ form-switch {
4623
4694
  }
4624
4695
  ```
4625
4696
 
4626
- ## package-ui/src/form/boolean/switch/switch.ts
4697
+ ## package-ui/form/boolean/switch/switch.ts
4627
4698
 
4628
4699
  ```ts
4629
4700
  import { define_element } from "#base";
@@ -4792,7 +4863,7 @@ export function form_switch<ID extends string | undefined>(
4792
4863
  }
4793
4864
  ```
4794
4865
 
4795
- ## package-ui/src/form/globals.d.ts
4866
+ ## package-ui/form/globals.d.ts
4796
4867
 
4797
4868
  ```ts
4798
4869
  declare module "*.scss" {
@@ -4801,7 +4872,7 @@ declare module "*.scss" {
4801
4872
  }
4802
4873
  ```
4803
4874
 
4804
- ## package-ui/src/form/group/group.scss
4875
+ ## package-ui/form/group/group.scss
4805
4876
 
4806
4877
  ```scss
4807
4878
  @use "../base";
@@ -4855,7 +4926,7 @@ form-group {
4855
4926
  }
4856
4927
  ```
4857
4928
 
4858
- ## package-ui/src/form/group/group.ts
4929
+ ## package-ui/form/group/group.ts
4859
4930
 
4860
4931
  ```ts
4861
4932
  import { define_element } from "#base";
@@ -4988,7 +5059,7 @@ export function form_group<
4988
5059
  }
4989
5060
  ```
4990
5061
 
4991
- ## package-ui/src/form/group/group_base.scss
5062
+ ## package-ui/form/group/group_base.scss
4992
5063
 
4993
5064
  ```scss
4994
5065
  @use "../base";
@@ -5026,7 +5097,7 @@ $padding: 0.4rem;
5026
5097
  }
5027
5098
  ```
5028
5099
 
5029
- ## package-ui/src/form/group/group_base.ts
5100
+ ## package-ui/form/group/group_base.ts
5030
5101
 
5031
5102
  ```ts
5032
5103
  import { AccessTypes } from "#base";
@@ -5197,7 +5268,7 @@ export abstract class FormGroupBase<
5197
5268
  }
5198
5269
  ```
5199
5270
 
5200
- ## package-ui/src/form/group/group_collapser.scss
5271
+ ## package-ui/form/group/group_collapser.scss
5201
5272
 
5202
5273
  ```scss
5203
5274
  @use "../base";
@@ -5296,7 +5367,7 @@ form-group-collapser {
5296
5367
  }
5297
5368
  ```
5298
5369
 
5299
- ## package-ui/src/form/group/group_collapser.ts
5370
+ ## package-ui/form/group/group_collapser.ts
5300
5371
 
5301
5372
  ```ts
5302
5373
  import { define_element } from "#base";
@@ -5463,7 +5534,7 @@ export function form_group_collapser(
5463
5534
  }
5464
5535
  ```
5465
5536
 
5466
- ## package-ui/src/form/index.ts
5537
+ ## package-ui/form/index.ts
5467
5538
 
5468
5539
  ```ts
5469
5540
  import {
@@ -5644,7 +5715,7 @@ export {
5644
5715
  } from "./special/date_time/date_time_input";
5645
5716
  ```
5646
5717
 
5647
- ## package-ui/src/form/list/list_field.scss
5718
+ ## package-ui/form/list/list_field.scss
5648
5719
 
5649
5720
  ```scss
5650
5721
  @use "../base";
@@ -5655,7 +5726,7 @@ form-listfield {
5655
5726
  }
5656
5727
  ```
5657
5728
 
5658
- ## package-ui/src/form/list/list_field.ts
5729
+ ## package-ui/form/list/list_field.ts
5659
5730
 
5660
5731
  ```ts
5661
5732
  import { define_element } from "#base";
@@ -5688,7 +5759,7 @@ export function form_list_field<T extends FormElement>(element: T) {
5688
5759
  }
5689
5760
  ```
5690
5761
 
5691
- ## package-ui/src/form/number/number_base.scss
5762
+ ## package-ui/form/number/number_base.scss
5692
5763
 
5693
5764
  ```scss
5694
5765
  @use "../base";
@@ -5727,7 +5798,7 @@ export function form_list_field<T extends FormElement>(element: T) {
5727
5798
  }
5728
5799
  ```
5729
5800
 
5730
- ## package-ui/src/form/number/number_base.ts
5801
+ ## package-ui/form/number/number_base.ts
5731
5802
 
5732
5803
  ```ts
5733
5804
  import { none } from "@chocbite/ts-lib/result";
@@ -5858,7 +5929,7 @@ function fraction_digits(val: number): number {
5858
5929
  }
5859
5930
  ```
5860
5931
 
5861
- ## package-ui/src/form/number/number_input/number_input.scss
5932
+ ## package-ui/form/number/number_input/number_input.scss
5862
5933
 
5863
5934
  ```scss
5864
5935
  @use "../../base";
@@ -5944,7 +6015,7 @@ form-numberinput {
5944
6015
  }
5945
6016
  ```
5946
6017
 
5947
- ## package-ui/src/form/number/number_input/number_input.ts
6018
+ ## package-ui/form/number/number_input/number_input.ts
5948
6019
 
5949
6020
  ```ts
5950
6021
  import { define_element } from "#base";
@@ -6176,7 +6247,7 @@ export function form_number_input<ID extends string | undefined>(
6176
6247
  }
6177
6248
  ```
6178
6249
 
6179
- ## package-ui/src/form/number/progress/progress.scss
6250
+ ## package-ui/form/number/progress/progress.scss
6180
6251
 
6181
6252
  ```scss
6182
6253
  @use "../../base";
@@ -6249,7 +6320,7 @@ form-progress {
6249
6320
  }
6250
6321
  ```
6251
6322
 
6252
- ## package-ui/src/form/number/progress/progress.ts
6323
+ ## package-ui/form/number/progress/progress.ts
6253
6324
 
6254
6325
  ```ts
6255
6326
  import { define_element } from "#base";
@@ -6365,7 +6436,7 @@ export function form_progress<ID extends string | undefined>(
6365
6436
  }
6366
6437
  ```
6367
6438
 
6368
- ## package-ui/src/form/number/slider/slider.scss
6439
+ ## package-ui/form/number/slider/slider.scss
6369
6440
 
6370
6441
  ```scss
6371
6442
  @use "../../base";
@@ -6531,7 +6602,7 @@ form-slider {
6531
6602
  }
6532
6603
  ```
6533
6604
 
6534
- ## package-ui/src/form/number/slider/slider.ts
6605
+ ## package-ui/form/number/slider/slider.ts
6535
6606
 
6536
6607
  ```ts
6537
6608
  import { define_element } from "#base";
@@ -6943,7 +7014,7 @@ export function form_slider<ID extends string | undefined>(
6943
7014
  }
6944
7015
  ```
6945
7016
 
6946
- ## package-ui/src/form/number/stepper/stepper.scss
7017
+ ## package-ui/form/number/stepper/stepper.scss
6947
7018
 
6948
7019
  ```scss
6949
7020
  @use "../../base";
@@ -7058,7 +7129,7 @@ form-stepper {
7058
7129
  }
7059
7130
  ```
7060
7131
 
7061
- ## package-ui/src/form/number/stepper/stepper.ts
7132
+ ## package-ui/form/number/stepper/stepper.ts
7062
7133
 
7063
7134
  ```ts
7064
7135
  import { define_element } from "#base";
@@ -7445,7 +7516,7 @@ export function form_stepper<ID extends string | undefined>(
7445
7516
  }
7446
7517
  ```
7447
7518
 
7448
- ## package-ui/src/form/selectors/drop_down/drop_down.scss
7519
+ ## package-ui/form/selectors/drop_down/drop_down.scss
7449
7520
 
7450
7521
  ```scss
7451
7522
  @use "../../base";
@@ -7670,7 +7741,7 @@ form-dropdownbox {
7670
7741
  }
7671
7742
  ```
7672
7743
 
7673
- ## package-ui/src/form/selectors/drop_down/drop_down.ts
7744
+ ## package-ui/form/selectors/drop_down/drop_down.ts
7674
7745
 
7675
7746
  ```ts
7676
7747
  import { Base, define_element } from "#base";
@@ -8077,7 +8148,7 @@ DOCUMENT_HANDLER.events.on("added", (e) => add_box(e.data));
8077
8148
  DOCUMENT_HANDLER.events.on("removed", (e) => boxes.delete(e.data));
8078
8149
  ```
8079
8150
 
8080
- ## package-ui/src/form/selectors/selector_base.ts
8151
+ ## package-ui/form/selectors/selector_base.ts
8081
8152
 
8082
8153
  ```ts
8083
8154
  import { some } from "@chocbite/ts-lib/result";
@@ -8149,7 +8220,7 @@ export abstract class FormSelectorBase<
8149
8220
  }
8150
8221
  ```
8151
8222
 
8152
- ## package-ui/src/form/selectors/toggle_button/toggle_button.scss
8223
+ ## package-ui/form/selectors/toggle_button/toggle_button.scss
8153
8224
 
8154
8225
  ```scss
8155
8226
  @use "../../base";
@@ -8305,7 +8376,7 @@ form-togglebutton {
8305
8376
  }
8306
8377
  ```
8307
8378
 
8308
- ## package-ui/src/form/selectors/toggle_button/toggle_button.ts
8379
+ ## package-ui/form/selectors/toggle_button/toggle_button.ts
8309
8380
 
8310
8381
  ```ts
8311
8382
  import { define_element } from "#base";
@@ -8436,7 +8507,7 @@ export function form_toggle_button<RT, ID extends string | undefined>(
8436
8507
  }
8437
8508
  ```
8438
8509
 
8439
- ## package-ui/src/form/shared.ts
8510
+ ## package-ui/form/shared.ts
8440
8511
 
8441
8512
  ```ts
8442
8513
  import {
@@ -8843,7 +8914,7 @@ font.make_variable(
8843
8914
  );
8844
8915
  ```
8845
8916
 
8846
- ## package-ui/src/form/spacing/spacer.scss
8917
+ ## package-ui/form/spacing/spacer.scss
8847
8918
 
8848
8919
  ```scss
8849
8920
  @use "../base";
@@ -8855,7 +8926,7 @@ form-spacer {
8855
8926
  }
8856
8927
  ```
8857
8928
 
8858
- ## package-ui/src/form/spacing/spacer.ts
8929
+ ## package-ui/form/spacing/spacer.ts
8859
8930
 
8860
8931
  ```ts
8861
8932
  import { define_element } from "#base";
@@ -8900,7 +8971,7 @@ export function form_spacer(options?: FormSpacerOptions): FormSpacer {
8900
8971
  }
8901
8972
  ```
8902
8973
 
8903
- ## package-ui/src/form/special/color/color_input.scss
8974
+ ## package-ui/form/special/color/color_input.scss
8904
8975
 
8905
8976
  ```scss
8906
8977
  @use "../../base";
@@ -8963,7 +9034,7 @@ form-colorinput {
8963
9034
  }
8964
9035
  ```
8965
9036
 
8966
- ## package-ui/src/form/special/color/color_input.ts
9037
+ ## package-ui/form/special/color/color_input.ts
8967
9038
 
8968
9039
  ```ts
8969
9040
  import { define_element } from "#base";
@@ -9040,7 +9111,7 @@ export function form_color<ID extends string | undefined>(
9040
9111
  }
9041
9112
  ```
9042
9113
 
9043
- ## package-ui/src/form/special/date_time/date_time_input.scss
9114
+ ## package-ui/form/special/date_time/date_time_input.scss
9044
9115
 
9045
9116
  ```scss
9046
9117
  @use "../../base";
@@ -9113,7 +9184,7 @@ form-datetimeinput {
9113
9184
  }
9114
9185
  ```
9115
9186
 
9116
- ## package-ui/src/form/special/date_time/date_time_input.ts
9187
+ ## package-ui/form/special/date_time/date_time_input.ts
9117
9188
 
9118
9189
  ```ts
9119
9190
  import { define_element } from "#base";
@@ -9320,7 +9391,7 @@ export function form_date_time<
9320
9391
  }
9321
9392
  ```
9322
9393
 
9323
- ## package-ui/src/form/special/ip/ip_input.scss
9394
+ ## package-ui/form/special/ip/ip_input.scss
9324
9395
 
9325
9396
  ```scss
9326
9397
  @use "../../base";
@@ -9390,7 +9461,7 @@ form-ipinput {
9390
9461
  }
9391
9462
  ```
9392
9463
 
9393
- ## package-ui/src/form/special/ip/ip_input.ts
9464
+ ## package-ui/form/special/ip/ip_input.ts
9394
9465
 
9395
9466
  ```ts
9396
9467
  import { define_element } from "#base";
@@ -9678,7 +9749,7 @@ export function form_ip<ID extends string | undefined>(
9678
9749
  }
9679
9750
  ```
9680
9751
 
9681
- ## package-ui/src/form/special/password/password_input.scss
9752
+ ## package-ui/form/special/password/password_input.scss
9682
9753
 
9683
9754
  ```scss
9684
9755
  @use "../../base";
@@ -9733,7 +9804,7 @@ form-passwordinput {
9733
9804
  }
9734
9805
  ```
9735
9806
 
9736
- ## package-ui/src/form/special/password/password_input.ts
9807
+ ## package-ui/form/special/password/password_input.ts
9737
9808
 
9738
9809
  ```ts
9739
9810
  import { define_element } from "#base";
@@ -9822,7 +9893,7 @@ export function form_password<ID extends string | undefined>(
9822
9893
  }
9823
9894
  ```
9824
9895
 
9825
- ## package-ui/src/form/text/input/text_input.scss
9896
+ ## package-ui/form/text/input/text_input.scss
9826
9897
 
9827
9898
  ```scss
9828
9899
  @use "../../base";
@@ -9870,7 +9941,7 @@ form-textinput {
9870
9941
  }
9871
9942
  ```
9872
9943
 
9873
- ## package-ui/src/form/text/input/text_input.ts
9944
+ ## package-ui/form/text/input/text_input.ts
9874
9945
 
9875
9946
  ```ts
9876
9947
  import { define_element } from "#base";
@@ -10073,7 +10144,7 @@ export function form_text_input<ID extends string | undefined>(
10073
10144
  }
10074
10145
  ```
10075
10146
 
10076
- ## package-ui/src/form/text/multi_line/text_multi_line.scss
10147
+ ## package-ui/form/text/multi_line/text_multi_line.scss
10077
10148
 
10078
10149
  ```scss
10079
10150
  @use "../../base";
@@ -10162,7 +10233,7 @@ form-textmultiline {
10162
10233
  }
10163
10234
  ```
10164
10235
 
10165
- ## package-ui/src/form/text/multi_line/text_multi_line.ts
10236
+ ## package-ui/form/text/multi_line/text_multi_line.ts
10166
10237
 
10167
10238
  ```ts
10168
10239
  import { define_element } from "#base";
@@ -10396,7 +10467,7 @@ export function form_text_multiline<ID extends string | undefined>(
10396
10467
  }
10397
10468
  ```
10398
10469
 
10399
- ## package-ui/src/form/text/text/text.scss
10470
+ ## package-ui/form/text/text/text.scss
10400
10471
 
10401
10472
  ```scss
10402
10473
  @use "../../base";
@@ -10418,7 +10489,7 @@ form-text {
10418
10489
  }
10419
10490
  ```
10420
10491
 
10421
- ## package-ui/src/form/text/text/text.ts
10492
+ ## package-ui/form/text/text/text.ts
10422
10493
 
10423
10494
  ```ts
10424
10495
  import { define_element } from "#base";
@@ -10469,7 +10540,7 @@ export function form_text(options: FormTextOptions): FormText {
10469
10540
  }
10470
10541
  ```
10471
10542
 
10472
- ## package-ui/src/icons/font.scss
10543
+ ## package-ui/icons/font.scss
10473
10544
 
10474
10545
  ```scss
10475
10546
  @font-face {
@@ -10480,7 +10551,7 @@ export function form_text(options: FormTextOptions): FormText {
10480
10551
  }
10481
10552
  ```
10482
10553
 
10483
- ## package-ui/src/icons/globals.d.ts
10554
+ ## package-ui/icons/globals.d.ts
10484
10555
 
10485
10556
  ```ts
10486
10557
  declare module "*.scss" {
@@ -10489,18 +10560,18 @@ declare module "*.scss" {
10489
10560
  }
10490
10561
  ```
10491
10562
 
10492
- ## package-ui/src/icons/index.ts
10563
+ ## package-ui/icons/index.ts
10493
10564
 
10494
10565
  ```ts
10495
10566
  export * from "./material/material-symbols-rounded";
10496
10567
  import "./font.scss";
10497
10568
  ```
10498
10569
 
10499
- ## package-ui/src/icons/material/material-symbols-rounded.ts
10570
+ ## package-ui/icons/material/material-symbols-rounded.ts
10500
10571
 
10501
10572
  Omitted, generated file with 4107 icons. Every icon is `export const material_<name>_rounded = generate_function(...)`, e.g. `material_10k_rounded`, exported from `@chocbite/ts-lib-ui/icons`. Search the `.d.mts` files of this package for the available names.
10502
10573
 
10503
- ## package-ui/src/icons/mixins.scss
10574
+ ## package-ui/icons/mixins.scss
10504
10575
 
10505
10576
  ```scss
10506
10577
  @mixin material-symbols-rounded {
@@ -10517,7 +10588,7 @@ Omitted, generated file with 4107 icons. Every icon is `export const material_<n
10517
10588
  }
10518
10589
  ```
10519
10590
 
10520
- ## package-ui/src/icons/shared.ts
10591
+ ## package-ui/icons/shared.ts
10521
10592
 
10522
10593
  ```ts
10523
10594
  import { node_clone } from "#dom";
@@ -10540,7 +10611,7 @@ export function generate_function(name: string, icon: string): SVGFunc {
10540
10611
  }
10541
10612
  ```
10542
10613
 
10543
- ## package-ui/src/keyboard/base.ts
10614
+ ## package-ui/keyboard/base.ts
10544
10615
 
10545
10616
  ```ts
10546
10617
  import { Base } from "#base";
@@ -10644,13 +10715,13 @@ export abstract class KeyboardBase extends Base {
10644
10715
  }
10645
10716
  ```
10646
10717
 
10647
- ## package-ui/src/keyboard/declarations.d.ts
10718
+ ## package-ui/keyboard/declarations.d.ts
10648
10719
 
10649
10720
  ```ts
10650
10721
  declare module "*.scss";
10651
10722
  ```
10652
10723
 
10653
- ## package-ui/src/keyboard/helpers.ts
10724
+ ## package-ui/keyboard/helpers.ts
10654
10725
 
10655
10726
  ```ts
10656
10727
  import { KeyboardType } from "./types";
@@ -10709,7 +10780,7 @@ export function keyboard_type(element: HTMLElement): KeyboardType | undefined {
10709
10780
  }
10710
10781
  ```
10711
10782
 
10712
- ## package-ui/src/keyboard/index.ts
10783
+ ## package-ui/keyboard/index.ts
10713
10784
 
10714
10785
  ```ts
10715
10786
  import { DOCUMENT_HANDLER } from "#document";
@@ -10801,7 +10872,7 @@ export function keyboard_create(config: KeyboardConfig): Keyboard_Keys {
10801
10872
  }
10802
10873
  ```
10803
10874
 
10804
- ## package-ui/src/keyboard/keyboard_color.scss
10875
+ ## package-ui/keyboard/keyboard_color.scss
10805
10876
 
10806
10877
  ```scss
10807
10878
  onscreen-keyboard-keyboard-color {
@@ -10893,7 +10964,7 @@ onscreen-keyboard-keyboard-color {
10893
10964
  }
10894
10965
  ```
10895
10966
 
10896
- ## package-ui/src/keyboard/keyboard_color.ts
10967
+ ## package-ui/keyboard/keyboard_color.ts
10897
10968
 
10898
10969
  ```ts
10899
10970
  import { define_element } from "#base";
@@ -11136,7 +11207,7 @@ export class Keyboard_Color extends KeyboardBase {
11136
11207
  define_element(Keyboard_Color);
11137
11208
  ```
11138
11209
 
11139
- ## package-ui/src/keyboard/keyboard_datetime.scss
11210
+ ## package-ui/keyboard/keyboard_datetime.scss
11140
11211
 
11141
11212
  ```scss
11142
11213
  onscreen-keyboard-keyboard-datetime {
@@ -11282,7 +11353,7 @@ onscreen-keyboard-keyboard-datetime {
11282
11353
  }
11283
11354
  ```
11284
11355
 
11285
- ## package-ui/src/keyboard/keyboard_datetime.ts
11356
+ ## package-ui/keyboard/keyboard_datetime.ts
11286
11357
 
11287
11358
  ```ts
11288
11359
  import { define_element } from "#base";
@@ -11735,7 +11806,7 @@ define_element(Keyboard_DateTime);
11735
11806
  export const DATETIME_KEYBOARD = new Keyboard_DateTime();
11736
11807
  ```
11737
11808
 
11738
- ## package-ui/src/keyboard/keyboard_keys.scss
11809
+ ## package-ui/keyboard/keyboard_keys.scss
11739
11810
 
11740
11811
  ```scss
11741
11812
  onscreen-keyboard-keyboard-keys {
@@ -11788,7 +11859,7 @@ onscreen-keyboard-key {
11788
11859
  }
11789
11860
  ```
11790
11861
 
11791
- ## package-ui/src/keyboard/keyboard_keys.ts
11862
+ ## package-ui/keyboard/keyboard_keys.ts
11792
11863
 
11793
11864
  ```ts
11794
11865
  import { Base, define_element } from "#base";
@@ -12143,7 +12214,7 @@ export class Keyboard_Keys extends KeyboardBase {
12143
12214
  define_element(Keyboard_Keys);
12144
12215
  ```
12145
12216
 
12146
- ## package-ui/src/keyboard/number.ts
12217
+ ## package-ui/keyboard/number.ts
12147
12218
 
12148
12219
  ```ts
12149
12220
  import { Keyboard_Keys } from "./keyboard_keys";
@@ -12311,12 +12382,12 @@ export const PHONE_KEYBOARD = new Keyboard_Keys({
12311
12382
  });
12312
12383
  ```
12313
12384
 
12314
- ## package-ui/src/keyboard/settings.ts
12385
+ ## package-ui/keyboard/settings.ts
12315
12386
 
12316
12387
  ```ts
12317
12388
  import { settings_init } from "#settings";
12318
12389
  import { state as st } from "@chocbite/ts-lib/state";
12319
- import { version } from "../../../package.json";
12390
+ import { version } from "../../package.json";
12320
12391
 
12321
12392
  const SETTINGS = settings_init(
12322
12393
  "@chocbite/ts-lib-keyboard",
@@ -12336,7 +12407,7 @@ SETTINGS.register(
12336
12407
  export const VIRTUAL_KEYBOARD = PRIVATE_VIRTUAL_KEYBOARD.read_write;
12337
12408
  ```
12338
12409
 
12339
- ## package-ui/src/keyboard/shared.ts
12410
+ ## package-ui/keyboard/shared.ts
12340
12411
 
12341
12412
  ```ts
12342
12413
  import { GREY } from "@chocbite/ts-lib/colors";
@@ -12409,7 +12480,7 @@ colors.make_variable(
12409
12480
  );
12410
12481
  ```
12411
12482
 
12412
- ## package-ui/src/keyboard/text.ts
12483
+ ## package-ui/keyboard/text.ts
12413
12484
 
12414
12485
  ```ts
12415
12486
  import { Keyboard_Keys } from "./keyboard_keys";
@@ -12595,7 +12666,7 @@ export const EMAIL_KEYBOARD = new Keyboard_Keys({
12595
12666
  });
12596
12667
  ```
12597
12668
 
12598
- ## package-ui/src/keyboard/types.ts
12669
+ ## package-ui/keyboard/types.ts
12599
12670
 
12600
12671
  ```ts
12601
12672
  export const KeyboardSpecialKeys = {
@@ -12675,25 +12746,22 @@ export interface KeyboardConfig {
12675
12746
  }
12676
12747
  ```
12677
12748
 
12678
- ## package-ui/src/list/add_row.scss
12749
+ ## package-ui/list/add_row.scss
12679
12750
 
12680
12751
  ```scss
12681
12752
  list-addrow {
12682
12753
  display: contents;
12683
12754
 
12684
- &[inert] > span {
12755
+ &[inert] span.add {
12685
12756
  opacity: 0.6;
12686
12757
  pointer-events: none;
12687
12758
  }
12688
12759
 
12689
- > span {
12760
+ //In the key field with sub rows, directly in the add row without them
12761
+ span.add {
12690
12762
  color: var(--list-colors-text-add);
12691
12763
  grid-column: 1 / -1;
12692
12764
 
12693
- list-container > div.sub-rows & {
12694
- grid-column: 2 / -1;
12695
- }
12696
-
12697
12765
  display: flex;
12698
12766
  align-items: center;
12699
12767
  justify-content: center;
@@ -12733,7 +12801,7 @@ list-addrow {
12733
12801
  }
12734
12802
  ```
12735
12803
 
12736
- ## package-ui/src/list/add_row.ts
12804
+ ## package-ui/list/add_row.ts
12737
12805
 
12738
12806
  ```ts
12739
12807
  import { Base, define_element } from "#base";
@@ -12782,9 +12850,13 @@ export class ListAddRow<
12782
12850
  super();
12783
12851
  this.#parent = parent;
12784
12852
  this.depth = parent.depth + 1;
12785
- if (root.sub_rows) this.appendChild(new ListKeyField(this));
12786
- this.#button = this.appendChild(document.createElement("span"));
12853
+ this.#button = document.createElement("span");
12854
+ this.#button.className = "add";
12787
12855
  this.#button.tabIndex = 0;
12856
+ //With sub rows the button is in the key field after the tree lines, it runs from the key column to the end
12857
+ if (root.sub_rows)
12858
+ this.appendChild(new ListKeyField(this)).tail = this.#button;
12859
+ else this.appendChild(this.#button);
12788
12860
  this.#text = this.#button.appendChild(document.createTextNode(""));
12789
12861
  }
12790
12862
 
@@ -12845,11 +12917,14 @@ export class ListAddRow<
12845
12917
  define_element(ListAddRow);
12846
12918
  ```
12847
12919
 
12848
- ## package-ui/src/list/container.scss
12920
+ ## package-ui/list/container.scss
12849
12921
 
12850
12922
  ```scss
12923
+ @use "../icons/mixins" as icons;
12924
+
12851
12925
  list-container {
12852
12926
  $sizer_width: 0.5rem;
12927
+ $sizer_touch_width: 1.5rem;
12853
12928
 
12854
12929
  position: relative;
12855
12930
  display: block;
@@ -12869,12 +12944,11 @@ list-container {
12869
12944
  position: sticky;
12870
12945
  border-bottom: 1px solid var(--list-colors-border-header);
12871
12946
  background-color: var(--list-colors-background-row_even);
12947
+ //Above the rows scrolling under it
12872
12948
  z-index: 999;
12873
12949
 
12874
12950
  &:first-child {
12875
12951
  left: 0;
12876
- z-index: 3;
12877
- border-right: 1px solid var(--list-colors-border-column);
12878
12952
  }
12879
12953
  }
12880
12954
 
@@ -12913,6 +12987,7 @@ list-container {
12913
12987
  }
12914
12988
  }
12915
12989
 
12990
+ //Handle resizing the column
12916
12991
  > div {
12917
12992
  display: flex;
12918
12993
  position: relative;
@@ -12922,8 +12997,11 @@ list-container {
12922
12997
  cursor: ew-resize;
12923
12998
  justify-content: center;
12924
12999
  align-items: center;
13000
+ //A drag on the handle resizes, it does not pan the list
13001
+ touch-action: none;
12925
13002
 
12926
- &:hover {
13003
+ &:hover,
13004
+ &.active {
12927
13005
  background-color: var(--list-colors-background-row_hover);
12928
13006
  }
12929
13007
 
@@ -12933,6 +13011,26 @@ list-container {
12933
13011
  height: 80%;
12934
13012
  background-color: var(--list-colors-border-column);
12935
13013
  }
13014
+
13015
+ &.active::after {
13016
+ background-color: var(--list-colors-focus-normal);
13017
+ }
13018
+
13019
+ //Wide enough for a finger, with two lines as a grip so it shows it can be grabbed
13020
+ .touch & {
13021
+ width: $sizer_touch_width;
13022
+
13023
+ &::after {
13024
+ width: 3px;
13025
+ height: 60%;
13026
+ transform: translateX(-0.2rem);
13027
+ box-shadow: 0.4rem 0 0 var(--list-colors-border-column);
13028
+ }
13029
+
13030
+ &.active::after {
13031
+ box-shadow: 0.4rem 0 0 var(--list-colors-focus-normal);
13032
+ }
13033
+ }
12936
13034
  }
12937
13035
  }
12938
13036
  }
@@ -12943,21 +13041,146 @@ list-container {
12943
13041
  }
12944
13042
  }
12945
13043
  }
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
+
13080
+ //Hidden input showing write errors with the validation message of the browser, placed over a row by the list
13081
+ list-container > input.list-warn {
13082
+ all: unset;
13083
+ visibility: hidden;
13084
+ position: absolute;
13085
+ pointer-events: none;
13086
+ height: 0px;
13087
+ width: 0px;
13088
+ }
13089
+
13090
+ // _ ______ _____
13091
+ // | | | ____| /\ | __ \
13092
+ // | | | |__ / \ | | | |
13093
+ // | | | __| / /\ \ | | | |
13094
+ // | |____| |____ / ____ \| |__| |
13095
+ // |______|______/_/ \_\_____/
13096
+ //Columns in front of the key field column, the drag handles and then the checkboxes or radio buttons
13097
+ //They are square and sticky, each starts where the ones before it end
13098
+ list-container > div {
13099
+ --list-drag-width: 0px;
13100
+ --list-check-width: 0px;
13101
+ --list-lead-size: var(--list-size-row_min);
13102
+ .touch & {
13103
+ --list-lead-size: var(--list-size-touch_row_min);
13104
+ }
13105
+ &.drag {
13106
+ --list-drag-width: var(--list-lead-size);
13107
+ }
13108
+ &.check {
13109
+ --list-check-width: var(--list-lead-size);
13110
+ }
13111
+
13112
+ list-keyfield,
13113
+ > list-headerrow > .key {
13114
+ left: calc(var(--list-drag-width) + var(--list-check-width));
13115
+ }
13116
+ //Sticky in both directions, above the column headers that scroll under them sideways
13117
+ > list-headerrow > :first-child,
13118
+ > list-headerrow > .key,
13119
+ > list-headerrow > list-dragfield,
13120
+ > list-headerrow > list-checkfield {
13121
+ z-index: 1000;
13122
+ }
13123
+
13124
+ //A resized key column, the column fits the widest key field minimum, so opening sub rows widens it by their indent
13125
+ //The containment makes the text not count for the width, the key fields stretch to the column like other cells
13126
+ &.key-sized {
13127
+ list-keyfield {
13128
+ box-sizing: border-box;
13129
+ contain: inline-size;
13130
+ min-width: max(var(--list-key-width), var(--list-key-min));
13131
+
13132
+ //A word longer than the space breaks instead of running under the next column
13133
+ > span.text {
13134
+ overflow-wrap: anywhere;
13135
+ }
13136
+ }
13137
+ //Stretches to the column like the other header cells, the width holds the column without rows
13138
+ > list-headerrow > .key {
13139
+ min-width: var(--list-key-width);
13140
+ }
13141
+ }
13142
+
13143
+ //The error and add rows start after the lead columns
13144
+ @for $lead from 1 through 2 {
13145
+ &.lead-#{$lead} {
13146
+ //With sub rows the key field holds the button or error and runs to the end
13147
+ list-keyfield.tail,
13148
+ list-addrow > span,
13149
+ list-error {
13150
+ grid-column: #{$lead + 1} / -1;
13151
+ }
13152
+ }
13153
+ }
13154
+ }
12946
13155
  ```
12947
13156
 
12948
- ## package-ui/src/list/container.ts
13157
+ ## package-ui/list/container.ts
12949
13158
 
12950
13159
  ```ts
12951
13160
  import { Base, define_element, type BaseIntersectObserver } from "#base";
13161
+ import ctm from "#context-menu";
12952
13162
  import { px_to_rem } from "#theme";
12953
- import { state, type State, type StateInferSub } from "@chocbite/ts-lib/state";
12954
- import state_ui from "../state_ui";
13163
+ import {
13164
+ state,
13165
+ type State,
13166
+ type StateInferSub,
13167
+ type StateREAW,
13168
+ type StateSub,
13169
+ } from "@chocbite/ts-lib/state";
13170
+ import type { Result } from "@chocbite/ts-lib/result";
12955
13171
  import { ListAddRow, type ListAddRowOptions } from "./add_row";
13172
+ import { ListDragField, ListReorder, type ListReorderOptions } from "./drag";
12956
13173
  import "./container.scss";
12957
13174
  import { list_rows_error_update, type ListRowsError } from "./error";
12958
- import { list_align_apply, text_field } from "./field";
12959
- import { ListRow } from "./row";
13175
+ import { list_align_apply } from "./field";
13176
+ import { list_rows_apply, ListRow } from "./row";
13177
+ import {
13178
+ ListCheckField,
13179
+ ListSelection,
13180
+ type ListSelectionOptions,
13181
+ } from "./selection";
12960
13182
  import "./shared";
13183
+ import { ListWarn } from "./warn";
12961
13184
  import type {
12962
13185
  ListColumnOptions,
12963
13186
  ListRoot,
@@ -12967,6 +13190,9 @@ import type {
12967
13190
  ListTypeExtract,
12968
13191
  } from "./types.ts";
12969
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
+
12970
13196
  class HeaderField extends Base {
12971
13197
  static element_name() {
12972
13198
  return "headerfield";
@@ -12984,6 +13210,11 @@ class HeaderField extends Base {
12984
13210
  if (text) this.text = text;
12985
13211
  }
12986
13212
 
13213
+ /**Elements shown instead of the text */
13214
+ set nodes(nodes: Node[]) {
13215
+ this.#text.replaceChildren(...nodes);
13216
+ }
13217
+
12987
13218
  set text(value: string) {
12988
13219
  this.#text.textContent = value;
12989
13220
  }
@@ -13002,16 +13233,26 @@ class HeaderField extends Base {
13002
13233
  double_timeout = 0;
13003
13234
  }, 300);
13004
13235
  this.setPointerCapture(e.pointerId);
13236
+ const handle = e.currentTarget as HTMLElement;
13237
+ handle.classList.add("active");
13005
13238
  const start_x = e.pageX;
13006
13239
  const start_width = this.#box.offsetWidth;
13007
13240
  this.onpointermove = (ev: PointerEvent) => {
13008
13241
  sizer(px_to_rem(start_width + (ev.pageX - start_x)));
13009
13242
  };
13010
- this.onpointerup = () => {
13011
- this.releasePointerCapture(e.pointerId);
13243
+ //A cancel or lost capture also ends the resize, a touch the browser takes for something else cancels
13244
+ const end = () => {
13245
+ if (this.hasPointerCapture(e.pointerId))
13246
+ this.releasePointerCapture(e.pointerId);
13247
+ handle.classList.remove("active");
13012
13248
  this.onpointermove = null;
13013
13249
  this.onpointerup = null;
13250
+ this.onpointercancel = null;
13251
+ this.onlostpointercapture = null;
13014
13252
  };
13253
+ this.onpointerup = end;
13254
+ this.onpointercancel = end;
13255
+ this.onlostpointercapture = end;
13015
13256
  };
13016
13257
  } else if (this.#sizer) {
13017
13258
  this.#sizer.remove();
@@ -13035,20 +13276,87 @@ class HeaderRow<
13035
13276
  }
13036
13277
 
13037
13278
  set fields(fields: HeaderField[]) {
13038
- if (this.#root.sub_rows) this.replaceChildren(text_field(), ...fields);
13039
- else this.replaceChildren(...fields);
13279
+ const lead: HTMLElement[] = [];
13280
+ if (this.#drag_header) lead.push(this.#drag_header);
13281
+ if (this.#check_header) lead.push(this.#check_header);
13282
+ if (this.#key_header) lead.push(this.#key_header);
13283
+ this.replaceChildren(...lead, ...fields);
13040
13284
  }
13041
13285
 
13042
- #root: ListRoot<R, T, A, S>;
13286
+ /**Header of the key field column, only with sub rows */
13287
+ get key_header(): HTMLElement | undefined {
13288
+ return this.#key_header;
13289
+ }
13290
+
13291
+ /**Header of the key field column, only with sub rows */
13292
+ #key_header?: HeaderField;
13293
+ /**Empty header of the drag handle column */
13294
+ #drag_header?: ListDragField;
13295
+ /**Header of the checkbox or radio button column, in multi mode it selects or deselects all rows */
13296
+ #check_header?: ListCheckField;
13043
13297
 
13044
- constructor(root: ListRoot<R, T, A, S>) {
13298
+ constructor(
13299
+ root: ListRoot<R, T, A, S>,
13300
+ key_sizer: (width: number | undefined) => void,
13301
+ ) {
13045
13302
  super();
13046
- this.#root = root;
13303
+ if (root.sub_rows) {
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);
13324
+ }
13325
+ if (root.reorder) this.#drag_header = new ListDragField();
13326
+ const selection = root.selection;
13327
+ if (selection?.column) this.#check_header = new ListCheckField();
13328
+ if (selection?.multi) {
13329
+ const check = this.#check_header!;
13330
+ check.onclick = () => {
13331
+ if (selection.amount_selected > 0) selection.clear();
13332
+ else selection.select_all();
13333
+ };
13334
+ ctm.attach(
13335
+ check,
13336
+ ctm.menu([
13337
+ ctm.line(
13338
+ "Select all",
13339
+ () => selection.select_all(),
13340
+ undefined,
13341
+ "Ctrl+A",
13342
+ ),
13343
+ ctm.line("Deselect all", () => selection.clear(), undefined, "Esc"),
13344
+ ]),
13345
+ );
13346
+ selection.on_change = () => {
13347
+ const selected = selection.amount_selected;
13348
+ check.classList.toggle("some", selected > 0);
13349
+ check.classList.toggle(
13350
+ "all",
13351
+ selected > 0 && selected === selection.amount_selectable,
13352
+ );
13353
+ };
13354
+ }
13047
13355
  }
13048
13356
  }
13049
13357
  define_element(HeaderRow);
13050
13358
 
13051
- interface ContainerOptions<S extends boolean = false> {
13359
+ interface ContainerOptions<S extends boolean = false, R = unknown, K = R> {
13052
13360
  /**Should header row be omitted */
13053
13361
  headless?: boolean;
13054
13362
  /**Can rows have sub rows */
@@ -13057,6 +13365,10 @@ interface ContainerOptions<S extends boolean = false> {
13057
13365
  add_row?: ListAddRowOptions;
13058
13366
  /**If list should use a container to give fields the option of attach/detach to states when visible */
13059
13367
  observer?: BaseIntersectObserver;
13368
+ /**Lets the user select rows, only rows that are visible can be selected */
13369
+ selection?: ListSelectionOptions<R, K>;
13370
+ /**Lets the user move rows with a drag handle in front of the rows, rows in a writable array state can be moved */
13371
+ reorder?: ListReorderOptions<R>;
13060
13372
  }
13061
13373
 
13062
13374
  class Container<
@@ -13064,6 +13376,7 @@ class Container<
13064
13376
  T extends { [key: string]: ListColumnOptions<any, any> },
13065
13377
  S extends boolean = false,
13066
13378
  R = ListTypeExtract<A>,
13379
+ K = R,
13067
13380
  > extends Base {
13068
13381
  static element_name() {
13069
13382
  return "container";
@@ -13073,6 +13386,8 @@ class Container<
13073
13386
  }
13074
13387
 
13075
13388
  #root: ListRoot<R, T, A, S>;
13389
+ #selection?: ListSelection<K>;
13390
+ #selection_sub?: StateSub<Result<K[], string>>;
13076
13391
  #parent: ListRowParent<A>;
13077
13392
  #box = this.appendChild(document.createElement("div"));
13078
13393
  #header?: HeaderRow<R, T, A, S>;
@@ -13080,12 +13395,16 @@ class Container<
13080
13395
  #error?: ListRowsError<A>;
13081
13396
  #add_row?: ListAddRow<R, T, A, S>;
13082
13397
  #state_sub?: StateInferSub<State<R[]>>;
13398
+ /**Width of the key field column in rem set by resizing, fits the key fields when undefined */
13399
+ #key_width?: number;
13400
+ /**Shows why a write failed, or that open all stopped */
13401
+ #warn?: ListWarn;
13083
13402
 
13084
13403
  constructor(
13085
- columns: { [K in keyof T]: ListColumnOptions<T[K], any> },
13404
+ columns: { [C in keyof T]: ListColumnOptions<T[C], any> },
13086
13405
  transform: ListRowTransformer<R, T, A, S>,
13087
13406
  rows: A,
13088
- options?: ContainerOptions<S>,
13407
+ options?: ContainerOptions<S, R, K>,
13089
13408
  ) {
13090
13409
  super();
13091
13410
  this.#root = {
@@ -13094,6 +13413,9 @@ class Container<
13094
13413
  columns_visible: [],
13095
13414
  transform,
13096
13415
  observer: options?.observer,
13416
+ open_all: () => this.open_all(),
13417
+ close_all: () => this.close_all(),
13418
+ any_open: () => this.#open_rows().length > 0,
13097
13419
  };
13098
13420
  this.#parent = {
13099
13421
  depth: -1,
@@ -13102,17 +13424,53 @@ class Container<
13102
13424
  state: rows,
13103
13425
  };
13104
13426
 
13427
+ this.#child_box = document.createElement("div");
13428
+ //Shows why a write of the selection or a move failed
13429
+ const warn =
13430
+ options?.selection || options?.reorder || options?.sub_rows
13431
+ ? new ListWarn(this)
13432
+ : undefined;
13433
+ this.#warn = warn;
13434
+ if (options?.reorder) {
13435
+ this.#root.reorder = new ListReorder(this, options.reorder, warn!);
13436
+ this.#box.classList.add("drag");
13437
+ }
13438
+ if (options?.selection) {
13439
+ this.#selection = new ListSelection(
13440
+ options.selection,
13441
+ this.#child_box,
13442
+ Boolean(options.sub_rows),
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");
13447
+ this.#selection.on_error = (row, message) =>
13448
+ warn!.show(row?.anchor ?? this.#header ?? this.#box, message);
13449
+ }
13450
+ //Columns in front of the key field column, the error and add rows start after them
13451
+ const lead =
13452
+ Number(Boolean(options?.reorder)) +
13453
+ Number(Boolean(this.#selection?.column));
13454
+ if (lead) this.#box.classList.add("lead-" + lead);
13455
+
13105
13456
  if (!options?.headless)
13106
- this.#header = this.#box.appendChild(new HeaderRow(this.#root));
13107
- this.#child_box = this.#box.appendChild(document.createElement("div"));
13457
+ this.#header = this.#box.appendChild(
13458
+ new HeaderRow(this.#root, (width) => {
13459
+ this.#key_width = width;
13460
+ this.#update_column_widths();
13461
+ }),
13462
+ );
13463
+ this.#box.appendChild(this.#child_box);
13108
13464
  if (options?.sub_rows) this.#box.classList.add("sub-rows");
13109
13465
  this.add_row = options?.add_row;
13110
13466
 
13111
13467
  this.columns = columns;
13112
13468
  this.rows = rows;
13469
+ //Selection works without a bound state, in a state of its own nobody else can reach
13470
+ if (this.#selection) this.bind({});
13113
13471
  }
13114
13472
 
13115
- set columns(columns: { [K in keyof T]: ListColumnOptions<T[K], any> }) {
13473
+ set columns(columns: { [C in keyof T]: ListColumnOptions<T[C], any> }) {
13116
13474
  this.#root.columns.clear();
13117
13475
  const order = new Map<keyof T, number>();
13118
13476
  let index = 0;
@@ -13126,27 +13484,86 @@ class Container<
13126
13484
  (a, b) => order.get(a)! - order.get(b)!,
13127
13485
  );
13128
13486
 
13129
- if (this.#header)
13130
- this.#header.fields = this.#root.columns_visible.map((key) => {
13487
+ if (this.#header) {
13488
+ const headers = this.#root.columns_visible.map((key) => {
13131
13489
  const column = this.#root.columns.get(key)!;
13132
13490
  const header = new HeaderField(column.title);
13133
13491
  list_align_apply(header, column.align);
13134
13492
  header.sizable(typeof column.fixed_width === "undefined", (width) => {
13493
+ if (width !== undefined) this.#freeze_auto_widths(headers);
13135
13494
  column.init_width = width;
13136
13495
  this.#update_column_widths();
13137
13496
  });
13138
13497
  return header;
13139
13498
  });
13499
+ this.#header.fields = headers;
13500
+ }
13140
13501
  this.#update_column_widths();
13141
13502
 
13142
13503
  for (let i = 0; i < this.#child_box.childElementCount; i++)
13143
13504
  (this.#child_box.children[i] as ListRow<R, T, A, S>).columns_changed();
13144
13505
  }
13145
13506
 
13507
+ /**Gives the auto width columns their current width, so resizing one column does not resize the others
13508
+ * Only measures while there are auto width columns, so after the first resize a move does no layout here*/
13509
+ #freeze_auto_widths(headers: HeaderField[]) {
13510
+ const auto = this.#root.columns_visible.flatMap((key, i) => {
13511
+ const col = this.#root.columns.get(key)!;
13512
+ return col.fixed_width === undefined && !col.init_width ? [i] : [];
13513
+ });
13514
+ //Measured before any is set, setting one would change the layout of the rest
13515
+ const widths = auto.map((i) => px_to_rem(headers[i].offsetWidth));
13516
+ auto.forEach((i, j) => {
13517
+ this.#root.columns.get(this.#root.columns_visible[i])!.init_width =
13518
+ widths[j];
13519
+ });
13520
+ }
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
+
13146
13561
  #update_column_widths() {
13147
13562
  const widths: string[] = this.#root.columns_visible.map((key) => {
13148
13563
  const col = this.#root.columns.get(key)!;
13149
- const width = col.fixed_width ?? col.init_width;
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);
13150
13567
  if (width) {
13151
13568
  if (width === "min") return "min-content";
13152
13569
  else if (width === "max") return "max-content";
@@ -13154,7 +13571,19 @@ class Container<
13154
13571
  }
13155
13572
  return "auto";
13156
13573
  });
13157
- if (this.#root.sub_rows) widths.unshift("min-content");
13574
+ //The key fields get the width instead of the column, so it never gets smaller than its widest key field minimum
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");
13578
+ this.#box.classList.toggle("key-sized", Boolean(this.#key_width));
13579
+ if (this.#key_width)
13580
+ this.#box.style.setProperty(
13581
+ "--list-key-width",
13582
+ `${Math.max(this.#key_width, 1)}rem`,
13583
+ );
13584
+ else this.#box.style.removeProperty("--list-key-width");
13585
+ if (this.#selection?.column) widths.unshift("var(--list-check-width)");
13586
+ if (this.#root.reorder) widths.unshift("var(--list-drag-width)");
13158
13587
  this.#box.style.gridTemplateColumns = widths.join(" ");
13159
13588
  }
13160
13589
 
@@ -13210,10 +13639,28 @@ class Container<
13210
13639
  this.#root.sub_rows,
13211
13640
  this.#parent,
13212
13641
  );
13213
- state_ui.a.apply(this.#child_box, rows, {
13214
- create: (row) => new ListRow<R, T, A, S>(this.#root, this.#parent, row),
13215
- update: (element, row) => (element.data = row),
13216
- });
13642
+ list_rows_apply(this.#root, this.#parent, this.#child_box, rows);
13643
+ }
13644
+
13645
+ /**Binds the selection to an array state of keys, which can be shared with other lists and elements
13646
+ * The list shows the keys that have a visible row, and only writes the state on user actions,
13647
+ * with array write instructions, so it must be a state that applies them, like a local writable state
13648
+ * Without a state the selection is kept in a state of the list that nobody else can reach
13649
+ * Needs the selection option */
13650
+ bind(opts: { selection?: StateREAW<K[], any, K[]> }): this {
13651
+ const selection = this.#selection;
13652
+ if (!selection) {
13653
+ if (opts.selection) console.error("List has no selection option", this);
13654
+ return this;
13655
+ }
13656
+ if (this.#selection_sub) this.detach_state(this.#selection_sub);
13657
+ const target = opts.selection ?? state.ok_w<K[]>([]);
13658
+ selection.target = target;
13659
+ this.#selection_sub = this.attach_state(
13660
+ target as StateREAW<K[]>,
13661
+ (value: Result<K[], string>) => selection.apply(value),
13662
+ );
13663
+ return this;
13217
13664
  }
13218
13665
  }
13219
13666
  define_element(Container);
@@ -13223,23 +13670,551 @@ export function container<
13223
13670
  T extends {},
13224
13671
  S extends boolean = false,
13225
13672
  R = ListTypeExtract<A>,
13673
+ K = R,
13226
13674
  >(
13227
- columns: { [K in keyof T]: ListColumnOptions<T[K], any> },
13675
+ columns: { [C in keyof T]: ListColumnOptions<T[C], any> },
13228
13676
  transform: ListRowTransformer<R, NoInfer<T>, A, S>,
13229
13677
  rows: A,
13230
- options?: ContainerOptions<S>,
13678
+ options?: ContainerOptions<S, R, K>,
13231
13679
  ) {
13232
- return new Container<A, T, S, R>(columns, transform, rows, options);
13680
+ return new Container<A, T, S, R, K>(columns, transform, rows, options);
13681
+ }
13682
+ ```
13683
+
13684
+ ## package-ui/list/drag.scss
13685
+
13686
+ ```scss
13687
+ @use "../icons/mixins" as icons;
13688
+
13689
+ list-dragfield {
13690
+ position: sticky;
13691
+ left: 0;
13692
+ z-index: 2;
13693
+ display: flex;
13694
+ align-items: center;
13695
+ justify-content: center;
13696
+ box-sizing: border-box;
13697
+ min-height: var(--list-drag-width);
13698
+ user-select: none;
13699
+ //The handle drags, it does not pan the list
13700
+ touch-action: none;
13701
+ border-right: 1px solid var(--list-colors-border-column);
13702
+
13703
+ &::before {
13704
+ @include icons.material-symbols-rounded;
13705
+ font-size: 1.2rem;
13706
+ line-height: 1;
13707
+ color: var(--list-colors-icon-drag);
13708
+
13709
+ .touch & {
13710
+ font-size: 1.8rem;
13711
+ }
13712
+ }
13713
+
13714
+ //Glyph of the icon font, drag_indicator
13715
+ list-row.movable > div > & {
13716
+ cursor: grab;
13717
+
13718
+ &::before {
13719
+ content: "\e945";
13720
+ }
13721
+ }
13722
+ }
13723
+
13724
+ //Rows being dragged are dimmed where they are until the move comes back from the state
13725
+ list-row.dragging > div > * {
13726
+ opacity: 0.4;
13727
+ }
13728
+
13729
+ //Shows where dragged rows are dropped, a line between rows or a box around the row they go into
13730
+ list-container > span.list-drop {
13731
+ display: block;
13732
+ position: absolute;
13733
+ //Above the rows and their sticky cells, below the header the rows scroll under
13734
+ z-index: 998;
13735
+ pointer-events: none;
13736
+ box-sizing: border-box;
13737
+ //A line, the list sizes it and places it inside the top or bottom edge of the row, starting at the indent of the row
13738
+ background-color: var(--list-colors-focus-normal);
13739
+
13740
+ &[hidden] {
13741
+ display: none;
13742
+ }
13743
+
13744
+ &.into {
13745
+ background-color: transparent;
13746
+ border: 2px solid var(--list-colors-focus-normal);
13747
+ }
13748
+ }
13749
+
13750
+ //Follows the pointer while dragging, with what is dragged, it is in the body to be above all lists
13751
+ span.list-drag-label {
13752
+ display: block;
13753
+ position: fixed;
13754
+ z-index: 10000;
13755
+ pointer-events: none;
13756
+ padding: 0.2rem 0.5rem;
13757
+ border-radius: 0.3rem;
13758
+ font-size: 0.9rem;
13759
+ white-space: nowrap;
13760
+ color: var(--list-colors-text-field);
13761
+ background-color: var(--list-colors-background-row_even);
13762
+ border: 1px solid var(--list-colors-border-header);
13763
+ box-shadow: 0 0.1rem 0.3rem var(--list-colors-border-header);
13764
+
13765
+ //Nowhere to drop
13766
+ &.none {
13767
+ opacity: 0.5;
13768
+ }
13769
+ }
13770
+ ```
13771
+
13772
+ ## package-ui/list/drag.ts
13773
+
13774
+ ```ts
13775
+ import { Base, define_element } from "#base";
13776
+ import type { Option, Result } from "@chocbite/ts-lib/result";
13777
+ import { state, type State, type StateREAW } from "@chocbite/ts-lib/state";
13778
+ import "./drag.scss";
13779
+ import type { ListWarn } from "./warn";
13780
+
13781
+ /**What moving needs from a row */
13782
+ export interface ListMovableRow extends HTMLElement {
13783
+ readonly data: unknown;
13784
+ /**Moving of the list the row is in */
13785
+ readonly reorder: object | undefined;
13786
+ readonly parent_rows: unknown;
13787
+ readonly parent_row: ListMovableRow | undefined;
13788
+ readonly next_row: ListMovableRow | undefined;
13789
+ readonly first_sub_row: ListMovableRow | undefined;
13790
+ readonly movable: boolean;
13791
+ readonly droppable: boolean;
13792
+ readonly selected: boolean;
13793
+ readonly multi_selected: boolean;
13794
+ readonly label: string;
13795
+ readonly anchor: Element | undefined;
13796
+ readonly index: number;
13797
+ readonly openable: boolean;
13798
+ open: boolean;
13799
+ drop_rows(): unknown;
13800
+ focus_cell(): void;
13801
+ }
13802
+
13803
+ type AnyRow = ListMovableRow;
13804
+ type Rows = StateREAW<unknown[], Option<{}>, unknown[]>;
13805
+
13806
+ /**Lists that rows can be dragged between, rows are given from one list to another of the same group
13807
+ * The type is checked both ways, so only lists with exactly the same row type can join */
13808
+ export class ListDragGroup<R> {
13809
+ declare readonly type: (value: R) => R;
13810
+ }
13811
+
13812
+ /**Where rows are dropped, given to can_drop */
13813
+ export interface ListDropTarget<R> {
13814
+ /**Row the rows become sub rows of, undefined for the top level */
13815
+ parent: R | undefined;
13816
+ /**List the rows are dropped in */
13817
+ list: HTMLElement;
13818
+ }
13819
+
13820
+ export interface ListReorderOptions<R> {
13821
+ /**Lists of the same group can give rows to each other, without a group rows only move inside the list */
13822
+ group?: ListDragGroup<R>;
13823
+ /**Whether the row data can be dropped at the target, all dropped rows must be allowed for a drop */
13824
+ can_drop?(data: R, target: ListDropTarget<R>): boolean;
13825
+ /**Rows moved to another parent or list are only inserted there, not removed from where they came from
13826
+ * For apps that remove the rows themselves when they are added, set on the list the rows are dragged from
13827
+ * Moves inside one parent are still one move write */
13828
+ no_remove?: boolean;
13829
+ }
13830
+
13831
+ /**Drag handle cell in front of a row, empty in the header */
13832
+ export class ListDragField extends Base {
13833
+ static element_name() {
13834
+ return "dragfield";
13835
+ }
13836
+ static element_name_space() {
13837
+ return "list";
13838
+ }
13839
+ }
13840
+ define_element(ListDragField);
13841
+
13842
+ /**Place rows are dropped at, before or after a row, or into it as its last sub rows */
13843
+ export interface ListDropPlace {
13844
+ row: AnyRow;
13845
+ mode: "before" | "after" | "into";
13846
+ }
13847
+
13848
+ /**Pixels the pointer moves before a press on the handle becomes a drag */
13849
+ const DRAG_THRESHOLD = 5;
13850
+ /**Milliseconds hovering into a closed row before it opens */
13851
+ const OPEN_DELAY = 600;
13852
+ /**Thickness of the drop line in pixels, it is drawn inside the row it is about */
13853
+ const LINE_WIDTH = 5;
13854
+ /**Distance from the top or bottom edge of a list in pixels where dragging scrolls it */
13855
+ const SCROLL_EDGE = 32;
13856
+
13857
+ /**A rows state that the list can write moves to */
13858
+ function writable(rows: unknown): rows is Rows {
13859
+ return state.is.state(rows) && (rows as State<unknown>).writable;
13860
+ }
13861
+
13862
+ /**Moving rows of a list by dragging their handle or with alt and the arrow keys
13863
+ * Like the selection, moves are only written to the rows states, the rows move when the states give the change back */
13864
+ export class ListReorder<R> {
13865
+ readonly group: ListDragGroup<R>;
13866
+ readonly container: HTMLElement;
13867
+ #options: ListReorderOptions<R>;
13868
+ #warn: ListWarn;
13869
+ /**Shows where rows are dropped in this list */
13870
+ #indicator: HTMLSpanElement;
13871
+
13872
+ constructor(
13873
+ container: HTMLElement,
13874
+ options: ListReorderOptions<R>,
13875
+ warn: ListWarn,
13876
+ ) {
13877
+ this.container = container;
13878
+ this.group = options.group ?? new ListDragGroup<R>();
13879
+ this.#options = options;
13880
+ this.#warn = warn;
13881
+ this.#indicator = container.appendChild(document.createElement("span"));
13882
+ this.#indicator.className = "list-drop";
13883
+ this.#indicator.hidden = true;
13884
+ }
13885
+
13886
+ /**Makes the handle cell of a row */
13887
+ handle(row: AnyRow): ListDragField {
13888
+ const handle = new ListDragField();
13889
+ handle.onpointerdown = (e) => this.#press(row, handle, e);
13890
+ return handle;
13891
+ }
13892
+
13893
+ // _____ _____ _____
13894
+ // | __ \| __ \ /\ / ____|
13895
+ // | | | | |__) | / \ | | __
13896
+ // | | | | _ / / /\ \| | |_ |
13897
+ // | |__| | | \ \ / ____ \ |__| |
13898
+ // |_____/|_| \_\/_/ \_\_____|
13899
+
13900
+ #press(row: AnyRow, handle: ListDragField, e: PointerEvent) {
13901
+ if (e.button !== 0 || !row.movable) return;
13902
+ e.preventDefault();
13903
+ handle.setPointerCapture(e.pointerId);
13904
+ const start_x = e.clientX;
13905
+ const start_y = e.clientY;
13906
+ let x = start_x;
13907
+ let y = start_y;
13908
+ let rows: AnyRow[] | undefined;
13909
+ let place: ListDropPlace | undefined;
13910
+ let shown: ListReorder<R> | undefined;
13911
+ let frame = 0;
13912
+ let open_timer = 0;
13913
+ let open_row: AnyRow | undefined;
13914
+ const label = document.createElement("span");
13915
+ label.className = "list-drag-label";
13916
+
13917
+ const update = () => {
13918
+ frame = requestAnimationFrame(update);
13919
+ this.#scroll(x, y);
13920
+ const next = this.#place(x, y, rows!);
13921
+ shown?.indicate(undefined);
13922
+ shown = next?.row.reorder as ListReorder<R> | undefined;
13923
+ shown?.indicate(next);
13924
+ place = next;
13925
+ label.style.left = x + 12 + "px";
13926
+ label.style.top = y + 12 + "px";
13927
+ label.classList.toggle("none", !next);
13928
+ //Hovering into a closed row opens it after a moment
13929
+ const hover =
13930
+ next?.mode === "into" && !next.row.open ? next.row : undefined;
13931
+ if (hover !== open_row) {
13932
+ clearTimeout(open_timer);
13933
+ open_row = hover;
13934
+ if (hover)
13935
+ open_timer = window.setTimeout(() => (hover.open = true), OPEN_DELAY);
13936
+ }
13937
+ };
13938
+ const end = (drop: boolean) => {
13939
+ handle.onpointermove = null;
13940
+ handle.onpointerup = null;
13941
+ handle.onpointercancel = null;
13942
+ handle.onlostpointercapture = null;
13943
+ document.removeEventListener("keydown", escape, true);
13944
+ cancelAnimationFrame(frame);
13945
+ clearTimeout(open_timer);
13946
+ shown?.indicate(undefined);
13947
+ label.remove();
13948
+ if (!rows) return;
13949
+ for (const dragged of rows) dragged.classList.remove("dragging");
13950
+ if (drop && place) void this.#drop(rows, place);
13951
+ };
13952
+ const escape = (ev: KeyboardEvent) => {
13953
+ if (ev.key !== "Escape") return;
13954
+ ev.preventDefault();
13955
+ ev.stopPropagation();
13956
+ end(false);
13957
+ };
13958
+
13959
+ handle.onpointermove = (ev) => {
13960
+ x = ev.clientX;
13961
+ y = ev.clientY;
13962
+ if (rows) return;
13963
+ if (Math.hypot(x - start_x, y - start_y) < DRAG_THRESHOLD) return;
13964
+ rows = this.#dragged(row);
13965
+ for (const dragged of rows) dragged.classList.add("dragging");
13966
+ label.textContent =
13967
+ rows.length > 1 ? rows.length + " rows" : row.label || "1 row";
13968
+ //In the body, a list is a stacking context, so a label in it would be covered by the lists after it
13969
+ document.body.appendChild(label);
13970
+ document.addEventListener("keydown", escape, true);
13971
+ update();
13972
+ };
13973
+ handle.onpointerup = () => end(true);
13974
+ handle.onpointercancel = () => end(false);
13975
+ handle.onlostpointercapture = () => end(false);
13976
+ }
13977
+
13978
+ /**Rows a drag from the row moves, the visible selected movable rows when the row is selected in multi mode
13979
+ * Sub rows of a dragged row move with it, so they are left out */
13980
+ #dragged(row: AnyRow): AnyRow[] {
13981
+ if (!row.selected || !row.multi_selected) return [row];
13982
+ const rows = [
13983
+ ...this.container.querySelectorAll<AnyRow>("list-row.selected.movable"),
13984
+ ].filter((selected) => selected.reorder === this);
13985
+ const dragged = new Set(rows);
13986
+ return rows.filter((selected) => {
13987
+ for (let parent = selected.parent_row; parent; parent = parent.parent_row)
13988
+ if (dragged.has(parent)) return false;
13989
+ return true;
13990
+ });
13991
+ }
13992
+
13993
+ /**Scrolls the list under the pointer when the pointer is near its top or bottom edge */
13994
+ #scroll(x: number, y: number) {
13995
+ const list = document
13996
+ .elementFromPoint(x, y)
13997
+ ?.closest<HTMLElement>("list-container");
13998
+ const target = list ?? this.container;
13999
+ const rect = target.getBoundingClientRect();
14000
+ if (x < rect.left || x > rect.right) return;
14001
+ if (y < rect.top + SCROLL_EDGE)
14002
+ target.scrollTop -= Math.ceil((rect.top + SCROLL_EDGE - y) / 4);
14003
+ else if (y > rect.bottom - SCROLL_EDGE)
14004
+ target.scrollTop += Math.ceil((y - rect.bottom + SCROLL_EDGE) / 4);
14005
+ }
14006
+
14007
+ // _____ _____ ____ _____
14008
+ // | __ \| __ \ / __ \| __ \
14009
+ // | | | | |__) | | | | |__) |
14010
+ // | | | | _ /| | | | ___/
14011
+ // | |__| | | \ \| |__| | |
14012
+ // |_____/|_| \_\\____/|_|
14013
+
14014
+ /**The place under the pointer, undefined when the rows can not be dropped there */
14015
+ #place(x: number, y: number, rows: AnyRow[]): ListDropPlace | undefined {
14016
+ const element = document.elementFromPoint(x, y);
14017
+ let row = element?.closest<AnyRow>("list-row") ?? undefined;
14018
+ let mode: ListDropPlace["mode"];
14019
+ if (!row) {
14020
+ //Below the last row of a list drops after it
14021
+ const list = element?.closest<HTMLElement>("list-container");
14022
+ const last = list?.querySelector<AnyRow>(
14023
+ ":scope > div > div > list-row:last-child",
14024
+ );
14025
+ if (!last?.anchor || y < last.anchor.getBoundingClientRect().bottom)
14026
+ return undefined;
14027
+ row = last;
14028
+ mode = "after";
14029
+ } else {
14030
+ const rect = row.anchor?.getBoundingClientRect();
14031
+ if (!rect) return undefined;
14032
+ const part = (y - rect.top) / rect.height;
14033
+ if (row.openable)
14034
+ mode = part < 0.25 ? "before" : part > 0.75 ? "after" : "into";
14035
+ else mode = part < 0.5 ? "before" : "after";
14036
+ }
14037
+ const reorder = row.reorder as ListReorder<R> | undefined;
14038
+ if (reorder?.group !== this.group) return undefined;
14039
+ //After an open row is before its first sub row
14040
+ if (mode === "after" && row.open) {
14041
+ const first = row.first_sub_row;
14042
+ if (first) {
14043
+ row = first;
14044
+ mode = "before";
14045
+ }
14046
+ }
14047
+ const place: ListDropPlace = { row, mode };
14048
+ return reorder.#allowed(place, rows) ? place : undefined;
14049
+ }
14050
+
14051
+ /**Whether the rows can be dropped at the place of this list */
14052
+ #allowed(place: ListDropPlace, rows: AnyRow[]): boolean {
14053
+ const parent = place.mode === "into" ? place.row : place.row.parent_row;
14054
+ if (place.mode !== "into" && rows.includes(place.row)) return false;
14055
+ //Not into itself or its own sub rows
14056
+ for (let up: AnyRow | undefined = parent; up; up = up.parent_row)
14057
+ if (rows.includes(up)) return false;
14058
+ if (place.mode === "into" ? !place.row.droppable : !place.row.movable)
14059
+ return false;
14060
+ const options = this.#options;
14061
+ if (!options.can_drop) return true;
14062
+ const target: ListDropTarget<R> = {
14063
+ parent: parent?.data as R | undefined,
14064
+ list: this.container,
14065
+ };
14066
+ return rows.every((row) => options.can_drop!(row.data as R, target));
14067
+ }
14068
+
14069
+ /**Shows where rows are dropped in this list, undefined hides it */
14070
+ indicate(place: ListDropPlace | undefined) {
14071
+ const indicator = this.#indicator;
14072
+ const cell = place?.row.anchor;
14073
+ if (!place || !cell) {
14074
+ indicator.hidden = true;
14075
+ return;
14076
+ }
14077
+ const list = this.container;
14078
+ const box = list.getBoundingClientRect();
14079
+ const rect = cell.getBoundingClientRect();
14080
+ const top = rect.top - box.top + list.scrollTop;
14081
+ //A line starts at the tree indent of the row, so the depth the rows land at shows,
14082
+ //after the last sub row of an open row and before the next row are at the same height
14083
+ const opener =
14084
+ place.mode === "into"
14085
+ ? undefined
14086
+ : place.row.querySelector(
14087
+ ":scope > div > list-keyfield > span:not(.text)",
14088
+ );
14089
+ const left =
14090
+ (opener ?? cell).getBoundingClientRect().left -
14091
+ box.left +
14092
+ list.scrollLeft;
14093
+ //Ends at the right edge of the rows, not the scroll width of the list, which includes the indicator itself,
14094
+ //rounded down so it never makes the list wider and flashes a scrollbar
14095
+ const grid = list.querySelector(":scope > div") ?? list;
14096
+ const right =
14097
+ grid.getBoundingClientRect().right - box.left + list.scrollLeft;
14098
+ indicator.hidden = false;
14099
+ indicator.className = "list-drop " + place.mode;
14100
+ indicator.style.left = left + "px";
14101
+ indicator.style.width = Math.max(Math.floor(right - left), 0) + "px";
14102
+ //Drawn inside the row it is about, at its top or bottom edge
14103
+ indicator.style.top =
14104
+ (place.mode === "after" ? top + rect.height - LINE_WIDTH : top) + "px";
14105
+ indicator.style.height =
14106
+ (place.mode === "into" ? rect.height : LINE_WIDTH) + "px";
14107
+ }
14108
+
14109
+ // __ __ ______ ________
14110
+ // | \/ |/ __ \ \ / / ____|
14111
+ // | \ / | | | \ \ / /| |__
14112
+ // | |\/| | | | |\ \/ / | __|
14113
+ // | | | | |__| | \ / | |____
14114
+ // |_| |_|\____/ \/ |______|
14115
+
14116
+ /**Writes the moves of the rows to the place, rows next to each other in one parent move with one write
14117
+ * Moving to another parent inserts first and removes after, so a failure can leave a row twice but never loses it */
14118
+ async #drop(rows: AnyRow[], place: ListDropPlace) {
14119
+ const errors: string[] = [];
14120
+ const into = place.mode === "into" ? place.row : undefined;
14121
+ //Rows are dropped in order before this row, undefined appends to the parent
14122
+ const before: AnyRow | undefined =
14123
+ place.mode === "before"
14124
+ ? place.row
14125
+ : place.mode === "after"
14126
+ ? place.row.next_row
14127
+ : undefined;
14128
+ const target_box =
14129
+ place.mode === "into" ? undefined : place.row.parentElement;
14130
+ const target_rows = into ? into.drop_rows() : place.row.parent_rows;
14131
+ if (!writable(target_rows)) return;
14132
+ for (const chunk of this.#chunks(rows)) {
14133
+ const first = chunk[0];
14134
+ const source_box = first.parentElement;
14135
+ const same = into ? first.parent_row === into : source_box === target_box;
14136
+ if (same) {
14137
+ const from = first.index;
14138
+ const end = before ? before.index : source_box!.childElementCount;
14139
+ const to = from < end ? end - chunk.length : end;
14140
+ if (from === to) continue;
14141
+ const result = await target_rows.write(
14142
+ state.a.write.move(from, to, chunk.length),
14143
+ );
14144
+ if (result.err) errors.push(result.error);
14145
+ continue;
14146
+ }
14147
+ const items = chunk.map((row) => row.data);
14148
+ const inserted: Result<void, string> = await target_rows.write(
14149
+ before
14150
+ ? state.a.write.splice(before.index, 0, ...items)
14151
+ : state.a.write.push(...items),
14152
+ );
14153
+ if (inserted.err) {
14154
+ errors.push(inserted.error);
14155
+ continue;
14156
+ }
14157
+ //The app already took the rows out of the source while inserting
14158
+ if (this.#options.no_remove || !first.parentElement) continue;
14159
+ const source_rows = first.parent_rows;
14160
+ if (!writable(source_rows)) continue;
14161
+ const removed = await source_rows.write(
14162
+ state.a.write.splice(first.index, chunk.length),
14163
+ );
14164
+ if (removed.err) errors.push(removed.error);
14165
+ }
14166
+ if (into && errors.length === 0) into.open = true;
14167
+ if (errors.length)
14168
+ (place.row.reorder as ListReorder<R> | undefined)?.warn(
14169
+ place.row,
14170
+ [...new Set(errors)].join("\n"),
14171
+ );
14172
+ }
14173
+
14174
+ /**Splits rows in display order into runs of rows next to each other in one parent */
14175
+ #chunks(rows: AnyRow[]): AnyRow[][] {
14176
+ const chunks: AnyRow[][] = [];
14177
+ for (const row of rows) {
14178
+ const last = chunks[chunks.length - 1]?.at(-1);
14179
+ if (
14180
+ last &&
14181
+ last.parentElement === row.parentElement &&
14182
+ last.next_row === row
14183
+ )
14184
+ chunks[chunks.length - 1].push(row);
14185
+ else chunks.push([row]);
14186
+ }
14187
+ return chunks;
14188
+ }
14189
+
14190
+ /**Shows why a move failed at the row, in the list of the row */
14191
+ warn(row: AnyRow, message: string) {
14192
+ this.#warn.show(row.anchor, message);
14193
+ }
14194
+
14195
+ /**Moves the row one place up or down in its parent, from the keyboard, the row keeps the focus */
14196
+ async key_move(row: AnyRow, direction: -1 | 1) {
14197
+ const rows = row.parent_rows;
14198
+ if (!row.movable || !writable(rows)) return;
14199
+ const from = row.index;
14200
+ const to = from + direction;
14201
+ if (to < 0 || to >= row.parentElement!.childElementCount) return;
14202
+ const result = await rows.write(state.a.write.move(from, to, 1));
14203
+ //Moving takes the row out of the document for a moment, which loses the focus
14204
+ row.focus_cell();
14205
+ if (result.err) this.warn(row, result.error);
14206
+ }
13233
14207
  }
13234
14208
  ```
13235
14209
 
13236
- ## package-ui/src/list/error.scss
14210
+ ## package-ui/list/error.scss
13237
14211
 
13238
14212
  ```scss
13239
14213
  list-rowserror {
13240
14214
  display: contents;
13241
14215
 
13242
- > list-error {
14216
+ > list-error,
14217
+ > list-keyfield {
13243
14218
  background-color: var(--list-colors-background-row_odd);
13244
14219
  }
13245
14220
  }
@@ -13258,15 +14233,10 @@ list-error {
13258
14233
  .touch & {
13259
14234
  min-height: var(--list-size-touch_row_min);
13260
14235
  }
13261
-
13262
- //The first column of a list with sub rows is for the key fields
13263
- list-container > div.sub-rows & {
13264
- grid-column: 2 / -1;
13265
- }
13266
14236
  }
13267
14237
  ```
13268
14238
 
13269
- ## package-ui/src/list/error.ts
14239
+ ## package-ui/list/error.ts
13270
14240
 
13271
14241
  ```ts
13272
14242
  import { Base, define_element } from "#base";
@@ -13309,8 +14279,9 @@ export class ListRowsError<A extends ListType<any>>
13309
14279
  super();
13310
14280
  this.#parent = parent;
13311
14281
  this.depth = parent.depth + 1;
13312
- if (sub_rows) this.appendChild(new ListKeyField(this));
13313
- this.appendChild(this.#text);
14282
+ //With sub rows the text is in the key field after the tree lines, it runs from the key column to the end
14283
+ if (sub_rows) this.appendChild(new ListKeyField(this)).tail = this.#text;
14284
+ else this.appendChild(this.#text);
13314
14285
  }
13315
14286
 
13316
14287
  set text(value: string) {
@@ -13355,7 +14326,7 @@ export function list_rows_error_update<A extends ListType<any>>(
13355
14326
  }
13356
14327
  ```
13357
14328
 
13358
- ## package-ui/src/list/field.scss
14329
+ ## package-ui/list/field.scss
13359
14330
 
13360
14331
  ```scss
13361
14332
  list-textfield,
@@ -13385,7 +14356,7 @@ list-numberfield {
13385
14356
  }
13386
14357
  ```
13387
14358
 
13388
- ## package-ui/src/list/field.ts
14359
+ ## package-ui/list/field.ts
13389
14360
 
13390
14361
  ```ts
13391
14362
  import { Base, define_element } from "#base";
@@ -13470,7 +14441,7 @@ export function node_field<T extends Node>(node: T) {
13470
14441
  }
13471
14442
  ```
13472
14443
 
13473
- ## package-ui/src/list/globals.d.ts
14444
+ ## package-ui/list/globals.d.ts
13474
14445
 
13475
14446
  ```ts
13476
14447
  declare module "*.scss" {
@@ -13479,10 +14450,11 @@ declare module "*.scss" {
13479
14450
  }
13480
14451
  ```
13481
14452
 
13482
- ## package-ui/src/list/index.ts
14453
+ ## package-ui/list/index.ts
13483
14454
 
13484
14455
  ```ts
13485
14456
  import { container } from "./container";
14457
+ import { ListDragGroup } from "./drag";
13486
14458
  import { node_field, number_field, text_field } from "./field";
13487
14459
  import { column, column_string } from "./types";
13488
14460
 
@@ -13493,23 +14465,54 @@ export const list = {
13493
14465
  text_field,
13494
14466
  number_field,
13495
14467
  node_field,
14468
+ /**Group of lists that can give rows to each other by dragging, all lists of a group must have the same row type */
14469
+ drag_group<R>(): ListDragGroup<R> {
14470
+ return new ListDragGroup<R>();
14471
+ },
13496
14472
  };
13497
14473
 
13498
14474
  export { ListField } from "./field";
14475
+ export type { ListDragGroup, ListDropTarget, ListReorderOptions } from "./drag";
13499
14476
 
13500
14477
  export default list;
13501
14478
  ```
13502
14479
 
13503
- ## package-ui/src/list/key_field.scss
14480
+ ## package-ui/list/key_field.scss
13504
14481
 
13505
14482
  ```scss
13506
14483
  @use "../icons/mixins" as icons;
13507
14484
 
13508
14485
  list-keyfield {
13509
14486
  --list-row-size: var(--list-size-row_min);
14487
+ //Width of an indent line box, the space after it and the width of the opener
14488
+ //The vertical lines sit at the right edge of an indent box and the middle of the opener, so they line up between depths
14489
+ --list-key-indent: calc(var(--list-row-size) / 2);
14490
+ --list-key-indent-space: calc(var(--list-row-size) / 2 - 0.1rem);
14491
+ --list-key-opener: var(--list-row-size);
14492
+ --list-key-icon: calc(var(--list-row-size) - 0.4rem);
13510
14493
  .touch & {
13511
14494
  --list-row-size: var(--list-size-touch_row_min);
13512
- }
14495
+ --list-key-indent: calc(var(--list-row-size) / 2 - 0.3rem + 1.5px);
14496
+ --list-key-indent-space: calc(var(--list-row-size) / 2 - 0.4rem);
14497
+ --list-key-opener: calc(var(--list-row-size) - 0.4rem);
14498
+ --list-key-icon: calc(var(--list-row-size) - 1.1rem);
14499
+ }
14500
+ //Smallest width of the key column when resized, the indents, the opener, the icon with its padding, 3rem of the text and the border
14501
+ --list-key-min-icon: 0px;
14502
+ --list-key-min-text: 0px;
14503
+ &.has-icon {
14504
+ --list-key-min-icon: calc(var(--list-key-icon) + 0.5rem);
14505
+ }
14506
+ &.has-text,
14507
+ &.tail {
14508
+ --list-key-min-text: 4rem;
14509
+ }
14510
+ --list-key-min: calc(
14511
+ var(--list-key-depth) *
14512
+ (var(--list-key-indent) + 1px + var(--list-key-indent-space)) +
14513
+ var(--list-key-opener) + var(--list-key-min-icon) +
14514
+ var(--list-key-min-text) + 1px
14515
+ );
13513
14516
 
13514
14517
  position: sticky;
13515
14518
  left: 0;
@@ -13520,7 +14523,7 @@ list-keyfield {
13520
14523
  border-right: 1px solid var(--list-colors-border-column);
13521
14524
  background-color: var(--list-colors-background-row_odd);
13522
14525
 
13523
- &:focus-visible::before {
14526
+ &:focus-visible:not(.click-focus)::before {
13524
14527
  content: "";
13525
14528
  position: absolute;
13526
14529
  width: 100%;
@@ -13531,40 +14534,49 @@ list-keyfield {
13531
14534
  pointer-events: none;
13532
14535
  }
13533
14536
 
14537
+ //Line from the middle of an open row down to its sub rows, at the line of the sub rows
14538
+ list-row.open > div > & {
14539
+ background-image: linear-gradient(
14540
+ var(--list-colors-border-column),
14541
+ var(--list-colors-border-column)
14542
+ );
14543
+ background-repeat: no-repeat;
14544
+ background-size: 1px 50%;
14545
+ background-position: calc(
14546
+ (var(--list-key-depth) + 1) *
14547
+ (var(--list-key-indent) + 1px + var(--list-key-indent-space)) +
14548
+ var(--list-key-opener) / 2
14549
+ )
14550
+ 100%;
14551
+ }
14552
+
13534
14553
  > div {
13535
- width: calc(var(--list-row-size) / 2);
13536
- margin-right: calc(var(--list-row-size) / 2 - 0.1rem);
14554
+ flex-shrink: 0;
14555
+ width: var(--list-key-indent);
14556
+ margin-right: var(--list-key-indent-space);
13537
14557
  height: 100%;
13538
14558
  position: relative;
13539
14559
  border-right: 1px solid;
13540
-
13541
- .touch & {
13542
- width: calc(var(--list-row-size) / 2 - 0.3rem + 1.5px);
13543
- margin-right: calc(var(--list-row-size) / 2 - 0.4rem);
13544
- }
13545
14560
  }
13546
14561
 
13547
14562
  &.openable {
13548
- > span {
14563
+ > span.opener {
13549
14564
  > div {
13550
14565
  display: block;
13551
14566
  }
13552
14567
  }
13553
14568
  }
13554
14569
 
13555
- > span {
14570
+ > span.opener {
13556
14571
  position: relative;
14572
+ flex-shrink: 0;
13557
14573
  display: flex;
13558
14574
  align-items: center;
13559
14575
  justify-content: flex-start;
13560
14576
  height: 100%;
13561
14577
  min-height: var(--list-row-size);
13562
14578
  background-color: inherit;
13563
- width: var(--list-row-size);
13564
-
13565
- .touch & {
13566
- width: calc(var(--list-row-size) - 0.4rem);
13567
- }
14579
+ width: var(--list-key-opener);
13568
14580
 
13569
14581
  &::before {
13570
14582
  content: "";
@@ -13577,17 +14589,18 @@ list-keyfield {
13577
14589
  border-right: 1px solid var(--list-colors-border-column);
13578
14590
 
13579
14591
  list-addrow > &,
13580
- list-rowserror > &,
13581
- list-row:not(.addrow) > span > list-row:last-child > * > &,
13582
- div:not(.addrow) > div > list-row:last-child > * > & {
13583
- height: calc(var(--list-row-size) / 2);
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 > & {
14596
+ height: 50%;
13584
14597
  }
13585
14598
  }
13586
14599
  &::after {
13587
14600
  content: "";
13588
14601
  display: block;
13589
14602
  position: absolute;
13590
- height: calc(var(--list-row-size) / 2);
14603
+ height: 50%;
13591
14604
  width: 50%;
13592
14605
  top: 0;
13593
14606
  left: 50%;
@@ -13640,30 +14653,55 @@ list-keyfield {
13640
14653
  }
13641
14654
  }
13642
14655
 
13643
- svg {
14656
+ //Icon and text are centered instead of stretched, so in a tall row the line down to the sub rows shows below them
14657
+ > span.text {
14658
+ display: flex;
14659
+ align-self: center;
14660
+ align-items: center;
14661
+ min-width: 0;
14662
+ color: var(--list-colors-text-key_field);
14663
+ padding: 0 0.25rem;
14664
+ min-height: var(--list-row-size);
14665
+ //Covers the line down to the sub rows, it would run through the text without an icon
14666
+ background-color: inherit;
14667
+ }
14668
+
14669
+ > svg {
13644
14670
  position: relative;
14671
+ flex-shrink: 0;
14672
+ align-self: center;
14673
+ //Covers the line down to the sub rows, it would show through the transparent parts of the icon
14674
+ background-color: inherit;
13645
14675
  fill: var(--list-colors-icon-key_icon);
13646
14676
  padding: 0.25rem;
13647
- width: calc(var(--list-row-size) - 0.4rem);
14677
+ width: var(--list-key-icon);
13648
14678
  height: auto;
14679
+ }
13649
14680
 
13650
- .touch & {
13651
- width: calc(var(--list-row-size) - 1.1rem);
13652
- height: auto;
14681
+ //Runs into the value columns, the tail takes the space of the line after the text
14682
+ &.tail {
14683
+ grid-column: 1 / -1;
14684
+ border-right: none;
14685
+
14686
+ > :last-child {
14687
+ flex-grow: 1;
14688
+ }
14689
+ &::after {
14690
+ display: none;
13653
14691
  }
13654
14692
  }
13655
14693
 
13656
14694
  &::after {
13657
14695
  content: "";
14696
+ align-self: flex-start;
13658
14697
  height: 50%;
13659
14698
  border-bottom: 1px solid var(--list-colors-border-column);
13660
14699
  flex-grow: 1;
13661
- height: calc(var(--list-row-size) / 2);
13662
14700
  }
13663
14701
  }
13664
14702
  ```
13665
14703
 
13666
- ## package-ui/src/list/key_field.ts
14704
+ ## package-ui/list/key_field.ts
13667
14705
 
13668
14706
  ```ts
13669
14707
  import { Base, define_element } from "#base";
@@ -13675,7 +14713,10 @@ import "./key_field.scss";
13675
14713
  import type { ListRowParent, ListType } from "./types";
13676
14714
 
13677
14715
  export interface ListKeyFieldOptions {
14716
+ /**Icon shown after the sub row opener */
13678
14717
  icon?: SVGFunc | State<SVGFunc>;
14718
+ /**Text shown after the icon, an error of a state is shown as the text */
14719
+ text?: string | State<string>;
13679
14720
  }
13680
14721
 
13681
14722
  export class ListKeyField<A extends ListType<any>> extends Base {
@@ -13689,12 +14730,16 @@ export class ListKeyField<A extends ListType<any>> extends Base {
13689
14730
  #opener: HTMLDivElement;
13690
14731
  #text_box?: HTMLSpanElement;
13691
14732
  #icon?: SVGSVGElement;
14733
+ #tail?: HTMLElement;
13692
14734
 
13693
14735
  constructor(parent: ListRowParent<A>) {
13694
14736
  super();
13695
14737
  this.tabIndex = 0;
14738
+ //Places the line down to the sub rows of an open row
14739
+ this.style.setProperty("--list-key-depth", String(parent.depth));
13696
14740
  this.onkeydown = (e) => {
13697
- if (e.key === "Enter" || e.key === " ") parent.open = !parent.open;
14741
+ if (parent.key_down?.(e)) e.preventDefault();
14742
+ else if (e.key === "Enter" || e.key === " ") parent.open = !parent.open;
13698
14743
  else if (e.key === "ArrowRight") parent.open = true;
13699
14744
  else if (e.key === "ArrowLeft") parent.open = false;
13700
14745
  else if (e.key === "ArrowDown") parent.select_adjacent("next", none());
@@ -13704,6 +14749,7 @@ export class ListKeyField<A extends ListType<any>> extends Base {
13704
14749
  };
13705
14750
 
13706
14751
  const opener_box = document.createElement("span");
14752
+ opener_box.className = "opener";
13707
14753
  this.#opener = opener_box.appendChild(document.createElement("div"));
13708
14754
  this.replaceChildren(
13709
14755
  ...array_from_length(parent.depth, (i) => {
@@ -13725,15 +14771,47 @@ export class ListKeyField<A extends ListType<any>> extends Base {
13725
14771
  if (state.is.state(options?.icon)) {
13726
14772
  this.attach_state_to_prop("icon", options.icon, () => some(undefined));
13727
14773
  } else this.detach_state_from_prop("icon").icon = options?.icon;
14774
+ if (state.is.state(options?.text)) {
14775
+ this.attach_state_to_prop("text", options.text, (e) => some(e));
14776
+ } else this.detach_state_from_prop("text").text = options?.text;
13728
14777
  }
13729
14778
 
13730
14779
  set icon(value: SVGFunc | undefined) {
13731
14780
  if (this.#icon) this.#icon.remove();
13732
14781
  this.#icon = undefined;
14782
+ this.classList.toggle("has-icon", Boolean(value));
13733
14783
  if (!value) return;
13734
14784
  this.#icon = value();
13735
- if (this.#text_box) this.insertBefore(this.#icon, this.#text_box);
13736
- else this.appendChild(this.#icon);
14785
+ this.insertBefore(this.#icon, this.#text_box ?? this.#tail ?? null);
14786
+ }
14787
+
14788
+ /**Element filling the rest of the key field, the button of an add row or the text of an error
14789
+ * A key field with a tail spans from the key column to the end of the row, so it works without value columns */
14790
+ set tail(value: HTMLElement | undefined) {
14791
+ if (value === this.#tail) return;
14792
+ this.#tail?.remove();
14793
+ this.#tail = value;
14794
+ this.classList.toggle("tail", Boolean(value));
14795
+ if (value) this.appendChild(value);
14796
+ }
14797
+ get tail(): HTMLElement | undefined {
14798
+ return this.#tail;
14799
+ }
14800
+
14801
+ /**Text after the icon, an empty string removes the text element */
14802
+ set text(value: string | undefined) {
14803
+ this.classList.toggle("has-text", Boolean(value));
14804
+ if (!value) {
14805
+ this.#text_box?.remove();
14806
+ this.#text_box = undefined;
14807
+ return;
14808
+ }
14809
+ if (!this.#text_box) {
14810
+ this.#text_box = document.createElement("span");
14811
+ this.#text_box.className = "text";
14812
+ this.insertBefore(this.#text_box, this.#tail ?? null);
14813
+ }
14814
+ this.#text_box.textContent = value;
13737
14815
  }
13738
14816
 
13739
14817
  // ____ _____ ______ _ _ _____ _ _ _____
@@ -13754,7 +14832,7 @@ export class ListKeyField<A extends ListType<any>> extends Base {
13754
14832
  define_element(ListKeyField);
13755
14833
  ```
13756
14834
 
13757
- ## package-ui/src/list/row.scss
14835
+ ## package-ui/list/row.scss
13758
14836
 
13759
14837
  ```scss
13760
14838
  list-container > div:not(.addrow) > div > :last-child,
@@ -13815,21 +14893,33 @@ list-row {
13815
14893
  }
13816
14894
  }
13817
14895
  }
14896
+
14897
+ //After the even, odd and hover backgrounds so it wins over them
14898
+ list-row.selected {
14899
+ > div > * {
14900
+ background-color: var(--list-colors-background-row_selected);
14901
+ }
14902
+ > div:hover > * {
14903
+ background-color: var(--list-colors-background-row_selected_hover);
14904
+ }
14905
+ }
13818
14906
  ```
13819
14907
 
13820
- ## package-ui/src/list/row.ts
14908
+ ## package-ui/list/row.ts
13821
14909
 
13822
14910
  ```ts
13823
14911
  import { Base, define_element } from "#base";
13824
- import ctm, { ContextMenu } from "#context-menu";
13825
- import { some, type Option } from "@chocbite/ts-lib/result";
14912
+ import ctm, { ContextMenu, type ContextMenuLines } from "#context-menu";
14913
+ import { none, some, type Option } from "@chocbite/ts-lib/result";
13826
14914
  import { state, type State, type StateInferSub } from "@chocbite/ts-lib/state";
13827
- import state_ui from "../state_ui";
14915
+ import state_ui from "#state_ui";
13828
14916
  import { ListAddRow, type ListAddRowOptions } from "./add_row";
14917
+ import type { ListDragField } from "./drag";
13829
14918
  import { list_rows_error_update, ListError, type ListRowsError } from "./error";
13830
14919
  import { list_align_apply, type ListField } from "./field";
13831
14920
  import { ListKeyField, type ListKeyFieldOptions } from "./key_field";
13832
14921
  import "./row.scss";
14922
+ import { ListCheckField, type ListSelection } from "./selection";
13833
14923
  import type {
13834
14924
  ListParentRows,
13835
14925
  ListRoot,
@@ -13838,6 +14928,9 @@ import type {
13838
14928
  ListType,
13839
14929
  } from "./types";
13840
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
+
13841
14934
  export type ListSubRows<R> = () => R[] | State<R[]>;
13842
14935
 
13843
14936
  export interface ListRowOptions<R, T extends {}, S extends boolean> {
@@ -13847,6 +14940,8 @@ export interface ListRowOptions<R, T extends {}, S extends boolean> {
13847
14940
  sub_rows?: S extends true ? ListSubRows<R> : never;
13848
14941
  add_row?: ListAddRowOptions;
13849
14942
  context_menu?: ContextMenu | (() => Option<ContextMenu>);
14943
+ /**Whether the row can be selected when the list has selection, true when undefined */
14944
+ selectable?: boolean;
13850
14945
  values: T;
13851
14946
  }
13852
14947
 
@@ -13865,6 +14960,15 @@ export class ListRow<R, T extends {}, A extends ListType<R>, S extends boolean>
13865
14960
  #sub_rows?: ListSubRows<R>;
13866
14961
  readonly depth: number;
13867
14962
  #key_field?: ListKeyField<A>;
14963
+ /**Drag handle cell, only with reorder */
14964
+ #drag?: ListDragField;
14965
+ /**Checkbox or radio button cell, only with selection */
14966
+ #check?: ListCheckField;
14967
+ #data!: R;
14968
+ /**Sub rows of a closed row given for a drop, used when it opens so the sub rows function is called once */
14969
+ #drop_rows?: R[] | State<R[]>;
14970
+ /**Key of the row in the selection, undefined when the row can not be selected */
14971
+ selection_key?: unknown;
13868
14972
  #field_box: HTMLDivElement;
13869
14973
  #child_box: HTMLSpanElement;
13870
14974
  #add_row?: ListAddRow<R, T, A, S>;
@@ -13892,6 +14996,8 @@ export class ListRow<R, T extends {}, A extends ListType<R>, S extends boolean>
13892
14996
  }
13893
14997
  this.#field_box = this.appendChild(document.createElement("div"));
13894
14998
  this.#child_box = this.appendChild(document.createElement("span"));
14999
+ if (this.#root.reorder) this.#drag = this.#root.reorder.handle(this);
15000
+ if (this.#root.selection) this.#selection_setup(this.#root.selection);
13895
15001
  //A right click on a sub row without its own menu reaches the child box before this row
13896
15002
  if (this.#root.sub_rows)
13897
15003
  this.#child_box.oncontextmenu = () => {
@@ -13917,9 +15023,11 @@ export class ListRow<R, T extends {}, A extends ListType<R>, S extends boolean>
13917
15023
 
13918
15024
  /**Shows the cells after the key field, which stays so an invalid row keeps its indent and arrow key navigation */
13919
15025
  #show_cells(cells: readonly HTMLElement[]) {
13920
- if (this.#key_field)
13921
- this.#field_box.replaceChildren(this.#key_field, ...cells);
13922
- else this.#field_box.replaceChildren(...cells);
15026
+ const lead: HTMLElement[] = [];
15027
+ if (this.#drag) lead.push(this.#drag);
15028
+ if (this.#check) lead.push(this.#check);
15029
+ if (this.#key_field) lead.push(this.#key_field);
15030
+ this.#field_box.replaceChildren(...lead, ...cells);
13923
15031
  }
13924
15032
 
13925
15033
  #apply_values() {
@@ -13953,33 +15061,82 @@ export class ListRow<R, T extends {}, A extends ListType<R>, S extends boolean>
13953
15061
  direction: "next" | "previous" | "p_next" | "p_previous" | "last",
13954
15062
  field: Option<number>,
13955
15063
  ) {
13956
- if (!this.#key_field) return;
15064
+ if (!this.#key_field && !this.#check) return;
13957
15065
  //Open is not enough, an open row can show an error instead of sub rows
13958
15066
  const has_rows = this.#child_box.childElementCount > 0;
13959
15067
  if (direction === "next" || direction === "p_next") {
13960
15068
  if (direction === "next" && has_rows)
13961
- (
13962
- this.#child_box.firstElementChild! as ListRow<R, T, A, false>
13963
- ).#key_field!.focus();
15069
+ (this.#child_box.firstElementChild! as ListRow<R, T, A, S>).#focus();
13964
15070
  else {
13965
15071
  const sibling = this.nextElementSibling;
13966
- if (sibling instanceof ListRow) sibling.#key_field!.focus();
15072
+ if (sibling instanceof ListRow) sibling.#focus();
13967
15073
  else this.#parent.select_adjacent("p_next", field);
13968
15074
  }
13969
15075
  } else if (direction === "previous") {
13970
15076
  const sibling = this.previousElementSibling;
13971
15077
  if (sibling instanceof ListRow) {
13972
15078
  if (sibling.open) sibling.select_adjacent("last", field);
13973
- else sibling.#key_field!.focus();
15079
+ else sibling.#focus();
13974
15080
  } else this.#parent.select_adjacent("p_previous", field);
13975
- } else if (direction === "p_previous") this.#key_field.focus();
15081
+ } else if (direction === "p_previous") this.#focus();
13976
15082
  else if (direction === "last") {
13977
15083
  if (has_rows) {
13978
15084
  (
13979
15085
  this.#child_box.lastElementChild as ListRow<R, T, A, S>
13980
15086
  ).select_adjacent("last", field);
13981
- } else this.#key_field.focus();
15087
+ } else this.#focus();
15088
+ }
15089
+ }
15090
+
15091
+ /**Focuses the cell used for keyboard navigation, the key field or else the checkbox */
15092
+ #focus(options?: FocusOptions) {
15093
+ (this.#key_field ?? this.#check)?.focus(options);
15094
+ }
15095
+
15096
+ /**Focuses the cell used for keyboard navigation */
15097
+ focus_cell() {
15098
+ this.#focus({ preventScroll: true });
15099
+ }
15100
+
15101
+ /**Moves the focus to the keyboard cell after a click, so the selection keys work right away
15102
+ * Unless the click focused something in the row itself, like an input of a field */
15103
+ #focus_after_click() {
15104
+ const active = document.activeElement;
15105
+ if (active && active !== document.body && this.#field_box.contains(active))
15106
+ return;
15107
+ const cell = this.#key_field ?? this.#check;
15108
+ if (!cell) return;
15109
+ //Without scrolling, the sticky cell would scroll the list sideways
15110
+ cell.focus({ preventScroll: true });
15111
+ //Focus from script shows the focus ring, which a click should not, removed again by a key or blur
15112
+ cell.classList.add("click-focus");
15113
+ }
15114
+
15115
+ key_down(e: KeyboardEvent): boolean {
15116
+ const selection = this.#root.selection;
15117
+ if (e.altKey && (e.key === "ArrowDown" || e.key === "ArrowUp")) {
15118
+ if (!this.#root.reorder) return false;
15119
+ void this.#root.reorder.key_move(this, e.key === "ArrowDown" ? 1 : -1);
15120
+ return true;
15121
+ }
15122
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") {
15123
+ this.select_adjacent(e.key === "ArrowDown" ? "next" : "previous", none());
15124
+ const focused = document.activeElement?.closest("list-row");
15125
+ if (
15126
+ selection &&
15127
+ focused !== this &&
15128
+ focused instanceof ListRow &&
15129
+ focused.selection_key !== undefined
15130
+ )
15131
+ selection.focus_moved(focused.selection_key, e);
15132
+ return true;
15133
+ }
15134
+ if (!selection) return false;
15135
+ if (e.key === " " && this.selection_key === undefined) {
15136
+ selection.on_error?.(this, NOT_SELECTABLE);
15137
+ return true;
13982
15138
  }
15139
+ return selection.key_down(this.selection_key, e);
13983
15140
  }
13984
15141
 
13985
15142
  // _____ _______
@@ -13990,6 +15147,14 @@ export class ListRow<R, T extends {}, A extends ListType<R>, S extends boolean>
13990
15147
  // |_____/_/ \_\_/_/ \_\
13991
15148
 
13992
15149
  set data(data: R) {
15150
+ this.#data = data;
15151
+ this.#drop_rows = undefined;
15152
+ this.classList.toggle(
15153
+ "movable",
15154
+ Boolean(this.#drag) &&
15155
+ state.is.state(this.#parent.state) &&
15156
+ this.#parent.state.writable,
15157
+ );
13993
15158
  const result = this.#root.transform(
13994
15159
  data,
13995
15160
  this,
@@ -14003,8 +15168,10 @@ export class ListRow<R, T extends {}, A extends ListType<R>, S extends boolean>
14003
15168
  const row_options = result.value;
14004
15169
  if (this.#invalid) {
14005
15170
  this.#invalid = undefined;
15171
+ if (this.#key_field) this.#key_field.tail = undefined;
14006
15172
  this.#show_cells(this.#fields);
14007
15173
  }
15174
+ this.#selection_update(row_options.selectable ?? true, data);
14008
15175
  if (this.#key_field) this.#key_field.options = row_options.key_field;
14009
15176
  this.#sub_rows = row_options.sub_rows;
14010
15177
 
@@ -14037,8 +15204,18 @@ export class ListRow<R, T extends {}, A extends ListType<R>, S extends boolean>
14037
15204
  //Setup context menu, blocked for right clicks bubbling up from sub rows
14038
15205
  ctm.detach(this);
14039
15206
  this.#sub_row_menu = false;
14040
- if (row_options.context_menu)
14041
- ctm.attach(this, row_options.context_menu, () => {
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
15209
+ const menu =
15210
+ this.#root.sub_rows || this.selection_key !== undefined
15211
+ ? ctm.combine(
15212
+ () => this.#open_lines(),
15213
+ () => this.#selection_lines(),
15214
+ row_options.context_menu,
15215
+ )
15216
+ : row_options.context_menu;
15217
+ if (menu)
15218
+ ctm.attach(this, menu, () => {
14042
15219
  const from_sub_row = this.#sub_row_menu;
14043
15220
  this.#sub_row_menu = false;
14044
15221
  return from_sub_row;
@@ -14047,6 +15224,7 @@ export class ListRow<R, T extends {}, A extends ListType<R>, S extends boolean>
14047
15224
 
14048
15225
  /**Replaces the fields with the text and removes everything else the row options gave */
14049
15226
  #set_invalid(text: string) {
15227
+ this.#selection_update(false);
14050
15228
  if (this.#key_field) this.#key_field.options = undefined;
14051
15229
  this.#sub_rows = undefined;
14052
15230
  this.add_row = undefined;
@@ -14057,7 +15235,11 @@ export class ListRow<R, T extends {}, A extends ListType<R>, S extends boolean>
14057
15235
  this.#sub_row_menu = false;
14058
15236
  if (!this.#invalid) {
14059
15237
  this.#invalid = new ListError();
14060
- this.#show_cells([this.#invalid]);
15238
+ //With sub rows the text is in the key field after the tree lines, it runs from the key column to the end
15239
+ if (this.#key_field) {
15240
+ this.#key_field.tail = this.#invalid;
15241
+ this.#show_cells([]);
15242
+ } else this.#show_cells([this.#invalid]);
14061
15243
  }
14062
15244
  this.#invalid.text = text;
14063
15245
  }
@@ -14100,7 +15282,9 @@ export class ListRow<R, T extends {}, A extends ListType<R>, S extends boolean>
14100
15282
  set open(open: boolean) {
14101
15283
  if (!this.openable) return;
14102
15284
  if (open && this.#child_box.childElementCount === 0) {
14103
- if (this.#sub_rows) this.rows = this.#sub_rows?.();
15285
+ const rows = this.#drop_rows ?? this.#sub_rows?.();
15286
+ this.#drop_rows = undefined;
15287
+ if (rows) this.rows = rows;
14104
15288
  } else if (!open && this.open) this.rows = [];
14105
15289
  }
14106
15290
  get open(): boolean {
@@ -14149,20 +15333,631 @@ export class ListRow<R, T extends {}, A extends ListType<R>, S extends boolean>
14149
15333
  this,
14150
15334
  );
14151
15335
  this.classList.toggle("open", rows.length > 0 || error !== undefined);
14152
- state_ui.a.apply(this.#child_box, rows, {
14153
- create: (row) => new ListRow<R, T, A, S>(this.#root, this, row),
15336
+ list_rows_apply(this.#root, this, this.#child_box, rows);
15337
+ }
15338
+
15339
+ // _____ ______ _ ______ _____ _______ _____ ____ _ _
15340
+ // / ____| ____| | | ____/ ____|__ __|_ _/ __ \| \ | |
15341
+ // | (___ | |__ | | | |__ | | | | | || | | | \| |
15342
+ // \___ \| __| | | | __|| | | | | || | | | . ` |
15343
+ // ____) | |____| |____| |___| |____ | | _| || |__| | |\ |
15344
+ // |_____/|______|______|______\_____| |_| |_____\____/|_| \_|
15345
+
15346
+ #selection_setup(selection: ListSelection<unknown>) {
15347
+ const clear_click_focus = (e: Event) =>
15348
+ (e.currentTarget as HTMLElement).classList.remove("click-focus");
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
+ }
15365
+ for (const cell of [this.#check, this.#key_field])
15366
+ if (cell) {
15367
+ cell.addEventListener("keydown", clear_click_focus);
15368
+ cell.addEventListener("blur", clear_click_focus);
15369
+ }
15370
+ this.#field_box.onclick = (e) => {
15371
+ //Focus first, moving the focus after the warning would close it
15372
+ this.#focus_after_click();
15373
+ if (this.selection_key !== undefined)
15374
+ selection.click(this.selection_key, e);
15375
+ else selection.on_error?.(this, NOT_SELECTABLE);
15376
+ };
15377
+ //Shift click would select text between the rows
15378
+ this.#field_box.onmousedown = (e) => {
15379
+ if (e.shiftKey && selection.multi) e.preventDefault();
15380
+ };
15381
+ }
15382
+
15383
+ /**Registers the row in the selection with the key of its data, or removes it when not selectable */
15384
+ #selection_update(selectable: boolean, data?: R) {
15385
+ const selection = this.#root.selection;
15386
+ if (!selection) return;
15387
+ const key: unknown = selectable ? selection.key(data) : undefined;
15388
+ if (key === this.selection_key) return;
15389
+ if (this.selection_key !== undefined)
15390
+ selection.unregister(this.selection_key, this);
15391
+ this.selection_key = key;
15392
+ if (key !== undefined) selection.register(key, this);
15393
+ this.classList.toggle("selectable", key !== undefined);
15394
+ }
15395
+
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 */
15398
+ #open_lines(): ContextMenuLines {
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;
15409
+ }
15410
+
15411
+ /**Context menu lines to select or deselect the row, and in multi mode all rows
15412
+ * Empty when the row can not be selected */
15413
+ #selection_lines(): ContextMenuLines {
15414
+ const selection = this.#root.selection;
15415
+ const key = this.selection_key;
15416
+ if (!selection || key === undefined) return [];
15417
+ const lines: ContextMenuLines = [
15418
+ selection.is_selected(key)
15419
+ ? ctm.line("Deselect", () => selection.deselect(key))
15420
+ : ctm.line("Select", () => selection.select(key)),
15421
+ ];
15422
+ if (selection.multi)
15423
+ lines.push(
15424
+ ctm.line(
15425
+ "Select all",
15426
+ () => selection.select_all(),
15427
+ undefined,
15428
+ "Ctrl+A",
15429
+ ),
15430
+ ctm.line("Deselect all", () => selection.clear(), undefined, "Esc"),
15431
+ );
15432
+ return lines;
15433
+ }
15434
+
15435
+ // __ __ ______ _______ _ _ _____
15436
+ // | \/ |/ __ \ \ / /_ _| \ | |/ ____|
15437
+ // | \ / | | | \ \ / / | | | \| | | __
15438
+ // | |\/| | | | |\ \/ / | | | . ` | | |_ |
15439
+ // | | | | |__| | \ / _| |_| |\ | |__| |
15440
+ // |_| |_|\____/ \/ |_____|_| \_|\_____|
15441
+
15442
+ get data(): R {
15443
+ return this.#data;
15444
+ }
15445
+
15446
+ /**Moving of the list the row is in, undefined when its rows can not be moved */
15447
+ get reorder() {
15448
+ return this.#root.reorder;
15449
+ }
15450
+
15451
+ /**Rows of the parent the row is in */
15452
+ get parent_rows(): ListParentRows<A> {
15453
+ return this.#parent.state;
15454
+ }
15455
+
15456
+ /**Row the row is a sub row of, undefined for top level rows */
15457
+ get parent_row(): ListRow<R, T, A, S> | undefined {
15458
+ return this.#parent instanceof ListRow ? this.#parent : undefined;
15459
+ }
15460
+
15461
+ get next_row(): ListRow<R, T, A, S> | undefined {
15462
+ const next = this.nextElementSibling;
15463
+ return next instanceof ListRow ? next : undefined;
15464
+ }
15465
+
15466
+ get first_sub_row(): ListRow<R, T, A, S> | undefined {
15467
+ const first = this.#child_box.firstElementChild;
15468
+ return first instanceof ListRow ? first : undefined;
15469
+ }
15470
+
15471
+ /**Whether the row has a handle and its parent rows can be written */
15472
+ get movable(): boolean {
15473
+ return this.classList.contains("movable");
15474
+ }
15475
+
15476
+ /**Whether rows can be dropped into the row, it must be openable with sub rows in a writable state */
15477
+ get droppable(): boolean {
15478
+ if (!this.openable) return false;
15479
+ const rows = this.drop_rows();
15480
+ return state.is.state(rows) && rows.writable;
15481
+ }
15482
+
15483
+ /**The sub rows rows are dropped into, also of a closed row */
15484
+ drop_rows(): R[] | State<R[]> | undefined {
15485
+ if (this.open) return this.state;
15486
+ return (this.#drop_rows ??= this.#sub_rows?.());
15487
+ }
15488
+
15489
+ /**Whether the row is selected in a list with multi selection, a drag of it moves all selected rows */
15490
+ get multi_selected(): boolean {
15491
+ return this.selected && Boolean(this.#root.selection?.multi);
15492
+ }
15493
+
15494
+ /**Text naming the row while it is dragged, the key field text or the text of the first cell */
15495
+ get label(): string {
15496
+ const text =
15497
+ this.#key_field?.querySelector(".text")?.textContent ||
15498
+ this.#fields[0]?.textContent ||
15499
+ "";
15500
+ return text.trim();
15501
+ }
15502
+
15503
+ /**First visible cell of the row, the row itself is display contents and has no box */
15504
+ get anchor(): Element | undefined {
15505
+ return this.#field_box.firstElementChild ?? undefined;
15506
+ }
15507
+
15508
+ set selected(value: boolean) {
15509
+ this.classList.toggle("selected", value);
15510
+ }
15511
+ get selected(): boolean {
15512
+ return this.classList.contains("selected");
15513
+ }
15514
+
15515
+ /**Removes the row and its sub rows from the selection, when the row is removed */
15516
+ selection_leave() {
15517
+ const selection = this.#root.selection;
15518
+ if (!selection) return;
15519
+ if (this.selection_key !== undefined)
15520
+ selection.unregister(this.selection_key, this);
15521
+ this.selection_key = undefined;
15522
+ for (let i = 0; i < this.#child_box.childElementCount; i++)
15523
+ (this.#child_box.children[i] as ListRow<R, T, A, S>).selection_leave();
15524
+ }
15525
+ }
15526
+ define_element(ListRow);
15527
+
15528
+ /**Applies rows to a row box, removed rows leave the selection, which updates once after all changes */
15529
+ export function list_rows_apply<
15530
+ R,
15531
+ T extends {},
15532
+ A extends ListType<R>,
15533
+ S extends boolean,
15534
+ >(
15535
+ root: ListRoot<R, T, A, S>,
15536
+ parent: ListRowParent<A>,
15537
+ box: HTMLElement,
15538
+ rows: readonly R[],
15539
+ ) {
15540
+ const apply = () =>
15541
+ state_ui.a.apply(box, rows, {
15542
+ create: (row) => new ListRow<R, T, A, S>(root, parent, row),
14154
15543
  update: (element, row) => (element.data = row),
15544
+ destroy: (element) => element.selection_leave(),
15545
+ });
15546
+ if (root.selection) root.selection.batch(apply);
15547
+ else apply();
15548
+ }
15549
+ ```
15550
+
15551
+ ## package-ui/list/selection.scss
15552
+
15553
+ ```scss
15554
+ @use "../icons/mixins" as icons;
15555
+
15556
+ list-checkfield {
15557
+ position: sticky;
15558
+ left: var(--list-drag-width);
15559
+ z-index: 2;
15560
+ display: flex;
15561
+ align-items: center;
15562
+ justify-content: center;
15563
+ box-sizing: border-box;
15564
+ //Square, so rows keep the same height without a glyph, like unselectable rows
15565
+ min-height: var(--list-check-width);
15566
+ user-select: none;
15567
+ cursor: pointer;
15568
+ outline: none;
15569
+ border-right: 1px solid var(--list-colors-border-column);
15570
+
15571
+ &::before {
15572
+ @include icons.material-symbols-rounded;
15573
+ font-size: 1.2rem;
15574
+ //Fits in the minimum row height, so the glyph does not make rows taller
15575
+ line-height: 1;
15576
+ color: var(--list-colors-icon-check);
15577
+
15578
+ .touch & {
15579
+ font-size: 1.8rem;
15580
+ }
15581
+ }
15582
+
15583
+ &:focus-visible:not(.click-focus) {
15584
+ outline: 2px solid var(--list-colors-focus-normal);
15585
+ outline-offset: -2px;
15586
+ }
15587
+ }
15588
+
15589
+ //Glyphs of the icon font, check_box_outline_blank, check_box and indeterminate_check_box
15590
+ list-container > div.multi {
15591
+ list-row.selectable > div > list-checkfield::before,
15592
+ > list-headerrow > list-checkfield::before {
15593
+ content: "\e835";
15594
+ }
15595
+ list-row.selectable.selected > div > list-checkfield::before,
15596
+ > list-headerrow > list-checkfield.all::before {
15597
+ content: "\e834";
15598
+ }
15599
+ > list-headerrow > list-checkfield.some:not(.all)::before {
15600
+ content: "\e909";
15601
+ }
15602
+ }
15603
+
15604
+ //Glyphs of the icon font, radio_button_unchecked and radio_button_checked
15605
+ list-container > div.single {
15606
+ list-row.selectable > div > list-checkfield::before {
15607
+ content: "\e836";
15608
+ }
15609
+ list-row.selectable.selected > div > list-checkfield::before {
15610
+ content: "\e837";
15611
+ }
15612
+ //Nothing to select all with
15613
+ > list-headerrow > list-checkfield {
15614
+ cursor: default;
15615
+ }
15616
+ }
15617
+ ```
15618
+
15619
+ ## package-ui/list/selection.ts
15620
+
15621
+ ```ts
15622
+ import { Base, define_element } from "#base";
15623
+ import type { Result } from "@chocbite/ts-lib/result";
15624
+ import { state, type StateREAW } from "@chocbite/ts-lib/state";
15625
+ import "./selection.scss";
15626
+
15627
+ export interface ListSelectionOptions<R, K = R> {
15628
+ /**Single allows one selected row and shows radio buttons in front of the rows,
15629
+ * multi allows any amount and shows checkboxes, which toggle a row without modifier keys */
15630
+ mode: "single" | "multi";
15631
+ /**Identity of the data of a row, the selection is a list of these
15632
+ * Defaults to the data itself, give a key when rows can have equal data, like primitives
15633
+ * Keys must be unique among the rows of the list, sub rows included */
15634
+ key?: (data: R) => K;
15635
+ }
15636
+
15637
+ /**What the selection needs from a row */
15638
+ export interface ListSelectionRow {
15639
+ /**Shows the row as selected */
15640
+ selected: boolean;
15641
+ /**Cell to point at with a message about the row */
15642
+ readonly anchor: Element | undefined;
15643
+ }
15644
+
15645
+ /**Selection of the rows of a list, kept in an array state of keys owned by the app
15646
+ * The list shows the keys of the state that have a visible row, and writes the state only on user actions,
15647
+ * keys of rows it does not show are left alone, except by select all and deselect all which replace the selection */
15648
+ export class ListSelection<K> {
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;
15653
+ readonly key: (data: any) => K;
15654
+ /**Called after a change of the shown selection or of the selectable rows */
15655
+ on_change?: () => void;
15656
+ /**Called when the state rejects a write, with the row the user acted on */
15657
+ on_error?: (row: ListSelectionRow | undefined, message: string) => void;
15658
+ /**State user actions are written to */
15659
+ target?: StateREAW<K[], any, K[]>;
15660
+
15661
+ /**Element holding all rows of the list, sub rows included, in display order */
15662
+ #box: Element;
15663
+ #rows = new Map<K, ListSelectionRow & Element>();
15664
+ /**Mirror of the state array, the removed and changed entries of an update only give positions or new items */
15665
+ #keys: K[] = [];
15666
+ /**How often each key is in the state, a key that is in it twice stays selected when one is removed */
15667
+ #counts = new Map<K, number>();
15668
+ /**Amount of visible rows that are selected */
15669
+ #shown = 0;
15670
+ #anchor?: K;
15671
+ #batch = 0;
15672
+ #changed = false;
15673
+
15674
+ constructor(
15675
+ options: ListSelectionOptions<any, K>,
15676
+ box: Element,
15677
+ key_column: boolean,
15678
+ ) {
15679
+ this.multi = options.mode === "multi";
15680
+ this.column = this.multi || !key_column;
15681
+ this.key = options.key ?? ((data) => data as K);
15682
+ this.#box = box;
15683
+ }
15684
+
15685
+ /**Runs the function with the change notification delayed until all nested batches are done */
15686
+ batch<T>(func: () => T): T {
15687
+ this.#batch++;
15688
+ try {
15689
+ return func();
15690
+ } finally {
15691
+ if (--this.#batch === 0 && this.#changed) {
15692
+ this.#changed = false;
15693
+ this.on_change?.();
15694
+ }
15695
+ }
15696
+ }
15697
+
15698
+ // _____ _______ _______ ______
15699
+ // / ____|__ __|/\|__ __| ____|
15700
+ // | (___ | | / \ | | | |__
15701
+ // \___ \ | | / /\ \ | | | __|
15702
+ // ____) | | |/ ____ \| | | |____
15703
+ // |_____/ |_/_/ \_\_| |______|
15704
+
15705
+ /**Applies a value of the state, only the changed keys are touched when the value carries its changes */
15706
+ apply(value: Result<readonly K[], string>) {
15707
+ this.batch(() => {
15708
+ if (!value.ok) {
15709
+ this.#fresh([]);
15710
+ return;
15711
+ }
15712
+ for (const change of state.a.read(value.value)) {
15713
+ if (change.type === "fresh") this.#fresh(change.items);
15714
+ else if (change.type === "added") {
15715
+ this.#keys.splice(change.index, 0, ...change.items);
15716
+ for (const key of change.items) this.#add(key);
15717
+ } else if (change.type === "removed") {
15718
+ for (const key of this.#keys.splice(
15719
+ change.index,
15720
+ change.items.length,
15721
+ ))
15722
+ this.#remove(key);
15723
+ } else if (change.type === "changed")
15724
+ change.items.forEach((key, i) => {
15725
+ const old = this.#keys[change.index + i];
15726
+ this.#keys[change.index + i] = key;
15727
+ this.#remove(old);
15728
+ this.#add(key);
15729
+ });
15730
+ else {
15731
+ const moved = this.#keys.splice(
15732
+ change.from_index,
15733
+ change.items.length,
15734
+ );
15735
+ this.#keys.splice(change.to_index, 0, ...moved);
15736
+ }
15737
+ }
15738
+ });
15739
+ }
15740
+
15741
+ #fresh(keys: readonly K[]) {
15742
+ const old = this.#counts;
15743
+ this.#keys = [...keys];
15744
+ this.#counts = new Map();
15745
+ for (const key of keys)
15746
+ this.#counts.set(key, (this.#counts.get(key) ?? 0) + 1);
15747
+ for (const key of old.keys())
15748
+ if (!this.#counts.has(key)) this.#show(key, false);
15749
+ for (const key of this.#counts.keys())
15750
+ if (!old.has(key)) this.#show(key, true);
15751
+ }
15752
+
15753
+ #add(key: K) {
15754
+ const count = this.#counts.get(key) ?? 0;
15755
+ this.#counts.set(key, count + 1);
15756
+ if (count === 0) this.#show(key, true);
15757
+ }
15758
+
15759
+ #remove(key: K) {
15760
+ const count = this.#counts.get(key);
15761
+ if (!count) return;
15762
+ if (count > 1) this.#counts.set(key, count - 1);
15763
+ else {
15764
+ this.#counts.delete(key);
15765
+ this.#show(key, false);
15766
+ }
15767
+ }
15768
+
15769
+ #show(key: K, selected: boolean) {
15770
+ const row = this.#rows.get(key);
15771
+ if (!row) return;
15772
+ row.selected = selected;
15773
+ this.#shown += selected ? 1 : -1;
15774
+ this.#changed = true;
15775
+ }
15776
+
15777
+ /**Writes the state, a rejected write is reported at the row of the key the user acted on */
15778
+ #write(value: K[], key?: K) {
15779
+ const write = this.target?.write(value);
15780
+ if (!write) return;
15781
+ const row = key === undefined ? undefined : this.#rows.get(key);
15782
+ void write.then((result) => {
15783
+ if (result.err) this.on_error?.(row, result.error);
14155
15784
  });
14156
15785
  }
15786
+
15787
+ // _____ ______ _______
15788
+ // | __ \ / __ \ \ / / ____|
15789
+ // | |__) | | | \ \ /\ / / (___
15790
+ // | _ /| | | |\ \/ \/ / \___ \
15791
+ // | | \ \| |__| | \ /\ / ____) |
15792
+ // |_| \_\\____/ \/ \/ |_____/
15793
+
15794
+ /**Adds a visible row that can be selected, it shows whether its key is in the state */
15795
+ register(key: K, row: ListSelectionRow & Element) {
15796
+ this.#rows.set(key, row);
15797
+ row.selected = this.#counts.has(key);
15798
+ if (row.selected) this.#shown++;
15799
+ this.#changed = true;
15800
+ }
15801
+
15802
+ /**Removes a row that is no longer visible or selectable, the state keeps its key */
15803
+ unregister(key: K, row: ListSelectionRow & Element) {
15804
+ if (this.#rows.get(key) === row) {
15805
+ this.#rows.delete(key);
15806
+ if (this.#counts.has(key)) this.#shown--;
15807
+ }
15808
+ row.selected = false;
15809
+ this.#changed = true;
15810
+ }
15811
+
15812
+ /**Amount of visible rows that can be selected */
15813
+ get amount_selectable(): number {
15814
+ return this.#rows.size;
15815
+ }
15816
+
15817
+ /**Amount of visible rows that are selected */
15818
+ get amount_selected(): number {
15819
+ return this.#shown;
15820
+ }
15821
+
15822
+ is_selected(key: K): boolean {
15823
+ return this.#counts.has(key);
15824
+ }
15825
+
15826
+ // _ _ _____ ______ _____
15827
+ // | | | |/ ____| ____| __ \
15828
+ // | | | | (___ | |__ | |__) |
15829
+ // | | | |\___ \| __| | _ /
15830
+ // | |__| |____) | |____| | \ \
15831
+ // \____/|_____/|______|_| \_\
15832
+ //Every user action writes the state, the rows show the change when the state gives it back
15833
+
15834
+ /**Keys of the selectable rows from one row to another in display order, both included */
15835
+ #range(from: K, to: K): K[] {
15836
+ const keys: K[] = [];
15837
+ let inside = false;
15838
+ const rows = this.#box.querySelectorAll("list-row");
15839
+ const from_row = this.#rows.get(from);
15840
+ const to_row = this.#rows.get(to);
15841
+ for (let i = 0; i < rows.length; i++) {
15842
+ const row = rows[i];
15843
+ const edge = row === from_row || row === to_row;
15844
+ if (edge || inside) {
15845
+ const key = (row as unknown as { selection_key: K | undefined })
15846
+ .selection_key;
15847
+ if (key !== undefined && this.#rows.get(key) === row) keys.push(key);
15848
+ }
15849
+ if (edge) {
15850
+ if (inside || from_row === to_row) break;
15851
+ inside = true;
15852
+ }
15853
+ }
15854
+ return keys;
15855
+ }
15856
+
15857
+ #select_range(to: K, add: boolean) {
15858
+ if (!this.#rows.has(to)) return;
15859
+ const anchor =
15860
+ this.#anchor !== undefined && this.#rows.has(this.#anchor)
15861
+ ? this.#anchor
15862
+ : to;
15863
+ const keys = this.#range(anchor, to);
15864
+ this.#anchor = anchor;
15865
+ if (!add) return this.#write(state.a.write.fresh(keys), to);
15866
+ const added = keys.filter((key) => !this.#counts.has(key));
15867
+ if (added.length) this.#write(state.a.write.push(...added), to);
15868
+ }
15869
+
15870
+ /**Replaces the selection with only the row */
15871
+ select_only(key: K) {
15872
+ if (!this.#rows.has(key)) return;
15873
+ this.#anchor = key;
15874
+ if (this.#keys.length === 1 && this.#keys[0] === key) return;
15875
+ this.#write(state.a.write.fresh([key]), key);
15876
+ }
15877
+
15878
+ /**Adds the row to the selection, in single mode it replaces the selection */
15879
+ select(key: K) {
15880
+ if (!this.multi) return this.select_only(key);
15881
+ if (!this.#rows.has(key)) return;
15882
+ this.#anchor = key;
15883
+ if (!this.#counts.has(key)) this.#write(state.a.write.push(key), key);
15884
+ }
15885
+
15886
+ /**Removes the row from the selection */
15887
+ deselect(key: K) {
15888
+ if (this.#counts.has(key)) this.#write(state.a.write.delete(key), key);
15889
+ }
15890
+
15891
+ /**Toggles the row, in single mode selecting replaces the selection */
15892
+ toggle(key: K) {
15893
+ if (!this.#rows.has(key)) return;
15894
+ if (this.#counts.has(key)) {
15895
+ this.#anchor = key;
15896
+ this.deselect(key);
15897
+ } else this.select(key);
15898
+ }
15899
+
15900
+ /**Replaces the selection with all visible selectable rows, multi mode only */
15901
+ select_all() {
15902
+ if (this.multi) this.#write(state.a.write.fresh([...this.#rows.keys()]));
15903
+ }
15904
+
15905
+ /**Clears the selection, also of keys without a visible row */
15906
+ clear() {
15907
+ if (this.#keys.length) this.#write(state.a.write.fresh([]));
15908
+ }
15909
+
15910
+ /**Click on the checkbox or radio button of a row */
15911
+ check_click(key: K) {
15912
+ if (this.multi) this.toggle(key);
15913
+ else this.select_only(key);
15914
+ }
15915
+
15916
+ /**Click on a row outside its checkbox or radio button */
15917
+ click(key: K, e: MouseEvent) {
15918
+ if (this.multi && e.shiftKey)
15919
+ this.#select_range(key, e.ctrlKey || e.metaKey);
15920
+ else if (e.ctrlKey || e.metaKey) this.toggle(key);
15921
+ else this.select_only(key);
15922
+ }
15923
+
15924
+ /**Focus moved to a row with the arrow keys, only shift in multi mode extends the range, otherwise the focus moves alone and space selects */
15925
+ focus_moved(key: K, e: KeyboardEvent) {
15926
+ if (this.multi && e.shiftKey)
15927
+ this.#select_range(key, e.ctrlKey || e.metaKey);
15928
+ }
15929
+
15930
+ /**Handles selection keys pressed on a row, returns true when the key was used */
15931
+ key_down(key: K | undefined, e: KeyboardEvent): boolean {
15932
+ if (e.key === " ") {
15933
+ if (key === undefined) return true;
15934
+ if (this.multi || e.ctrlKey || e.metaKey) this.toggle(key);
15935
+ else this.select_only(key);
15936
+ } else if (e.key === "Escape") this.clear();
15937
+ else if (this.multi && (e.ctrlKey || e.metaKey) && e.key === "a")
15938
+ this.select_all();
15939
+ else return false;
15940
+ return true;
15941
+ }
14157
15942
  }
14158
- define_element(ListRow);
15943
+
15944
+ /**Checkbox or radio button cell in front of a row or in the header, its look comes from the selected class of the row or the header */
15945
+ export class ListCheckField extends Base {
15946
+ static element_name() {
15947
+ return "checkfield";
15948
+ }
15949
+ static element_name_space() {
15950
+ return "list";
15951
+ }
15952
+ }
15953
+ define_element(ListCheckField);
14159
15954
  ```
14160
15955
 
14161
- ## package-ui/src/list/shared.ts
15956
+ ## package-ui/list/shared.ts
14162
15957
 
14163
15958
  ```ts
14164
15959
  import { theme_init_variable_root } from "#theme";
14165
- import { GREY, ORANGE, RED } from "@chocbite/ts-lib/colors";
15960
+ import { BLUE, GREY, ORANGE, RED } from "@chocbite/ts-lib/colors";
14166
15961
 
14167
15962
  const theme_root = theme_init_variable_root(
14168
15963
  "list",
@@ -14291,6 +16086,24 @@ colors_icon.make_variable(
14291
16086
  "Color",
14292
16087
  undefined,
14293
16088
  );
16089
+ colors_icon.make_variable(
16090
+ "drag",
16091
+ "Drag Handle Color",
16092
+ "Color of the drag handles that move rows",
16093
+ GREY["600"],
16094
+ GREY["400"],
16095
+ "Color",
16096
+ undefined,
16097
+ );
16098
+ colors_icon.make_variable(
16099
+ "check",
16100
+ "Selection Checkbox Color",
16101
+ "Color of the selection checkboxes",
16102
+ GREY["800"],
16103
+ GREY["200"],
16104
+ "Color",
16105
+ undefined,
16106
+ );
14294
16107
  colors_icon.make_variable(
14295
16108
  "add_icon",
14296
16109
  "Add Row Icon Color",
@@ -14339,6 +16152,24 @@ colors_background.make_variable(
14339
16152
  "Color",
14340
16153
  undefined,
14341
16154
  );
16155
+ colors_background.make_variable(
16156
+ "row_selected",
16157
+ "Selected Row Background Color",
16158
+ "Color of selected row element backgrounds",
16159
+ BLUE["100"],
16160
+ BLUE["900"],
16161
+ "Color",
16162
+ undefined,
16163
+ );
16164
+ colors_background.make_variable(
16165
+ "row_selected_hover",
16166
+ "Selected Hover Row Background Color",
16167
+ "Color of selected row element backgrounds when hovering",
16168
+ BLUE["200"],
16169
+ BLUE["800"],
16170
+ "Color",
16171
+ undefined,
16172
+ );
14342
16173
 
14343
16174
  // ____ ____ _____ _____ ______ _____ _____ ____ _ ____ _____ _____
14344
16175
  // | _ \ / __ \| __ \| __ \| ____| __ \ / ____/ __ \| | / __ \| __ \ / ____|
@@ -14523,7 +16354,7 @@ font.make_variable(
14523
16354
  );
14524
16355
  ```
14525
16356
 
14526
- ## package-ui/src/list/types.ts
16357
+ ## package-ui/list/types.ts
14527
16358
 
14528
16359
  ```ts
14529
16360
  import type { BaseIntersectObserver } from "#base";
@@ -14532,6 +16363,8 @@ import type { State } from "@chocbite/ts-lib/state";
14532
16363
  import list from ".";
14533
16364
  import type { ListField, ListTextField } from "./field";
14534
16365
  import type { ListRow, ListRowOptions } from "./row";
16366
+ import type { ListReorder } from "./drag";
16367
+ import type { ListSelection } from "./selection";
14535
16368
 
14536
16369
  export type ListType<R> = R[] | State<R[]>;
14537
16370
 
@@ -14543,8 +16376,7 @@ export type ListTypeExtract<A extends ListType<any>> = A extends (infer U)[]
14543
16376
 
14544
16377
  /**Rows of a row parent, the top level rows or sub rows, which can be an array or a state regardless of the top level rows */
14545
16378
  export type ListParentRows<A extends ListType<any>> =
14546
- | A
14547
- | ListType<ListTypeExtract<A>>;
16379
+ A | ListType<ListTypeExtract<A>>;
14548
16380
 
14549
16381
  export const ListDataType = {
14550
16382
  number: "number",
@@ -14556,7 +16388,7 @@ export type ListDataType = (typeof ListDataType)[keyof typeof ListDataType];
14556
16388
  export type ListColumnAlign = "left" | "center" | "right";
14557
16389
 
14558
16390
  export interface ListColumnOptions<V, C extends ListField> {
14559
- /**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*/
14560
16392
  init_width?: number;
14561
16393
  /**If the column has a fixed width in rem, overrides init_width and disables resizing*/
14562
16394
  fixed_width?: number | "min" | "max";
@@ -14632,6 +16464,16 @@ export interface ListRoot<
14632
16464
  transform: ListRowTransformer<R, T, A, S>;
14633
16465
  /**Observer for the container if observer is active */
14634
16466
  observer?: BaseIntersectObserver;
16467
+ /**Selection of rows, when enabled */
16468
+ selection?: ListSelection<any>;
16469
+ /**Moving of rows, when enabled */
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;
14635
16477
  }
14636
16478
 
14637
16479
  export interface ListRowParent<A extends ListType<any>> {
@@ -14646,16 +16488,62 @@ export interface ListRowParent<A extends ListType<any>> {
14646
16488
  ): void;
14647
16489
  /**Rows of the parent, the rows of the container or the sub rows of a row */
14648
16490
  state: ListParentRows<A>;
16491
+ /**Handles a key pressed in the key field before the key field does, returns true when the key was used */
16492
+ key_down?(e: KeyboardEvent): boolean;
16493
+ }
16494
+ ```
16495
+
16496
+ ## package-ui/list/warn.ts
16497
+
16498
+ ```ts
16499
+ /**Shows why a write of the list failed as the validation message of the browser, at the row it is about, like the form elements do
16500
+ * One hidden input in the container is placed over the row before the message is shown, it clears after 5 seconds */
16501
+ export class ListWarn {
16502
+ #container: HTMLElement;
16503
+ #input: HTMLInputElement;
16504
+ #timeout?: number;
16505
+
16506
+ constructor(container: HTMLElement) {
16507
+ this.#container = container;
16508
+ this.#input = container.appendChild(document.createElement("input"));
16509
+ this.#input.className = "list-warn";
16510
+ this.#input.tabIndex = -1;
16511
+ }
16512
+
16513
+ /**Shows the message at the element, or at the top of the list without element
16514
+ * @param at element to point at, rows are display contents, so give one of their cells */
16515
+ show(at: Element | undefined, message: string) {
16516
+ const input = this.#input;
16517
+ const container = this.#container;
16518
+ const box = container.getBoundingClientRect();
16519
+ const rect = at?.getBoundingClientRect() ?? box;
16520
+ input.style.top = rect.top - box.top + container.scrollTop + "px";
16521
+ input.style.left =
16522
+ Math.max(rect.left - box.left, 0) + container.scrollLeft + "px";
16523
+ input.style.width = rect.width + "px";
16524
+ input.style.height = rect.height + "px";
16525
+ //Showing the message can move the focus to the input, the keyboard cell keeps it
16526
+ const focused = document.activeElement;
16527
+ input.setCustomValidity(message);
16528
+ input.reportValidity();
16529
+ if (focused instanceof HTMLElement && focused !== document.activeElement)
16530
+ focused.focus({ preventScroll: true });
16531
+ if (this.#timeout) clearTimeout(this.#timeout);
16532
+ this.#timeout = window.setTimeout(() => {
16533
+ input.setCustomValidity("");
16534
+ input.reportValidity();
16535
+ }, 5000);
16536
+ }
14649
16537
  }
14650
16538
  ```
14651
16539
 
14652
- ## package-ui/src/selection/index.ts
16540
+ ## package-ui/selection/index.ts
14653
16541
 
14654
16542
  ```ts
14655
16543
  export * from "./selection";
14656
16544
  ```
14657
16545
 
14658
- ## package-ui/src/selection/selection.ts
16546
+ ## package-ui/selection/selection.ts
14659
16547
 
14660
16548
  ```ts
14661
16549
  type TextControl = HTMLInputElement | HTMLTextAreaElement;
@@ -14773,7 +16661,7 @@ export function set_selection_all(element: HTMLElement): void {
14773
16661
  }
14774
16662
  ```
14775
16663
 
14776
- ## package-ui/src/settings/index.ts
16664
+ ## package-ui/settings/index.ts
14777
16665
 
14778
16666
  ```ts
14779
16667
  import { ok, type Option, type ResultOk } from "@chocbite/ts-lib/result";
@@ -14991,7 +16879,7 @@ export class SettingsGroup {
14991
16879
  }
14992
16880
  ```
14993
16881
 
14994
- ## package-ui/src/spinner/globals.d.ts
16882
+ ## package-ui/spinner/globals.d.ts
14995
16883
 
14996
16884
  ```ts
14997
16885
  declare module "*.scss" {
@@ -15000,7 +16888,7 @@ declare module "*.scss" {
15000
16888
  }
15001
16889
  ```
15002
16890
 
15003
- ## package-ui/src/spinner/index.scss
16891
+ ## package-ui/spinner/index.scss
15004
16892
 
15005
16893
  ```scss
15006
16894
  spinner-spinner {
@@ -15039,7 +16927,7 @@ spinner-spinner {
15039
16927
  }
15040
16928
  ```
15041
16929
 
15042
- ## package-ui/src/spinner/index.ts
16930
+ ## package-ui/spinner/index.ts
15043
16931
 
15044
16932
  ```ts
15045
16933
  import { Base, define_element } from "#base";
@@ -15100,7 +16988,7 @@ export class Spinner extends Base {
15100
16988
  define_element(Spinner);
15101
16989
  ```
15102
16990
 
15103
- ## package-ui/src/state_ui/array.ts
16991
+ ## package-ui/state_ui/array.ts
15104
16992
 
15105
16993
  ```ts
15106
16994
  import state from "@chocbite/ts-lib/state";
@@ -15202,7 +17090,7 @@ export const ARRAY_UI = {
15202
17090
  };
15203
17091
  ```
15204
17092
 
15205
- ## package-ui/src/state_ui/index.ts
17093
+ ## package-ui/state_ui/index.ts
15206
17094
 
15207
17095
  ```ts
15208
17096
  import { ARRAY_UI } from "./array";
@@ -15223,7 +17111,7 @@ export default state_ui;
15223
17111
  export type { StateUIArrayApplyHandlers } from "./array";
15224
17112
  ```
15225
17113
 
15226
- ## package-ui/src/svg/attributes.ts
17114
+ ## package-ui/svg/attributes.ts
15227
17115
 
15228
17116
  ```ts
15229
17117
  export class SVGAttributes<T extends SVGElement> {
@@ -15339,7 +17227,7 @@ export class SVGAttributes<T extends SVGElement> {
15339
17227
  }
15340
17228
  ```
15341
17229
 
15342
- ## package-ui/src/svg/index.ts
17230
+ ## package-ui/svg/index.ts
15343
17231
 
15344
17232
  ```ts
15345
17233
  import { SVGAttributes } from "./attributes";
@@ -15390,7 +17278,7 @@ declare global {
15390
17278
  }
15391
17279
  ```
15392
17280
 
15393
- ## package-ui/src/svg/primitives/circle.ts
17281
+ ## package-ui/svg/primitives/circle.ts
15394
17282
 
15395
17283
  ```ts
15396
17284
  import { SVGAttributes } from "../attributes";
@@ -15437,7 +17325,7 @@ export function circle_arc(
15437
17325
  }
15438
17326
  ```
15439
17327
 
15440
- ## package-ui/src/svg/primitives/ellipse.ts
17328
+ ## package-ui/svg/primitives/ellipse.ts
15441
17329
 
15442
17330
  ```ts
15443
17331
  import { degrees_to_radians } from "@chocbite/ts-lib/math";
@@ -15499,7 +17387,7 @@ export function ellipse_arc(
15499
17387
  }
15500
17388
  ```
15501
17389
 
15502
- ## package-ui/src/svg/primitives/group.ts
17390
+ ## package-ui/svg/primitives/group.ts
15503
17391
 
15504
17392
  ```ts
15505
17393
  import { SVGAttributes } from "../attributes";
@@ -15511,7 +17399,7 @@ export function group(): SVGAttributes<SVGGElement> {
15511
17399
  }
15512
17400
  ```
15513
17401
 
15514
- ## package-ui/src/svg/primitives/line.ts
17402
+ ## package-ui/svg/primitives/line.ts
15515
17403
 
15516
17404
  ```ts
15517
17405
  import { SVGAttributes } from "../attributes";
@@ -15536,7 +17424,7 @@ export function line(
15536
17424
  }
15537
17425
  ```
15538
17426
 
15539
- ## package-ui/src/svg/primitives/path.ts
17427
+ ## package-ui/svg/primitives/path.ts
15540
17428
 
15541
17429
  ```ts
15542
17430
  import { SVGAttributes } from "../attributes";
@@ -15565,7 +17453,7 @@ export function path_line(
15565
17453
  }
15566
17454
  ```
15567
17455
 
15568
- ## package-ui/src/svg/primitives/rectangle.ts
17456
+ ## package-ui/svg/primitives/rectangle.ts
15569
17457
 
15570
17458
  ```ts
15571
17459
  import { SVGAttributes } from "../attributes";
@@ -15614,7 +17502,7 @@ export function rectangle_from_corner(
15614
17502
  }
15615
17503
  ```
15616
17504
 
15617
- ## package-ui/src/svg/primitives/shared.ts
17505
+ ## package-ui/svg/primitives/shared.ts
15618
17506
 
15619
17507
  ```ts
15620
17508
  import { SVGAttributes } from "../attributes";
@@ -15627,7 +17515,7 @@ export function create_svg_element<K extends keyof SVGElementTagNameMap>(
15627
17515
  }
15628
17516
  ```
15629
17517
 
15630
- ## package-ui/src/svg/primitives/svg.ts
17518
+ ## package-ui/svg/primitives/svg.ts
15631
17519
 
15632
17520
  ```ts
15633
17521
  import { SVGAttributes } from "../attributes";
@@ -15649,7 +17537,7 @@ export function svg(
15649
17537
  }
15650
17538
  ```
15651
17539
 
15652
- ## package-ui/src/svg/primitives/text.ts
17540
+ ## package-ui/svg/primitives/text.ts
15653
17541
 
15654
17542
  ```ts
15655
17543
  import { SVGAttributes } from "../attributes";
@@ -15792,7 +17680,7 @@ export function multi_line_text(
15792
17680
  }
15793
17681
  ```
15794
17682
 
15795
- ## package-ui/src/svg/primitives/triangle.ts
17683
+ ## package-ui/svg/primitives/triangle.ts
15796
17684
 
15797
17685
  ```ts
15798
17686
  import { SVGAttributes } from "../attributes";
@@ -15830,13 +17718,13 @@ export function isosceles_triangle(
15830
17718
  }
15831
17719
  ```
15832
17720
 
15833
- ## package-ui/src/svg/shared.ts
17721
+ ## package-ui/svg/shared.ts
15834
17722
 
15835
17723
  ```ts
15836
17724
  export const NAME_SPACE = "http://www.w3.org/2000/svg";
15837
17725
  ```
15838
17726
 
15839
- ## package-ui/src/svg/util/anchorPoint.ts
17727
+ ## package-ui/svg/util/anchorPoint.ts
15840
17728
 
15841
17729
  ```ts
15842
17730
  //Enum describing the diffrent possible anchor points
@@ -15855,7 +17743,7 @@ export type SVGAnchorPoint =
15855
17743
  (typeof SVGAnchorPoint)[keyof typeof SVGAnchorPoint];
15856
17744
  ```
15857
17745
 
15858
- ## package-ui/src/svg/util/angleToAnchorPoint.ts
17746
+ ## package-ui/svg/util/angleToAnchorPoint.ts
15859
17747
 
15860
17748
  ```ts
15861
17749
  import { SVGAnchorPoint } from "./anchorPoint";
@@ -15887,7 +17775,7 @@ export const angle_to_anchor_point = (angle: number) => {
15887
17775
  };
15888
17776
  ```
15889
17777
 
15890
- ## package-ui/src/test/index.ts
17778
+ ## package-ui/test/index.ts
15891
17779
 
15892
17780
  ```ts
15893
17781
  import { Base, define_element } from "#base";
@@ -16186,7 +18074,7 @@ export class TestSetterBox extends TestBase {
16186
18074
  define_element(TestSetterBox);
16187
18075
  ```
16188
18076
 
16189
- ## package-ui/src/theme/builtIn.ts
18077
+ ## package-ui/theme/builtIn.ts
16190
18078
 
16191
18079
  ```ts
16192
18080
  import { GREY } from "@chocbite/ts-lib/colors";
@@ -16268,7 +18156,7 @@ colors.make_variable(
16268
18156
  );
16269
18157
  ```
16270
18158
 
16271
- ## package-ui/src/theme/engine.ts
18159
+ ## package-ui/theme/engine.ts
16272
18160
 
16273
18161
  ```ts
16274
18162
  import { DOCUMENT_HANDLER } from "#document";
@@ -16468,7 +18356,7 @@ ANIMATION_SPEED.sub((val) => {
16468
18356
  });
16469
18357
  ```
16470
18358
 
16471
- ## package-ui/src/theme/globals.d.ts
18359
+ ## package-ui/theme/globals.d.ts
16472
18360
 
16473
18361
  ```ts
16474
18362
  declare module "*.scss" {
@@ -16477,7 +18365,7 @@ declare module "*.scss" {
16477
18365
  }
16478
18366
  ```
16479
18367
 
16480
- ## package-ui/src/theme/index.scss
18368
+ ## package-ui/theme/index.scss
16481
18369
 
16482
18370
  ```scss
16483
18371
  @use "./mixins";
@@ -16534,7 +18422,7 @@ html {
16534
18422
  }
16535
18423
  ```
16536
18424
 
16537
- ## package-ui/src/theme/index.ts
18425
+ ## package-ui/theme/index.ts
16538
18426
 
16539
18427
  ```ts
16540
18428
  export { BUILT_IN } from "./builtIn";
@@ -16558,7 +18446,7 @@ export { theme_init_variable_root, ThemeVariableGroup } from "./variables";
16558
18446
  import "./index.scss";
16559
18447
  ```
16560
18448
 
16561
- ## package-ui/src/theme/init.ts
18449
+ ## package-ui/theme/init.ts
16562
18450
 
16563
18451
  ```ts
16564
18452
  import { theme_engine } from "./engine";
@@ -16605,7 +18493,7 @@ export function theme_init(options: ThemeInitOptions = {}) {
16605
18493
  }
16606
18494
  ```
16607
18495
 
16608
- ## package-ui/src/theme/mixins.scss
18496
+ ## package-ui/theme/mixins.scss
16609
18497
 
16610
18498
  ```scss
16611
18499
  @mixin scrollbar {
@@ -16649,7 +18537,7 @@ export function theme_init(options: ThemeInitOptions = {}) {
16649
18537
  }
16650
18538
  ```
16651
18539
 
16652
- ## package-ui/src/theme/settings.ts
18540
+ ## package-ui/theme/settings.ts
16653
18541
 
16654
18542
  ```ts
16655
18543
  import {
@@ -16662,7 +18550,7 @@ import {
16662
18550
  import { settings_init } from "#settings";
16663
18551
  import { none, ok, some, type Option } from "@chocbite/ts-lib/result";
16664
18552
  import { state as st } from "@chocbite/ts-lib/state";
16665
- import { version } from "../../../package.json";
18553
+ import { version } from "../../package.json";
16666
18554
 
16667
18555
  const SETTINGS = settings_init(
16668
18556
  "@chocbite/ts-lib-theme",
@@ -16970,7 +18858,7 @@ SETTINGS.register(
16970
18858
  export const ANIMATION_SPEED = PRIVATE_ANIMATION_SPEED.read_write;
16971
18859
  ```
16972
18860
 
16973
- ## package-ui/src/theme/shared.ts
18861
+ ## package-ui/theme/shared.ts
16974
18862
 
16975
18863
  ```ts
16976
18864
  import type { ThemeVariableGroup } from "./variables";
@@ -16978,7 +18866,7 @@ import type { ThemeVariableGroup } from "./variables";
16978
18866
  export const BOTTOM_GROUPS: { [key: string]: ThemeVariableGroup } = {};
16979
18867
  ```
16980
18868
 
16981
- ## package-ui/src/theme/variables.ts
18869
+ ## package-ui/theme/variables.ts
16982
18870
 
16983
18871
  ```ts
16984
18872
  import { theme_engine } from "./engine";