@spectrum-web-components/button 0.19.0-devmode.0 → 0.19.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.
- package/package.json +8 -8
- package/sp-button.js +1 -2
- package/sp-button.js.map +1 -1
- package/sp-clear-button.js +1 -2
- package/sp-clear-button.js.map +1 -1
- package/sp-close-button.js +1 -2
- package/sp-close-button.js.map +1 -1
- package/src/Button.js +1 -78
- package/src/Button.js.map +1 -1
- package/src/ButtonBase.js +6 -205
- package/src/ButtonBase.js.map +1 -1
- package/src/ClearButton.js +6 -52
- package/src/ClearButton.js.map +1 -1
- package/src/CloseButton.js +5 -48
- package/src/CloseButton.js.map +1 -1
- package/src/StyledButton.js +1 -7
- package/src/StyledButton.js.map +1 -1
- package/src/button-base.css.js +2 -4
- package/src/button-base.css.js.map +1 -1
- package/src/button.css.js +2 -4
- package/src/button.css.js.map +1 -1
- package/src/index.js +1 -5
- package/src/index.js.map +1 -1
- package/src/spectrum-button-base.css.js +2 -4
- package/src/spectrum-button-base.css.js.map +1 -1
- package/src/spectrum-button.css.js +2 -4
- package/src/spectrum-button.css.js.map +1 -1
- package/stories/button-accent-fill-sizes.stories.js +1 -30
- package/stories/button-accent-fill-sizes.stories.js.map +1 -1
- package/stories/button-accent-fill.stories.js +1 -31
- package/stories/button-accent-fill.stories.js.map +1 -1
- package/stories/button-accent-outline-sizes.stories.js +1 -30
- package/stories/button-accent-outline-sizes.stories.js.map +1 -1
- package/stories/button-accent-outline.stories.js +1 -31
- package/stories/button-accent-outline.stories.js.map +1 -1
- package/stories/button-black-fill-sizes.stories.js +1 -31
- package/stories/button-black-fill-sizes.stories.js.map +1 -1
- package/stories/button-black-fill.stories.js +1 -33
- package/stories/button-black-fill.stories.js.map +1 -1
- package/stories/button-black-outline-sizes.stories.js +1 -31
- package/stories/button-black-outline-sizes.stories.js.map +1 -1
- package/stories/button-black-outline.stories.js +1 -33
- package/stories/button-black-outline.stories.js.map +1 -1
- package/stories/button-negative-fill-sizes.stories.js +1 -30
- package/stories/button-negative-fill-sizes.stories.js.map +1 -1
- package/stories/button-negative-fill.stories.js +1 -31
- package/stories/button-negative-fill.stories.js.map +1 -1
- package/stories/button-negative-outline-sizes.stories.js +1 -30
- package/stories/button-negative-outline-sizes.stories.js.map +1 -1
- package/stories/button-negative-outline.stories.js +1 -31
- package/stories/button-negative-outline.stories.js.map +1 -1
- package/stories/button-primary-fill-sizes.stories.js +1 -30
- package/stories/button-primary-fill-sizes.stories.js.map +1 -1
- package/stories/button-primary-fill.stories.js +1 -31
- package/stories/button-primary-fill.stories.js.map +1 -1
- package/stories/button-primary-outline-sizes.stories.js +1 -30
- package/stories/button-primary-outline-sizes.stories.js.map +1 -1
- package/stories/button-primary-outline.stories.js +1 -31
- package/stories/button-primary-outline.stories.js.map +1 -1
- package/stories/button-secondary-fill-sizes.stories.js +1 -30
- package/stories/button-secondary-fill-sizes.stories.js.map +1 -1
- package/stories/button-secondary-fill.stories.js +1 -31
- package/stories/button-secondary-fill.stories.js.map +1 -1
- package/stories/button-secondary-outline-sizes.stories.js +1 -30
- package/stories/button-secondary-outline-sizes.stories.js.map +1 -1
- package/stories/button-secondary-outline.stories.js +1 -31
- package/stories/button-secondary-outline.stories.js.map +1 -1
- package/stories/button-white-fill-sizes.stories.js +1 -31
- package/stories/button-white-fill-sizes.stories.js.map +1 -1
- package/stories/button-white-fill.stories.js +1 -33
- package/stories/button-white-fill.stories.js.map +1 -1
- package/stories/button-white-outline-sizes.stories.js +1 -31
- package/stories/button-white-outline-sizes.stories.js.map +1 -1
- package/stories/button-white-outline.stories.js +1 -33
- package/stories/button-white-outline.stories.js.map +1 -1
- package/stories/index.js +36 -137
- package/stories/index.js.map +1 -1
- package/test/benchmark/test-basic.js +1 -4
- package/test/benchmark/test-basic.js.map +1 -1
- package/test/button-accent-fill-sizes.test-vrt.js +1 -3
- package/test/button-accent-fill-sizes.test-vrt.js.map +1 -1
- package/test/button-accent-fill.test-vrt.js +1 -3
- package/test/button-accent-fill.test-vrt.js.map +1 -1
- package/test/button-accent-outline-sizes.test-vrt.js +1 -3
- package/test/button-accent-outline-sizes.test-vrt.js.map +1 -1
- package/test/button-accent-outline.test-vrt.js +1 -3
- package/test/button-accent-outline.test-vrt.js.map +1 -1
- package/test/button-black-fill-sizes.test-vrt.js +1 -3
- package/test/button-black-fill-sizes.test-vrt.js.map +1 -1
- package/test/button-black-fill.test-vrt.js +1 -3
- package/test/button-black-fill.test-vrt.js.map +1 -1
- package/test/button-black-outline-sizes.test-vrt.js +1 -3
- package/test/button-black-outline-sizes.test-vrt.js.map +1 -1
- package/test/button-black-outline.test-vrt.js +1 -3
- package/test/button-black-outline.test-vrt.js.map +1 -1
- package/test/button-negative-fill-sizes.test-vrt.js +1 -3
- package/test/button-negative-fill-sizes.test-vrt.js.map +1 -1
- package/test/button-negative-fill.test-vrt.js +1 -3
- package/test/button-negative-fill.test-vrt.js.map +1 -1
- package/test/button-negative-outline-sizes.test-vrt.js +1 -3
- package/test/button-negative-outline-sizes.test-vrt.js.map +1 -1
- package/test/button-negative-outline.test-vrt.js +1 -3
- package/test/button-negative-outline.test-vrt.js.map +1 -1
- package/test/button-primary-fill-sizes.test-vrt.js +1 -3
- package/test/button-primary-fill-sizes.test-vrt.js.map +1 -1
- package/test/button-primary-fill.test-vrt.js +1 -3
- package/test/button-primary-fill.test-vrt.js.map +1 -1
- package/test/button-primary-outline-sizes.test-vrt.js +1 -3
- package/test/button-primary-outline-sizes.test-vrt.js.map +1 -1
- package/test/button-primary-outline.test-vrt.js +1 -3
- package/test/button-primary-outline.test-vrt.js.map +1 -1
- package/test/button-secondary-fill-sizes.test-vrt.js +1 -3
- package/test/button-secondary-fill-sizes.test-vrt.js.map +1 -1
- package/test/button-secondary-fill.test-vrt.js +1 -3
- package/test/button-secondary-fill.test-vrt.js.map +1 -1
- package/test/button-secondary-outline-sizes.test-vrt.js +1 -3
- package/test/button-secondary-outline-sizes.test-vrt.js.map +1 -1
- package/test/button-secondary-outline.test-vrt.js +1 -3
- package/test/button-secondary-outline.test-vrt.js.map +1 -1
- package/test/button-white-fill-sizes.test-vrt.js +1 -3
- package/test/button-white-fill-sizes.test-vrt.js.map +1 -1
- package/test/button-white-fill.test-vrt.js +1 -3
- package/test/button-white-fill.test-vrt.js.map +1 -1
- package/test/button-white-outline-sizes.test-vrt.js +1 -3
- package/test/button-white-outline-sizes.test-vrt.js.map +1 -1
- package/test/button-white-outline.test-vrt.js +1 -3
- package/test/button-white-outline.test-vrt.js.map +1 -1
- package/test/button.test.js +29 -349
- package/test/button.test.js.map +1 -1
- package/test/clear-button.test.js +4 -15
- package/test/clear-button.test.js.map +1 -1
- package/test/close-button.test.js +4 -15
- package/test/close-button.test.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/button",
|
|
3
|
-
"version": "0.19.0
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -82,12 +82,12 @@
|
|
|
82
82
|
"lit-html"
|
|
83
83
|
],
|
|
84
84
|
"dependencies": {
|
|
85
|
-
"@spectrum-web-components/base": "^0.
|
|
86
|
-
"@spectrum-web-components/clear-button": "^0.2.0
|
|
87
|
-
"@spectrum-web-components/close-button": "^0.3.0
|
|
88
|
-
"@spectrum-web-components/icon": "^0.12.0
|
|
89
|
-
"@spectrum-web-components/icons-ui": "^0.9.0
|
|
90
|
-
"@spectrum-web-components/shared": "^0.15.0
|
|
85
|
+
"@spectrum-web-components/base": "^0.7.0",
|
|
86
|
+
"@spectrum-web-components/clear-button": "^0.2.0",
|
|
87
|
+
"@spectrum-web-components/close-button": "^0.3.0",
|
|
88
|
+
"@spectrum-web-components/icon": "^0.12.0",
|
|
89
|
+
"@spectrum-web-components/icons-ui": "^0.9.0",
|
|
90
|
+
"@spectrum-web-components/shared": "^0.15.0",
|
|
91
91
|
"tslib": "^2.0.0"
|
|
92
92
|
},
|
|
93
93
|
"devDependencies": {
|
|
@@ -99,5 +99,5 @@
|
|
|
99
99
|
"./sp-*.js",
|
|
100
100
|
"./**/*.dev.js"
|
|
101
101
|
],
|
|
102
|
-
"gitHead": "
|
|
102
|
+
"gitHead": "05c81318844160db3f8156144106e643507fef97"
|
|
103
103
|
}
|
package/sp-button.js
CHANGED
package/sp-button.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["sp-button.ts"],
|
|
4
4
|
"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 { Button } from './src/Button.js';\n\ncustomElements.define('sp-button', Button);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-button': Button;\n }\n}\n"],
|
|
5
|
-
"mappings": "AAWA
|
|
5
|
+
"mappings": "AAWA,yCAEA,eAAe,OAAO,YAAa,CAAM",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/sp-clear-button.js
CHANGED
package/sp-clear-button.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["sp-clear-button.ts"],
|
|
4
4
|
"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 { ClearButton } from './src/ClearButton.js';\n\ncustomElements.define('sp-clear-button', ClearButton);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-clear-button': ClearButton;\n }\n}\n"],
|
|
5
|
-
"mappings": "AAWA
|
|
5
|
+
"mappings": "AAWA,mDAEA,eAAe,OAAO,kBAAmB,CAAW",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/sp-close-button.js
CHANGED
package/sp-close-button.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["sp-close-button.ts"],
|
|
4
4
|
"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 { CloseButton } from './src/CloseButton.js';\n\ncustomElements.define('sp-close-button', CloseButton);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-close-button': CloseButton;\n }\n}\n"],
|
|
5
|
-
"mappings": "AAYA
|
|
5
|
+
"mappings": "AAYA,mDAEA,eAAe,OAAO,kBAAmB,CAAW",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/Button.js
CHANGED
|
@@ -1,79 +1,2 @@
|
|
|
1
|
-
var
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
-
if (decorator = decorators[i])
|
|
7
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
-
if (kind && result)
|
|
9
|
-
__defProp(target, key, result);
|
|
10
|
-
return result;
|
|
11
|
-
};
|
|
12
|
-
import {
|
|
13
|
-
SizedMixin
|
|
14
|
-
} from "@spectrum-web-components/base";
|
|
15
|
-
import { property } from "@spectrum-web-components/base/src/decorators.js";
|
|
16
|
-
import { StyledButton } from "./StyledButton.js";
|
|
17
|
-
import buttonStyles from "./button.css.js";
|
|
18
|
-
export const VALID_VARIANTS = [
|
|
19
|
-
"accent",
|
|
20
|
-
"primary",
|
|
21
|
-
"secondary",
|
|
22
|
-
"negative",
|
|
23
|
-
"white",
|
|
24
|
-
"black"
|
|
25
|
-
];
|
|
26
|
-
export class Button extends SizedMixin(StyledButton) {
|
|
27
|
-
constructor() {
|
|
28
|
-
super(...arguments);
|
|
29
|
-
this._variant = "accent";
|
|
30
|
-
this.treatment = "fill";
|
|
31
|
-
}
|
|
32
|
-
static get styles() {
|
|
33
|
-
return [...super.styles, buttonStyles];
|
|
34
|
-
}
|
|
35
|
-
get variant() {
|
|
36
|
-
return this._variant;
|
|
37
|
-
}
|
|
38
|
-
set variant(variant) {
|
|
39
|
-
if (variant === this.variant)
|
|
40
|
-
return;
|
|
41
|
-
this.requestUpdate("variant", this.variant);
|
|
42
|
-
switch (variant) {
|
|
43
|
-
case "cta":
|
|
44
|
-
this._variant = "accent";
|
|
45
|
-
break;
|
|
46
|
-
case "overBackground":
|
|
47
|
-
this._variant = "white";
|
|
48
|
-
this.treatment = "outline";
|
|
49
|
-
break;
|
|
50
|
-
default:
|
|
51
|
-
if (!VALID_VARIANTS.includes(variant)) {
|
|
52
|
-
this._variant = "accent";
|
|
53
|
-
} else {
|
|
54
|
-
this._variant = variant;
|
|
55
|
-
}
|
|
56
|
-
break;
|
|
57
|
-
}
|
|
58
|
-
this.setAttribute("variant", this.variant);
|
|
59
|
-
}
|
|
60
|
-
set quiet(quiet) {
|
|
61
|
-
this.treatment = quiet ? "outline" : "fill";
|
|
62
|
-
}
|
|
63
|
-
firstUpdated(changes) {
|
|
64
|
-
super.firstUpdated(changes);
|
|
65
|
-
if (!this.hasAttribute("variant")) {
|
|
66
|
-
this.setAttribute("variant", this.variant);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
__decorateClass([
|
|
71
|
-
property()
|
|
72
|
-
], Button.prototype, "variant", 1);
|
|
73
|
-
__decorateClass([
|
|
74
|
-
property({ reflect: true })
|
|
75
|
-
], Button.prototype, "treatment", 2);
|
|
76
|
-
__decorateClass([
|
|
77
|
-
property({ type: Boolean })
|
|
78
|
-
], Button.prototype, "quiet", 1);
|
|
1
|
+
var c=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var a=(i,t,n,r)=>{for(var e=r>1?void 0:r?p(t,n):t,s=i.length-1,o;s>=0;s--)(o=i[s])&&(e=(r?o(t,n,e):o(e))||e);return r&&e&&c(t,n,e),e};import{SizedMixin as l}from"@spectrum-web-components/base";import{property as u}from"@spectrum-web-components/base/src/decorators.js";import{StyledButton as h}from"./StyledButton.js";import v from"./button.css.js";export const VALID_VARIANTS=["accent","primary","secondary","negative","white","black"];export class Button extends l(h){constructor(){super(...arguments);this._variant="accent";this.treatment="fill"}static get styles(){return[...super.styles,v]}get variant(){return this._variant}set variant(t){if(t!==this.variant){switch(this.requestUpdate("variant",this.variant),t){case"cta":this._variant="accent";break;case"overBackground":this._variant="white",this.treatment="outline";break;default:VALID_VARIANTS.includes(t)?this._variant=t:this._variant="accent";break}this.setAttribute("variant",this.variant)}}set quiet(t){this.treatment=t?"outline":"fill"}firstUpdated(t){super.firstUpdated(t),this.hasAttribute("variant")||this.setAttribute("variant",this.variant)}}a([u()],Button.prototype,"variant",1),a([u({reflect:!0})],Button.prototype,"treatment",2),a([u({type:Boolean})],Button.prototype,"quiet",1);
|
|
79
2
|
//# sourceMappingURL=Button.js.map
|
package/src/Button.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["Button.ts"],
|
|
4
4
|
"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 PropertyValues,\n SizedMixin,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\nimport { StyledButton } from './StyledButton.js';\nimport buttonStyles from './button.css.js';\n\nexport type DeprecatedButtonVariants = 'cta' | 'overBackground';\nexport type ButtonStatics = 'white' | 'black';\nexport type ButtonVariants =\n | 'accent'\n | 'primary'\n | 'secondary'\n | 'negative'\n | ButtonStatics\n | DeprecatedButtonVariants;\nexport const VALID_VARIANTS = [\n 'accent',\n 'primary',\n 'secondary',\n 'negative',\n 'white',\n 'black',\n];\n\nexport type ButtonTreatments = 'fill' | 'outline';\n\n/**\n * @element sp-button\n *\n * @slot - text label of the Button\n * @slot icon - The icon to use for Button\n */\nexport class Button extends SizedMixin(StyledButton) {\n public static override get styles(): CSSResultArray {\n return [...super.styles, buttonStyles];\n }\n\n /**\n * The visual variant to apply to this button.\n */\n @property()\n public get variant(): ButtonVariants {\n return this._variant;\n }\n public set variant(variant: ButtonVariants) {\n if (variant === this.variant) return;\n\n this.requestUpdate('variant', this.variant);\n switch (variant) {\n case 'cta':\n this._variant = 'accent';\n break;\n case 'overBackground':\n this._variant = 'white';\n this.treatment = 'outline';\n break;\n default:\n if (!VALID_VARIANTS.includes(variant)) {\n this._variant = 'accent';\n } else {\n this._variant = variant;\n }\n break;\n }\n this.setAttribute('variant', this.variant);\n }\n private _variant: ButtonVariants = 'accent';\n\n /**\n * The visual variant to apply to this button.\n */\n @property({ reflect: true })\n public treatment: ButtonTreatments = 'fill';\n\n /**\n * Style this button to be less obvious\n */\n @property({ type: Boolean })\n public set quiet(quiet: boolean) {\n this.treatment = quiet ? 'outline' : 'fill';\n }\n\n protected override firstUpdated(changes: PropertyValues<this>): void {\n super.firstUpdated(changes);\n if (!this.hasAttribute('variant')) {\n this.setAttribute('variant', this.variant);\n }\n }\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "wMAYA,2DAKA,2EACA,iDACA,+BAWO,YAAM,gBAAiB,CAC1B,SACA,UACA,YACA,WACA,QACA,OACJ,EAUO,aAAM,cAAe,GAAW,CAAY,CAAE,CAA9C,kCAkCK,cAA2B,SAM5B,eAA8B,iBAvCV,SAAyB,CAChD,MAAO,CAAC,GAAG,MAAM,OAAQ,CAAY,CACzC,IAMW,UAA0B,CACjC,MAAO,MAAK,QAChB,IACW,SAAQ,EAAyB,CACxC,GAAI,IAAY,KAAK,QAGrB,QADA,KAAK,cAAc,UAAW,KAAK,OAAO,EAClC,OACC,MACD,KAAK,SAAW,SAChB,UACC,iBACD,KAAK,SAAW,QAChB,KAAK,UAAY,UACjB,cAEA,AAAK,eAAe,SAAS,CAAO,EAGhC,KAAK,SAAW,EAFhB,KAAK,SAAW,SAIpB,MAER,KAAK,aAAa,UAAW,KAAK,OAAO,EAC7C,IAaW,OAAM,EAAgB,CAC7B,KAAK,UAAY,EAAQ,UAAY,MACzC,CAEmB,aAAa,EAAqC,CACjE,MAAM,aAAa,CAAO,EACrB,KAAK,aAAa,SAAS,GAC5B,KAAK,aAAa,UAAW,KAAK,OAAO,CAEjD,CACJ,CA/Ce,GADX,AAAC,EAAS,GACC,AATR,OASQ,uBA+BJ,GADP,AAAC,EAAS,CAAE,QAAS,EAAK,CAAC,GACpB,AAxCJ,OAwCI,yBAMI,GADX,AAAC,EAAS,CAAE,KAAM,OAAQ,CAAC,GAChB,AA9CR,OA8CQ",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/ButtonBase.js
CHANGED
|
@@ -1,215 +1,16 @@
|
|
|
1
|
-
var
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
-
if (decorator = decorators[i])
|
|
7
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
-
if (kind && result)
|
|
9
|
-
__defProp(target, key, result);
|
|
10
|
-
return result;
|
|
11
|
-
};
|
|
12
|
-
import {
|
|
13
|
-
html
|
|
14
|
-
} from "@spectrum-web-components/base";
|
|
15
|
-
import {
|
|
16
|
-
property,
|
|
17
|
-
query
|
|
18
|
-
} from "@spectrum-web-components/base/src/decorators.js";
|
|
19
|
-
import { LikeAnchor } from "@spectrum-web-components/shared/src/like-anchor.js";
|
|
20
|
-
import { Focusable } from "@spectrum-web-components/shared/src/focusable.js";
|
|
21
|
-
import {
|
|
22
|
-
ObserveSlotPresence,
|
|
23
|
-
ObserveSlotText
|
|
24
|
-
} from "@spectrum-web-components/shared";
|
|
25
|
-
export class ButtonBase extends LikeAnchor(ObserveSlotText(ObserveSlotPresence(Focusable, '[slot="icon"]'))) {
|
|
26
|
-
constructor() {
|
|
27
|
-
super();
|
|
28
|
-
this.active = false;
|
|
29
|
-
this.type = "button";
|
|
30
|
-
this.proxyFocus = this.proxyFocus.bind(this);
|
|
31
|
-
this.addEventListener("click", this.handleClickCapture, {
|
|
32
|
-
capture: true
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
get hasIcon() {
|
|
36
|
-
return this.slotContentIsPresent;
|
|
37
|
-
}
|
|
38
|
-
get hasLabel() {
|
|
39
|
-
return this.slotHasContent;
|
|
40
|
-
}
|
|
41
|
-
get focusElement() {
|
|
42
|
-
return this;
|
|
43
|
-
}
|
|
44
|
-
get buttonContent() {
|
|
45
|
-
const content = [
|
|
46
|
-
html`
|
|
1
|
+
var d=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var s=(n,e,t,r)=>{for(var i=r>1?void 0:r?c(e,t):e,a=n.length-1,h;a>=0;a--)(h=n[a])&&(i=(r?h(e,t,i):h(i))||i);return r&&i&&d(e,t,i),i};import{html as o}from"@spectrum-web-components/base";import{property as l,query as u}from"@spectrum-web-components/base/src/decorators.js";import{LikeAnchor as p}from"@spectrum-web-components/shared/src/like-anchor.js";import{Focusable as v}from"@spectrum-web-components/shared/src/focusable.js";import{ObserveSlotPresence as b,ObserveSlotText as m}from"@spectrum-web-components/shared";export class ButtonBase extends p(m(b(v,'[slot="icon"]'))){constructor(){super();this.active=!1;this.type="button";this.proxyFocus=this.proxyFocus.bind(this),this.addEventListener("click",this.handleClickCapture,{capture:!0})}get hasIcon(){return this.slotContentIsPresent}get hasLabel(){return this.slotHasContent}get focusElement(){return this}get buttonContent(){const e=[o`
|
|
47
2
|
<div id="label" ?hidden=${!this.hasLabel}>
|
|
48
3
|
<slot
|
|
49
4
|
id="slot"
|
|
50
5
|
@slotchange=${this.manageTextObservedSlot}
|
|
51
6
|
></slot>
|
|
52
7
|
</div>
|
|
53
|
-
`
|
|
54
|
-
];
|
|
55
|
-
if (this.hasIcon) {
|
|
56
|
-
content.unshift(html`
|
|
8
|
+
`];return this.hasIcon&&e.unshift(o`
|
|
57
9
|
<slot name="icon" ?icon-only=${!this.hasLabel}></slot>
|
|
58
|
-
`);
|
|
59
|
-
}
|
|
60
|
-
return content;
|
|
61
|
-
}
|
|
62
|
-
click() {
|
|
63
|
-
if (this.disabled) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
if (this.shouldProxyClick()) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
super.click();
|
|
70
|
-
}
|
|
71
|
-
handleClickCapture(event) {
|
|
72
|
-
if (this.disabled) {
|
|
73
|
-
event.preventDefault();
|
|
74
|
-
event.stopImmediatePropagation();
|
|
75
|
-
event.stopPropagation();
|
|
76
|
-
return false;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
proxyFocus() {
|
|
80
|
-
this.focus();
|
|
81
|
-
}
|
|
82
|
-
shouldProxyClick() {
|
|
83
|
-
let handled = false;
|
|
84
|
-
if (this.anchorElement) {
|
|
85
|
-
this.anchorElement.click();
|
|
86
|
-
handled = true;
|
|
87
|
-
} else if (this.type !== "button") {
|
|
88
|
-
const proxy = document.createElement("button");
|
|
89
|
-
proxy.type = this.type;
|
|
90
|
-
this.insertAdjacentElement("afterend", proxy);
|
|
91
|
-
proxy.click();
|
|
92
|
-
proxy.remove();
|
|
93
|
-
handled = true;
|
|
94
|
-
}
|
|
95
|
-
return handled;
|
|
96
|
-
}
|
|
97
|
-
renderAnchor() {
|
|
98
|
-
return html`
|
|
10
|
+
`),e}click(){this.disabled||this.shouldProxyClick()||super.click()}handleClickCapture(e){if(this.disabled)return e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation(),!1}proxyFocus(){this.focus()}shouldProxyClick(){let e=!1;if(this.anchorElement)this.anchorElement.click(),e=!0;else if(this.type!=="button"){const t=document.createElement("button");t.type=this.type,this.insertAdjacentElement("afterend",t),t.click(),t.remove(),e=!0}return e}renderAnchor(){return o`
|
|
99
11
|
${this.buttonContent}
|
|
100
|
-
${super.renderAnchor({
|
|
101
|
-
|
|
102
|
-
ariaHidden: true,
|
|
103
|
-
className: "button anchor hidden"
|
|
104
|
-
})}
|
|
105
|
-
`;
|
|
106
|
-
}
|
|
107
|
-
renderButton() {
|
|
108
|
-
return html`
|
|
12
|
+
${super.renderAnchor({id:"button",ariaHidden:!0,className:"button anchor hidden"})}
|
|
13
|
+
`}renderButton(){return o`
|
|
109
14
|
${this.buttonContent}
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
render() {
|
|
113
|
-
return this.href && this.href.length > 0 ? this.renderAnchor() : this.renderButton();
|
|
114
|
-
}
|
|
115
|
-
handleKeydown(event) {
|
|
116
|
-
const { code } = event;
|
|
117
|
-
switch (code) {
|
|
118
|
-
case "Space":
|
|
119
|
-
event.preventDefault();
|
|
120
|
-
if (typeof this.href === "undefined") {
|
|
121
|
-
this.addEventListener("keyup", this.handleKeyup);
|
|
122
|
-
this.active = true;
|
|
123
|
-
}
|
|
124
|
-
break;
|
|
125
|
-
default:
|
|
126
|
-
break;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
handleKeypress(event) {
|
|
130
|
-
const { code } = event;
|
|
131
|
-
switch (code) {
|
|
132
|
-
case "Enter":
|
|
133
|
-
case "NumpadEnter":
|
|
134
|
-
this.click();
|
|
135
|
-
break;
|
|
136
|
-
default:
|
|
137
|
-
break;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
handleKeyup(event) {
|
|
141
|
-
const { code } = event;
|
|
142
|
-
switch (code) {
|
|
143
|
-
case "Space":
|
|
144
|
-
this.removeEventListener("keyup", this.handleKeyup);
|
|
145
|
-
this.active = false;
|
|
146
|
-
this.click();
|
|
147
|
-
break;
|
|
148
|
-
default:
|
|
149
|
-
break;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
handleRemoveActive() {
|
|
153
|
-
this.active = false;
|
|
154
|
-
}
|
|
155
|
-
handlePointerdown() {
|
|
156
|
-
this.active = true;
|
|
157
|
-
}
|
|
158
|
-
manageAnchor() {
|
|
159
|
-
if (this.href && this.href.length > 0) {
|
|
160
|
-
if (this.getAttribute("role") === "button") {
|
|
161
|
-
this.setAttribute("role", "link");
|
|
162
|
-
}
|
|
163
|
-
this.removeEventListener("click", this.shouldProxyClick);
|
|
164
|
-
} else {
|
|
165
|
-
if (!this.hasAttribute("role") || this.getAttribute("role") === "link") {
|
|
166
|
-
this.setAttribute("role", "button");
|
|
167
|
-
}
|
|
168
|
-
this.addEventListener("click", this.shouldProxyClick);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
firstUpdated(changed) {
|
|
172
|
-
super.firstUpdated(changed);
|
|
173
|
-
if (!this.hasAttribute("tabindex")) {
|
|
174
|
-
this.tabIndex = 0;
|
|
175
|
-
}
|
|
176
|
-
this.manageAnchor();
|
|
177
|
-
this.addEventListener("keydown", this.handleKeydown);
|
|
178
|
-
this.addEventListener("keypress", this.handleKeypress);
|
|
179
|
-
this.addEventListener("pointerdown", this.handlePointerdown);
|
|
180
|
-
}
|
|
181
|
-
updated(changed) {
|
|
182
|
-
super.updated(changed);
|
|
183
|
-
if (changed.has("href")) {
|
|
184
|
-
this.manageAnchor();
|
|
185
|
-
}
|
|
186
|
-
if (changed.has("label")) {
|
|
187
|
-
this.setAttribute("aria-label", this.label || "");
|
|
188
|
-
}
|
|
189
|
-
if (changed.has("active")) {
|
|
190
|
-
if (this.active) {
|
|
191
|
-
this.addEventListener("focusout", this.handleRemoveActive);
|
|
192
|
-
this.addEventListener("pointerup", this.handleRemoveActive);
|
|
193
|
-
this.addEventListener("pointerleave", this.handleRemoveActive);
|
|
194
|
-
} else {
|
|
195
|
-
this.removeEventListener("focusout", this.handleRemoveActive);
|
|
196
|
-
this.removeEventListener("pointerup", this.handleRemoveActive);
|
|
197
|
-
this.removeEventListener("pointerleave", this.handleRemoveActive);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
if (this.anchorElement) {
|
|
201
|
-
this.anchorElement.addEventListener("focus", this.proxyFocus);
|
|
202
|
-
this.anchorElement.tabIndex = -1;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
__decorateClass([
|
|
207
|
-
property({ type: Boolean, reflect: true })
|
|
208
|
-
], ButtonBase.prototype, "active", 2);
|
|
209
|
-
__decorateClass([
|
|
210
|
-
property({ type: String })
|
|
211
|
-
], ButtonBase.prototype, "type", 2);
|
|
212
|
-
__decorateClass([
|
|
213
|
-
query(".anchor")
|
|
214
|
-
], ButtonBase.prototype, "anchorElement", 2);
|
|
15
|
+
`}render(){return this.href&&this.href.length>0?this.renderAnchor():this.renderButton()}handleKeydown(e){const{code:t}=e;switch(t){case"Space":e.preventDefault(),typeof this.href=="undefined"&&(this.addEventListener("keyup",this.handleKeyup),this.active=!0);break;default:break}}handleKeypress(e){const{code:t}=e;switch(t){case"Enter":case"NumpadEnter":this.click();break;default:break}}handleKeyup(e){const{code:t}=e;switch(t){case"Space":this.removeEventListener("keyup",this.handleKeyup),this.active=!1,this.click();break;default:break}}handleRemoveActive(){this.active=!1}handlePointerdown(){this.active=!0}manageAnchor(){this.href&&this.href.length>0?(this.getAttribute("role")==="button"&&this.setAttribute("role","link"),this.removeEventListener("click",this.shouldProxyClick)):((!this.hasAttribute("role")||this.getAttribute("role")==="link")&&this.setAttribute("role","button"),this.addEventListener("click",this.shouldProxyClick))}firstUpdated(e){super.firstUpdated(e),this.hasAttribute("tabindex")||(this.tabIndex=0),this.manageAnchor(),this.addEventListener("keydown",this.handleKeydown),this.addEventListener("keypress",this.handleKeypress),this.addEventListener("pointerdown",this.handlePointerdown)}updated(e){super.updated(e),e.has("href")&&this.manageAnchor(),e.has("label")&&this.setAttribute("aria-label",this.label||""),e.has("active")&&(this.active?(this.addEventListener("focusout",this.handleRemoveActive),this.addEventListener("pointerup",this.handleRemoveActive),this.addEventListener("pointerleave",this.handleRemoveActive)):(this.removeEventListener("focusout",this.handleRemoveActive),this.removeEventListener("pointerup",this.handleRemoveActive),this.removeEventListener("pointerleave",this.handleRemoveActive))),this.anchorElement&&(this.anchorElement.addEventListener("focus",this.proxyFocus),this.anchorElement.tabIndex=-1)}}s([l({type:Boolean,reflect:!0})],ButtonBase.prototype,"active",2),s([l({type:String})],ButtonBase.prototype,"type",2),s([u(".anchor")],ButtonBase.prototype,"anchorElement",2);
|
|
215
16
|
//# sourceMappingURL=ButtonBase.js.map
|
package/src/ButtonBase.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["ButtonBase.ts"],
|
|
4
4
|
"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 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 { LikeAnchor } from '@spectrum-web-components/shared/src/like-anchor.js';\nimport { Focusable } from '@spectrum-web-components/shared/src/focusable.js';\nimport {\n ObserveSlotPresence,\n ObserveSlotText,\n} from '@spectrum-web-components/shared';\n\n/**\n * @slot - text content to be displayed in the Button element\n * @slot icon - icon element(s) to display at the start of the button\n */\nexport class ButtonBase extends LikeAnchor(\n ObserveSlotText(ObserveSlotPresence(Focusable, '[slot=\"icon\"]'))\n) {\n protected get hasIcon(): boolean {\n return this.slotContentIsPresent;\n }\n\n @property({ type: Boolean, reflect: true })\n public active = false;\n\n @property({ type: String })\n public type: 'button' | 'submit' | 'reset' = 'button';\n\n protected get hasLabel(): boolean {\n return this.slotHasContent;\n }\n\n @query('.anchor')\n private anchorElement!: HTMLButtonElement;\n\n public override get focusElement(): HTMLElement {\n return this;\n }\n\n protected get buttonContent(): TemplateResult[] {\n const content = [\n html`\n <div id=\"label\" ?hidden=${!this.hasLabel}>\n <slot\n id=\"slot\"\n @slotchange=${this.manageTextObservedSlot}\n ></slot>\n </div>\n `,\n ];\n if (this.hasIcon) {\n content.unshift(html`\n <slot name=\"icon\" ?icon-only=${!this.hasLabel}></slot>\n `);\n }\n return content;\n }\n\n constructor() {\n super();\n this.proxyFocus = this.proxyFocus.bind(this);\n\n this.addEventListener('click', this.handleClickCapture, {\n capture: true,\n });\n }\n\n public override click(): void {\n if (this.disabled) {\n return;\n }\n\n if (this.shouldProxyClick()) {\n return;\n }\n\n super.click();\n }\n\n private handleClickCapture(event: Event): void | boolean {\n if (this.disabled) {\n event.preventDefault();\n event.stopImmediatePropagation();\n event.stopPropagation();\n return false;\n }\n }\n\n private proxyFocus(): void {\n this.focus();\n }\n\n private shouldProxyClick(): boolean {\n let handled = false;\n if (this.anchorElement) {\n this.anchorElement.click();\n handled = true;\n } else if (this.type !== 'button') {\n const proxy = document.createElement('button');\n proxy.type = this.type;\n this.insertAdjacentElement('afterend', proxy);\n proxy.click();\n proxy.remove();\n handled = true;\n }\n return handled;\n }\n\n public override renderAnchor(): TemplateResult {\n return html`\n ${this.buttonContent}\n ${super.renderAnchor({\n id: 'button',\n ariaHidden: true,\n className: 'button anchor hidden',\n })}\n `;\n }\n\n protected renderButton(): TemplateResult {\n return html`\n ${this.buttonContent}\n `;\n }\n\n protected override render(): TemplateResult {\n return this.href && this.href.length > 0\n ? this.renderAnchor()\n : this.renderButton();\n }\n\n protected handleKeydown(event: KeyboardEvent): void {\n const { code } = event;\n switch (code) {\n case 'Space':\n event.preventDefault();\n if (typeof this.href === 'undefined') {\n this.addEventListener('keyup', this.handleKeyup);\n this.active = true;\n }\n break;\n default:\n break;\n }\n }\n\n private handleKeypress(event: KeyboardEvent): void {\n const { code } = event;\n switch (code) {\n case 'Enter':\n case 'NumpadEnter':\n this.click();\n break;\n default:\n break;\n }\n }\n\n protected handleKeyup(event: KeyboardEvent): void {\n const { code } = event;\n switch (code) {\n case 'Space':\n this.removeEventListener('keyup', this.handleKeyup);\n this.active = false;\n this.click();\n break;\n default:\n break;\n }\n }\n\n private handleRemoveActive(): void {\n this.active = false;\n }\n\n private handlePointerdown(): void {\n this.active = true;\n }\n\n private manageAnchor(): void {\n if (this.href && this.href.length > 0) {\n if (this.getAttribute('role') === 'button') {\n this.setAttribute('role', 'link');\n }\n this.removeEventListener('click', this.shouldProxyClick);\n } else {\n if (\n !this.hasAttribute('role') ||\n this.getAttribute('role') === 'link'\n ) {\n this.setAttribute('role', 'button');\n }\n this.addEventListener('click', this.shouldProxyClick);\n }\n }\n\n protected override firstUpdated(changed: PropertyValues): void {\n super.firstUpdated(changed);\n if (!this.hasAttribute('tabindex')) {\n this.tabIndex = 0;\n }\n this.manageAnchor();\n this.addEventListener('keydown', this.handleKeydown);\n this.addEventListener('keypress', this.handleKeypress);\n this.addEventListener('pointerdown', this.handlePointerdown);\n }\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n if (changed.has('href')) {\n this.manageAnchor();\n }\n if (changed.has('label')) {\n this.setAttribute('aria-label', this.label || '');\n }\n if (changed.has('active')) {\n if (this.active) {\n this.addEventListener('focusout', this.handleRemoveActive);\n this.addEventListener('pointerup', this.handleRemoveActive);\n this.addEventListener('pointerleave', this.handleRemoveActive);\n } else {\n this.removeEventListener('focusout', this.handleRemoveActive);\n this.removeEventListener('pointerup', this.handleRemoveActive);\n this.removeEventListener(\n 'pointerleave',\n this.handleRemoveActive\n );\n }\n }\n if (this.anchorElement) {\n this.anchorElement.addEventListener('focus', this.proxyFocus);\n this.anchorElement.tabIndex = -1;\n }\n }\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/ClearButton.js
CHANGED
|
@@ -1,70 +1,24 @@
|
|
|
1
|
-
var
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
-
if (decorator = decorators[i])
|
|
7
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
-
if (kind && result)
|
|
9
|
-
__defProp(target, key, result);
|
|
10
|
-
return result;
|
|
11
|
-
};
|
|
12
|
-
import {
|
|
13
|
-
html,
|
|
14
|
-
SizedMixin
|
|
15
|
-
} from "@spectrum-web-components/base";
|
|
16
|
-
import { property } from "@spectrum-web-components/base/src/decorators.js";
|
|
17
|
-
import { StyledButton } from "./StyledButton.js";
|
|
18
|
-
import buttonStyles from "@spectrum-web-components/clear-button/src/clear-button.css.js";
|
|
19
|
-
import "@spectrum-web-components/icons-ui/icons/sp-icon-cross75.js";
|
|
20
|
-
import "@spectrum-web-components/icons-ui/icons/sp-icon-cross100.js";
|
|
21
|
-
import "@spectrum-web-components/icons-ui/icons/sp-icon-cross200.js";
|
|
22
|
-
import "@spectrum-web-components/icons-ui/icons/sp-icon-cross300.js";
|
|
23
|
-
import crossMediumStyles from "@spectrum-web-components/icon/src/spectrum-icon-cross.css.js";
|
|
24
|
-
const crossIcon = {
|
|
25
|
-
s: () => html`
|
|
1
|
+
var l=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var p=(e,r,c,t)=>{for(var s=t>1?void 0:t?m(r,c):r,i=e.length-1,n;i>=0;i--)(n=e[i])&&(s=(t?n(r,c,s):n(s))||s);return t&&s&&l(r,c,s),s};import{html as o,SizedMixin as u}from"@spectrum-web-components/base";import{property as a}from"@spectrum-web-components/base/src/decorators.js";import{StyledButton as d}from"./StyledButton.js";import I from"@spectrum-web-components/clear-button/src/clear-button.css.js";import"@spectrum-web-components/icons-ui/icons/sp-icon-cross75.js";import"@spectrum-web-components/icons-ui/icons/sp-icon-cross100.js";import"@spectrum-web-components/icons-ui/icons/sp-icon-cross200.js";import"@spectrum-web-components/icons-ui/icons/sp-icon-cross300.js";import y from"@spectrum-web-components/icon/src/spectrum-icon-cross.css.js";const S={s:()=>o`
|
|
26
2
|
<sp-icon-cross75
|
|
27
3
|
slot="icon"
|
|
28
4
|
class="icon spectrum-UIIcon-Cross75"
|
|
29
5
|
></sp-icon-cross75>
|
|
30
|
-
`,
|
|
31
|
-
m: () => html`
|
|
6
|
+
`,m:()=>o`
|
|
32
7
|
<sp-icon-cross100
|
|
33
8
|
slot="icon"
|
|
34
9
|
class="icon spectrum-UIIcon-Cross100"
|
|
35
10
|
></sp-icon-cross100>
|
|
36
|
-
`,
|
|
37
|
-
l: () => html`
|
|
11
|
+
`,l:()=>o`
|
|
38
12
|
<sp-icon-cross200
|
|
39
13
|
slot="icon"
|
|
40
14
|
class="icon spectrum-UIIcon-Cross200"
|
|
41
15
|
></sp-icon-cross200>
|
|
42
|
-
`,
|
|
43
|
-
xl: () => html`
|
|
16
|
+
`,xl:()=>o`
|
|
44
17
|
<sp-icon-cross300
|
|
45
18
|
slot="icon"
|
|
46
19
|
class="icon spectrum-UIIcon-Cross300"
|
|
47
20
|
></sp-icon-cross300>
|
|
48
|
-
`
|
|
49
|
-
};
|
|
50
|
-
export class ClearButton extends SizedMixin(StyledButton) {
|
|
51
|
-
constructor() {
|
|
52
|
-
super(...arguments);
|
|
53
|
-
this.variant = "";
|
|
54
|
-
}
|
|
55
|
-
static get styles() {
|
|
56
|
-
return [...super.styles, buttonStyles, crossMediumStyles];
|
|
57
|
-
}
|
|
58
|
-
get buttonContent() {
|
|
59
|
-
return [crossIcon[this.size]()];
|
|
60
|
-
}
|
|
61
|
-
render() {
|
|
62
|
-
return html`
|
|
21
|
+
`};export class ClearButton extends u(d){constructor(){super(...arguments);this.variant=""}static get styles(){return[...super.styles,I,y]}get buttonContent(){return[S[this.size]()]}render(){return o`
|
|
63
22
|
<div class="fill">${super.render()}</div>
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
__decorateClass([
|
|
68
|
-
property({ reflect: true })
|
|
69
|
-
], ClearButton.prototype, "variant", 2);
|
|
23
|
+
`}}p([a({reflect:!0})],ClearButton.prototype,"variant",2);
|
|
70
24
|
//# sourceMappingURL=ClearButton.js.map
|
package/src/ClearButton.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["ClearButton.ts"],
|
|
4
4
|
"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 SizedMixin,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\nimport { StyledButton } from './StyledButton.js';\nimport buttonStyles from '@spectrum-web-components/clear-button/src/clear-button.css.js';\nimport '@spectrum-web-components/icons-ui/icons/sp-icon-cross75.js';\nimport '@spectrum-web-components/icons-ui/icons/sp-icon-cross100.js';\nimport '@spectrum-web-components/icons-ui/icons/sp-icon-cross200.js';\nimport '@spectrum-web-components/icons-ui/icons/sp-icon-cross300.js';\nimport crossMediumStyles from '@spectrum-web-components/icon/src/spectrum-icon-cross.css.js';\n\nconst crossIcon: Record<string, () => TemplateResult> = {\n s: () => html`\n <sp-icon-cross75\n slot=\"icon\"\n class=\"icon spectrum-UIIcon-Cross75\"\n ></sp-icon-cross75>\n `,\n m: () => html`\n <sp-icon-cross100\n slot=\"icon\"\n class=\"icon spectrum-UIIcon-Cross100\"\n ></sp-icon-cross100>\n `,\n l: () => html`\n <sp-icon-cross200\n slot=\"icon\"\n class=\"icon spectrum-UIIcon-Cross200\"\n ></sp-icon-cross200>\n `,\n xl: () => html`\n <sp-icon-cross300\n slot=\"icon\"\n class=\"icon spectrum-UIIcon-Cross300\"\n ></sp-icon-cross300>\n `,\n};\n\n/**\n * @element sp-clear-button\n *\n * @slot - text label of the Clear Button\n * @slot icon - The icon to use for Clear Button\n */\nexport class ClearButton extends SizedMixin(StyledButton) {\n public static override get styles(): CSSResultArray {\n return [...super.styles, buttonStyles, crossMediumStyles];\n }\n\n /**\n * The visual variant to apply to this button.\n */\n @property({ reflect: true })\n public variant: 'overBackground' | '' = '';\n\n protected override get buttonContent(): TemplateResult[] {\n return [crossIcon[this.size]()];\n }\n\n protected override render(): TemplateResult {\n return html`\n <div class=\"fill\">${super.render()}</div>\n `;\n }\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "wMAYA,qEAMA,2EACA,iDACA,6EACA,mEACA,oEACA,oEACA,oEACA,4EAEA,KAAM,GAAkD,CACpD,EAAG,IAAM;AAAA;AAAA;AAAA;AAAA;AAAA,MAMT,EAAG,IAAM;AAAA;AAAA;AAAA;AAAA;AAAA,MAMT,EAAG,IAAM;AAAA;AAAA;AAAA;AAAA;AAAA,MAMT,GAAI,IAAM;AAAA;AAAA;AAAA;AAAA;AAAA,KAMd,EAQO,aAAM,mBAAoB,GAAW,CAAY,CAAE,CAAnD,kCASI,aAAiC,aARb,SAAyB,CAChD,MAAO,CAAC,GAAG,MAAM,OAAQ,EAAc,CAAiB,CAC5D,IAQuB,gBAAkC,CACrD,MAAO,CAAC,EAAU,KAAK,MAAM,CAAC,CAClC,CAEmB,QAAyB,CACxC,MAAO;AAAA,gCACiB,MAAM,OAAO;AAAA,SAEzC,CACJ,CAXW,GADP,AAAC,EAAS,CAAE,QAAS,EAAK,CAAC,GACpB,AATJ,YASI",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/CloseButton.js
CHANGED
|
@@ -1,65 +1,22 @@
|
|
|
1
|
-
var
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
-
if (decorator = decorators[i])
|
|
7
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
-
if (kind && result)
|
|
9
|
-
__defProp(target, key, result);
|
|
10
|
-
return result;
|
|
11
|
-
};
|
|
12
|
-
import {
|
|
13
|
-
html,
|
|
14
|
-
SizedMixin
|
|
15
|
-
} from "@spectrum-web-components/base";
|
|
16
|
-
import { property } from "@spectrum-web-components/base/src/decorators.js";
|
|
17
|
-
import { StyledButton } from "./StyledButton.js";
|
|
18
|
-
import buttonStyles from "@spectrum-web-components/close-button/src/close-button.css.js";
|
|
19
|
-
import "@spectrum-web-components/icons-ui/icons/sp-icon-cross75.js";
|
|
20
|
-
import "@spectrum-web-components/icons-ui/icons/sp-icon-cross100.js";
|
|
21
|
-
import "@spectrum-web-components/icons-ui/icons/sp-icon-cross200.js";
|
|
22
|
-
import "@spectrum-web-components/icons-ui/icons/sp-icon-cross300.js";
|
|
23
|
-
import crossMediumStyles from "@spectrum-web-components/icon/src/spectrum-icon-cross.css.js";
|
|
24
|
-
const crossIcon = {
|
|
25
|
-
s: () => html`
|
|
1
|
+
var l=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var p=(c,o,e,t)=>{for(var s=t>1?void 0:t?m(o,e):o,i=c.length-1,n;i>=0;i--)(n=c[i])&&(s=(t?n(o,e,s):n(s))||s);return t&&s&&l(o,e,s),s};import{html as r,SizedMixin as u}from"@spectrum-web-components/base";import{property as a}from"@spectrum-web-components/base/src/decorators.js";import{StyledButton as S}from"./StyledButton.js";import y from"@spectrum-web-components/close-button/src/close-button.css.js";import"@spectrum-web-components/icons-ui/icons/sp-icon-cross75.js";import"@spectrum-web-components/icons-ui/icons/sp-icon-cross100.js";import"@spectrum-web-components/icons-ui/icons/sp-icon-cross200.js";import"@spectrum-web-components/icons-ui/icons/sp-icon-cross300.js";import I from"@spectrum-web-components/icon/src/spectrum-icon-cross.css.js";const d={s:()=>r`
|
|
26
2
|
<sp-icon-cross75
|
|
27
3
|
slot="icon"
|
|
28
4
|
class="icon spectrum-UIIcon-Cross75"
|
|
29
5
|
></sp-icon-cross75>
|
|
30
|
-
`,
|
|
31
|
-
m: () => html`
|
|
6
|
+
`,m:()=>r`
|
|
32
7
|
<sp-icon-cross100
|
|
33
8
|
slot="icon"
|
|
34
9
|
class="icon spectrum-UIIcon-Cross100"
|
|
35
10
|
></sp-icon-cross100>
|
|
36
|
-
`,
|
|
37
|
-
l: () => html`
|
|
11
|
+
`,l:()=>r`
|
|
38
12
|
<sp-icon-cross200
|
|
39
13
|
slot="icon"
|
|
40
14
|
class="icon spectrum-UIIcon-Cross200"
|
|
41
15
|
></sp-icon-cross200>
|
|
42
|
-
`,
|
|
43
|
-
xl: () => html`
|
|
16
|
+
`,xl:()=>r`
|
|
44
17
|
<sp-icon-cross300
|
|
45
18
|
slot="icon"
|
|
46
19
|
class="icon spectrum-UIIcon-Cross300"
|
|
47
20
|
></sp-icon-cross300>
|
|
48
|
-
`
|
|
49
|
-
};
|
|
50
|
-
export class CloseButton extends SizedMixin(StyledButton) {
|
|
51
|
-
constructor() {
|
|
52
|
-
super(...arguments);
|
|
53
|
-
this.variant = "";
|
|
54
|
-
}
|
|
55
|
-
static get styles() {
|
|
56
|
-
return [...super.styles, buttonStyles, crossMediumStyles];
|
|
57
|
-
}
|
|
58
|
-
get buttonContent() {
|
|
59
|
-
return [crossIcon[this.size]()];
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
__decorateClass([
|
|
63
|
-
property({ reflect: true })
|
|
64
|
-
], CloseButton.prototype, "variant", 2);
|
|
21
|
+
`};export class CloseButton extends u(S){constructor(){super(...arguments);this.variant=""}static get styles(){return[...super.styles,y,I]}get buttonContent(){return[d[this.size]()]}}p([a({reflect:!0})],CloseButton.prototype,"variant",2);
|
|
65
22
|
//# sourceMappingURL=CloseButton.js.map
|