@internetarchive/elements 0.2.3-alpha-webdev8378.7 → 0.2.3-alpha-webdev8378.8
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/dist/src/elements/ia-dropdown-search-bar/ia-dropdown-search-bar.d.ts.map +1 -1
- package/dist/src/elements/ia-dropdown-search-bar/ia-dropdown-search-bar.js +165 -163
- package/dist/src/elements/ia-dropdown-search-bar/ia-dropdown-search-bar.js.map +1 -1
- package/dist/src/elements/ia-dropdown-search-bar/models.d.ts +1 -1
- package/dist/src/elements/ia-dropdown-search-bar/models.js.map +1 -1
- 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/elements/index.js.map +1 -1
- package/dist/src/themes/theme-styles.js +87 -87
- package/dist/src/themes/theme-styles.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ia-dropdown-search-bar.d.ts","sourceRoot":"","sources":["../../../../src/elements/ia-dropdown-search-bar/ia-dropdown-search-bar.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,UAAU,EAAW,cAAc,EAAE,MAAM,KAAK,CAAC;AAIrE,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"ia-dropdown-search-bar.d.ts","sourceRoot":"","sources":["../../../../src/elements/ia-dropdown-search-bar/ia-dropdown-search-bar.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,UAAU,EAAW,cAAc,EAAE,MAAM,KAAK,CAAC;AAIrE,OAAO,KAAK,EAAE,cAAc,EAAyB,MAAM,UAAU,CAAC;AAKtE,OAAO,0CAA0C,CAAC;AAClD,OAAO,8BAA8B,CAAC;AACtC,OAAO,uDAAuD,CAAC;AAU/D,qBACa,mBAAoB,SAAQ,UAAU;IACjD,+CAA+C;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IAE3C,+CAA+C;IACpB,UAAU,EAAE,cAAc,EAAE,CAAM;IAE7D,kDAAkD;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAEtD,4CAA4C;IAChB,WAAW,SAAiB;IAExD,uCAAuC;IACV,aAAa,UAAS;IAEnD,0EAA0E;IAC7C,YAAY,UAAS;IAElD,8DAA8D;IACjC,OAAO,UAAS;IAG7C,OAAO,CAAC,WAAW,CAAwB;IAE3C,8EAA8E;IAC9E,OAAO,KAAK,gBAAgB,GAE3B;IAED,MAAM,IAAI,cAAc;IAexB;;OAEG;IACH,OAAO,KAAK,gBAAgB,GAoB3B;IAED;;OAEG;IACH,OAAO,KAAK,eAAe,GAe1B;IAED;;OAEG;IACH,OAAO,KAAK,oBAAoB,GAkB/B;IAED;;OAEG;IACH,OAAO,KAAK,qBAAqB,GAGhC;IAED;;OAEG;IACH,OAAO,KAAK,WAAW,GAEtB;IAED;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAM1B;;OAEG;IACH,OAAO,CAAC,YAAY;IAIpB;;;;;OAKG;IACH,OAAO,CAAC,sBAAsB;IAkB9B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAW3B,MAAM,KAAK,MAAM,8BAmHhB;CACF"}
|
|
@@ -33,78 +33,80 @@ let IADropdownSearchBar = class IADropdownSearchBar extends LitElement {
|
|
|
33
33
|
return this.selectedCategory ?? this.categories?.[0]?.id ?? '';
|
|
34
34
|
}
|
|
35
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>
|
|
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
47
|
`;
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
50
|
* Template for the category dropdown on the left side of the search bar.
|
|
51
51
|
*/
|
|
52
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.categories}
|
|
65
|
-
@optionSelected=${this.handleCategorySelected}
|
|
66
|
-
>
|
|
67
|
-
<span slot="dropdown-label"
|
|
68
|
-
|
|
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.categories}
|
|
65
|
+
@optionSelected=${this.handleCategorySelected}
|
|
66
|
+
>
|
|
67
|
+
<span slot="dropdown-label" part="category-dropdown-label"
|
|
68
|
+
>${this.selectedCategoryLabel}</span
|
|
69
|
+
>
|
|
70
|
+
</ia-dropdown>
|
|
69
71
|
`;
|
|
70
72
|
}
|
|
71
73
|
/**
|
|
72
74
|
* Template for the main text entry box of the search bar.
|
|
73
75
|
*/
|
|
74
76
|
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>
|
|
77
|
+
return html `
|
|
78
|
+
<ia-clearable-text-input
|
|
79
|
+
id="search-input"
|
|
80
|
+
part="search-input"
|
|
81
|
+
.value=${this.spacedQuery}
|
|
82
|
+
placeholder=${this.placeholder}
|
|
83
|
+
clearButtonScreenReaderLabel=${msg('Clear search query')}
|
|
84
|
+
screenReaderLabel=${msg('Search the Archive. Filters and Advanced Search available below.')}
|
|
85
|
+
@clear=${this.searchFieldCleared}
|
|
86
|
+
@submit=${this.handleSubmit}
|
|
87
|
+
></ia-clearable-text-input>
|
|
86
88
|
`;
|
|
87
89
|
}
|
|
88
90
|
/**
|
|
89
91
|
* Template for the "magnifying glass" search button to the right of the search bar.
|
|
90
92
|
*/
|
|
91
93
|
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
|
-
>
|
|
94
|
+
return html `
|
|
95
|
+
<button
|
|
96
|
+
id="search-button"
|
|
97
|
+
part="search-button"
|
|
98
|
+
class=${this.loading ? 'loading' : nothing}
|
|
99
|
+
type="button"
|
|
100
|
+
aria-label=${msg('Search')}
|
|
101
|
+
@click=${this.handleSubmit}
|
|
102
|
+
>
|
|
101
103
|
${this.loading
|
|
102
|
-
? html `<ia-status-indicator
|
|
103
|
-
mode="loading"
|
|
104
|
-
class="search-button-loading-icon"
|
|
104
|
+
? html `<ia-status-indicator
|
|
105
|
+
mode="loading"
|
|
106
|
+
class="search-button-loading-icon"
|
|
105
107
|
></ia-status-indicator>`
|
|
106
|
-
: html `<img src=${searchIcon} alt="" />`}
|
|
107
|
-
</button>
|
|
108
|
+
: html `<img src=${searchIcon} alt="" />`}
|
|
109
|
+
</button>
|
|
108
110
|
`;
|
|
109
111
|
}
|
|
110
112
|
/**
|
|
@@ -163,117 +165,117 @@ let IADropdownSearchBar = class IADropdownSearchBar extends LitElement {
|
|
|
163
165
|
}));
|
|
164
166
|
}
|
|
165
167
|
static get styles() {
|
|
166
|
-
const ownStyles = css `
|
|
167
|
-
:host {
|
|
168
|
-
--search-bar-height--: var(--search-bar-height, 30px);
|
|
169
|
-
--search-bar-width--: var(--search-bar-width, 300px);
|
|
170
|
-
--search-bar-internal-padding--: var(--padding-sm, 5px);
|
|
171
|
-
--clear-button-offset--: var(--clear-button-offset, 0);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
#container {
|
|
175
|
-
display: inline-block;
|
|
176
|
-
width: var(--search-bar-width--);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
#main-bar {
|
|
180
|
-
display: flex;
|
|
181
|
-
height: var(--search-bar-height--, 30px);
|
|
182
|
-
flex: 1;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
#category-dropdown {
|
|
186
|
-
display: flex;
|
|
187
|
-
flex-shrink: 0;
|
|
188
|
-
height: 100%;
|
|
189
|
-
box-sizing: border-box;
|
|
190
|
-
|
|
191
|
-
background-color: #f5f5f7;
|
|
192
|
-
border: 1px solid #999;
|
|
193
|
-
border-radius: 5px 0 0 5px;
|
|
194
|
-
|
|
195
|
-
--dropdownMainButtonPadding: 0 var(--search-bar-internal-padding--, 5px);
|
|
196
|
-
--dropdownBgColor: #2c2c2c;
|
|
197
|
-
--dropdownTextColor: #fff;
|
|
198
|
-
--dropdownBorderColor: #ddd;
|
|
199
|
-
--dropdownCaretColor: var(--ia-theme-primary-text-color, #2c2c2c);
|
|
200
|
-
--dropdownHoverBgColor: rgba(255, 255, 255, 0.3);
|
|
201
|
-
--dropdownHoverTextColor: #fff;
|
|
202
|
-
--dropdownSelectedBgColor: rgba(255, 255, 255, 0.3);
|
|
203
|
-
--dropdownSelectedTextColor: #fff;
|
|
204
|
-
--dropdownWhiteSpace: nowrap;
|
|
205
|
-
--dropdownOffsetTop: 2px;
|
|
206
|
-
--caretHeight: 8px;
|
|
207
|
-
--caretWidth: 12px;
|
|
208
|
-
--caretPadding: 0 0 0 5px;
|
|
209
|
-
--dropdownFontSize: inherit;
|
|
210
|
-
--dropdownBorderRadius: 4px;
|
|
211
|
-
--buttonSlotPaddingRight: 0;
|
|
212
|
-
--dropdownTextAlign: left;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
#category-dropdown [slot='dropdown-label'] {
|
|
216
|
-
color: var(--ia-theme-primary-text-color, #2c2c2c);
|
|
217
|
-
font-size: 1.4rem;
|
|
218
|
-
font-family: inherit;
|
|
219
|
-
white-space: nowrap;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
.no-dropdown #search-input {
|
|
223
|
-
border-left: 1px solid #999;
|
|
224
|
-
border-radius: 5px 0 0 5px;
|
|
225
|
-
overflow: hidden;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
#search-input {
|
|
229
|
-
width: 100%;
|
|
230
|
-
height: 100%;
|
|
231
|
-
box-sizing: border-box;
|
|
232
|
-
border-top: 1px solid #999;
|
|
233
|
-
border-bottom: 1px solid #999;
|
|
234
|
-
font-size: inherit;
|
|
235
|
-
|
|
236
|
-
--input-height: calc(var(--search-bar-height--) - 2px);
|
|
237
|
-
--input-padding: 0 var(--search-bar-internal-padding--, 5px);
|
|
238
|
-
--input-background-color: var(
|
|
239
|
-
--ia-theme-secondary-background-color,
|
|
240
|
-
#fff
|
|
241
|
-
);
|
|
242
|
-
--input-border-radius: 0;
|
|
243
|
-
--input-border-width: 0;
|
|
244
|
-
--input-box-shadow: none;
|
|
245
|
-
--input-focused-box-shadow: none;
|
|
246
|
-
--input-font-size: auto;
|
|
247
|
-
--clear-button-top: var(--clear-button-offset--, 0);
|
|
248
|
-
--clear-button-right: 2px;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
#search-button {
|
|
252
|
-
appearance: none;
|
|
253
|
-
box-sizing: border-box;
|
|
254
|
-
border-radius: 0 5px 5px 0;
|
|
255
|
-
background-color: var(--ia-theme-secondary-background-color, #fff);
|
|
256
|
-
border: 1px solid #999;
|
|
257
|
-
border-left: 0;
|
|
258
|
-
padding: 0 var(--search-bar-internal-padding--, 5px) 0 5px;
|
|
259
|
-
min-width: 30px;
|
|
260
|
-
height: 100%;
|
|
261
|
-
cursor: pointer;
|
|
262
|
-
display: flex;
|
|
263
|
-
align-items: center;
|
|
264
|
-
justify-content: center;
|
|
265
|
-
flex-shrink: 0;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
#search-button img {
|
|
269
|
-
width: 18px;
|
|
270
|
-
height: 18px;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
.search-button-loading-icon {
|
|
274
|
-
--icon-width: 20px;
|
|
275
|
-
margin-top: 2px;
|
|
276
|
-
}
|
|
168
|
+
const ownStyles = css `
|
|
169
|
+
:host {
|
|
170
|
+
--search-bar-height--: var(--search-bar-height, 30px);
|
|
171
|
+
--search-bar-width--: var(--search-bar-width, 300px);
|
|
172
|
+
--search-bar-internal-padding--: var(--padding-sm, 5px);
|
|
173
|
+
--clear-button-offset--: var(--clear-button-offset, 0);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
#container {
|
|
177
|
+
display: inline-block;
|
|
178
|
+
width: var(--search-bar-width--);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
#main-bar {
|
|
182
|
+
display: flex;
|
|
183
|
+
height: var(--search-bar-height--, 30px);
|
|
184
|
+
flex: 1;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
#category-dropdown {
|
|
188
|
+
display: flex;
|
|
189
|
+
flex-shrink: 0;
|
|
190
|
+
height: 100%;
|
|
191
|
+
box-sizing: border-box;
|
|
192
|
+
|
|
193
|
+
background-color: #f5f5f7;
|
|
194
|
+
border: 1px solid #999;
|
|
195
|
+
border-radius: 5px 0 0 5px;
|
|
196
|
+
|
|
197
|
+
--dropdownMainButtonPadding: 0 var(--search-bar-internal-padding--, 5px);
|
|
198
|
+
--dropdownBgColor: #2c2c2c;
|
|
199
|
+
--dropdownTextColor: #fff;
|
|
200
|
+
--dropdownBorderColor: #ddd;
|
|
201
|
+
--dropdownCaretColor: var(--ia-theme-primary-text-color, #2c2c2c);
|
|
202
|
+
--dropdownHoverBgColor: rgba(255, 255, 255, 0.3);
|
|
203
|
+
--dropdownHoverTextColor: #fff;
|
|
204
|
+
--dropdownSelectedBgColor: rgba(255, 255, 255, 0.3);
|
|
205
|
+
--dropdownSelectedTextColor: #fff;
|
|
206
|
+
--dropdownWhiteSpace: nowrap;
|
|
207
|
+
--dropdownOffsetTop: 2px;
|
|
208
|
+
--caretHeight: 8px;
|
|
209
|
+
--caretWidth: 12px;
|
|
210
|
+
--caretPadding: 0 0 0 5px;
|
|
211
|
+
--dropdownFontSize: inherit;
|
|
212
|
+
--dropdownBorderRadius: 4px;
|
|
213
|
+
--buttonSlotPaddingRight: 0;
|
|
214
|
+
--dropdownTextAlign: left;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
#category-dropdown [slot='dropdown-label'] {
|
|
218
|
+
color: var(--ia-theme-primary-text-color, #2c2c2c);
|
|
219
|
+
font-size: 1.4rem;
|
|
220
|
+
font-family: inherit;
|
|
221
|
+
white-space: nowrap;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.no-dropdown #search-input {
|
|
225
|
+
border-left: 1px solid #999;
|
|
226
|
+
border-radius: 5px 0 0 5px;
|
|
227
|
+
overflow: hidden;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
#search-input {
|
|
231
|
+
width: 100%;
|
|
232
|
+
height: 100%;
|
|
233
|
+
box-sizing: border-box;
|
|
234
|
+
border-top: 1px solid #999;
|
|
235
|
+
border-bottom: 1px solid #999;
|
|
236
|
+
font-size: inherit;
|
|
237
|
+
|
|
238
|
+
--input-height: calc(var(--search-bar-height--) - 2px);
|
|
239
|
+
--input-padding: 0 var(--search-bar-internal-padding--, 5px);
|
|
240
|
+
--input-background-color: var(
|
|
241
|
+
--ia-theme-secondary-background-color,
|
|
242
|
+
#fff
|
|
243
|
+
);
|
|
244
|
+
--input-border-radius: 0;
|
|
245
|
+
--input-border-width: 0;
|
|
246
|
+
--input-box-shadow: none;
|
|
247
|
+
--input-focused-box-shadow: none;
|
|
248
|
+
--input-font-size: auto;
|
|
249
|
+
--clear-button-top: var(--clear-button-offset--, 0);
|
|
250
|
+
--clear-button-right: 2px;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
#search-button {
|
|
254
|
+
appearance: none;
|
|
255
|
+
box-sizing: border-box;
|
|
256
|
+
border-radius: 0 5px 5px 0;
|
|
257
|
+
background-color: var(--ia-theme-secondary-background-color, #fff);
|
|
258
|
+
border: 1px solid #999;
|
|
259
|
+
border-left: 0;
|
|
260
|
+
padding: 0 var(--search-bar-internal-padding--, 5px) 0 5px;
|
|
261
|
+
min-width: 30px;
|
|
262
|
+
height: 100%;
|
|
263
|
+
cursor: pointer;
|
|
264
|
+
display: flex;
|
|
265
|
+
align-items: center;
|
|
266
|
+
justify-content: center;
|
|
267
|
+
flex-shrink: 0;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
#search-button img {
|
|
271
|
+
width: 18px;
|
|
272
|
+
height: 18px;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
.search-button-loading-icon {
|
|
276
|
+
--icon-width: 20px;
|
|
277
|
+
margin-top: 2px;
|
|
278
|
+
}
|
|
277
279
|
`;
|
|
278
280
|
return [themeStyles, ownStyles];
|
|
279
281
|
}
|
|
@@ -1 +1 @@
|
|
|
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;IACb,eAAe,EAAE,iBAAiB;IAClC,eAAe,EAAE,iBAAiB;CACnC,CAAC;AAGK,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,UAAU;IAA5C;;QAIL,+CAA+C;QACpB,eAAU,GAAqB,EAAE,CAAC;QAK7D,4CAA4C;QAChB,gBAAW,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC;QAExD,uCAAuC;QACV,kBAAa,GAAG,KAAK,CAAC;QAEnD,0EAA0E;QAC7C,iBAAY,GAAG,KAAK,CAAC;QAElD,8DAA8D;QACjC,YAAO,GAAG,KAAK,CAAC;IAoR/C,CAAC;IA/QC,8EAA8E;IAC9E,IAAY,gBAAgB;QAC1B,OAAO,IAAI,CAAC,gBAAgB,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,E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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA+GpB,CAAC;QAEF,OAAO,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IAClC,CAAC;CACF,CAAA;AAtS6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAAgB;AAGhB;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;uDAAmC;AAGjC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6DAA2B;AAG1B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,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,CAwS/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.categories}\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 * The display label for the currently selected category.\r\n */\r\n private get selectedCategoryLabel(): string | TemplateResult {\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: 1.4rem;\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
|
+
{"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;AAKnE,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;IACb,eAAe,EAAE,iBAAiB;IAClC,eAAe,EAAE,iBAAiB;CACnC,CAAC;AAGK,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,UAAU;IAA5C;;QAIL,+CAA+C;QACpB,eAAU,GAAqB,EAAE,CAAC;QAK7D,4CAA4C;QAChB,gBAAW,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC;QAExD,uCAAuC;QACV,kBAAa,GAAG,KAAK,CAAC;QAEnD,0EAA0E;QAC7C,iBAAY,GAAG,KAAK,CAAC;QAElD,8DAA8D;QACjC,YAAO,GAAG,KAAK,CAAC;IAsR/C,CAAC;IAjRC,8EAA8E;IAC9E,IAAY,gBAAgB;QAC1B,OAAO,IAAI,CAAC,gBAAgB,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC;IACjE,CAAC;IAED,MA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA+GpB,CAAC;QAEF,OAAO,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IAClC,CAAC;CACF,CAAA;AAxS6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAAgB;AAGhB;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;uDAAmC;AAGjC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6DAA2B;AAG1B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,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,CA0S/B","sourcesContent":["import { msg } from '@lit/localize';\nimport { css, html, LitElement, nothing, TemplateResult } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport type { IaClearableTextInput } from '@internetarchive/ia-clearable-text-input';\nimport type { optionInterface } from '@internetarchive/ia-dropdown';\nimport type { SearchCategory, SearchRequestedDetail } from './models';\n\nimport themeStyles from '@src/themes/theme-styles';\nimport searchIcon from './search.svg';\n\nimport '@internetarchive/ia-clearable-text-input';\nimport '@internetarchive/ia-dropdown';\nimport '@src/elements/ia-status-indicator/ia-status-indicator';\n\n/**\n * Event names emitted by this component\n */\nconst Events = {\n CategoryChanged: 'categoryChanged',\n SearchRequested: 'searchRequested',\n};\n\n@customElement('ia-dropdown-search-bar')\nexport class IADropdownSearchBar extends LitElement {\n /** The query that appears in the search bar */\n @property({ type: String }) query?: string;\n\n /** Dropdown menu options (tab IDs + labels) */\n @property({ type: Array }) categories: SearchCategory[] = [];\n\n /** The currently selected dropdown category ID */\n @property({ type: String }) selectedCategory?: string;\n\n /** Placeholder text for the search input */\n @property({ type: String }) placeholder = msg('Search');\n\n /** Whether to use the mobile layout */\n @property({ type: Boolean }) useMobileView = false;\n\n /** Whether to hide the category dropdown to the left of the search bar */\n @property({ type: Boolean }) hideDropdown = false;\n\n /** Whether the search button should show its loading state */\n @property({ type: Boolean }) loading = false;\n\n @query('#search-input')\n private searchInput!: IaClearableTextInput;\n\n /** The effective selected category, falling back to the first in the list. */\n private get resolvedCategory(): string {\n return this.selectedCategory ?? this.categories?.[0]?.id ?? '';\n }\n\n render(): TemplateResult {\n return html`\n <div id=\"container\" part=\"container\" role=\"search\">\n <div\n id=\"main-bar\"\n part=\"main-bar\"\n class=${this.hideDropdown ? 'no-dropdown' : nothing}\n >\n ${this.hideDropdown ? nothing : this.dropdownTemplate}\n ${this.textBoxTemplate} ${this.searchButtonTemplate}\n </div>\n </div>\n `;\n }\n\n /**\n * Template for the category dropdown on the left side of the search bar.\n */\n private get dropdownTemplate(): TemplateResult {\n return html`\n <ia-dropdown\n id=\"category-dropdown\"\n part=\"category-dropdown\"\n displayCaret\n includeSelectedOption\n closeOnSelect\n closeOnEscape\n closeOnBackdropClick\n openViaButton\n .selectedOption=${this.resolvedCategory}\n .options=${this.categories}\n @optionSelected=${this.handleCategorySelected}\n >\n <span slot=\"dropdown-label\" part=\"category-dropdown-label\"\n >${this.selectedCategoryLabel}</span\n >\n </ia-dropdown>\n `;\n }\n\n /**\n * Template for the main text entry box of the search bar.\n */\n private get textBoxTemplate(): TemplateResult {\n return html`\n <ia-clearable-text-input\n id=\"search-input\"\n part=\"search-input\"\n .value=${this.spacedQuery}\n placeholder=${this.placeholder}\n clearButtonScreenReaderLabel=${msg('Clear search query')}\n screenReaderLabel=${msg(\n 'Search the Archive. Filters and Advanced Search available below.',\n )}\n @clear=${this.searchFieldCleared}\n @submit=${this.handleSubmit}\n ></ia-clearable-text-input>\n `;\n }\n\n /**\n * Template for the \"magnifying glass\" search button to the right of the search bar.\n */\n private get searchButtonTemplate(): TemplateResult {\n return html`\n <button\n id=\"search-button\"\n part=\"search-button\"\n class=${this.loading ? 'loading' : nothing}\n type=\"button\"\n aria-label=${msg('Search')}\n @click=${this.handleSubmit}\n >\n ${this.loading\n ? html`<ia-status-indicator\n mode=\"loading\"\n class=\"search-button-loading-icon\"\n ></ia-status-indicator>`\n : html`<img src=${searchIcon} alt=\"\" />`}\n </button>\n `;\n }\n\n /**\n * The display label for the currently selected category.\n */\n private get selectedCategoryLabel(): string | TemplateResult {\n const match = this.categories.find((c) => c.id === this.resolvedCategory);\n return match?.label ?? this.resolvedCategory;\n }\n\n /**\n * The current search query with +'s replaced by spaces.\n */\n private get spacedQuery(): string {\n return this.query?.replace(/\\+/g, ' ') ?? '';\n }\n\n /**\n * Handler for when the search bar's clear button is pressed.\n */\n private searchFieldCleared(): void {\n if (this.query) {\n this.emitSearchRequested();\n }\n }\n\n /**\n * Handler for Enter key or search button click.\n */\n private handleSubmit(): void {\n this.emitSearchRequested();\n }\n\n /**\n * Handler for when the user selects a category from the dropdown.\n *\n * Sets `selectedCategory` locally for immediate visual feedback (semi-controlled\n * pattern). The parent also binds this property and may re-set it on re-render.\n */\n private handleCategorySelected(\n e: CustomEvent<{ option: optionInterface }>,\n ): void {\n const newCategoryId = e.detail.option.id;\n if (newCategoryId === this.resolvedCategory) return;\n\n this.selectedCategory = newCategoryId;\n\n // On next tick, focus the text input bar (seemingly fails in Safari without the delay)\n setTimeout(() => this.searchInput.focus());\n\n this.dispatchEvent(\n new CustomEvent<string>(Events.CategoryChanged, {\n detail: newCategoryId,\n }),\n );\n }\n\n /**\n * Emits a `searchRequested` event with the current query and category.\n */\n private emitSearchRequested(): void {\n this.dispatchEvent(\n new CustomEvent<SearchRequestedDetail>(Events.SearchRequested, {\n detail: {\n query: this.searchInput.value,\n category: this.resolvedCategory,\n },\n }),\n );\n }\n\n static get styles() {\n const ownStyles = css`\n :host {\n --search-bar-height--: var(--search-bar-height, 30px);\n --search-bar-width--: var(--search-bar-width, 300px);\n --search-bar-internal-padding--: var(--padding-sm, 5px);\n --clear-button-offset--: var(--clear-button-offset, 0);\n }\n\n #container {\n display: inline-block;\n width: var(--search-bar-width--);\n }\n\n #main-bar {\n display: flex;\n height: var(--search-bar-height--, 30px);\n flex: 1;\n }\n\n #category-dropdown {\n display: flex;\n flex-shrink: 0;\n height: 100%;\n box-sizing: border-box;\n\n background-color: #f5f5f7;\n border: 1px solid #999;\n border-radius: 5px 0 0 5px;\n\n --dropdownMainButtonPadding: 0 var(--search-bar-internal-padding--, 5px);\n --dropdownBgColor: #2c2c2c;\n --dropdownTextColor: #fff;\n --dropdownBorderColor: #ddd;\n --dropdownCaretColor: var(--ia-theme-primary-text-color, #2c2c2c);\n --dropdownHoverBgColor: rgba(255, 255, 255, 0.3);\n --dropdownHoverTextColor: #fff;\n --dropdownSelectedBgColor: rgba(255, 255, 255, 0.3);\n --dropdownSelectedTextColor: #fff;\n --dropdownWhiteSpace: nowrap;\n --dropdownOffsetTop: 2px;\n --caretHeight: 8px;\n --caretWidth: 12px;\n --caretPadding: 0 0 0 5px;\n --dropdownFontSize: inherit;\n --dropdownBorderRadius: 4px;\n --buttonSlotPaddingRight: 0;\n --dropdownTextAlign: left;\n }\n\n #category-dropdown [slot='dropdown-label'] {\n color: var(--ia-theme-primary-text-color, #2c2c2c);\n font-size: 1.4rem;\n font-family: inherit;\n white-space: nowrap;\n }\n\n .no-dropdown #search-input {\n border-left: 1px solid #999;\n border-radius: 5px 0 0 5px;\n overflow: hidden;\n }\n\n #search-input {\n width: 100%;\n height: 100%;\n box-sizing: border-box;\n border-top: 1px solid #999;\n border-bottom: 1px solid #999;\n font-size: inherit;\n\n --input-height: calc(var(--search-bar-height--) - 2px);\n --input-padding: 0 var(--search-bar-internal-padding--, 5px);\n --input-background-color: var(\n --ia-theme-secondary-background-color,\n #fff\n );\n --input-border-radius: 0;\n --input-border-width: 0;\n --input-box-shadow: none;\n --input-focused-box-shadow: none;\n --input-font-size: auto;\n --clear-button-top: var(--clear-button-offset--, 0);\n --clear-button-right: 2px;\n }\n\n #search-button {\n appearance: none;\n box-sizing: border-box;\n border-radius: 0 5px 5px 0;\n background-color: var(--ia-theme-secondary-background-color, #fff);\n border: 1px solid #999;\n border-left: 0;\n padding: 0 var(--search-bar-internal-padding--, 5px) 0 5px;\n min-width: 30px;\n height: 100%;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n }\n\n #search-button img {\n width: 18px;\n height: 18px;\n }\n\n .search-button-loading-icon {\n --icon-width: 20px;\n margin-top: 2px;\n }\n `;\n\n return [themeStyles, ownStyles];\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../../../src/elements/ia-dropdown-search-bar/models.ts"],"names":[],"mappings":"","sourcesContent":["import { TemplateResult } from
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../../../src/elements/ia-dropdown-search-bar/models.ts"],"names":[],"mappings":"","sourcesContent":["import { TemplateResult } from 'lit';\n\n/**\n * A category to include in the dropdown. Consists of an internal `id` string that is\n * emitted on selection, and a human-readable `label` to display in the dropdown.\n */\nexport type SearchCategory = {\n id: string;\n label: string | TemplateResult;\n};\n\n/**\n * Detail object emitted with `searchRequested` events.\n */\nexport type SearchRequestedDetail = {\n query: string;\n category: string;\n};\n"]}
|
|
@@ -28,25 +28,25 @@ let IAOTPForm = class IAOTPForm extends LitElement {
|
|
|
28
28
|
this.numericOnly = true;
|
|
29
29
|
}
|
|
30
30
|
render() {
|
|
31
|
-
return html `
|
|
32
|
-
<div class="input-section">
|
|
33
|
-
<ia-otp-input
|
|
34
|
-
.numChars=${this.numPasscodeChars}
|
|
35
|
-
?numericOnly=${this.numericOnly}
|
|
31
|
+
return html `
|
|
32
|
+
<div class="input-section">
|
|
33
|
+
<ia-otp-input
|
|
34
|
+
.numChars=${this.numPasscodeChars}
|
|
35
|
+
?numericOnly=${this.numericOnly}
|
|
36
36
|
?disabled=${this.validationStatus === 'loading' ||
|
|
37
|
-
this.validationStatus === 'success'}
|
|
38
|
-
></ia-otp-input>
|
|
39
|
-
<ia-status-indicator
|
|
40
|
-
part="status-indicator"
|
|
41
|
-
.mode=${this.validationStatus}
|
|
42
|
-
></ia-status-indicator>
|
|
43
|
-
</div>
|
|
37
|
+
this.validationStatus === 'success'}
|
|
38
|
+
></ia-otp-input>
|
|
39
|
+
<ia-status-indicator
|
|
40
|
+
part="status-indicator"
|
|
41
|
+
.mode=${this.validationStatus}
|
|
42
|
+
></ia-status-indicator>
|
|
43
|
+
</div>
|
|
44
44
|
${this.validationStatus === 'error'
|
|
45
|
-
? html `<p class="error-msg">
|
|
46
|
-
${msg('The code entered is invalid or expired')}
|
|
45
|
+
? html `<p class="error-msg">
|
|
46
|
+
${msg('The code entered is invalid or expired')}
|
|
47
47
|
</p>`
|
|
48
|
-
: nothing}
|
|
49
|
-
${this.resendCodeButtonTemplate}
|
|
48
|
+
: nothing}
|
|
49
|
+
${this.resendCodeButtonTemplate}
|
|
50
50
|
`;
|
|
51
51
|
}
|
|
52
52
|
willUpdate(changed) {
|
|
@@ -62,19 +62,19 @@ let IAOTPForm = class IAOTPForm extends LitElement {
|
|
|
62
62
|
/* The button to display to send a new code */
|
|
63
63
|
get resendCodeButtonTemplate() {
|
|
64
64
|
return this.newCodeSending
|
|
65
|
-
? html `<span part="new-code-message" class="new-code-msg"
|
|
66
|
-
>${msg('Emailing...')}</span
|
|
65
|
+
? html `<span part="new-code-message" class="new-code-msg"
|
|
66
|
+
>${msg('Emailing...')}</span
|
|
67
67
|
>`
|
|
68
|
-
: html `
|
|
69
|
-
<button
|
|
70
|
-
class="new-code-btn link"
|
|
71
|
-
part="new-code-button"
|
|
68
|
+
: html `
|
|
69
|
+
<button
|
|
70
|
+
class="new-code-btn link"
|
|
71
|
+
part="new-code-button"
|
|
72
72
|
.disabled=${this.validationStatus === 'loading' ||
|
|
73
|
-
this.validationStatus === 'success'}
|
|
74
|
-
@click=${this.handleNewCodeRequested}
|
|
75
|
-
>
|
|
76
|
-
${msg('Email me another code')}
|
|
77
|
-
</button>
|
|
73
|
+
this.validationStatus === 'success'}
|
|
74
|
+
@click=${this.handleNewCodeRequested}
|
|
75
|
+
>
|
|
76
|
+
${msg('Email me another code')}
|
|
77
|
+
</button>
|
|
78
78
|
`;
|
|
79
79
|
}
|
|
80
80
|
/* Emits an event to request the new code */
|
|
@@ -88,67 +88,67 @@ let IAOTPForm = class IAOTPForm extends LitElement {
|
|
|
88
88
|
static get styles() {
|
|
89
89
|
return [
|
|
90
90
|
themeStyles,
|
|
91
|
-
css `
|
|
92
|
-
:host {
|
|
93
|
-
--font-size-standard--: var(--font-size-standard);
|
|
94
|
-
--font-size-lg--: var(--font-size-lg);
|
|
95
|
-
--color-success--: var(--color-success);
|
|
96
|
-
--color-danger--: var(--color-danger);
|
|
97
|
-
--link-color--: var(--link-color);
|
|
98
|
-
|
|
99
|
-
display: flex;
|
|
100
|
-
flex-direction: column;
|
|
101
|
-
align-items: center;
|
|
102
|
-
justify-content: center;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
.input-section {
|
|
106
|
-
display: flex;
|
|
107
|
-
flex-direction: row;
|
|
108
|
-
align-items: center;
|
|
109
|
-
justify-content: center;
|
|
110
|
-
gap: 5px;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
ia-status-indicator {
|
|
114
|
-
--icon-width: calc(var(--font-size-lg--) * 1.33);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
.error-msg {
|
|
118
|
-
margin-top: 10px;
|
|
119
|
-
font-size: var(--font-size-standard--);
|
|
120
|
-
color: var(--color-danger--);
|
|
121
|
-
margin-bottom: -10px;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
.new-code-btn {
|
|
125
|
-
font-family: inherit;
|
|
126
|
-
font-size: var(--font-size-standard--);
|
|
127
|
-
display: block;
|
|
128
|
-
width: fit-content;
|
|
129
|
-
margin-top: 10px;
|
|
130
|
-
border: 0;
|
|
131
|
-
padding: 0;
|
|
132
|
-
appearance: none;
|
|
133
|
-
background: none;
|
|
134
|
-
color: var(--link-color--);
|
|
135
|
-
text-decoration: none;
|
|
136
|
-
cursor: pointer;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
.new-code-btn:hover,
|
|
140
|
-
.new-code-btn:focus {
|
|
141
|
-
text-decoration: underline;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
.new-code-msg {
|
|
145
|
-
margin-top: 10px;
|
|
146
|
-
font-size: var(--font-size-standard--);
|
|
147
|
-
color: var(--link-color--);
|
|
148
|
-
display: flex;
|
|
149
|
-
flex-direction: column;
|
|
150
|
-
justify-content: center;
|
|
151
|
-
}
|
|
91
|
+
css `
|
|
92
|
+
:host {
|
|
93
|
+
--font-size-standard--: var(--font-size-standard);
|
|
94
|
+
--font-size-lg--: var(--font-size-lg);
|
|
95
|
+
--color-success--: var(--color-success);
|
|
96
|
+
--color-danger--: var(--color-danger);
|
|
97
|
+
--link-color--: var(--link-color);
|
|
98
|
+
|
|
99
|
+
display: flex;
|
|
100
|
+
flex-direction: column;
|
|
101
|
+
align-items: center;
|
|
102
|
+
justify-content: center;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.input-section {
|
|
106
|
+
display: flex;
|
|
107
|
+
flex-direction: row;
|
|
108
|
+
align-items: center;
|
|
109
|
+
justify-content: center;
|
|
110
|
+
gap: 5px;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
ia-status-indicator {
|
|
114
|
+
--icon-width: calc(var(--font-size-lg--) * 1.33);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.error-msg {
|
|
118
|
+
margin-top: 10px;
|
|
119
|
+
font-size: var(--font-size-standard--);
|
|
120
|
+
color: var(--color-danger--);
|
|
121
|
+
margin-bottom: -10px;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.new-code-btn {
|
|
125
|
+
font-family: inherit;
|
|
126
|
+
font-size: var(--font-size-standard--);
|
|
127
|
+
display: block;
|
|
128
|
+
width: fit-content;
|
|
129
|
+
margin-top: 10px;
|
|
130
|
+
border: 0;
|
|
131
|
+
padding: 0;
|
|
132
|
+
appearance: none;
|
|
133
|
+
background: none;
|
|
134
|
+
color: var(--link-color--);
|
|
135
|
+
text-decoration: none;
|
|
136
|
+
cursor: pointer;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.new-code-btn:hover,
|
|
140
|
+
.new-code-btn:focus {
|
|
141
|
+
text-decoration: underline;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.new-code-msg {
|
|
145
|
+
margin-top: 10px;
|
|
146
|
+
font-size: var(--font-size-standard--);
|
|
147
|
+
color: var(--link-color--);
|
|
148
|
+
display: flex;
|
|
149
|
+
flex-direction: column;
|
|
150
|
+
justify-content: center;
|
|
151
|
+
}
|
|
152
152
|
`,
|
|
153
153
|
];
|
|
154
154
|
}
|