@fluid-topics/ft-checkbox 1.3.63 → 1.4.3
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/build/ft-base-checkbox.d.ts +45 -0
- package/build/ft-base-checkbox.js +174 -0
- package/build/ft-checkbox.d.ts +3 -18
- package/build/ft-checkbox.js +5 -108
- package/build/ft-checkbox.light.js +2071 -176
- package/build/ft-checkbox.min.js +2066 -179
- package/build/ft-checkbox.styles.js +1 -1
- package/build/ftds-checkbox.d.ts +29 -0
- package/build/ftds-checkbox.js +111 -0
- package/build/ftds-checkbox.styles.d.ts +1 -0
- package/build/ftds-checkbox.styles.js +158 -0
- package/build/index.d.ts +2 -1
- package/build/index.js +4 -1
- package/package.json +8 -5
- package/build/ft-checkbox.properties.d.ts +0 -6
- package/build/ft-checkbox.properties.js +0 -1
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { PropertyValues } from "lit";
|
|
2
|
+
import { ElementDefinitionsMap, FtLitElement } from "@fluid-topics/ft-wc-utils";
|
|
3
|
+
import { ClassInfo } from "lit/directives/class-map.js";
|
|
4
|
+
export interface FtBaseCheckboxProperties {
|
|
5
|
+
name: string;
|
|
6
|
+
value: string;
|
|
7
|
+
label: string;
|
|
8
|
+
checked: boolean;
|
|
9
|
+
indeterminate: boolean;
|
|
10
|
+
disabled: boolean;
|
|
11
|
+
legendColor: string;
|
|
12
|
+
helper: string;
|
|
13
|
+
}
|
|
14
|
+
export declare class FtCheckboxChangeEvent extends CustomEvent<boolean> {
|
|
15
|
+
constructor(checked: boolean);
|
|
16
|
+
}
|
|
17
|
+
export declare class FtBaseCheckbox extends FtLitElement implements FtBaseCheckboxProperties {
|
|
18
|
+
static elementDefinitions: ElementDefinitionsMap;
|
|
19
|
+
name: string;
|
|
20
|
+
value: string;
|
|
21
|
+
label: string;
|
|
22
|
+
helper: string;
|
|
23
|
+
checked: boolean;
|
|
24
|
+
indeterminate: boolean;
|
|
25
|
+
disabled: boolean;
|
|
26
|
+
rippleUnbounded: boolean;
|
|
27
|
+
error: boolean;
|
|
28
|
+
legendColor: string;
|
|
29
|
+
private container?;
|
|
30
|
+
private ripple?;
|
|
31
|
+
private input;
|
|
32
|
+
get checkboxClasses(): ClassInfo;
|
|
33
|
+
get checkboxHelperClasses(): ClassInfo;
|
|
34
|
+
get typographyVariant(): string;
|
|
35
|
+
protected renderBoxContainer(): import("lit-html").TemplateResult<1>;
|
|
36
|
+
protected render(): import("lit-html").TemplateResult<1>;
|
|
37
|
+
protected renderBoxIcon(): any;
|
|
38
|
+
protected renderSlotBody(): unknown;
|
|
39
|
+
protected onSlotchange(): void;
|
|
40
|
+
protected willUpdate(changedProperties: PropertyValues): void;
|
|
41
|
+
protected onChange(event: Event): void;
|
|
42
|
+
protected contentAvailableCallback(props: PropertyValues): void;
|
|
43
|
+
click(): void;
|
|
44
|
+
focus(): void;
|
|
45
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { html, } from "lit";
|
|
8
|
+
import { property, query, } from "lit/decorators.js";
|
|
9
|
+
import { FtLitElement, } from "@fluid-topics/ft-wc-utils";
|
|
10
|
+
import { classMap, } from "lit/directives/class-map.js";
|
|
11
|
+
import { FtRipple } from "@fluid-topics/ft-ripple";
|
|
12
|
+
import { FtTypography, FtTypographyVariants, } from "@fluid-topics/ft-typography";
|
|
13
|
+
export class FtCheckboxChangeEvent extends CustomEvent {
|
|
14
|
+
constructor(checked) {
|
|
15
|
+
super("change", { detail: checked });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
class FtBaseCheckbox extends FtLitElement {
|
|
19
|
+
constructor() {
|
|
20
|
+
super(...arguments);
|
|
21
|
+
this.name = "";
|
|
22
|
+
this.value = "";
|
|
23
|
+
this.label = "";
|
|
24
|
+
this.helper = "";
|
|
25
|
+
this.checked = false;
|
|
26
|
+
this.indeterminate = false;
|
|
27
|
+
this.disabled = false;
|
|
28
|
+
this.rippleUnbounded = true;
|
|
29
|
+
this.error = false;
|
|
30
|
+
this.legendColor = "";
|
|
31
|
+
}
|
|
32
|
+
get checkboxClasses() {
|
|
33
|
+
return {
|
|
34
|
+
"ft-checkbox": true,
|
|
35
|
+
"ft-checkbox--error": this.error,
|
|
36
|
+
"ft-checkbox--checked": this.indeterminate ? false : this.checked,
|
|
37
|
+
"ft-checkbox--indeterminate": this.indeterminate,
|
|
38
|
+
"ft-checkbox--disabled": this.disabled,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
get checkboxHelperClasses() {
|
|
42
|
+
return {
|
|
43
|
+
"ft-checkbox-helper--disabled": this.disabled,
|
|
44
|
+
"ft-checkbox-helper--error": this.error,
|
|
45
|
+
"ft-checkbox-helper--checked": this.indeterminate ? false : this.checked,
|
|
46
|
+
"ft-checkbox-helper--indeterminate": this.indeterminate,
|
|
47
|
+
"ft-checkbox-helper--legend-color-displayed": this.legendColor && this.legendColor.trim().length > 0,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
get typographyVariant() {
|
|
51
|
+
return FtTypographyVariants.body2;
|
|
52
|
+
}
|
|
53
|
+
renderBoxContainer() {
|
|
54
|
+
return html `
|
|
55
|
+
<div class="ft-checkbox--box-container" part="checkbox-box-container">
|
|
56
|
+
<ft-ripple part="checkbox-ripple"
|
|
57
|
+
?disabled=${this.disabled}
|
|
58
|
+
?primary=${this.checked || this.indeterminate}
|
|
59
|
+
?unbounded=${this.rippleUnbounded}>
|
|
60
|
+
</ft-ripple>
|
|
61
|
+
<div class="ft-checkbox--box" part="checkbox-box">
|
|
62
|
+
${this.renderBoxIcon()}
|
|
63
|
+
</div>
|
|
64
|
+
<input type="checkbox"
|
|
65
|
+
id="checkbox-input"
|
|
66
|
+
part="checkbox-input"
|
|
67
|
+
name="${this.name}"
|
|
68
|
+
aria-checked="${this.indeterminate ? "mixed" : (this.checked ? "true" : "false")}"
|
|
69
|
+
role="checkbox"
|
|
70
|
+
.checked=${this.indeterminate ? false : this.checked}
|
|
71
|
+
.indeterminate=${this.indeterminate}
|
|
72
|
+
.disabled=${this.disabled}
|
|
73
|
+
@change=${this.onChange}
|
|
74
|
+
>
|
|
75
|
+
</div>
|
|
76
|
+
`;
|
|
77
|
+
}
|
|
78
|
+
render() {
|
|
79
|
+
return html `
|
|
80
|
+
<label class="${classMap(this.checkboxClasses)}" for="checkbox-input" part="checkbox-label">
|
|
81
|
+
${this.renderBoxContainer()}
|
|
82
|
+
${this.renderSlotBody()}
|
|
83
|
+
</label>
|
|
84
|
+
`;
|
|
85
|
+
}
|
|
86
|
+
renderBoxIcon() {
|
|
87
|
+
return html `
|
|
88
|
+
<svg class="ft-checkbox--checkmark" viewBox="0 0 24 24" part="checkbox-check" aria-hidden="true">
|
|
89
|
+
<path class="ft-checkbox--checkmark-path" fill="none"
|
|
90
|
+
d="${(this.indeterminate && !this.checked)
|
|
91
|
+
? "M2,12 22,12"
|
|
92
|
+
: "M1.73,12.91 8.1,19.28 22.79,4.59"}"></path>
|
|
93
|
+
</svg>
|
|
94
|
+
`;
|
|
95
|
+
}
|
|
96
|
+
renderSlotBody() {
|
|
97
|
+
return html `
|
|
98
|
+
<ft-typography variant="${this.typographyVariant}" part="checkbox-body">
|
|
99
|
+
<slot @slotchange=${this.onSlotchange}></slot>
|
|
100
|
+
</ft-typography>
|
|
101
|
+
`;
|
|
102
|
+
}
|
|
103
|
+
onSlotchange() {
|
|
104
|
+
this.requestUpdate();
|
|
105
|
+
}
|
|
106
|
+
willUpdate(changedProperties) {
|
|
107
|
+
super.willUpdate(changedProperties);
|
|
108
|
+
if (changedProperties.has("checked")) {
|
|
109
|
+
this.ariaChecked = this.checked ? "true" : "false";
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
onChange(event) {
|
|
113
|
+
event.stopPropagation();
|
|
114
|
+
this.checked = event.target.checked;
|
|
115
|
+
this.indeterminate = false;
|
|
116
|
+
this.dispatchEvent(new FtCheckboxChangeEvent(this.checked));
|
|
117
|
+
}
|
|
118
|
+
contentAvailableCallback(props) {
|
|
119
|
+
var _a;
|
|
120
|
+
super.contentAvailableCallback(props);
|
|
121
|
+
(_a = this.ripple) === null || _a === void 0 ? void 0 : _a.setupFor(this.container);
|
|
122
|
+
}
|
|
123
|
+
click() {
|
|
124
|
+
this.input.click();
|
|
125
|
+
}
|
|
126
|
+
focus() {
|
|
127
|
+
this.input.focus();
|
|
128
|
+
setTimeout(() => {
|
|
129
|
+
var _a;
|
|
130
|
+
(_a = this.ripple) === null || _a === void 0 ? void 0 : _a.forceFocusUpdate();
|
|
131
|
+
}, 0);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
FtBaseCheckbox.elementDefinitions = {
|
|
135
|
+
"ft-ripple": FtRipple,
|
|
136
|
+
"ft-typography": FtTypography,
|
|
137
|
+
};
|
|
138
|
+
__decorate([
|
|
139
|
+
property()
|
|
140
|
+
], FtBaseCheckbox.prototype, "name", void 0);
|
|
141
|
+
__decorate([
|
|
142
|
+
property()
|
|
143
|
+
], FtBaseCheckbox.prototype, "value", void 0);
|
|
144
|
+
__decorate([
|
|
145
|
+
property()
|
|
146
|
+
], FtBaseCheckbox.prototype, "label", void 0);
|
|
147
|
+
__decorate([
|
|
148
|
+
property()
|
|
149
|
+
], FtBaseCheckbox.prototype, "helper", void 0);
|
|
150
|
+
__decorate([
|
|
151
|
+
property({ type: Boolean, reflect: true })
|
|
152
|
+
], FtBaseCheckbox.prototype, "checked", void 0);
|
|
153
|
+
__decorate([
|
|
154
|
+
property({ type: Boolean })
|
|
155
|
+
], FtBaseCheckbox.prototype, "indeterminate", void 0);
|
|
156
|
+
__decorate([
|
|
157
|
+
property({ type: Boolean })
|
|
158
|
+
], FtBaseCheckbox.prototype, "disabled", void 0);
|
|
159
|
+
__decorate([
|
|
160
|
+
property({ type: Boolean })
|
|
161
|
+
], FtBaseCheckbox.prototype, "error", void 0);
|
|
162
|
+
__decorate([
|
|
163
|
+
property()
|
|
164
|
+
], FtBaseCheckbox.prototype, "legendColor", void 0);
|
|
165
|
+
__decorate([
|
|
166
|
+
query(".ft-checkbox")
|
|
167
|
+
], FtBaseCheckbox.prototype, "container", void 0);
|
|
168
|
+
__decorate([
|
|
169
|
+
query("ft-ripple")
|
|
170
|
+
], FtBaseCheckbox.prototype, "ripple", void 0);
|
|
171
|
+
__decorate([
|
|
172
|
+
query("input")
|
|
173
|
+
], FtBaseCheckbox.prototype, "input", void 0);
|
|
174
|
+
export { FtBaseCheckbox };
|
package/build/ft-checkbox.d.ts
CHANGED
|
@@ -1,20 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { FtCheckboxProperties } from "./ft-checkbox.properties";
|
|
4
|
-
export declare class FtCheckbox extends FtLitElement implements FtCheckboxProperties {
|
|
5
|
-
static elementDefinitions: ElementDefinitionsMap;
|
|
1
|
+
import { FtBaseCheckbox, FtBaseCheckboxProperties } from "./ft-base-checkbox";
|
|
2
|
+
export declare class FtCheckbox extends FtBaseCheckbox implements FtBaseCheckboxProperties {
|
|
6
3
|
static styles: import("lit").CSSResult;
|
|
7
|
-
|
|
8
|
-
checked: boolean;
|
|
9
|
-
indeterminate: boolean;
|
|
10
|
-
disabled: boolean;
|
|
11
|
-
error: boolean;
|
|
12
|
-
private container?;
|
|
13
|
-
private ripple?;
|
|
14
|
-
private input;
|
|
15
|
-
protected render(): import("lit-html").TemplateResult<1>;
|
|
16
|
-
private onChange;
|
|
17
|
-
protected contentAvailableCallback(props: PropertyValues): void;
|
|
18
|
-
click(): void;
|
|
19
|
-
focus(): void;
|
|
4
|
+
get typographyVariant(): string;
|
|
20
5
|
}
|
package/build/ft-checkbox.js
CHANGED
|
@@ -1,113 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
import { html } from "lit";
|
|
8
|
-
import { property, query } from "lit/decorators.js";
|
|
9
|
-
import { FtLitElement } from "@fluid-topics/ft-wc-utils";
|
|
10
|
-
import { classMap } from "lit/directives/class-map.js";
|
|
11
|
-
import { FtRipple } from "@fluid-topics/ft-ripple";
|
|
12
|
-
import { FtTypography } from "@fluid-topics/ft-typography";
|
|
1
|
+
import { FtBaseCheckbox, } from "./ft-base-checkbox";
|
|
2
|
+
import { FtTypographyVariants } from "@fluid-topics/ft-typography";
|
|
13
3
|
import { styles } from "./ft-checkbox.styles";
|
|
14
|
-
class FtCheckbox extends
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
this.name = "";
|
|
18
|
-
this.checked = false;
|
|
19
|
-
this.indeterminate = false;
|
|
20
|
-
this.disabled = false;
|
|
21
|
-
this.error = false;
|
|
22
|
-
}
|
|
23
|
-
render() {
|
|
24
|
-
const classes = {
|
|
25
|
-
"ft-checkbox": true,
|
|
26
|
-
"ft-checkbox--error": this.error,
|
|
27
|
-
"ft-checkbox--checked": this.checked,
|
|
28
|
-
"ft-checkbox--indeterminate": this.indeterminate,
|
|
29
|
-
"ft-checkbox--disabled": this.disabled,
|
|
30
|
-
};
|
|
31
|
-
return html `
|
|
32
|
-
<label class="${classMap(classes)}" for="checkbox-input" part="checkbox-label">
|
|
33
|
-
<div class="ft-checkbox--box-container" part="checkbox-box-container">
|
|
34
|
-
<ft-ripple part="checkbox-ripple"
|
|
35
|
-
?disabled=${this.disabled}
|
|
36
|
-
?primary=${this.checked || this.indeterminate}
|
|
37
|
-
unbounded>
|
|
38
|
-
</ft-ripple>
|
|
39
|
-
<div class="ft-checkbox--box" part="checkbox-box">
|
|
40
|
-
<svg class="ft-checkbox--checkmark" viewBox="0 0 24 24" part="checkbox-check" aria-hidden="true">
|
|
41
|
-
<path class="ft-checkbox--checkmark-path" fill="none"
|
|
42
|
-
d=${(this.indeterminate && !this.checked)
|
|
43
|
-
? "M2,12 22,12"
|
|
44
|
-
: "M1.73,12.91 8.1,19.28 22.79,4.59"}></path>
|
|
45
|
-
</svg>
|
|
46
|
-
</div>
|
|
47
|
-
<input type="checkbox"
|
|
48
|
-
id="checkbox-input"
|
|
49
|
-
name="${this.name}"
|
|
50
|
-
.checked=${this.checked}
|
|
51
|
-
.disabled=${this.disabled}
|
|
52
|
-
@change=${this.onChange}
|
|
53
|
-
aria-checked=${this.indeterminate ? "mixed" : (this.checked ? "true" : "false")}
|
|
54
|
-
>
|
|
55
|
-
</div>
|
|
56
|
-
<ft-typography variant="body2" part="checkbox-body">
|
|
57
|
-
<slot></slot>
|
|
58
|
-
</ft-typography>
|
|
59
|
-
</label>
|
|
60
|
-
`;
|
|
61
|
-
}
|
|
62
|
-
onChange(event) {
|
|
63
|
-
event.stopPropagation();
|
|
64
|
-
this.checked = event.target.checked;
|
|
65
|
-
this.indeterminate = false;
|
|
66
|
-
this.dispatchEvent(new CustomEvent("change", { detail: this.checked }));
|
|
67
|
-
}
|
|
68
|
-
contentAvailableCallback(props) {
|
|
69
|
-
var _a;
|
|
70
|
-
super.contentAvailableCallback(props);
|
|
71
|
-
(_a = this.ripple) === null || _a === void 0 ? void 0 : _a.setupFor(this.container);
|
|
72
|
-
}
|
|
73
|
-
click() {
|
|
74
|
-
this.input.click();
|
|
75
|
-
}
|
|
76
|
-
focus() {
|
|
77
|
-
this.input.focus();
|
|
78
|
-
setTimeout(() => {
|
|
79
|
-
var _a;
|
|
80
|
-
(_a = this.ripple) === null || _a === void 0 ? void 0 : _a.forceFocusUpdate();
|
|
81
|
-
}, 0);
|
|
4
|
+
class FtCheckbox extends FtBaseCheckbox {
|
|
5
|
+
get typographyVariant() {
|
|
6
|
+
return FtTypographyVariants.body2;
|
|
82
7
|
}
|
|
83
8
|
}
|
|
84
|
-
FtCheckbox.elementDefinitions = {
|
|
85
|
-
"ft-ripple": FtRipple,
|
|
86
|
-
"ft-typography": FtTypography
|
|
87
|
-
};
|
|
88
9
|
FtCheckbox.styles = styles;
|
|
89
|
-
__decorate([
|
|
90
|
-
property()
|
|
91
|
-
], FtCheckbox.prototype, "name", void 0);
|
|
92
|
-
__decorate([
|
|
93
|
-
property({ type: Boolean, reflect: true })
|
|
94
|
-
], FtCheckbox.prototype, "checked", void 0);
|
|
95
|
-
__decorate([
|
|
96
|
-
property({ type: Boolean })
|
|
97
|
-
], FtCheckbox.prototype, "indeterminate", void 0);
|
|
98
|
-
__decorate([
|
|
99
|
-
property({ type: Boolean })
|
|
100
|
-
], FtCheckbox.prototype, "disabled", void 0);
|
|
101
|
-
__decorate([
|
|
102
|
-
property({ type: Boolean })
|
|
103
|
-
], FtCheckbox.prototype, "error", void 0);
|
|
104
|
-
__decorate([
|
|
105
|
-
query(".ft-checkbox")
|
|
106
|
-
], FtCheckbox.prototype, "container", void 0);
|
|
107
|
-
__decorate([
|
|
108
|
-
query("ft-ripple")
|
|
109
|
-
], FtCheckbox.prototype, "ripple", void 0);
|
|
110
|
-
__decorate([
|
|
111
|
-
query("input")
|
|
112
|
-
], FtCheckbox.prototype, "input", void 0);
|
|
113
10
|
export { FtCheckbox };
|