@evlop/commons 1.0.103 → 1.0.106
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/src/components/hoc/withSettings.d.ts.map +1 -1
- package/dist/src/components/hoc/withSettings.js +15 -21
- package/dist/src/components/hoc/withSettings.js.map +1 -1
- package/dist/src/helpers/index.d.ts +1 -0
- package/dist/src/helpers/index.d.ts.map +1 -1
- package/dist/src/helpers/index.js +1 -0
- package/dist/src/helpers/index.js.map +1 -1
- package/dist/src/helpers/themeHelpers.d.ts +21 -0
- package/dist/src/helpers/themeHelpers.d.ts.map +1 -0
- package/dist/src/helpers/themeHelpers.js +88 -0
- package/dist/src/helpers/themeHelpers.js.map +1 -0
- package/package.json +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"withSettings.d.ts","sourceRoot":"","sources":["../../../../src/components/hoc/withSettings.tsx"],"names":[],"mappings":"AACA,OAAO,KAAoF,MAAM,OAAO,CAAC;AAIzG,eAAO,MAAM,YAAY;;;;
|
1
|
+
{"version":3,"file":"withSettings.d.ts","sourceRoot":"","sources":["../../../../src/components/hoc/withSettings.tsx"],"names":[],"mappings":"AACA,OAAO,KAAoF,MAAM,OAAO,CAAC;AAIzG,eAAO,MAAM,YAAY;;;;mIAsLvB,CAAC;AAGH,eAAO,MAAM,WAAW;;;;mIAAe,CAAC;AACxC,eAAe,YAAY,CAAC"}
|
@@ -29,12 +29,9 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
29
29
|
}
|
30
30
|
return t;
|
31
31
|
};
|
32
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
33
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
34
|
-
};
|
35
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
36
33
|
exports.withToolbar = exports.withSettings = void 0;
|
37
|
-
const lodash_1 =
|
34
|
+
const lodash_1 = __importStar(require("lodash"));
|
38
35
|
const react_1 = __importStar(require("react"));
|
39
36
|
const contexts_1 = require("../../contexts");
|
40
37
|
const hooks_1 = require("../../hooks");
|
@@ -42,9 +39,8 @@ const withSettings = ({ name: elementName, valueOptions = [], configurationOptio
|
|
42
39
|
const newRef = react_1.useRef();
|
43
40
|
const ref = react_1.useMemo(() => forwardedRef || newRef, [newRef, forwardedRef]);
|
44
41
|
const { model, dataModel = model, configModel = dataModel && `${dataModel}_config`, restrictEdit, action: actionProp, onPress, onClick: onClickProp = onPress } = props;
|
45
|
-
const configDataKey = react_1.useMemo(() => configModel, [dataModel, configModel]);
|
46
42
|
const isEditing = hooks_1.useEditable();
|
47
|
-
const isEditable = !!dataModel || !!
|
43
|
+
const isEditable = !!dataModel || !!configModel;
|
48
44
|
const editMode = isEditing && isEditable;
|
49
45
|
const id = react_1.useMemo(() => lodash_1.default.random(100000000000000), []);
|
50
46
|
const { data, updateData } = hooks_1.useComponentData();
|
@@ -53,22 +49,20 @@ const withSettings = ({ name: elementName, valueOptions = [], configurationOptio
|
|
53
49
|
const values = react_1.useMemo(() => {
|
54
50
|
if (!dataModel || !valueOptions)
|
55
51
|
return {};
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
}, {});
|
52
|
+
// merge configuration option from props and configuration option values from model
|
53
|
+
const valuePropNames = lodash_1.map(valueOptions, 'name');
|
54
|
+
const propsForValue = lodash_1.pick(props, valuePropNames);
|
55
|
+
return lodash_1.assign(propsForValue, lodash_1.get(data, dataModel));
|
61
56
|
}, [dataModel, props, data]);
|
62
57
|
// Extract configs from component data
|
63
58
|
const configs = react_1.useMemo(() => {
|
64
|
-
if (!
|
59
|
+
if (!configModel || !configurationOptions)
|
65
60
|
return {};
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
}, [configDataKey, props, data]);
|
61
|
+
// merge configuration option from props and configuration option values from model
|
62
|
+
const configOptionPropNames = lodash_1.map(configurationOptions, 'name');
|
63
|
+
const propsForConfigOptions = lodash_1.pick(props, configOptionPropNames);
|
64
|
+
return lodash_1.assign(propsForConfigOptions, lodash_1.get(data, configModel));
|
65
|
+
}, [configModel, props, data]);
|
72
66
|
const action = values.action || actionProp;
|
73
67
|
const { focused, onFocus, onBlur } = hooks_1.useFocus();
|
74
68
|
const [hovered, setHover] = react_1.useState(false);
|
@@ -171,11 +165,11 @@ const withSettings = ({ name: elementName, valueOptions = [], configurationOptio
|
|
171
165
|
break;
|
172
166
|
case 'elementValueUpdated': {
|
173
167
|
const { name: key, value } = data;
|
174
|
-
updateData(`${isValue(key) ? dataModel :
|
168
|
+
updateData(`${isValue(key) ? dataModel : configModel}.${key}`, value);
|
175
169
|
break;
|
176
170
|
}
|
177
171
|
}
|
178
|
-
}, [id, dataModel, onFocus, onBlur,
|
172
|
+
}, [id, dataModel, onFocus, onBlur, configModel, updateData]);
|
179
173
|
react_1.useEffect(() => {
|
180
174
|
if (editMode) {
|
181
175
|
window.addEventListener('message', onConfigUpdate);
|
@@ -187,7 +181,7 @@ const withSettings = ({ name: elementName, valueOptions = [], configurationOptio
|
|
187
181
|
return { stack: [{ id, name: dataModel, ref, values, update: updateData, valueOptions, configurationOptions }, ...toolbarStack], setActiveToolbar };
|
188
182
|
}, [id, dataModel, values, toolbarStack, setActiveToolbar, ref, updateData]);
|
189
183
|
return (react_1.default.createElement(contexts_1.ToolbarProvider, { value: elementContext },
|
190
|
-
react_1.default.createElement(RenderComponent, Object.assign({ "data-id": id, animate: true, change: change, focused: focused, hovered: hovered, isEditing: editMode }, props,
|
184
|
+
react_1.default.createElement(RenderComponent, Object.assign({ "data-id": id, animate: true, change: change, focused: focused, hovered: hovered, isEditing: editMode }, props, configs, values, extraProps, { action: forwardActions, ref: ref }))));
|
191
185
|
});
|
192
186
|
exports.withSettings = withSettings;
|
193
187
|
exports.withToolbar = exports.withSettings;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"withSettings.js","sourceRoot":"","sources":["../../../../src/components/hoc/withSettings.tsx"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"withSettings.js","sourceRoot":"","sources":["../../../../src/components/hoc/with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,CAAC,yBAAc,CAAC,CAAC;IAE3E,MAAM,cAAc,GAAO,eAAO,CAAC,GAAE,EAAE;QACnC,OAAO,EAAC,KAAK,EAAC,CAAC,EAAC,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,oBAAoB,EAAC,EAAE,GAAG,YAAY,CAAC,EAAE,gBAAgB,EAAC,CAAC;IACnJ,CAAC,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,gBAAgB,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC;IAG7E,OAAO,CACH,8BAAC,0BAAe,IAAC,KAAK,EAAE,cAAc;QAClC,8BAAC,eAAe,6BACH,EAAE,EACX,OAAO,QACP,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,QAAQ,IACf,KAAK,EACL,OAAO,EACP,MAAM,EACN,UAAU,IACd,MAAM,EAAE,cAAc,EACtB,GAAG,EAAE,GAAG,IACV,CACY,CACrB,CAAC;AACN,CAAC,CAAC,CAAC;AAtLU,QAAA,YAAY,gBAsLtB;AAGU,QAAA,WAAW,GAAG,oBAAY,CAAC;AACxC,kBAAe,oBAAY,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/helpers/index.tsx"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC"}
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/helpers/index.tsx"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC"}
|
@@ -13,4 +13,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
require("./handlebarHelpers");
|
14
14
|
__exportStar(require("./functions"), exports);
|
15
15
|
__exportStar(require("./commonStyles"), exports);
|
16
|
+
__exportStar(require("./themeHelpers"), exports);
|
16
17
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/helpers/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8BAA4B;AAC5B,8CAA4B;AAC5B,iDAA+B"}
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/helpers/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8BAA4B;AAC5B,8CAA4B;AAC5B,iDAA+B;AAC/B,iDAA+B"}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
export declare const generateSizeScale: (baseSize: number, variants: {
|
2
|
+
scale: number;
|
3
|
+
name: string;
|
4
|
+
}[]) => {};
|
5
|
+
export declare const fontVariations: {
|
6
|
+
scale: number;
|
7
|
+
name: string;
|
8
|
+
}[];
|
9
|
+
export declare const generateFontSizes: (baseFontSize: number) => {};
|
10
|
+
export declare const lineHeightVariants: {
|
11
|
+
scale: number;
|
12
|
+
name: string;
|
13
|
+
}[];
|
14
|
+
export declare const generateLineHeights: (baseFontSize: number) => {};
|
15
|
+
export declare const spacingVariations: {
|
16
|
+
scale: number;
|
17
|
+
name: string;
|
18
|
+
}[];
|
19
|
+
export declare const generateSpacingSizes: (baseSpacing: number) => {};
|
20
|
+
export declare function getColorVariants(colors: Object[]): Object[];
|
21
|
+
//# sourceMappingURL=themeHelpers.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"themeHelpers.d.ts","sourceRoot":"","sources":["../../../src/helpers/themeHelpers.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,iBAAiB,aAAa,MAAM,YAAY;IAAC,KAAK,EAAC,MAAM,CAAC;IAAC,MAAK,MAAM,CAAA;CAAC,EAAE,OAGpF,CAAC;AAGP,eAAO,MAAM,cAAc;;;GAa1B,CAAA;AAED,eAAO,MAAM,iBAAiB,iBAAkB,MAAM,OAAoD,CAAC;AAG3G,eAAO,MAAM,kBAAkB;;;GAAwD,CAAC;AACxF,eAAO,MAAM,mBAAmB,iBAAkB,MAAM,OAAwD,CAAC;AAGjH,eAAO,MAAM,iBAAiB;;;GAc7B,CAAA;AAED,eAAO,MAAM,oBAAoB,gBAAiB,MAAM,OAAsD,CAAC;AAI/G,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,YAoChD"}
|
@@ -0,0 +1,88 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getColorVariants = exports.generateSpacingSizes = exports.spacingVariations = exports.generateLineHeights = exports.lineHeightVariants = exports.generateFontSizes = exports.fontVariations = exports.generateSizeScale = void 0;
|
4
|
+
const lodash_1 = require("lodash");
|
5
|
+
const polished_1 = require("polished");
|
6
|
+
const generateSizeScale = (baseSize, variants) => variants.reduce((sizes, { name, scale }) => {
|
7
|
+
sizes[name] = baseSize * scale;
|
8
|
+
return sizes;
|
9
|
+
}, {});
|
10
|
+
exports.generateSizeScale = generateSizeScale;
|
11
|
+
// font sizes
|
12
|
+
exports.fontVariations = [
|
13
|
+
{ scale: 7 / 16, name: 'xxxs' },
|
14
|
+
{ scale: 9 / 16, name: 'xxs' },
|
15
|
+
{ scale: 10 / 16, name: 'xs' },
|
16
|
+
{ scale: 13 / 16, name: 'sm' },
|
17
|
+
{ scale: 16 / 16, name: 'md' },
|
18
|
+
{ scale: 18 / 16, name: 'lg' },
|
19
|
+
{ scale: 24 / 16, name: 'xl' },
|
20
|
+
{ scale: 32 / 16, name: 'xxl' },
|
21
|
+
{ scale: 40 / 16, name: 'xxxl' },
|
22
|
+
{ scale: 48 / 16, name: 'xxxxl' },
|
23
|
+
{ scale: 60 / 16, name: 'xxxxxl' },
|
24
|
+
{ scale: 72 / 16, name: 'xxxxxxl' },
|
25
|
+
];
|
26
|
+
const generateFontSizes = (baseFontSize) => exports.generateSizeScale(baseFontSize, exports.fontVariations);
|
27
|
+
exports.generateFontSizes = generateFontSizes;
|
28
|
+
// line heights for font
|
29
|
+
exports.lineHeightVariants = exports.fontVariations.map(f => (Object.assign(Object.assign({}, f), { scale: f.scale * 1.6 })));
|
30
|
+
const generateLineHeights = (baseFontSize) => exports.generateSizeScale(baseFontSize, exports.lineHeightVariants);
|
31
|
+
exports.generateLineHeights = generateLineHeights;
|
32
|
+
// spacing
|
33
|
+
exports.spacingVariations = [
|
34
|
+
{ scale: 0 / 16, name: 'none' },
|
35
|
+
{ scale: 2 / 16, name: 'xxxs' },
|
36
|
+
{ scale: 4 / 16, name: 'xxs' },
|
37
|
+
{ scale: 8 / 16, name: 'xs' },
|
38
|
+
{ scale: 12 / 16, name: 'sm' },
|
39
|
+
{ scale: 16 / 16, name: 'md' },
|
40
|
+
{ scale: 18 / 16, name: 'lg' },
|
41
|
+
{ scale: 24 / 16, name: 'xl' },
|
42
|
+
{ scale: 32 / 16, name: 'xxl' },
|
43
|
+
{ scale: 40 / 16, name: 'xxxl' },
|
44
|
+
{ scale: 48 / 16, name: 'xxxxl' },
|
45
|
+
{ scale: 64 / 16, name: 'xxxxxl' },
|
46
|
+
{ scale: 72 / 16, name: 'xxxxxxl' },
|
47
|
+
];
|
48
|
+
const generateSpacingSizes = (baseSpacing) => exports.generateSizeScale(baseSpacing, exports.spacingVariations);
|
49
|
+
exports.generateSpacingSizes = generateSpacingSizes;
|
50
|
+
// colors
|
51
|
+
function getColorVariants(colors) {
|
52
|
+
return new Proxy(colors, {
|
53
|
+
get: (target, color) => {
|
54
|
+
const colorParams = lodash_1.split(color, '-');
|
55
|
+
let resultColor = target[colorParams.shift()];
|
56
|
+
if (!resultColor)
|
57
|
+
return;
|
58
|
+
while (!lodash_1.isEmpty(colorParams) && resultColor) {
|
59
|
+
const op = colorParams.shift();
|
60
|
+
switch (op) {
|
61
|
+
case 'lighten':
|
62
|
+
const lightenAmount = +colorParams.shift() / 100;
|
63
|
+
resultColor = polished_1.lighten(lightenAmount, resultColor);
|
64
|
+
break;
|
65
|
+
case 'darken':
|
66
|
+
const darkenAmount = +colorParams.shift() / 100;
|
67
|
+
resultColor = polished_1.darken(darkenAmount, resultColor);
|
68
|
+
break;
|
69
|
+
case 'transparentize':
|
70
|
+
const transparentizeAmount = +colorParams.shift() / 100;
|
71
|
+
resultColor = polished_1.transparentize(transparentizeAmount, resultColor);
|
72
|
+
break;
|
73
|
+
case 'invert':
|
74
|
+
resultColor = lodash_1.invert(resultColor);
|
75
|
+
break;
|
76
|
+
case 'grayscale':
|
77
|
+
resultColor = polished_1.grayscale(resultColor);
|
78
|
+
break;
|
79
|
+
default:
|
80
|
+
}
|
81
|
+
}
|
82
|
+
return resultColor;
|
83
|
+
},
|
84
|
+
set() { return false; }
|
85
|
+
});
|
86
|
+
}
|
87
|
+
exports.getColorVariants = getColorVariants;
|
88
|
+
//# sourceMappingURL=themeHelpers.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"themeHelpers.js","sourceRoot":"","sources":["../../../src/helpers/themeHelpers.tsx"],"names":[],"mappings":";;;AAAA,mCAAgD;AAChD,uCAAsE;AAE/D,MAAM,iBAAiB,GAAG,CAAC,QAAe,EAAE,QAAuC,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAC,IAAI,EAAE,KAAK,EAAC,EAAC,EAAE;IACnI,KAAK,CAAC,IAAI,CAAC,GAAG,QAAQ,GAAC,KAAK,CAAC;IAC7B,OAAO,KAAK,CAAC;AACjB,CAAC,EAAE,EAAE,CAAC,CAAC;AAHM,QAAA,iBAAiB,qBAGvB;AAEP,aAAa;AACA,QAAA,cAAc,GAAG;IAC1B,EAAC,KAAK,EAAE,CAAC,GAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAC;IAC3B,EAAC,KAAK,EAAE,CAA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