@spectrum-web-components/action-button 0.7.4 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/custom-elements.json +19 -2
  2. package/package.json +7 -7
  3. package/src/ActionButton.d.ts +1 -0
  4. package/src/ActionButton.js +4 -2
  5. package/src/ActionButton.js.map +1 -1
  6. package/src/action-button.css.js +111 -105
  7. package/src/action-button.css.js.map +1 -1
  8. package/src/spectrum-action-button.css.js +106 -104
  9. package/src/spectrum-action-button.css.js.map +1 -1
  10. package/src/spectrum-config.js +31 -2
  11. package/stories/action-button-black-quiet.stories.js +34 -0
  12. package/stories/action-button-black-quiet.stories.js.map +1 -0
  13. package/stories/action-button-black.stories.js +29 -0
  14. package/stories/action-button-black.stories.js.map +1 -0
  15. package/stories/action-button-emphasized-quiet.stories.js +32 -0
  16. package/stories/action-button-emphasized-quiet.stories.js.map +1 -0
  17. package/stories/action-button-emphasized.stories.js +27 -0
  18. package/stories/action-button-emphasized.stories.js.map +1 -0
  19. package/stories/action-button-quiet.stories.js +27 -0
  20. package/stories/action-button-quiet.stories.js.map +1 -0
  21. package/stories/action-button-standard.stories.js +22 -0
  22. package/stories/action-button-standard.stories.js.map +1 -0
  23. package/stories/action-button-white-quiet.stories.js +34 -0
  24. package/stories/action-button-white-quiet.stories.js.map +1 -0
  25. package/stories/action-button-white.stories.js +29 -0
  26. package/stories/action-button-white.stories.js.map +1 -0
  27. package/stories/action-button.stories.js +17 -74
  28. package/stories/action-button.stories.js.map +1 -1
  29. package/stories/{action-button-sizes.stories.js → index.js} +26 -44
  30. package/stories/index.js.map +1 -0
  31. package/stories/action-button-sizes.stories.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectrum-web-components/action-button",
3
- "version": "0.7.4",
3
+ "version": "0.8.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -44,19 +44,19 @@
44
44
  "lit-html"
45
45
  ],
46
46
  "dependencies": {
47
- "@spectrum-web-components/base": "^0.5.2",
48
- "@spectrum-web-components/button": "^0.16.4",
49
- "@spectrum-web-components/icon": "^0.11.3",
50
- "@spectrum-web-components/icons-ui": "^0.8.3",
47
+ "@spectrum-web-components/base": "^0.5.4",
48
+ "@spectrum-web-components/button": "^0.17.1",
49
+ "@spectrum-web-components/icon": "^0.11.5",
50
+ "@spectrum-web-components/icons-ui": "^0.8.5",
51
51
  "tslib": "^2.0.0"
52
52
  },
53
53
  "devDependencies": {
54
- "@spectrum-css/actionbutton": "^1.0.10"
54
+ "@spectrum-css/actionbutton": "^1.1.6"
55
55
  },
56
56
  "types": "./src/index.d.ts",
57
57
  "customElements": "custom-elements.json",
58
58
  "sideEffects": [
59
59
  "./sp-*.js"
60
60
  ],
61
- "gitHead": "bb5308b9be01cc7c5bbab289312042256bdcc740"
61
+ "gitHead": "caf12727e7f91dcf961e1fadacc727eea9ece27b"
62
62
  }
@@ -35,6 +35,7 @@ export declare class ActionButton extends ActionButton_base {
35
35
  * should be used when `selected === false`
36
36
  */
37
37
  toggles: boolean;
38
+ variant?: 'white' | 'black';
38
39
  get value(): string;
39
40
  set value(value: string);
40
41
  private _value;
@@ -150,8 +150,7 @@ export class ActionButton extends SizedMixin(ButtonBase) {
150
150
  if (this.holdAffordance) {
151
151
  buttonContent.unshift(html `
152
152
  <sp-icon-corner-triangle300
153
- id="hold-affordance"
154
- class="${holdAffordanceClass[this.size]}"
153
+ class="hold-affordance ${holdAffordanceClass[this.size]}"
155
154
  ></sp-icon-corner-triangle300>
156
155
  `);
157
156
  }
@@ -194,6 +193,9 @@ __decorate([
194
193
  __decorate([
195
194
  property({ type: Boolean, reflect: true })
196
195
  ], ActionButton.prototype, "toggles", void 0);
196
+ __decorate([
197
+ property({ reflect: true })
198
+ ], ActionButton.prototype, "variant", void 0);
197
199
  __decorate([
198
200
  property({ type: String })
199
201
  ], ActionButton.prototype, "value", null);
@@ -1 +1 @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,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC;oDAC3C;AAG9B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2CACtB;AAGrB;IADC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CACL;AAOvB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8CACnB;AAQxB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;6CACpB;AAGvB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yCAG1B","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 DefaultElementSize,\n html,\n PropertyValues,\n SizedMixin,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\nimport { ButtonBase } from '@spectrum-web-components/button';\nimport buttonStyles from './action-button.css.js';\nimport cornerTriangleStyles from '@spectrum-web-components/icon/src/spectrum-icon-corner-triangle.css.js';\nimport '@spectrum-web-components/icons-ui/icons/sp-icon-corner-triangle300.js';\n\nconst holdAffordanceClass = {\n s: 'spectrum-UIIcon-CornerTriangle75',\n m: 'spectrum-UIIcon-CornerTriangle100',\n l: 'spectrum-UIIcon-CornerTriangle200',\n xl: 'spectrum-UIIcon-CornerTriangle300',\n};\n\nconst LONGPRESS_DURATION = 300;\nlet LONGPRESS_TIMEOUT: ReturnType<typeof setTimeout>;\n\nexport type LongpressEvent = {\n source: 'pointer' | 'keyboard';\n};\n\n/**\n * @element sp-action-button\n *\n * @slot - text label of the Action Button\n * @slot icon - The icon to use for Action Button\n * @fires change - Announces a change in the `selected` property of an action button\n * @fires longpress - Synthesizes a \"longpress\" interaction that signifies a\n * `pointerdown` event that is >=300ms or a keyboard event wher code is `Space` or code is `ArrowDown`\n * while `altKey===true`.\n */\nexport class ActionButton extends SizedMixin(ButtonBase) {\n public static get styles(): CSSResultArray {\n return [buttonStyles, cornerTriangleStyles];\n }\n\n @property({ type: Boolean, reflect: true })\n public emphasized = false;\n\n @property({ type: Boolean, reflect: true, attribute: 'hold-affordance' })\n public holdAffordance = false;\n\n @property({ type: Boolean, reflect: true })\n public quiet = false;\n\n @property({ reflect: true })\n public role = 'button';\n\n /**\n * Whether an Action Button with `role='button'`\n * should also be `aria-pressed='true'`\n */\n @property({ type: Boolean, reflect: true })\n public selected = false;\n\n /**\n * Whether to automatically manage the `selected`\n * attribute on interaction and whether `aria-pressed=\"false\"`\n * should be used when `selected === false`\n */\n @property({ type: Boolean, reflect: true })\n public toggles = false;\n\n @property({ type: String })\n public get value(): string {\n return this._value || this.itemText;\n }\n public set value(value: string) {\n if (value === this._value) {\n return;\n }\n this._value = value || '';\n if (this._value) {\n this.setAttribute('value', this._value);\n } else {\n this.removeAttribute('value');\n }\n }\n private _value = '';\n\n /**\n * @private\n */\n public get itemText(): string {\n return (this.textContent || /* c8 ignore next */ '').trim();\n }\n\n constructor() {\n super();\n this.addEventListener('click', this.onClick);\n this.addEventListener('pointerdown', this.onPointerdown);\n }\n\n private onClick = (): void => {\n if (!this.toggles) {\n return;\n }\n this.selected = !this.selected;\n const applyDefault = this.dispatchEvent(\n new Event('change', {\n cancelable: true,\n })\n );\n if (!applyDefault) {\n this.selected = !this.selected;\n }\n };\n\n private onPointerdown(): void {\n this.addEventListener('pointerup', this.onPointerup);\n this.addEventListener('pointercancel', this.onPointerup);\n LONGPRESS_TIMEOUT = setTimeout(() => {\n this.dispatchEvent(\n new CustomEvent<LongpressEvent>('longpress', {\n bubbles: true,\n composed: true,\n detail: {\n source: 'pointer',\n },\n })\n );\n }, LONGPRESS_DURATION);\n }\n\n private onPointerup(): void {\n clearTimeout(LONGPRESS_TIMEOUT);\n this.removeEventListener('pointerup', this.onPointerup);\n this.removeEventListener('pointercancel', this.onPointerup);\n }\n\n /**\n * @private\n */\n protected handleKeydown(event: KeyboardEvent): void {\n if (!this.holdAffordance) {\n return super.handleKeydown(event);\n }\n const { code, altKey } = event;\n if (code === 'Space' || (altKey && code === 'ArrowDown')) {\n event.preventDefault();\n if (code === 'ArrowDown') {\n event.stopPropagation();\n event.stopImmediatePropagation();\n }\n this.addEventListener('keyup', this.handleKeyup);\n this.active = true;\n }\n }\n\n protected handleKeyup(event: KeyboardEvent): void {\n if (!this.holdAffordance) {\n return super.handleKeyup(event);\n }\n const { code, altKey } = event;\n if (code === 'Space' || (altKey && code === 'ArrowDown')) {\n event.stopPropagation();\n this.dispatchEvent(\n new CustomEvent<LongpressEvent>('longpress', {\n bubbles: true,\n composed: true,\n detail: {\n source: 'keyboard',\n },\n })\n );\n this.active = false;\n }\n }\n\n protected get buttonContent(): TemplateResult[] {\n const buttonContent = super.buttonContent;\n if (this.holdAffordance) {\n buttonContent.unshift(html`\n <sp-icon-corner-triangle300\n id=\"hold-affordance\"\n class=\"${holdAffordanceClass[\n this.size as DefaultElementSize\n ]}\"\n ></sp-icon-corner-triangle300>\n `);\n }\n return buttonContent;\n }\n\n protected updated(changes: PropertyValues): void {\n super.updated(changes);\n const isButton = this.role === 'button';\n const canBePressed = isButton && (this.selected || this.toggles);\n if (changes.has('selected') || changes.has('role')) {\n // When role !== 'button' then the Action Button is within\n // an Action Group that manages selects which means the\n // Action Button is a \"checkbox\" or \"radio\" and cannot\n // accept the `aria-pressed` attribute.\n if (canBePressed) {\n this.setAttribute(\n 'aria-pressed',\n this.selected ? 'true' : 'false'\n );\n } else {\n // When !this.toggles the lack of \"aria-pressed\" is inconsequential.\n this.removeAttribute('aria-pressed');\n }\n }\n }\n}\n\ndeclare global {\n interface GlobalEventHandlersEventMap {\n longpress: CustomEvent<LongpressEvent>;\n }\n}\n"]}
1
+ {"version":3,"file":"ActionButton.js","sourceRoot":"","sources":["ActionButton.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;;AAEF,OAAO,EAGH,IAAI,EAEJ,UAAU,GAEb,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,iDAAiD,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,YAAY,MAAM,wBAAwB,CAAC;AAClD,OAAO,oBAAoB,MAAM,wEAAwE,CAAC;AAC1G,OAAO,uEAAuE,CAAC;AAE/E,MAAM,mBAAmB,GAAG;IACxB,CAAC,EAAE,kCAAkC;IACrC,CAAC,EAAE,mCAAmC;IACtC,CAAC,EAAE,mCAAmC;IACtC,EAAE,EAAE,mCAAmC;CAC1C,CAAC;AAEF,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAC/B,IAAI,iBAAgD,CAAC;AAMrD;;;;;;;;;GASG;AACH,MAAM,OAAO,YAAa,SAAQ,UAAU,CAAC,UAAU,CAAC;IA2DpD;QACI,KAAK,EAAE,CAAC;QAtDL,eAAU,GAAG,KAAK,CAAC;QAGnB,mBAAc,GAAG,KAAK,CAAC;QAGvB,UAAK,GAAG,KAAK,CAAC;QAGd,SAAI,GAAG,QAAQ,CAAC;QAEvB;;;WAGG;QAEI,aAAQ,GAAG,KAAK,CAAC;QAExB;;;;WAIG;QAEI,YAAO,GAAG,KAAK,CAAC;QAoBf,WAAM,GAAG,EAAE,CAAC;QAeZ,YAAO,GAAG,GAAS,EAAE;YACzB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;gBACf,OAAO;aACV;YACD,IAA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IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;aACxC;SACJ;IACL,CAAC;CACJ;AAzKG;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;gDACjB;AAG1B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC;oDAC3C;AAG9B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2CACtB;AAGrB;IADC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CACL;AAOvB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8CACnB;AAQxB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;6CACpB;AAGvB;IADC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;6CACO;AAGnC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yCAG1B","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 DefaultElementSize,\n html,\n PropertyValues,\n SizedMixin,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\nimport { ButtonBase } from '@spectrum-web-components/button';\nimport buttonStyles from './action-button.css.js';\nimport cornerTriangleStyles from '@spectrum-web-components/icon/src/spectrum-icon-corner-triangle.css.js';\nimport '@spectrum-web-components/icons-ui/icons/sp-icon-corner-triangle300.js';\n\nconst holdAffordanceClass = {\n s: 'spectrum-UIIcon-CornerTriangle75',\n m: 'spectrum-UIIcon-CornerTriangle100',\n l: 'spectrum-UIIcon-CornerTriangle200',\n xl: 'spectrum-UIIcon-CornerTriangle300',\n};\n\nconst LONGPRESS_DURATION = 300;\nlet LONGPRESS_TIMEOUT: ReturnType<typeof setTimeout>;\n\nexport type LongpressEvent = {\n source: 'pointer' | 'keyboard';\n};\n\n/**\n * @element sp-action-button\n *\n * @slot - text label of the Action Button\n * @slot icon - The icon to use for Action Button\n * @fires change - Announces a change in the `selected` property of an action button\n * @fires longpress - Synthesizes a \"longpress\" interaction that signifies a\n * `pointerdown` event that is >=300ms or a keyboard event wher code is `Space` or code is `ArrowDown`\n * while `altKey===true`.\n */\nexport class ActionButton extends SizedMixin(ButtonBase) {\n public static get styles(): CSSResultArray {\n return [buttonStyles, cornerTriangleStyles];\n }\n\n @property({ type: Boolean, reflect: true })\n public emphasized = false;\n\n @property({ type: Boolean, reflect: true, attribute: 'hold-affordance' })\n public holdAffordance = false;\n\n @property({ type: Boolean, reflect: true })\n public quiet = false;\n\n @property({ reflect: true })\n public role = 'button';\n\n /**\n * Whether an Action Button with `role='button'`\n * should also be `aria-pressed='true'`\n */\n @property({ type: Boolean, reflect: true })\n public selected = false;\n\n /**\n * Whether to automatically manage the `selected`\n * attribute on interaction and whether `aria-pressed=\"false\"`\n * should be used when `selected === false`\n */\n @property({ type: Boolean, reflect: true })\n public toggles = false;\n\n @property({ reflect: true })\n public variant?: 'white' | 'black';\n\n @property({ type: String })\n public get value(): string {\n return this._value || this.itemText;\n }\n public set value(value: string) {\n if (value === this._value) {\n return;\n }\n this._value = value || '';\n if (this._value) {\n this.setAttribute('value', this._value);\n } else {\n this.removeAttribute('value');\n }\n }\n private _value = '';\n\n /**\n * @private\n */\n public get itemText(): string {\n return (this.textContent || /* c8 ignore next */ '').trim();\n }\n\n constructor() {\n super();\n this.addEventListener('click', this.onClick);\n this.addEventListener('pointerdown', this.onPointerdown);\n }\n\n private onClick = (): void => {\n if (!this.toggles) {\n return;\n }\n this.selected = !this.selected;\n const applyDefault = this.dispatchEvent(\n new Event('change', {\n cancelable: true,\n })\n );\n if (!applyDefault) {\n this.selected = !this.selected;\n }\n };\n\n private onPointerdown(): void {\n this.addEventListener('pointerup', this.onPointerup);\n this.addEventListener('pointercancel', this.onPointerup);\n LONGPRESS_TIMEOUT = setTimeout(() => {\n this.dispatchEvent(\n new CustomEvent<LongpressEvent>('longpress', {\n bubbles: true,\n composed: true,\n detail: {\n source: 'pointer',\n },\n })\n );\n }, LONGPRESS_DURATION);\n }\n\n private onPointerup(): void {\n clearTimeout(LONGPRESS_TIMEOUT);\n this.removeEventListener('pointerup', this.onPointerup);\n this.removeEventListener('pointercancel', this.onPointerup);\n }\n\n /**\n * @private\n */\n protected handleKeydown(event: KeyboardEvent): void {\n if (!this.holdAffordance) {\n return super.handleKeydown(event);\n }\n const { code, altKey } = event;\n if (code === 'Space' || (altKey && code === 'ArrowDown')) {\n event.preventDefault();\n if (code === 'ArrowDown') {\n event.stopPropagation();\n event.stopImmediatePropagation();\n }\n this.addEventListener('keyup', this.handleKeyup);\n this.active = true;\n }\n }\n\n protected handleKeyup(event: KeyboardEvent): void {\n if (!this.holdAffordance) {\n return super.handleKeyup(event);\n }\n const { code, altKey } = event;\n if (code === 'Space' || (altKey && code === 'ArrowDown')) {\n event.stopPropagation();\n this.dispatchEvent(\n new CustomEvent<LongpressEvent>('longpress', {\n bubbles: true,\n composed: true,\n detail: {\n source: 'keyboard',\n },\n })\n );\n this.active = false;\n }\n }\n\n protected get buttonContent(): TemplateResult[] {\n const buttonContent = super.buttonContent;\n if (this.holdAffordance) {\n buttonContent.unshift(html`\n <sp-icon-corner-triangle300\n class=\"hold-affordance ${holdAffordanceClass[\n this.size as DefaultElementSize\n ]}\"\n ></sp-icon-corner-triangle300>\n `);\n }\n return buttonContent;\n }\n\n protected updated(changes: PropertyValues): void {\n super.updated(changes);\n const isButton = this.role === 'button';\n const canBePressed = isButton && (this.selected || this.toggles);\n if (changes.has('selected') || changes.has('role')) {\n // When role !== 'button' then the Action Button is within\n // an Action Group that manages selects which means the\n // Action Button is a \"checkbox\" or \"radio\" and cannot\n // accept the `aria-pressed` attribute.\n if (canBePressed) {\n this.setAttribute(\n 'aria-pressed',\n this.selected ? 'true' : 'false'\n );\n } else {\n // When !this.toggles the lack of \"aria-pressed\" is inconsequential.\n this.removeAttribute('aria-pressed');\n }\n }\n }\n}\n\ndeclare global {\n interface GlobalEventHandlersEventMap {\n longpress: CustomEvent<LongpressEvent>;\n }\n}\n"]}