@luminescent/ui-qwik 6.8.2 → 6.8.3-2

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 (139) hide show
  1. package/lib/components/docs/Anchor.d.ts +4 -0
  2. package/lib/components/docs/Blobs.d.ts +4 -0
  3. package/lib/components/docs/ColorPicker.d.ts +4 -0
  4. package/lib/components/docs/Dropdown.d.ts +4 -0
  5. package/lib/components/docs/IconsLogos.d.ts +4 -0
  6. package/lib/components/docs/Nav.d.ts +4 -0
  7. package/lib/components/docs/NumberInput.d.ts +4 -0
  8. package/lib/components/docs/RangeInput.d.ts +4 -0
  9. package/lib/components/docs/SelectMenu.d.ts +4 -0
  10. package/lib/components/docs/Settings.d.ts +2 -0
  11. package/lib/components/docs/Sidebar.d.ts +4 -0
  12. package/lib/components/docs/Toggle.d.ts +4 -0
  13. package/lib/components/docs/lum-btn.d.ts +4 -0
  14. package/lib/components/docs/lum-card.d.ts +4 -0
  15. package/lib/components/docs/lum-classes.d.ts +4 -0
  16. package/lib/components/docs/lum-input.d.ts +4 -0
  17. package/{lib-types → lib}/components/elements/Anchor.d.ts +2 -2
  18. package/lib/components/elements/Anchor.qwik.cjs +26 -0
  19. package/lib/components/elements/Anchor.qwik.mjs +26 -0
  20. package/{lib-types → lib}/components/elements/Blobs.d.ts +1 -1
  21. package/lib/components/elements/Blobs.qwik.cjs +191 -0
  22. package/lib/components/elements/Blobs.qwik.mjs +191 -0
  23. package/{lib-types → lib}/components/elements/ColorPicker.d.ts +2 -2
  24. package/lib/components/elements/ColorPicker.qwik.cjs +314 -0
  25. package/lib/components/elements/ColorPicker.qwik.mjs +314 -0
  26. package/{lib-types → lib}/components/elements/Dropdown.d.ts +2 -2
  27. package/lib/components/elements/Dropdown.qwik.cjs +31 -0
  28. package/lib/components/elements/Dropdown.qwik.mjs +31 -0
  29. package/{lib-types → lib}/components/elements/Nav.d.ts +2 -2
  30. package/lib/components/elements/Nav.qwik.cjs +98 -0
  31. package/lib/components/elements/Nav.qwik.mjs +98 -0
  32. package/{lib-types → lib}/components/elements/NumberInput.d.ts +3 -3
  33. package/lib/components/elements/NumberInput.qwik.cjs +87 -0
  34. package/lib/components/elements/NumberInput.qwik.mjs +87 -0
  35. package/{lib-types → lib}/components/elements/RangeInput.d.ts +3 -3
  36. package/lib/components/elements/RangeInput.qwik.cjs +77 -0
  37. package/lib/components/elements/RangeInput.qwik.mjs +77 -0
  38. package/{lib-types → lib}/components/elements/SelectMenu.d.ts +3 -3
  39. package/lib/components/elements/SelectMenu.qwik.cjs +134 -0
  40. package/lib/components/elements/SelectMenu.qwik.mjs +134 -0
  41. package/{lib-types → lib}/components/elements/Sidebar.d.ts +2 -2
  42. package/lib/components/elements/Sidebar.qwik.cjs +37 -0
  43. package/lib/components/elements/Sidebar.qwik.mjs +37 -0
  44. package/{lib-types → lib}/components/elements/Toggle.d.ts +2 -2
  45. package/lib/components/elements/Toggle.qwik.cjs +39 -0
  46. package/lib/components/elements/Toggle.qwik.mjs +39 -0
  47. package/lib/components/functions.qwik.cjs +18 -0
  48. package/lib/components/functions.qwik.mjs +18 -0
  49. package/{lib-types → lib}/components/logos/Birdflop.d.ts +1 -1
  50. package/lib/components/logos/Birdflop.qwik.cjs +73 -0
  51. package/lib/components/logos/Birdflop.qwik.mjs +73 -0
  52. package/lib/components/logos/Discord.d.ts +2 -0
  53. package/lib/components/logos/Discord.qwik.cjs +18 -0
  54. package/lib/components/logos/Discord.qwik.mjs +18 -0
  55. package/lib/components/logos/Fabric.d.ts +2 -0
  56. package/lib/components/logos/Fabric.qwik.cjs +32 -0
  57. package/lib/components/logos/Fabric.qwik.mjs +32 -0
  58. package/lib/components/logos/Forge.d.ts +2 -0
  59. package/lib/components/logos/Forge.qwik.cjs +31 -0
  60. package/lib/components/logos/Forge.qwik.mjs +31 -0
  61. package/{lib-types → lib}/components/logos/IconProps.d.ts +1 -1
  62. package/lib/components/logos/Luminescent.d.ts +3 -0
  63. package/lib/components/logos/Luminescent.qwik.cjs +143 -0
  64. package/lib/components/logos/Luminescent.qwik.mjs +143 -0
  65. package/lib/components/logos/Paper.d.ts +2 -0
  66. package/lib/components/logos/Paper.qwik.cjs +40 -0
  67. package/lib/components/logos/Paper.qwik.mjs +40 -0
  68. package/{lib-types/components/logos/Waterfall.d.ts → lib/components/logos/Pterodactyl.d.ts} +1 -1
  69. package/lib/components/logos/Pterodactyl.qwik.cjs +35 -0
  70. package/lib/components/logos/Pterodactyl.qwik.mjs +35 -0
  71. package/lib/components/logos/Purpur.d.ts +2 -0
  72. package/lib/components/logos/Purpur.qwik.cjs +76 -0
  73. package/lib/components/logos/Purpur.qwik.mjs +76 -0
  74. package/{lib-types/components/logos/Purpur.d.ts → lib/components/logos/Velocity.d.ts} +1 -1
  75. package/lib/components/logos/Velocity.qwik.cjs +27 -0
  76. package/lib/components/logos/Velocity.qwik.mjs +27 -0
  77. package/{lib-types/components/logos/Discord.d.ts → lib/components/logos/Waterfall.d.ts} +1 -1
  78. package/lib/components/logos/Waterfall.qwik.cjs +21 -0
  79. package/lib/components/logos/Waterfall.qwik.mjs +21 -0
  80. package/lib/index.qwik.cjs +47 -1730
  81. package/lib/index.qwik.mjs +21 -1704
  82. package/lib/svg/ChevronDown.d.ts +2 -0
  83. package/lib/svg/ChevronDown.qwik.cjs +23 -0
  84. package/lib/svg/ChevronDown.qwik.mjs +23 -0
  85. package/lib/svg/Link.d.ts +2 -0
  86. package/lib/svg/Link.qwik.cjs +34 -0
  87. package/lib/svg/Link.qwik.mjs +34 -0
  88. package/lib/svg/Menu.d.ts +2 -0
  89. package/lib/svg/Menu.qwik.cjs +31 -0
  90. package/lib/svg/Menu.qwik.mjs +31 -0
  91. package/lib/svg/Minus.d.ts +2 -0
  92. package/lib/svg/Minus.qwik.cjs +23 -0
  93. package/lib/svg/Minus.qwik.mjs +23 -0
  94. package/lib/svg/Plus.d.ts +2 -0
  95. package/lib/svg/Plus.qwik.cjs +28 -0
  96. package/lib/svg/Plus.qwik.mjs +28 -0
  97. package/{lib-types/svg/Minus.d.ts → lib/svg/Shuffle.d.ts} +1 -1
  98. package/lib/svg/Shuffle.qwik.cjs +37 -0
  99. package/lib/svg/Shuffle.qwik.mjs +37 -0
  100. package/lib/utils/color.qwik.cjs +134 -0
  101. package/lib/utils/color.qwik.mjs +134 -0
  102. package/package.json +22 -25
  103. package/LICENSE +0 -661
  104. package/lib-types/components/docs/Anchor.d.ts +0 -4
  105. package/lib-types/components/docs/Blobs.d.ts +0 -4
  106. package/lib-types/components/docs/ColorPicker.d.ts +0 -4
  107. package/lib-types/components/docs/Dropdown.d.ts +0 -4
  108. package/lib-types/components/docs/IconsLogos.d.ts +0 -4
  109. package/lib-types/components/docs/Nav.d.ts +0 -4
  110. package/lib-types/components/docs/NumberInput.d.ts +0 -4
  111. package/lib-types/components/docs/RangeInput.d.ts +0 -4
  112. package/lib-types/components/docs/SelectMenu.d.ts +0 -4
  113. package/lib-types/components/docs/Settings.d.ts +0 -2
  114. package/lib-types/components/docs/Sidebar.d.ts +0 -4
  115. package/lib-types/components/docs/Toggle.d.ts +0 -4
  116. package/lib-types/components/docs/lum-btn.d.ts +0 -4
  117. package/lib-types/components/docs/lum-card.d.ts +0 -4
  118. package/lib-types/components/docs/lum-classes.d.ts +0 -4
  119. package/lib-types/components/docs/lum-input.d.ts +0 -4
  120. package/lib-types/components/logos/Fabric.d.ts +0 -2
  121. package/lib-types/components/logos/Forge.d.ts +0 -2
  122. package/lib-types/components/logos/Luminescent.d.ts +0 -3
  123. package/lib-types/components/logos/Paper.d.ts +0 -2
  124. package/lib-types/components/logos/Pterodactyl.d.ts +0 -2
  125. package/lib-types/components/logos/Velocity.d.ts +0 -2
  126. package/lib-types/entry.dev.d.ts +0 -2
  127. package/lib-types/entry.ssr.d.ts +0 -14
  128. package/lib-types/root.d.ts +0 -3
  129. package/lib-types/svg/ChevronDown.d.ts +0 -2
  130. package/lib-types/svg/Link.d.ts +0 -2
  131. package/lib-types/svg/Menu.d.ts +0 -2
  132. package/lib-types/svg/Plus.d.ts +0 -2
  133. package/lib-types/svg/Shuffle.d.ts +0 -2
  134. package/tailwind.config.js +0 -94
  135. /package/{lib-types → lib}/components/elements.d.ts +0 -0
  136. /package/{lib-types → lib}/components/functions.d.ts +0 -0
  137. /package/{lib-types → lib}/components/logos.d.ts +0 -0
  138. /package/{lib-types → lib}/index.d.ts +0 -0
  139. /package/{lib-types → lib}/utils/color.d.ts +0 -0
@@ -0,0 +1,314 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("@qwik.dev/core/jsx-runtime");
4
+ const core = require("@qwik.dev/core");
5
+ const color = require("../../utils/color.qwik.cjs");
6
+ const Shuffle = require("../../svg/Shuffle.qwik.cjs");
7
+ const ColorPicker = core.component$(({ id, value = "#000000", colors = [
8
+ "#FAEDCB",
9
+ "#C9E4DE",
10
+ "#C6DEF1",
11
+ "#DBCDF0",
12
+ "#F2C6DE",
13
+ "#FCD05C",
14
+ "#5FE2C5",
15
+ "#4498DB",
16
+ "#9863E7",
17
+ "#E43A96",
18
+ "#000000",
19
+ "#555555",
20
+ "#AAAAAA",
21
+ "#FFFFFF"
22
+ ], onInput$, preview = "left", horizontal, showInput = true, opacity, ...props }) => {
23
+ const height = 150;
24
+ const width = height - 25;
25
+ const maxHue = height - 2;
26
+ const hsvColor = color.rgbToHsv(color.hexToRgba(value));
27
+ const store = core.useStore({
28
+ hue: {
29
+ position: hsvColor.h * maxHue,
30
+ color: color.rgbToHex(color.hsvToRgb({
31
+ h: hsvColor.h,
32
+ s: 1,
33
+ v: 1
34
+ }))
35
+ },
36
+ opacity: {
37
+ position: hsvColor.a !== void 0 ? (1 - hsvColor.a) * maxHue : 0
38
+ },
39
+ bPosition: (1 - hsvColor.v) * maxHue,
40
+ sPosition: hsvColor.s * width,
41
+ value
42
+ });
43
+ const setColor = core.$(async (color$1) => {
44
+ if (!/^#[0-9a-f]{0,8}$/i.test(color$1)) return;
45
+ const hsv = color.rgbToHsv(color.hexToRgba(color$1));
46
+ store.hue.position = hsv.h * maxHue;
47
+ store.hue.color = color.rgbToHex(color.hsvToRgb({
48
+ h: hsv.h,
49
+ s: 1,
50
+ v: 1,
51
+ a: hsv.a
52
+ }));
53
+ store.sPosition = hsv.s * width;
54
+ store.bPosition = (1 - hsv.v) * maxHue;
55
+ store.value = color$1;
56
+ await onInput$?.(store.value);
57
+ });
58
+ const hueChange = core.$(async (e, hOffset) => {
59
+ const { y } = color.getMousePosition(e);
60
+ store.hue.position = color.clamp(maxHue - (y - hOffset), 0, maxHue);
61
+ const hsvColor2 = color.rgbToHsv(color.hexToRgba(store.value));
62
+ const h = store.hue.position / maxHue;
63
+ hsvColor2.h = h;
64
+ store.hue.color = color.rgbToHex(color.hsvToRgb({
65
+ h,
66
+ s: 1,
67
+ v: 1,
68
+ a: hsvColor2.a
69
+ }));
70
+ store.value = color.rgbToHex(color.hsvToRgb(hsvColor2));
71
+ await onInput$?.(store.value);
72
+ });
73
+ const hueMouseDown = core.$(async (e, el) => {
74
+ const hOffset = el.getBoundingClientRect().top;
75
+ await hueChange(e, hOffset);
76
+ const eventListener = (e2) => void hueChange(e2, hOffset);
77
+ window.addEventListener("mousemove", eventListener);
78
+ window.addEventListener("touchmove", eventListener);
79
+ const mouseUpListener = () => {
80
+ window.removeEventListener("mousemove", eventListener);
81
+ window.removeEventListener("touchmove", eventListener);
82
+ window.removeEventListener("mouseup", mouseUpListener);
83
+ window.removeEventListener("touchend", mouseUpListener);
84
+ };
85
+ window.addEventListener("mouseup", mouseUpListener);
86
+ window.addEventListener("touchend", mouseUpListener);
87
+ });
88
+ const sbChange = core.$(async (e, hOffset) => {
89
+ const { x, y } = color.getMousePosition(e);
90
+ store.bPosition = color.clamp(y - hOffset.top, 0, maxHue);
91
+ store.sPosition = color.clamp(x - hOffset.left, 0, width);
92
+ const s = store.sPosition / width;
93
+ const v = 1 - store.bPosition / maxHue;
94
+ store.value = color.rgbToHex(color.hsvToRgb({
95
+ h: store.hue.position / maxHue,
96
+ s,
97
+ v,
98
+ a: store.opacity.position !== void 0 ? 1 - store.opacity.position / maxHue : 1
99
+ }));
100
+ await onInput$?.(store.value);
101
+ });
102
+ const sbMouseDown = core.$(async (e, el) => {
103
+ const offset = el.getBoundingClientRect();
104
+ await sbChange(e, offset);
105
+ const eventListener = (e2) => void sbChange(e2, offset);
106
+ window.addEventListener("mousemove", eventListener);
107
+ window.addEventListener("touchmove", eventListener);
108
+ const mouseUpListener = () => {
109
+ window.removeEventListener("mousemove", eventListener);
110
+ window.removeEventListener("touchmove", eventListener);
111
+ window.removeEventListener("mouseup", mouseUpListener);
112
+ window.removeEventListener("touchend", mouseUpListener);
113
+ };
114
+ window.addEventListener("mouseup", mouseUpListener);
115
+ window.addEventListener("touchend", mouseUpListener);
116
+ });
117
+ const opacityChange = core.$(async (e, hOffset) => {
118
+ const { x } = color.getMousePosition(e);
119
+ store.opacity.position = color.clamp(x - hOffset.left, 0, maxHue);
120
+ const a = 1 - store.opacity.position / maxHue;
121
+ const hsvColor2 = color.rgbToHsv(color.hexToRgba(store.value));
122
+ hsvColor2.a = a;
123
+ store.value = color.rgbToHex(color.hsvToRgb(hsvColor2));
124
+ await onInput$?.(store.value);
125
+ });
126
+ const opacityMouseDown = core.$(async (e, el) => {
127
+ const offset = el.getBoundingClientRect();
128
+ await opacityChange(e, offset);
129
+ const eventListener = (e2) => void opacityChange(e2, offset);
130
+ window.addEventListener("mousemove", eventListener);
131
+ window.addEventListener("touchmove", eventListener);
132
+ const mouseUpListener = () => {
133
+ window.removeEventListener("mousemove", eventListener);
134
+ window.removeEventListener("touchmove", eventListener);
135
+ window.removeEventListener("mouseup", mouseUpListener);
136
+ window.removeEventListener("touchend", mouseUpListener);
137
+ };
138
+ window.addEventListener("mouseup", mouseUpListener);
139
+ window.addEventListener("touchend", mouseUpListener);
140
+ });
141
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", {
142
+ class: {
143
+ "lum-card touch-none p-4": true,
144
+ "flex-col": !horizontal,
145
+ ...props.class
146
+ },
147
+ id,
148
+ onInput$: async (e, el) => {
149
+ if (!el.dataset.value) return;
150
+ await setColor(el.dataset.value);
151
+ },
152
+ children: [
153
+ /* @__PURE__ */ jsxRuntime.jsxs("div", {
154
+ class: "flex gap-4",
155
+ children: [
156
+ /* @__PURE__ */ jsxRuntime.jsxs("div", {
157
+ class: "relative h-37.5 w-31.25 rounded-md",
158
+ style: {
159
+ background: `linear-gradient(to right, #FFFFFF, ${store.hue.color})`
160
+ },
161
+ onMouseDown$: sbMouseDown,
162
+ onTouchStart$: sbMouseDown,
163
+ "preventdefault:mousedown": true,
164
+ "preventdefault:touchstart": true,
165
+ children: [
166
+ /* @__PURE__ */ jsxRuntime.jsx("div", {
167
+ class: "h-37.5 w-31.25 rounded-md border border-gray-700 bg-linear-to-b from-transparent to-black"
168
+ }),
169
+ /* @__PURE__ */ jsxRuntime.jsx("div", {
170
+ class: {
171
+ "absolute -top-2 -left-2 h-4 w-4 rounded-md border lum-bg drop-shadow-lg": true
172
+ },
173
+ style: {
174
+ "--bg-color": store.value,
175
+ transform: `translate(${store.sPosition}px, ${store.bPosition}px)`
176
+ }
177
+ })
178
+ ]
179
+ }),
180
+ /* @__PURE__ */ jsxRuntime.jsx("div", {
181
+ class: "relative h-37.5 w-2 rounded-md border border-gray-700",
182
+ style: {
183
+ background: "linear-gradient(to bottom, #ff0000, #ff00ff, #0000ff, #00ffff, #00ff00, #ffff00, #ff0000)"
184
+ },
185
+ onMouseDown$: hueMouseDown,
186
+ onTouchStart$: hueMouseDown,
187
+ "preventdefault:mousedown": true,
188
+ "preventdefault:touchstart": true,
189
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", {
190
+ class: "absolute -bottom-2 -left-1.25 h-4 w-4 rounded-md lum-bg! bg-[#ff0000] ",
191
+ style: {
192
+ transform: `translateY(${-store.hue.position}px)`,
193
+ "--bg-color": store.hue.color
194
+ }
195
+ })
196
+ })
197
+ ]
198
+ }),
199
+ opacity && /* @__PURE__ */ jsxRuntime.jsxs("div", {
200
+ class: "relative h-2 w-full rounded-md",
201
+ onMouseDown$: opacityMouseDown,
202
+ onTouchStart$: opacityMouseDown,
203
+ "preventdefault:mousedown": true,
204
+ "preventdefault:touchstart": true,
205
+ style: {
206
+ backgroundColor: "white",
207
+ backgroundImage: `
208
+ linear-gradient(45deg, #ccc 25%, transparent 25%),
209
+ linear-gradient(135deg, #ccc 25%, transparent 25%),
210
+ linear-gradient(45deg, transparent 75%, #ccc 75%),
211
+ linear-gradient(135deg, transparent 75%, #ccc 75%);
212
+ `,
213
+ backgroundSize: "8px 8px",
214
+ backgroundPosition: "0 0, 4px 0, 4px -4px, 0 4px"
215
+ },
216
+ children: [
217
+ /* @__PURE__ */ jsxRuntime.jsx("div", {
218
+ class: "alsolute inset-0 h-2 w-full rounded-md border border-gray-700",
219
+ style: {
220
+ background: `linear-gradient(to right, ${store.value}, transparent)`
221
+ }
222
+ }),
223
+ /* @__PURE__ */ jsxRuntime.jsx("div", {
224
+ class: "absolute -bottom-1.25 -left-1.25 h-4 w-4 rounded-md",
225
+ style: {
226
+ transform: `translateX(${store.opacity.position ?? 1}px)`,
227
+ backgroundColor: store.value,
228
+ backgroundImage: `
229
+ linear-gradient(45deg, #ccc4 25%, transparent 25%),
230
+ linear-gradient(135deg, #ccc4 25%, transparent 25%),
231
+ linear-gradient(45deg, transparent 75%, #ccc4 75%),
232
+ linear-gradient(135deg, transparent 75%, #ccc4 75%);
233
+ `,
234
+ backgroundSize: "8px 8px",
235
+ backgroundPosition: "0 0, 4px 0, 4px -4px, 0 4px"
236
+ }
237
+ })
238
+ ]
239
+ }),
240
+ /* @__PURE__ */ jsxRuntime.jsxs("div", {
241
+ class: "flex w-37.5 flex-wrap justify-between gap-1",
242
+ children: [
243
+ showInput && /* @__PURE__ */ jsxRuntime.jsxs("div", {
244
+ class: {
245
+ "mb-2 flex w-37.5 border-b border-b-gray-700 pb-3": true,
246
+ "flex-row gap-1": preview == "left",
247
+ "flex-row-reverse gap-1": preview == "right",
248
+ "flex-col": preview == "top",
249
+ "flex-col-reverse": preview == "bottom"
250
+ },
251
+ children: [
252
+ preview != "full" && /* @__PURE__ */ jsxRuntime.jsx("div", {
253
+ class: {
254
+ "border border-gray-700 rounded-sm": true,
255
+ "aspect-square h-full": preview == "left" || preview == "right",
256
+ "h-3 w-full": preview == "top" || preview == "bottom",
257
+ "rounded-b-none": preview == "top",
258
+ "rounded-t-none": preview == "bottom"
259
+ },
260
+ style: {
261
+ backgroundColor: `${store.value}`
262
+ }
263
+ }),
264
+ /* @__PURE__ */ jsxRuntime.jsx("input", {
265
+ class: {
266
+ "lum-input w-full p-1 text-xs rounded-sm": true,
267
+ "rounded-t-none border-t-0": preview == "top",
268
+ "rounded-b-none border-b-0": preview == "bottom"
269
+ },
270
+ value: store.value,
271
+ style: preview == "full" ? {
272
+ backgroundColor: `${store.value}`,
273
+ color: color.getBrightness(color.hexToRgba(store.value)) > 0.5 ? "black" : "white"
274
+ } : {},
275
+ onInput$: async (e, el) => {
276
+ await setColor(el.value);
277
+ }
278
+ })
279
+ ]
280
+ }),
281
+ colors.map((color2, i) => {
282
+ return /* @__PURE__ */ jsxRuntime.jsx("button", {
283
+ type: "button",
284
+ name: color2,
285
+ class: {
286
+ "lum-btn rounded-sm h-[1.6rem] w-[1.6rem] p-0 lum-bg hover:brightness-150": true,
287
+ "border-lum-accent": color2 === store.value
288
+ },
289
+ style: {
290
+ "--bg-color": color2
291
+ },
292
+ onClick$: async () => {
293
+ await setColor(color2);
294
+ }
295
+ }, i);
296
+ }),
297
+ /* @__PURE__ */ jsxRuntime.jsx("button", {
298
+ type: "button",
299
+ class: "lum-btn rounded-sm h-[1.6rem] w-[1.6rem] p-0.5",
300
+ name: "Randomize",
301
+ onClick$: async () => {
302
+ const color2 = `#${Math.floor(Math.random() * 16777215).toString(16)}`;
303
+ await setColor(color2);
304
+ },
305
+ children: /* @__PURE__ */ jsxRuntime.jsx(Shuffle.Shuffle, {
306
+ class: "p-0.5 pl-0.5 text-lum-text"
307
+ })
308
+ })
309
+ ]
310
+ })
311
+ ]
312
+ });
313
+ });
314
+ exports.ColorPicker = ColorPicker;
@@ -0,0 +1,314 @@
1
+ import { jsxs, jsx } from "@qwik.dev/core/jsx-runtime";
2
+ import { component$, useStore, $ } from "@qwik.dev/core";
3
+ import { rgbToHsv, hexToRgba, rgbToHex, hsvToRgb, getMousePosition, clamp, getBrightness } from "../../utils/color.qwik.mjs";
4
+ import { Shuffle } from "../../svg/Shuffle.qwik.mjs";
5
+ const ColorPicker = component$(({ id, value = "#000000", colors = [
6
+ "#FAEDCB",
7
+ "#C9E4DE",
8
+ "#C6DEF1",
9
+ "#DBCDF0",
10
+ "#F2C6DE",
11
+ "#FCD05C",
12
+ "#5FE2C5",
13
+ "#4498DB",
14
+ "#9863E7",
15
+ "#E43A96",
16
+ "#000000",
17
+ "#555555",
18
+ "#AAAAAA",
19
+ "#FFFFFF"
20
+ ], onInput$, preview = "left", horizontal, showInput = true, opacity, ...props }) => {
21
+ const height = 150;
22
+ const width = height - 25;
23
+ const maxHue = height - 2;
24
+ const hsvColor = rgbToHsv(hexToRgba(value));
25
+ const store = useStore({
26
+ hue: {
27
+ position: hsvColor.h * maxHue,
28
+ color: rgbToHex(hsvToRgb({
29
+ h: hsvColor.h,
30
+ s: 1,
31
+ v: 1
32
+ }))
33
+ },
34
+ opacity: {
35
+ position: hsvColor.a !== void 0 ? (1 - hsvColor.a) * maxHue : 0
36
+ },
37
+ bPosition: (1 - hsvColor.v) * maxHue,
38
+ sPosition: hsvColor.s * width,
39
+ value
40
+ });
41
+ const setColor = $(async (color) => {
42
+ if (!/^#[0-9a-f]{0,8}$/i.test(color)) return;
43
+ const hsv = rgbToHsv(hexToRgba(color));
44
+ store.hue.position = hsv.h * maxHue;
45
+ store.hue.color = rgbToHex(hsvToRgb({
46
+ h: hsv.h,
47
+ s: 1,
48
+ v: 1,
49
+ a: hsv.a
50
+ }));
51
+ store.sPosition = hsv.s * width;
52
+ store.bPosition = (1 - hsv.v) * maxHue;
53
+ store.value = color;
54
+ await onInput$?.(store.value);
55
+ });
56
+ const hueChange = $(async (e, hOffset) => {
57
+ const { y } = getMousePosition(e);
58
+ store.hue.position = clamp(maxHue - (y - hOffset), 0, maxHue);
59
+ const hsvColor2 = rgbToHsv(hexToRgba(store.value));
60
+ const h = store.hue.position / maxHue;
61
+ hsvColor2.h = h;
62
+ store.hue.color = rgbToHex(hsvToRgb({
63
+ h,
64
+ s: 1,
65
+ v: 1,
66
+ a: hsvColor2.a
67
+ }));
68
+ store.value = rgbToHex(hsvToRgb(hsvColor2));
69
+ await onInput$?.(store.value);
70
+ });
71
+ const hueMouseDown = $(async (e, el) => {
72
+ const hOffset = el.getBoundingClientRect().top;
73
+ await hueChange(e, hOffset);
74
+ const eventListener = (e2) => void hueChange(e2, hOffset);
75
+ window.addEventListener("mousemove", eventListener);
76
+ window.addEventListener("touchmove", eventListener);
77
+ const mouseUpListener = () => {
78
+ window.removeEventListener("mousemove", eventListener);
79
+ window.removeEventListener("touchmove", eventListener);
80
+ window.removeEventListener("mouseup", mouseUpListener);
81
+ window.removeEventListener("touchend", mouseUpListener);
82
+ };
83
+ window.addEventListener("mouseup", mouseUpListener);
84
+ window.addEventListener("touchend", mouseUpListener);
85
+ });
86
+ const sbChange = $(async (e, hOffset) => {
87
+ const { x, y } = getMousePosition(e);
88
+ store.bPosition = clamp(y - hOffset.top, 0, maxHue);
89
+ store.sPosition = clamp(x - hOffset.left, 0, width);
90
+ const s = store.sPosition / width;
91
+ const v = 1 - store.bPosition / maxHue;
92
+ store.value = rgbToHex(hsvToRgb({
93
+ h: store.hue.position / maxHue,
94
+ s,
95
+ v,
96
+ a: store.opacity.position !== void 0 ? 1 - store.opacity.position / maxHue : 1
97
+ }));
98
+ await onInput$?.(store.value);
99
+ });
100
+ const sbMouseDown = $(async (e, el) => {
101
+ const offset = el.getBoundingClientRect();
102
+ await sbChange(e, offset);
103
+ const eventListener = (e2) => void sbChange(e2, offset);
104
+ window.addEventListener("mousemove", eventListener);
105
+ window.addEventListener("touchmove", eventListener);
106
+ const mouseUpListener = () => {
107
+ window.removeEventListener("mousemove", eventListener);
108
+ window.removeEventListener("touchmove", eventListener);
109
+ window.removeEventListener("mouseup", mouseUpListener);
110
+ window.removeEventListener("touchend", mouseUpListener);
111
+ };
112
+ window.addEventListener("mouseup", mouseUpListener);
113
+ window.addEventListener("touchend", mouseUpListener);
114
+ });
115
+ const opacityChange = $(async (e, hOffset) => {
116
+ const { x } = getMousePosition(e);
117
+ store.opacity.position = clamp(x - hOffset.left, 0, maxHue);
118
+ const a = 1 - store.opacity.position / maxHue;
119
+ const hsvColor2 = rgbToHsv(hexToRgba(store.value));
120
+ hsvColor2.a = a;
121
+ store.value = rgbToHex(hsvToRgb(hsvColor2));
122
+ await onInput$?.(store.value);
123
+ });
124
+ const opacityMouseDown = $(async (e, el) => {
125
+ const offset = el.getBoundingClientRect();
126
+ await opacityChange(e, offset);
127
+ const eventListener = (e2) => void opacityChange(e2, offset);
128
+ window.addEventListener("mousemove", eventListener);
129
+ window.addEventListener("touchmove", eventListener);
130
+ const mouseUpListener = () => {
131
+ window.removeEventListener("mousemove", eventListener);
132
+ window.removeEventListener("touchmove", eventListener);
133
+ window.removeEventListener("mouseup", mouseUpListener);
134
+ window.removeEventListener("touchend", mouseUpListener);
135
+ };
136
+ window.addEventListener("mouseup", mouseUpListener);
137
+ window.addEventListener("touchend", mouseUpListener);
138
+ });
139
+ return /* @__PURE__ */ jsxs("div", {
140
+ class: {
141
+ "lum-card touch-none p-4": true,
142
+ "flex-col": !horizontal,
143
+ ...props.class
144
+ },
145
+ id,
146
+ onInput$: async (e, el) => {
147
+ if (!el.dataset.value) return;
148
+ await setColor(el.dataset.value);
149
+ },
150
+ children: [
151
+ /* @__PURE__ */ jsxs("div", {
152
+ class: "flex gap-4",
153
+ children: [
154
+ /* @__PURE__ */ jsxs("div", {
155
+ class: "relative h-37.5 w-31.25 rounded-md",
156
+ style: {
157
+ background: `linear-gradient(to right, #FFFFFF, ${store.hue.color})`
158
+ },
159
+ onMouseDown$: sbMouseDown,
160
+ onTouchStart$: sbMouseDown,
161
+ "preventdefault:mousedown": true,
162
+ "preventdefault:touchstart": true,
163
+ children: [
164
+ /* @__PURE__ */ jsx("div", {
165
+ class: "h-37.5 w-31.25 rounded-md border border-gray-700 bg-linear-to-b from-transparent to-black"
166
+ }),
167
+ /* @__PURE__ */ jsx("div", {
168
+ class: {
169
+ "absolute -top-2 -left-2 h-4 w-4 rounded-md border lum-bg drop-shadow-lg": true
170
+ },
171
+ style: {
172
+ "--bg-color": store.value,
173
+ transform: `translate(${store.sPosition}px, ${store.bPosition}px)`
174
+ }
175
+ })
176
+ ]
177
+ }),
178
+ /* @__PURE__ */ jsx("div", {
179
+ class: "relative h-37.5 w-2 rounded-md border border-gray-700",
180
+ style: {
181
+ background: "linear-gradient(to bottom, #ff0000, #ff00ff, #0000ff, #00ffff, #00ff00, #ffff00, #ff0000)"
182
+ },
183
+ onMouseDown$: hueMouseDown,
184
+ onTouchStart$: hueMouseDown,
185
+ "preventdefault:mousedown": true,
186
+ "preventdefault:touchstart": true,
187
+ children: /* @__PURE__ */ jsx("div", {
188
+ class: "absolute -bottom-2 -left-1.25 h-4 w-4 rounded-md lum-bg! bg-[#ff0000] ",
189
+ style: {
190
+ transform: `translateY(${-store.hue.position}px)`,
191
+ "--bg-color": store.hue.color
192
+ }
193
+ })
194
+ })
195
+ ]
196
+ }),
197
+ opacity && /* @__PURE__ */ jsxs("div", {
198
+ class: "relative h-2 w-full rounded-md",
199
+ onMouseDown$: opacityMouseDown,
200
+ onTouchStart$: opacityMouseDown,
201
+ "preventdefault:mousedown": true,
202
+ "preventdefault:touchstart": true,
203
+ style: {
204
+ backgroundColor: "white",
205
+ backgroundImage: `
206
+ linear-gradient(45deg, #ccc 25%, transparent 25%),
207
+ linear-gradient(135deg, #ccc 25%, transparent 25%),
208
+ linear-gradient(45deg, transparent 75%, #ccc 75%),
209
+ linear-gradient(135deg, transparent 75%, #ccc 75%);
210
+ `,
211
+ backgroundSize: "8px 8px",
212
+ backgroundPosition: "0 0, 4px 0, 4px -4px, 0 4px"
213
+ },
214
+ children: [
215
+ /* @__PURE__ */ jsx("div", {
216
+ class: "alsolute inset-0 h-2 w-full rounded-md border border-gray-700",
217
+ style: {
218
+ background: `linear-gradient(to right, ${store.value}, transparent)`
219
+ }
220
+ }),
221
+ /* @__PURE__ */ jsx("div", {
222
+ class: "absolute -bottom-1.25 -left-1.25 h-4 w-4 rounded-md",
223
+ style: {
224
+ transform: `translateX(${store.opacity.position ?? 1}px)`,
225
+ backgroundColor: store.value,
226
+ backgroundImage: `
227
+ linear-gradient(45deg, #ccc4 25%, transparent 25%),
228
+ linear-gradient(135deg, #ccc4 25%, transparent 25%),
229
+ linear-gradient(45deg, transparent 75%, #ccc4 75%),
230
+ linear-gradient(135deg, transparent 75%, #ccc4 75%);
231
+ `,
232
+ backgroundSize: "8px 8px",
233
+ backgroundPosition: "0 0, 4px 0, 4px -4px, 0 4px"
234
+ }
235
+ })
236
+ ]
237
+ }),
238
+ /* @__PURE__ */ jsxs("div", {
239
+ class: "flex w-37.5 flex-wrap justify-between gap-1",
240
+ children: [
241
+ showInput && /* @__PURE__ */ jsxs("div", {
242
+ class: {
243
+ "mb-2 flex w-37.5 border-b border-b-gray-700 pb-3": true,
244
+ "flex-row gap-1": preview == "left",
245
+ "flex-row-reverse gap-1": preview == "right",
246
+ "flex-col": preview == "top",
247
+ "flex-col-reverse": preview == "bottom"
248
+ },
249
+ children: [
250
+ preview != "full" && /* @__PURE__ */ jsx("div", {
251
+ class: {
252
+ "border border-gray-700 rounded-sm": true,
253
+ "aspect-square h-full": preview == "left" || preview == "right",
254
+ "h-3 w-full": preview == "top" || preview == "bottom",
255
+ "rounded-b-none": preview == "top",
256
+ "rounded-t-none": preview == "bottom"
257
+ },
258
+ style: {
259
+ backgroundColor: `${store.value}`
260
+ }
261
+ }),
262
+ /* @__PURE__ */ jsx("input", {
263
+ class: {
264
+ "lum-input w-full p-1 text-xs rounded-sm": true,
265
+ "rounded-t-none border-t-0": preview == "top",
266
+ "rounded-b-none border-b-0": preview == "bottom"
267
+ },
268
+ value: store.value,
269
+ style: preview == "full" ? {
270
+ backgroundColor: `${store.value}`,
271
+ color: getBrightness(hexToRgba(store.value)) > 0.5 ? "black" : "white"
272
+ } : {},
273
+ onInput$: async (e, el) => {
274
+ await setColor(el.value);
275
+ }
276
+ })
277
+ ]
278
+ }),
279
+ colors.map((color, i) => {
280
+ return /* @__PURE__ */ jsx("button", {
281
+ type: "button",
282
+ name: color,
283
+ class: {
284
+ "lum-btn rounded-sm h-[1.6rem] w-[1.6rem] p-0 lum-bg hover:brightness-150": true,
285
+ "border-lum-accent": color === store.value
286
+ },
287
+ style: {
288
+ "--bg-color": color
289
+ },
290
+ onClick$: async () => {
291
+ await setColor(color);
292
+ }
293
+ }, i);
294
+ }),
295
+ /* @__PURE__ */ jsx("button", {
296
+ type: "button",
297
+ class: "lum-btn rounded-sm h-[1.6rem] w-[1.6rem] p-0.5",
298
+ name: "Randomize",
299
+ onClick$: async () => {
300
+ const color = `#${Math.floor(Math.random() * 16777215).toString(16)}`;
301
+ await setColor(color);
302
+ },
303
+ children: /* @__PURE__ */ jsx(Shuffle, {
304
+ class: "p-0.5 pl-0.5 text-lum-text"
305
+ })
306
+ })
307
+ ]
308
+ })
309
+ ]
310
+ });
311
+ });
312
+ export {
313
+ ColorPicker
314
+ };
@@ -1,4 +1,4 @@
1
- import type { PropsOf } from '@builder.io/qwik';
1
+ import type { PropsOf } from '@qwik.dev/core';
2
2
  interface DropdownProps extends Omit<PropsOf<'button'>, 'class'> {
3
3
  class?: {
4
4
  [key: string]: boolean;
@@ -6,5 +6,5 @@ interface DropdownProps extends Omit<PropsOf<'button'>, 'class'> {
6
6
  hover?: boolean;
7
7
  opened?: boolean;
8
8
  }
9
- export declare const Dropdown: import("@builder.io/qwik").Component<DropdownProps>;
9
+ export declare const Dropdown: import("@qwik.dev/core").Component<DropdownProps>;
10
10
  export {};
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("@qwik.dev/core/jsx-runtime");
4
+ const core = require("@qwik.dev/core");
5
+ const ChevronDown = require("../../svg/ChevronDown.qwik.cjs");
6
+ const Dropdown = core.component$(({ class: Class, hover, opened, ...props }) => {
7
+ return /* @__PURE__ */ jsxRuntime.jsxs("button", {
8
+ type: "button",
9
+ class: {
10
+ "group lum-btn": true,
11
+ ...Class
12
+ },
13
+ ...props,
14
+ children: [
15
+ /* @__PURE__ */ jsxRuntime.jsx("span", {
16
+ class: "flex-1 text-left",
17
+ children: /* @__PURE__ */ jsxRuntime.jsx(core.Slot, {})
18
+ }),
19
+ /* @__PURE__ */ jsxRuntime.jsx(ChevronDown.ChevronDown, {
20
+ size: 16,
21
+ class: {
22
+ "ease-out motion-safe:transition-transform": true,
23
+ "rotate-180 transform": opened,
24
+ "duration-300 group-hover:rotate-180 group-hover:transform group-hover:duration-75": hover,
25
+ "focus-within:rotate-180 focus-within:transform focus-within:duration-75": true
26
+ }
27
+ })
28
+ ]
29
+ });
30
+ });
31
+ exports.Dropdown = Dropdown;