@spectrum-web-components/search 0.10.5 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -223,7 +223,7 @@
223
223
  {
224
224
  "kind": "variable",
225
225
  "name": "styles",
226
- "default": "css`\n:host{--spectrum-search-quiet-button-offset:calc(var(\n--spectrum-actionbutton-m-texticon-min-width,\nvar(--spectrum-global-dimension-size-400)\n)/2 - var(--spectrum-alias-ui-icon-cross-size-100)/2)}#textfield{display:inline-block;position:relative}:host([dir=ltr]) #button{right:0}:host([dir=rtl]) #button{left:0}#button{position:absolute;top:0}#input{-webkit-appearance:none;border-radius:var(\n--spectrum-alias-search-border-radius,var(--spectrum-global-dimension-size-50)\n);outline-offset:-2px}#input::-webkit-search-cancel-button,#input::-webkit-search-decoration{-webkit-appearance:none}#textfield:after{border-radius:var(\n--spectrum-alias-search-border-radius,var(--spectrum-global-dimension-size-50)\n)}:host([dir=ltr]:not([quiet])) #textfield .icon{left:var(\n--spectrum-alias-search-padding-left-m\n)}:host([dir=rtl]:not([quiet])) #textfield .icon{right:var(\n--spectrum-alias-search-padding-left-m\n)}:host([dir=ltr]:not([quiet])) #textfield #input{padding-left:calc(var(--spectrum-alias-search-padding-left-m) + var(\n--spectrum-alias-workflow-icon-size-m,\nvar(--spectrum-global-dimension-size-225)\n) + var(\n--spectrum-textfield-m-texticon-icon-gap,\nvar(--spectrum-global-dimension-size-100)\n) - var(\n--spectrum-textfield-m-texticon-border-size,\nvar(--spectrum-alias-input-border-size)\n))}:host([dir=rtl]:not([quiet])) #textfield #input{padding-right:calc(var(--spectrum-alias-search-padding-left-m) + var(\n--spectrum-alias-workflow-icon-size-m,\nvar(--spectrum-global-dimension-size-225)\n) + var(\n--spectrum-textfield-m-texticon-icon-gap,\nvar(--spectrum-global-dimension-size-100)\n) - var(\n--spectrum-textfield-m-texticon-border-size,\nvar(--spectrum-alias-input-border-size)\n))}:host([quiet]) #button{transform:translateX(var(--spectrum-search-quiet-button-offset))}:host([quiet]) #input{border-radius:var(\n--spectrum-alias-search-border-radius-quiet,0\n)}:host([quiet]) #textfield:after{border-radius:var(\n--spectrum-alias-search-border-radius-quiet,0\n)}.icon{color:var(\n--spectrum-textfield-m-texticon-icon-color,var(--spectrum-alias-component-icon-color-default)\n)}#input:hover~.icon{color:var(\n--spectrum-search-m-icon-color-hover,var(--spectrum-alias-component-icon-color-hover)\n)}#input:active~.icon{color:var(\n--spectrum-search-m-icon-color-down,var(--spectrum-alias-component-icon-color-down)\n)}#input.focus-visible~.icon{color:var(\n--spectrum-search-m-icon-color-key-focus,var(--spectrum-alias-component-icon-color-key-focus)\n)}#input:focus-visible~.icon{color:var(\n--spectrum-search-m-icon-color-key-focus,var(--spectrum-alias-component-icon-color-key-focus)\n)}#input:disabled~.icon{color:var(\n--spectrum-textfield-m-texticon-text-color-disabled,var(--spectrum-alias-component-text-color-disabled)\n)}input::-webkit-search-cancel-button{display:none}\n`"
226
+ "default": "css`\n:host{--spectrum-search-quiet-button-offset:calc(var(\n--spectrum-actionbutton-m-texticon-min-width,\nvar(--spectrum-global-dimension-size-400)\n)/2 - var(--spectrum-alias-ui-icon-cross-size-100)/2)}#textfield{display:inline-block;position:relative}:host([dir=ltr]) #button{right:0}:host([dir=rtl]) #button{left:0}#button{position:absolute;top:0}.input{-webkit-appearance:none;border-radius:var(\n--spectrum-alias-search-border-radius,var(--spectrum-global-dimension-size-50)\n);outline-offset:-2px}.input::-webkit-search-cancel-button,.input::-webkit-search-decoration{-webkit-appearance:none}#textfield:after{border-radius:var(\n--spectrum-alias-search-border-radius,var(--spectrum-global-dimension-size-50)\n)}:host([dir=ltr]:not([quiet])) #textfield .icon{left:var(\n--spectrum-alias-search-padding-left-m\n)}:host([dir=rtl]:not([quiet])) #textfield .icon{right:var(\n--spectrum-alias-search-padding-left-m\n)}:host([dir=ltr]:not([quiet])) #textfield .input{padding-left:calc(var(--spectrum-alias-search-padding-left-m) + var(\n--spectrum-alias-workflow-icon-size-m,\nvar(--spectrum-global-dimension-size-225)\n) + var(\n--spectrum-textfield-m-texticon-icon-gap,\nvar(--spectrum-global-dimension-size-100)\n) - var(\n--spectrum-textfield-m-texticon-border-size,\nvar(--spectrum-alias-input-border-size)\n))}:host([dir=rtl]:not([quiet])) #textfield .input{padding-right:calc(var(--spectrum-alias-search-padding-left-m) + var(\n--spectrum-alias-workflow-icon-size-m,\nvar(--spectrum-global-dimension-size-225)\n) + var(\n--spectrum-textfield-m-texticon-icon-gap,\nvar(--spectrum-global-dimension-size-100)\n) - var(\n--spectrum-textfield-m-texticon-border-size,\nvar(--spectrum-alias-input-border-size)\n))}:host([quiet]) #button{transform:translateX(var(--spectrum-search-quiet-button-offset))}:host([quiet]) .input{border-radius:var(\n--spectrum-alias-search-border-radius-quiet,0\n)}:host([quiet]) #textfield:after{border-radius:var(\n--spectrum-alias-search-border-radius-quiet,0\n)}.icon{color:var(\n--spectrum-textfield-m-texticon-icon-color,var(--spectrum-alias-component-icon-color-default)\n)}.input:hover~.icon{color:var(\n--spectrum-search-m-icon-color-hover,var(--spectrum-alias-component-icon-color-hover)\n)}.input:active~.icon{color:var(\n--spectrum-search-m-icon-color-down,var(--spectrum-alias-component-icon-color-down)\n)}.input.focus-visible~.icon{color:var(\n--spectrum-search-m-icon-color-key-focus,var(--spectrum-alias-component-icon-color-key-focus)\n)}.input:focus-visible~.icon{color:var(\n--spectrum-search-m-icon-color-key-focus,var(--spectrum-alias-component-icon-color-key-focus)\n)}.input:disabled~.icon{color:var(\n--spectrum-textfield-m-texticon-text-color-disabled,var(--spectrum-alias-component-text-color-disabled)\n)}input::-webkit-search-cancel-button{display:none}\n`"
227
227
  }
228
228
  ],
229
229
  "exports": [
@@ -244,7 +244,7 @@
244
244
  {
245
245
  "kind": "variable",
246
246
  "name": "styles",
247
- "default": "css`\n:host{--spectrum-search-quiet-button-offset:calc(var(\n--spectrum-actionbutton-m-texticon-min-width,\nvar(--spectrum-global-dimension-size-400)\n)/2 - var(--spectrum-alias-ui-icon-cross-size-100)/2)}#textfield{display:inline-block;position:relative}:host([dir=ltr]) #button{right:0}:host([dir=rtl]) #button{left:0}#button{position:absolute;top:0}#input{-webkit-appearance:none;border-radius:var(\n--spectrum-alias-search-border-radius,var(--spectrum-global-dimension-size-50)\n);outline-offset:-2px}#input::-webkit-search-cancel-button,#input::-webkit-search-decoration{-webkit-appearance:none}#textfield:after{border-radius:var(\n--spectrum-alias-search-border-radius,var(--spectrum-global-dimension-size-50)\n)}:host([dir=ltr]:not([quiet])) #textfield .icon{left:var(\n--spectrum-alias-search-padding-left-m\n)}:host([dir=rtl]:not([quiet])) #textfield .icon{right:var(\n--spectrum-alias-search-padding-left-m\n)}:host([dir=ltr]:not([quiet])) #textfield #input{padding-left:calc(var(--spectrum-alias-search-padding-left-m) + var(\n--spectrum-alias-workflow-icon-size-m,\nvar(--spectrum-global-dimension-size-225)\n) + var(\n--spectrum-textfield-m-texticon-icon-gap,\nvar(--spectrum-global-dimension-size-100)\n) - var(\n--spectrum-textfield-m-texticon-border-size,\nvar(--spectrum-alias-input-border-size)\n))}:host([dir=rtl]:not([quiet])) #textfield #input{padding-right:calc(var(--spectrum-alias-search-padding-left-m) + var(\n--spectrum-alias-workflow-icon-size-m,\nvar(--spectrum-global-dimension-size-225)\n) + var(\n--spectrum-textfield-m-texticon-icon-gap,\nvar(--spectrum-global-dimension-size-100)\n) - var(\n--spectrum-textfield-m-texticon-border-size,\nvar(--spectrum-alias-input-border-size)\n))}:host([quiet]) #button{transform:translateX(var(--spectrum-search-quiet-button-offset))}:host([quiet]) #input{border-radius:var(\n--spectrum-alias-search-border-radius-quiet,0\n)}:host([quiet]) #textfield:after{border-radius:var(\n--spectrum-alias-search-border-radius-quiet,0\n)}.icon{color:var(\n--spectrum-textfield-m-texticon-icon-color,var(--spectrum-alias-component-icon-color-default)\n)}#input:hover~.icon{color:var(\n--spectrum-search-m-icon-color-hover,var(--spectrum-alias-component-icon-color-hover)\n)}#input:active~.icon{color:var(\n--spectrum-search-m-icon-color-down,var(--spectrum-alias-component-icon-color-down)\n)}#input.focus-visible~.icon{color:var(\n--spectrum-search-m-icon-color-key-focus,var(--spectrum-alias-component-icon-color-key-focus)\n)}#input:focus-visible~.icon{color:var(\n--spectrum-search-m-icon-color-key-focus,var(--spectrum-alias-component-icon-color-key-focus)\n)}#input:disabled~.icon{color:var(\n--spectrum-textfield-m-texticon-text-color-disabled,var(--spectrum-alias-component-text-color-disabled)\n)}\n`"
247
+ "default": "css`\n:host{--spectrum-search-quiet-button-offset:calc(var(\n--spectrum-actionbutton-m-texticon-min-width,\nvar(--spectrum-global-dimension-size-400)\n)/2 - var(--spectrum-alias-ui-icon-cross-size-100)/2)}#textfield{display:inline-block;position:relative}:host([dir=ltr]) #button{right:0}:host([dir=rtl]) #button{left:0}#button{position:absolute;top:0}.input{-webkit-appearance:none;border-radius:var(\n--spectrum-alias-search-border-radius,var(--spectrum-global-dimension-size-50)\n);outline-offset:-2px}.input::-webkit-search-cancel-button,.input::-webkit-search-decoration{-webkit-appearance:none}#textfield:after{border-radius:var(\n--spectrum-alias-search-border-radius,var(--spectrum-global-dimension-size-50)\n)}:host([dir=ltr]:not([quiet])) #textfield .icon{left:var(\n--spectrum-alias-search-padding-left-m\n)}:host([dir=rtl]:not([quiet])) #textfield .icon{right:var(\n--spectrum-alias-search-padding-left-m\n)}:host([dir=ltr]:not([quiet])) #textfield .input{padding-left:calc(var(--spectrum-alias-search-padding-left-m) + var(\n--spectrum-alias-workflow-icon-size-m,\nvar(--spectrum-global-dimension-size-225)\n) + var(\n--spectrum-textfield-m-texticon-icon-gap,\nvar(--spectrum-global-dimension-size-100)\n) - var(\n--spectrum-textfield-m-texticon-border-size,\nvar(--spectrum-alias-input-border-size)\n))}:host([dir=rtl]:not([quiet])) #textfield .input{padding-right:calc(var(--spectrum-alias-search-padding-left-m) + var(\n--spectrum-alias-workflow-icon-size-m,\nvar(--spectrum-global-dimension-size-225)\n) + var(\n--spectrum-textfield-m-texticon-icon-gap,\nvar(--spectrum-global-dimension-size-100)\n) - var(\n--spectrum-textfield-m-texticon-border-size,\nvar(--spectrum-alias-input-border-size)\n))}:host([quiet]) #button{transform:translateX(var(--spectrum-search-quiet-button-offset))}:host([quiet]) .input{border-radius:var(\n--spectrum-alias-search-border-radius-quiet,0\n)}:host([quiet]) #textfield:after{border-radius:var(\n--spectrum-alias-search-border-radius-quiet,0\n)}.icon{color:var(\n--spectrum-textfield-m-texticon-icon-color,var(--spectrum-alias-component-icon-color-default)\n)}.input:hover~.icon{color:var(\n--spectrum-search-m-icon-color-hover,var(--spectrum-alias-component-icon-color-hover)\n)}.input:active~.icon{color:var(\n--spectrum-search-m-icon-color-down,var(--spectrum-alias-component-icon-color-down)\n)}.input.focus-visible~.icon{color:var(\n--spectrum-search-m-icon-color-key-focus,var(--spectrum-alias-component-icon-color-key-focus)\n)}.input:focus-visible~.icon{color:var(\n--spectrum-search-m-icon-color-key-focus,var(--spectrum-alias-component-icon-color-key-focus)\n)}.input:disabled~.icon{color:var(\n--spectrum-textfield-m-texticon-text-color-disabled,var(--spectrum-alias-component-text-color-disabled)\n)}\n`"
248
248
  }
249
249
  ],
250
250
  "exports": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectrum-web-components/search",
3
- "version": "0.10.5",
3
+ "version": "0.11.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -44,20 +44,20 @@
44
44
  "lit-html"
45
45
  ],
46
46
  "dependencies": {
47
- "@spectrum-web-components/base": "^0.5.3",
48
- "@spectrum-web-components/button": "^0.17.0",
49
- "@spectrum-web-components/icon": "^0.11.4",
50
- "@spectrum-web-components/icons-workflow": "^0.8.4",
51
- "@spectrum-web-components/textfield": "^0.11.2",
47
+ "@spectrum-web-components/base": "^0.5.5",
48
+ "@spectrum-web-components/button": "^0.17.3",
49
+ "@spectrum-web-components/icon": "^0.11.6",
50
+ "@spectrum-web-components/icons-workflow": "^0.8.6",
51
+ "@spectrum-web-components/textfield": "^0.11.5",
52
52
  "tslib": "^2.0.0"
53
53
  },
54
54
  "devDependencies": {
55
- "@spectrum-css/search": "^4.2.3"
55
+ "@spectrum-css/search": "^4.2.8"
56
56
  },
57
57
  "types": "./src/index.d.ts",
58
58
  "customElements": "custom-elements.json",
59
59
  "sideEffects": [
60
60
  "./sp-*.js"
61
61
  ],
62
- "gitHead": "57aba8030b6af96af4015a0aa830e342a17dc219"
62
+ "gitHead": "bdff893e2b95aba7737c58d01c6ac68861cb8b2e"
63
63
  }
package/sp-search.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { Search } from './src/Search.js';
2
+ declare global {
3
+ interface HTMLElementTagNameMap {
4
+ 'sp-search': Search;
5
+ }
6
+ }
package/sp-search.js ADDED
@@ -0,0 +1,14 @@
1
+ /*
2
+ Copyright 2020 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software distributed under
8
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ OF ANY KIND, either express or implied. See the License for the specific language
10
+ governing permissions and limitations under the License.
11
+ */
12
+ import { Search } from './src/Search.js';
13
+ customElements.define('sp-search', Search);
14
+ //# sourceMappingURL=sp-search.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sp-search.js","sourceRoot":"","sources":["sp-search.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,cAAc,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { Search } from './src/Search.js';\n\ncustomElements.define('sp-search', Search);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-search': Search;\n }\n}\n"]}
@@ -0,0 +1,25 @@
1
+ import { CSSResultArray, PropertyValues, TemplateResult } from '@spectrum-web-components/base';
2
+ import { Textfield } from '@spectrum-web-components/textfield';
3
+ import '@spectrum-web-components/button/sp-clear-button.js';
4
+ import '@spectrum-web-components/icons-workflow/icons/sp-icon-magnify.js';
5
+ /**
6
+ * @element sp-search
7
+ * @slot help-text - default or non-negative help text to associate to your form element
8
+ * @slot negative-help-text - negative help text to associate to your form element when `invalid`
9
+ *
10
+ * @fires submit - The search form has been submitted.
11
+ */
12
+ export declare class Search extends Textfield {
13
+ static get styles(): CSSResultArray;
14
+ action: string;
15
+ label: string;
16
+ method?: 'GET' | 'POST' | 'dialog';
17
+ placeholder: string;
18
+ form: HTMLFormElement;
19
+ private handleSubmit;
20
+ private handleKeydown;
21
+ reset(): Promise<void>;
22
+ protected renderField(): TemplateResult;
23
+ firstUpdated(changedProperties: PropertyValues): void;
24
+ updated(changedProperties: PropertyValues): void;
25
+ }
package/src/Search.js ADDED
@@ -0,0 +1,121 @@
1
+ /*
2
+ Copyright 2020 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software distributed under
8
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ OF ANY KIND, either express or implied. See the License for the specific language
10
+ governing permissions and limitations under the License.
11
+ */
12
+ import { __decorate } from "tslib";
13
+ import { html, } from '@spectrum-web-components/base';
14
+ import { property, query, } from '@spectrum-web-components/base/src/decorators.js';
15
+ import { ifDefined } from '@spectrum-web-components/base/src/directives.js';
16
+ import { Textfield } from '@spectrum-web-components/textfield';
17
+ import '@spectrum-web-components/button/sp-clear-button.js';
18
+ import '@spectrum-web-components/icons-workflow/icons/sp-icon-magnify.js';
19
+ import searchStyles from './search.css.js';
20
+ const stopPropagation = (event) => event.stopPropagation();
21
+ /**
22
+ * @element sp-search
23
+ * @slot help-text - default or non-negative help text to associate to your form element
24
+ * @slot negative-help-text - negative help text to associate to your form element when `invalid`
25
+ *
26
+ * @fires submit - The search form has been submitted.
27
+ */
28
+ export class Search extends Textfield {
29
+ constructor() {
30
+ super(...arguments);
31
+ this.action = '';
32
+ this.label = 'Search';
33
+ this.placeholder = 'Search';
34
+ }
35
+ static get styles() {
36
+ return [...super.styles, searchStyles];
37
+ }
38
+ handleSubmit(event) {
39
+ const applyDefault = this.dispatchEvent(new Event('submit', {
40
+ cancelable: true,
41
+ bubbles: true,
42
+ }));
43
+ if (!applyDefault) {
44
+ event.preventDefault();
45
+ }
46
+ }
47
+ handleKeydown(event) {
48
+ const { code } = event;
49
+ if (!this.value || code !== 'Escape') {
50
+ return;
51
+ }
52
+ this.reset();
53
+ }
54
+ async reset() {
55
+ this.value = '';
56
+ await this.updateComplete;
57
+ this.focusElement.dispatchEvent(new InputEvent('input', {
58
+ bubbles: true,
59
+ composed: true,
60
+ }));
61
+ // The native `change` event on an `input` element is not composed,
62
+ // so this synthetic replication of a `change` event must not be
63
+ // either as the `Textfield` baseclass should only need to handle
64
+ // the native variant of this interaction.
65
+ this.focusElement.dispatchEvent(new InputEvent('change', {
66
+ bubbles: true,
67
+ }));
68
+ }
69
+ renderField() {
70
+ return html `
71
+ <form
72
+ action=${this.action}
73
+ id="form"
74
+ method=${ifDefined(this.method)}
75
+ @submit=${this.handleSubmit}
76
+ @reset=${this.reset}
77
+ @keydown=${this.handleKeydown}
78
+ >
79
+ <sp-icon-magnify
80
+ class="icon magnifier icon-workflow"
81
+ ></sp-icon-magnify>
82
+ ${super.renderField()}
83
+ ${this.value
84
+ ? html `
85
+ <sp-clear-button
86
+ id="button"
87
+ label="Reset"
88
+ tabindex="-1"
89
+ type="reset"
90
+ @keydown=${stopPropagation}
91
+ ></sp-clear-button>
92
+ `
93
+ : html ``}
94
+ </form>
95
+ `;
96
+ }
97
+ firstUpdated(changedProperties) {
98
+ super.firstUpdated(changedProperties);
99
+ this.inputElement.setAttribute('type', 'search');
100
+ }
101
+ updated(changedProperties) {
102
+ super.updated(changedProperties);
103
+ this.multiline = false;
104
+ }
105
+ }
106
+ __decorate([
107
+ property()
108
+ ], Search.prototype, "action", void 0);
109
+ __decorate([
110
+ property()
111
+ ], Search.prototype, "label", void 0);
112
+ __decorate([
113
+ property()
114
+ ], Search.prototype, "method", void 0);
115
+ __decorate([
116
+ property()
117
+ ], Search.prototype, "placeholder", void 0);
118
+ __decorate([
119
+ query('#form')
120
+ ], Search.prototype, "form", void 0);
121
+ //# sourceMappingURL=Search.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Search.js","sourceRoot":"","sources":["Search.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;;AAEF,OAAO,EAEH,IAAI,GAGP,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACH,QAAQ,EACR,KAAK,GACR,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,iDAAiD,CAAC;AAE5E,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAC/D,OAAO,oDAAoD,CAAC;AAC5D,OAAO,kEAAkE,CAAC;AAE1E,OAAO,YAAY,MAAM,iBAAiB,CAAC;AAE3C,MAAM,eAAe,GAAG,CAAC,KAAY,EAAQ,EAAE,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC;AAExE;;;;;;GAMG;AACH,MAAM,OAAO,MAAO,SAAQ,SAAS;IAArC;;QAMW,WAAM,GAAG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AClB,IAAI,CAAC,KAAK;2BACR,IAAI,CAAC,aAAa;;;;;kBAK3B,KAAK,CAAC,WAAW,EAAE;kBACnB,IAAI,CAAC,KAAK;YACR,CAAC,CAAC,IAAI,CAAA;;;;;;yCAMe,eAAe;;uBAEjC;YACH,CAAC,CAAC,IAAI,CAAA,EAAE;;SAEnB,CAAC;IACN,CAAC;IAEM,YAAY,CAAC,iBAAiC;QACjD,KAAK,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC;QACtC,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACrD,CAAC;IAEM,OAAO,CAAC,iBAAiC;QAC5C,KAAK,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;QACjC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IAC3B,CAAC;CACJ;AA5FG;IADC,QAAQ,EAAE;sCACQ;AAGnB;IADC,QAAQ,EAAE;qCACa;AAGxB;IADC,QAAQ,EAAE;sCAC+B;AAG1C;IADC,QAAQ,EAAE;2CACmB;AAG9B;IADC,KAAK,CAAC,OAAO,CAAC;oCACe","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n html,\n PropertyValues,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n property,\n query,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport { ifDefined } from '@spectrum-web-components/base/src/directives.js';\n\nimport { Textfield } from '@spectrum-web-components/textfield';\nimport '@spectrum-web-components/button/sp-clear-button.js';\nimport '@spectrum-web-components/icons-workflow/icons/sp-icon-magnify.js';\n\nimport searchStyles from './search.css.js';\n\nconst stopPropagation = (event: Event): void => event.stopPropagation();\n\n/**\n * @element sp-search\n * @slot help-text - default or non-negative help text to associate to your form element\n * @slot negative-help-text - negative help text to associate to your form element when `invalid`\n *\n * @fires submit - The search form has been submitted.\n */\nexport class Search extends Textfield {\n public static get styles(): CSSResultArray {\n return [...super.styles, searchStyles];\n }\n\n @property()\n public action = '';\n\n @property()\n public label = 'Search';\n\n @property()\n public method?: 'GET' | 'POST' | 'dialog';\n\n @property()\n public placeholder = 'Search';\n\n @query('#form')\n public form!: HTMLFormElement;\n\n private handleSubmit(event: Event): void {\n const applyDefault = this.dispatchEvent(\n new Event('submit', {\n cancelable: true,\n bubbles: true,\n })\n );\n if (!applyDefault) {\n event.preventDefault();\n }\n }\n\n private handleKeydown(event: KeyboardEvent): void {\n const { code } = event;\n if (!this.value || code !== 'Escape') {\n return;\n }\n this.reset();\n }\n\n public async reset(): Promise<void> {\n this.value = '';\n await this.updateComplete;\n this.focusElement.dispatchEvent(\n new InputEvent('input', {\n bubbles: true,\n composed: true,\n })\n );\n // The native `change` event on an `input` element is not composed,\n // so this synthetic replication of a `change` event must not be\n // either as the `Textfield` baseclass should only need to handle\n // the native variant of this interaction.\n this.focusElement.dispatchEvent(\n new InputEvent('change', {\n bubbles: true,\n })\n );\n }\n\n protected renderField(): TemplateResult {\n return html`\n <form\n action=${this.action}\n id=\"form\"\n method=${ifDefined(this.method)}\n @submit=${this.handleSubmit}\n @reset=${this.reset}\n @keydown=${this.handleKeydown}\n >\n <sp-icon-magnify\n class=\"icon magnifier icon-workflow\"\n ></sp-icon-magnify>\n ${super.renderField()}\n ${this.value\n ? html`\n <sp-clear-button\n id=\"button\"\n label=\"Reset\"\n tabindex=\"-1\"\n type=\"reset\"\n @keydown=${stopPropagation}\n ></sp-clear-button>\n `\n : html``}\n </form>\n `;\n }\n\n public firstUpdated(changedProperties: PropertyValues): void {\n super.firstUpdated(changedProperties);\n this.inputElement.setAttribute('type', 'search');\n }\n\n public updated(changedProperties: PropertyValues): void {\n super.updated(changedProperties);\n this.multiline = false;\n }\n}\n"]}
package/src/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './Search.js';
package/src/index.js ADDED
@@ -0,0 +1,13 @@
1
+ /*
2
+ Copyright 2020 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software distributed under
8
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ OF ANY KIND, either express or implied. See the License for the specific language
10
+ governing permissions and limitations under the License.
11
+ */
12
+ export * from './Search.js';
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,cAAc,aAAa,CAAC","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nexport * from './Search.js';\n"]}
@@ -0,0 +1,2 @@
1
+ declare const styles: import("@spectrum-web-components/base").CSSResult;
2
+ export default styles;
@@ -0,0 +1,62 @@
1
+ /*
2
+ Copyright 2022 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software distributed under
8
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ OF ANY KIND, either express or implied. See the License for the specific language
10
+ governing permissions and limitations under the License.
11
+ */
12
+ import { css } from '@spectrum-web-components/base';
13
+ const styles = css `
14
+ :host{--spectrum-search-quiet-button-offset:calc(var(
15
+ --spectrum-actionbutton-m-texticon-min-width,
16
+ var(--spectrum-global-dimension-size-400)
17
+ )/2 - var(--spectrum-alias-ui-icon-cross-size-100)/2)}#textfield{display:inline-block;position:relative}:host([dir=ltr]) #button{right:0}:host([dir=rtl]) #button{left:0}#button{position:absolute;top:0}.input{-webkit-appearance:none;border-radius:var(
18
+ --spectrum-alias-search-border-radius,var(--spectrum-global-dimension-size-50)
19
+ );outline-offset:-2px}.input::-webkit-search-cancel-button,.input::-webkit-search-decoration{-webkit-appearance:none}#textfield:after{border-radius:var(
20
+ --spectrum-alias-search-border-radius,var(--spectrum-global-dimension-size-50)
21
+ )}:host([dir=ltr]:not([quiet])) #textfield .icon{left:var(
22
+ --spectrum-alias-search-padding-left-m
23
+ )}:host([dir=rtl]:not([quiet])) #textfield .icon{right:var(
24
+ --spectrum-alias-search-padding-left-m
25
+ )}:host([dir=ltr]:not([quiet])) #textfield .input{padding-left:calc(var(--spectrum-alias-search-padding-left-m) + var(
26
+ --spectrum-alias-workflow-icon-size-m,
27
+ var(--spectrum-global-dimension-size-225)
28
+ ) + var(
29
+ --spectrum-textfield-m-texticon-icon-gap,
30
+ var(--spectrum-global-dimension-size-100)
31
+ ) - var(
32
+ --spectrum-textfield-m-texticon-border-size,
33
+ var(--spectrum-alias-input-border-size)
34
+ ))}:host([dir=rtl]:not([quiet])) #textfield .input{padding-right:calc(var(--spectrum-alias-search-padding-left-m) + var(
35
+ --spectrum-alias-workflow-icon-size-m,
36
+ var(--spectrum-global-dimension-size-225)
37
+ ) + var(
38
+ --spectrum-textfield-m-texticon-icon-gap,
39
+ var(--spectrum-global-dimension-size-100)
40
+ ) - var(
41
+ --spectrum-textfield-m-texticon-border-size,
42
+ var(--spectrum-alias-input-border-size)
43
+ ))}:host([quiet]) #button{transform:translateX(var(--spectrum-search-quiet-button-offset))}:host([quiet]) .input{border-radius:var(
44
+ --spectrum-alias-search-border-radius-quiet,0
45
+ )}:host([quiet]) #textfield:after{border-radius:var(
46
+ --spectrum-alias-search-border-radius-quiet,0
47
+ )}.icon{color:var(
48
+ --spectrum-textfield-m-texticon-icon-color,var(--spectrum-alias-component-icon-color-default)
49
+ )}.input:hover~.icon{color:var(
50
+ --spectrum-search-m-icon-color-hover,var(--spectrum-alias-component-icon-color-hover)
51
+ )}.input:active~.icon{color:var(
52
+ --spectrum-search-m-icon-color-down,var(--spectrum-alias-component-icon-color-down)
53
+ )}.input.focus-visible~.icon{color:var(
54
+ --spectrum-search-m-icon-color-key-focus,var(--spectrum-alias-component-icon-color-key-focus)
55
+ )}.input:focus-visible~.icon{color:var(
56
+ --spectrum-search-m-icon-color-key-focus,var(--spectrum-alias-component-icon-color-key-focus)
57
+ )}.input:disabled~.icon{color:var(
58
+ --spectrum-textfield-m-texticon-text-color-disabled,var(--spectrum-alias-component-text-color-disabled)
59
+ )}input::-webkit-search-cancel-button{display:none}
60
+ `;
61
+ export default styles;
62
+ //# sourceMappingURL=search.css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search.css.js","sourceRoot":"","sources":["search.css.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AACpD,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+CjB,CAAC;AACF,eAAe,MAAM,CAAC","sourcesContent":["/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { css } from '@spectrum-web-components/base';\nconst styles = css`\n:host{--spectrum-search-quiet-button-offset:calc(var(\n--spectrum-actionbutton-m-texticon-min-width,\nvar(--spectrum-global-dimension-size-400)\n)/2 - var(--spectrum-alias-ui-icon-cross-size-100)/2)}#textfield{display:inline-block;position:relative}:host([dir=ltr]) #button{right:0}:host([dir=rtl]) #button{left:0}#button{position:absolute;top:0}.input{-webkit-appearance:none;border-radius:var(\n--spectrum-alias-search-border-radius,var(--spectrum-global-dimension-size-50)\n);outline-offset:-2px}.input::-webkit-search-cancel-button,.input::-webkit-search-decoration{-webkit-appearance:none}#textfield:after{border-radius:var(\n--spectrum-alias-search-border-radius,var(--spectrum-global-dimension-size-50)\n)}:host([dir=ltr]:not([quiet])) #textfield .icon{left:var(\n--spectrum-alias-search-padding-left-m\n)}:host([dir=rtl]:not([quiet])) #textfield .icon{right:var(\n--spectrum-alias-search-padding-left-m\n)}:host([dir=ltr]:not([quiet])) #textfield .input{padding-left:calc(var(--spectrum-alias-search-padding-left-m) + var(\n--spectrum-alias-workflow-icon-size-m,\nvar(--spectrum-global-dimension-size-225)\n) + var(\n--spectrum-textfield-m-texticon-icon-gap,\nvar(--spectrum-global-dimension-size-100)\n) - var(\n--spectrum-textfield-m-texticon-border-size,\nvar(--spectrum-alias-input-border-size)\n))}:host([dir=rtl]:not([quiet])) #textfield .input{padding-right:calc(var(--spectrum-alias-search-padding-left-m) + var(\n--spectrum-alias-workflow-icon-size-m,\nvar(--spectrum-global-dimension-size-225)\n) + var(\n--spectrum-textfield-m-texticon-icon-gap,\nvar(--spectrum-global-dimension-size-100)\n) - var(\n--spectrum-textfield-m-texticon-border-size,\nvar(--spectrum-alias-input-border-size)\n))}:host([quiet]) #button{transform:translateX(var(--spectrum-search-quiet-button-offset))}:host([quiet]) .input{border-radius:var(\n--spectrum-alias-search-border-radius-quiet,0\n)}:host([quiet]) #textfield:after{border-radius:var(\n--spectrum-alias-search-border-radius-quiet,0\n)}.icon{color:var(\n--spectrum-textfield-m-texticon-icon-color,var(--spectrum-alias-component-icon-color-default)\n)}.input:hover~.icon{color:var(\n--spectrum-search-m-icon-color-hover,var(--spectrum-alias-component-icon-color-hover)\n)}.input:active~.icon{color:var(\n--spectrum-search-m-icon-color-down,var(--spectrum-alias-component-icon-color-down)\n)}.input.focus-visible~.icon{color:var(\n--spectrum-search-m-icon-color-key-focus,var(--spectrum-alias-component-icon-color-key-focus)\n)}.input:focus-visible~.icon{color:var(\n--spectrum-search-m-icon-color-key-focus,var(--spectrum-alias-component-icon-color-key-focus)\n)}.input:disabled~.icon{color:var(\n--spectrum-textfield-m-texticon-text-color-disabled,var(--spectrum-alias-component-text-color-disabled)\n)}input::-webkit-search-cancel-button{display:none}\n`;\nexport default styles;"]}
@@ -19,7 +19,7 @@ const config = {
19
19
  selector: '.spectrum-Search',
20
20
  shadowSelector: '#textfield',
21
21
  },
22
- focus: '#input',
22
+ focus: '.input',
23
23
  attributes: [
24
24
  {
25
25
  type: 'boolean',
@@ -28,10 +28,6 @@ const config = {
28
28
  },
29
29
  ],
30
30
  ids: [
31
- {
32
- selector: '.spectrum-Search-input',
33
- name: 'input',
34
- },
35
31
  {
36
32
  selector: '.spectrum-Search-clearButton',
37
33
  name: 'button',
@@ -42,6 +38,10 @@ const config = {
42
38
  },
43
39
  ],
44
40
  classes: [
41
+ {
42
+ selector: '.spectrum-Search-input',
43
+ name: 'input',
44
+ },
45
45
  {
46
46
  selector: '.spectrum-Icon',
47
47
  name: 'icon',
@@ -0,0 +1,2 @@
1
+ declare const styles: import("@spectrum-web-components/base").CSSResult;
2
+ export default styles;
@@ -0,0 +1,62 @@
1
+ /*
2
+ Copyright 2022 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software distributed under
8
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ OF ANY KIND, either express or implied. See the License for the specific language
10
+ governing permissions and limitations under the License.
11
+ */
12
+ import { css } from '@spectrum-web-components/base';
13
+ const styles = css `
14
+ :host{--spectrum-search-quiet-button-offset:calc(var(
15
+ --spectrum-actionbutton-m-texticon-min-width,
16
+ var(--spectrum-global-dimension-size-400)
17
+ )/2 - var(--spectrum-alias-ui-icon-cross-size-100)/2)}#textfield{display:inline-block;position:relative}:host([dir=ltr]) #button{right:0}:host([dir=rtl]) #button{left:0}#button{position:absolute;top:0}.input{-webkit-appearance:none;border-radius:var(
18
+ --spectrum-alias-search-border-radius,var(--spectrum-global-dimension-size-50)
19
+ );outline-offset:-2px}.input::-webkit-search-cancel-button,.input::-webkit-search-decoration{-webkit-appearance:none}#textfield:after{border-radius:var(
20
+ --spectrum-alias-search-border-radius,var(--spectrum-global-dimension-size-50)
21
+ )}:host([dir=ltr]:not([quiet])) #textfield .icon{left:var(
22
+ --spectrum-alias-search-padding-left-m
23
+ )}:host([dir=rtl]:not([quiet])) #textfield .icon{right:var(
24
+ --spectrum-alias-search-padding-left-m
25
+ )}:host([dir=ltr]:not([quiet])) #textfield .input{padding-left:calc(var(--spectrum-alias-search-padding-left-m) + var(
26
+ --spectrum-alias-workflow-icon-size-m,
27
+ var(--spectrum-global-dimension-size-225)
28
+ ) + var(
29
+ --spectrum-textfield-m-texticon-icon-gap,
30
+ var(--spectrum-global-dimension-size-100)
31
+ ) - var(
32
+ --spectrum-textfield-m-texticon-border-size,
33
+ var(--spectrum-alias-input-border-size)
34
+ ))}:host([dir=rtl]:not([quiet])) #textfield .input{padding-right:calc(var(--spectrum-alias-search-padding-left-m) + var(
35
+ --spectrum-alias-workflow-icon-size-m,
36
+ var(--spectrum-global-dimension-size-225)
37
+ ) + var(
38
+ --spectrum-textfield-m-texticon-icon-gap,
39
+ var(--spectrum-global-dimension-size-100)
40
+ ) - var(
41
+ --spectrum-textfield-m-texticon-border-size,
42
+ var(--spectrum-alias-input-border-size)
43
+ ))}:host([quiet]) #button{transform:translateX(var(--spectrum-search-quiet-button-offset))}:host([quiet]) .input{border-radius:var(
44
+ --spectrum-alias-search-border-radius-quiet,0
45
+ )}:host([quiet]) #textfield:after{border-radius:var(
46
+ --spectrum-alias-search-border-radius-quiet,0
47
+ )}.icon{color:var(
48
+ --spectrum-textfield-m-texticon-icon-color,var(--spectrum-alias-component-icon-color-default)
49
+ )}.input:hover~.icon{color:var(
50
+ --spectrum-search-m-icon-color-hover,var(--spectrum-alias-component-icon-color-hover)
51
+ )}.input:active~.icon{color:var(
52
+ --spectrum-search-m-icon-color-down,var(--spectrum-alias-component-icon-color-down)
53
+ )}.input.focus-visible~.icon{color:var(
54
+ --spectrum-search-m-icon-color-key-focus,var(--spectrum-alias-component-icon-color-key-focus)
55
+ )}.input:focus-visible~.icon{color:var(
56
+ --spectrum-search-m-icon-color-key-focus,var(--spectrum-alias-component-icon-color-key-focus)
57
+ )}.input:disabled~.icon{color:var(
58
+ --spectrum-textfield-m-texticon-text-color-disabled,var(--spectrum-alias-component-text-color-disabled)
59
+ )}
60
+ `;
61
+ export default styles;
62
+ //# sourceMappingURL=spectrum-search.css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spectrum-search.css.js","sourceRoot":"","sources":["spectrum-search.css.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AACpD,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+CjB,CAAC;AACF,eAAe,MAAM,CAAC","sourcesContent":["/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { css } from '@spectrum-web-components/base';\nconst styles = css`\n:host{--spectrum-search-quiet-button-offset:calc(var(\n--spectrum-actionbutton-m-texticon-min-width,\nvar(--spectrum-global-dimension-size-400)\n)/2 - var(--spectrum-alias-ui-icon-cross-size-100)/2)}#textfield{display:inline-block;position:relative}:host([dir=ltr]) #button{right:0}:host([dir=rtl]) #button{left:0}#button{position:absolute;top:0}.input{-webkit-appearance:none;border-radius:var(\n--spectrum-alias-search-border-radius,var(--spectrum-global-dimension-size-50)\n);outline-offset:-2px}.input::-webkit-search-cancel-button,.input::-webkit-search-decoration{-webkit-appearance:none}#textfield:after{border-radius:var(\n--spectrum-alias-search-border-radius,var(--spectrum-global-dimension-size-50)\n)}:host([dir=ltr]:not([quiet])) #textfield .icon{left:var(\n--spectrum-alias-search-padding-left-m\n)}:host([dir=rtl]:not([quiet])) #textfield .icon{right:var(\n--spectrum-alias-search-padding-left-m\n)}:host([dir=ltr]:not([quiet])) #textfield .input{padding-left:calc(var(--spectrum-alias-search-padding-left-m) + var(\n--spectrum-alias-workflow-icon-size-m,\nvar(--spectrum-global-dimension-size-225)\n) + var(\n--spectrum-textfield-m-texticon-icon-gap,\nvar(--spectrum-global-dimension-size-100)\n) - var(\n--spectrum-textfield-m-texticon-border-size,\nvar(--spectrum-alias-input-border-size)\n))}:host([dir=rtl]:not([quiet])) #textfield .input{padding-right:calc(var(--spectrum-alias-search-padding-left-m) + var(\n--spectrum-alias-workflow-icon-size-m,\nvar(--spectrum-global-dimension-size-225)\n) + var(\n--spectrum-textfield-m-texticon-icon-gap,\nvar(--spectrum-global-dimension-size-100)\n) - var(\n--spectrum-textfield-m-texticon-border-size,\nvar(--spectrum-alias-input-border-size)\n))}:host([quiet]) #button{transform:translateX(var(--spectrum-search-quiet-button-offset))}:host([quiet]) .input{border-radius:var(\n--spectrum-alias-search-border-radius-quiet,0\n)}:host([quiet]) #textfield:after{border-radius:var(\n--spectrum-alias-search-border-radius-quiet,0\n)}.icon{color:var(\n--spectrum-textfield-m-texticon-icon-color,var(--spectrum-alias-component-icon-color-default)\n)}.input:hover~.icon{color:var(\n--spectrum-search-m-icon-color-hover,var(--spectrum-alias-component-icon-color-hover)\n)}.input:active~.icon{color:var(\n--spectrum-search-m-icon-color-down,var(--spectrum-alias-component-icon-color-down)\n)}.input.focus-visible~.icon{color:var(\n--spectrum-search-m-icon-color-key-focus,var(--spectrum-alias-component-icon-color-key-focus)\n)}.input:focus-visible~.icon{color:var(\n--spectrum-search-m-icon-color-key-focus,var(--spectrum-alias-component-icon-color-key-focus)\n)}.input:disabled~.icon{color:var(\n--spectrum-textfield-m-texticon-text-color-disabled,var(--spectrum-alias-component-text-color-disabled)\n)}\n`;\nexport default styles;"]}
@@ -0,0 +1,29 @@
1
+ /*
2
+ Copyright 2018 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software distributed under
8
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ OF ANY KIND, either express or implied. See the License for the specific language
10
+ governing permissions and limitations under the License.
11
+ */
12
+ import '../sp-search.js';
13
+ import { html } from '@spectrum-web-components/base';
14
+ export default {
15
+ component: 'sp-search',
16
+ title: 'Search',
17
+ };
18
+ export const Default = () => html `
19
+ <sp-search></sp-search>
20
+ <sp-search disabled></sp-search>
21
+ `;
22
+ export const autofocus = () => html `
23
+ <sp-search autofocus></sp-search>
24
+ `;
25
+ export const Quiet = () => html `
26
+ <sp-search quiet></sp-search>
27
+ <sp-search quiet disabled></sp-search>
28
+ `;
29
+ //# sourceMappingURL=search.stories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search.stories.js","sourceRoot":"","sources":["search.stories.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,iBAAiB,CAAC;AACzB,OAAO,EAAE,IAAI,EAAkB,MAAM,+BAA+B,CAAC;AAErE,eAAe;IACX,SAAS,EAAE,WAAW;IACtB,KAAK,EAAE,QAAQ;CAClB,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAG,GAAmB,EAAE,CAAC,IAAI,CAAA;;;CAGhD,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,GAAmB,EAAE,CAAC,IAAI,CAAA;;CAElD,CAAC;AAEF,MAAM,CAAC,MAAM,KAAK,GAAG,GAAmB,EAAE,CAAC,IAAI,CAAA;;;CAG9C,CAAC","sourcesContent":["/*\nCopyright 2018 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport '../sp-search.js';\nimport { html, TemplateResult } from '@spectrum-web-components/base';\n\nexport default {\n component: 'sp-search',\n title: 'Search',\n};\n\nexport const Default = (): TemplateResult => html`\n <sp-search></sp-search>\n <sp-search disabled></sp-search>\n`;\n\nexport const autofocus = (): TemplateResult => html`\n <sp-search autofocus></sp-search>\n`;\n\nexport const Quiet = (): TemplateResult => html`\n <sp-search quiet></sp-search>\n <sp-search quiet disabled></sp-search>\n`;\n"]}
@@ -0,0 +1,24 @@
1
+ /*
2
+ Copyright 2020 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software distributed under
8
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ OF ANY KIND, either express or implied. See the License for the specific language
10
+ governing permissions and limitations under the License.
11
+ */
12
+ import '@spectrum-web-components/search/sp-search.js';
13
+ import { html } from 'lit';
14
+ import { measureFixtureCreation } from '../../../../test/benchmark/helpers.js';
15
+ measureFixtureCreation(html `
16
+ <sp-search
17
+ placeholder="Search millions of images"
18
+ label="Search for an image"
19
+ @submit=${(event) => {
20
+ event.preventDefault();
21
+ }}
22
+ ></sp-search>
23
+ `);
24
+ //# sourceMappingURL=test-basic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-basic.js","sourceRoot":"","sources":["test-basic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO,8CAA8C,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAE/E,sBAAsB,CAAC,IAAI,CAAA;;;;kBAIT,CAAC,KAAY,EAAE,EAAE;IACvB,KAAK,CAAC,cAAc,EAAE,CAAC;AAC3B,CAAC;;CAER,CAAC,CAAC","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport '@spectrum-web-components/search/sp-search.js';\nimport { html } from 'lit';\nimport { measureFixtureCreation } from '../../../../test/benchmark/helpers.js';\n\nmeasureFixtureCreation(html`\n <sp-search\n placeholder=\"Search millions of images\"\n label=\"Search for an image\"\n @submit=${(event: Event) => {\n event.preventDefault();\n }}\n ></sp-search>\n`);\n"]}
@@ -0,0 +1,15 @@
1
+ /*
2
+ Copyright 2020 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software distributed under
8
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ OF ANY KIND, either express or implied. See the License for the specific language
10
+ governing permissions and limitations under the License.
11
+ */
12
+ import * as stories from '../stories/search.stories.js';
13
+ import { regressVisuals } from '../../../test/visual/test.js';
14
+ regressVisuals('SearchStories', stories);
15
+ //# sourceMappingURL=search.test-vrt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search.test-vrt.js","sourceRoot":"","sources":["search.test-vrt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO,KAAK,OAAO,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,cAAc,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport * as stories from '../stories/search.stories.js';\nimport { regressVisuals } from '../../../test/visual/test.js';\n\nregressVisuals('SearchStories', stories);\n"]}
@@ -0,0 +1,157 @@
1
+ /*
2
+ Copyright 2020 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software distributed under
8
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ OF ANY KIND, either express or implied. See the License for the specific language
10
+ governing permissions and limitations under the License.
11
+ */
12
+ import '../sp-search.js';
13
+ import { elementUpdated, expect, html, litFixture } from '@open-wc/testing';
14
+ import { escapeEvent, spaceEvent } from '../../../test/testing-helpers.js';
15
+ import '@spectrum-web-components/shared/src/focus-visible.js';
16
+ import { spy } from 'sinon';
17
+ describe('Search', () => {
18
+ it('loads accessibly', async () => {
19
+ const el = await litFixture(html `
20
+ <sp-search></sp-search>
21
+ `);
22
+ await elementUpdated(el);
23
+ await expect(el).to.be.accessible();
24
+ });
25
+ it('can be cleared', async () => {
26
+ const el = await litFixture(html `
27
+ <sp-search value="Test"></sp-search>
28
+ `);
29
+ await elementUpdated(el);
30
+ expect(el.value).to.equal('Test');
31
+ const root = el.shadowRoot ? el.shadowRoot : el;
32
+ const clearButton = root.querySelector('#button');
33
+ clearButton.click();
34
+ await elementUpdated(el);
35
+ expect(el.value).to.equal('');
36
+ });
37
+ it('captures keyboard events to the clear button', async () => {
38
+ const el = await litFixture(html `
39
+ <sp-search value="Test"></sp-search>
40
+ `);
41
+ await elementUpdated(el);
42
+ expect(el.value).to.equal('Test');
43
+ const root = el.shadowRoot ? el.shadowRoot : el;
44
+ const clearButton = root.querySelector('#button');
45
+ clearButton.dispatchEvent(escapeEvent());
46
+ await elementUpdated(el);
47
+ expect(el.value).to.equal('Test');
48
+ });
49
+ it('dispatches events when using the "clear" button', async () => {
50
+ const inputSpy = spy();
51
+ const changeSpy = spy();
52
+ const handleInput = (event) => {
53
+ const target = event.target;
54
+ inputSpy(target.value);
55
+ };
56
+ const handleChange = (event) => {
57
+ const target = event.target;
58
+ changeSpy(target.value);
59
+ };
60
+ const el = await litFixture(html `
61
+ <sp-search
62
+ value="Test"
63
+ @change=${handleChange}
64
+ @input=${handleInput}
65
+ ></sp-search>
66
+ `);
67
+ await elementUpdated(el);
68
+ expect(el.value).to.equal('Test');
69
+ const root = el.shadowRoot ? el.shadowRoot : el;
70
+ const clearButton = root.querySelector('#button');
71
+ inputSpy.resetHistory();
72
+ changeSpy.resetHistory();
73
+ clearButton.click();
74
+ await elementUpdated(el);
75
+ expect(el.value).to.equal('');
76
+ expect(inputSpy.calledOnce, 'one input').to.be.true;
77
+ expect(inputSpy.calledWith(''), 'was blank').to.be.true;
78
+ expect(changeSpy.calledOnce, 'one change').to.be.true;
79
+ expect(changeSpy.calledWith(''), 'was blank').to.be.true;
80
+ });
81
+ it('can be cleared via "Escape"', async () => {
82
+ const inputSpy = spy();
83
+ const changeSpy = spy();
84
+ const handleInput = (event) => {
85
+ const target = event.target;
86
+ inputSpy(target.value);
87
+ };
88
+ const handleChange = (event) => {
89
+ const target = event.target;
90
+ changeSpy(target.value);
91
+ };
92
+ const el = await litFixture(html `
93
+ <sp-search
94
+ value="Test"
95
+ @change=${handleChange}
96
+ @input=${handleInput}
97
+ ></sp-search>
98
+ `);
99
+ await elementUpdated(el);
100
+ expect(el.value).to.equal('Test');
101
+ el.focusElement.dispatchEvent(spaceEvent());
102
+ await elementUpdated(el);
103
+ expect(el.value).to.equal('Test');
104
+ inputSpy.resetHistory();
105
+ changeSpy.resetHistory();
106
+ el.focusElement.dispatchEvent(escapeEvent());
107
+ await elementUpdated(el);
108
+ expect(el.value).to.equal('');
109
+ expect(inputSpy.calledOnce, 'one input').to.be.true;
110
+ expect(inputSpy.calledWith(''), 'was blank').to.be.true;
111
+ expect(changeSpy.calledOnce, 'one change').to.be.true;
112
+ expect(changeSpy.calledWith(''), 'was blank').to.be.true;
113
+ });
114
+ it('cannot be multiline', async () => {
115
+ const el = await litFixture(html `
116
+ <sp-search multiline></sp-search>
117
+ `);
118
+ await elementUpdated(el);
119
+ expect(el.multiline).to.be.false;
120
+ el.multiline = true;
121
+ await elementUpdated(el);
122
+ expect(el.multiline).to.be.false;
123
+ });
124
+ it('accepts `placeholder` and `label` properties', async () => {
125
+ const testString = 'Search for images';
126
+ const el = await litFixture(html `
127
+ <sp-search></sp-search>
128
+ `);
129
+ await elementUpdated(el);
130
+ el.placeholder = testString;
131
+ el.label = testString;
132
+ await elementUpdated(el);
133
+ expect(el.focusElement.placeholder).to.equal(testString);
134
+ expect(el.focusElement.getAttribute('aria-label')).to.equal(testString);
135
+ });
136
+ it('can have default prevented', async () => {
137
+ const el = await litFixture(html `
138
+ <sp-search
139
+ @submit=${(event) => {
140
+ event.preventDefault();
141
+ }}
142
+ ></sp-search>
143
+ `);
144
+ await elementUpdated(el);
145
+ const searchForm = (el.shadowRoot
146
+ ? el.shadowRoot.querySelector('form')
147
+ : el.querySelector('form'));
148
+ const submitEvent = new Event('submit', {
149
+ cancelable: true,
150
+ bubbles: false,
151
+ composed: false,
152
+ });
153
+ searchForm.dispatchEvent(submitEvent);
154
+ expect(submitEvent.defaultPrevented).to.be.true;
155
+ });
156
+ });
157
+ //# sourceMappingURL=search.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search.test.js","sourceRoot":"","sources":["search.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,iBAAiB,CAAC;AAEzB,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,sDAAsD,CAAC;AAC9D,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5B,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IACpB,EAAE,CAAC,kBAAkB,EAAE,KAAK,IAAI,EAAE;QAC9B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G,IAAI,KAAK,CAAC,QAAQ,EAAE;YACpC,UAAU,EAAE,IAAI;YAChB,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,KAAK;SAClB,CAAC,CAAC;QACH,UAAU,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;QAEtC,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;IACpD,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport '../sp-search.js';\nimport { Search } from '../';\nimport { elementUpdated, expect, html, litFixture } from '@open-wc/testing';\nimport { escapeEvent, spaceEvent } from '../../../test/testing-helpers.js';\nimport '@spectrum-web-components/shared/src/focus-visible.js';\nimport { spy } from 'sinon';\n\ndescribe('Search', () => {\n it('loads accessibly', async () => {\n const el = await litFixture<Search>(\n html`\n <sp-search></sp-search>\n `\n );\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n it('can be cleared', async () => {\n const el = await litFixture<Search>(\n html`\n <sp-search value=\"Test\"></sp-search>\n `\n );\n\n await elementUpdated(el);\n expect(el.value).to.equal('Test');\n\n const root = el.shadowRoot ? el.shadowRoot : el;\n const clearButton = root.querySelector('#button') as HTMLButtonElement;\n clearButton.click();\n\n await elementUpdated(el);\n\n expect(el.value).to.equal('');\n });\n it('captures keyboard events to the clear button', async () => {\n const el = await litFixture<Search>(\n html`\n <sp-search value=\"Test\"></sp-search>\n `\n );\n\n await elementUpdated(el);\n expect(el.value).to.equal('Test');\n\n const root = el.shadowRoot ? el.shadowRoot : el;\n const clearButton = root.querySelector('#button') as HTMLButtonElement;\n clearButton.dispatchEvent(escapeEvent());\n\n await elementUpdated(el);\n\n expect(el.value).to.equal('Test');\n });\n it('dispatches events when using the \"clear\" button', async () => {\n const inputSpy = spy();\n const changeSpy = spy();\n const handleInput = (event: Event): void => {\n const target = event.target as HTMLInputElement;\n inputSpy(target.value);\n };\n const handleChange = (event: Event): void => {\n const target = event.target as HTMLInputElement;\n changeSpy(target.value);\n };\n const el = await litFixture<Search>(\n html`\n <sp-search\n value=\"Test\"\n @change=${handleChange}\n @input=${handleInput}\n ></sp-search>\n `\n );\n\n await elementUpdated(el);\n expect(el.value).to.equal('Test');\n\n const root = el.shadowRoot ? el.shadowRoot : el;\n const clearButton = root.querySelector('#button') as HTMLButtonElement;\n inputSpy.resetHistory();\n changeSpy.resetHistory();\n clearButton.click();\n\n await elementUpdated(el);\n\n expect(el.value).to.equal('');\n expect(inputSpy.calledOnce, 'one input').to.be.true;\n expect(inputSpy.calledWith(''), 'was blank').to.be.true;\n expect(changeSpy.calledOnce, 'one change').to.be.true;\n expect(changeSpy.calledWith(''), 'was blank').to.be.true;\n });\n it('can be cleared via \"Escape\"', async () => {\n const inputSpy = spy();\n const changeSpy = spy();\n const handleInput = (event: Event): void => {\n const target = event.target as HTMLInputElement;\n inputSpy(target.value);\n };\n const handleChange = (event: Event): void => {\n const target = event.target as HTMLInputElement;\n changeSpy(target.value);\n };\n const el = await litFixture<Search>(\n html`\n <sp-search\n value=\"Test\"\n @change=${handleChange}\n @input=${handleInput}\n ></sp-search>\n `\n );\n\n await elementUpdated(el);\n expect(el.value).to.equal('Test');\n el.focusElement.dispatchEvent(spaceEvent());\n\n await elementUpdated(el);\n expect(el.value).to.equal('Test');\n\n inputSpy.resetHistory();\n changeSpy.resetHistory();\n el.focusElement.dispatchEvent(escapeEvent());\n\n await elementUpdated(el);\n\n expect(el.value).to.equal('');\n expect(inputSpy.calledOnce, 'one input').to.be.true;\n expect(inputSpy.calledWith(''), 'was blank').to.be.true;\n expect(changeSpy.calledOnce, 'one change').to.be.true;\n expect(changeSpy.calledWith(''), 'was blank').to.be.true;\n });\n it('cannot be multiline', async () => {\n const el = await litFixture<Search>(\n html`\n <sp-search multiline></sp-search>\n `\n );\n\n await elementUpdated(el);\n\n expect(el.multiline).to.be.false;\n\n el.multiline = true;\n\n await elementUpdated(el);\n\n expect(el.multiline).to.be.false;\n });\n it('accepts `placeholder` and `label` properties', async () => {\n const testString = 'Search for images';\n const el = await litFixture<Search>(\n html`\n <sp-search></sp-search>\n `\n );\n\n await elementUpdated(el);\n el.placeholder = testString;\n el.label = testString;\n\n await elementUpdated(el);\n\n expect(el.focusElement.placeholder).to.equal(testString);\n expect(el.focusElement.getAttribute('aria-label')).to.equal(testString);\n });\n it('can have default prevented', async () => {\n const el = await litFixture<Search>(\n html`\n <sp-search\n @submit=${(event: Event) => {\n event.preventDefault();\n }}\n ></sp-search>\n `\n );\n\n await elementUpdated(el);\n const searchForm = (\n el.shadowRoot\n ? el.shadowRoot.querySelector('form')\n : el.querySelector('form')\n ) as HTMLFormElement;\n\n const submitEvent = new Event('submit', {\n cancelable: true,\n bubbles: false,\n composed: false,\n });\n searchForm.dispatchEvent(submitEvent);\n\n expect(submitEvent.defaultPrevented).to.be.true;\n });\n});\n"]}