@gisce/ooui 0.1.3 → 0.1.6

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/dist/Button.d.ts CHANGED
@@ -24,6 +24,12 @@ declare class Button extends Field {
24
24
  _confirmMessage: string;
25
25
  get confirmMessage(): string;
26
26
  set confirm(value: string);
27
+ _primary: boolean;
28
+ get primary(): boolean;
29
+ set primary(value: boolean);
30
+ _danger: boolean;
31
+ get danger(): boolean;
32
+ set danger(value: boolean);
27
33
  constructor(props: any);
28
34
  }
29
35
  export default Button;
package/dist/Button.js CHANGED
@@ -39,6 +39,8 @@ var Button = /** @class */ (function (_super) {
39
39
  * Confirm string for modal in button types workflow
40
40
  */
41
41
  _this._confirmMessage = "";
42
+ _this._primary = false;
43
+ _this._danger = false;
42
44
  if (props) {
43
45
  if (props.string) {
44
46
  _this._caption = props.string;
@@ -55,6 +57,18 @@ var Button = /** @class */ (function (_super) {
55
57
  if (props.icon) {
56
58
  _this._icon = props.icon;
57
59
  }
60
+ if (props.primary) {
61
+ var primary = props.primary;
62
+ if (primary === "1" || primary === 1 || primary === true) {
63
+ _this._primary = true;
64
+ }
65
+ }
66
+ if (props.danger) {
67
+ var danger = props.danger;
68
+ if (danger === "1" || danger === 1 || danger === true) {
69
+ _this._danger = true;
70
+ }
71
+ }
58
72
  }
59
73
  return _this;
60
74
  }
@@ -102,6 +116,26 @@ var Button = /** @class */ (function (_super) {
102
116
  enumerable: false,
103
117
  configurable: true
104
118
  });
119
+ Object.defineProperty(Button.prototype, "primary", {
120
+ get: function () {
121
+ return this._primary;
122
+ },
123
+ set: function (value) {
124
+ this._primary = value;
125
+ },
126
+ enumerable: false,
127
+ configurable: true
128
+ });
129
+ Object.defineProperty(Button.prototype, "danger", {
130
+ get: function () {
131
+ return this._danger;
132
+ },
133
+ set: function (value) {
134
+ this._danger = value;
135
+ },
136
+ enumerable: false,
137
+ configurable: true
138
+ });
105
139
  return Button;
106
140
  }(Field));
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CAAC,KAAK,CAAC;QACpB,CAAC;aACD,UAAS,KAAyB;YAChC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACrB,CAAC;;;OAHA;IASD,sBAAI,kCAAc;aAAlB;YACE,OAAO,IAAI,CAAC,eAAe,CAAC;QAC9B,CAAC;;;OAAA;IACD,sBAAI,2BAAO;aAAX,UAAY,KAAa;YACvB,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC;QAC/B,CAAC;;;OAAA;IAGD,sBAAI,2BAAO;aAAX;YACE,OAAO,IAAI,CAAC,QAAQ,CAAC;QACvB,CAAC;aACD,UAAY,KAAc;YACxB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACxB,CAAC;;;OAHA;IAMD,sBAAI,0BAAM;aAAV;YACE,OAAO,IAAI,CAAC,OAAO,CAAC;QACtB,CAAC;aACD,UAAW,KAAc;YACvB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACvB,CAAC;;;OAHA;IA6CH,aAAC;AAAD,CAAC,AArGD,CAAqB,KAAK,GAqGzB;AAED,eAAe,MAAM,CAAC"}
@@ -1,5 +1,9 @@
1
1
  import Field from "./Field";
2
2
  declare class Indicator extends Field {
3
3
  _nolabel: boolean;
4
+ _card: boolean;
5
+ get card(): boolean;
6
+ set card(value: boolean);
7
+ constructor(props: any);
4
8
  }
5
9
  export default Indicator;
package/dist/Indicator.js CHANGED
@@ -14,11 +14,25 @@ var __extends = (this && this.__extends) || (function () {
14
14
  import Field from "./Field";
15
15
  var Indicator = /** @class */ (function (_super) {
16
16
  __extends(Indicator, _super);
17
- function Indicator() {
18
- var _this = _super !== null && _super.apply(this, arguments) || this;
17
+ function Indicator(props) {
18
+ var _this = _super.call(this, props) || this;
19
19
  _this._nolabel = true;
20
+ _this._card = false;
21
+ if (_this._parsedWidgetProps) {
22
+ _this._card = _this._parsedWidgetProps.card;
23
+ }
20
24
  return _this;
21
25
  }
26
+ Object.defineProperty(Indicator.prototype, "card", {
27
+ get: function () {
28
+ return this._card;
29
+ },
30
+ set: function (value) {
31
+ this._card = value;
32
+ },
33
+ enumerable: false,
34
+ configurable: true
35
+ });
22
36
  return Indicator;
23
37
  }(Field));
24
38
  export default Indicator;
@@ -1 +1 @@
1
- {"version":3,"file":"Indicator.js","sourceRoot":"","sources":["../src/Indicator.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,SAAS,CAAC;AAE5B;IAAwB,6BAAK;IAA7B;QAAA,qEAEC;QADC,cAAQ,GAAY,IAAI,CAAC;;IAC3B,CAAC;IAAD,gBAAC;AAAD,CAAC,AAFD,CAAwB,KAAK,GAE5B;AAGD,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"Indicator.js","sourceRoot":"","sources":["../src/Indicator.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,SAAS,CAAC;AAE5B;IAAwB,6BAAK;IAW3B,mBAAY,KAAU;QAAtB,YACE,kBAAM,KAAK,CAAC,SAKb;QAhBD,cAAQ,GAAY,IAAI,CAAC;QAYvB,KAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,KAAI,CAAC,kBAAkB,EAAE;YAC3B,KAAI,CAAC,KAAK,GAAG,KAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC;SAC3C;;IACH,CAAC;IAbD,sBAAI,2BAAI;aAAR;YACE,OAAO,IAAI,CAAC,KAAK,CAAC;QACpB,CAAC;aACD,UAAS,KAAc;YACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACrB,CAAC;;;OAHA;IAYH,gBAAC;AAAD,CAAC,AAlBD,CAAwB,KAAK,GAkB5B;AAGD,eAAe,SAAS,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gisce/ooui",
3
- "version": "0.1.3",
3
+ "version": "0.1.6",
4
4
  "dependencies": {},
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/Button.ts CHANGED
@@ -45,6 +45,22 @@ class Button extends Field {
45
45
  this._confirmMessage = value;
46
46
  }
47
47
 
48
+ _primary: boolean = false;
49
+ get primary(): boolean {
50
+ return this._primary;
51
+ }
52
+ set primary(value: boolean) {
53
+ this._primary = value;
54
+ }
55
+
56
+ _danger: boolean = false;
57
+ get danger(): boolean {
58
+ return this._danger;
59
+ }
60
+ set danger(value: boolean) {
61
+ this._danger = value;
62
+ }
63
+
48
64
  constructor(props: any) {
49
65
  super({
50
66
  ...props,
@@ -71,6 +87,18 @@ class Button extends Field {
71
87
  if (props.icon) {
72
88
  this._icon = props.icon;
73
89
  }
90
+ if (props.primary) {
91
+ const primary = props.primary;
92
+ if (primary === "1" || primary === 1 || primary === true) {
93
+ this._primary = true
94
+ }
95
+ }
96
+ if (props.danger) {
97
+ const danger = props.danger;
98
+ if (danger === "1" || danger === 1 || danger === true) {
99
+ this._danger = true
100
+ }
101
+ }
74
102
  }
75
103
  }
76
104
  }
package/src/Indicator.ts CHANGED
@@ -2,6 +2,22 @@ import Field from "./Field";
2
2
 
3
3
  class Indicator extends Field {
4
4
  _nolabel: boolean = true;
5
+
6
+ _card: boolean;
7
+ get card(): boolean {
8
+ return this._card;
9
+ }
10
+ set card(value: boolean) {
11
+ this._card = value;
12
+ }
13
+
14
+ constructor(props: any) {
15
+ super(props);
16
+ this._card = false;
17
+ if (this._parsedWidgetProps) {
18
+ this._card = this._parsedWidgetProps.card;
19
+ }
20
+ }
5
21
  }
6
22
 
7
23
 
@@ -55,4 +55,78 @@ describe("A Button", () => {
55
55
 
56
56
  expect(widget.nolabel).toBe(false);
57
57
  });
58
+ describe('primary attribute', () => {
59
+ it("should have primary attribute as false for default", () => {
60
+ const widgetFactory = new WidgetFactory();
61
+ const props = {
62
+ string: "Button",
63
+ };
64
+ const widget = widgetFactory.createWidget("button", props);
65
+ expect(widget.primary).toBe(false);
66
+ });
67
+ it("should parse primary option for 1", () => {
68
+ const widgetFactory = new WidgetFactory();
69
+ const props = {
70
+ string: "Button",
71
+ primary: 1
72
+ };
73
+ const widget = widgetFactory.createWidget("button", props);
74
+ expect(widget.primary).toBe(true);
75
+ });
76
+ it("should parse primary option for '1'", () => {
77
+ const widgetFactory = new WidgetFactory();
78
+ const props = {
79
+ string: "Button",
80
+ primary: "1"
81
+ };
82
+ const widget = widgetFactory.createWidget("button", props);
83
+ expect(widget.primary).toBe(true);
84
+ });
85
+ it("should parse primary option for true", () => {
86
+ const widgetFactory = new WidgetFactory();
87
+ const props = {
88
+ string: "Button",
89
+ primary: true
90
+ };
91
+ const widget = widgetFactory.createWidget("button", props);
92
+ expect(widget.primary).toBe(true);
93
+ });
94
+ });
95
+ describe('danger attribute', () => {
96
+ it("should have danger attribute as false for default", () => {
97
+ const widgetFactory = new WidgetFactory();
98
+ const props = {
99
+ string: "Button",
100
+ };
101
+ const widget = widgetFactory.createWidget("button", props);
102
+ expect(widget.danger).toBe(false);
103
+ });
104
+ it("should parse danger option for 1", () => {
105
+ const widgetFactory = new WidgetFactory();
106
+ const props = {
107
+ string: "Button",
108
+ danger: 1
109
+ };
110
+ const widget = widgetFactory.createWidget("button", props);
111
+ expect(widget.danger).toBe(true);
112
+ });
113
+ it("should parse danger option for '1'", () => {
114
+ const widgetFactory = new WidgetFactory();
115
+ const props = {
116
+ string: "Button",
117
+ danger: "1"
118
+ };
119
+ const widget = widgetFactory.createWidget("button", props);
120
+ expect(widget.danger).toBe(true);
121
+ });
122
+ it("should parse danger option for true", () => {
123
+ const widgetFactory = new WidgetFactory();
124
+ const props = {
125
+ string: "Button",
126
+ danger: true
127
+ };
128
+ const widget = widgetFactory.createWidget("button", props);
129
+ expect(widget.danger).toBe(true);
130
+ });
131
+ });
58
132
  });
@@ -0,0 +1,27 @@
1
+ import WidgetFactory from "../WidgetFactory";
2
+ import Indicator from "../Indicator";
3
+
4
+ describe("An Indicator", () => {
5
+ it("should create a Indicator widget from factory", () => {
6
+ const widgetFactory = new WidgetFactory();
7
+
8
+ const widget = widgetFactory.createWidget("indicator", {});
9
+ expect(widget).toBeInstanceOf(Indicator);
10
+
11
+ });
12
+
13
+ it('should have card as false as default', () => {
14
+ const widgetFactory = new WidgetFactory();
15
+ const widget = widgetFactory.createWidget("indicator", {});
16
+ expect(widget.card).toBe(false);
17
+ });
18
+
19
+ it('should parse widget props', () => {
20
+ const widgetFactory = new WidgetFactory();
21
+ const props = {
22
+ widget_props: "{'card': true}"
23
+ };
24
+ const widget = widgetFactory.createWidget("indicator", props);
25
+ expect(widget.card).toBe(true);
26
+ });
27
+ });