@internetarchive/elements 0.2.3-alpha-webdev8378.2 → 0.2.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/LICENSE +661 -661
- package/README.md +320 -320
- package/dist/src/elements/ia-combo-box/caret-closed.svg +8 -8
- package/dist/src/elements/ia-combo-box/caret-open.svg +8 -8
- package/dist/src/elements/ia-combo-box/clear.svg +8 -8
- package/dist/src/elements/ia-otp-form/ia-otp-form.js +88 -88
- package/dist/src/elements/ia-otp-form/ia-otp-form.js.map +1 -1
- package/dist/src/elements/ia-status-indicator/ia-status-indicator.js +149 -149
- package/dist/src/elements/ia-status-indicator/ia-status-indicator.js.map +1 -1
- package/dist/src/labs/ia-snow/flake.svg +1 -1
- package/dist/src/themes/theme-styles.d.ts.map +1 -1
- package/dist/src/themes/theme-styles.js +77 -87
- package/dist/src/themes/theme-styles.js.map +1 -1
- package/package.json +118 -120
- package/dist/src/elements/ia-dropdown-search-bar/ia-dropdown-search-bar.d.ts +0 -71
- package/dist/src/elements/ia-dropdown-search-bar/ia-dropdown-search-bar.d.ts.map +0 -1
- package/dist/src/elements/ia-dropdown-search-bar/ia-dropdown-search-bar.js +0 -319
- package/dist/src/elements/ia-dropdown-search-bar/ia-dropdown-search-bar.js.map +0 -1
- package/dist/src/elements/ia-dropdown-search-bar/models.d.ts +0 -16
- package/dist/src/elements/ia-dropdown-search-bar/models.d.ts.map +0 -1
- package/dist/src/elements/ia-dropdown-search-bar/models.js +0 -2
- package/dist/src/elements/ia-dropdown-search-bar/models.js.map +0 -1
- package/dist/src/elements/ia-dropdown-search-bar/search.svg +0 -10
|
@@ -1,319 +0,0 @@
|
|
|
1
|
-
import { __decorate } from "tslib";
|
|
2
|
-
import { msg } from '@lit/localize';
|
|
3
|
-
import { css, html, LitElement, nothing } from 'lit';
|
|
4
|
-
import { customElement, property, query } from 'lit/decorators.js';
|
|
5
|
-
import themeStyles from '../../themes/theme-styles.js';
|
|
6
|
-
import searchIcon from './search.svg';
|
|
7
|
-
import '@internetarchive/ia-clearable-text-input';
|
|
8
|
-
import '@internetarchive/ia-dropdown';
|
|
9
|
-
import '../../elements/ia-status-indicator/ia-status-indicator.js';
|
|
10
|
-
/**
|
|
11
|
-
* Event names emitted by this component
|
|
12
|
-
*/
|
|
13
|
-
const Events = {
|
|
14
|
-
CategoryChanged: 'categoryChanged',
|
|
15
|
-
SearchRequested: 'searchRequested',
|
|
16
|
-
};
|
|
17
|
-
let IADropdownSearchBar = class IADropdownSearchBar extends LitElement {
|
|
18
|
-
constructor() {
|
|
19
|
-
super(...arguments);
|
|
20
|
-
/** Dropdown menu options (tab IDs + labels) */
|
|
21
|
-
this.categories = [];
|
|
22
|
-
/** Placeholder text for the search input */
|
|
23
|
-
this.placeholder = msg('Search');
|
|
24
|
-
/** Whether to use the mobile layout */
|
|
25
|
-
this.useMobileView = false;
|
|
26
|
-
/** Whether to hide the category dropdown to the left of the search bar */
|
|
27
|
-
this.hideDropdown = false;
|
|
28
|
-
/** Whether the search button should show its loading state */
|
|
29
|
-
this.loading = false;
|
|
30
|
-
}
|
|
31
|
-
/** The effective selected category, falling back to the first in the list. */
|
|
32
|
-
get resolvedCategory() {
|
|
33
|
-
return this.selectedCategory ?? this.categories[0]?.id ?? '';
|
|
34
|
-
}
|
|
35
|
-
render() {
|
|
36
|
-
return html `
|
|
37
|
-
<div id="container" part="container" role="search">
|
|
38
|
-
<div
|
|
39
|
-
id="main-bar"
|
|
40
|
-
part="main-bar"
|
|
41
|
-
class=${this.hideDropdown ? 'no-dropdown' : nothing}
|
|
42
|
-
>
|
|
43
|
-
${this.hideDropdown ? nothing : this.dropdownTemplate}
|
|
44
|
-
${this.textBoxTemplate} ${this.searchButtonTemplate}
|
|
45
|
-
</div>
|
|
46
|
-
</div>
|
|
47
|
-
`;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Template for the category dropdown on the left side of the search bar.
|
|
51
|
-
*/
|
|
52
|
-
get dropdownTemplate() {
|
|
53
|
-
return html `
|
|
54
|
-
<ia-dropdown
|
|
55
|
-
id="category-dropdown"
|
|
56
|
-
part="category-dropdown"
|
|
57
|
-
displayCaret
|
|
58
|
-
includeSelectedOption
|
|
59
|
-
closeOnSelect
|
|
60
|
-
closeOnEscape
|
|
61
|
-
closeOnBackdropClick
|
|
62
|
-
openViaButton
|
|
63
|
-
.selectedOption=${this.resolvedCategory}
|
|
64
|
-
.options=${this.dropdownOptions}
|
|
65
|
-
@optionSelected=${this.handleCategorySelected}
|
|
66
|
-
>
|
|
67
|
-
<span slot="dropdown-label">${this.selectedCategoryLabel}</span>
|
|
68
|
-
</ia-dropdown>
|
|
69
|
-
`;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Template for the main text entry box of the search bar.
|
|
73
|
-
*/
|
|
74
|
-
get textBoxTemplate() {
|
|
75
|
-
return html `
|
|
76
|
-
<ia-clearable-text-input
|
|
77
|
-
id="search-input"
|
|
78
|
-
part="search-input"
|
|
79
|
-
.value=${this.spacedQuery}
|
|
80
|
-
placeholder=${this.placeholder}
|
|
81
|
-
clearButtonScreenReaderLabel=${msg('Clear search query')}
|
|
82
|
-
screenReaderLabel=${msg('Search the Archive. Filters and Advanced Search available below.')}
|
|
83
|
-
@clear=${this.searchFieldCleared}
|
|
84
|
-
@submit=${this.handleSubmit}
|
|
85
|
-
></ia-clearable-text-input>
|
|
86
|
-
`;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Template for the "magnifying glass" search button to the right of the search bar.
|
|
90
|
-
*/
|
|
91
|
-
get searchButtonTemplate() {
|
|
92
|
-
return html `
|
|
93
|
-
<button
|
|
94
|
-
id="search-button"
|
|
95
|
-
part="search-button"
|
|
96
|
-
class=${this.loading ? 'loading' : nothing}
|
|
97
|
-
type="button"
|
|
98
|
-
aria-label=${msg('Search')}
|
|
99
|
-
@click=${this.handleSubmit}
|
|
100
|
-
>
|
|
101
|
-
${this.loading
|
|
102
|
-
? html `<ia-status-indicator
|
|
103
|
-
mode="loading"
|
|
104
|
-
class="search-button-loading-icon"
|
|
105
|
-
></ia-status-indicator>`
|
|
106
|
-
: html `<img src=${searchIcon} alt="" />`}
|
|
107
|
-
</button>
|
|
108
|
-
`;
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Converts the `categories` array into the `optionInterface[]` format
|
|
112
|
-
* expected by `ia-dropdown`.
|
|
113
|
-
*/
|
|
114
|
-
get dropdownOptions() {
|
|
115
|
-
return this.categories.map((cat) => ({
|
|
116
|
-
id: cat.id,
|
|
117
|
-
label: html `<span>${cat.label}</span>`,
|
|
118
|
-
}));
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* The display label for the currently selected category.
|
|
122
|
-
*/
|
|
123
|
-
get selectedCategoryLabel() {
|
|
124
|
-
const match = this.categories.find((c) => c.id === this.resolvedCategory);
|
|
125
|
-
return match?.label ?? this.resolvedCategory;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* The current search query with +'s replaced by spaces.
|
|
129
|
-
*/
|
|
130
|
-
get spacedQuery() {
|
|
131
|
-
return this.query?.replace(/\+/g, ' ') ?? '';
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Handler for when the search bar's clear button is pressed.
|
|
135
|
-
*/
|
|
136
|
-
searchFieldCleared() {
|
|
137
|
-
if (this.query) {
|
|
138
|
-
this.emitSearchRequested();
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Handler for Enter key or search button click.
|
|
143
|
-
*/
|
|
144
|
-
handleSubmit() {
|
|
145
|
-
this.emitSearchRequested();
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Handler for when the user selects a category from the dropdown.
|
|
149
|
-
*
|
|
150
|
-
* Sets `selectedCategory` locally for immediate visual feedback (semi-controlled
|
|
151
|
-
* pattern). The parent also binds this property and may re-set it on re-render.
|
|
152
|
-
*/
|
|
153
|
-
handleCategorySelected(e) {
|
|
154
|
-
const newCategoryId = e.detail.option.id;
|
|
155
|
-
if (newCategoryId === this.resolvedCategory)
|
|
156
|
-
return;
|
|
157
|
-
this.selectedCategory = newCategoryId;
|
|
158
|
-
// On next tick, focus the text input bar (seemingly fails in Safari without the delay)
|
|
159
|
-
setTimeout(() => this.searchInput.focus());
|
|
160
|
-
this.dispatchEvent(new CustomEvent(Events.CategoryChanged, {
|
|
161
|
-
detail: newCategoryId,
|
|
162
|
-
}));
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Emits a `searchRequested` event with the current query and category.
|
|
166
|
-
*/
|
|
167
|
-
emitSearchRequested() {
|
|
168
|
-
this.dispatchEvent(new CustomEvent(Events.SearchRequested, {
|
|
169
|
-
detail: {
|
|
170
|
-
query: this.searchInput.value,
|
|
171
|
-
category: this.resolvedCategory,
|
|
172
|
-
},
|
|
173
|
-
}));
|
|
174
|
-
}
|
|
175
|
-
static get styles() {
|
|
176
|
-
const ownStyles = css `
|
|
177
|
-
:host {
|
|
178
|
-
--search-bar-height--: var(--search-bar-height, 30px);
|
|
179
|
-
--search-bar-width--: var(--search-bar-width, 300px);
|
|
180
|
-
--search-bar-internal-padding--: var(--padding-sm, 5px);
|
|
181
|
-
--clear-button-offset--: var(--clear-button-offset, 0);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
#container {
|
|
185
|
-
display: inline-block;
|
|
186
|
-
width: var(--search-bar-width--);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
#main-bar {
|
|
190
|
-
display: flex;
|
|
191
|
-
height: var(--search-bar-height--, 30px);
|
|
192
|
-
flex: 1;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
#category-dropdown {
|
|
196
|
-
display: flex;
|
|
197
|
-
flex-shrink: 0;
|
|
198
|
-
height: 100%;
|
|
199
|
-
box-sizing: border-box;
|
|
200
|
-
|
|
201
|
-
background-color: #f5f5f7;
|
|
202
|
-
border: 1px solid #999;
|
|
203
|
-
border-radius: 5px 0 0 5px;
|
|
204
|
-
|
|
205
|
-
--dropdownMainButtonPadding: 0 var(--search-bar-internal-padding--, 5px);
|
|
206
|
-
--dropdownBgColor: #2c2c2c;
|
|
207
|
-
--dropdownTextColor: #fff;
|
|
208
|
-
--dropdownBorderColor: #ddd;
|
|
209
|
-
--dropdownCaretColor: var(--ia-theme-primary-text-color, #2c2c2c);
|
|
210
|
-
--dropdownHoverBgColor: rgba(255, 255, 255, 0.3);
|
|
211
|
-
--dropdownHoverTextColor: #fff;
|
|
212
|
-
--dropdownSelectedBgColor: rgba(255, 255, 255, 0.3);
|
|
213
|
-
--dropdownSelectedTextColor: #fff;
|
|
214
|
-
--dropdownWhiteSpace: nowrap;
|
|
215
|
-
--dropdownOffsetTop: 2px;
|
|
216
|
-
--caretHeight: 8px;
|
|
217
|
-
--caretWidth: 12px;
|
|
218
|
-
--caretPadding: 0 0 0 5px;
|
|
219
|
-
--dropdownFontSize: inherit;
|
|
220
|
-
--dropdownBorderRadius: 4px;
|
|
221
|
-
--buttonSlotPaddingRight: 0;
|
|
222
|
-
--dropdownTextAlign: left;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
#category-dropdown [slot='dropdown-label'] {
|
|
226
|
-
color: var(--ia-theme-primary-text-color, #2c2c2c);
|
|
227
|
-
font-size: inherit;
|
|
228
|
-
font-family: inherit;
|
|
229
|
-
white-space: nowrap;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
.no-dropdown #search-input {
|
|
233
|
-
border-left: 1px solid #999;
|
|
234
|
-
border-radius: 5px 0 0 5px;
|
|
235
|
-
overflow: hidden;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
#search-input {
|
|
239
|
-
width: 100%;
|
|
240
|
-
height: 100%;
|
|
241
|
-
box-sizing: border-box;
|
|
242
|
-
border-top: 1px solid #999;
|
|
243
|
-
border-bottom: 1px solid #999;
|
|
244
|
-
font-size: inherit;
|
|
245
|
-
|
|
246
|
-
--input-height: calc(var(--search-bar-height--) - 2px);
|
|
247
|
-
--input-padding: 0 var(--search-bar-internal-padding--, 5px);
|
|
248
|
-
--input-background-color: var(
|
|
249
|
-
--ia-theme-secondary-background-color,
|
|
250
|
-
#fff
|
|
251
|
-
);
|
|
252
|
-
--input-border-radius: 0;
|
|
253
|
-
--input-border-width: 0;
|
|
254
|
-
--input-box-shadow: none;
|
|
255
|
-
--input-focused-box-shadow: none;
|
|
256
|
-
--input-font-size: auto;
|
|
257
|
-
--clear-button-top: var(--clear-button-offset--, 0);
|
|
258
|
-
--clear-button-right: 2px;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
#search-button {
|
|
262
|
-
appearance: none;
|
|
263
|
-
box-sizing: border-box;
|
|
264
|
-
border-radius: 0 5px 5px 0;
|
|
265
|
-
background-color: var(--ia-theme-secondary-background-color, #fff);
|
|
266
|
-
border: 1px solid #999;
|
|
267
|
-
border-left: 0;
|
|
268
|
-
padding: 0 var(--search-bar-internal-padding--, 5px) 0 5px;
|
|
269
|
-
min-width: 30px;
|
|
270
|
-
height: 100%;
|
|
271
|
-
cursor: pointer;
|
|
272
|
-
display: flex;
|
|
273
|
-
align-items: center;
|
|
274
|
-
justify-content: center;
|
|
275
|
-
flex-shrink: 0;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
#search-button img {
|
|
279
|
-
width: 18px;
|
|
280
|
-
height: 18px;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
.search-button-loading-icon {
|
|
284
|
-
--icon-width: 20px;
|
|
285
|
-
margin-top: 2px;
|
|
286
|
-
}
|
|
287
|
-
`;
|
|
288
|
-
return [themeStyles, ownStyles];
|
|
289
|
-
}
|
|
290
|
-
};
|
|
291
|
-
__decorate([
|
|
292
|
-
property({ type: String })
|
|
293
|
-
], IADropdownSearchBar.prototype, "query", void 0);
|
|
294
|
-
__decorate([
|
|
295
|
-
property({ type: Array })
|
|
296
|
-
], IADropdownSearchBar.prototype, "categories", void 0);
|
|
297
|
-
__decorate([
|
|
298
|
-
property({ type: String })
|
|
299
|
-
], IADropdownSearchBar.prototype, "selectedCategory", void 0);
|
|
300
|
-
__decorate([
|
|
301
|
-
property({ type: String })
|
|
302
|
-
], IADropdownSearchBar.prototype, "placeholder", void 0);
|
|
303
|
-
__decorate([
|
|
304
|
-
property({ type: Boolean })
|
|
305
|
-
], IADropdownSearchBar.prototype, "useMobileView", void 0);
|
|
306
|
-
__decorate([
|
|
307
|
-
property({ type: Boolean })
|
|
308
|
-
], IADropdownSearchBar.prototype, "hideDropdown", void 0);
|
|
309
|
-
__decorate([
|
|
310
|
-
property({ type: Boolean })
|
|
311
|
-
], IADropdownSearchBar.prototype, "loading", void 0);
|
|
312
|
-
__decorate([
|
|
313
|
-
query('#search-input')
|
|
314
|
-
], IADropdownSearchBar.prototype, "searchInput", void 0);
|
|
315
|
-
IADropdownSearchBar = __decorate([
|
|
316
|
-
customElement('ia-dropdown-search-bar')
|
|
317
|
-
], IADropdownSearchBar);
|
|
318
|
-
export { IADropdownSearchBar };
|
|
319
|
-
//# sourceMappingURL=ia-dropdown-search-bar.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ia-dropdown-search-bar.js","sourceRoot":"","sources":["../../../../src/elements/ia-dropdown-search-bar/ia-dropdown-search-bar.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAkB,MAAM,KAAK,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAQnE,OAAO,WAAW,MAAM,0BAA0B,CAAC;AACnD,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC,OAAO,0CAA0C,CAAC;AAClD,OAAO,8BAA8B,CAAC;AACtC,OAAO,uDAAuD,CAAC;AAE/D;;GAEG;AACH,MAAM,MAAM,GAAG;IAC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,EAAE,CAAC;wDAA6B;AAG3B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;0DAAuB;AAGtB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;yDAAsB;AAGrB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;oDAAiB;AAGrC;IADP,KAAK,CAAC,eAAe,CAAC;wDACoB;AAvBhC,mBAAmB;IAD/B,aAAa,CAAC,wBAAwB,CAAC;GAC3B,mBAAmB,CAmT/B","sourcesContent":["import { msg } from '@lit/localize';\r\nimport { css, html, LitElement, nothing, TemplateResult } from 'lit';\r\nimport { customElement, property, query } from 'lit/decorators.js';\r\nimport type { IaClearableTextInput } from '@internetarchive/ia-clearable-text-input';\r\nimport type { optionInterface } from '@internetarchive/ia-dropdown';\r\nimport type {\r\n SearchCategory,\r\n SearchRequestedDetail,\r\n} from './models';\r\n\r\nimport themeStyles from '@src/themes/theme-styles';\r\nimport searchIcon from './search.svg';\r\n\r\nimport '@internetarchive/ia-clearable-text-input';\r\nimport '@internetarchive/ia-dropdown';\r\nimport '@src/elements/ia-status-indicator/ia-status-indicator';\r\n\r\n/**\r\n * Event names emitted by this component\r\n */\r\nconst Events = {\r\n CategoryChanged: 'categoryChanged',\r\n SearchRequested: 'searchRequested',\r\n};\r\n\r\n@customElement('ia-dropdown-search-bar')\r\nexport class IADropdownSearchBar extends LitElement {\r\n /** The query that appears in the search bar */\r\n @property({ type: String }) query?: string;\r\n\r\n /** Dropdown menu options (tab IDs + labels) */\r\n @property({ type: Array }) categories: SearchCategory[] = [];\r\n\r\n /** The currently selected dropdown category ID */\r\n @property({ type: String }) selectedCategory?: string;\r\n\r\n /** Placeholder text for the search input */\r\n @property({ type: String }) placeholder = msg('Search');\r\n\r\n /** Whether to use the mobile layout */\r\n @property({ type: Boolean }) useMobileView = false;\r\n\r\n /** Whether to hide the category dropdown to the left of the search bar */\r\n @property({ type: Boolean }) hideDropdown = false;\r\n\r\n /** Whether the search button should show its loading state */\r\n @property({ type: Boolean }) loading = false;\r\n\r\n @query('#search-input')\r\n private searchInput!: IaClearableTextInput;\r\n\r\n /** The effective selected category, falling back to the first in the list. */\r\n private get resolvedCategory(): string {\r\n return this.selectedCategory ?? this.categories[0]?.id ?? '';\r\n }\r\n\r\n render(): TemplateResult {\r\n return html`\r\n <div id=\"container\" part=\"container\" role=\"search\">\r\n <div\r\n id=\"main-bar\"\r\n part=\"main-bar\"\r\n class=${this.hideDropdown ? 'no-dropdown' : nothing}\r\n >\r\n ${this.hideDropdown ? nothing : this.dropdownTemplate}\r\n ${this.textBoxTemplate} ${this.searchButtonTemplate}\r\n </div>\r\n </div>\r\n `;\r\n }\r\n\r\n /**\r\n * Template for the category dropdown on the left side of the search bar.\r\n */\r\n private get dropdownTemplate(): TemplateResult {\r\n return html`\r\n <ia-dropdown\r\n id=\"category-dropdown\"\r\n part=\"category-dropdown\"\r\n displayCaret\r\n includeSelectedOption\r\n closeOnSelect\r\n closeOnEscape\r\n closeOnBackdropClick\r\n openViaButton\r\n .selectedOption=${this.resolvedCategory}\r\n .options=${this.dropdownOptions}\r\n @optionSelected=${this.handleCategorySelected}\r\n >\r\n <span slot=\"dropdown-label\">${this.selectedCategoryLabel}</span>\r\n </ia-dropdown>\r\n `;\r\n }\r\n\r\n /**\r\n * Template for the main text entry box of the search bar.\r\n */\r\n private get textBoxTemplate(): TemplateResult {\r\n return html`\r\n <ia-clearable-text-input\r\n id=\"search-input\"\r\n part=\"search-input\"\r\n .value=${this.spacedQuery}\r\n placeholder=${this.placeholder}\r\n clearButtonScreenReaderLabel=${msg('Clear search query')}\r\n screenReaderLabel=${msg(\r\n 'Search the Archive. Filters and Advanced Search available below.',\r\n )}\r\n @clear=${this.searchFieldCleared}\r\n @submit=${this.handleSubmit}\r\n ></ia-clearable-text-input>\r\n `;\r\n }\r\n\r\n /**\r\n * Template for the \"magnifying glass\" search button to the right of the search bar.\r\n */\r\n private get searchButtonTemplate(): TemplateResult {\r\n return html`\r\n <button\r\n id=\"search-button\"\r\n part=\"search-button\"\r\n class=${this.loading ? 'loading' : nothing}\r\n type=\"button\"\r\n aria-label=${msg('Search')}\r\n @click=${this.handleSubmit}\r\n >\r\n ${this.loading\r\n ? html`<ia-status-indicator\r\n mode=\"loading\"\r\n class=\"search-button-loading-icon\"\r\n ></ia-status-indicator>`\r\n : html`<img src=${searchIcon} alt=\"\" />`}\r\n </button>\r\n `;\r\n }\r\n\r\n /**\r\n * Converts the `categories` array into the `optionInterface[]` format\r\n * expected by `ia-dropdown`.\r\n */\r\n private get dropdownOptions(): optionInterface[] {\r\n return this.categories.map((cat) => ({\r\n id: cat.id,\r\n label: html`<span>${cat.label}</span>`,\r\n }));\r\n }\r\n\r\n /**\r\n * The display label for the currently selected category.\r\n */\r\n private get selectedCategoryLabel(): string {\r\n const match = this.categories.find((c) => c.id === this.resolvedCategory);\r\n return match?.label ?? this.resolvedCategory;\r\n }\r\n\r\n /**\r\n * The current search query with +'s replaced by spaces.\r\n */\r\n private get spacedQuery(): string {\r\n return this.query?.replace(/\\+/g, ' ') ?? '';\r\n }\r\n\r\n /**\r\n * Handler for when the search bar's clear button is pressed.\r\n */\r\n private searchFieldCleared(): void {\r\n if (this.query) {\r\n this.emitSearchRequested();\r\n }\r\n }\r\n\r\n /**\r\n * Handler for Enter key or search button click.\r\n */\r\n private handleSubmit(): void {\r\n this.emitSearchRequested();\r\n }\r\n\r\n /**\r\n * Handler for when the user selects a category from the dropdown.\r\n *\r\n * Sets `selectedCategory` locally for immediate visual feedback (semi-controlled\r\n * pattern). The parent also binds this property and may re-set it on re-render.\r\n */\r\n private handleCategorySelected(\r\n e: CustomEvent<{ option: optionInterface }>,\r\n ): void {\r\n const newCategoryId = e.detail.option.id;\r\n if (newCategoryId === this.resolvedCategory) return;\r\n\r\n this.selectedCategory = newCategoryId;\r\n\r\n // On next tick, focus the text input bar (seemingly fails in Safari without the delay)\r\n setTimeout(() => this.searchInput.focus());\r\n\r\n this.dispatchEvent(\r\n new CustomEvent<string>(Events.CategoryChanged, {\r\n detail: newCategoryId,\r\n }),\r\n );\r\n }\r\n\r\n /**\r\n * Emits a `searchRequested` event with the current query and category.\r\n */\r\n private emitSearchRequested(): void {\r\n this.dispatchEvent(\r\n new CustomEvent<SearchRequestedDetail>(Events.SearchRequested, {\r\n detail: {\r\n query: this.searchInput.value,\r\n category: this.resolvedCategory,\r\n },\r\n }),\r\n );\r\n }\r\n\r\n static get styles() {\r\n const ownStyles = css`\r\n :host {\r\n --search-bar-height--: var(--search-bar-height, 30px);\r\n --search-bar-width--: var(--search-bar-width, 300px);\r\n --search-bar-internal-padding--: var(--padding-sm, 5px);\r\n --clear-button-offset--: var(--clear-button-offset, 0);\r\n }\r\n\r\n #container {\r\n display: inline-block;\r\n width: var(--search-bar-width--);\r\n }\r\n\r\n #main-bar {\r\n display: flex;\r\n height: var(--search-bar-height--, 30px);\r\n flex: 1;\r\n }\r\n\r\n #category-dropdown {\r\n display: flex;\r\n flex-shrink: 0;\r\n height: 100%;\r\n box-sizing: border-box;\r\n\r\n background-color: #f5f5f7;\r\n border: 1px solid #999;\r\n border-radius: 5px 0 0 5px;\r\n\r\n --dropdownMainButtonPadding: 0 var(--search-bar-internal-padding--, 5px);\r\n --dropdownBgColor: #2c2c2c;\r\n --dropdownTextColor: #fff;\r\n --dropdownBorderColor: #ddd;\r\n --dropdownCaretColor: var(--ia-theme-primary-text-color, #2c2c2c);\r\n --dropdownHoverBgColor: rgba(255, 255, 255, 0.3);\r\n --dropdownHoverTextColor: #fff;\r\n --dropdownSelectedBgColor: rgba(255, 255, 255, 0.3);\r\n --dropdownSelectedTextColor: #fff;\r\n --dropdownWhiteSpace: nowrap;\r\n --dropdownOffsetTop: 2px;\r\n --caretHeight: 8px;\r\n --caretWidth: 12px;\r\n --caretPadding: 0 0 0 5px;\r\n --dropdownFontSize: inherit;\r\n --dropdownBorderRadius: 4px;\r\n --buttonSlotPaddingRight: 0;\r\n --dropdownTextAlign: left;\r\n }\r\n\r\n #category-dropdown [slot='dropdown-label'] {\r\n color: var(--ia-theme-primary-text-color, #2c2c2c);\r\n font-size: inherit;\r\n font-family: inherit;\r\n white-space: nowrap;\r\n }\r\n\r\n .no-dropdown #search-input {\r\n border-left: 1px solid #999;\r\n border-radius: 5px 0 0 5px;\r\n overflow: hidden;\r\n }\r\n\r\n #search-input {\r\n width: 100%;\r\n height: 100%;\r\n box-sizing: border-box;\r\n border-top: 1px solid #999;\r\n border-bottom: 1px solid #999;\r\n font-size: inherit;\r\n\r\n --input-height: calc(var(--search-bar-height--) - 2px);\r\n --input-padding: 0 var(--search-bar-internal-padding--, 5px);\r\n --input-background-color: var(\r\n --ia-theme-secondary-background-color,\r\n #fff\r\n );\r\n --input-border-radius: 0;\r\n --input-border-width: 0;\r\n --input-box-shadow: none;\r\n --input-focused-box-shadow: none;\r\n --input-font-size: auto;\r\n --clear-button-top: var(--clear-button-offset--, 0);\r\n --clear-button-right: 2px;\r\n }\r\n\r\n #search-button {\r\n appearance: none;\r\n box-sizing: border-box;\r\n border-radius: 0 5px 5px 0;\r\n background-color: var(--ia-theme-secondary-background-color, #fff);\r\n border: 1px solid #999;\r\n border-left: 0;\r\n padding: 0 var(--search-bar-internal-padding--, 5px) 0 5px;\r\n min-width: 30px;\r\n height: 100%;\r\n cursor: pointer;\r\n display: flex;\r\n align-items: center;\r\n justify-content: center;\r\n flex-shrink: 0;\r\n }\r\n\r\n #search-button img {\r\n width: 18px;\r\n height: 18px;\r\n }\r\n\r\n .search-button-loading-icon {\r\n --icon-width: 20px;\r\n margin-top: 2px;\r\n }\r\n `;\r\n\r\n return [themeStyles, ownStyles];\r\n }\r\n}\r\n"]}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A category to include in the dropdown. Consists of an internal `id` string that is
|
|
3
|
-
* emitted on selection, an a human-readable `label` to display in the dropdown.
|
|
4
|
-
*/
|
|
5
|
-
export type SearchCategory = {
|
|
6
|
-
id: string;
|
|
7
|
-
label: string;
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* Detail object emitted with `searchRequested` events.
|
|
11
|
-
*/
|
|
12
|
-
export type SearchRequestedDetail = {
|
|
13
|
-
query: string;
|
|
14
|
-
category: string;
|
|
15
|
-
};
|
|
16
|
-
//# sourceMappingURL=models.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../../../src/elements/ia-dropdown-search-bar/models.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../../../src/elements/ia-dropdown-search-bar/models.ts"],"names":[],"mappings":"","sourcesContent":["/**\r\n * A category to include in the dropdown. Consists of an internal `id` string that is\r\n * emitted on selection, an a human-readable `label` to display in the dropdown.\r\n */\r\nexport type SearchCategory = {\r\n id: string;\r\n label: string;\r\n};\r\n\r\n/**\r\n * Detail object emitted with `searchRequested` events.\r\n */\r\nexport type SearchRequestedDetail = {\r\n query: string;\r\n category: string;\r\n};\r\n"]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
<svg
|
|
2
|
-
viewBox="0 0 100 100"
|
|
3
|
-
xmlns="http://www.w3.org/2000/svg">
|
|
4
|
-
<path
|
|
5
|
-
class="fill-color"
|
|
6
|
-
d="m17.0555551 41.3194459c0-12.7430552 10.3541664-23.1027772 23.0847216-23.1027772 12.7166664 0 23.0777773 10.359722 23.0777773 23.1027772 0 12.7361108-10.3611109 23.0986106-23.0777773 23.0986106-12.7305552 0-23.0847216-10.3624998-23.0847216-23.0986106zm-17.24305512 0c0 22.2916661 18.04583292 40.3472213 40.32777672 40.3472213 8.9208332 0 17.145833-2.9319449 23.8194439-7.8527776l24.1513883 24.0777771c1.2125 1.1402778 2.8430555 1.8430556 4.6374999 1.8430556 3.7444443 0 6.7805554-3.0361111 6.7805554-6.7791665 0-2.0652778-.9222222-3.9069444-2.3736111-5.1499999l-23.718055-23.7458328c4.4152777-6.4791665 7.0152776-14.3055552 7.0152776-22.7402772 0-22.2791661-18.0458328-40.34861006-40.312499-40.34861006-22.2819438 0-40.32777672 18.06944396-40.32777672 40.34861006z"
|
|
7
|
-
fill="#2c2c2c"
|
|
8
|
-
fill-rule="evenodd"
|
|
9
|
-
/>
|
|
10
|
-
</svg>
|