@opentinyvue/vue-color-select-panel 3.26.0 → 3.27.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.
package/lib/pc.js CHANGED
@@ -1,11 +1,13 @@
1
1
  import Button from '@opentinyvue/vue-button';
2
2
  import Input from '@opentinyvue/vue-input';
3
- import { renderless as renderless$3, api as api$3 } from '@opentinyvue/vue-renderless/color-select-panel/vue';
3
+ import Numeric from '@opentinyvue/vue-numeric';
4
+ import { renderless as renderless$4, api as api$4 } from '@opentinyvue/vue-renderless/color-select-panel/vue';
4
5
  import { defineComponent, setup, props, directive } from '@opentinyvue/vue-common';
5
- import { renderless as renderless$1, api as api$1 } from '@opentinyvue/vue-renderless/color-select-panel/hue-select/vue';
6
+ import { renderless as renderless$2, api as api$2 } from '@opentinyvue/vue-renderless/color-select-panel/hue-select/vue';
6
7
  import { api, renderless } from '@opentinyvue/vue-renderless/color-select-panel/sv-select/vue';
7
- import { openBlock, createElementBlock, normalizeStyle, createElementVNode, resolveComponent, createVNode, resolveDirective, withDirectives, withModifiers, createBlock, createCommentVNode, withCtx, Fragment, renderList, toDisplayString, createTextVNode } from 'vue';
8
- import { renderless as renderless$2, api as api$2 } from '@opentinyvue/vue-renderless/color-select-panel/alpha-select/vue';
8
+ import { openBlock, createElementBlock, normalizeStyle, createElementVNode, Fragment, renderList, withModifiers, resolveComponent, createVNode, createBlock, createCommentVNode, resolveDirective, withDirectives, withCtx, toDisplayString, createTextVNode } from 'vue';
9
+ import { renderless as renderless$1, api as api$1 } from '@opentinyvue/vue-renderless/color-select-panel/linear-gradient/vue';
10
+ import { renderless as renderless$3, api as api$3 } from '@opentinyvue/vue-renderless/color-select-panel/alpha-select/vue';
9
11
  import '@opentinyvue/vue-theme/color-select-panel/index.css';
10
12
  import { Clickoutside } from '@opentinyvue/vue-directive';
11
13
  import Select from '@opentinyvue/vue-select';
@@ -44,7 +46,7 @@ var _export_sfc = function _export_sfc2(sfc, props) {
44
46
  return target;
45
47
  };
46
48
 
47
- var _sfc_main$3 = defineComponent({
49
+ var _sfc_main$4 = defineComponent({
48
50
  emit: ["ready", "svUpdate"],
49
51
  props: {
50
52
  color: {
@@ -61,7 +63,7 @@ var _sfc_main$3 = defineComponent({
61
63
  });
62
64
  }
63
65
  });
64
- var _hoisted_1$2 = /* @__PURE__ */ createElementVNode(
66
+ var _hoisted_1$3 = /* @__PURE__ */ createElementVNode(
65
67
  "div",
66
68
  {
67
69
  class: "white"
@@ -79,7 +81,7 @@ var _hoisted_2$2 = /* @__PURE__ */ createElementVNode(
79
81
  -1
80
82
  /* HOISTED */
81
83
  );
82
- function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
84
+ function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
83
85
  return openBlock(), createElementBlock(
84
86
  "div",
85
87
  {
@@ -89,7 +91,7 @@ function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
89
91
  background: _ctx.state.bg
90
92
  })
91
93
  },
92
- [_hoisted_1$2, _hoisted_2$2, createElementVNode(
94
+ [_hoisted_1$3, _hoisted_2$2, createElementVNode(
93
95
  "div",
94
96
  {
95
97
  class: "cursor",
@@ -108,7 +110,72 @@ function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
108
110
  /* STYLE */
109
111
  );
110
112
  }
111
- var SvSelect = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$3]]);
113
+ var SvSelect = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$4]]);
114
+ var _sfc_main$3 = defineComponent({
115
+ props: {},
116
+ setup: function setup2(props2, context) {
117
+ return setup({
118
+ props: props2,
119
+ context,
120
+ renderless: renderless$1,
121
+ api: api$1,
122
+ mono: true
123
+ });
124
+ }
125
+ });
126
+ var _hoisted_1$2 = ["onMousedown"];
127
+ function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
128
+ return openBlock(), createElementBlock(
129
+ "div",
130
+ {
131
+ class: "tiny-color-select-panel__linear-gradient",
132
+ ref: "linearGradientBar",
133
+ onClick: _cache[1] || (_cache[1] = function() {
134
+ return _ctx.onClickBar && _ctx.onClickBar.apply(_ctx, arguments);
135
+ }),
136
+ style: normalizeStyle({
137
+ background: _ctx.state.linearGradientBarBackground
138
+ })
139
+ },
140
+ [(openBlock(true), createElementBlock(
141
+ Fragment,
142
+ null,
143
+ renderList(_ctx.context.colorPoints, function(point, idx) {
144
+ return openBlock(), createElementBlock("div", {
145
+ class: "tiny-color-select-panel__linear-gradient__thumb",
146
+ ref_for: true,
147
+ ref: "thumb",
148
+ key: idx,
149
+ onClick: _cache[0] || (_cache[0] = withModifiers(function() {
150
+ }, ["stop"])),
151
+ onMousedown: function onMousedown(event) {
152
+ return _ctx.onThumbMouseDown(event, point);
153
+ },
154
+ style: normalizeStyle({
155
+ left: point.cursorLeft + "px",
156
+ transform: "translateX(-50%)"
157
+ })
158
+ }, [createElementVNode(
159
+ "div",
160
+ {
161
+ class: "tiny-color-select-panel__linear-gradient__thumb-heart",
162
+ style: normalizeStyle({
163
+ background: point.color.value
164
+ })
165
+ },
166
+ null,
167
+ 4
168
+ /* STYLE */
169
+ )], 44, _hoisted_1$2);
170
+ }),
171
+ 128
172
+ /* KEYED_FRAGMENT */
173
+ ))],
174
+ 4
175
+ /* STYLE */
176
+ );
177
+ }
178
+ var linearGradient = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$3]]);
112
179
  var _sfc_main$2 = defineComponent({
113
180
  emits: ["hueUpdate", "svReady", "hueReady"],
114
181
  props: {
@@ -120,14 +187,15 @@ var _sfc_main$2 = defineComponent({
120
187
  }
121
188
  },
122
189
  components: {
123
- SvSelect
190
+ SvSelect,
191
+ LinearGradient: linearGradient
124
192
  },
125
- setup: function setup2(props2, context) {
193
+ setup: function setup3(props2, context) {
126
194
  return setup({
127
195
  props: props2,
128
196
  context,
129
- renderless: renderless$1,
130
- api: api$1,
197
+ renderless: renderless$2,
198
+ api: api$2,
131
199
  mono: true
132
200
  });
133
201
  }
@@ -141,6 +209,7 @@ var _hoisted_2$1 = {
141
209
  };
142
210
  function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
143
211
  var _component_sv_select = resolveComponent("sv-select");
212
+ var _component_linear_gradient = resolveComponent("linear-gradient");
144
213
  return openBlock(), createElementBlock("div", _hoisted_1$1, [createVNode(_component_sv_select, {
145
214
  color: _ctx.color,
146
215
  onReady: _ctx.onSvReady
@@ -162,7 +231,7 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
162
231
  {
163
232
  class: "tiny-color-select-panel__inner__hue-select-thumb-heart",
164
233
  style: normalizeStyle({
165
- background: _ctx.color.value
234
+ background: _ctx.state.ctx.activeColor.color.value
166
235
  })
167
236
  },
168
237
  null,
@@ -174,7 +243,9 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
174
243
  )],
175
244
  512
176
245
  /* NEED_PATCH */
177
- )]);
246
+ ), _ctx.state.ctx.colorMode === "linear-gradient" ? (openBlock(), createBlock(_component_linear_gradient, {
247
+ key: 0
248
+ })) : createCommentVNode("v-if", true)]);
178
249
  }
179
250
  var HueSelect = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2]]);
180
251
  var _sfc_main$1 = defineComponent({
@@ -184,12 +255,12 @@ var _sfc_main$1 = defineComponent({
184
255
  type: Object
185
256
  }
186
257
  },
187
- setup: function setup3(props2, context) {
258
+ setup: function setup4(props2, context) {
188
259
  return setup({
189
260
  props: props2,
190
261
  context,
191
- renderless: renderless$2,
192
- api: api$2,
262
+ renderless: renderless$3,
263
+ api: api$3,
193
264
  mono: true
194
265
  });
195
266
  }
@@ -232,7 +303,7 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
232
303
  {
233
304
  class: "tiny-color-select-panel__inner__hue-select-thumb-heart",
234
305
  style: normalizeStyle({
235
- background: _ctx.color.value
306
+ background: _ctx.state.activeColor.color.value
236
307
  })
237
308
  },
238
309
  null,
@@ -247,26 +318,533 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
247
318
  );
248
319
  }
249
320
  var AlphaSelect = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
321
+ var node = {};
322
+ var hasRequiredNode;
323
+ function requireNode() {
324
+ if (hasRequiredNode) return node;
325
+ hasRequiredNode = 1;
326
+ var GradientParser = GradientParser || {};
327
+ GradientParser.stringify = /* @__PURE__ */ (function() {
328
+ var visitor = {
329
+ "visit_linear-gradient": function visit_linearGradient(node2) {
330
+ return visitor.visit_gradient(node2);
331
+ },
332
+ "visit_repeating-linear-gradient": function visit_repeatingLinearGradient(node2) {
333
+ return visitor.visit_gradient(node2);
334
+ },
335
+ "visit_radial-gradient": function visit_radialGradient(node2) {
336
+ return visitor.visit_gradient(node2);
337
+ },
338
+ "visit_repeating-radial-gradient": function visit_repeatingRadialGradient(node2) {
339
+ return visitor.visit_gradient(node2);
340
+ },
341
+ "visit_gradient": function visit_gradient(node2) {
342
+ var orientation = visitor.visit(node2.orientation);
343
+ if (orientation) {
344
+ orientation += ", ";
345
+ }
346
+ return node2.type + "(" + orientation + visitor.visit(node2.colorStops) + ")";
347
+ },
348
+ "visit_shape": function visit_shape(node2) {
349
+ var result = node2.value, at = visitor.visit(node2.at), style = visitor.visit(node2.style);
350
+ if (style) {
351
+ result += " " + style;
352
+ }
353
+ if (at) {
354
+ result += " at " + at;
355
+ }
356
+ return result;
357
+ },
358
+ "visit_default-radial": function visit_defaultRadial(node2) {
359
+ var result = "", at = visitor.visit(node2.at);
360
+ if (at) {
361
+ result += at;
362
+ }
363
+ return result;
364
+ },
365
+ "visit_extent-keyword": function visit_extentKeyword(node2) {
366
+ var result = node2.value, at = visitor.visit(node2.at);
367
+ if (at) {
368
+ result += " at " + at;
369
+ }
370
+ return result;
371
+ },
372
+ "visit_position-keyword": function visit_positionKeyword(node2) {
373
+ return node2.value;
374
+ },
375
+ "visit_position": function visit_position(node2) {
376
+ return visitor.visit(node2.value.x) + " " + visitor.visit(node2.value.y);
377
+ },
378
+ "visit_%": function visit_(node2) {
379
+ return node2.value + "%";
380
+ },
381
+ "visit_em": function visit_em(node2) {
382
+ return node2.value + "em";
383
+ },
384
+ "visit_px": function visit_px(node2) {
385
+ return node2.value + "px";
386
+ },
387
+ "visit_calc": function visit_calc(node2) {
388
+ return "calc(" + node2.value + ")";
389
+ },
390
+ "visit_literal": function visit_literal(node2) {
391
+ return visitor.visit_color(node2.value, node2);
392
+ },
393
+ "visit_hex": function visit_hex(node2) {
394
+ return visitor.visit_color("#" + node2.value, node2);
395
+ },
396
+ "visit_rgb": function visit_rgb(node2) {
397
+ return visitor.visit_color("rgb(" + node2.value.join(", ") + ")", node2);
398
+ },
399
+ "visit_rgba": function visit_rgba(node2) {
400
+ return visitor.visit_color("rgba(" + node2.value.join(", ") + ")", node2);
401
+ },
402
+ "visit_hsl": function visit_hsl(node2) {
403
+ return visitor.visit_color("hsl(" + node2.value[0] + ", " + node2.value[1] + "%, " + node2.value[2] + "%)", node2);
404
+ },
405
+ "visit_hsla": function visit_hsla(node2) {
406
+ return visitor.visit_color("hsla(" + node2.value[0] + ", " + node2.value[1] + "%, " + node2.value[2] + "%, " + node2.value[3] + ")", node2);
407
+ },
408
+ "visit_var": function visit_var(node2) {
409
+ return visitor.visit_color("var(" + node2.value + ")", node2);
410
+ },
411
+ "visit_color": function visit_color(resultColor, node2) {
412
+ var result = resultColor, length = visitor.visit(node2.length);
413
+ if (length) {
414
+ result += " " + length;
415
+ }
416
+ return result;
417
+ },
418
+ "visit_angular": function visit_angular(node2) {
419
+ return node2.value + "deg";
420
+ },
421
+ "visit_directional": function visit_directional(node2) {
422
+ return "to " + node2.value;
423
+ },
424
+ "visit_array": function visit_array(elements) {
425
+ var result = "", size = elements.length;
426
+ elements.forEach(function(element, i) {
427
+ result += visitor.visit(element);
428
+ if (i < size - 1) {
429
+ result += ", ";
430
+ }
431
+ });
432
+ return result;
433
+ },
434
+ "visit_object": function visit_object(obj) {
435
+ if (obj.width && obj.height) {
436
+ return visitor.visit(obj.width) + " " + visitor.visit(obj.height);
437
+ }
438
+ return "";
439
+ },
440
+ "visit": function visit(element) {
441
+ if (!element) {
442
+ return "";
443
+ }
444
+ if (element instanceof Array) {
445
+ return visitor.visit_array(element);
446
+ } else if (typeof element === "object" && !element.type) {
447
+ return visitor.visit_object(element);
448
+ } else if (element.type) {
449
+ var nodeVisitor = visitor["visit_" + element.type];
450
+ if (nodeVisitor) {
451
+ return nodeVisitor(element);
452
+ } else {
453
+ throw Error("Missing visitor visit_" + element.type);
454
+ }
455
+ } else {
456
+ throw Error("Invalid node.");
457
+ }
458
+ }
459
+ };
460
+ return function(root) {
461
+ return visitor.visit(root);
462
+ };
463
+ })();
464
+ var GradientParser = GradientParser || {};
465
+ GradientParser.parse = /* @__PURE__ */ (function() {
466
+ var tokens = {
467
+ linearGradient: /^(\-(webkit|o|ms|moz)\-)?(linear\-gradient)/i,
468
+ repeatingLinearGradient: /^(\-(webkit|o|ms|moz)\-)?(repeating\-linear\-gradient)/i,
469
+ radialGradient: /^(\-(webkit|o|ms|moz)\-)?(radial\-gradient)/i,
470
+ repeatingRadialGradient: /^(\-(webkit|o|ms|moz)\-)?(repeating\-radial\-gradient)/i,
471
+ sideOrCorner: /^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,
472
+ extentKeywords: /^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,
473
+ positionKeywords: /^(left|center|right|top|bottom)/i,
474
+ pixelValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,
475
+ percentageValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,
476
+ emValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,
477
+ angleValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,
478
+ radianValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))rad/,
479
+ startCall: /^\(/,
480
+ endCall: /^\)/,
481
+ comma: /^,/,
482
+ hexColor: /^\#([0-9a-fA-F]+)/,
483
+ literalColor: /^([a-zA-Z]+)/,
484
+ rgbColor: /^rgb/i,
485
+ rgbaColor: /^rgba/i,
486
+ varColor: /^var/i,
487
+ calcValue: /^calc/i,
488
+ variableName: /^(--[a-zA-Z0-9-,\s\#]+)/,
489
+ number: /^(([0-9]*\.[0-9]+)|([0-9]+\.?))/,
490
+ hslColor: /^hsl/i,
491
+ hslaColor: /^hsla/i
492
+ };
493
+ var input = "";
494
+ function error(msg) {
495
+ var err = new Error(input + ": " + msg);
496
+ err.source = input;
497
+ throw err;
498
+ }
499
+ function getAST() {
500
+ var ast = matchListDefinitions();
501
+ if (input.length > 0) {
502
+ error("Invalid input not EOF");
503
+ }
504
+ return ast;
505
+ }
506
+ function matchListDefinitions() {
507
+ return matchListing(matchDefinition);
508
+ }
509
+ function matchDefinition() {
510
+ return matchGradient("linear-gradient", tokens.linearGradient, matchLinearOrientation) || matchGradient("repeating-linear-gradient", tokens.repeatingLinearGradient, matchLinearOrientation) || matchGradient("radial-gradient", tokens.radialGradient, matchListRadialOrientations) || matchGradient("repeating-radial-gradient", tokens.repeatingRadialGradient, matchListRadialOrientations);
511
+ }
512
+ function matchGradient(gradientType, pattern, orientationMatcher) {
513
+ return matchCall(pattern, function(captures) {
514
+ var orientation = orientationMatcher();
515
+ if (orientation) {
516
+ if (!scan(tokens.comma)) {
517
+ error("Missing comma before color stops");
518
+ }
519
+ }
520
+ return {
521
+ type: gradientType,
522
+ orientation,
523
+ colorStops: matchListing(matchColorStop)
524
+ };
525
+ });
526
+ }
527
+ function matchCall(pattern, callback) {
528
+ var captures = scan(pattern);
529
+ if (captures) {
530
+ if (!scan(tokens.startCall)) {
531
+ error("Missing (");
532
+ }
533
+ var result = callback(captures);
534
+ if (!scan(tokens.endCall)) {
535
+ error("Missing )");
536
+ }
537
+ return result;
538
+ }
539
+ }
540
+ function matchLinearOrientation() {
541
+ var sideOrCorner = matchSideOrCorner();
542
+ if (sideOrCorner) {
543
+ return sideOrCorner;
544
+ }
545
+ var legacyDirection = match("position-keyword", tokens.positionKeywords, 1);
546
+ if (legacyDirection) {
547
+ return {
548
+ type: "directional",
549
+ value: legacyDirection.value
550
+ };
551
+ }
552
+ return matchAngle();
553
+ }
554
+ function matchSideOrCorner() {
555
+ return match("directional", tokens.sideOrCorner, 1);
556
+ }
557
+ function matchAngle() {
558
+ return match("angular", tokens.angleValue, 1) || match("angular", tokens.radianValue, 1);
559
+ }
560
+ function matchListRadialOrientations() {
561
+ var radialOrientations, radialOrientation = matchRadialOrientation(), lookaheadCache;
562
+ if (radialOrientation) {
563
+ radialOrientations = [];
564
+ radialOrientations.push(radialOrientation);
565
+ lookaheadCache = input;
566
+ if (scan(tokens.comma)) {
567
+ radialOrientation = matchRadialOrientation();
568
+ if (radialOrientation) {
569
+ radialOrientations.push(radialOrientation);
570
+ } else {
571
+ input = lookaheadCache;
572
+ }
573
+ }
574
+ }
575
+ return radialOrientations;
576
+ }
577
+ function matchRadialOrientation() {
578
+ var radialType = matchCircle() || matchEllipse();
579
+ if (radialType) {
580
+ radialType.at = matchAtPosition();
581
+ } else {
582
+ var extent = matchExtentKeyword();
583
+ if (extent) {
584
+ radialType = extent;
585
+ var positionAt = matchAtPosition();
586
+ if (positionAt) {
587
+ radialType.at = positionAt;
588
+ }
589
+ } else {
590
+ var atPosition = matchAtPosition();
591
+ if (atPosition) {
592
+ radialType = {
593
+ type: "default-radial",
594
+ at: atPosition
595
+ };
596
+ } else {
597
+ var defaultPosition = matchPositioning();
598
+ if (defaultPosition) {
599
+ radialType = {
600
+ type: "default-radial",
601
+ at: defaultPosition
602
+ };
603
+ }
604
+ }
605
+ }
606
+ }
607
+ return radialType;
608
+ }
609
+ function matchCircle() {
610
+ var circle = match("shape", /^(circle)/i, 0);
611
+ if (circle) {
612
+ circle.style = matchLength() || matchExtentKeyword();
613
+ }
614
+ return circle;
615
+ }
616
+ function matchEllipse() {
617
+ var ellipse = match("shape", /^(ellipse)/i, 0);
618
+ if (ellipse) {
619
+ ellipse.style = matchPositioning() || matchDistance() || matchExtentKeyword();
620
+ }
621
+ return ellipse;
622
+ }
623
+ function matchExtentKeyword() {
624
+ return match("extent-keyword", tokens.extentKeywords, 1);
625
+ }
626
+ function matchAtPosition() {
627
+ if (match("position", /^at/, 0)) {
628
+ var positioning = matchPositioning();
629
+ if (!positioning) {
630
+ error("Missing positioning value");
631
+ }
632
+ return positioning;
633
+ }
634
+ }
635
+ function matchPositioning() {
636
+ var location = matchCoordinates();
637
+ if (location.x || location.y) {
638
+ return {
639
+ type: "position",
640
+ value: location
641
+ };
642
+ }
643
+ }
644
+ function matchCoordinates() {
645
+ return {
646
+ x: matchDistance(),
647
+ y: matchDistance()
648
+ };
649
+ }
650
+ function matchListing(matcher) {
651
+ var captures = matcher(), result = [];
652
+ if (captures) {
653
+ result.push(captures);
654
+ while (scan(tokens.comma)) {
655
+ captures = matcher();
656
+ if (captures) {
657
+ result.push(captures);
658
+ } else {
659
+ error("One extra comma");
660
+ }
661
+ }
662
+ }
663
+ return result;
664
+ }
665
+ function matchColorStop() {
666
+ var color = matchColor();
667
+ if (!color) {
668
+ error("Expected color definition");
669
+ }
670
+ color.length = matchDistance();
671
+ return color;
672
+ }
673
+ function matchColor() {
674
+ return matchHexColor() || matchHSLAColor() || matchHSLColor() || matchRGBAColor() || matchRGBColor() || matchVarColor() || matchLiteralColor();
675
+ }
676
+ function matchLiteralColor() {
677
+ return match("literal", tokens.literalColor, 0);
678
+ }
679
+ function matchHexColor() {
680
+ return match("hex", tokens.hexColor, 1);
681
+ }
682
+ function matchRGBColor() {
683
+ return matchCall(tokens.rgbColor, function() {
684
+ return {
685
+ type: "rgb",
686
+ value: matchListing(matchNumber)
687
+ };
688
+ });
689
+ }
690
+ function matchRGBAColor() {
691
+ return matchCall(tokens.rgbaColor, function() {
692
+ return {
693
+ type: "rgba",
694
+ value: matchListing(matchNumber)
695
+ };
696
+ });
697
+ }
698
+ function matchVarColor() {
699
+ return matchCall(tokens.varColor, function() {
700
+ return {
701
+ type: "var",
702
+ value: matchVariableName()
703
+ };
704
+ });
705
+ }
706
+ function matchHSLColor() {
707
+ return matchCall(tokens.hslColor, function() {
708
+ var lookahead = scan(tokens.percentageValue);
709
+ if (lookahead) {
710
+ error("HSL hue value must be a number in degrees (0-360) or normalized (-360 to 360), not a percentage");
711
+ }
712
+ var hue = matchNumber();
713
+ scan(tokens.comma);
714
+ var captures = scan(tokens.percentageValue);
715
+ var sat = captures ? captures[1] : null;
716
+ scan(tokens.comma);
717
+ captures = scan(tokens.percentageValue);
718
+ var light = captures ? captures[1] : null;
719
+ if (!sat || !light) {
720
+ error("Expected percentage value for saturation and lightness in HSL");
721
+ }
722
+ return {
723
+ type: "hsl",
724
+ value: [hue, sat, light]
725
+ };
726
+ });
727
+ }
728
+ function matchHSLAColor() {
729
+ return matchCall(tokens.hslaColor, function() {
730
+ var hue = matchNumber();
731
+ scan(tokens.comma);
732
+ var captures = scan(tokens.percentageValue);
733
+ var sat = captures ? captures[1] : null;
734
+ scan(tokens.comma);
735
+ captures = scan(tokens.percentageValue);
736
+ var light = captures ? captures[1] : null;
737
+ scan(tokens.comma);
738
+ var alpha = matchNumber();
739
+ if (!sat || !light) {
740
+ error("Expected percentage value for saturation and lightness in HSLA");
741
+ }
742
+ return {
743
+ type: "hsla",
744
+ value: [hue, sat, light, alpha]
745
+ };
746
+ });
747
+ }
748
+ function matchVariableName() {
749
+ return scan(tokens.variableName)[1];
750
+ }
751
+ function matchNumber() {
752
+ return scan(tokens.number)[1];
753
+ }
754
+ function matchDistance() {
755
+ return match("%", tokens.percentageValue, 1) || matchPositionKeyword() || matchCalc() || matchLength();
756
+ }
757
+ function matchPositionKeyword() {
758
+ return match("position-keyword", tokens.positionKeywords, 1);
759
+ }
760
+ function matchCalc() {
761
+ return matchCall(tokens.calcValue, function() {
762
+ var openParenCount = 1;
763
+ var i = 0;
764
+ while (openParenCount > 0 && i < input.length) {
765
+ var char = input.charAt(i);
766
+ if (char === "(") {
767
+ openParenCount++;
768
+ } else if (char === ")") {
769
+ openParenCount--;
770
+ }
771
+ i++;
772
+ }
773
+ if (openParenCount > 0) {
774
+ error("Missing closing parenthesis in calc() expression");
775
+ }
776
+ var calcContent = input.substring(0, i - 1);
777
+ consume(i - 1);
778
+ return {
779
+ type: "calc",
780
+ value: calcContent
781
+ };
782
+ });
783
+ }
784
+ function matchLength() {
785
+ return match("px", tokens.pixelValue, 1) || match("em", tokens.emValue, 1);
786
+ }
787
+ function match(type, pattern, captureIndex) {
788
+ var captures = scan(pattern);
789
+ if (captures) {
790
+ return {
791
+ type,
792
+ value: captures[captureIndex]
793
+ };
794
+ }
795
+ }
796
+ function scan(regexp) {
797
+ var captures, blankCaptures;
798
+ blankCaptures = /^[\n\r\t\s]+/.exec(input);
799
+ if (blankCaptures) {
800
+ consume(blankCaptures[0].length);
801
+ }
802
+ captures = regexp.exec(input);
803
+ if (captures) {
804
+ consume(captures[0].length);
805
+ }
806
+ return captures;
807
+ }
808
+ function consume(size) {
809
+ input = input.substr(size);
810
+ }
811
+ return function(code) {
812
+ input = code.toString().trim();
813
+ if (input.endsWith(";")) {
814
+ input = input.slice(0, -1);
815
+ }
816
+ return getAST();
817
+ };
818
+ })();
819
+ node.parse = GradientParser.parse;
820
+ node.stringify = GradientParser.stringify;
821
+ return node;
822
+ }
823
+ var nodeExports = requireNode();
250
824
  var _sfc_main = defineComponent({
251
825
  emits: ["update:modelValue", "cancel", "confirm", "color-update"],
252
- props: [].concat(props, ["modelValue", "visible", "alpha", "history", "predefine", "format", "enableHistory", "enablePredefineColor"]),
826
+ props: [].concat(props, ["modelValue", "visible", "alpha", "history", "predefine", "format", "enableHistory", "enablePredefineColor", "colorMode"]),
253
827
  components: {
254
828
  HueSelect,
255
829
  AlphaSelect,
256
830
  TinyButton: Button,
257
831
  TinyInput: Input,
258
832
  TinySelect: Select,
259
- TinyOption: Option
833
+ TinyOption: Option,
834
+ TinyNumeric: Numeric
260
835
  },
261
836
  directives: directive({
262
837
  Clickoutside
263
838
  }),
264
- setup: function setup4(props2, context) {
839
+ setup: function setup5(props2, context) {
265
840
  return setup({
266
841
  props: props2,
267
842
  context,
268
- renderless: renderless$3,
269
- api: api$3
843
+ renderless: renderless$4,
844
+ api: api$4,
845
+ extendOptions: {
846
+ parse: nodeExports.parse
847
+ }
270
848
  });
271
849
  }
272
850
  });
@@ -289,27 +867,31 @@ var _hoisted_5 = {
289
867
  class: "tiny-color-select-panel__tools-hex"
290
868
  };
291
869
  var _hoisted_6 = {
870
+ key: 0,
871
+ class: "tiny-color-select-panel__tools-deg"
872
+ };
873
+ var _hoisted_7 = {
292
874
  key: 1,
293
875
  class: "tiny-color-select-panel__tools-hex"
294
876
  };
295
- var _hoisted_7 = {
877
+ var _hoisted_8 = {
296
878
  key: 2
297
879
  };
298
- var _hoisted_8 = {
880
+ var _hoisted_9 = {
299
881
  key: 0,
300
882
  class: "tiny-color-select-panel__history"
301
883
  };
302
- var _hoisted_9 = ["onClick"];
303
- var _hoisted_10 = {
884
+ var _hoisted_10 = ["onClick"];
885
+ var _hoisted_11 = {
304
886
  key: 3,
305
887
  class: "tiny-color-select-panel__predefine-title"
306
888
  };
307
- var _hoisted_11 = {
889
+ var _hoisted_12 = {
308
890
  key: 4,
309
891
  class: "tiny-color-select-panel__predefine"
310
892
  };
311
- var _hoisted_12 = ["onClick"];
312
- var _hoisted_13 = {
893
+ var _hoisted_13 = ["onClick"];
894
+ var _hoisted_14 = {
313
895
  class: "tiny-color-select-panel__tools-btns"
314
896
  };
315
897
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
@@ -318,12 +900,13 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
318
900
  var _component_tiny_option = resolveComponent("tiny-option");
319
901
  var _component_tiny_select = resolveComponent("tiny-select");
320
902
  var _component_tiny_input = resolveComponent("tiny-input");
903
+ var _component_tiny_numeric = resolveComponent("tiny-numeric");
321
904
  var _component_tiny_button = resolveComponent("tiny-button");
322
905
  var _directive_clickoutside = resolveDirective("clickoutside");
323
906
  return _ctx.state.showPicker ? withDirectives((openBlock(), createElementBlock("div", {
324
907
  key: 0,
325
908
  class: "tiny-color-select-panel",
326
- onClick: _cache[6] || (_cache[6] = withModifiers(function() {
909
+ onClick: _cache[7] || (_cache[7] = withModifiers(function() {
327
910
  }, ["stop"]))
328
911
  }, [createVNode(_component_hue_select, {
329
912
  color: _ctx.state.color,
@@ -338,7 +921,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
338
921
  {
339
922
  class: "tiny-color-select-panel__display",
340
923
  style: normalizeStyle({
341
- background: _ctx.state.color.value
924
+ background: _ctx.state.isLinearGradient ? _ctx.state.linearGradient : _ctx.state.color.value
342
925
  })
343
926
  },
344
927
  null,
@@ -374,31 +957,38 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
374
957
  "onUpdate:modelValue": _cache[1] || (_cache[1] = function($event) {
375
958
  return _ctx.state.input = $event;
376
959
  })
377
- }, null, 8, ["modelValue"])])) : (openBlock(), createElementBlock("div", _hoisted_6, [createVNode(_component_tiny_input, {
960
+ }, null, 8, ["modelValue"]), _ctx.state.isLinearGradient ? (openBlock(), createElementBlock("div", _hoisted_6, [createVNode(_component_tiny_numeric, {
961
+ modelValue: _ctx.state.ctx.deg,
962
+ "onUpdate:modelValue": _cache[2] || (_cache[2] = function($event) {
963
+ return _ctx.state.ctx.deg = $event;
964
+ }),
965
+ unit: "deg",
966
+ "mouse-wheel": ""
967
+ }, null, 8, ["modelValue"])])) : createCommentVNode("v-if", true)])) : (openBlock(), createElementBlock("div", _hoisted_7, [createVNode(_component_tiny_input, {
378
968
  class: "tiny-color-select-panel__tools-hex4",
379
969
  modelValue: _ctx.state.hexInput4,
380
- "onUpdate:modelValue": _cache[2] || (_cache[2] = function($event) {
970
+ "onUpdate:modelValue": _cache[3] || (_cache[3] = function($event) {
381
971
  return _ctx.state.hexInput4 = $event;
382
972
  })
383
973
  }, null, 8, ["modelValue"]), createVNode(_component_tiny_input, {
384
974
  class: "tiny-color-select-panel__tools-hex5",
385
975
  modelValue: _ctx.state.hexInput5,
386
- "onUpdate:modelValue": _cache[3] || (_cache[3] = function($event) {
976
+ "onUpdate:modelValue": _cache[4] || (_cache[4] = function($event) {
387
977
  return _ctx.state.hexInput5 = $event;
388
978
  })
389
979
  }, null, 8, ["modelValue"]), createVNode(_component_tiny_input, {
390
980
  class: "tiny-color-select-panel__tools-hex6",
391
981
  modelValue: _ctx.state.hexInput6,
392
- "onUpdate:modelValue": _cache[4] || (_cache[4] = function($event) {
982
+ "onUpdate:modelValue": _cache[5] || (_cache[5] = function($event) {
393
983
  return _ctx.state.hexInput6 = $event;
394
984
  })
395
985
  }, null, 8, ["modelValue"]), createVNode(_component_tiny_input, {
396
986
  class: "tiny-color-select-panel__tools-hex7",
397
987
  modelValue: _ctx.state.hexInput7,
398
- "onUpdate:modelValue": _cache[5] || (_cache[5] = function($event) {
988
+ "onUpdate:modelValue": _cache[6] || (_cache[6] = function($event) {
399
989
  return _ctx.state.hexInput7 = $event;
400
990
  })
401
- }, null, 8, ["modelValue"])]))])]), _ctx.state.enableHistory ? (openBlock(), createElementBlock("div", _hoisted_7, [_ctx.state.enableHistory && _ctx.state.stack.length ? (openBlock(), createElementBlock("div", _hoisted_8, [(openBlock(true), createElementBlock(
991
+ }, null, 8, ["modelValue"])]))])]), _ctx.state.enableHistory ? (openBlock(), createElementBlock("div", _hoisted_8, [_ctx.state.enableHistory && _ctx.state.stack.length ? (openBlock(), createElementBlock("div", _hoisted_9, [(openBlock(true), createElementBlock(
402
992
  Fragment,
403
993
  null,
404
994
  renderList(_ctx.state.stack, function(color, key) {
@@ -411,17 +1001,17 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
411
1001
  onClick: function onClick() {
412
1002
  return _ctx.onHistoryClick(color);
413
1003
  }
414
- }, null, 12, _hoisted_9);
1004
+ }, null, 12, _hoisted_10);
415
1005
  }),
416
1006
  128
417
1007
  /* KEYED_FRAGMENT */
418
1008
  ))])) : createCommentVNode("v-if", true)])) : createCommentVNode("v-if", true), _ctx.state.enablePredefineColor ? (openBlock(), createElementBlock(
419
1009
  "div",
420
- _hoisted_10,
1010
+ _hoisted_11,
421
1011
  toDisplayString(_ctx.t("ui.colorSelectPanel.predefine")),
422
1012
  1
423
1013
  /* TEXT */
424
- )) : createCommentVNode("v-if", true), _ctx.state.enablePredefineColor && _ctx.state.predefineStack.length ? (openBlock(), createElementBlock("div", _hoisted_11, [(openBlock(true), createElementBlock(
1014
+ )) : createCommentVNode("v-if", true), _ctx.state.enablePredefineColor && _ctx.state.predefineStack.length ? (openBlock(), createElementBlock("div", _hoisted_12, [(openBlock(true), createElementBlock(
425
1015
  Fragment,
426
1016
  null,
427
1017
  renderList(_ctx.state.predefineStack, function(color, key) {
@@ -434,11 +1024,11 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
434
1024
  onClick: function onClick() {
435
1025
  return _ctx.onPredefineColorClick(color);
436
1026
  }
437
- }, null, 12, _hoisted_12);
1027
+ }, null, 12, _hoisted_13);
438
1028
  }),
439
1029
  128
440
1030
  /* KEYED_FRAGMENT */
441
- ))])) : createCommentVNode("v-if", true), createElementVNode("div", _hoisted_13, [createVNode(_component_tiny_button, {
1031
+ ))])) : createCommentVNode("v-if", true), createElementVNode("div", _hoisted_14, [createVNode(_component_tiny_button, {
442
1032
  size: "small",
443
1033
  type: "primary",
444
1034
  onClick: _ctx.onConfirm
package/package.json CHANGED
@@ -1,23 +1,25 @@
1
1
  {
2
2
  "name": "@opentinyvue/vue-color-select-panel",
3
3
  "type": "module",
4
- "version": "3.26.0",
4
+ "version": "3.27.0",
5
5
  "description": "",
6
6
  "license": "MIT",
7
7
  "sideEffects": false,
8
8
  "main": "./lib/index.js",
9
9
  "module": "./lib/index.js",
10
10
  "dependencies": {
11
- "@opentinyvue/vue-button": "~3.26.0",
12
- "@opentinyvue/vue-collapse": "~3.26.0",
13
- "@opentinyvue/vue-collapse-item": "~3.26.0",
14
- "@opentinyvue/vue-common": "~3.26.0",
15
- "@opentinyvue/vue-directive": "~3.26.0",
16
- "@opentinyvue/vue-input": "~3.26.0",
17
- "@opentinyvue/vue-option": "~3.26.0",
18
- "@opentinyvue/vue-renderless": "~3.26.0",
19
- "@opentinyvue/vue-select": "~3.26.0",
20
- "@opentinyvue/vue-theme": "~3.26.0"
11
+ "@opentinyvue/vue-button": "~3.27.0",
12
+ "@opentinyvue/vue-collapse": "~3.27.0",
13
+ "@opentinyvue/vue-collapse-item": "~3.27.0",
14
+ "@opentinyvue/vue-common": "~3.27.0",
15
+ "@opentinyvue/vue-directive": "~3.27.0",
16
+ "@opentinyvue/vue-input": "~3.27.0",
17
+ "@opentinyvue/vue-numeric": "~3.27.0",
18
+ "@opentinyvue/vue-option": "~3.27.0",
19
+ "@opentinyvue/vue-renderless": "~3.27.0",
20
+ "@opentinyvue/vue-select": "~3.27.0",
21
+ "@opentinyvue/vue-theme": "~3.27.0",
22
+ "gradient-parser": "^1.1.1"
21
23
  },
22
24
  "types": "index.d.ts"
23
25
  }
@@ -0,0 +1,17 @@
1
+ declare const _default: import("@vue/runtime-core").DefineComponent<Readonly<import("@vue/runtime-core").ComponentPropsOptions<{
2
+ [x: string]: unknown;
3
+ }>>, {
4
+ t: (this: any, path: any, options?: any) => any;
5
+ vm: any;
6
+ f: (props: any, attrs?: {}) => {};
7
+ a: (attrs: any, filters: any, include: any) => {};
8
+ d: (props: any) => void;
9
+ dp: (props: any) => void;
10
+ gcls: (key: any) => any;
11
+ m: (...cssClasses: any[]) => string;
12
+ }, any, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {}, string, import("@vue/runtime-core").PublicProps, readonly string[] | Readonly<import("@vue/runtime-core").ExtractPropTypes<Readonly<import("@vue/runtime-core").ComponentObjectPropsOptions<{
13
+ [x: string]: unknown;
14
+ }>>>>, {
15
+ readonly [x: number]: string;
16
+ } | {}, {}>;
17
+ export default _default;
package/src/pc.vue.d.ts CHANGED
@@ -15,6 +15,7 @@ declare const _default: import("@vue/runtime-core").DefineComponent<Readonly<{
15
15
  history?: any;
16
16
  enableHistory?: any;
17
17
  enablePredefineColor?: any;
18
+ colorMode?: any;
18
19
  }>, {
19
20
  t: (this: any, path: any, options?: any) => any;
20
21
  vm: any;
@@ -41,6 +42,7 @@ declare const _default: import("@vue/runtime-core").DefineComponent<Readonly<{
41
42
  history?: any;
42
43
  enableHistory?: any;
43
44
  enablePredefineColor?: any;
45
+ colorMode?: any;
44
46
  }>>> & {
45
47
  onCancel?: ((...args: any[]) => any) | undefined;
46
48
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
@@ -63,5 +65,6 @@ declare const _default: import("@vue/runtime-core").DefineComponent<Readonly<{
63
65
  readonly history?: any;
64
66
  readonly enableHistory?: any;
65
67
  readonly enablePredefineColor?: any;
68
+ readonly colorMode?: any;
66
69
  }, {}>;
67
70
  export default _default;