plmt-constructor-sdk 0.13.5 → 0.13.7

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.
@@ -1,112 +1,112 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createColorizeColors = exports.colorizeClassName = exports.provideCssVariables = exports.themeProjectKeys = exports.themeKeys = void 0;
4
- const logical_not_1 = require("logical-not");
5
- exports.themeKeys = [
6
- 'background',
7
- 'backgroundBright',
8
- 'backgroundTint',
9
- 'text',
10
- 'textTint',
11
- ];
12
- exports.themeProjectKeys = ['colors'];
13
- const head = document.querySelector('head');
14
- const body = document.querySelector('body');
15
- const providedCssVariablesMap = {};
16
- let prevThemeClassName = '';
17
- let prevThemeProjectClassName = '';
18
- function provideCssVariables({ theme, themeKey, themeProjectKey, }) {
19
- const themeClassName = `plmt-theme-${kebabCase(themeKey)}`;
20
- if ((0, logical_not_1.not)(themeClassName in providedCssVariablesMap)) {
21
- const cssVariables = [];
22
- Object.entries(theme).forEach(([key, source]) => {
23
- if (exports.themeKeys.includes(key)) {
24
- const name = kebabCase(key);
25
- if (Array.isArray(source))
26
- source.forEach((value, i) => cssVariables.push({
27
- name: `--${name}-${i}`,
28
- value,
29
- }));
30
- else
31
- cssVariables.push({ name: `--${name}`, value: source });
32
- }
33
- });
34
- addStyles(themeClassName, [
35
- { className: themeClassName, cssProperties: cssVariables },
36
- ]);
37
- }
38
- prevThemeClassName = switchClassName(prevThemeClassName, themeClassName);
39
- const themeProjectClassName = `plmt-project-${themeProjectKey}`;
40
- if ((0, logical_not_1.not)(themeProjectClassName in providedCssVariablesMap)) {
41
- const cssVariables = theme.colors.map((value, i) => ({
42
- name: `--plmt-color-${i}`,
43
- value,
44
- }));
45
- addStyles(themeProjectClassName, [
46
- { className: themeProjectClassName, cssProperties: cssVariables },
47
- ]);
48
- }
49
- prevThemeProjectClassName = switchClassName(prevThemeProjectClassName, themeProjectClassName);
50
- if ((0, logical_not_1.not)('colorize' in providedCssVariablesMap)) {
51
- const items = [];
52
- theme.colorize.forEach((colors, i) => {
53
- colors.forEach((value, j) => items.push({
54
- className: colorizeClassName(i, j),
55
- cssProperties: [
56
- {
57
- name: 'background-color',
58
- value,
59
- },
60
- ],
61
- }));
62
- });
63
- addStyles(`colorize`, items);
64
- }
65
- }
66
- exports.provideCssVariables = provideCssVariables;
67
- function colorizeClassName(i, j) {
68
- return `plmt-colorize-${i}-${j}`;
69
- }
70
- exports.colorizeClassName = colorizeClassName;
71
- const range10 = [...Array(10)].map((_, i) => i);
72
- function createColorizeColors(source) {
73
- return source.map((color) => {
74
- const [r, g, b] = parseColor(color);
75
- return range10.map((i) => `rgba(${r},${g},${b},${++i > 9 ? '1' : `0.${i}`})`);
76
- });
77
- }
78
- exports.createColorizeColors = createColorizeColors;
79
- const color6hex = /([0-9abcdef]{2})([0-9abcdef]{2})([0-9abcdef]{2})/i;
80
- const color3hex = /([0-9abcdef])([0-9abcdef])([0-9abcdef])/i;
81
- function parseColor(source) {
82
- const [, r, g, b] = source.match(color6hex) ||
83
- source.match(color3hex) || [, '0', '0', '0'];
84
- return [parseInt(r, 16), parseInt(g, 16), parseInt(b, 16)];
85
- }
86
- function addStyles(name, items) {
87
- const style = document.createElement('style');
88
- providedCssVariablesMap[name] = style;
89
- const styleParts = [];
90
- items.forEach(({ className, cssProperties }) => {
91
- styleParts.push('.', className, '{\n');
92
- cssProperties.forEach(({ name, value }) => styleParts.push(' ', name, ': ', value, ';\n'));
93
- styleParts.push('}\n');
94
- });
95
- style.innerHTML = styleParts.join('');
96
- head.append(style);
97
- }
98
- function switchClassName(prev, next) {
99
- if (prev)
100
- body.classList.remove(prev);
101
- body.classList.add(next);
102
- return next;
103
- }
104
- function kebabCase(source) {
105
- const chars = Array(source.length);
106
- for (let i = 0, lim = source.length; i < lim; i++) {
107
- const char = source.charAt(i);
108
- const lowerCaseChar = char.toLowerCase();
109
- chars[i] = char === lowerCaseChar ? char : '-' + lowerCaseChar;
110
- }
111
- return chars.join('');
112
- }
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createColorizeColors = exports.colorizeClassName = exports.provideCssVariables = exports.themeProjectKeys = exports.themeKeys = void 0;
4
+ const logical_not_1 = require("logical-not");
5
+ exports.themeKeys = [
6
+ 'background',
7
+ 'backgroundBright',
8
+ 'backgroundTint',
9
+ 'text',
10
+ 'textTint',
11
+ ];
12
+ exports.themeProjectKeys = ['colors'];
13
+ const head = document.querySelector('head');
14
+ const body = document.querySelector('body');
15
+ const providedCssVariablesMap = {};
16
+ let prevThemeClassName = '';
17
+ let prevThemeProjectClassName = '';
18
+ function provideCssVariables({ theme, themeKey, themeProjectKey, }) {
19
+ const themeClassName = `plmt-theme-${kebabCase(themeKey)}`;
20
+ if ((0, logical_not_1.not)(themeClassName in providedCssVariablesMap)) {
21
+ const cssVariables = [];
22
+ Object.entries(theme).forEach(([key, source]) => {
23
+ if (exports.themeKeys.includes(key)) {
24
+ const name = kebabCase(key);
25
+ if (Array.isArray(source))
26
+ source.forEach((value, i) => cssVariables.push({
27
+ name: `--${name}-${i}`,
28
+ value,
29
+ }));
30
+ else
31
+ cssVariables.push({ name: `--${name}`, value: source });
32
+ }
33
+ });
34
+ addStyles(themeClassName, [
35
+ { className: themeClassName, cssProperties: cssVariables },
36
+ ]);
37
+ }
38
+ prevThemeClassName = switchClassName(prevThemeClassName, themeClassName);
39
+ const themeProjectClassName = `plmt-project-${themeProjectKey}`;
40
+ if ((0, logical_not_1.not)(themeProjectClassName in providedCssVariablesMap)) {
41
+ const cssVariables = theme.colors.map((value, i) => ({
42
+ name: `--plmt-color-${i}`,
43
+ value,
44
+ }));
45
+ addStyles(themeProjectClassName, [
46
+ { className: themeProjectClassName, cssProperties: cssVariables },
47
+ ]);
48
+ }
49
+ prevThemeProjectClassName = switchClassName(prevThemeProjectClassName, themeProjectClassName);
50
+ if ((0, logical_not_1.not)('colorize' in providedCssVariablesMap)) {
51
+ const items = [];
52
+ theme.colorize.forEach((colors, i) => {
53
+ colors.forEach((value, j) => items.push({
54
+ className: colorizeClassName(i, j),
55
+ cssProperties: [
56
+ {
57
+ name: 'background-color',
58
+ value,
59
+ },
60
+ ],
61
+ }));
62
+ });
63
+ addStyles(`colorize`, items);
64
+ }
65
+ }
66
+ exports.provideCssVariables = provideCssVariables;
67
+ function colorizeClassName(i, j) {
68
+ return `plmt-colorize-${i}-${j}`;
69
+ }
70
+ exports.colorizeClassName = colorizeClassName;
71
+ const range10 = [...Array(10)].map((_, i) => i);
72
+ function createColorizeColors(source) {
73
+ return source.map((color) => {
74
+ const [r, g, b] = parseColor(color);
75
+ return range10.map((i) => `rgba(${r},${g},${b},${++i > 9 ? '1' : `0.${i}`})`);
76
+ });
77
+ }
78
+ exports.createColorizeColors = createColorizeColors;
79
+ const color6hex = /([0-9abcdef]{2})([0-9abcdef]{2})([0-9abcdef]{2})/i;
80
+ const color3hex = /([0-9abcdef])([0-9abcdef])([0-9abcdef])/i;
81
+ function parseColor(source) {
82
+ const [, r, g, b] = source.match(color6hex) ||
83
+ source.match(color3hex) || [, '0', '0', '0'];
84
+ return [parseInt(r, 16), parseInt(g, 16), parseInt(b, 16)];
85
+ }
86
+ function addStyles(name, items) {
87
+ const style = document.createElement('style');
88
+ providedCssVariablesMap[name] = style;
89
+ const styleParts = [];
90
+ items.forEach(({ className, cssProperties }) => {
91
+ styleParts.push('.', className, '{\n');
92
+ cssProperties.forEach(({ name, value }) => styleParts.push(' ', name, ': ', value, ';\n'));
93
+ styleParts.push('}\n');
94
+ });
95
+ style.innerHTML = styleParts.join('');
96
+ head.append(style);
97
+ }
98
+ function switchClassName(prev, next) {
99
+ if (prev)
100
+ body.classList.remove(prev);
101
+ body.classList.add(next);
102
+ return next;
103
+ }
104
+ function kebabCase(source) {
105
+ const chars = Array(source.length);
106
+ for (let i = 0, lim = source.length; i < lim; i++) {
107
+ const char = source.charAt(i);
108
+ const lowerCaseChar = char.toLowerCase();
109
+ chars[i] = char === lowerCaseChar ? char : '-' + lowerCaseChar;
110
+ }
111
+ return chars.join('');
112
+ }
@@ -1,24 +1,24 @@
1
- import { Text, ViewSettingsItem } from '../config';
2
- export declare enum ViewSettingsItemType {
3
- Input = "text",
4
- Checkbox = "checkbox",
5
- Radio = "radio",
6
- Select = "select",
7
- ColorPicker = "color-picker",
8
- Title = "title",
9
- TextArea = "textArea"
10
- }
11
- export interface ViewSettingsItemValue {
12
- type: ViewSettingsItemType;
13
- key: string;
14
- label: Text;
15
- defaultValue?: any;
16
- options?: {
17
- label: Text;
18
- value: string;
19
- }[];
20
- span?: number;
21
- }
22
- export declare const viewSettingsItemValue = "418d9556-a046-4623-be0b-4f4f69ccb783";
23
- export declare function viewSettingsExtract(viewSettings: ViewSettingsItem[]): ViewSettingsItemValue[];
24
- export declare function valueConversion(type: ViewSettingsItemType, source: any): any;
1
+ import { Text, ViewSettingsItem } from '../config';
2
+ export declare enum ViewSettingsItemType {
3
+ Input = "text",
4
+ Checkbox = "checkbox",
5
+ Radio = "radio",
6
+ Select = "select",
7
+ ColorPicker = "color-picker",
8
+ Title = "title",
9
+ TextArea = "textArea"
10
+ }
11
+ export interface ViewSettingsItemValue {
12
+ type: ViewSettingsItemType;
13
+ key: string;
14
+ label: Text;
15
+ defaultValue?: any;
16
+ options?: {
17
+ label: Text;
18
+ value: string;
19
+ }[];
20
+ span?: number;
21
+ }
22
+ export declare const viewSettingsItemValue = "418d9556-a046-4623-be0b-4f4f69ccb783";
23
+ export declare function viewSettingsExtract(viewSettings: ViewSettingsItem[]): ViewSettingsItemValue[];
24
+ export declare function valueConversion(type: ViewSettingsItemType, source: any): any;
@@ -1,50 +1,50 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.valueConversion = exports.viewSettingsExtract = exports.viewSettingsItemValue = exports.ViewSettingsItemType = void 0;
4
- var ViewSettingsItemType;
5
- (function (ViewSettingsItemType) {
6
- ViewSettingsItemType["Input"] = "text";
7
- ViewSettingsItemType["Checkbox"] = "checkbox";
8
- ViewSettingsItemType["Radio"] = "radio";
9
- ViewSettingsItemType["Select"] = "select";
10
- ViewSettingsItemType["ColorPicker"] = "color-picker";
11
- ViewSettingsItemType["Title"] = "title";
12
- ViewSettingsItemType["TextArea"] = "textArea";
13
- })(ViewSettingsItemType = exports.ViewSettingsItemType || (exports.ViewSettingsItemType = {}));
14
- exports.viewSettingsItemValue = '418d9556-a046-4623-be0b-4f4f69ccb783';
15
- function viewSettingsExtract(viewSettings) {
16
- return viewSettings
17
- .map((item) => item[exports.viewSettingsItemValue])
18
- .map((item) => ({
19
- type: item.type,
20
- key: item.key,
21
- label: item.label,
22
- defaultValue: valueConversion(item.type, item.defaultValue),
23
- options: item.options || [],
24
- span: getSpan(item.span),
25
- }));
26
- }
27
- exports.viewSettingsExtract = viewSettingsExtract;
28
- function valueConversion(type, source) {
29
- switch (type) {
30
- case ViewSettingsItemType.Input:
31
- case ViewSettingsItemType.Radio:
32
- case ViewSettingsItemType.Select:
33
- case ViewSettingsItemType.ColorPicker:
34
- case ViewSettingsItemType.TextArea:
35
- return source ? String(source) : '';
36
- case ViewSettingsItemType.Checkbox:
37
- return Boolean(source);
38
- default:
39
- return '';
40
- }
41
- }
42
- exports.valueConversion = valueConversion;
43
- function getSpan(source) {
44
- source |= 0;
45
- if (source > 24)
46
- return 24;
47
- if (source < 0)
48
- return 0;
49
- return source;
50
- }
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.valueConversion = exports.viewSettingsExtract = exports.viewSettingsItemValue = exports.ViewSettingsItemType = void 0;
4
+ var ViewSettingsItemType;
5
+ (function (ViewSettingsItemType) {
6
+ ViewSettingsItemType["Input"] = "text";
7
+ ViewSettingsItemType["Checkbox"] = "checkbox";
8
+ ViewSettingsItemType["Radio"] = "radio";
9
+ ViewSettingsItemType["Select"] = "select";
10
+ ViewSettingsItemType["ColorPicker"] = "color-picker";
11
+ ViewSettingsItemType["Title"] = "title";
12
+ ViewSettingsItemType["TextArea"] = "textArea";
13
+ })(ViewSettingsItemType = exports.ViewSettingsItemType || (exports.ViewSettingsItemType = {}));
14
+ exports.viewSettingsItemValue = '418d9556-a046-4623-be0b-4f4f69ccb783';
15
+ function viewSettingsExtract(viewSettings) {
16
+ return viewSettings
17
+ .map((item) => item[exports.viewSettingsItemValue])
18
+ .map((item) => ({
19
+ type: item.type,
20
+ key: item.key,
21
+ label: item.label,
22
+ defaultValue: valueConversion(item.type, item.defaultValue),
23
+ options: item.options || [],
24
+ span: getSpan(item.span),
25
+ }));
26
+ }
27
+ exports.viewSettingsExtract = viewSettingsExtract;
28
+ function valueConversion(type, source) {
29
+ switch (type) {
30
+ case ViewSettingsItemType.Input:
31
+ case ViewSettingsItemType.Radio:
32
+ case ViewSettingsItemType.Select:
33
+ case ViewSettingsItemType.ColorPicker:
34
+ case ViewSettingsItemType.TextArea:
35
+ return source ? String(source) : '';
36
+ case ViewSettingsItemType.Checkbox:
37
+ return Boolean(source);
38
+ default:
39
+ return '';
40
+ }
41
+ }
42
+ exports.valueConversion = valueConversion;
43
+ function getSpan(source) {
44
+ source |= 0;
45
+ if (source > 24)
46
+ return 24;
47
+ if (source < 0)
48
+ return 0;
49
+ return source;
50
+ }
@@ -1,56 +1,56 @@
1
- import { Locale } from '../config';
2
- import { Filter, Sort, Target } from '../data';
3
- import { WidgetRenderEnv } from '../widget';
4
- import { ThemeProvide } from './theme';
5
- import { WidgetDataOptionColumn_Server, WidgetRepresent } from './widget';
6
- export declare enum Input {
7
- Change = "ptnl.input.change",
8
- ChangeLang = "ptnl.input.changeLang",
9
- ChangeTheme = "ptnl.input.changeTheme",
10
- ChangeOtherFilters = "ptnl.input.ChangeOtherFilters",
11
- ChangeWidgetRenderEnv = "ptnl.input.changeWidgetRenderEnv"
12
- }
13
- export declare enum Output {
14
- Init = "ptnl.output.init",
15
- Ready = "ptnl.output.ready",
16
- SetFilter = "ptnl.output.setFilter",
17
- RemoveFilterAt = "ptnl.output.RemoveFilterAt",
18
- SetSort = "ptnl.output.setSort",
19
- RemoveSortAt = "ptnl.output.RemoveSortAt",
20
- Interact = "ptnl.output.interact"
21
- }
22
- export interface InputParameter extends Record<Input, any> {
23
- [Input.Change]: WidgetRepresent;
24
- [Input.ChangeLang]: Locale;
25
- [Input.ChangeTheme]: ThemeProvide;
26
- [Input.ChangeOtherFilters]: WidgetDataOptionColumn_Server[];
27
- [Input.ChangeWidgetRenderEnv]: WidgetRenderEnv;
28
- }
29
- export interface OutputParameter extends Record<Output, any> {
30
- [Output.Init]: void;
31
- [Output.Ready]: void;
32
- [Output.SetFilter]: {
33
- filter: Filter;
34
- target: Target;
35
- rowIndex: number;
36
- };
37
- [Output.RemoveFilterAt]: {
38
- index: number;
39
- };
40
- [Output.SetSort]: {
41
- sort: Sort;
42
- target: Target;
43
- };
44
- [Output.RemoveSortAt]: {
45
- index: number;
46
- };
47
- [Output.Interact]: {
48
- dataOptionId: number;
49
- dataIndex: number;
50
- };
51
- }
52
- export interface OutputData {
53
- token: string;
54
- type: Output;
55
- payload?: any;
56
- }
1
+ import { Locale } from '../config';
2
+ import { Filter, Sort, Target } from '../data';
3
+ import { WidgetRenderEnv } from '../widget';
4
+ import { ThemeProvide } from './theme';
5
+ import { WidgetDataOptionColumn_Server, WidgetRepresent } from './widget';
6
+ export declare enum Input {
7
+ Change = "ptnl.input.change",
8
+ ChangeLang = "ptnl.input.changeLang",
9
+ ChangeTheme = "ptnl.input.changeTheme",
10
+ ChangeOtherFilters = "ptnl.input.ChangeOtherFilters",
11
+ ChangeWidgetRenderEnv = "ptnl.input.changeWidgetRenderEnv"
12
+ }
13
+ export declare enum Output {
14
+ Init = "ptnl.output.init",
15
+ Ready = "ptnl.output.ready",
16
+ SetFilter = "ptnl.output.setFilter",
17
+ RemoveFilterAt = "ptnl.output.RemoveFilterAt",
18
+ SetSort = "ptnl.output.setSort",
19
+ RemoveSortAt = "ptnl.output.RemoveSortAt",
20
+ Interact = "ptnl.output.interact"
21
+ }
22
+ export interface InputParameter extends Record<Input, any> {
23
+ [Input.Change]: WidgetRepresent;
24
+ [Input.ChangeLang]: Locale;
25
+ [Input.ChangeTheme]: ThemeProvide;
26
+ [Input.ChangeOtherFilters]: WidgetDataOptionColumn_Server[];
27
+ [Input.ChangeWidgetRenderEnv]: WidgetRenderEnv;
28
+ }
29
+ export interface OutputParameter extends Record<Output, any> {
30
+ [Output.Init]: void;
31
+ [Output.Ready]: void;
32
+ [Output.SetFilter]: {
33
+ filter: Filter;
34
+ target: Target;
35
+ rowIndex: number;
36
+ };
37
+ [Output.RemoveFilterAt]: {
38
+ index: number;
39
+ };
40
+ [Output.SetSort]: {
41
+ sort: Sort;
42
+ target: Target;
43
+ };
44
+ [Output.RemoveSortAt]: {
45
+ index: number;
46
+ };
47
+ [Output.Interact]: {
48
+ dataOptionId: number;
49
+ dataIndex: number;
50
+ };
51
+ }
52
+ export interface OutputData {
53
+ token: string;
54
+ type: Output;
55
+ payload?: any;
56
+ }
@@ -1,21 +1,21 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Output = exports.Input = void 0;
4
- var Input;
5
- (function (Input) {
6
- Input["Change"] = "ptnl.input.change";
7
- Input["ChangeLang"] = "ptnl.input.changeLang";
8
- Input["ChangeTheme"] = "ptnl.input.changeTheme";
9
- Input["ChangeOtherFilters"] = "ptnl.input.ChangeOtherFilters";
10
- Input["ChangeWidgetRenderEnv"] = "ptnl.input.changeWidgetRenderEnv";
11
- })(Input = exports.Input || (exports.Input = {}));
12
- var Output;
13
- (function (Output) {
14
- Output["Init"] = "ptnl.output.init";
15
- Output["Ready"] = "ptnl.output.ready";
16
- Output["SetFilter"] = "ptnl.output.setFilter";
17
- Output["RemoveFilterAt"] = "ptnl.output.RemoveFilterAt";
18
- Output["SetSort"] = "ptnl.output.setSort";
19
- Output["RemoveSortAt"] = "ptnl.output.RemoveSortAt";
20
- Output["Interact"] = "ptnl.output.interact";
21
- })(Output = exports.Output || (exports.Output = {}));
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Output = exports.Input = void 0;
4
+ var Input;
5
+ (function (Input) {
6
+ Input["Change"] = "ptnl.input.change";
7
+ Input["ChangeLang"] = "ptnl.input.changeLang";
8
+ Input["ChangeTheme"] = "ptnl.input.changeTheme";
9
+ Input["ChangeOtherFilters"] = "ptnl.input.ChangeOtherFilters";
10
+ Input["ChangeWidgetRenderEnv"] = "ptnl.input.changeWidgetRenderEnv";
11
+ })(Input = exports.Input || (exports.Input = {}));
12
+ var Output;
13
+ (function (Output) {
14
+ Output["Init"] = "ptnl.output.init";
15
+ Output["Ready"] = "ptnl.output.ready";
16
+ Output["SetFilter"] = "ptnl.output.setFilter";
17
+ Output["RemoveFilterAt"] = "ptnl.output.RemoveFilterAt";
18
+ Output["SetSort"] = "ptnl.output.setSort";
19
+ Output["RemoveSortAt"] = "ptnl.output.RemoveSortAt";
20
+ Output["Interact"] = "ptnl.output.interact";
21
+ })(Output = exports.Output || (exports.Output = {}));
@@ -1,4 +1,4 @@
1
- import { DataSettings } from '../widget';
2
- import { WidgetRepresent } from './widget';
3
- export declare type DataSettingsMethods = Pick<DataSettings, 'setFilter' | 'removeFilterAt' | 'setSort' | 'removeSortAt' | 'interact'>;
4
- export declare function provideDataTo(widget: any, { dataOptionsMap, viewOptions }: WidgetRepresent, dataSettingsMethods?: DataSettingsMethods): void;
1
+ import { DataSettings } from '../widget';
2
+ import { WidgetRepresent } from './widget';
3
+ export declare type DataSettingsMethods = Pick<DataSettings, 'setFilter' | 'removeFilterAt' | 'setSort' | 'removeSortAt' | 'interact'>;
4
+ export declare function provideDataTo(widget: any, { dataOptionsMap, viewOptions }: WidgetRepresent, dataSettingsMethods?: DataSettingsMethods): void;