@syware/jlib 0.12.0 → 0.13.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 (142) hide show
  1. package/README.md +1 -1
  2. package/dist/atoms/jl-avatar.css.js +1 -1
  3. package/dist/atoms/jl-avatar.js +1 -8
  4. package/dist/atoms/jl-button.css.js +1 -1
  5. package/dist/atoms/jl-button.js +4 -6
  6. package/dist/atoms/jl-checkbox.css.js +1 -1
  7. package/dist/atoms/jl-checkbox.js +8 -10
  8. package/dist/atoms/jl-chip.css.js +1 -1
  9. package/dist/atoms/jl-chip.js +3 -11
  10. package/dist/atoms/jl-divider.css.js +1 -1
  11. package/dist/atoms/jl-divider.js +1 -5
  12. package/dist/atoms/jl-icon.css.js +1 -1
  13. package/dist/atoms/jl-icon.d.ts +2 -0
  14. package/dist/atoms/jl-icon.js +5 -1
  15. package/dist/atoms/jl-input.d.ts +7 -2
  16. package/dist/atoms/jl-input.js +36 -31
  17. package/dist/atoms/jl-link.css.js +1 -1
  18. package/dist/atoms/jl-link.js +3 -6
  19. package/dist/atoms/jl-rating.css.js +1 -1
  20. package/dist/atoms/jl-rating.d.ts +2 -2
  21. package/dist/atoms/jl-rating.js +17 -35
  22. package/dist/atoms/jl-select.d.ts +8 -3
  23. package/dist/atoms/jl-select.js +26 -13
  24. package/dist/atoms/jl-skeleton.d.ts +1 -0
  25. package/dist/atoms/jl-skeleton.js +4 -1
  26. package/dist/atoms/jl-slider.d.ts +4 -0
  27. package/dist/atoms/jl-slider.js +29 -15
  28. package/dist/atoms/jl-switch.css.js +1 -1
  29. package/dist/atoms/jl-switch.js +2 -8
  30. package/dist/atoms/jl-textarea.css.js +1 -1
  31. package/dist/atoms/jl-textarea.d.ts +4 -5
  32. package/dist/atoms/jl-textarea.js +15 -30
  33. package/dist/lib/calendar.js +3 -2
  34. package/dist/lib/floating.d.ts +10 -0
  35. package/dist/lib/floating.js +27 -8
  36. package/dist/lib/flow.d.ts +7 -3
  37. package/dist/lib/flow.js +19 -8
  38. package/dist/lib/indicator.d.ts +16 -0
  39. package/dist/lib/indicator.js +32 -6
  40. package/dist/lib/intl.d.ts +6 -0
  41. package/dist/lib/intl.js +19 -0
  42. package/dist/lib/palette.js +1 -6
  43. package/dist/lib/table.d.ts +14 -2
  44. package/dist/lib/table.js +50 -39
  45. package/dist/molecules/jl-accordion-item.css.js +1 -1
  46. package/dist/molecules/jl-accordion-item.js +1 -5
  47. package/dist/molecules/jl-account-button.css.js +1 -1
  48. package/dist/molecules/jl-account-button.js +1 -5
  49. package/dist/molecules/jl-alert.css.js +1 -1
  50. package/dist/molecules/jl-alert.d.ts +5 -5
  51. package/dist/molecules/jl-alert.js +4 -13
  52. package/dist/molecules/jl-avatar-group.d.ts +7 -5
  53. package/dist/molecules/jl-avatar-group.js +15 -5
  54. package/dist/molecules/jl-breadcrumb.d.ts +7 -4
  55. package/dist/molecules/jl-breadcrumb.js +32 -8
  56. package/dist/molecules/jl-calendar.d.ts +12 -3
  57. package/dist/molecules/jl-calendar.js +79 -48
  58. package/dist/molecules/jl-card.css.js +1 -1
  59. package/dist/molecules/jl-card.js +2 -8
  60. package/dist/molecules/jl-chip-group.css.js +1 -1
  61. package/dist/molecules/jl-chip-group.d.ts +6 -2
  62. package/dist/molecules/jl-chip-group.js +13 -18
  63. package/dist/molecules/jl-code-block.css.js +1 -1
  64. package/dist/molecules/jl-code-block.d.ts +7 -5
  65. package/dist/molecules/jl-code-block.js +19 -22
  66. package/dist/molecules/jl-combobox.css.js +1 -1
  67. package/dist/molecules/jl-combobox.d.ts +4 -0
  68. package/dist/molecules/jl-combobox.js +33 -19
  69. package/dist/molecules/jl-date-picker.d.ts +6 -0
  70. package/dist/molecules/jl-date-picker.js +29 -9
  71. package/dist/molecules/jl-empty.css.js +1 -1
  72. package/dist/molecules/jl-empty.js +4 -19
  73. package/dist/molecules/jl-field.css.js +1 -1
  74. package/dist/molecules/jl-field.d.ts +7 -1
  75. package/dist/molecules/jl-field.js +35 -23
  76. package/dist/molecules/jl-file-drop.css.js +1 -1
  77. package/dist/molecules/jl-file-drop.js +1 -3
  78. package/dist/molecules/jl-input-list.css.js +1 -1
  79. package/dist/molecules/jl-input-list.d.ts +12 -1
  80. package/dist/molecules/jl-input-list.js +81 -51
  81. package/dist/molecules/jl-list-item.css.js +1 -1
  82. package/dist/molecules/jl-list-item.d.ts +3 -1
  83. package/dist/molecules/jl-list-item.js +26 -27
  84. package/dist/molecules/jl-load-state.css.js +1 -1
  85. package/dist/molecules/jl-load-state.d.ts +6 -1
  86. package/dist/molecules/jl-load-state.js +15 -18
  87. package/dist/molecules/jl-menu.d.ts +1 -0
  88. package/dist/molecules/jl-menu.js +9 -2
  89. package/dist/molecules/jl-pagination.css.js +1 -1
  90. package/dist/molecules/jl-pagination.d.ts +7 -1
  91. package/dist/molecules/jl-pagination.js +43 -35
  92. package/dist/molecules/jl-search.css.js +1 -1
  93. package/dist/molecules/jl-search.js +4 -12
  94. package/dist/molecules/jl-segmented.css.js +1 -1
  95. package/dist/molecules/jl-segmented.d.ts +4 -2
  96. package/dist/molecules/jl-segmented.js +19 -26
  97. package/dist/molecules/jl-stat.css.js +1 -1
  98. package/dist/molecules/jl-stat.js +2 -8
  99. package/dist/molecules/jl-steps.d.ts +10 -3
  100. package/dist/molecules/jl-steps.js +82 -49
  101. package/dist/molecules/jl-tabs.d.ts +5 -2
  102. package/dist/molecules/jl-tabs.js +31 -25
  103. package/dist/molecules/jl-tag-input.css.js +1 -1
  104. package/dist/molecules/jl-tag-input.d.ts +13 -1
  105. package/dist/molecules/jl-tag-input.js +57 -30
  106. package/dist/molecules/jl-timeline.css.js +1 -1
  107. package/dist/molecules/jl-timeline.d.ts +3 -1
  108. package/dist/molecules/jl-timeline.js +9 -14
  109. package/dist/molecules/jl-toast.css.js +1 -1
  110. package/dist/molecules/jl-toast.js +2 -10
  111. package/dist/molecules/jl-tooltip.d.ts +2 -1
  112. package/dist/molecules/jl-tooltip.js +11 -15
  113. package/dist/organisms/jl-command-palette.css.js +1 -1
  114. package/dist/organisms/jl-command-palette.d.ts +8 -1
  115. package/dist/organisms/jl-command-palette.js +73 -42
  116. package/dist/organisms/jl-confirm.css.js +1 -1
  117. package/dist/organisms/jl-confirm.js +1 -5
  118. package/dist/organisms/jl-dialog.css.js +1 -1
  119. package/dist/organisms/jl-dialog.js +1 -5
  120. package/dist/organisms/jl-drawer.css.js +1 -1
  121. package/dist/organisms/jl-drawer.js +1 -3
  122. package/dist/organisms/jl-flow.d.ts +18 -2
  123. package/dist/organisms/jl-flow.js +128 -44
  124. package/dist/organisms/jl-navbar.css.js +1 -1
  125. package/dist/organisms/jl-navbar.d.ts +1 -1
  126. package/dist/organisms/jl-navbar.js +3 -5
  127. package/dist/organisms/jl-page-header.css.js +1 -1
  128. package/dist/organisms/jl-page-header.js +1 -5
  129. package/dist/organisms/jl-page-outlet.d.ts +4 -3
  130. package/dist/organisms/jl-page-outlet.js +7 -8
  131. package/dist/organisms/jl-side-nav.css.js +1 -1
  132. package/dist/organisms/jl-side-nav.d.ts +9 -2
  133. package/dist/organisms/jl-side-nav.js +44 -16
  134. package/dist/organisms/jl-tab-bar.css.js +1 -1
  135. package/dist/organisms/jl-tab-bar.js +0 -2
  136. package/dist/organisms/jl-table.css.js +1 -1
  137. package/dist/organisms/jl-table.d.ts +18 -6
  138. package/dist/organisms/jl-table.js +91 -57
  139. package/dist/organisms/jl-tree.css.js +1 -1
  140. package/dist/organisms/jl-tree.d.ts +22 -2
  141. package/dist/organisms/jl-tree.js +101 -41
  142. package/package.json +1 -1
@@ -19,6 +19,8 @@ export declare const portsOf: (node: FlowNode) => FlowPort[];
19
19
  export declare const nodeHeight: (node: FlowNode) => number;
20
20
  /** The exit an edge leaves by: its own, or its node's first. */
21
21
  export declare const portOfEdge: (node: FlowNode, edge: FlowEdge) => string;
22
+ /** The graph's nodes by id: where its edges look their ends up, once per graph rather than once per edge. */
23
+ export declare const nodesById: (graph: FlowGraph) => Map<string, FlowNode>;
22
24
  export declare const snap: (point: FlowPoint) => FlowPoint;
23
25
  /** Where a node's n-th exit sits along its bottom edge: the edge cut in equal parts, each exit in the middle of one. */
24
26
  export declare const portX: (index: number, count: number) => number;
@@ -35,14 +37,16 @@ export declare const edgePath: (from: FlowPoint, to: FlowPoint) => string;
35
37
  /** The point halfway along `edgePath(from, to)`. */
36
38
  export declare const edgeMidpoint: (from: FlowPoint, to: FlowPoint) => FlowPoint;
37
39
  /** Where an edge starts and ends, or nothing when one of its ends is gone. */
38
- export declare function edgeEnds(graph: FlowGraph, edge: FlowEdge): FlowEdgeEnds | undefined;
40
+ export declare function edgeEnds(nodes: ReadonlyMap<string, FlowNode>, edge: FlowEdge): FlowEdgeEnds | undefined;
39
41
  /** A run went this way: its node left by the edge's exit, and the node it leads to ran too. */
40
- export declare function isEdgeTaken(graph: FlowGraph, edge: FlowEdge): boolean;
42
+ export declare function isEdgeTaken(nodes: ReadonlyMap<string, FlowNode>, edge: FlowEdge): boolean;
41
43
  /** The position of a node centred on a point: where something dropped there lands. */
42
44
  export declare const centeredAt: (point: FlowPoint) => FlowPoint;
43
45
  /** The node under a point, other than `except`. */
44
46
  export declare const nodeAt: (graph: FlowGraph, point: FlowPoint, except?: string) => FlowNode | undefined;
45
- export declare const isPortFree: (graph: FlowGraph, node: FlowNode, portId: string) => boolean;
47
+ /** The exits each node has an edge leaving by, read in one pass over the edges. */
48
+ export declare function usedPorts(graph: FlowGraph, nodes: ReadonlyMap<string, FlowNode>): Map<string, Set<string>>;
49
+ export declare const isPortFree: (used: ReadonlyMap<string, ReadonlySet<string>>, node: FlowNode, portId: string) => boolean;
46
50
  /**
47
51
  * The graph with one more edge, or nothing when the edge cannot be: a node does not connect to itself, a start takes
48
52
  * no incoming edge, and an exit joins a node once.
package/dist/lib/flow.js CHANGED
@@ -28,6 +28,8 @@ var nodeHeight = (node) => node.detail ? FLOW_NODE.heightWithDetail : FLOW_NODE.
28
28
  /** The exit an edge leaves by: its own, or its node's first. */
29
29
  var portOfEdge = (node, edge) => edge.port ?? portsOf(node)[0]?.id ?? "";
30
30
  var nodeById = (graph, id) => graph.nodes.find((node) => node.id === id);
31
+ /** The graph's nodes by id: where its edges look their ends up, once per graph rather than once per edge. */
32
+ var nodesById = (graph) => new Map(graph.nodes.map((node) => [node.id, node]));
31
33
  var toGrid = (value) => Math.round(value / GRID) * GRID + 0;
32
34
  var snap = (point) => ({
33
35
  x: toGrid(point.x),
@@ -144,9 +146,9 @@ var edgePath = (from, to) => roundedPath(edgeRoute(from, to));
144
146
  /** The point halfway along `edgePath(from, to)`. */
145
147
  var edgeMidpoint = (from, to) => halfway(edgeRoute(from, to));
146
148
  /** Where an edge starts and ends, or nothing when one of its ends is gone. */
147
- function edgeEnds(graph, edge) {
148
- const source = nodeById(graph, edge.from);
149
- const target = nodeById(graph, edge.to);
149
+ function edgeEnds(nodes, edge) {
150
+ const source = nodes.get(edge.from);
151
+ const target = nodes.get(edge.to);
150
152
  const portId = source ? portOfEdge(source, edge) : "";
151
153
  const from = source ? outputAnchor(source, portId) : void 0;
152
154
  if (!source || !target || !from) return;
@@ -159,9 +161,9 @@ function edgeEnds(graph, edge) {
159
161
  }
160
162
  var isInside = (point, node) => point.x >= node.position.x && point.x <= node.position.x + FLOW_NODE.width && point.y >= node.position.y && point.y <= node.position.y + nodeHeight(node);
161
163
  /** A run went this way: its node left by the edge's exit, and the node it leads to ran too. */
162
- function isEdgeTaken(graph, edge) {
163
- const source = nodeById(graph, edge.from);
164
- const target = nodeById(graph, edge.to);
164
+ function isEdgeTaken(nodes, edge) {
165
+ const source = nodes.get(edge.from);
166
+ const target = nodes.get(edge.to);
165
167
  return source?.taken !== void 0 && source.taken === portOfEdge(source, edge) && target?.status !== void 0;
166
168
  }
167
169
  /** The position of a node centred on a point: where something dropped there lands. */
@@ -171,7 +173,16 @@ var centeredAt = (point) => snap({
171
173
  });
172
174
  /** The node under a point, other than `except`. */
173
175
  var nodeAt = (graph, point, except = "") => graph.nodes.find((node) => node.id !== except && isInside(point, node));
174
- var isPortFree = (graph, node, portId) => !graph.edges.some((edge) => edge.from === node.id && portOfEdge(node, edge) === portId);
176
+ /** The exits each node has an edge leaving by, read in one pass over the edges. */
177
+ function usedPorts(graph, nodes) {
178
+ const used = /* @__PURE__ */ new Map();
179
+ for (const edge of graph.edges) {
180
+ const source = nodes.get(edge.from);
181
+ if (source !== void 0) used.set(source.id, (used.get(source.id) ?? /* @__PURE__ */ new Set()).add(portOfEdge(source, edge)));
182
+ }
183
+ return used;
184
+ }
185
+ var isPortFree = (used, node, portId) => !(used.get(node.id)?.has(portId) ?? false);
175
186
  /**
176
187
  * The graph with one more edge, or nothing when the edge cannot be: a node does not connect to itself, a start takes
177
188
  * no incoming edge, and an exit joins a node once.
@@ -367,4 +378,4 @@ function revealIn(viewport, node, width, height) {
367
378
  zoom
368
379
  };
369
380
  }
370
- export { DEFAULT_PORT, FLOW_NODE, FLOW_ZOOM, centeredAt, connect, edgeEnds, edgeMidpoint, edgePath, edgeRoute, fitView, inputAnchor, isEdgeTaken, isPortFree, layoutFlow, moveNode, nodeAt, nodeHeight, outputAnchor, portOfEdge, portX, portsOf, positionAfter, removeEdge, removeNode, revealIn, roundedPath, snap, toWorld, zoomAt };
381
+ export { DEFAULT_PORT, FLOW_NODE, FLOW_ZOOM, centeredAt, connect, edgeEnds, edgeMidpoint, edgePath, edgeRoute, fitView, inputAnchor, isEdgeTaken, isPortFree, layoutFlow, moveNode, nodeAt, nodeHeight, nodesById, outputAnchor, portOfEdge, portX, portsOf, positionAfter, removeEdge, removeNode, revealIn, roundedPath, snap, toWorld, usedPorts, zoomAt };
@@ -1,6 +1,22 @@
1
+ /** An indicator kept over a target that changes; see `followTarget`. */
2
+ interface IndicatorFollower {
3
+ /** Asks for a move at the next frame: many asks before it make one move. */
4
+ place(): void;
5
+ /** Moves the indicator again whenever this element changes size. */
6
+ watch(element: Element): void;
7
+ /** Forgets the move asked for and stops watching. */
8
+ stop(): void;
9
+ }
1
10
  /**
2
11
  * Puts a sliding indicator (the underline of a tab, the thumb of a segmented control) over the chosen element:
3
12
  * its offset and size become `--x`, `--y`, `--w` and `--h`, which the component's styles use. The indicator gets
4
13
  * `data-placed` once it has a first position, so the styles can animate its later moves only.
5
14
  */
6
15
  export declare function moveIndicator(indicator: HTMLElement, target: HTMLElement | null): void;
16
+ /**
17
+ * Keeps an indicator over its target, which `target` finds at the time of the move. A component's inputs each ask for
18
+ * a move (several at its connection): measuring the target at each would lay the page out once per input, in the
19
+ * middle of the changes. The move waits for the next frame instead, where the browser lays the page out anyway.
20
+ */
21
+ export declare function followTarget(indicator: () => HTMLElement, target: () => HTMLElement | null): IndicatorFollower;
22
+ export {};
@@ -1,3 +1,4 @@
1
+ import { watchSizes } from "./resize.js";
1
2
  // src/lib/indicator.ts
2
3
  /**
3
4
  * Puts a sliding indicator (the underline of a tab, the thumb of a segmented control) over the chosen element:
@@ -7,12 +8,37 @@
7
8
  function moveIndicator(indicator, target) {
8
9
  indicator.hidden = target === null;
9
10
  if (target === null) return;
10
- indicator.style.setProperty("--x", `${target.offsetLeft}px`);
11
- indicator.style.setProperty("--y", `${target.offsetTop}px`);
12
- indicator.style.setProperty("--w", `${target.offsetWidth}px`);
13
- indicator.style.setProperty("--h", `${target.offsetHeight}px`);
14
- if (target.offsetWidth > 0 && indicator.dataset.placed === void 0) requestAnimationFrame(() => {
11
+ const { offsetHeight, offsetLeft, offsetTop, offsetWidth } = target;
12
+ indicator.style.setProperty("--x", `${offsetLeft}px`);
13
+ indicator.style.setProperty("--y", `${offsetTop}px`);
14
+ indicator.style.setProperty("--w", `${offsetWidth}px`);
15
+ indicator.style.setProperty("--h", `${offsetHeight}px`);
16
+ if (offsetWidth > 0 && indicator.dataset.placed === void 0) requestAnimationFrame(() => {
15
17
  indicator.dataset.placed = "";
16
18
  });
17
19
  }
18
- export { moveIndicator };
20
+ /**
21
+ * Keeps an indicator over its target, which `target` finds at the time of the move. A component's inputs each ask for
22
+ * a move (several at its connection): measuring the target at each would lay the page out once per input, in the
23
+ * middle of the changes. The move waits for the next frame instead, where the browser lays the page out anyway.
24
+ */
25
+ function followTarget(indicator, target) {
26
+ const frame = { id: 0 };
27
+ const sizes = watchSizes(() => moveIndicator(indicator(), target()));
28
+ return {
29
+ place: () => {
30
+ if (frame.id !== 0) return;
31
+ frame.id = requestAnimationFrame(() => {
32
+ frame.id = 0;
33
+ moveIndicator(indicator(), target());
34
+ });
35
+ },
36
+ stop: () => {
37
+ cancelAnimationFrame(frame.id);
38
+ frame.id = 0;
39
+ sizes.disconnect();
40
+ },
41
+ watch: (element) => sizes.observe(element)
42
+ };
43
+ }
44
+ export { followTarget, moveIndicator };
@@ -0,0 +1,6 @@
1
+ /** The `Intl.DateTimeFormat` of a locale and options, made once. */
2
+ export declare const dateTimeFormat: (locale: string | undefined, options?: Intl.DateTimeFormatOptions) => Intl.DateTimeFormat;
3
+ /** The `Intl.NumberFormat` of a locale and options, made once. */
4
+ export declare const numberFormat: (locale: string | undefined, options?: Intl.NumberFormatOptions) => Intl.NumberFormat;
5
+ /** The `Intl.Collator` of a locale and options, made once: what `localeCompare` makes again on every call. */
6
+ export declare const collator: (locale: string | undefined, options?: Intl.CollatorOptions) => Intl.Collator;
@@ -0,0 +1,19 @@
1
+ // src/lib/intl.ts
2
+ var dateFormats = /* @__PURE__ */ new Map();
3
+ var numberFormats = /* @__PURE__ */ new Map();
4
+ var collators = /* @__PURE__ */ new Map();
5
+ var keyOf = (locale, options) => `${locale ?? ""} ${JSON.stringify(options ?? {})}`;
6
+ function cached(made, key, make) {
7
+ const found = made.get(key);
8
+ if (found !== void 0) return found;
9
+ const making = make();
10
+ made.set(key, making);
11
+ return making;
12
+ }
13
+ /** The `Intl.DateTimeFormat` of a locale and options, made once. */
14
+ var dateTimeFormat = (locale, options) => cached(dateFormats, keyOf(locale, options), () => new Intl.DateTimeFormat(locale, options));
15
+ /** The `Intl.NumberFormat` of a locale and options, made once. */
16
+ var numberFormat = (locale, options) => cached(numberFormats, keyOf(locale, options), () => new Intl.NumberFormat(locale, options));
17
+ /** The `Intl.Collator` of a locale and options, made once: what `localeCompare` makes again on every call. */
18
+ var collator = (locale, options) => cached(collators, keyOf(locale, options), () => new Intl.Collator(locale, options));
19
+ export { collator, dateTimeFormat, numberFormat };
@@ -39,12 +39,7 @@ function matchCommands(commands, query) {
39
39
  }
40
40
  /** The matches under their group headings, groups in the order their first command comes. */
41
41
  function groupMatches(matches) {
42
- const groups = /* @__PURE__ */ new Map();
43
- for (const match of matches) {
44
- const label = match.command.group ?? NO_GROUP;
45
- groups.set(label, [...groups.get(label) ?? [], match]);
46
- }
47
- return [...groups].map(([label, grouped]) => ({
42
+ return [...Map.groupBy(matches, (match) => match.command.group ?? NO_GROUP)].map(([label, grouped]) => ({
48
43
  label,
49
44
  matches: grouped
50
45
  }));
@@ -8,12 +8,23 @@ export declare function toTime(value: unknown): number;
8
8
  * Orders two cell values ascending: numbers by value, dates by time, text with `localeCompare`. Empty and
9
9
  * unreadable values come after the others.
10
10
  */
11
- export declare function compareCells(a: unknown, b: unknown, format: TableCellFormat, locale?: string): number;
11
+ export declare const compareCells: (a: unknown, b: unknown, format: TableCellFormat, locale?: string) => number;
12
12
  /**
13
13
  * A row's field by its name, whatever the page's type of row: a column names its field as text, and the HTML that
14
14
  * writes the rows is not checked against a type.
15
15
  */
16
16
  export declare const fieldOf: (row: object, key: string) => unknown;
17
+ /** How a column orders: which way, its values read in which format, its text compared in which language. */
18
+ interface ColumnOrder {
19
+ direction: TableSortDirection;
20
+ format?: TableCellFormat;
21
+ locale?: string;
22
+ }
23
+ /**
24
+ * Items ordered by a value of each, read once per item rather than at every comparison; `none` gives them back as
25
+ * they came. The sort is stable, and empty values stay at the end in both directions.
26
+ */
27
+ export declare function sortBy<Item>(items: readonly Item[], readValue: (item: Item) => unknown, order: ColumnOrder): Item[];
17
28
  /**
18
29
  * The rows ordered by one column; `none` gives them back as they came. The sort is stable, and empty values stay
19
30
  * at the end in both directions.
@@ -38,7 +49,7 @@ export declare const openRows: (expanded: readonly TableRowKey[], expansion: Tab
38
49
  /** The open rows after one opens or closes: one at a time, opening a row closes the one that was open. */
39
50
  export declare const withRowOpen: (expanded: readonly TableRowKey[], key: TableRowKey, open: boolean, expansion: TableExpansion) => TableRowKey[];
40
51
  /** What changed between two sets of open rows, as the `toggle` events to emit: the rows closed, then those opened. */
41
- export declare function rowToggles(before: readonly TableRowKey[], after: readonly TableRowKey[]): TableToggle[];
52
+ export declare function rowToggles(before: Iterable<TableRowKey>, after: Iterable<TableRowKey>): TableToggle[];
42
53
  /**
43
54
  * A renderer of `renderers` written for the page's own type of row, for a table that does not say its type of row:
44
55
  * the table hands each renderer back a row the page gave it, so
@@ -46,3 +57,4 @@ export declare function rowToggles(before: readonly TableRowKey[], after: readon
46
57
  * rows (`JlTable<Order>`) hands its renderers an order already.
47
58
  */
48
59
  export declare const cellOf: <Row>(draw: (row: Row) => Node) => TableCellRenderer;
60
+ export {};
package/dist/lib/table.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { collator, dateTimeFormat, numberFormat } from "./intl.js";
1
2
  // src/lib/table.ts
2
3
  /** What a header press does to a column's order: ascending, then descending, then as the rows came. */
3
4
  var NEXT_DIRECTION = {
@@ -15,6 +16,7 @@ var DATE_TIME_FORMAT = {
15
16
  dateStyle: "medium",
16
17
  timeStyle: "short"
17
18
  };
19
+ var NUMERIC_TEXT = { numeric: true };
18
20
  var nextSortDirection = (direction) => NEXT_DIRECTION[direction];
19
21
  var isEmpty = (value) => value === null || value === void 0 || value === "";
20
22
  /** A cell's value as a number, `NaN` when it is not one. */
@@ -30,26 +32,34 @@ function toTime(value) {
30
32
  if (typeof value === "string" && value.trim() !== "") return Date.parse(value);
31
33
  return NaN;
32
34
  }
33
- var compareNumbers = (a, b) => a - b;
34
- var COMPARERS = {
35
- badge: (a, b, locale) => String(a).localeCompare(String(b), locale),
36
- code: (a, b, locale) => String(a).localeCompare(String(b), locale),
37
- date: (a, b) => compareNumbers(toTime(a), toTime(b)),
38
- datetime: (a, b) => compareNumbers(toTime(a), toTime(b)),
39
- number: (a, b) => compareNumbers(toNumber(a), toNumber(b)),
40
- text: (a, b, locale) => String(a).localeCompare(String(b), locale, { numeric: true })
35
+ /** What a column orders its values by: numbers for numbers and dates, text for the rest. */
36
+ var SORT_VALUES = {
37
+ badge: String,
38
+ code: String,
39
+ date: toTime,
40
+ datetime: toTime,
41
+ number: toNumber,
42
+ text: String
41
43
  };
42
- /** Whether a value cannot be ordered in the format: empty, or not a number or a date where one is expected. */
43
- function isUnorderable(value, format) {
44
- if (isEmpty(value)) return true;
45
- return {
46
- badge: () => false,
47
- code: () => false,
48
- date: () => Number.isNaN(toTime(value)),
49
- datetime: () => Number.isNaN(toTime(value)),
50
- number: () => Number.isNaN(toNumber(value)),
51
- text: () => false
52
- }[format]();
44
+ var TEXT_ORDERS = {
45
+ badge: void 0,
46
+ code: void 0,
47
+ date: void 0,
48
+ datetime: void 0,
49
+ number: void 0,
50
+ text: NUMERIC_TEXT
51
+ };
52
+ /** A value as its column orders it, read once per sort; `undefined` when it cannot be ordered: empty, or unreadable. */
53
+ function sortValueOf(value, format) {
54
+ if (isEmpty(value)) return;
55
+ const sortValue = SORT_VALUES[format](value);
56
+ return Number.isNaN(sortValue) ? void 0 : sortValue;
57
+ }
58
+ var compareTextOf = (format, locale) => collator(locale, TEXT_ORDERS[format]).compare;
59
+ /** Orders two sort values one way, the values that cannot be ordered after the others in both directions. */
60
+ function compareSortValues(a, b, sign, compareText) {
61
+ if (a === void 0 || b === void 0) return Number(a === void 0) - Number(b === void 0);
62
+ return sign * (typeof a === "number" && typeof b === "number" ? a - b : compareText(String(a), String(b)));
53
63
  }
54
64
  /**
55
65
  * A row's field by its name, whatever the page's type of row: a column names its field as text, and the HTML that
@@ -57,35 +67,33 @@ function isUnorderable(value, format) {
57
67
  */
58
68
  var fieldOf = (row, key) => Reflect.get(row, key);
59
69
  /**
60
- * The rows ordered by one column; `none` gives them back as they came. The sort is stable, and empty values stay
61
- * at the end in both directions.
70
+ * Items ordered by a value of each, read once per item rather than at every comparison; `none` gives them back as
71
+ * they came. The sort is stable, and empty values stay at the end in both directions.
62
72
  */
63
- function sortRows(rows, key, direction, format = "text", locale) {
64
- const sign = DIRECTION_SIGN[direction];
65
- if (sign === 0 || key === "") return [...rows];
66
- return [...rows].sort((a, b) => {
67
- const aValue = fieldOf(a, key);
68
- const bValue = fieldOf(b, key);
69
- const aMissing = isUnorderable(aValue, format);
70
- const bMissing = isUnorderable(bValue, format);
71
- if (aMissing || bMissing) return Number(aMissing) - Number(bMissing);
72
- return sign * COMPARERS[format](aValue, bValue, locale);
73
- });
73
+ function sortBy(items, readValue, order) {
74
+ const sign = DIRECTION_SIGN[order.direction];
75
+ if (sign === 0) return [...items];
76
+ const format = order.format ?? "text";
77
+ const compareText = compareTextOf(format, order.locale);
78
+ return items.map((item) => ({
79
+ item,
80
+ value: sortValueOf(readValue(item), format)
81
+ })).sort((a, b) => compareSortValues(a.value, b.value, sign, compareText)).map(({ item }) => item);
74
82
  }
75
83
  var FORMATTERS = {
76
84
  badge: (value) => String(value),
77
85
  code: (value) => String(value),
78
86
  date: (value, locale) => {
79
87
  const time = toTime(value);
80
- return Number.isNaN(time) ? String(value) : new Intl.DateTimeFormat(locale, DATE_FORMAT).format(time);
88
+ return Number.isNaN(time) ? String(value) : dateTimeFormat(locale, DATE_FORMAT).format(time);
81
89
  },
82
90
  datetime: (value, locale) => {
83
91
  const time = toTime(value);
84
- return Number.isNaN(time) ? String(value) : new Intl.DateTimeFormat(locale, DATE_TIME_FORMAT).format(time);
92
+ return Number.isNaN(time) ? String(value) : dateTimeFormat(locale, DATE_TIME_FORMAT).format(time);
85
93
  },
86
94
  number: (value, locale) => {
87
95
  const number = toNumber(value);
88
- return Number.isNaN(number) ? String(value) : new Intl.NumberFormat(locale).format(number);
96
+ return Number.isNaN(number) ? String(value) : numberFormat(locale).format(number);
89
97
  },
90
98
  text: (value) => String(value)
91
99
  };
@@ -116,7 +124,8 @@ function selectionState(keys, selected) {
116
124
  }
117
125
  /** The selection after the select-all box is pressed: every row when not all were selected, else none of them. */
118
126
  function toggleAll(keys, selected) {
119
- const others = [...selected].filter((key) => !keys.includes(key));
127
+ const shown = new Set(keys);
128
+ const others = [...selected].filter((key) => !shown.has(key));
120
129
  return selectionState(keys, selected) === "all" ? others : [...others, ...keys];
121
130
  }
122
131
  /** The selection with one row added or taken out. */
@@ -140,11 +149,13 @@ var ROW_OPENERS = {
140
149
  var withRowOpen = (expanded, key, open, expansion) => ROW_OPENERS[expansion](expanded, key, open);
141
150
  /** What changed between two sets of open rows, as the `toggle` events to emit: the rows closed, then those opened. */
142
151
  function rowToggles(before, after) {
143
- const closed = before.filter((key) => !after.includes(key)).map((key) => ({
152
+ const was = new Set(before);
153
+ const is = new Set(after);
154
+ const closed = [...was].filter((key) => !is.has(key)).map((key) => ({
144
155
  key,
145
156
  open: false
146
157
  }));
147
- const opened = after.filter((key) => !before.includes(key)).map((key) => ({
158
+ const opened = [...is].filter((key) => !was.has(key)).map((key) => ({
148
159
  key,
149
160
  open: true
150
161
  }));
@@ -157,4 +168,4 @@ function rowToggles(before, after) {
157
168
  * rows (`JlTable<Order>`) hands its renderers an order already.
158
169
  */
159
170
  var cellOf = (draw) => (row) => draw(row);
160
- export { cellOf, columnAlign, columnWidth, fieldOf, formatCell, nextSortDirection, openRows, rowKeyOf, rowToggles, selectionState, sortRows, toNumber, toTime, toggleAll, toggleKey, withRowOpen };
171
+ export { cellOf, columnAlign, columnWidth, fieldOf, formatCell, nextSortDirection, openRows, rowKeyOf, rowToggles, selectionState, sortBy, toNumber, toTime, toggleAll, toggleKey, withRowOpen };
@@ -1,3 +1,3 @@
1
1
  // src/molecules/jl-accordion-item.css?inline
2
- var jl_accordion_item_default = ":host{border-bottom:1px solid var(--jl-line);interpolate-size:allow-keywords;--pad-x:0px;display:block}summary{min-height:48px;padding:12px var(--pad-x);border-radius:var(--jl-radius-xs);color:var(--jl-text);font-size:var(--jl-font-md);cursor:pointer;-webkit-user-select:none;user-select:none;align-items:center;gap:10px;font-weight:600;line-height:1.4;list-style:none;display:flex}summary::-webkit-details-marker{display:none}.titles{flex:1;min-width:0;display:grid}.description{color:var(--jl-muted);font-size:var(--jl-font-sm);text-overflow:ellipsis;white-space:nowrap;font-weight:400;overflow:hidden}.icon{color:var(--jl-muted)}.chevron{color:var(--jl-faint);transition:rotate var(--jl-slow) var(--jl-ease)}summary:hover .chevron{color:var(--jl-text)}details[open] .chevron{rotate:180deg}summary:focus-visible{box-shadow:inset 0 0 0 2px color-mix(in srgb, var(--jl-brand) 60%, transparent)}details::details-content{box-sizing:inherit;block-size:0;transition:block-size var(--jl-slow) var(--jl-ease), content-visibility var(--jl-slow) allow-discrete;overflow:clip}details[open]::details-content{block-size:auto}.content{padding:0 var(--pad-x) 16px;color:var(--jl-text-2);font-size:var(--jl-font-md);line-height:1.6}:host([disabled]) summary{color:var(--jl-faint);cursor:not-allowed}:host([disabled]) summary:hover .chevron{color:var(--jl-faint)}";
2
+ var jl_accordion_item_default = ":host{border-bottom:1px solid var(--jl-line);interpolate-size:allow-keywords;--pad-x:0px;display:block}summary{min-height:48px;padding:12px var(--pad-x);border-radius:var(--jl-radius-xs);color:var(--jl-text);font-size:var(--jl-font-md);cursor:pointer;-webkit-user-select:none;user-select:none;align-items:center;gap:10px;font-weight:600;line-height:1.4;list-style:none;display:flex}summary::-webkit-details-marker{display:none}.titles{flex:1;min-width:0;display:grid}.description{color:var(--jl-muted);font-size:var(--jl-font-sm);text-overflow:ellipsis;white-space:nowrap;font-weight:400;overflow:hidden}.description:empty{display:none}.icon{color:var(--jl-muted)}.chevron{color:var(--jl-faint);transition:rotate var(--jl-slow) var(--jl-ease)}summary:hover .chevron{color:var(--jl-text)}details[open] .chevron{rotate:180deg}summary:focus-visible{box-shadow:inset 0 0 0 2px color-mix(in srgb, var(--jl-brand) 60%, transparent)}details::details-content{box-sizing:inherit;block-size:0;transition:block-size var(--jl-slow) var(--jl-ease), content-visibility var(--jl-slow) allow-discrete;overflow:clip}details[open]::details-content{block-size:auto}.content{padding:0 var(--pad-x) 16px;color:var(--jl-text-2);font-size:var(--jl-font-md);line-height:1.6}:host([disabled]) summary{color:var(--jl-faint);cursor:not-allowed}:host([disabled]) summary:hover .chevron{color:var(--jl-faint)}";
3
3
  export { jl_accordion_item_default as default };
@@ -22,7 +22,6 @@ var JlAccordionItem = class extends JlElement {
22
22
  /** A quieter line under the heading, shown open or closed: what the section holds ("3 fields", "2 pages"). */
23
23
  description = this.useChange("", (value) => {
24
24
  this._refs.description.textContent = value;
25
- this._refs.description.hidden = value === "";
26
25
  }, { attribute: "description" });
27
26
  open = this.useChange(false, (value) => this.renderOpen(value), { attribute: "open" });
28
27
  /** An icon before the heading; the `icon` slot takes a richer one instead. */
@@ -57,10 +56,7 @@ var JlAccordionItem = class extends JlElement {
57
56
  }),
58
57
  /* @__PURE__ */ jsxs("span", {
59
58
  class: "titles",
60
- children: [/* @__PURE__ */ jsx("span", { class: "heading" }), /* @__PURE__ */ jsx("span", {
61
- class: "description",
62
- hidden: true
63
- })]
59
+ children: [/* @__PURE__ */ jsx("span", { class: "heading" }), /* @__PURE__ */ jsx("span", { class: "description" })]
64
60
  }),
65
61
  /* @__PURE__ */ jsx(JlIcon, {
66
62
  class: "chevron",
@@ -1,3 +1,3 @@
1
1
  // src/molecules/jl-account-button.css?inline
2
- var jl_account_button_default = ":host{display:block}.base{border-radius:var(--jl-radius-sm);width:100%;color:var(--jl-text);text-align:left;cursor:pointer;transition:background var(--jl-fast) var(--jl-ease);background:0 0;border:0;padding:6px 8px;text-decoration:none;display:flex}.base:hover{background:var(--jl-surface-2)}.content{flex:1;align-items:center;gap:10px;min-width:0;display:flex}jl-avatar{flex:none}.text{min-width:0;line-height:1.3;display:grid}.name,.description{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.name{font-size:var(--jl-font-sm);font-weight:650}.description{color:var(--jl-muted);font-size:var(--jl-font-xs)}:host([compact]){display:inline-block}:host([compact]) .base{border-radius:var(--jl-radius-pill);width:auto;padding:2px}:host([compact]) .text{display:none}:host([current]) .base{background:var(--jl-accent-soft)}:host([current]) .name{color:var(--jl-accent)}:host([current][compact]) .base{box-shadow:0 0 0 2px var(--jl-accent)}";
2
+ var jl_account_button_default = ":host{display:block}.base{border-radius:var(--jl-radius-sm);width:100%;color:var(--jl-text);text-align:left;cursor:pointer;transition:background var(--jl-fast) var(--jl-ease);background:0 0;border:0;padding:6px 8px;text-decoration:none;display:flex}.base:hover{background:var(--jl-surface-2)}.content{flex:1;align-items:center;gap:10px;min-width:0;display:flex}jl-avatar{flex:none}.text{min-width:0;line-height:1.3;display:grid}.name,.description{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.name{font-size:var(--jl-font-sm);font-weight:650}.description{color:var(--jl-muted);font-size:var(--jl-font-xs)}.description:empty{display:none}:host([compact]){display:inline-block}:host([compact]) .base{border-radius:var(--jl-radius-pill);width:auto;padding:2px}:host([compact]) .text{display:none}:host([current]) .base{background:var(--jl-accent-soft)}:host([current]) .name{color:var(--jl-accent)}:host([current][compact]) .base{box-shadow:0 0 0 2px var(--jl-accent)}";
3
3
  export { jl_account_button_default as default };
@@ -23,7 +23,6 @@ var JlAccountButton = class extends JlElement {
23
23
  /** The line under the name: their role, their company. */
24
24
  description = this.useChange("", (value) => {
25
25
  this._refs.description.textContent = value;
26
- this._refs.description.hidden = value === "";
27
26
  this.renderLabel();
28
27
  }, { attribute: "description" });
29
28
  /** Their picture; their initials without it. */
@@ -56,10 +55,7 @@ var JlAccountButton = class extends JlElement {
56
55
  class: "content",
57
56
  children: [avatar, /* @__PURE__ */ jsxs("span", {
58
57
  class: "text",
59
- children: [/* @__PURE__ */ jsx("span", { class: "name" }), /* @__PURE__ */ jsx("span", {
60
- class: "description",
61
- hidden: true
62
- })]
58
+ children: [/* @__PURE__ */ jsx("span", { class: "name" }), /* @__PURE__ */ jsx("span", { class: "description" })]
63
59
  })]
64
60
  })
65
61
  }), /* @__PURE__ */ jsx("a", {
@@ -1,3 +1,3 @@
1
1
  // src/molecules/jl-alert.css?inline
2
- var jl_alert_default = ":host{--fg:var(--jl-info);--bg:var(--jl-info-soft);--border:color-mix(in srgb, var(--fg) 24%, var(--bg));display:block}:host([tone=accent]){--fg:var(--jl-accent);--bg:var(--jl-accent-soft)}:host([tone=ok]){--fg:var(--jl-ok);--bg:var(--jl-ok-soft)}:host([tone=warn]){--fg:var(--jl-warn);--bg:var(--jl-warn-soft)}:host([tone=danger]){--fg:var(--jl-danger);--bg:var(--jl-danger-soft)}:host([tone=neutral]){--fg:var(--jl-muted);--bg:var(--jl-surface-2);--border:var(--jl-line)}.alert{border:1px solid var(--border);border-radius:var(--jl-radius);background:var(--bg);color:var(--jl-text-2);font-size:var(--jl-font-md);align-items:flex-start;gap:12px;padding:12px 14px;line-height:1.5;display:flex}:host([dismissible]) .alert{padding-right:8px}.icon{color:var(--fg);margin-top:1.5px}.content{flex:1;gap:2px;min-width:0;display:grid}.heading{color:var(--jl-text);font-weight:650}.actions{flex-wrap:wrap;gap:8px;margin-top:10px;display:flex}.close{--jl-accent:var(--fg);--jl-accent-soft:color-mix(in srgb, var(--fg) 12%, transparent);margin:-5px 0}::slotted(a){color:inherit;font-weight:600}";
2
+ var jl_alert_default = ":host{--fg:var(--jl-info);--bg:var(--jl-info-soft);--border:color-mix(in srgb, var(--fg) 24%, var(--bg));display:block}:host([tone=accent]){--fg:var(--jl-accent);--bg:var(--jl-accent-soft)}:host([tone=ok]){--fg:var(--jl-ok);--bg:var(--jl-ok-soft)}:host([tone=warn]){--fg:var(--jl-warn);--bg:var(--jl-warn-soft)}:host([tone=danger]){--fg:var(--jl-danger);--bg:var(--jl-danger-soft)}:host([tone=neutral]){--fg:var(--jl-muted);--bg:var(--jl-surface-2);--border:var(--jl-line)}.alert{border:1px solid var(--border);border-radius:var(--jl-radius);background:var(--bg);color:var(--jl-text-2);font-size:var(--jl-font-md);align-items:flex-start;gap:12px;padding:12px 14px;line-height:1.5;display:flex}:host([dismissible]) .alert{padding-right:8px}.icon{color:var(--fg);margin-top:1.5px}:host(:not([has-icon])) .icon,.heading:empty,.description:empty{display:none}.content{flex:1;gap:2px;min-width:0;display:grid}.heading{color:var(--jl-text);font-weight:650}.actions{flex-wrap:wrap;gap:8px;margin-top:10px;display:flex}.close{--jl-accent:var(--fg);--jl-accent-soft:color-mix(in srgb, var(--fg) 12%, transparent);margin:-5px 0}::slotted(a){color:inherit;font-weight:600}";
3
3
  export { jl_alert_default as default };
@@ -10,6 +10,11 @@ export declare class JlAlert extends JlElement {
10
10
  readonly events: Readonly<import("@jadis/core").UseEventsHandler<{
11
11
  dismiss: undefined;
12
12
  }>>;
13
+ /** An icon name in place of the tone's own; `none` shows no icon. */
14
+ readonly icon: Readonly<Readonly<{
15
+ get(): string;
16
+ set(setter: string | ((prevState: string) => string)): void;
17
+ }>>;
13
18
  readonly tone: Readonly<Readonly<{
14
19
  get(): Tone;
15
20
  set(setter: ((prevState: Tone) => Tone) | Tone): void;
@@ -23,11 +28,6 @@ export declare class JlAlert extends JlElement {
23
28
  get(): string;
24
29
  set(setter: string | ((prevState: string) => string)): void;
25
30
  }>>;
26
- /** An icon name in place of the tone's own; `none` shows no icon. */
27
- readonly icon: Readonly<Readonly<{
28
- get(): string;
29
- set(setter: string | ((prevState: string) => string)): void;
30
- }>>;
31
31
  /** Shows an × that hides the alert and fires `dismiss`. */
32
32
  readonly dismissible: Readonly<Readonly<{
33
33
  get(): boolean;
@@ -39,6 +39,8 @@ var TONE_ROLES = {
39
39
  var JlAlert = class extends JlElement {
40
40
  static selector = "jl-alert";
41
41
  events = this.useEvents();
42
+ /** An icon name in place of the tone's own; `none` shows no icon. */
43
+ icon = this.useChange("", () => this.renderIcon(), { attribute: "icon" });
42
44
  tone = this.useChange("info", (value) => {
43
45
  this.reflect("tone", value);
44
46
  this._refs.alert.setAttribute("role", TONE_ROLES[value]);
@@ -49,15 +51,11 @@ var JlAlert = class extends JlElement {
49
51
  });
50
52
  heading = this.useChange("", (value) => {
51
53
  this._refs.heading.textContent = value;
52
- this._refs.heading.hidden = value === "";
53
54
  }, { attribute: "heading" });
54
55
  /** The message as plain text, for pages that set it from code; richer content goes in the default slot. */
55
56
  description = this.useChange("", (value) => {
56
57
  this._refs.description.textContent = value;
57
- this._refs.description.hidden = value === "";
58
58
  }, { attribute: "description" });
59
- /** An icon name in place of the tone's own; `none` shows no icon. */
60
- icon = this.useChange("", () => this.renderIcon(), { attribute: "icon" });
61
59
  /** Shows an × that hides the alert and fires `dismiss`. */
62
60
  dismissible = this.useChange(false, (value) => {
63
61
  this._refs.close.hidden = !value;
@@ -92,14 +90,8 @@ var JlAlert = class extends JlElement {
92
90
  /* @__PURE__ */ jsxs("div", {
93
91
  class: "content",
94
92
  children: [
95
- /* @__PURE__ */ jsx("p", {
96
- class: "heading",
97
- hidden: true
98
- }),
99
- /* @__PURE__ */ jsx("p", {
100
- class: "description",
101
- hidden: true
102
- }),
93
+ /* @__PURE__ */ jsx("p", { class: "heading" }),
94
+ /* @__PURE__ */ jsx("p", { class: "description" }),
103
95
  /* @__PURE__ */ jsx("div", {
104
96
  class: "text",
105
97
  hidden: true,
@@ -145,7 +137,6 @@ var JlAlert = class extends JlElement {
145
137
  const name = own === "" ? TONE_ICONS[this.tone.get()] : own;
146
138
  this._refs.icon.name.set(name === NO_ICON ? "" : name);
147
139
  this._refs.icon.filled.set(own === "" && TONE_ICON_FILLED[this.tone.get()]);
148
- this._refs.icon.hidden = name === NO_ICON;
149
140
  this.reflect("has-icon", name !== NO_ICON);
150
141
  }
151
142
  };
@@ -6,20 +6,22 @@ import type { AvatarItem, AvatarSize } from '../types/jl-avatar.types';
6
6
  */
7
7
  export declare class JlAvatarGroup extends JlElement {
8
8
  static readonly selector = "jl-avatar-group";
9
- /** The people, in order: `[{ "name": "Ada Lovelace", "src": "/ada.jpg" }]`. */
10
- readonly items: Readonly<Readonly<{
11
- get(): AvatarItem[];
12
- set(setter: AvatarItem[] | ((prevState: AvatarItem[]) => AvatarItem[])): void;
13
- }>>;
14
9
  /** How many avatars show before the count; 0 shows them all. */
15
10
  readonly max: Readonly<Readonly<{
16
11
  get(): number;
17
12
  set(setter: number | ((prevState: number) => number)): void;
18
13
  }>>;
14
+ /** The people, in order: `[{ "name": "Ada Lovelace", "src": "/ada.jpg" }]`. */
15
+ readonly items: Readonly<Readonly<{
16
+ get(): AvatarItem[];
17
+ set(setter: AvatarItem[] | ((prevState: AvatarItem[]) => AvatarItem[])): void;
18
+ }>>;
19
19
  readonly size: Readonly<Readonly<{
20
20
  get(): AvatarSize;
21
21
  set(setter: ((prevState: AvatarSize) => AvatarSize) | AvatarSize): void;
22
22
  }>>;
23
+ /** What the avatars were made from: the inputs call back with what they hold as the group connects. */
24
+ private readonly _drawn;
23
25
  private readonly _refs;
24
26
  templateHtml(): Node;
25
27
  templateCss(): string;
@@ -14,20 +14,25 @@ var NAME_SEPARATOR = ", ";
14
14
  */
15
15
  var JlAvatarGroup = class extends JlElement {
16
16
  static selector = "jl-avatar-group";
17
+ /** How many avatars show before the count; 0 shows them all. */
18
+ max = this.useChange(0, () => this.render(), { attribute: "max" });
17
19
  /** The people, in order: `[{ "name": "Ada Lovelace", "src": "/ada.jpg" }]`. */
18
20
  items = this.useChange([], () => this.render(), {
19
21
  attribute: "items",
20
22
  parse: jsonOf([])
21
23
  });
22
- /** How many avatars show before the count; 0 shows them all. */
23
- max = this.useChange(0, () => this.render(), { attribute: "max" });
24
24
  size = this.useChange("md", (value) => {
25
25
  this.reflect("size", value);
26
- this.render();
26
+ for (const avatar of this._refs.group.querySelectorAll(JlAvatar.selector)) avatar.size.set(value);
27
27
  }, {
28
28
  attribute: "size",
29
29
  parse: oneOf(AVATAR_SIZES, "md")
30
30
  });
31
+ /** What the avatars were made from: the inputs call back with what they hold as the group connects. */
32
+ _drawn = {
33
+ items: null,
34
+ max: 0
35
+ };
31
36
  _refs = this.useRefs((ref) => ({ group: ref(".group") }));
32
37
  templateHtml() {
33
38
  return /* @__PURE__ */ jsx("div", {
@@ -40,8 +45,13 @@ var JlAvatarGroup = class extends JlElement {
40
45
  return css`${BASE_STYLES}${jl_avatar_group_default}`;
41
46
  }
42
47
  render() {
43
- const items = this.items.get().filter((item) => typeof item?.name === "string");
44
- const { shown, hidden } = splitVisible(items, this.max.get());
48
+ const all = this.items.get();
49
+ const max = this.max.get();
50
+ if (all === this._drawn.items && max === this._drawn.max) return;
51
+ this._drawn.items = all;
52
+ this._drawn.max = max;
53
+ const items = all.filter((item) => typeof item?.name === "string");
54
+ const { shown, hidden } = splitVisible(items, max);
45
55
  const size = this.size.get();
46
56
  const avatars = shown.map((item) => /* @__PURE__ */ jsx(JlAvatar, {
47
57
  name: item.name,