@flourish/ui-styles 4.0.0 → 5.0.1

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/.eslintrc.json CHANGED
@@ -1,7 +1,3 @@
1
1
  {
2
- "plugins": [
3
- "@flourish/flourish"
4
- ],
5
- "extends": "plugin:@flourish/flourish/flourish",
6
- "env": { "browser": true }
7
- }
2
+ "extends": "../../.eslintrc.cjs"
3
+ }
package/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ # Flourish Component License v1.1
2
+
3
+ Use of code and documentation (“Software”) released under the Flourish Component License v1.1 (“Licence”) is subject to the following terms. If you intend to use the Software on behalf of a company or other entity, you represent that you have the appropriate authority to bind such company or other entity to this Licence. By accessing or otherwise using the Software, you are agreeing to be bound by the terms of this Licence. If you do not agree to these terms, please do not use the Software and remove it from your computer. This Licence is governed by English law and was last updated on 29 August 2022.
4
+
5
+ ## Licence and restrictions
6
+ The Software was created by and is owned by Canva UK Operations Ltd (we, us or our). Subject to the terms and conditions in this License, we grant you a revocable, non-exclusive, non-transferable, royalty-free licence to install the Software for the sole purpose of creating digital visualisation templates (“Templates”) to upload to our online platform, Flourish.
7
+
8
+ Without written permission from us, Templates or other works created with or incorporating the Software (or any part of it) may not be incorporated into any other online tool or platform, or sold or sub-licensed, or used for any other purpose.
9
+
10
+ You may distribute the Software, provided that you only distribute complete un-modified copies and include a copy of this license and any copyright, patent, trade mark and attribution notices incorporated into the Software in all distributions.
11
+
12
+ You agree that you are solely responsible for (and that we have no responsibility to you or to any third party for) any data, content, or resources that you create, transmit or display through Software, and for the consequences of your actions (including any loss or damage which we may suffer) by doing so.
13
+
14
+ ## Intellectual property
15
+ Nothing in this Licence shall cause the ownership of any intellectual property rights of either party to be transferred to the other. As between the parties, all intellectual property rights in the Software belong to us. Except as expressly provided by this Agreement, you shall not acquire any right, title or interest in the intellectual property rights in the Software (or any part of it). All our intellectual property rights and other rights which are not expressly granted to you by this Agreement are reserved by us.
16
+
17
+ ## Our liability
18
+ The Software is provided on an “as is” basis. Except as expressly set out in this Licence and subject only to the below, no implied conditions, warranties or other terms, including any implied terms relating to satisfactory quality or fitness for any purpose, will apply to the Software (or any part of it) or to anything supplied or provided by us under this Licence.
19
+
20
+ We do not warrant or represent that the Software (or any part of it) will operate continuously without error or be entirely free of bugs, viruses or other contaminants or will be suitable for your purposes.
21
+
22
+ Nothing in these terms and conditions shall limit or exclude our liability to you: (a) for death or personal injury caused by our negligence; (b) for fraudulent misrepresentation; (c) for breach of any term implied by the Consumer Rights Act 2015 and which, by law, may not be limited or excluded; or (d) for any other liability that, by law, may not be limited or excluded.
23
+
24
+ In no event shall we be liable to you for any indirect or consequential losses, or for any loss of profit, revenue, contracts, data, goodwill or other similar losses, and any liability we do have for losses you suffer arising from any use of the Software shall not exceed £500.
25
+
26
+ We will not be liable or responsible for any failure to perform, or delay in performance of, any of our obligations under this Licence that is caused by events outside our reasonable control.
package/RELEASE_NOTES.md CHANGED
@@ -1,3 +1,10 @@
1
+ # 5.0.1
2
+ * Fix license annotation
3
+
4
+ # 5.0.0
5
+ * Change default background button color to black [BREAKING]
6
+ * Ignore layout background color if not enabled
7
+
1
8
  # 4.0.0
2
9
  * Move slider width setting from @flourish/ui-styles to @flourish/controls [BREAKING] For use with version 8.0.0+ of @flourish/controls
3
10
 
package/package.json CHANGED
@@ -1,41 +1,30 @@
1
1
  {
2
2
  "name": "@flourish/ui-styles",
3
- "version": "4.0.0",
3
+ "version": "5.0.1",
4
+ "private": false,
4
5
  "description": "Flourish module for styling UI elements",
5
6
  "main": "ui-styles.js",
6
7
  "module": "src/index.js",
7
- "scripts": {
8
- "lint": "eslint src",
9
- "build": "rollup -c",
10
- "prepare": "npm run build && npm run minify",
11
- "minify": "uglifyjs -m -o ui-styles.min.js ui-styles.js",
12
- "precommit": "lint-staged"
13
- },
14
8
  "author": "Kiln Enterprises Ltd",
15
- "license": "https://flourish.studio/terms/fcl/",
9
+ "license": "LicenseRef-LICENSE",
16
10
  "dependencies": {
17
11
  "@flourish/pocket-knife": "^1.0.0",
18
12
  "d3-selection": "^1.4.0"
19
13
  },
20
14
  "devDependencies": {
21
15
  "@flourish/eslint-plugin-flourish": "^0.7.2",
22
- "eslint": "^5.16.0",
23
- "husky": "^1.3.1",
24
- "lint-staged": "^8.1.3",
25
- "rollup": "^1.1.2",
26
- "rollup-plugin-node-resolve": "^4.0.0",
27
- "uglify-js": "^3.4.9"
16
+ "eslint": "^8.35.0",
17
+ "rollup": "3",
18
+ "rollup-plugin-node-resolve": "^5.2.0",
19
+ "uglify-js": "^3.17.4"
28
20
  },
29
21
  "repository": {
30
22
  "type": "git",
31
23
  "url": "git://github.com/kiln/flourish-ui-styles.git"
32
24
  },
33
- "lint-staged": {
34
- "*.js": "npm run lint --"
35
- },
36
- "husky": {
37
- "hooks": {
38
- "pre-commit": "lint-staged"
39
- }
25
+ "scripts": {
26
+ "lint": "eslint src",
27
+ "build": "rollup -c",
28
+ "minify": "uglifyjs -m -o ui-styles.min.js ui-styles.js"
40
29
  }
41
- }
30
+ }
@@ -5,7 +5,7 @@ var DEFAULTS = Object.freeze({
5
5
  background: null,
6
6
  font_color: null,
7
7
 
8
- background_selected: "#2886b2",
8
+ background_selected: "#333333",
9
9
  font_color_selected: "#ffffff",
10
10
 
11
11
  background_hover: null,
@@ -39,7 +39,7 @@ ButtonStyle.prototype._createStylesheet = function() {
39
39
  ButtonStyle.prototype.update = function() {
40
40
  this._styles.clear();
41
41
 
42
- var background_color = this._state.background || this._layout.background_color || "#ffffff";
42
+ var background_color = this._state.background || (this._layout.background_color_enabled ? this._layout.background_color || "#ffffff" : "#ffffff");
43
43
  var text_color = this._state.font_color || this._layout.font_color || "#333333";
44
44
  var border_color = hexToRgba(this._state.border_color || text_color, this._state.border_transparency);
45
45
  var read_direction = getTextDirection();
@@ -34,7 +34,7 @@ DropdownStyle.prototype._createStylesheet = function() {
34
34
  DropdownStyle.prototype.update = function() {
35
35
  this._styles.clear();
36
36
 
37
- var background_color = this._state.background || this._layout.background_color || "#ffffff";
37
+ var background_color = this._state.background || (this._layout.background_color_enabled ? this._layout.background_color || "#ffffff" : "#ffffff");
38
38
  var text_color = this._state.font_color || this._layout.font_color || "#333333";
39
39
  var border_color = hexToRgba(this._state.border_color || text_color, this._state.border_transparency);
40
40
 
package/ui-styles.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
3
  typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
- (global = global || self, factory(global['ui-styles'] = {}));
5
- }(this, (function (exports) { 'use strict';
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["ui-styles"] = {}));
5
+ })(this, (function (exports) { 'use strict';
6
6
 
7
7
  function Stylesheet() {
8
8
  this.declarations = [];
@@ -11,7 +11,7 @@
11
11
 
12
12
  Stylesheet.prototype.select = function(selector) {
13
13
  if (!selector) return this;
14
- var declaration = new Declaration(selector, this);
14
+ var declaration = new Declaration(selector);
15
15
  declaration.parent = this;
16
16
  this.addDeclaration(declaration);
17
17
 
@@ -56,7 +56,7 @@
56
56
  return this.parent.select(this.selector + " " + selector);
57
57
  };
58
58
 
59
- var DEFAULTS = Object.freeze({
59
+ var DEFAULTS$3 = Object.freeze({
60
60
  font_size: 1,
61
61
  font_weight: "bold",
62
62
  height: 2
@@ -64,7 +64,7 @@
64
64
 
65
65
  function GeneralControlsStyle(state_, selector_, layout_) {
66
66
  this._state = state_;
67
- for (var key in DEFAULTS) { if (this._state[key] === undefined) this._state[key] = DEFAULTS[key]; }
67
+ for (var key in DEFAULTS$3) { if (this._state[key] === undefined) this._state[key] = DEFAULTS$3[key]; }
68
68
 
69
69
  this._layout = layout_ || {};
70
70
 
@@ -502,179 +502,6 @@
502
502
  : m1) * 255;
503
503
  }
504
504
 
505
- var deg2rad = Math.PI / 180;
506
- var rad2deg = 180 / Math.PI;
507
-
508
- // https://observablehq.com/@mbostock/lab-and-rgb
509
- var K = 18,
510
- Xn = 0.96422,
511
- Yn = 1,
512
- Zn = 0.82521,
513
- t0 = 4 / 29,
514
- t1 = 6 / 29,
515
- t2 = 3 * t1 * t1,
516
- t3 = t1 * t1 * t1;
517
-
518
- function labConvert(o) {
519
- if (o instanceof Lab) return new Lab(o.l, o.a, o.b, o.opacity);
520
- if (o instanceof Hcl) return hcl2lab(o);
521
- if (!(o instanceof Rgb)) o = rgbConvert(o);
522
- var r = rgb2lrgb(o.r),
523
- g = rgb2lrgb(o.g),
524
- b = rgb2lrgb(o.b),
525
- y = xyz2lab((0.2225045 * r + 0.7168786 * g + 0.0606169 * b) / Yn), x, z;
526
- if (r === g && g === b) x = z = y; else {
527
- x = xyz2lab((0.4360747 * r + 0.3850649 * g + 0.1430804 * b) / Xn);
528
- z = xyz2lab((0.0139322 * r + 0.0971045 * g + 0.7141733 * b) / Zn);
529
- }
530
- return new Lab(116 * y - 16, 500 * (x - y), 200 * (y - z), o.opacity);
531
- }
532
-
533
- function lab(l, a, b, opacity) {
534
- return arguments.length === 1 ? labConvert(l) : new Lab(l, a, b, opacity == null ? 1 : opacity);
535
- }
536
-
537
- function Lab(l, a, b, opacity) {
538
- this.l = +l;
539
- this.a = +a;
540
- this.b = +b;
541
- this.opacity = +opacity;
542
- }
543
-
544
- define(Lab, lab, extend(Color, {
545
- brighter: function(k) {
546
- return new Lab(this.l + K * (k == null ? 1 : k), this.a, this.b, this.opacity);
547
- },
548
- darker: function(k) {
549
- return new Lab(this.l - K * (k == null ? 1 : k), this.a, this.b, this.opacity);
550
- },
551
- rgb: function() {
552
- var y = (this.l + 16) / 116,
553
- x = isNaN(this.a) ? y : y + this.a / 500,
554
- z = isNaN(this.b) ? y : y - this.b / 200;
555
- x = Xn * lab2xyz(x);
556
- y = Yn * lab2xyz(y);
557
- z = Zn * lab2xyz(z);
558
- return new Rgb(
559
- lrgb2rgb( 3.1338561 * x - 1.6168667 * y - 0.4906146 * z),
560
- lrgb2rgb(-0.9787684 * x + 1.9161415 * y + 0.0334540 * z),
561
- lrgb2rgb( 0.0719453 * x - 0.2289914 * y + 1.4052427 * z),
562
- this.opacity
563
- );
564
- }
565
- }));
566
-
567
- function xyz2lab(t) {
568
- return t > t3 ? Math.pow(t, 1 / 3) : t / t2 + t0;
569
- }
570
-
571
- function lab2xyz(t) {
572
- return t > t1 ? t * t * t : t2 * (t - t0);
573
- }
574
-
575
- function lrgb2rgb(x) {
576
- return 255 * (x <= 0.0031308 ? 12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055);
577
- }
578
-
579
- function rgb2lrgb(x) {
580
- return (x /= 255) <= 0.04045 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4);
581
- }
582
-
583
- function hclConvert(o) {
584
- if (o instanceof Hcl) return new Hcl(o.h, o.c, o.l, o.opacity);
585
- if (!(o instanceof Lab)) o = labConvert(o);
586
- if (o.a === 0 && o.b === 0) return new Hcl(NaN, 0 < o.l && o.l < 100 ? 0 : NaN, o.l, o.opacity);
587
- var h = Math.atan2(o.b, o.a) * rad2deg;
588
- return new Hcl(h < 0 ? h + 360 : h, Math.sqrt(o.a * o.a + o.b * o.b), o.l, o.opacity);
589
- }
590
-
591
- function hcl(h, c, l, opacity) {
592
- return arguments.length === 1 ? hclConvert(h) : new Hcl(h, c, l, opacity == null ? 1 : opacity);
593
- }
594
-
595
- function Hcl(h, c, l, opacity) {
596
- this.h = +h;
597
- this.c = +c;
598
- this.l = +l;
599
- this.opacity = +opacity;
600
- }
601
-
602
- function hcl2lab(o) {
603
- if (isNaN(o.h)) return new Lab(o.l, 0, 0, o.opacity);
604
- var h = o.h * deg2rad;
605
- return new Lab(o.l, Math.cos(h) * o.c, Math.sin(h) * o.c, o.opacity);
606
- }
607
-
608
- define(Hcl, hcl, extend(Color, {
609
- brighter: function(k) {
610
- return new Hcl(this.h, this.c, this.l + K * (k == null ? 1 : k), this.opacity);
611
- },
612
- darker: function(k) {
613
- return new Hcl(this.h, this.c, this.l - K * (k == null ? 1 : k), this.opacity);
614
- },
615
- rgb: function() {
616
- return hcl2lab(this).rgb();
617
- }
618
- }));
619
-
620
- var A = -0.14861,
621
- B = +1.78277,
622
- C = -0.29227,
623
- D = -0.90649,
624
- E = +1.97294,
625
- ED = E * D,
626
- EB = E * B,
627
- BC_DA = B * C - D * A;
628
-
629
- function cubehelixConvert(o) {
630
- if (o instanceof Cubehelix) return new Cubehelix(o.h, o.s, o.l, o.opacity);
631
- if (!(o instanceof Rgb)) o = rgbConvert(o);
632
- var r = o.r / 255,
633
- g = o.g / 255,
634
- b = o.b / 255,
635
- l = (BC_DA * b + ED * r - EB * g) / (BC_DA + ED - EB),
636
- bl = b - l,
637
- k = (E * (g - l) - C * bl) / D,
638
- s = Math.sqrt(k * k + bl * bl) / (E * l * (1 - l)), // NaN if l=0 or l=1
639
- h = s ? Math.atan2(k, bl) * rad2deg - 120 : NaN;
640
- return new Cubehelix(h < 0 ? h + 360 : h, s, l, o.opacity);
641
- }
642
-
643
- function cubehelix(h, s, l, opacity) {
644
- return arguments.length === 1 ? cubehelixConvert(h) : new Cubehelix(h, s, l, opacity == null ? 1 : opacity);
645
- }
646
-
647
- function Cubehelix(h, s, l, opacity) {
648
- this.h = +h;
649
- this.s = +s;
650
- this.l = +l;
651
- this.opacity = +opacity;
652
- }
653
-
654
- define(Cubehelix, cubehelix, extend(Color, {
655
- brighter: function(k) {
656
- k = k == null ? brighter : Math.pow(brighter, k);
657
- return new Cubehelix(this.h, this.s, this.l * k, this.opacity);
658
- },
659
- darker: function(k) {
660
- k = k == null ? darker : Math.pow(darker, k);
661
- return new Cubehelix(this.h, this.s, this.l * k, this.opacity);
662
- },
663
- rgb: function() {
664
- var h = isNaN(this.h) ? 0 : (this.h + 120) * deg2rad,
665
- l = +this.l,
666
- a = isNaN(this.s) ? 0 : this.s * l * (1 - l),
667
- cosh = Math.cos(h),
668
- sinh = Math.sin(h);
669
- return new Rgb(
670
- 255 * (l + a * (A * cosh + B * sinh)),
671
- 255 * (l + a * (C * cosh + D * sinh)),
672
- 255 * (l + a * (E * cosh)),
673
- this.opacity
674
- );
675
- }
676
- }));
677
-
678
505
  var prefix = "$";
679
506
 
680
507
  function Map() {}
@@ -753,7 +580,7 @@
753
580
 
754
581
  var proto = map.prototype;
755
582
 
756
- Set.prototype = set.prototype = {
583
+ Set.prototype = {
757
584
  constructor: Set,
758
585
  has: proto.has,
759
586
  add: function(value) {
@@ -769,33 +596,8 @@
769
596
  each: proto.each
770
597
  };
771
598
 
772
- function set(object, f) {
773
- var set = new Set;
774
-
775
- // Copy constructor.
776
- if (object instanceof Set) object.each(function(value) { set.add(value); });
777
-
778
- // Otherwise, assume it’s an array.
779
- else if (object) {
780
- var i = -1, n = object.length;
781
- if (f == null) while (++i < n) set.add(object[i]);
782
- else while (++i < n) set.add(f(object[i], i, object));
783
- }
784
-
785
- return set;
786
- }
787
-
788
- var getTextDimensions = (function() {
789
- var context = document.createElement("canvas").getContext("2d");
790
- return function(text, font) {
791
- context.font = font || "10px sans-serif";
792
- var metrics = context.measureText(text);
793
- return {
794
- width: metrics.width,
795
- height: metrics.actualBoundingBoxAscent + metrics.actualBoundingBoxDescent
796
- };
797
- };
798
- })();
599
+ var canvas = document.createElement("canvas");
600
+ canvas.getContext("2d");
799
601
 
800
602
  function getTextDirection() {
801
603
  return window.getComputedStyle(document.body).direction || "ltr";
@@ -814,11 +616,11 @@
814
616
  return c ? c.toString() : false;
815
617
  }
816
618
 
817
- var DEFAULTS$1 = Object.freeze({
619
+ var DEFAULTS$2 = Object.freeze({
818
620
  background: null,
819
621
  font_color: null,
820
622
 
821
- background_selected: "#2886b2",
623
+ background_selected: "#333333",
822
624
  font_color_selected: "#ffffff",
823
625
 
824
626
  background_hover: null,
@@ -832,7 +634,7 @@
832
634
 
833
635
  function ButtonStyle(state_, selector_, layout_) {
834
636
  this._state = state_;
835
- for (var key in DEFAULTS$1) { if (this._state[key] === undefined) this._state[key] = DEFAULTS$1[key]; }
637
+ for (var key in DEFAULTS$2) { if (this._state[key] === undefined) this._state[key] = DEFAULTS$2[key]; }
836
638
 
837
639
  this._layout = layout_ || {};
838
640
 
@@ -852,7 +654,7 @@
852
654
  ButtonStyle.prototype.update = function() {
853
655
  this._styles.clear();
854
656
 
855
- var background_color = this._state.background || this._layout.background_color || "#ffffff";
657
+ var background_color = this._state.background || (this._layout.background_color_enabled ? this._layout.background_color || "#ffffff" : "#ffffff");
856
658
  var text_color = this._state.font_color || this._layout.font_color || "#333333";
857
659
  var border_color = hexToRgba(this._state.border_color || text_color, this._state.border_transparency);
858
660
  var read_direction = getTextDirection();
@@ -899,7 +701,7 @@
899
701
  this._stylesheet.innerHTML = this._styles.print();
900
702
  };
901
703
 
902
- var DEFAULTS$2 = Object.freeze({
704
+ var DEFAULTS$1 = Object.freeze({
903
705
  background: null,
904
706
  font_color: null,
905
707
 
@@ -912,7 +714,7 @@
912
714
 
913
715
  function DropdownStyle(state_, selector_, layout_) {
914
716
  this._state = state_;
915
- for (var key in DEFAULTS$2) { if (this._state[key] === undefined) this._state[key] = DEFAULTS$2[key]; }
717
+ for (var key in DEFAULTS$1) { if (this._state[key] === undefined) this._state[key] = DEFAULTS$1[key]; }
916
718
 
917
719
  this._layout = layout_ || {};
918
720
 
@@ -932,7 +734,7 @@
932
734
  DropdownStyle.prototype.update = function() {
933
735
  this._styles.clear();
934
736
 
935
- var background_color = this._state.background || this._layout.background_color || "#ffffff";
737
+ var background_color = this._state.background || (this._layout.background_color_enabled ? this._layout.background_color || "#ffffff" : "#ffffff");
936
738
  var text_color = this._state.font_color || this._layout.font_color || "#333333";
937
739
  var border_color = hexToRgba(this._state.border_color || text_color, this._state.border_transparency);
938
740
 
@@ -1009,7 +811,7 @@
1009
811
  return rem * parseFloat(getComputedStyle(document.documentElement).fontSize);
1010
812
  }
1011
813
 
1012
- var DEFAULTS$3 = Object.freeze({
814
+ var DEFAULTS = Object.freeze({
1013
815
  play_color: null,
1014
816
  handle_color: null,
1015
817
  font_color: null,
@@ -1024,7 +826,7 @@
1024
826
 
1025
827
  function SliderStyle(state_, selector_, layout_) {
1026
828
  this._state = state_;
1027
- for (var key in DEFAULTS$3) { if (this._state[key] === undefined) this._state[key] = DEFAULTS$3[key]; }
829
+ for (var key in DEFAULTS) { if (this._state[key] === undefined) this._state[key] = DEFAULTS[key]; }
1028
830
 
1029
831
  this._layout = layout_ || {};
1030
832
 
@@ -1125,6 +927,4 @@
1125
927
  exports.createGeneralControlsStyle = createGeneralControlsStyle;
1126
928
  exports.createSliderStyle = createSliderStyle;
1127
929
 
1128
- Object.defineProperty(exports, '__esModule', { value: true });
1129
-
1130
- })));
930
+ }));
File without changes