@luminescent/ui 0.7.6 → 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",
@@ -23,7 +22,7 @@ const sizeClasses = {
23
22
  lg: "text-base px-6 py-3 rounded-lg gap-3",
24
23
  xl: "text-base px-8 py-4 rounded-xl gap-4"
25
24
  };
26
- const buttonClass = "relative flex items-center gap-3 transition ease-in-out border text-gray-50 fill-gray-50 disabled:opacity-50 hover:shadow-lg active:scale-95";
25
+ const buttonClass = "relative flex items-center gap-3 transition ease-in-out border text-gray-50 fill-gray-50 disabled:opacity-50 hover:shadow-lg active:scale-95 whitespace-nowrap";
27
26
  const Button = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
28
27
  const props1 = _restProps(props, [
29
28
  "color",
@@ -269,7 +268,7 @@ const TextInput = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props
269
268
  class: "flex flex-col"
270
269
  }, [
271
270
  /* @__PURE__ */ _jsxQ("label", null, {
272
- class: "pb-2",
271
+ class: "text-gray-300 pb-1",
273
272
  for: _fnSignal((p0) => p0.id, [
274
273
  props
275
274
  ], "p0.id")
@@ -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,325 +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
- this.$colors.innerHTML = options.colors.map((color) => `<div class="color-picker-color" style="background: ${color}"></div>`).join("");
581
- }
582
- this.setSize(options.width || 175, options.height || 150);
583
- this.setColor(options.color);
584
- }
585
- /**
586
- * Add the ColorPicker instance to a DOM element.
587
- * @param {HTMLElement} el
588
- * @return {ColorPicker} Returns itself for chaining purpose
589
- */
590
- appendTo(el) {
591
- if (typeof el === "string")
592
- document.querySelector(el).appendChild(this.$el);
593
- else
594
- el.appendChild(this.$el);
595
- return this;
596
- }
597
- /**
598
- * Removes picker from its parent and kill all listeners.
599
- * Call this method for proper destroy.
600
- */
601
- remove() {
602
- this._callbacks = [];
603
- this._onSaturationMouseUp();
604
- this._onHueMouseUp();
605
- this.$saturation.removeEventListener("mousedown", this._onSaturationMouseDown);
606
- this.$saturation.removeEventListener("touchstart", this._onSaturationMouseDown);
607
- this.$hue.removeEventListener("mousedown", this._onHueMouseDown);
608
- this.$hue.removeEventListener("touchstart", this._onHueMouseDown);
609
- if (this.$el.parentNode)
610
- this.$el.parentNode.removeChild(this.$el);
611
- }
612
- /**
613
- * Manually set the current color of the picker. This is the method
614
- * used on instantiation to convert `color` option to actual color for
615
- * the picker. Param can be a hexadecimal number or an hex String.
616
- * @param {String|Number} color hex color desired
617
- * @return {ColorPicker} Returns itself for chaining purpose
618
- */
619
- setColor(color) {
620
- this._inputIsNumber = !isNaN(Number(color));
621
- this.color.fromHex(color);
622
- const { h, s, v } = this.color.hsv;
623
- if (!isNaN(h))
624
- this.hue = h;
625
- this._moveSelectorTo(this._saturationWidth * s, (1 - v) * this._hueHeight);
626
- this._moveHueTo((1 - this.hue) * this._hueHeight);
627
- this._updateHue();
628
- return this;
629
- }
630
- /**
631
- * Set size of the color picker for a given width and height. Note that
632
- * a padding of 5px will be added if you chose to use the background option
633
- * of the constructor.
634
- * @param {Number} width
635
- * @param {Number} height
636
- * @return {ColorPicker} Returns itself for chaining purpose
637
- */
638
- setSize(width, height) {
639
- this.width = width;
640
- this.height = height;
641
- this.$el.style.width = this.width + this._widthUnits;
642
- this.$el.style.height = this.height + this._heightUnits;
643
- this._saturationWidth = this.width - 25;
644
- this.$saturation.style.width = this._saturationWidth + "px";
645
- this._hueHeight = this.height;
646
- this._maxHue = this._hueHeight - 2;
647
- return this;
648
- }
649
- /**
650
- * Set the background color of the picker. It also adds a 5px padding
651
- * for design purpose.
652
- * @param {String|Number} color hex color desired for background
653
- * @return {ColorPicker} Returns itself for chaining purpose
654
- */
655
- setBackgroundColor(color) {
656
- this.backgroundColor.fromHex(color);
657
- this.$el.style.padding = "5px";
658
- this.$el.style.background = this.backgroundColor.hexString;
659
- return this;
660
- }
661
- /**
662
- * Removes background of the picker if previously set. It's no use
663
- * calling this method if you didn't set the background option on start
664
- * or if you didn't call setBackgroundColor previously.
665
- */
666
- setNoBackground() {
667
- this.$el.style.padding = "0px";
668
- this.$el.style.background = "none";
669
- return this;
670
- }
671
- /**
672
- * Registers callback to the update event of the picker.
673
- * picker inherits from [component/emitter](https://github.com/component/emitter)
674
- * so you could do the same thing by calling `colorPicker.on('update');`
675
- * @param {Function} callback
676
- * @return {ColorPicker} Returns itself for chaining purpose
677
- */
678
- onChange(callback) {
679
- if (this._callbacks.indexOf(callback) < 0) {
680
- this._callbacks.push(callback);
681
- callback(this.getHexString());
682
- }
683
- return this;
684
- }
685
- /**
686
- * Is true when mouse is down and user is currently choosing a color.
687
- */
688
- get isChoosing() {
689
- return this._isChoosing;
690
- }
691
- /* =============================================================================
692
- Color getters
693
- ============================================================================= */
694
- /**
695
- * Main color getter, will return a formatted color string depending on input
696
- * or a number depending on the last setColor call.
697
- * @return {Number|String}
698
- */
699
- getColor() {
700
- if (this._inputIsNumber)
701
- return this.getHexNumber();
702
- return this.getHexString();
703
- }
704
- /**
705
- * Returns color as css hex string (ex: '#FF0000').
706
- * @return {String}
707
- */
708
- getHexString() {
709
- return this.color.hexString.toUpperCase();
710
- }
711
- /**
712
- * Returns color as number (ex: 0xFF0000).
713
- * @return {Number}
714
- */
715
- getHexNumber() {
716
- return this.color.hex;
717
- }
718
- /**
719
- * Returns color as {r: 1, g: 0, b: 0} object.
720
- * @return {Object}
721
- */
722
- getRGB() {
723
- return this.color.rgb;
724
- }
725
- /**
726
- * Returns color as {h: 100, s: 1, v: 1} object.
727
- * @return {Object}
728
- */
729
- getHSV() {
730
- return this.color.hsv;
731
- }
732
- /**
733
- * Returns true if color is perceived as dark
734
- * @return {Boolean}
735
- */
736
- isDark() {
737
- return this.color.isDark;
738
- }
739
- /**
740
- * Returns true if color is perceived as light
741
- * @return {Boolean}
742
- */
743
- isLight() {
744
- return this.color.isLight;
745
- }
746
- /* =============================================================================
747
- Private methods
748
- ============================================================================= */
749
- _moveSelectorTo(x, y) {
750
- this.position.x = clamp(x, 0, this._saturationWidth);
751
- this.position.y = clamp(y, 0, this._hueHeight);
752
- this.$sbSelector.style.transform = `translate(${this.position.x}px, ${this.position.y}px)`;
753
- }
754
- _updateColorFromPosition() {
755
- this.color.fromHsv({
756
- h: this.hue,
757
- s: this.position.x / this._saturationWidth,
758
- v: 1 - this.position.y / this._hueHeight
759
- });
760
- this._updateColor();
761
- }
762
- _moveHueTo(y) {
763
- this._huePosition = clamp(y, 0, this._maxHue);
764
- this.$hSelector.style.transform = `translateY(${this._huePosition}px)`;
765
- }
766
- _updateHueFromPosition() {
767
- const hsvColor = this.getHSV();
768
- this.hue = 1 - this._huePosition / this._maxHue;
769
- this.color.fromHsv({
770
- h: this.hue,
771
- s: hsvColor.s,
772
- v: hsvColor.v
773
- });
774
- this._updateHue();
775
- }
776
- _updateHue() {
777
- this.hueColor.fromHsv({
778
- h: this.hue,
779
- s: 1,
780
- v: 1
781
- });
782
- this.$hSelector.style.background = this.hueColor.hexString;
783
- this.$saturation.style.background = `linear-gradient(to right, #fff, ${this.hueColor.hexString})`;
784
- this._updateColor();
785
- }
786
- _updateColor() {
787
- this.$sbSelector.style.background = this.getHexString();
788
- this.$sbSelector.style.borderColor = this.isDark() ? "#fff" : "#000";
789
- this._triggerChange();
790
- }
791
- _triggerChange() {
792
- this._callbacks.forEach((callback) => callback(this.getHexString()));
793
- }
794
- }
795
400
  const ColorInput = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
796
401
  const props1 = _restProps(props, [
797
402
  "onInput$",
@@ -799,98 +404,16 @@ const ColorInput = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((prop
799
404
  "presetColors",
800
405
  "preview"
801
406
  ]);
802
- useStylesQrl(/* @__PURE__ */ inlinedQrl(`
803
- .color-picker {
804
- display: flex;
805
- gap: 12px;
806
- height: 185px !important;
807
- width: 100% !important;
808
- padding: 15px;
809
- border-radius: 10px;
810
- border: 1px solid rgb(31 41 55);
811
- filter: drop-shadow(0px 0px 5px rgba(0, 0, 0, 0.5));
812
- background: rgba(31 41 55 / 40%);
813
- backdrop-filter: blur(10px);
814
- user-select: none;
815
- position: relative;
816
- z-index: 1000;
817
- }
818
-
819
- .color-picker-saturation {
820
- position: relative;
821
- height: 100%;
822
- width: 100%;
823
- background: linear-gradient(to right, #FFFFFF, #FF0000);
824
- float: left;
825
- border-radius: 5px;
826
- border: 1px solid rgb(31 41 55);
827
- }
828
-
829
- .color-picker-brightness {
830
- width: 100%;
831
- height: 100%;
832
- background: linear-gradient(rgba(255, 255, 255, 0), rgba(0, 0, 0, 1));
833
- }
834
-
835
- .color-picker-sbSelector {
836
- border: 1px solid white;
837
- position: absolute;
838
- width: 14px;
839
- height: 14px;
840
- background: white;
841
- border-radius: 10px;
842
- top: -7px;
843
- left: -7px;
844
- box-sizing: border-box;
845
- }
846
-
847
- .color-picker-hue {
848
- width: 8px;
849
- border-radius: 5px;
850
- height: 100%;
851
- position: relative;
852
- float: left;
853
- 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%);
854
- border: 1px solid rgb(31 41 55);
855
- }
856
-
857
- .color-picker-colors {
858
- height: 100%;
859
- position: relative;
860
- display: flex;
861
- flex-direction: column;
862
- gap: 5px;
863
- float: left;
864
- justify-content: space-evenly;
865
- flex-wrap: wrap;
866
- }
867
-
868
- .color-picker-color {
869
- height: 25px;
870
- width: 25px;
871
- border-radius: 5px;
872
- position: relative;
873
- background: red;
874
- border: 1px solid rgb(31 41 55);
875
- }
876
-
877
- .color-picker-hSelector {
878
- border: 1px solid white;
879
- position: absolute;
880
- width: 14px;
881
- height: 14px;
882
- background: white;
883
- border-radius: 10px;
884
- top: -6px;
885
- left: -4px;
886
- box-sizing: border-box;
887
- }
888
- `, "ColorInput_component_useStyles_SMNFl4Oy0IA"));
889
- return /* @__PURE__ */ _jsxQ("div", null, null, [
407
+ const store = useStore({
408
+ opened: false
409
+ });
410
+ return /* @__PURE__ */ _jsxQ("div", null, {
411
+ class: "relative"
412
+ }, [
890
413
  /* @__PURE__ */ _jsxQ("label", {
891
414
  for: _wrapSignal(props1, "id")
892
415
  }, {
893
- class: "mb-2 flex"
416
+ class: "text-gray-300 pb-1 flex"
894
417
  }, /* @__PURE__ */ _jsxC(Slot, null, 3, "0s_0"), 1, null),
895
418
  /* @__PURE__ */ _jsxC(TextInputRaw, {
896
419
  ...props1,
@@ -898,54 +421,16 @@ const ColorInput = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((prop
898
421
  return props.value ?? "#000000";
899
422
  },
900
423
  onBlur$: /* @__PURE__ */ inlinedQrl(() => {
901
- const [props12] = useLexicalScope();
902
- const pickerDiv = document.getElementById(`${props12.id}-color-picker`);
903
- pickerDiv.classList.add("opacity-0", "pointer-events-none", "scale-95");
424
+ const [store2] = useLexicalScope();
425
+ store2.opened = false;
904
426
  }, "ColorInput_component_div_TextInputRaw_onBlur_giB7aSy8tnc", [
905
- props1
427
+ store
906
428
  ]),
907
- onFocus$: /* @__PURE__ */ inlinedQrl((event, element) => {
908
- const [props12, props2] = useLexicalScope();
909
- const pickerDiv = document.getElementById(`${props12.id}-color-picker`);
910
- if (!pickerDiv.children.length) {
911
- if (isServer)
912
- return;
913
- const picker = new ColorPicker({
914
- el: pickerDiv,
915
- color: props2.value ?? "#000000",
916
- colors: props2.presetColors,
917
- width: 150,
918
- height: 150
919
- });
920
- picker.onChange((color) => {
921
- element.value = color;
922
- switch (props2.preview ?? "left") {
923
- case "full":
924
- element.style.backgroundColor = color;
925
- element.style.color = getBrightness(hexNumberToRgb(hexStringToNumber(color))) > 0.5 ? "black" : "white";
926
- break;
927
- case "left":
928
- element.style.borderLeft = `40px solid ${color}`;
929
- break;
930
- case "right":
931
- element.style.borderRight = `40px solid ${color}`;
932
- break;
933
- case "top":
934
- element.style.borderTop = `10px solid ${color}`;
935
- break;
936
- case "bottom":
937
- element.style.borderBottom = `10px solid ${color}`;
938
- break;
939
- }
940
- if (props2.onInput$)
941
- props2.onInput$(color, element);
942
- });
943
- element.addEventListener("input", () => picker.setColor(element.value));
944
- }
945
- pickerDiv.classList.remove("opacity-0", "pointer-events-none", "scale-95");
429
+ onFocus$: /* @__PURE__ */ inlinedQrl(() => {
430
+ const [store2] = useLexicalScope();
431
+ store2.opened = true;
946
432
  }, "ColorInput_component_div_TextInputRaw_onFocus_9bHrhSeTgfI", [
947
- props1,
948
- props
433
+ store
949
434
  ]),
950
435
  style: (props.preview ?? "left") == "full" ? {
951
436
  backgroundColor: `${props.value ?? "#000000"}`,
@@ -960,18 +445,288 @@ const ColorInput = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((prop
960
445
  borderBottom: `10px solid ${props.value ?? "#000000"}`
961
446
  } : {},
962
447
  [_IMMUTABLE]: {
448
+ onBlur$: _IMMUTABLE,
449
+ onFocus$: _IMMUTABLE,
963
450
  value: _fnSignal((p0) => p0.value ?? "#000000", [
964
451
  props
965
452
  ], 'p0.value??"#000000"')
966
453
  }
967
454
  }, 0, "0s_1"),
968
- /* @__PURE__ */ _jsxQ("div", {
969
- id: `${props1.id}-color-picker`
970
- }, {
971
- class: "absolute mt-2 opacity-0 transition-all pointer-events-none scale-95"
972
- }, null, 3, null)
973
- ], 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");
974
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"));
975
730
  const LoadingIcon = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
976
731
  const props1 = _restProps(props, [
977
732
  "width",
@@ -998,8 +753,9 @@ const Header = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) =
998
753
  _jsxBranch();
999
754
  let Component = /* @__PURE__ */ _jsxC(Fragment, {
1000
755
  children: /* @__PURE__ */ _jsxQ("h2", null, {
1001
- class: "flex flex-1 items-center font-bold text-2xl"
756
+ class: "flex gap-2 flex-1 items-center font-bold text-2xl whitespace-nowrap"
1002
757
  }, [
758
+ /* @__PURE__ */ _jsxC(Slot, null, 3, "dL_0"),
1003
759
  props.id && /* @__PURE__ */ _jsxC(Anchor, {
1004
760
  get id() {
1005
761
  return props.id;
@@ -1009,8 +765,7 @@ const Header = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) =
1009
765
  props
1010
766
  ], "p0.id")
1011
767
  }
1012
- }, 3, "dL_0"),
1013
- /* @__PURE__ */ _jsxC(Slot, null, 3, "dL_1")
768
+ }, 3, "dL_1")
1014
769
  ], 1, null)
1015
770
  }, 1, "dL_2");
1016
771
  if (props.subheader)
@@ -1019,7 +774,7 @@ const Header = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) =
1019
774
  }, [
1020
775
  Component,
1021
776
  /* @__PURE__ */ _jsxQ("h3", null, {
1022
- class: "flex flex-1 items-center text-gray-400 text-sm"
777
+ class: "flex items-center text-gray-400 text-sm"
1023
778
  }, _fnSignal((p0) => p0.subheader, [
1024
779
  props
1025
780
  ], "p0.subheader"), 3, null)
@@ -1089,7 +844,7 @@ const NumberInput = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pro
1089
844
  class: "flex flex-col"
1090
845
  }, [
1091
846
  /* @__PURE__ */ _jsxQ("label", null, {
1092
- class: "pb-2",
847
+ class: "text-gray-300 pb-1",
1093
848
  for: _fnSignal((p0) => p0.id, [
1094
849
  props
1095
850
  ], "p0.id")
@@ -1175,6 +930,7 @@ const NumberInputRaw = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((
1175
930
  ...props1,
1176
931
  class: {
1177
932
  [InputClasses]: true,
933
+ "text-center": true,
1178
934
  ...props1.class
1179
935
  }
1180
936
  }, {
@@ -1254,7 +1010,7 @@ const SelectInput = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pro
1254
1010
  class: "flex flex-col"
1255
1011
  }, [
1256
1012
  /* @__PURE__ */ _jsxQ("label", null, {
1257
- class: "pb-2",
1013
+ class: "text-gray-300 pb-1",
1258
1014
  for: _fnSignal((p0) => p0.id, [
1259
1015
  props
1260
1016
  ], "p0.id")
@@ -1410,7 +1166,7 @@ const TextArea = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props)
1410
1166
  class: "flex flex-col"
1411
1167
  }, [
1412
1168
  /* @__PURE__ */ _jsxQ("label", null, {
1413
- class: "pb-2",
1169
+ class: "text-gray-300 pb-1",
1414
1170
  for: _fnSignal((p0) => p0.id, [
1415
1171
  props
1416
1172
  ], "p0.id")
@@ -1489,7 +1245,7 @@ const Toggle = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) =
1489
1245
  props.label && /* @__PURE__ */ _jsxQ("label", {
1490
1246
  for: _wrapSignal(props1, "id")
1491
1247
  }, {
1492
- class: "text-gray-100"
1248
+ class: "text-gray-300"
1493
1249
  }, _fnSignal((p0) => p0.label, [
1494
1250
  props
1495
1251
  ], "p0.label"), 3, "yu_0")
@@ -1936,6 +1692,7 @@ export {
1936
1692
  ButtonAnchor,
1937
1693
  Card,
1938
1694
  ColorInput,
1695
+ ColorPickerRaw,
1939
1696
  Header,
1940
1697
  InputClasses,
1941
1698
  LoadingIcon,