@internetarchive/elements 0.2.1 → 0.2.2-webdev-8356.1
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/README.md +139 -32
- package/dist/src/elements/ia-combo-box/ia-combo-box.d.ts +3 -3
- package/dist/src/elements/ia-combo-box/ia-combo-box.d.ts.map +1 -1
- package/dist/src/elements/ia-combo-box/ia-combo-box.js +14 -10
- package/dist/src/elements/ia-combo-box/ia-combo-box.js.map +1 -1
- package/dist/src/elements/ia-zendesk-widget/ia-zendesk-widget.d.ts +78 -0
- package/dist/src/elements/ia-zendesk-widget/ia-zendesk-widget.d.ts.map +1 -0
- package/dist/src/elements/ia-zendesk-widget/ia-zendesk-widget.js +221 -0
- package/dist/src/elements/ia-zendesk-widget/ia-zendesk-widget.js.map +1 -0
- package/dist/src/elements/ia-zendesk-widget/loader-icon.svg +26 -0
- package/dist/src/elements/ia-zendesk-widget/question-icon.svg +27 -0
- package/dist/src/elements/index.d.ts +1 -0
- package/dist/src/elements/index.d.ts.map +1 -1
- package/dist/src/elements/index.js +1 -0
- package/dist/src/elements/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# 📚 _elements_ 🏛️
|
|
2
2
|
|
|
3
|
+
## Demo
|
|
4
|
+
|
|
5
|
+
<https://internetarchive.github.io/elements>
|
|
6
|
+
|
|
3
7
|
## Installation
|
|
4
8
|
|
|
5
9
|
```zsh
|
|
@@ -16,6 +20,71 @@ import "@internetarchive/elements/ia-button/ia-button";
|
|
|
16
20
|
<ia-button @click=() => alert('Clicked!')>Click Me</ia-button>
|
|
17
21
|
```
|
|
18
22
|
|
|
23
|
+
## Build Dependencies
|
|
24
|
+
|
|
25
|
+
We use SVGs in this repo, which not all build systems support out of the box. Here's how to support SVGs:
|
|
26
|
+
|
|
27
|
+
### Webpack
|
|
28
|
+
|
|
29
|
+
Add this to your Webpack config:
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
module: {
|
|
33
|
+
rules: [
|
|
34
|
+
{
|
|
35
|
+
test: /\.svg/,
|
|
36
|
+
type: 'asset/resource',
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### @web/test-runner
|
|
43
|
+
|
|
44
|
+
Install rollup image plugins:
|
|
45
|
+
|
|
46
|
+
```shell
|
|
47
|
+
npm i -D @rollup/plugin-image @web/dev-server-rollup
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Update config:
|
|
51
|
+
|
|
52
|
+
```js
|
|
53
|
+
import rollupImage from '@rollup/plugin-image';
|
|
54
|
+
import { rollupAdapter } from '@web/dev-server-rollup';
|
|
55
|
+
|
|
56
|
+
export default ({
|
|
57
|
+
mimeTypes: {
|
|
58
|
+
'**/*.scss': 'js',
|
|
59
|
+
'**/*.css': 'js',
|
|
60
|
+
'**/*.svg': 'js',
|
|
61
|
+
'**/*.json': 'js',
|
|
62
|
+
},
|
|
63
|
+
plugins: [rollupAdapter(rollupImage())],
|
|
64
|
+
})
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Jest
|
|
68
|
+
|
|
69
|
+
Create `SVGMock` file, ie `tests/jest/mocks/svg.js`
|
|
70
|
+
|
|
71
|
+
```js
|
|
72
|
+
/**
|
|
73
|
+
* Mock for SVG imports in Jest tests.
|
|
74
|
+
*/
|
|
75
|
+
export class SVGMock {}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Add to Jest config:
|
|
79
|
+
|
|
80
|
+
```json
|
|
81
|
+
"jest": {
|
|
82
|
+
"moduleNameMapper": {
|
|
83
|
+
"\\.svg$": "<rootDir>/tests/jest/mocks/svg.js",
|
|
84
|
+
},
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
19
88
|
## Development
|
|
20
89
|
|
|
21
90
|
```zsh
|
|
@@ -23,10 +92,41 @@ npm i
|
|
|
23
92
|
npm run dev
|
|
24
93
|
```
|
|
25
94
|
|
|
95
|
+
## Versioning and Publishing
|
|
96
|
+
|
|
97
|
+
### Prerelease Version
|
|
98
|
+
|
|
99
|
+
1. Create prerelease version on your branch:
|
|
100
|
+
1. `npm version prerelease --preid=<some_prefix>`
|
|
101
|
+
2. If you use JIRA, recommend using the ticket number, ie `--preid=webdev-1234`
|
|
102
|
+
3. This will also create a `git` tag
|
|
103
|
+
2. Push the tag that was created in the `npm version` step
|
|
104
|
+
3. Publish prerelease to npm:
|
|
105
|
+
1. Go to the [Element release page](https://github.com/internetarchive/elements/releases)
|
|
106
|
+
2. Tap `Draft a new release` button
|
|
107
|
+
3. Select the tag you created
|
|
108
|
+
4. Tap `Generate release notes`
|
|
109
|
+
5. Select `Set as a pre-release`
|
|
110
|
+
6. Tap `Publish release`
|
|
111
|
+
|
|
112
|
+
### Release Version
|
|
113
|
+
|
|
114
|
+
1. Use [Semantic Versioning](https://semver.org) to determine release number
|
|
115
|
+
2. On the `main` branch:
|
|
116
|
+
1. Run `npm version [major | minor | patch]`
|
|
117
|
+
2. `git push && git push --tags`
|
|
118
|
+
3. Publish release to npm:
|
|
119
|
+
1. Go to the [Element release page](https://github.com/internetarchive/elements/releases)
|
|
120
|
+
2. Tap `Draft a new release` button
|
|
121
|
+
3. Select the tag you created
|
|
122
|
+
4. Tap `Generate release notes`
|
|
123
|
+
5. Select `Set as the latest release`
|
|
124
|
+
6. Tap `Publish release`
|
|
125
|
+
|
|
26
126
|
## Adding a Component
|
|
27
127
|
|
|
28
128
|
### Structure
|
|
29
|
-
Each component has its own directory in `src/elements` (or `src/labs` if it's still in development). The basic structure looks like this, though components can have additional files and directories if
|
|
129
|
+
Each component has its own directory in `src/elements` (or `src/labs` if it's still in development). The basic structure looks like this, though components can have additional files and directories if needed. Take a look at other elements to see what they each contain.
|
|
30
130
|
```
|
|
31
131
|
src
|
|
32
132
|
- elements
|
|
@@ -42,61 +142,68 @@ To demo your component, we have a component catalog that you can add your demo t
|
|
|
42
142
|
|
|
43
143
|
We have a story template you can use for consistency. [More info on `story-template`](#story-template). The easiest way to use this is to copy an existing story and modify it for your needs.
|
|
44
144
|
|
|
45
|
-
|
|
145
|
+
Your story will be discovered by `/demo/app-root.ts` and added to the page.
|
|
46
146
|
|
|
47
147
|
#### Story Template<a id="story-template"></a>
|
|
48
148
|
|
|
49
149
|
The story template is a component you can use in your story to demo your component. This lets us present them in a consistent way.
|
|
50
150
|
|
|
51
|
-
It has
|
|
151
|
+
It has a few main configurations:
|
|
52
152
|
|
|
53
153
|
*Properties*
|
|
54
154
|
- `elementTag` (_string_) your component's name, ie `ia-button`
|
|
55
|
-
- `exampleUsage` (_string_) your element's example usage, displays it with syntax highlighting
|
|
56
155
|
- `labs` (_boolean_) if your component is in `labs` to update links
|
|
156
|
+
- `styleInputSettings` (_StyleInputSettings array_) the style options to display, in the appropriate format
|
|
157
|
+
- `propInputSettings` (_PropInputSettings array_) the prop options to display, in the appropriate format
|
|
158
|
+
|
|
159
|
+
**Note:** If the type of prop input you want to use isn't yet available in the `propInputSettings` options,
|
|
160
|
+
you can instead slot in custom property settings by using `slot="settings"`, adding a button to apply the
|
|
161
|
+
properties, and passing in a `customExampleUsage` (see `ia-snow-story.ts` for a sample implementation).
|
|
57
162
|
|
|
58
163
|
*Slots*
|
|
59
164
|
- `demo` put your component demo in here
|
|
60
|
-
- `settings` put your component settings in here
|
|
61
165
|
|
|
62
166
|
Here's an example:
|
|
63
167
|
```typescript
|
|
64
168
|
import '@demo/story-template';
|
|
169
|
+
|
|
170
|
+
// Style options to display
|
|
171
|
+
const styleInputSettings: StyleInputSettings[] = [
|
|
172
|
+
{
|
|
173
|
+
label: 'Button BG color',
|
|
174
|
+
cssVariable: '--button-background-color',
|
|
175
|
+
defaultValue: 'blue', // Should match the actual fallback value for the variable
|
|
176
|
+
inputType: 'color',
|
|
177
|
+
},
|
|
178
|
+
];
|
|
179
|
+
|
|
180
|
+
// Prop options to display
|
|
181
|
+
const propInputSettings: PropInputSettings[] = [
|
|
182
|
+
{
|
|
183
|
+
label: 'Mode',
|
|
184
|
+
inputType: 'radio',
|
|
185
|
+
propertyName: 'mode', // Should match the name of the property from its @property() declaration
|
|
186
|
+
radioOptions: ['primary', 'secondary', 'danger'],
|
|
187
|
+
defaultValue: 'primary', // Should match the actual default value from the @property() declaration, if any
|
|
188
|
+
},
|
|
189
|
+
]
|
|
65
190
|
...
|
|
66
191
|
render() {
|
|
67
192
|
return html`
|
|
68
|
-
<story-template
|
|
193
|
+
<story-template
|
|
194
|
+
elementTag="ia-button"
|
|
195
|
+
elementClassName="IAButton"
|
|
196
|
+
.styleInputData=${{settings: this.styleInputSettings}}
|
|
197
|
+
.propInputData=${{settings: this.propInputSettings}}
|
|
198
|
+
>
|
|
69
199
|
<div slot="demo">
|
|
70
|
-
<ia-button @click=${() => alert('Button clicked!')}
|
|
71
|
-
|
|
72
|
-
>
|
|
73
|
-
</div>
|
|
74
|
-
|
|
75
|
-
<div slot="settings">
|
|
76
|
-
<table>
|
|
77
|
-
<tr>
|
|
78
|
-
<td>Color</td>
|
|
79
|
-
<td><input type="color" value="#007bff" id="color" /></td>
|
|
80
|
-
</tr>
|
|
81
|
-
</table>
|
|
82
|
-
<button @click=${this.apply}>Apply</button>
|
|
200
|
+
<ia-button @click=${() => alert('Button clicked!')}>
|
|
201
|
+
Click Me
|
|
202
|
+
</ia-button>
|
|
83
203
|
</div>
|
|
84
204
|
</story-template>
|
|
85
205
|
`;
|
|
86
206
|
}
|
|
87
|
-
|
|
88
|
-
// return a string of your element's usage and it will
|
|
89
|
-
// be displayed with syntax highlighting
|
|
90
|
-
// can be dynamic
|
|
91
|
-
private get exampleUsage(): string {
|
|
92
|
-
return `<ia-button @click=\${() => alert('Button clicked!')}>
|
|
93
|
-
Click Me
|
|
94
|
-
</ia-button>`;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
private apply(): void {
|
|
98
|
-
// update component settings based on settings change
|
|
99
|
-
}
|
|
100
207
|
```
|
|
101
208
|
|
|
102
209
|
## Component Inventory
|
|
@@ -137,9 +137,9 @@ export declare class IAComboBox extends LitElement {
|
|
|
137
137
|
* The text that we are currently using the filter the dropdown menu options.
|
|
138
138
|
*/
|
|
139
139
|
private filterText;
|
|
140
|
-
private mainWidgetRow
|
|
141
|
-
private textInput
|
|
142
|
-
private optionsList
|
|
140
|
+
private mainWidgetRow?;
|
|
141
|
+
private textInput?;
|
|
142
|
+
private optionsList?;
|
|
143
143
|
static formAssociated: boolean;
|
|
144
144
|
static shadowRootOptions: ShadowRootInit;
|
|
145
145
|
private internals;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ia-combo-box.d.ts","sourceRoot":"","sources":["../../../../src/elements/ia-combo-box/ia-combo-box.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EACV,OAAO,EACP,cAAc,EACd,cAAc,EAEd,cAAc,EACf,MAAM,KAAK,CAAC;AAQb,OAAO,EAGL,KAAK,kBAAkB,EAEvB,KAAK,sBAAsB,EAE3B,KAAK,gBAAgB,EACtB,MAAM,UAAU,CAAC;AA0BlB;;;;GAIG;AACH,qBACa,UAAW,SAAQ,UAAU;IACxC;;;;;;;;;;OAUG;IACwB,OAAO,EAAE,gBAAgB,EAAE,CAAM;IAE5D;;OAEG;IACyB,WAAW,CAAC,EAAE,MAAM,CAAC;IAEjD;;;;;;;;;;OAUG;IACyB,QAAQ,EAAE,kBAAkB,CAAoB;IAE5E;;;;OAIG;IAEH,sBAAsB,SAA4B;IAElD;;;;;;;;;;;;;;;;;;;;OAoBG;IACyB,MAAM,EAAE,sBAAsB,CAClC;IAExB;;;OAGG;IAEH,aAAa,UAAS;IAEtB;;;;OAIG;IACyC,IAAI,UAAS;IAEzD;;;OAGG;IAGH;;;;;OAKG;IAEH,aAAa,UAAS;IAEtB;;;;OAIG;IAEH,QAAQ,UAAS;IAEjB;;;OAGG;IACyC,SAAS,UAAS;IAE9D;;OAEG;IACyC,IAAI,UAAS;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kBAAkB;IAY1B,OAAO,CAAC,eAAe;IAQvB,OAAO,CAAC,eAAe;IAYvB;;OAEG;IACH,OAAO,KAAK,OAAO,GAElB;IAED;;;OAGG;IACH,OAAO,KAAK,qBAAqB,GAEhC;IAED;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;IAiC3B;;;OAGG;IACH,OAAO,KAAK,aAAa,GAExB;IAED;;OAEG;IACH,OAAO,CAAC,YAAY;IAIpB;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IAO1B;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAY5B;;;OAGG;IACH,OAAO,CAAC,4BAA4B;IAUpC;;;OAGG;IACH,OAAO,CAAC,sBAAsB;IAsB9B;;OAEG;IACH,OAAO,KAAK,mBAAmB,GAE9B;IAED;;OAEG;IACH,OAAO,KAAK,kBAAkB,GAE7B;IAED;;OAEG;IACH,OAAO,KAAK,iBAAiB,GAE5B;IAED;;OAEG;IACH,IAAI,cAAc,IAAI,gBAAgB,GAAG,IAAI,CAG5C;IAED;;;OAGG;IACH,OAAO,KAAK,gBAAgB,GAG3B;IAED;;;OAGG;IACH,OAAO,KAAK,kBAAkB,GAG7B;IAED,MAAM,KAAK,MAAM,IAAI,cAAc,CAuKlC;CACF"}
|
|
@@ -262,12 +262,12 @@ let IAComboBox = class IAComboBox extends LitElement {
|
|
|
262
262
|
if (changed.has('open')) {
|
|
263
263
|
if (this.open) {
|
|
264
264
|
this.positionOptionsMenu();
|
|
265
|
-
this.optionsList
|
|
266
|
-
this.optionsList
|
|
265
|
+
this.optionsList?.showPopover?.();
|
|
266
|
+
this.optionsList?.classList.add('visible');
|
|
267
267
|
}
|
|
268
268
|
else {
|
|
269
|
-
this.optionsList
|
|
270
|
-
this.optionsList
|
|
269
|
+
this.optionsList?.hidePopover?.();
|
|
270
|
+
this.optionsList?.classList.remove('visible');
|
|
271
271
|
}
|
|
272
272
|
}
|
|
273
273
|
}
|
|
@@ -534,8 +534,9 @@ let IAComboBox = class IAComboBox extends LitElement {
|
|
|
534
534
|
* Handler for `input` events in the text input box.
|
|
535
535
|
*/
|
|
536
536
|
async handleTextBoxInput() {
|
|
537
|
-
|
|
538
|
-
this.
|
|
537
|
+
const value = this.textInput?.value ?? '';
|
|
538
|
+
this.enteredText = value;
|
|
539
|
+
this.setFilterText(value);
|
|
539
540
|
this.openOptionsMenu();
|
|
540
541
|
await this.updateComplete;
|
|
541
542
|
this.highlightFirstOption();
|
|
@@ -641,7 +642,7 @@ let IAComboBox = class IAComboBox extends LitElement {
|
|
|
641
642
|
*/
|
|
642
643
|
handleClearButtonClick() {
|
|
643
644
|
this.clearSelectedOption();
|
|
644
|
-
this.textInput
|
|
645
|
+
this.textInput?.focus();
|
|
645
646
|
this.openOptionsMenu();
|
|
646
647
|
}
|
|
647
648
|
/**
|
|
@@ -650,7 +651,7 @@ let IAComboBox = class IAComboBox extends LitElement {
|
|
|
650
651
|
handleFocus() {
|
|
651
652
|
if (this.behavior !== 'select-only') {
|
|
652
653
|
// Always keep focus on the text input if it's editable
|
|
653
|
-
this.textInput
|
|
654
|
+
this.textInput?.focus();
|
|
654
655
|
}
|
|
655
656
|
this.hasFocus = true;
|
|
656
657
|
this.losingFocus = false;
|
|
@@ -763,7 +764,7 @@ let IAComboBox = class IAComboBox extends LitElement {
|
|
|
763
764
|
this.highlightedOption = option;
|
|
764
765
|
await this.updateComplete;
|
|
765
766
|
const { optionsList, highlightedElement } = this;
|
|
766
|
-
if (!highlightedElement)
|
|
767
|
+
if (!highlightedElement || !optionsList)
|
|
767
768
|
return;
|
|
768
769
|
// TODO: Not ideal as this will trigger a reflow...
|
|
769
770
|
// But may not be an issue in practice given the highlight isn't changing in a hot loop.
|
|
@@ -837,7 +838,8 @@ let IAComboBox = class IAComboBox extends LitElement {
|
|
|
837
838
|
* matched. Defaults to `true`.
|
|
838
839
|
*/
|
|
839
840
|
setTextValue(value, setFilter = true) {
|
|
840
|
-
this.textInput
|
|
841
|
+
if (this.textInput)
|
|
842
|
+
this.textInput.value = value;
|
|
841
843
|
this.enteredText = value;
|
|
842
844
|
if (setFilter)
|
|
843
845
|
this.setFilterText(value);
|
|
@@ -905,6 +907,8 @@ let IAComboBox = class IAComboBox extends LitElement {
|
|
|
905
907
|
*/
|
|
906
908
|
positionOptionsMenu() {
|
|
907
909
|
const { mainWidgetRow, optionsList } = this;
|
|
910
|
+
if (!mainWidgetRow || !optionsList)
|
|
911
|
+
return;
|
|
908
912
|
const mainWidgetRect = mainWidgetRow.getBoundingClientRect();
|
|
909
913
|
const { innerHeight, scrollX, scrollY } = window;
|
|
910
914
|
const usableHeightAbove = mainWidgetRect.top;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ia-combo-box.js","sourceRoot":"","sources":["../../../../src/elements/ia-combo-box/ia-combo-box.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,IAAI,EACJ,UAAU,EACV,OAAO,EAGP,GAAG,GAEJ,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC,OAAO,EACL,QAAQ,EACR,aAAa,GAMd,MAAM,UAAU,CAAC;AAClB,OAAO,WAAW,MAAM,0BAA0B,CAAC;AAEnD,OAAO,eAAe,MAAM,oBAAoB,CAAC;AACjD,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAC7C,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC;;;GAGG;AACH,MAAM,cAAc,GAClB;IACE,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI;IACf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;AAezD;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC;iDACnD;AAQtB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;4CAClD;AAM2B;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;6CAAmB;AAKlB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;wCAAc;AAOb;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;4CAAkB;AAMjB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;4CAAkB;AASjC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yCAA6B;AAKvC;IAAhB,KAAK,EAAE;4CAA0B;AAQjB;IAAhB,KAAK,EAAE;qDAA2D;AAKlD;IAAhB,KAAK,EAAE;+CAAkC;AAKzB;IAAhB,KAAK,EAAE;8CAAiC;AAEN;IAAlC,KAAK,CAAC,kBAAkB,CAAC;iDAAwC;AAEpC;IAA7B,KAAK,CAAC,aAAa,CAAC;6CAAsC;AAE3B;IAA/B,KAAK,CAAC,eAAe,CAAC;+CAAwC;AAjKpD,UAAU;IADtB,aAAa,CAAC,cAAc,CAAC;GACjB,UAAU,CA0yCtB","sourcesContent":["import {\n html,\n LitElement,\n nothing,\n TemplateResult,\n CSSResultGroup,\n css,\n PropertyValues,\n} from 'lit';\nimport { customElement, property, state, query } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { live } from 'lit/directives/live.js';\nimport { when } from 'lit/directives/when.js';\nimport { msg } from '@lit/localize';\n\nimport {\n hasAnyOf,\n isSubsequence,\n type IAComboBoxBehavior,\n type IAComboBoxFilterFunction,\n type IAComboBoxFilterOption,\n type IAComboBoxFilterPreset,\n type IAComboBoxOption,\n} from './models';\nimport themeStyles from '@src/themes/theme-styles';\n\nimport caretClosedIcon from './caret-closed.svg';\nimport caretOpenIcon from './caret-open.svg';\nimport clearIcon from './clear.svg';\n\n/**\n * Map from filter preset keys to their associated filtering function.\n * @see {@linkcode IAComboBox.filter}\n */\nconst FILTER_PRESETS: Record<IAComboBoxFilterPreset, IAComboBoxFilterFunction> =\n {\n all: () => true,\n prefix: (filterText, optionText) => optionText.startsWith(filterText),\n suffix: (filterText, optionText) => optionText.endsWith(filterText),\n substring: (filterText, optionText) => optionText.includes(filterText),\n subsequence: isSubsequence,\n };\n\nconst DEFAULT_BEHAVIOR: IAComboBoxBehavior = 'list';\nconst DEFAULT_FILTER_PRESET: IAComboBoxFilterPreset = 'substring';\n\nconst STRING_IDENTITY_FN = (str: string): string => str;\nconst STRING_LOWER_CASE_FN = (str: string): string => str.toLocaleLowerCase();\n\n/**\n * A flexible component combining the features of a dropdown menu and a text input,\n * allowing users to either select from a predefined list of options or type\n * freeform text to filter down & find specific options.\n */\n@customElement('ia-combo-box')\nexport class IAComboBox extends LitElement {\n /**\n * Array of options representing values that this combo box can take.\n *\n * If this combo box's `behavior` property is `select-only` or `list`, these options\n * represent _all_ of the allowed values that the user may choose from.\n *\n * If this combo box's `behavior` property is `freeform`, this array simply represents\n * a non-exhaustive list of _suggested_ values, which the user may either choose from\n * or enter their own value.\n * @see {@linkcode IAComboBox.behavior}\n */\n @property({ type: Array }) options: IAComboBoxOption[] = [];\n\n /**\n * Optional placeholder text to display in the combo box when no option is selected.\n */\n @property({ type: String }) placeholder?: string;\n\n /**\n * What style of behavior to use for the combo box.\n *\n * Currently, the options are\n * - `select-only` (behaving similar to a `<select>`, disallowing text entry and only\n * allowing selection from the predefined, unfiltered options)\n * - `list` (the default, allowing text entry to filter the dropdown list, but still\n * requiring values to be set from the predefined options)\n * - `freeform` (allows text entry to filter the dropdown list, and also allows setting\n * custom values not included in the list)\n */\n @property({ type: String }) behavior: IAComboBoxBehavior = DEFAULT_BEHAVIOR;\n\n /**\n * Maximum number of options to include in the autocomplete menu when filtering.\n *\n * Default value is `Infinity`, presenting all matching options regardless of count.\n */\n @property({ type: Number, attribute: 'max-autocomplete-entries' })\n maxAutocompleteEntries = Number.POSITIVE_INFINITY;\n\n /**\n * Specifies how the options should be filtered when text is entered into the combo box.\n * Has no effect if `behavior` is `select-only`, as the component is not text-editable.\n *\n * Default is `substring`, showing only options whose `text` contains the value entered\n * as a substring at any position. The possible preset options are:\n * - `all`: Does not filter the dropdown entries. They will always all be shown (up to\n * the limit specified by `maxAutocompleteEntries`).\n * - `prefix`: Only includes options whose text _starts_ with the entered value.\n * - `suffix`: Only includes options whose text _ends_ with the entered value.\n * - `substring`: Only includes options whose text contains the entered value as a\n * contiguous substring.\n * - `subsequence`: Only shows options whose text has the characters of the entered\n * value in order, though they do not need to be contiguous.\n * E.g., `ace` is a subsequence of `archive` (but not a substring).\n *\n * If custom filtering outside of these presets is desired, an arbitrary filtering function\n * may instead be bound to this property directly.\n *\n * @see {@link IAComboBox.caseSensitive} to enable case-sensitive filtering.\n */\n @property({ type: String }) filter: IAComboBoxFilterOption =\n DEFAULT_FILTER_PRESET;\n\n /**\n * Whether filtering should be case-sensitive. Default is `false`, performing only\n * case-insensitive filtering.\n */\n @property({ type: Boolean, reflect: true, attribute: 'case-sensitive' })\n caseSensitive = false;\n\n /**\n * Whether the filtered options should be listed in lexicographically-sorted order,\n * respecting the current `caseSensitive` setting.\n * Default is `false`, displaying them in the same order as the provided options array.\n */\n @property({ type: Boolean, reflect: true }) sort = false;\n\n /**\n * Whether the combo box allows multiple options to be selected at once.\n * Default is `false`, allowing only a single option to be selected.\n */\n // @property({ type: Boolean, reflect: true }) multiple = false; // TODO\n\n /**\n * Whether pressing the Up/Down arrow keys should wrap focus back to the text input box\n * while focus is already on the first/last option, respectively.\n *\n * Default is `false`, doing nothing upon such key presses.\n */\n @property({ type: Boolean, reflect: true, attribute: 'wrap-arrow-keys' })\n wrapArrowKeys = false;\n\n /**\n * Whether the options list should remain open after an option is selected.\n *\n * Default is `false`, closing the options list when a selection is made.\n */\n @property({ type: Boolean, reflect: true, attribute: 'stay-open' })\n stayOpen = false;\n\n /**\n * Whether the combo box shows a clear button when a value is selected.\n * Default is `false`.\n */\n @property({ type: Boolean, reflect: true }) clearable = false;\n\n /**\n * Whether the combo box's option menu is currently expanded. Default is `false`.\n */\n @property({ type: Boolean, reflect: true }) open = false;\n\n /**\n * Whether the combo box should be rendered in its disabled state, preventing all\n * interactions such as editing the text field or opening the options menu.\n * Default is `false`.\n */\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n /**\n * If used within a form, whether this combo box is required to have a value selected\n * before the form may be submitted. Default is `false`.\n */\n @property({ type: Boolean, reflect: true }) required = false;\n\n /**\n * For `select-only` or `list` behavior, this value is the ID of the selected option,\n * or `null` if there is no selection.\n *\n * For `freeform` behavior, this may be any string entered into the text field, and\n * need not correspond to an option ID.\n */\n @property({ type: String }) value: string | null = null;\n\n /**\n * Whether any part of this component currently has focus.\n */\n @state() private hasFocus = false;\n\n /**\n * Which option in the dropdown menu is currently highlighted by the user. Not to be\n * confused with the _selected_ option that has been committed, this field only\n * represents the user's current navigation state within the menu, which they may\n * subsequently select by, e.g., hitting Enter.\n */\n @state() private highlightedOption: IAComboBoxOption | null = null;\n\n /**\n * The text than has been entered into the text input box.\n */\n @state() private enteredText: string = '';\n\n /**\n * The text that we are currently using the filter the dropdown menu options.\n */\n @state() private filterText: string = '';\n\n @query('#main-widget-row') private mainWidgetRow!: HTMLDivElement;\n\n @query('#text-input') private textInput!: HTMLInputElement;\n\n @query('#options-list') private optionsList!: HTMLUListElement;\n\n static formAssociated = true;\n\n static shadowRootOptions: ShadowRootInit = {\n ...LitElement.shadowRootOptions,\n delegatesFocus: true,\n };\n\n private internals: ElementInternals;\n\n /**\n * Set when part of the component blurs, and cleared when any part of it is focused.\n * If still set on the next tick after a blur event, this serves as a signal that focus\n * has moved away from the component as a whole and should be closed.\n */\n private losingFocus = false;\n\n /**\n * A cache of the mapping from option IDs to their corresponding options, so that\n * we can more efficiently look up options by ID.\n */\n private optionsByID: Map<string, IAComboBoxOption> = new Map();\n\n /**\n * A cache of the values against which each option should be filtered, to minimize\n * the work needed at filter time to handle case-insensitivity etc.\n */\n private optionFilteringValues: Map<IAComboBoxOption, string> = new Map();\n\n /**\n * A cache of the current set of options that is pre-sorted if the component's\n * `sort` flag is set, or as provided otherwise. Just ensures we don't have to\n * sort all the options again every time we filter them.\n */\n private optionsRespectingSortFlag: IAComboBoxOption[] = [];\n\n /**\n * A cache of the current set of filtered options, so that we don't have to\n * recalculate it unnecessarily whenever the component is opened/closed/etc.\n */\n private filteredOptions: IAComboBoxOption[] = [];\n\n constructor() {\n super();\n this.internals = this.attachInternals();\n }\n\n render(): TemplateResult | typeof nothing {\n const mainWidgetClasses = classMap({\n disabled: this.disabled,\n focused: this.hasFocus,\n });\n\n return html`\n <div id=\"container\" part=\"container\">\n ${this.labelTemplate}\n <div id=\"main-widget-row\" class=${mainWidgetClasses} part=\"combo-box\">\n ${this.textInputTemplate}\n ${this.clearable ? this.clearButtonTemplate : nothing}\n ${this.caretButtonTemplate}\n </div>\n ${this.optionsListTemplate}\n </div>\n `;\n }\n\n willUpdate(changed: PropertyValues): void {\n if (changed.has('options') || changed.has('caseSensitive')) {\n // Need to update the cached values against which our filters are matched\n this.rebuildOptionFilteringValues();\n }\n\n if (changed.has('options')) {\n // Need to update the cached mapping of IDs to options\n this.rebuildOptionIDMap();\n }\n\n if (changed.has('options') || changed.has('sort')) {\n // Sort the options upfront if needed\n this.rebuildSortedOptions();\n }\n\n if (\n hasAnyOf(changed, [\n 'options',\n 'behavior',\n 'maxAutocompleteEntries',\n 'filter',\n 'filterText',\n 'caseSensitive',\n 'sort',\n ])\n ) {\n // If anything about the options or how they are filtered has changed, we need to\n // update our cache of the filtered options\n this.rebuildFilteredOptions();\n }\n\n if (changed.has('open')) {\n if (this.open) {\n // Highlight selection on open, if possible\n if (this.value) this.setHighlightedOption(this.selectedOption);\n } else {\n // Clear highlight on close\n this.setHighlightedOption(null);\n }\n }\n\n if (changed.has('required')) {\n this.updateFormValidity();\n }\n }\n\n updated(changed: PropertyValues): void {\n if (changed.has('value')) {\n this.handleValueChanged();\n }\n\n if (changed.has('options')) {\n // May need to clear the value if it no longer corresponds to an option\n if (this.behavior !== 'freeform' && !this.selectedOption) {\n this.clearSelectedOption();\n }\n }\n\n if (changed.has('open')) {\n if (this.open) {\n this.positionOptionsMenu();\n this.optionsList.showPopover?.();\n this.optionsList.classList.add('visible');\n } else {\n this.optionsList.hidePopover?.();\n this.optionsList.classList.remove('visible');\n }\n }\n }\n\n //\n // TEMPLATES\n //\n\n /**\n * Template for the main label for the combo box.\n *\n * Uses the contents of the `label` named slot as the label text.\n */\n private get labelTemplate(): TemplateResult {\n return html`\n <label id=\"label\" for=\"text-input\" part=\"label\">\n <slot name=\"label\"></slot>\n </label>\n `;\n }\n\n /**\n * Template for the text input field that users can edit to filter the available\n * options or (if freeform behavior) to enter a custom value.\n */\n private get textInputTemplate(): TemplateResult {\n const textInputClasses = classMap({\n 'clear-padding': this.clearable && !this.shouldShowClearButton,\n });\n\n return html`\n <input\n type=\"text\"\n id=\"text-input\"\n class=${textInputClasses}\n .value=${live(this.enteredText)}\n placeholder=${ifDefined(this.placeholder)}\n part=\"text-input\"\n role=\"combobox\"\n autocomplete=\"off\"\n aria-autocomplete=\"list\"\n aria-controls=\"options-list\"\n aria-expanded=${this.open}\n aria-activedescendant=${ifDefined(this.highlightedOption?.id)}\n ?readonly=${this.behavior === 'select-only'}\n ?disabled=${this.disabled}\n ?required=${this.required}\n @click=${this.handleComboBoxClick}\n @keydown=${this.handleComboBoxKeyDown}\n @input=${this.handleTextBoxInput}\n @focus=${this.handleFocus}\n @blur=${this.handleBlur}\n />\n `;\n }\n\n /**\n * Template for the clear button that is shown when the `clearable` property\n * is true.\n */\n private get clearButtonTemplate(): TemplateResult {\n return html`\n <button\n type=\"button\"\n id=\"clear-button\"\n part=\"clear-button\"\n tabindex=\"-1\"\n ?hidden=${!this.shouldShowClearButton}\n @click=${this.handleClearButtonClick}\n >\n <span class=\"sr-only\">${msg('Clear')}</span>\n <slot name=\"clear-button\">\n <img\n class=\"icon clear-icon\"\n part=\"icon clear-icon\"\n src=${clearIcon}\n alt=\"\"\n aria-hidden=\"true\"\n />\n </slot>\n </button>\n `;\n }\n\n /**\n * Template for the caret open/closed icons to show beside the text input.\n * The icons are wrapped in named slots to allow consumers to override them.\n */\n private get caretTemplate(): TemplateResult {\n return html`\n <slot name=\"caret-closed\" ?hidden=${this.open}>\n <img\n class=\"icon caret-icon\"\n part=\"icon caret-icon\"\n src=${caretClosedIcon}\n alt=\"\"\n aria-hidden=\"true\"\n />\n </slot>\n <slot name=\"caret-open\" ?hidden=${!this.open}>\n <img\n class=\"icon caret-icon\"\n part=\"icon caret-icon\"\n src=${caretOpenIcon}\n alt=\"\"\n aria-hidden=\"true\"\n />\n </slot>\n `;\n }\n\n /**\n * Template for the caret button to be shown beside the text input.\n */\n private get caretButtonTemplate(): TemplateResult {\n return html`\n <button\n type=\"button\"\n id=\"caret-button\"\n part=\"caret-button\"\n tabindex=\"-1\"\n aria-controls=\"options-list\"\n aria-expanded=${this.open}\n ?disabled=${this.disabled}\n @click=${this.handleComboBoxClick}\n @keydown=${this.handleComboBoxKeyDown}\n @focus=${this.handleFocus}\n @blur=${this.handleBlur}\n >\n <span class=\"sr-only\">${msg('Toggle options')}</span>\n ${this.caretTemplate}\n </button>\n `;\n }\n\n /**\n * Template for the options list that is displayed when the combo box is open.\n */\n private get optionsListTemplate(): TemplateResult {\n return html`\n <ul\n id=\"options-list\"\n part=\"options-list\"\n role=\"listbox\"\n tabindex=\"-1\"\n popover\n ?hidden=${!this.open}\n @focus=${this.handleFocus}\n @blur=${this.handleBlur}\n >\n <slot name=\"options-list-top\"></slot>\n ${when(this.open, () => this.optionTemplates)}\n <slot name=\"options-list-bottom\"></slot>\n </ul>\n `;\n }\n\n /**\n * Array of templates for all of the filtered options to be shown in the options menu.\n */\n private get optionTemplates(): TemplateResult[] {\n // If there are no options matching the filter, just show a message saying as much.\n if (this.filteredOptions.length === 0 && this.maxAutocompleteEntries > 0) {\n return [this.emptyOptionsTemplate];\n }\n\n // Otherwise build a list item for each filtered option\n return this.filteredOptions.map((opt) => {\n const isHighlighted = opt === this.highlightedOption;\n const optionClasses = classMap({\n option: true,\n highlight: isHighlighted,\n });\n\n return html`\n <li\n id=${opt.id}\n class=${optionClasses}\n part=\"option ${isHighlighted ? 'highlight' : ''}\"\n role=\"option\"\n tabindex=\"-1\"\n @pointerenter=${this.handleOptionPointerEnter}\n @pointermove=${this.handleOptionPointerMove}\n @click=${this.handleOptionClick}\n @focus=${this.handleFocus}\n @blur=${this.handleBlur}\n >\n ${opt.content ?? opt.text}\n </li>\n `;\n });\n }\n\n /**\n * Info message shown in the listbox when no options match the entered text.\n * Renders within an `empty-options` named slot so that its content can be customized.\n */\n private get emptyOptionsTemplate(): TemplateResult {\n return html`\n <li id=\"empty-options\" part=\"empty-options\">\n <slot name=\"empty-options\">${msg('No matching options')}</slot>\n </li>\n `;\n }\n\n //\n // EVENT HANDLERS & MUTATORS\n //\n\n /**\n * Handler for when the pointer device enters an option element in the dropdown.\n */\n private handleOptionPointerEnter(e: PointerEvent): void {\n this.handleOptionPointerMove(e);\n }\n\n /**\n * Handler for when the pointer device is moved within an option in the dropdown.\n */\n private handleOptionPointerMove(e: PointerEvent): void {\n const target = e.currentTarget as HTMLLIElement;\n const option = this.getOptionFor(target.id);\n if (option) this.setHighlightedOption(option);\n }\n\n /**\n * Handler for when the user clicks on an option in the dropdown.\n */\n private handleOptionClick(e: PointerEvent): void {\n const target = e.currentTarget as HTMLLIElement;\n const option = this.getOptionFor(target.id);\n if (option) {\n this.setSelectedOption(option.id);\n if (!this.stayOpen) this.closeOptionsMenu();\n }\n }\n\n /**\n * Handler for `keydown` events on various special keys.\n */\n private handleComboBoxKeyDown(e: KeyboardEvent): void {\n switch (e.key) {\n case 'Enter':\n this.handleEnterPressed();\n break;\n case 'Escape':\n this.handleEscapePressed();\n break;\n case 'ArrowUp':\n if (e.altKey) {\n this.handleAltUpArrowPressed();\n } else {\n this.handleUpArrowPressed();\n }\n break;\n case 'ArrowDown':\n if (e.altKey) {\n this.handleAltDownArrowPressed();\n } else {\n this.handleDownArrowPressed();\n }\n break;\n case 'Tab':\n this.handleTabPressed();\n return; // Never cancel the default behavior for Tab\n case ' ':\n this.handleSpacePressed(e);\n return; // Let the Space handler decide whether to cancel defaults/propagation\n default:\n // Do nothing and leave defaults/propagation in place for all other keys\n return;\n }\n\n e.stopPropagation();\n e.preventDefault();\n }\n\n /**\n * Handler for `input` events in the text input box.\n */\n private async handleTextBoxInput(): Promise<void> {\n this.enteredText = this.textInput.value;\n this.setFilterText(this.textInput.value);\n this.openOptionsMenu();\n\n await this.updateComplete;\n this.highlightFirstOption();\n }\n\n /**\n * Handler for when the Enter key is pressed\n */\n private handleEnterPressed(): void {\n // Just open the options menu if it's currently closed\n if (!this.open) {\n this.openOptionsMenu();\n return;\n }\n\n if (this.highlightedOption) {\n // If an option is highlighted, select it\n this.setSelectedOption(this.highlightedOption.id);\n } else if (this.behavior === 'freeform') {\n // Otherwise, in the freeform behavior we just accept the current value regardless\n this.setValue(this.enteredText);\n }\n\n // Close the options list if needed\n if (!this.stayOpen) this.open = false;\n }\n\n /**\n * Handler for when the Escape key is pressed\n */\n private handleEscapePressed(): void {\n // Close the options menu if it's currently open\n if (this.open) {\n this.closeOptionsMenu();\n return;\n }\n\n // Otherwise, deselect any selected option & clear any filter text\n this.clearSelectedOption();\n }\n\n /**\n * Handler for when the Up Arrow key is pressed (without modifiers).\n * @see {@linkcode handleAltUpArrowPressed()} for behavior under the Alt modifier.\n */\n private handleUpArrowPressed(): void {\n if (!this.open) this.openOptionsMenu();\n this.highlightPreviousOption();\n }\n\n /**\n * Handler for when the Down Arrow key is pressed (without modifiers).\n * @see {@linkcode handleAltDownArrowPressed()} for behavior under the Alt modifier.\n */\n private handleDownArrowPressed(): void {\n if (!this.open) this.openOptionsMenu();\n this.highlightNextOption();\n }\n\n /**\n * Handler for when the Alt + Up Arrow key combo is pressed\n */\n private handleAltUpArrowPressed(): void {\n this.closeOptionsMenu();\n }\n\n /**\n * Handler for when the Alt + Down Arrow key combo is pressed\n */\n private handleAltDownArrowPressed(): void {\n this.openOptionsMenu();\n }\n\n /**\n * Handler for when the Tab key is pressed\n */\n private handleTabPressed(): void {\n if (this.highlightedOption) {\n this.setSelectedOption(this.highlightedOption.id);\n if (!this.stayOpen) this.open = false;\n }\n }\n\n /**\n * Handler for when the Space key is handleTabPressed\n */\n private handleSpacePressed(e: KeyboardEvent): void {\n if (this.behavior === 'select-only') {\n if (!this.open) {\n this.openOptionsMenu();\n } else if (this.highlightedOption) {\n this.setSelectedOption(this.highlightedOption.id);\n if (!this.stayOpen) this.open = false;\n }\n\n e.stopPropagation();\n e.preventDefault();\n }\n }\n\n /**\n * Handler for clicks on the combo box input field or caret button.\n */\n private handleComboBoxClick(): void {\n this.toggleOptionsMenu();\n }\n\n /**\n * Handler for when the clear button is clicked.\n */\n private handleClearButtonClick(): void {\n this.clearSelectedOption();\n this.textInput.focus();\n this.openOptionsMenu();\n }\n\n /**\n * Handler for when any part of the combo box receives focus.\n */\n private handleFocus(): void {\n if (this.behavior !== 'select-only') {\n // Always keep focus on the text input if it's editable\n this.textInput.focus();\n }\n this.hasFocus = true;\n this.losingFocus = false;\n }\n\n /**\n * Handler for when any part of the combo box loses focus.\n */\n private handleBlur(): void {\n this.hasFocus = false;\n this.losingFocus = true;\n\n // On the next tick, check whether we've actually lost focus to some other element,\n // or just had a momentary internal focus switch. If it's the former, we should\n // close the menu and possibly make a selection (depending on desired behavior).\n setTimeout(() => {\n if (this.losingFocus && !this.shadowRoot?.activeElement) {\n this.losingFocus = false;\n this.closeOptionsMenu();\n\n if (this.behavior === 'list') {\n this.setTextValue(this.selectedOption?.text ?? '', false);\n } else if (\n this.behavior === 'freeform' &&\n (this.enteredText || this.value)\n ) {\n this.setValue(this.enteredText);\n }\n }\n }, 0);\n }\n\n /**\n * Handler for when the `value` of this component is changed externally\n */\n private handleValueChanged(): void {\n // Setting a null value always clears the component\n if (this.value == null) {\n if (this.enteredText) this.setTextValue('', false);\n return;\n }\n\n const option = this.getOptionFor(this.value);\n\n if (this.behavior === 'freeform') {\n const newText = option?.text ?? this.value;\n if (newText !== this.enteredText) {\n this.setTextValue(newText);\n }\n return;\n }\n\n // In non-freeform modes, the value must correspond to a predefined option.\n // If it doesn't, just clear the component.\n if (!option) {\n this.clearSelectedOption();\n return;\n }\n\n if (this.enteredText !== option.text) {\n this.setTextValue(option.text, false);\n this.setFilterText('');\n }\n }\n\n /**\n * Highlights the first option shown in the filtered list.\n */\n private highlightFirstOption(): void {\n this.setHighlightedOption(this.firstFilteredOption);\n }\n\n /**\n * Highlights the last option shown in the filtered list.\n */\n private highlightLastOption(): void {\n this.setHighlightedOption(this.lastFilteredOption);\n }\n\n /**\n * Highlights the option before the currently highlighted one in the list, or the last one\n * if none is highlighted.\n */\n private highlightPreviousOption(): void {\n const { filteredOptions, lastFilteredIndex } = this;\n\n // If no option is highlighted yet, highlight the last one\n if (!this.highlightedOption) {\n this.highlightLastOption();\n return;\n }\n\n // Otherwise, move to the previous option (wrapping if needed)\n const { highlightedIndex } = this;\n const previousIndex =\n this.wrapArrowKeys && highlightedIndex === 0\n ? lastFilteredIndex // Wrap around to the end\n : Math.max(highlightedIndex - 1, 0);\n this.setHighlightedOption(filteredOptions[previousIndex]);\n }\n\n /**\n * Highlights the option after the currently highlighted one in the list, or the first one\n * if none is highlighted.\n */\n private highlightNextOption(): void {\n const { filteredOptions, lastFilteredIndex } = this;\n\n // If no option is highlighted yet, highlight the first one\n if (!this.highlightedOption) {\n this.highlightFirstOption();\n return;\n }\n\n // Otherwise, move to the next option (wrapping if needed)\n const { highlightedIndex } = this;\n const nextIndex =\n this.wrapArrowKeys && highlightedIndex === lastFilteredIndex\n ? 0 // Wrap back to the start\n : Math.min(highlightedIndex + 1, lastFilteredIndex);\n this.setHighlightedOption(filteredOptions[nextIndex]);\n }\n\n /**\n * Highlights the given option and scrolls it into view if necessary.\n * If `null` is provided, any current highlight will be cleared.\n */\n private async setHighlightedOption(\n option: IAComboBoxOption | null,\n ): Promise<void> {\n this.highlightedOption = option;\n await this.updateComplete;\n\n const { optionsList, highlightedElement } = this;\n if (!highlightedElement) return;\n\n // TODO: Not ideal as this will trigger a reflow...\n // But may not be an issue in practice given the highlight isn't changing in a hot loop.\n // If we have issues with this let's see if we can hook up an IntersectionObserver.\n const elmtRect = highlightedElement.getBoundingClientRect();\n const listRect = optionsList.getBoundingClientRect();\n if (elmtRect.top < listRect.top || elmtRect.bottom > listRect.bottom) {\n highlightedElement.scrollIntoView({ block: 'nearest' });\n }\n }\n\n /**\n * Changes this combo box's selected option to the one matching the specified ID.\n *\n * Throws a `RangeError` if given an ID that does not correspond to any option\n * held by this combo box.\n */\n setSelectedOption(id: string): void {\n const option = this.getOptionFor(id);\n if (!option) throw new RangeError('Unknown option ID');\n\n const prevValue = this.value;\n this.value = option.id;\n this.internals.setFormValue(this.value);\n this.setTextValue(option.text, false);\n this.setFilterText('');\n if (this.value !== prevValue) this.emitChangeEvent();\n\n // Invoke the option's select callback if defined\n option.onSelected?.(option);\n }\n\n /**\n * Clears any currently selected option from this combo box, setting it to null\n * and clearing any value in the text box.\n */\n clearSelectedOption(): void {\n const prevValue = this.value;\n this.value = null;\n this.internals.setFormValue(this.value);\n this.setTextValue('');\n if (this.value !== prevValue) this.emitChangeEvent();\n }\n\n /**\n * Set this combo box's value to the given string if possible.\n *\n * In `freeform` behavior, this always succeeds.\n *\n * In other behavior modes, this method is identical to `setSelectedOption`,\n * interpreting the input as an option ID and throwing an error if no such\n * option exists.\n *\n * @see {@linkcode IAComboBox.setSelectedOption}\n */\n private setValue(value: string): void {\n if (this.behavior === 'freeform') {\n const prevValue = this.value;\n this.value = value;\n this.internals.setFormValue(this.value);\n this.setTextValue(value);\n if (this.value !== prevValue) this.emitChangeEvent();\n } else {\n this.setSelectedOption(value);\n }\n }\n\n /**\n * Changes the value of the text input box, and updates the filter accordingly.\n *\n * @param setFilter Whether to also update the filter text against which options are\n * matched. Defaults to `true`.\n */\n private setTextValue(value: string, setFilter = true): void {\n this.textInput.value = value;\n this.enteredText = value;\n if (setFilter) this.setFilterText(value);\n }\n\n /**\n * Sets the current filter text based on the provided string. The resulting filter\n * text might not exactly match the provided value, depending on the current case\n * sensitivity.\n */\n private setFilterText(baseFilterText: string): void {\n const { caseTransform } = this;\n this.filterText = caseTransform(baseFilterText);\n }\n\n openOptionsMenu(): void {\n this.open = true;\n this.emitToggleEvent();\n }\n\n closeOptionsMenu(): void {\n this.open = false;\n this.emitToggleEvent();\n }\n\n toggleOptionsMenu(): void {\n this.open = !this.open;\n this.emitToggleEvent();\n }\n\n private updateFormValidity(): void {\n if (this.required && !this.value) {\n this.internals.setValidity(\n { valueMissing: true },\n msg('A value is required'),\n );\n } else {\n // All good\n this.internals.setValidity({});\n }\n }\n\n private emitChangeEvent(): void {\n this.dispatchEvent(\n new CustomEvent<string | null>('change', {\n detail: this.value,\n }),\n );\n }\n\n private emitToggleEvent(): void {\n this.dispatchEvent(\n new CustomEvent<boolean>('toggle', {\n detail: this.open,\n }),\n );\n }\n\n //\n // HELPERS\n //\n\n /**\n * True iff no selection has been made and no text has been entered.\n */\n private get isEmpty(): boolean {\n return !this.selectedOption && !this.enteredText;\n }\n\n /**\n * We only show the clear button when the `clearable` property is set\n * and the combo box is neither empty nor disabled.\n */\n private get shouldShowClearButton(): boolean {\n return this.clearable && !this.disabled && !this.isEmpty;\n }\n\n /**\n * Sets the size and position of the options menu to match the size and position of\n * the combo box widget. Prefers to position below the main widget, but will flip\n * to the top if needed & if there's more room above.\n */\n private positionOptionsMenu(): void {\n const { mainWidgetRow, optionsList } = this;\n const mainWidgetRect = mainWidgetRow.getBoundingClientRect();\n\n const { innerHeight, scrollX, scrollY } = window;\n const usableHeightAbove = mainWidgetRect.top;\n const usableHeightBelow = innerHeight - mainWidgetRect.bottom;\n\n const maxHeightVar = `var(--combo-box-list-max-height--)`;\n\n const optionsListStyles: Record<string, string> = {\n top: `${mainWidgetRect.bottom + scrollY}px`,\n left: `${mainWidgetRect.left + scrollX}px`,\n width: `var(--combo-box-list-width--, ${mainWidgetRect.width}px)`,\n maxHeight: `min(${maxHeightVar}, ${usableHeightBelow}px)`,\n };\n\n Object.assign(optionsList.style, optionsListStyles);\n\n // Wait a tick for it to appear, then check if we should flip it upwards instead\n setTimeout(() => {\n const listRect = optionsList.getBoundingClientRect();\n const overflowingViewport = listRect.bottom >= innerHeight;\n const moreSpaceAbove = usableHeightAbove > usableHeightBelow;\n if (overflowingViewport && moreSpaceAbove) {\n optionsList.style.top = 'auto';\n optionsList.style.bottom = `${innerHeight - mainWidgetRect.top - scrollY}px`;\n optionsList.style.maxHeight = `min(${maxHeightVar}, ${usableHeightAbove}px)`;\n }\n }, 0);\n }\n\n /**\n * A function to transform option & filter text based on the combo box's\n * current case sensitivity.\n */\n private get caseTransform(): (text: string) => string {\n return this.caseSensitive ? STRING_IDENTITY_FN : STRING_LOWER_CASE_FN;\n }\n\n /**\n * Returns the combo box option having the given ID, or null if none exists.\n */\n private getOptionFor(id: string): IAComboBoxOption | null {\n return this.optionsByID.get(id) ?? null;\n }\n\n /**\n * Clears any previously-cached mapping of IDs to options, and rebuilds the\n * map based on the current set of options.\n */\n private rebuildOptionIDMap(): void {\n this.optionsByID.clear();\n for (const option of this.options) {\n this.optionsByID.set(option.id, option);\n }\n }\n\n /**\n * Applies any required sort to the options and caches the result to be used\n * at filter/display time.\n */\n private rebuildSortedOptions(): void {\n if (this.sort) {\n this.optionsRespectingSortFlag = [...this.options].sort((a, b) => {\n const aValue = this.optionFilteringValues.get(a) as string;\n const bValue = this.optionFilteringValues.get(b) as string;\n return aValue.localeCompare(bValue);\n });\n } else {\n this.optionsRespectingSortFlag = this.options;\n }\n }\n\n /**\n * Clears any previously-cached option filtering values, and rebuilds the\n * map based on the current component properties.\n */\n private rebuildOptionFilteringValues(): void {\n this.optionFilteringValues.clear();\n\n const { caseTransform } = this;\n for (const option of this.options) {\n const filteringValue = caseTransform(option.text);\n this.optionFilteringValues.set(option, filteringValue);\n }\n }\n\n /**\n * Returns the filtered array of options by applying the specified filter function\n * with the current filter text, up to the limit specified by `maxAutocompleteEntries`.\n */\n private rebuildFilteredOptions(): void {\n // We don't want to filter the results in select-only mode\n const resolvedFilterOption =\n this.behavior === 'select-only' ? 'all' : this.filter;\n\n const filterFn =\n typeof resolvedFilterOption === 'string'\n ? FILTER_PRESETS[resolvedFilterOption]\n : resolvedFilterOption;\n\n const filtered = this.optionsRespectingSortFlag\n .filter((opt) => {\n const optionFilteringValue = this.optionFilteringValues.get(opt);\n if (!optionFilteringValue) return false;\n\n return filterFn(this.filterText, optionFilteringValue, opt);\n })\n .slice(0, this.maxAutocompleteEntries);\n\n this.filteredOptions = filtered;\n }\n\n /**\n * The first option appearing in the filtered list, or null if there are none.\n */\n private get firstFilteredOption(): IAComboBoxOption | null {\n return this.filteredOptions[0] ?? null;\n }\n\n /**\n * The last option appearing in the filtered list, or null if there are none.\n */\n private get lastFilteredOption(): IAComboBoxOption | null {\n return this.filteredOptions[this.lastFilteredIndex] ?? null;\n }\n\n /**\n * The index of the last filtered option, or -1 if no options match the filter.\n */\n private get lastFilteredIndex(): number {\n return this.filteredOptions.length - 1;\n }\n\n /**\n * The IAComboBoxOption that is currently selected, or null if none is selected.\n */\n get selectedOption(): IAComboBoxOption | null {\n if (this.value == null) return null;\n return this.getOptionFor(this.value);\n }\n\n /**\n * The index of the currently highlighted option in the filtered list, or -1 if\n * no option is currently highlighted.\n */\n private get highlightedIndex(): number {\n if (!this.highlightedOption) return -1;\n return this.filteredOptions.indexOf(this.highlightedOption);\n }\n\n /**\n * The HTML element representing the currently-highlighted option, or null if\n * no option is highlighted.\n */\n private get highlightedElement(): HTMLElement | null {\n if (!this.highlightedOption) return null;\n return this.shadowRoot!.getElementById(this.highlightedOption.id);\n }\n\n static get styles(): CSSResultGroup {\n const ownStyles = css`\n :host {\n --combo-box-width--: var(--combo-box-width);\n --combo-box-padding--: var(--padding-sm);\n --combo-box-list-width--: var(--combo-box-list-width, unset);\n --combo-box-list-max-height--: var(--combo-box-list-max-height, 250px);\n }\n\n #container {\n display: inline-block;\n width: var(--combo-box-width--);\n }\n\n #label {\n display: block;\n width: fit-content;\n }\n\n #main-widget-row {\n display: inline-flex;\n align-items: stretch;\n flex-wrap: nowrap;\n background: white;\n border: 1px solid black;\n width: 100%;\n }\n\n #main-widget-row:not(.focused, .disabled):hover,\n #main-widget-row:not(.focused, .disabled):active {\n background: #fafafa;\n }\n\n #main-widget-row.focused {\n outline: black auto 1px;\n outline-offset: 3px;\n }\n\n #main-widget-row.disabled {\n background: #f4f4f4;\n border-color: #a0a0a0;\n color: #404040;\n }\n\n #text-input {\n appearance: none;\n background: transparent;\n border: none;\n padding: var(--combo-box-padding--);\n padding-right: 0;\n width: 100%;\n font-size: inherit;\n font-family: inherit;\n font-weight: inherit;\n font-style: inherit;\n color: inherit;\n outline: none;\n text-overflow: ellipsis;\n }\n\n #text-input.clear-padding {\n padding-right: 30px;\n }\n\n #text-input:read-only {\n cursor: pointer;\n }\n\n #clear-button,\n #caret-button {\n display: inline-flex;\n align-items: center;\n appearance: none;\n background: transparent;\n border: none;\n padding: var(--combo-box-padding--) 5px;\n outline: none;\n font-size: inherit;\n font-family: inherit;\n font-weight: inherit;\n font-style: inherit;\n cursor: pointer;\n }\n\n #clear-button {\n flex: 0 0 30px;\n }\n\n #clear-button[hidden] {\n display: none;\n }\n\n #caret-button {\n padding-right: var(--combo-box-padding--);\n }\n\n #options-list {\n position: absolute;\n list-style-type: none;\n margin: 1px 0 0;\n border: none;\n padding: 0;\n background: white;\n width: var(--combo-box-list-width--);\n max-height: 400px;\n box-shadow: 0 0 1px 1px #ddd;\n opacity: 0;\n transition: opacity 0.125s ease;\n }\n\n #options-list.visible {\n opacity: 1;\n }\n\n #empty-options {\n padding: 5px;\n color: #606060;\n font-style: italic;\n text-align: center;\n }\n\n .caret-icon {\n width: 0.875em;\n height: 0.875em;\n }\n\n .clear-icon {\n width: 1em;\n height: 1em;\n }\n\n .option {\n padding: 7px 5px;\n width: 100%;\n box-sizing: border-box;\n line-height: 1.1;\n text-overflow: ellipsis;\n overflow: hidden;\n cursor: pointer;\n }\n\n .highlight {\n background-color: #dbe0ff;\n }\n\n .disabled,\n .disabled * {\n cursor: not-allowed !important;\n }\n\n .sr-only {\n position: absolute !important;\n width: 1px !important;\n height: 1px !important;\n margin: -1px !important;\n padding: 0 !important;\n border: 0 !important;\n overflow: hidden !important;\n white-space: nowrap !important;\n clip: rect(1px, 1px, 1px, 1px) !important;\n -webkit-clip-path: inset(50%) !important;\n clip-path: inset(50%) !important;\n user-select: none !important;\n }\n `;\n\n return [themeStyles, ownStyles];\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ia-combo-box.js","sourceRoot":"","sources":["../../../../src/elements/ia-combo-box/ia-combo-box.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,IAAI,EACJ,UAAU,EACV,OAAO,EAGP,GAAG,GAEJ,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,wBA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AAE;qDAA2D;AAKlD;IAAhB,KAAK,EAAE;+CAAkC;AAKzB;IAAhB,KAAK,EAAE;8CAAiC;AAEN;IAAlC,KAAK,CAAC,kBAAkB,CAAC;iDAAwC;AAEpC;IAA7B,KAAK,CAAC,aAAa,CAAC;6CAAsC;AAE3B;IAA/B,KAAK,CAAC,eAAe,CAAC;+CAAwC;AAjKpD,UAAU;IADtB,aAAa,CAAC,cAAc,CAAC;GACjB,UAAU,CA4yCtB","sourcesContent":["import {\n html,\n LitElement,\n nothing,\n TemplateResult,\n CSSResultGroup,\n css,\n PropertyValues,\n} from 'lit';\nimport { customElement, property, state, query } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { live } from 'lit/directives/live.js';\nimport { when } from 'lit/directives/when.js';\nimport { msg } from '@lit/localize';\n\nimport {\n hasAnyOf,\n isSubsequence,\n type IAComboBoxBehavior,\n type IAComboBoxFilterFunction,\n type IAComboBoxFilterOption,\n type IAComboBoxFilterPreset,\n type IAComboBoxOption,\n} from './models';\nimport themeStyles from '@src/themes/theme-styles';\n\nimport caretClosedIcon from './caret-closed.svg';\nimport caretOpenIcon from './caret-open.svg';\nimport clearIcon from './clear.svg';\n\n/**\n * Map from filter preset keys to their associated filtering function.\n * @see {@linkcode IAComboBox.filter}\n */\nconst FILTER_PRESETS: Record<IAComboBoxFilterPreset, IAComboBoxFilterFunction> =\n {\n all: () => true,\n prefix: (filterText, optionText) => optionText.startsWith(filterText),\n suffix: (filterText, optionText) => optionText.endsWith(filterText),\n substring: (filterText, optionText) => optionText.includes(filterText),\n subsequence: isSubsequence,\n };\n\nconst DEFAULT_BEHAVIOR: IAComboBoxBehavior = 'list';\nconst DEFAULT_FILTER_PRESET: IAComboBoxFilterPreset = 'substring';\n\nconst STRING_IDENTITY_FN = (str: string): string => str;\nconst STRING_LOWER_CASE_FN = (str: string): string => str.toLocaleLowerCase();\n\n/**\n * A flexible component combining the features of a dropdown menu and a text input,\n * allowing users to either select from a predefined list of options or type\n * freeform text to filter down & find specific options.\n */\n@customElement('ia-combo-box')\nexport class IAComboBox extends LitElement {\n /**\n * Array of options representing values that this combo box can take.\n *\n * If this combo box's `behavior` property is `select-only` or `list`, these options\n * represent _all_ of the allowed values that the user may choose from.\n *\n * If this combo box's `behavior` property is `freeform`, this array simply represents\n * a non-exhaustive list of _suggested_ values, which the user may either choose from\n * or enter their own value.\n * @see {@linkcode IAComboBox.behavior}\n */\n @property({ type: Array }) options: IAComboBoxOption[] = [];\n\n /**\n * Optional placeholder text to display in the combo box when no option is selected.\n */\n @property({ type: String }) placeholder?: string;\n\n /**\n * What style of behavior to use for the combo box.\n *\n * Currently, the options are\n * - `select-only` (behaving similar to a `<select>`, disallowing text entry and only\n * allowing selection from the predefined, unfiltered options)\n * - `list` (the default, allowing text entry to filter the dropdown list, but still\n * requiring values to be set from the predefined options)\n * - `freeform` (allows text entry to filter the dropdown list, and also allows setting\n * custom values not included in the list)\n */\n @property({ type: String }) behavior: IAComboBoxBehavior = DEFAULT_BEHAVIOR;\n\n /**\n * Maximum number of options to include in the autocomplete menu when filtering.\n *\n * Default value is `Infinity`, presenting all matching options regardless of count.\n */\n @property({ type: Number, attribute: 'max-autocomplete-entries' })\n maxAutocompleteEntries = Number.POSITIVE_INFINITY;\n\n /**\n * Specifies how the options should be filtered when text is entered into the combo box.\n * Has no effect if `behavior` is `select-only`, as the component is not text-editable.\n *\n * Default is `substring`, showing only options whose `text` contains the value entered\n * as a substring at any position. The possible preset options are:\n * - `all`: Does not filter the dropdown entries. They will always all be shown (up to\n * the limit specified by `maxAutocompleteEntries`).\n * - `prefix`: Only includes options whose text _starts_ with the entered value.\n * - `suffix`: Only includes options whose text _ends_ with the entered value.\n * - `substring`: Only includes options whose text contains the entered value as a\n * contiguous substring.\n * - `subsequence`: Only shows options whose text has the characters of the entered\n * value in order, though they do not need to be contiguous.\n * E.g., `ace` is a subsequence of `archive` (but not a substring).\n *\n * If custom filtering outside of these presets is desired, an arbitrary filtering function\n * may instead be bound to this property directly.\n *\n * @see {@link IAComboBox.caseSensitive} to enable case-sensitive filtering.\n */\n @property({ type: String }) filter: IAComboBoxFilterOption =\n DEFAULT_FILTER_PRESET;\n\n /**\n * Whether filtering should be case-sensitive. Default is `false`, performing only\n * case-insensitive filtering.\n */\n @property({ type: Boolean, reflect: true, attribute: 'case-sensitive' })\n caseSensitive = false;\n\n /**\n * Whether the filtered options should be listed in lexicographically-sorted order,\n * respecting the current `caseSensitive` setting.\n * Default is `false`, displaying them in the same order as the provided options array.\n */\n @property({ type: Boolean, reflect: true }) sort = false;\n\n /**\n * Whether the combo box allows multiple options to be selected at once.\n * Default is `false`, allowing only a single option to be selected.\n */\n // @property({ type: Boolean, reflect: true }) multiple = false; // TODO\n\n /**\n * Whether pressing the Up/Down arrow keys should wrap focus back to the text input box\n * while focus is already on the first/last option, respectively.\n *\n * Default is `false`, doing nothing upon such key presses.\n */\n @property({ type: Boolean, reflect: true, attribute: 'wrap-arrow-keys' })\n wrapArrowKeys = false;\n\n /**\n * Whether the options list should remain open after an option is selected.\n *\n * Default is `false`, closing the options list when a selection is made.\n */\n @property({ type: Boolean, reflect: true, attribute: 'stay-open' })\n stayOpen = false;\n\n /**\n * Whether the combo box shows a clear button when a value is selected.\n * Default is `false`.\n */\n @property({ type: Boolean, reflect: true }) clearable = false;\n\n /**\n * Whether the combo box's option menu is currently expanded. Default is `false`.\n */\n @property({ type: Boolean, reflect: true }) open = false;\n\n /**\n * Whether the combo box should be rendered in its disabled state, preventing all\n * interactions such as editing the text field or opening the options menu.\n * Default is `false`.\n */\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n /**\n * If used within a form, whether this combo box is required to have a value selected\n * before the form may be submitted. Default is `false`.\n */\n @property({ type: Boolean, reflect: true }) required = false;\n\n /**\n * For `select-only` or `list` behavior, this value is the ID of the selected option,\n * or `null` if there is no selection.\n *\n * For `freeform` behavior, this may be any string entered into the text field, and\n * need not correspond to an option ID.\n */\n @property({ type: String }) value: string | null = null;\n\n /**\n * Whether any part of this component currently has focus.\n */\n @state() private hasFocus = false;\n\n /**\n * Which option in the dropdown menu is currently highlighted by the user. Not to be\n * confused with the _selected_ option that has been committed, this field only\n * represents the user's current navigation state within the menu, which they may\n * subsequently select by, e.g., hitting Enter.\n */\n @state() private highlightedOption: IAComboBoxOption | null = null;\n\n /**\n * The text than has been entered into the text input box.\n */\n @state() private enteredText: string = '';\n\n /**\n * The text that we are currently using the filter the dropdown menu options.\n */\n @state() private filterText: string = '';\n\n @query('#main-widget-row') private mainWidgetRow?: HTMLDivElement;\n\n @query('#text-input') private textInput?: HTMLInputElement;\n\n @query('#options-list') private optionsList?: HTMLUListElement;\n\n static formAssociated = true;\n\n static shadowRootOptions: ShadowRootInit = {\n ...LitElement.shadowRootOptions,\n delegatesFocus: true,\n };\n\n private internals: ElementInternals;\n\n /**\n * Set when part of the component blurs, and cleared when any part of it is focused.\n * If still set on the next tick after a blur event, this serves as a signal that focus\n * has moved away from the component as a whole and should be closed.\n */\n private losingFocus = false;\n\n /**\n * A cache of the mapping from option IDs to their corresponding options, so that\n * we can more efficiently look up options by ID.\n */\n private optionsByID: Map<string, IAComboBoxOption> = new Map();\n\n /**\n * A cache of the values against which each option should be filtered, to minimize\n * the work needed at filter time to handle case-insensitivity etc.\n */\n private optionFilteringValues: Map<IAComboBoxOption, string> = new Map();\n\n /**\n * A cache of the current set of options that is pre-sorted if the component's\n * `sort` flag is set, or as provided otherwise. Just ensures we don't have to\n * sort all the options again every time we filter them.\n */\n private optionsRespectingSortFlag: IAComboBoxOption[] = [];\n\n /**\n * A cache of the current set of filtered options, so that we don't have to\n * recalculate it unnecessarily whenever the component is opened/closed/etc.\n */\n private filteredOptions: IAComboBoxOption[] = [];\n\n constructor() {\n super();\n this.internals = this.attachInternals();\n }\n\n render(): TemplateResult | typeof nothing {\n const mainWidgetClasses = classMap({\n disabled: this.disabled,\n focused: this.hasFocus,\n });\n\n return html`\n <div id=\"container\" part=\"container\">\n ${this.labelTemplate}\n <div id=\"main-widget-row\" class=${mainWidgetClasses} part=\"combo-box\">\n ${this.textInputTemplate}\n ${this.clearable ? this.clearButtonTemplate : nothing}\n ${this.caretButtonTemplate}\n </div>\n ${this.optionsListTemplate}\n </div>\n `;\n }\n\n willUpdate(changed: PropertyValues): void {\n if (changed.has('options') || changed.has('caseSensitive')) {\n // Need to update the cached values against which our filters are matched\n this.rebuildOptionFilteringValues();\n }\n\n if (changed.has('options')) {\n // Need to update the cached mapping of IDs to options\n this.rebuildOptionIDMap();\n }\n\n if (changed.has('options') || changed.has('sort')) {\n // Sort the options upfront if needed\n this.rebuildSortedOptions();\n }\n\n if (\n hasAnyOf(changed, [\n 'options',\n 'behavior',\n 'maxAutocompleteEntries',\n 'filter',\n 'filterText',\n 'caseSensitive',\n 'sort',\n ])\n ) {\n // If anything about the options or how they are filtered has changed, we need to\n // update our cache of the filtered options\n this.rebuildFilteredOptions();\n }\n\n if (changed.has('open')) {\n if (this.open) {\n // Highlight selection on open, if possible\n if (this.value) this.setHighlightedOption(this.selectedOption);\n } else {\n // Clear highlight on close\n this.setHighlightedOption(null);\n }\n }\n\n if (changed.has('required')) {\n this.updateFormValidity();\n }\n }\n\n updated(changed: PropertyValues): void {\n if (changed.has('value')) {\n this.handleValueChanged();\n }\n\n if (changed.has('options')) {\n // May need to clear the value if it no longer corresponds to an option\n if (this.behavior !== 'freeform' && !this.selectedOption) {\n this.clearSelectedOption();\n }\n }\n\n if (changed.has('open')) {\n if (this.open) {\n this.positionOptionsMenu();\n this.optionsList?.showPopover?.();\n this.optionsList?.classList.add('visible');\n } else {\n this.optionsList?.hidePopover?.();\n this.optionsList?.classList.remove('visible');\n }\n }\n }\n\n //\n // TEMPLATES\n //\n\n /**\n * Template for the main label for the combo box.\n *\n * Uses the contents of the `label` named slot as the label text.\n */\n private get labelTemplate(): TemplateResult {\n return html`\n <label id=\"label\" for=\"text-input\" part=\"label\">\n <slot name=\"label\"></slot>\n </label>\n `;\n }\n\n /**\n * Template for the text input field that users can edit to filter the available\n * options or (if freeform behavior) to enter a custom value.\n */\n private get textInputTemplate(): TemplateResult {\n const textInputClasses = classMap({\n 'clear-padding': this.clearable && !this.shouldShowClearButton,\n });\n\n return html`\n <input\n type=\"text\"\n id=\"text-input\"\n class=${textInputClasses}\n .value=${live(this.enteredText)}\n placeholder=${ifDefined(this.placeholder)}\n part=\"text-input\"\n role=\"combobox\"\n autocomplete=\"off\"\n aria-autocomplete=\"list\"\n aria-controls=\"options-list\"\n aria-expanded=${this.open}\n aria-activedescendant=${ifDefined(this.highlightedOption?.id)}\n ?readonly=${this.behavior === 'select-only'}\n ?disabled=${this.disabled}\n ?required=${this.required}\n @click=${this.handleComboBoxClick}\n @keydown=${this.handleComboBoxKeyDown}\n @input=${this.handleTextBoxInput}\n @focus=${this.handleFocus}\n @blur=${this.handleBlur}\n />\n `;\n }\n\n /**\n * Template for the clear button that is shown when the `clearable` property\n * is true.\n */\n private get clearButtonTemplate(): TemplateResult {\n return html`\n <button\n type=\"button\"\n id=\"clear-button\"\n part=\"clear-button\"\n tabindex=\"-1\"\n ?hidden=${!this.shouldShowClearButton}\n @click=${this.handleClearButtonClick}\n >\n <span class=\"sr-only\">${msg('Clear')}</span>\n <slot name=\"clear-button\">\n <img\n class=\"icon clear-icon\"\n part=\"icon clear-icon\"\n src=${clearIcon}\n alt=\"\"\n aria-hidden=\"true\"\n />\n </slot>\n </button>\n `;\n }\n\n /**\n * Template for the caret open/closed icons to show beside the text input.\n * The icons are wrapped in named slots to allow consumers to override them.\n */\n private get caretTemplate(): TemplateResult {\n return html`\n <slot name=\"caret-closed\" ?hidden=${this.open}>\n <img\n class=\"icon caret-icon\"\n part=\"icon caret-icon\"\n src=${caretClosedIcon}\n alt=\"\"\n aria-hidden=\"true\"\n />\n </slot>\n <slot name=\"caret-open\" ?hidden=${!this.open}>\n <img\n class=\"icon caret-icon\"\n part=\"icon caret-icon\"\n src=${caretOpenIcon}\n alt=\"\"\n aria-hidden=\"true\"\n />\n </slot>\n `;\n }\n\n /**\n * Template for the caret button to be shown beside the text input.\n */\n private get caretButtonTemplate(): TemplateResult {\n return html`\n <button\n type=\"button\"\n id=\"caret-button\"\n part=\"caret-button\"\n tabindex=\"-1\"\n aria-controls=\"options-list\"\n aria-expanded=${this.open}\n ?disabled=${this.disabled}\n @click=${this.handleComboBoxClick}\n @keydown=${this.handleComboBoxKeyDown}\n @focus=${this.handleFocus}\n @blur=${this.handleBlur}\n >\n <span class=\"sr-only\">${msg('Toggle options')}</span>\n ${this.caretTemplate}\n </button>\n `;\n }\n\n /**\n * Template for the options list that is displayed when the combo box is open.\n */\n private get optionsListTemplate(): TemplateResult {\n return html`\n <ul\n id=\"options-list\"\n part=\"options-list\"\n role=\"listbox\"\n tabindex=\"-1\"\n popover\n ?hidden=${!this.open}\n @focus=${this.handleFocus}\n @blur=${this.handleBlur}\n >\n <slot name=\"options-list-top\"></slot>\n ${when(this.open, () => this.optionTemplates)}\n <slot name=\"options-list-bottom\"></slot>\n </ul>\n `;\n }\n\n /**\n * Array of templates for all of the filtered options to be shown in the options menu.\n */\n private get optionTemplates(): TemplateResult[] {\n // If there are no options matching the filter, just show a message saying as much.\n if (this.filteredOptions.length === 0 && this.maxAutocompleteEntries > 0) {\n return [this.emptyOptionsTemplate];\n }\n\n // Otherwise build a list item for each filtered option\n return this.filteredOptions.map((opt) => {\n const isHighlighted = opt === this.highlightedOption;\n const optionClasses = classMap({\n option: true,\n highlight: isHighlighted,\n });\n\n return html`\n <li\n id=${opt.id}\n class=${optionClasses}\n part=\"option ${isHighlighted ? 'highlight' : ''}\"\n role=\"option\"\n tabindex=\"-1\"\n @pointerenter=${this.handleOptionPointerEnter}\n @pointermove=${this.handleOptionPointerMove}\n @click=${this.handleOptionClick}\n @focus=${this.handleFocus}\n @blur=${this.handleBlur}\n >\n ${opt.content ?? opt.text}\n </li>\n `;\n });\n }\n\n /**\n * Info message shown in the listbox when no options match the entered text.\n * Renders within an `empty-options` named slot so that its content can be customized.\n */\n private get emptyOptionsTemplate(): TemplateResult {\n return html`\n <li id=\"empty-options\" part=\"empty-options\">\n <slot name=\"empty-options\">${msg('No matching options')}</slot>\n </li>\n `;\n }\n\n //\n // EVENT HANDLERS & MUTATORS\n //\n\n /**\n * Handler for when the pointer device enters an option element in the dropdown.\n */\n private handleOptionPointerEnter(e: PointerEvent): void {\n this.handleOptionPointerMove(e);\n }\n\n /**\n * Handler for when the pointer device is moved within an option in the dropdown.\n */\n private handleOptionPointerMove(e: PointerEvent): void {\n const target = e.currentTarget as HTMLLIElement;\n const option = this.getOptionFor(target.id);\n if (option) this.setHighlightedOption(option);\n }\n\n /**\n * Handler for when the user clicks on an option in the dropdown.\n */\n private handleOptionClick(e: PointerEvent): void {\n const target = e.currentTarget as HTMLLIElement;\n const option = this.getOptionFor(target.id);\n if (option) {\n this.setSelectedOption(option.id);\n if (!this.stayOpen) this.closeOptionsMenu();\n }\n }\n\n /**\n * Handler for `keydown` events on various special keys.\n */\n private handleComboBoxKeyDown(e: KeyboardEvent): void {\n switch (e.key) {\n case 'Enter':\n this.handleEnterPressed();\n break;\n case 'Escape':\n this.handleEscapePressed();\n break;\n case 'ArrowUp':\n if (e.altKey) {\n this.handleAltUpArrowPressed();\n } else {\n this.handleUpArrowPressed();\n }\n break;\n case 'ArrowDown':\n if (e.altKey) {\n this.handleAltDownArrowPressed();\n } else {\n this.handleDownArrowPressed();\n }\n break;\n case 'Tab':\n this.handleTabPressed();\n return; // Never cancel the default behavior for Tab\n case ' ':\n this.handleSpacePressed(e);\n return; // Let the Space handler decide whether to cancel defaults/propagation\n default:\n // Do nothing and leave defaults/propagation in place for all other keys\n return;\n }\n\n e.stopPropagation();\n e.preventDefault();\n }\n\n /**\n * Handler for `input` events in the text input box.\n */\n private async handleTextBoxInput(): Promise<void> {\n const value = this.textInput?.value ?? '';\n this.enteredText = value;\n this.setFilterText(value);\n this.openOptionsMenu();\n\n await this.updateComplete;\n this.highlightFirstOption();\n }\n\n /**\n * Handler for when the Enter key is pressed\n */\n private handleEnterPressed(): void {\n // Just open the options menu if it's currently closed\n if (!this.open) {\n this.openOptionsMenu();\n return;\n }\n\n if (this.highlightedOption) {\n // If an option is highlighted, select it\n this.setSelectedOption(this.highlightedOption.id);\n } else if (this.behavior === 'freeform') {\n // Otherwise, in the freeform behavior we just accept the current value regardless\n this.setValue(this.enteredText);\n }\n\n // Close the options list if needed\n if (!this.stayOpen) this.open = false;\n }\n\n /**\n * Handler for when the Escape key is pressed\n */\n private handleEscapePressed(): void {\n // Close the options menu if it's currently open\n if (this.open) {\n this.closeOptionsMenu();\n return;\n }\n\n // Otherwise, deselect any selected option & clear any filter text\n this.clearSelectedOption();\n }\n\n /**\n * Handler for when the Up Arrow key is pressed (without modifiers).\n * @see {@linkcode handleAltUpArrowPressed()} for behavior under the Alt modifier.\n */\n private handleUpArrowPressed(): void {\n if (!this.open) this.openOptionsMenu();\n this.highlightPreviousOption();\n }\n\n /**\n * Handler for when the Down Arrow key is pressed (without modifiers).\n * @see {@linkcode handleAltDownArrowPressed()} for behavior under the Alt modifier.\n */\n private handleDownArrowPressed(): void {\n if (!this.open) this.openOptionsMenu();\n this.highlightNextOption();\n }\n\n /**\n * Handler for when the Alt + Up Arrow key combo is pressed\n */\n private handleAltUpArrowPressed(): void {\n this.closeOptionsMenu();\n }\n\n /**\n * Handler for when the Alt + Down Arrow key combo is pressed\n */\n private handleAltDownArrowPressed(): void {\n this.openOptionsMenu();\n }\n\n /**\n * Handler for when the Tab key is pressed\n */\n private handleTabPressed(): void {\n if (this.highlightedOption) {\n this.setSelectedOption(this.highlightedOption.id);\n if (!this.stayOpen) this.open = false;\n }\n }\n\n /**\n * Handler for when the Space key is handleTabPressed\n */\n private handleSpacePressed(e: KeyboardEvent): void {\n if (this.behavior === 'select-only') {\n if (!this.open) {\n this.openOptionsMenu();\n } else if (this.highlightedOption) {\n this.setSelectedOption(this.highlightedOption.id);\n if (!this.stayOpen) this.open = false;\n }\n\n e.stopPropagation();\n e.preventDefault();\n }\n }\n\n /**\n * Handler for clicks on the combo box input field or caret button.\n */\n private handleComboBoxClick(): void {\n this.toggleOptionsMenu();\n }\n\n /**\n * Handler for when the clear button is clicked.\n */\n private handleClearButtonClick(): void {\n this.clearSelectedOption();\n this.textInput?.focus();\n this.openOptionsMenu();\n }\n\n /**\n * Handler for when any part of the combo box receives focus.\n */\n private handleFocus(): void {\n if (this.behavior !== 'select-only') {\n // Always keep focus on the text input if it's editable\n this.textInput?.focus();\n }\n this.hasFocus = true;\n this.losingFocus = false;\n }\n\n /**\n * Handler for when any part of the combo box loses focus.\n */\n private handleBlur(): void {\n this.hasFocus = false;\n this.losingFocus = true;\n\n // On the next tick, check whether we've actually lost focus to some other element,\n // or just had a momentary internal focus switch. If it's the former, we should\n // close the menu and possibly make a selection (depending on desired behavior).\n setTimeout(() => {\n if (this.losingFocus && !this.shadowRoot?.activeElement) {\n this.losingFocus = false;\n this.closeOptionsMenu();\n\n if (this.behavior === 'list') {\n this.setTextValue(this.selectedOption?.text ?? '', false);\n } else if (\n this.behavior === 'freeform' &&\n (this.enteredText || this.value)\n ) {\n this.setValue(this.enteredText);\n }\n }\n }, 0);\n }\n\n /**\n * Handler for when the `value` of this component is changed externally\n */\n private handleValueChanged(): void {\n // Setting a null value always clears the component\n if (this.value == null) {\n if (this.enteredText) this.setTextValue('', false);\n return;\n }\n\n const option = this.getOptionFor(this.value);\n\n if (this.behavior === 'freeform') {\n const newText = option?.text ?? this.value;\n if (newText !== this.enteredText) {\n this.setTextValue(newText);\n }\n return;\n }\n\n // In non-freeform modes, the value must correspond to a predefined option.\n // If it doesn't, just clear the component.\n if (!option) {\n this.clearSelectedOption();\n return;\n }\n\n if (this.enteredText !== option.text) {\n this.setTextValue(option.text, false);\n this.setFilterText('');\n }\n }\n\n /**\n * Highlights the first option shown in the filtered list.\n */\n private highlightFirstOption(): void {\n this.setHighlightedOption(this.firstFilteredOption);\n }\n\n /**\n * Highlights the last option shown in the filtered list.\n */\n private highlightLastOption(): void {\n this.setHighlightedOption(this.lastFilteredOption);\n }\n\n /**\n * Highlights the option before the currently highlighted one in the list, or the last one\n * if none is highlighted.\n */\n private highlightPreviousOption(): void {\n const { filteredOptions, lastFilteredIndex } = this;\n\n // If no option is highlighted yet, highlight the last one\n if (!this.highlightedOption) {\n this.highlightLastOption();\n return;\n }\n\n // Otherwise, move to the previous option (wrapping if needed)\n const { highlightedIndex } = this;\n const previousIndex =\n this.wrapArrowKeys && highlightedIndex === 0\n ? lastFilteredIndex // Wrap around to the end\n : Math.max(highlightedIndex - 1, 0);\n this.setHighlightedOption(filteredOptions[previousIndex]);\n }\n\n /**\n * Highlights the option after the currently highlighted one in the list, or the first one\n * if none is highlighted.\n */\n private highlightNextOption(): void {\n const { filteredOptions, lastFilteredIndex } = this;\n\n // If no option is highlighted yet, highlight the first one\n if (!this.highlightedOption) {\n this.highlightFirstOption();\n return;\n }\n\n // Otherwise, move to the next option (wrapping if needed)\n const { highlightedIndex } = this;\n const nextIndex =\n this.wrapArrowKeys && highlightedIndex === lastFilteredIndex\n ? 0 // Wrap back to the start\n : Math.min(highlightedIndex + 1, lastFilteredIndex);\n this.setHighlightedOption(filteredOptions[nextIndex]);\n }\n\n /**\n * Highlights the given option and scrolls it into view if necessary.\n * If `null` is provided, any current highlight will be cleared.\n */\n private async setHighlightedOption(\n option: IAComboBoxOption | null,\n ): Promise<void> {\n this.highlightedOption = option;\n await this.updateComplete;\n\n const { optionsList, highlightedElement } = this;\n if (!highlightedElement || !optionsList) return;\n\n // TODO: Not ideal as this will trigger a reflow...\n // But may not be an issue in practice given the highlight isn't changing in a hot loop.\n // If we have issues with this let's see if we can hook up an IntersectionObserver.\n const elmtRect = highlightedElement.getBoundingClientRect();\n const listRect = optionsList.getBoundingClientRect();\n if (elmtRect.top < listRect.top || elmtRect.bottom > listRect.bottom) {\n highlightedElement.scrollIntoView({ block: 'nearest' });\n }\n }\n\n /**\n * Changes this combo box's selected option to the one matching the specified ID.\n *\n * Throws a `RangeError` if given an ID that does not correspond to any option\n * held by this combo box.\n */\n setSelectedOption(id: string): void {\n const option = this.getOptionFor(id);\n if (!option) throw new RangeError('Unknown option ID');\n\n const prevValue = this.value;\n this.value = option.id;\n this.internals.setFormValue(this.value);\n this.setTextValue(option.text, false);\n this.setFilterText('');\n if (this.value !== prevValue) this.emitChangeEvent();\n\n // Invoke the option's select callback if defined\n option.onSelected?.(option);\n }\n\n /**\n * Clears any currently selected option from this combo box, setting it to null\n * and clearing any value in the text box.\n */\n clearSelectedOption(): void {\n const prevValue = this.value;\n this.value = null;\n this.internals.setFormValue(this.value);\n this.setTextValue('');\n if (this.value !== prevValue) this.emitChangeEvent();\n }\n\n /**\n * Set this combo box's value to the given string if possible.\n *\n * In `freeform` behavior, this always succeeds.\n *\n * In other behavior modes, this method is identical to `setSelectedOption`,\n * interpreting the input as an option ID and throwing an error if no such\n * option exists.\n *\n * @see {@linkcode IAComboBox.setSelectedOption}\n */\n private setValue(value: string): void {\n if (this.behavior === 'freeform') {\n const prevValue = this.value;\n this.value = value;\n this.internals.setFormValue(this.value);\n this.setTextValue(value);\n if (this.value !== prevValue) this.emitChangeEvent();\n } else {\n this.setSelectedOption(value);\n }\n }\n\n /**\n * Changes the value of the text input box, and updates the filter accordingly.\n *\n * @param setFilter Whether to also update the filter text against which options are\n * matched. Defaults to `true`.\n */\n private setTextValue(value: string, setFilter = true): void {\n if (this.textInput) this.textInput.value = value;\n this.enteredText = value;\n if (setFilter) this.setFilterText(value);\n }\n\n /**\n * Sets the current filter text based on the provided string. The resulting filter\n * text might not exactly match the provided value, depending on the current case\n * sensitivity.\n */\n private setFilterText(baseFilterText: string): void {\n const { caseTransform } = this;\n this.filterText = caseTransform(baseFilterText);\n }\n\n openOptionsMenu(): void {\n this.open = true;\n this.emitToggleEvent();\n }\n\n closeOptionsMenu(): void {\n this.open = false;\n this.emitToggleEvent();\n }\n\n toggleOptionsMenu(): void {\n this.open = !this.open;\n this.emitToggleEvent();\n }\n\n private updateFormValidity(): void {\n if (this.required && !this.value) {\n this.internals.setValidity(\n { valueMissing: true },\n msg('A value is required'),\n );\n } else {\n // All good\n this.internals.setValidity({});\n }\n }\n\n private emitChangeEvent(): void {\n this.dispatchEvent(\n new CustomEvent<string | null>('change', {\n detail: this.value,\n }),\n );\n }\n\n private emitToggleEvent(): void {\n this.dispatchEvent(\n new CustomEvent<boolean>('toggle', {\n detail: this.open,\n }),\n );\n }\n\n //\n // HELPERS\n //\n\n /**\n * True iff no selection has been made and no text has been entered.\n */\n private get isEmpty(): boolean {\n return !this.selectedOption && !this.enteredText;\n }\n\n /**\n * We only show the clear button when the `clearable` property is set\n * and the combo box is neither empty nor disabled.\n */\n private get shouldShowClearButton(): boolean {\n return this.clearable && !this.disabled && !this.isEmpty;\n }\n\n /**\n * Sets the size and position of the options menu to match the size and position of\n * the combo box widget. Prefers to position below the main widget, but will flip\n * to the top if needed & if there's more room above.\n */\n private positionOptionsMenu(): void {\n const { mainWidgetRow, optionsList } = this;\n if (!mainWidgetRow || !optionsList) return;\n const mainWidgetRect = mainWidgetRow.getBoundingClientRect();\n\n const { innerHeight, scrollX, scrollY } = window;\n const usableHeightAbove = mainWidgetRect.top;\n const usableHeightBelow = innerHeight - mainWidgetRect.bottom;\n\n const maxHeightVar = `var(--combo-box-list-max-height--)`;\n\n const optionsListStyles: Record<string, string> = {\n top: `${mainWidgetRect.bottom + scrollY}px`,\n left: `${mainWidgetRect.left + scrollX}px`,\n width: `var(--combo-box-list-width--, ${mainWidgetRect.width}px)`,\n maxHeight: `min(${maxHeightVar}, ${usableHeightBelow}px)`,\n };\n\n Object.assign(optionsList.style, optionsListStyles);\n\n // Wait a tick for it to appear, then check if we should flip it upwards instead\n setTimeout(() => {\n const listRect = optionsList.getBoundingClientRect();\n const overflowingViewport = listRect.bottom >= innerHeight;\n const moreSpaceAbove = usableHeightAbove > usableHeightBelow;\n if (overflowingViewport && moreSpaceAbove) {\n optionsList.style.top = 'auto';\n optionsList.style.bottom = `${innerHeight - mainWidgetRect.top - scrollY}px`;\n optionsList.style.maxHeight = `min(${maxHeightVar}, ${usableHeightAbove}px)`;\n }\n }, 0);\n }\n\n /**\n * A function to transform option & filter text based on the combo box's\n * current case sensitivity.\n */\n private get caseTransform(): (text: string) => string {\n return this.caseSensitive ? STRING_IDENTITY_FN : STRING_LOWER_CASE_FN;\n }\n\n /**\n * Returns the combo box option having the given ID, or null if none exists.\n */\n private getOptionFor(id: string): IAComboBoxOption | null {\n return this.optionsByID.get(id) ?? null;\n }\n\n /**\n * Clears any previously-cached mapping of IDs to options, and rebuilds the\n * map based on the current set of options.\n */\n private rebuildOptionIDMap(): void {\n this.optionsByID.clear();\n for (const option of this.options) {\n this.optionsByID.set(option.id, option);\n }\n }\n\n /**\n * Applies any required sort to the options and caches the result to be used\n * at filter/display time.\n */\n private rebuildSortedOptions(): void {\n if (this.sort) {\n this.optionsRespectingSortFlag = [...this.options].sort((a, b) => {\n const aValue = this.optionFilteringValues.get(a) as string;\n const bValue = this.optionFilteringValues.get(b) as string;\n return aValue.localeCompare(bValue);\n });\n } else {\n this.optionsRespectingSortFlag = this.options;\n }\n }\n\n /**\n * Clears any previously-cached option filtering values, and rebuilds the\n * map based on the current component properties.\n */\n private rebuildOptionFilteringValues(): void {\n this.optionFilteringValues.clear();\n\n const { caseTransform } = this;\n for (const option of this.options) {\n const filteringValue = caseTransform(option.text);\n this.optionFilteringValues.set(option, filteringValue);\n }\n }\n\n /**\n * Returns the filtered array of options by applying the specified filter function\n * with the current filter text, up to the limit specified by `maxAutocompleteEntries`.\n */\n private rebuildFilteredOptions(): void {\n // We don't want to filter the results in select-only mode\n const resolvedFilterOption =\n this.behavior === 'select-only' ? 'all' : this.filter;\n\n const filterFn =\n typeof resolvedFilterOption === 'string'\n ? FILTER_PRESETS[resolvedFilterOption]\n : resolvedFilterOption;\n\n const filtered = this.optionsRespectingSortFlag\n .filter((opt) => {\n const optionFilteringValue = this.optionFilteringValues.get(opt);\n if (!optionFilteringValue) return false;\n\n return filterFn(this.filterText, optionFilteringValue, opt);\n })\n .slice(0, this.maxAutocompleteEntries);\n\n this.filteredOptions = filtered;\n }\n\n /**\n * The first option appearing in the filtered list, or null if there are none.\n */\n private get firstFilteredOption(): IAComboBoxOption | null {\n return this.filteredOptions[0] ?? null;\n }\n\n /**\n * The last option appearing in the filtered list, or null if there are none.\n */\n private get lastFilteredOption(): IAComboBoxOption | null {\n return this.filteredOptions[this.lastFilteredIndex] ?? null;\n }\n\n /**\n * The index of the last filtered option, or -1 if no options match the filter.\n */\n private get lastFilteredIndex(): number {\n return this.filteredOptions.length - 1;\n }\n\n /**\n * The IAComboBoxOption that is currently selected, or null if none is selected.\n */\n get selectedOption(): IAComboBoxOption | null {\n if (this.value == null) return null;\n return this.getOptionFor(this.value);\n }\n\n /**\n * The index of the currently highlighted option in the filtered list, or -1 if\n * no option is currently highlighted.\n */\n private get highlightedIndex(): number {\n if (!this.highlightedOption) return -1;\n return this.filteredOptions.indexOf(this.highlightedOption);\n }\n\n /**\n * The HTML element representing the currently-highlighted option, or null if\n * no option is highlighted.\n */\n private get highlightedElement(): HTMLElement | null {\n if (!this.highlightedOption) return null;\n return this.shadowRoot!.getElementById(this.highlightedOption.id);\n }\n\n static get styles(): CSSResultGroup {\n const ownStyles = css`\n :host {\n --combo-box-width--: var(--combo-box-width);\n --combo-box-padding--: var(--padding-sm);\n --combo-box-list-width--: var(--combo-box-list-width, unset);\n --combo-box-list-max-height--: var(--combo-box-list-max-height, 250px);\n }\n\n #container {\n display: inline-block;\n width: var(--combo-box-width--);\n }\n\n #label {\n display: block;\n width: fit-content;\n }\n\n #main-widget-row {\n display: inline-flex;\n align-items: stretch;\n flex-wrap: nowrap;\n background: white;\n border: 1px solid black;\n width: 100%;\n }\n\n #main-widget-row:not(.focused, .disabled):hover,\n #main-widget-row:not(.focused, .disabled):active {\n background: #fafafa;\n }\n\n #main-widget-row.focused {\n outline: black auto 1px;\n outline-offset: 3px;\n }\n\n #main-widget-row.disabled {\n background: #f4f4f4;\n border-color: #a0a0a0;\n color: #404040;\n }\n\n #text-input {\n appearance: none;\n background: transparent;\n border: none;\n padding: var(--combo-box-padding--);\n padding-right: 0;\n width: 100%;\n font-size: inherit;\n font-family: inherit;\n font-weight: inherit;\n font-style: inherit;\n color: inherit;\n outline: none;\n text-overflow: ellipsis;\n }\n\n #text-input.clear-padding {\n padding-right: 30px;\n }\n\n #text-input:read-only {\n cursor: pointer;\n }\n\n #clear-button,\n #caret-button {\n display: inline-flex;\n align-items: center;\n appearance: none;\n background: transparent;\n border: none;\n padding: var(--combo-box-padding--) 5px;\n outline: none;\n font-size: inherit;\n font-family: inherit;\n font-weight: inherit;\n font-style: inherit;\n cursor: pointer;\n }\n\n #clear-button {\n flex: 0 0 30px;\n }\n\n #clear-button[hidden] {\n display: none;\n }\n\n #caret-button {\n padding-right: var(--combo-box-padding--);\n }\n\n #options-list {\n position: absolute;\n list-style-type: none;\n margin: 1px 0 0;\n border: none;\n padding: 0;\n background: white;\n width: var(--combo-box-list-width--);\n max-height: 400px;\n box-shadow: 0 0 1px 1px #ddd;\n opacity: 0;\n transition: opacity 0.125s ease;\n }\n\n #options-list.visible {\n opacity: 1;\n }\n\n #empty-options {\n padding: 5px;\n color: #606060;\n font-style: italic;\n text-align: center;\n }\n\n .caret-icon {\n width: 0.875em;\n height: 0.875em;\n }\n\n .clear-icon {\n width: 1em;\n height: 1em;\n }\n\n .option {\n padding: 7px 5px;\n width: 100%;\n box-sizing: border-box;\n line-height: 1.1;\n text-overflow: ellipsis;\n overflow: hidden;\n cursor: pointer;\n }\n\n .highlight {\n background-color: #dbe0ff;\n }\n\n .disabled,\n .disabled * {\n cursor: not-allowed !important;\n }\n\n .sr-only {\n position: absolute !important;\n width: 1px !important;\n height: 1px !important;\n margin: -1px !important;\n padding: 0 !important;\n border: 0 !important;\n overflow: hidden !important;\n white-space: nowrap !important;\n clip: rect(1px, 1px, 1px, 1px) !important;\n -webkit-clip-path: inset(50%) !important;\n clip-path: inset(50%) !important;\n user-select: none !important;\n }\n `;\n\n return [themeStyles, ownStyles];\n }\n}\n"]}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { LitElement, type CSSResultGroup, type TemplateResult } from 'lit';
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
/**
|
|
5
|
+
* Zendesk Messenger API injected by the ze-snippet script.
|
|
6
|
+
* Overloaded to cover the two call shapes we use:
|
|
7
|
+
* - `messenger:on` — subscribe to open/close lifecycle events
|
|
8
|
+
* - `messenger` — imperatively open or close the widget panel
|
|
9
|
+
*/
|
|
10
|
+
zE?: {
|
|
11
|
+
(target: 'messenger:on', event: 'open' | 'close', callback: () => void): void;
|
|
12
|
+
(target: 'messenger', action: 'open' | 'close'): void;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A lightweight launcher button that loads and opens the Zendesk Messenger
|
|
18
|
+
* widget on demand.
|
|
19
|
+
*
|
|
20
|
+
* The native Zendesk launcher is never shown — this button is the sole entry
|
|
21
|
+
* point. The Zendesk snippet script is fetched lazily on the first click so
|
|
22
|
+
* it does not affect page load performance.
|
|
23
|
+
*
|
|
24
|
+
* @fires zendeskHelpButtonClicked - Dispatched when the user clicks the Help
|
|
25
|
+
* button, before the widget is opened.
|
|
26
|
+
*
|
|
27
|
+
* @cssprop --button-blue - Button background colour (default: `#194880`).
|
|
28
|
+
* @cssprop --icon-fill-color - SVG icon fill colour (default: `#fff`).
|
|
29
|
+
* @cssprop --link-color - Button text colour (default: `#fff`).
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```html
|
|
33
|
+
* <ia-zendesk-widget
|
|
34
|
+
* widget-src="https://static.zdassets.com/ekr/snippet.js?key=YOUR_KEY"
|
|
35
|
+
* ></ia-zendesk-widget>
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare class IAZendeskWidget extends LitElement {
|
|
39
|
+
/** URL of the Zendesk `ze-snippet` loader script, including the `key` query param. */
|
|
40
|
+
widgetSrc: string;
|
|
41
|
+
/** Controls Help button visibility. Hidden while the widget panel is open. */
|
|
42
|
+
private buttonVisible;
|
|
43
|
+
/** True from the first click until Zendesk fires the `open` event. Shows the spinner. */
|
|
44
|
+
private isLoading;
|
|
45
|
+
/**
|
|
46
|
+
* Set to `true` after the snippet has loaded and the `messenger:on` listeners
|
|
47
|
+
* have been registered. Prevents duplicate listener registration on
|
|
48
|
+
* subsequent clicks.
|
|
49
|
+
*/
|
|
50
|
+
private zendeskReady;
|
|
51
|
+
/**
|
|
52
|
+
* Click handler for the Help button.
|
|
53
|
+
*
|
|
54
|
+
* On the first call: injects the Zendesk script, waits for `window.zE` to
|
|
55
|
+
* become available, registers open/close listeners, then opens the panel.
|
|
56
|
+
*
|
|
57
|
+
* On subsequent calls: the script is already present so we go straight to
|
|
58
|
+
* opening the panel. The spinner stays on until Zendesk fires `'open'`.
|
|
59
|
+
*/
|
|
60
|
+
private initiateZenDesk;
|
|
61
|
+
/**
|
|
62
|
+
* Appends the Zendesk snippet `<script>` to `<head>` if it has not already
|
|
63
|
+
* been added. Resolves once the script has loaded; rejects on network error.
|
|
64
|
+
* Guarded by the `ze-snippet` id so multiple widget instances on the same
|
|
65
|
+
* page share a single script tag.
|
|
66
|
+
*/
|
|
67
|
+
private loadZendeskScript;
|
|
68
|
+
/**
|
|
69
|
+
* Polls `window.zE` at 100 ms intervals until the Zendesk API is available.
|
|
70
|
+
* The snippet performs its own async initialisation after loading, so
|
|
71
|
+
* `window.zE` may not be set immediately when `script.onload` fires.
|
|
72
|
+
*/
|
|
73
|
+
private waitForZendesk;
|
|
74
|
+
private get iconTemplate();
|
|
75
|
+
render(): TemplateResult;
|
|
76
|
+
static get styles(): CSSResultGroup;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=ia-zendesk-widget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ia-zendesk-widget.d.ts","sourceRoot":"","sources":["../../../../src/elements/ia-zendesk-widget/ia-zendesk-widget.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,UAAU,EACV,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,KAAK,CAAC;AAQb,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd;;;;;WAKG;QACH,EAAE,CAAC,EAAE;YACH,CACE,MAAM,EAAE,cAAc,EACtB,KAAK,EAAE,MAAM,GAAG,OAAO,EACvB,QAAQ,EAAE,MAAM,IAAI,GACnB,IAAI,CAAC;YACR,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;SACvD,CAAC;KACH;CACF;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBACa,eAAgB,SAAQ,UAAU;IAC7C,sFAAsF;IAEtF,SAAS,SAAM;IAEf,8EAA8E;IACrE,OAAO,CAAC,aAAa,CAAQ;IAEtC,yFAAyF;IAChF,OAAO,CAAC,SAAS,CAAS;IAEnC;;;;OAIG;IACH,OAAO,CAAC,YAAY,CAAS;IAE7B;;;;;;;;OAQG;YACW,eAAe;IAoC7B;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB;IAezB;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAgBtB,OAAO,KAAK,YAAY,GAIvB;IAED,MAAM,IAAI,cAAc;IAYxB,MAAM,KAAK,MAAM,IAAI,cAAc,CAiElC;CACF"}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { css, html, LitElement, } from 'lit';
|
|
3
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
|
4
|
+
import { unsafeHTML } from 'lit/directives/unsafe-html.js';
|
|
5
|
+
import loaderIconSvg from './loader-icon.svg?raw';
|
|
6
|
+
import questionIconSvg from './question-icon.svg?raw';
|
|
7
|
+
/**
|
|
8
|
+
* A lightweight launcher button that loads and opens the Zendesk Messenger
|
|
9
|
+
* widget on demand.
|
|
10
|
+
*
|
|
11
|
+
* The native Zendesk launcher is never shown — this button is the sole entry
|
|
12
|
+
* point. The Zendesk snippet script is fetched lazily on the first click so
|
|
13
|
+
* it does not affect page load performance.
|
|
14
|
+
*
|
|
15
|
+
* @fires zendeskHelpButtonClicked - Dispatched when the user clicks the Help
|
|
16
|
+
* button, before the widget is opened.
|
|
17
|
+
*
|
|
18
|
+
* @cssprop --button-blue - Button background colour (default: `#194880`).
|
|
19
|
+
* @cssprop --icon-fill-color - SVG icon fill colour (default: `#fff`).
|
|
20
|
+
* @cssprop --link-color - Button text colour (default: `#fff`).
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```html
|
|
24
|
+
* <ia-zendesk-widget
|
|
25
|
+
* widget-src="https://static.zdassets.com/ekr/snippet.js?key=YOUR_KEY"
|
|
26
|
+
* ></ia-zendesk-widget>
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
let IAZendeskWidget = class IAZendeskWidget extends LitElement {
|
|
30
|
+
constructor() {
|
|
31
|
+
super(...arguments);
|
|
32
|
+
/** URL of the Zendesk `ze-snippet` loader script, including the `key` query param. */
|
|
33
|
+
this.widgetSrc = '';
|
|
34
|
+
/** Controls Help button visibility. Hidden while the widget panel is open. */
|
|
35
|
+
this.buttonVisible = true;
|
|
36
|
+
/** True from the first click until Zendesk fires the `open` event. Shows the spinner. */
|
|
37
|
+
this.isLoading = false;
|
|
38
|
+
/**
|
|
39
|
+
* Set to `true` after the snippet has loaded and the `messenger:on` listeners
|
|
40
|
+
* have been registered. Prevents duplicate listener registration on
|
|
41
|
+
* subsequent clicks.
|
|
42
|
+
*/
|
|
43
|
+
this.zendeskReady = false;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Click handler for the Help button.
|
|
47
|
+
*
|
|
48
|
+
* On the first call: injects the Zendesk script, waits for `window.zE` to
|
|
49
|
+
* become available, registers open/close listeners, then opens the panel.
|
|
50
|
+
*
|
|
51
|
+
* On subsequent calls: the script is already present so we go straight to
|
|
52
|
+
* opening the panel. The spinner stays on until Zendesk fires `'open'`.
|
|
53
|
+
*/
|
|
54
|
+
async initiateZenDesk() {
|
|
55
|
+
this.isLoading = true;
|
|
56
|
+
this.dispatchEvent(new Event('zendeskHelpButtonClicked'));
|
|
57
|
+
try {
|
|
58
|
+
if (!this.zendeskReady) {
|
|
59
|
+
await this.loadZendeskScript();
|
|
60
|
+
await this.waitForZendesk();
|
|
61
|
+
// Register lifecycle listeners exactly once.
|
|
62
|
+
// isLoading is cleared here (not earlier) so the spinner persists until
|
|
63
|
+
// the widget panel is actually visible to the user.
|
|
64
|
+
window.zE('messenger:on', 'open', () => {
|
|
65
|
+
this.buttonVisible = false;
|
|
66
|
+
this.isLoading = false;
|
|
67
|
+
});
|
|
68
|
+
// Delay matches the Zendesk close animation so the Help button does not
|
|
69
|
+
// reappear while the panel is still sliding out.
|
|
70
|
+
window.zE('messenger:on', 'close', () => {
|
|
71
|
+
setTimeout(() => {
|
|
72
|
+
this.buttonVisible = true;
|
|
73
|
+
}, 500);
|
|
74
|
+
});
|
|
75
|
+
this.zendeskReady = true;
|
|
76
|
+
}
|
|
77
|
+
window.zE('messenger', 'open');
|
|
78
|
+
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
this.isLoading = false;
|
|
81
|
+
// eslint-disable-next-line no-console
|
|
82
|
+
console.error('[ia-zendesk-widget]', err);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Appends the Zendesk snippet `<script>` to `<head>` if it has not already
|
|
87
|
+
* been added. Resolves once the script has loaded; rejects on network error.
|
|
88
|
+
* Guarded by the `ze-snippet` id so multiple widget instances on the same
|
|
89
|
+
* page share a single script tag.
|
|
90
|
+
*/
|
|
91
|
+
loadZendeskScript() {
|
|
92
|
+
return new Promise((resolve, reject) => {
|
|
93
|
+
if (document.getElementById('ze-snippet')) {
|
|
94
|
+
resolve();
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const script = document.createElement('script');
|
|
98
|
+
script.id = 'ze-snippet';
|
|
99
|
+
script.src = this.widgetSrc;
|
|
100
|
+
script.onload = () => resolve();
|
|
101
|
+
script.onerror = () => reject(new Error('Failed to load Zendesk script'));
|
|
102
|
+
document.head.appendChild(script);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Polls `window.zE` at 100 ms intervals until the Zendesk API is available.
|
|
107
|
+
* The snippet performs its own async initialisation after loading, so
|
|
108
|
+
* `window.zE` may not be set immediately when `script.onload` fires.
|
|
109
|
+
*/
|
|
110
|
+
waitForZendesk(timeoutMs = 10_000) {
|
|
111
|
+
return new Promise((resolve, reject) => {
|
|
112
|
+
const check = setInterval(() => {
|
|
113
|
+
if (window.zE) {
|
|
114
|
+
clearInterval(check);
|
|
115
|
+
clearTimeout(timeout);
|
|
116
|
+
resolve();
|
|
117
|
+
}
|
|
118
|
+
}, 100);
|
|
119
|
+
const timeout = setTimeout(() => {
|
|
120
|
+
clearInterval(check);
|
|
121
|
+
reject(new Error('Zendesk API did not initialise in time'));
|
|
122
|
+
}, timeoutMs);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
get iconTemplate() {
|
|
126
|
+
return this.isLoading
|
|
127
|
+
? unsafeHTML(loaderIconSvg)
|
|
128
|
+
: unsafeHTML(questionIconSvg);
|
|
129
|
+
}
|
|
130
|
+
render() {
|
|
131
|
+
return html `
|
|
132
|
+
<button
|
|
133
|
+
class="help-widget ${this.buttonVisible ? '' : 'hidden'}"
|
|
134
|
+
@click=${this.initiateZenDesk}
|
|
135
|
+
>
|
|
136
|
+
${this.iconTemplate}
|
|
137
|
+
<span class="hidden-sm">Help</span>
|
|
138
|
+
</button>
|
|
139
|
+
`;
|
|
140
|
+
}
|
|
141
|
+
static get styles() {
|
|
142
|
+
return css `
|
|
143
|
+
:host {
|
|
144
|
+
--button-blue: #194880;
|
|
145
|
+
--white: #fff;
|
|
146
|
+
--icon-fill-color: var(--white);
|
|
147
|
+
--link-color: var(--white);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.help-widget {
|
|
151
|
+
width: 108px;
|
|
152
|
+
height: 46px;
|
|
153
|
+
margin: 14px 20px;
|
|
154
|
+
position: fixed;
|
|
155
|
+
bottom: 0;
|
|
156
|
+
right: 0;
|
|
157
|
+
z-index: 999998;
|
|
158
|
+
background: var(--button-blue);
|
|
159
|
+
color: var(--link-color);
|
|
160
|
+
letter-spacing: 0.6px;
|
|
161
|
+
font-size: 14px;
|
|
162
|
+
transition: opacity 0.12s linear;
|
|
163
|
+
border-radius: 999rem;
|
|
164
|
+
border: 0;
|
|
165
|
+
outline: none;
|
|
166
|
+
font-weight: 700;
|
|
167
|
+
cursor: pointer;
|
|
168
|
+
vertical-align: middle;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.fill-color {
|
|
172
|
+
fill: var(--icon-fill-color);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.help-widget svg {
|
|
176
|
+
vertical-align: middle;
|
|
177
|
+
margin-right: 3px;
|
|
178
|
+
pointer-events: none;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.help-widget .hidden-sm {
|
|
182
|
+
pointer-events: none;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.hidden {
|
|
186
|
+
opacity: 0;
|
|
187
|
+
display: none;
|
|
188
|
+
visibility: hidden;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
@media (max-width: 767px) {
|
|
192
|
+
.hidden-sm {
|
|
193
|
+
display: none;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.help-widget {
|
|
197
|
+
padding: 13px;
|
|
198
|
+
width: initial;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.help-widget svg {
|
|
202
|
+
margin-right: 0;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
`;
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
__decorate([
|
|
209
|
+
property({ type: String, attribute: 'widget-src' })
|
|
210
|
+
], IAZendeskWidget.prototype, "widgetSrc", void 0);
|
|
211
|
+
__decorate([
|
|
212
|
+
state()
|
|
213
|
+
], IAZendeskWidget.prototype, "buttonVisible", void 0);
|
|
214
|
+
__decorate([
|
|
215
|
+
state()
|
|
216
|
+
], IAZendeskWidget.prototype, "isLoading", void 0);
|
|
217
|
+
IAZendeskWidget = __decorate([
|
|
218
|
+
customElement('ia-zendesk-widget')
|
|
219
|
+
], IAZendeskWidget);
|
|
220
|
+
export { IAZendeskWidget };
|
|
221
|
+
//# sourceMappingURL=ia-zendesk-widget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ia-zendesk-widget.js","sourceRoot":"","sources":["../../../../src/elements/ia-zendesk-widget/ia-zendesk-widget.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,GAAG,EACH,IAAI,EACJ,UAAU,GAGX,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,UAAU,EAAuB,MAAM,+BAA+B,CAAC;AAEhF,OAAO,aAAa,MAAM,uBAAuB,CAAC;AAClD,OAAO,eAAe,MAAM,yBAAyB,CAAC;AAsBtD;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,UAAU;IAAxC;;QACL,sFAAsF;QAEtF,cAAS,GAAG,EAAE,CAAC;QAEf,8EAA8E;QAC7D,kBAAa,GAAG,IAAI,CAAC;QAEtC,yFAAyF;QACxE,cAAS,GAAG,KAAK,CAAC;QAEnC;;;;WAIG;QACK,iBAAY,GAAG,KAAK,CAAC;IA6K/B,CAAC;IA3KC;;;;;;;;OAQG;IACK,KAAK,CAAC,eAAe;QAC3B,IAAI,CAAC,SAAS,GAAG,IAA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C,CAAC,QAAQ;iBAC9C,IAAI,CAAC,eAAe;;UAE3B,IAAI,CAAC,YAAY;;;KAGtB,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA+DT,CAAC;IACJ,CAAC;CACF,CAAA;AA1LC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;kDACrC;AAGE;IAAhB,KAAK,EAAE;sDAA8B;AAGrB;IAAhB,KAAK,EAAE;kDAA2B;AATxB,eAAe;IAD3B,aAAa,CAAC,mBAAmB,CAAC;GACtB,eAAe,CA6L3B","sourcesContent":["import {\n css,\n html,\n LitElement,\n type CSSResultGroup,\n type TemplateResult,\n} from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport { unsafeHTML, UnsafeHTMLDirective } from 'lit/directives/unsafe-html.js';\n\nimport loaderIconSvg from './loader-icon.svg?raw';\nimport questionIconSvg from './question-icon.svg?raw';\nimport { DirectiveResult } from 'lit/directive.js';\n\ndeclare global {\n interface Window {\n /**\n * Zendesk Messenger API injected by the ze-snippet script.\n * Overloaded to cover the two call shapes we use:\n * - `messenger:on` — subscribe to open/close lifecycle events\n * - `messenger` — imperatively open or close the widget panel\n */\n zE?: {\n (\n target: 'messenger:on',\n event: 'open' | 'close',\n callback: () => void,\n ): void;\n (target: 'messenger', action: 'open' | 'close'): void;\n };\n }\n}\n\n/**\n * A lightweight launcher button that loads and opens the Zendesk Messenger\n * widget on demand.\n *\n * The native Zendesk launcher is never shown — this button is the sole entry\n * point. The Zendesk snippet script is fetched lazily on the first click so\n * it does not affect page load performance.\n *\n * @fires zendeskHelpButtonClicked - Dispatched when the user clicks the Help\n * button, before the widget is opened.\n *\n * @cssprop --button-blue - Button background colour (default: `#194880`).\n * @cssprop --icon-fill-color - SVG icon fill colour (default: `#fff`).\n * @cssprop --link-color - Button text colour (default: `#fff`).\n *\n * @example\n * ```html\n * <ia-zendesk-widget\n * widget-src=\"https://static.zdassets.com/ekr/snippet.js?key=YOUR_KEY\"\n * ></ia-zendesk-widget>\n * ```\n */\n@customElement('ia-zendesk-widget')\nexport class IAZendeskWidget extends LitElement {\n /** URL of the Zendesk `ze-snippet` loader script, including the `key` query param. */\n @property({ type: String, attribute: 'widget-src' })\n widgetSrc = '';\n\n /** Controls Help button visibility. Hidden while the widget panel is open. */\n @state() private buttonVisible = true;\n\n /** True from the first click until Zendesk fires the `open` event. Shows the spinner. */\n @state() private isLoading = false;\n\n /**\n * Set to `true` after the snippet has loaded and the `messenger:on` listeners\n * have been registered. Prevents duplicate listener registration on\n * subsequent clicks.\n */\n private zendeskReady = false;\n\n /**\n * Click handler for the Help button.\n *\n * On the first call: injects the Zendesk script, waits for `window.zE` to\n * become available, registers open/close listeners, then opens the panel.\n *\n * On subsequent calls: the script is already present so we go straight to\n * opening the panel. The spinner stays on until Zendesk fires `'open'`.\n */\n private async initiateZenDesk(): Promise<void> {\n this.isLoading = true;\n this.dispatchEvent(new Event('zendeskHelpButtonClicked'));\n\n try {\n if (!this.zendeskReady) {\n await this.loadZendeskScript();\n await this.waitForZendesk();\n\n // Register lifecycle listeners exactly once.\n // isLoading is cleared here (not earlier) so the spinner persists until\n // the widget panel is actually visible to the user.\n window.zE!('messenger:on', 'open', () => {\n this.buttonVisible = false;\n this.isLoading = false;\n });\n\n // Delay matches the Zendesk close animation so the Help button does not\n // reappear while the panel is still sliding out.\n window.zE!('messenger:on', 'close', () => {\n setTimeout(() => {\n this.buttonVisible = true;\n }, 500);\n });\n\n this.zendeskReady = true;\n }\n\n window.zE!('messenger', 'open');\n } catch (err) {\n this.isLoading = false;\n // eslint-disable-next-line no-console\n console.error('[ia-zendesk-widget]', err);\n }\n }\n\n /**\n * Appends the Zendesk snippet `<script>` to `<head>` if it has not already\n * been added. Resolves once the script has loaded; rejects on network error.\n * Guarded by the `ze-snippet` id so multiple widget instances on the same\n * page share a single script tag.\n */\n private loadZendeskScript(): Promise<void> {\n return new Promise((resolve, reject) => {\n if (document.getElementById('ze-snippet')) {\n resolve();\n return;\n }\n const script = document.createElement('script');\n script.id = 'ze-snippet';\n script.src = this.widgetSrc;\n script.onload = () => resolve();\n script.onerror = () => reject(new Error('Failed to load Zendesk script'));\n document.head.appendChild(script);\n });\n }\n\n /**\n * Polls `window.zE` at 100 ms intervals until the Zendesk API is available.\n * The snippet performs its own async initialisation after loading, so\n * `window.zE` may not be set immediately when `script.onload` fires.\n */\n private waitForZendesk(timeoutMs = 10_000): Promise<void> {\n return new Promise((resolve, reject) => {\n const check = setInterval(() => {\n if (window.zE) {\n clearInterval(check);\n clearTimeout(timeout);\n resolve();\n }\n }, 100);\n const timeout = setTimeout(() => {\n clearInterval(check);\n reject(new Error('Zendesk API did not initialise in time'));\n }, timeoutMs);\n });\n }\n\n private get iconTemplate(): DirectiveResult<typeof UnsafeHTMLDirective> {\n return this.isLoading\n ? unsafeHTML(loaderIconSvg)\n : unsafeHTML(questionIconSvg);\n }\n\n render(): TemplateResult {\n return html`\n <button\n class=\"help-widget ${this.buttonVisible ? '' : 'hidden'}\"\n @click=${this.initiateZenDesk}\n >\n ${this.iconTemplate}\n <span class=\"hidden-sm\">Help</span>\n </button>\n `;\n }\n\n static get styles(): CSSResultGroup {\n return css`\n :host {\n --button-blue: #194880;\n --white: #fff;\n --icon-fill-color: var(--white);\n --link-color: var(--white);\n }\n\n .help-widget {\n width: 108px;\n height: 46px;\n margin: 14px 20px;\n position: fixed;\n bottom: 0;\n right: 0;\n z-index: 999998;\n background: var(--button-blue);\n color: var(--link-color);\n letter-spacing: 0.6px;\n font-size: 14px;\n transition: opacity 0.12s linear;\n border-radius: 999rem;\n border: 0;\n outline: none;\n font-weight: 700;\n cursor: pointer;\n vertical-align: middle;\n }\n\n .fill-color {\n fill: var(--icon-fill-color);\n }\n\n .help-widget svg {\n vertical-align: middle;\n margin-right: 3px;\n pointer-events: none;\n }\n\n .help-widget .hidden-sm {\n pointer-events: none;\n }\n\n .hidden {\n opacity: 0;\n display: none;\n visibility: hidden;\n }\n\n @media (max-width: 767px) {\n .hidden-sm {\n display: none;\n }\n\n .help-widget {\n padding: 13px;\n width: initial;\n }\n\n .help-widget svg {\n margin-right: 0;\n }\n }\n `;\n }\n}\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<svg
|
|
2
|
+
class="icon-loader"
|
|
3
|
+
height="20"
|
|
4
|
+
viewBox="0 0 128 128"
|
|
5
|
+
width="20"
|
|
6
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
7
|
+
>
|
|
8
|
+
<g>
|
|
9
|
+
<circle cx="16" cy="64" r="16" class="fill-color" fill-opacity="1" />
|
|
10
|
+
<circle cx="16" cy="64" r="14.344" class="fill-color" fill-opacity="1" transform="rotate(45 64 64)" />
|
|
11
|
+
<circle cx="16" cy="64" r="12.531" class="fill-color" fill-opacity="1" transform="rotate(90 64 64)" />
|
|
12
|
+
<circle cx="16" cy="64" r="10.75" class="fill-color" fill-opacity="1" transform="rotate(135 64 64)" />
|
|
13
|
+
<circle cx="16" cy="64" r="10.063" class="fill-color" fill-opacity="1" transform="rotate(180 64 64)" />
|
|
14
|
+
<circle cx="16" cy="64" r="8.063" class="fill-color" fill-opacity="1" transform="rotate(225 64 64)" />
|
|
15
|
+
<circle cx="16" cy="64" r="6.438" class="fill-color" fill-opacity="1" transform="rotate(270 64 64)" />
|
|
16
|
+
<circle cx="16" cy="64" r="5.375" class="fill-color" fill-opacity="1" transform="rotate(315 64 64)" />
|
|
17
|
+
<animateTransform
|
|
18
|
+
attributeName="transform"
|
|
19
|
+
type="rotate"
|
|
20
|
+
values="0 64 64;315 64 64;270 64 64;225 64 64;180 64 64;135 64 64;90 64 64;45 64 64"
|
|
21
|
+
calcMode="discrete"
|
|
22
|
+
dur="720ms"
|
|
23
|
+
repeatCount="indefinite"
|
|
24
|
+
/>
|
|
25
|
+
</g>
|
|
26
|
+
</svg>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<svg
|
|
2
|
+
class="icon-question"
|
|
3
|
+
height="20"
|
|
4
|
+
viewBox="0 0 20 20"
|
|
5
|
+
width="20"
|
|
6
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
7
|
+
>
|
|
8
|
+
<g class="fill-color" fill-rule="nonzero">
|
|
9
|
+
<path
|
|
10
|
+
d="m10.7078125 12.8359375v-.4140625c0-.765625.2890625-1.1484375 1.328125-1.75
|
|
11
|
+
1.1015625-.6484375 1.671875-1.46875 1.671875-2.6484375
|
|
12
|
+
0-1.78125-1.4765625-3.0234375-3.7109375-3.0234375
|
|
13
|
+
-2.3984375 0-3.7578125 1.34375-3.796875 3.265625h2.1171875
|
|
14
|
+
c.046875-.8828125.640625-1.453125 1.5390625-1.453125
|
|
15
|
+
.890625 0 1.484375.5390625 1.484375 1.28125s-.3046875 1.125-1.3125 1.7265625
|
|
16
|
+
c-1.078125.6328125-1.5078125 1.3359375-1.40625 2.5625l.015625.453125z"
|
|
17
|
+
/>
|
|
18
|
+
<path
|
|
19
|
+
d="m9.7 16.57c.711 0 1.281-.539 1.281-1.227s-.57-1.226-1.28-1.226
|
|
20
|
+
c-.704 0-1.274.539-1.274 1.226s.57 1.227 1.274 1.227z"
|
|
21
|
+
/>
|
|
22
|
+
<path
|
|
23
|
+
d="m10 0c-5.523 0-10 4.477-10 10s4.477 10 10 10 10-4.477 10-10-4.477-10-10-10z
|
|
24
|
+
m0 2c4.418 0 8 3.582 8 8s-3.582 8-8 8-8-3.582-8-8 3.582-8 8-8z"
|
|
25
|
+
/>
|
|
26
|
+
</g>
|
|
27
|
+
</svg>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uCAAuC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/elements/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC","sourcesContent":["export * from './ia-button/ia-button';\nexport * from './ia-combo-box/ia-combo-box';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/elements/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uCAAuC,CAAC","sourcesContent":["export * from './ia-button/ia-button';\nexport * from './ia-combo-box/ia-combo-box';\nexport * from './ia-zendesk-widget/ia-zendesk-widget';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@internetarchive/elements",
|
|
3
|
-
"version": "0.2.1",
|
|
3
|
+
"version": "0.2.2-webdev-8356.1",
|
|
4
4
|
"description": "A web component library from the Internet Archive.",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"types": "./dist/src/elements/index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@lit/localize": "^0.12.2",
|
|
31
|
-
"lit": "^3.3.
|
|
31
|
+
"lit": "^2.8.0 || ^3.3.2",
|
|
32
32
|
"magic-snowflakes": "^7.0.2",
|
|
33
33
|
"tslib": "^2.8.1"
|
|
34
34
|
},
|