@redvars/peacock 3.6.1 → 3.6.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.
Files changed (120) hide show
  1. package/dist/assets/components.css.map +1 -1
  2. package/dist/assets/styles.css +1 -1
  3. package/dist/assets/styles.css.map +1 -1
  4. package/dist/assets/tokens.css +1 -1
  5. package/dist/assets/tokens.css.map +1 -1
  6. package/dist/{button-colors-Ccys3hvS.js → button-colors-Cg6oxiz-.js} +126 -116
  7. package/dist/{button-colors-Ccys3hvS.js.map → button-colors-Cg6oxiz-.js.map} +1 -1
  8. package/dist/button-group.js +2 -2
  9. package/dist/button.js +18 -16
  10. package/dist/button.js.map +1 -1
  11. package/dist/canvas.js +126 -107
  12. package/dist/canvas.js.map +1 -1
  13. package/dist/card.js +1 -1
  14. package/dist/card.js.map +1 -1
  15. package/dist/code-highlighter.js +34 -9
  16. package/dist/code-highlighter.js.map +1 -1
  17. package/dist/custom-elements-jsdocs.json +4306 -3215
  18. package/dist/custom-elements.json +8344 -7173
  19. package/dist/{flow-designer-node-BWrPuxAR.js → flow-designer-node-9Bqyn6qx.js} +2 -1
  20. package/dist/flow-designer-node-9Bqyn6qx.js.map +1 -0
  21. package/dist/flow-designer-node.js +1 -1
  22. package/dist/flow-designer.js +1402 -8
  23. package/dist/flow-designer.js.map +1 -1
  24. package/dist/icon-CueRR7wx.js +260 -0
  25. package/dist/icon-CueRR7wx.js.map +1 -0
  26. package/dist/{icon-button-CK1ZuE-2.js → icon-button-AdJBEoNy.js} +34 -30
  27. package/dist/icon-button-AdJBEoNy.js.map +1 -0
  28. package/dist/index.js +10 -9
  29. package/dist/index.js.map +1 -1
  30. package/dist/modal.js +11 -11
  31. package/dist/modal.js.map +1 -1
  32. package/dist/{navigation-rail-DTTkqohi.js → navigation-rail-DAUuJ_Yp.js} +975 -486
  33. package/dist/navigation-rail-DAUuJ_Yp.js.map +1 -0
  34. package/dist/peacock-loader.js +33 -30
  35. package/dist/peacock-loader.js.map +1 -1
  36. package/dist/{popover-NC7b1lTq.js → popover-DUPmMVWS.js} +9 -4
  37. package/dist/{popover-NC7b1lTq.js.map → popover-DUPmMVWS.js.map} +1 -1
  38. package/dist/popover-content.js +1 -1
  39. package/dist/popover-content.js.map +1 -1
  40. package/dist/popover.js +1 -1
  41. package/dist/search.js +11 -14
  42. package/dist/search.js.map +1 -1
  43. package/dist/src/__controllers/floating-controller.d.ts +1 -0
  44. package/dist/src/avatar/avatar.d.ts +1 -1
  45. package/dist/src/breadcrumb/breadcrumb/breadcrumb.d.ts +0 -1
  46. package/dist/src/canvas/canvas.d.ts +3 -3
  47. package/dist/src/chip/chip/chip.d.ts +14 -11
  48. package/dist/src/chip/chip-set/chip-set.d.ts +20 -0
  49. package/dist/src/chip/chip-set/index.d.ts +1 -0
  50. package/dist/src/code-highlighter/code-highlighter.d.ts +4 -0
  51. package/dist/src/field/field.d.ts +1 -0
  52. package/dist/src/flow-designer/flow-designer-node.d.ts +1 -0
  53. package/dist/src/image/image.d.ts +2 -2
  54. package/dist/src/index.d.ts +2 -0
  55. package/dist/src/input/input.d.ts +1 -3
  56. package/dist/src/item/index.d.ts +1 -0
  57. package/dist/src/item/item.d.ts +48 -0
  58. package/dist/src/menu/menu/menu.d.ts +1 -0
  59. package/dist/src/menu/menu-item/menu-item.d.ts +8 -9
  60. package/dist/src/menu/sub-menu/sub-menu.d.ts +1 -0
  61. package/dist/src/modal/modal.d.ts +1 -1
  62. package/dist/src/navigation-rail/navigation-rail.d.ts +2 -6
  63. package/dist/src/popover/popover-content.d.ts +1 -1
  64. package/dist/src/search/search.d.ts +2 -6
  65. package/dist/test/chip.test.d.ts +1 -0
  66. package/dist/test/item.test.d.ts +1 -0
  67. package/dist/tsconfig.tsbuildinfo +1 -1
  68. package/package.json +1 -1
  69. package/readme.md +2 -2
  70. package/scss/mixin.scss +23 -0
  71. package/scss/styles.scss +3 -3
  72. package/scss/tokens.css +1 -1
  73. package/src/__controllers/floating-controller.ts +9 -3
  74. package/src/avatar/avatar.scss +4 -4
  75. package/src/avatar/avatar.ts +1 -1
  76. package/src/breadcrumb/breadcrumb/breadcrumb.ts +0 -1
  77. package/src/button/button/button-sizes.scss +11 -11
  78. package/src/button/button/button.scss +96 -122
  79. package/src/button/button/button.ts +38 -36
  80. package/src/button/icon-button/icon-button-sizes.scss +8 -8
  81. package/src/button/icon-button/icon-button.ts +23 -20
  82. package/src/canvas/canvas.scss +18 -6
  83. package/src/canvas/canvas.ts +125 -103
  84. package/src/card/card.ts +1 -1
  85. package/src/chip/chip/chip.scss +120 -46
  86. package/src/chip/chip/chip.ts +97 -38
  87. package/src/chip/chip-set/chip-set.scss +13 -0
  88. package/src/chip/chip-set/chip-set.ts +25 -0
  89. package/src/chip/chip-set/index.ts +1 -0
  90. package/src/code-highlighter/code-highlighter.ts +33 -6
  91. package/src/empty-state/empty-state.scss +1 -0
  92. package/src/field/field.scss +1 -1
  93. package/src/field/field.ts +6 -0
  94. package/src/flow-designer/flow-designer-node.ts +1 -0
  95. package/src/image/image.scss +21 -16
  96. package/src/image/image.ts +13 -14
  97. package/src/index.ts +2 -0
  98. package/src/input/input.ts +16 -25
  99. package/src/item/index.ts +1 -0
  100. package/src/item/item.scss +184 -0
  101. package/src/item/item.ts +340 -0
  102. package/src/menu/menu/menu.ts +16 -9
  103. package/src/menu/menu-item/menu-item.scss +30 -108
  104. package/src/menu/menu-item/menu-item.ts +89 -129
  105. package/src/menu/sub-menu/sub-menu.ts +6 -2
  106. package/src/modal/modal.scss +10 -10
  107. package/src/modal/modal.ts +1 -1
  108. package/src/navigation-rail/navigation-rail.ts +2 -6
  109. package/src/peacock-loader.ts +28 -22
  110. package/src/popover/popover-content.ts +1 -1
  111. package/src/search/search.ts +11 -16
  112. package/src/select/option.ts +1 -1
  113. package/src/select/select.scss +1 -10
  114. package/src/select/select.ts +2 -0
  115. package/dist/flow-designer-DvTUrDp5.js +0 -1656
  116. package/dist/flow-designer-DvTUrDp5.js.map +0 -1
  117. package/dist/flow-designer-node-BWrPuxAR.js.map +0 -1
  118. package/dist/icon-button-CK1ZuE-2.js.map +0 -1
  119. package/dist/navigation-rail-DTTkqohi.js.map +0 -1
  120. package/src/chip/chip/chip-colors.scss +0 -31
package/dist/button.js CHANGED
@@ -3,7 +3,7 @@ import { n } from './property-1psGvXOq.js';
3
3
  import { r } from './state-DwbEjqVk.js';
4
4
  import { e } from './class-map-YU7g0o3B.js';
5
5
  import { B as BaseButton, o, s as spread } from './BaseButton-BNFAYn-S.js';
6
- import { c as css_248z$1, a as css_248z$2 } from './button-colors-Ccys3hvS.js';
6
+ import { c as css_248z$1, a as css_248z$2 } from './button-colors-Cg6oxiz-.js';
7
7
  import { o as observerSlotChangesWithCallback } from './observe-slot-change-BGJfgg2E.js';
8
8
  import { t as throttle } from './BaseHyperlinkMixin-BNuwbiEf.js';
9
9
  import './directive-ZPhl09Yt.js';
@@ -17,8 +17,8 @@ var css_248z = i`:host([size=xs]),
17
17
 
18
18
  :host([size=xs]) .button,
19
19
  :host([size=extra-small]) .button {
20
- --_button-icon-size: 1rem;
21
- --_button_container-padding: 0.75rem;
20
+ --private-button-icon-size: 1rem;
21
+ --private-button-container-padding: 0.75rem;
22
22
  font-size: 0.875rem !important;
23
23
  font-weight: var(--font-weight-medium) !important;
24
24
  line-height: 1.25rem !important;
@@ -32,9 +32,9 @@ var css_248z = i`:host([size=xs]),
32
32
 
33
33
  :host([size=sm]) .button,
34
34
  :host([size=small]) .button {
35
- --_button-icon-size: 1.25rem;
36
- --_button_container-padding: 1rem;
37
- --_button-icon-label-spacing: 0.5rem;
35
+ --private-button-icon-size: 1.25rem;
36
+ --private-button-container-padding: 1rem;
37
+ --private-button-icon-label-spacing: 0.5rem;
38
38
  font-size: 0.875rem !important;
39
39
  font-weight: var(--font-weight-medium) !important;
40
40
  line-height: 1.25rem !important;
@@ -48,8 +48,8 @@ var css_248z = i`:host([size=xs]),
48
48
 
49
49
  :host([size=md]) .button,
50
50
  :host([size=medium]) .button {
51
- --_button-icon-size: 1.5rem;
52
- --_button_container-padding: 1.5rem;
51
+ --private-button-icon-size: 1.5rem;
52
+ --private-button-container-padding: 1.5rem;
53
53
  font-size: 1rem !important;
54
54
  font-weight: var(--font-weight-medium) !important;
55
55
  line-height: 1.5rem !important;
@@ -63,8 +63,8 @@ var css_248z = i`:host([size=xs]),
63
63
 
64
64
  :host([size=lg]) .button,
65
65
  :host([size=large]) .button {
66
- --_button-icon-size: 2rem;
67
- --_button_container-padding: 3rem;
66
+ --private-button-icon-size: 2rem;
67
+ --private-button-container-padding: 3rem;
68
68
  font-size: 1.5rem !important;
69
69
  font-weight: var(--font-weight-regular) !important;
70
70
  line-height: 2rem !important;
@@ -78,8 +78,8 @@ var css_248z = i`:host([size=xs]),
78
78
 
79
79
  :host([size=xl]) .button,
80
80
  :host([size=extra-large]) .button {
81
- --_button-icon-size: 2.5rem;
82
- --_button_container-padding: 4rem;
81
+ --private-button-icon-size: 2.5rem;
82
+ --private-button-container-padding: 4rem;
83
83
  font-size: 2rem !important;
84
84
  font-weight: var(--font-weight-regular) !important;
85
85
  line-height: 2.5rem !important;
@@ -191,10 +191,8 @@ let Button = class Button extends BaseButton {
191
191
  }
192
192
  }
193
193
  render() {
194
- const isLink = this.__isLink();
195
194
  const cssClasses = {
196
195
  button: true,
197
- 'button-element': true,
198
196
  [`size-${this.size}`]: true,
199
197
  [`variant-${this.variant}`]: true,
200
198
  [`color-${this.color}`]: true,
@@ -204,7 +202,8 @@ let Button = class Button extends BaseButton {
204
202
  'show-skeleton': this.skeleton,
205
203
  [`icon-align-${this.iconAlign}`]: true,
206
204
  };
207
- if (!isLink) {
205
+ if (!this.__isLink()) {
206
+ cssClasses['native-button'] = true;
208
207
  return b `<button
209
208
  class=${e(cssClasses)}
210
209
  id="button"
@@ -224,7 +223,9 @@ let Button = class Button extends BaseButton {
224
223
  </button>
225
224
  ${this.__renderTooltip()}`;
226
225
  }
227
- return b `<a
226
+ else {
227
+ cssClasses['native-link'] = true;
228
+ return b `<a
228
229
  class=${e(cssClasses)}
229
230
  id="button"
230
231
  href=${this.href}
@@ -245,6 +246,7 @@ let Button = class Button extends BaseButton {
245
246
  ${this.renderButtonContent()}
246
247
  </a>
247
248
  ${this.__renderTooltip()}`;
249
+ }
248
250
  }
249
251
  renderButtonContent() {
250
252
  return b `
@@ -1 +1 @@
1
- {"version":3,"file":"button.js","sources":["../../src/button/button/button.ts"],"sourcesContent":["import { html } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport IndividualComponent from '@/IndividualComponent.js';\nimport styles from './button.scss';\nimport colorStyles from './button-colors.scss';\nimport sizeStyles from './button-sizes.scss';\nimport { observerSlotChangesWithCallback } from '@/__utils/observe-slot-change.js';\nimport { throttle } from '@/__utils/throttle.js';\nimport { spread } from '@/__directive/spread.js';\nimport { BaseButton } from '../BaseButton.js';\n\n/**\n * @label Button\n * @tag wc-button\n * @rawTag button\n *\n * @summary Buttons help people initiate actions, from sending an email, to sharing a document, to liking a post.\n * @overview\n * <p>Buttons are clickable elements that are used to trigger actions. They communicate calls to action to the user and allow users to interact with pages in a variety of ways. Button labels express what action will occur when the user interacts with it.</p>\n *\n * @cssprop --button-container-shape: Defines the border radius of the button container shape.\n *\n * @cssprop --button-container-shape-start-start: Defines the start position of the button container shape.\n * @cssprop --button-container-shape-start-end: Defines the end position of the button container shape.\n * @cssprop --button-container-shape-end-start: Defines the start position of the button container shape.\n * @cssprop --button-container-shape-end-end: Defines the end position of the button container shape.\n *\n *\n * @cssprop --filled-button-container-color: Color of the filled button container.\n * @cssprop --filled-button-label-text-color: Text color of the filled button label.\n *\n * @cssprop --outlined-button-container-color: Color of the outlined button container.\n * @cssprop --outlined-button-label-text-color: Text color of the outlined button label.\n *\n * @cssprop --text-button-label-text-color: Text color of the text button label.\n *\n * @cssprop --tonal-button-container-color: Color of the tonal button container.\n * @cssprop --tonal-button-label-text-color: Text color of the tonal button label.\n *\n * @cssprop --elevated-button-container-color: Color of the elevated button container.\n * @cssprop --elevated-button-label-text-color: Text color of the elevated button label.\n *\n * @cssprop --neo-button-container-color: Color of the neo button container.\n * @cssprop --neo-button-label-text-color: Text color of the neo button label.\n *\n * @fires {MouseEvent} click - Dispatched when the button is clicked.\n *\n * @example\n * ```html\n * <wc-button>Button</wc-button>\n * ```\n * @tags display\n */\n@IndividualComponent\nexport class Button extends BaseButton {\n static override styles = [styles, colorStyles, sizeStyles];\n\n /**\n * Icon alignment.\n * Possible values are `\"start\"`, `\"end\"`. Defaults to `\"end\"`.\n */\n @property({ attribute: 'icon-align' })\n iconAlign: 'start' | 'end' = 'end';\n\n /**\n * Button size.\n * Possible values are `\"xs\"`, `\"sm\"`, `\"md\"`, `\"lg\"`, `\"xl\"`. Defaults to `\"sm\"`.\n */\n @property({ reflect: true }) size: 'xs' | 'sm' | 'md' | 'lg' | 'xl' = 'sm';\n\n /**\n * Type is preset of color and variant. Type will be only applied.\n *\n */\n @property({ type: String }) type?: 'primary' | 'secondary' | 'tertiary';\n \n /**\n * The visual style of the button.\n *\n * Possible variant values:\n * `\"filled\"` is a filled button.\n * `\"outlined\"` is an outlined button.\n * `\"text\"` is a transparent button.\n * `\"tonal\"` is a light color button.\n * `\"elevated\"` is elevated button\n */\n @property() variant:\n | 'elevated'\n | 'filled'\n | 'tonal'\n | 'outlined'\n | 'text'\n | 'neo' = 'filled';\n \n /**\n * Defines the primary color of the button. This can be set to predefined color names to apply specific color themes.\n */\n @property({ reflect: true }) color:\n | 'primary'\n | 'success'\n | 'danger'\n | 'warning'\n | 'surface'\n | 'on-surface' = 'primary';\n\n /**\n * Additional ARIA attributes to pass to the inner button/anchor element.\n */\n @property({ reflect: true })\n configAria?: { [key: string]: any };\n\n @state()\n private slotHasContent = false;\n\n override focus() {\n this.buttonElement?.focus();\n }\n\n override blur() {\n this.buttonElement?.blur();\n }\n\n override firstUpdated() {\n this.__dispatchClickWithThrottle = throttle(\n this.__dispatchClick,\n this.throttleDelay,\n );\n observerSlotChangesWithCallback(\n this.renderRoot.querySelector('slot'),\n hasContent => {\n this.slotHasContent = hasContent;\n this.requestUpdate();\n },\n );\n\n this.__convertTypeToVariantAndColor();\n }\n\n __convertTypeToVariantAndColor() {\n if (this.type === 'primary') {\n this.color = 'primary';\n this.variant = 'filled';\n } else if (this.type === 'secondary') {\n this.color = 'surface';\n this.variant = 'filled';\n } else if (this.type === 'tertiary') {\n this.color = 'primary';\n this.variant = 'text';\n } else if (this.type === 'danger') {\n this.color = 'danger';\n this.variant = 'filled';\n }\n }\n\n override render() {\n const isLink = this.__isLink();\n\n const cssClasses = {\n button: true,\n 'button-element': true,\n [`size-${this.size}`]: true,\n [`variant-${this.variant}`]: true,\n [`color-${this.color}`]: true,\n disabled: this.disabled || this.softDisabled,\n pressed: this.isPressed,\n 'has-content': this.slotHasContent,\n 'show-skeleton': this.skeleton,\n [`icon-align-${this.iconAlign}`]: true,\n };\n\n if (!isLink) {\n return html`<button\n class=${classMap(cssClasses)}\n id=\"button\"\n type=${this.htmlType}\n @click=${this.__dispatchClickWithThrottle}\n @mousedown=${this.__handlePress}\n @keydown=${this.__handlePress}\n @keyup=${this.__handlePress}\n\n aria-describedby=${ifDefined(this.softDisabled ? BaseButton.DISABLED_REASON_ID : undefined)}\n ?aria-disabled=${this.softDisabled}\n\n ?disabled=${this.disabled}\n ${spread(this.configAria)}\n >\n ${this.renderButtonContent()}\n </button>\n ${this.__renderTooltip()}`;\n }\n return html`<a\n class=${classMap(cssClasses)}\n id=\"button\"\n href=${this.href}\n target=${this.target}\n tabindex=${this.disabled ? '-1' : '0'}\n \n @click=${this.__dispatchClick}\n @mousedown=${this.__handlePress}\n @keydown=${this.__handlePress}\n @keyup=${this.__handlePress}\n role=\"button\"\n\n aria-describedby=${ifDefined(this.softDisabled ? BaseButton.DISABLED_REASON_ID : undefined)}\n ?aria-disabled=${this.softDisabled}\n\n ${spread(this.configAria)}\n >\n ${this.renderButtonContent()}\n </a>\n ${this.__renderTooltip()}`;\n }\n\n renderButtonContent() {\n return html`\n <wc-focus-ring class=\"focus-ring\" for='button'></wc-focus-ring>\n <wc-elevation class=\"elevation\"></wc-elevation>\n <div class=\"neo-background\"></div>\n <div class=\"background\"></div>\n <div class=\"outline\"></div>\n <wc-ripple class=\"ripple\"></wc-ripple>\n <wc-skeleton class=\"skeleton\"></wc-skeleton>\n\n <div class=\"button-content\">\n <div class=\"slot-container\">\n <slot></slot>\n </div>\n\n <slot name=\"icon\"></slot>\n </div>\n\n ${this.__renderDisabledReason(this.softDisabled)}\n `;\n }\n}\n"],"names":["html","classMap","ifDefined","styles","colorStyles","sizeStyles","property","state"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCG;AAEI,IAAM,MAAM,GAAZ,MAAM,MAAO,SAAQ,UAAU,CAAA;AAA/B,IAAA,WAAA,GAAA;;AAGL;;;AAGG;QAEH,IAAA,CAAA,SAAS,GAAoB,KAAK;AAElC;;;AAGG;QAC0B,IAAA,CAAA,IAAI,GAAqC,IAAI;AAQxE;;;;;;;;;AASG;QACS,IAAA,CAAA,OAAO,GAMP,QAAQ;AAEpB;;AAEG;QAC0B,IAAA,CAAA,KAAK,GAMf,SAAS;QAStB,IAAA,CAAA,cAAc,GAAG,KAAK;IA0HhC;IAxHW,KAAK,GAAA;AACZ,QAAA,IAAI,CAAC,aAAa,EAAE,KAAK,EAAE;IAC7B;IAES,IAAI,GAAA;AACX,QAAA,IAAI,CAAC,aAAa,EAAE,IAAI,EAAE;IAC5B;IAES,YAAY,GAAA;AACnB,QAAA,IAAI,CAAC,2BAA2B,GAAG,QAAQ,CACzC,IAAI,CAAC,eAAe,EACpB,IAAI,CAAC,aAAa,CACnB;AACD,QAAA,+BAA+B,CAC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A,YAAA,EAAA,MAAA,CAAA;AAG5B,UAAA,CAAA;AADP,IAAAC,CAAK;AACyB,CAAA,EAAA,MAAA,CAAA,SAAA,EAAA,gBAAA,EAAA,MAAA,CAAA;AA1DpB,MAAM,GAAA,UAAA,CAAA;IADlB;AACY,CAAA,EAAA,MAAM,CAoLlB;;;;"}
1
+ {"version":3,"file":"button.js","sources":["../../src/button/button/button.ts"],"sourcesContent":["import { html } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport IndividualComponent from '@/IndividualComponent.js';\nimport styles from './button.scss';\nimport colorStyles from './button-colors.scss';\nimport sizeStyles from './button-sizes.scss';\nimport { observerSlotChangesWithCallback } from '@/__utils/observe-slot-change.js';\nimport { throttle } from '@/__utils/throttle.js';\nimport { spread } from '@/__directive/spread.js';\nimport { BaseButton } from '../BaseButton.js';\n\n/**\n * @label Button\n * @tag wc-button\n * @rawTag button\n *\n * @summary Buttons help people initiate actions, from sending an email, to sharing a document, to liking a post.\n * @overview\n * <p>Buttons are clickable elements that are used to trigger actions. They communicate calls to action to the user and allow users to interact with pages in a variety of ways. Button labels express what action will occur when the user interacts with it.</p>\n *\n * @cssprop --button-container-shape: Defines the border radius of the button container shape.\n *\n * @cssprop --button-container-shape-start-start: Defines the start position of the button container shape.\n * @cssprop --button-container-shape-start-end: Defines the end position of the button container shape.\n * @cssprop --button-container-shape-end-start: Defines the start position of the button container shape.\n * @cssprop --button-container-shape-end-end: Defines the end position of the button container shape.\n *\n *\n * @cssprop --filled-button-container-color: Color of the filled button container.\n * @cssprop --filled-button-label-text-color: Text color of the filled button label.\n *\n * @cssprop --outlined-button-container-color: Color of the outlined button container.\n * @cssprop --outlined-button-label-text-color: Text color of the outlined button label.\n *\n * @cssprop --text-button-label-text-color: Text color of the text button label.\n *\n * @cssprop --tonal-button-container-color: Color of the tonal button container.\n * @cssprop --tonal-button-label-text-color: Text color of the tonal button label.\n *\n * @cssprop --elevated-button-container-color: Color of the elevated button container.\n * @cssprop --elevated-button-label-text-color: Text color of the elevated button label.\n *\n * @cssprop --neo-button-container-color: Color of the neo button container.\n * @cssprop --neo-button-label-text-color: Text color of the neo button label.\n *\n * @fires {MouseEvent} click - Dispatched when the button is clicked.\n *\n * @example\n * ```html\n * <wc-button>Button</wc-button>\n * ```\n * @tags display\n */\n@IndividualComponent\nexport class Button extends BaseButton {\n static override styles = [styles, colorStyles, sizeStyles];\n\n /**\n * Icon alignment.\n * Possible values are `\"start\"`, `\"end\"`. Defaults to `\"end\"`.\n */\n @property({ attribute: 'icon-align' })\n iconAlign: 'start' | 'end' = 'end';\n\n /**\n * Button size.\n * Possible values are `\"xs\"`, `\"sm\"`, `\"md\"`, `\"lg\"`, `\"xl\"`. Defaults to `\"sm\"`.\n */\n @property({ reflect: true }) size: 'xs' | 'sm' | 'md' | 'lg' | 'xl' = 'sm';\n\n /**\n * Type is preset of color and variant. Type will be only applied.\n *\n */\n @property({ type: String }) type?: 'primary' | 'secondary' | 'tertiary';\n\n /**\n * The visual style of the button.\n *\n * Possible variant values:\n * `\"filled\"` is a filled button.\n * `\"outlined\"` is an outlined button.\n * `\"text\"` is a transparent button.\n * `\"tonal\"` is a light color button.\n * `\"elevated\"` is elevated button\n */\n @property() variant:\n | 'elevated'\n | 'filled'\n | 'tonal'\n | 'outlined'\n | 'text'\n | 'neo' = 'filled';\n\n /**\n * Defines the primary color of the button. This can be set to predefined color names to apply specific color themes.\n */\n @property({ reflect: true }) color:\n | 'primary'\n | 'success'\n | 'danger'\n | 'warning'\n | 'surface'\n | 'on-surface' = 'primary';\n\n /**\n * Additional ARIA attributes to pass to the inner button/anchor element.\n */\n @property({ reflect: true })\n configAria?: { [key: string]: any };\n\n @state()\n private slotHasContent = false;\n\n override focus() {\n this.buttonElement?.focus();\n }\n\n override blur() {\n this.buttonElement?.blur();\n }\n\n override firstUpdated() {\n this.__dispatchClickWithThrottle = throttle(\n this.__dispatchClick,\n this.throttleDelay,\n );\n observerSlotChangesWithCallback(\n this.renderRoot.querySelector('slot'),\n hasContent => {\n this.slotHasContent = hasContent;\n this.requestUpdate();\n },\n );\n\n this.__convertTypeToVariantAndColor();\n }\n\n __convertTypeToVariantAndColor() {\n if (this.type === 'primary') {\n this.color = 'primary';\n this.variant = 'filled';\n } else if (this.type === 'secondary') {\n this.color = 'surface';\n this.variant = 'filled';\n } else if (this.type === 'tertiary') {\n this.color = 'primary';\n this.variant = 'text';\n } else if (this.type === 'danger') {\n this.color = 'danger';\n this.variant = 'filled';\n }\n }\n\n override render() {\n\n const cssClasses: any = {\n button: true,\n [`size-${this.size}`]: true,\n [`variant-${this.variant}`]: true,\n [`color-${this.color}`]: true,\n disabled: this.disabled || this.softDisabled,\n pressed: this.isPressed,\n 'has-content': this.slotHasContent,\n 'show-skeleton': this.skeleton,\n [`icon-align-${this.iconAlign}`]: true,\n };\n\n if (!this.__isLink()) {\n cssClasses['native-button'] = true;\n\n return html`<button\n class=${classMap(cssClasses)}\n id=\"button\"\n type=${this.htmlType}\n @click=${this.__dispatchClickWithThrottle}\n @mousedown=${this.__handlePress}\n @keydown=${this.__handlePress}\n @keyup=${this.__handlePress}\n\n aria-describedby=${ifDefined(this.softDisabled ? BaseButton.DISABLED_REASON_ID : undefined)}\n ?aria-disabled=${this.softDisabled}\n\n ?disabled=${this.disabled}\n ${spread(this.configAria)}\n >\n ${this.renderButtonContent()}\n </button>\n ${this.__renderTooltip()}`;\n } else {\n cssClasses['native-link'] = true;\n return html`<a\n class=${classMap(cssClasses)}\n id=\"button\"\n href=${this.href}\n target=${this.target}\n tabindex=${this.disabled ? '-1' : '0'}\n \n @click=${this.__dispatchClick}\n @mousedown=${this.__handlePress}\n @keydown=${this.__handlePress}\n @keyup=${this.__handlePress}\n role=\"button\"\n\n aria-describedby=${ifDefined(this.softDisabled ? BaseButton.DISABLED_REASON_ID : undefined)}\n ?aria-disabled=${this.softDisabled}\n\n ${spread(this.configAria)}\n >\n ${this.renderButtonContent()}\n </a>\n ${this.__renderTooltip()}`;\n }\n }\n\n renderButtonContent() {\n return html`\n <wc-focus-ring class=\"focus-ring\" for='button'></wc-focus-ring>\n <wc-elevation class=\"elevation\"></wc-elevation>\n <div class=\"neo-background\"></div>\n <div class=\"background\"></div>\n <div class=\"outline\"></div>\n <wc-ripple class=\"ripple\"></wc-ripple>\n <wc-skeleton class=\"skeleton\"></wc-skeleton>\n\n <div class=\"button-content\">\n <div class=\"slot-container\">\n <slot></slot>\n </div>\n\n <slot name=\"icon\"></slot>\n </div>\n\n ${this.__renderDisabledReason(this.softDisabled)}\n `;\n }\n}\n"],"names":["html","classMap","ifDefined","styles","colorStyles","sizeStyles","property","state"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCG;AAEI,IAAM,MAAM,GAAZ,MAAM,MAAO,SAAQ,UAAU,CAAA;AAA/B,IAAA,WAAA,GAAA;;AAGL;;;AAGG;QAEH,IAAA,CAAA,SAAS,GAAoB,KAAK;AAElC;;;AAGG;QAC0B,IAAA,CAAA,IAAI,GAAqC,IAAI;AAQ1E;;;;;;;;;AASG;QACS,IAAA,CAAA,OAAO,GAMP,QAAQ;AAEpB;;AAEG;QAC0B,IAAA,CAAA,KAAK,GAMf,SAAS;QASpB,IAAA,CAAA,cAAc,GAAG,KAAK;IA4HhC;IA1HW,KAAK,GAAA;AACZ,QAAA,IAAI,CAAC,aAAa,EAAE,KAAK,EAAE;IAC7B;IAES,IAAI,GAAA;AACX,QAAA,IAAI,CAAC,aAAa,EAAE,IAAI,EAAE;IAC5B;IAES,YAAY,GAAA;AACnB,QAAA,IAAI,CAAC,2BAA2B,GAAG,QAAQ,CACzC,IAAI,CAAC,eAAe,EACpB,IAAI,CAAC,aAAa,CACnB;AACD,QAAA,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,EAAE,IAAI,EAAE;AACS,CAAA,EAAA,MAAA,CAAA,SAAA,EAAA,YAAA,EAAA,MAAA,CAAA;AAG5B,UAAA,CAAA;AADP,IAAAC,CAAK;AACyB,CAAA,EAAA,MAAA,CAAA,SAAA,EAAA,gBAAA,EAAA,MAAA,CAAA;AA1DpB,MAAM,GAAA,UAAA,CAAA;IADlB;AACY,CAAA,EAAA,MAAM,CAsLlB;;;;"}
package/dist/canvas.js CHANGED
@@ -21,8 +21,22 @@ var css_248z = i`* {
21
21
  }
22
22
 
23
23
  .canvas-wrapper {
24
+ position: relative;
24
25
  background: var(--canvas-background);
25
- border-radius: var(--shape-corner-medium);
26
+ }
27
+
28
+ .canvas {
29
+ display: block;
30
+ }
31
+
32
+ .canvas-background,
33
+ .canvas-shapes {
34
+ position: absolute;
35
+ inset: 0;
36
+ }
37
+
38
+ .canvas-background {
39
+ pointer-events: none;
26
40
  }
27
41
 
28
42
  #canvas-background circle {
@@ -31,14 +45,13 @@ var css_248z = i`* {
31
45
 
32
46
  #endarrow polyline {
33
47
  fill: none;
34
- stroke: var(--canvas-arrow-color);
48
+ stroke: context-stroke;
35
49
  vector-effect: non-scaling-stroke;
36
50
  stroke-width: 2;
51
+ stroke-linejoin: round;
52
+ stroke-linecap: round;
37
53
  }
38
54
 
39
- .line.no-color {
40
- stroke: var(--canvas-line-color);
41
- }
42
55
  .line.variant-dashed {
43
56
  stroke-dasharray: 6 6;
44
57
  }
@@ -64,6 +77,8 @@ var css_248z = i`* {
64
77
  }`;
65
78
 
66
79
  var Canvas_1;
80
+ const GRID_GAP = 10;
81
+ const GRID_DOT_RADIUS = 1;
67
82
  /**
68
83
  * @label Canvas
69
84
  * @tag wc-canvas
@@ -101,8 +116,6 @@ let Canvas = Canvas_1 = class Canvas extends i$1 {
101
116
  * Zoom multiplier for the canvas dimensions.
102
117
  */
103
118
  this.zoom = 1;
104
- this.unitSize = 1;
105
- this.gap = this.unitSize * 10;
106
119
  }
107
120
  static getNextPoint(point, direction, length) {
108
121
  if (direction === 'down')
@@ -115,47 +128,44 @@ let Canvas = Canvas_1 = class Canvas extends i$1 {
115
128
  return { x: point.x + length, y: point.y };
116
129
  return { x: point.x, y: point.y };
117
130
  }
118
- static updateComputationArea(point, area) {
119
- const nextArea = { ...area };
120
- if (point.x > nextArea.width)
121
- nextArea.width = point.x;
122
- else if (point.x < nextArea.x)
123
- nextArea.x = point.x;
124
- if (point.y > nextArea.height)
125
- nextArea.height = point.y;
126
- else if (point.y < nextArea.y)
127
- nextArea.y = point.y;
128
- return nextArea;
131
+ static updateExtents(extents, x, y) {
132
+ if (x < extents.minX)
133
+ extents.minX = x;
134
+ if (x > extents.maxX)
135
+ extents.maxX = x;
136
+ if (y < extents.minY)
137
+ extents.minY = y;
138
+ if (y > extents.maxY)
139
+ extents.maxY = y;
129
140
  }
130
141
  static getStrokeVariantClasses(variant) {
131
142
  return {
132
143
  line: true,
133
- 'no-color': false,
134
144
  'variant-dashed': variant === 'dashed' || variant === 'animated-dashed',
135
145
  'variant-animated-dashed': variant === 'animated-dashed',
136
146
  };
137
147
  }
138
148
  computeShapes(initialBounds) {
139
- const dotRadius = this.unitSize;
140
- let computedViewbox = { ...initialBounds };
149
+ // Track world-space bounds (grid units) as shapes are processed.
150
+ const extents = {
151
+ minX: initialBounds.x,
152
+ minY: initialBounds.y,
153
+ maxX: initialBounds.x + initialBounds.width,
154
+ maxY: initialBounds.y + initialBounds.height,
155
+ };
141
156
  const shapes = this.shapes.map(shape => {
142
157
  switch (shape.type) {
143
158
  case 'circle': {
144
159
  const r = shape.radius || 1;
145
160
  const cx = shape.x || 0;
146
161
  const cy = shape.y || 0;
147
- if (cx + Math.ceil(r) > computedViewbox.width)
148
- computedViewbox.width = cx + Math.ceil(r);
149
- if (cx - Math.ceil(r) < computedViewbox.x)
150
- computedViewbox.x = cx - Math.ceil(r);
151
- if (cy + Math.ceil(r) > computedViewbox.height)
152
- computedViewbox.height = cy + Math.ceil(r);
153
- if (cy - Math.ceil(r) < computedViewbox.y)
154
- computedViewbox.y = cy - Math.ceil(r);
162
+ Canvas_1.updateExtents(extents, cx - r, cy - r);
163
+ Canvas_1.updateExtents(extents, cx + r, cy + r);
164
+ // Convert from grid units to SVG pixels using the fixed gap.
155
165
  return w `<circle
156
- cx=${cx * this.gap + dotRadius}
157
- cy=${cy * this.gap + dotRadius}
158
- r=${r * this.gap}
166
+ cx=${cx * GRID_GAP + GRID_DOT_RADIUS}
167
+ cy=${cy * GRID_GAP + GRID_DOT_RADIUS}
168
+ r=${r * GRID_GAP}
159
169
  fill=${shape.color || 'var(--canvas-line-color, var(--color-on-surface))'}
160
170
  />`;
161
171
  }
@@ -164,33 +174,28 @@ let Canvas = Canvas_1 = class Canvas extends i$1 {
164
174
  const h = shape.height || 1;
165
175
  const rx = shape.x || 0;
166
176
  const ry = shape.y || 0;
167
- if (rx + Math.ceil(w$1) > computedViewbox.width)
168
- computedViewbox.width = rx + Math.ceil(w$1);
169
- if (rx - Math.ceil(w$1) < computedViewbox.x)
170
- computedViewbox.x = rx - Math.ceil(w$1);
171
- if (ry + Math.ceil(h) > computedViewbox.height)
172
- computedViewbox.height = ry + Math.ceil(h);
173
- if (ry - Math.ceil(h) < computedViewbox.y)
174
- computedViewbox.y = ry - Math.ceil(h);
177
+ Canvas_1.updateExtents(extents, rx, ry);
178
+ Canvas_1.updateExtents(extents, rx + w$1, ry + h);
175
179
  return w `<rect
176
- x=${rx * this.gap + dotRadius}
177
- y=${ry * this.gap}
178
- width=${w$1 * this.gap + dotRadius}
179
- height=${h * this.gap + dotRadius}
180
+ x=${rx * GRID_GAP + GRID_DOT_RADIUS}
181
+ y=${ry * GRID_GAP}
182
+ width=${w$1 * GRID_GAP + GRID_DOT_RADIUS}
183
+ height=${h * GRID_GAP + GRID_DOT_RADIUS}
180
184
  fill=${shape.color || 'var(--canvas-line-color, var(--color-on-surface))'}
181
185
  />`;
182
186
  }
183
187
  case 'line': {
184
188
  const start = shape.start || { x: 0, y: 0 };
185
189
  const end = shape.end || { x: 0, y: 0 };
186
- const pathString = `M${start.x * this.gap + dotRadius} ${start.y * this.gap + dotRadius} L${end.x * this.gap + dotRadius} ${end.y * this.gap + dotRadius}`;
190
+ Canvas_1.updateExtents(extents, start.x, start.y);
191
+ Canvas_1.updateExtents(extents, end.x, end.y);
192
+ const pathString = `M${start.x * GRID_GAP + GRID_DOT_RADIUS} ${start.y * GRID_GAP + GRID_DOT_RADIUS} L${end.x * GRID_GAP + GRID_DOT_RADIUS} ${end.y * GRID_GAP + GRID_DOT_RADIUS}`;
187
193
  const strokeColor = shape.color ||
188
194
  'var(--canvas-line-color, var(--color-on-surface))';
189
195
  return w `<path
190
196
  class=${e({
191
197
  ...Canvas_1.getStrokeVariantClasses(shape.variant),
192
198
  clickable: !!shape.clickable,
193
- 'no-color': !shape.color,
194
199
  })}
195
200
  stroke-width="2"
196
201
  stroke-linecap="round"
@@ -204,35 +209,38 @@ let Canvas = Canvas_1 = class Canvas extends i$1 {
204
209
  }
205
210
  case 'connector': {
206
211
  const start = shape.start || { x: 0, y: 0 };
207
- let pathString = `M${start.x * this.gap + dotRadius} ${start.y * this.gap + dotRadius}`;
212
+ let pathString = `M${start.x * GRID_GAP + GRID_DOT_RADIUS} ${start.y * GRID_GAP + GRID_DOT_RADIUS}`;
208
213
  let current = { ...start };
209
- computedViewbox = Canvas_1.updateComputationArea(current, computedViewbox);
214
+ Canvas_1.updateExtents(extents, current.x, current.y);
210
215
  const pathSegments = shape.path || [];
211
216
  for (let i = 0; i < pathSegments.length; i += 1) {
212
217
  const path = pathSegments[i];
213
218
  if (i === 0) {
219
+ // Move one unit first so curved corner joins don't overlap start.
214
220
  const point = Canvas_1.getNextPoint(current, path.direction, 1);
215
- pathString += ` L${point.x * this.gap + dotRadius} ${point.y * this.gap + dotRadius}`;
221
+ pathString += ` L${point.x * GRID_GAP + GRID_DOT_RADIUS} ${point.y * GRID_GAP + GRID_DOT_RADIUS}`;
216
222
  current = { ...point };
217
- computedViewbox = Canvas_1.updateComputationArea(current, computedViewbox);
223
+ Canvas_1.updateExtents(extents, current.x, current.y);
218
224
  }
219
225
  const point = Canvas_1.getNextPoint(current, path.direction, path.length - 2);
220
- pathString += ` L${point.x * this.gap + dotRadius} ${point.y * this.gap + dotRadius}`;
226
+ pathString += ` L${point.x * GRID_GAP + GRID_DOT_RADIUS} ${point.y * GRID_GAP + GRID_DOT_RADIUS}`;
221
227
  current = { ...point };
222
- computedViewbox = Canvas_1.updateComputationArea(current, computedViewbox);
228
+ Canvas_1.updateExtents(extents, current.x, current.y);
223
229
  if (i === pathSegments.length - 1) {
224
230
  const endPoint = Canvas_1.getNextPoint(current, path.direction, 1);
225
- pathString += ` L${endPoint.x * this.gap + dotRadius} ${endPoint.y * this.gap + dotRadius}`;
231
+ pathString += ` L${endPoint.x * GRID_GAP + GRID_DOT_RADIUS} ${endPoint.y * GRID_GAP + GRID_DOT_RADIUS}`;
226
232
  current = { ...endPoint };
227
- computedViewbox = Canvas_1.updateComputationArea(current, computedViewbox);
233
+ Canvas_1.updateExtents(extents, current.x, current.y);
228
234
  }
229
235
  else {
230
236
  const nextPath = pathSegments[i + 1];
231
237
  const midPoint = Canvas_1.getNextPoint(current, path.direction, 1);
238
+ Canvas_1.updateExtents(extents, midPoint.x, midPoint.y);
232
239
  const nextPoint = Canvas_1.getNextPoint(midPoint, nextPath.direction, 1);
233
- pathString += ` Q ${midPoint.x * this.gap + dotRadius} ${midPoint.y * this.gap + dotRadius} ${nextPoint.x * this.gap + dotRadius} ${nextPoint.y * this.gap + dotRadius}`;
240
+ // Use a quadratic segment to round corners between directions.
241
+ pathString += ` Q ${midPoint.x * GRID_GAP + GRID_DOT_RADIUS} ${midPoint.y * GRID_GAP + GRID_DOT_RADIUS} ${nextPoint.x * GRID_GAP + GRID_DOT_RADIUS} ${nextPoint.y * GRID_GAP + GRID_DOT_RADIUS}`;
234
242
  current = { ...nextPoint };
235
- computedViewbox = Canvas_1.updateComputationArea(current, computedViewbox);
243
+ Canvas_1.updateExtents(extents, current.x, current.y);
236
244
  }
237
245
  }
238
246
  const strokeColor = shape.color ||
@@ -241,7 +249,6 @@ let Canvas = Canvas_1 = class Canvas extends i$1 {
241
249
  <path
242
250
  class=${e({
243
251
  ...Canvas_1.getStrokeVariantClasses(shape.variant),
244
- 'no-color': !shape.color,
245
252
  })}
246
253
  stroke-width="2"
247
254
  stroke-linecap="round"
@@ -266,17 +273,64 @@ let Canvas = Canvas_1 = class Canvas extends i$1 {
266
273
  return A;
267
274
  }
268
275
  });
269
- // Padding
270
- computedViewbox.x -= this.padding;
271
- computedViewbox.y -= this.padding;
272
- computedViewbox.width += this.padding;
273
- computedViewbox.height += this.padding;
274
- computedViewbox.width -= computedViewbox.x;
275
- computedViewbox.height -= computedViewbox.y;
276
+ // Expand bounds with padding so shapes are not flush to the edge.
277
+ const computedViewbox = {
278
+ x: extents.minX - this.padding,
279
+ y: extents.minY - this.padding,
280
+ width: Math.max(extents.maxX - extents.minX + this.padding * 2, 0),
281
+ height: Math.max(extents.maxY - extents.minY + this.padding * 2, 0),
282
+ };
276
283
  return { shapes, computedViewbox };
277
284
  }
285
+ renderBackgroundSvg(computedViewBox, svgViewBox) {
286
+ return b `
287
+ <svg
288
+ class="canvas canvas-background"
289
+ height="100%"
290
+ width="100%"
291
+ viewBox=${svgViewBox}
292
+ aria-hidden="true"
293
+ >
294
+ <defs>
295
+ <pattern
296
+ id="canvas-background"
297
+ patternUnits="userSpaceOnUse"
298
+ width=${GRID_GAP}
299
+ height=${GRID_GAP}
300
+ >
301
+ <circle cx="1" cy="1" r=${GRID_DOT_RADIUS} />
302
+ </pattern>
303
+ </defs>
304
+
305
+ <rect
306
+ x=${computedViewBox.x * GRID_GAP}
307
+ y=${computedViewBox.y * GRID_GAP}
308
+ width="100%"
309
+ height="100%"
310
+ fill="url(#canvas-background)"
311
+ />
312
+ </svg>
313
+ `;
314
+ }
315
+ renderShapesSvg(shapes, svgViewBox) {
316
+ return b `
317
+ <svg
318
+ class="canvas canvas-shapes"
319
+ height="100%"
320
+ width="100%"
321
+ viewBox=${svgViewBox}
322
+ >
323
+ <defs>
324
+ <marker id="endarrow" markerWidth="10" markerHeight="10" refX="5" refY="5" markerUnits="strokeWidth" orient="auto">
325
+ <polyline points="0 2, 5 5, 0 8"></polyline>
326
+ </marker>
327
+ </defs>
328
+
329
+ ${shapes}
330
+ </svg>
331
+ `;
332
+ }
278
333
  render() {
279
- const dotRadius = this.unitSize;
280
334
  let computedViewBox = { width: 0, height: 0, x: 0, y: 0 };
281
335
  const { shapes, computedViewbox } = this.computeShapes(computedViewBox);
282
336
  computedViewBox = computedViewbox;
@@ -289,53 +343,18 @@ let Canvas = Canvas_1 = class Canvas extends i$1 {
289
343
  height: parseInt(viewBox[3], 10),
290
344
  };
291
345
  }
292
- const wrapperWidth = (computedViewBox.width * this.gap + 2) * dotRadius * this.zoom;
293
- const wrapperHeight = (computedViewBox.height * this.gap + 2) * dotRadius * this.zoom;
294
- const svgViewBox = `${computedViewBox.x * this.gap} ${computedViewBox.y * this.gap} ${computedViewBox.width * this.gap + 2 * dotRadius} ${computedViewBox.height * this.gap + 2 * dotRadius}`;
346
+ // Zoom scales the outer viewport size while the SVG viewBox stays in world units.
347
+ const wrapperWidth = (computedViewBox.width * GRID_GAP + 2) * GRID_DOT_RADIUS * this.zoom;
348
+ const wrapperHeight = (computedViewBox.height * GRID_GAP + 2) * GRID_DOT_RADIUS * this.zoom;
349
+ // viewBox maps world-space extents into the internal SVG coordinate system.
350
+ const svgViewBox = `${computedViewBox.x * GRID_GAP} ${computedViewBox.y * GRID_GAP} ${computedViewBox.width * GRID_GAP + 2 * GRID_DOT_RADIUS} ${computedViewBox.height * GRID_GAP + 2 * GRID_DOT_RADIUS}`;
295
351
  return b `
296
352
  <div
297
353
  class="canvas-wrapper"
298
354
  style="width: ${wrapperWidth}px; height: ${wrapperHeight}px;"
299
355
  >
300
- <svg
301
- class="canvas"
302
- height="100%"
303
- width="100%"
304
- viewBox=${svgViewBox}
305
- >
306
- <defs>
307
- <pattern
308
- id="canvas-background"
309
- patternUnits="userSpaceOnUse"
310
- width=${this.gap}
311
- height=${this.gap}
312
- >
313
- <circle cx="1" cy="1" r=${dotRadius} />
314
- </pattern>
315
-
316
- <marker
317
- id="endarrow"
318
- markerWidth="15"
319
- markerHeight="22.5"
320
- refX="9"
321
- refY="15"
322
- markerUnits="userSpaceOnUse"
323
- orient="auto"
324
- >
325
- <polyline points="0 22.5, 7.5 15, 0 7.5"></polyline>
326
- </marker>
327
- </defs>
328
-
329
- <rect
330
- x=${computedViewBox.x * this.gap}
331
- y=${computedViewBox.y * this.gap}
332
- width="100%"
333
- height="100%"
334
- fill="url(#canvas-background)"
335
- />
336
-
337
- ${shapes}
338
- </svg>
356
+ ${this.renderBackgroundSvg(computedViewBox, svgViewBox)}
357
+ ${this.renderShapesSvg(shapes, svgViewBox)}
339
358
  </div>
340
359
  `;
341
360
  }