@fluid-topics/ft-search-bar 0.1.6 → 0.1.9

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.
@@ -0,0 +1,24 @@
1
+ import { FtCssVariable } from "@fluid-topics/ft-wc-utils";
2
+ export declare const FtSearchBarCssVariables: {
3
+ height: FtCssVariable;
4
+ borderRadius: FtCssVariable;
5
+ mobileOpenPosition: FtCssVariable;
6
+ mobileOpenTop: FtCssVariable;
7
+ mobileOpenBottom: FtCssVariable;
8
+ mobileOpenLeft: FtCssVariable;
9
+ mobileOpenRight: FtCssVariable;
10
+ floatingZIndex: FtCssVariable;
11
+ colorSurface: FtCssVariable;
12
+ colorOnSurface: FtCssVariable;
13
+ colorOnSurfaceMedium: FtCssVariable;
14
+ colorOutline: FtCssVariable;
15
+ colorPrimary: FtCssVariable;
16
+ elevation02: FtCssVariable;
17
+ buttonColor: FtCssVariable;
18
+ buttonRippleColor: FtCssVariable;
19
+ };
20
+ export declare const searchBarCss: import("lit").CSSResult;
21
+ export declare const facetsCss: import("lit").CSSResult;
22
+ export declare const selectedFiltersCss: import("lit").CSSResult;
23
+ export declare const suggestionsCss: import("lit").CSSResult;
24
+ //# sourceMappingURL=ft-search-bar.css.d.ts.map
@@ -0,0 +1,392 @@
1
+ import { designSystemVariables, FtCssVariable, setVariable } from "@fluid-topics/ft-wc-utils";
2
+ import { css } from "lit";
3
+ import { FtButtonCssVariables } from "@fluid-topics/ft-button";
4
+ import { FtInputLabelCssVariables } from "@fluid-topics/ft-input-label";
5
+ import { FtSelectCssVariables } from "@fluid-topics/ft-select";
6
+ import { FtSnapScrollCssVariables } from "@fluid-topics/ft-snap-scroll";
7
+ import { FtChipCssVariables } from "@fluid-topics/ft-chip";
8
+ export const FtSearchBarCssVariables = {
9
+ height: FtCssVariable.create("--ft-search-bar-height", "SIZE", "38px"),
10
+ borderRadius: FtCssVariable.extend("--ft-search-bar-border-radius", designSystemVariables.borderRadiusS),
11
+ mobileOpenPosition: FtCssVariable.create("--ft-search-bar-mobile-open-position", "POSITION", "fixed"),
12
+ mobileOpenTop: FtCssVariable.create("--ft-search-bar-mobile-open-top", "SIZE", "0"),
13
+ mobileOpenBottom: FtCssVariable.create("--ft-search-bar-mobile-open-bottom", "SIZE", "0"),
14
+ mobileOpenLeft: FtCssVariable.create("--ft-search-bar-mobile-open-left", "SIZE", "0"),
15
+ mobileOpenRight: FtCssVariable.create("--ft-search-bar-mobile-open-right", "SIZE", "0"),
16
+ floatingZIndex: FtCssVariable.create("--ft-search-bar-floating-components-z-index", "NUMBER", "2"),
17
+ colorSurface: FtCssVariable.external(designSystemVariables.colorSurface, "Design system"),
18
+ colorOnSurface: FtCssVariable.external(designSystemVariables.colorOnSurface, "Design system"),
19
+ colorOnSurfaceMedium: FtCssVariable.external(designSystemVariables.colorOnSurfaceMedium, "Design system"),
20
+ colorOutline: FtCssVariable.external(designSystemVariables.colorOutline, "Design system"),
21
+ colorPrimary: FtCssVariable.external(designSystemVariables.colorPrimary, "Design system"),
22
+ elevation02: FtCssVariable.external(designSystemVariables.elevation02, "Design system"),
23
+ buttonColor: FtCssVariable.external(FtButtonCssVariables.color, "Button"),
24
+ buttonRippleColor: FtCssVariable.external(FtButtonCssVariables.rippleColor, "Button"),
25
+ };
26
+ //language=css
27
+ export const searchBarCss = css `
28
+ * {
29
+ box-sizing: border-box;
30
+ }
31
+
32
+ .ft-search-bar--container {
33
+ display: flex;
34
+ flex-direction: column;
35
+ gap: 8px;
36
+ color: ${FtSearchBarCssVariables.colorOnSurface};
37
+ background: ${FtSearchBarCssVariables.colorSurface};
38
+ outline: none;
39
+ }
40
+
41
+ .ft-search-bar--container > * {
42
+ flex-shrink: 0;
43
+ }
44
+
45
+ .ft-search-bar--mobile-menu-open {
46
+ position: ${FtSearchBarCssVariables.mobileOpenPosition};
47
+ top: ${FtSearchBarCssVariables.mobileOpenTop};
48
+ bottom: ${FtSearchBarCssVariables.mobileOpenBottom};
49
+ left: ${FtSearchBarCssVariables.mobileOpenLeft};
50
+ right: ${FtSearchBarCssVariables.mobileOpenRight};
51
+ z-index: ${FtSearchBarCssVariables.floatingZIndex};
52
+ padding: 16px;
53
+ }
54
+
55
+ .ft-search-bar {
56
+ position: relative;
57
+ display: flex;
58
+ flex-direction: row;
59
+ align-items: center;
60
+ height: ${FtSearchBarCssVariables.height};
61
+
62
+ background: ${FtSearchBarCssVariables.colorSurface};
63
+ border: 1px solid ${FtSearchBarCssVariables.colorOutline};
64
+ border-radius: ${FtSearchBarCssVariables.borderRadius};
65
+ }
66
+
67
+ .ft-search-bar--floating-panel-open .ft-search-bar {
68
+ border-radius: ${FtSearchBarCssVariables.borderRadius} ${FtSearchBarCssVariables.borderRadius} 0 0;
69
+ }
70
+
71
+ .ft-search-bar--input-container {
72
+ flex-grow: 1;
73
+ flex-shrink: 1;
74
+ position: relative;
75
+ height: calc(100% - 2px);
76
+ }
77
+
78
+ .ft-search-bar--input-outline {
79
+ flex-grow: 1;
80
+ flex-shrink: 1;
81
+ height: 100%;
82
+ width: 100%;
83
+ align-self: stretch;
84
+ display: grid;
85
+ padding: 0 8px;
86
+ border-radius: ${FtSearchBarCssVariables.borderRadius};
87
+ }
88
+
89
+ .ft-search-bar--dense .ft-search-bar--input-outline {
90
+ grid-template-columns: auto minmax(200px, 1fr);
91
+ gap: 8px;
92
+ }
93
+
94
+ .ft-search-bar--input-container:focus-within .ft-search-bar--input-outline {
95
+ outline: 2px solid ${FtSearchBarCssVariables.colorPrimary};
96
+ }
97
+
98
+ .ft-search-bar--input {
99
+ height: 100%;
100
+ flex-grow: 1;
101
+ border: none;
102
+ background-color: transparent;
103
+ outline: none;
104
+ }
105
+
106
+ .ft-search-bar--desktop .ft-search-bar--input {
107
+ flex-shrink: 0;
108
+ min-width: 250px;
109
+ }
110
+
111
+ .ft-search-bar > ft-button {
112
+ flex-shrink: 0;
113
+ }
114
+
115
+ .ft-search-bar--left-action {
116
+ ${setVariable(FtButtonCssVariables.borderRadius, css `calc(${FtSearchBarCssVariables.borderRadius} - 1px) 0 0 calc(${FtSearchBarCssVariables.borderRadius} - 1px)`)};
117
+ border-right: 1px solid ${FtSearchBarCssVariables.colorOutline};
118
+ height: 100%;
119
+ }
120
+
121
+ .ft-search-bar--left-action::part(button) {
122
+ height: 100%;
123
+ }
124
+
125
+ .ft-search-bar--floating-panel-open .ft-search-bar--left-action {
126
+ ${setVariable(FtButtonCssVariables.borderRadius, css `calc(${FtSearchBarCssVariables.borderRadius} - 1px) 0 0 0`)};
127
+ }
128
+
129
+ .ft-search-bar .ft-search-bar--launch-search,
130
+ .ft-search-bar--clear-query {
131
+ margin: 0 4px;
132
+ }
133
+
134
+ .ft-search-bar--separator {
135
+ height: 20px;
136
+ border-right: 1px solid ${FtSearchBarCssVariables.colorOutline};
137
+ }
138
+
139
+ .ft-search-bar--left-action.ft-search-bar--content-locale {
140
+ ${setVariable(FtInputLabelCssVariables.borderColor, "transparent")};
141
+ ${setVariable(FtInputLabelCssVariables.borderRadiusS, css `calc(${FtSearchBarCssVariables.borderRadius} - 1px)`)};
142
+ ${setVariable(FtSelectCssVariables.selectedOptionColor, FtSearchBarCssVariables.buttonColor)};
143
+ }
144
+
145
+ .ft-search-bar--left-action.ft-search-bar--content-locale,
146
+ .ft-search-bar--left-action.ft-search-bar--content-locale::part(container),
147
+ .ft-search-bar--left-action.ft-search-bar--content-locale::part(main-panel) {
148
+ height: 100%;
149
+ }
150
+
151
+ .ft-search-bar--left-action.ft-search-bar--content-locale::part(options) {
152
+ top: calc(100% + 1px);
153
+ right: unset;
154
+ width: max-content;
155
+ min-width: 100%;
156
+ }
157
+
158
+ .ft-search-bar--left-action.ft-search-bar--content-locale::part(selected-value) {
159
+ border-radius: calc(${FtSearchBarCssVariables.borderRadius} - 1px) 0 0 calc(${FtSearchBarCssVariables.borderRadius} - 1px);
160
+ }
161
+
162
+ `;
163
+ //language=css
164
+ export const facetsCss = css `
165
+ .ft-search-bar--floating-panel .ft-search-bar--presets {
166
+ margin-right: auto;
167
+ }
168
+
169
+ .ft-search-bar--floating-panel .ft-search-bar--presets {
170
+ min-width: 250px;
171
+ ${setVariable(FtSelectCssVariables.optionsZIndex, "2")};
172
+ }
173
+
174
+ .ft-search-bar--floating-panel {
175
+ flex-direction: column;
176
+ gap: 16px;
177
+ padding: 16px;
178
+ }
179
+
180
+ .ft-search-bar--floating-panel-open .ft-search-bar--floating-panel {
181
+ display: flex;
182
+ }
183
+
184
+ .ft-search-bar--desktop .ft-search-bar--facets-actions {
185
+ display: flex;
186
+ align-items: center;
187
+ justify-content: flex-end;
188
+ gap: 8px;
189
+ padding: 0 10px;
190
+ }
191
+
192
+ .ft-search-bar--mobile .ft-search-bar--facets-actions {
193
+ flex-shrink: 0;
194
+ flex-grow: 0;
195
+ display: flex;
196
+ gap: 16px;
197
+ align-items: center;
198
+ justify-content: space-evenly;
199
+ }
200
+
201
+ .ft-search-bar--mobile .ft-search-bar--facets-actions > * {
202
+ flex-grow: 1;
203
+ flex-basis: 0;
204
+ }
205
+
206
+ .ft-search-bar--content-locale::part(clear-button) {
207
+ display: none;
208
+ }
209
+
210
+ .ft-search-bar--floating-panel .ft-search-bar--filters-container {
211
+ display: block;
212
+ height: 350px;
213
+ --ft-snap-scroll-gap: 16px;
214
+ }
215
+
216
+ .ft-search-bar--floating-panel ft-filter {
217
+ display: flex;
218
+ flex-grow: 0;
219
+ max-height: 100%;
220
+ max-width: 250px;
221
+ }
222
+
223
+ .ft-search-bar--hierarchical-filter {
224
+ width: 250px;
225
+ }
226
+
227
+ .ft-search-bar--mobile .ft-search-bar--filters-container {
228
+ flex-grow: 1;
229
+ flex-shrink: 1;
230
+ overflow-y: auto;
231
+ margin: 0 -16px;
232
+ padding: 0 16px;
233
+ }
234
+
235
+ .ft-search-bar--mobile .ft-search-bar--filters-container ft-filter {
236
+ display: flex;
237
+ max-height: 60vh;
238
+ }
239
+
240
+ .ft-search-bar--mobile ft-filter::part(container) {
241
+ flex-grow: 1;
242
+ }
243
+
244
+ .ft-search-bar--filter-label {
245
+ display: flex;
246
+ justify-content: space-between;
247
+ align-items: baseline;
248
+ gap: 8px;
249
+ }
250
+
251
+ .ft-search-bar--filter-label > * {
252
+ white-space: nowrap;
253
+ overflow: hidden;
254
+ text-overflow: ellipsis;
255
+ }
256
+
257
+ .ft-search-bar--filter-label > :first-child {
258
+ flex-shrink: 0;
259
+ }
260
+
261
+ .ft-search-bar--filter-label > :last-child {
262
+ flex-shrink: 1;
263
+ color: ${FtSearchBarCssVariables.colorOnSurfaceMedium};
264
+ }
265
+
266
+ ft-accordion-item::part(toggle) {
267
+ margin-left: -16px;
268
+ margin-right: -16px;
269
+ }
270
+
271
+ ft-accordion-item::part(label) {
272
+ overflow: hidden;
273
+ }
274
+
275
+ ft-accordion-item::part(content) {
276
+ padding-left: 0;
277
+ padding-right: 0;
278
+ }
279
+
280
+ .ft-search-bar--floating-panel .ft-search-bar--launch-search {
281
+ margin: 0;
282
+ }
283
+ `;
284
+ //language=css
285
+ export const selectedFiltersCss = css `
286
+ .ft-search-bar--selected-filters:not(ft-snap-scroll) {
287
+ flex-shrink: 0;
288
+ display: flex;
289
+ flex-direction: row;
290
+ flex-wrap: wrap;
291
+ gap: 8px;
292
+ }
293
+
294
+ ft-snap-scroll.ft-search-bar--selected-filters {
295
+ overflow: hidden;
296
+ ${setVariable(FtSnapScrollCssVariables.gap, "4px")};
297
+ }
298
+
299
+ ft-snap-scroll.ft-search-bar--selected-filters::part(content) {
300
+ align-items: center;
301
+ }
302
+
303
+ .ft-search-bar--desktop ft-snap-scroll.ft-search-bar--selected-filters {
304
+ ${setVariable(FtChipCssVariables.iconSize, "17px")};
305
+ ${setVariable(FtChipCssVariables.fontSize, "12px")};
306
+ }
307
+
308
+ .ft-search-bar--selected-filters * {
309
+ max-width: 100%;
310
+ }
311
+
312
+ .ft-search-bar--selected-filters ft-chip {
313
+ flex-grow: 0;
314
+ }
315
+ `;
316
+ //language=css
317
+ export const suggestionsCss = css `
318
+ .ft-search-bar--mobile .ft-search-bar--suggestions {
319
+ flex-grow: 1;
320
+ flex-shrink: 1;
321
+ overflow-y: auto;
322
+ height: 0;
323
+ }
324
+
325
+ .ft-search-bar--mobile-menu-open .ft-search-bar--suggestions {
326
+ border-top: 1px solid ${FtSearchBarCssVariables.colorOutline};
327
+ }
328
+
329
+ .ft-search-bar--mobile-menu-open .ft-search-bar--suggestions {
330
+ height: initial;
331
+ }
332
+
333
+ .ft-search-bar--floating-panel,
334
+ .ft-search-bar--desktop .ft-search-bar--suggestions {
335
+ position: absolute;
336
+ z-index: var(--ft-search-bar-floating-components-z-index, 1);
337
+ top: 100%;
338
+ left: -1px;
339
+ right: -1px;
340
+ display: none;
341
+ background: ${FtSearchBarCssVariables.colorSurface};
342
+ border: 1px solid ${FtSearchBarCssVariables.colorOutline};
343
+ border-radius: 0 0 ${FtSearchBarCssVariables.borderRadius} ${FtSearchBarCssVariables.borderRadius};
344
+ box-shadow: ${FtSearchBarCssVariables.elevation02};
345
+ outline: none;
346
+ }
347
+
348
+ .ft-search-bar--desktop .ft-search-bar--suggestions {
349
+ top: calc(100% + 2px);
350
+ }
351
+
352
+ .ft-search-bar--input-container:focus-within .ft-search-bar--suggestions-not-empty {
353
+ display: block;
354
+ }
355
+
356
+ .ft-search-bar--no-suggestions {
357
+ text-align: center;
358
+ padding: 8px;
359
+ color: ${FtSearchBarCssVariables.colorOnSurface};
360
+ }
361
+
362
+ .ft-search-bar--suggestion {
363
+ text-decoration: none;
364
+ position: relative;
365
+ display: flex;
366
+ align-items: center;
367
+ padding: 8px;
368
+ gap: 8px;
369
+ cursor: pointer;
370
+ color: ${FtSearchBarCssVariables.colorOnSurface};
371
+ min-height: 52px;
372
+ }
373
+
374
+ .ft-search-bar--desktop .ft-search-bar--suggestion {
375
+ min-height: 44px;
376
+ }
377
+
378
+ .ft-search-bar--suggestion:focus {
379
+ outline: none;
380
+ }
381
+
382
+ .ft-search-bar--recent-search + .ft-search-bar--suggestion:not(.ft-search-bar--recent-search) {
383
+ border-top: 1px solid ${FtSearchBarCssVariables.colorOutline};
384
+ }
385
+
386
+ .ft-search-bar--suggestion ft-typography {
387
+ display: block;
388
+ flex-grow: 1;
389
+ flex-shrink: 1;
390
+ }
391
+ `;
392
+ //# sourceMappingURL=ft-search-bar.css.js.map
@@ -1,6 +1,6 @@
1
1
  import { PropertyValues } from "lit";
2
- import { ElementDefinitionsMap, FtCssVariable, FtLitElement, ParametrizedLabels } from "@fluid-topics/ft-wc-utils";
3
- import { FluidTopicsApi, FtSearchRequest, FtSuggestRequest } from "@fluid-topics/public-api";
2
+ import { ElementDefinitionsMap, FtLitElement, ParametrizedLabels } from "@fluid-topics/ft-wc-utils";
3
+ import { FluidTopicsApi, FtSearchFacetConf, FtSearchRequest, FtSuggestRequest } from "@fluid-topics/public-api";
4
4
  declare global {
5
5
  interface Window {
6
6
  fluidtopics?: {
@@ -11,8 +11,6 @@ declare global {
11
11
  export interface FtSearchBarLabels extends ParametrizedLabels {
12
12
  clearFilters?: string;
13
13
  filtersButton?: string;
14
- oneFilterEnabled?: string;
15
- nFiltersEnabled?: string;
16
14
  inputPlaceHolder?: string;
17
15
  filterInputPlaceHolder?: string;
18
16
  clearInputButton?: string;
@@ -21,10 +19,15 @@ export interface FtSearchBarLabels extends ParametrizedLabels {
21
19
  searchButton?: string;
22
20
  noSuggestions?: string;
23
21
  contentLocaleSelector?: string;
22
+ presetsSelector?: string;
24
23
  removeRecentSearch?: string;
25
24
  back?: string;
26
25
  }
27
26
  export declare const DEFAULT_LABELS: FtSearchBarLabels;
27
+ declare type RelevantFtSearchRequest = Pick<FtSearchRequest, "contentLocale" | "filters"> & Partial<FtSearchRequest>;
28
+ export interface FtSearchPreset extends RelevantFtSearchRequest {
29
+ name: string;
30
+ }
28
31
  export interface FtSearchBarProperties {
29
32
  labels?: FtSearchBarLabels;
30
33
  baseUrl: string;
@@ -32,25 +35,11 @@ export interface FtSearchBarProperties {
32
35
  contentLocale?: string;
33
36
  uiLocale?: string;
34
37
  displayedFilters?: Array<string>;
38
+ presets?: Array<FtSearchPreset>;
39
+ selectedPreset?: string;
40
+ dense: boolean;
35
41
  }
36
- export declare const FtSearchBarCssVariables: {
37
- height: FtCssVariable;
38
- borderRadius: FtCssVariable;
39
- mobileOpenPosition: FtCssVariable;
40
- mobileOpenTop: FtCssVariable;
41
- mobileOpenBottom: FtCssVariable;
42
- mobileOpenLeft: FtCssVariable;
43
- mobileOpenRight: FtCssVariable;
44
- floatingZIndex: FtCssVariable;
45
- colorSurface: FtCssVariable;
46
- colorOnSurface: FtCssVariable;
47
- colorOnSurfaceMedium: FtCssVariable;
48
- colorOutline: FtCssVariable;
49
- colorPrimary: FtCssVariable;
50
- elevation02: FtCssVariable;
51
- buttonColor: FtCssVariable;
52
- buttonRippleColor: FtCssVariable;
53
- };
42
+ export { FtSearchBarCssVariables } from "./ft-search-bar.css";
54
43
  export declare class LaunchSearchEvent extends CustomEvent<FtSearchRequest> {
55
44
  constructor(request: FtSearchRequest);
56
45
  }
@@ -60,6 +49,7 @@ export declare class SearchStateChangeEvent extends CustomEvent<FtSearchRequest>
60
49
  export declare class FtSearchBar extends FtLitElement implements FtSearchBarProperties {
61
50
  static elementDefinitions: ElementDefinitionsMap;
62
51
  protected getStyles(): import("lit").CSSResult[];
52
+ dense: boolean;
63
53
  baseUrl: string;
64
54
  apiIntegrationIdentifier: string;
65
55
  contentLocale?: string;
@@ -68,12 +58,15 @@ export declare class FtSearchBar extends FtLitElement implements FtSearchBarProp
68
58
  labels: FtSearchBarLabels;
69
59
  private labelResolver;
70
60
  displayedFilters: Array<string>;
61
+ presets: Array<FtSearchPreset>;
62
+ selectedPreset?: string;
71
63
  searchRequestSerializer: (request: FtSearchRequest) => string;
72
64
  private searchFilters;
73
65
  private sizeCategory;
74
66
  private displayFacets;
75
67
  private mobileMenuOpen;
76
68
  private facets;
69
+ private knownFacetLabels;
77
70
  private container?;
78
71
  private filtersOpener?;
79
72
  private floatingContainer?;
@@ -92,24 +85,28 @@ export declare class FtSearchBar extends FtLitElement implements FtSearchBarProp
92
85
  private get recentSearchesStorageKey();
93
86
  private api?;
94
87
  get request(): FtSearchRequest;
88
+ get facetsRequest(): Array<FtSearchFacetConf>;
95
89
  get suggestRequest(): FtSuggestRequest;
90
+ private get isMobile();
96
91
  private get hasFacets();
92
+ private get hasPresets();
97
93
  private get hasLocaleSelector();
98
94
  focus(): void;
99
95
  clear(): void;
100
96
  protected getTemplate(): import("lit-html").TemplateResult<1>;
101
- private renderDesktopSearchBar;
102
- private renderSearchBarLeftAction;
103
- private renderDesktopSearchBarButtons;
104
97
  private renderMobileSearchBar;
105
98
  private renderMobileSearchBarButtons;
106
- private renderMobileFacetsActions;
107
99
  private renderMobileFacets;
108
- private renderSuggestions;
109
- private getIcon;
110
- private renderDesktopFacetsActions;
100
+ private contentLocalesAsFilterOptions;
101
+ private renderDesktopSearchBar;
102
+ private renderSearchBarLeftAction;
103
+ private renderDesktopSearchBarButtons;
104
+ private renderFacetsActions;
111
105
  private renderDesktopFacets;
112
106
  private renderSelectedFacets;
107
+ private renderSuggestions;
108
+ private getIcon;
109
+ private openMobileFilters;
113
110
  protected firstUpdated(props: PropertyValues): Promise<void>;
114
111
  protected update(props: PropertyValues): void;
115
112
  protected contentAvailableCallback(props: PropertyValues): void;
@@ -133,6 +130,9 @@ export declare class FtSearchBar extends FtLitElement implements FtSearchBarProp
133
130
  private updateSize;
134
131
  private getLocaleLabel;
135
132
  private setFilter;
133
+ private compareFilters;
134
+ private compareRequests;
135
+ private setFiltersFromPreset;
136
136
  private clearFilters;
137
137
  private removeRecentSearch;
138
138
  private onSuggestKeyDown;