@fluid-topics/ft-checkbox 1.3.63 → 1.4.1

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.
@@ -1,4 +1,4 @@
1
- import { designSystemVariables, FtCssVariableFactory, setVariable } from "@fluid-topics/ft-wc-utils";
1
+ import { designSystemVariables, FtCssVariableFactory, setVariable, } from "@fluid-topics/ft-wc-utils";
2
2
  import { css } from "lit";
3
3
  import { FtTypographyCssVariables } from "@fluid-topics/ft-typography";
4
4
  import { FtRippleCssVariables } from "@fluid-topics/ft-ripple";
@@ -0,0 +1,29 @@
1
+ import { FtBaseCheckbox, FtBaseCheckboxProperties } from "./ft-base-checkbox";
2
+ import { ClassInfo } from "lit/directives/class-map.js";
3
+ import { ElementDefinitionsMap } from "@fluid-topics/ft-wc-utils";
4
+ import { DesignSystemFamily } from "@fluid-topics/design-system-variables";
5
+ import { nothing } from "lit";
6
+ export declare class FtdsCheckboxChangeEvent extends CustomEvent<{
7
+ value: string;
8
+ checked: boolean;
9
+ }> {
10
+ constructor(value: string, checked: boolean);
11
+ }
12
+ declare const FtdsCheckbox_base: import("@fluid-topics/ft-wc-utils").FtdsBaseType<typeof FtBaseCheckbox>;
13
+ export declare class FtdsCheckbox extends FtdsCheckbox_base implements FtBaseCheckboxProperties {
14
+ static elementDefinitions: ElementDefinitionsMap;
15
+ rippleUnbounded: boolean;
16
+ family: DesignSystemFamily;
17
+ static styles: import("lit").CSSResult[];
18
+ get checkboxClasses(): ClassInfo;
19
+ protected render(): import("lit-html").TemplateResult<1>;
20
+ protected renderBoxIcon(): unknown;
21
+ private notNullOrBlank;
22
+ protected renderSlotBody(): import("lit-html").TemplateResult<1> | typeof nothing;
23
+ protected renderLegendColor(): import("lit-html").TemplateResult<1> | typeof nothing;
24
+ protected renderHelper(): import("lit-html").TemplateResult<1> | typeof nothing;
25
+ protected renderPopover(): import("lit-html").TemplateResult<1>;
26
+ get typographyVariant(): string;
27
+ protected onChange(event: Event): void;
28
+ }
29
+ export {};
@@ -0,0 +1,111 @@
1
+ import { FtBaseCheckbox, } from "./ft-base-checkbox";
2
+ import { classMap, } from "lit/directives/class-map.js";
3
+ import { safariEllipsisFix, toFtdsBase, } from "@fluid-topics/ft-wc-utils";
4
+ import { dsStyles } from "./ftds-checkbox.styles";
5
+ import { DesignSystemFamily } from "@fluid-topics/design-system-variables";
6
+ import { FtdsTypography, FtdsTypographyVariants, } from "@fluid-topics/ft-typography";
7
+ import { html, nothing, } from "lit";
8
+ import { FtIcon, FtIcons, } from "@fluid-topics/ft-icon";
9
+ import { FtdsPopover } from "@fluid-topics/ft-popover";
10
+ import { FtdsLink } from "@fluid-topics/ft-link";
11
+ export class FtdsCheckboxChangeEvent extends CustomEvent {
12
+ constructor(value, checked) {
13
+ super("change", { detail: { value: value, checked: checked }, bubbles: true, composed: true });
14
+ }
15
+ }
16
+ class FtdsCheckbox extends toFtdsBase(FtBaseCheckbox) {
17
+ constructor() {
18
+ super(...arguments);
19
+ this.rippleUnbounded = false;
20
+ this.family = DesignSystemFamily.brand;
21
+ }
22
+ get checkboxClasses() {
23
+ return {
24
+ ...super.checkboxClasses,
25
+ ...this.getDesignSystemBaseClasses(),
26
+ };
27
+ }
28
+ render() {
29
+ return html `
30
+ <div part="checkbox-and-popover">
31
+ <div part="checkbox-label-and-helper">
32
+ <label class="${classMap(this.checkboxClasses)}" for="checkbox-input" part="checkbox-label">
33
+ ${this.renderBoxContainer()}
34
+ ${this.renderLegendColor()}
35
+ ${this.renderSlotBody()}
36
+ </label>
37
+ ${this.renderHelper()}
38
+ </div>
39
+ ${this.renderPopover()}
40
+ </div>
41
+ `;
42
+ }
43
+ renderBoxIcon() {
44
+ if (this.indeterminate) {
45
+ return html `
46
+ <ft-icon part="checkbox-icon" value="${FtIcons.HYPHEN_SOLID}"></ft-icon>`;
47
+ }
48
+ if (this.checked) {
49
+ return html `
50
+ <ft-icon part="checkbox-icon" value="${FtIcons.CHECK}"></ft-icon>`;
51
+ }
52
+ return nothing;
53
+ }
54
+ notNullOrBlank(field) {
55
+ return field && field.trim().length > 0;
56
+ }
57
+ renderSlotBody() {
58
+ return this.notNullOrBlank(this.label)
59
+ ? html `
60
+ <ftds-typography variant="${this.typographyVariant}"
61
+ part="checkbox-body">${this.label}
62
+ </ftds-typography>`
63
+ : nothing;
64
+ }
65
+ renderLegendColor() {
66
+ return this.notNullOrBlank(this.legendColor)
67
+ ? html `
68
+ <div part="checkbox-legend-color"
69
+ style="background-color: ${this.legendColor}">
70
+ </div>`
71
+ : nothing;
72
+ }
73
+ renderHelper() {
74
+ return this.notNullOrBlank(this.helper)
75
+ ? html `
76
+ <ftds-typography class="${classMap(this.checkboxHelperClasses)}"
77
+ variant="${FtdsTypographyVariants.caption1medium}"
78
+ part="checkbox-helper">${this.helper}
79
+ </ftds-typography>`
80
+ : nothing;
81
+ }
82
+ renderPopover() {
83
+ return html `
84
+ <div part="checkbox-popover">
85
+ <div part="checkbox-popover-wrapper">
86
+ <slot @slotchange=${this.onSlotchange}></slot>
87
+ </div>
88
+ </div>`;
89
+ }
90
+ get typographyVariant() {
91
+ return FtdsTypographyVariants.body2medium;
92
+ }
93
+ onChange(event) {
94
+ event.stopPropagation();
95
+ this.checked = event.target.checked;
96
+ this.indeterminate = false;
97
+ this.dispatchEvent(new FtdsCheckboxChangeEvent(this.value, this.checked));
98
+ }
99
+ }
100
+ FtdsCheckbox.elementDefinitions = {
101
+ ...FtBaseCheckbox.elementDefinitions,
102
+ "ftds-popover": FtdsPopover,
103
+ "ftds-link": FtdsLink,
104
+ "ftds-typography": FtdsTypography,
105
+ "ft-icon": FtIcon,
106
+ };
107
+ FtdsCheckbox.styles = [
108
+ safariEllipsisFix,
109
+ dsStyles,
110
+ ];
111
+ export { FtdsCheckbox };
@@ -0,0 +1 @@
1
+ export declare const dsStyles: import("lit").CSSResult;
@@ -0,0 +1,158 @@
1
+ import { checkbox, } from "@fluid-topics/ft-wc-utils";
2
+ import { css } from "lit";
3
+ import { FtRippleCssVariables } from "@fluid-topics/ft-ripple";
4
+ import { FtIconCssVariables } from "@fluid-topics/ft-icon";
5
+ // language=CSS
6
+ export const dsStyles = css `
7
+ * {
8
+ box-sizing: border-box;
9
+ --input-size: calc(${checkbox.boxSize} + 2 * (${checkbox.focusOutlineOffset} + ${checkbox.focusOutlineWidth}));
10
+ --input-margin: calc(-1 * ${checkbox.focusOutlineOffset} - ${checkbox.focusOutlineWidth});
11
+ }
12
+
13
+ [part="checkbox-label-and-helper"] {
14
+ display: flex;
15
+ flex-direction: column;
16
+ align-items: self-start;
17
+ gap: ${checkbox.helperPaddingTop};
18
+ }
19
+
20
+ [part="checkbox-and-popover"] {
21
+ display: flex;
22
+ align-items: flex-start;
23
+ gap: ${checkbox.labelHorizontalGap};
24
+ }
25
+
26
+ [part="checkbox-popover"] {
27
+ flex: 0 0 auto;
28
+ height: ${checkbox.boxSize};
29
+
30
+ }
31
+
32
+ [part="checkbox-popover-wrapper"] {
33
+ margin-top: -5px;
34
+ }
35
+
36
+ [part="checkbox-helper"] {
37
+ display: block;
38
+ color: ${checkbox.helperTextColor};
39
+ margin-left: calc(${checkbox.boxSize} + ${checkbox.horizontalGap});
40
+
41
+ &.ft-checkbox-helper--disabled {
42
+ background-color: transparent;
43
+ opacity: ${checkbox.uncheckedDisabledComponentOpacity};
44
+ }
45
+
46
+ &.ft-checkbox-helper--disabled.ft-checkbox-helper--checked, &.ft-checkbox-helper--disabled.ft-checkbox-helper--indeterminate {
47
+ background-color: transparent;
48
+ opacity: ${checkbox.checkedDisabledComponentOpacity};
49
+ }
50
+
51
+ &.ft-checkbox-helper--legend-color-displayed {
52
+ margin-left: calc(${checkbox.boxSize} + (${checkbox.horizontalGap} * 2 + ${checkbox.colorLegendSize}));
53
+ }
54
+ }
55
+
56
+ .ft-checkbox {
57
+ display: inline-flex;
58
+ align-items: flex-start;
59
+ gap: ${checkbox.horizontalGap};
60
+ color: ${checkbox.color};
61
+
62
+ input {
63
+ opacity: 0;
64
+ position: absolute;
65
+ flex: 0 0 auto;
66
+ width: var(--input-size);
67
+ height: var(--input-size);
68
+ border-radius: ${checkbox.borderRadius};
69
+ }
70
+
71
+ .ft-checkbox--box-container {
72
+ position: relative;
73
+ display: flex;
74
+ flex: 0 0 auto;
75
+ justify-content: center;
76
+ align-items: center;
77
+ width: var(--input-size);
78
+ height: var(--input-size);
79
+ margin: var(--input-margin);
80
+ border-radius: ${checkbox.borderRadius};
81
+ }
82
+
83
+ .ft-checkbox--box-container:has(:focus-visible) {
84
+ outline: ${checkbox.focusOutlineWidth} solid ${checkbox.focusFocusRingColor};
85
+ }
86
+
87
+ .ft-checkbox--box {
88
+ display: flex;
89
+ flex: 0 0 auto;
90
+ align-items: center;
91
+ justify-content: center;
92
+ box-shadow: inset 0 0 0 ${checkbox.borderWidth} ${checkbox.uncheckedBorderColor};
93
+ border-radius: ${checkbox.borderRadius};
94
+ width: ${checkbox.boxSize};
95
+ height: ${checkbox.boxSize};
96
+ color: ${checkbox.checkedIconColor};
97
+
98
+ ft-icon {
99
+ ${FtIconCssVariables.size.set(checkbox.iconSize)};
100
+ }
101
+ }
102
+
103
+ &.ft-checkbox--disabled {
104
+ background-color: transparent;
105
+ opacity: ${checkbox.uncheckedDisabledComponentOpacity};
106
+ }
107
+
108
+ ft-ripple {
109
+ flex: 0 0 auto;
110
+ z-index: 0;
111
+ ${FtRippleCssVariables.color.set(checkbox.uncheckedStateLayerColor)};
112
+ ${FtRippleCssVariables.backgroundColor.set(checkbox.uncheckedStateLayerColor)};
113
+ ${FtRippleCssVariables.opacityContentOnSurfaceHover.set(checkbox.uncheckedHoverStateLayerOpacity)};
114
+ ${FtRippleCssVariables.opacityContentOnSurfaceFocused.set(checkbox.uncheckedFocusStateLayerOpacity)};
115
+ ${FtRippleCssVariables.opacityContentOnSurfacePressed.set(checkbox.uncheckedActiveStateLayerOpacity)};
116
+ ${FtRippleCssVariables.borderRadius.set("2px")};
117
+ }
118
+
119
+ [part="checkbox-legend-color"] {
120
+ flex: 0 0 auto;
121
+ margin-top: calc((${checkbox.boxSize} - ${checkbox.colorLegendSize}) / 2);
122
+ width: ${checkbox.colorLegendSize};
123
+ height: ${checkbox.colorLegendSize};
124
+ border-radius: 50%;
125
+ }
126
+ }
127
+
128
+ .ft-checkbox--checked, .ft-checkbox--indeterminate {
129
+ color: ${checkbox.color};
130
+
131
+ .ft-checkbox--box {
132
+ display: flex;
133
+ align-items: center;
134
+ justify-content: center;
135
+ background-color: ${checkbox.checkedBackgroundColor};
136
+ box-shadow: inset 0 0 0 ${checkbox.borderWidth} ${checkbox.checkedBackgroundColor};
137
+ color: ${checkbox.checkedIconColor};
138
+ }
139
+
140
+ &.ft-checkbox--disabled {
141
+ opacity: ${checkbox.checkedDisabledComponentOpacity};
142
+ }
143
+
144
+ .ft-checkbox--checkmark {
145
+ opacity: 1;
146
+ }
147
+
148
+ ft-ripple {
149
+ z-index: 0;
150
+ ${FtRippleCssVariables.color.set(checkbox.checkedStateLayerColor)};
151
+ ${FtRippleCssVariables.backgroundColor.set(checkbox.checkedStateLayerColor)};
152
+ ${FtRippleCssVariables.opacityContentOnSurfaceHover.set(checkbox.checkedHoverStateLayerOpacity)};
153
+ ${FtRippleCssVariables.opacityContentOnSurfaceFocused.set(checkbox.checkedFocusStateLayerOpacity)};
154
+ ${FtRippleCssVariables.opacityContentOnSurfacePressed.set(checkbox.checkedActiveStateLayerOpacity)};
155
+ ${FtRippleCssVariables.borderRadius.set("2px")};
156
+ }
157
+ }
158
+ `;
package/build/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from "./ft-checkbox";
2
2
  export * from "./ft-checkbox.styles";
3
- export * from "./ft-checkbox.properties";
3
+ export * from "./ftds-checkbox";
4
+ export * from "./ftds-checkbox.styles";
package/build/index.js CHANGED
@@ -1,6 +1,9 @@
1
1
  import { customElement } from "@fluid-topics/ft-wc-utils";
2
2
  import { FtCheckbox } from "./ft-checkbox";
3
+ import { FtdsCheckbox } from "./ftds-checkbox";
3
4
  export * from "./ft-checkbox";
4
5
  export * from "./ft-checkbox.styles";
5
- export * from "./ft-checkbox.properties";
6
+ export * from "./ftds-checkbox";
7
+ export * from "./ftds-checkbox.styles";
6
8
  customElement("ft-checkbox")(FtCheckbox);
9
+ customElement("ftds-checkbox")(FtdsCheckbox);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/ft-checkbox",
3
- "version": "1.3.63",
3
+ "version": "1.4.1",
4
4
  "description": "A checkbox component",
5
5
  "keywords": [
6
6
  "Lit"
@@ -19,10 +19,13 @@
19
19
  "url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
20
20
  },
21
21
  "dependencies": {
22
- "@fluid-topics/ft-ripple": "1.3.63",
23
- "@fluid-topics/ft-typography": "1.3.63",
24
- "@fluid-topics/ft-wc-utils": "1.3.63",
22
+ "@fluid-topics/ft-icon": "1.4.1",
23
+ "@fluid-topics/ft-link": "1.4.1",
24
+ "@fluid-topics/ft-popover": "1.4.1",
25
+ "@fluid-topics/ft-ripple": "1.4.1",
26
+ "@fluid-topics/ft-typography": "1.4.1",
27
+ "@fluid-topics/ft-wc-utils": "1.4.1",
25
28
  "lit": "3.1.0"
26
29
  },
27
- "gitHead": "d5a25917d4f07daff26d04ec39843e9d03c7a86e"
30
+ "gitHead": "1afa9ec0ae6a444d5dbd791dd7ecf2cee8766f8c"
28
31
  }
@@ -1,6 +0,0 @@
1
- export interface FtCheckboxProperties {
2
- name: string;
3
- checked: boolean;
4
- indeterminate: boolean;
5
- disabled: boolean;
6
- }
@@ -1 +0,0 @@
1
- export {};