@syware/jlib 0.17.0 → 0.18.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 (39) hide show
  1. package/dist/all.js +5 -3
  2. package/dist/base/jl-combobox-base.css.js +3 -0
  3. package/dist/base/jl-combobox-base.d.ts +202 -0
  4. package/dist/base/jl-combobox-base.js +632 -0
  5. package/dist/index.d.ts +1 -0
  6. package/dist/index.js +4 -2
  7. package/dist/lib/combobox.d.ts +12 -0
  8. package/dist/lib/combobox.js +22 -0
  9. package/dist/lib/floating.d.ts +5 -1
  10. package/dist/lib/floating.js +9 -1
  11. package/dist/lib/input-list.d.ts +2 -0
  12. package/dist/lib/input-list.js +3 -3
  13. package/dist/lib/internals.js +1 -0
  14. package/dist/lib/table.d.ts +24 -3
  15. package/dist/lib/table.js +58 -2
  16. package/dist/lib/texts-de.d.ts +3 -0
  17. package/dist/lib/texts-de.js +3 -0
  18. package/dist/lib/texts-fr.d.ts +3 -0
  19. package/dist/lib/texts-fr.js +3 -0
  20. package/dist/lib/texts.d.ts +3 -0
  21. package/dist/lib/texts.js +3 -0
  22. package/dist/molecules/jl-combobox.d.ts +15 -123
  23. package/dist/molecules/jl-combobox.js +24 -461
  24. package/dist/molecules/jl-input-list.d.ts +8 -1
  25. package/dist/molecules/jl-input-list.js +16 -5
  26. package/dist/molecules/jl-multi-combobox.css.js +3 -0
  27. package/dist/molecules/jl-multi-combobox.d.ts +50 -0
  28. package/dist/molecules/jl-multi-combobox.js +176 -0
  29. package/dist/molecules/jl-popover.d.ts +2 -0
  30. package/dist/molecules/jl-popover.js +4 -0
  31. package/dist/organisms/jl-side-nav.js +1 -1
  32. package/dist/organisms/jl-table.css.js +1 -1
  33. package/dist/organisms/jl-table.d.ts +77 -5
  34. package/dist/organisms/jl-table.js +223 -23
  35. package/dist/templates/jl-app-shell.js +1 -1
  36. package/dist/types/jl-combobox.types.d.ts +5 -0
  37. package/dist/types/jl-table.types.d.ts +22 -0
  38. package/package.json +2 -1
  39. package/dist/molecules/jl-combobox.css.js +0 -3
@@ -1,18 +1,22 @@
1
1
  import { jlText } from "../lib/texts.js";
2
2
  import { BASE_STYLES } from "../styles/shared.js";
3
3
  import { JlElement } from "../base/jl-element.js";
4
- import { jsonOf, oneOf, textOf } from "../lib/attributes.js";
4
+ import { clampedNumber, jsonOf, oneOf, textListOf, textOf } from "../lib/attributes.js";
5
+ import { watchSizes } from "../lib/resize.js";
5
6
  import { registerIcons } from "../lib/icons.js";
6
- import { columnAlign, columnWidth, fieldOf, formatCell, nextSortDirection, openRows, rowKeyOf, rowToggles, selectionState, sortBy, toggleAll, toggleKey, withRowOpen } from "../lib/table.js";
7
+ import { columnAlign, columnChoices, columnWidth, fieldOf, formatCell, frozenCells, frozenCss, nextSortDirection, openRows, rowKeyOf, rowToggles, selectionState, shownColumns, sortBy, stickyOffsets, toggleAll, toggleKey, withRowOpen } from "../lib/table.js";
7
8
  import { JlIcon } from "../atoms/jl-icon.js";
8
9
  import { setOrRemove } from "../lib/dom.js";
9
10
  import { hasSlotted } from "../lib/slots.js";
10
11
  import { JlBadge } from "../atoms/jl-badge.js";
12
+ import { JlButton } from "../atoms/jl-button.js";
13
+ import { JlCheckbox } from "../atoms/jl-checkbox.js";
11
14
  import { startedOnControl } from "../lib/surface.js";
15
+ import { JlPopover } from "../molecules/jl-popover.js";
12
16
  import { PRESS_EVENTS, pressButtonOf, tellPress } from "../lib/press.js";
13
17
  import jl_table_default from "./jl-table.css.js";
14
18
  import { css } from "@jadis/core";
15
- import { ArrowDown, ArrowUp, ChevronRight, ChevronsUpDown, Inbox } from "lucide";
19
+ import { ArrowDown, ArrowUp, ChevronRight, ChevronsUpDown, Columns3, Inbox } from "lucide";
16
20
  import { Fragment, jsx, jsxs } from "@jadis/core/jsx-runtime";
17
21
  // src/organisms/jl-table.tsx
18
22
  registerIcons({
@@ -20,6 +24,7 @@ registerIcons({
20
24
  "arrow-up": ArrowUp,
21
25
  "chevron-right": ChevronRight,
22
26
  "chevrons-up-down": ChevronsUpDown,
27
+ "columns-3": Columns3,
23
28
  inbox: Inbox
24
29
  });
25
30
  var TABLE_SORT_DIRECTIONS = [
@@ -27,6 +32,7 @@ var TABLE_SORT_DIRECTIONS = [
27
32
  "asc",
28
33
  "desc"
29
34
  ];
35
+ var TABLE_SORT_MODES = ["local", "remote"];
30
36
  var TABLE_EXPANSIONS = [
31
37
  "none",
32
38
  "single",
@@ -41,7 +47,9 @@ var SORT_ICON_SIZE = 14;
41
47
  var EMPTY_ICON_SIZE = 18;
42
48
  var CHEVRON_SIZE = 16;
43
49
  var NO_SORT = "none";
50
+ var LOCAL_SORT = "local";
44
51
  var NO_EXPANSION = "none";
52
+ var NO_FROZEN = 0;
45
53
  var ARIA_SORT = {
46
54
  asc: "ascending",
47
55
  desc: "descending",
@@ -102,9 +110,10 @@ var isOpen = (row) => row.querySelector(":scope > .expand-cell > .expand")?.getA
102
110
  /**
103
111
  * Rows of data under column headings. `columns` say what each column shows and how (`format`: text, number, date,
104
112
  * badge, code); `rows` are plain objects. Sortable headings cycle ascending, descending and unsorted, and sort the
105
- * rows in place; `selectable` adds a checkbox column. The header stays on top while the rows scroll within
106
- * `max-height`, and the table scrolls sideways on narrow screens. Cells of a column can be drawn by code with
107
- * `renderers`. `expandable` rows open on a press to show their `detail` under them, the row staying as it is: one at
113
+ * rows in place, or leave the order to the page (`sort-mode="remote"`); `selectable` adds a checkbox column.
114
+ * `hidden-columns` leaves columns out, and `column-chooser` lets people choose them. The header stays on top while the
115
+ * rows scroll within `max-height`, and the table scrolls sideways on narrow screens. Cells of a column can be drawn by
116
+ * code with `renderers`. `expandable` rows open on a press to show their `detail` under them, the row staying as it is: one at
108
117
  * a time (`single`) or any number (`multiple`). A press on a row fires `press` with the row, the button and the
109
118
  * browser's event, which a page cancels to refuse it: to open a record on a click, its own menu on a right click.
110
119
  *
@@ -114,7 +123,7 @@ var isOpen = (row) => row.querySelector(":scope > .expand-cell > .expand")?.getA
114
123
  var JlTable = class extends JlElement {
115
124
  static selector = "jl-table";
116
125
  events = this.useEvents();
117
- columns = this.useChange([], () => this.schedule("head", "body"), {
126
+ columns = this.useChange([], () => this.schedule("head", "body", "chooser"), {
118
127
  attribute: "columns",
119
128
  parse: jsonOf([])
120
129
  });
@@ -136,6 +145,33 @@ var JlTable = class extends JlElement {
136
145
  attribute: "sort-direction",
137
146
  parse: oneOf(TABLE_SORT_DIRECTIONS, NO_SORT)
138
147
  });
148
+ /**
149
+ * Who orders the rows: the table (`local`), or the page (`remote`): a heading's press then shows the sort and
150
+ * emits `sort`, and the rows stay in the order given, as a server sorted them.
151
+ */
152
+ sortMode = this.useChange(LOCAL_SORT, () => this.schedule("order"), {
153
+ attribute: "sort-mode",
154
+ parse: oneOf(TABLE_SORT_MODES, LOCAL_SORT)
155
+ });
156
+ /** The keys of the columns not drawn; a column with `hideable: false` shows whatever it says. */
157
+ hiddenColumns = this.useChange([], () => this.schedule("head", "body", "choices"), {
158
+ attribute: "hidden-columns",
159
+ parse: textListOf
160
+ });
161
+ /** A button at the end of the header row opens the list of columns, whose boxes show or hide them. */
162
+ columnChooser = this.useChange(false, (value) => this.renderColumnChooser(value), { attribute: "column-chooser" });
163
+ /** How many columns stay in view at the start while the rows scroll sideways; the checkbox and chevron stay too. */
164
+ frozenStart = this.useChange(NO_FROZEN, () => this.schedule("frozen"), {
165
+ attribute: "frozen-start",
166
+ parse: clampedNumber(NO_FROZEN, NO_FROZEN, Number.MAX_SAFE_INTEGER)
167
+ });
168
+ /** How many columns stay in view at the end while the rows scroll sideways. */
169
+ frozenEnd = this.useChange(NO_FROZEN, () => this.schedule("frozen"), {
170
+ attribute: "frozen-end",
171
+ parse: clampedNumber(NO_FROZEN, NO_FROZEN, Number.MAX_SAFE_INTEGER)
172
+ });
173
+ /** The column chooser's name, on its button and over its list; jlib's own text when empty. */
174
+ columnsLabel = this.useChange("", () => this.drawColumnsLabel(), { attribute: "columns-label" });
139
175
  /** Adds a checkbox to each row, and one in the header that selects them all. */
140
176
  selectable = this.useChange(false, (value) => {
141
177
  this.reflect("selectable", value);
@@ -185,10 +221,23 @@ var JlTable = class extends JlElement {
185
221
  _source = { detail: null };
186
222
  _pending = {
187
223
  body: false,
224
+ choices: false,
225
+ chooser: false,
226
+ frozen: false,
188
227
  head: false,
189
228
  order: false,
190
229
  queued: false
191
230
  };
231
+ _frozen = { sizes: watchSizes(() => this.measureFrozen()) };
232
+ /**
233
+ * The column chooser once drawn, its boxes by column key, changed in place so the focus stays on the box pressed,
234
+ * and what watches the rows' scrollbar, which the chooser stands beside.
235
+ */
236
+ _chooser = {
237
+ boxes: /* @__PURE__ */ new Map(),
238
+ parts: null,
239
+ sizes: watchSizes(() => this.placeChooser())
240
+ };
192
241
  /**
193
242
  * The rows as drawn in the order of `rows` (the rows and their checkboxes carry their place), by key, and their
194
243
  * keys in the order shown; the keys each state was last drawn for, so a change redraws only the rows it concerns.
@@ -201,9 +250,12 @@ var JlTable = class extends JlElement {
201
250
  };
202
251
  _refs = this.useRefs((ref) => ({
203
252
  body: ref("tbody"),
253
+ chooser: ref(".chooser"),
204
254
  foot: ref(".foot"),
205
255
  footSlot: ref("slot[name=\"footer\"]"),
256
+ frozenRules: ref("style.frozen-rules"),
206
257
  head: ref("thead"),
258
+ scroll: ref(".scroll"),
207
259
  table: ref("table")
208
260
  }));
209
261
  /** Draws what an open row shows under it, from the row: `(row) => <JlFacts items={…} />`. */
@@ -227,15 +279,23 @@ var JlTable = class extends JlElement {
227
279
  return /* @__PURE__ */ jsxs("div", {
228
280
  class: "frame",
229
281
  attrs: { part: "base" },
230
- children: [/* @__PURE__ */ jsx("div", {
231
- class: "scroll",
232
- children: /* @__PURE__ */ jsxs("table", { children: [/* @__PURE__ */ jsx("thead", {}), /* @__PURE__ */ jsx("tbody", {})] })
233
- }), /* @__PURE__ */ jsx("div", {
234
- class: "foot",
235
- attrs: { part: "footer" },
236
- hidden: true,
237
- children: /* @__PURE__ */ jsx("slot", { name: "footer" })
238
- })]
282
+ children: [
283
+ /* @__PURE__ */ jsx("style", { class: "frozen-rules" }),
284
+ /* @__PURE__ */ jsx("div", {
285
+ class: "chooser",
286
+ hidden: true
287
+ }),
288
+ /* @__PURE__ */ jsx("div", {
289
+ class: "scroll",
290
+ children: /* @__PURE__ */ jsxs("table", { children: [/* @__PURE__ */ jsx("thead", {}), /* @__PURE__ */ jsx("tbody", {})] })
291
+ }),
292
+ /* @__PURE__ */ jsx("div", {
293
+ class: "foot",
294
+ attrs: { part: "footer" },
295
+ hidden: true,
296
+ children: /* @__PURE__ */ jsx("slot", { name: "footer" })
297
+ })
298
+ ]
239
299
  });
240
300
  }
241
301
  templateCss() {
@@ -252,6 +312,50 @@ var JlTable = class extends JlElement {
252
312
  if (isTableCheckbox(event.target)) this.changeSelection(event.target);
253
313
  });
254
314
  for (const type of PRESS_EVENTS) this.on(this._refs.body, type, (event) => this.pressRow(event));
315
+ this.watchScrollbar();
316
+ this.watchFrozen();
317
+ }
318
+ onDisconnect() {
319
+ this._chooser.sizes.disconnect();
320
+ this._frozen.sizes.disconnect();
321
+ }
322
+ /** Shows or hides the column chooser, drawn the first time it shows: a table without one builds none. */
323
+ renderColumnChooser(shown) {
324
+ this.reflect("column-chooser", shown);
325
+ this._refs.chooser.hidden = !shown;
326
+ if (shown && this._chooser.parts === null) this.drawChooser();
327
+ this.watchScrollbar();
328
+ }
329
+ drawChooser() {
330
+ const button = /* @__PURE__ */ jsx(JlButton, {
331
+ slot: "trigger",
332
+ icon: "columns-3",
333
+ variant: "ghost",
334
+ size: "sm"
335
+ });
336
+ const list = /* @__PURE__ */ jsx("fieldset", { class: "column-list" });
337
+ const popover = /* @__PURE__ */ jsxs(JlPopover, {
338
+ placement: "bottom-end",
339
+ children: [button, list]
340
+ });
341
+ this._chooser.parts = {
342
+ button,
343
+ list,
344
+ popover
345
+ };
346
+ this._refs.chooser.replaceChildren(popover);
347
+ this.drawColumnsLabel();
348
+ this.schedule("chooser");
349
+ }
350
+ /** The rows' scrollbar is watched while the chooser shows, so it stands beside the bar, not over it. */
351
+ watchScrollbar() {
352
+ this._chooser.sizes.disconnect();
353
+ if (this.isConnected && this.columnChooser.get()) this._chooser.sizes.observe(this._refs.scroll);
354
+ }
355
+ /** The scroller's width counts its scrollbar and its client width does not: the chooser moves left by the bar. */
356
+ placeChooser() {
357
+ const scroll = this._refs.scroll;
358
+ this.style.setProperty("--scrollbar", `${scroll.offsetWidth - scroll.clientWidth}px`);
255
359
  }
256
360
  /** The bar under the rows shows when the page put something in it; what stands there alone goes to its end. */
257
361
  drawFoot() {
@@ -261,8 +365,18 @@ var JlTable = class extends JlElement {
261
365
  }
262
366
  /** Draws on the next microtask: the inputs set while connecting give one drawing, not one each. */
263
367
  drawTexts() {
368
+ this.drawColumnsLabel();
264
369
  this.schedule("head", "body");
265
370
  }
371
+ /** The chooser's name: its button's, its list's and the heading over the list. */
372
+ drawColumnsLabel() {
373
+ const parts = this._chooser.parts;
374
+ if (parts === null) return;
375
+ const label = this.columnsLabel.get() || jlText("columns");
376
+ parts.button.hint.set(label);
377
+ parts.popover.heading.set(label);
378
+ parts.list.setAttribute("aria-label", label);
379
+ }
266
380
  schedule(...parts) {
267
381
  for (const part of parts) this._pending[part] = true;
268
382
  if (this._pending.queued) return;
@@ -270,14 +384,20 @@ var JlTable = class extends JlElement {
270
384
  queueMicrotask(() => this.flush());
271
385
  }
272
386
  flush() {
273
- const { body, head, order } = this._pending;
387
+ const { body, choices, chooser, frozen, head, order } = this._pending;
274
388
  Object.assign(this._pending, {
275
389
  body: false,
390
+ choices: false,
391
+ chooser: false,
392
+ frozen: false,
276
393
  head: false,
277
394
  order: false,
278
395
  queued: false
279
396
  });
397
+ if (chooser) this.renderChooser();
398
+ if (choices && !chooser) this.renderChoices();
280
399
  if (head) this.renderHead();
400
+ if (head || frozen) this.renderFrozen();
281
401
  if (head || order) this.renderSortState();
282
402
  if (body) this.renderBody();
283
403
  if (order && !body) this.renderOrder();
@@ -285,6 +405,36 @@ var JlTable = class extends JlElement {
285
405
  this.renderSelection();
286
406
  this.renderExpansion();
287
407
  }
408
+ /** The columns drawn: all but the hidden ones, a column that cannot be hidden staying. */
409
+ shownColumns() {
410
+ return shownColumns(this.columns.get(), this.hiddenColumns.get());
411
+ }
412
+ /** One box per column, in their order, drawn again when the columns change. */
413
+ renderChooser() {
414
+ const list = this._chooser.parts?.list;
415
+ if (list === void 0) return;
416
+ const boxes = this.columns.get().map(({ key, label }) => [key, /* @__PURE__ */ jsx(JlCheckbox, {
417
+ label,
418
+ onChange: (shown) => this.chooseColumn(key, shown)
419
+ })]);
420
+ this._chooser.boxes = new Map(boxes);
421
+ list.replaceChildren(...this._chooser.boxes.values());
422
+ this.renderChoices();
423
+ }
424
+ /** Ticks the boxes of the columns shown and turns off those that cannot change, in place. */
425
+ renderChoices() {
426
+ for (const { key, locked, shown } of columnChoices(this.columns.get(), this.hiddenColumns.get())) {
427
+ const box = this._chooser.boxes.get(key);
428
+ box?.checked.set(shown);
429
+ box?.disabled.set(locked);
430
+ }
431
+ }
432
+ /** A box of the chooser was ticked or cleared: the column shows or hides, and the page hears which are hidden. */
433
+ chooseColumn(key, shown) {
434
+ const hidden = toggleKey(this.hiddenColumns.get(), key, !shown);
435
+ this.hiddenColumns.set(hidden);
436
+ this.events.emit("columns", hidden);
437
+ }
288
438
  sortBy(name) {
289
439
  const key = this.columns.get().find((column) => column.key === name)?.key;
290
440
  if (key === void 0) return;
@@ -355,6 +505,53 @@ var JlTable = class extends JlElement {
355
505
  span(columns) {
356
506
  return columns.length + Number(this.selectable.get()) + Number(this.isExpandable());
357
507
  }
508
+ /** The cells that stay in view at each side: the frozen columns among those shown, the lead cells with the start. */
509
+ frozenCells() {
510
+ const lead = Number(this.selectable.get()) + Number(this.isExpandable());
511
+ return frozenCells(this.shownColumns().length, lead, {
512
+ end: this.frozenEnd.get(),
513
+ start: this.frozenStart.get()
514
+ });
515
+ }
516
+ /** The rules that keep the frozen cells in view, by their place in the row: rows drawn later need nothing. */
517
+ renderFrozen() {
518
+ const rules = frozenCss(this.frozenCells());
519
+ if (this._refs.frozenRules.textContent !== rules) this._refs.frozenRules.textContent = rules;
520
+ this.watchFrozen();
521
+ }
522
+ watchFrozen() {
523
+ const sizes = this._frozen.sizes;
524
+ sizes.disconnect();
525
+ const { end, start } = this.frozenCells();
526
+ if (!this.isConnected || start + end === 0) {
527
+ this.reflect("scrolls-sideways", false);
528
+ return;
529
+ }
530
+ const cells = this.headingCells();
531
+ const frozen = [...cells.slice(0, start), ...cells.slice(cells.length - end)];
532
+ for (const element of [
533
+ ...frozen,
534
+ this._refs.scroll,
535
+ this._refs.table
536
+ ]) sizes.observe(element);
537
+ }
538
+ /** The frozen cells' offsets, from the headings' widths, and whether the rows scroll sideways, which shows the lines. */
539
+ measureFrozen() {
540
+ const { end, start } = this.frozenCells();
541
+ const widths = this.headingCells().map((cell) => cell.getBoundingClientRect().width);
542
+ this.setFrozenOffsets("start", stickyOffsets(widths.slice(0, start)));
543
+ this.setFrozenOffsets("end", stickyOffsets(widths.slice(widths.length - end).reverse()));
544
+ const scroll = this._refs.scroll;
545
+ this.reflect("scrolls-sideways", scroll.scrollWidth > scroll.clientWidth);
546
+ }
547
+ setFrozenOffsets(side, offsets) {
548
+ offsets.forEach((offset, index) => {
549
+ this.style.setProperty(`--frozen-${side}-${index}`, `${offset}px`);
550
+ });
551
+ }
552
+ headingCells() {
553
+ return [...this._refs.head.rows[0]?.cells ?? []];
554
+ }
358
555
  renderHead() {
359
556
  const selectAll = this.selectable.get() ? /* @__PURE__ */ jsx("th", {
360
557
  class: "select-cell",
@@ -372,7 +569,7 @@ var JlTable = class extends JlElement {
372
569
  this._refs.head.replaceChildren(/* @__PURE__ */ jsxs("tr", { children: [
373
570
  selectAll,
374
571
  details,
375
- this.columns.get().map((column) => this.headerCell(column))
572
+ this.shownColumns().map((column) => this.headerCell(column))
376
573
  ] }));
377
574
  }
378
575
  headerCell(column) {
@@ -403,10 +600,13 @@ var JlTable = class extends JlElement {
403
600
  cell.querySelector(".sort-icon")?.name.set(SORT_ICONS[direction]);
404
601
  }
405
602
  }
406
- /** The drawn rows in the order of the sort; each row's sort value is read once, not at every comparison. */
603
+ /**
604
+ * The drawn rows in the order of the sort; each row's sort value is read once, not at every comparison. Sorted by
605
+ * the page, they stay in the order given.
606
+ */
407
607
  sortedView() {
408
608
  const key = this.sortKey.get();
409
- if (key === NO_SORT_KEY) return [...this._view.drawn];
609
+ if (key === NO_SORT_KEY || this.sortMode.get() === "remote") return [...this._view.drawn];
410
610
  const format = this.columns.get().find((column) => column.key === key)?.format;
411
611
  return sortBy(this._view.drawn, ({ row }) => fieldOf(row, key), {
412
612
  direction: this.sortDirection.get(),
@@ -414,7 +614,7 @@ var JlTable = class extends JlElement {
414
614
  });
415
615
  }
416
616
  renderBody() {
417
- const columns = this.columns.get();
617
+ const columns = this.shownColumns();
418
618
  if (this.loading.get()) {
419
619
  this.setView([]);
420
620
  this._refs.body.replaceChildren(...this.skeletonRows(columns));
@@ -586,7 +786,7 @@ var JlTable = class extends JlElement {
586
786
  class: "detail",
587
787
  id,
588
788
  children: /* @__PURE__ */ jsx("td", {
589
- colSpan: this.span(this.columns.get()),
789
+ colSpan: this.span(this.shownColumns()),
590
790
  children: /* @__PURE__ */ jsx("div", {
591
791
  class: "detail-body",
592
792
  children: data === void 0 || draw === null ? "" : draw(data)
@@ -606,4 +806,4 @@ var JlTable = class extends JlElement {
606
806
  }
607
807
  };
608
808
  JlTable.register();
609
- export { JlTable, TABLE_EXPANSIONS, TABLE_SORT_DIRECTIONS };
809
+ export { JlTable, TABLE_EXPANSIONS, TABLE_SORT_DIRECTIONS, TABLE_SORT_MODES };
@@ -1,9 +1,9 @@
1
1
  import { jlText } from "../lib/texts.js";
2
2
  import { BASE_STYLES } from "../styles/shared.js";
3
3
  import { JlElement } from "../base/jl-element.js";
4
+ import { watchSizes } from "../lib/resize.js";
4
5
  import { registerIcons } from "../lib/icons.js";
5
6
  import { JlIcon } from "../atoms/jl-icon.js";
6
- import { watchSizes } from "../lib/resize.js";
7
7
  import jl_app_shell_default from "./jl-app-shell.css.js";
8
8
  import { css } from "@jadis/core";
9
9
  import { Menu } from "lucide";
@@ -6,3 +6,8 @@ export type ComboboxOption = {
6
6
  description?: string;
7
7
  disabled?: boolean;
8
8
  };
9
+ /**
10
+ * Who narrows the options to what was typed: the combobox (`local`), or the page (`none`), which hears `input` and
11
+ * gives the options it found, shown as they are.
12
+ */
13
+ export type ComboboxFilter = 'local' | 'none';
@@ -5,6 +5,11 @@ export type TableCellFormat = 'text' | 'number' | 'date' | 'datetime' | 'badge'
5
5
  export type TableAlign = 'left' | 'center' | 'right';
6
6
  /** The order of a sorted column; `none` keeps the rows as they came. */
7
7
  export type TableSortDirection = 'asc' | 'desc' | 'none';
8
+ /**
9
+ * Who orders the rows: the table (`local`), or the page (`remote`), which hears of the sort and gives the rows in
10
+ * that order, as a server sorts a page of results.
11
+ */
12
+ export type TableSortMode = 'local' | 'remote';
8
13
  /** A row of a table that does not say its type: any field, of any value. */
9
14
  export type TableRow = Record<string, unknown>;
10
15
  /** The names of a type of row's fields: what a column shows, sorts by, or shows under its value. */
@@ -38,6 +43,18 @@ export type TableColumn<Row extends object = TableRow, Extra extends string = ne
38
43
  * otherwise.
39
44
  */
40
45
  wrap?: boolean;
46
+ /** `false` keeps the column shown, whatever `hiddenColumns` says; the column chooser shows its box ticked and off. */
47
+ hideable?: boolean;
48
+ };
49
+ /**
50
+ * A column's line in the column chooser: shown or not, and locked when its box cannot change: a column that cannot
51
+ * be hidden, or the last one shown.
52
+ */
53
+ export type TableColumnChoice<Key extends string = string> = {
54
+ key: Key;
55
+ label: string;
56
+ shown: boolean;
57
+ locked: boolean;
41
58
  };
42
59
  /** A row's identity, the value of its `row-key` field. */
43
60
  export type TableRowKey = string | number;
@@ -73,3 +90,8 @@ export type TablePress<Row extends object = TableRow> = {
73
90
  button: PressButton;
74
91
  event: MouseEvent;
75
92
  };
93
+ /** How many cells of each row stay in view at each side while the rows scroll sideways. */
94
+ export type TableFrozen = {
95
+ start: number;
96
+ end: number;
97
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syware/jlib",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "description": "A tree-shakeable component library on Jadis and native Web Components, organised in atomic design",
5
5
  "keywords": [
6
6
  "web-components",
@@ -101,6 +101,7 @@
101
101
  "@types/node": "^24.13.3",
102
102
  "axe-core": "^4.14.0",
103
103
  "happy-dom": "^21.0.4",
104
+ "jsdom": "^30.1.3",
104
105
  "playwright-core": "^1.64.1",
105
106
  "typescript": "^7.0.2",
106
107
  "vite": "^8.3.5",
@@ -1,3 +0,0 @@
1
- // src/molecules/jl-combobox.css?inline
2
- var jl_combobox_default = ":host{min-width:0;display:block}.toggle jl-icon{transition:transform var(--jl-fast) var(--jl-ease)}:host([open]) .toggle jl-icon{transform:rotate(180deg)}.toggle:disabled{cursor:not-allowed}.popup{padding:4px}.listbox{max-height:min(264px, var(--room,100dvh) - 10px);margin:0;padding:0;list-style:none;position:relative;overflow-y:auto}.option{border-radius:var(--jl-radius-xs);min-height:34px;color:var(--jl-text);font-size:var(--jl-font-md);cursor:pointer;-webkit-user-select:none;user-select:none;align-items:center;gap:10px;padding:6px 10px;line-height:1.35;display:flex}.option[aria-selected=true]{background:var(--jl-surface-3)}.option-label{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.option.chosen .option-label{font-weight:600}.option[aria-disabled=true]{color:var(--jl-faint);cursor:not-allowed}.text{flex:1;gap:1px;min-width:0;display:grid}.description{color:var(--jl-muted);font-size:var(--jl-font-xs)}.check{color:var(--jl-accent);visibility:hidden}.option.chosen .check{visibility:visible}mark{color:var(--jl-accent);background:0 0;font-weight:700}.empty{color:var(--jl-muted);font-size:var(--jl-font-sm);padding:8px 10px}";
3
- export { jl_combobox_default as default };