@luminescent/ui 0.7.7 → 0.8.0

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.
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const qwik = require("@builder.io/qwik");
4
- const build = require("@builder.io/qwik/build");
5
4
  const jsxRuntime = require("@builder.io/qwik/jsx-runtime");
6
5
  const Anchor = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => /* @__PURE__ */ qwik._jsxQ("span", null, {
7
6
  class: "block h-32 -mt-32",
@@ -307,80 +306,6 @@ function getMousePosition(e) {
307
306
  };
308
307
  }
309
308
  const pad2 = (c) => c.length == 1 ? "0" + c : "" + c;
310
- class Color {
311
- constructor(color) {
312
- this._rgba = {
313
- r: 0,
314
- g: 0,
315
- b: 0,
316
- a: 1
317
- };
318
- this._hsva = {
319
- h: 0,
320
- s: 0,
321
- v: 0,
322
- a: 1
323
- };
324
- this.fromHex(color);
325
- }
326
- fromHex(color = 0) {
327
- if (typeof color === "number") {
328
- this._hexNumber = color;
329
- this._hexString = numberToHexString(this._hexNumber);
330
- } else {
331
- this._hexString = color.toUpperCase();
332
- this._hexNumber = hexStringToNumber(this._hexString);
333
- }
334
- const { r, g, b } = hexNumberToRgb(this._hexNumber);
335
- this._rgba.r = r;
336
- this._rgba.g = g;
337
- this._rgba.b = b;
338
- const { h, s, v } = rgbToHsv(this._rgba);
339
- this._hsva.h = h;
340
- this._hsva.s = s;
341
- this._hsva.v = v;
342
- this._updateBrightness();
343
- }
344
- fromHsv(color) {
345
- const { h, s, v } = color;
346
- this._hsva.h = h;
347
- this._hsva.s = s;
348
- this._hsva.v = v;
349
- const { r, g, b } = hsvToRgb(this._hsva);
350
- this._rgba.r = r;
351
- this._rgba.g = g;
352
- this._rgba.b = b;
353
- this._hexString = rgbToHex(this._rgba);
354
- this._hexNumber = hexStringToNumber(this._hexString);
355
- this._updateBrightness();
356
- }
357
- _updateBrightness() {
358
- this._brightness = getBrightness(this._rgba);
359
- this._isDark = this._brightness < 0.5;
360
- this._isLight = !this._isDark;
361
- }
362
- get rgb() {
363
- return this._rgba;
364
- }
365
- get hsv() {
366
- return this._hsva;
367
- }
368
- get hex() {
369
- return this._hexNumber;
370
- }
371
- get hexString() {
372
- return this._hexString;
373
- }
374
- get brightness() {
375
- return this._brightness;
376
- }
377
- get isDark() {
378
- return this._isDark;
379
- }
380
- get isLight() {
381
- return this._isLight;
382
- }
383
- }
384
309
  function getBrightness(color) {
385
310
  const { r, g, b } = color;
386
311
  return (r * 299 + g * 587 + b * 114) / 1e3;
@@ -405,7 +330,6 @@ function rgbToHex(color) {
405
330
  ];
406
331
  return hex.join("").toUpperCase();
407
332
  }
408
- const numberToHexString = (color) => "#" + ("00000" + (color | 0).toString(16)).substr(-6).toUpperCase();
409
333
  const hexStringToNumber = (color) => parseInt(color.replace("#", ""), 16);
410
334
  function hsvToRgb(color) {
411
335
  let { h } = color;
@@ -475,338 +399,6 @@ function rgbToHsv(color) {
475
399
  v
476
400
  };
477
401
  }
478
- class ColorPicker {
479
- constructor(options = {}) {
480
- this._widthUnits = "px";
481
- this._heightUnits = "px";
482
- this._huePosition = 0;
483
- this._hueHeight = 0;
484
- this._maxHue = 0;
485
- this._inputIsNumber = false;
486
- this._saturationWidth = 0;
487
- this._isChoosing = false;
488
- this._callbacks = [];
489
- this.width = 0;
490
- this.height = 0;
491
- this.hue = 0;
492
- this.position = {
493
- x: 0,
494
- y: 0
495
- };
496
- this.color = new Color(0);
497
- this.backgroundColor = new Color(0);
498
- this.hueColor = new Color(0);
499
- this._onSaturationMouseDown = (e) => {
500
- const sbOffset = this.$saturation.getBoundingClientRect();
501
- const { x, y } = getMousePosition(e);
502
- this._isChoosing = true;
503
- this._moveSelectorTo(x - sbOffset.left, y - sbOffset.top);
504
- this._updateColorFromPosition();
505
- this._window.addEventListener("mouseup", this._onSaturationMouseUp);
506
- this._window.addEventListener("touchend", this._onSaturationMouseUp);
507
- this._window.addEventListener("mousemove", this._onSaturationMouseMove);
508
- this._window.addEventListener("touchmove", this._onSaturationMouseMove);
509
- e.preventDefault();
510
- };
511
- this._onSaturationMouseMove = (e) => {
512
- const sbOffset = this.$saturation.getBoundingClientRect();
513
- const { x, y } = getMousePosition(e);
514
- this._moveSelectorTo(x - sbOffset.left, y - sbOffset.top);
515
- this._updateColorFromPosition();
516
- };
517
- this._onSaturationMouseUp = () => {
518
- this._isChoosing = false;
519
- this._window.removeEventListener("mouseup", this._onSaturationMouseUp);
520
- this._window.removeEventListener("touchend", this._onSaturationMouseUp);
521
- this._window.removeEventListener("mousemove", this._onSaturationMouseMove);
522
- this._window.removeEventListener("touchmove", this._onSaturationMouseMove);
523
- };
524
- this._onHueMouseDown = (e) => {
525
- const hOffset = this.$hue.getBoundingClientRect();
526
- const { y } = getMousePosition(e);
527
- this._isChoosing = true;
528
- this._moveHueTo(y - hOffset.top);
529
- this._updateHueFromPosition();
530
- this._window.addEventListener("mouseup", this._onHueMouseUp);
531
- this._window.addEventListener("touchend", this._onHueMouseUp);
532
- this._window.addEventListener("mousemove", this._onHueMouseMove);
533
- this._window.addEventListener("touchmove", this._onHueMouseMove);
534
- e.preventDefault();
535
- };
536
- this._onHueMouseMove = (e) => {
537
- const hOffset = this.$hue.getBoundingClientRect();
538
- const { y } = getMousePosition(e);
539
- this._moveHueTo(y - hOffset.top);
540
- this._updateHueFromPosition();
541
- };
542
- this._onHueMouseUp = () => {
543
- this._isChoosing = false;
544
- this._window.removeEventListener("mouseup", this._onHueMouseUp);
545
- this._window.removeEventListener("touchend", this._onHueMouseUp);
546
- this._window.removeEventListener("mousemove", this._onHueMouseMove);
547
- this._window.removeEventListener("touchmove", this._onHueMouseMove);
548
- };
549
- this._window = options.window || window;
550
- this._document = this._window.document;
551
- this.$el = this._document.createElement("div");
552
- this.$el.className = "color-picker";
553
- this.$el.innerHTML = `
554
- <div class="color-picker-saturation">
555
- <div class="color-picker-brightness"></div>
556
- <div class="color-picker-sbSelector"></div>
557
- </div>
558
- <div class="color-picker-hue">
559
- <div class="color-picker-hSelector"></div>
560
- </div>
561
- `;
562
- this.$saturation = this.$el.querySelector(".color-picker-saturation");
563
- this.$hue = this.$el.querySelector(".color-picker-hue");
564
- this.$sbSelector = this.$el.querySelector(".color-picker-sbSelector");
565
- this.$hSelector = this.$el.querySelector(".color-picker-hSelector");
566
- this.$saturation.addEventListener("mousedown", this._onSaturationMouseDown);
567
- this.$saturation.addEventListener("touchstart", this._onSaturationMouseDown);
568
- this.$hue.addEventListener("mousedown", this._onHueMouseDown);
569
- this.$hue.addEventListener("touchstart", this._onHueMouseDown);
570
- if (options.el)
571
- this.appendTo(options.el);
572
- if (options.background)
573
- this.setBackgroundColor(options.background);
574
- if (options.widthUnits)
575
- this._widthUnits = options.widthUnits;
576
- if (options.heightUnits)
577
- this._heightUnits = options.heightUnits;
578
- if (options.colors) {
579
- this.$colors = this._document.createElement("div");
580
- this.$colors.className = "color-picker-colors";
581
- this.$el.appendChild(this.$colors);
582
- options.colors.forEach((color) => {
583
- const $color = this._document.createElement("button");
584
- $color.className = "color-picker-color";
585
- $color.style.background = `${color}`;
586
- $color.addEventListener("mousedown", (e) => {
587
- this.setColor(color);
588
- e.preventDefault();
589
- });
590
- $color.addEventListener("touchstart", (e) => {
591
- this.setColor(color);
592
- e.preventDefault();
593
- });
594
- this.$colors.appendChild($color);
595
- });
596
- }
597
- this.setSize(options.width || 175, options.height || 150);
598
- this.setColor(options.color);
599
- }
600
- /**
601
- * Add the ColorPicker instance to a DOM element.
602
- * @param {HTMLElement} el
603
- * @return {ColorPicker} Returns itself for chaining purpose
604
- */
605
- appendTo(el) {
606
- if (typeof el === "string")
607
- document.querySelector(el).appendChild(this.$el);
608
- else
609
- el.appendChild(this.$el);
610
- return this;
611
- }
612
- /**
613
- * Removes picker from its parent and kill all listeners.
614
- * Call this method for proper destroy.
615
- */
616
- remove() {
617
- this._callbacks = [];
618
- this._onSaturationMouseUp();
619
- this._onHueMouseUp();
620
- this.$saturation.removeEventListener("mousedown", this._onSaturationMouseDown);
621
- this.$saturation.removeEventListener("touchstart", this._onSaturationMouseDown);
622
- this.$hue.removeEventListener("mousedown", this._onHueMouseDown);
623
- this.$hue.removeEventListener("touchstart", this._onHueMouseDown);
624
- if (this.$el.parentNode)
625
- this.$el.parentNode.removeChild(this.$el);
626
- }
627
- /**
628
- * Manually set the current color of the picker. This is the method
629
- * used on instantiation to convert `color` option to actual color for
630
- * the picker. Param can be a hexadecimal number or an hex String.
631
- * @param {String|Number} color hex color desired
632
- * @return {ColorPicker} Returns itself for chaining purpose
633
- */
634
- setColor(color) {
635
- this._inputIsNumber = !isNaN(Number(color));
636
- this.color.fromHex(color);
637
- const { h, s, v } = this.color.hsv;
638
- if (!isNaN(h))
639
- this.hue = h;
640
- this._moveSelectorTo(this._saturationWidth * s, (1 - v) * this._hueHeight);
641
- this._moveHueTo((1 - this.hue) * this._hueHeight);
642
- this._updateHue();
643
- return this;
644
- }
645
- /**
646
- * Set size of the color picker for a given width and height. Note that
647
- * a padding of 5px will be added if you chose to use the background option
648
- * of the constructor.
649
- * @param {Number} width
650
- * @param {Number} height
651
- * @return {ColorPicker} Returns itself for chaining purpose
652
- */
653
- setSize(width, height) {
654
- this.width = width;
655
- this.height = height;
656
- this.$el.style.width = this.width + this._widthUnits;
657
- this.$el.style.height = this.height + this._heightUnits;
658
- this._saturationWidth = this.width - 25;
659
- this.$saturation.style.width = this._saturationWidth + "px";
660
- this._hueHeight = this.height;
661
- this._maxHue = this._hueHeight - 2;
662
- return this;
663
- }
664
- /**
665
- * Set the background color of the picker. It also adds a 5px padding
666
- * for design purpose.
667
- * @param {String|Number} color hex color desired for background
668
- * @return {ColorPicker} Returns itself for chaining purpose
669
- */
670
- setBackgroundColor(color) {
671
- this.backgroundColor.fromHex(color);
672
- this.$el.style.padding = "5px";
673
- this.$el.style.background = this.backgroundColor.hexString;
674
- return this;
675
- }
676
- /**
677
- * Removes background of the picker if previously set. It's no use
678
- * calling this method if you didn't set the background option on start
679
- * or if you didn't call setBackgroundColor previously.
680
- */
681
- setNoBackground() {
682
- this.$el.style.padding = "0px";
683
- this.$el.style.background = "none";
684
- return this;
685
- }
686
- /**
687
- * Registers callback to the update event of the picker.
688
- * picker inherits from [component/emitter](https://github.com/component/emitter)
689
- * so you could do the same thing by calling `colorPicker.on('update');`
690
- * @param {Function} callback
691
- * @return {ColorPicker} Returns itself for chaining purpose
692
- */
693
- onChange(callback) {
694
- if (this._callbacks.indexOf(callback) < 0) {
695
- this._callbacks.push(callback);
696
- callback(this.getHexString());
697
- }
698
- return this;
699
- }
700
- /**
701
- * Is true when mouse is down and user is currently choosing a color.
702
- */
703
- get isChoosing() {
704
- return this._isChoosing;
705
- }
706
- /* =============================================================================
707
- Color getters
708
- ============================================================================= */
709
- /**
710
- * Main color getter, will return a formatted color string depending on input
711
- * or a number depending on the last setColor call.
712
- * @return {Number|String}
713
- */
714
- getColor() {
715
- if (this._inputIsNumber)
716
- return this.getHexNumber();
717
- return this.getHexString();
718
- }
719
- /**
720
- * Returns color as css hex string (ex: '#FF0000').
721
- * @return {String}
722
- */
723
- getHexString() {
724
- return this.color.hexString.toUpperCase();
725
- }
726
- /**
727
- * Returns color as number (ex: 0xFF0000).
728
- * @return {Number}
729
- */
730
- getHexNumber() {
731
- return this.color.hex;
732
- }
733
- /**
734
- * Returns color as {r: 1, g: 0, b: 0} object.
735
- * @return {Object}
736
- */
737
- getRGB() {
738
- return this.color.rgb;
739
- }
740
- /**
741
- * Returns color as {h: 100, s: 1, v: 1} object.
742
- * @return {Object}
743
- */
744
- getHSV() {
745
- return this.color.hsv;
746
- }
747
- /**
748
- * Returns true if color is perceived as dark
749
- * @return {Boolean}
750
- */
751
- isDark() {
752
- return this.color.isDark;
753
- }
754
- /**
755
- * Returns true if color is perceived as light
756
- * @return {Boolean}
757
- */
758
- isLight() {
759
- return this.color.isLight;
760
- }
761
- /* =============================================================================
762
- Private methods
763
- ============================================================================= */
764
- _moveSelectorTo(x, y) {
765
- this.position.x = clamp(x, 0, this._saturationWidth);
766
- this.position.y = clamp(y, 0, this._hueHeight);
767
- this.$sbSelector.style.transform = `translate(${this.position.x}px, ${this.position.y}px)`;
768
- }
769
- _updateColorFromPosition() {
770
- this.color.fromHsv({
771
- h: this.hue,
772
- s: this.position.x / this._saturationWidth,
773
- v: 1 - this.position.y / this._hueHeight
774
- });
775
- this._updateColor();
776
- }
777
- _moveHueTo(y) {
778
- this._huePosition = clamp(y, 0, this._maxHue);
779
- this.$hSelector.style.transform = `translateY(${this._huePosition}px)`;
780
- }
781
- _updateHueFromPosition() {
782
- const hsvColor = this.getHSV();
783
- this.hue = 1 - this._huePosition / this._maxHue;
784
- this.color.fromHsv({
785
- h: this.hue,
786
- s: hsvColor.s,
787
- v: hsvColor.v
788
- });
789
- this._updateHue();
790
- }
791
- _updateHue() {
792
- this.hueColor.fromHsv({
793
- h: this.hue,
794
- s: 1,
795
- v: 1
796
- });
797
- this.$hSelector.style.background = this.hueColor.hexString;
798
- this.$saturation.style.background = `linear-gradient(to right, #fff, ${this.hueColor.hexString})`;
799
- this._updateColor();
800
- }
801
- _updateColor() {
802
- this.$sbSelector.style.background = this.getHexString();
803
- this.$sbSelector.style.borderColor = this.isDark() ? "#fff" : "#000";
804
- this._triggerChange();
805
- }
806
- _triggerChange() {
807
- this._callbacks.forEach((callback) => callback(this.getHexString()));
808
- }
809
- }
810
402
  const ColorInput = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
811
403
  const props1 = qwik._restProps(props, [
812
404
  "onInput$",
@@ -814,101 +406,12 @@ const ColorInput = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inline
814
406
  "presetColors",
815
407
  "preview"
816
408
  ]);
817
- qwik.useStylesQrl(/* @__PURE__ */ qwik.inlinedQrl(`
818
- .color-picker {
819
- display: flex;
820
- gap: 12px;
821
- height: 185px !important;
822
- width: 100% !important;
823
- padding: 15px;
824
- border-radius: 10px;
825
- border: 1px solid rgb(31 41 55);
826
- filter: drop-shadow(0px 0px 5px rgba(0, 0, 0, 0.5));
827
- background: rgba(31 41 55 / 40%);
828
- backdrop-filter: blur(10px);
829
- user-select: none;
830
- position: relative;
831
- z-index: 1000;
832
- }
833
-
834
- .color-picker-saturation {
835
- position: relative;
836
- height: 100%;
837
- width: 100%;
838
- background: linear-gradient(to right, #FFFFFF, #FF0000);
839
- float: left;
840
- border-radius: 5px;
841
- border: 1px solid rgb(31 41 55);
842
- }
843
-
844
- .color-picker-brightness {
845
- width: 100%;
846
- height: 100%;
847
- background: linear-gradient(rgba(255, 255, 255, 0), rgba(0, 0, 0, 1));
848
- }
849
-
850
- .color-picker-sbSelector {
851
- border: 1px solid white;
852
- position: absolute;
853
- width: 14px;
854
- height: 14px;
855
- background: white;
856
- border-radius: 10px;
857
- top: -7px;
858
- left: -7px;
859
- box-sizing: border-box;
860
- }
861
-
862
- .color-picker-hue {
863
- width: 8px;
864
- border-radius: 5px;
865
- height: 100%;
866
- position: relative;
867
- float: left;
868
- background: linear-gradient(rgb(255, 0, 0) 0%, rgb(255, 0, 255) 17%, rgb(0, 0, 255) 34%, rgb(0, 255, 255) 50%, rgb(0, 255, 0) 67%, rgb(255, 255, 0) 84%, rgb(255, 0, 0) 100%);
869
- border: 1px solid rgb(31 41 55);
870
- }
871
-
872
- .color-picker-colors {
873
- height: 100%;
874
- position: relative;
875
- display: flex;
876
- flex-direction: column;
877
- gap: 5px;
878
- float: left;
879
- justify-content: space-evenly;
880
- flex-wrap: wrap;
881
- }
882
-
883
- .color-picker-color {
884
- transition: all 0.2s;
885
- height: 25px;
886
- width: 25px;
887
- border-radius: 5px;
888
- position: relative;
889
- background: red;
890
- border: 1px solid rgb(31 41 55);
891
- cursor: pointer;
892
- }
893
-
894
- .color-picker-color:hover {
895
- border: 1px solid white;
896
- transform: scale(1.1);
897
- }
898
-
899
- .color-picker-hSelector {
900
- border: 1px solid white;
901
- position: absolute;
902
- width: 14px;
903
- height: 14px;
904
- background: white;
905
- border-radius: 10px;
906
- top: -6px;
907
- left: -4px;
908
- box-sizing: border-box;
909
- }
910
- `, "ColorInput_component_useStyles_SMNFl4Oy0IA"));
911
- return /* @__PURE__ */ qwik._jsxQ("div", null, null, [
409
+ const store = qwik.useStore({
410
+ opened: false
411
+ });
412
+ return /* @__PURE__ */ qwik._jsxQ("div", null, {
413
+ class: "relative"
414
+ }, [
912
415
  /* @__PURE__ */ qwik._jsxQ("label", {
913
416
  for: qwik._wrapSignal(props1, "id")
914
417
  }, {
@@ -919,68 +422,17 @@ const ColorInput = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inline
919
422
  get value() {
920
423
  return props.value ?? "#000000";
921
424
  },
922
- onBlur$: /* @__PURE__ */ qwik.inlinedQrl((event, element) => {
923
- const [props12] = qwik.useLexicalScope();
924
- console.log(event);
925
- const pickerDiv = document.getElementById(`${props12.id}-color-picker`);
926
- pickerDiv.classList.add("opacity-0", "pointer-events-none", "scale-95");
425
+ onBlur$: /* @__PURE__ */ qwik.inlinedQrl(() => {
426
+ const [store2] = qwik.useLexicalScope();
427
+ store2.opened = false;
927
428
  }, "ColorInput_component_div_TextInputRaw_onBlur_giB7aSy8tnc", [
928
- props1
429
+ store
929
430
  ]),
930
- onFocus$: /* @__PURE__ */ qwik.inlinedQrl((event, element) => {
931
- const [props12, props2] = qwik.useLexicalScope();
932
- const pickerDiv = document.getElementById(`${props12.id}-color-picker`);
933
- if (!pickerDiv.children.length) {
934
- if (build.isServer)
935
- return;
936
- const picker = new ColorPicker({
937
- el: pickerDiv,
938
- color: props2.value ?? "#000000",
939
- colors: [
940
- "#FAEDCB",
941
- "#C9E4DE",
942
- "#C6DEF1",
943
- "#DBCDF0",
944
- "#F2C6DE",
945
- "#FCD05C",
946
- "#5FE2C5",
947
- "#4498DB",
948
- "#9863E7",
949
- "#E43A96",
950
- ...props2.presetColors ?? []
951
- ],
952
- width: 150,
953
- height: 150
954
- });
955
- picker.onChange((color) => {
956
- element.value = color;
957
- switch (props2.preview ?? "left") {
958
- case "full":
959
- element.style.backgroundColor = color;
960
- element.style.color = getBrightness(hexNumberToRgb(hexStringToNumber(color))) > 0.5 ? "black" : "white";
961
- break;
962
- case "left":
963
- element.style.borderLeft = `40px solid ${color}`;
964
- break;
965
- case "right":
966
- element.style.borderRight = `40px solid ${color}`;
967
- break;
968
- case "top":
969
- element.style.borderTop = `10px solid ${color}`;
970
- break;
971
- case "bottom":
972
- element.style.borderBottom = `10px solid ${color}`;
973
- break;
974
- }
975
- if (props2.onInput$)
976
- props2.onInput$(color, element);
977
- });
978
- element.addEventListener("input", () => picker.setColor(element.value));
979
- }
980
- pickerDiv.classList.remove("opacity-0", "pointer-events-none", "scale-95");
431
+ onFocus$: /* @__PURE__ */ qwik.inlinedQrl(() => {
432
+ const [store2] = qwik.useLexicalScope();
433
+ store2.opened = true;
981
434
  }, "ColorInput_component_div_TextInputRaw_onFocus_9bHrhSeTgfI", [
982
- props1,
983
- props
435
+ store
984
436
  ]),
985
437
  style: (props.preview ?? "left") == "full" ? {
986
438
  backgroundColor: `${props.value ?? "#000000"}`,
@@ -995,18 +447,288 @@ const ColorInput = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inline
995
447
  borderBottom: `10px solid ${props.value ?? "#000000"}`
996
448
  } : {},
997
449
  [qwik._IMMUTABLE]: {
450
+ onBlur$: qwik._IMMUTABLE,
451
+ onFocus$: qwik._IMMUTABLE,
998
452
  value: qwik._fnSignal((p0) => p0.value ?? "#000000", [
999
453
  props
1000
454
  ], 'p0.value??"#000000"')
1001
455
  }
1002
456
  }, 0, "0s_1"),
1003
- /* @__PURE__ */ qwik._jsxQ("div", {
1004
- id: `${props1.id}-color-picker`
1005
- }, {
1006
- class: "absolute mt-2 opacity-0 transition-all pointer-events-none scale-95"
1007
- }, null, 3, null)
1008
- ], 1, "0s_2");
457
+ /* @__PURE__ */ qwik._jsxC(ColorPickerRaw, {
458
+ get color() {
459
+ return props.value ?? "#000000";
460
+ },
461
+ get colors() {
462
+ return [
463
+ "#FAEDCB",
464
+ "#C9E4DE",
465
+ "#C6DEF1",
466
+ "#DBCDF0",
467
+ "#F2C6DE",
468
+ "#FCD05C",
469
+ "#5FE2C5",
470
+ "#4498DB",
471
+ "#9863E7",
472
+ "#E43A96",
473
+ ...props.presetColors ?? []
474
+ ];
475
+ },
476
+ get class() {
477
+ return {
478
+ "transition-all absolute top-full mt-2 left-0 gap-1 z-[1000]": true,
479
+ "opacity-0 pointer-events-none scale-95": !store.opened
480
+ };
481
+ },
482
+ onInput$: /* @__PURE__ */ qwik.inlinedQrl((color) => {
483
+ const [props12, props2] = qwik.useLexicalScope();
484
+ const el = document.getElementById(props12.id);
485
+ el.value = color;
486
+ switch (props2.preview ?? "left") {
487
+ case "full":
488
+ el.style.backgroundColor = color;
489
+ el.style.color = getBrightness(hexNumberToRgb(hexStringToNumber(color))) > 0.5 ? "black" : "white";
490
+ break;
491
+ case "left":
492
+ el.style.borderLeft = `40px solid ${color}`;
493
+ break;
494
+ case "right":
495
+ el.style.borderRight = `40px solid ${color}`;
496
+ break;
497
+ case "top":
498
+ el.style.borderTop = `10px solid ${color}`;
499
+ break;
500
+ case "bottom":
501
+ el.style.borderBottom = `10px solid ${color}`;
502
+ break;
503
+ }
504
+ props2.onInput$?.(color);
505
+ }, "ColorInput_component_div_ColorPickerRaw_onInput_wTO4B2czR7s", [
506
+ props1,
507
+ props
508
+ ]),
509
+ [qwik._IMMUTABLE]: {
510
+ class: qwik._fnSignal((p0) => ({
511
+ "transition-all absolute top-full mt-2 left-0 gap-1 z-[1000]": true,
512
+ "opacity-0 pointer-events-none scale-95": !p0.opened
513
+ }), [
514
+ store
515
+ ], '{"transition-all absolute top-full mt-2 left-0 gap-1 z-[1000]":true,"opacity-0 pointer-events-none scale-95":!p0.opened}'),
516
+ color: qwik._fnSignal((p0) => p0.value ?? "#000000", [
517
+ props
518
+ ], 'p0.value??"#000000"'),
519
+ colors: qwik._fnSignal((p0) => [
520
+ "#FAEDCB",
521
+ "#C9E4DE",
522
+ "#C6DEF1",
523
+ "#DBCDF0",
524
+ "#F2C6DE",
525
+ "#FCD05C",
526
+ "#5FE2C5",
527
+ "#4498DB",
528
+ "#9863E7",
529
+ "#E43A96",
530
+ ...p0.presetColors ?? []
531
+ ], [
532
+ props
533
+ ], '["#FAEDCB","#C9E4DE","#C6DEF1","#DBCDF0","#F2C6DE","#FCD05C","#5FE2C5","#4498DB","#9863E7","#E43A96",...p0.presetColors??[]]')
534
+ }
535
+ }, 3, "0s_2")
536
+ ], 1, "0s_3");
1009
537
  }, "ColorInput_component_jilGo0Bn3Ps"));
538
+ const ColorPickerRaw = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
539
+ const props1 = qwik._restProps(props, [
540
+ "color",
541
+ "colors",
542
+ "onInput$"
543
+ ]);
544
+ const width = 125;
545
+ const maxHue = 148;
546
+ const hsvColor = rgbToHsv(hexNumberToRgb(hexStringToNumber(props.color)));
547
+ const store = qwik.useStore({
548
+ hue: {
549
+ position: hsvColor.h * maxHue,
550
+ color: rgbToHex(hsvToRgb({
551
+ h: hsvColor.h,
552
+ s: 1,
553
+ v: 1
554
+ }))
555
+ },
556
+ bPosition: (1 - hsvColor.v) * maxHue,
557
+ sPosition: hsvColor.s * width,
558
+ color: props.color
559
+ });
560
+ const setColor = /* @__PURE__ */ qwik.inlinedQrl((color) => {
561
+ const [maxHue2, props2, store2, width2] = qwik.useLexicalScope();
562
+ store2.color = color;
563
+ const hsv = rgbToHsv(hexNumberToRgb(hexStringToNumber(color)));
564
+ store2.hue.position = hsv.h * maxHue2;
565
+ store2.hue.color = rgbToHex(hsvToRgb({
566
+ h: hsv.h,
567
+ s: 1,
568
+ v: 1
569
+ }));
570
+ store2.sPosition = hsv.s * width2;
571
+ store2.bPosition = (1 - hsv.v) * maxHue2;
572
+ props2.onInput$?.(color);
573
+ }, "ColorPickerRaw_component_setColor_KSE5T0GnULs", [
574
+ maxHue,
575
+ props,
576
+ store,
577
+ width
578
+ ]);
579
+ const hueChange = /* @__PURE__ */ qwik.inlinedQrl((e, hOffset) => {
580
+ const [maxHue2, props2, store2] = qwik.useLexicalScope();
581
+ const { y } = getMousePosition(e);
582
+ store2.hue.position = clamp(maxHue2 - (y - hOffset), 0, maxHue2);
583
+ const hsvColor2 = rgbToHsv(hexNumberToRgb(hexStringToNumber(store2.color)));
584
+ const h = store2.hue.position / maxHue2;
585
+ hsvColor2.h = h;
586
+ store2.hue.color = rgbToHex(hsvToRgb({
587
+ h,
588
+ s: 1,
589
+ v: 1
590
+ }));
591
+ store2.color = rgbToHex(hsvToRgb(hsvColor2));
592
+ props2.onInput$?.(store2.color);
593
+ }, "ColorPickerRaw_component_hueChange_za4ruRb84uA", [
594
+ maxHue,
595
+ props,
596
+ store
597
+ ]);
598
+ const hueMouseDown = /* @__PURE__ */ qwik.inlinedQrl((e, el) => {
599
+ const [hueChange2] = qwik.useLexicalScope();
600
+ const hOffset = el.getBoundingClientRect().top;
601
+ hueChange2(e, hOffset);
602
+ const eventListener = (e2) => hueChange2(e2, hOffset);
603
+ window.addEventListener("mousemove", eventListener);
604
+ window.addEventListener("touchmove", eventListener);
605
+ const mouseUpListener = () => {
606
+ window.removeEventListener("mousemove", eventListener);
607
+ window.removeEventListener("touchmove", eventListener);
608
+ window.removeEventListener("mouseup", mouseUpListener);
609
+ window.removeEventListener("touchend", mouseUpListener);
610
+ };
611
+ window.addEventListener("mouseup", mouseUpListener);
612
+ window.addEventListener("touchend", mouseUpListener);
613
+ }, "ColorPickerRaw_component_hueMouseDown_IbHBnI0jzpg", [
614
+ hueChange
615
+ ]);
616
+ const sbChange = /* @__PURE__ */ qwik.inlinedQrl((e, hOffset) => {
617
+ const [maxHue2, props2, store2, width2] = qwik.useLexicalScope();
618
+ const { x, y } = getMousePosition(e);
619
+ store2.bPosition = clamp(y - hOffset.top, 0, maxHue2);
620
+ store2.sPosition = clamp(x - hOffset.left, 0, width2);
621
+ const s = store2.sPosition / width2;
622
+ const v = 1 - store2.bPosition / maxHue2;
623
+ store2.color = rgbToHex(hsvToRgb({
624
+ h: store2.hue.position / maxHue2,
625
+ s,
626
+ v
627
+ }));
628
+ props2.onInput$?.(store2.color);
629
+ }, "ColorPickerRaw_component_sbChange_yhwlg2HYP8Y", [
630
+ maxHue,
631
+ props,
632
+ store,
633
+ width
634
+ ]);
635
+ const sbMouseDown = /* @__PURE__ */ qwik.inlinedQrl((e, el) => {
636
+ const [sbChange2] = qwik.useLexicalScope();
637
+ const offset = el.getBoundingClientRect();
638
+ sbChange2(e, offset);
639
+ const eventListener = (e2) => sbChange2(e2, offset);
640
+ window.addEventListener("mousemove", eventListener);
641
+ window.addEventListener("touchmove", eventListener);
642
+ const mouseUpListener = () => {
643
+ window.removeEventListener("mousemove", eventListener);
644
+ window.removeEventListener("touchmove", eventListener);
645
+ window.removeEventListener("mouseup", mouseUpListener);
646
+ window.removeEventListener("touchend", mouseUpListener);
647
+ };
648
+ window.addEventListener("mouseup", mouseUpListener);
649
+ window.addEventListener("touchend", mouseUpListener);
650
+ }, "ColorPickerRaw_component_sbMouseDown_hRgkP7lymfY", [
651
+ sbChange
652
+ ]);
653
+ return /* @__PURE__ */ qwik._jsxQ("div", {
654
+ class: {
655
+ "transition-all p-4 gap-4 bg-gray-800/50 backdrop-blur-xl flex rounded-lg border border-gray-700 touch-none": true,
656
+ ...props1.class
657
+ }
658
+ }, {
659
+ "preventdefault:mousedown": true,
660
+ "preventdefault:touchstart": true
661
+ }, [
662
+ /* @__PURE__ */ qwik._jsxQ("div", null, {
663
+ class: "w-[125px] h-[150px] border border-gray-700 rounded-md relative",
664
+ onMouseDown$: sbMouseDown,
665
+ onTouchStart$: sbMouseDown,
666
+ "preventdefault:mousedown": true,
667
+ "preventdefault:touchstart": true,
668
+ style: qwik._fnSignal((p0) => ({
669
+ background: `linear-gradient(to right, #FFFFFF, ${p0.hue.color})`
670
+ }), [
671
+ store
672
+ ], "{background:`linear-gradient(to right, #FFFFFF, ${p0.hue.color})`}")
673
+ }, [
674
+ /* @__PURE__ */ qwik._jsxQ("div", null, {
675
+ class: "w-[125px] h-[150px] border border-gray-700 rounded-md bg-gradient-to-b from-transparent to-black"
676
+ }, null, 3, null),
677
+ /* @__PURE__ */ qwik._jsxQ("div", null, {
678
+ class: "absolute -top-2 -left-2 w-4 h-4 border border-white rounded-full bg-white",
679
+ style: qwik._fnSignal((p0) => ({
680
+ background: p0.color,
681
+ transform: `translate(${p0.sPosition}px, ${p0.bPosition}px)`
682
+ }), [
683
+ store
684
+ ], "{background:p0.color,transform:`translate(${p0.sPosition}px, ${p0.bPosition}px)`}")
685
+ }, null, 3, null)
686
+ ], 3, null),
687
+ /* @__PURE__ */ qwik._jsxQ("div", null, {
688
+ class: "h-[150px] relative w-2 border border-gray-700 rounded-md",
689
+ onMouseDown$: hueMouseDown,
690
+ onTouchStart$: hueMouseDown,
691
+ "preventdefault:mousedown": true,
692
+ "preventdefault:touchstart": true,
693
+ style: {
694
+ background: "linear-gradient(to bottom, #ff0000, #ff00ff, #0000ff, #00ffff, #00ff00, #ffff00, #ff0000)"
695
+ }
696
+ }, /* @__PURE__ */ qwik._jsxQ("div", null, {
697
+ class: "absolute -bottom-2 -left-[5px] w-4 h-4 border border-white rounded-full bg-[#ff0000]",
698
+ style: qwik._fnSignal((p0) => ({
699
+ transform: `translateY(${-p0.hue.position}px)`,
700
+ background: p0.hue.color
701
+ }), [
702
+ store
703
+ ], "{transform:`translateY(${-p0.hue.position}px)`,background:p0.hue.color}")
704
+ }, null, 3, null), 3, null),
705
+ /* @__PURE__ */ qwik._jsxQ("div", null, {
706
+ class: "h-[150px] flex flex-col flex-wrap gap-1 justify-evenly"
707
+ }, props.colors.map((color, i) => {
708
+ return /* @__PURE__ */ qwik._jsxQ("button", {
709
+ onMouseDown$: /* @__PURE__ */ qwik.inlinedQrl(() => {
710
+ const [color2, setColor2] = qwik.useLexicalScope();
711
+ setColor2(color2);
712
+ }, "ColorPickerRaw_component_div_div_button_onMouseDown_C5tqQYvx7wA", [
713
+ color,
714
+ setColor
715
+ ]),
716
+ onTouchStart$: /* @__PURE__ */ qwik.inlinedQrl(() => {
717
+ const [color2, setColor2] = qwik.useLexicalScope();
718
+ setColor2(color2);
719
+ }, "ColorPickerRaw_component_div_div_button_onTouchStart_qgiiO8Blb88", [
720
+ color,
721
+ setColor
722
+ ]),
723
+ style: `background: ${color}`
724
+ }, {
725
+ class: "w-[25px] h-[25px] border border-gray-700 rounded-md hover:scale-110 transition-all",
726
+ "preventdefault:mousedown": true,
727
+ "preventdefault:touchstart": true
728
+ }, null, 2, i);
729
+ }), 1, null)
730
+ ], 1, "0s_4");
731
+ }, "ColorPickerRaw_component_CWQPPcezhyA"));
1010
732
  const LoadingIcon = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
1011
733
  const props1 = qwik._restProps(props, [
1012
734
  "width",
@@ -1971,6 +1693,7 @@ exports.Button = Button;
1971
1693
  exports.ButtonAnchor = ButtonAnchor;
1972
1694
  exports.Card = Card;
1973
1695
  exports.ColorInput = ColorInput;
1696
+ exports.ColorPickerRaw = ColorPickerRaw;
1974
1697
  exports.Header = Header;
1975
1698
  exports.InputClasses = InputClasses;
1976
1699
  exports.LoadingIcon = LoadingIcon;