@chocbite/ts-lib-ui 1.0.6 → 1.1.0

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 (63) hide show
  1. package/AGENTS.md +164 -3
  2. package/SOURCE.md +2000 -268
  3. package/base/index.d.mts +1 -1
  4. package/base/index.mjs +7 -7
  5. package/base/index.mjs.map +1 -1
  6. package/canvas/index.d.mts +1 -1
  7. package/canvas/index.mjs +8 -8
  8. package/canvas/index.mjs.map +1 -1
  9. package/context-menu/index.d.mts +2 -2
  10. package/context-menu/index.mjs +1 -1
  11. package/{context-menu-Bo8R6DmK.mjs → context-menu-DE3EUtY8.mjs} +149 -111
  12. package/context-menu-DE3EUtY8.mjs.map +1 -0
  13. package/document/index.mjs +1 -1
  14. package/document/index.mjs.map +1 -1
  15. package/dom/index.mjs +1 -1
  16. package/dom/index.mjs.map +1 -1
  17. package/form/index.d.mts +6 -5
  18. package/form/index.mjs +30 -29
  19. package/form/index.mjs.map +1 -1
  20. package/icons/index.d.mts +1 -1
  21. package/icons/index.mjs +1 -1
  22. package/{icons-e2J_Ojic.mjs → icons-B88i-7MC.mjs} +2 -2
  23. package/{index-ClIBfrHy.d.mts → index-BDWg5GX2.d.mts} +2 -2
  24. package/{index-ClfL2SQR.d.mts → index-CvzH3M_5.d.mts} +2 -2
  25. package/index-Cw4AcuUl.d.mts +371 -0
  26. package/{index-Pr2sLv9e.d.mts → index-YNZjMIO7.d.mts} +33 -17
  27. package/keyboard/index.d.mts +1 -1
  28. package/keyboard/index.mjs +12 -12
  29. package/keyboard/index.mjs.map +1 -1
  30. package/list/index.d.mts +2 -2
  31. package/list/index.mjs +1 -1
  32. package/list-D08epOjk.mjs +1566 -0
  33. package/list-D08epOjk.mjs.map +1 -0
  34. package/package.json +5 -80
  35. package/selection/index.mjs +1 -1
  36. package/selection/index.mjs.map +1 -1
  37. package/settings/index.mjs +1 -1
  38. package/settings/index.mjs.map +1 -1
  39. package/spinner/index.d.mts +1 -1
  40. package/spinner/index.mjs +3 -3
  41. package/spinner/index.mjs.map +1 -1
  42. package/state_ui/index.mjs +1 -1
  43. package/{state_ui-Bm3TeKNL.mjs → state_ui-Dtm2y5RU.mjs} +3 -3
  44. package/state_ui-Dtm2y5RU.mjs.map +1 -0
  45. package/style.css +307 -63
  46. package/svg/index.d.mts +1 -1
  47. package/svg/index.mjs +1 -1
  48. package/{svg-1bp-yIPC.mjs → svg-Yz7elqnU.mjs} +16 -16
  49. package/svg-Yz7elqnU.mjs.map +1 -0
  50. package/test/index.d.mts +1 -1
  51. package/test/index.mjs +1 -1
  52. package/test/index.mjs.map +1 -1
  53. package/theme/index.d.mts +1 -1
  54. package/theme/index.mjs +1 -1
  55. package/{theme-DgVtLDzP.mjs → theme-BJS5z1iW.mjs} +9 -9
  56. package/theme-BJS5z1iW.mjs.map +1 -0
  57. package/context-menu-Bo8R6DmK.mjs.map +0 -1
  58. package/index-BTUFkF9s.d.mts +0 -173
  59. package/list-DOXIQOEY.mjs +0 -715
  60. package/list-DOXIQOEY.mjs.map +0 -1
  61. package/state_ui-Bm3TeKNL.mjs.map +0 -1
  62. package/svg-1bp-yIPC.mjs.map +0 -1
  63. 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.0, built from ssh://git@forgejo.nsns.dk:2222/chocbite/ts-lib.git at commit 8de9a71, 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,12 @@ 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
12851
12923
  list-container {
12852
12924
  $sizer_width: 0.5rem;
12925
+ $sizer_touch_width: 1.5rem;
12853
12926
 
12854
12927
  position: relative;
12855
12928
  display: block;
@@ -12869,12 +12942,11 @@ list-container {
12869
12942
  position: sticky;
12870
12943
  border-bottom: 1px solid var(--list-colors-border-header);
12871
12944
  background-color: var(--list-colors-background-row_even);
12945
+ //Above the rows scrolling under it
12872
12946
  z-index: 999;
12873
12947
 
12874
12948
  &:first-child {
12875
12949
  left: 0;
12876
- z-index: 3;
12877
- border-right: 1px solid var(--list-colors-border-column);
12878
12950
  }
12879
12951
  }
12880
12952
 
@@ -12913,6 +12985,7 @@ list-container {
12913
12985
  }
12914
12986
  }
12915
12987
 
12988
+ //Handle resizing the column
12916
12989
  > div {
12917
12990
  display: flex;
12918
12991
  position: relative;
@@ -12922,8 +12995,11 @@ list-container {
12922
12995
  cursor: ew-resize;
12923
12996
  justify-content: center;
12924
12997
  align-items: center;
12998
+ //A drag on the handle resizes, it does not pan the list
12999
+ touch-action: none;
12925
13000
 
12926
- &:hover {
13001
+ &:hover,
13002
+ &.active {
12927
13003
  background-color: var(--list-colors-background-row_hover);
12928
13004
  }
12929
13005
 
@@ -12933,6 +13009,26 @@ list-container {
12933
13009
  height: 80%;
12934
13010
  background-color: var(--list-colors-border-column);
12935
13011
  }
13012
+
13013
+ &.active::after {
13014
+ background-color: var(--list-colors-focus-normal);
13015
+ }
13016
+
13017
+ //Wide enough for a finger, with two lines as a grip so it shows it can be grabbed
13018
+ .touch & {
13019
+ width: $sizer_touch_width;
13020
+
13021
+ &::after {
13022
+ width: 3px;
13023
+ height: 60%;
13024
+ transform: translateX(-0.2rem);
13025
+ box-shadow: 0.4rem 0 0 var(--list-colors-border-column);
13026
+ }
13027
+
13028
+ &.active::after {
13029
+ box-shadow: 0.4rem 0 0 var(--list-colors-focus-normal);
13030
+ }
13031
+ }
12936
13032
  }
12937
13033
  }
12938
13034
  }
@@ -12943,21 +13039,109 @@ list-container {
12943
13039
  }
12944
13040
  }
12945
13041
  }
13042
+
13043
+ //Hidden input showing write errors with the validation message of the browser, placed over a row by the list
13044
+ list-container > input.list-warn {
13045
+ all: unset;
13046
+ visibility: hidden;
13047
+ position: absolute;
13048
+ pointer-events: none;
13049
+ }
13050
+
13051
+ // _ ______ _____
13052
+ // | | | ____| /\ | __ \
13053
+ // | | | |__ / \ | | | |
13054
+ // | | | __| / /\ \ | | | |
13055
+ // | |____| |____ / ____ \| |__| |
13056
+ // |______|______/_/ \_\_____/
13057
+ //Columns in front of the key field column, the drag handles and then the checkboxes or radio buttons
13058
+ //They are square and sticky, each starts where the ones before it end
13059
+ list-container > div {
13060
+ --list-drag-width: 0px;
13061
+ --list-check-width: 0px;
13062
+ --list-lead-size: var(--list-size-row_min);
13063
+ .touch & {
13064
+ --list-lead-size: var(--list-size-touch_row_min);
13065
+ }
13066
+ &.drag {
13067
+ --list-drag-width: var(--list-lead-size);
13068
+ }
13069
+ &.check {
13070
+ --list-check-width: var(--list-lead-size);
13071
+ }
13072
+
13073
+ list-keyfield,
13074
+ > list-headerrow > .key {
13075
+ left: calc(var(--list-drag-width) + var(--list-check-width));
13076
+ }
13077
+ //Sticky in both directions, above the column headers that scroll under them sideways
13078
+ > list-headerrow > :first-child,
13079
+ > list-headerrow > .key,
13080
+ > list-headerrow > list-dragfield,
13081
+ > list-headerrow > list-checkfield {
13082
+ z-index: 1000;
13083
+ }
13084
+
13085
+ //A resized key column, the column fits the widest key field minimum, so opening sub rows widens it by their indent
13086
+ //The containment makes the text not count for the width, the key fields stretch to the column like other cells
13087
+ &.key-sized {
13088
+ list-keyfield {
13089
+ box-sizing: border-box;
13090
+ contain: inline-size;
13091
+ min-width: max(var(--list-key-width), var(--list-key-min));
13092
+
13093
+ //A word longer than the space breaks instead of running under the next column
13094
+ > span.text {
13095
+ overflow-wrap: anywhere;
13096
+ }
13097
+ }
13098
+ //Stretches to the column like the other header cells, the width holds the column without rows
13099
+ > list-headerrow > .key {
13100
+ min-width: var(--list-key-width);
13101
+ }
13102
+ }
13103
+
13104
+ //The error and add rows start after the lead columns
13105
+ @for $lead from 1 through 2 {
13106
+ &.lead-#{$lead} {
13107
+ //With sub rows the key field holds the button or error and runs to the end
13108
+ list-keyfield.tail,
13109
+ list-addrow > span,
13110
+ list-error {
13111
+ grid-column: #{$lead + 1} / -1;
13112
+ }
13113
+ }
13114
+ }
13115
+ }
12946
13116
  ```
12947
13117
 
12948
- ## package-ui/src/list/container.ts
13118
+ ## package-ui/list/container.ts
12949
13119
 
12950
13120
  ```ts
12951
13121
  import { Base, define_element, type BaseIntersectObserver } from "#base";
13122
+ import ctm from "#context-menu";
12952
13123
  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";
13124
+ import {
13125
+ state,
13126
+ type State,
13127
+ type StateInferSub,
13128
+ type StateREAW,
13129
+ type StateSub,
13130
+ } from "@chocbite/ts-lib/state";
13131
+ import type { Result } from "@chocbite/ts-lib/result";
12955
13132
  import { ListAddRow, type ListAddRowOptions } from "./add_row";
13133
+ import { ListDragField, ListReorder, type ListReorderOptions } from "./drag";
12956
13134
  import "./container.scss";
12957
13135
  import { list_rows_error_update, type ListRowsError } from "./error";
12958
- import { list_align_apply, text_field } from "./field";
12959
- import { ListRow } from "./row";
13136
+ import { list_align_apply } from "./field";
13137
+ import { list_rows_apply, ListRow } from "./row";
13138
+ import {
13139
+ ListCheckField,
13140
+ ListSelection,
13141
+ type ListSelectionOptions,
13142
+ } from "./selection";
12960
13143
  import "./shared";
13144
+ import { ListWarn } from "./warn";
12961
13145
  import type {
12962
13146
  ListColumnOptions,
12963
13147
  ListRoot,
@@ -13002,16 +13186,26 @@ class HeaderField extends Base {
13002
13186
  double_timeout = 0;
13003
13187
  }, 300);
13004
13188
  this.setPointerCapture(e.pointerId);
13189
+ const handle = e.currentTarget as HTMLElement;
13190
+ handle.classList.add("active");
13005
13191
  const start_x = e.pageX;
13006
13192
  const start_width = this.#box.offsetWidth;
13007
13193
  this.onpointermove = (ev: PointerEvent) => {
13008
13194
  sizer(px_to_rem(start_width + (ev.pageX - start_x)));
13009
13195
  };
13010
- this.onpointerup = () => {
13011
- this.releasePointerCapture(e.pointerId);
13196
+ //A cancel or lost capture also ends the resize, a touch the browser takes for something else cancels
13197
+ const end = () => {
13198
+ if (this.hasPointerCapture(e.pointerId))
13199
+ this.releasePointerCapture(e.pointerId);
13200
+ handle.classList.remove("active");
13012
13201
  this.onpointermove = null;
13013
13202
  this.onpointerup = null;
13203
+ this.onpointercancel = null;
13204
+ this.onlostpointercapture = null;
13014
13205
  };
13206
+ this.onpointerup = end;
13207
+ this.onpointercancel = end;
13208
+ this.onlostpointercapture = end;
13015
13209
  };
13016
13210
  } else if (this.#sizer) {
13017
13211
  this.#sizer.remove();
@@ -13035,20 +13229,65 @@ class HeaderRow<
13035
13229
  }
13036
13230
 
13037
13231
  set fields(fields: HeaderField[]) {
13038
- if (this.#root.sub_rows) this.replaceChildren(text_field(), ...fields);
13039
- else this.replaceChildren(...fields);
13232
+ const lead: HTMLElement[] = [];
13233
+ if (this.#drag_header) lead.push(this.#drag_header);
13234
+ if (this.#check_header) lead.push(this.#check_header);
13235
+ if (this.#key_header) lead.push(this.#key_header);
13236
+ this.replaceChildren(...lead, ...fields);
13040
13237
  }
13041
13238
 
13042
- #root: ListRoot<R, T, A, S>;
13239
+ /**Header of the key field column, only with sub rows */
13240
+ #key_header?: HeaderField;
13241
+ /**Empty header of the drag handle column */
13242
+ #drag_header?: ListDragField;
13243
+ /**Header of the checkbox or radio button column, in multi mode it selects or deselects all rows */
13244
+ #check_header?: ListCheckField;
13043
13245
 
13044
- constructor(root: ListRoot<R, T, A, S>) {
13246
+ constructor(
13247
+ root: ListRoot<R, T, A, S>,
13248
+ key_sizer: (width: number | undefined) => void,
13249
+ ) {
13045
13250
  super();
13046
- this.#root = root;
13251
+ if (root.sub_rows) {
13252
+ this.#key_header = new HeaderField();
13253
+ this.#key_header.classList.add("key");
13254
+ this.#key_header.sizable(true, key_sizer);
13255
+ }
13256
+ if (root.reorder) this.#drag_header = new ListDragField();
13257
+ const selection = root.selection;
13258
+ if (selection) this.#check_header = new ListCheckField();
13259
+ if (selection?.multi) {
13260
+ const check = this.#check_header!;
13261
+ check.onclick = () => {
13262
+ if (selection.amount_selected > 0) selection.clear();
13263
+ else selection.select_all();
13264
+ };
13265
+ ctm.attach(
13266
+ check,
13267
+ ctm.menu([
13268
+ ctm.line(
13269
+ "Select all",
13270
+ () => selection.select_all(),
13271
+ undefined,
13272
+ "Ctrl+A",
13273
+ ),
13274
+ ctm.line("Deselect all", () => selection.clear(), undefined, "Esc"),
13275
+ ]),
13276
+ );
13277
+ selection.on_change = () => {
13278
+ const selected = selection.amount_selected;
13279
+ check.classList.toggle("some", selected > 0);
13280
+ check.classList.toggle(
13281
+ "all",
13282
+ selected > 0 && selected === selection.amount_selectable,
13283
+ );
13284
+ };
13285
+ }
13047
13286
  }
13048
13287
  }
13049
13288
  define_element(HeaderRow);
13050
13289
 
13051
- interface ContainerOptions<S extends boolean = false> {
13290
+ interface ContainerOptions<S extends boolean = false, R = unknown, K = R> {
13052
13291
  /**Should header row be omitted */
13053
13292
  headless?: boolean;
13054
13293
  /**Can rows have sub rows */
@@ -13057,6 +13296,10 @@ interface ContainerOptions<S extends boolean = false> {
13057
13296
  add_row?: ListAddRowOptions;
13058
13297
  /**If list should use a container to give fields the option of attach/detach to states when visible */
13059
13298
  observer?: BaseIntersectObserver;
13299
+ /**Lets the user select rows, only rows that are visible can be selected */
13300
+ selection?: ListSelectionOptions<R, K>;
13301
+ /**Lets the user move rows with a drag handle in front of the rows, rows in a writable array state can be moved */
13302
+ reorder?: ListReorderOptions<R>;
13060
13303
  }
13061
13304
 
13062
13305
  class Container<
@@ -13064,6 +13307,7 @@ class Container<
13064
13307
  T extends { [key: string]: ListColumnOptions<any, any> },
13065
13308
  S extends boolean = false,
13066
13309
  R = ListTypeExtract<A>,
13310
+ K = R,
13067
13311
  > extends Base {
13068
13312
  static element_name() {
13069
13313
  return "container";
@@ -13073,6 +13317,8 @@ class Container<
13073
13317
  }
13074
13318
 
13075
13319
  #root: ListRoot<R, T, A, S>;
13320
+ #selection?: ListSelection<K>;
13321
+ #selection_sub?: StateSub<Result<K[], string>>;
13076
13322
  #parent: ListRowParent<A>;
13077
13323
  #box = this.appendChild(document.createElement("div"));
13078
13324
  #header?: HeaderRow<R, T, A, S>;
@@ -13080,12 +13326,14 @@ class Container<
13080
13326
  #error?: ListRowsError<A>;
13081
13327
  #add_row?: ListAddRow<R, T, A, S>;
13082
13328
  #state_sub?: StateInferSub<State<R[]>>;
13329
+ /**Width of the key field column in rem set by resizing, fits the key fields when undefined */
13330
+ #key_width?: number;
13083
13331
 
13084
13332
  constructor(
13085
- columns: { [K in keyof T]: ListColumnOptions<T[K], any> },
13333
+ columns: { [C in keyof T]: ListColumnOptions<T[C], any> },
13086
13334
  transform: ListRowTransformer<R, T, A, S>,
13087
13335
  rows: A,
13088
- options?: ContainerOptions<S>,
13336
+ options?: ContainerOptions<S, R, K>,
13089
13337
  ) {
13090
13338
  super();
13091
13339
  this.#root = {
@@ -13102,17 +13350,47 @@ class Container<
13102
13350
  state: rows,
13103
13351
  };
13104
13352
 
13353
+ this.#child_box = document.createElement("div");
13354
+ //Shows why a write of the selection or a move failed
13355
+ const warn =
13356
+ options?.selection || options?.reorder ? new ListWarn(this) : undefined;
13357
+ if (options?.reorder) {
13358
+ this.#root.reorder = new ListReorder(this, options.reorder, warn!);
13359
+ this.#box.classList.add("drag");
13360
+ }
13361
+ if (options?.selection) {
13362
+ this.#selection = new ListSelection(options.selection, this.#child_box);
13363
+ this.#root.selection = this.#selection;
13364
+ this.#box.classList.add(
13365
+ "check",
13366
+ this.#selection.multi ? "multi" : "single",
13367
+ );
13368
+ this.#selection.on_error = (row, message) =>
13369
+ warn!.show(row?.anchor ?? this.#header ?? this.#box, message);
13370
+ }
13371
+ //Columns in front of the key field column, the error and add rows start after them
13372
+ const lead =
13373
+ Number(Boolean(options?.reorder)) + Number(Boolean(options?.selection));
13374
+ if (lead) this.#box.classList.add("lead-" + lead);
13375
+
13105
13376
  if (!options?.headless)
13106
- this.#header = this.#box.appendChild(new HeaderRow(this.#root));
13107
- this.#child_box = this.#box.appendChild(document.createElement("div"));
13377
+ this.#header = this.#box.appendChild(
13378
+ new HeaderRow(this.#root, (width) => {
13379
+ this.#key_width = width;
13380
+ this.#update_column_widths();
13381
+ }),
13382
+ );
13383
+ this.#box.appendChild(this.#child_box);
13108
13384
  if (options?.sub_rows) this.#box.classList.add("sub-rows");
13109
13385
  this.add_row = options?.add_row;
13110
13386
 
13111
13387
  this.columns = columns;
13112
13388
  this.rows = rows;
13389
+ //Selection works without a bound state, in a state of its own nobody else can reach
13390
+ if (this.#selection) this.bind({});
13113
13391
  }
13114
13392
 
13115
- set columns(columns: { [K in keyof T]: ListColumnOptions<T[K], any> }) {
13393
+ set columns(columns: { [C in keyof T]: ListColumnOptions<T[C], any> }) {
13116
13394
  this.#root.columns.clear();
13117
13395
  const order = new Map<keyof T, number>();
13118
13396
  let index = 0;
@@ -13126,23 +13404,41 @@ class Container<
13126
13404
  (a, b) => order.get(a)! - order.get(b)!,
13127
13405
  );
13128
13406
 
13129
- if (this.#header)
13130
- this.#header.fields = this.#root.columns_visible.map((key) => {
13407
+ if (this.#header) {
13408
+ const headers = this.#root.columns_visible.map((key) => {
13131
13409
  const column = this.#root.columns.get(key)!;
13132
13410
  const header = new HeaderField(column.title);
13133
13411
  list_align_apply(header, column.align);
13134
13412
  header.sizable(typeof column.fixed_width === "undefined", (width) => {
13413
+ if (width !== undefined) this.#freeze_auto_widths(headers);
13135
13414
  column.init_width = width;
13136
13415
  this.#update_column_widths();
13137
13416
  });
13138
13417
  return header;
13139
13418
  });
13419
+ this.#header.fields = headers;
13420
+ }
13140
13421
  this.#update_column_widths();
13141
13422
 
13142
13423
  for (let i = 0; i < this.#child_box.childElementCount; i++)
13143
13424
  (this.#child_box.children[i] as ListRow<R, T, A, S>).columns_changed();
13144
13425
  }
13145
13426
 
13427
+ /**Gives the auto width columns their current width, so resizing one column does not resize the others
13428
+ * Only measures while there are auto width columns, so after the first resize a move does no layout here*/
13429
+ #freeze_auto_widths(headers: HeaderField[]) {
13430
+ const auto = this.#root.columns_visible.flatMap((key, i) => {
13431
+ const col = this.#root.columns.get(key)!;
13432
+ return col.fixed_width === undefined && !col.init_width ? [i] : [];
13433
+ });
13434
+ //Measured before any is set, setting one would change the layout of the rest
13435
+ const widths = auto.map((i) => px_to_rem(headers[i].offsetWidth));
13436
+ auto.forEach((i, j) => {
13437
+ this.#root.columns.get(this.#root.columns_visible[i])!.init_width =
13438
+ widths[j];
13439
+ });
13440
+ }
13441
+
13146
13442
  #update_column_widths() {
13147
13443
  const widths: string[] = this.#root.columns_visible.map((key) => {
13148
13444
  const col = this.#root.columns.get(key)!;
@@ -13154,7 +13450,17 @@ class Container<
13154
13450
  }
13155
13451
  return "auto";
13156
13452
  });
13157
- if (this.#root.sub_rows) widths.unshift("min-content");
13453
+ //The key fields get the width instead of the column, so it never gets smaller than its widest key field minimum
13454
+ if (this.#root.sub_rows) widths.unshift("max-content");
13455
+ this.#box.classList.toggle("key-sized", Boolean(this.#key_width));
13456
+ if (this.#key_width)
13457
+ this.#box.style.setProperty(
13458
+ "--list-key-width",
13459
+ `${Math.max(this.#key_width, 1)}rem`,
13460
+ );
13461
+ else this.#box.style.removeProperty("--list-key-width");
13462
+ if (this.#selection) widths.unshift("var(--list-check-width)");
13463
+ if (this.#root.reorder) widths.unshift("var(--list-drag-width)");
13158
13464
  this.#box.style.gridTemplateColumns = widths.join(" ");
13159
13465
  }
13160
13466
 
@@ -13210,10 +13516,28 @@ class Container<
13210
13516
  this.#root.sub_rows,
13211
13517
  this.#parent,
13212
13518
  );
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
- });
13519
+ list_rows_apply(this.#root, this.#parent, this.#child_box, rows);
13520
+ }
13521
+
13522
+ /**Binds the selection to an array state of keys, which can be shared with other lists and elements
13523
+ * The list shows the keys that have a visible row, and only writes the state on user actions,
13524
+ * with array write instructions, so it must be a state that applies them, like a local writable state
13525
+ * Without a state the selection is kept in a state of the list that nobody else can reach
13526
+ * Needs the selection option */
13527
+ bind(opts: { selection?: StateREAW<K[], any, K[]> }): this {
13528
+ const selection = this.#selection;
13529
+ if (!selection) {
13530
+ if (opts.selection) console.error("List has no selection option", this);
13531
+ return this;
13532
+ }
13533
+ if (this.#selection_sub) this.detach_state(this.#selection_sub);
13534
+ const target = opts.selection ?? state.ok_w<K[]>([]);
13535
+ selection.target = target;
13536
+ this.#selection_sub = this.attach_state(
13537
+ target as StateREAW<K[]>,
13538
+ (value: Result<K[], string>) => selection.apply(value),
13539
+ );
13540
+ return this;
13217
13541
  }
13218
13542
  }
13219
13543
  define_element(Container);
@@ -13223,23 +13547,551 @@ export function container<
13223
13547
  T extends {},
13224
13548
  S extends boolean = false,
13225
13549
  R = ListTypeExtract<A>,
13550
+ K = R,
13226
13551
  >(
13227
- columns: { [K in keyof T]: ListColumnOptions<T[K], any> },
13552
+ columns: { [C in keyof T]: ListColumnOptions<T[C], any> },
13228
13553
  transform: ListRowTransformer<R, NoInfer<T>, A, S>,
13229
13554
  rows: A,
13230
- options?: ContainerOptions<S>,
13555
+ options?: ContainerOptions<S, R, K>,
13231
13556
  ) {
13232
- return new Container<A, T, S, R>(columns, transform, rows, options);
13557
+ return new Container<A, T, S, R, K>(columns, transform, rows, options);
13558
+ }
13559
+ ```
13560
+
13561
+ ## package-ui/list/drag.scss
13562
+
13563
+ ```scss
13564
+ @use "../icons/mixins" as icons;
13565
+
13566
+ list-dragfield {
13567
+ position: sticky;
13568
+ left: 0;
13569
+ z-index: 2;
13570
+ display: flex;
13571
+ align-items: center;
13572
+ justify-content: center;
13573
+ box-sizing: border-box;
13574
+ min-height: var(--list-drag-width);
13575
+ user-select: none;
13576
+ //The handle drags, it does not pan the list
13577
+ touch-action: none;
13578
+ border-right: 1px solid var(--list-colors-border-column);
13579
+
13580
+ &::before {
13581
+ @include icons.material-symbols-rounded;
13582
+ font-size: 1.2rem;
13583
+ line-height: 1;
13584
+ color: var(--list-colors-icon-drag);
13585
+
13586
+ .touch & {
13587
+ font-size: 1.8rem;
13588
+ }
13589
+ }
13590
+
13591
+ //Glyph of the icon font, drag_indicator
13592
+ list-row.movable > div > & {
13593
+ cursor: grab;
13594
+
13595
+ &::before {
13596
+ content: "\e945";
13597
+ }
13598
+ }
13599
+ }
13600
+
13601
+ //Rows being dragged are dimmed where they are until the move comes back from the state
13602
+ list-row.dragging > div > * {
13603
+ opacity: 0.4;
13604
+ }
13605
+
13606
+ //Shows where dragged rows are dropped, a line between rows or a box around the row they go into
13607
+ list-container > span.list-drop {
13608
+ display: block;
13609
+ position: absolute;
13610
+ //Above the rows and their sticky cells, below the header the rows scroll under
13611
+ z-index: 998;
13612
+ pointer-events: none;
13613
+ box-sizing: border-box;
13614
+ //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
13615
+ background-color: var(--list-colors-focus-normal);
13616
+
13617
+ &[hidden] {
13618
+ display: none;
13619
+ }
13620
+
13621
+ &.into {
13622
+ background-color: transparent;
13623
+ border: 2px solid var(--list-colors-focus-normal);
13624
+ }
13625
+ }
13626
+
13627
+ //Follows the pointer while dragging, with what is dragged, it is in the body to be above all lists
13628
+ span.list-drag-label {
13629
+ display: block;
13630
+ position: fixed;
13631
+ z-index: 10000;
13632
+ pointer-events: none;
13633
+ padding: 0.2rem 0.5rem;
13634
+ border-radius: 0.3rem;
13635
+ font-size: 0.9rem;
13636
+ white-space: nowrap;
13637
+ color: var(--list-colors-text-field);
13638
+ background-color: var(--list-colors-background-row_even);
13639
+ border: 1px solid var(--list-colors-border-header);
13640
+ box-shadow: 0 0.1rem 0.3rem var(--list-colors-border-header);
13641
+
13642
+ //Nowhere to drop
13643
+ &.none {
13644
+ opacity: 0.5;
13645
+ }
13233
13646
  }
13234
13647
  ```
13235
13648
 
13236
- ## package-ui/src/list/error.scss
13649
+ ## package-ui/list/drag.ts
13650
+
13651
+ ```ts
13652
+ import { Base, define_element } from "#base";
13653
+ import type { Option, Result } from "@chocbite/ts-lib/result";
13654
+ import { state, type State, type StateREAW } from "@chocbite/ts-lib/state";
13655
+ import "./drag.scss";
13656
+ import type { ListWarn } from "./warn";
13657
+
13658
+ /**What moving needs from a row */
13659
+ export interface ListMovableRow extends HTMLElement {
13660
+ readonly data: unknown;
13661
+ /**Moving of the list the row is in */
13662
+ readonly reorder: object | undefined;
13663
+ readonly parent_rows: unknown;
13664
+ readonly parent_row: ListMovableRow | undefined;
13665
+ readonly next_row: ListMovableRow | undefined;
13666
+ readonly first_sub_row: ListMovableRow | undefined;
13667
+ readonly movable: boolean;
13668
+ readonly droppable: boolean;
13669
+ readonly selected: boolean;
13670
+ readonly multi_selected: boolean;
13671
+ readonly label: string;
13672
+ readonly anchor: Element | undefined;
13673
+ readonly index: number;
13674
+ readonly openable: boolean;
13675
+ open: boolean;
13676
+ drop_rows(): unknown;
13677
+ focus_cell(): void;
13678
+ }
13679
+
13680
+ type AnyRow = ListMovableRow;
13681
+ type Rows = StateREAW<unknown[], Option<{}>, unknown[]>;
13682
+
13683
+ /**Lists that rows can be dragged between, rows are given from one list to another of the same group
13684
+ * The type is checked both ways, so only lists with exactly the same row type can join */
13685
+ export class ListDragGroup<R> {
13686
+ declare readonly type: (value: R) => R;
13687
+ }
13688
+
13689
+ /**Where rows are dropped, given to can_drop */
13690
+ export interface ListDropTarget<R> {
13691
+ /**Row the rows become sub rows of, undefined for the top level */
13692
+ parent: R | undefined;
13693
+ /**List the rows are dropped in */
13694
+ list: HTMLElement;
13695
+ }
13696
+
13697
+ export interface ListReorderOptions<R> {
13698
+ /**Lists of the same group can give rows to each other, without a group rows only move inside the list */
13699
+ group?: ListDragGroup<R>;
13700
+ /**Whether the row data can be dropped at the target, all dropped rows must be allowed for a drop */
13701
+ can_drop?(data: R, target: ListDropTarget<R>): boolean;
13702
+ /**Rows moved to another parent or list are only inserted there, not removed from where they came from
13703
+ * For apps that remove the rows themselves when they are added, set on the list the rows are dragged from
13704
+ * Moves inside one parent are still one move write */
13705
+ no_remove?: boolean;
13706
+ }
13707
+
13708
+ /**Drag handle cell in front of a row, empty in the header */
13709
+ export class ListDragField extends Base {
13710
+ static element_name() {
13711
+ return "dragfield";
13712
+ }
13713
+ static element_name_space() {
13714
+ return "list";
13715
+ }
13716
+ }
13717
+ define_element(ListDragField);
13718
+
13719
+ /**Place rows are dropped at, before or after a row, or into it as its last sub rows */
13720
+ export interface ListDropPlace {
13721
+ row: AnyRow;
13722
+ mode: "before" | "after" | "into";
13723
+ }
13724
+
13725
+ /**Pixels the pointer moves before a press on the handle becomes a drag */
13726
+ const DRAG_THRESHOLD = 5;
13727
+ /**Milliseconds hovering into a closed row before it opens */
13728
+ const OPEN_DELAY = 600;
13729
+ /**Thickness of the drop line in pixels, it is drawn inside the row it is about */
13730
+ const LINE_WIDTH = 5;
13731
+ /**Distance from the top or bottom edge of a list in pixels where dragging scrolls it */
13732
+ const SCROLL_EDGE = 32;
13733
+
13734
+ /**A rows state that the list can write moves to */
13735
+ function writable(rows: unknown): rows is Rows {
13736
+ return state.is.state(rows) && (rows as State<unknown>).writable;
13737
+ }
13738
+
13739
+ /**Moving rows of a list by dragging their handle or with alt and the arrow keys
13740
+ * Like the selection, moves are only written to the rows states, the rows move when the states give the change back */
13741
+ export class ListReorder<R> {
13742
+ readonly group: ListDragGroup<R>;
13743
+ readonly container: HTMLElement;
13744
+ #options: ListReorderOptions<R>;
13745
+ #warn: ListWarn;
13746
+ /**Shows where rows are dropped in this list */
13747
+ #indicator: HTMLSpanElement;
13748
+
13749
+ constructor(
13750
+ container: HTMLElement,
13751
+ options: ListReorderOptions<R>,
13752
+ warn: ListWarn,
13753
+ ) {
13754
+ this.container = container;
13755
+ this.group = options.group ?? new ListDragGroup<R>();
13756
+ this.#options = options;
13757
+ this.#warn = warn;
13758
+ this.#indicator = container.appendChild(document.createElement("span"));
13759
+ this.#indicator.className = "list-drop";
13760
+ this.#indicator.hidden = true;
13761
+ }
13762
+
13763
+ /**Makes the handle cell of a row */
13764
+ handle(row: AnyRow): ListDragField {
13765
+ const handle = new ListDragField();
13766
+ handle.onpointerdown = (e) => this.#press(row, handle, e);
13767
+ return handle;
13768
+ }
13769
+
13770
+ // _____ _____ _____
13771
+ // | __ \| __ \ /\ / ____|
13772
+ // | | | | |__) | / \ | | __
13773
+ // | | | | _ / / /\ \| | |_ |
13774
+ // | |__| | | \ \ / ____ \ |__| |
13775
+ // |_____/|_| \_\/_/ \_\_____|
13776
+
13777
+ #press(row: AnyRow, handle: ListDragField, e: PointerEvent) {
13778
+ if (e.button !== 0 || !row.movable) return;
13779
+ e.preventDefault();
13780
+ handle.setPointerCapture(e.pointerId);
13781
+ const start_x = e.clientX;
13782
+ const start_y = e.clientY;
13783
+ let x = start_x;
13784
+ let y = start_y;
13785
+ let rows: AnyRow[] | undefined;
13786
+ let place: ListDropPlace | undefined;
13787
+ let shown: ListReorder<R> | undefined;
13788
+ let frame = 0;
13789
+ let open_timer = 0;
13790
+ let open_row: AnyRow | undefined;
13791
+ const label = document.createElement("span");
13792
+ label.className = "list-drag-label";
13793
+
13794
+ const update = () => {
13795
+ frame = requestAnimationFrame(update);
13796
+ this.#scroll(x, y);
13797
+ const next = this.#place(x, y, rows!);
13798
+ shown?.indicate(undefined);
13799
+ shown = next?.row.reorder as ListReorder<R> | undefined;
13800
+ shown?.indicate(next);
13801
+ place = next;
13802
+ label.style.left = x + 12 + "px";
13803
+ label.style.top = y + 12 + "px";
13804
+ label.classList.toggle("none", !next);
13805
+ //Hovering into a closed row opens it after a moment
13806
+ const hover =
13807
+ next?.mode === "into" && !next.row.open ? next.row : undefined;
13808
+ if (hover !== open_row) {
13809
+ clearTimeout(open_timer);
13810
+ open_row = hover;
13811
+ if (hover)
13812
+ open_timer = window.setTimeout(() => (hover.open = true), OPEN_DELAY);
13813
+ }
13814
+ };
13815
+ const end = (drop: boolean) => {
13816
+ handle.onpointermove = null;
13817
+ handle.onpointerup = null;
13818
+ handle.onpointercancel = null;
13819
+ handle.onlostpointercapture = null;
13820
+ document.removeEventListener("keydown", escape, true);
13821
+ cancelAnimationFrame(frame);
13822
+ clearTimeout(open_timer);
13823
+ shown?.indicate(undefined);
13824
+ label.remove();
13825
+ if (!rows) return;
13826
+ for (const dragged of rows) dragged.classList.remove("dragging");
13827
+ if (drop && place) void this.#drop(rows, place);
13828
+ };
13829
+ const escape = (ev: KeyboardEvent) => {
13830
+ if (ev.key !== "Escape") return;
13831
+ ev.preventDefault();
13832
+ ev.stopPropagation();
13833
+ end(false);
13834
+ };
13835
+
13836
+ handle.onpointermove = (ev) => {
13837
+ x = ev.clientX;
13838
+ y = ev.clientY;
13839
+ if (rows) return;
13840
+ if (Math.hypot(x - start_x, y - start_y) < DRAG_THRESHOLD) return;
13841
+ rows = this.#dragged(row);
13842
+ for (const dragged of rows) dragged.classList.add("dragging");
13843
+ label.textContent =
13844
+ rows.length > 1 ? rows.length + " rows" : row.label || "1 row";
13845
+ //In the body, a list is a stacking context, so a label in it would be covered by the lists after it
13846
+ document.body.appendChild(label);
13847
+ document.addEventListener("keydown", escape, true);
13848
+ update();
13849
+ };
13850
+ handle.onpointerup = () => end(true);
13851
+ handle.onpointercancel = () => end(false);
13852
+ handle.onlostpointercapture = () => end(false);
13853
+ }
13854
+
13855
+ /**Rows a drag from the row moves, the visible selected movable rows when the row is selected in multi mode
13856
+ * Sub rows of a dragged row move with it, so they are left out */
13857
+ #dragged(row: AnyRow): AnyRow[] {
13858
+ if (!row.selected || !row.multi_selected) return [row];
13859
+ const rows = [
13860
+ ...this.container.querySelectorAll<AnyRow>("list-row.selected.movable"),
13861
+ ].filter((selected) => selected.reorder === this);
13862
+ const dragged = new Set(rows);
13863
+ return rows.filter((selected) => {
13864
+ for (let parent = selected.parent_row; parent; parent = parent.parent_row)
13865
+ if (dragged.has(parent)) return false;
13866
+ return true;
13867
+ });
13868
+ }
13869
+
13870
+ /**Scrolls the list under the pointer when the pointer is near its top or bottom edge */
13871
+ #scroll(x: number, y: number) {
13872
+ const list = document
13873
+ .elementFromPoint(x, y)
13874
+ ?.closest<HTMLElement>("list-container");
13875
+ const target = list ?? this.container;
13876
+ const rect = target.getBoundingClientRect();
13877
+ if (x < rect.left || x > rect.right) return;
13878
+ if (y < rect.top + SCROLL_EDGE)
13879
+ target.scrollTop -= Math.ceil((rect.top + SCROLL_EDGE - y) / 4);
13880
+ else if (y > rect.bottom - SCROLL_EDGE)
13881
+ target.scrollTop += Math.ceil((y - rect.bottom + SCROLL_EDGE) / 4);
13882
+ }
13883
+
13884
+ // _____ _____ ____ _____
13885
+ // | __ \| __ \ / __ \| __ \
13886
+ // | | | | |__) | | | | |__) |
13887
+ // | | | | _ /| | | | ___/
13888
+ // | |__| | | \ \| |__| | |
13889
+ // |_____/|_| \_\\____/|_|
13890
+
13891
+ /**The place under the pointer, undefined when the rows can not be dropped there */
13892
+ #place(x: number, y: number, rows: AnyRow[]): ListDropPlace | undefined {
13893
+ const element = document.elementFromPoint(x, y);
13894
+ let row = element?.closest<AnyRow>("list-row") ?? undefined;
13895
+ let mode: ListDropPlace["mode"];
13896
+ if (!row) {
13897
+ //Below the last row of a list drops after it
13898
+ const list = element?.closest<HTMLElement>("list-container");
13899
+ const last = list?.querySelector<AnyRow>(
13900
+ ":scope > div > div > list-row:last-child",
13901
+ );
13902
+ if (!last?.anchor || y < last.anchor.getBoundingClientRect().bottom)
13903
+ return undefined;
13904
+ row = last;
13905
+ mode = "after";
13906
+ } else {
13907
+ const rect = row.anchor?.getBoundingClientRect();
13908
+ if (!rect) return undefined;
13909
+ const part = (y - rect.top) / rect.height;
13910
+ if (row.openable)
13911
+ mode = part < 0.25 ? "before" : part > 0.75 ? "after" : "into";
13912
+ else mode = part < 0.5 ? "before" : "after";
13913
+ }
13914
+ const reorder = row.reorder as ListReorder<R> | undefined;
13915
+ if (reorder?.group !== this.group) return undefined;
13916
+ //After an open row is before its first sub row
13917
+ if (mode === "after" && row.open) {
13918
+ const first = row.first_sub_row;
13919
+ if (first) {
13920
+ row = first;
13921
+ mode = "before";
13922
+ }
13923
+ }
13924
+ const place: ListDropPlace = { row, mode };
13925
+ return reorder.#allowed(place, rows) ? place : undefined;
13926
+ }
13927
+
13928
+ /**Whether the rows can be dropped at the place of this list */
13929
+ #allowed(place: ListDropPlace, rows: AnyRow[]): boolean {
13930
+ const parent = place.mode === "into" ? place.row : place.row.parent_row;
13931
+ if (place.mode !== "into" && rows.includes(place.row)) return false;
13932
+ //Not into itself or its own sub rows
13933
+ for (let up: AnyRow | undefined = parent; up; up = up.parent_row)
13934
+ if (rows.includes(up)) return false;
13935
+ if (place.mode === "into" ? !place.row.droppable : !place.row.movable)
13936
+ return false;
13937
+ const options = this.#options;
13938
+ if (!options.can_drop) return true;
13939
+ const target: ListDropTarget<R> = {
13940
+ parent: parent?.data as R | undefined,
13941
+ list: this.container,
13942
+ };
13943
+ return rows.every((row) => options.can_drop!(row.data as R, target));
13944
+ }
13945
+
13946
+ /**Shows where rows are dropped in this list, undefined hides it */
13947
+ indicate(place: ListDropPlace | undefined) {
13948
+ const indicator = this.#indicator;
13949
+ const cell = place?.row.anchor;
13950
+ if (!place || !cell) {
13951
+ indicator.hidden = true;
13952
+ return;
13953
+ }
13954
+ const list = this.container;
13955
+ const box = list.getBoundingClientRect();
13956
+ const rect = cell.getBoundingClientRect();
13957
+ const top = rect.top - box.top + list.scrollTop;
13958
+ //A line starts at the tree indent of the row, so the depth the rows land at shows,
13959
+ //after the last sub row of an open row and before the next row are at the same height
13960
+ const opener =
13961
+ place.mode === "into"
13962
+ ? undefined
13963
+ : place.row.querySelector(
13964
+ ":scope > div > list-keyfield > span:not(.text)",
13965
+ );
13966
+ const left =
13967
+ (opener ?? cell).getBoundingClientRect().left -
13968
+ box.left +
13969
+ list.scrollLeft;
13970
+ //Ends at the right edge of the rows, not the scroll width of the list, which includes the indicator itself,
13971
+ //rounded down so it never makes the list wider and flashes a scrollbar
13972
+ const grid = list.querySelector(":scope > div") ?? list;
13973
+ const right =
13974
+ grid.getBoundingClientRect().right - box.left + list.scrollLeft;
13975
+ indicator.hidden = false;
13976
+ indicator.className = "list-drop " + place.mode;
13977
+ indicator.style.left = left + "px";
13978
+ indicator.style.width = Math.max(Math.floor(right - left), 0) + "px";
13979
+ //Drawn inside the row it is about, at its top or bottom edge
13980
+ indicator.style.top =
13981
+ (place.mode === "after" ? top + rect.height - LINE_WIDTH : top) + "px";
13982
+ indicator.style.height =
13983
+ (place.mode === "into" ? rect.height : LINE_WIDTH) + "px";
13984
+ }
13985
+
13986
+ // __ __ ______ ________
13987
+ // | \/ |/ __ \ \ / / ____|
13988
+ // | \ / | | | \ \ / /| |__
13989
+ // | |\/| | | | |\ \/ / | __|
13990
+ // | | | | |__| | \ / | |____
13991
+ // |_| |_|\____/ \/ |______|
13992
+
13993
+ /**Writes the moves of the rows to the place, rows next to each other in one parent move with one write
13994
+ * Moving to another parent inserts first and removes after, so a failure can leave a row twice but never loses it */
13995
+ async #drop(rows: AnyRow[], place: ListDropPlace) {
13996
+ const errors: string[] = [];
13997
+ const into = place.mode === "into" ? place.row : undefined;
13998
+ //Rows are dropped in order before this row, undefined appends to the parent
13999
+ const before: AnyRow | undefined =
14000
+ place.mode === "before"
14001
+ ? place.row
14002
+ : place.mode === "after"
14003
+ ? place.row.next_row
14004
+ : undefined;
14005
+ const target_box =
14006
+ place.mode === "into" ? undefined : place.row.parentElement;
14007
+ const target_rows = into ? into.drop_rows() : place.row.parent_rows;
14008
+ if (!writable(target_rows)) return;
14009
+ for (const chunk of this.#chunks(rows)) {
14010
+ const first = chunk[0];
14011
+ const source_box = first.parentElement;
14012
+ const same = into ? first.parent_row === into : source_box === target_box;
14013
+ if (same) {
14014
+ const from = first.index;
14015
+ const end = before ? before.index : source_box!.childElementCount;
14016
+ const to = from < end ? end - chunk.length : end;
14017
+ if (from === to) continue;
14018
+ const result = await target_rows.write(
14019
+ state.a.write.move(from, to, chunk.length),
14020
+ );
14021
+ if (result.err) errors.push(result.error);
14022
+ continue;
14023
+ }
14024
+ const items = chunk.map((row) => row.data);
14025
+ const inserted: Result<void, string> = await target_rows.write(
14026
+ before
14027
+ ? state.a.write.splice(before.index, 0, ...items)
14028
+ : state.a.write.push(...items),
14029
+ );
14030
+ if (inserted.err) {
14031
+ errors.push(inserted.error);
14032
+ continue;
14033
+ }
14034
+ //The app already took the rows out of the source while inserting
14035
+ if (this.#options.no_remove || !first.parentElement) continue;
14036
+ const source_rows = first.parent_rows;
14037
+ if (!writable(source_rows)) continue;
14038
+ const removed = await source_rows.write(
14039
+ state.a.write.splice(first.index, chunk.length),
14040
+ );
14041
+ if (removed.err) errors.push(removed.error);
14042
+ }
14043
+ if (into && errors.length === 0) into.open = true;
14044
+ if (errors.length)
14045
+ (place.row.reorder as ListReorder<R> | undefined)?.warn(
14046
+ place.row,
14047
+ [...new Set(errors)].join("\n"),
14048
+ );
14049
+ }
14050
+
14051
+ /**Splits rows in display order into runs of rows next to each other in one parent */
14052
+ #chunks(rows: AnyRow[]): AnyRow[][] {
14053
+ const chunks: AnyRow[][] = [];
14054
+ for (const row of rows) {
14055
+ const last = chunks[chunks.length - 1]?.at(-1);
14056
+ if (
14057
+ last &&
14058
+ last.parentElement === row.parentElement &&
14059
+ last.next_row === row
14060
+ )
14061
+ chunks[chunks.length - 1].push(row);
14062
+ else chunks.push([row]);
14063
+ }
14064
+ return chunks;
14065
+ }
14066
+
14067
+ /**Shows why a move failed at the row, in the list of the row */
14068
+ warn(row: AnyRow, message: string) {
14069
+ this.#warn.show(row.anchor, message);
14070
+ }
14071
+
14072
+ /**Moves the row one place up or down in its parent, from the keyboard, the row keeps the focus */
14073
+ async key_move(row: AnyRow, direction: -1 | 1) {
14074
+ const rows = row.parent_rows;
14075
+ if (!row.movable || !writable(rows)) return;
14076
+ const from = row.index;
14077
+ const to = from + direction;
14078
+ if (to < 0 || to >= row.parentElement!.childElementCount) return;
14079
+ const result = await rows.write(state.a.write.move(from, to, 1));
14080
+ //Moving takes the row out of the document for a moment, which loses the focus
14081
+ row.focus_cell();
14082
+ if (result.err) this.warn(row, result.error);
14083
+ }
14084
+ }
14085
+ ```
14086
+
14087
+ ## package-ui/list/error.scss
13237
14088
 
13238
14089
  ```scss
13239
14090
  list-rowserror {
13240
14091
  display: contents;
13241
14092
 
13242
- > list-error {
14093
+ > list-error,
14094
+ > list-keyfield {
13243
14095
  background-color: var(--list-colors-background-row_odd);
13244
14096
  }
13245
14097
  }
@@ -13258,15 +14110,10 @@ list-error {
13258
14110
  .touch & {
13259
14111
  min-height: var(--list-size-touch_row_min);
13260
14112
  }
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
14113
  }
13267
14114
  ```
13268
14115
 
13269
- ## package-ui/src/list/error.ts
14116
+ ## package-ui/list/error.ts
13270
14117
 
13271
14118
  ```ts
13272
14119
  import { Base, define_element } from "#base";
@@ -13309,8 +14156,9 @@ export class ListRowsError<A extends ListType<any>>
13309
14156
  super();
13310
14157
  this.#parent = parent;
13311
14158
  this.depth = parent.depth + 1;
13312
- if (sub_rows) this.appendChild(new ListKeyField(this));
13313
- this.appendChild(this.#text);
14159
+ //With sub rows the text is in the key field after the tree lines, it runs from the key column to the end
14160
+ if (sub_rows) this.appendChild(new ListKeyField(this)).tail = this.#text;
14161
+ else this.appendChild(this.#text);
13314
14162
  }
13315
14163
 
13316
14164
  set text(value: string) {
@@ -13355,7 +14203,7 @@ export function list_rows_error_update<A extends ListType<any>>(
13355
14203
  }
13356
14204
  ```
13357
14205
 
13358
- ## package-ui/src/list/field.scss
14206
+ ## package-ui/list/field.scss
13359
14207
 
13360
14208
  ```scss
13361
14209
  list-textfield,
@@ -13385,7 +14233,7 @@ list-numberfield {
13385
14233
  }
13386
14234
  ```
13387
14235
 
13388
- ## package-ui/src/list/field.ts
14236
+ ## package-ui/list/field.ts
13389
14237
 
13390
14238
  ```ts
13391
14239
  import { Base, define_element } from "#base";
@@ -13470,7 +14318,7 @@ export function node_field<T extends Node>(node: T) {
13470
14318
  }
13471
14319
  ```
13472
14320
 
13473
- ## package-ui/src/list/globals.d.ts
14321
+ ## package-ui/list/globals.d.ts
13474
14322
 
13475
14323
  ```ts
13476
14324
  declare module "*.scss" {
@@ -13479,10 +14327,11 @@ declare module "*.scss" {
13479
14327
  }
13480
14328
  ```
13481
14329
 
13482
- ## package-ui/src/list/index.ts
14330
+ ## package-ui/list/index.ts
13483
14331
 
13484
14332
  ```ts
13485
14333
  import { container } from "./container";
14334
+ import { ListDragGroup } from "./drag";
13486
14335
  import { node_field, number_field, text_field } from "./field";
13487
14336
  import { column, column_string } from "./types";
13488
14337
 
@@ -13493,23 +14342,54 @@ export const list = {
13493
14342
  text_field,
13494
14343
  number_field,
13495
14344
  node_field,
14345
+ /**Group of lists that can give rows to each other by dragging, all lists of a group must have the same row type */
14346
+ drag_group<R>(): ListDragGroup<R> {
14347
+ return new ListDragGroup<R>();
14348
+ },
13496
14349
  };
13497
14350
 
13498
14351
  export { ListField } from "./field";
14352
+ export type { ListDragGroup, ListDropTarget, ListReorderOptions } from "./drag";
13499
14353
 
13500
14354
  export default list;
13501
14355
  ```
13502
14356
 
13503
- ## package-ui/src/list/key_field.scss
14357
+ ## package-ui/list/key_field.scss
13504
14358
 
13505
14359
  ```scss
13506
14360
  @use "../icons/mixins" as icons;
13507
14361
 
13508
14362
  list-keyfield {
13509
14363
  --list-row-size: var(--list-size-row_min);
14364
+ //Width of an indent line box, the space after it and the width of the opener
14365
+ //The vertical lines sit at the right edge of an indent box and the middle of the opener, so they line up between depths
14366
+ --list-key-indent: calc(var(--list-row-size) / 2);
14367
+ --list-key-indent-space: calc(var(--list-row-size) / 2 - 0.1rem);
14368
+ --list-key-opener: var(--list-row-size);
14369
+ --list-key-icon: calc(var(--list-row-size) - 0.4rem);
13510
14370
  .touch & {
13511
14371
  --list-row-size: var(--list-size-touch_row_min);
13512
- }
14372
+ --list-key-indent: calc(var(--list-row-size) / 2 - 0.3rem + 1.5px);
14373
+ --list-key-indent-space: calc(var(--list-row-size) / 2 - 0.4rem);
14374
+ --list-key-opener: calc(var(--list-row-size) - 0.4rem);
14375
+ --list-key-icon: calc(var(--list-row-size) - 1.1rem);
14376
+ }
14377
+ //Smallest width of the key column when resized, the indents, the opener, the icon with its padding, 3rem of the text and the border
14378
+ --list-key-min-icon: 0px;
14379
+ --list-key-min-text: 0px;
14380
+ &.has-icon {
14381
+ --list-key-min-icon: calc(var(--list-key-icon) + 0.5rem);
14382
+ }
14383
+ &.has-text,
14384
+ &.tail {
14385
+ --list-key-min-text: 4rem;
14386
+ }
14387
+ --list-key-min: calc(
14388
+ var(--list-key-depth) *
14389
+ (var(--list-key-indent) + 1px + var(--list-key-indent-space)) +
14390
+ var(--list-key-opener) + var(--list-key-min-icon) +
14391
+ var(--list-key-min-text) + 1px
14392
+ );
13513
14393
 
13514
14394
  position: sticky;
13515
14395
  left: 0;
@@ -13520,7 +14400,7 @@ list-keyfield {
13520
14400
  border-right: 1px solid var(--list-colors-border-column);
13521
14401
  background-color: var(--list-colors-background-row_odd);
13522
14402
 
13523
- &:focus-visible::before {
14403
+ &:focus-visible:not(.click-focus)::before {
13524
14404
  content: "";
13525
14405
  position: absolute;
13526
14406
  width: 100%;
@@ -13531,40 +14411,49 @@ list-keyfield {
13531
14411
  pointer-events: none;
13532
14412
  }
13533
14413
 
14414
+ //Line from the middle of an open row down to its sub rows, at the line of the sub rows
14415
+ list-row.open > div > & {
14416
+ background-image: linear-gradient(
14417
+ var(--list-colors-border-column),
14418
+ var(--list-colors-border-column)
14419
+ );
14420
+ background-repeat: no-repeat;
14421
+ background-size: 1px 50%;
14422
+ background-position: calc(
14423
+ (var(--list-key-depth) + 1) *
14424
+ (var(--list-key-indent) + 1px + var(--list-key-indent-space)) +
14425
+ var(--list-key-opener) / 2
14426
+ )
14427
+ 100%;
14428
+ }
14429
+
13534
14430
  > div {
13535
- width: calc(var(--list-row-size) / 2);
13536
- margin-right: calc(var(--list-row-size) / 2 - 0.1rem);
14431
+ flex-shrink: 0;
14432
+ width: var(--list-key-indent);
14433
+ margin-right: var(--list-key-indent-space);
13537
14434
  height: 100%;
13538
14435
  position: relative;
13539
14436
  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
14437
  }
13546
14438
 
13547
14439
  &.openable {
13548
- > span {
14440
+ > span.opener {
13549
14441
  > div {
13550
14442
  display: block;
13551
14443
  }
13552
14444
  }
13553
14445
  }
13554
14446
 
13555
- > span {
14447
+ > span.opener {
13556
14448
  position: relative;
14449
+ flex-shrink: 0;
13557
14450
  display: flex;
13558
14451
  align-items: center;
13559
14452
  justify-content: flex-start;
13560
14453
  height: 100%;
13561
14454
  min-height: var(--list-row-size);
13562
14455
  background-color: inherit;
13563
- width: var(--list-row-size);
13564
-
13565
- .touch & {
13566
- width: calc(var(--list-row-size) - 0.4rem);
13567
- }
14456
+ width: var(--list-key-opener);
13568
14457
 
13569
14458
  &::before {
13570
14459
  content: "";
@@ -13580,14 +14469,14 @@ list-keyfield {
13580
14469
  list-rowserror > &,
13581
14470
  list-row:not(.addrow) > span > list-row:last-child > * > &,
13582
14471
  div:not(.addrow) > div > list-row:last-child > * > & {
13583
- height: calc(var(--list-row-size) / 2);
14472
+ height: 50%;
13584
14473
  }
13585
14474
  }
13586
14475
  &::after {
13587
14476
  content: "";
13588
14477
  display: block;
13589
14478
  position: absolute;
13590
- height: calc(var(--list-row-size) / 2);
14479
+ height: 50%;
13591
14480
  width: 50%;
13592
14481
  top: 0;
13593
14482
  left: 50%;
@@ -13640,30 +14529,55 @@ list-keyfield {
13640
14529
  }
13641
14530
  }
13642
14531
 
13643
- svg {
14532
+ //Icon and text are centered instead of stretched, so in a tall row the line down to the sub rows shows below them
14533
+ > span.text {
14534
+ display: flex;
14535
+ align-self: center;
14536
+ align-items: center;
14537
+ min-width: 0;
14538
+ color: var(--list-colors-text-key_field);
14539
+ padding: 0 0.25rem;
14540
+ min-height: var(--list-row-size);
14541
+ //Covers the line down to the sub rows, it would run through the text without an icon
14542
+ background-color: inherit;
14543
+ }
14544
+
14545
+ > svg {
13644
14546
  position: relative;
14547
+ flex-shrink: 0;
14548
+ align-self: center;
14549
+ //Covers the line down to the sub rows, it would show through the transparent parts of the icon
14550
+ background-color: inherit;
13645
14551
  fill: var(--list-colors-icon-key_icon);
13646
14552
  padding: 0.25rem;
13647
- width: calc(var(--list-row-size) - 0.4rem);
14553
+ width: var(--list-key-icon);
13648
14554
  height: auto;
14555
+ }
13649
14556
 
13650
- .touch & {
13651
- width: calc(var(--list-row-size) - 1.1rem);
13652
- height: auto;
14557
+ //Runs into the value columns, the tail takes the space of the line after the text
14558
+ &.tail {
14559
+ grid-column: 1 / -1;
14560
+ border-right: none;
14561
+
14562
+ > :last-child {
14563
+ flex-grow: 1;
14564
+ }
14565
+ &::after {
14566
+ display: none;
13653
14567
  }
13654
14568
  }
13655
14569
 
13656
14570
  &::after {
13657
14571
  content: "";
14572
+ align-self: flex-start;
13658
14573
  height: 50%;
13659
14574
  border-bottom: 1px solid var(--list-colors-border-column);
13660
14575
  flex-grow: 1;
13661
- height: calc(var(--list-row-size) / 2);
13662
14576
  }
13663
14577
  }
13664
14578
  ```
13665
14579
 
13666
- ## package-ui/src/list/key_field.ts
14580
+ ## package-ui/list/key_field.ts
13667
14581
 
13668
14582
  ```ts
13669
14583
  import { Base, define_element } from "#base";
@@ -13675,7 +14589,10 @@ import "./key_field.scss";
13675
14589
  import type { ListRowParent, ListType } from "./types";
13676
14590
 
13677
14591
  export interface ListKeyFieldOptions {
14592
+ /**Icon shown after the sub row opener */
13678
14593
  icon?: SVGFunc | State<SVGFunc>;
14594
+ /**Text shown after the icon, an error of a state is shown as the text */
14595
+ text?: string | State<string>;
13679
14596
  }
13680
14597
 
13681
14598
  export class ListKeyField<A extends ListType<any>> extends Base {
@@ -13689,12 +14606,16 @@ export class ListKeyField<A extends ListType<any>> extends Base {
13689
14606
  #opener: HTMLDivElement;
13690
14607
  #text_box?: HTMLSpanElement;
13691
14608
  #icon?: SVGSVGElement;
14609
+ #tail?: HTMLElement;
13692
14610
 
13693
14611
  constructor(parent: ListRowParent<A>) {
13694
14612
  super();
13695
14613
  this.tabIndex = 0;
14614
+ //Places the line down to the sub rows of an open row
14615
+ this.style.setProperty("--list-key-depth", String(parent.depth));
13696
14616
  this.onkeydown = (e) => {
13697
- if (e.key === "Enter" || e.key === " ") parent.open = !parent.open;
14617
+ if (parent.key_down?.(e)) e.preventDefault();
14618
+ else if (e.key === "Enter" || e.key === " ") parent.open = !parent.open;
13698
14619
  else if (e.key === "ArrowRight") parent.open = true;
13699
14620
  else if (e.key === "ArrowLeft") parent.open = false;
13700
14621
  else if (e.key === "ArrowDown") parent.select_adjacent("next", none());
@@ -13704,6 +14625,7 @@ export class ListKeyField<A extends ListType<any>> extends Base {
13704
14625
  };
13705
14626
 
13706
14627
  const opener_box = document.createElement("span");
14628
+ opener_box.className = "opener";
13707
14629
  this.#opener = opener_box.appendChild(document.createElement("div"));
13708
14630
  this.replaceChildren(
13709
14631
  ...array_from_length(parent.depth, (i) => {
@@ -13725,15 +14647,47 @@ export class ListKeyField<A extends ListType<any>> extends Base {
13725
14647
  if (state.is.state(options?.icon)) {
13726
14648
  this.attach_state_to_prop("icon", options.icon, () => some(undefined));
13727
14649
  } else this.detach_state_from_prop("icon").icon = options?.icon;
14650
+ if (state.is.state(options?.text)) {
14651
+ this.attach_state_to_prop("text", options.text, (e) => some(e));
14652
+ } else this.detach_state_from_prop("text").text = options?.text;
13728
14653
  }
13729
14654
 
13730
14655
  set icon(value: SVGFunc | undefined) {
13731
14656
  if (this.#icon) this.#icon.remove();
13732
14657
  this.#icon = undefined;
14658
+ this.classList.toggle("has-icon", Boolean(value));
13733
14659
  if (!value) return;
13734
14660
  this.#icon = value();
13735
- if (this.#text_box) this.insertBefore(this.#icon, this.#text_box);
13736
- else this.appendChild(this.#icon);
14661
+ this.insertBefore(this.#icon, this.#text_box ?? this.#tail ?? null);
14662
+ }
14663
+
14664
+ /**Element filling the rest of the key field, the button of an add row or the text of an error
14665
+ * A key field with a tail spans from the key column to the end of the row, so it works without value columns */
14666
+ set tail(value: HTMLElement | undefined) {
14667
+ if (value === this.#tail) return;
14668
+ this.#tail?.remove();
14669
+ this.#tail = value;
14670
+ this.classList.toggle("tail", Boolean(value));
14671
+ if (value) this.appendChild(value);
14672
+ }
14673
+ get tail(): HTMLElement | undefined {
14674
+ return this.#tail;
14675
+ }
14676
+
14677
+ /**Text after the icon, an empty string removes the text element */
14678
+ set text(value: string | undefined) {
14679
+ this.classList.toggle("has-text", Boolean(value));
14680
+ if (!value) {
14681
+ this.#text_box?.remove();
14682
+ this.#text_box = undefined;
14683
+ return;
14684
+ }
14685
+ if (!this.#text_box) {
14686
+ this.#text_box = document.createElement("span");
14687
+ this.#text_box.className = "text";
14688
+ this.insertBefore(this.#text_box, this.#tail ?? null);
14689
+ }
14690
+ this.#text_box.textContent = value;
13737
14691
  }
13738
14692
 
13739
14693
  // ____ _____ ______ _ _ _____ _ _ _____
@@ -13754,7 +14708,7 @@ export class ListKeyField<A extends ListType<any>> extends Base {
13754
14708
  define_element(ListKeyField);
13755
14709
  ```
13756
14710
 
13757
- ## package-ui/src/list/row.scss
14711
+ ## package-ui/list/row.scss
13758
14712
 
13759
14713
  ```scss
13760
14714
  list-container > div:not(.addrow) > div > :last-child,
@@ -13815,21 +14769,33 @@ list-row {
13815
14769
  }
13816
14770
  }
13817
14771
  }
14772
+
14773
+ //After the even, odd and hover backgrounds so it wins over them
14774
+ list-row.selected {
14775
+ > div > * {
14776
+ background-color: var(--list-colors-background-row_selected);
14777
+ }
14778
+ > div:hover > * {
14779
+ background-color: var(--list-colors-background-row_selected_hover);
14780
+ }
14781
+ }
13818
14782
  ```
13819
14783
 
13820
- ## package-ui/src/list/row.ts
14784
+ ## package-ui/list/row.ts
13821
14785
 
13822
14786
  ```ts
13823
14787
  import { Base, define_element } from "#base";
13824
- import ctm, { ContextMenu } from "#context-menu";
13825
- import { some, type Option } from "@chocbite/ts-lib/result";
14788
+ import ctm, { ContextMenu, type ContextMenuLines } from "#context-menu";
14789
+ import { none, some, type Option } from "@chocbite/ts-lib/result";
13826
14790
  import { state, type State, type StateInferSub } from "@chocbite/ts-lib/state";
13827
- import state_ui from "../state_ui";
14791
+ import state_ui from "#state_ui";
13828
14792
  import { ListAddRow, type ListAddRowOptions } from "./add_row";
14793
+ import type { ListDragField } from "./drag";
13829
14794
  import { list_rows_error_update, ListError, type ListRowsError } from "./error";
13830
14795
  import { list_align_apply, type ListField } from "./field";
13831
14796
  import { ListKeyField, type ListKeyFieldOptions } from "./key_field";
13832
14797
  import "./row.scss";
14798
+ import { ListCheckField, type ListSelection } from "./selection";
13833
14799
  import type {
13834
14800
  ListParentRows,
13835
14801
  ListRoot,
@@ -13847,6 +14813,8 @@ export interface ListRowOptions<R, T extends {}, S extends boolean> {
13847
14813
  sub_rows?: S extends true ? ListSubRows<R> : never;
13848
14814
  add_row?: ListAddRowOptions;
13849
14815
  context_menu?: ContextMenu | (() => Option<ContextMenu>);
14816
+ /**Whether the row can be selected when the list has selection, true when undefined */
14817
+ selectable?: boolean;
13850
14818
  values: T;
13851
14819
  }
13852
14820
 
@@ -13865,6 +14833,15 @@ export class ListRow<R, T extends {}, A extends ListType<R>, S extends boolean>
13865
14833
  #sub_rows?: ListSubRows<R>;
13866
14834
  readonly depth: number;
13867
14835
  #key_field?: ListKeyField<A>;
14836
+ /**Drag handle cell, only with reorder */
14837
+ #drag?: ListDragField;
14838
+ /**Checkbox or radio button cell, only with selection */
14839
+ #check?: ListCheckField;
14840
+ #data!: R;
14841
+ /**Sub rows of a closed row given for a drop, used when it opens so the sub rows function is called once */
14842
+ #drop_rows?: R[] | State<R[]>;
14843
+ /**Key of the row in the selection, undefined when the row can not be selected */
14844
+ selection_key?: unknown;
13868
14845
  #field_box: HTMLDivElement;
13869
14846
  #child_box: HTMLSpanElement;
13870
14847
  #add_row?: ListAddRow<R, T, A, S>;
@@ -13892,6 +14869,8 @@ export class ListRow<R, T extends {}, A extends ListType<R>, S extends boolean>
13892
14869
  }
13893
14870
  this.#field_box = this.appendChild(document.createElement("div"));
13894
14871
  this.#child_box = this.appendChild(document.createElement("span"));
14872
+ if (this.#root.reorder) this.#drag = this.#root.reorder.handle(this);
14873
+ if (this.#root.selection) this.#selection_setup(this.#root.selection);
13895
14874
  //A right click on a sub row without its own menu reaches the child box before this row
13896
14875
  if (this.#root.sub_rows)
13897
14876
  this.#child_box.oncontextmenu = () => {
@@ -13917,9 +14896,11 @@ export class ListRow<R, T extends {}, A extends ListType<R>, S extends boolean>
13917
14896
 
13918
14897
  /**Shows the cells after the key field, which stays so an invalid row keeps its indent and arrow key navigation */
13919
14898
  #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);
14899
+ const lead: HTMLElement[] = [];
14900
+ if (this.#drag) lead.push(this.#drag);
14901
+ if (this.#check) lead.push(this.#check);
14902
+ if (this.#key_field) lead.push(this.#key_field);
14903
+ this.#field_box.replaceChildren(...lead, ...cells);
13923
14904
  }
13924
14905
 
13925
14906
  #apply_values() {
@@ -13953,35 +14934,79 @@ export class ListRow<R, T extends {}, A extends ListType<R>, S extends boolean>
13953
14934
  direction: "next" | "previous" | "p_next" | "p_previous" | "last",
13954
14935
  field: Option<number>,
13955
14936
  ) {
13956
- if (!this.#key_field) return;
14937
+ if (!this.#key_field && !this.#check) return;
13957
14938
  //Open is not enough, an open row can show an error instead of sub rows
13958
14939
  const has_rows = this.#child_box.childElementCount > 0;
13959
14940
  if (direction === "next" || direction === "p_next") {
13960
14941
  if (direction === "next" && has_rows)
13961
- (
13962
- this.#child_box.firstElementChild! as ListRow<R, T, A, false>
13963
- ).#key_field!.focus();
14942
+ (this.#child_box.firstElementChild! as ListRow<R, T, A, S>).#focus();
13964
14943
  else {
13965
14944
  const sibling = this.nextElementSibling;
13966
- if (sibling instanceof ListRow) sibling.#key_field!.focus();
14945
+ if (sibling instanceof ListRow) sibling.#focus();
13967
14946
  else this.#parent.select_adjacent("p_next", field);
13968
14947
  }
13969
14948
  } else if (direction === "previous") {
13970
14949
  const sibling = this.previousElementSibling;
13971
14950
  if (sibling instanceof ListRow) {
13972
14951
  if (sibling.open) sibling.select_adjacent("last", field);
13973
- else sibling.#key_field!.focus();
14952
+ else sibling.#focus();
13974
14953
  } else this.#parent.select_adjacent("p_previous", field);
13975
- } else if (direction === "p_previous") this.#key_field.focus();
14954
+ } else if (direction === "p_previous") this.#focus();
13976
14955
  else if (direction === "last") {
13977
14956
  if (has_rows) {
13978
14957
  (
13979
14958
  this.#child_box.lastElementChild as ListRow<R, T, A, S>
13980
14959
  ).select_adjacent("last", field);
13981
- } else this.#key_field.focus();
14960
+ } else this.#focus();
13982
14961
  }
13983
14962
  }
13984
14963
 
14964
+ /**Focuses the cell used for keyboard navigation, the key field or else the checkbox */
14965
+ #focus(options?: FocusOptions) {
14966
+ (this.#key_field ?? this.#check)?.focus(options);
14967
+ }
14968
+
14969
+ /**Focuses the cell used for keyboard navigation */
14970
+ focus_cell() {
14971
+ this.#focus({ preventScroll: true });
14972
+ }
14973
+
14974
+ /**Moves the focus to the keyboard cell after a click, so the selection keys work right away
14975
+ * Unless the click focused something in the row itself, like an input of a field */
14976
+ #focus_after_click() {
14977
+ const active = document.activeElement;
14978
+ if (active && active !== document.body && this.#field_box.contains(active))
14979
+ return;
14980
+ const cell = this.#key_field ?? this.#check;
14981
+ if (!cell) return;
14982
+ //Without scrolling, the sticky cell would scroll the list sideways
14983
+ cell.focus({ preventScroll: true });
14984
+ //Focus from script shows the focus ring, which a click should not, removed again by a key or blur
14985
+ cell.classList.add("click-focus");
14986
+ }
14987
+
14988
+ key_down(e: KeyboardEvent): boolean {
14989
+ const selection = this.#root.selection;
14990
+ if (e.altKey && (e.key === "ArrowDown" || e.key === "ArrowUp")) {
14991
+ if (!this.#root.reorder) return false;
14992
+ void this.#root.reorder.key_move(this, e.key === "ArrowDown" ? 1 : -1);
14993
+ return true;
14994
+ }
14995
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") {
14996
+ this.select_adjacent(e.key === "ArrowDown" ? "next" : "previous", none());
14997
+ const focused = document.activeElement?.closest("list-row");
14998
+ if (
14999
+ selection &&
15000
+ focused !== this &&
15001
+ focused instanceof ListRow &&
15002
+ focused.selection_key !== undefined
15003
+ )
15004
+ selection.focus_moved(focused.selection_key, e);
15005
+ return true;
15006
+ }
15007
+ return selection ? selection.key_down(this.selection_key, e) : false;
15008
+ }
15009
+
13985
15010
  // _____ _______
13986
15011
  // | __ \ /\|__ __|/\
13987
15012
  // | | | | / \ | | / \
@@ -13990,6 +15015,14 @@ export class ListRow<R, T extends {}, A extends ListType<R>, S extends boolean>
13990
15015
  // |_____/_/ \_\_/_/ \_\
13991
15016
 
13992
15017
  set data(data: R) {
15018
+ this.#data = data;
15019
+ this.#drop_rows = undefined;
15020
+ this.classList.toggle(
15021
+ "movable",
15022
+ Boolean(this.#drag) &&
15023
+ state.is.state(this.#parent.state) &&
15024
+ this.#parent.state.writable,
15025
+ );
13993
15026
  const result = this.#root.transform(
13994
15027
  data,
13995
15028
  this,
@@ -14003,8 +15036,10 @@ export class ListRow<R, T extends {}, A extends ListType<R>, S extends boolean>
14003
15036
  const row_options = result.value;
14004
15037
  if (this.#invalid) {
14005
15038
  this.#invalid = undefined;
15039
+ if (this.#key_field) this.#key_field.tail = undefined;
14006
15040
  this.#show_cells(this.#fields);
14007
15041
  }
15042
+ this.#selection_update(row_options.selectable ?? true, data);
14008
15043
  if (this.#key_field) this.#key_field.options = row_options.key_field;
14009
15044
  this.#sub_rows = row_options.sub_rows;
14010
15045
 
@@ -14037,8 +15072,19 @@ export class ListRow<R, T extends {}, A extends ListType<R>, S extends boolean>
14037
15072
  //Setup context menu, blocked for right clicks bubbling up from sub rows
14038
15073
  ctm.detach(this);
14039
15074
  this.#sub_row_menu = false;
14040
- if (row_options.context_menu)
14041
- ctm.attach(this, row_options.context_menu, () => {
15075
+ //An openable row gets open or close lines and a selectable row select lines, in front of its own menu
15076
+ //Openable can be a state, the lines are made when the menu opens
15077
+ const openable = this.#root.sub_rows && Boolean(row_options.openable);
15078
+ const menu =
15079
+ openable || this.selection_key !== undefined
15080
+ ? ctm.combine(
15081
+ () => this.#open_lines(),
15082
+ () => this.#selection_lines(),
15083
+ row_options.context_menu,
15084
+ )
15085
+ : row_options.context_menu;
15086
+ if (menu)
15087
+ ctm.attach(this, menu, () => {
14042
15088
  const from_sub_row = this.#sub_row_menu;
14043
15089
  this.#sub_row_menu = false;
14044
15090
  return from_sub_row;
@@ -14047,6 +15093,7 @@ export class ListRow<R, T extends {}, A extends ListType<R>, S extends boolean>
14047
15093
 
14048
15094
  /**Replaces the fields with the text and removes everything else the row options gave */
14049
15095
  #set_invalid(text: string) {
15096
+ this.#selection_update(false);
14050
15097
  if (this.#key_field) this.#key_field.options = undefined;
14051
15098
  this.#sub_rows = undefined;
14052
15099
  this.add_row = undefined;
@@ -14057,7 +15104,11 @@ export class ListRow<R, T extends {}, A extends ListType<R>, S extends boolean>
14057
15104
  this.#sub_row_menu = false;
14058
15105
  if (!this.#invalid) {
14059
15106
  this.#invalid = new ListError();
14060
- this.#show_cells([this.#invalid]);
15107
+ //With sub rows the text is in the key field after the tree lines, it runs from the key column to the end
15108
+ if (this.#key_field) {
15109
+ this.#key_field.tail = this.#invalid;
15110
+ this.#show_cells([]);
15111
+ } else this.#show_cells([this.#invalid]);
14061
15112
  }
14062
15113
  this.#invalid.text = text;
14063
15114
  }
@@ -14100,7 +15151,9 @@ export class ListRow<R, T extends {}, A extends ListType<R>, S extends boolean>
14100
15151
  set open(open: boolean) {
14101
15152
  if (!this.openable) return;
14102
15153
  if (open && this.#child_box.childElementCount === 0) {
14103
- if (this.#sub_rows) this.rows = this.#sub_rows?.();
15154
+ const rows = this.#drop_rows ?? this.#sub_rows?.();
15155
+ this.#drop_rows = undefined;
15156
+ if (rows) this.rows = rows;
14104
15157
  } else if (!open && this.open) this.rows = [];
14105
15158
  }
14106
15159
  get open(): boolean {
@@ -14149,20 +15202,612 @@ export class ListRow<R, T extends {}, A extends ListType<R>, S extends boolean>
14149
15202
  this,
14150
15203
  );
14151
15204
  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),
15205
+ list_rows_apply(this.#root, this, this.#child_box, rows);
15206
+ }
15207
+
15208
+ // _____ ______ _ ______ _____ _______ _____ ____ _ _
15209
+ // / ____| ____| | | ____/ ____|__ __|_ _/ __ \| \ | |
15210
+ // | (___ | |__ | | | |__ | | | | | || | | | \| |
15211
+ // \___ \| __| | | | __|| | | | | || | | | . ` |
15212
+ // ____) | |____| |____| |___| |____ | | _| || |__| | |\ |
15213
+ // |_____/|______|______|______\_____| |_| |_____\____/|_| \_|
15214
+
15215
+ #selection_setup(selection: ListSelection<unknown>) {
15216
+ const clear_click_focus = (e: Event) =>
15217
+ (e.currentTarget as HTMLElement).classList.remove("click-focus");
15218
+ this.#check = new ListCheckField();
15219
+ //The key field is the keyboard cell when there is one
15220
+ if (!this.#key_field) this.#check.tabIndex = 0;
15221
+ this.#check.onkeydown = (e) => {
15222
+ if (this.key_down(e)) e.preventDefault();
15223
+ };
15224
+ for (const cell of [this.#check, this.#key_field])
15225
+ if (cell) {
15226
+ cell.addEventListener("keydown", clear_click_focus);
15227
+ cell.addEventListener("blur", clear_click_focus);
15228
+ }
15229
+ this.#check.onclick = (e) => {
15230
+ e.stopPropagation();
15231
+ if (this.selection_key !== undefined)
15232
+ selection.check_click(this.selection_key);
15233
+ this.#focus_after_click();
15234
+ };
15235
+ this.#field_box.onclick = (e) => {
15236
+ if (this.selection_key !== undefined)
15237
+ selection.click(this.selection_key, e);
15238
+ this.#focus_after_click();
15239
+ };
15240
+ //Shift click would select text between the rows
15241
+ this.#field_box.onmousedown = (e) => {
15242
+ if (e.shiftKey && selection.multi) e.preventDefault();
15243
+ };
15244
+ }
15245
+
15246
+ /**Registers the row in the selection with the key of its data, or removes it when not selectable */
15247
+ #selection_update(selectable: boolean, data?: R) {
15248
+ const selection = this.#root.selection;
15249
+ if (!selection) return;
15250
+ const key: unknown = selectable ? selection.key(data) : undefined;
15251
+ if (key === this.selection_key) return;
15252
+ if (this.selection_key !== undefined)
15253
+ selection.unregister(this.selection_key, this);
15254
+ this.selection_key = key;
15255
+ if (key !== undefined) selection.register(key, this);
15256
+ this.classList.toggle("selectable", key !== undefined);
15257
+ }
15258
+
15259
+ /**Context menu line to open or close the sub rows, empty when the row can not be opened */
15260
+ #open_lines(): ContextMenuLines {
15261
+ if (!this.openable) return [];
15262
+ return [
15263
+ this.open
15264
+ ? ctm.line("Close", () => (this.open = false))
15265
+ : ctm.line("Open", () => (this.open = true)),
15266
+ ];
15267
+ }
15268
+
15269
+ /**Context menu lines to select or deselect the row, and in multi mode all rows
15270
+ * Empty when the row can not be selected */
15271
+ #selection_lines(): ContextMenuLines {
15272
+ const selection = this.#root.selection;
15273
+ const key = this.selection_key;
15274
+ if (!selection || key === undefined) return [];
15275
+ const lines: ContextMenuLines = [
15276
+ selection.is_selected(key)
15277
+ ? ctm.line("Deselect", () => selection.deselect(key))
15278
+ : ctm.line("Select", () => selection.select(key)),
15279
+ ];
15280
+ if (selection.multi)
15281
+ lines.push(
15282
+ ctm.line(
15283
+ "Select all",
15284
+ () => selection.select_all(),
15285
+ undefined,
15286
+ "Ctrl+A",
15287
+ ),
15288
+ ctm.line("Deselect all", () => selection.clear(), undefined, "Esc"),
15289
+ );
15290
+ return lines;
15291
+ }
15292
+
15293
+ // __ __ ______ _______ _ _ _____
15294
+ // | \/ |/ __ \ \ / /_ _| \ | |/ ____|
15295
+ // | \ / | | | \ \ / / | | | \| | | __
15296
+ // | |\/| | | | |\ \/ / | | | . ` | | |_ |
15297
+ // | | | | |__| | \ / _| |_| |\ | |__| |
15298
+ // |_| |_|\____/ \/ |_____|_| \_|\_____|
15299
+
15300
+ get data(): R {
15301
+ return this.#data;
15302
+ }
15303
+
15304
+ /**Moving of the list the row is in, undefined when its rows can not be moved */
15305
+ get reorder() {
15306
+ return this.#root.reorder;
15307
+ }
15308
+
15309
+ /**Rows of the parent the row is in */
15310
+ get parent_rows(): ListParentRows<A> {
15311
+ return this.#parent.state;
15312
+ }
15313
+
15314
+ /**Row the row is a sub row of, undefined for top level rows */
15315
+ get parent_row(): ListRow<R, T, A, S> | undefined {
15316
+ return this.#parent instanceof ListRow ? this.#parent : undefined;
15317
+ }
15318
+
15319
+ get next_row(): ListRow<R, T, A, S> | undefined {
15320
+ const next = this.nextElementSibling;
15321
+ return next instanceof ListRow ? next : undefined;
15322
+ }
15323
+
15324
+ get first_sub_row(): ListRow<R, T, A, S> | undefined {
15325
+ const first = this.#child_box.firstElementChild;
15326
+ return first instanceof ListRow ? first : undefined;
15327
+ }
15328
+
15329
+ /**Whether the row has a handle and its parent rows can be written */
15330
+ get movable(): boolean {
15331
+ return this.classList.contains("movable");
15332
+ }
15333
+
15334
+ /**Whether rows can be dropped into the row, it must be openable with sub rows in a writable state */
15335
+ get droppable(): boolean {
15336
+ if (!this.openable) return false;
15337
+ const rows = this.drop_rows();
15338
+ return state.is.state(rows) && rows.writable;
15339
+ }
15340
+
15341
+ /**The sub rows rows are dropped into, also of a closed row */
15342
+ drop_rows(): R[] | State<R[]> | undefined {
15343
+ if (this.open) return this.state;
15344
+ return (this.#drop_rows ??= this.#sub_rows?.());
15345
+ }
15346
+
15347
+ /**Whether the row is selected in a list with multi selection, a drag of it moves all selected rows */
15348
+ get multi_selected(): boolean {
15349
+ return this.selected && Boolean(this.#root.selection?.multi);
15350
+ }
15351
+
15352
+ /**Text naming the row while it is dragged, the key field text or the text of the first cell */
15353
+ get label(): string {
15354
+ const text =
15355
+ this.#key_field?.querySelector(".text")?.textContent ||
15356
+ this.#fields[0]?.textContent ||
15357
+ "";
15358
+ return text.trim();
15359
+ }
15360
+
15361
+ /**First visible cell of the row, the row itself is display contents and has no box */
15362
+ get anchor(): Element | undefined {
15363
+ return this.#field_box.firstElementChild ?? undefined;
15364
+ }
15365
+
15366
+ set selected(value: boolean) {
15367
+ this.classList.toggle("selected", value);
15368
+ }
15369
+ get selected(): boolean {
15370
+ return this.classList.contains("selected");
15371
+ }
15372
+
15373
+ /**Removes the row and its sub rows from the selection, when the row is removed */
15374
+ selection_leave() {
15375
+ const selection = this.#root.selection;
15376
+ if (!selection) return;
15377
+ if (this.selection_key !== undefined)
15378
+ selection.unregister(this.selection_key, this);
15379
+ this.selection_key = undefined;
15380
+ for (let i = 0; i < this.#child_box.childElementCount; i++)
15381
+ (this.#child_box.children[i] as ListRow<R, T, A, S>).selection_leave();
15382
+ }
15383
+ }
15384
+ define_element(ListRow);
15385
+
15386
+ /**Applies rows to a row box, removed rows leave the selection, which updates once after all changes */
15387
+ export function list_rows_apply<
15388
+ R,
15389
+ T extends {},
15390
+ A extends ListType<R>,
15391
+ S extends boolean,
15392
+ >(
15393
+ root: ListRoot<R, T, A, S>,
15394
+ parent: ListRowParent<A>,
15395
+ box: HTMLElement,
15396
+ rows: readonly R[],
15397
+ ) {
15398
+ const apply = () =>
15399
+ state_ui.a.apply(box, rows, {
15400
+ create: (row) => new ListRow<R, T, A, S>(root, parent, row),
14154
15401
  update: (element, row) => (element.data = row),
15402
+ destroy: (element) => element.selection_leave(),
14155
15403
  });
15404
+ if (root.selection) root.selection.batch(apply);
15405
+ else apply();
15406
+ }
15407
+ ```
15408
+
15409
+ ## package-ui/list/selection.scss
15410
+
15411
+ ```scss
15412
+ @use "../icons/mixins" as icons;
15413
+
15414
+ list-checkfield {
15415
+ position: sticky;
15416
+ left: var(--list-drag-width);
15417
+ z-index: 2;
15418
+ display: flex;
15419
+ align-items: center;
15420
+ justify-content: center;
15421
+ box-sizing: border-box;
15422
+ //Square, so rows keep the same height without a glyph, like unselectable rows
15423
+ min-height: var(--list-check-width);
15424
+ user-select: none;
15425
+ cursor: pointer;
15426
+ outline: none;
15427
+ border-right: 1px solid var(--list-colors-border-column);
15428
+
15429
+ &::before {
15430
+ @include icons.material-symbols-rounded;
15431
+ font-size: 1.2rem;
15432
+ //Fits in the minimum row height, so the glyph does not make rows taller
15433
+ line-height: 1;
15434
+ color: var(--list-colors-icon-check);
15435
+
15436
+ .touch & {
15437
+ font-size: 1.8rem;
15438
+ }
15439
+ }
15440
+
15441
+ &:focus-visible:not(.click-focus) {
15442
+ outline: 2px solid var(--list-colors-focus-normal);
15443
+ outline-offset: -2px;
14156
15444
  }
14157
15445
  }
14158
- define_element(ListRow);
15446
+
15447
+ //Glyphs of the icon font, check_box_outline_blank, check_box and indeterminate_check_box
15448
+ list-container > div.multi {
15449
+ list-row.selectable > div > list-checkfield::before,
15450
+ > list-headerrow > list-checkfield::before {
15451
+ content: "\e835";
15452
+ }
15453
+ list-row.selectable.selected > div > list-checkfield::before,
15454
+ > list-headerrow > list-checkfield.all::before {
15455
+ content: "\e834";
15456
+ }
15457
+ > list-headerrow > list-checkfield.some:not(.all)::before {
15458
+ content: "\e909";
15459
+ }
15460
+ }
15461
+
15462
+ //Glyphs of the icon font, radio_button_unchecked and radio_button_checked
15463
+ list-container > div.single {
15464
+ list-row.selectable > div > list-checkfield::before {
15465
+ content: "\e836";
15466
+ }
15467
+ list-row.selectable.selected > div > list-checkfield::before {
15468
+ content: "\e837";
15469
+ }
15470
+ //Nothing to select all with
15471
+ > list-headerrow > list-checkfield {
15472
+ cursor: default;
15473
+ }
15474
+ }
15475
+ ```
15476
+
15477
+ ## package-ui/list/selection.ts
15478
+
15479
+ ```ts
15480
+ import { Base, define_element } from "#base";
15481
+ import type { Result } from "@chocbite/ts-lib/result";
15482
+ import { state, type StateREAW } from "@chocbite/ts-lib/state";
15483
+ import "./selection.scss";
15484
+
15485
+ export interface ListSelectionOptions<R, K = R> {
15486
+ /**Single allows one selected row and shows radio buttons in front of the rows,
15487
+ * multi allows any amount and shows checkboxes, which toggle a row without modifier keys */
15488
+ mode: "single" | "multi";
15489
+ /**Identity of the data of a row, the selection is a list of these
15490
+ * Defaults to the data itself, give a key when rows can have equal data, like primitives
15491
+ * Keys must be unique among the rows of the list, sub rows included */
15492
+ key?: (data: R) => K;
15493
+ }
15494
+
15495
+ /**What the selection needs from a row */
15496
+ export interface ListSelectionRow {
15497
+ /**Shows the row as selected */
15498
+ selected: boolean;
15499
+ /**Cell to point at with a message about the row */
15500
+ readonly anchor: Element | undefined;
15501
+ }
15502
+
15503
+ /**Selection of the rows of a list, kept in an array state of keys owned by the app
15504
+ * The list shows the keys of the state that have a visible row, and writes the state only on user actions,
15505
+ * keys of rows it does not show are left alone, except by select all and deselect all which replace the selection */
15506
+ export class ListSelection<K> {
15507
+ readonly multi: boolean;
15508
+ readonly key: (data: any) => K;
15509
+ /**Called after a change of the shown selection or of the selectable rows */
15510
+ on_change?: () => void;
15511
+ /**Called when the state rejects a write, with the row the user acted on */
15512
+ on_error?: (row: ListSelectionRow | undefined, message: string) => void;
15513
+ /**State user actions are written to */
15514
+ target?: StateREAW<K[], any, K[]>;
15515
+
15516
+ /**Element holding all rows of the list, sub rows included, in display order */
15517
+ #box: Element;
15518
+ #rows = new Map<K, ListSelectionRow & Element>();
15519
+ /**Mirror of the state array, the removed and changed entries of an update only give positions or new items */
15520
+ #keys: K[] = [];
15521
+ /**How often each key is in the state, a key that is in it twice stays selected when one is removed */
15522
+ #counts = new Map<K, number>();
15523
+ /**Amount of visible rows that are selected */
15524
+ #shown = 0;
15525
+ #anchor?: K;
15526
+ #batch = 0;
15527
+ #changed = false;
15528
+
15529
+ constructor(options: ListSelectionOptions<any, K>, box: Element) {
15530
+ this.multi = options.mode === "multi";
15531
+ this.key = options.key ?? ((data) => data as K);
15532
+ this.#box = box;
15533
+ }
15534
+
15535
+ /**Runs the function with the change notification delayed until all nested batches are done */
15536
+ batch<T>(func: () => T): T {
15537
+ this.#batch++;
15538
+ try {
15539
+ return func();
15540
+ } finally {
15541
+ if (--this.#batch === 0 && this.#changed) {
15542
+ this.#changed = false;
15543
+ this.on_change?.();
15544
+ }
15545
+ }
15546
+ }
15547
+
15548
+ // _____ _______ _______ ______
15549
+ // / ____|__ __|/\|__ __| ____|
15550
+ // | (___ | | / \ | | | |__
15551
+ // \___ \ | | / /\ \ | | | __|
15552
+ // ____) | | |/ ____ \| | | |____
15553
+ // |_____/ |_/_/ \_\_| |______|
15554
+
15555
+ /**Applies a value of the state, only the changed keys are touched when the value carries its changes */
15556
+ apply(value: Result<readonly K[], string>) {
15557
+ this.batch(() => {
15558
+ if (!value.ok) {
15559
+ this.#fresh([]);
15560
+ return;
15561
+ }
15562
+ for (const change of state.a.read(value.value)) {
15563
+ if (change.type === "fresh") this.#fresh(change.items);
15564
+ else if (change.type === "added") {
15565
+ this.#keys.splice(change.index, 0, ...change.items);
15566
+ for (const key of change.items) this.#add(key);
15567
+ } else if (change.type === "removed") {
15568
+ for (const key of this.#keys.splice(
15569
+ change.index,
15570
+ change.items.length,
15571
+ ))
15572
+ this.#remove(key);
15573
+ } else if (change.type === "changed")
15574
+ change.items.forEach((key, i) => {
15575
+ const old = this.#keys[change.index + i];
15576
+ this.#keys[change.index + i] = key;
15577
+ this.#remove(old);
15578
+ this.#add(key);
15579
+ });
15580
+ else {
15581
+ const moved = this.#keys.splice(
15582
+ change.from_index,
15583
+ change.items.length,
15584
+ );
15585
+ this.#keys.splice(change.to_index, 0, ...moved);
15586
+ }
15587
+ }
15588
+ });
15589
+ }
15590
+
15591
+ #fresh(keys: readonly K[]) {
15592
+ const old = this.#counts;
15593
+ this.#keys = [...keys];
15594
+ this.#counts = new Map();
15595
+ for (const key of keys)
15596
+ this.#counts.set(key, (this.#counts.get(key) ?? 0) + 1);
15597
+ for (const key of old.keys())
15598
+ if (!this.#counts.has(key)) this.#show(key, false);
15599
+ for (const key of this.#counts.keys())
15600
+ if (!old.has(key)) this.#show(key, true);
15601
+ }
15602
+
15603
+ #add(key: K) {
15604
+ const count = this.#counts.get(key) ?? 0;
15605
+ this.#counts.set(key, count + 1);
15606
+ if (count === 0) this.#show(key, true);
15607
+ }
15608
+
15609
+ #remove(key: K) {
15610
+ const count = this.#counts.get(key);
15611
+ if (!count) return;
15612
+ if (count > 1) this.#counts.set(key, count - 1);
15613
+ else {
15614
+ this.#counts.delete(key);
15615
+ this.#show(key, false);
15616
+ }
15617
+ }
15618
+
15619
+ #show(key: K, selected: boolean) {
15620
+ const row = this.#rows.get(key);
15621
+ if (!row) return;
15622
+ row.selected = selected;
15623
+ this.#shown += selected ? 1 : -1;
15624
+ this.#changed = true;
15625
+ }
15626
+
15627
+ /**Writes the state, a rejected write is reported at the row of the key the user acted on */
15628
+ #write(value: K[], key?: K) {
15629
+ const write = this.target?.write(value);
15630
+ if (!write) return;
15631
+ const row = key === undefined ? undefined : this.#rows.get(key);
15632
+ void write.then((result) => {
15633
+ if (result.err) this.on_error?.(row, result.error);
15634
+ });
15635
+ }
15636
+
15637
+ // _____ ______ _______
15638
+ // | __ \ / __ \ \ / / ____|
15639
+ // | |__) | | | \ \ /\ / / (___
15640
+ // | _ /| | | |\ \/ \/ / \___ \
15641
+ // | | \ \| |__| | \ /\ / ____) |
15642
+ // |_| \_\\____/ \/ \/ |_____/
15643
+
15644
+ /**Adds a visible row that can be selected, it shows whether its key is in the state */
15645
+ register(key: K, row: ListSelectionRow & Element) {
15646
+ this.#rows.set(key, row);
15647
+ row.selected = this.#counts.has(key);
15648
+ if (row.selected) this.#shown++;
15649
+ this.#changed = true;
15650
+ }
15651
+
15652
+ /**Removes a row that is no longer visible or selectable, the state keeps its key */
15653
+ unregister(key: K, row: ListSelectionRow & Element) {
15654
+ if (this.#rows.get(key) === row) {
15655
+ this.#rows.delete(key);
15656
+ if (this.#counts.has(key)) this.#shown--;
15657
+ }
15658
+ row.selected = false;
15659
+ this.#changed = true;
15660
+ }
15661
+
15662
+ /**Amount of visible rows that can be selected */
15663
+ get amount_selectable(): number {
15664
+ return this.#rows.size;
15665
+ }
15666
+
15667
+ /**Amount of visible rows that are selected */
15668
+ get amount_selected(): number {
15669
+ return this.#shown;
15670
+ }
15671
+
15672
+ is_selected(key: K): boolean {
15673
+ return this.#counts.has(key);
15674
+ }
15675
+
15676
+ // _ _ _____ ______ _____
15677
+ // | | | |/ ____| ____| __ \
15678
+ // | | | | (___ | |__ | |__) |
15679
+ // | | | |\___ \| __| | _ /
15680
+ // | |__| |____) | |____| | \ \
15681
+ // \____/|_____/|______|_| \_\
15682
+ //Every user action writes the state, the rows show the change when the state gives it back
15683
+
15684
+ /**Keys of the selectable rows from one row to another in display order, both included */
15685
+ #range(from: K, to: K): K[] {
15686
+ const keys: K[] = [];
15687
+ let inside = false;
15688
+ const rows = this.#box.querySelectorAll("list-row");
15689
+ const from_row = this.#rows.get(from);
15690
+ const to_row = this.#rows.get(to);
15691
+ for (let i = 0; i < rows.length; i++) {
15692
+ const row = rows[i];
15693
+ const edge = row === from_row || row === to_row;
15694
+ if (edge || inside) {
15695
+ const key = (row as unknown as { selection_key: K | undefined })
15696
+ .selection_key;
15697
+ if (key !== undefined && this.#rows.get(key) === row) keys.push(key);
15698
+ }
15699
+ if (edge) {
15700
+ if (inside || from_row === to_row) break;
15701
+ inside = true;
15702
+ }
15703
+ }
15704
+ return keys;
15705
+ }
15706
+
15707
+ #select_range(to: K, add: boolean) {
15708
+ if (!this.#rows.has(to)) return;
15709
+ const anchor =
15710
+ this.#anchor !== undefined && this.#rows.has(this.#anchor)
15711
+ ? this.#anchor
15712
+ : to;
15713
+ const keys = this.#range(anchor, to);
15714
+ this.#anchor = anchor;
15715
+ if (!add) return this.#write(state.a.write.fresh(keys), to);
15716
+ const added = keys.filter((key) => !this.#counts.has(key));
15717
+ if (added.length) this.#write(state.a.write.push(...added), to);
15718
+ }
15719
+
15720
+ /**Replaces the selection with only the row */
15721
+ select_only(key: K) {
15722
+ if (!this.#rows.has(key)) return;
15723
+ this.#anchor = key;
15724
+ if (this.#keys.length === 1 && this.#keys[0] === key) return;
15725
+ this.#write(state.a.write.fresh([key]), key);
15726
+ }
15727
+
15728
+ /**Adds the row to the selection, in single mode it replaces the selection */
15729
+ select(key: K) {
15730
+ if (!this.multi) return this.select_only(key);
15731
+ if (!this.#rows.has(key)) return;
15732
+ this.#anchor = key;
15733
+ if (!this.#counts.has(key)) this.#write(state.a.write.push(key), key);
15734
+ }
15735
+
15736
+ /**Removes the row from the selection */
15737
+ deselect(key: K) {
15738
+ if (this.#counts.has(key)) this.#write(state.a.write.delete(key), key);
15739
+ }
15740
+
15741
+ /**Toggles the row, in single mode selecting replaces the selection */
15742
+ toggle(key: K) {
15743
+ if (!this.#rows.has(key)) return;
15744
+ if (this.#counts.has(key)) {
15745
+ this.#anchor = key;
15746
+ this.deselect(key);
15747
+ } else this.select(key);
15748
+ }
15749
+
15750
+ /**Replaces the selection with all visible selectable rows, multi mode only */
15751
+ select_all() {
15752
+ if (this.multi) this.#write(state.a.write.fresh([...this.#rows.keys()]));
15753
+ }
15754
+
15755
+ /**Clears the selection, also of keys without a visible row */
15756
+ clear() {
15757
+ if (this.#keys.length) this.#write(state.a.write.fresh([]));
15758
+ }
15759
+
15760
+ /**Click on the checkbox or radio button of a row */
15761
+ check_click(key: K) {
15762
+ if (this.multi) this.toggle(key);
15763
+ else this.select_only(key);
15764
+ }
15765
+
15766
+ /**Click on a row outside its checkbox or radio button */
15767
+ click(key: K, e: MouseEvent) {
15768
+ if (this.multi && e.shiftKey)
15769
+ this.#select_range(key, e.ctrlKey || e.metaKey);
15770
+ else if (e.ctrlKey || e.metaKey) this.toggle(key);
15771
+ else this.select_only(key);
15772
+ }
15773
+
15774
+ /**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 */
15775
+ focus_moved(key: K, e: KeyboardEvent) {
15776
+ if (this.multi && e.shiftKey)
15777
+ this.#select_range(key, e.ctrlKey || e.metaKey);
15778
+ }
15779
+
15780
+ /**Handles selection keys pressed on a row, returns true when the key was used */
15781
+ key_down(key: K | undefined, e: KeyboardEvent): boolean {
15782
+ if (e.key === " ") {
15783
+ if (key === undefined) return true;
15784
+ if (this.multi || e.ctrlKey || e.metaKey) this.toggle(key);
15785
+ else this.select_only(key);
15786
+ } else if (e.key === "Escape") this.clear();
15787
+ else if (this.multi && (e.ctrlKey || e.metaKey) && e.key === "a")
15788
+ this.select_all();
15789
+ else return false;
15790
+ return true;
15791
+ }
15792
+ }
15793
+
15794
+ /**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 */
15795
+ export class ListCheckField extends Base {
15796
+ static element_name() {
15797
+ return "checkfield";
15798
+ }
15799
+ static element_name_space() {
15800
+ return "list";
15801
+ }
15802
+ }
15803
+ define_element(ListCheckField);
14159
15804
  ```
14160
15805
 
14161
- ## package-ui/src/list/shared.ts
15806
+ ## package-ui/list/shared.ts
14162
15807
 
14163
15808
  ```ts
14164
15809
  import { theme_init_variable_root } from "#theme";
14165
- import { GREY, ORANGE, RED } from "@chocbite/ts-lib/colors";
15810
+ import { BLUE, GREY, ORANGE, RED } from "@chocbite/ts-lib/colors";
14166
15811
 
14167
15812
  const theme_root = theme_init_variable_root(
14168
15813
  "list",
@@ -14291,6 +15936,24 @@ colors_icon.make_variable(
14291
15936
  "Color",
14292
15937
  undefined,
14293
15938
  );
15939
+ colors_icon.make_variable(
15940
+ "drag",
15941
+ "Drag Handle Color",
15942
+ "Color of the drag handles that move rows",
15943
+ GREY["600"],
15944
+ GREY["400"],
15945
+ "Color",
15946
+ undefined,
15947
+ );
15948
+ colors_icon.make_variable(
15949
+ "check",
15950
+ "Selection Checkbox Color",
15951
+ "Color of the selection checkboxes",
15952
+ GREY["800"],
15953
+ GREY["200"],
15954
+ "Color",
15955
+ undefined,
15956
+ );
14294
15957
  colors_icon.make_variable(
14295
15958
  "add_icon",
14296
15959
  "Add Row Icon Color",
@@ -14339,6 +16002,24 @@ colors_background.make_variable(
14339
16002
  "Color",
14340
16003
  undefined,
14341
16004
  );
16005
+ colors_background.make_variable(
16006
+ "row_selected",
16007
+ "Selected Row Background Color",
16008
+ "Color of selected row element backgrounds",
16009
+ BLUE["100"],
16010
+ BLUE["900"],
16011
+ "Color",
16012
+ undefined,
16013
+ );
16014
+ colors_background.make_variable(
16015
+ "row_selected_hover",
16016
+ "Selected Hover Row Background Color",
16017
+ "Color of selected row element backgrounds when hovering",
16018
+ BLUE["200"],
16019
+ BLUE["800"],
16020
+ "Color",
16021
+ undefined,
16022
+ );
14342
16023
 
14343
16024
  // ____ ____ _____ _____ ______ _____ _____ ____ _ ____ _____ _____
14344
16025
  // | _ \ / __ \| __ \| __ \| ____| __ \ / ____/ __ \| | / __ \| __ \ / ____|
@@ -14523,7 +16204,7 @@ font.make_variable(
14523
16204
  );
14524
16205
  ```
14525
16206
 
14526
- ## package-ui/src/list/types.ts
16207
+ ## package-ui/list/types.ts
14527
16208
 
14528
16209
  ```ts
14529
16210
  import type { BaseIntersectObserver } from "#base";
@@ -14532,6 +16213,8 @@ import type { State } from "@chocbite/ts-lib/state";
14532
16213
  import list from ".";
14533
16214
  import type { ListField, ListTextField } from "./field";
14534
16215
  import type { ListRow, ListRowOptions } from "./row";
16216
+ import type { ListReorder } from "./drag";
16217
+ import type { ListSelection } from "./selection";
14535
16218
 
14536
16219
  export type ListType<R> = R[] | State<R[]>;
14537
16220
 
@@ -14543,8 +16226,7 @@ export type ListTypeExtract<A extends ListType<any>> = A extends (infer U)[]
14543
16226
 
14544
16227
  /**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
16228
  export type ListParentRows<A extends ListType<any>> =
14546
- | A
14547
- | ListType<ListTypeExtract<A>>;
16229
+ A | ListType<ListTypeExtract<A>>;
14548
16230
 
14549
16231
  export const ListDataType = {
14550
16232
  number: "number",
@@ -14632,6 +16314,10 @@ export interface ListRoot<
14632
16314
  transform: ListRowTransformer<R, T, A, S>;
14633
16315
  /**Observer for the container if observer is active */
14634
16316
  observer?: BaseIntersectObserver;
16317
+ /**Selection of rows, when enabled */
16318
+ selection?: ListSelection<any>;
16319
+ /**Moving of rows, when enabled */
16320
+ reorder?: ListReorder<R>;
14635
16321
  }
14636
16322
 
14637
16323
  export interface ListRowParent<A extends ListType<any>> {
@@ -14646,16 +16332,62 @@ export interface ListRowParent<A extends ListType<any>> {
14646
16332
  ): void;
14647
16333
  /**Rows of the parent, the rows of the container or the sub rows of a row */
14648
16334
  state: ListParentRows<A>;
16335
+ /**Handles a key pressed in the key field before the key field does, returns true when the key was used */
16336
+ key_down?(e: KeyboardEvent): boolean;
16337
+ }
16338
+ ```
16339
+
16340
+ ## package-ui/list/warn.ts
16341
+
16342
+ ```ts
16343
+ /**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
16344
+ * One hidden input in the container is placed over the row before the message is shown, it clears after 5 seconds */
16345
+ export class ListWarn {
16346
+ #container: HTMLElement;
16347
+ #input: HTMLInputElement;
16348
+ #timeout?: number;
16349
+
16350
+ constructor(container: HTMLElement) {
16351
+ this.#container = container;
16352
+ this.#input = container.appendChild(document.createElement("input"));
16353
+ this.#input.className = "list-warn";
16354
+ this.#input.tabIndex = -1;
16355
+ }
16356
+
16357
+ /**Shows the message at the element, or at the top of the list without element
16358
+ * @param at element to point at, rows are display contents, so give one of their cells */
16359
+ show(at: Element | undefined, message: string) {
16360
+ const input = this.#input;
16361
+ const container = this.#container;
16362
+ const box = container.getBoundingClientRect();
16363
+ const rect = at?.getBoundingClientRect() ?? box;
16364
+ input.style.top = rect.top - box.top + container.scrollTop + "px";
16365
+ input.style.left =
16366
+ Math.max(rect.left - box.left, 0) + container.scrollLeft + "px";
16367
+ input.style.width = rect.width + "px";
16368
+ input.style.height = rect.height + "px";
16369
+ //Showing the message can move the focus to the input, the keyboard cell keeps it
16370
+ const focused = document.activeElement;
16371
+ input.setCustomValidity(message);
16372
+ input.reportValidity();
16373
+ if (focused instanceof HTMLElement && focused !== document.activeElement)
16374
+ focused.focus({ preventScroll: true });
16375
+ if (this.#timeout) clearTimeout(this.#timeout);
16376
+ this.#timeout = window.setTimeout(() => {
16377
+ input.setCustomValidity("");
16378
+ input.reportValidity();
16379
+ }, 5000);
16380
+ }
14649
16381
  }
14650
16382
  ```
14651
16383
 
14652
- ## package-ui/src/selection/index.ts
16384
+ ## package-ui/selection/index.ts
14653
16385
 
14654
16386
  ```ts
14655
16387
  export * from "./selection";
14656
16388
  ```
14657
16389
 
14658
- ## package-ui/src/selection/selection.ts
16390
+ ## package-ui/selection/selection.ts
14659
16391
 
14660
16392
  ```ts
14661
16393
  type TextControl = HTMLInputElement | HTMLTextAreaElement;
@@ -14773,7 +16505,7 @@ export function set_selection_all(element: HTMLElement): void {
14773
16505
  }
14774
16506
  ```
14775
16507
 
14776
- ## package-ui/src/settings/index.ts
16508
+ ## package-ui/settings/index.ts
14777
16509
 
14778
16510
  ```ts
14779
16511
  import { ok, type Option, type ResultOk } from "@chocbite/ts-lib/result";
@@ -14991,7 +16723,7 @@ export class SettingsGroup {
14991
16723
  }
14992
16724
  ```
14993
16725
 
14994
- ## package-ui/src/spinner/globals.d.ts
16726
+ ## package-ui/spinner/globals.d.ts
14995
16727
 
14996
16728
  ```ts
14997
16729
  declare module "*.scss" {
@@ -15000,7 +16732,7 @@ declare module "*.scss" {
15000
16732
  }
15001
16733
  ```
15002
16734
 
15003
- ## package-ui/src/spinner/index.scss
16735
+ ## package-ui/spinner/index.scss
15004
16736
 
15005
16737
  ```scss
15006
16738
  spinner-spinner {
@@ -15039,7 +16771,7 @@ spinner-spinner {
15039
16771
  }
15040
16772
  ```
15041
16773
 
15042
- ## package-ui/src/spinner/index.ts
16774
+ ## package-ui/spinner/index.ts
15043
16775
 
15044
16776
  ```ts
15045
16777
  import { Base, define_element } from "#base";
@@ -15100,7 +16832,7 @@ export class Spinner extends Base {
15100
16832
  define_element(Spinner);
15101
16833
  ```
15102
16834
 
15103
- ## package-ui/src/state_ui/array.ts
16835
+ ## package-ui/state_ui/array.ts
15104
16836
 
15105
16837
  ```ts
15106
16838
  import state from "@chocbite/ts-lib/state";
@@ -15202,7 +16934,7 @@ export const ARRAY_UI = {
15202
16934
  };
15203
16935
  ```
15204
16936
 
15205
- ## package-ui/src/state_ui/index.ts
16937
+ ## package-ui/state_ui/index.ts
15206
16938
 
15207
16939
  ```ts
15208
16940
  import { ARRAY_UI } from "./array";
@@ -15223,7 +16955,7 @@ export default state_ui;
15223
16955
  export type { StateUIArrayApplyHandlers } from "./array";
15224
16956
  ```
15225
16957
 
15226
- ## package-ui/src/svg/attributes.ts
16958
+ ## package-ui/svg/attributes.ts
15227
16959
 
15228
16960
  ```ts
15229
16961
  export class SVGAttributes<T extends SVGElement> {
@@ -15339,7 +17071,7 @@ export class SVGAttributes<T extends SVGElement> {
15339
17071
  }
15340
17072
  ```
15341
17073
 
15342
- ## package-ui/src/svg/index.ts
17074
+ ## package-ui/svg/index.ts
15343
17075
 
15344
17076
  ```ts
15345
17077
  import { SVGAttributes } from "./attributes";
@@ -15390,7 +17122,7 @@ declare global {
15390
17122
  }
15391
17123
  ```
15392
17124
 
15393
- ## package-ui/src/svg/primitives/circle.ts
17125
+ ## package-ui/svg/primitives/circle.ts
15394
17126
 
15395
17127
  ```ts
15396
17128
  import { SVGAttributes } from "../attributes";
@@ -15437,7 +17169,7 @@ export function circle_arc(
15437
17169
  }
15438
17170
  ```
15439
17171
 
15440
- ## package-ui/src/svg/primitives/ellipse.ts
17172
+ ## package-ui/svg/primitives/ellipse.ts
15441
17173
 
15442
17174
  ```ts
15443
17175
  import { degrees_to_radians } from "@chocbite/ts-lib/math";
@@ -15499,7 +17231,7 @@ export function ellipse_arc(
15499
17231
  }
15500
17232
  ```
15501
17233
 
15502
- ## package-ui/src/svg/primitives/group.ts
17234
+ ## package-ui/svg/primitives/group.ts
15503
17235
 
15504
17236
  ```ts
15505
17237
  import { SVGAttributes } from "../attributes";
@@ -15511,7 +17243,7 @@ export function group(): SVGAttributes<SVGGElement> {
15511
17243
  }
15512
17244
  ```
15513
17245
 
15514
- ## package-ui/src/svg/primitives/line.ts
17246
+ ## package-ui/svg/primitives/line.ts
15515
17247
 
15516
17248
  ```ts
15517
17249
  import { SVGAttributes } from "../attributes";
@@ -15536,7 +17268,7 @@ export function line(
15536
17268
  }
15537
17269
  ```
15538
17270
 
15539
- ## package-ui/src/svg/primitives/path.ts
17271
+ ## package-ui/svg/primitives/path.ts
15540
17272
 
15541
17273
  ```ts
15542
17274
  import { SVGAttributes } from "../attributes";
@@ -15565,7 +17297,7 @@ export function path_line(
15565
17297
  }
15566
17298
  ```
15567
17299
 
15568
- ## package-ui/src/svg/primitives/rectangle.ts
17300
+ ## package-ui/svg/primitives/rectangle.ts
15569
17301
 
15570
17302
  ```ts
15571
17303
  import { SVGAttributes } from "../attributes";
@@ -15614,7 +17346,7 @@ export function rectangle_from_corner(
15614
17346
  }
15615
17347
  ```
15616
17348
 
15617
- ## package-ui/src/svg/primitives/shared.ts
17349
+ ## package-ui/svg/primitives/shared.ts
15618
17350
 
15619
17351
  ```ts
15620
17352
  import { SVGAttributes } from "../attributes";
@@ -15627,7 +17359,7 @@ export function create_svg_element<K extends keyof SVGElementTagNameMap>(
15627
17359
  }
15628
17360
  ```
15629
17361
 
15630
- ## package-ui/src/svg/primitives/svg.ts
17362
+ ## package-ui/svg/primitives/svg.ts
15631
17363
 
15632
17364
  ```ts
15633
17365
  import { SVGAttributes } from "../attributes";
@@ -15649,7 +17381,7 @@ export function svg(
15649
17381
  }
15650
17382
  ```
15651
17383
 
15652
- ## package-ui/src/svg/primitives/text.ts
17384
+ ## package-ui/svg/primitives/text.ts
15653
17385
 
15654
17386
  ```ts
15655
17387
  import { SVGAttributes } from "../attributes";
@@ -15792,7 +17524,7 @@ export function multi_line_text(
15792
17524
  }
15793
17525
  ```
15794
17526
 
15795
- ## package-ui/src/svg/primitives/triangle.ts
17527
+ ## package-ui/svg/primitives/triangle.ts
15796
17528
 
15797
17529
  ```ts
15798
17530
  import { SVGAttributes } from "../attributes";
@@ -15830,13 +17562,13 @@ export function isosceles_triangle(
15830
17562
  }
15831
17563
  ```
15832
17564
 
15833
- ## package-ui/src/svg/shared.ts
17565
+ ## package-ui/svg/shared.ts
15834
17566
 
15835
17567
  ```ts
15836
17568
  export const NAME_SPACE = "http://www.w3.org/2000/svg";
15837
17569
  ```
15838
17570
 
15839
- ## package-ui/src/svg/util/anchorPoint.ts
17571
+ ## package-ui/svg/util/anchorPoint.ts
15840
17572
 
15841
17573
  ```ts
15842
17574
  //Enum describing the diffrent possible anchor points
@@ -15855,7 +17587,7 @@ export type SVGAnchorPoint =
15855
17587
  (typeof SVGAnchorPoint)[keyof typeof SVGAnchorPoint];
15856
17588
  ```
15857
17589
 
15858
- ## package-ui/src/svg/util/angleToAnchorPoint.ts
17590
+ ## package-ui/svg/util/angleToAnchorPoint.ts
15859
17591
 
15860
17592
  ```ts
15861
17593
  import { SVGAnchorPoint } from "./anchorPoint";
@@ -15887,7 +17619,7 @@ export const angle_to_anchor_point = (angle: number) => {
15887
17619
  };
15888
17620
  ```
15889
17621
 
15890
- ## package-ui/src/test/index.ts
17622
+ ## package-ui/test/index.ts
15891
17623
 
15892
17624
  ```ts
15893
17625
  import { Base, define_element } from "#base";
@@ -16186,7 +17918,7 @@ export class TestSetterBox extends TestBase {
16186
17918
  define_element(TestSetterBox);
16187
17919
  ```
16188
17920
 
16189
- ## package-ui/src/theme/builtIn.ts
17921
+ ## package-ui/theme/builtIn.ts
16190
17922
 
16191
17923
  ```ts
16192
17924
  import { GREY } from "@chocbite/ts-lib/colors";
@@ -16268,7 +18000,7 @@ colors.make_variable(
16268
18000
  );
16269
18001
  ```
16270
18002
 
16271
- ## package-ui/src/theme/engine.ts
18003
+ ## package-ui/theme/engine.ts
16272
18004
 
16273
18005
  ```ts
16274
18006
  import { DOCUMENT_HANDLER } from "#document";
@@ -16468,7 +18200,7 @@ ANIMATION_SPEED.sub((val) => {
16468
18200
  });
16469
18201
  ```
16470
18202
 
16471
- ## package-ui/src/theme/globals.d.ts
18203
+ ## package-ui/theme/globals.d.ts
16472
18204
 
16473
18205
  ```ts
16474
18206
  declare module "*.scss" {
@@ -16477,7 +18209,7 @@ declare module "*.scss" {
16477
18209
  }
16478
18210
  ```
16479
18211
 
16480
- ## package-ui/src/theme/index.scss
18212
+ ## package-ui/theme/index.scss
16481
18213
 
16482
18214
  ```scss
16483
18215
  @use "./mixins";
@@ -16534,7 +18266,7 @@ html {
16534
18266
  }
16535
18267
  ```
16536
18268
 
16537
- ## package-ui/src/theme/index.ts
18269
+ ## package-ui/theme/index.ts
16538
18270
 
16539
18271
  ```ts
16540
18272
  export { BUILT_IN } from "./builtIn";
@@ -16558,7 +18290,7 @@ export { theme_init_variable_root, ThemeVariableGroup } from "./variables";
16558
18290
  import "./index.scss";
16559
18291
  ```
16560
18292
 
16561
- ## package-ui/src/theme/init.ts
18293
+ ## package-ui/theme/init.ts
16562
18294
 
16563
18295
  ```ts
16564
18296
  import { theme_engine } from "./engine";
@@ -16605,7 +18337,7 @@ export function theme_init(options: ThemeInitOptions = {}) {
16605
18337
  }
16606
18338
  ```
16607
18339
 
16608
- ## package-ui/src/theme/mixins.scss
18340
+ ## package-ui/theme/mixins.scss
16609
18341
 
16610
18342
  ```scss
16611
18343
  @mixin scrollbar {
@@ -16649,7 +18381,7 @@ export function theme_init(options: ThemeInitOptions = {}) {
16649
18381
  }
16650
18382
  ```
16651
18383
 
16652
- ## package-ui/src/theme/settings.ts
18384
+ ## package-ui/theme/settings.ts
16653
18385
 
16654
18386
  ```ts
16655
18387
  import {
@@ -16662,7 +18394,7 @@ import {
16662
18394
  import { settings_init } from "#settings";
16663
18395
  import { none, ok, some, type Option } from "@chocbite/ts-lib/result";
16664
18396
  import { state as st } from "@chocbite/ts-lib/state";
16665
- import { version } from "../../../package.json";
18397
+ import { version } from "../../package.json";
16666
18398
 
16667
18399
  const SETTINGS = settings_init(
16668
18400
  "@chocbite/ts-lib-theme",
@@ -16970,7 +18702,7 @@ SETTINGS.register(
16970
18702
  export const ANIMATION_SPEED = PRIVATE_ANIMATION_SPEED.read_write;
16971
18703
  ```
16972
18704
 
16973
- ## package-ui/src/theme/shared.ts
18705
+ ## package-ui/theme/shared.ts
16974
18706
 
16975
18707
  ```ts
16976
18708
  import type { ThemeVariableGroup } from "./variables";
@@ -16978,7 +18710,7 @@ import type { ThemeVariableGroup } from "./variables";
16978
18710
  export const BOTTOM_GROUPS: { [key: string]: ThemeVariableGroup } = {};
16979
18711
  ```
16980
18712
 
16981
- ## package-ui/src/theme/variables.ts
18713
+ ## package-ui/theme/variables.ts
16982
18714
 
16983
18715
  ```ts
16984
18716
  import { theme_engine } from "./engine";