@oicl/openbridge-webcomponents-full-bundle 2.0.0-next.144 → 2.0.0-next.145

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 (30) hide show
  1. package/bundle/openbridge-webcomponents.bundle.js +4736 -4470
  2. package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
  3. package/custom-elements.json +206 -21
  4. package/dist/components/checkbox-item/checkbox-item.css.js +137 -12
  5. package/dist/components/checkbox-item/checkbox-item.css.js.map +1 -1
  6. package/dist/components/checkbox-item/checkbox-item.d.ts +68 -39
  7. package/dist/components/checkbox-item/checkbox-item.d.ts.map +1 -1
  8. package/dist/components/checkbox-item/checkbox-item.js +66 -25
  9. package/dist/components/checkbox-item/checkbox-item.js.map +1 -1
  10. package/dist/components/checkbox-list/checkbox-list-visibility.d.ts +16 -0
  11. package/dist/components/checkbox-list/checkbox-list-visibility.d.ts.map +1 -0
  12. package/dist/components/checkbox-list/checkbox-list-visibility.js +12 -0
  13. package/dist/components/checkbox-list/checkbox-list-visibility.js.map +1 -0
  14. package/dist/components/checkbox-list/checkbox-list.css.js +23 -0
  15. package/dist/components/checkbox-list/checkbox-list.css.js.map +1 -0
  16. package/dist/components/checkbox-list/checkbox-list.d.ts +66 -0
  17. package/dist/components/checkbox-list/checkbox-list.d.ts.map +1 -0
  18. package/dist/components/checkbox-list/checkbox-list.js +81 -0
  19. package/dist/components/checkbox-list/checkbox-list.js.map +1 -0
  20. package/package.json +1 -1
  21. package/src/components/checkbox-item/checkbox-item.css +63 -17
  22. package/src/components/checkbox-item/checkbox-item.spec.ts +115 -0
  23. package/src/components/checkbox-item/checkbox-item.stories.ts +82 -97
  24. package/src/components/checkbox-item/checkbox-item.ts +118 -64
  25. package/src/components/checkbox-list/checkbox-list-visibility.spec.ts +68 -0
  26. package/src/components/checkbox-list/checkbox-list-visibility.ts +23 -0
  27. package/src/components/checkbox-list/checkbox-list.css +13 -0
  28. package/src/components/checkbox-list/checkbox-list.spec.ts +93 -0
  29. package/src/components/checkbox-list/checkbox-list.stories.ts +161 -0
  30. package/src/components/checkbox-list/checkbox-list.ts +130 -0
@@ -0,0 +1,130 @@
1
+ import {LitElement, html, unsafeCSS, type PropertyValues} from 'lit';
2
+ import {property} from 'lit/decorators.js';
3
+ import {customElement} from '../../decorator.js';
4
+ import componentStyle from './checkbox-list.css?inline';
5
+ import {
6
+ ObcCheckboxItem,
7
+ ObcCheckboxItemHoverStyle,
8
+ type ObcCheckboxItemExpandToggleEvent,
9
+ } from '../checkbox-item/checkbox-item.js';
10
+ import {computeHiddenRows} from './checkbox-list-visibility.js';
11
+
12
+ /**
13
+ * `<obc-checkbox-list>` – A vertical list of `<obc-checkbox-item>` rows that
14
+ * collapses the rows under a closed parent.
15
+ *
16
+ * ### Overview
17
+ * Rows are slotted flat, in document order; the tree is read from each row's
18
+ * `level`. When an expandable row is collapsed, the list sets `hidden` on
19
+ * every following row with a greater level until a row of equal or smaller
20
+ * level. The list also applies its `hoverStyle` to every row so a list reads
21
+ * as one surface.
22
+ *
23
+ * ### Features
24
+ * - Flat markup, level-driven hierarchy — no nesting of elements required.
25
+ * - Handles `expand-toggle`: sets the row's `expanded` and recomputes.
26
+ * - Reacts to `expandable`, `expanded` and `level` changes made from outside.
27
+ * - `hoverStyle` forwarded to slotted rows, including rows added later.
28
+ *
29
+ * ### Usage Guidelines
30
+ * - Start levels at 1 when any row is expandable so chevrons and checkboxes
31
+ * align; use level 0 for a plain list.
32
+ * - The list owns the `hidden` attribute of its rows; do not bind it yourself.
33
+ * - Selection stays per row: listen to each row's `change`.
34
+ *
35
+ * ### Accessibility
36
+ * The host is the `role="group"`; rows are ordinary checkboxes and buttons in
37
+ * the natural tab order and hidden rows leave it. This is a group of
38
+ * checkboxes with disclosure buttons, not a tree widget, so there is no
39
+ * roving tabindex. Name the group with `aria-label` or `aria-labelledby` on
40
+ * the host.
41
+ *
42
+ * ### Example
43
+ * ```html
44
+ * <obc-checkbox-list aria-label="Report types">
45
+ * <obc-checkbox-item level="1" expandable expanded status="mixed" label="Reports"></obc-checkbox-item>
46
+ * <obc-checkbox-item level="2" status="checked" label="Monthly"></obc-checkbox-item>
47
+ * <obc-checkbox-item level="2" label="Quarterly"></obc-checkbox-item>
48
+ * <obc-checkbox-item level="1" expandable label="Archive"></obc-checkbox-item>
49
+ * </obc-checkbox-list>
50
+ * ```
51
+ *
52
+ * @property hoverStyle - Hover treatment applied to every slotted row: `touch-target` or `visual-target`.
53
+ * @slot - `obc-checkbox-item` rows in document order; hierarchy comes from each row's `level`.
54
+ * @beta
55
+ */
56
+ @customElement('obc-checkbox-list')
57
+ export class ObcCheckboxList extends LitElement {
58
+ @property({type: String}) hoverStyle: ObcCheckboxItemHoverStyle =
59
+ ObcCheckboxItemHoverStyle.touchTarget;
60
+
61
+ private mutationObserver?: MutationObserver;
62
+
63
+ override connectedCallback(): void {
64
+ super.connectedCallback();
65
+ // The role sits on the host so a consumer's aria-label / aria-labelledby
66
+ // names the group.
67
+ if (!this.hasAttribute('role')) this.setAttribute('role', 'group');
68
+ // Rows are light-DOM children owned by the consumer, so `expandable`,
69
+ // `expanded` and `level` can change without any event reaching the list.
70
+ this.mutationObserver = new MutationObserver(() => this.sync());
71
+ this.mutationObserver.observe(this, {
72
+ childList: true,
73
+ attributes: true,
74
+ attributeFilter: ['expandable', 'expanded', 'level'],
75
+ subtree: true,
76
+ });
77
+ this.addEventListener('expand-toggle', this.onExpandToggle);
78
+ }
79
+
80
+ override disconnectedCallback(): void {
81
+ super.disconnectedCallback();
82
+ this.mutationObserver?.disconnect();
83
+ this.mutationObserver = undefined;
84
+ this.removeEventListener('expand-toggle', this.onExpandToggle);
85
+ }
86
+
87
+ override firstUpdated(): void {
88
+ this.sync();
89
+ }
90
+
91
+ override updated(changed: PropertyValues<this>): void {
92
+ if (changed.has('hoverStyle')) this.sync();
93
+ }
94
+
95
+ private onExpandToggle = (event: Event): void => {
96
+ const row = event.target;
97
+ if (!(row instanceof ObcCheckboxItem)) return;
98
+ row.expanded = (event as ObcCheckboxItemExpandToggleEvent).detail;
99
+ this.sync();
100
+ };
101
+
102
+ private rows(): ObcCheckboxItem[] {
103
+ return Array.from(this.children).filter(
104
+ (el): el is ObcCheckboxItem => el instanceof ObcCheckboxItem
105
+ );
106
+ }
107
+
108
+ private sync(): void {
109
+ const rows = this.rows();
110
+ const hidden = computeHiddenRows(rows);
111
+ rows.forEach((row, i) => {
112
+ row.hoverStyle = this.hoverStyle;
113
+ row.hidden = hidden[i];
114
+ });
115
+ }
116
+
117
+ override render() {
118
+ return html`<div class="list">
119
+ <slot @slotchange=${() => this.sync()}></slot>
120
+ </div>`;
121
+ }
122
+
123
+ static override styles = unsafeCSS(componentStyle);
124
+ }
125
+
126
+ declare global {
127
+ interface HTMLElementTagNameMap {
128
+ 'obc-checkbox-list': ObcCheckboxList;
129
+ }
130
+ }