@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,393 +1,259 @@
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 { LitElement as I, html as c, nothing as S } from "lit";
2
+ import { query as C, property as n, state as $, customElement as x } from "lit/decorators.js";
3
+ import { styleMap as y } from "lit/directives/style-map.js";
4
+ import { repeat as N } from "lit/directives/repeat.js";
5
+ import { defaultSettings as u, Status as l, parseColors as w, PaletteError as v, Direction as _ } from "./color-palette-utils.js";
6
+ import { ColorPaletteItem as T } from "./item/color-palette-item.js";
7
+ import { copyToClipboard as m } from "../../utils/basicUtils.js";
8
+ import { EventEmitter as b } from "../../utils/EventEmitter.js";
9
+ import { CanvasGradient as A } from "../canvas/canvas-gradient.js";
10
+ import { classMap as D } from "lit/directives/class-map.js";
11
+ import { ColorPaletteItemEdit as M } from "./item/color-palette-item-edit.js";
12
+ import { ref as g, createRef as P } from "lit/directives/ref.js";
13
+ import L from "./color-palette.styles.js";
14
+ var E = Object.defineProperty, O = Object.getOwnPropertyDescriptor, o = (t, e, s, a) => {
15
+ for (var i = a > 1 ? void 0 : a ? O(e, s) : e, h = t.length - 1, p; h >= 0; h--)
16
+ (p = t[h]) && (i = (a ? p(e, s, i) : p(i)) || i);
17
+ return a && i && E(e, s, i), i;
6
18
  };
7
- import { LitElement, html, nothing } from 'lit';
8
- import { customElement, property, query, state } from 'lit/decorators.js';
9
- import { styleMap } from 'lit/directives/style-map.js';
10
- import { repeat } from 'lit/directives/repeat.js';
11
- import { defaultSettings, Direction, PaletteError, parseColors, Status } from './color-palette-utils.js';
12
- import { ColorPaletteItem } from './item/color-palette-item.js';
13
- import { copyToClipboard } from '../../utils/basicUtils.js';
14
- import { EventEmitter } from '../../utils/EventEmitter.js';
15
- import { CanvasGradient } from '../canvas/canvas-gradient.js';
16
- import { classMap } from 'lit/directives/class-map.js';
17
- import { ColorPaletteItemEdit } from './item/color-palette-item-edit.js';
18
- import { createRef, ref } from 'lit/directives/ref.js';
19
- import styles from './color-palette.styles.js';
20
- /**
21
- * A component which can display colors in various ways.
22
- *
23
- * @cssprop {<length>} --palette-height - The height of the palette.
24
- * @cssprop {<length> } --palette-width - The width of the palette.
25
- * @cssprop {<color>} --palette-background-color - The background color of the palette.
26
- * @cssprop {<color>} --palette-color - The color of the palette.
27
- * @cssprop {<length>} --palette-column-flex-basis - The flex size for palette items.
28
- * @cssprop {<length>} --palette-corners - The radius of the palette corners.
29
- */
30
- let ColorPalette = class ColorPalette extends LitElement {
31
- constructor() {
32
- super(...arguments);
33
- /** @internal */
34
- this._editMode = false;
35
- /** The input colors the palette will display. */
36
- this.colors = [];
37
- // Settings
38
- /**
39
- * The height of the palette.
40
- * @default 150
41
- */
42
- this.height = defaultSettings.height;
43
- /**
44
- * The width of the palette.
45
- * @default 700
46
- */
47
- this.width = defaultSettings.width;
48
- /**
49
- * The direction the palette colors will face.
50
- * @default column
51
- */
52
- this.direction = defaultSettings.direction;
53
- /** Whether the colors will appear as a gradient. */
54
- this.gradient = false;
55
- /** Whether hovering over the palette is allowed. */
56
- this.preventHover = false;
57
- /** Whether the text on each color is shown. */
58
- this.hideText = false;
59
- /** Whether the input bypasses validation checks. */
60
- this.override = false;
61
- /** The aliases for each color. */
62
- this.aliases = [];
63
- /** The maximum width of the container. (So that the palette doesn't expand past its bounds) */
64
- this.maxWidth = 0;
65
- /** The current status of the palette. */
66
- this.status = Status.VALID;
67
- /** @internal Whether the palette should pulse on error. */
68
- this.pulse = false;
69
- /** Public way to subscribe to events. */
70
- this.emitter = new EventEmitter();
71
- /** Extended settings */
72
- this.pluginSettings = defaultSettings;
73
- }
74
- static { this.styles = [styles]; }
75
- /**
76
- * Whether the palette can be edited.
77
- * @type {boolean}
78
- * @default false
79
- */
80
- set editMode(val) {
81
- this._editMode = val;
82
- this.emitter.emit('editMode', val);
83
- }
84
- get editMode() {
85
- return this._editMode;
86
- }
87
- /** Helper accessor for settings */
88
- set settings({ height, width, direction, gradient, preventHover, override, aliases }) {
89
- this.height = height;
90
- this.width = width;
91
- this.direction = direction;
92
- this.gradient = gradient;
93
- this.preventHover = preventHover;
94
- this.override = override;
95
- this.aliases = aliases;
96
- }
97
- get settings() {
98
- return {
99
- height: this.height,
100
- width: this.width,
101
- direction: this.direction,
102
- gradient: this.gradient,
103
- preventHover: this.preventHover,
104
- hideText: this.hideText,
105
- override: this.override,
106
- aliases: this.aliases,
107
- };
108
- }
109
- connectedCallback() {
110
- super.connectedCallback();
111
- // Pulse the Invalid Palette to show its location
112
- if (this.pluginSettings.errorPulse) {
113
- this.pulse = true;
114
- setTimeout(() => {
115
- this.pulse = false;
116
- }, this.pluginSettings.noticeDuration);
117
- }
118
- }
119
- disconnectedCallback() {
120
- super.disconnectedCallback();
121
- this.emitter.clear();
122
- }
123
- willUpdate(_changedProperties) {
124
- super.willUpdate(_changedProperties);
125
- this.setStatusAndColors();
126
- }
127
- /** Sets the current status and parses colors. */
128
- setStatusAndColors() {
129
- const isSettingsValid = () => {
130
- return (!isNaN(this.height)
131
- && !isNaN(this.width)
132
- && Object.values(Direction).includes(this.direction)
133
- && this.gradient != null
134
- && this.preventHover != null
135
- && this.hideText != null
136
- && this.override != null
137
- && (this.aliases instanceof Array
138
- || typeof this.aliases === 'undefined'));
139
- };
140
- const colorsResult = parseColors(this.colors, this.override);
141
- if (!isSettingsValid()) {
142
- this.status = Status.INVALID_SETTINGS;
143
- }
144
- // Set status to invalid if parsedColors returns a status, or if parsedColors returns an empty array
145
- if (typeof colorsResult === 'string' || (typeof colorsResult === 'object' && colorsResult.length === 0)) {
146
- this.status = this.status === Status.INVALID_SETTINGS ? Status.INVALID_COLORS_AND_SETTINGS : Status.INVALID_COLORS;
147
- }
148
- if (typeof colorsResult === 'object') {
149
- this.colors = colorsResult;
150
- }
151
- if (this.colors.length <= 1 && this.gradient)
152
- this.status = Status.INVALID_GRADIENT;
153
- }
154
- render() {
155
- const paletteStyles = {
156
- // Set default corner style
157
- '--palette-corners': this.pluginSettings.corners ? '5px' : '0px',
158
- '--palette-height': `${this.height}px`,
159
- '--palette-width': `${this.getPaletteWidth()}px`,
160
- '--palette-column-flex-basis': `${(this.height / this.colors.length / 2)}px`
161
- };
162
- const invalidStyles = {
163
- animation: this.pulse ? `pulse ${this.pluginSettings.noticeDuration / 1000 / 2}s infinite` : ''
164
- };
165
- const paletteClasses = {
166
- "palette-scroll": this.width > defaultSettings.width,
167
- };
168
- return html `
169
- <div
170
- id="palette"
171
- class=${classMap(paletteClasses)}
172
- style=${this.status === Status.VALID ? styleMap(paletteStyles) : styleMap(invalidStyles)}
173
- >
174
- ${this.createPalette()}
175
- </div>
19
+ let r = class extends I {
20
+ constructor() {
21
+ super(...arguments), this._editMode = !1, this.colors = [], this.height = u.height, this.width = u.width, this.direction = u.direction, this.gradient = !1, this.preventHover = !1, this.hideText = !1, this.override = !1, this.aliases = [], this.maxWidth = 0, this.status = l.VALID, this.pulse = !1, this.emitter = new b(), this.pluginSettings = u;
22
+ }
23
+ set editMode(t) {
24
+ this._editMode = t, this.emitter.emit("editMode", t);
25
+ }
26
+ get editMode() {
27
+ return this._editMode;
28
+ }
29
+ /** Helper accessor for settings */
30
+ set settings({ height: t, width: e, direction: s, gradient: a, preventHover: i, override: h, aliases: p }) {
31
+ this.height = t, this.width = e, this.direction = s, this.gradient = a, this.preventHover = i, this.override = h, this.aliases = p;
32
+ }
33
+ get settings() {
34
+ return {
35
+ height: this.height,
36
+ width: this.width,
37
+ direction: this.direction,
38
+ gradient: this.gradient,
39
+ preventHover: this.preventHover,
40
+ hideText: this.hideText,
41
+ override: this.override,
42
+ aliases: this.aliases
43
+ };
44
+ }
45
+ connectedCallback() {
46
+ super.connectedCallback(), this.pluginSettings.errorPulse && (this.pulse = !0, setTimeout(() => {
47
+ this.pulse = !1;
48
+ }, this.pluginSettings.noticeDuration));
49
+ }
50
+ disconnectedCallback() {
51
+ super.disconnectedCallback(), this.emitter.clear();
52
+ }
53
+ willUpdate(t) {
54
+ super.willUpdate(t), this.setStatusAndColors();
55
+ }
56
+ /** Sets the current status and parses colors. */
57
+ setStatusAndColors() {
58
+ const t = () => !isNaN(this.height) && !isNaN(this.width) && Object.values(_).includes(this.direction) && this.gradient != null && this.preventHover != null && this.hideText != null && this.override != null && (this.aliases instanceof Array || typeof this.aliases > "u"), e = w(this.colors, this.override);
59
+ t() || (this.status = l.INVALID_SETTINGS), (typeof e == "string" || typeof e == "object" && e.length === 0) && (this.status = this.status === l.INVALID_SETTINGS ? l.INVALID_COLORS_AND_SETTINGS : l.INVALID_COLORS), typeof e == "object" && (this.colors = e), this.colors.length <= 1 && this.gradient && (this.status = l.INVALID_GRADIENT);
60
+ }
61
+ render() {
62
+ const t = {
63
+ // Set default corner style
64
+ "--palette-corners": this.pluginSettings.corners ? "5px" : "0px",
65
+ "--palette-height": `${this.height}px`,
66
+ "--palette-width": `${this.getPaletteWidth()}px`,
67
+ "--palette-column-flex-basis": `${this.height / this.colors.length / 2}px`
68
+ }, e = {
69
+ animation: this.pulse ? `pulse ${this.pluginSettings.noticeDuration / 1e3 / 2}s infinite` : ""
70
+ }, s = {
71
+ "palette-scroll": this.width > u.width
72
+ };
73
+ return c`
74
+ <div
75
+ id="palette"
76
+ class=${D(s)}
77
+ style=${this.status === l.VALID ? y(t) : y(e)}
78
+ >
79
+ ${this.createPalette()}
80
+ </div>
176
81
  `;
82
+ }
83
+ /** @returns `user` OR `auto` width based on which is more appropriate. */
84
+ getPaletteWidth() {
85
+ return this.maxWidth < this.settings.width && this.maxWidth > 0 ? this.maxWidth : this.settings.width;
86
+ }
87
+ /** Creates a color palette or gradient palette depending on settings. */
88
+ createPalette() {
89
+ try {
90
+ if (this.status === l.VALID)
91
+ return this.gradient ? this.createGradient() : this.createColors();
92
+ throw new v(this.status);
93
+ } catch (t) {
94
+ return t instanceof v ? (this.emitter.emit("notice", t.message), this.createInvalidPalette(t.status, t.message)) : S;
177
95
  }
178
- /** @returns `user` OR `auto` width based on which is more appropriate. */
179
- getPaletteWidth() {
180
- // Automatically set width if offset is less than settings width
181
- if (this.maxWidth < this.settings.width && this.maxWidth > 0)
182
- return this.maxWidth;
183
- // Set user-set width
184
- else
185
- return this.settings.width;
186
- }
187
- /** Creates a color palette or gradient palette depending on settings. */
188
- createPalette() {
189
- try {
190
- if (this.status === Status.VALID) {
191
- if (this.gradient)
192
- return this.createGradient();
193
- else
194
- return this.createColors();
195
- }
196
- else {
197
- // Throw error & create Invalid Palette
198
- throw new PaletteError(this.status);
199
- }
200
- }
201
- catch (err) {
202
- if (!(err instanceof PaletteError))
203
- return nothing;
204
- this.emitter.emit('notice', err.message);
205
- return this.createInvalidPalette(err.status, err.message);
206
- }
207
- }
208
- ;
209
- /** Create a color palette. */
210
- createColors() {
211
- return html `
212
- ${repeat(this.colors, (color, index) => {
213
- let itemRef = (item) => {
214
- if (!(item instanceof ColorPaletteItem))
215
- return;
216
- item.emitter.clear();
217
- item.emitter.on('click', async (e) => await copyToClipboard(color.toUpperCase(), this.pluginSettings.copyFormat));
218
- };
219
- let itemEditRef = (item) => {
220
- if (!(item instanceof ColorPaletteItemEdit))
221
- return;
222
- item.emitter.clear();
223
- item.emitter.on('click', async (e) => await copyToClipboard(color.toUpperCase(), this.pluginSettings.copyFormat));
224
- item.emitter.on('trash', (e) => {
225
- e.stopPropagation();
226
- const deletedIndex = this.colors.indexOf(color);
227
- this.colors = this.colors.filter((_, index) => index !== deletedIndex);
228
- this.aliases = this.aliases.filter((_, index) => index !== deletedIndex);
229
- this.emitter.emit('changed', this.colors, this.settings);
230
- });
231
- item.emitter.on('alias', (alias) => {
232
- // Get the index of the alias relative to the PaletteItem color
233
- const aliasIndex = this.colors.findIndex((val) => val === color);
234
- for (let i = 0; i < aliasIndex; i++) {
235
- // Set empty strings to empty indexes
236
- if (!this.aliases[i])
237
- this.aliases[i] = '';
238
- }
239
- // Set modified alias index
240
- this.aliases[aliasIndex] = alias;
241
- this.emitter.emit('changed', this.colors, this.settings);
242
- });
243
- };
244
- return !this.editMode
245
- ? html `
246
- <color-palette-item
247
- color=${color}
248
- alias=${this.aliases?.[index] || ''}
249
- aliasMode=${this.pluginSettings.aliasMode}
250
- direction=${this.direction}
251
- ?editMode=${this.editMode}
252
- height=${this.height}
253
- ?preventHover=${this.preventHover}
254
- ?hideText=${this.hideText}
255
- colorCount=${this.colors.length}
256
- ${ref(itemRef)}
257
- >
258
- </color-palette-item>
259
- `
260
- : html `
261
- <color-palette-item-edit
262
- draggable=${true}
263
- color=${color}
264
- alias=${this.aliases?.[index] || ''}
265
- aliasMode=${this.pluginSettings.aliasMode}
266
- direction=${this.direction}
267
- ?editMode=${this.editMode}
268
- height=${this.height}
269
- ?preventHover=${this.preventHover}
270
- ?hideText=${this.hideText}
271
- colorCount=${this.colors.length}
272
- ?stabilizeWhileEditing=${this.pluginSettings.stabilizeWhileEditing}
273
- ${ref(itemEditRef)}
274
- >
275
- </color-palette-item-edit>
96
+ }
97
+ /** Create a color palette. */
98
+ createColors() {
99
+ return c`
100
+ ${N(
101
+ this.colors,
102
+ (t, e) => {
103
+ let s = (i) => {
104
+ i instanceof T && (i.emitter.clear(), i.emitter.on("click", async (h) => await m(t.toUpperCase(), this.pluginSettings.copyFormat)));
105
+ }, a = (i) => {
106
+ i instanceof M && (i.emitter.clear(), i.emitter.on("click", async (h) => await m(t.toUpperCase(), this.pluginSettings.copyFormat)), i.emitter.on("trash", (h) => {
107
+ h.stopPropagation();
108
+ const p = this.colors.indexOf(t);
109
+ this.colors = this.colors.filter((d, f) => f !== p), this.aliases = this.aliases.filter((d, f) => f !== p), this.emitter.emit("changed", this.colors, this.settings);
110
+ }), i.emitter.on("alias", (h) => {
111
+ const p = this.colors.findIndex((d) => d === t);
112
+ for (let d = 0; d < p; d++)
113
+ this.aliases[d] || (this.aliases[d] = "");
114
+ this.aliases[p] = h, this.emitter.emit("changed", this.colors, this.settings);
115
+ }));
116
+ };
117
+ return this.editMode ? c`
118
+ <color-palette-item-edit
119
+ draggable=${!0}
120
+ color=${t}
121
+ alias=${this.aliases?.[e] || ""}
122
+ aliasMode=${this.pluginSettings.aliasMode}
123
+ direction=${this.direction}
124
+ ?editMode=${this.editMode}
125
+ height=${this.height}
126
+ ?preventHover=${this.preventHover}
127
+ ?hideText=${this.hideText}
128
+ colorCount=${this.colors.length}
129
+ ?stabilizeWhileEditing=${this.pluginSettings.stabilizeWhileEditing}
130
+ ${g(a)}
131
+ >
132
+ </color-palette-item-edit>
133
+ ` : c`
134
+ <color-palette-item
135
+ color=${t}
136
+ alias=${this.aliases?.[e] || ""}
137
+ aliasMode=${this.pluginSettings.aliasMode}
138
+ direction=${this.direction}
139
+ ?editMode=${this.editMode}
140
+ height=${this.height}
141
+ ?preventHover=${this.preventHover}
142
+ ?hideText=${this.hideText}
143
+ colorCount=${this.colors.length}
144
+ ${g(s)}
145
+ >
146
+ </color-palette-item>
276
147
  `;
277
- })}
148
+ }
149
+ )}
278
150
  `;
279
- }
280
- /** Create a gradient palette. */
281
- createGradient() {
282
- let tooltipRef = createRef();
283
- let canvasRef = (canvas) => {
284
- if (!(canvas instanceof CanvasGradient))
285
- return;
286
- canvas.emitter.clear();
287
- canvas.emitter.on('click', async (color) => await copyToClipboard(color.toUpperCase(), this.pluginSettings.copyFormat));
288
- canvas.emitter.on('move', (pos) => {
289
- if (!tooltipRef.value)
290
- return;
291
- let tooltip = tooltipRef.value;
292
- // Set tooltip text
293
- tooltip.text = canvas.getCanvasHex(pos.x, pos.y).toUpperCase();
294
- // Set tooltip position
295
- tooltip.setClampedPosition(pos, this.getBoundingClientRect());
296
- });
297
- };
298
- return html `
299
- <tool-tip
300
- id="tooltip"
301
- trigger="hover"
302
- ?display=${!this.preventHover}
303
- ${ref(tooltipRef)}
304
- >
305
- <canvas-gradient
306
- .colors=${this.colors}
307
- height=${this.height}
308
- width=${this.getPaletteWidth()}
309
- direction=${this.direction}
310
- id="canvas"
311
- ${ref(canvasRef)}
312
- >
313
- </canvas-gradient>
314
- </tool-tip>
151
+ }
152
+ /** Create a gradient palette. */
153
+ createGradient() {
154
+ let t = P(), e = (s) => {
155
+ s instanceof A && (s.emitter.clear(), s.emitter.on("click", async (a) => await m(a.toUpperCase(), this.pluginSettings.copyFormat)), s.emitter.on("move", (a) => {
156
+ if (!t.value) return;
157
+ let i = t.value;
158
+ i.text = s.getCanvasHex(a.x, a.y).toUpperCase(), i.setClampedPosition(a, this.getBoundingClientRect());
159
+ }));
160
+ };
161
+ return c`
162
+ <tool-tip
163
+ id="tooltip"
164
+ trigger="hover"
165
+ ?display=${!this.preventHover}
166
+ ${g(t)}
167
+ >
168
+ <canvas-gradient
169
+ .colors=${this.colors}
170
+ height=${this.height}
171
+ width=${this.getPaletteWidth()}
172
+ direction=${this.direction}
173
+ id="canvas"
174
+ ${g(e)}
175
+ >
176
+ </canvas-gradient>
177
+ </tool-tip>
315
178
  `;
179
+ }
180
+ /**
181
+ * Create invalid palette based on palette status.
182
+ * @param type Palette status type
183
+ */
184
+ createInvalidPalette(t, e = "") {
185
+ let s = "Invalid palette";
186
+ switch (t) {
187
+ case l.INVALID_COLORS:
188
+ s = "Colors are defined incorrectly";
189
+ break;
190
+ case l.INVALID_SETTINGS:
191
+ s = "Issues parsing settings";
192
+ break;
193
+ case l.INVALID_COLORS_AND_SETTINGS:
194
+ s = "Colors and settings are defined incorrectly";
195
+ break;
196
+ case l.INVALID_GRADIENT:
197
+ s = "Gradients require more than 1 color to display";
198
+ break;
316
199
  }
317
- /**
318
- * Create invalid palette based on palette status.
319
- * @param type Palette status type
320
- */
321
- createInvalidPalette(type, message = '') {
322
- let defaultMessage = 'Invalid palette';
323
- switch (type) {
324
- case Status.INVALID_COLORS:
325
- defaultMessage = 'Colors are defined incorrectly';
326
- break;
327
- case Status.INVALID_SETTINGS:
328
- defaultMessage = 'Issues parsing settings';
329
- break;
330
- case Status.INVALID_COLORS_AND_SETTINGS:
331
- defaultMessage = 'Colors and settings are defined incorrectly';
332
- break;
333
- case Status.INVALID_GRADIENT:
334
- defaultMessage = 'Gradients require more than 1 color to display';
335
- break;
336
- }
337
- this.emitter.emit('notice', `Palette:\n${message ? message : defaultMessage}`);
338
- return html `
339
- <section id="invalid">
340
- <span>${type}</span>
341
- </section>
200
+ return this.emitter.emit("notice", `Palette:
201
+ ${e || s}`), c`
202
+ <section id="invalid">
203
+ <span>${t}</span>
204
+ </section>
342
205
  `;
343
- }
206
+ }
207
+ };
208
+ r.styles = [L];
209
+ o([
210
+ C("#palette")
211
+ ], r.prototype, "palette", 2);
212
+ o([
213
+ n({ type: Boolean })
214
+ ], r.prototype, "editMode", 1);
215
+ o([
216
+ n({ type: Array, reflect: !0 })
217
+ ], r.prototype, "colors", 2);
218
+ o([
219
+ n({ type: Number, reflect: !0 })
220
+ ], r.prototype, "height", 2);
221
+ o([
222
+ n({ type: Number, reflect: !0 })
223
+ ], r.prototype, "width", 2);
224
+ o([
225
+ n({ type: String, reflect: !0 })
226
+ ], r.prototype, "direction", 2);
227
+ o([
228
+ n({ type: Boolean, reflect: !0 })
229
+ ], r.prototype, "gradient", 2);
230
+ o([
231
+ n({ type: Boolean, reflect: !0 })
232
+ ], r.prototype, "preventHover", 2);
233
+ o([
234
+ n({ type: Boolean, reflect: !0 })
235
+ ], r.prototype, "hideText", 2);
236
+ o([
237
+ n({ type: Boolean, reflect: !0 })
238
+ ], r.prototype, "override", 2);
239
+ o([
240
+ n({ type: Array, reflect: !0 })
241
+ ], r.prototype, "aliases", 2);
242
+ o([
243
+ n({ type: Number })
244
+ ], r.prototype, "maxWidth", 2);
245
+ o([
246
+ $()
247
+ ], r.prototype, "status", 2);
248
+ o([
249
+ $()
250
+ ], r.prototype, "pulse", 2);
251
+ o([
252
+ n({ type: Object })
253
+ ], r.prototype, "pluginSettings", 2);
254
+ r = o([
255
+ x("color-palette")
256
+ ], r);
257
+ export {
258
+ r as ColorPalette
344
259
  };
345
- __decorate([
346
- query('#palette')
347
- ], ColorPalette.prototype, "palette", void 0);
348
- __decorate([
349
- property({ type: Boolean })
350
- ], ColorPalette.prototype, "editMode", null);
351
- __decorate([
352
- property({ type: Array, reflect: true })
353
- ], ColorPalette.prototype, "colors", void 0);
354
- __decorate([
355
- property({ type: Number, reflect: true })
356
- ], ColorPalette.prototype, "height", void 0);
357
- __decorate([
358
- property({ type: Number, reflect: true })
359
- ], ColorPalette.prototype, "width", void 0);
360
- __decorate([
361
- property({ type: String, reflect: true })
362
- ], ColorPalette.prototype, "direction", void 0);
363
- __decorate([
364
- property({ type: Boolean, reflect: true })
365
- ], ColorPalette.prototype, "gradient", void 0);
366
- __decorate([
367
- property({ type: Boolean, reflect: true })
368
- ], ColorPalette.prototype, "preventHover", void 0);
369
- __decorate([
370
- property({ type: Boolean, reflect: true })
371
- ], ColorPalette.prototype, "hideText", void 0);
372
- __decorate([
373
- property({ type: Boolean, reflect: true })
374
- ], ColorPalette.prototype, "override", void 0);
375
- __decorate([
376
- property({ type: Array, reflect: true })
377
- ], ColorPalette.prototype, "aliases", void 0);
378
- __decorate([
379
- property({ type: Number })
380
- ], ColorPalette.prototype, "maxWidth", void 0);
381
- __decorate([
382
- state()
383
- ], ColorPalette.prototype, "status", void 0);
384
- __decorate([
385
- state()
386
- ], ColorPalette.prototype, "pulse", void 0);
387
- __decorate([
388
- property({ type: Object })
389
- ], ColorPalette.prototype, "pluginSettings", void 0);
390
- ColorPalette = __decorate([
391
- customElement('color-palette')
392
- ], ColorPalette);
393
- export { ColorPalette };