@alegendstale/holly-components 2.0.2 → 2.0.4

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 (137) hide show
  1. package/dist/components/absolute-container/absolute-container.js +79 -113
  2. package/dist/components/absolute-container/absolute-container.styles.js +20 -17
  3. package/dist/components/bottom-sheet/bottom-sheet.js +189 -319
  4. package/dist/components/bottom-sheet/bottom-sheet.styles.js +117 -114
  5. package/dist/components/canvas/canvas-base.d.ts +4 -1
  6. package/dist/components/canvas/canvas-base.d.ts.map +1 -1
  7. package/dist/components/canvas/canvas-base.js +51 -67
  8. package/dist/components/canvas/canvas-gradient.js +44 -69
  9. package/dist/components/canvas/canvas-image.js +112 -177
  10. package/dist/components/canvas/canvas-image.styles.js +23 -20
  11. package/dist/components/carousel-scroller/carousel-scroller.js +63 -87
  12. package/dist/components/carousel-scroller/carousel-scroller.styles.js +68 -65
  13. package/dist/components/color-palette/color-palette-utils.js +55 -104
  14. package/dist/components/color-palette/color-palette.js +250 -384
  15. package/dist/components/color-palette/color-palette.styles.js +92 -89
  16. package/dist/components/color-palette/component/color-palette-component.js +134 -188
  17. package/dist/components/color-palette/component/color-palette-component.styles.js +12 -9
  18. package/dist/components/color-palette/editor/color-palette-editor.js +413 -539
  19. package/dist/components/color-palette/editor/color-palette-editor.styles.js +149 -146
  20. package/dist/components/color-palette/editor/settings-item.js +32 -40
  21. package/dist/components/color-palette/editor/settings-item.styles.js +36 -33
  22. package/dist/components/color-palette/item/color-palette-item-edit.js +50 -84
  23. package/dist/components/color-palette/item/color-palette-item-edit.styles.js +53 -50
  24. package/dist/components/color-palette/item/color-palette-item.js +72 -107
  25. package/dist/components/color-palette/item/color-palette-item.styles.js +85 -82
  26. package/dist/components/color-palette/menu/color-palette-menu.js +162 -200
  27. package/dist/components/color-palette/menu/color-palette-menu.styles.js +51 -48
  28. package/dist/components/color-palette/menu/color-palette-reorder.js +76 -95
  29. package/dist/components/color-palette/menu/color-palette-reorder.styles.js +33 -30
  30. package/dist/components/draw-svg/draw-svg.js +35 -52
  31. package/dist/components/draw-svg/draw-svg.styles.js +41 -38
  32. package/dist/components/responsive-svg/responsive-svg.d.ts +2 -2
  33. package/dist/components/responsive-svg/responsive-svg.d.ts.map +1 -1
  34. package/dist/components/responsive-svg/responsive-svg.js +122 -174
  35. package/dist/components/responsive-svg/responsive-svg.styles.js +48 -45
  36. package/dist/components/tool-tip/tool-tip.d.ts +5 -1
  37. package/dist/components/tool-tip/tool-tip.d.ts.map +1 -1
  38. package/dist/components/tool-tip/tool-tip.js +64 -100
  39. package/dist/components/tool-tip/tool-tip.styles.js +60 -57
  40. package/dist/decorators/condCustomElement.js +8 -11
  41. package/dist/utils/EventEmitter.js +23 -23
  42. package/dist/utils/ResponsiveController.js +15 -18
  43. package/dist/utils/basicUtils.js +98 -146
  44. package/dist/utils/colorsea-wrapper.js +162 -166
  45. package/dist/utils/dragDropUtils.js +75 -119
  46. package/dist/utils/generateUtils.js +39 -73
  47. package/package.json +34 -64
  48. package/dist/components/absolute-container/absolute-container.stories.d.ts +0 -11
  49. package/dist/components/absolute-container/absolute-container.stories.d.ts.map +0 -1
  50. package/dist/components/absolute-container/absolute-container.stories.js +0 -64
  51. package/dist/components/absolute-container/index.d.ts +0 -2
  52. package/dist/components/absolute-container/index.d.ts.map +0 -1
  53. package/dist/components/absolute-container/index.js +0 -1
  54. package/dist/components/bottom-sheet/bottom-sheet.stories.d.ts +0 -17
  55. package/dist/components/bottom-sheet/bottom-sheet.stories.d.ts.map +0 -1
  56. package/dist/components/bottom-sheet/bottom-sheet.stories.js +0 -67
  57. package/dist/components/bottom-sheet/index.d.ts +0 -2
  58. package/dist/components/bottom-sheet/index.d.ts.map +0 -1
  59. package/dist/components/bottom-sheet/index.js +0 -1
  60. package/dist/components/canvas/canvas-base.stories.d.ts +0 -7
  61. package/dist/components/canvas/canvas-base.stories.d.ts.map +0 -1
  62. package/dist/components/canvas/canvas-base.stories.js +0 -24
  63. package/dist/components/canvas/canvas-gradient.stories.d.ts +0 -14
  64. package/dist/components/canvas/canvas-gradient.stories.d.ts.map +0 -1
  65. package/dist/components/canvas/canvas-gradient.stories.js +0 -46
  66. package/dist/components/canvas/canvas-image.stories.d.ts +0 -13
  67. package/dist/components/canvas/canvas-image.stories.d.ts.map +0 -1
  68. package/dist/components/canvas/canvas-image.stories.js +0 -49
  69. package/dist/components/canvas/index.d.ts +0 -3
  70. package/dist/components/canvas/index.d.ts.map +0 -1
  71. package/dist/components/canvas/index.js +0 -2
  72. package/dist/components/carousel-scroller/carousel-scroller.stories.d.ts +0 -13
  73. package/dist/components/carousel-scroller/carousel-scroller.stories.d.ts.map +0 -1
  74. package/dist/components/carousel-scroller/carousel-scroller.stories.js +0 -56
  75. package/dist/components/carousel-scroller/index.d.ts +0 -2
  76. package/dist/components/carousel-scroller/index.d.ts.map +0 -1
  77. package/dist/components/carousel-scroller/index.js +0 -1
  78. package/dist/components/color-palette/component/color-palette-component.stories.d.ts +0 -13
  79. package/dist/components/color-palette/component/color-palette-component.stories.d.ts.map +0 -1
  80. package/dist/components/color-palette/component/color-palette-component.stories.js +0 -75
  81. package/dist/components/color-palette/component/index.d.ts +0 -2
  82. package/dist/components/color-palette/component/index.d.ts.map +0 -1
  83. package/dist/components/color-palette/component/index.js +0 -1
  84. package/dist/components/color-palette/editor/color-palette-editor.stories.d.ts +0 -18
  85. package/dist/components/color-palette/editor/color-palette-editor.stories.d.ts.map +0 -1
  86. package/dist/components/color-palette/editor/color-palette-editor.stories.js +0 -67
  87. package/dist/components/color-palette/editor/index.d.ts +0 -2
  88. package/dist/components/color-palette/editor/index.d.ts.map +0 -1
  89. package/dist/components/color-palette/editor/index.js +0 -1
  90. package/dist/components/color-palette/index.d.ts +0 -6
  91. package/dist/components/color-palette/index.d.ts.map +0 -1
  92. package/dist/components/color-palette/index.js +0 -5
  93. package/dist/components/color-palette/item/index.d.ts +0 -3
  94. package/dist/components/color-palette/item/index.d.ts.map +0 -1
  95. package/dist/components/color-palette/item/index.js +0 -2
  96. package/dist/components/color-palette/menu/index.d.ts +0 -3
  97. package/dist/components/color-palette/menu/index.d.ts.map +0 -1
  98. package/dist/components/color-palette/menu/index.js +0 -2
  99. package/dist/components/color-palette/storybook/color-palette-invalid.stories.d.ts +0 -33
  100. package/dist/components/color-palette/storybook/color-palette-invalid.stories.d.ts.map +0 -1
  101. package/dist/components/color-palette/storybook/color-palette-invalid.stories.js +0 -62
  102. package/dist/components/color-palette/storybook/color-palette-valid.stories.d.ts +0 -52
  103. package/dist/components/color-palette/storybook/color-palette-valid.stories.d.ts.map +0 -1
  104. package/dist/components/color-palette/storybook/color-palette-valid.stories.js +0 -268
  105. package/dist/components/color-palette/storybook/color-palette.stories.d.ts +0 -27
  106. package/dist/components/color-palette/storybook/color-palette.stories.d.ts.map +0 -1
  107. package/dist/components/color-palette/storybook/color-palette.stories.js +0 -129
  108. package/dist/components/draw-svg/draw-svg.stories.d.ts +0 -7
  109. package/dist/components/draw-svg/draw-svg.stories.d.ts.map +0 -1
  110. package/dist/components/draw-svg/draw-svg.stories.js +0 -61
  111. package/dist/components/draw-svg/index.d.ts +0 -2
  112. package/dist/components/draw-svg/index.d.ts.map +0 -1
  113. package/dist/components/draw-svg/index.js +0 -1
  114. package/dist/components/responsive-svg/index.d.ts +0 -2
  115. package/dist/components/responsive-svg/index.d.ts.map +0 -1
  116. package/dist/components/responsive-svg/index.js +0 -1
  117. package/dist/components/responsive-svg/responsive-svg.stories.d.ts +0 -26
  118. package/dist/components/responsive-svg/responsive-svg.stories.d.ts.map +0 -1
  119. package/dist/components/responsive-svg/responsive-svg.stories.js +0 -194
  120. package/dist/components/tool-tip/index.d.ts +0 -2
  121. package/dist/components/tool-tip/index.d.ts.map +0 -1
  122. package/dist/components/tool-tip/index.js +0 -1
  123. package/dist/components/tool-tip/tool-tip.stories.d.ts +0 -16
  124. package/dist/components/tool-tip/tool-tip.stories.d.ts.map +0 -1
  125. package/dist/components/tool-tip/tool-tip.stories.js +0 -62
  126. package/dist/decorators/index.d.ts +0 -2
  127. package/dist/decorators/index.d.ts.map +0 -1
  128. package/dist/decorators/index.js +0 -1
  129. package/dist/index.d.ts +0 -11
  130. package/dist/index.d.ts.map +0 -1
  131. package/dist/index.js +0 -10
  132. package/dist/utils/index.d.ts +0 -5
  133. package/dist/utils/index.d.ts.map +0 -1
  134. package/dist/utils/index.js +0 -4
  135. package/dist/utils/types.d.ts +0 -5
  136. package/dist/utils/types.d.ts.map +0 -1
  137. package/dist/utils/types.js +0 -1
@@ -1,553 +1,427 @@
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;
6
- };
7
- import { LitElement, html } from 'lit';
8
- import { customElement, property, query, state } from 'lit/decorators.js';
9
- import { ArrowUpToLine, createElement, Image, Link, Pipette, Shuffle } from 'lucide';
10
- import { defaultSettings, Direction } from '../color-palette-utils.js';
11
- import { Combination, generateColors } from '../../../utils/generateUtils.js';
12
- import colorsea from '../../../utils/colorsea-wrapper.js';
13
- import { copyToClipboard, parseUrl } from '../../../utils/basicUtils.js';
14
- import { CopyFormat, urlRegex } from '../color-palette-utils.js';
15
- import { CanvasImage } from '../../canvas/canvas-image.js';
16
- import { ref, createRef } from 'lit/directives/ref.js';
17
- import { EventEmitter } from '../../../utils/EventEmitter.js';
18
- import { ColorPalette } from '../color-palette.js';
19
- import styles from './color-palette-editor.styles.js';
20
- import './settings-item.js';
21
- export var SelectedInput;
22
- (function (SelectedInput) {
23
- SelectedInput["Color_Picker"] = "Color Picker";
24
- SelectedInput["Generate"] = "Generate";
25
- SelectedInput["Image"] = "Image";
26
- SelectedInput["URL"] = "URL";
27
- })(SelectedInput || (SelectedInput = {}));
28
- /**
29
- * An editor which can assist in modifying new or existing color palettes.
30
- *
31
- * @dependency setting-item
32
- *
33
- * @cssprop {<color>} --cta-background - The call to action background color.
34
- */
35
- let ColorPaletteEditor = class ColorPaletteEditor extends LitElement {
36
- constructor() {
37
- super(...arguments);
38
- /** The palette colors to be edited. */
39
- this.colors = [];
40
- /** The palette settings to be edited. */
41
- this.settings = {
42
- height: defaultSettings.height,
43
- width: defaultSettings.width,
44
- direction: defaultSettings.direction,
45
- gradient: defaultSettings.gradient,
46
- preventHover: defaultSettings.preventHover,
47
- hideText: defaultSettings.hideText,
48
- override: defaultSettings.override,
49
- aliases: []
50
- };
51
- /** The editing input that will be used. */
52
- this.selectedInput = SelectedInput.Color_Picker;
53
- /** The color theory combination used when generating colors. */
54
- this.combination = Combination.Random;
55
- /** @internal Whether the color input is enabled. */
56
- this.colorPickerDisabled = false;
57
- /** Public way to subscribe to events. */
58
- this.emitter = new EventEmitter();
59
- }
60
- static { this.styles = [styles]; }
61
- disconnectedCallback() {
62
- this.emitter.clear();
63
- }
64
- render() {
65
- const chooseControl = () => {
66
- switch (this.selectedInput) {
67
- case SelectedInput.Color_Picker:
68
- return this.pickerOption();
69
- case SelectedInput.Generate:
70
- return this.generateOption();
71
- case SelectedInput.Image:
72
- return this.imageOption();
73
- case SelectedInput.URL:
74
- return this.urlOption();
75
- }
76
- };
77
- const paletteRef = (palette) => {
78
- if (!(palette instanceof ColorPalette))
79
- return;
80
- palette.emitter.on('changed', (colors, settings) => {
81
- this.colors = colors;
82
- this.settings = settings;
83
- });
84
- };
85
- return html `
86
- <div id="color-palette-editor">
87
- <h1>Editor</h1>
88
- <section id='colors'>
89
- <h3>Colors</h3>
90
- <div id="control-container">
91
- <button
92
- title="Color Picker"
93
- @click=${() => this.selectedInput = SelectedInput.Color_Picker}
94
- >
95
- ${createElement(Pipette)}
96
- </button>
97
- <button
98
- title="Generate"
99
- @click=${() => this.selectedInput = SelectedInput.Generate}
100
- >
101
- ${createElement(Shuffle)}
102
- </button>
103
- <button
104
- title="Image"
105
- @click=${() => this.selectedInput = SelectedInput.Image}
106
- >
107
- ${createElement(Image)}
108
- </button>
109
- <button
110
- title="URL"
111
- @click=${() => this.selectedInput = SelectedInput.URL}
112
- >
113
- ${createElement(Link)}
114
- </button>
115
- </div>
116
- <div id='colors-container'>
117
- ${chooseControl()}
118
- </div>
119
- </section>
120
- <section id='preview'>
121
- <color-palette
122
- .colors=${this.colors}
123
- height=${this.settings.height}
124
- width=${this.settings.width}
125
- direction=${this.settings.direction}
126
- ?gradient=${this.settings.gradient}
127
- ?preventHover=${this.settings.preventHover}
128
- ?hideText=${this.settings.hideText}
129
- ?override=${this.settings.override}
130
- .aliases=${this.settings.aliases}
131
- ?editMode=${true}
132
- maxWidth=${560}
133
- ${ref(paletteRef)}
134
- >
135
- </color-palette>
136
- </section>
137
- <section id='settings'>
138
- <h3>Settings</h3>
139
- ${this.renderSettings()}
140
- <button
141
- id='create-btn'
1
+ import { LitElement as x, html as l } from "lit";
2
+ import { query as P, property as v, state as H, customElement as T } from "lit/decorators.js";
3
+ import { createElement as p, Pipette as U, Shuffle as C, Image as O, Link as R, ArrowUpToLine as D } from "lucide";
4
+ import { defaultSettings as u, Direction as M, urlRegex as G, CopyFormat as S } from "../color-palette-utils.js";
5
+ import { Combination as f, generateColors as L } from "../../../utils/generateUtils.js";
6
+ import b from "../../../utils/colorsea-wrapper.js";
7
+ import { parseUrl as _, copyToClipboard as j } from "../../../utils/basicUtils.js";
8
+ import { CanvasImage as w } from "../../canvas/canvas-image.js";
9
+ import { ref as m, createRef as $ } from "lit/directives/ref.js";
10
+ import { EventEmitter as A } from "../../../utils/EventEmitter.js";
11
+ import { ColorPalette as B } from "../color-palette.js";
12
+ import F from "./color-palette-editor.styles.js";
13
+ var W = Object.defineProperty, q = Object.getOwnPropertyDescriptor, g = (t, n, s, o) => {
14
+ for (var r = o > 1 ? void 0 : o ? q(n, s) : n, c = t.length - 1, h; c >= 0; c--)
15
+ (h = t[c]) && (r = (o ? h(n, s, r) : h(r)) || r);
16
+ return o && r && W(n, s, r), r;
17
+ }, X = /* @__PURE__ */ ((t) => (t.Color_Picker = "Color Picker", t.Generate = "Generate", t.Image = "Image", t.URL = "URL", t))(X || {});
18
+ let a = class extends x {
19
+ constructor() {
20
+ super(...arguments), this.colors = [], this.settings = {
21
+ height: u.height,
22
+ width: u.width,
23
+ direction: u.direction,
24
+ gradient: u.gradient,
25
+ preventHover: u.preventHover,
26
+ hideText: u.hideText,
27
+ override: u.override,
28
+ aliases: []
29
+ }, this.selectedInput = "Color Picker", this.combination = f.Random, this.colorPickerDisabled = !1, this.emitter = new A();
30
+ }
31
+ disconnectedCallback() {
32
+ this.emitter.clear();
33
+ }
34
+ render() {
35
+ const t = () => {
36
+ switch (this.selectedInput) {
37
+ case "Color Picker":
38
+ return this.pickerOption();
39
+ case "Generate":
40
+ return this.generateOption();
41
+ case "Image":
42
+ return this.imageOption();
43
+ case "URL":
44
+ return this.urlOption();
45
+ }
46
+ }, n = (s) => {
47
+ s instanceof B && s.emitter.on("changed", (o, r) => {
48
+ this.colors = o, this.settings = r;
49
+ });
50
+ };
51
+ return l`
52
+ <div id="color-palette-editor">
53
+ <h1>Editor</h1>
54
+ <section id='colors'>
55
+ <h3>Colors</h3>
56
+ <div id="control-container">
57
+ <button
58
+ title="Color Picker"
59
+ @click=${() => this.selectedInput = "Color Picker"}
60
+ >
61
+ ${p(U)}
62
+ </button>
63
+ <button
64
+ title="Generate"
65
+ @click=${() => this.selectedInput = "Generate"}
66
+ >
67
+ ${p(C)}
68
+ </button>
69
+ <button
70
+ title="Image"
71
+ @click=${() => this.selectedInput = "Image"}
72
+ >
73
+ ${p(O)}
74
+ </button>
75
+ <button
76
+ title="URL"
77
+ @click=${() => this.selectedInput = "URL"}
78
+ >
79
+ ${p(R)}
80
+ </button>
81
+ </div>
82
+ <div id='colors-container'>
83
+ ${t()}
84
+ </div>
85
+ </section>
86
+ <section id='preview'>
87
+ <color-palette
88
+ .colors=${this.colors}
89
+ height=${this.settings.height}
90
+ width=${this.settings.width}
91
+ direction=${this.settings.direction}
92
+ ?gradient=${this.settings.gradient}
93
+ ?preventHover=${this.settings.preventHover}
94
+ ?hideText=${this.settings.hideText}
95
+ ?override=${this.settings.override}
96
+ .aliases=${this.settings.aliases}
97
+ ?editMode=${!0}
98
+ maxWidth=${560}
99
+ ${m(n)}
100
+ >
101
+ </color-palette>
102
+ </section>
103
+ <section id='settings'>
104
+ <h3>Settings</h3>
105
+ ${this.renderSettings()}
106
+ <button
107
+ id='create-btn'
142
108
  @click=${() => {
143
- try {
144
- // Generate random colors if none are provided
145
- if (this.colors.length === 0)
146
- this.colors = generateColors(Combination.Random).colors;
147
- this.emitter.emit('submit', this.colors, this.settings);
148
- }
149
- catch (e) {
150
- // new Notice(e);
151
- }
152
- }}
153
- >
154
- Create
155
- </button>
156
- </section>
157
- </div>
109
+ try {
110
+ this.colors.length === 0 && (this.colors = L(f.Random).colors), this.emitter.emit("submit", this.colors, this.settings);
111
+ } catch {
112
+ }
113
+ }}
114
+ >
115
+ Create
116
+ </button>
117
+ </section>
118
+ </div>
158
119
  `;
159
- }
160
- /** Renders the settings fields. */
161
- renderSettings() {
162
- return html `
163
- <setting-item
164
- name='Height'
165
- >
166
- <input
167
- type='number'
168
- value=${this.settings.height}
169
- step=${5}
170
- @input=${(e) => {
171
- if (!(e.target instanceof HTMLInputElement))
172
- return;
173
- this.settings = { ...this.settings, height: +e.target.value };
174
- }}
175
- >
176
- </setting-item>
177
- <setting-item
178
- name='Width'
179
- description='Caution - Might cause palette to display incorrectly.'
180
- >
181
- <input
182
- type='number'
183
- value=${this.settings.width}
184
- step=${10}
185
- @input=${(e) => {
186
- if (!(e.target instanceof HTMLInputElement))
187
- return;
188
- this.settings = { ...this.settings, width: +e.target.value };
189
- }}
190
- >
191
- </setting-item>
192
- <setting-item
193
- name='Direction'
194
- >
195
- <select
196
- @change=${(e) => {
197
- if (!(e.target instanceof HTMLSelectElement))
198
- return;
199
- this.settings = { ...this.settings, direction: e.target.value };
200
- }}
201
- >
202
- ${Object.values(Direction).map((val) => {
203
- return html `<option ?selected=${this.settings.direction === val}>${val}</option>`;
204
- })}
205
- </select>
206
- </setting-item>
207
- <setting-item
208
- name='Gradient'
209
- >
210
- <input
211
- type='checkbox'
212
- ?checked=${this.settings.gradient}
213
- @change=${(e) => {
214
- if (!(e.target instanceof HTMLInputElement))
215
- return;
216
- this.settings = { ...this.settings, gradient: e.target.checked };
217
- }}
218
- >
219
- </setting-item>
220
- <setting-item
221
- name='Prevent Hover'
222
- description='Toggles whether palettes can be hovered'
223
- >
224
- <input
225
- type='checkbox'
226
- ?checked=${this.settings.preventHover}
227
- @change=${(e) => {
228
- if (!(e.target instanceof HTMLInputElement))
229
- return;
230
- this.settings = { ...this.settings, preventHover: e.target.checked };
231
- }}
232
- >
233
- </setting-item>
234
- <setting-item
235
- name='Hide Text'
236
- description='Disables color and alias visibility'
237
- >
238
- <input
239
- type='checkbox'
240
- ?checked=${this.settings.hideText}
241
- @change=${(e) => {
242
- if (!(e.target instanceof HTMLInputElement))
243
- return;
244
- this.settings = { ...this.settings, hideText: e.target.checked };
245
- }}
246
- >
247
- </setting-item>
248
- <setting-item
249
- name='Override'
250
- description='Disables color validation for full control (advanced)'
251
- >
252
- <input
253
- type='checkbox'
254
- ?checked=${this.settings.override}
255
- @change=${(e) => {
256
- if (!(e.target instanceof HTMLInputElement))
257
- return;
258
- this.settings = { ...this.settings, override: e.target.checked };
259
- }}
260
- >
261
- </setting-item>
120
+ }
121
+ /** Renders the settings fields. */
122
+ renderSettings() {
123
+ return l`
124
+ <setting-item
125
+ name='Height'
126
+ >
127
+ <input
128
+ type='number'
129
+ value=${this.settings.height}
130
+ step=${5}
131
+ @input=${(t) => {
132
+ t.target instanceof HTMLInputElement && (this.settings = { ...this.settings, height: +t.target.value });
133
+ }}
134
+ >
135
+ </setting-item>
136
+ <setting-item
137
+ name='Width'
138
+ description='Caution - Might cause palette to display incorrectly.'
139
+ >
140
+ <input
141
+ type='number'
142
+ value=${this.settings.width}
143
+ step=${10}
144
+ @input=${(t) => {
145
+ t.target instanceof HTMLInputElement && (this.settings = { ...this.settings, width: +t.target.value });
146
+ }}
147
+ >
148
+ </setting-item>
149
+ <setting-item
150
+ name='Direction'
151
+ >
152
+ <select
153
+ @change=${(t) => {
154
+ t.target instanceof HTMLSelectElement && (this.settings = { ...this.settings, direction: t.target.value });
155
+ }}
156
+ >
157
+ ${Object.values(M).map((t) => l`<option ?selected=${this.settings.direction === t}>${t}</option>`)}
158
+ </select>
159
+ </setting-item>
160
+ <setting-item
161
+ name='Gradient'
162
+ >
163
+ <input
164
+ type='checkbox'
165
+ ?checked=${this.settings.gradient}
166
+ @change=${(t) => {
167
+ t.target instanceof HTMLInputElement && (this.settings = { ...this.settings, gradient: t.target.checked });
168
+ }}
169
+ >
170
+ </setting-item>
171
+ <setting-item
172
+ name='Prevent Hover'
173
+ description='Toggles whether palettes can be hovered'
174
+ >
175
+ <input
176
+ type='checkbox'
177
+ ?checked=${this.settings.preventHover}
178
+ @change=${(t) => {
179
+ t.target instanceof HTMLInputElement && (this.settings = { ...this.settings, preventHover: t.target.checked });
180
+ }}
181
+ >
182
+ </setting-item>
183
+ <setting-item
184
+ name='Hide Text'
185
+ description='Disables color and alias visibility'
186
+ >
187
+ <input
188
+ type='checkbox'
189
+ ?checked=${this.settings.hideText}
190
+ @change=${(t) => {
191
+ t.target instanceof HTMLInputElement && (this.settings = { ...this.settings, hideText: t.target.checked });
192
+ }}
193
+ >
194
+ </setting-item>
195
+ <setting-item
196
+ name='Override'
197
+ description='Disables color validation for full control (advanced)'
198
+ >
199
+ <input
200
+ type='checkbox'
201
+ ?checked=${this.settings.override}
202
+ @change=${(t) => {
203
+ t.target instanceof HTMLInputElement && (this.settings = { ...this.settings, override: t.target.checked });
204
+ }}
205
+ >
206
+ </setting-item>
262
207
  `;
263
- }
264
- /** Renders the picker option. */
265
- pickerOption() {
266
- return html `
267
- <setting-item
268
- name='Color Picker'
269
- description='Use handpicked colors'
270
- >
271
- <input
272
- type='color'
273
- @change=${(e) => {
274
- if (!(e.target instanceof HTMLInputElement))
275
- return;
276
- this.colors = [...this.colors, e.target.value];
277
- this.settings.aliases.push('');
278
- }}
279
- >
280
- </setting-item>
208
+ }
209
+ /** Renders the picker option. */
210
+ pickerOption() {
211
+ return l`
212
+ <setting-item
213
+ name='Color Picker'
214
+ description='Use handpicked colors'
215
+ >
216
+ <input
217
+ type='color'
218
+ @change=${(t) => {
219
+ t.target instanceof HTMLInputElement && (this.colors = [...this.colors, t.target.value], this.settings.aliases.push(""));
220
+ }}
221
+ >
222
+ </setting-item>
281
223
  `;
282
- }
283
- /** Renders the generate option. */
284
- generateOption() {
285
- this.colorPickerDisabled = this.combination === Combination.Random;
286
- return html `
287
- <setting-item
288
- name='Generate'
289
- description='Generate colors based on color theory'
290
- >
291
- <select
292
- @change=${(e) => {
293
- if (!(e.target instanceof HTMLSelectElement))
294
- return;
295
- this.combination = e.target.value;
296
- this.colorPickerDisabled = this.combination === Combination.Random;
297
- }}
298
- >
299
- ${Object.values(Combination).map((val) => {
300
- return html `<option ?selected=${this.combination === val}>${val}</option>`;
301
- })}
302
- </select>
303
- <input
304
- type='color'
305
- ?disabled=${this.colorPickerDisabled}
306
- @change=${(e) => {
307
- if (!(e.target instanceof HTMLInputElement))
308
- return;
309
- this.baseColor = colorsea(e.target.value);
310
- }}
311
- @contextmenu=${(e) => {
312
- e.preventDefault();
313
- if (!(e.target instanceof HTMLInputElement))
314
- return;
315
- e.target.value = colorsea('#000').hex();
316
- this.baseColor = undefined;
317
- }}
318
- >
319
- <button
320
- title='Loads the generated colors'
321
- @click=${(e) => {
322
- const generated = generateColors(this.combination, { baseColor: this.baseColor, settings: this.settings });
323
- this.colors = generated.colors;
324
- if (generated.settings)
325
- this.settings = generated.settings;
326
- }}
327
- >
328
- ${createElement(Shuffle)}
329
- </button>
330
- </setting-item>
224
+ }
225
+ /** Renders the generate option. */
226
+ generateOption() {
227
+ return this.colorPickerDisabled = this.combination === f.Random, l`
228
+ <setting-item
229
+ name='Generate'
230
+ description='Generate colors based on color theory'
231
+ >
232
+ <select
233
+ @change=${(t) => {
234
+ t.target instanceof HTMLSelectElement && (this.combination = t.target.value, this.colorPickerDisabled = this.combination === f.Random);
235
+ }}
236
+ >
237
+ ${Object.values(f).map((t) => l`<option ?selected=${this.combination === t}>${t}</option>`)}
238
+ </select>
239
+ <input
240
+ type='color'
241
+ ?disabled=${this.colorPickerDisabled}
242
+ @change=${(t) => {
243
+ t.target instanceof HTMLInputElement && (this.baseColor = b(t.target.value));
244
+ }}
245
+ @contextmenu=${(t) => {
246
+ t.preventDefault(), t.target instanceof HTMLInputElement && (t.target.value = b("#000").hex(), this.baseColor = void 0);
247
+ }}
248
+ >
249
+ <button
250
+ title='Loads the generated colors'
251
+ @click=${(t) => {
252
+ const n = L(this.combination, { baseColor: this.baseColor, settings: this.settings });
253
+ this.colors = n.colors, n.settings && (this.settings = n.settings);
254
+ }}
255
+ >
256
+ ${p(C)}
257
+ </button>
258
+ </setting-item>
331
259
  `;
332
- }
333
- /** Renders the image option. */
334
- imageOption() {
335
- let hex = '';
336
- let urlRef = createRef();
337
- let sliderRef = createRef();
338
- let fileRef = createRef();
339
- let fileUrl = urlRef.value?.value || '';
340
- let canvasEl;
341
- let tooltipRef = createRef();
342
- let canvasRef = (canvas) => {
343
- if (!(canvas instanceof CanvasImage))
344
- return;
345
- canvasEl = canvas;
346
- canvas.emitter.clear();
347
- canvas.emitter.on('click', async (color) => await copyToClipboard(color.toUpperCase(), CopyFormat.Raw));
348
- canvas.emitter.on('move', (pos) => {
349
- if (!tooltipRef.value)
350
- return;
351
- let tooltip = tooltipRef.value;
352
- // Set tooltip text
353
- tooltip.text = canvas.getCanvasHex(pos.x, pos.y).toUpperCase();
354
- // Set tooltip position
355
- tooltip.setClampedPosition(pos, canvas.getBoundingClientRect());
356
- });
357
- };
358
- const getColors = async () => {
359
- if (!sliderRef.value || !canvasEl)
360
- return;
361
- const sliderInput = sliderRef.value;
362
- const canvasImage = canvasEl;
363
- return await canvasImage.getPalette(+sliderInput.value);
364
- };
365
- const updateColors = async () => {
366
- const colors = await getColors();
367
- if (colors) {
368
- this.colors = colors.map((color) => colorsea(color).hex(0));
369
- this.settings.aliases = [];
370
- }
371
- };
372
- const updateImagePreview = async (url) => {
373
- if (!URL.canParse(url) || !canvasEl)
374
- return;
375
- const canvasImage = canvasEl;
376
- canvasImage.imageURL = url;
377
- await updateColors();
378
- };
379
- return html `
380
- <setting-item
381
- name='Image'
382
- description='Convert image into palette'
383
- >
384
- <input
385
- type='url'
386
- placeholder='Enter URL or select file'
387
- ${ref(urlRef)}
388
- >
389
- <button
390
- title='Right click to clear URL'
260
+ }
261
+ /** Renders the image option. */
262
+ imageOption() {
263
+ let t = "", n = $(), s = $(), o = $(), r = n.value?.value || "", c, h = $(), I = (e) => {
264
+ e instanceof w && (c = e, e.emitter.clear(), e.emitter.on("click", async (i) => await j(i.toUpperCase(), S.Raw)), e.emitter.on("move", (i) => {
265
+ if (!h.value) return;
266
+ let d = h.value;
267
+ d.text = e.getCanvasHex(i.x, i.y).toUpperCase(), d.setClampedPosition(i, e.getBoundingClientRect());
268
+ }));
269
+ };
270
+ const E = async () => {
271
+ if (!s.value || !c) return;
272
+ const e = s.value;
273
+ return await c.getPalette(+e.value);
274
+ }, y = async () => {
275
+ const e = await E();
276
+ e && (this.colors = e.map((i) => b(i).hex(0)), this.settings.aliases = []);
277
+ }, k = async (e) => {
278
+ if (!URL.canParse(e) || !c) return;
279
+ const i = c;
280
+ i.imageURL = e, await y();
281
+ };
282
+ return l`
283
+ <setting-item
284
+ name='Image'
285
+ description='Convert image into palette'
286
+ >
287
+ <input
288
+ type='url'
289
+ placeholder='Enter URL or select file'
290
+ ${m(n)}
291
+ >
292
+ <button
293
+ title='Right click to clear URL'
391
294
  @click=${async (e) => {
392
- try {
393
- if (!fileRef.value)
394
- return;
395
- let fileInput = fileRef.value;
396
- // Check if any text is present, otherwise prompt user to select image
397
- if (fileUrl !== '') {
398
- // Check if URL is valid
399
- if (URL.canParse(fileUrl))
400
- await updateImagePreview(fileUrl);
401
- else
402
- throw new Error('URL provided is not valid.');
403
- }
404
- else
405
- fileInput.click();
406
- }
407
- catch (e) {
408
- // new Notice(e);
409
- }
410
- }}
295
+ try {
296
+ if (!o.value) return;
297
+ let i = o.value;
298
+ if (r !== "")
299
+ if (URL.canParse(r)) await k(r);
300
+ else throw new Error("URL provided is not valid.");
301
+ else i.click();
302
+ } catch {
303
+ }
304
+ }}
411
305
  @contextmenu=${(e) => {
412
- e.preventDefault();
413
- if (!urlRef.value)
414
- return;
415
- const urlInput = urlRef.value;
416
- urlInput.value = '';
417
- }}
418
- >
419
- ${createElement(ArrowUpToLine)}
420
- </button>
421
- <input
422
- type ='file'
423
- accept = 'image/*'
306
+ if (e.preventDefault(), !n.value) return;
307
+ const i = n.value;
308
+ i.value = "";
309
+ }}
310
+ >
311
+ ${p(D)}
312
+ </button>
313
+ <input
314
+ type ='file'
315
+ accept = 'image/*'
424
316
  @change=${(e) => {
425
- try {
426
- const reader = new FileReader();
427
- const file = e.target.files?.[0];
428
- if (file)
429
- reader.readAsDataURL(file);
430
- reader.addEventListener('load', async () => {
431
- if (typeof reader.result === 'string') {
432
- fileUrl = reader.result;
433
- await updateImagePreview(fileUrl);
434
- }
435
- });
436
- reader.addEventListener('error', () => {
437
- throw new Error('Error processing image');
438
- });
439
- }
440
- catch (e) {
441
- // new Notice(e);
442
- }
443
- }}
444
- ${ref(fileRef)}
445
- >
446
- </setting-item>
447
- <setting-item
448
- name='Count'
449
- description='Set the number of colors to generate from the image'
450
- >
451
- <input
452
- id='range-slider'
453
- type='range'
454
- min='4'
455
- max='12'
456
- value='8'
317
+ try {
318
+ const i = new FileReader(), d = e.target.files?.[0];
319
+ d && i.readAsDataURL(d), i.addEventListener("load", async () => {
320
+ typeof i.result == "string" && (r = i.result, await k(r));
321
+ }), i.addEventListener("error", () => {
322
+ throw new Error("Error processing image");
323
+ });
324
+ } catch {
325
+ }
326
+ }}
327
+ ${m(o)}
328
+ >
329
+ </setting-item>
330
+ <setting-item
331
+ name='Count'
332
+ description='Set the number of colors to generate from the image'
333
+ >
334
+ <input
335
+ id='range-slider'
336
+ type='range'
337
+ min='4'
338
+ max='12'
339
+ value='8'
457
340
  @change=${async () => {
458
- await updateColors();
459
- }}
460
- ${ref(sliderRef)}
461
- >
462
- </setting-item>
463
- <tool-tip
464
- trigger='hover'
465
- ${ref(tooltipRef)}
466
- >
467
- <canvas-image
468
- width=${this.palette.getBoundingClientRect().width}
469
- height=${this.palette.getBoundingClientRect().height}
341
+ await y();
342
+ }}
343
+ ${m(s)}
344
+ >
345
+ </setting-item>
346
+ <tool-tip
347
+ trigger='hover'
348
+ ${m(h)}
349
+ >
350
+ <canvas-image
351
+ width=${this.palette.getBoundingClientRect().width}
352
+ height=${this.palette.getBoundingClientRect().height}
470
353
  @mousemove=${(e) => {
471
- if (!(e.target instanceof CanvasImage))
472
- return;
473
- hex = e.target.getCanvasHex(e.clientX, e.clientY);
474
- }}
354
+ e.target instanceof w && (t = e.target.getCanvasHex(e.clientX, e.clientY));
355
+ }}
475
356
  @click=${(e) => {
476
- if (!hex)
477
- return;
478
- this.colors = [...this.colors, hex];
479
- this.settings.aliases = [...this.settings.aliases, ''];
480
- }}
481
- ${ref(canvasRef)}
482
- >
483
- </canvas-image>
484
- </tool-tip>
357
+ t && (this.colors = [...this.colors, t], this.settings.aliases = [...this.settings.aliases, ""]);
358
+ }}
359
+ ${m(I)}
360
+ >
361
+ </canvas-image>
362
+ </tool-tip>
485
363
  `;
486
- }
487
- /** Renders the URL option. */
488
- urlOption() {
489
- let input;
490
- return html `
491
- <setting-item
492
- name='URL'
493
- description='Only coolors.co & colorhunt.co are currently supported'
494
- >
495
- <input
496
- type='url'
497
- placeholder='Enter URL'
498
- @change=${(e) => {
499
- if (!(e.target instanceof HTMLInputElement))
500
- return;
501
- input = e.target;
502
- }}
503
- >
504
- <button
505
- title='Right click to clear URL'
506
- @click=${(e) => {
507
- try {
508
- if (!input.value.match(urlRegex))
509
- throw new Error('URL provided is not valid.');
510
- this.colors = parseUrl(input.value);
511
- this.settings.aliases = [];
512
- }
513
- catch (e) {
514
- // new Notice(e)
515
- }
516
- }}
517
- @contextmenu=${(e) => {
518
- e.preventDefault();
519
- if (input)
520
- input.value = '';
521
- }}
522
- >
523
- ${createElement(Link)}
524
- </button>
525
- </setting-item>
364
+ }
365
+ /** Renders the URL option. */
366
+ urlOption() {
367
+ let t;
368
+ return l`
369
+ <setting-item
370
+ name='URL'
371
+ description='Only coolors.co & colorhunt.co are currently supported'
372
+ >
373
+ <input
374
+ type='url'
375
+ placeholder='Enter URL'
376
+ @change=${(n) => {
377
+ n.target instanceof HTMLInputElement && (t = n.target);
378
+ }}
379
+ >
380
+ <button
381
+ title='Right click to clear URL'
382
+ @click=${(n) => {
383
+ try {
384
+ if (!t.value.match(G)) throw new Error("URL provided is not valid.");
385
+ this.colors = _(t.value), this.settings.aliases = [];
386
+ } catch {
387
+ }
388
+ }}
389
+ @contextmenu=${(n) => {
390
+ n.preventDefault(), t && (t.value = "");
391
+ }}
392
+ >
393
+ ${p(R)}
394
+ </button>
395
+ </setting-item>
526
396
  `;
527
- }
397
+ }
398
+ };
399
+ a.styles = [F];
400
+ g([
401
+ P("#color-palette-editor")
402
+ ], a.prototype, "palette", 2);
403
+ g([
404
+ v({ type: Array })
405
+ ], a.prototype, "colors", 2);
406
+ g([
407
+ v({ type: Object })
408
+ ], a.prototype, "settings", 2);
409
+ g([
410
+ v({ type: String, reflect: !0 })
411
+ ], a.prototype, "selectedInput", 2);
412
+ g([
413
+ v({ type: String })
414
+ ], a.prototype, "combination", 2);
415
+ g([
416
+ v({ type: Object })
417
+ ], a.prototype, "baseColor", 2);
418
+ g([
419
+ H()
420
+ ], a.prototype, "colorPickerDisabled", 2);
421
+ a = g([
422
+ T("color-palette-editor")
423
+ ], a);
424
+ export {
425
+ a as ColorPaletteEditor,
426
+ X as SelectedInput
528
427
  };
529
- __decorate([
530
- query('#color-palette-editor')
531
- ], ColorPaletteEditor.prototype, "palette", void 0);
532
- __decorate([
533
- property({ type: Array })
534
- ], ColorPaletteEditor.prototype, "colors", void 0);
535
- __decorate([
536
- property({ type: Object })
537
- ], ColorPaletteEditor.prototype, "settings", void 0);
538
- __decorate([
539
- property({ type: String, reflect: true })
540
- ], ColorPaletteEditor.prototype, "selectedInput", void 0);
541
- __decorate([
542
- property({ type: String })
543
- ], ColorPaletteEditor.prototype, "combination", void 0);
544
- __decorate([
545
- property({ type: Object })
546
- ], ColorPaletteEditor.prototype, "baseColor", void 0);
547
- __decorate([
548
- state()
549
- ], ColorPaletteEditor.prototype, "colorPickerDisabled", void 0);
550
- ColorPaletteEditor = __decorate([
551
- customElement('color-palette-editor')
552
- ], ColorPaletteEditor);
553
- export { ColorPaletteEditor };