@fluid-topics/ft-filter 0.1.18 → 0.2.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.
@@ -39,6 +39,7 @@ export declare class FtFilterLevel extends FtLitElement {
39
39
  private displayMore;
40
40
  private buildMultiValuedOption;
41
41
  private buildMonoValuedOption;
42
+ private onRadioKeyUp;
42
43
  private optionsChanged;
43
44
  private displayLevel;
44
45
  }
@@ -8,14 +8,13 @@ import { css, html, nothing } from "lit";
8
8
  import { property, query, state } from "lit/decorators.js";
9
9
  import { repeat } from "lit/directives/repeat.js";
10
10
  import { designSystemVariables, FtCssVariable, FtLitElement, setVariable } from "@fluid-topics/ft-wc-utils";
11
- import { Checkbox } from "@material/mwc-checkbox";
12
11
  import { flatDeep } from "./utils";
13
12
  import { FtButton, FtButtonCssVariables } from "@fluid-topics/ft-button";
14
13
  import { FtTypography, FtTypographyBody2CssVariables } from "@fluid-topics/ft-typography";
15
- import { Formfield } from "@material/mwc-formfield";
16
- import { Radio } from "@material/mwc-radio";
17
- import { Icon } from "@material/mwc-icon";
18
14
  import { FtRipple } from "@fluid-topics/ft-ripple";
15
+ import { FtIcon } from "@fluid-topics/ft-icon";
16
+ import { FtCheckbox } from "@fluid-topics/ft-checkbox";
17
+ import { FtRadio } from "@fluid-topics/ft-radio";
19
18
  export const FtFilterLevelCssVariables = {
20
19
  borderRadiusM: FtCssVariable.external(designSystemVariables.borderRadiusM, "Design system"),
21
20
  colorOutline: FtCssVariable.external(designSystemVariables.colorOutline, "Design system"),
@@ -74,7 +73,7 @@ export class FtFilterLevel extends FtLitElement {
74
73
  @keyup=${this.goBackOnKeyPress}
75
74
  @click=${this.goBackOnClick}>
76
75
  <ft-ripple></ft-ripple>
77
- <mwc-icon>chevron_left</mwc-icon>
76
+ <ft-icon variant="material">chevron_left</ft-icon>
78
77
  <ft-typography variant="body2">${this.parent.label}</ft-typography>
79
78
  </div>
80
79
  `}
@@ -121,30 +120,33 @@ export class FtFilterLevel extends FtLitElement {
121
120
  buildMultiValuedOption(option) {
122
121
  var _a;
123
122
  return html `
124
- <mwc-formfield label="${option.label}">
125
- <mwc-checkbox
126
- reducedTouchTarget
127
- .checked=${option.selected}
128
- .disabled=${this.disabled}
129
- .indeterminate=${flatDeep((_a = option.subOptions) !== null && _a !== void 0 ? _a : [], o => { var _a; return (_a = o.subOptions) !== null && _a !== void 0 ? _a : []; }).some(o => o.selected)}
130
- @change=${(e) => this.optionsChanged(e, option)}
131
- ></mwc-checkbox>
132
- </mwc-formfield>
123
+ <ft-checkbox name="${this.id}"
124
+ .checked=${option.selected}
125
+ .disabled=${this.disabled}
126
+ .indeterminate=${flatDeep((_a = option.subOptions) !== null && _a !== void 0 ? _a : [], o => { var _a; return (_a = o.subOptions) !== null && _a !== void 0 ? _a : []; }).some(o => o.selected)}
127
+ @change=${(e) => this.optionsChanged(e, option)}>
128
+ ${option.label}
129
+ </ft-checkbox>
133
130
  `;
134
131
  }
135
132
  buildMonoValuedOption(option) {
136
133
  return html `
137
- <mwc-formfield label="${option.label}">
138
- <mwc-radio
139
- reducedTouchTarget
140
- name="${this.id}"
141
- ?checked=${option.selected}
142
- ?disabled=${this.disabled}
143
- @click=${(e) => this.optionsChanged(e, option)}
144
- ></mwc-radio>
145
- </mwc-formfield>
134
+ <ft-radio name="${this.id + Math.round(Math.random() * 1000000)}"
135
+ .checked=${option.selected}
136
+ ?disabled=${this.disabled}
137
+ @click=${(e) => this.optionsChanged(e, option)}
138
+ @keyup=${(e) => this.onRadioKeyUp(e, option)}
139
+ @change=${(e) => e.stopPropagation()}>
140
+
141
+ ${option.label}
142
+ </ft-radio>
146
143
  `;
147
144
  }
145
+ onRadioKeyUp(e, option) {
146
+ if (option.selected && e.key === " ") {
147
+ this.optionsChanged(e, option);
148
+ }
149
+ }
148
150
  optionsChanged(e, option) {
149
151
  e.stopPropagation();
150
152
  this.dispatchEvent(new CustomEvent("change", { detail: option }));
@@ -157,10 +159,9 @@ FtFilterLevel.elementDefinitions = {
157
159
  "ft-button": FtButton,
158
160
  "ft-ripple": FtRipple,
159
161
  "ft-typography": FtTypography,
160
- "mwc-checkbox": Checkbox,
161
- "mwc-formfield": Formfield,
162
- "mwc-icon": Icon,
163
- "mwc-radio": Radio,
162
+ "ft-checkbox": FtCheckbox,
163
+ "ft-icon": FtIcon,
164
+ "ft-radio": FtRadio,
164
165
  };
165
166
  // language=CSS
166
167
  FtFilterLevel.styles = [
@@ -192,7 +193,7 @@ FtFilterLevel.styles = [
192
193
  outline: none;
193
194
  }
194
195
 
195
- .ft-filter-level--go-back mwc-icon {
196
+ .ft-filter-level--go-back ft-icon {
196
197
  flex-shrink: 0;
197
198
  }
198
199
 
@@ -217,36 +218,13 @@ FtFilterLevel.styles = [
217
218
  ${setVariable(FtButtonCssVariables.color, FtFilterLevelCssVariables.colorOnSurface)};
218
219
  }
219
220
 
220
- mwc-formfield {
221
+ ft-radio, ft-checkbox {
221
222
  flex-shrink: 1;
222
223
  flex-grow: 1;
223
224
  display: block;
224
225
  max-width: calc(100% + 10px);
225
226
  margin-left: -10px;
226
227
  word-break: break-word;
227
-
228
- --mdc-theme-secondary: ${FtFilterLevelCssVariables.colorPrimary};
229
-
230
- --mdc-radio-unchecked-color: ${FtFilterLevelCssVariables.colorOnSurfaceMedium};
231
- --mdc-checkbox-unchecked-color: ${FtFilterLevelCssVariables.colorOnSurfaceMedium};
232
- --mdc-checkbox-ink-color: ${FtFilterLevelCssVariables.colorOnPrimary};
233
-
234
- --mdc-radio-disabled-color: ${FtFilterLevelCssVariables.colorOnSurfaceDisabled};
235
- --mdc-checkbox-disabled-color: ${FtFilterLevelCssVariables.colorOnSurfaceDisabled};
236
-
237
- --mdc-theme-on-surface: ${FtFilterLevelCssVariables.colorPrimary};
238
-
239
- --mdc-typography-body2-font-family: ${FtFilterLevelCssVariables.fontFamily};
240
- --mdc-typography-body2-font-size: ${FtFilterLevelCssVariables.fontSize};
241
- --mdc-typography-body2-font-weight: ${FtFilterLevelCssVariables.fontWeight};
242
- --mdc-typography-body2-letter-spacing: ${FtFilterLevelCssVariables.letterSpacing};
243
- --mdc-typography-body2-line-height: ${FtFilterLevelCssVariables.lineHeight};
244
- --mdc-typography-body2-text-transform: ${FtFilterLevelCssVariables.textTransform};
245
- --mdc-theme-text-primary-on-background: ${FtFilterLevelCssVariables.colorOnSurface};
246
- }
247
-
248
- .ft-filter--disabled {
249
- --mdc-theme-text-primary-on-background: ${FtFilterLevelCssVariables.colorOnSurfaceDisabled};
250
228
  }
251
229
  `
252
230
  ];