@fluid-topics/ft-filter 0.1.16 → 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.
@@ -17,7 +17,7 @@ export declare const FtFilterLevelCssVariables: {
17
17
  };
18
18
  export declare class FtFilterLevel extends FtLitElement {
19
19
  static elementDefinitions: ElementDefinitionsMap;
20
- protected getStyles(): import("lit").CSSResult[];
20
+ static styles: import("lit").CSSResult[];
21
21
  id: string;
22
22
  parent?: FtFilterOptionProperties;
23
23
  options: Array<FtFilterOptionProperties>;
@@ -33,12 +33,13 @@ export declare class FtFilterLevel extends FtLitElement {
33
33
  get hasHiddenValues(): boolean;
34
34
  private get limit();
35
35
  get height(): number;
36
- protected getTemplate(): import("lit-html").TemplateResult<1>;
36
+ protected render(): import("lit-html").TemplateResult<1>;
37
37
  private goBackOnKeyPress;
38
38
  private goBackOnClick;
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
  }
@@ -7,15 +7,14 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  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
- import { customElement, designSystemVariables, FtCssVariable, FtLitElement, setVariable } from "@fluid-topics/ft-wc-utils";
11
- import { Checkbox } from "@material/mwc-checkbox";
10
+ import { designSystemVariables, FtCssVariable, FtLitElement, setVariable } from "@fluid-topics/ft-wc-utils";
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"),
@@ -31,7 +30,7 @@ export const FtFilterLevelCssVariables = {
31
30
  lineHeight: FtCssVariable.external(FtTypographyBody2CssVariables.lineHeight, "Body2 typography"),
32
31
  textTransform: FtCssVariable.external(FtTypographyBody2CssVariables.textTransform, "Body2 typography"),
33
32
  };
34
- let FtFilterLevel = class FtFilterLevel extends FtLitElement {
33
+ export class FtFilterLevel extends FtLitElement {
35
34
  constructor() {
36
35
  super(...arguments);
37
36
  this.id = "";
@@ -45,96 +44,6 @@ let FtFilterLevel = class FtFilterLevel extends FtLitElement {
45
44
  this.displayedValuesLimit = 0;
46
45
  this.displayedPages = 1;
47
46
  }
48
- // language=CSS
49
- getStyles() {
50
- return [
51
- css `
52
- .ft-filter-level--container {
53
- display: flex;
54
- flex-direction: column;
55
- }
56
-
57
- .ft-filter-level--container > * {
58
- padding: 0 10px;
59
- }
60
-
61
- .ft-filter-level--go-back {
62
- flex-shrink: 0;
63
- text-decoration: none;
64
- position: relative;
65
- border-radius: ${FtFilterLevelCssVariables.borderRadiusM};
66
- overflow: hidden;
67
- display: flex;
68
- align-items: center;
69
- padding: 4px 4px;
70
- gap: 4px;
71
- cursor: pointer;
72
- color: ${FtFilterLevelCssVariables.colorOnSurface};
73
- }
74
-
75
- .ft-filter-level--go-back:focus {
76
- outline: none;
77
- }
78
-
79
- .ft-filter-level--go-back mwc-icon {
80
- flex-shrink: 0;
81
- }
82
-
83
- .ft-filter-level--go-back ft-typography {
84
- display: block;
85
- flex-grow: 1;
86
- flex-shrink: 0;
87
- }
88
-
89
- .ft-filter-level--option {
90
- display: flex;
91
- align-items: center;
92
- max-width: 100%;
93
- }
94
-
95
- .ft-filter-level--option ft-button {
96
- margin-right: -10px;
97
- flex-shrink: 0;
98
- }
99
-
100
- ft-button {
101
- ${setVariable(FtButtonCssVariables.color, FtFilterLevelCssVariables.colorOnSurface)};
102
- }
103
-
104
- mwc-formfield {
105
- flex-shrink: 1;
106
- flex-grow: 1;
107
- display: block;
108
- max-width: calc(100% + 10px);
109
- margin-left: -10px;
110
- word-break: break-word;
111
-
112
- --mdc-theme-secondary: ${FtFilterLevelCssVariables.colorPrimary};
113
-
114
- --mdc-radio-unchecked-color: ${FtFilterLevelCssVariables.colorOnSurfaceMedium};
115
- --mdc-checkbox-unchecked-color: ${FtFilterLevelCssVariables.colorOnSurfaceMedium};
116
- --mdc-checkbox-ink-color: ${FtFilterLevelCssVariables.colorOnPrimary};
117
-
118
- --mdc-radio-disabled-color: ${FtFilterLevelCssVariables.colorOnSurfaceDisabled};
119
- --mdc-checkbox-disabled-color: ${FtFilterLevelCssVariables.colorOnSurfaceDisabled};
120
-
121
- --mdc-theme-on-surface: ${FtFilterLevelCssVariables.colorPrimary};
122
-
123
- --mdc-typography-body2-font-family: ${FtFilterLevelCssVariables.fontFamily};
124
- --mdc-typography-body2-font-size: ${FtFilterLevelCssVariables.fontSize};
125
- --mdc-typography-body2-font-weight: ${FtFilterLevelCssVariables.fontWeight};
126
- --mdc-typography-body2-letter-spacing: ${FtFilterLevelCssVariables.letterSpacing};
127
- --mdc-typography-body2-line-height: ${FtFilterLevelCssVariables.lineHeight};
128
- --mdc-typography-body2-text-transform: ${FtFilterLevelCssVariables.textTransform};
129
- --mdc-theme-text-primary-on-background: ${FtFilterLevelCssVariables.colorOnSurface};
130
- }
131
-
132
- .ft-filter--disabled {
133
- --mdc-theme-text-primary-on-background: ${FtFilterLevelCssVariables.colorOnSurfaceDisabled};
134
- }
135
- `
136
- ];
137
- }
138
47
  get hasHiddenValues() {
139
48
  let limit = this.limit;
140
49
  return limit != null && limit < this.options.length;
@@ -146,7 +55,7 @@ let FtFilterLevel = class FtFilterLevel extends FtLitElement {
146
55
  var _a, _b;
147
56
  return (_b = (_a = this.container) === null || _a === void 0 ? void 0 : _a.scrollHeight) !== null && _b !== void 0 ? _b : 0;
148
57
  }
149
- getTemplate() {
58
+ render() {
150
59
  let options = this.options;
151
60
  if (this.hideSelectedOptions) {
152
61
  options = options.filter(o => !o.selected);
@@ -164,7 +73,7 @@ let FtFilterLevel = class FtFilterLevel extends FtLitElement {
164
73
  @keyup=${this.goBackOnKeyPress}
165
74
  @click=${this.goBackOnClick}>
166
75
  <ft-ripple></ft-ripple>
167
- <mwc-icon>chevron_left</mwc-icon>
76
+ <ft-icon variant="material">chevron_left</ft-icon>
168
77
  <ft-typography variant="body2">${this.parent.label}</ft-typography>
169
78
  </div>
170
79
  `}
@@ -211,30 +120,33 @@ let FtFilterLevel = class FtFilterLevel extends FtLitElement {
211
120
  buildMultiValuedOption(option) {
212
121
  var _a;
213
122
  return html `
214
- <mwc-formfield label="${option.label}">
215
- <mwc-checkbox
216
- reducedTouchTarget
217
- .checked=${option.selected}
218
- .disabled=${this.disabled}
219
- .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)}
220
- @change=${(e) => this.optionsChanged(e, option)}
221
- ></mwc-checkbox>
222
- </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>
223
130
  `;
224
131
  }
225
132
  buildMonoValuedOption(option) {
226
133
  return html `
227
- <mwc-formfield label="${option.label}">
228
- <mwc-radio
229
- reducedTouchTarget
230
- name="${this.id}"
231
- ?checked=${option.selected}
232
- ?disabled=${this.disabled}
233
- @click=${(e) => this.optionsChanged(e, option)}
234
- ></mwc-radio>
235
- </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>
236
143
  `;
237
144
  }
145
+ onRadioKeyUp(e, option) {
146
+ if (option.selected && e.key === " ") {
147
+ this.optionsChanged(e, option);
148
+ }
149
+ }
238
150
  optionsChanged(e, option) {
239
151
  e.stopPropagation();
240
152
  this.dispatchEvent(new CustomEvent("change", { detail: option }));
@@ -242,16 +154,80 @@ let FtFilterLevel = class FtFilterLevel extends FtLitElement {
242
154
  displayLevel(option) {
243
155
  this.dispatchEvent(new CustomEvent("display-level", { detail: option }));
244
156
  }
245
- };
157
+ }
246
158
  FtFilterLevel.elementDefinitions = {
247
159
  "ft-button": FtButton,
248
160
  "ft-ripple": FtRipple,
249
161
  "ft-typography": FtTypography,
250
- "mwc-checkbox": Checkbox,
251
- "mwc-formfield": Formfield,
252
- "mwc-icon": Icon,
253
- "mwc-radio": Radio,
162
+ "ft-checkbox": FtCheckbox,
163
+ "ft-icon": FtIcon,
164
+ "ft-radio": FtRadio,
254
165
  };
166
+ // language=CSS
167
+ FtFilterLevel.styles = [
168
+ css `
169
+ .ft-filter-level--container {
170
+ display: flex;
171
+ flex-direction: column;
172
+ }
173
+
174
+ .ft-filter-level--container > * {
175
+ padding: 0 10px;
176
+ }
177
+
178
+ .ft-filter-level--go-back {
179
+ flex-shrink: 0;
180
+ text-decoration: none;
181
+ position: relative;
182
+ border-radius: ${FtFilterLevelCssVariables.borderRadiusM};
183
+ overflow: hidden;
184
+ display: flex;
185
+ align-items: center;
186
+ padding: 4px 4px;
187
+ gap: 4px;
188
+ cursor: pointer;
189
+ color: ${FtFilterLevelCssVariables.colorOnSurface};
190
+ }
191
+
192
+ .ft-filter-level--go-back:focus {
193
+ outline: none;
194
+ }
195
+
196
+ .ft-filter-level--go-back ft-icon {
197
+ flex-shrink: 0;
198
+ }
199
+
200
+ .ft-filter-level--go-back ft-typography {
201
+ display: block;
202
+ flex-grow: 1;
203
+ flex-shrink: 0;
204
+ }
205
+
206
+ .ft-filter-level--option {
207
+ display: flex;
208
+ align-items: center;
209
+ max-width: 100%;
210
+ }
211
+
212
+ .ft-filter-level--option ft-button {
213
+ margin-right: -10px;
214
+ flex-shrink: 0;
215
+ }
216
+
217
+ ft-button {
218
+ ${setVariable(FtButtonCssVariables.color, FtFilterLevelCssVariables.colorOnSurface)};
219
+ }
220
+
221
+ ft-radio, ft-checkbox {
222
+ flex-shrink: 1;
223
+ flex-grow: 1;
224
+ display: block;
225
+ max-width: calc(100% + 10px);
226
+ margin-left: -10px;
227
+ word-break: break-word;
228
+ }
229
+ `
230
+ ];
255
231
  __decorate([
256
232
  property({ type: String })
257
233
  ], FtFilterLevel.prototype, "id", void 0);
@@ -288,8 +264,4 @@ __decorate([
288
264
  __decorate([
289
265
  state()
290
266
  ], FtFilterLevel.prototype, "displayedPages", void 0);
291
- FtFilterLevel = __decorate([
292
- customElement("ft-filter-level")
293
- ], FtFilterLevel);
294
- export { FtFilterLevel };
295
267
  //# sourceMappingURL=ft-filter-level.js.map
@@ -13,7 +13,7 @@ export declare class FtFilterOption extends FtLitElement implements FtFilterOpti
13
13
  selected: boolean;
14
14
  subOptions: Array<FtFilterOptionProperties>;
15
15
  private slotElement;
16
- protected getTemplate(): import("lit-html").TemplateResult<1>;
16
+ protected render(): import("lit-html").TemplateResult<1>;
17
17
  private updateSubOptionsFromSlot;
18
18
  protected updated(changedProperties: PropertyValues): void;
19
19
  }
@@ -4,10 +4,10 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
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
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- import { customElement, FtLitElement } from "@fluid-topics/ft-wc-utils";
7
+ import { FtLitElement } from "@fluid-topics/ft-wc-utils";
8
8
  import { property, query } from "lit/decorators.js";
9
9
  import { html } from "lit";
10
- let FtFilterOption = class FtFilterOption extends FtLitElement {
10
+ export class FtFilterOption extends FtLitElement {
11
11
  constructor() {
12
12
  super(...arguments);
13
13
  this.label = "";
@@ -15,7 +15,7 @@ let FtFilterOption = class FtFilterOption extends FtLitElement {
15
15
  this.selected = false;
16
16
  this.subOptions = [];
17
17
  }
18
- getTemplate() {
18
+ render() {
19
19
  return html `
20
20
  <slot class="ft-filter-option--slot" @slotchange=${this.updateSubOptionsFromSlot}></slot>
21
21
  `;
@@ -28,7 +28,7 @@ let FtFilterOption = class FtFilterOption extends FtLitElement {
28
28
  super.updated(changedProperties);
29
29
  this.dispatchEvent(new CustomEvent("option-change", { detail: this, bubbles: true }));
30
30
  }
31
- };
31
+ }
32
32
  FtFilterOption.elementDefinitions = {};
33
33
  __decorate([
34
34
  property({ type: String })
@@ -48,8 +48,4 @@ __decorate([
48
48
  __decorate([
49
49
  query(".ft-filter-option--slot")
50
50
  ], FtFilterOption.prototype, "slotElement", void 0);
51
- FtFilterOption = __decorate([
52
- customElement("ft-filter-option")
53
- ], FtFilterOption);
54
- export { FtFilterOption };
55
51
  //# sourceMappingURL=ft-filter-option.js.map
@@ -1,7 +1,6 @@
1
1
  import { PropertyValues } from "lit";
2
2
  import { ElementDefinitionsMap, FtCssVariable, FtLitElement } from "@fluid-topics/ft-wc-utils";
3
3
  import { FtFilterOptionProperties } from "./ft-filter-option";
4
- export * from "./ft-filter-option";
5
4
  export interface FtFilterProperties {
6
5
  id: string;
7
6
  label: string;
@@ -28,7 +27,7 @@ export declare class FtFilterChangeEvent extends CustomEvent<Array<any>> {
28
27
  }
29
28
  export declare class FtFilter extends FtLitElement implements FtFilterProperties {
30
29
  static elementDefinitions: ElementDefinitionsMap;
31
- protected getStyles(): import("lit").CSSResult[];
30
+ static styles: import("lit").CSSResult[];
32
31
  id: string;
33
32
  label: string;
34
33
  filterPlaceHolder: string;
@@ -52,7 +51,7 @@ export declare class FtFilter extends FtLitElement implements FtFilterProperties
52
51
  private slideOut?;
53
52
  private scrollResizeObserver;
54
53
  private get flatOptions();
55
- protected getTemplate(): import("lit-html").TemplateResult<1>;
54
+ protected render(): import("lit-html").TemplateResult<1>;
56
55
  protected update(props: PropertyValues): void;
57
56
  protected contentAvailableCallback(props: PropertyValues): void;
58
57
  private levelsScrollDebouncer;