polymatica-widget 2.1.13 → 2.1.14

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/LICENSE CHANGED
@@ -1,15 +1,15 @@
1
- ISC License
2
-
3
- Copyright 2021-2022 Polymatica
4
-
5
- Permission to use, copy, modify, and/or distribute this software for any
6
- purpose with or without fee is hereby granted, provided that the above
7
- copyright notice and this permission notice appear in all copies.
8
-
9
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1
+ ISC License
2
+
3
+ Copyright 2021-2022 Polymatica
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package/README.md CHANGED
@@ -1 +1 @@
1
- # Polymatica Widget SDK
1
+ # Polymatica Widget SDK
@@ -1 +1 @@
1
- export declare const widgetOptionsTargetKey = "6ba1fa0f-7eab-49f8-80ef-0fed376661e2";
1
+ export declare const widgetOptionsTargetKey = "6ba1fa0f-7eab-49f8-80ef-0fed376661e2";
@@ -1,4 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.widgetOptionsTargetKey = void 0;
4
- exports.widgetOptionsTargetKey = "6ba1fa0f-7eab-49f8-80ef-0fed376661e2";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.widgetOptionsTargetKey = void 0;
4
+ exports.widgetOptionsTargetKey = "6ba1fa0f-7eab-49f8-80ef-0fed376661e2";
@@ -1,4 +1,4 @@
1
- import { WidgetOption, WidgetOptionType } from "./widget-options";
2
- export declare function setWidgetOptionsTarget(options: WidgetOption[]): void;
3
- export declare function valueConversion(type: WidgetOptionType, source: any): any;
4
- export declare function getSpan(source?: number): number;
1
+ import { WidgetOption, WidgetOptionType } from "./widget-options";
2
+ export declare function setWidgetOptionsTarget(options: WidgetOption[]): void;
3
+ export declare function valueConversion(type: WidgetOptionType, source: any): any;
4
+ export declare function getSpan(source?: number): number;
@@ -1,63 +1,63 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getSpan = exports.valueConversion = exports.setWidgetOptionsTarget = void 0;
4
- const config_1 = require("../config");
5
- const constants_1 = require("./constants");
6
- const widget_options_1 = require("./widget-options");
7
- function setWidgetOptionsTarget(options) {
8
- globalThis[constants_1.widgetOptionsTargetKey] = options;
9
- }
10
- exports.setWidgetOptionsTarget = setWidgetOptionsTarget;
11
- function valueConversion(type, source) {
12
- switch (type) {
13
- case widget_options_1.WidgetOptionType.Text:
14
- case widget_options_1.WidgetOptionType.Title:
15
- return source ? String(source) : "";
16
- case widget_options_1.WidgetOptionType.Number:
17
- case widget_options_1.WidgetOptionType.Range:
18
- return source ? parseFloat(source) : 0;
19
- case widget_options_1.WidgetOptionType.Integer:
20
- return source ? parseInt(source, 10) : 0;
21
- case widget_options_1.WidgetOptionType.Interval:
22
- if (source)
23
- return {
24
- from: parseFloat(source.from) || 0,
25
- to: parseFloat(source.to) || 0,
26
- };
27
- return { from: 0, to: 0 };
28
- case widget_options_1.WidgetOptionType.Date:
29
- case widget_options_1.WidgetOptionType.DateTime:
30
- return parseDate(source);
31
- case widget_options_1.WidgetOptionType.Time:
32
- return source || "00:00";
33
- case widget_options_1.WidgetOptionType.DateInterval:
34
- if (source)
35
- return {
36
- from: parseDate(source.from),
37
- to: parseDate(source.to),
38
- };
39
- return { from: new Date(), to: new Date() };
40
- case widget_options_1.WidgetOptionType.ColorPicker:
41
- case widget_options_1.WidgetOptionType.Radio:
42
- case widget_options_1.WidgetOptionType.Select:
43
- return source;
44
- case widget_options_1.WidgetOptionType.Checkbox:
45
- return Boolean(source);
46
- default:
47
- return "";
48
- }
49
- }
50
- exports.valueConversion = valueConversion;
51
- function parseDate(source) {
52
- const data = new Date(source);
53
- return isNaN(data.valueOf()) ? new Date() : data;
54
- }
55
- function getSpan(source) {
56
- const span = source | 0;
57
- if (span > config_1.STEP)
58
- return config_1.STEP;
59
- if (span <= 0)
60
- return config_1.STEP;
61
- return span;
62
- }
63
- exports.getSpan = getSpan;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSpan = exports.valueConversion = exports.setWidgetOptionsTarget = void 0;
4
+ const config_1 = require("../config");
5
+ const constants_1 = require("./constants");
6
+ const widget_options_1 = require("./widget-options");
7
+ function setWidgetOptionsTarget(options) {
8
+ globalThis[constants_1.widgetOptionsTargetKey] = options;
9
+ }
10
+ exports.setWidgetOptionsTarget = setWidgetOptionsTarget;
11
+ function valueConversion(type, source) {
12
+ switch (type) {
13
+ case widget_options_1.WidgetOptionType.Text:
14
+ case widget_options_1.WidgetOptionType.Title:
15
+ return source ? String(source) : "";
16
+ case widget_options_1.WidgetOptionType.Number:
17
+ case widget_options_1.WidgetOptionType.Range:
18
+ return source ? parseFloat(source) : 0;
19
+ case widget_options_1.WidgetOptionType.Integer:
20
+ return source ? parseInt(source, 10) : 0;
21
+ case widget_options_1.WidgetOptionType.Interval:
22
+ if (source)
23
+ return {
24
+ from: parseFloat(source.from) || 0,
25
+ to: parseFloat(source.to) || 0,
26
+ };
27
+ return { from: 0, to: 0 };
28
+ case widget_options_1.WidgetOptionType.Date:
29
+ case widget_options_1.WidgetOptionType.DateTime:
30
+ return parseDate(source);
31
+ case widget_options_1.WidgetOptionType.Time:
32
+ return source || "00:00";
33
+ case widget_options_1.WidgetOptionType.DateInterval:
34
+ if (source)
35
+ return {
36
+ from: parseDate(source.from),
37
+ to: parseDate(source.to),
38
+ };
39
+ return { from: new Date(), to: new Date() };
40
+ case widget_options_1.WidgetOptionType.ColorPicker:
41
+ case widget_options_1.WidgetOptionType.Radio:
42
+ case widget_options_1.WidgetOptionType.Select:
43
+ return source;
44
+ case widget_options_1.WidgetOptionType.Checkbox:
45
+ return Boolean(source);
46
+ default:
47
+ return "";
48
+ }
49
+ }
50
+ exports.valueConversion = valueConversion;
51
+ function parseDate(source) {
52
+ const data = new Date(source);
53
+ return isNaN(data.valueOf()) ? new Date() : data;
54
+ }
55
+ function getSpan(source) {
56
+ const span = source | 0;
57
+ if (span > config_1.STEP)
58
+ return config_1.STEP;
59
+ if (span <= 0)
60
+ return config_1.STEP;
61
+ return span;
62
+ }
63
+ exports.getSpan = getSpan;
@@ -1,68 +1,68 @@
1
- import { Text } from "../locale";
2
- export declare enum WidgetOptionType {
3
- Title = "title",
4
- Label = "label",
5
- Spacer = "spacer",
6
- LineHorizontal = "line-horizontal",
7
- Tabs = "tabs",
8
- TabPanels = "tab-panels",
9
- Text = "text",
10
- Number = "number",
11
- Integer = "integer",
12
- Range = "range",
13
- Interval = "interval",
14
- Date = "date",
15
- Time = "time",
16
- DateTime = "datetime",
17
- DateInterval = "date-interval",
18
- Checkbox = "checkbox",
19
- ColorPicker = "color-picker",
20
- Radio = "radio",
21
- RadioButtons = "radio-buttons",
22
- Select = "select",
23
- Suggestion = "suggestion",
24
- Button = "button"
25
- }
26
- export interface WidgetOption {
27
- type: WidgetOptionType;
28
- }
29
- export interface Label extends WidgetOption {
30
- type: WidgetOptionType.Title | WidgetOptionType.Label;
31
- label: Text;
32
- hint?: Text;
33
- }
34
- export interface Spacer extends WidgetOption {
35
- type: WidgetOptionType.Spacer;
36
- span: number;
37
- }
38
- export interface Tabs extends WidgetOption {
39
- type: WidgetOptionType.Tabs;
40
- labels: {
41
- label: Text;
42
- value: string;
43
- }[];
44
- }
45
- export interface TabPanels extends WidgetOption {
46
- type: WidgetOptionType.TabPanels;
47
- items: Record<string, () => void>;
48
- }
49
- export interface Control extends WidgetOption {
50
- type: WidgetOptionType.Text | WidgetOptionType.Number | WidgetOptionType.Integer | WidgetOptionType.Range | WidgetOptionType.Interval | WidgetOptionType.Date | WidgetOptionType.Time | WidgetOptionType.DateTime | WidgetOptionType.DateInterval | WidgetOptionType.Checkbox | WidgetOptionType.ColorPicker;
51
- key: string;
52
- label: Text;
53
- span?: number;
54
- }
55
- export interface ControlWithOptions extends WidgetOption {
56
- type: WidgetOptionType.Radio | WidgetOptionType.RadioButtons | WidgetOptionType.Select | WidgetOptionType.Suggestion;
57
- key: string;
58
- label: Text;
59
- options: {
60
- label: Text;
61
- value: string | number | boolean;
62
- }[];
63
- }
64
- export interface Button extends WidgetOption {
65
- type: WidgetOptionType.Button;
66
- label: Text;
67
- target: string;
68
- }
1
+ import { Text } from "../locale";
2
+ export declare enum WidgetOptionType {
3
+ Title = "title",
4
+ Label = "label",
5
+ Spacer = "spacer",
6
+ LineHorizontal = "line-horizontal",
7
+ Tabs = "tabs",
8
+ TabPanels = "tab-panels",
9
+ Text = "text",
10
+ Number = "number",
11
+ Integer = "integer",
12
+ Range = "range",
13
+ Interval = "interval",
14
+ Date = "date",
15
+ Time = "time",
16
+ DateTime = "datetime",
17
+ DateInterval = "date-interval",
18
+ Checkbox = "checkbox",
19
+ ColorPicker = "color-picker",
20
+ Radio = "radio",
21
+ RadioButtons = "radio-buttons",
22
+ Select = "select",
23
+ Suggestion = "suggestion",
24
+ Button = "button"
25
+ }
26
+ export interface WidgetOption {
27
+ type: WidgetOptionType;
28
+ }
29
+ export interface Label extends WidgetOption {
30
+ type: WidgetOptionType.Title | WidgetOptionType.Label;
31
+ label: Text;
32
+ hint?: Text;
33
+ }
34
+ export interface Spacer extends WidgetOption {
35
+ type: WidgetOptionType.Spacer;
36
+ span: number;
37
+ }
38
+ export interface Tabs extends WidgetOption {
39
+ type: WidgetOptionType.Tabs;
40
+ labels: {
41
+ label: Text;
42
+ value: string;
43
+ }[];
44
+ }
45
+ export interface TabPanels extends WidgetOption {
46
+ type: WidgetOptionType.TabPanels;
47
+ items: Record<string, () => void>;
48
+ }
49
+ export interface Control extends WidgetOption {
50
+ type: WidgetOptionType.Text | WidgetOptionType.Number | WidgetOptionType.Integer | WidgetOptionType.Range | WidgetOptionType.Interval | WidgetOptionType.Date | WidgetOptionType.Time | WidgetOptionType.DateTime | WidgetOptionType.DateInterval | WidgetOptionType.Checkbox | WidgetOptionType.ColorPicker;
51
+ key: string;
52
+ label: Text;
53
+ span?: number;
54
+ }
55
+ export interface ControlWithOptions extends WidgetOption {
56
+ type: WidgetOptionType.Radio | WidgetOptionType.RadioButtons | WidgetOptionType.Select | WidgetOptionType.Suggestion;
57
+ key: string;
58
+ label: Text;
59
+ options: {
60
+ label: Text;
61
+ value: string | number | boolean;
62
+ }[];
63
+ }
64
+ export interface Button extends WidgetOption {
65
+ type: WidgetOptionType.Button;
66
+ label: Text;
67
+ target: string;
68
+ }
@@ -1,31 +1,31 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WidgetOptionType = void 0;
4
- var WidgetOptionType;
5
- (function (WidgetOptionType) {
6
- // Layout
7
- WidgetOptionType["Title"] = "title";
8
- WidgetOptionType["Label"] = "label";
9
- WidgetOptionType["Spacer"] = "spacer";
10
- WidgetOptionType["LineHorizontal"] = "line-horizontal";
11
- WidgetOptionType["Tabs"] = "tabs";
12
- WidgetOptionType["TabPanels"] = "tab-panels";
13
- // Controls
14
- WidgetOptionType["Text"] = "text";
15
- WidgetOptionType["Number"] = "number";
16
- WidgetOptionType["Integer"] = "integer";
17
- WidgetOptionType["Range"] = "range";
18
- WidgetOptionType["Interval"] = "interval";
19
- WidgetOptionType["Date"] = "date";
20
- WidgetOptionType["Time"] = "time";
21
- WidgetOptionType["DateTime"] = "datetime";
22
- WidgetOptionType["DateInterval"] = "date-interval";
23
- WidgetOptionType["Checkbox"] = "checkbox";
24
- WidgetOptionType["ColorPicker"] = "color-picker";
25
- WidgetOptionType["Radio"] = "radio";
26
- WidgetOptionType["RadioButtons"] = "radio-buttons";
27
- WidgetOptionType["Select"] = "select";
28
- WidgetOptionType["Suggestion"] = "suggestion";
29
- // Actions
30
- WidgetOptionType["Button"] = "button";
31
- })(WidgetOptionType = exports.WidgetOptionType || (exports.WidgetOptionType = {}));
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WidgetOptionType = void 0;
4
+ var WidgetOptionType;
5
+ (function (WidgetOptionType) {
6
+ // Layout
7
+ WidgetOptionType["Title"] = "title";
8
+ WidgetOptionType["Label"] = "label";
9
+ WidgetOptionType["Spacer"] = "spacer";
10
+ WidgetOptionType["LineHorizontal"] = "line-horizontal";
11
+ WidgetOptionType["Tabs"] = "tabs";
12
+ WidgetOptionType["TabPanels"] = "tab-panels";
13
+ // Controls
14
+ WidgetOptionType["Text"] = "text";
15
+ WidgetOptionType["Number"] = "number";
16
+ WidgetOptionType["Integer"] = "integer";
17
+ WidgetOptionType["Range"] = "range";
18
+ WidgetOptionType["Interval"] = "interval";
19
+ WidgetOptionType["Date"] = "date";
20
+ WidgetOptionType["Time"] = "time";
21
+ WidgetOptionType["DateTime"] = "datetime";
22
+ WidgetOptionType["DateInterval"] = "date-interval";
23
+ WidgetOptionType["Checkbox"] = "checkbox";
24
+ WidgetOptionType["ColorPicker"] = "color-picker";
25
+ WidgetOptionType["Radio"] = "radio";
26
+ WidgetOptionType["RadioButtons"] = "radio-buttons";
27
+ WidgetOptionType["Select"] = "select";
28
+ WidgetOptionType["Suggestion"] = "suggestion";
29
+ // Actions
30
+ WidgetOptionType["Button"] = "button";
31
+ })(WidgetOptionType = exports.WidgetOptionType || (exports.WidgetOptionType = {}));