@evlop/commons 1.0.220 → 1.0.221
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 +8 -132
- package/dist/src/components/hoc/withSettings.js.map +1 -1
- package/dist/src/contexts/ComponentContext.d.ts +0 -3
- package/dist/src/contexts/ComponentContext.d.ts.map +1 -1
- package/dist/src/contexts/ComponentContext.js +3 -1
- package/dist/src/contexts/ComponentContext.js.map +1 -1
- package/dist/src/hooks/index.d.ts +0 -1
- package/dist/src/hooks/index.d.ts.map +1 -1
- package/dist/src/hooks/index.js +0 -1
- package/dist/src/hooks/index.js.map +1 -1
- package/dist/src/hooks/useComponentData.d.ts +0 -1
- package/dist/src/hooks/useComponentData.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/src/hooks/useComponentConfigEditor.d.ts +0 -14
- package/dist/src/hooks/useComponentConfigEditor.d.ts.map +0 -1
- package/dist/src/hooks/useComponentConfigEditor.js +0 -58
- package/dist/src/hooks/useComponentConfigEditor.js.map +0 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"withSettings.d.ts","sourceRoot":"","sources":["../../../../src/components/hoc/withSettings.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
1
|
+
{"version":3,"file":"withSettings.d.ts","sourceRoot":"","sources":["../../../../src/components/hoc/withSettings.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,iBAAiB,EAAE,eAAe,EAAE,aAAa,EAAuB,MAAM,OAAO,CAAC;AACtG,OAAO,EAAE,MAAM,EAA+B,MAAM,aAAa,CAAC;AAElE,aAAK,WAAW,GAAG;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAE/F,oBAAY,qBAAqB,CAAC,CAAC,SAAS,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,CAAA;AAE/J,eAAO,MAAM,YAAY;;;;8LAsCvB,CAAC;AAGH,eAAO,MAAM,WAAW;;;;8LAAe,CAAC;AACxC,eAAe,YAAY,CAAC"}
|
@@ -31,46 +31,22 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
31
31
|
};
|
32
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
33
33
|
exports.withToolbar = exports.withSettings = void 0;
|
34
|
-
const lodash_1 =
|
34
|
+
const lodash_1 = require("lodash");
|
35
35
|
const react_1 = __importStar(require("react"));
|
36
|
-
const contexts_1 = require("../../contexts");
|
37
36
|
const hooks_1 = require("../../hooks");
|
38
37
|
const withSettings = ({ name: elementName, valueOptions = [], configurationOptions = [] }) => (BaseComponent) => react_1.forwardRef((props, forwardedRef) => {
|
39
|
-
const newRef = react_1.useRef();
|
40
|
-
const ref = react_1.useMemo(() => forwardedRef || newRef, [newRef, forwardedRef]);
|
41
38
|
const { model, dataModel = model, configModel = dataModel && `${dataModel}_config`, restrictEdit, action: actionProp, onPress, onClick: onClickProp = onPress } = props;
|
42
|
-
const
|
43
|
-
|
44
|
-
const
|
45
|
-
|
46
|
-
const { data, updateData } = hooks_1.useComponentData();
|
47
|
-
const scope = hooks_1.useScope();
|
48
|
-
// Extract values from component data
|
49
|
-
const values = react_1.useMemo(() => {
|
50
|
-
if (!dataModel || !valueOptions)
|
51
|
-
return {};
|
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));
|
39
|
+
const { data } = hooks_1.useComponentData();
|
40
|
+
// Extract values from component data,
|
41
|
+
const propsFromModel = react_1.useMemo(() => {
|
42
|
+
return lodash_1.assign({}, lodash_1.get(data, configModel), lodash_1.get(data, dataModel));
|
56
43
|
}, [dataModel, props, data]);
|
57
|
-
|
58
|
-
const configs = react_1.useMemo(() => {
|
59
|
-
if (!configModel || !configurationOptions)
|
60
|
-
return {};
|
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]);
|
66
|
-
const action = values.action || actionProp;
|
67
|
-
const { focused, onFocus, onBlur } = hooks_1.useFocus();
|
68
|
-
const [hovered, setHover] = react_1.useState(false);
|
44
|
+
const action = propsFromModel.action || actionProp;
|
69
45
|
const { handleAction, forwardActions } = react_1.useMemo(() => {
|
70
46
|
if (!action)
|
71
47
|
return {};
|
72
48
|
// if this is a link component forward link, route, navigate so it can be used as href tag
|
73
|
-
if (
|
49
|
+
if (elementName === 'link') {
|
74
50
|
const { link, route, navigate } = action, remainingActions = __rest(action, ["link", "route", "navigate"]);
|
75
51
|
return {
|
76
52
|
forwardActions: { link, route, navigate },
|
@@ -81,107 +57,7 @@ const withSettings = ({ name: elementName, valueOptions = [], configurationOptio
|
|
81
57
|
}, [dataModel, action]);
|
82
58
|
const actionClickEvent = hooks_1.useAction(handleAction);
|
83
59
|
const elementOnClick = action ? actionClickEvent : onClickProp;
|
84
|
-
|
85
|
-
const onMouseLeave = react_1.useCallback((e) => { e.preventDefault(); setHover(false); }, []);
|
86
|
-
const isValue = react_1.useCallback((name) => {
|
87
|
-
return !!valueOptions.find(field => field.name === name);
|
88
|
-
}, []);
|
89
|
-
const onClick = react_1.useCallback(e => {
|
90
|
-
e.stopPropagation();
|
91
|
-
e.preventDefault();
|
92
|
-
if (!focused) {
|
93
|
-
onFocus();
|
94
|
-
const componentConfigValues = {};
|
95
|
-
let componentConfigOptions = [];
|
96
|
-
if (dataModel) {
|
97
|
-
Object.assign(componentConfigValues, values);
|
98
|
-
componentConfigOptions.push(...valueOptions);
|
99
|
-
}
|
100
|
-
if (configModel) {
|
101
|
-
Object.assign(componentConfigValues, configs);
|
102
|
-
componentConfigOptions.push(...configurationOptions);
|
103
|
-
}
|
104
|
-
//disable user to edit certain fields from configuration options
|
105
|
-
if (!lodash_1.default.isEmpty(restrictEdit)) {
|
106
|
-
componentConfigOptions = componentConfigOptions.filter(field => !lodash_1.default.includes(restrictEdit, field.name));
|
107
|
-
}
|
108
|
-
// replace function in configuration option with function string
|
109
|
-
componentConfigOptions = JSON.parse(JSON.stringify(componentConfigOptions, (key, value) => {
|
110
|
-
if (typeof value === 'function') {
|
111
|
-
return {
|
112
|
-
type: 'function',
|
113
|
-
function: value.toString(),
|
114
|
-
};
|
115
|
-
}
|
116
|
-
return value;
|
117
|
-
}));
|
118
|
-
window.top.postMessage({
|
119
|
-
type: 'updateConfiguration',
|
120
|
-
id,
|
121
|
-
name: elementName,
|
122
|
-
values: componentConfigValues,
|
123
|
-
fields: componentConfigOptions,
|
124
|
-
}, '*');
|
125
|
-
}
|
126
|
-
}, [id, elementName, values, configs, focused, onFocus, valueOptions, configurationOptions, dataModel, configModel]);
|
127
|
-
const change = react_1.useCallback(lodash_1.default.debounce((key, value) => {
|
128
|
-
updateData(`${dataModel}.${key}`, value);
|
129
|
-
window.top.postMessage({
|
130
|
-
type: 'changeConfigurationValue',
|
131
|
-
id,
|
132
|
-
name: key,
|
133
|
-
value
|
134
|
-
}, '*');
|
135
|
-
}, 500), [dataModel, updateData]);
|
136
|
-
const scopeJSON = react_1.useMemo(() => {
|
137
|
-
if (!scope || !editMode || !focused)
|
138
|
-
return '';
|
139
|
-
return JSON.stringify(scope, (k, v) => typeof v === 'function' ? { type: 'Function' } : v);
|
140
|
-
}, [scope]);
|
141
|
-
react_1.useEffect(() => {
|
142
|
-
if (!scope || !editMode || !focused)
|
143
|
-
return;
|
144
|
-
window.top.postMessage({
|
145
|
-
type: 'scopeUpdated',
|
146
|
-
id,
|
147
|
-
scope: scopeJSON,
|
148
|
-
}, '*');
|
149
|
-
}, [scopeJSON, editMode, focused]);
|
150
|
-
const extraProps = react_1.useMemo(() => {
|
151
|
-
if (!editMode)
|
152
|
-
return { onClick: elementOnClick, onPress: elementOnClick, };
|
153
|
-
return { onClick, onPress: onClick, onMouseEnter, onMouseLeave };
|
154
|
-
}, [editMode, onClick, onMouseEnter, onMouseLeave, elementOnClick]);
|
155
|
-
const onConfigUpdate = react_1.useCallback(({ data = {} }) => {
|
156
|
-
const { type, id: eventForId } = data;
|
157
|
-
if (id !== eventForId)
|
158
|
-
return;
|
159
|
-
switch (type) {
|
160
|
-
case 'elementFocused':
|
161
|
-
onFocus();
|
162
|
-
break;
|
163
|
-
case 'elementBlurred':
|
164
|
-
onBlur();
|
165
|
-
break;
|
166
|
-
case 'elementValueUpdated': {
|
167
|
-
const { name: key, value } = data;
|
168
|
-
updateData(`${isValue(key) ? dataModel : configModel}.${key}`, value);
|
169
|
-
break;
|
170
|
-
}
|
171
|
-
}
|
172
|
-
}, [id, dataModel, onFocus, onBlur, configModel, updateData]);
|
173
|
-
react_1.useEffect(() => {
|
174
|
-
if (editMode) {
|
175
|
-
window.addEventListener('message', onConfigUpdate);
|
176
|
-
return () => window.removeEventListener('message', onConfigUpdate);
|
177
|
-
}
|
178
|
-
}, [focused, onConfigUpdate, editMode]);
|
179
|
-
const { stack: toolbarStack, setActiveToolbar } = react_1.useContext(contexts_1.ToolbarContext);
|
180
|
-
const elementContext = react_1.useMemo(() => {
|
181
|
-
return { stack: [{ id, name: dataModel, ref, values, update: updateData, valueOptions, configurationOptions }, ...toolbarStack], setActiveToolbar };
|
182
|
-
}, [id, dataModel, values, toolbarStack, setActiveToolbar, ref, updateData]);
|
183
|
-
return (react_1.default.createElement(contexts_1.ToolbarProvider, { value: elementContext },
|
184
|
-
react_1.default.createElement(BaseComponent, Object.assign({ animate: true, change: change, focused: focused, hovered: hovered, isEditing: editMode }, props, configs, values, extraProps, { action: forwardActions, ref: ref }))));
|
60
|
+
return (react_1.default.createElement(BaseComponent, Object.assign({ animate: true }, props, propsFromModel, { action: forwardActions, onClick: elementOnClick, onPress: elementOnClick, ref: forwardedRef })));
|
185
61
|
});
|
186
62
|
exports.withSettings = withSettings;
|
187
63
|
exports.withToolbar = exports.withSettings;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"withSettings.js","sourceRoot":"","sources":["../../../../src/components/hoc/withSettings.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
1
|
+
{"version":3,"file":"withSettings.js","sourceRoot":"","sources":["../../../../src/components/hoc/withSettings.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAqC;AACrC,+CAAsG;AACtG,uCAAkE;AAM3D,MAAM,YAAY,GAAC,CAAC,EAAC,IAAI,EAAE,WAAW,EAAE,YAAY,GAAG,EAAE,EAAE,oBAAoB,GAAG,EAAE,EAAC,EAAE,EAAE,CAAC,CAAmB,aAAqC,EAAE,EAAE,CAAC,kBAAU,CAA0C,CAAC,KAAU,EAAE,YAAY,EAAE,EAAE;IAC3O,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,KAAK,EAAG,WAAW,GAAG,SAAS,IAAI,GAAG,SAAS,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,EAAC,GAAG,KAAK,CAAC;IACxK,MAAM,EAAC,IAAI,EAAC,GAAG,wBAAgB,EAAE,CAAC;IAElC,sCAAsC;IACtC,MAAM,cAAc,GAAQ,eAAO,CAAC,GAAE,EAAE;QACpC,OAAQ,eAAM,CAAC,EAAE,EAAE,YAAG,CAAC,IAAI,EAAE,WAAW,CAAC,EAAE,YAAG,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;IACrE,CAAC,EAAE,CAAC,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;IAE7B,MAAM,MAAM,GAAG,cAAc,CAAC,MAAM,IAAI,UAAU,CAAC;IAEnD,MAAM,EAAC,YAAY,EAAE,cAAc,EAAC,GAAG,eAAO,CAAC,GAAE,EAAE;QAC/C,IAAG,CAAC,MAAM;YAAE,OAAO,EAAE,CAAC;QACtB,0FAA0F;QAC1F,IAAG,WAAW,KAAK,MAAM,EAAE;YACvB,MAAM,EAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,KAAyB,MAAM,EAA1B,gBAAgB,UAAI,MAAM,EAArD,6BAA4C,CAAS,CAAC;YAC5D,OAAO;gBACH,cAAc,EAAE,EAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAC;gBACvC,aAAa,EAAE,gBAAgB;aAClC,CAAA;SACJ;QACD,OAAO,EAAC,YAAY,EAAE,MAAM,EAAC,CAAC;IAClC,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;IAExB,MAAM,gBAAgB,GAAG,iBAAS,CAAC,YAAY,CAAC,CAAC;IACjD,MAAM,cAAc,GAAG,MAAM,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,WAAW,CAAC;IAE/D,OAAO,CACH,8BAAC,aAAa,kBACV,OAAO,UACH,KAAK,EACL,cAAc,IAClB,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,cAAc,EACvB,GAAG,EAAE,YAAY,IACnB,CACL,CAAC;AACN,CAAC,CAAC,CAAC;AAtCU,QAAA,YAAY,gBAsCtB;AAGU,QAAA,WAAW,GAAG,oBAAY,CAAC;AACxC,kBAAe,oBAAY,CAAC"}
|
@@ -1,14 +1,11 @@
|
|
1
1
|
declare const ComponentContext: import("react").Context<{
|
2
2
|
data: {};
|
3
|
-
updateData: (...props: any) => void;
|
4
3
|
}>;
|
5
4
|
export declare const ComponentProvider: import("react").Provider<{
|
6
5
|
data: {};
|
7
|
-
updateData: (...props: any) => void;
|
8
6
|
}>;
|
9
7
|
export declare const ComponentData: import("react").Consumer<{
|
10
8
|
data: {};
|
11
|
-
updateData: (...props: any) => void;
|
12
9
|
}>;
|
13
10
|
export default ComponentContext;
|
14
11
|
//# sourceMappingURL=ComponentContext.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ComponentContext.d.ts","sourceRoot":"","sources":["../../../src/contexts/ComponentContext.tsx"],"names":[],"mappings":"AAEA,QAAA,MAAM,gBAAgB;;
|
1
|
+
{"version":3,"file":"ComponentContext.d.ts","sourceRoot":"","sources":["../../../src/contexts/ComponentContext.tsx"],"names":[],"mappings":"AAEA,QAAA,MAAM,gBAAgB;;EAEpB,CAAC;AAEH,eAAO,MAAM,iBAAiB;;EAA4B,CAAC;AAE3D,eAAO,MAAM,aAAa;;EAA4B,CAAC;AAEvD,eAAe,gBAAgB,CAAA"}
|
@@ -2,7 +2,9 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.ComponentData = exports.ComponentProvider = void 0;
|
4
4
|
const react_1 = require("react");
|
5
|
-
const ComponentContext = react_1.createContext({
|
5
|
+
const ComponentContext = react_1.createContext({
|
6
|
+
data: {}
|
7
|
+
});
|
6
8
|
exports.ComponentProvider = ComponentContext.Provider;
|
7
9
|
exports.ComponentData = ComponentContext.Consumer;
|
8
10
|
exports.default = ComponentContext;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ComponentContext.js","sourceRoot":"","sources":["../../../src/contexts/ComponentContext.tsx"],"names":[],"mappings":";;;AAAA,iCAAoC;AAEpC,MAAM,gBAAgB,GAAG,qBAAa,CAAC,
|
1
|
+
{"version":3,"file":"ComponentContext.js","sourceRoot":"","sources":["../../../src/contexts/ComponentContext.tsx"],"names":[],"mappings":";;;AAAA,iCAAoC;AAEpC,MAAM,gBAAgB,GAAG,qBAAa,CAAC;IACnC,IAAI,EAAC,EAAE;CACV,CAAC,CAAC;AAEU,QAAA,iBAAiB,GAAG,gBAAgB,CAAC,QAAQ,CAAC;AAE9C,QAAA,aAAa,GAAG,gBAAgB,CAAC,QAAQ,CAAC;AAEvD,kBAAe,gBAAgB,CAAA"}
|
@@ -15,7 +15,6 @@ export * from './useCollection';
|
|
15
15
|
export * from './useCollectionProvider';
|
16
16
|
export * from './useCollectionRecord';
|
17
17
|
export * from './useCollectionRecordProvider';
|
18
|
-
export * from './useComponentConfigEditor';
|
19
18
|
export * from './useComponentConfigProps';
|
20
19
|
export * from './useLayoutEditor';
|
21
20
|
export * from './useMenuItems';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.tsx"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.tsx"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC"}
|
package/dist/src/hooks/index.js
CHANGED
@@ -27,7 +27,6 @@ __exportStar(require("./useCollection"), exports);
|
|
27
27
|
__exportStar(require("./useCollectionProvider"), exports);
|
28
28
|
__exportStar(require("./useCollectionRecord"), exports);
|
29
29
|
__exportStar(require("./useCollectionRecordProvider"), exports);
|
30
|
-
__exportStar(require("./useComponentConfigEditor"), exports);
|
31
30
|
__exportStar(require("./useComponentConfigProps"), exports);
|
32
31
|
__exportStar(require("./useLayoutEditor"), exports);
|
33
32
|
__exportStar(require("./useMenuItems"), exports);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iDAA+B;AAC/B,yDAAuC;AACvC,8CAA4B;AAC5B,kDAAgC;AAChC,4CAA0B;AAC1B,6CAA2B;AAC3B,qDAAmC;AACnC,gDAA8B;AAC9B,6CAA2B;AAC3B,mDAAiC;AACjC,2CAAyB;AACzB,6CAA2B;AAC3B,6CAA2B;AAC3B,kDAAgC;AAChC,0DAAwC;AACxC,wDAAsC;AACtC,gEAA8C;AAC9C,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iDAA+B;AAC/B,yDAAuC;AACvC,8CAA4B;AAC5B,kDAAgC;AAChC,4CAA0B;AAC1B,6CAA2B;AAC3B,qDAAmC;AACnC,gDAA8B;AAC9B,6CAA2B;AAC3B,mDAAiC;AACjC,2CAAyB;AACzB,6CAA2B;AAC3B,6CAA2B;AAC3B,kDAAgC;AAChC,0DAAwC;AACxC,wDAAsC;AACtC,gEAA8C;AAC9C,4DAA0C;AAC1C,oDAAkC;AAClC,iDAA+B;AAC/B,gDAA8B;AAC9B,4CAA0B;AAC1B,8CAA4B;AAC5B,kDAAgC;AAChC,8CAA4B;AAC5B,sDAAoC;AACpC,kDAAgC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useComponentData.d.ts","sourceRoot":"","sources":["../../../src/hooks/useComponentData.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB
|
1
|
+
{"version":3,"file":"useComponentData.d.ts","sourceRoot":"","sources":["../../../src/hooks/useComponentData.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB;;CAE5B,CAAC"}
|
package/package.json
CHANGED
@@ -1,14 +0,0 @@
|
|
1
|
-
export declare const useComponentConfigEditor: (config_name: any) => {
|
2
|
-
onChangeFont: (font: any) => void;
|
3
|
-
onChangeFontSize: (fontSize: any) => void;
|
4
|
-
onChangeBackgroundImage: (backgroundImage: any) => void;
|
5
|
-
onChangePadding: (padding: any) => void;
|
6
|
-
onChangeMargin: (margin: any) => void;
|
7
|
-
onAlignmentChange: (alignment: any) => void;
|
8
|
-
onBackgroundColorChange: (colorVariant: any) => void;
|
9
|
-
onVariantChange: (colorVariant: any) => void;
|
10
|
-
onChangeAnimation: (animation: any) => void;
|
11
|
-
changeConfig: (key: any, value: any) => void;
|
12
|
-
};
|
13
|
-
export default useComponentConfigEditor;
|
14
|
-
//# sourceMappingURL=useComponentConfigEditor.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"useComponentConfigEditor.d.ts","sourceRoot":"","sources":["../../../src/hooks/useComponentConfigEditor.tsx"],"names":[],"mappings":"AAIA,eAAO,MAAM,wBAAwB;;;;;;;;;;;CA0DpC,CAAC;AAEF,eAAe,wBAAwB,CAAC"}
|
@@ -1,58 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.useComponentConfigEditor = void 0;
|
7
|
-
const react_1 = require("react");
|
8
|
-
const useComponentData_1 = require("./useComponentData");
|
9
|
-
const lodash_1 = __importDefault(require("lodash"));
|
10
|
-
const useComponentConfigEditor = (config_name) => {
|
11
|
-
const { updateData: updateDataImmediate } = useComponentData_1.useComponentData();
|
12
|
-
const updateData = react_1.useCallback(lodash_1.default.debounce((...props) => updateDataImmediate(...props), 200), [updateDataImmediate]);
|
13
|
-
const onVariantChange = react_1.useCallback((colorVariant) => {
|
14
|
-
updateData(`${config_name}.color`, colorVariant);
|
15
|
-
}, [updateData]);
|
16
|
-
const onBackgroundColorChange = react_1.useCallback((colorVariant) => {
|
17
|
-
updateData(`${config_name}.backgroundColor`, colorVariant);
|
18
|
-
}, [updateData]);
|
19
|
-
const onAlignmentChange = react_1.useCallback((alignment) => {
|
20
|
-
updateData(`${config_name}.alignment`, alignment);
|
21
|
-
}, [updateData]);
|
22
|
-
const onChangeMargin = react_1.useCallback((margin) => {
|
23
|
-
updateData(`${config_name}.margin`, margin);
|
24
|
-
}, [updateData]);
|
25
|
-
const onChangePadding = react_1.useCallback((padding) => {
|
26
|
-
updateData(`${config_name}.padding`, padding);
|
27
|
-
}, [updateData]);
|
28
|
-
const onChangeBackgroundImage = react_1.useCallback((backgroundImage) => {
|
29
|
-
updateData(`${config_name}.backgroundImage`, backgroundImage);
|
30
|
-
}, [updateData]);
|
31
|
-
const onChangeFont = react_1.useCallback((font) => {
|
32
|
-
updateData(`${config_name}.font`, font);
|
33
|
-
}, [updateData]);
|
34
|
-
const onChangeFontSize = react_1.useCallback((fontSize) => {
|
35
|
-
updateData(`${config_name}.fontSize`, fontSize);
|
36
|
-
}, [updateData]);
|
37
|
-
const onChangeAnimation = react_1.useCallback((animation) => {
|
38
|
-
updateData(`${config_name}.animationName`, animation && animation.value);
|
39
|
-
}, [updateData]);
|
40
|
-
const changeConfig = react_1.useCallback((key, value) => {
|
41
|
-
updateData(`${config_name}.${key}`, value);
|
42
|
-
}, [updateData]);
|
43
|
-
return {
|
44
|
-
onChangeFont,
|
45
|
-
onChangeFontSize,
|
46
|
-
onChangeBackgroundImage,
|
47
|
-
onChangePadding,
|
48
|
-
onChangeMargin,
|
49
|
-
onAlignmentChange,
|
50
|
-
onBackgroundColorChange,
|
51
|
-
onVariantChange,
|
52
|
-
onChangeAnimation,
|
53
|
-
changeConfig
|
54
|
-
};
|
55
|
-
};
|
56
|
-
exports.useComponentConfigEditor = useComponentConfigEditor;
|
57
|
-
exports.default = exports.useComponentConfigEditor;
|
58
|
-
//# sourceMappingURL=useComponentConfigEditor.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"useComponentConfigEditor.js","sourceRoot":"","sources":["../../../src/hooks/useComponentConfigEditor.tsx"],"names":[],"mappings":";;;;;;AAAA,iCAAkC;AAClC,yDAAoD;AACpD,oDAAuB;AAEhB,MAAM,wBAAwB,GAAG,CAAC,WAAW,EAAC,EAAE;IAEnD,MAAM,EAAC,UAAU,EAAE,mBAAmB,EAAC,GAAG,mCAAgB,EAAE,CAAC;IAE7D,MAAM,UAAU,GAAG,mBAAW,CAAC,gBAAC,CAAC,QAAQ,CAAC,CAAC,GAAG,KAAK,EAAC,EAAE,CAAA,mBAAmB,CAAC,GAAG,KAAK,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,mBAAmB,CAAC,CAAC,CAAC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