@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.
- package/bundle/openbridge-webcomponents.bundle.js +4736 -4470
- package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
- package/custom-elements.json +206 -21
- package/dist/components/checkbox-item/checkbox-item.css.js +137 -12
- package/dist/components/checkbox-item/checkbox-item.css.js.map +1 -1
- package/dist/components/checkbox-item/checkbox-item.d.ts +68 -39
- package/dist/components/checkbox-item/checkbox-item.d.ts.map +1 -1
- package/dist/components/checkbox-item/checkbox-item.js +66 -25
- package/dist/components/checkbox-item/checkbox-item.js.map +1 -1
- package/dist/components/checkbox-list/checkbox-list-visibility.d.ts +16 -0
- package/dist/components/checkbox-list/checkbox-list-visibility.d.ts.map +1 -0
- package/dist/components/checkbox-list/checkbox-list-visibility.js +12 -0
- package/dist/components/checkbox-list/checkbox-list-visibility.js.map +1 -0
- package/dist/components/checkbox-list/checkbox-list.css.js +23 -0
- package/dist/components/checkbox-list/checkbox-list.css.js.map +1 -0
- package/dist/components/checkbox-list/checkbox-list.d.ts +66 -0
- package/dist/components/checkbox-list/checkbox-list.d.ts.map +1 -0
- package/dist/components/checkbox-list/checkbox-list.js +81 -0
- package/dist/components/checkbox-list/checkbox-list.js.map +1 -0
- package/package.json +1 -1
- package/src/components/checkbox-item/checkbox-item.css +63 -17
- package/src/components/checkbox-item/checkbox-item.spec.ts +115 -0
- package/src/components/checkbox-item/checkbox-item.stories.ts +82 -97
- package/src/components/checkbox-item/checkbox-item.ts +118 -64
- package/src/components/checkbox-list/checkbox-list-visibility.spec.ts +68 -0
- package/src/components/checkbox-list/checkbox-list-visibility.ts +23 -0
- package/src/components/checkbox-list/checkbox-list.css +13 -0
- package/src/components/checkbox-list/checkbox-list.spec.ts +93 -0
- package/src/components/checkbox-list/checkbox-list.stories.ts +161 -0
- package/src/components/checkbox-list/checkbox-list.ts +130 -0
|
@@ -2,6 +2,7 @@ import { LitElement } from 'lit';
|
|
|
2
2
|
import { CheckboxStatus } from '../checkbox/checkbox.js';
|
|
3
3
|
import '../checkbox/checkbox.js';
|
|
4
4
|
import '../../icons/icon-chevron-right-google.js';
|
|
5
|
+
import '../../icons/icon-chevron-down-google.js';
|
|
5
6
|
export declare enum ObcCheckboxItemState {
|
|
6
7
|
enabled = "enabled",
|
|
7
8
|
disabled = "disabled"
|
|
@@ -10,76 +11,104 @@ export declare enum ObcCheckboxItemHoverStyle {
|
|
|
10
11
|
touchTarget = "touch-target",
|
|
11
12
|
visualTarget = "visual-target"
|
|
12
13
|
}
|
|
14
|
+
export type ObcCheckboxItemExpandToggleEvent = CustomEvent<boolean>;
|
|
13
15
|
/**
|
|
14
|
-
* `<obc-checkbox-item>` – A list
|
|
15
|
-
*
|
|
16
|
+
* `<obc-checkbox-item>` – A list row that pairs `<obc-checkbox>` with a label,
|
|
17
|
+
* an optional description, and hierarchy affordances for nested lists.
|
|
16
18
|
*
|
|
17
19
|
* ### Overview
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
20
|
+
* The row is the touch target: clicking anywhere on it toggles the checkbox,
|
|
21
|
+
* except on the chevron button, which only asks to expand or collapse. Depth
|
|
22
|
+
* is a number (`level`); the row indents itself so a flat sequence of rows
|
|
23
|
+
* reads as a tree. `<obc-checkbox-list>` builds on this to hide the rows
|
|
24
|
+
* under a collapsed parent.
|
|
22
25
|
*
|
|
23
26
|
* ### Features
|
|
24
|
-
* - Three
|
|
25
|
-
* -
|
|
26
|
-
* -
|
|
27
|
-
*
|
|
28
|
-
* -
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* -
|
|
32
|
-
* - **Nested level 2:** Chevron slot is reserved and nested spacer is shown.
|
|
27
|
+
* - Three statuses: `unchecked`, `checked`, `mixed`.
|
|
28
|
+
* - `touch-target` or `visual-target` hover treatment.
|
|
29
|
+
* - `level` indentation: level 1 reserves the chevron slot, each further
|
|
30
|
+
* level adds a spacer.
|
|
31
|
+
* - `expandable` rows show a chevron button that fires `expand-toggle`; the
|
|
32
|
+
* host owns `expanded`.
|
|
33
|
+
* - Optional `description` line under the label.
|
|
34
|
+
* - Forwards `aria-describedby` to the inner checkbox.
|
|
33
35
|
*
|
|
34
36
|
* ### Usage Guidelines
|
|
35
|
-
* -
|
|
36
|
-
* -
|
|
37
|
-
*
|
|
38
|
-
* -
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* - No named slots. Label content is provided through the `label` property.
|
|
42
|
-
*
|
|
43
|
-
* ### Events
|
|
44
|
-
* - `change` – Fired when status changes (from row click or inner checkbox).
|
|
45
|
-
* **detail:** `{ status, disabled }`
|
|
37
|
+
* - Keep `status` as the source of truth; update it from the `change` event.
|
|
38
|
+
* - Set `expanded` in response to `expand-toggle` — the row never flips it
|
|
39
|
+
* itself, so a parent (or `<obc-checkbox-list>`) can veto or persist it.
|
|
40
|
+
* - Use `level` 0 for a plain list; start at 1 when any row in the list is
|
|
41
|
+
* expandable so chevrons and checkboxes line up.
|
|
42
|
+
* - Prefer `hoverStyle="touch-target"` for standard list behaviour.
|
|
46
43
|
*
|
|
47
|
-
* ###
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
44
|
+
* ### Accessibility
|
|
45
|
+
* The checkbox and the chevron are separate controls in the natural tab
|
|
46
|
+
* order. The chevron is a native button named by the row's label, with the
|
|
47
|
+
* state in `aria-expanded`, following the WAI-ARIA checkbox and disclosure
|
|
48
|
+
* button patterns.
|
|
52
49
|
*
|
|
53
50
|
* ### Example
|
|
54
51
|
* ```html
|
|
55
52
|
* <obc-checkbox-item
|
|
53
|
+
* level="1"
|
|
54
|
+
* expandable
|
|
55
|
+
* expanded
|
|
56
56
|
* status="mixed"
|
|
57
|
-
* label="
|
|
58
|
-
*
|
|
57
|
+
* label="Reports"
|
|
58
|
+
* ></obc-checkbox-item>
|
|
59
|
+
* <obc-checkbox-item
|
|
60
|
+
* level="2"
|
|
61
|
+
* status="checked"
|
|
62
|
+
* label="Monthly"
|
|
63
|
+
* description="Sent on the 1st"
|
|
59
64
|
* ></obc-checkbox-item>
|
|
60
65
|
* ```
|
|
61
66
|
*
|
|
62
|
-
* @
|
|
63
|
-
* @
|
|
64
|
-
* @
|
|
67
|
+
* @property status - Checkbox status: `unchecked`, `checked` or `mixed`.
|
|
68
|
+
* @property state - Item state: `enabled` or `disabled`.
|
|
69
|
+
* @property disabled - Disables the row and the inner checkbox.
|
|
70
|
+
* @property label - Text label; also the checkbox's accessible name.
|
|
71
|
+
* @property description - Secondary line under the label; hidden when empty.
|
|
72
|
+
* @property level - Depth in a nested list. 0 is a plain row; 1 reserves the chevron slot; each level above 1 adds a spacer.
|
|
73
|
+
* @property expandable - Shows the chevron button that fires `expand-toggle`.
|
|
74
|
+
* @property expanded - Whether the row's children are shown; drives the chevron direction and `aria-expanded`.
|
|
75
|
+
* @availableWhen expanded expandable==true
|
|
76
|
+
* @property hoverStyle - Which box shows hover and focus: the whole row (`touch-target`) or the checkbox (`visual-target`).
|
|
77
|
+
* @property ariaDescribedBy - Forwarded to the inner checkbox as `aria-describedby`.
|
|
65
78
|
* @fires {ObcCheckboxChangeEvent} change - Emitted when status changes.
|
|
79
|
+
* @fires {ObcCheckboxItemExpandToggleEvent} expand-toggle - Emitted when the chevron is activated; detail is the next `expanded` value. Bubbles and is composed.
|
|
66
80
|
* @stable
|
|
67
81
|
*/
|
|
68
82
|
export declare class ObcCheckboxItem extends LitElement {
|
|
83
|
+
/** Checkbox status: `unchecked`, `checked` or `mixed`. */
|
|
69
84
|
status: CheckboxStatus;
|
|
85
|
+
/** Item state: `enabled` or `disabled`. */
|
|
70
86
|
state: ObcCheckboxItemState;
|
|
87
|
+
/** Disables the row and the inner checkbox. */
|
|
71
88
|
disabled: boolean;
|
|
89
|
+
/** Text label; also the checkbox's accessible name. */
|
|
72
90
|
label: string;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
91
|
+
/** Secondary line under the label; hidden when empty. */
|
|
92
|
+
description: string;
|
|
93
|
+
/** Depth in a nested list. 0 is a plain row; 1 reserves the chevron slot; each level above 1 adds a spacer. */
|
|
94
|
+
level: number;
|
|
95
|
+
/** Shows the chevron button that fires `expand-toggle`. */
|
|
96
|
+
expandable: boolean;
|
|
97
|
+
/** Whether the row's children are shown; drives the chevron direction and `aria-expanded`. */
|
|
98
|
+
expanded: boolean;
|
|
99
|
+
/** Which box shows hover and focus: the whole row (`touch-target`) or the checkbox (`visual-target`). */
|
|
76
100
|
hoverStyle: ObcCheckboxItemHoverStyle;
|
|
101
|
+
/** Forwarded to the inner checkbox as `aria-describedby`. */
|
|
77
102
|
ariaDescribedBy: string;
|
|
78
103
|
private checkboxElement?;
|
|
104
|
+
private chevronButton?;
|
|
105
|
+
private get isDisabled();
|
|
79
106
|
private toggleStatusFromItem;
|
|
80
107
|
private handleItemClick;
|
|
108
|
+
private handleChevronClick;
|
|
81
109
|
private handleCheckboxChange;
|
|
82
110
|
focus(options?: FocusOptions): void;
|
|
111
|
+
private renderChevron;
|
|
83
112
|
render(): import('lit-html').TemplateResult<1>;
|
|
84
113
|
static styles: import('lit').CSSResult;
|
|
85
114
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox-item.d.ts","sourceRoot":"","sources":["../../../src/components/checkbox-item/checkbox-item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAA2B,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"checkbox-item.d.ts","sourceRoot":"","sources":["../../../src/components/checkbox-item/checkbox-item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAA2B,MAAM,KAAK,CAAC;AAOzD,OAAO,yBAAyB,CAAC;AACjC,OAAO,0CAA0C,CAAC;AAClD,OAAO,yCAAyC,CAAC;AACjD,OAAO,EAEL,cAAc,EAEf,MAAM,yBAAyB,CAAC;AAEjC,oBAAY,oBAAoB;IAC9B,OAAO,YAAY;IACnB,QAAQ,aAAa;CACtB;AAED,oBAAY,yBAAyB;IACnC,WAAW,iBAAiB;IAC5B,YAAY,kBAAkB;CAC/B;AAED,MAAM,MAAM,gCAAgC,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;AAEpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AACH,qBACa,eAAgB,SAAQ,UAAU;IACnB,MAAM,EAAE,cAAc,CAA4B;IAElD,KAAK,EAAE,oBAAoB,CACtB;IAEJ,QAAQ,UAAS;IAElB,KAAK,SAAM;IAEX,WAAW,SAAM;IAEF,KAAK,SAAK;IAET,UAAU,UAAS;IAEnB,QAAQ,UAAS;IAEjC,UAAU,EAAE,yBAAyB,CACvB;IAGxC,eAAe,SAAM;IAEE,OAAO,CAAC,eAAe,CAAC,CAAc;IAEnC,OAAO,CAAC,aAAa,CAAC,CAAc;IAE9D,OAAO,KAAK,UAAU,GAErB;IAED,OAAO,CAAC,oBAAoB;IAiB5B,OAAO,CAAC,eAAe;IAUvB,OAAO,CAAC,kBAAkB;IAW1B,OAAO,CAAC,oBAAoB;IAWZ,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI;IAInD,OAAO,CAAC,aAAa;IAsBZ,MAAM;IAuDf,OAAgB,MAAM,0BAA6B;CACpD;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,mBAAmB,EAAE,eAAe,CAAC;KACtC;CACF"}
|
|
@@ -2,10 +2,12 @@ import { unsafeCSS, LitElement, nothing, html } from "lit";
|
|
|
2
2
|
import { property, query } from "lit/decorators.js";
|
|
3
3
|
import { classMap } from "lit/directives/class-map.js";
|
|
4
4
|
import { ifDefined } from "lit/directives/if-defined.js";
|
|
5
|
+
import { styleMap } from "lit/directives/style-map.js";
|
|
5
6
|
import { customElement } from "../../decorator.js";
|
|
6
7
|
import componentStyle from "./checkbox-item.css.js";
|
|
7
8
|
import { CheckboxStatus, CheckboxState } from "../checkbox/checkbox.js";
|
|
8
9
|
import "../../icons/icon-chevron-right-google.js";
|
|
10
|
+
import "../../icons/icon-chevron-down-google.js";
|
|
9
11
|
var __defProp = Object.defineProperty;
|
|
10
12
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
11
13
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
@@ -33,14 +35,17 @@ let ObcCheckboxItem = class extends LitElement {
|
|
|
33
35
|
this.state = "enabled";
|
|
34
36
|
this.disabled = false;
|
|
35
37
|
this.label = "";
|
|
36
|
-
this.
|
|
37
|
-
this.
|
|
38
|
-
this.
|
|
38
|
+
this.description = "";
|
|
39
|
+
this.level = 0;
|
|
40
|
+
this.expandable = false;
|
|
41
|
+
this.expanded = false;
|
|
39
42
|
this.hoverStyle = "touch-target";
|
|
40
43
|
this.ariaDescribedBy = "";
|
|
41
44
|
}
|
|
45
|
+
get isDisabled() {
|
|
46
|
+
return this.disabled || this.state === "disabled";
|
|
47
|
+
}
|
|
42
48
|
toggleStatusFromItem() {
|
|
43
|
-
const isDisabled = this.disabled || this.state === "disabled";
|
|
44
49
|
if (this.status === CheckboxStatus.checked) {
|
|
45
50
|
this.status = CheckboxStatus.unchecked;
|
|
46
51
|
} else {
|
|
@@ -50,18 +55,28 @@ let ObcCheckboxItem = class extends LitElement {
|
|
|
50
55
|
new CustomEvent("change", {
|
|
51
56
|
detail: {
|
|
52
57
|
status: this.status,
|
|
53
|
-
disabled: isDisabled
|
|
58
|
+
disabled: this.isDisabled
|
|
54
59
|
}
|
|
55
60
|
})
|
|
56
61
|
);
|
|
57
62
|
}
|
|
58
63
|
handleItemClick(event) {
|
|
59
|
-
if (this.
|
|
64
|
+
if (this.isDisabled) return;
|
|
60
65
|
const path = event.composedPath();
|
|
61
|
-
|
|
62
|
-
if (
|
|
66
|
+
if (this.checkboxElement && path.includes(this.checkboxElement)) return;
|
|
67
|
+
if (this.chevronButton && path.includes(this.chevronButton)) return;
|
|
63
68
|
this.toggleStatusFromItem();
|
|
64
69
|
}
|
|
70
|
+
handleChevronClick(event) {
|
|
71
|
+
event.stopPropagation();
|
|
72
|
+
this.dispatchEvent(
|
|
73
|
+
new CustomEvent("expand-toggle", {
|
|
74
|
+
detail: !this.expanded,
|
|
75
|
+
bubbles: true,
|
|
76
|
+
composed: true
|
|
77
|
+
})
|
|
78
|
+
);
|
|
79
|
+
}
|
|
65
80
|
handleCheckboxChange(event) {
|
|
66
81
|
const checkboxEvent = event;
|
|
67
82
|
this.status = checkboxEvent.detail.status;
|
|
@@ -74,12 +89,30 @@ let ObcCheckboxItem = class extends LitElement {
|
|
|
74
89
|
focus(options) {
|
|
75
90
|
this.checkboxElement?.focus(options);
|
|
76
91
|
}
|
|
92
|
+
renderChevron() {
|
|
93
|
+
if (!this.expandable) return nothing;
|
|
94
|
+
return html`<button
|
|
95
|
+
type="button"
|
|
96
|
+
class="chevron-button"
|
|
97
|
+
aria-expanded=${this.expanded ? "true" : "false"}
|
|
98
|
+
aria-label=${ifDefined(this.label.trim() || void 0)}
|
|
99
|
+
?disabled=${this.isDisabled}
|
|
100
|
+
@click=${this.handleChevronClick}
|
|
101
|
+
>
|
|
102
|
+
<span class="chevron-visible">
|
|
103
|
+
${this.expanded ? html`<obi-chevron-down-google
|
|
104
|
+
class="chevron-icon"
|
|
105
|
+
></obi-chevron-down-google>` : html`<obi-chevron-right-google
|
|
106
|
+
class="chevron-icon"
|
|
107
|
+
></obi-chevron-right-google>`}
|
|
108
|
+
</span>
|
|
109
|
+
</button>`;
|
|
110
|
+
}
|
|
77
111
|
render() {
|
|
78
|
-
const isDisabled = this.
|
|
112
|
+
const isDisabled = this.isDisabled;
|
|
79
113
|
const hasCheckboxHoverEffects = !(this.hoverStyle === "touch-target" && !isDisabled);
|
|
80
|
-
const
|
|
81
|
-
const
|
|
82
|
-
const shouldRenderChevronIcon = this.isNested && this.isLevel1;
|
|
114
|
+
const depth = Math.max(0, Math.floor(this.level) - 1);
|
|
115
|
+
const hasChevronSlot = this.level >= 1 || this.expandable;
|
|
83
116
|
const checkboxAriaLabel = this.label.trim().length > 0 ? this.label : void 0;
|
|
84
117
|
return html`
|
|
85
118
|
<div
|
|
@@ -87,19 +120,18 @@ let ObcCheckboxItem = class extends LitElement {
|
|
|
87
120
|
"checkbox-item-container": true,
|
|
88
121
|
[`status-${this.status}`]: true,
|
|
89
122
|
[`hover-style-${this.hoverStyle}`]: true,
|
|
90
|
-
"is-nested":
|
|
91
|
-
"
|
|
92
|
-
"is-level-2": this.isLevel2,
|
|
123
|
+
"is-nested": hasChevronSlot,
|
|
124
|
+
"has-description": this.description !== "",
|
|
93
125
|
disabled: isDisabled
|
|
94
126
|
})}
|
|
95
127
|
@click=${this.handleItemClick}
|
|
96
128
|
>
|
|
97
|
-
${
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
${
|
|
129
|
+
${depth > 0 ? html`<div
|
|
130
|
+
class="nested-spacer"
|
|
131
|
+
aria-hidden="true"
|
|
132
|
+
style=${styleMap({ "--checkbox-item-depth": String(depth) })}
|
|
133
|
+
></div>` : nothing}
|
|
134
|
+
${hasChevronSlot ? html`<div class="chevron-container">${this.renderChevron()}</div>` : nothing}
|
|
103
135
|
<div class="content-container">
|
|
104
136
|
<obc-checkbox
|
|
105
137
|
.status=${this.status}
|
|
@@ -112,6 +144,9 @@ let ObcCheckboxItem = class extends LitElement {
|
|
|
112
144
|
></obc-checkbox>
|
|
113
145
|
<div class="checkbox-label-container">
|
|
114
146
|
<span class="checkbox-label">${this.label}</span>
|
|
147
|
+
${this.description ? html`<span class="checkbox-description"
|
|
148
|
+
>${this.description}</span
|
|
149
|
+
>` : nothing}
|
|
115
150
|
</div>
|
|
116
151
|
</div>
|
|
117
152
|
</div>
|
|
@@ -132,14 +167,17 @@ __decorateClass([
|
|
|
132
167
|
property({ type: String })
|
|
133
168
|
], ObcCheckboxItem.prototype, "label", 2);
|
|
134
169
|
__decorateClass([
|
|
135
|
-
property({ type:
|
|
136
|
-
], ObcCheckboxItem.prototype, "
|
|
170
|
+
property({ type: String })
|
|
171
|
+
], ObcCheckboxItem.prototype, "description", 2);
|
|
172
|
+
__decorateClass([
|
|
173
|
+
property({ type: Number, reflect: true })
|
|
174
|
+
], ObcCheckboxItem.prototype, "level", 2);
|
|
137
175
|
__decorateClass([
|
|
138
176
|
property({ type: Boolean, reflect: true })
|
|
139
|
-
], ObcCheckboxItem.prototype, "
|
|
177
|
+
], ObcCheckboxItem.prototype, "expandable", 2);
|
|
140
178
|
__decorateClass([
|
|
141
179
|
property({ type: Boolean, reflect: true })
|
|
142
|
-
], ObcCheckboxItem.prototype, "
|
|
180
|
+
], ObcCheckboxItem.prototype, "expanded", 2);
|
|
143
181
|
__decorateClass([
|
|
144
182
|
property({ type: String })
|
|
145
183
|
], ObcCheckboxItem.prototype, "hoverStyle", 2);
|
|
@@ -149,6 +187,9 @@ __decorateClass([
|
|
|
149
187
|
__decorateClass([
|
|
150
188
|
query("obc-checkbox")
|
|
151
189
|
], ObcCheckboxItem.prototype, "checkboxElement", 2);
|
|
190
|
+
__decorateClass([
|
|
191
|
+
query(".chevron-button")
|
|
192
|
+
], ObcCheckboxItem.prototype, "chevronButton", 2);
|
|
152
193
|
ObcCheckboxItem = __decorateClass([
|
|
153
194
|
customElement("obc-checkbox-item")
|
|
154
195
|
], ObcCheckboxItem);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox-item.js","sources":["../../../src/components/checkbox-item/checkbox-item.ts"],"sourcesContent":["import {LitElement, html, nothing, unsafeCSS} from 'lit';\nimport {property, query} from 'lit/decorators.js';\nimport {classMap} from 'lit/directives/class-map.js';\nimport {ifDefined} from 'lit/directives/if-defined.js';\nimport {customElement} from '../../decorator.js';\nimport componentStyle from './checkbox-item.css?inline';\nimport '../checkbox/checkbox.js';\nimport '../../icons/icon-chevron-right-google.js';\nimport {\n CheckboxState,\n CheckboxStatus,\n type ObcCheckboxChangeEvent,\n} from '../checkbox/checkbox.js';\n\nexport enum ObcCheckboxItemState {\n enabled = 'enabled',\n disabled = 'disabled',\n}\n\nexport enum ObcCheckboxItemHoverStyle {\n touchTarget = 'touch-target',\n visualTarget = 'visual-target',\n}\n\n/**\n * `<obc-checkbox-item>` – A list-item wrapper for `<obc-checkbox>` with label\n * and optional nested indentation affordances.\n *\n * ### Overview\n * Combines checkbox interaction with a row-like container used in menus and\n * hierarchical selection lists. The component proxies checkbox state changes,\n * supports touch-target or visual-target interaction behavior, and can render\n * nested structure indicators.\n *\n * ### Features\n * - Three checkbox statuses: `unchecked`, `checked`, `mixed`.\n * - Item state control: `enabled` or `disabled`.\n * - Two hover/focus interaction modes: `touch-target` and `visual-target`.\n * - Optional nested layout controls via `isNested`, `isLevel1`, `isLevel2`.\n * - Forwards `aria-describedby` to the inner checkbox for assistive context.\n *\n * ### Variants\n * - **Nested level 1:** Chevron icon is shown.\n * - **Nested level 2:** Chevron slot is reserved and nested spacer is shown.\n *\n * ### Usage Guidelines\n * - Use for checkbox rows that require text labels and optional hierarchy.\n * - Keep `status` as the source of truth for checked/mixed/unchecked value.\n * - Use `state=\"disabled\"` or `disabled` to lock interaction.\n * - Prefer `hoverStyle=\"touch-target\"` for standard list behavior.\n *\n * ### Slots / Content\n * - No named slots. Label content is provided through the `label` property.\n *\n * ### Events\n * - `change` – Fired when status changes (from row click or inner checkbox).\n * **detail:** `{ status, disabled }`\n *\n * ### Best Practices\n * - Provide non-empty `label` for accessible naming.\n * - Use `aria-describedby` when additional contextual text exists outside.\n * - For deep hierarchies, use `isNested` with `isLevel1` / `isLevel2`\n * consistently to preserve spacing and alignment.\n *\n * ### Example\n * ```html\n * <obc-checkbox-item\n * status=\"mixed\"\n * label=\"Include archived items\"\n * hoverStyle=\"touch-target\"\n * ></obc-checkbox-item>\n * ```\n *\n * @availableWhen isLevel1 isNested==true || hoverStyle==visual-target\n * @availableWhen isLevel2 isNested==true || hoverStyle==visual-target\n * @slot - No named slots.\n * @fires {ObcCheckboxChangeEvent} change - Emitted when status changes.\n * @stable\n */\n@customElement('obc-checkbox-item')\nexport class ObcCheckboxItem extends LitElement {\n @property({type: String}) status: CheckboxStatus = CheckboxStatus.unchecked;\n\n @property({type: String}) state: ObcCheckboxItemState =\n ObcCheckboxItemState.enabled;\n\n @property({type: Boolean}) disabled = false;\n\n @property({type: String}) label = '';\n\n @property({type: Boolean, reflect: true}) isNested = false;\n\n @property({type: Boolean, reflect: true}) isLevel1 = false;\n\n @property({type: Boolean, reflect: true}) isLevel2 = false;\n\n @property({type: String}) hoverStyle: ObcCheckboxItemHoverStyle =\n ObcCheckboxItemHoverStyle.touchTarget;\n\n @property({type: String, attribute: 'aria-describedby', reflect: true})\n ariaDescribedBy = '';\n\n @query('obc-checkbox') private checkboxElement?: HTMLElement;\n\n private toggleStatusFromItem() {\n const isDisabled =\n this.disabled || this.state === ObcCheckboxItemState.disabled;\n\n if (this.status === CheckboxStatus.checked) {\n this.status = CheckboxStatus.unchecked;\n } else {\n this.status = CheckboxStatus.checked;\n }\n\n this.dispatchEvent(\n new CustomEvent('change', {\n detail: {\n status: this.status,\n disabled: isDisabled,\n },\n })\n );\n }\n\n private handleItemClick(event: MouseEvent) {\n if (this.disabled || this.state === ObcCheckboxItemState.disabled) return;\n\n const path = event.composedPath();\n const checkboxElement = this.checkboxElement;\n if (checkboxElement && path.includes(checkboxElement)) return;\n\n this.toggleStatusFromItem();\n }\n\n private handleCheckboxChange(event: Event) {\n const checkboxEvent = event as ObcCheckboxChangeEvent;\n this.status = checkboxEvent.detail.status;\n\n this.dispatchEvent(\n new CustomEvent('change', {\n detail: checkboxEvent.detail,\n })\n );\n }\n\n public override focus(options?: FocusOptions): void {\n this.checkboxElement?.focus(options);\n }\n\n override render() {\n const isDisabled =\n this.disabled || this.state === ObcCheckboxItemState.disabled;\n const hasCheckboxHoverEffects = !(\n this.hoverStyle === ObcCheckboxItemHoverStyle.touchTarget && !isDisabled\n );\n const shouldRenderNestedSpacer = this.isNested && this.isLevel2;\n const shouldRenderChevronContainer = this.isNested;\n const shouldRenderChevronIcon = this.isNested && this.isLevel1;\n const checkboxAriaLabel =\n this.label.trim().length > 0 ? this.label : undefined;\n\n return html`\n <div\n class=${classMap({\n 'checkbox-item-container': true,\n [`status-${this.status}`]: true,\n [`hover-style-${this.hoverStyle}`]: true,\n 'is-nested': this.isNested,\n 'is-level-1': this.isLevel1,\n 'is-level-2': this.isLevel2,\n disabled: isDisabled,\n })}\n @click=${this.handleItemClick}\n >\n ${shouldRenderChevronContainer\n ? html`<div class=\"chevron-container\" aria-hidden=\"true\">\n ${shouldRenderChevronIcon\n ? html`<obi-chevron-right-google\n class=\"chevron-icon\"\n ></obi-chevron-right-google>`\n : nothing}\n </div>`\n : nothing}\n ${shouldRenderNestedSpacer\n ? html`<div class=\"nested-spacer\" aria-hidden=\"true\"></div>`\n : nothing}\n <div class=\"content-container\">\n <obc-checkbox\n .status=${this.status}\n .state=${CheckboxState.enabled}\n .disabled=${isDisabled}\n .hasHoverEffects=${hasCheckboxHoverEffects}\n aria-label=${ifDefined(checkboxAriaLabel)}\n aria-describedby=${ifDefined(this.ariaDescribedBy || undefined)}\n @change=${this.handleCheckboxChange}\n ></obc-checkbox>\n <div class=\"checkbox-label-container\">\n <span class=\"checkbox-label\">${this.label}</span>\n </div>\n </div>\n </div>\n `;\n }\n\n static override styles = unsafeCSS(componentStyle);\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'obc-checkbox-item': ObcCheckboxItem;\n }\n}\n"],"names":["ObcCheckboxItemState","ObcCheckboxItemHoverStyle"],"mappings":";;;;;;;;;;;;;;;;;;AAcO,IAAK,yCAAAA,0BAAL;AACLA,wBAAA,SAAA,IAAU;AACVA,wBAAA,UAAA,IAAW;AAFD,SAAAA;AAAA,GAAA,wBAAA,CAAA,CAAA;AAKL,IAAK,8CAAAC,+BAAL;AACLA,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AAED,gBAAA;AAAA,EAAzB,SAAS,EAAC,MAAM,OAAA,CAAO;AAAA,GARb,gBAQe,WAAA,SAAA,CAAA;AAEgB,gBAAA;AAAA,EAAzC,SAAS,EAAC,MAAM,SAAS,SAAS,MAAK;AAAA,GAV7B,gBAU+B,WAAA,YAAA,CAAA;AAEA,gBAAA;AAAA,EAAzC,SAAS,EAAC,MAAM,SAAS,SAAS,MAAK;AAAA,GAZ7B,gBAY+B,WAAA,YAAA,CAAA;AAEA,gBAAA;AAAA,EAAzC,SAAS,EAAC,MAAM,SAAS,SAAS,MAAK;AAAA,GAd7B,gBAc+B,WAAA,YAAA,CAAA;AAEhB,gBAAA;AAAA,EAAzB,SAAS,EAAC,MAAM,OAAA,CAAO;AAAA,GAhBb,gBAgBe,WAAA,cAAA,CAAA;AAI1B,gBAAA;AAAA,EADC,SAAS,EAAC,MAAM,QAAQ,WAAW,oBAAoB,SAAS,MAAK;AAAA,GAnB3D,gBAoBX,WAAA,mBAAA,CAAA;AAE+B,gBAAA;AAAA,EAA9B,MAAM,cAAc;AAAA,GAtBV,gBAsBoB,WAAA,mBAAA,CAAA;AAtBpB,kBAAN,gBAAA;AAAA,EADN,cAAc,mBAAmB;AAAA,GACrB,eAAA;"}
|
|
1
|
+
{"version":3,"file":"checkbox-item.js","sources":["../../../src/components/checkbox-item/checkbox-item.ts"],"sourcesContent":["import {LitElement, html, nothing, unsafeCSS} from 'lit';\nimport {property, query} from 'lit/decorators.js';\nimport {classMap} from 'lit/directives/class-map.js';\nimport {ifDefined} from 'lit/directives/if-defined.js';\nimport {styleMap} from 'lit/directives/style-map.js';\nimport {customElement} from '../../decorator.js';\nimport componentStyle from './checkbox-item.css?inline';\nimport '../checkbox/checkbox.js';\nimport '../../icons/icon-chevron-right-google.js';\nimport '../../icons/icon-chevron-down-google.js';\nimport {\n CheckboxState,\n CheckboxStatus,\n type ObcCheckboxChangeEvent,\n} from '../checkbox/checkbox.js';\n\nexport enum ObcCheckboxItemState {\n enabled = 'enabled',\n disabled = 'disabled',\n}\n\nexport enum ObcCheckboxItemHoverStyle {\n touchTarget = 'touch-target',\n visualTarget = 'visual-target',\n}\n\nexport type ObcCheckboxItemExpandToggleEvent = CustomEvent<boolean>;\n\n/**\n * `<obc-checkbox-item>` – A list row that pairs `<obc-checkbox>` with a label,\n * an optional description, and hierarchy affordances for nested lists.\n *\n * ### Overview\n * The row is the touch target: clicking anywhere on it toggles the checkbox,\n * except on the chevron button, which only asks to expand or collapse. Depth\n * is a number (`level`); the row indents itself so a flat sequence of rows\n * reads as a tree. `<obc-checkbox-list>` builds on this to hide the rows\n * under a collapsed parent.\n *\n * ### Features\n * - Three statuses: `unchecked`, `checked`, `mixed`.\n * - `touch-target` or `visual-target` hover treatment.\n * - `level` indentation: level 1 reserves the chevron slot, each further\n * level adds a spacer.\n * - `expandable` rows show a chevron button that fires `expand-toggle`; the\n * host owns `expanded`.\n * - Optional `description` line under the label.\n * - Forwards `aria-describedby` to the inner checkbox.\n *\n * ### Usage Guidelines\n * - Keep `status` as the source of truth; update it from the `change` event.\n * - Set `expanded` in response to `expand-toggle` — the row never flips it\n * itself, so a parent (or `<obc-checkbox-list>`) can veto or persist it.\n * - Use `level` 0 for a plain list; start at 1 when any row in the list is\n * expandable so chevrons and checkboxes line up.\n * - Prefer `hoverStyle=\"touch-target\"` for standard list behaviour.\n *\n * ### Accessibility\n * The checkbox and the chevron are separate controls in the natural tab\n * order. The chevron is a native button named by the row's label, with the\n * state in `aria-expanded`, following the WAI-ARIA checkbox and disclosure\n * button patterns.\n *\n * ### Example\n * ```html\n * <obc-checkbox-item\n * level=\"1\"\n * expandable\n * expanded\n * status=\"mixed\"\n * label=\"Reports\"\n * ></obc-checkbox-item>\n * <obc-checkbox-item\n * level=\"2\"\n * status=\"checked\"\n * label=\"Monthly\"\n * description=\"Sent on the 1st\"\n * ></obc-checkbox-item>\n * ```\n *\n * @property status - Checkbox status: `unchecked`, `checked` or `mixed`.\n * @property state - Item state: `enabled` or `disabled`.\n * @property disabled - Disables the row and the inner checkbox.\n * @property label - Text label; also the checkbox's accessible name.\n * @property description - Secondary line under the label; hidden when empty.\n * @property level - Depth in a nested list. 0 is a plain row; 1 reserves the chevron slot; each level above 1 adds a spacer.\n * @property expandable - Shows the chevron button that fires `expand-toggle`.\n * @property expanded - Whether the row's children are shown; drives the chevron direction and `aria-expanded`.\n * @availableWhen expanded expandable==true\n * @property hoverStyle - Which box shows hover and focus: the whole row (`touch-target`) or the checkbox (`visual-target`).\n * @property ariaDescribedBy - Forwarded to the inner checkbox as `aria-describedby`.\n * @fires {ObcCheckboxChangeEvent} change - Emitted when status changes.\n * @fires {ObcCheckboxItemExpandToggleEvent} expand-toggle - Emitted when the chevron is activated; detail is the next `expanded` value. Bubbles and is composed.\n * @stable\n */\n@customElement('obc-checkbox-item')\nexport class ObcCheckboxItem extends LitElement {\n @property({type: String}) status: CheckboxStatus = CheckboxStatus.unchecked;\n\n @property({type: String}) state: ObcCheckboxItemState =\n ObcCheckboxItemState.enabled;\n\n @property({type: Boolean}) disabled = false;\n\n @property({type: String}) label = '';\n\n @property({type: String}) description = '';\n\n @property({type: Number, reflect: true}) level = 0;\n\n @property({type: Boolean, reflect: true}) expandable = false;\n\n @property({type: Boolean, reflect: true}) expanded = false;\n\n @property({type: String}) hoverStyle: ObcCheckboxItemHoverStyle =\n ObcCheckboxItemHoverStyle.touchTarget;\n\n @property({type: String, attribute: 'aria-describedby', reflect: true})\n ariaDescribedBy = '';\n\n @query('obc-checkbox') private checkboxElement?: HTMLElement;\n\n @query('.chevron-button') private chevronButton?: HTMLElement;\n\n private get isDisabled(): boolean {\n return this.disabled || this.state === ObcCheckboxItemState.disabled;\n }\n\n private toggleStatusFromItem() {\n if (this.status === CheckboxStatus.checked) {\n this.status = CheckboxStatus.unchecked;\n } else {\n this.status = CheckboxStatus.checked;\n }\n\n this.dispatchEvent(\n new CustomEvent('change', {\n detail: {\n status: this.status,\n disabled: this.isDisabled,\n },\n })\n );\n }\n\n private handleItemClick(event: MouseEvent) {\n if (this.isDisabled) return;\n\n const path = event.composedPath();\n if (this.checkboxElement && path.includes(this.checkboxElement)) return;\n if (this.chevronButton && path.includes(this.chevronButton)) return;\n\n this.toggleStatusFromItem();\n }\n\n private handleChevronClick(event: MouseEvent) {\n event.stopPropagation();\n this.dispatchEvent(\n new CustomEvent<boolean>('expand-toggle', {\n detail: !this.expanded,\n bubbles: true,\n composed: true,\n })\n );\n }\n\n private handleCheckboxChange(event: Event) {\n const checkboxEvent = event as ObcCheckboxChangeEvent;\n this.status = checkboxEvent.detail.status;\n\n this.dispatchEvent(\n new CustomEvent('change', {\n detail: checkboxEvent.detail,\n })\n );\n }\n\n public override focus(options?: FocusOptions): void {\n this.checkboxElement?.focus(options);\n }\n\n private renderChevron() {\n if (!this.expandable) return nothing;\n return html`<button\n type=\"button\"\n class=\"chevron-button\"\n aria-expanded=${this.expanded ? 'true' : 'false'}\n aria-label=${ifDefined(this.label.trim() || undefined)}\n ?disabled=${this.isDisabled}\n @click=${this.handleChevronClick}\n >\n <span class=\"chevron-visible\">\n ${this.expanded\n ? html`<obi-chevron-down-google\n class=\"chevron-icon\"\n ></obi-chevron-down-google>`\n : html`<obi-chevron-right-google\n class=\"chevron-icon\"\n ></obi-chevron-right-google>`}\n </span>\n </button>`;\n }\n\n override render() {\n const isDisabled = this.isDisabled;\n const hasCheckboxHoverEffects = !(\n this.hoverStyle === ObcCheckboxItemHoverStyle.touchTarget && !isDisabled\n );\n const depth = Math.max(0, Math.floor(this.level) - 1);\n const hasChevronSlot = this.level >= 1 || this.expandable;\n const checkboxAriaLabel =\n this.label.trim().length > 0 ? this.label : undefined;\n\n return html`\n <div\n class=${classMap({\n 'checkbox-item-container': true,\n [`status-${this.status}`]: true,\n [`hover-style-${this.hoverStyle}`]: true,\n 'is-nested': hasChevronSlot,\n 'has-description': this.description !== '',\n disabled: isDisabled,\n })}\n @click=${this.handleItemClick}\n >\n ${depth > 0\n ? html`<div\n class=\"nested-spacer\"\n aria-hidden=\"true\"\n style=${styleMap({'--checkbox-item-depth': String(depth)})}\n ></div>`\n : nothing}\n ${hasChevronSlot\n ? html`<div class=\"chevron-container\">${this.renderChevron()}</div>`\n : nothing}\n <div class=\"content-container\">\n <obc-checkbox\n .status=${this.status}\n .state=${CheckboxState.enabled}\n .disabled=${isDisabled}\n .hasHoverEffects=${hasCheckboxHoverEffects}\n aria-label=${ifDefined(checkboxAriaLabel)}\n aria-describedby=${ifDefined(this.ariaDescribedBy || undefined)}\n @change=${this.handleCheckboxChange}\n ></obc-checkbox>\n <div class=\"checkbox-label-container\">\n <span class=\"checkbox-label\">${this.label}</span>\n ${this.description\n ? html`<span class=\"checkbox-description\"\n >${this.description}</span\n >`\n : nothing}\n </div>\n </div>\n </div>\n `;\n }\n\n static override styles = unsafeCSS(componentStyle);\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'obc-checkbox-item': ObcCheckboxItem;\n }\n}\n"],"names":["ObcCheckboxItemState","ObcCheckboxItemHoverStyle"],"mappings":";;;;;;;;;;;;;;;;;;;;AAgBO,IAAK,yCAAAA,0BAAL;AACLA,wBAAA,SAAA,IAAU;AACVA,wBAAA,UAAA,IAAW;AAFD,SAAAA;AAAA,GAAA,wBAAA,CAAA,CAAA;AAKL,IAAK,8CAAAC,+BAAL;AACLA,6BAAA,aAAA,IAAc;AACdA,6BAAA,cAAA,IAAe;AAFL,SAAAA;AAAA,GAAA,6BAAA,CAAA,CAAA;AA2EL,IAAM,kBAAN,cAA8B,WAAW;AAAA,EAAzC,cAAA;AAAA,UAAA,GAAA,SAAA;AACqB,SAAA,SAAyB,eAAe;AAExC,SAAA,QACxB;AAEyB,SAAA,WAAW;AAEZ,SAAA,QAAQ;AAER,SAAA,cAAc;AAEC,SAAA,QAAQ;AAEP,SAAA,aAAa;AAEb,SAAA,WAAW;AAE3B,SAAA,aACxB;AAGF,SAAA,kBAAkB;AAAA,EAAA;AAAA,EAMlB,IAAY,aAAsB;AAChC,WAAO,KAAK,Y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,eAAA;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Visibility of a flat checkbox-item sequence
|
|
3
|
+
*
|
|
4
|
+
* `<obc-checkbox-list>` keeps its rows flat and infers the tree from each
|
|
5
|
+
* row's `level`. A row is hidden while a preceding, visible, collapsed
|
|
6
|
+
* expandable row of smaller level is still "open" — that is, until a row of
|
|
7
|
+
* equal or smaller level closes it. Kept free of DOM so it can be unit-tested.
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
export interface CheckboxListRow {
|
|
11
|
+
level: number;
|
|
12
|
+
expandable: boolean;
|
|
13
|
+
expanded: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function computeHiddenRows(rows: readonly CheckboxListRow[]): boolean[];
|
|
16
|
+
//# sourceMappingURL=checkbox-list-visibility.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkbox-list-visibility.d.ts","sourceRoot":"","sources":["../../../src/components/checkbox-list/checkbox-list-visibility.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,SAAS,eAAe,EAAE,GAAG,OAAO,EAAE,CAO7E"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
function computeHiddenRows(rows) {
|
|
2
|
+
let cutLevel = null;
|
|
3
|
+
return rows.map((row) => {
|
|
4
|
+
if (cutLevel !== null && row.level > cutLevel) return true;
|
|
5
|
+
cutLevel = row.expandable && !row.expanded ? row.level : null;
|
|
6
|
+
return false;
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
computeHiddenRows
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=checkbox-list-visibility.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkbox-list-visibility.js","sources":["../../../src/components/checkbox-list/checkbox-list-visibility.ts"],"sourcesContent":["/**\n * Visibility of a flat checkbox-item sequence\n *\n * `<obc-checkbox-list>` keeps its rows flat and infers the tree from each\n * row's `level`. A row is hidden while a preceding, visible, collapsed\n * expandable row of smaller level is still \"open\" — that is, until a row of\n * equal or smaller level closes it. Kept free of DOM so it can be unit-tested.\n * @module\n */\nexport interface CheckboxListRow {\n level: number;\n expandable: boolean;\n expanded: boolean;\n}\n\nexport function computeHiddenRows(rows: readonly CheckboxListRow[]): boolean[] {\n let cutLevel: number | null = null;\n return rows.map((row) => {\n if (cutLevel !== null && row.level > cutLevel) return true;\n cutLevel = row.expandable && !row.expanded ? row.level : null;\n return false;\n });\n}\n"],"names":[],"mappings":"AAeO,SAAS,kBAAkB,MAA6C;AAC7E,MAAI,WAA0B;AAC9B,SAAO,KAAK,IAAI,CAAC,QAAQ;AACvB,QAAI,aAAa,QAAQ,IAAI,QAAQ,SAAU,QAAO;AACtD,eAAW,IAAI,cAAc,CAAC,IAAI,WAAW,IAAI,QAAQ;AACzD,WAAO;AAAA,EACT,CAAC;AACH;"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { css } from "lit";
|
|
2
|
+
const componentStyle = css`* {
|
|
3
|
+
-webkit-tap-highlight-color: transparent;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
:host {
|
|
7
|
+
display: block;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.list {
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
align-items: stretch;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
::slotted([hidden]) {
|
|
17
|
+
display: none; /* collapsed rows leave layout; :host is display:block so [hidden] alone would not win */
|
|
18
|
+
}
|
|
19
|
+
`;
|
|
20
|
+
export {
|
|
21
|
+
componentStyle as default
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=checkbox-list.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkbox-list.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { LitElement, PropertyValues } from 'lit';
|
|
2
|
+
import { ObcCheckboxItemHoverStyle } from '../checkbox-item/checkbox-item.js';
|
|
3
|
+
/**
|
|
4
|
+
* `<obc-checkbox-list>` – A vertical list of `<obc-checkbox-item>` rows that
|
|
5
|
+
* collapses the rows under a closed parent.
|
|
6
|
+
*
|
|
7
|
+
* ### Overview
|
|
8
|
+
* Rows are slotted flat, in document order; the tree is read from each row's
|
|
9
|
+
* `level`. When an expandable row is collapsed, the list sets `hidden` on
|
|
10
|
+
* every following row with a greater level until a row of equal or smaller
|
|
11
|
+
* level. The list also applies its `hoverStyle` to every row so a list reads
|
|
12
|
+
* as one surface.
|
|
13
|
+
*
|
|
14
|
+
* ### Features
|
|
15
|
+
* - Flat markup, level-driven hierarchy — no nesting of elements required.
|
|
16
|
+
* - Handles `expand-toggle`: sets the row's `expanded` and recomputes.
|
|
17
|
+
* - Reacts to `expandable`, `expanded` and `level` changes made from outside.
|
|
18
|
+
* - `hoverStyle` forwarded to slotted rows, including rows added later.
|
|
19
|
+
*
|
|
20
|
+
* ### Usage Guidelines
|
|
21
|
+
* - Start levels at 1 when any row is expandable so chevrons and checkboxes
|
|
22
|
+
* align; use level 0 for a plain list.
|
|
23
|
+
* - The list owns the `hidden` attribute of its rows; do not bind it yourself.
|
|
24
|
+
* - Selection stays per row: listen to each row's `change`.
|
|
25
|
+
*
|
|
26
|
+
* ### Accessibility
|
|
27
|
+
* The host is the `role="group"`; rows are ordinary checkboxes and buttons in
|
|
28
|
+
* the natural tab order and hidden rows leave it. This is a group of
|
|
29
|
+
* checkboxes with disclosure buttons, not a tree widget, so there is no
|
|
30
|
+
* roving tabindex. Name the group with `aria-label` or `aria-labelledby` on
|
|
31
|
+
* the host.
|
|
32
|
+
*
|
|
33
|
+
* ### Example
|
|
34
|
+
* ```html
|
|
35
|
+
* <obc-checkbox-list aria-label="Report types">
|
|
36
|
+
* <obc-checkbox-item level="1" expandable expanded status="mixed" label="Reports"></obc-checkbox-item>
|
|
37
|
+
* <obc-checkbox-item level="2" status="checked" label="Monthly"></obc-checkbox-item>
|
|
38
|
+
* <obc-checkbox-item level="2" label="Quarterly"></obc-checkbox-item>
|
|
39
|
+
* <obc-checkbox-item level="1" expandable label="Archive"></obc-checkbox-item>
|
|
40
|
+
* </obc-checkbox-list>
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @property hoverStyle - Hover treatment applied to every slotted row: `touch-target` or `visual-target`.
|
|
44
|
+
* @slot - `obc-checkbox-item` rows in document order; hierarchy comes from each row's `level`.
|
|
45
|
+
* @beta
|
|
46
|
+
*/
|
|
47
|
+
export declare class ObcCheckboxList extends LitElement {
|
|
48
|
+
/** Hover treatment applied to every slotted row: `touch-target` or `visual-target`. */
|
|
49
|
+
hoverStyle: ObcCheckboxItemHoverStyle;
|
|
50
|
+
private mutationObserver?;
|
|
51
|
+
connectedCallback(): void;
|
|
52
|
+
disconnectedCallback(): void;
|
|
53
|
+
firstUpdated(): void;
|
|
54
|
+
updated(changed: PropertyValues<this>): void;
|
|
55
|
+
private onExpandToggle;
|
|
56
|
+
private rows;
|
|
57
|
+
private sync;
|
|
58
|
+
render(): import('lit-html').TemplateResult<1>;
|
|
59
|
+
static styles: import('lit').CSSResult;
|
|
60
|
+
}
|
|
61
|
+
declare global {
|
|
62
|
+
interface HTMLElementTagNameMap {
|
|
63
|
+
'obc-checkbox-list': ObcCheckboxList;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=checkbox-list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkbox-list.d.ts","sourceRoot":"","sources":["../../../src/components/checkbox-list/checkbox-list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAmB,KAAK,cAAc,EAAC,MAAM,KAAK,CAAC;AAIrE,OAAO,EAEL,yBAAyB,EAE1B,MAAM,mCAAmC,CAAC;AAG3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,qBACa,eAAgB,SAAQ,UAAU;IACnB,UAAU,EAAE,yBAAyB,CACvB;IAExC,OAAO,CAAC,gBAAgB,CAAC,CAAmB;IAEnC,iBAAiB,IAAI,IAAI;IAiBzB,oBAAoB,IAAI,IAAI;IAO5B,YAAY,IAAI,IAAI;IAIpB,OAAO,CAAC,OAAO,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,IAAI;IAIrD,OAAO,CAAC,cAAc,CAKpB;IAEF,OAAO,CAAC,IAAI;IAMZ,OAAO,CAAC,IAAI;IASH,MAAM;IAMf,OAAgB,MAAM,0BAA6B;CACpD;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,mBAAmB,EAAE,eAAe,CAAC;KACtC;CACF"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { unsafeCSS, LitElement, html } from "lit";
|
|
2
|
+
import { property } from "lit/decorators.js";
|
|
3
|
+
import { customElement } from "../../decorator.js";
|
|
4
|
+
import componentStyle from "./checkbox-list.css.js";
|
|
5
|
+
import { ObcCheckboxItemHoverStyle, ObcCheckboxItem } from "../checkbox-item/checkbox-item.js";
|
|
6
|
+
import { computeHiddenRows } from "./checkbox-list-visibility.js";
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
9
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
10
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
11
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
12
|
+
if (decorator = decorators[i])
|
|
13
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
14
|
+
if (kind && result) __defProp(target, key, result);
|
|
15
|
+
return result;
|
|
16
|
+
};
|
|
17
|
+
let ObcCheckboxList = class extends LitElement {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(...arguments);
|
|
20
|
+
this.hoverStyle = ObcCheckboxItemHoverStyle.touchTarget;
|
|
21
|
+
this.onExpandToggle = (event) => {
|
|
22
|
+
const row = event.target;
|
|
23
|
+
if (!(row instanceof ObcCheckboxItem)) return;
|
|
24
|
+
row.expanded = event.detail;
|
|
25
|
+
this.sync();
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
connectedCallback() {
|
|
29
|
+
super.connectedCallback();
|
|
30
|
+
if (!this.hasAttribute("role")) this.setAttribute("role", "group");
|
|
31
|
+
this.mutationObserver = new MutationObserver(() => this.sync());
|
|
32
|
+
this.mutationObserver.observe(this, {
|
|
33
|
+
childList: true,
|
|
34
|
+
attributes: true,
|
|
35
|
+
attributeFilter: ["expandable", "expanded", "level"],
|
|
36
|
+
subtree: true
|
|
37
|
+
});
|
|
38
|
+
this.addEventListener("expand-toggle", this.onExpandToggle);
|
|
39
|
+
}
|
|
40
|
+
disconnectedCallback() {
|
|
41
|
+
super.disconnectedCallback();
|
|
42
|
+
this.mutationObserver?.disconnect();
|
|
43
|
+
this.mutationObserver = void 0;
|
|
44
|
+
this.removeEventListener("expand-toggle", this.onExpandToggle);
|
|
45
|
+
}
|
|
46
|
+
firstUpdated() {
|
|
47
|
+
this.sync();
|
|
48
|
+
}
|
|
49
|
+
updated(changed) {
|
|
50
|
+
if (changed.has("hoverStyle")) this.sync();
|
|
51
|
+
}
|
|
52
|
+
rows() {
|
|
53
|
+
return Array.from(this.children).filter(
|
|
54
|
+
(el) => el instanceof ObcCheckboxItem
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
sync() {
|
|
58
|
+
const rows = this.rows();
|
|
59
|
+
const hidden = computeHiddenRows(rows);
|
|
60
|
+
rows.forEach((row, i) => {
|
|
61
|
+
row.hoverStyle = this.hoverStyle;
|
|
62
|
+
row.hidden = hidden[i];
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
render() {
|
|
66
|
+
return html`<div class="list">
|
|
67
|
+
<slot @slotchange=${() => this.sync()}></slot>
|
|
68
|
+
</div>`;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
ObcCheckboxList.styles = unsafeCSS(componentStyle);
|
|
72
|
+
__decorateClass([
|
|
73
|
+
property({ type: String })
|
|
74
|
+
], ObcCheckboxList.prototype, "hoverStyle", 2);
|
|
75
|
+
ObcCheckboxList = __decorateClass([
|
|
76
|
+
customElement("obc-checkbox-list")
|
|
77
|
+
], ObcCheckboxList);
|
|
78
|
+
export {
|
|
79
|
+
ObcCheckboxList
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=checkbox-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkbox-list.js","sources":["../../../src/components/checkbox-list/checkbox-list.ts"],"sourcesContent":["import {LitElement, html, unsafeCSS, type PropertyValues} from 'lit';\nimport {property} from 'lit/decorators.js';\nimport {customElement} from '../../decorator.js';\nimport componentStyle from './checkbox-list.css?inline';\nimport {\n ObcCheckboxItem,\n ObcCheckboxItemHoverStyle,\n type ObcCheckboxItemExpandToggleEvent,\n} from '../checkbox-item/checkbox-item.js';\nimport {computeHiddenRows} from './checkbox-list-visibility.js';\n\n/**\n * `<obc-checkbox-list>` – A vertical list of `<obc-checkbox-item>` rows that\n * collapses the rows under a closed parent.\n *\n * ### Overview\n * Rows are slotted flat, in document order; the tree is read from each row's\n * `level`. When an expandable row is collapsed, the list sets `hidden` on\n * every following row with a greater level until a row of equal or smaller\n * level. The list also applies its `hoverStyle` to every row so a list reads\n * as one surface.\n *\n * ### Features\n * - Flat markup, level-driven hierarchy — no nesting of elements required.\n * - Handles `expand-toggle`: sets the row's `expanded` and recomputes.\n * - Reacts to `expandable`, `expanded` and `level` changes made from outside.\n * - `hoverStyle` forwarded to slotted rows, including rows added later.\n *\n * ### Usage Guidelines\n * - Start levels at 1 when any row is expandable so chevrons and checkboxes\n * align; use level 0 for a plain list.\n * - The list owns the `hidden` attribute of its rows; do not bind it yourself.\n * - Selection stays per row: listen to each row's `change`.\n *\n * ### Accessibility\n * The host is the `role=\"group\"`; rows are ordinary checkboxes and buttons in\n * the natural tab order and hidden rows leave it. This is a group of\n * checkboxes with disclosure buttons, not a tree widget, so there is no\n * roving tabindex. Name the group with `aria-label` or `aria-labelledby` on\n * the host.\n *\n * ### Example\n * ```html\n * <obc-checkbox-list aria-label=\"Report types\">\n * <obc-checkbox-item level=\"1\" expandable expanded status=\"mixed\" label=\"Reports\"></obc-checkbox-item>\n * <obc-checkbox-item level=\"2\" status=\"checked\" label=\"Monthly\"></obc-checkbox-item>\n * <obc-checkbox-item level=\"2\" label=\"Quarterly\"></obc-checkbox-item>\n * <obc-checkbox-item level=\"1\" expandable label=\"Archive\"></obc-checkbox-item>\n * </obc-checkbox-list>\n * ```\n *\n * @property hoverStyle - Hover treatment applied to every slotted row: `touch-target` or `visual-target`.\n * @slot - `obc-checkbox-item` rows in document order; hierarchy comes from each row's `level`.\n * @beta\n */\n@customElement('obc-checkbox-list')\nexport class ObcCheckboxList extends LitElement {\n @property({type: String}) hoverStyle: ObcCheckboxItemHoverStyle =\n ObcCheckboxItemHoverStyle.touchTarget;\n\n private mutationObserver?: MutationObserver;\n\n override connectedCallback(): void {\n super.connectedCallback();\n // The role sits on the host so a consumer's aria-label / aria-labelledby\n // names the group.\n if (!this.hasAttribute('role')) this.setAttribute('role', 'group');\n // Rows are light-DOM children owned by the consumer, so `expandable`,\n // `expanded` and `level` can change without any event reaching the list.\n this.mutationObserver = new MutationObserver(() => this.sync());\n this.mutationObserver.observe(this, {\n childList: true,\n attributes: true,\n attributeFilter: ['expandable', 'expanded', 'level'],\n subtree: true,\n });\n this.addEventListener('expand-toggle', this.onExpandToggle);\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.mutationObserver?.disconnect();\n this.mutationObserver = undefined;\n this.removeEventListener('expand-toggle', this.onExpandToggle);\n }\n\n override firstUpdated(): void {\n this.sync();\n }\n\n override updated(changed: PropertyValues<this>): void {\n if (changed.has('hoverStyle')) this.sync();\n }\n\n private onExpandToggle = (event: Event): void => {\n const row = event.target;\n if (!(row instanceof ObcCheckboxItem)) return;\n row.expanded = (event as ObcCheckboxItemExpandToggleEvent).detail;\n this.sync();\n };\n\n private rows(): ObcCheckboxItem[] {\n return Array.from(this.children).filter(\n (el): el is ObcCheckboxItem => el instanceof ObcCheckboxItem\n );\n }\n\n private sync(): void {\n const rows = this.rows();\n const hidden = computeHiddenRows(rows);\n rows.forEach((row, i) => {\n row.hoverStyle = this.hoverStyle;\n row.hidden = hidden[i];\n });\n }\n\n override render() {\n return html`<div class=\"list\">\n <slot @slotchange=${() => this.sync()}></slot>\n </div>`;\n }\n\n static override styles = unsafeCSS(componentStyle);\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'obc-checkbox-list': ObcCheckboxList;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAwDO,IAAM,kBAAN,cAA8B,WAAW;AAAA,EAAzC,cAAA;AAAA,UAAA,GAAA,SAAA;AACqB,SAAA,aACxB,0BAA0B;AAoC5B,SAAQ,iBAAiB,CAAC,UAAuB;AAC/C,YAAM,MAAM,MAAM;AAClB,UAAI,EAAE,eAAe,iBAAkB;AACvC,UAAI,WAAY,MAA2C;AAC3D,WAAK,KAAA;AAAA,IACP;AAAA,EAAA;AAAA,EArCS,oBAA0B;AACjC,UAAM,kBAAA;AAGN,QAAI,CAAC,KAAK,aAAa,MAAM,EAAG,MAAK,aAAa,QAAQ,OAAO;AAGjE,SAAK,mBAAmB,IAAI,iBAAiB,MAAM,KAAK,MAAM;AAC9D,SAAK,iBAAiB,QAAQ,MAAM;AAAA,MAClC,WAAW;AAAA,MACX,YAAY;AAAA,MACZ,iB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