@flourish/ui-styles 6.0.0 → 6.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/RELEASE_NOTES.md +6 -0
- package/controls-style/settings.yml +3 -3
- package/package.json +15 -9
- package/rollup.config.mjs +11 -6
- package/src/button-style/index.js +59 -20
- package/src/dropdown-style/index.js +67 -27
- package/src/general-controls-style/index.js +19 -12
- package/src/index.js +6 -1
- package/src/lib/js2css.js +10 -9
- package/src/slider-style/index.js +31 -16
- package/ui-styles.js +277 -85
- package/ui-styles.min.js +1 -1
package/ui-styles.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
return this;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
Stylesheet.prototype.select = function(selector) {
|
|
12
|
+
Stylesheet.prototype.select = function (selector) {
|
|
13
13
|
if (!selector) return this;
|
|
14
14
|
var declaration = new Declaration(selector);
|
|
15
15
|
declaration.parent = this;
|
|
@@ -18,16 +18,16 @@
|
|
|
18
18
|
return declaration;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
Stylesheet.prototype.addDeclaration = function(declaration) {
|
|
21
|
+
Stylesheet.prototype.addDeclaration = function (declaration) {
|
|
22
22
|
this.declarations.push(declaration);
|
|
23
23
|
return this;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
Stylesheet.prototype.print = function() {
|
|
26
|
+
Stylesheet.prototype.print = function () {
|
|
27
27
|
var text = "";
|
|
28
|
-
this.declarations.forEach(function(declaration) {
|
|
28
|
+
this.declarations.forEach(function (declaration) {
|
|
29
29
|
text += declaration.selector + " {\n";
|
|
30
|
-
declaration.styles.forEach(function(style) {
|
|
30
|
+
declaration.styles.forEach(function (style) {
|
|
31
31
|
text += "\t" + style[0] + ": " + style[1] + ";\n";
|
|
32
32
|
});
|
|
33
33
|
text += "}\n\n";
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
return text;
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
Stylesheet.prototype.clear = function() {
|
|
38
|
+
Stylesheet.prototype.clear = function () {
|
|
39
39
|
this.declarations = [];
|
|
40
40
|
return this;
|
|
41
41
|
};
|
|
@@ -46,25 +46,28 @@
|
|
|
46
46
|
return this;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
Declaration.prototype.style = function(property, _value) {
|
|
49
|
+
Declaration.prototype.style = function (property, _value) {
|
|
50
50
|
var value = typeof value_ == "function" ? _value() : _value;
|
|
51
|
-
if (value !== "" && value !== null && value !== undefined)
|
|
51
|
+
if (value !== "" && value !== null && value !== undefined)
|
|
52
|
+
this.styles.push([property, value]);
|
|
52
53
|
return this;
|
|
53
54
|
};
|
|
54
55
|
|
|
55
|
-
Declaration.prototype.select = function(selector) {
|
|
56
|
+
Declaration.prototype.select = function (selector) {
|
|
56
57
|
return this.parent.select(this.selector + " " + selector);
|
|
57
58
|
};
|
|
58
59
|
|
|
59
60
|
var DEFAULTS$3 = Object.freeze({
|
|
60
61
|
font_size: 1,
|
|
61
62
|
font_weight: "bold",
|
|
62
|
-
height: 2
|
|
63
|
+
height: 2,
|
|
63
64
|
});
|
|
64
65
|
|
|
65
66
|
function GeneralControlsStyle(state_, selector_, layout_) {
|
|
66
67
|
this._state = state_;
|
|
67
|
-
for (var key in DEFAULTS$3) {
|
|
68
|
+
for (var key in DEFAULTS$3) {
|
|
69
|
+
if (this._state[key] === undefined) this._state[key] = DEFAULTS$3[key];
|
|
70
|
+
}
|
|
68
71
|
|
|
69
72
|
this._layout = layout_ || {};
|
|
70
73
|
|
|
@@ -75,44 +78,49 @@
|
|
|
75
78
|
return this;
|
|
76
79
|
}
|
|
77
80
|
|
|
78
|
-
GeneralControlsStyle.prototype._createStylesheet = function() {
|
|
81
|
+
GeneralControlsStyle.prototype._createStylesheet = function () {
|
|
79
82
|
this._stylesheet = document.createElement("style");
|
|
80
83
|
this._stylesheet.className = "fl-ui-styles-controls";
|
|
81
84
|
document.head.appendChild(this._stylesheet);
|
|
82
85
|
};
|
|
83
86
|
|
|
84
|
-
GeneralControlsStyle.prototype.update = function() {
|
|
87
|
+
GeneralControlsStyle.prototype.update = function () {
|
|
85
88
|
this._styles.clear();
|
|
86
89
|
|
|
87
|
-
this._styles.select(this._selector + ".hidden")
|
|
88
|
-
.style("display", "none");
|
|
90
|
+
this._styles.select(this._selector + ".hidden").style("display", "none");
|
|
89
91
|
|
|
90
|
-
this._styles
|
|
92
|
+
this._styles
|
|
93
|
+
.select(this._selector)
|
|
91
94
|
.style("vertical-align", "middle")
|
|
92
95
|
.style("position", "relative")
|
|
93
96
|
.style("font-size", this._state.font_size + "rem")
|
|
94
97
|
.style("font-weight", this._state.font_weight);
|
|
95
98
|
|
|
96
|
-
this._styles
|
|
99
|
+
this._styles
|
|
100
|
+
.select(".fl-controls-title")
|
|
97
101
|
.style("font-size", this._state.font_size + "rem")
|
|
98
102
|
.style("font-weight", this._state.font_weight)
|
|
99
103
|
.style("vertical-align", "middle");
|
|
100
104
|
|
|
101
|
-
this._styles
|
|
105
|
+
this._styles
|
|
106
|
+
.select(this._selector + ".fl-control .button")
|
|
102
107
|
.style("height", this._state.height + "rem")
|
|
103
108
|
.style("padding", "0 0.5em");
|
|
104
109
|
|
|
105
|
-
this._styles
|
|
110
|
+
this._styles
|
|
111
|
+
.select(this._selector + "-dropdown select")
|
|
106
112
|
.style("height", this._state.height + "rem")
|
|
107
113
|
.style("font-size", this._state.font_size + "rem")
|
|
108
114
|
.style("font-weight", this._state.font_weight)
|
|
109
115
|
.style("padding", 0 + " " + this._state.height * 0.1 + "rem");
|
|
110
116
|
|
|
111
|
-
this._styles
|
|
117
|
+
this._styles
|
|
118
|
+
.select(this._selector + "-slider .slider-end-labels")
|
|
112
119
|
.style("font-size", this._state.font_size + "rem")
|
|
113
120
|
.style("font-weight", this._state.font_weight);
|
|
114
121
|
|
|
115
|
-
this._styles
|
|
122
|
+
this._styles
|
|
123
|
+
.select(this._selector + "-slider")
|
|
116
124
|
.style("height", this._state.height + "rem");
|
|
117
125
|
|
|
118
126
|
// Some additional styling for slider controls
|
|
@@ -621,8 +629,33 @@
|
|
|
621
629
|
each: proto.each
|
|
622
630
|
};
|
|
623
631
|
|
|
632
|
+
// This is an exception because mocha doesn't run in a browser context, so some
|
|
633
|
+
// browser methods aren't available.
|
|
634
|
+
const is_browser =
|
|
635
|
+
typeof window !== "undefined" &&
|
|
636
|
+
typeof document !== "undefined" &&
|
|
637
|
+
typeof document.createElement === "function" &&
|
|
638
|
+
typeof document.body?.appendChild === "function" &&
|
|
639
|
+
typeof HTMLElement !== "undefined";
|
|
640
|
+
|
|
624
641
|
const canvas = document.createElement("canvas");
|
|
625
|
-
canvas.getContext("2d");
|
|
642
|
+
const ctx = canvas.getContext("2d");
|
|
643
|
+
|
|
644
|
+
const tnums_svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
645
|
+
const tnums_text_element = document.createElementNS(
|
|
646
|
+
"http://www.w3.org/2000/svg",
|
|
647
|
+
"text",
|
|
648
|
+
);
|
|
649
|
+
tnums_svg.appendChild(tnums_text_element);
|
|
650
|
+
if (is_browser) {
|
|
651
|
+
canvas.style.position = "fixed";
|
|
652
|
+
canvas.style.left = "1000vw";
|
|
653
|
+
tnums_svg.style.position = "fixed";
|
|
654
|
+
tnums_svg.style.left = "1000vw";
|
|
655
|
+
document.body.appendChild(canvas);
|
|
656
|
+
document.body.appendChild(tnums_svg);
|
|
657
|
+
}
|
|
658
|
+
let is_browser_supporting_tnums_in_canvas = null;
|
|
626
659
|
|
|
627
660
|
function getTextDirection() {
|
|
628
661
|
return window.getComputedStyle(document.body).direction || "ltr";
|
|
@@ -641,6 +674,71 @@
|
|
|
641
674
|
return c ? c.toString() : false;
|
|
642
675
|
}
|
|
643
676
|
|
|
677
|
+
function checkBrowserTnumSupport() {
|
|
678
|
+
const test_tnum_string = "0123456789.,£";
|
|
679
|
+
const no_tnum_canvas = document.createElement("canvas");
|
|
680
|
+
const tnum_canvas = document.createElement("canvas");
|
|
681
|
+
const no_tnum_ctx = no_tnum_canvas.getContext("2d");
|
|
682
|
+
const tnum_ctx = tnum_canvas.getContext("2d");
|
|
683
|
+
|
|
684
|
+
no_tnum_canvas.setAttribute(
|
|
685
|
+
"style",
|
|
686
|
+
"font-feature-settings: normal; font-variant-numeric: normal; position: fixed; left: 1000vw;",
|
|
687
|
+
);
|
|
688
|
+
tnum_canvas.setAttribute(
|
|
689
|
+
"style",
|
|
690
|
+
'font-feature-settings: "tnum" 1; font-variant-numeric: tabular-nums; position: fixed; left: 1000vw;',
|
|
691
|
+
);
|
|
692
|
+
|
|
693
|
+
no_tnum_ctx.font = tnum_ctx.font = ctx.font;
|
|
694
|
+
|
|
695
|
+
document.body.appendChild(no_tnum_canvas);
|
|
696
|
+
document.body.appendChild(tnum_canvas);
|
|
697
|
+
|
|
698
|
+
const width_no_tnum = no_tnum_ctx.measureText(test_tnum_string).width;
|
|
699
|
+
const width_tnum = tnum_ctx.measureText(test_tnum_string).width;
|
|
700
|
+
|
|
701
|
+
is_browser_supporting_tnums_in_canvas = width_no_tnum !== width_tnum;
|
|
702
|
+
|
|
703
|
+
document.body.removeChild(no_tnum_canvas);
|
|
704
|
+
document.body.removeChild(tnum_canvas);
|
|
705
|
+
|
|
706
|
+
return is_browser_supporting_tnums_in_canvas;
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
ctx.measureTextWithTnums = function (text) {
|
|
710
|
+
if (!is_browser) return ctx.measureText(text);
|
|
711
|
+
const computed_style = window.getComputedStyle(this.canvas);
|
|
712
|
+
const is_tnums_style_set =
|
|
713
|
+
(computed_style.fontFeatureSettings || "").includes("tnum") ||
|
|
714
|
+
(computed_style.fontVariantNumeric || "").includes("tabular-nums");
|
|
715
|
+
|
|
716
|
+
// No tnums set for this text, so measure using canvas
|
|
717
|
+
if (!is_tnums_style_set) return this.measureText(text);
|
|
718
|
+
|
|
719
|
+
// Tnums are set, check if browser supports it
|
|
720
|
+
if (is_browser_supporting_tnums_in_canvas === null) checkBrowserTnumSupport();
|
|
721
|
+
|
|
722
|
+
// Browser supports tnums in canvas, measure text
|
|
723
|
+
if (is_browser_supporting_tnums_in_canvas) return this.measureText(text);
|
|
724
|
+
|
|
725
|
+
// Browser does not support tnums in canvas, measure text using svg instead
|
|
726
|
+
tnums_text_element.textContent = text;
|
|
727
|
+
tnums_text_element.setAttribute(
|
|
728
|
+
"style",
|
|
729
|
+
`font: ${ctx.font}; font-feature-settings: 'tnum' 1; font-variant-numeric: tabular-nums; position: fixed; left: 1000vw;`,
|
|
730
|
+
);
|
|
731
|
+
|
|
732
|
+
let svg_text_width = tnums_text_element.getBBox().width;
|
|
733
|
+
|
|
734
|
+
// measureText in order to return a full TextMetrics object with the svg measured width
|
|
735
|
+
const measured_text = this.measureText(text);
|
|
736
|
+
return {
|
|
737
|
+
...measured_text,
|
|
738
|
+
width: svg_text_width,
|
|
739
|
+
};
|
|
740
|
+
};
|
|
741
|
+
|
|
644
742
|
var DEFAULTS$2 = Object.freeze({
|
|
645
743
|
background: null,
|
|
646
744
|
font_color: null,
|
|
@@ -654,12 +752,14 @@
|
|
|
654
752
|
border_width: 1,
|
|
655
753
|
border_transparency: 0.25,
|
|
656
754
|
border_color: null,
|
|
657
|
-
border_radius: 3
|
|
755
|
+
border_radius: 3,
|
|
658
756
|
});
|
|
659
757
|
|
|
660
758
|
function ButtonStyle(state_, selector_, layout_) {
|
|
661
759
|
this._state = state_;
|
|
662
|
-
for (var key in DEFAULTS$2) {
|
|
760
|
+
for (var key in DEFAULTS$2) {
|
|
761
|
+
if (this._state[key] === undefined) this._state[key] = DEFAULTS$2[key];
|
|
762
|
+
}
|
|
663
763
|
|
|
664
764
|
this._layout = layout_ || {};
|
|
665
765
|
|
|
@@ -670,24 +770,34 @@
|
|
|
670
770
|
return this;
|
|
671
771
|
}
|
|
672
772
|
|
|
673
|
-
ButtonStyle.prototype._createStylesheet = function() {
|
|
773
|
+
ButtonStyle.prototype._createStylesheet = function () {
|
|
674
774
|
this._stylesheet = document.createElement("style");
|
|
675
775
|
this._stylesheet.className = "fl-ui-styles-button";
|
|
676
776
|
document.head.appendChild(this._stylesheet);
|
|
677
777
|
};
|
|
678
778
|
|
|
679
|
-
ButtonStyle.prototype.update = function() {
|
|
779
|
+
ButtonStyle.prototype.update = function () {
|
|
680
780
|
this._styles.clear();
|
|
681
781
|
|
|
682
|
-
var background_color =
|
|
683
|
-
|
|
684
|
-
|
|
782
|
+
var background_color =
|
|
783
|
+
this._state.background ||
|
|
784
|
+
(this._layout.background_color_enabled
|
|
785
|
+
? this._layout.background_color || "#ffffff"
|
|
786
|
+
: "#ffffff");
|
|
787
|
+
var text_color =
|
|
788
|
+
this._state.font_color || this._layout.font_color || "#333333";
|
|
789
|
+
var border_color = hexToRgba(
|
|
790
|
+
this._state.border_color || text_color,
|
|
791
|
+
this._state.border_transparency,
|
|
792
|
+
);
|
|
685
793
|
var read_direction = getTextDirection();
|
|
686
794
|
|
|
687
|
-
this._styles
|
|
795
|
+
this._styles
|
|
796
|
+
.select(this._selector + ".fl-control.hidden")
|
|
688
797
|
.style("display", "none");
|
|
689
798
|
|
|
690
|
-
this._styles
|
|
799
|
+
this._styles
|
|
800
|
+
.select(this._selector + ".fl-control .button")
|
|
691
801
|
.style("overflow", "hidden")
|
|
692
802
|
.style("white-space", "nowrap")
|
|
693
803
|
.style("margin", "0 2px 0 0 !important")
|
|
@@ -696,15 +806,18 @@
|
|
|
696
806
|
.style("border", this._state.border_width + "px solid " + border_color)
|
|
697
807
|
.style("border-radius", this._state.border_radius + "px");
|
|
698
808
|
|
|
699
|
-
this._styles
|
|
809
|
+
this._styles
|
|
810
|
+
.select(this._selector + ".fl-control .button:hover")
|
|
700
811
|
.style("background-color", this._state.background_hover || background_color)
|
|
701
812
|
.style("color", this._state.font_color_hover || text_color);
|
|
702
813
|
|
|
703
|
-
this._styles
|
|
814
|
+
this._styles
|
|
815
|
+
.select(this._selector + ".fl-control .button.selected")
|
|
704
816
|
.style("background-color", this._state.background_selected)
|
|
705
817
|
.style("color", this._state.font_color_selected);
|
|
706
818
|
|
|
707
|
-
this._styles
|
|
819
|
+
this._styles
|
|
820
|
+
.select(this._selector + ".grouped.fl-control .button")
|
|
708
821
|
.style("border-right", "none")
|
|
709
822
|
.style("border-radius", "0")
|
|
710
823
|
.style("margin", "0");
|
|
@@ -713,14 +826,38 @@
|
|
|
713
826
|
var left_most_button_selector = is_rtl ? ":last-child" : ":first-child";
|
|
714
827
|
var right_most_button_selector = is_rtl ? ":first-child" : ":last-child";
|
|
715
828
|
|
|
716
|
-
this._styles
|
|
717
|
-
.
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
829
|
+
this._styles
|
|
830
|
+
.select(
|
|
831
|
+
this._selector +
|
|
832
|
+
".grouped.fl-control .button" +
|
|
833
|
+
left_most_button_selector,
|
|
834
|
+
)
|
|
835
|
+
.style(
|
|
836
|
+
"border-radius",
|
|
837
|
+
this._state.border_radius + "px 0 0 " + this._state.border_radius + "px",
|
|
838
|
+
);
|
|
839
|
+
|
|
840
|
+
this._styles
|
|
841
|
+
.select(
|
|
842
|
+
this._selector +
|
|
843
|
+
".grouped.fl-control .button" +
|
|
844
|
+
right_most_button_selector,
|
|
845
|
+
)
|
|
846
|
+
.style(
|
|
847
|
+
"border-radius",
|
|
848
|
+
"0 " +
|
|
849
|
+
this._state.border_radius +
|
|
850
|
+
"px " +
|
|
851
|
+
this._state.border_radius +
|
|
852
|
+
"px 0",
|
|
853
|
+
)
|
|
854
|
+
.style(
|
|
855
|
+
"border-right",
|
|
856
|
+
this._state.border_width + "px solid " + border_color,
|
|
857
|
+
);
|
|
858
|
+
|
|
859
|
+
this._styles
|
|
860
|
+
.select(this._selector + ".grouped.fl-control.fixed-width:not(.hidden)")
|
|
724
861
|
.style("width", this._state.grouped_width + "%");
|
|
725
862
|
|
|
726
863
|
this._stylesheet.innerHTML = this._styles.print();
|
|
@@ -734,12 +871,14 @@
|
|
|
734
871
|
border_width: 1,
|
|
735
872
|
border_color: null,
|
|
736
873
|
border_transparency: 0.25,
|
|
737
|
-
border_radius: 3
|
|
874
|
+
border_radius: 3,
|
|
738
875
|
});
|
|
739
876
|
|
|
740
877
|
function DropdownStyle(state_, selector_, layout_) {
|
|
741
878
|
this._state = state_;
|
|
742
|
-
for (var key in DEFAULTS$1) {
|
|
879
|
+
for (var key in DEFAULTS$1) {
|
|
880
|
+
if (this._state[key] === undefined) this._state[key] = DEFAULTS$1[key];
|
|
881
|
+
}
|
|
743
882
|
|
|
744
883
|
this._layout = layout_ || {};
|
|
745
884
|
|
|
@@ -750,36 +889,42 @@
|
|
|
750
889
|
return this;
|
|
751
890
|
}
|
|
752
891
|
|
|
753
|
-
DropdownStyle.prototype._createStylesheet = function() {
|
|
892
|
+
DropdownStyle.prototype._createStylesheet = function () {
|
|
754
893
|
this._stylesheet = document.createElement("style");
|
|
755
894
|
this._stylesheet.className = "fl-ui-styles-dropdown";
|
|
756
895
|
document.head.appendChild(this._stylesheet);
|
|
757
896
|
};
|
|
758
897
|
|
|
759
|
-
DropdownStyle.prototype.update = function() {
|
|
898
|
+
DropdownStyle.prototype.update = function () {
|
|
760
899
|
this._styles.clear();
|
|
761
900
|
|
|
762
901
|
const background_color = this._state.background || "transparent";
|
|
763
|
-
const user_defined_text_color =
|
|
902
|
+
const user_defined_text_color =
|
|
903
|
+
this._state.font_color || this._layout.font_color;
|
|
764
904
|
const text_color = user_defined_text_color || "inherit";
|
|
765
905
|
let border_color;
|
|
766
906
|
if (this._state.border_color) {
|
|
767
|
-
border_color = hexToRgba(
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
}
|
|
772
|
-
|
|
907
|
+
border_color = hexToRgba(
|
|
908
|
+
this._state.border_color,
|
|
909
|
+
this._state.border_transparency,
|
|
910
|
+
);
|
|
911
|
+
} else if (user_defined_text_color) {
|
|
912
|
+
border_color = hexToRgba(
|
|
913
|
+
user_defined_text_color,
|
|
914
|
+
this._state.border_transparency,
|
|
915
|
+
);
|
|
916
|
+
} else {
|
|
773
917
|
border_color = "currentColor";
|
|
774
918
|
}
|
|
775
919
|
|
|
776
|
-
this._styles
|
|
920
|
+
this._styles
|
|
921
|
+
.select(this._selector + " .heading")
|
|
777
922
|
.style("margin-bottom", "0.4em");
|
|
778
923
|
|
|
779
|
-
this._styles.select(this._selector)
|
|
780
|
-
.style("pointer-events", "all");
|
|
924
|
+
this._styles.select(this._selector).style("pointer-events", "all");
|
|
781
925
|
|
|
782
|
-
this._styles
|
|
926
|
+
this._styles
|
|
927
|
+
.select(this._selector + " select")
|
|
783
928
|
.style("display", "inline-block")
|
|
784
929
|
.style("cursor", "pointer")
|
|
785
930
|
.style("overflow", "hidden")
|
|
@@ -788,15 +933,37 @@
|
|
|
788
933
|
.style("font-family", "inherit")
|
|
789
934
|
.style("background-color", background_color)
|
|
790
935
|
.style("color", text_color)
|
|
791
|
-
.style(
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
936
|
+
.style(
|
|
937
|
+
"border",
|
|
938
|
+
this._state.border_style == "bottom"
|
|
939
|
+
? this._state.border_width + "px solid transparent"
|
|
940
|
+
: this._state.border_width + "px solid " + border_color,
|
|
941
|
+
)
|
|
942
|
+
.style(
|
|
943
|
+
"border-bottom",
|
|
944
|
+
this._state.border_style == "bottom"
|
|
945
|
+
? this._state.border_width + "px solid " + border_color
|
|
946
|
+
: null,
|
|
947
|
+
)
|
|
948
|
+
.style(
|
|
949
|
+
"border-radius",
|
|
950
|
+
this._state.border_style == "bottom"
|
|
951
|
+
? null
|
|
952
|
+
: this._state.border_radius + "px",
|
|
953
|
+
);
|
|
954
|
+
|
|
955
|
+
this._styles
|
|
956
|
+
.select(this._selector + ":after")
|
|
957
|
+
.style(
|
|
958
|
+
"right",
|
|
959
|
+
this._state.border_style == "bottom"
|
|
960
|
+
? null
|
|
961
|
+
: this._state.border_width + 5 + "px",
|
|
962
|
+
)
|
|
797
963
|
.style("color", text_color);
|
|
798
964
|
|
|
799
|
-
this._styles
|
|
965
|
+
this._styles
|
|
966
|
+
.select(this._selector + " .main .current")
|
|
800
967
|
.style("line-height", "1em")
|
|
801
968
|
.style("height", "100%")
|
|
802
969
|
.style("max-width", "88%")
|
|
@@ -804,7 +971,8 @@
|
|
|
804
971
|
.style("overflow", "hidden")
|
|
805
972
|
.style("vertical-align", "top");
|
|
806
973
|
|
|
807
|
-
this._styles
|
|
974
|
+
this._styles
|
|
975
|
+
.select(this._selector + " .list")
|
|
808
976
|
.style("top", "2px")
|
|
809
977
|
.style("min-width", "100%")
|
|
810
978
|
.style("padding", "2px")
|
|
@@ -819,22 +987,31 @@
|
|
|
819
987
|
.style("font-weight", "normal")
|
|
820
988
|
.style("color", text_color);
|
|
821
989
|
|
|
822
|
-
this._styles
|
|
990
|
+
this._styles
|
|
991
|
+
.select(this._selector + ".open .list")
|
|
823
992
|
.style("display", "block")
|
|
824
993
|
.style("border", this._state.border_width + "px solid " + border_color)
|
|
825
994
|
.style("background-color", background_color)
|
|
826
995
|
.style("z-index", "1")
|
|
827
996
|
.style("animation", "dropdown-out 200ms");
|
|
828
997
|
|
|
829
|
-
this._styles
|
|
998
|
+
this._styles
|
|
999
|
+
.select(this._selector + " .list-item:hover")
|
|
830
1000
|
.style("opacity", "0.6");
|
|
831
1001
|
|
|
832
|
-
this._styles
|
|
1002
|
+
this._styles
|
|
1003
|
+
.select(
|
|
1004
|
+
this._selector +
|
|
1005
|
+
" .list-item.selected, " +
|
|
1006
|
+
this._selector +
|
|
1007
|
+
" .list-item.selected:hover",
|
|
1008
|
+
)
|
|
833
1009
|
.style("opacity", "1")
|
|
834
1010
|
.style("cursor", "default");
|
|
835
1011
|
|
|
836
1012
|
if (this._state.border_style == "bottom") {
|
|
837
|
-
this._styles
|
|
1013
|
+
this._styles
|
|
1014
|
+
.select(this._selector + " .main")
|
|
838
1015
|
.style("padding-left", 0)
|
|
839
1016
|
.style("padding-right", "0.1rem");
|
|
840
1017
|
}
|
|
@@ -856,12 +1033,14 @@
|
|
|
856
1033
|
track_height: 0.2,
|
|
857
1034
|
margin: 4.5,
|
|
858
1035
|
|
|
859
|
-
play_button: true
|
|
1036
|
+
play_button: true,
|
|
860
1037
|
});
|
|
861
1038
|
|
|
862
1039
|
function SliderStyle(state_, selector_, layout_) {
|
|
863
1040
|
this._state = state_;
|
|
864
|
-
for (var key in DEFAULTS) {
|
|
1041
|
+
for (var key in DEFAULTS) {
|
|
1042
|
+
if (this._state[key] === undefined) this._state[key] = DEFAULTS[key];
|
|
1043
|
+
}
|
|
865
1044
|
|
|
866
1045
|
this._layout = layout_ || {};
|
|
867
1046
|
|
|
@@ -872,66 +1051,79 @@
|
|
|
872
1051
|
return this;
|
|
873
1052
|
}
|
|
874
1053
|
|
|
875
|
-
SliderStyle.prototype._createStylesheet = function() {
|
|
1054
|
+
SliderStyle.prototype._createStylesheet = function () {
|
|
876
1055
|
this._stylesheet = document.createElement("style");
|
|
877
1056
|
this._stylesheet.className = "fl-ui-styles-slider";
|
|
878
1057
|
document.head.appendChild(this._stylesheet);
|
|
879
1058
|
};
|
|
880
1059
|
|
|
881
|
-
SliderStyle.prototype.update = function() {
|
|
1060
|
+
SliderStyle.prototype.update = function () {
|
|
882
1061
|
this._styles.clear();
|
|
883
1062
|
|
|
884
1063
|
var track_color = this._state.track_color || "#dddddd";
|
|
885
|
-
var text_color =
|
|
1064
|
+
var text_color =
|
|
1065
|
+
this._state.font_color || this._layout.font_color || "currentColor";
|
|
886
1066
|
var slider_color = "currentColor"; // So that handle can inherit layout text color via this parent
|
|
887
|
-
var handle_color =
|
|
888
|
-
|
|
1067
|
+
var handle_color =
|
|
1068
|
+
this._state.handle_color || this._layout.font_color || "currentColor";
|
|
1069
|
+
var play_color =
|
|
1070
|
+
this._state.play_color || this._layout.font_color || "currentColor";
|
|
889
1071
|
|
|
890
1072
|
var handle_radius = Math.round(remToPx(this._state.handle_height));
|
|
891
1073
|
var track_height = remToPx(this._state.track_height);
|
|
892
1074
|
|
|
893
|
-
this._styles
|
|
1075
|
+
this._styles
|
|
1076
|
+
.select(this._selector + " .fl-controls-slider")
|
|
894
1077
|
.style("height", handle_radius * 2 + "px");
|
|
895
1078
|
|
|
896
|
-
this._styles
|
|
1079
|
+
this._styles
|
|
1080
|
+
.select(this._selector + " .slider-play")
|
|
897
1081
|
.style("fill", play_color)
|
|
898
1082
|
.style("width", handle_radius + "px")
|
|
899
1083
|
.style("height", handle_radius + "px")
|
|
900
1084
|
.style("display", this._state.play_button ? null : "none");
|
|
901
1085
|
|
|
902
|
-
this._styles
|
|
1086
|
+
this._styles
|
|
1087
|
+
.select(this._selector + " .slider-label")
|
|
903
1088
|
.style("padding-inline-start", "0.3rem")
|
|
904
1089
|
.style("box-sizing", "content-box")
|
|
905
1090
|
.style("color", text_color);
|
|
906
1091
|
|
|
907
|
-
this._styles
|
|
1092
|
+
this._styles
|
|
1093
|
+
.select(this._selector + " input[type=range]")
|
|
908
1094
|
.style("-webkit-appearance", "none")
|
|
909
1095
|
.style("color", slider_color)
|
|
910
1096
|
.style("background-color", "transparent");
|
|
911
1097
|
|
|
912
1098
|
// Chrome/Edge
|
|
913
|
-
this._styles
|
|
1099
|
+
this._styles
|
|
1100
|
+
.select(
|
|
1101
|
+
this._selector + " input[type=range]::-webkit-slider-runnable-track",
|
|
1102
|
+
)
|
|
914
1103
|
.style("-webkit-appearance", "none")
|
|
915
1104
|
.style("background", track_color)
|
|
916
1105
|
.style("border-radius", "100px")
|
|
917
1106
|
.style("height", track_height + "px");
|
|
918
1107
|
|
|
919
|
-
this._styles
|
|
1108
|
+
this._styles
|
|
1109
|
+
.select(this._selector + " input[type=range]::-webkit-slider-thumb")
|
|
920
1110
|
.style("-webkit-appearance", "none")
|
|
921
1111
|
.style("width", handle_radius + "px")
|
|
922
1112
|
.style("height", handle_radius + "px")
|
|
923
1113
|
.style("border-radius", "100px")
|
|
924
1114
|
.style("background", handle_color)
|
|
925
|
-
.style("margin-top", -handle_radius/2 + track_height/2 + "px");
|
|
1115
|
+
.style("margin-top", -handle_radius / 2 + track_height / 2 + "px");
|
|
926
1116
|
|
|
927
1117
|
// Firefox
|
|
928
|
-
this._styles
|
|
1118
|
+
this._styles
|
|
1119
|
+
.select(this._selector + " input[type=range]::-moz-range-track")
|
|
929
1120
|
.style("-webkit-appearance", "none")
|
|
930
1121
|
.style("background", track_color)
|
|
931
1122
|
.style("border-radius", "100px")
|
|
932
1123
|
.style("height", track_height + "px");
|
|
933
1124
|
|
|
934
|
-
this._styles
|
|
1125
|
+
this._styles
|
|
1126
|
+
.select(this._selector + " input[type=range]::-moz-range-thumb")
|
|
935
1127
|
.style("-webkit-appearance", "none")
|
|
936
1128
|
.style("width", handle_radius + "px")
|
|
937
1129
|
.style("height", handle_radius + "px")
|