@spectrum-web-components/story-decorator 0.4.1 → 0.4.3

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectrum-web-components/story-decorator",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -46,12 +46,12 @@
46
46
  ],
47
47
  "dependencies": {
48
48
  "@spectrum-web-components/base": "^0.5.1",
49
- "@spectrum-web-components/field-label": "^0.7.1",
50
- "@spectrum-web-components/menu": "^0.11.1",
51
- "@spectrum-web-components/overlay": "^0.13.1",
52
- "@spectrum-web-components/picker": "^0.9.1",
53
- "@spectrum-web-components/switch": "^0.9.1",
54
- "@spectrum-web-components/theme": "^0.9.1",
49
+ "@spectrum-web-components/field-label": "^0.7.3",
50
+ "@spectrum-web-components/menu": "^0.11.3",
51
+ "@spectrum-web-components/overlay": "^0.13.3",
52
+ "@spectrum-web-components/picker": "^0.9.3",
53
+ "@spectrum-web-components/switch": "^0.9.3",
54
+ "@spectrum-web-components/theme": "^0.9.3",
55
55
  "tslib": "^2.0.0"
56
56
  },
57
57
  "types": "./src/index.d.ts",
@@ -60,5 +60,5 @@
60
60
  "./sp-*.js",
61
61
  "./sp-*.ts"
62
62
  ],
63
- "gitHead": "df3f333ee26a45f9fc247716b6e8ef051dca630b"
63
+ "gitHead": "279380c6d72c0819fe224b405844af9ddcb87f8a"
64
64
  }
@@ -226,6 +226,9 @@ export class StoryDecorator extends SpectrumElement {
226
226
  }
227
227
  StoryDecorator.styles = [
228
228
  css `
229
+ :host(:focus) {
230
+ outline: none;
231
+ }
229
232
  sp-theme {
230
233
  overflow-x: hidden;
231
234
  display: block;
@@ -238,7 +241,6 @@ StoryDecorator.styles = [
238
241
  2 * var(--spectrum-alias-focus-ring-size) +
239
242
  var(--spectrum-alias-item-height-m)
240
243
  );
241
- box-sizing: border-box;
242
244
  background-color: var(--spectrum-global-color-gray-100);
243
245
  color: var(
244
246
  --spectrum-body-text-color,
@@ -1 +1 @@
1
- {"version":3,"file":"StoryDecorator.js","sourceRoot":"","sources":["StoryDecorator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;;AAEF,OAAO,EACH,GAAG,EACH,IAAI,EACJ,OAAO,EACP,eAAe,GAElB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACH,QAAQ,EACR,UAAU,GACb,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,iDAAiD,CAAC;AAC5E,OAAO,4CAA4C,CAAC;AACpD,OAAO,8CAA8C,CAAC;AACtD,OAAO,wDAAwD,CAAC;AAChE,OAAO,8CAA8C,CAAC;AACtD,OAAO,0CAA0C,CAAC;AAClD,OAAO,+CAA+C,CAAC;AACvD,OAAO,8CAA8C,CAAC;AAItD,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,YAAY,CAAC;AAEpB,MAAM,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;AAC3C,MAAM,SAAS,GAAG,IAAI,eAAe,CAAC,WAAW,CAAC,CAAC;AAEnD,MAAM,CAAC,IAAI,GAAG,GACT,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAmB,IAAI,KAAK,CAAC;AACxD,MAAM,CAAC,IAAI,KAAK,GAAW,SAAS,CAAC,GAAG,CAAC,UAAU,CAAW,IAAI,OAAO,CAAC;AAC1E,MAAM,CAAC,IAAI,KAAK,GAAW,SAAS,CAAC,GAAG,CAAC,UAAU,CAAW,IAAI,QAAQ,CAAC;AAC3E,MAAM,CAAC,IAAI,YAAY,GAAG,SAAS,CAAC,GAAG,CAAC,iBAAiB,CAAC,KAAK,MAAM,CAAC;AAEtE,MAAM,CAAC,kBAAkB,GAAG,MAAM,CAAC,kBAAkB,IAAI;IACrD,YAAY,EAAE,KAAK;IACnB,YAAY,EAAE,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;;;;;SAOjC,CAAC;IACN,CAAC;IAED,IAAY,YAAY;QACpB,OAAO,IAAI,CAAA;;;;;;;yBAOM,IAAI,CAAC,KAAK;0BACT,IAAI,CAAC,WAAW;;;;;SAKjC,CAAC;IACN,CAAC;IAED,IAAY,UAAU;QAClB,OAAO,IAAI,CAAA;;;;;;;yBAOM,IAAI,CAAC,SAAS;0BACb,IAAI,CAAC,WAAW;;;;;SAKjC,CAAC;IACN,CAAC;IAED,IAAY,mBAAmB;QAC3B,OAAO,IAAI,CAAA;;;2BAGQ,IAAI,CAAC,YAAY;0BAClB,IAAI,CAAC,WAAW;;;;SAIjC,CAAC;IACN,CAAC;;AArPM,qBAAM,GAAG;IACZ,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;kBAwBO,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAwC/B;CACJ,CAAC;AAGF;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CACkC;AAG7D;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CACkC;AAG7D;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iDAEoB;AAG/C;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oDACH;AAGpE;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;kDACjB;AAG1B;IADC,UAAU,CAAC,UAAU,CAAC;6CACD","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 css,\n html,\n nothing,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n property,\n queryAsync,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport { ifDefined } from '@spectrum-web-components/base/src/directives.js';\nimport '@spectrum-web-components/theme/sp-theme.js';\nimport '@spectrum-web-components/theme/src/themes.js';\nimport '@spectrum-web-components/field-label/sp-field-label.js';\nimport '@spectrum-web-components/picker/sp-picker.js';\nimport '@spectrum-web-components/menu/sp-menu.js';\nimport '@spectrum-web-components/menu/sp-menu-item.js';\nimport '@spectrum-web-components/switch/sp-switch.js';\nimport { Picker } from '@spectrum-web-components/picker';\nimport { Switch } from '@spectrum-web-components/switch';\nimport { Color, Scale, Theme } from '@spectrum-web-components/theme';\nimport { ActiveOverlay } from '@spectrum-web-components/overlay';\nimport './types.js';\n\nconst queryString = window.location.search;\nconst urlParams = new URLSearchParams(queryString);\n\nexport let dir: 'ltr' | 'rtl' =\n (urlParams.get('sp_dir') as 'ltr' | 'rtl') || 'ltr';\nexport let color: Color = (urlParams.get('sp_color') as Color) || 'light';\nexport let scale: Scale = (urlParams.get('sp_scale') as Scale) || 'medium';\nexport let reduceMotion = urlParams.get('sp_reduceMotion') === 'true';\n\nwindow.__swc_hack_knobs__ = window.__swc_hack_knobs__ || {\n defaultColor: color,\n defaultScale: scale,\n defaultDirection: dir,\n defaultReduceMotion: reduceMotion,\n};\n\nconst reduceMotionProperties = css`\n --spectrum-global-animation-duration-100: 0ms;\n --spectrum-global-animation-duration-200: 0ms;\n --spectrum-global-animation-duration-300: 0ms;\n --spectrum-global-animation-duration-400: 0ms;\n --spectrum-global-animation-duration-500: 0ms;\n --spectrum-global-animation-duration-600: 0ms;\n --spectrum-global-animation-duration-700: 0ms;\n --spectrum-global-animation-duration-800: 0ms;\n --spectrum-global-animation-duration-900: 0ms;\n --spectrum-global-animation-duration-1000: 0ms;\n --spectrum-global-animation-duration-2000: 0ms;\n --spectrum-global-animation-duration-4000: 0ms;\n --spectrum-coachmark-animation-indicator-ring-duration: 0ms;\n`;\n\nActiveOverlay.prototype.renderTheme = function (\n content: TemplateResult\n): TemplateResult {\n const { color, scale, lang } = this.theme;\n return html`\n ${window.__swc_hack_knobs__.defaultReduceMotion\n ? html`\n <style>\n sp-theme {\n ${reduceMotionProperties}\n }\n </style>\n `\n : html``}\n <sp-theme\n color=${ifDefined(color)}\n scale=${ifDefined(scale)}\n lang=${ifDefined(lang)}\n part=\"theme\"\n >\n ${content}\n </sp-theme>\n `;\n};\n\nexport class StoryDecorator extends SpectrumElement {\n static styles = [\n css`\n sp-theme {\n overflow-x: hidden;\n display: block;\n box-sizing: border-box;\n width: 100%;\n min-height: 100vh;\n padding: var(--spectrum-global-dimension-size-100)\n var(--spectrum-global-dimension-size-100)\n calc(\n 2 * var(--spectrum-alias-focus-ring-size) +\n var(--spectrum-alias-item-height-m)\n );\n box-sizing: border-box;\n background-color: var(--spectrum-global-color-gray-100);\n color: var(\n --spectrum-body-text-color,\n var(--spectrum-alias-text-color)\n );\n }\n :host([screenshot]) sp-theme {\n padding: var(--spectrum-global-dimension-size-100);\n }\n :host([reduce-motion]) sp-theme {\n ${reduceMotionProperties}\n }\n .manage-theme {\n position: fixed;\n bottom: 0;\n left: var(--spectrum-global-dimension-size-200);\n right: var(--spectrum-global-dimension-size-200);\n display: flex;\n align-items: center;\n justify-content: flex-end;\n box-sizing: border-box;\n background-color: var(--spectrum-global-color-gray-100);\n padding-bottom: calc(2 * var(--spectrum-alias-focus-ring-size));\n }\n [dir='ltr'] sp-field-label {\n padding-left: 0;\n padding-right: var(\n --spectrum-fieldlabel-side-padding-x,\n var(--spectrum-global-dimension-size-100)\n );\n margin-left: var(--spectrum-global-dimension-size-400);\n }\n [dir='ltr'] sp-switch {\n margin-left: var(--spectrum-global-dimension-size-400);\n margin-right: 0;\n padding: 0;\n }\n [dir='rtl'] sp-field-label {\n padding-right: 0;\n padding-left: var(\n --spectrum-fieldlabel-side-padding-x,\n var(--spectrum-global-dimension-size-100)\n );\n margin-right: var(--spectrum-global-dimension-size-400);\n }\n [dir='rtl'] sp-switch {\n margin-right: var(--spectrum-global-dimension-size-400);\n margin-left: 0;\n padding: 0;\n }\n `,\n ];\n\n @property({ type: String })\n public color: Color = window.__swc_hack_knobs__.defaultColor;\n\n @property({ type: String })\n public scale: Scale = window.__swc_hack_knobs__.defaultScale;\n\n @property({ type: String })\n public direction: 'ltr' | 'rtl' =\n window.__swc_hack_knobs__.defaultDirection;\n\n @property({ type: Boolean, attribute: 'reduce-motion', reflect: true })\n public reduceMotion = window.__swc_hack_knobs__.defaultReduceMotion;\n\n @property({ type: Boolean, reflect: true })\n public screenshot = false;\n\n @queryAsync('sp-theme')\n private theme!: Theme;\n\n public ready = false;\n\n public async startManagingContentDirection(el: HTMLElement): Promise<void> {\n (await this.theme).startManagingContentDirection(el);\n }\n\n public async stopManagingContentDirection(el: HTMLElement): Promise<void> {\n (await this.theme).stopManagingContentDirection(el);\n }\n\n private updateTheme({ target }: Event & { target: Picker | Switch }): void {\n const { id } = target;\n const { value } = target as Picker;\n const { checked } = target as Switch;\n switch (id) {\n case 'color':\n this.color =\n color =\n window.__swc_hack_knobs__.defaultColor =\n value as Color;\n break;\n case 'scale':\n this.scale =\n scale =\n window.__swc_hack_knobs__.defaultScale =\n value as Scale;\n break;\n case 'dir':\n this.direction =\n dir =\n window.__swc_hack_knobs__.defaultDirection =\n value as 'ltr' | 'rtl';\n break;\n case 'reduceMotion':\n this.reduceMotion =\n reduceMotion =\n window.__swc_hack_knobs__.defaultReduceMotion =\n checked as boolean;\n break;\n }\n }\n\n protected handleKeydown(event: KeyboardEvent): void {\n const path = event.composedPath();\n const hasInput = path.some((node) => node instanceof HTMLInputElement);\n if (hasInput) {\n event.stopPropagation();\n }\n }\n\n protected render(): TemplateResult {\n return html`\n <sp-theme\n color=${this.color}\n scale=${this.scale}\n dir=${this.direction}\n part=\"container\"\n @keydown=${this.handleKeydown}\n >\n <slot @slotchange=${this.checkReady}></slot>\n ${this.screenshot ? nothing : this.manageTheme}\n </sp-theme>\n `;\n }\n\n protected async checkReady({\n target,\n }: Event & { target: HTMLSlotElement }): Promise<void> {\n this.ready = false;\n const descendents = target.assignedElements({\n flatten: true,\n }) as SpectrumElement[];\n const litElementDescendents = descendents.filter(\n (el) =>\n el.tagName.search('-') !== -1 &&\n typeof el.updateComplete !== 'undefined'\n );\n const updates = litElementDescendents.map((el) => el.updateComplete);\n await Promise.all(updates);\n new Promise((res) => {\n setTimeout(res);\n }).then(async () => {\n await (document.fonts ? document.fonts.ready : Promise.resolve());\n setTimeout(() => (this.ready = true));\n });\n }\n\n private get manageTheme(): TemplateResult {\n return html`\n <div class=\"manage-theme\" part=\"controls\">\n ${this.colorControl} ${this.scaleControl} ${this.dirControl}\n ${this.reduceMotionControl}\n </div>\n `;\n }\n\n private get colorControl(): TemplateResult {\n return html`\n <sp-field-label for=\"color\">Theme</sp-field-label>\n <sp-picker\n id=\"color\"\n placement=\"top\"\n quiet\n .value=${this.color}\n @change=${this.updateTheme}\n >\n <sp-menu-item value=\"lightest\">Lightest</sp-menu-item>\n <sp-menu-item value=\"light\">Light</sp-menu-item>\n <sp-menu-item value=\"dark\">Dark</sp-menu-item>\n <sp-menu-item value=\"darkest\">Darkest</sp-menu-item>\n </sp-picker>\n `;\n }\n\n private get scaleControl(): TemplateResult {\n return html`\n <sp-field-label for=\"scale\">Scale</sp-field-label>\n <sp-picker\n id=\"scale\"\n label=\"Scale\"\n placement=\"top\"\n quiet\n .value=${this.scale}\n @change=${this.updateTheme}\n >\n <sp-menu-item value=\"medium\">Medium</sp-menu-item>\n <sp-menu-item value=\"large\">Large</sp-menu-item>\n </sp-picker>\n `;\n }\n\n private get dirControl(): TemplateResult {\n return html`\n <sp-field-label for=\"dir\">Direction</sp-field-label>\n <sp-picker\n id=\"dir\"\n label=\"Direction\"\n placement=\"top\"\n quiet\n .value=${this.direction}\n @change=${this.updateTheme}\n >\n <sp-menu-item value=\"ltr\">LTR</sp-menu-item>\n <sp-menu-item value=\"rtl\">RTL</sp-menu-item>\n </sp-picker>\n `;\n }\n\n private get reduceMotionControl(): TemplateResult {\n return html`\n <sp-switch\n id=\"reduceMotion\"\n ?checked=${this.reduceMotion}\n @change=${this.updateTheme}\n >\n Reduce Motion\n </sp-switch>\n `;\n }\n}\n"]}
1
+ {"version":3,"file":"StoryDecorator.js","sourceRoot":"","sources":["StoryDecorator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;;AAEF,OAAO,EACH,GAAG,EACH,IAAI,EACJ,OAAO,EACP,eAAe,GAElB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACH,QAAQ,EACR,UAAU,GACb,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,iDAAiD,CAAC;AAC5E,OAAO,4CAA4C,CAAC;AACpD,OAAO,8CAA8C,CAAC;AACtD,OAAO,wDAAwD,CAAC;AAChE,OAAO,8CAA8C,CAAC;AACtD,OAAO,0CAA0C,CAAC;AAClD,OAAO,+CAA+C,CAAC;AACvD,OAAO,8CAA8C,CAAC;AAItD,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,YAAY,CAAC;AAEpB,MAAM,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;AAC3C,MAAM,SAAS,GAAG,IAAI,eAAe,CAAC,WAAW,CAAC,CAAC;AAEnD,MAAM,CAAC,IAAI,GAAG,GACT,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAmB,IAAI,KAAK,CAAC;AACxD,MAAM,CAAC,IAAI,KAAK,GAAW,SAAS,CAAC,GAAG,CAAC,UAAU,CAAW,IAAI,OAAO,CAAC;AAC1E,MAAM,CAAC,IAAI,KAAK,GAAW,SAAS,CAAC,GAAG,CAAC,UAAU,CAAW,IAAI,QAAQ,CAAC;AAC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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 css,\n html,\n nothing,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n property,\n queryAsync,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport { ifDefined } from '@spectrum-web-components/base/src/directives.js';\nimport '@spectrum-web-components/theme/sp-theme.js';\nimport '@spectrum-web-components/theme/src/themes.js';\nimport '@spectrum-web-components/field-label/sp-field-label.js';\nimport '@spectrum-web-components/picker/sp-picker.js';\nimport '@spectrum-web-components/menu/sp-menu.js';\nimport '@spectrum-web-components/menu/sp-menu-item.js';\nimport '@spectrum-web-components/switch/sp-switch.js';\nimport { Picker } from '@spectrum-web-components/picker';\nimport { Switch } from '@spectrum-web-components/switch';\nimport { Color, Scale, Theme } from '@spectrum-web-components/theme';\nimport { ActiveOverlay } from '@spectrum-web-components/overlay';\nimport './types.js';\n\nconst queryString = window.location.search;\nconst urlParams = new URLSearchParams(queryString);\n\nexport let dir: 'ltr' | 'rtl' =\n (urlParams.get('sp_dir') as 'ltr' | 'rtl') || 'ltr';\nexport let color: Color = (urlParams.get('sp_color') as Color) || 'light';\nexport let scale: Scale = (urlParams.get('sp_scale') as Scale) || 'medium';\nexport let reduceMotion = urlParams.get('sp_reduceMotion') === 'true';\n\nwindow.__swc_hack_knobs__ = window.__swc_hack_knobs__ || {\n defaultColor: color,\n defaultScale: scale,\n defaultDirection: dir,\n defaultReduceMotion: reduceMotion,\n};\n\nconst reduceMotionProperties = css`\n --spectrum-global-animation-duration-100: 0ms;\n --spectrum-global-animation-duration-200: 0ms;\n --spectrum-global-animation-duration-300: 0ms;\n --spectrum-global-animation-duration-400: 0ms;\n --spectrum-global-animation-duration-500: 0ms;\n --spectrum-global-animation-duration-600: 0ms;\n --spectrum-global-animation-duration-700: 0ms;\n --spectrum-global-animation-duration-800: 0ms;\n --spectrum-global-animation-duration-900: 0ms;\n --spectrum-global-animation-duration-1000: 0ms;\n --spectrum-global-animation-duration-2000: 0ms;\n --spectrum-global-animation-duration-4000: 0ms;\n --spectrum-coachmark-animation-indicator-ring-duration: 0ms;\n`;\n\nActiveOverlay.prototype.renderTheme = function (\n content: TemplateResult\n): TemplateResult {\n const { color, scale, lang } = this.theme;\n return html`\n ${window.__swc_hack_knobs__.defaultReduceMotion\n ? html`\n <style>\n sp-theme {\n ${reduceMotionProperties}\n }\n </style>\n `\n : html``}\n <sp-theme\n color=${ifDefined(color)}\n scale=${ifDefined(scale)}\n lang=${ifDefined(lang)}\n part=\"theme\"\n >\n ${content}\n </sp-theme>\n `;\n};\n\nexport class StoryDecorator extends SpectrumElement {\n static styles = [\n css`\n :host(:focus) {\n outline: none;\n }\n sp-theme {\n overflow-x: hidden;\n display: block;\n box-sizing: border-box;\n width: 100%;\n min-height: 100vh;\n padding: var(--spectrum-global-dimension-size-100)\n var(--spectrum-global-dimension-size-100)\n calc(\n 2 * var(--spectrum-alias-focus-ring-size) +\n var(--spectrum-alias-item-height-m)\n );\n background-color: var(--spectrum-global-color-gray-100);\n color: var(\n --spectrum-body-text-color,\n var(--spectrum-alias-text-color)\n );\n }\n :host([screenshot]) sp-theme {\n padding: var(--spectrum-global-dimension-size-100);\n }\n :host([reduce-motion]) sp-theme {\n ${reduceMotionProperties}\n }\n .manage-theme {\n position: fixed;\n bottom: 0;\n left: var(--spectrum-global-dimension-size-200);\n right: var(--spectrum-global-dimension-size-200);\n display: flex;\n align-items: center;\n justify-content: flex-end;\n box-sizing: border-box;\n background-color: var(--spectrum-global-color-gray-100);\n padding-bottom: calc(2 * var(--spectrum-alias-focus-ring-size));\n }\n [dir='ltr'] sp-field-label {\n padding-left: 0;\n padding-right: var(\n --spectrum-fieldlabel-side-padding-x,\n var(--spectrum-global-dimension-size-100)\n );\n margin-left: var(--spectrum-global-dimension-size-400);\n }\n [dir='ltr'] sp-switch {\n margin-left: var(--spectrum-global-dimension-size-400);\n margin-right: 0;\n padding: 0;\n }\n [dir='rtl'] sp-field-label {\n padding-right: 0;\n padding-left: var(\n --spectrum-fieldlabel-side-padding-x,\n var(--spectrum-global-dimension-size-100)\n );\n margin-right: var(--spectrum-global-dimension-size-400);\n }\n [dir='rtl'] sp-switch {\n margin-right: var(--spectrum-global-dimension-size-400);\n margin-left: 0;\n padding: 0;\n }\n `,\n ];\n\n @property({ type: String })\n public color: Color = window.__swc_hack_knobs__.defaultColor;\n\n @property({ type: String })\n public scale: Scale = window.__swc_hack_knobs__.defaultScale;\n\n @property({ type: String })\n public direction: 'ltr' | 'rtl' =\n window.__swc_hack_knobs__.defaultDirection;\n\n @property({ type: Boolean, attribute: 'reduce-motion', reflect: true })\n public reduceMotion = window.__swc_hack_knobs__.defaultReduceMotion;\n\n @property({ type: Boolean, reflect: true })\n public screenshot = false;\n\n @queryAsync('sp-theme')\n private theme!: Theme;\n\n public ready = false;\n\n public async startManagingContentDirection(el: HTMLElement): Promise<void> {\n (await this.theme).startManagingContentDirection(el);\n }\n\n public async stopManagingContentDirection(el: HTMLElement): Promise<void> {\n (await this.theme).stopManagingContentDirection(el);\n }\n\n private updateTheme({ target }: Event & { target: Picker | Switch }): void {\n const { id } = target;\n const { value } = target as Picker;\n const { checked } = target as Switch;\n switch (id) {\n case 'color':\n this.color =\n color =\n window.__swc_hack_knobs__.defaultColor =\n value as Color;\n break;\n case 'scale':\n this.scale =\n scale =\n window.__swc_hack_knobs__.defaultScale =\n value as Scale;\n break;\n case 'dir':\n this.direction =\n dir =\n window.__swc_hack_knobs__.defaultDirection =\n value as 'ltr' | 'rtl';\n break;\n case 'reduceMotion':\n this.reduceMotion =\n reduceMotion =\n window.__swc_hack_knobs__.defaultReduceMotion =\n checked as boolean;\n break;\n }\n }\n\n protected handleKeydown(event: KeyboardEvent): void {\n const path = event.composedPath();\n const hasInput = path.some((node) => node instanceof HTMLInputElement);\n if (hasInput) {\n event.stopPropagation();\n }\n }\n\n protected render(): TemplateResult {\n return html`\n <sp-theme\n color=${this.color}\n scale=${this.scale}\n dir=${this.direction}\n part=\"container\"\n @keydown=${this.handleKeydown}\n >\n <slot @slotchange=${this.checkReady}></slot>\n ${this.screenshot ? nothing : this.manageTheme}\n </sp-theme>\n `;\n }\n\n protected async checkReady({\n target,\n }: Event & { target: HTMLSlotElement }): Promise<void> {\n this.ready = false;\n const descendents = target.assignedElements({\n flatten: true,\n }) as SpectrumElement[];\n const litElementDescendents = descendents.filter(\n (el) =>\n el.tagName.search('-') !== -1 &&\n typeof el.updateComplete !== 'undefined'\n );\n const updates = litElementDescendents.map((el) => el.updateComplete);\n await Promise.all(updates);\n new Promise((res) => {\n setTimeout(res);\n }).then(async () => {\n await (document.fonts ? document.fonts.ready : Promise.resolve());\n setTimeout(() => (this.ready = true));\n });\n }\n\n private get manageTheme(): TemplateResult {\n return html`\n <div class=\"manage-theme\" part=\"controls\">\n ${this.colorControl} ${this.scaleControl} ${this.dirControl}\n ${this.reduceMotionControl}\n </div>\n `;\n }\n\n private get colorControl(): TemplateResult {\n return html`\n <sp-field-label for=\"color\">Theme</sp-field-label>\n <sp-picker\n id=\"color\"\n placement=\"top\"\n quiet\n .value=${this.color}\n @change=${this.updateTheme}\n >\n <sp-menu-item value=\"lightest\">Lightest</sp-menu-item>\n <sp-menu-item value=\"light\">Light</sp-menu-item>\n <sp-menu-item value=\"dark\">Dark</sp-menu-item>\n <sp-menu-item value=\"darkest\">Darkest</sp-menu-item>\n </sp-picker>\n `;\n }\n\n private get scaleControl(): TemplateResult {\n return html`\n <sp-field-label for=\"scale\">Scale</sp-field-label>\n <sp-picker\n id=\"scale\"\n label=\"Scale\"\n placement=\"top\"\n quiet\n .value=${this.scale}\n @change=${this.updateTheme}\n >\n <sp-menu-item value=\"medium\">Medium</sp-menu-item>\n <sp-menu-item value=\"large\">Large</sp-menu-item>\n </sp-picker>\n `;\n }\n\n private get dirControl(): TemplateResult {\n return html`\n <sp-field-label for=\"dir\">Direction</sp-field-label>\n <sp-picker\n id=\"dir\"\n label=\"Direction\"\n placement=\"top\"\n quiet\n .value=${this.direction}\n @change=${this.updateTheme}\n >\n <sp-menu-item value=\"ltr\">LTR</sp-menu-item>\n <sp-menu-item value=\"rtl\">RTL</sp-menu-item>\n </sp-picker>\n `;\n }\n\n private get reduceMotionControl(): TemplateResult {\n return html`\n <sp-switch\n id=\"reduceMotion\"\n ?checked=${this.reduceMotion}\n @change=${this.updateTheme}\n >\n Reduce Motion\n </sp-switch>\n `;\n }\n}\n"]}