@alegendstale/holly-components 2.0.3 → 2.0.5

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 (136) hide show
  1. package/custom-elements.json +6366 -0
  2. package/dist/components/absolute-container/absolute-container.js +79 -113
  3. package/dist/components/absolute-container/absolute-container.styles.js +20 -17
  4. package/dist/components/bottom-sheet/bottom-sheet.js +189 -319
  5. package/dist/components/bottom-sheet/bottom-sheet.styles.js +117 -114
  6. package/dist/components/canvas/canvas-base.d.ts +4 -1
  7. package/dist/components/canvas/canvas-base.d.ts.map +1 -1
  8. package/dist/components/canvas/canvas-base.js +51 -67
  9. package/dist/components/canvas/canvas-gradient.js +44 -69
  10. package/dist/components/canvas/canvas-image.js +112 -177
  11. package/dist/components/canvas/canvas-image.styles.js +23 -20
  12. package/dist/components/carousel-scroller/carousel-scroller.js +63 -87
  13. package/dist/components/carousel-scroller/carousel-scroller.styles.js +68 -65
  14. package/dist/components/color-palette/color-palette-utils.js +55 -104
  15. package/dist/components/color-palette/color-palette.js +250 -384
  16. package/dist/components/color-palette/color-palette.styles.js +92 -89
  17. package/dist/components/color-palette/component/color-palette-component.js +134 -188
  18. package/dist/components/color-palette/component/color-palette-component.styles.js +12 -9
  19. package/dist/components/color-palette/editor/color-palette-editor.js +413 -539
  20. package/dist/components/color-palette/editor/color-palette-editor.styles.js +149 -146
  21. package/dist/components/color-palette/editor/settings-item.js +32 -40
  22. package/dist/components/color-palette/editor/settings-item.styles.js +36 -33
  23. package/dist/components/color-palette/item/color-palette-item-edit.js +50 -84
  24. package/dist/components/color-palette/item/color-palette-item-edit.styles.js +53 -50
  25. package/dist/components/color-palette/item/color-palette-item.js +72 -107
  26. package/dist/components/color-palette/item/color-palette-item.styles.js +85 -82
  27. package/dist/components/color-palette/menu/color-palette-menu.js +162 -200
  28. package/dist/components/color-palette/menu/color-palette-menu.styles.js +51 -48
  29. package/dist/components/color-palette/menu/color-palette-reorder.js +76 -95
  30. package/dist/components/color-palette/menu/color-palette-reorder.styles.js +33 -30
  31. package/dist/components/draw-svg/draw-svg.js +35 -52
  32. package/dist/components/draw-svg/draw-svg.styles.js +41 -38
  33. package/dist/components/responsive-svg/responsive-svg.js +122 -174
  34. package/dist/components/responsive-svg/responsive-svg.styles.js +48 -45
  35. package/dist/components/tool-tip/tool-tip.d.ts +5 -1
  36. package/dist/components/tool-tip/tool-tip.d.ts.map +1 -1
  37. package/dist/components/tool-tip/tool-tip.js +64 -100
  38. package/dist/components/tool-tip/tool-tip.styles.js +60 -57
  39. package/dist/decorators/condCustomElement.js +8 -11
  40. package/dist/utils/EventEmitter.js +23 -23
  41. package/dist/utils/ResponsiveController.js +15 -18
  42. package/dist/utils/basicUtils.js +98 -146
  43. package/dist/utils/colorsea-wrapper.js +162 -166
  44. package/dist/utils/dragDropUtils.js +75 -119
  45. package/dist/utils/generateUtils.js +39 -73
  46. package/package.json +43 -60
  47. package/dist/components/absolute-container/absolute-container.stories.d.ts +0 -11
  48. package/dist/components/absolute-container/absolute-container.stories.d.ts.map +0 -1
  49. package/dist/components/absolute-container/absolute-container.stories.js +0 -64
  50. package/dist/components/absolute-container/index.d.ts +0 -2
  51. package/dist/components/absolute-container/index.d.ts.map +0 -1
  52. package/dist/components/absolute-container/index.js +0 -1
  53. package/dist/components/bottom-sheet/bottom-sheet.stories.d.ts +0 -17
  54. package/dist/components/bottom-sheet/bottom-sheet.stories.d.ts.map +0 -1
  55. package/dist/components/bottom-sheet/bottom-sheet.stories.js +0 -67
  56. package/dist/components/bottom-sheet/index.d.ts +0 -2
  57. package/dist/components/bottom-sheet/index.d.ts.map +0 -1
  58. package/dist/components/bottom-sheet/index.js +0 -1
  59. package/dist/components/canvas/canvas-base.stories.d.ts +0 -7
  60. package/dist/components/canvas/canvas-base.stories.d.ts.map +0 -1
  61. package/dist/components/canvas/canvas-base.stories.js +0 -24
  62. package/dist/components/canvas/canvas-gradient.stories.d.ts +0 -14
  63. package/dist/components/canvas/canvas-gradient.stories.d.ts.map +0 -1
  64. package/dist/components/canvas/canvas-gradient.stories.js +0 -46
  65. package/dist/components/canvas/canvas-image.stories.d.ts +0 -13
  66. package/dist/components/canvas/canvas-image.stories.d.ts.map +0 -1
  67. package/dist/components/canvas/canvas-image.stories.js +0 -49
  68. package/dist/components/canvas/index.d.ts +0 -3
  69. package/dist/components/canvas/index.d.ts.map +0 -1
  70. package/dist/components/canvas/index.js +0 -2
  71. package/dist/components/carousel-scroller/carousel-scroller.stories.d.ts +0 -13
  72. package/dist/components/carousel-scroller/carousel-scroller.stories.d.ts.map +0 -1
  73. package/dist/components/carousel-scroller/carousel-scroller.stories.js +0 -56
  74. package/dist/components/carousel-scroller/index.d.ts +0 -2
  75. package/dist/components/carousel-scroller/index.d.ts.map +0 -1
  76. package/dist/components/carousel-scroller/index.js +0 -1
  77. package/dist/components/color-palette/component/color-palette-component.stories.d.ts +0 -13
  78. package/dist/components/color-palette/component/color-palette-component.stories.d.ts.map +0 -1
  79. package/dist/components/color-palette/component/color-palette-component.stories.js +0 -75
  80. package/dist/components/color-palette/component/index.d.ts +0 -2
  81. package/dist/components/color-palette/component/index.d.ts.map +0 -1
  82. package/dist/components/color-palette/component/index.js +0 -1
  83. package/dist/components/color-palette/editor/color-palette-editor.stories.d.ts +0 -18
  84. package/dist/components/color-palette/editor/color-palette-editor.stories.d.ts.map +0 -1
  85. package/dist/components/color-palette/editor/color-palette-editor.stories.js +0 -67
  86. package/dist/components/color-palette/editor/index.d.ts +0 -2
  87. package/dist/components/color-palette/editor/index.d.ts.map +0 -1
  88. package/dist/components/color-palette/editor/index.js +0 -1
  89. package/dist/components/color-palette/index.d.ts +0 -6
  90. package/dist/components/color-palette/index.d.ts.map +0 -1
  91. package/dist/components/color-palette/index.js +0 -5
  92. package/dist/components/color-palette/item/index.d.ts +0 -3
  93. package/dist/components/color-palette/item/index.d.ts.map +0 -1
  94. package/dist/components/color-palette/item/index.js +0 -2
  95. package/dist/components/color-palette/menu/index.d.ts +0 -3
  96. package/dist/components/color-palette/menu/index.d.ts.map +0 -1
  97. package/dist/components/color-palette/menu/index.js +0 -2
  98. package/dist/components/color-palette/storybook/color-palette-invalid.stories.d.ts +0 -33
  99. package/dist/components/color-palette/storybook/color-palette-invalid.stories.d.ts.map +0 -1
  100. package/dist/components/color-palette/storybook/color-palette-invalid.stories.js +0 -62
  101. package/dist/components/color-palette/storybook/color-palette-valid.stories.d.ts +0 -52
  102. package/dist/components/color-palette/storybook/color-palette-valid.stories.d.ts.map +0 -1
  103. package/dist/components/color-palette/storybook/color-palette-valid.stories.js +0 -268
  104. package/dist/components/color-palette/storybook/color-palette.stories.d.ts +0 -27
  105. package/dist/components/color-palette/storybook/color-palette.stories.d.ts.map +0 -1
  106. package/dist/components/color-palette/storybook/color-palette.stories.js +0 -129
  107. package/dist/components/draw-svg/draw-svg.stories.d.ts +0 -7
  108. package/dist/components/draw-svg/draw-svg.stories.d.ts.map +0 -1
  109. package/dist/components/draw-svg/draw-svg.stories.js +0 -61
  110. package/dist/components/draw-svg/index.d.ts +0 -2
  111. package/dist/components/draw-svg/index.d.ts.map +0 -1
  112. package/dist/components/draw-svg/index.js +0 -1
  113. package/dist/components/responsive-svg/index.d.ts +0 -2
  114. package/dist/components/responsive-svg/index.d.ts.map +0 -1
  115. package/dist/components/responsive-svg/index.js +0 -1
  116. package/dist/components/responsive-svg/responsive-svg.stories.d.ts +0 -26
  117. package/dist/components/responsive-svg/responsive-svg.stories.d.ts.map +0 -1
  118. package/dist/components/responsive-svg/responsive-svg.stories.js +0 -194
  119. package/dist/components/tool-tip/index.d.ts +0 -2
  120. package/dist/components/tool-tip/index.d.ts.map +0 -1
  121. package/dist/components/tool-tip/index.js +0 -1
  122. package/dist/components/tool-tip/tool-tip.stories.d.ts +0 -16
  123. package/dist/components/tool-tip/tool-tip.stories.d.ts.map +0 -1
  124. package/dist/components/tool-tip/tool-tip.stories.js +0 -62
  125. package/dist/decorators/index.d.ts +0 -2
  126. package/dist/decorators/index.d.ts.map +0 -1
  127. package/dist/decorators/index.js +0 -1
  128. package/dist/index.d.ts +0 -11
  129. package/dist/index.d.ts.map +0 -1
  130. package/dist/index.js +0 -10
  131. package/dist/utils/index.d.ts +0 -5
  132. package/dist/utils/index.d.ts.map +0 -1
  133. package/dist/utils/index.js +0 -4
  134. package/dist/utils/types.d.ts +0 -5
  135. package/dist/utils/types.d.ts.map +0 -1
  136. package/dist/utils/types.js +0 -1
@@ -1,115 +1,118 @@
1
- import { css } from 'lit';
2
- export default css `
3
- :host {
4
- contain: content;
5
- overscroll-behavior-block: none;
6
- --height: fit-content;
7
- }
8
-
9
- :host([dragging]) dialog {
10
- #content {
11
- cursor: grabbing;
12
- /* Important! Prevents mobile browsers from reclaiming PointerMove event on touch devices */
13
- touch-action: none;
14
- /* Prevent weird scrollbar movement on mobile when dragging */
15
- overflow-y: hidden;
16
- }
17
- }
18
-
19
- :host(:not([dragging])) dialog {
20
- /* Only animate if not dragging */
21
- transition-property: overlay opacity display;
22
- transition-duration: 0.25s;
23
- transition-behavior: allow-discrete;
24
-
25
- &::backdrop {
26
- transition-property: overlay opacity display;
27
- transition-duration: 0.25s;
28
- transition-behavior: allow-discrete;
29
- }
30
-
31
- #content {
32
- /* Allow scroll */
33
- touch-action: pan-y;
34
- }
35
- }
36
-
37
- dialog {
38
- display: none;
39
- opacity: 0;
40
- translate: 0 var(--height);
41
-
42
- height: var(--height);
43
- min-height: 0;
44
- max-height: 100%;
45
- min-width: 100%;
46
- max-width: 100%;
47
- flex-direction: column;
48
- box-sizing: border-box;
49
- padding: 0;
50
- border: 0;
51
- background-color: light-dark(#d9d9d9, #1c1c1c);
52
- /* Important! Removes default browser styling, allowing bottom to work */
53
- inset: unset;
54
- bottom: 0;
55
- left: 0;
56
- overflow-y: hidden;
57
-
58
- /* Important! Prevents mobile browsers from reclaiming PointerMove event on touch devices */
59
- touch-action: none;
60
- /* Prevent weird scrollbar movement on mobile when dragging */
61
- overflow-y: hidden;
62
-
63
- &[open] {
64
- display: flex;
65
- opacity: 1;
66
- translate: 0 0;
67
-
68
- &::backdrop {
69
- opacity: 0.8;
70
- }
71
- }
72
-
73
- &::backdrop {
74
- background: black;
75
- opacity: 0;
76
- }
77
- }
78
-
79
- @starting-style {
80
- dialog[open] {
81
- opacity: 0;
82
- translate: 0 var(--height);
83
-
84
- &::backdrop {
85
- opacity: 0;
86
- }
87
- }
88
- }
89
-
90
- #handle {
91
- display: block;
92
- position: sticky;
93
- top: 0;
94
- background: transparent;
95
- border: 0;
96
- cursor: grabbing;
97
- min-height: 35px;
98
- user-select: none;
99
- touch-action: none;
100
- }
101
-
102
- div {
103
- /* display: contents; */
104
- overflow-y: auto;
105
- scrollbar-width: none;
106
- box-sizing: border-box;
107
- min-height: 100%;
108
- min-width: 100%;
109
- }
110
-
111
- ::slotted(*) {
112
- /* Prevent slotted items from taking pointer events */
113
- /* pointer-events: none; */
114
- }
1
+ import { css as o } from "lit";
2
+ const e = o`
3
+ :host {
4
+ contain: content;
5
+ overscroll-behavior-block: none;
6
+ --height: fit-content;
7
+ }
8
+
9
+ :host([dragging]) dialog {
10
+ #content {
11
+ cursor: grabbing;
12
+ /* Important! Prevents mobile browsers from reclaiming PointerMove event on touch devices */
13
+ touch-action: none;
14
+ /* Prevent weird scrollbar movement on mobile when dragging */
15
+ overflow-y: hidden;
16
+ }
17
+ }
18
+
19
+ :host(:not([dragging])) dialog {
20
+ /* Only animate if not dragging */
21
+ transition-property: overlay opacity display;
22
+ transition-duration: 0.25s;
23
+ transition-behavior: allow-discrete;
24
+
25
+ &::backdrop {
26
+ transition-property: overlay opacity display;
27
+ transition-duration: 0.25s;
28
+ transition-behavior: allow-discrete;
29
+ }
30
+
31
+ #content {
32
+ /* Allow scroll */
33
+ touch-action: pan-y;
34
+ }
35
+ }
36
+
37
+ dialog {
38
+ display: none;
39
+ opacity: 0;
40
+ translate: 0 var(--height);
41
+
42
+ height: var(--height);
43
+ min-height: 0;
44
+ max-height: 100%;
45
+ min-width: 100%;
46
+ max-width: 100%;
47
+ flex-direction: column;
48
+ box-sizing: border-box;
49
+ padding: 0;
50
+ border: 0;
51
+ background-color: light-dark(#d9d9d9, #1c1c1c);
52
+ /* Important! Removes default browser styling, allowing bottom to work */
53
+ inset: unset;
54
+ bottom: 0;
55
+ left: 0;
56
+ overflow-y: hidden;
57
+
58
+ /* Important! Prevents mobile browsers from reclaiming PointerMove event on touch devices */
59
+ touch-action: none;
60
+ /* Prevent weird scrollbar movement on mobile when dragging */
61
+ overflow-y: hidden;
62
+
63
+ &[open] {
64
+ display: flex;
65
+ opacity: 1;
66
+ translate: 0 0;
67
+
68
+ &::backdrop {
69
+ opacity: 0.8;
70
+ }
71
+ }
72
+
73
+ &::backdrop {
74
+ background: black;
75
+ opacity: 0;
76
+ }
77
+ }
78
+
79
+ @starting-style {
80
+ dialog[open] {
81
+ opacity: 0;
82
+ translate: 0 var(--height);
83
+
84
+ &::backdrop {
85
+ opacity: 0;
86
+ }
87
+ }
88
+ }
89
+
90
+ #handle {
91
+ display: block;
92
+ position: sticky;
93
+ top: 0;
94
+ background: transparent;
95
+ border: 0;
96
+ cursor: grabbing;
97
+ min-height: 35px;
98
+ user-select: none;
99
+ touch-action: none;
100
+ }
101
+
102
+ div {
103
+ /* display: contents; */
104
+ overflow-y: auto;
105
+ scrollbar-width: none;
106
+ box-sizing: border-box;
107
+ min-height: 100%;
108
+ min-width: 100%;
109
+ }
110
+
111
+ ::slotted(*) {
112
+ /* Prevent slotted items from taking pointer events */
113
+ /* pointer-events: none; */
114
+ }
115
115
  `;
116
+ export {
117
+ e as default
118
+ };
@@ -1,10 +1,13 @@
1
1
  import { EventEmitter } from '../../utils/EventEmitter.js';
2
2
  import { LitElement } from 'lit';
3
- import { client } from '../../utils/types.js';
4
3
  type EventMap = {
5
4
  click: [hex: string];
6
5
  move: [e: client];
7
6
  };
7
+ type client = {
8
+ x: number;
9
+ y: number;
10
+ };
8
11
  /**
9
12
  * Utility component to help with creating canvases.
10
13
  */
@@ -1 +1 @@
1
- {"version":3,"file":"canvas-base.d.ts","sourceRoot":"","sources":["../../../src/components/canvas/canvas-base.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAE5C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,KAAK,QAAQ,GAAG;IACf,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACrB,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,qBACa,UAAW,SAAQ,UAAU;IACzC,MAAM,CAAC,MAAM,4BAMX;IAEF,0BAA0B;IAE1B,SAAS,CAAC,MAAM,EAAG,iBAAiB,CAAC;IAErC,0BAA0B;IAC1B,SAAS,CAAC,OAAO,EAAG,wBAAwB,CAAC;IAE7C,yCAAyC;IAClC,OAAO,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAgC;IAEtE,oBAAoB,IAAI,IAAI;IAK5B,MAAM;IAqBN,iDAAiD;IAC1C,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAWpD"}
1
+ {"version":3,"file":"canvas-base.d.ts","sourceRoot":"","sources":["../../../src/components/canvas/canvas-base.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAG5C,KAAK,QAAQ,GAAG;IACf,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACrB,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;CAClB,CAAC;AAEF,KAAK,MAAM,GAAG;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACV,CAAA;AAED;;GAEG;AACH,qBACa,UAAW,SAAQ,UAAU;IACzC,MAAM,CAAC,MAAM,4BAMX;IAEF,0BAA0B;IAE1B,SAAS,CAAC,MAAM,EAAG,iBAAiB,CAAC;IAErC,0BAA0B;IAC1B,SAAS,CAAC,OAAO,EAAG,wBAAwB,CAAC;IAE7C,yCAAyC;IAClC,OAAO,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAgC;IAEtE,oBAAoB,IAAI,IAAI;IAK5B,MAAM;IAqBN,iDAAiD;IAC1C,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAWpD"}
@@ -1,71 +1,55 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
1
+ import m from "../../utils/colorsea-wrapper.js";
2
+ import { EventEmitter as h } from "../../utils/EventEmitter.js";
3
+ import { ref as u } from "lit/directives/ref.js";
4
+ import { css as f, LitElement as x, html as d } from "lit";
5
+ import { query as g, customElement as C } from "lit/decorators.js";
6
+ var y = Object.defineProperty, b = Object.getOwnPropertyDescriptor, v = (i, e, r, a) => {
7
+ for (var t = a > 1 ? void 0 : a ? b(e, r) : e, n = i.length - 1, s; n >= 0; n--)
8
+ (s = i[n]) && (t = (a ? s(e, r, t) : s(t)) || t);
9
+ return a && t && y(e, r, t), t;
6
10
  };
7
- import colorsea from '../../utils/colorsea-wrapper.js';
8
- import { EventEmitter } from '../../utils/EventEmitter.js';
9
- import { ref } from 'lit/directives/ref.js';
10
- import { LitElement, html, css } from 'lit';
11
- import { customElement, query } from 'lit/decorators.js';
12
- /**
13
- * Utility component to help with creating canvases.
14
- */
15
- let CanvasBase = class CanvasBase extends LitElement {
16
- constructor() {
17
- super(...arguments);
18
- /** Public way to subscribe to events. */
19
- this.emitter = new EventEmitter();
20
- }
21
- static { this.styles = [
22
- css `
23
- :host {
24
- display: block;
25
- }
26
- `
27
- ]; }
28
- disconnectedCallback() {
29
- super.disconnectedCallback();
30
- this.emitter.clear();
31
- }
32
- render() {
33
- let canvasRef = (canvas) => {
34
- if (!(canvas instanceof HTMLCanvasElement))
35
- return;
36
- this.context = canvas.getContext('2d', { willReadFrequently: true, alpha: true });
37
- };
38
- return html `
39
- <canvas
40
- @click=${(e) => this.emitter.emit('click', this.getCanvasHex(e.clientX, e.clientY))}
11
+ let c = class extends x {
12
+ constructor() {
13
+ super(...arguments), this.emitter = new h();
14
+ }
15
+ disconnectedCallback() {
16
+ super.disconnectedCallback(), this.emitter.clear();
17
+ }
18
+ render() {
19
+ return d`
20
+ <canvas
21
+ @click=${(e) => this.emitter.emit("click", this.getCanvasHex(e.clientX, e.clientY))}
41
22
  @pointermove=${(e) => {
42
- // Track only the first touch
43
- if (!e.isPrimary)
44
- return;
45
- this.emitter.emit('move', { x: e.clientX, y: e.clientY });
46
- }}
47
- ${ref(canvasRef)}
48
- >
49
- </canvas>
23
+ e.isPrimary && this.emitter.emit("move", { x: e.clientX, y: e.clientY });
24
+ }}
25
+ ${u((e) => {
26
+ e instanceof HTMLCanvasElement && (this.context = e.getContext("2d", { willReadFrequently: !0, alpha: !0 }));
27
+ })}
28
+ >
29
+ </canvas>
50
30
  `;
51
- }
52
- /** Retrieves the hex from the mouse position. */
53
- getCanvasHex(clientX, clientY) {
54
- const canvasBounds = this.canvas.getBoundingClientRect();
55
- let x = clientX - canvasBounds.left;
56
- let y = clientY - canvasBounds.top;
57
- let [r, g, b, a] = this.context.getImageData(x, y, 1, 1).data;
58
- // Convert alpha from 0-255 to 0-1
59
- const alpha = Math.round((a / 255) * 100);
60
- // Hide alpha value if not an alpha color
61
- let hex = alpha !== 255 ? colorsea([r, g, b, alpha]).hex() : colorsea([r, g, b]).hex();
62
- return hex;
63
- }
31
+ }
32
+ /** Retrieves the hex from the mouse position. */
33
+ getCanvasHex(i, e) {
34
+ const r = this.canvas.getBoundingClientRect();
35
+ let a = i - r.left, t = e - r.top, [n, s, o, p] = this.context.getImageData(a, t, 1, 1).data;
36
+ const l = Math.round(p / 255 * 100);
37
+ return l !== 255 ? m([n, s, o, l]).hex() : m([n, s, o]).hex();
38
+ }
39
+ };
40
+ c.styles = [
41
+ f`
42
+ :host {
43
+ display: block;
44
+ }
45
+ `
46
+ ];
47
+ v([
48
+ g("canvas")
49
+ ], c.prototype, "canvas", 2);
50
+ c = v([
51
+ C("canvas-base")
52
+ ], c);
53
+ export {
54
+ c as CanvasBase
64
55
  };
65
- __decorate([
66
- query('canvas')
67
- ], CanvasBase.prototype, "canvas", void 0);
68
- CanvasBase = __decorate([
69
- customElement('canvas-base')
70
- ], CanvasBase);
71
- export { CanvasBase };
@@ -1,71 +1,46 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
1
+ import { Direction as h } from "../color-palette/color-palette-utils.js";
2
+ import { property as c, customElement as f } from "lit/decorators.js";
3
+ import { CanvasBase as d } from "./canvas-base.js";
4
+ import { isColorValid as u } from "../../utils/basicUtils.js";
5
+ var m = Object.defineProperty, y = Object.getOwnPropertyDescriptor, p = (r, e, o, s) => {
6
+ for (var t = s > 1 ? void 0 : s ? y(e, o) : e, n = r.length - 1, a; n >= 0; n--)
7
+ (a = r[n]) && (t = (s ? a(e, o, t) : a(t)) || t);
8
+ return s && t && m(e, o, t), t;
6
9
  };
7
- import { Direction } from '../color-palette/color-palette-utils.js';
8
- import { customElement, property } from 'lit/decorators.js';
9
- import { CanvasBase } from './canvas-base.js';
10
- import { isColorValid } from '../../utils/basicUtils.js';
11
- /**
12
- * Utility component to make creating and retrieving gradient colors easier based on canvas coordinates.
13
- *
14
- * @dependency canvas-base
15
- */
16
- let CanvasGradient = class CanvasGradient extends CanvasBase {
17
- constructor() {
18
- super(...arguments);
19
- /** An array of the colors that will make the gradient. */
20
- this.colors = [];
21
- /** The height of the gradient canvas. */
22
- this.height = 0;
23
- /** The width of the gradient canvas. */
24
- this.width = 0;
25
- /** The direction the gradient will face. (Column or Row) */
26
- this.direction = Direction.Column;
27
- }
28
- static { this.styles = [...CanvasBase.styles]; }
29
- updated(_changedProperties) {
30
- super.updated(_changedProperties);
31
- this.createGradient(this.colors, this.height, this.width, this.direction);
32
- }
33
- /** Creates a new gradient canvas */
34
- createGradient(colors, height, width, direction) {
35
- if (!this.context)
36
- return;
37
- this.canvas.height = height;
38
- this.canvas.width = width;
39
- let gradient = direction === Direction.Column ? this.context.createLinearGradient(0, 0, width, 0) : this.context.createLinearGradient(0, 0, 0, height);
40
- let colorStops = [];
41
- for (const [i, color] of colors.entries()) {
42
- // Skip non-colors, even with override enabled. This prevents errors, especially dealing with css-variables which cannot be parsed at run-time.
43
- if (isColorValid(color)) {
44
- gradient.addColorStop(i / (colors.length - 1), color);
45
- colorStops.push(color);
46
- }
47
- }
48
- if (colorStops.length <= 1)
49
- throw new Error('There are not enough valid color stops to create the gradient.');
50
- this.context.fillStyle = gradient || '#000';
51
- this.context.fillRect(0, 0, width, height);
52
- this.canvas.classList.add('gradient');
53
- this.canvas.style.setProperty('--palette-column-flex-basis', (height / colors.length / 2).toString() + 'px');
54
- }
10
+ let i = class extends d {
11
+ constructor() {
12
+ super(...arguments), this.colors = [], this.height = 0, this.width = 0, this.direction = h.Column;
13
+ }
14
+ updated(r) {
15
+ super.updated(r), this.createGradient(this.colors, this.height, this.width, this.direction);
16
+ }
17
+ /** Creates a new gradient canvas */
18
+ createGradient(r, e, o, s) {
19
+ if (!this.context) return;
20
+ this.canvas.height = e, this.canvas.width = o;
21
+ let t = s === h.Column ? this.context.createLinearGradient(0, 0, o, 0) : this.context.createLinearGradient(0, 0, 0, e), n = [];
22
+ for (const [a, l] of r.entries())
23
+ u(l) && (t.addColorStop(a / (r.length - 1), l), n.push(l));
24
+ if (n.length <= 1) throw new Error("There are not enough valid color stops to create the gradient.");
25
+ this.context.fillStyle = t || "#000", this.context.fillRect(0, 0, o, e), this.canvas.classList.add("gradient"), this.canvas.style.setProperty("--palette-column-flex-basis", (e / r.length / 2).toString() + "px");
26
+ }
27
+ };
28
+ i.styles = [...d.styles];
29
+ p([
30
+ c({ type: Array })
31
+ ], i.prototype, "colors", 2);
32
+ p([
33
+ c({ type: Number })
34
+ ], i.prototype, "height", 2);
35
+ p([
36
+ c({ type: Number })
37
+ ], i.prototype, "width", 2);
38
+ p([
39
+ c({ type: String })
40
+ ], i.prototype, "direction", 2);
41
+ i = p([
42
+ f("canvas-gradient")
43
+ ], i);
44
+ export {
45
+ i as CanvasGradient
55
46
  };
56
- __decorate([
57
- property({ type: Array })
58
- ], CanvasGradient.prototype, "colors", void 0);
59
- __decorate([
60
- property({ type: Number })
61
- ], CanvasGradient.prototype, "height", void 0);
62
- __decorate([
63
- property({ type: Number })
64
- ], CanvasGradient.prototype, "width", void 0);
65
- __decorate([
66
- property({ type: String })
67
- ], CanvasGradient.prototype, "direction", void 0);
68
- CanvasGradient = __decorate([
69
- customElement('canvas-gradient')
70
- ], CanvasGradient);
71
- export { CanvasGradient };