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