@fusion.dev/helix-headless 0.240.4 → 0.241.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.
@@ -5,6 +5,7 @@ import { property, state } from 'lit/decorators.js';
5
5
  import { html } from 'lit/static-html.js';
6
6
  import { TableBinding } from '../../data-table/binding.js';
7
7
  import '../../button/index.js';
8
+ import '../../radio/index.js';
8
9
  const exports = (table) => table !== null && typeof table.download === 'function';
9
10
  let HelixHeadlessTableExport = class HelixHeadlessTableExport extends HelixElement {
10
11
  constructor() {
@@ -64,16 +65,13 @@ let HelixHeadlessTableExport = class HelixHeadlessTableExport extends HelixEleme
64
65
  this.said = formatWords(this, 'copiedLabel', { count: table.exportData(options).rows.length });
65
66
  return true;
66
67
  }
67
- renderChoices(name, current, choices, choose) {
68
- return choices.map((choice) => html `<label part="choice${choice.value === current ? ' choice-checked' : ''}"
69
- ><input
70
- part="choice-input"
71
- type="radio"
72
- name=${name}
73
- .value=${choice.value}
74
- .checked=${choice.value === current}
75
- @change=${() => choose(choice.value)}
76
- />${choice.label}</label
68
+ renderChoices(current, choices) {
69
+ const radio = this.tag('radio');
70
+ return choices.map((choice) => html `<${radio}
71
+ part="choice${choice.value === current ? ' choice-checked' : ''}"
72
+ exportparts="box: choice-box, item: choice-item, label: choice-label"
73
+ value=${choice.value}
74
+ >${choice.label}</${radio}
77
75
  >`);
78
76
  }
79
77
  renderActions(count, found) {
@@ -104,9 +102,8 @@ let HelixHeadlessTableExport = class HelixHeadlessTableExport extends HelixEleme
104
102
  { label: 'JSON', value: 'json' },
105
103
  ...(exports(table) && table.xlsx ? [{ label: 'XLSX', value: 'xlsx' }] : []),
106
104
  ];
107
- return html `<fieldset part="rows">
108
- <legend part="legend">${this.rowsLabel}</legend>
109
- <div part="options">${this.renderChoices('rows', options.rows, [
105
+ const group = this.tag('radio-group');
106
+ const rows = [
110
107
  ...(selected > 0
111
108
  ? [
112
109
  {
@@ -123,11 +120,24 @@ let HelixHeadlessTableExport = class HelixHeadlessTableExport extends HelixEleme
123
120
  label: formatWords(this, 'allRowsLabel', { count: table?.everyRowCount ?? 0 }),
124
121
  value: 'all',
125
122
  },
126
- ], (value) => (this.chosenRows = value))}</div>
127
- </fieldset>
128
- <fieldset part="columns">
129
- <legend part="legend">${this.columnsLabel}</legend>
130
- <div part="options">${this.renderChoices('columns', options.columns, [
123
+ ];
124
+ const value = (event) => event.target.value;
125
+ return html `<${group}
126
+ part="rows"
127
+ exportparts="feedback: rows-feedback, hint: rows-hint, items: rows-items, label: rows-label"
128
+ label=${this.rowsLabel}
129
+ .value=${options.rows}
130
+ @change=${(event) => (this.chosenRows = value(event))}
131
+ >${this.renderChoices(options.rows, rows)}</${group}
132
+ >
133
+ <${group}
134
+ part="columns"
135
+ exportparts="feedback: columns-feedback, hint: columns-hint, items: columns-items, label: columns-label"
136
+ label=${this.columnsLabel}
137
+ orientation="horizontal"
138
+ .value=${options.columns}
139
+ @change=${(event) => (this.chosenColumns = value(event))}
140
+ >${this.renderChoices(options.columns, [
131
141
  {
132
142
  label: formatWords(this, 'visibleColumnsLabel', { count: visible }),
133
143
  value: 'visible',
@@ -136,19 +146,29 @@ let HelixHeadlessTableExport = class HelixHeadlessTableExport extends HelixEleme
136
146
  label: formatWords(this, 'allColumnsLabel', { count: columns.length }),
137
147
  value: 'all',
138
148
  },
139
- ], (value) => (this.chosenColumns = value))}</div>
140
- </fieldset>
141
- <fieldset part="values">
142
- <legend part="legend">${this.valuesLabel}</legend>
143
- <div part="options">${this.renderChoices('values', options.values, [
149
+ ])}</${group}
150
+ >
151
+ <${group}
152
+ part="values"
153
+ exportparts="feedback: values-feedback, hint: values-hint, items: values-items, label: values-label"
154
+ label=${this.valuesLabel}
155
+ orientation="horizontal"
156
+ .value=${options.values}
157
+ @change=${(event) => (this.chosenValues = value(event))}
158
+ >${this.renderChoices(options.values, [
144
159
  { label: this.shownLabel, value: 'shown' },
145
160
  { label: this.rawLabel, value: 'raw' },
146
- ], (value) => (this.chosenValues = value))}</div>
147
- </fieldset>
148
- <fieldset part="format">
149
- <legend part="legend">${this.formatLabel}</legend>
150
- <div part="options">${this.renderChoices('format', options.format, formats, (value) => (this.chosenFormat = value))}</div>
151
- </fieldset>
161
+ ])}</${group}
162
+ >
163
+ <${group}
164
+ part="format"
165
+ exportparts="feedback: format-feedback, hint: format-hint, items: format-items, label: format-label"
166
+ label=${this.formatLabel}
167
+ orientation="horizontal"
168
+ .value=${options.format}
169
+ @change=${(event) => (this.chosenFormat = value(event))}
170
+ >${this.renderChoices(options.format, formats)}</${group}
171
+ >
152
172
  ${this.renderActions(count, table !== null)}
153
173
  <span part="live" aria-live="polite">${this.said || nothing}</span>`;
154
174
  }
@@ -1,5 +1,6 @@
1
1
  import { HelixElement } from '@fusion.dev/helix-core';
2
2
  import { type PropertyValues, type TemplateResult } from 'lit';
3
+ import '../../checkbox/index.js';
3
4
  /** Where an item stands in a move: the item being moved, or the one the drop indicator is beside. */
4
5
  export type TreeItemMove = 'dragging' | 'drop-after' | 'drop-before';
5
6
  declare const HelixHeadlessTreeItem_base: (new (...args: any[]) => import("@fusion.dev/helix-core").MixinControllerOpenInterface) & typeof HelixElement;
@@ -72,9 +73,20 @@ declare const HelixHeadlessTreeItem_base: (new (...args: any[]) => import("@fusi
72
73
  * @event {ToggleEvent} toggle - Sent when the branch opens or closes, with `newState` and `oldState`.
73
74
  *
74
75
  * @csspart actions - The `actions` slot, which draws no box of its own. `inert` while the actions are not shown, which takes what it holds off the tab order and out of reach of the pointer.
75
- * @csspart checkbox - The check mark's box, in a tree with `selection-mode="multiple"`.
76
- * @csspart checkbox-checked - The check mark's box while the item is checked.
77
- * @csspart checkbox-mixed - The check mark's box while some of a branch's items are checked.
76
+ * @csspart check - The inert `Checkbox` that draws the check mark, inside `checkbox`.
77
+ * @csspart check-box - Forwarded from the checkbox: the box drawn for its input.
78
+ * @csspart check-control - Forwarded from the checkbox: its native input, inert.
79
+ * @csspart check-feedback - Forwarded from the checkbox. Not shown, since a check mark is never wrong.
80
+ * @csspart check-field - Forwarded from the checkbox: the row that holds its box.
81
+ * @csspart check-hint - Forwarded from the checkbox. Not shown, since a check mark has no help.
82
+ * @csspart check-label - Forwarded from the checkbox. Not shown, since the item's own label names it.
83
+ * @csspart check-mark - Forwarded from the checkbox: the tick, or the dash while some of a branch's items are checked.
84
+ * @csspart check-mark-checked - Forwarded from the checkbox: added to `check-mark` while the item is checked.
85
+ * @csspart check-mark-dash - Forwarded from the checkbox: added to `check-mark` while it is the dash.
86
+ * @csspart check-mark-indeterminate - Forwarded from the checkbox: added to `check-mark` while some of a branch's items are checked.
87
+ * @csspart checkbox - What holds the check mark, in a tree with `selection-mode="multiple"`. A press on it checks the item.
88
+ * @csspart checkbox-checked - Added to `checkbox` while the item is checked.
89
+ * @csspart checkbox-mixed - Added to `checkbox` while some of a branch's items are checked.
78
90
  * @csspart grip - The handle a pointer drags to move the item, in a `reorderable` tree. Hidden from screen readers, which move the item with Alt and an arrow.
79
91
  * @csspart grip-mark - The icon on the grip.
80
92
  * @csspart group - The container for nested items.
@@ -270,7 +282,21 @@ export declare class HelixHeadlessTreeItem extends HelixHeadlessTreeItem_base {
270
282
  * fallback, so an icon of your own replaces it by being slotted.
271
283
  */
272
284
  protected renderToggle(): TemplateResult;
273
- /** The check mark, in a tree with `selection-mode="multiple"`. */
285
+ /**
286
+ * The check mark, in a tree with `selection-mode="multiple"`: the library's
287
+ * own `Checkbox`, so the box is the one every form draws, and `inert`.
288
+ *
289
+ * **Inert, because the row is the control.** The row is a `treeitem` that
290
+ * says checked, unchecked or mixed in a multiselectable tree, and a tree is
291
+ * one tab stop moved by the arrow keys. A live checkbox in it would be a
292
+ * second control read inside every row and a tab stop of its own. `inert`
293
+ * takes the box out of focus, out of the accessibility tree and out of
294
+ * hit testing, so it only draws. In a shadow root it joins no form either.
295
+ *
296
+ * **The press lands on the span around it.** An inert element is not a
297
+ * target, so a press on the box goes to the span under it, which checks the
298
+ * row, as a press on the box always has.
299
+ */
274
300
  private renderCheckbox;
275
301
  /** Everything inside the row, which is the same whichever element it is. */
276
302
  private renderRow;
@@ -1,10 +1,12 @@
1
1
  import { __decorate } from "tslib";
2
2
  import { auditNesting, customElement, HelixBeforeSelectEvent, HelixElement, HelixLoadEvent, MixinControllerOpen, } from '@fusion.dev/helix-core';
3
- import { caretDown, check, dotsSixVertical, minus } from '@fusion.dev/helix-icons';
4
- import { html, nothing } from 'lit';
3
+ import { caretDown, dotsSixVertical } from '@fusion.dev/helix-icons';
4
+ import { nothing } from 'lit';
5
5
  import { property, state } from 'lit/decorators.js';
6
6
  import { unsafeSVG } from 'lit/directives/unsafe-svg.js';
7
+ import { html } from 'lit/static-html.js';
7
8
  import { fromGrip } from '../grip.js';
9
+ import '../../checkbox/index.js';
8
10
  let HelixHeadlessTreeItem = class HelixHeadlessTreeItem extends MixinControllerOpen(HelixElement) {
9
11
  constructor() {
10
12
  super(...arguments);
@@ -204,14 +206,21 @@ let HelixHeadlessTreeItem = class HelixHeadlessTreeItem extends MixinControllerO
204
206
  return nothing;
205
207
  }
206
208
  const mixed = this.checked === 'mixed';
207
- const glyph = mixed ? minus : this.checked ? check : undefined;
209
+ const checkbox = this.tag('checkbox');
208
210
  return html `<span
209
211
  part="checkbox${mixed ? ' checkbox-mixed' : this.checked ? ' checkbox-checked' : ''}"
210
212
  aria-hidden="true"
211
213
  @click=${this.handleCheckClick}
212
- >${glyph
213
- ? html `<svg fill="currentColor" viewBox=${glyph.viewBox}>${unsafeSVG(glyph.content)}</svg>`
214
- : nothing}</span
214
+ ><${checkbox}
215
+ part="check"
216
+ exportparts="box: check-box, control: check-control, feedback: check-feedback,
217
+ field: check-field, hint: check-hint, label: check-label, mark: check-mark,
218
+ mark-checked: check-mark-checked, mark-dash: check-mark-dash,
219
+ mark-indeterminate: check-mark-indeterminate"
220
+ inert
221
+ .checked=${this.checked === true}
222
+ .indeterminate=${mixed}
223
+ ></${checkbox}></span
215
224
  >`;
216
225
  }
217
226
  renderRow() {
@@ -2,6 +2,7 @@ import { HelixElement } from '@fusion.dev/helix-core';
2
2
  import { type TemplateResult } from 'lit';
3
3
  import { TableBinding, type ToolTable } from '../../data-table/binding.js';
4
4
  import '../../button/index.js';
5
+ import '../../radio/index.js';
5
6
  /** The sections the panel lists, in order. */
6
7
  type Section = 'columns' | 'export' | 'filters' | 'sort';
7
8
  /**
@@ -47,8 +48,11 @@ type Section = 'columns' | 'export' | 'filters' | 'sort';
47
48
  * @slot presets - A `QuickFilters` row for the table, shown above the sections.
48
49
  *
49
50
  * @csspart back - The button that returns from a section to the list.
50
- * @csspart choice - One sort order, its input and its words.
51
- * @csspart choice-input - The radio input of a sort order.
51
+ * @csspart choice - One sort order, a `Radio`.
52
+ * @csspart choice-box - The circle of a sort order's `Radio`.
53
+ * @csspart choice-checked - Added to `choice` while it is the table's sort.
54
+ * @csspart choice-item - The button of a sort order's `Radio`, which covers its row.
55
+ * @csspart choice-label - The words of a sort order's `Radio`.
52
56
  * @csspart header - The row that holds the title, or Back, and Reset.
53
57
  * @csspart page - The open section.
54
58
  * @csspart reset - The button that clears the search, the filters, and the sort.
@@ -61,7 +65,11 @@ type Section = 'columns' | 'export' | 'filters' | 'sort';
61
65
  * @csspart show-live - Forwarded from the button. Not shown in the panel, whose button does not load.
62
66
  * @csspart show-spinner - Forwarded from the button. Not shown in the panel, whose button does not load.
63
67
  * @csspart show-text - Forwarded from the button: the words inside `show`.
64
- * @csspart sort - The sort orders the panel draws.
68
+ * @csspart sort - The `Radio Group` of sort orders the panel draws, named by its `aria-label`.
69
+ * @csspart sort-feedback - Forwarded from the radio group. Not shown, since a sort is never wrong.
70
+ * @csspart sort-hint - Forwarded from the radio group. Not shown, since the sort has no help.
71
+ * @csspart sort-items - The sort orders inside `sort`.
72
+ * @csspart sort-label - The name of `sort`, clipped, since the panel's heading already says it.
65
73
  * @csspart summary - What a section holds now.
66
74
  * @csspart title - The panel's heading.
67
75
  */
@@ -7,6 +7,7 @@ import { unsafeSVG } from 'lit/directives/unsafe-svg.js';
7
7
  import { html } from 'lit/static-html.js';
8
8
  import { columnName, TableBinding } from '../../data-table/binding.js';
9
9
  import '../../button/index.js';
10
+ import '../../radio/index.js';
10
11
  const closable = (element) => typeof element.hide === 'function' &&
11
12
  element.open === true;
12
13
  let HelixHeadlessViewPanel = class HelixHeadlessViewPanel extends HelixElement {
@@ -97,19 +98,23 @@ let HelixHeadlessViewPanel = class HelixHeadlessViewPanel extends HelixElement {
97
98
  value: `${column.field}:${direction}`,
98
99
  }))),
99
100
  ];
100
- return html `<fieldset part="sort">
101
- <legend>${this.sortLabel}</legend>
102
- ${orders.map((order) => html `<label part="choice"
103
- ><input
104
- part="choice-input"
105
- type="radio"
106
- name="sort"
107
- .value=${order.value}
108
- .checked=${table.view.sort === order.value}
109
- @change=${() => table.requestView({ sort: order.value })}
110
- />${order.label}</label
111
- >`)}
112
- </fieldset>`;
101
+ const group = this.tag('radio-group');
102
+ const radio = this.tag('radio');
103
+ return html `<${group}
104
+ part="sort"
105
+ exportparts="feedback: sort-feedback, hint: sort-hint, items: sort-items, label: sort-label"
106
+ aria-label=${this.sortLabel}
107
+ .value=${table.view.sort}
108
+ @change=${(event) => {
109
+ table.requestView({ sort: event.target.value });
110
+ }}
111
+ >${orders.map((order) => html `<${radio}
112
+ part="choice${table.view.sort === order.value ? ' choice-checked' : ''}"
113
+ exportparts="box: choice-box, item: choice-item, label: choice-label"
114
+ value=${order.value}
115
+ >${order.label}</${radio}
116
+ >`)}</${group}
117
+ >`;
113
118
  }
114
119
  renderShow(count) {
115
120
  const button = this.tag('button');