amis-core 3.4.0 → 3.4.2
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/esm/Root.js +1 -1
- package/esm/RootRenderer.js +8 -8
- package/esm/SchemaRenderer.js +16 -12
- package/esm/Scoped.js +3 -1
- package/esm/StatusScoped.js +1 -1
- package/esm/WithRootStore.js +1 -1
- package/esm/WithStore.js +9 -8
- package/esm/actions/Action.js +1 -1
- package/esm/actions/AjaxAction.js +2 -2
- package/esm/actions/BreakAction.js +1 -1
- package/esm/actions/BroadcastAction.js +1 -1
- package/esm/actions/CmptAction.js +1 -1
- package/esm/actions/ContinueAction.js +1 -1
- package/esm/actions/CopyAction.js +1 -1
- package/esm/actions/CustomAction.js +3 -1
- package/esm/actions/DialogAction.js +1 -1
- package/esm/actions/DrawerAction.js +5 -1
- package/esm/actions/EmailAction.js +1 -1
- package/esm/actions/LinkAction.js +1 -1
- package/esm/actions/LoopAction.js +1 -1
- package/esm/actions/PageAction.js +1 -1
- package/esm/actions/ParallelAction.js +1 -1
- package/esm/actions/StatusAction.js +1 -1
- package/esm/actions/SwitchAction.js +1 -1
- package/esm/actions/ToastAction.js +1 -1
- package/esm/components/CustomStyle.d.ts +5 -6
- package/esm/components/CustomStyle.js +47 -6
- package/esm/components/LazyComponent.d.ts +1 -2
- package/esm/components/LazyComponent.js +12 -8
- package/esm/components/Overlay.js +3 -1
- package/esm/components/PopOver.d.ts +12 -12
- package/esm/components/PopOver.js +3 -1
- package/esm/env.d.ts +2 -2
- package/esm/env.js +1 -1
- package/esm/envOverwrite.js +1 -1
- package/esm/factory.d.ts +7 -7
- package/esm/factory.js +1 -1
- package/esm/index.js +5 -5
- package/esm/locale.d.ts +1 -1
- package/esm/locale.js +3 -3
- package/esm/polyfills.js +1 -1
- package/esm/renderers/Form.d.ts +1 -1
- package/esm/renderers/Form.js +10 -8
- package/esm/renderers/Item.d.ts +24 -56
- package/esm/renderers/Item.js +25 -31
- package/esm/renderers/Options.js +14 -12
- package/esm/renderers/Placeholder.js +1 -1
- package/esm/renderers/builtin.js +1 -1
- package/esm/renderers/register.js +1 -1
- package/esm/renderers/wrapControl.js +70 -80
- package/esm/store/app.js +3 -1
- package/esm/store/combo.d.ts +384 -0
- package/esm/store/combo.js +1 -1
- package/esm/store/crud.js +31 -25
- package/esm/store/form.d.ts +160 -0
- package/esm/store/form.js +15 -13
- package/esm/store/formItem.d.ts +4 -0
- package/esm/store/formItem.js +42 -26
- package/esm/store/iRenderer.js +3 -1
- package/esm/store/index.js +1 -1
- package/esm/store/list.js +1 -1
- package/esm/store/manager.js +1 -1
- package/esm/store/modal.js +1 -1
- package/esm/store/node.js +1 -1
- package/esm/store/pagination.js +1 -1
- package/esm/store/root.d.ts +1 -1
- package/esm/store/root.js +12 -5
- package/esm/store/service.js +38 -33
- package/esm/store/status.js +1 -1
- package/esm/store/table.d.ts +760 -21
- package/esm/store/table.js +157 -57
- package/esm/store/table2.js +11 -8
- package/esm/theme.d.ts +18 -31
- package/esm/theme.js +1 -1
- package/esm/utils/Animation.js +1 -1
- package/esm/utils/ColorScale.js +1 -1
- package/esm/utils/DataSchema.js +1 -1
- package/esm/utils/DataScope.js +1 -1
- package/esm/utils/RootClose.js +1 -1
- package/esm/utils/SimpleMap.js +1 -1
- package/esm/utils/api.d.ts +3 -3
- package/esm/utils/api.js +3 -2
- package/esm/utils/arraySlice.js +1 -1
- package/esm/utils/attachmentAdpator.js +1 -1
- package/esm/utils/autobind.js +1 -1
- package/esm/utils/columnsSplit.js +1 -1
- package/esm/utils/dataMapping.js +1 -1
- package/esm/utils/date.js +1 -1
- package/esm/utils/debug.d.ts +1 -0
- package/esm/utils/debug.js +24 -2
- package/esm/utils/decodeEntity.js +1 -1
- package/esm/utils/dom.js +1 -1
- package/esm/utils/errors.js +1 -1
- package/esm/utils/escapeHtml.js +1 -1
- package/esm/utils/filter-schema.js +1 -1
- package/esm/utils/filter.js +1 -1
- package/esm/utils/formatDuration.js +1 -1
- package/esm/utils/formula.js +1 -1
- package/esm/utils/getVariable.js +1 -1
- package/esm/utils/grammar.js +1 -1
- package/esm/utils/handleAction.js +1 -1
- package/esm/utils/helper.d.ts +13 -1
- package/esm/utils/helper.js +99 -5
- package/esm/utils/highlight.js +1 -1
- package/esm/utils/icon.js +1 -1
- package/esm/utils/image.js +1 -1
- package/esm/utils/isPureVariable.js +1 -1
- package/esm/utils/json-schema-2-amis-schema.js +1 -1
- package/esm/utils/keyToPath.d.ts +1 -1
- package/esm/utils/keyToPath.js +2 -1
- package/esm/utils/makeSorter.js +1 -1
- package/esm/utils/math.js +1 -1
- package/esm/utils/memoryParse.js +1 -1
- package/esm/utils/normalizeLink.js +1 -1
- package/esm/utils/normalizeOptions.js +1 -1
- package/esm/utils/object.js +1 -1
- package/esm/utils/offset.js +1 -1
- package/esm/utils/offsetParent.js +1 -1
- package/esm/utils/optionValueCompare.js +1 -1
- package/esm/utils/position.js +1 -1
- package/esm/utils/prettyBytes.js +1 -1
- package/esm/utils/renderer-event.js +2 -2
- package/esm/utils/replaceText.js +1 -1
- package/esm/utils/resize-sensor.d.ts +3 -1
- package/esm/utils/resize-sensor.js +34 -22
- package/esm/utils/resolveCondition.js +1 -1
- package/esm/utils/resolveVariable.js +1 -1
- package/esm/utils/resolveVariableAndFilter.js +1 -1
- package/esm/utils/resolveVariableAndFilterForAsync.js +1 -1
- package/esm/utils/scrollPosition.js +1 -1
- package/esm/utils/string2regExp.js +1 -1
- package/esm/utils/stripNumber.js +1 -1
- package/esm/utils/style-helper.d.ts +22 -14
- package/esm/utils/style-helper.js +181 -120
- package/esm/utils/style.js +1 -1
- package/esm/utils/toNumber.js +1 -1
- package/esm/utils/tokenize.js +1 -1
- package/esm/utils/tpl-builtin.js +1 -1
- package/esm/utils/tpl-lodash.js +1 -1
- package/esm/utils/tpl.js +1 -1
- package/esm/utils/uncontrollable.js +1 -1
- package/esm/utils/validations.js +1 -1
- package/lib/Root.js +1 -1
- package/lib/RootRenderer.js +8 -8
- package/lib/SchemaRenderer.js +16 -12
- package/lib/Scoped.js +3 -1
- package/lib/StatusScoped.js +1 -1
- package/lib/WithRootStore.js +1 -1
- package/lib/WithStore.js +9 -8
- package/lib/actions/Action.js +1 -1
- package/lib/actions/AjaxAction.js +2 -2
- package/lib/actions/BreakAction.js +1 -1
- package/lib/actions/BroadcastAction.js +1 -1
- package/lib/actions/CmptAction.js +1 -1
- package/lib/actions/ContinueAction.js +1 -1
- package/lib/actions/CopyAction.js +1 -1
- package/lib/actions/CustomAction.js +3 -1
- package/lib/actions/DialogAction.js +1 -1
- package/lib/actions/DrawerAction.js +5 -1
- package/lib/actions/EmailAction.js +1 -1
- package/lib/actions/LinkAction.js +1 -1
- package/lib/actions/LoopAction.js +1 -1
- package/lib/actions/PageAction.js +1 -1
- package/lib/actions/ParallelAction.js +1 -1
- package/lib/actions/StatusAction.js +1 -1
- package/lib/actions/SwitchAction.js +1 -1
- package/lib/actions/ToastAction.js +1 -1
- package/lib/components/CustomStyle.d.ts +5 -6
- package/lib/components/CustomStyle.js +46 -4
- package/lib/components/LazyComponent.d.ts +1 -2
- package/lib/components/LazyComponent.js +12 -9
- package/lib/components/Overlay.js +3 -1
- package/lib/components/PopOver.d.ts +12 -12
- package/lib/components/PopOver.js +3 -1
- package/lib/env.d.ts +2 -2
- package/lib/env.js +1 -1
- package/lib/envOverwrite.js +1 -1
- package/lib/factory.d.ts +7 -7
- package/lib/factory.js +1 -1
- package/lib/index.js +11 -3
- package/lib/locale.d.ts +1 -1
- package/lib/locale.js +3 -3
- package/lib/polyfills.js +1 -1
- package/lib/renderers/Form.d.ts +1 -1
- package/lib/renderers/Form.js +10 -8
- package/lib/renderers/Item.d.ts +24 -56
- package/lib/renderers/Item.js +26 -31
- package/lib/renderers/Options.js +14 -12
- package/lib/renderers/Placeholder.js +1 -1
- package/lib/renderers/builtin.js +1 -1
- package/lib/renderers/register.js +1 -1
- package/lib/renderers/wrapControl.js +70 -79
- package/lib/store/app.js +3 -1
- package/lib/store/combo.d.ts +384 -0
- package/lib/store/combo.js +1 -1
- package/lib/store/crud.js +31 -25
- package/lib/store/form.d.ts +160 -0
- package/lib/store/form.js +15 -13
- package/lib/store/formItem.d.ts +4 -0
- package/lib/store/formItem.js +41 -25
- package/lib/store/iRenderer.js +3 -1
- package/lib/store/index.js +1 -1
- package/lib/store/list.js +1 -1
- package/lib/store/manager.js +1 -1
- package/lib/store/modal.js +1 -1
- package/lib/store/node.js +1 -1
- package/lib/store/pagination.js +1 -1
- package/lib/store/root.d.ts +1 -1
- package/lib/store/root.js +11 -4
- package/lib/store/service.js +38 -33
- package/lib/store/status.js +1 -1
- package/lib/store/table.d.ts +760 -21
- package/lib/store/table.js +157 -57
- package/lib/store/table2.js +11 -8
- package/lib/theme.d.ts +18 -31
- package/lib/theme.js +1 -1
- package/lib/utils/Animation.js +1 -1
- package/lib/utils/ColorScale.js +1 -1
- package/lib/utils/DataSchema.js +1 -1
- package/lib/utils/DataScope.js +1 -1
- package/lib/utils/RootClose.js +1 -1
- package/lib/utils/SimpleMap.js +1 -1
- package/lib/utils/api.d.ts +3 -3
- package/lib/utils/api.js +3 -2
- package/lib/utils/arraySlice.js +1 -1
- package/lib/utils/attachmentAdpator.js +1 -1
- package/lib/utils/autobind.js +1 -1
- package/lib/utils/columnsSplit.js +1 -1
- package/lib/utils/dataMapping.js +1 -1
- package/lib/utils/date.js +1 -1
- package/lib/utils/debug.d.ts +1 -0
- package/lib/utils/debug.js +24 -1
- package/lib/utils/decodeEntity.js +1 -1
- package/lib/utils/dom.js +1 -1
- package/lib/utils/errors.js +1 -1
- package/lib/utils/escapeHtml.js +1 -1
- package/lib/utils/filter-schema.js +1 -1
- package/lib/utils/filter.js +1 -1
- package/lib/utils/formatDuration.js +1 -1
- package/lib/utils/formula.js +1 -1
- package/lib/utils/getVariable.js +1 -1
- package/lib/utils/grammar.js +1 -1
- package/lib/utils/handleAction.js +1 -1
- package/lib/utils/helper.d.ts +13 -1
- package/lib/utils/helper.js +101 -4
- package/lib/utils/highlight.js +1 -1
- package/lib/utils/icon.js +1 -1
- package/lib/utils/image.js +1 -1
- package/lib/utils/isPureVariable.js +1 -1
- package/lib/utils/json-schema-2-amis-schema.js +1 -1
- package/lib/utils/keyToPath.d.ts +1 -1
- package/lib/utils/keyToPath.js +2 -1
- package/lib/utils/makeSorter.js +1 -1
- package/lib/utils/math.js +1 -1
- package/lib/utils/memoryParse.js +1 -1
- package/lib/utils/normalizeLink.js +1 -1
- package/lib/utils/normalizeOptions.js +1 -1
- package/lib/utils/object.js +1 -1
- package/lib/utils/offset.js +1 -1
- package/lib/utils/offsetParent.js +1 -1
- package/lib/utils/optionValueCompare.js +1 -1
- package/lib/utils/position.js +1 -1
- package/lib/utils/prettyBytes.js +1 -1
- package/lib/utils/renderer-event.js +2 -2
- package/lib/utils/replaceText.js +1 -1
- package/lib/utils/resize-sensor.d.ts +3 -1
- package/lib/utils/resize-sensor.js +34 -22
- package/lib/utils/resolveCondition.js +1 -1
- package/lib/utils/resolveVariable.js +1 -1
- package/lib/utils/resolveVariableAndFilter.js +1 -1
- package/lib/utils/resolveVariableAndFilterForAsync.js +1 -1
- package/lib/utils/scrollPosition.js +1 -1
- package/lib/utils/string2regExp.js +1 -1
- package/lib/utils/stripNumber.js +1 -1
- package/lib/utils/style-helper.d.ts +22 -14
- package/lib/utils/style-helper.js +188 -120
- package/lib/utils/style.js +1 -1
- package/lib/utils/toNumber.js +1 -1
- package/lib/utils/tokenize.js +1 -1
- package/lib/utils/tpl-builtin.js +1 -1
- package/lib/utils/tpl-lodash.js +1 -1
- package/lib/utils/tpl.js +1 -1
- package/lib/utils/uncontrollable.js +1 -1
- package/lib/utils/validations.js +1 -1
- package/package.json +5 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v3.4.
|
|
2
|
+
* amis-core v3.4.2
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -7,8 +7,6 @@
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
9
9
|
|
|
10
|
-
var tslib = require('tslib');
|
|
11
|
-
|
|
12
10
|
/**
|
|
13
11
|
* @file resize-sensor.js.
|
|
14
12
|
* @author fex
|
|
@@ -17,16 +15,22 @@ var EventQueue = /** @class */ (function () {
|
|
|
17
15
|
function EventQueue() {
|
|
18
16
|
this.q = [];
|
|
19
17
|
}
|
|
20
|
-
EventQueue.prototype.add = function (cb) {
|
|
21
|
-
|
|
18
|
+
EventQueue.prototype.add = function (cb, type) {
|
|
19
|
+
if (type === void 0) { type = 'both'; }
|
|
20
|
+
this.q.push({
|
|
21
|
+
fn: cb,
|
|
22
|
+
type: type
|
|
23
|
+
});
|
|
22
24
|
};
|
|
23
|
-
EventQueue.prototype.call = function () {
|
|
25
|
+
EventQueue.prototype.call = function (type) {
|
|
24
26
|
var args = [];
|
|
25
|
-
for (var _i =
|
|
26
|
-
args[_i] = arguments[_i];
|
|
27
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
28
|
+
args[_i - 1] = arguments[_i];
|
|
27
29
|
}
|
|
28
|
-
this.q.forEach(function (
|
|
29
|
-
|
|
30
|
+
this.q.forEach(function (item) {
|
|
31
|
+
if (item.type === type || item.type === 'both' || type === 'both') {
|
|
32
|
+
item.fn.apply(null, args);
|
|
33
|
+
}
|
|
30
34
|
});
|
|
31
35
|
};
|
|
32
36
|
return EventQueue;
|
|
@@ -43,16 +47,17 @@ function getComputedStyle(element, prop) {
|
|
|
43
47
|
return element.style[prop];
|
|
44
48
|
}
|
|
45
49
|
}
|
|
46
|
-
function attachResizeEvent(element, resized) {
|
|
50
|
+
function attachResizeEvent(element, resized, type) {
|
|
51
|
+
if (type === void 0) { type = 'both'; }
|
|
47
52
|
if (!element) {
|
|
48
53
|
return;
|
|
49
54
|
}
|
|
50
55
|
if (!element.resizedAttached) {
|
|
51
56
|
element.resizedAttached = new EventQueue();
|
|
52
|
-
element.resizedAttached.add(resized);
|
|
57
|
+
element.resizedAttached.add(resized, type);
|
|
53
58
|
}
|
|
54
59
|
else if (element.resizedAttached) {
|
|
55
|
-
element.resizedAttached.add(resized);
|
|
60
|
+
element.resizedAttached.add(resized, type);
|
|
56
61
|
return;
|
|
57
62
|
}
|
|
58
63
|
var resizeSensor = (element.resizeSensor =
|
|
@@ -94,9 +99,10 @@ function attachResizeEvent(element, resized) {
|
|
|
94
99
|
}
|
|
95
100
|
};
|
|
96
101
|
reset();
|
|
97
|
-
var changed = function () {
|
|
102
|
+
var changed = function (type) {
|
|
103
|
+
if (type === void 0) { type = 'both'; }
|
|
98
104
|
if (element.resizedAttached) {
|
|
99
|
-
element.resizedAttached.call();
|
|
105
|
+
element.resizedAttached.call(type);
|
|
100
106
|
}
|
|
101
107
|
};
|
|
102
108
|
var addEvent = function (el, name, cb) {
|
|
@@ -116,9 +122,14 @@ function attachResizeEvent(element, resized) {
|
|
|
116
122
|
}
|
|
117
123
|
};
|
|
118
124
|
var onScroll = function (e) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
125
|
+
var widthChanged = element.offsetWidth != lastWidth;
|
|
126
|
+
var heightChanged = element.offsetHeight != lastHeight;
|
|
127
|
+
if (widthChanged || heightChanged) {
|
|
128
|
+
changed(widthChanged && heightChanged
|
|
129
|
+
? 'both'
|
|
130
|
+
: widthChanged
|
|
131
|
+
? 'width'
|
|
132
|
+
: 'height');
|
|
122
133
|
}
|
|
123
134
|
reset();
|
|
124
135
|
};
|
|
@@ -150,8 +161,9 @@ function detach(element) {
|
|
|
150
161
|
delete element.originPosition;
|
|
151
162
|
}
|
|
152
163
|
}
|
|
153
|
-
function resizeSensor(element, callback, once) {
|
|
164
|
+
function resizeSensor(element, callback, once, type) {
|
|
154
165
|
if (once === void 0) { once = false; }
|
|
166
|
+
if (type === void 0) { type = 'both'; }
|
|
155
167
|
if (!element) {
|
|
156
168
|
return function () { };
|
|
157
169
|
}
|
|
@@ -161,10 +173,10 @@ function resizeSensor(element, callback, once) {
|
|
|
161
173
|
callback.apply(this, arguments);
|
|
162
174
|
disposeEvent === null || disposeEvent === void 0 ? void 0 : disposeEvent();
|
|
163
175
|
detach(element);
|
|
164
|
-
});
|
|
165
|
-
return;
|
|
176
|
+
}, type);
|
|
177
|
+
return function () { };
|
|
166
178
|
}
|
|
167
|
-
disposeEvent = attachResizeEvent(element, callback);
|
|
179
|
+
disposeEvent = attachResizeEvent(element, callback, type);
|
|
168
180
|
var detached = false;
|
|
169
181
|
return function () {
|
|
170
182
|
if (detached)
|
package/lib/utils/stripNumber.js
CHANGED
|
@@ -7,19 +7,10 @@ interface extra {
|
|
|
7
7
|
pre?: string;
|
|
8
8
|
suf?: string;
|
|
9
9
|
}
|
|
10
|
-
export declare function
|
|
11
|
-
export declare function insertStyle(style: string, id: string): void;
|
|
10
|
+
export declare function findOrCreateStyle(id: string, doc?: Document): HTMLElement;
|
|
11
|
+
export declare function insertStyle(style: string, id: string, doc?: Document): void;
|
|
12
12
|
export declare function addStyle(style: string, id: string): void;
|
|
13
|
-
export declare function formatStyle(themeCss: any, classNames: {
|
|
14
|
-
key: string;
|
|
15
|
-
value?: string;
|
|
16
|
-
weights?: {
|
|
17
|
-
default?: extra;
|
|
18
|
-
hover?: extra;
|
|
19
|
-
active?: extra;
|
|
20
|
-
disabled?: extra;
|
|
21
|
-
};
|
|
22
|
-
}[], id?: string, defaultData?: any): {
|
|
13
|
+
export declare function formatStyle(themeCss: any, classNames?: CustomStyleClassName[], id?: string, defaultData?: any): {
|
|
23
14
|
value: string;
|
|
24
15
|
origin: {
|
|
25
16
|
className: string;
|
|
@@ -28,7 +19,6 @@ export declare function formatStyle(themeCss: any, classNames: {
|
|
|
28
19
|
};
|
|
29
20
|
export interface CustomStyleClassName {
|
|
30
21
|
key: string;
|
|
31
|
-
value?: string;
|
|
32
22
|
weights?: {
|
|
33
23
|
default?: extra;
|
|
34
24
|
hover?: extra;
|
|
@@ -36,9 +26,27 @@ export interface CustomStyleClassName {
|
|
|
36
26
|
disabled?: extra;
|
|
37
27
|
};
|
|
38
28
|
}
|
|
39
|
-
export declare function insertCustomStyle(themeCss: any, classNames: CustomStyleClassName[], id
|
|
29
|
+
export declare function insertCustomStyle(themeCss: any, classNames: CustomStyleClassName[], id: string, defaultData?: any, customStyleClassPrefix?: string, doc?: Document): void;
|
|
40
30
|
/**
|
|
41
31
|
* 根据路径获取默认值
|
|
42
32
|
*/
|
|
43
33
|
export declare function getValueByPath(path: string, data: any): any;
|
|
34
|
+
/**
|
|
35
|
+
* 设置源码编辑自定义样式
|
|
36
|
+
*/
|
|
37
|
+
export declare function insertEditCustomStyle(customStyle: any, id?: string, doc?: Document): void;
|
|
38
|
+
export interface InsertCustomStyle {
|
|
39
|
+
themeCss: any;
|
|
40
|
+
classNames: CustomStyleClassName[];
|
|
41
|
+
id?: string;
|
|
42
|
+
defaultData?: any;
|
|
43
|
+
customStyleClassPrefix?: string;
|
|
44
|
+
doc?: Document;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* 移除自定义样式
|
|
48
|
+
*/
|
|
49
|
+
export declare function removeCustomStyle(type: string, id: string, doc?: Document): void;
|
|
50
|
+
export declare function formatInputThemeCss(themeCss: any): any;
|
|
51
|
+
export declare function setThemeClassName(name: string, id?: string, themeCss?: any, extra?: string): string;
|
|
44
52
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v3.4.
|
|
2
|
+
* amis-core v3.4.2
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -10,10 +10,16 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
10
10
|
var tslib = require('tslib');
|
|
11
11
|
var helper = require('./helper.js');
|
|
12
12
|
var cloneDeep = require('lodash/cloneDeep');
|
|
13
|
+
var isObject = require('lodash/isObject');
|
|
14
|
+
var map = require('lodash/map');
|
|
15
|
+
var isEmpty = require('lodash/isEmpty');
|
|
13
16
|
|
|
14
17
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
15
18
|
|
|
16
19
|
var cloneDeep__default = /*#__PURE__*/_interopDefaultLegacy(cloneDeep);
|
|
20
|
+
var isObject__default = /*#__PURE__*/_interopDefaultLegacy(isObject);
|
|
21
|
+
var map__default = /*#__PURE__*/_interopDefaultLegacy(map);
|
|
22
|
+
var isEmpty__default = /*#__PURE__*/_interopDefaultLegacy(isEmpty);
|
|
17
23
|
|
|
18
24
|
var valueMap = {
|
|
19
25
|
'marginTop': 'margin-top',
|
|
@@ -44,22 +50,26 @@ var inheritValueMap = {
|
|
|
44
50
|
background: 'bg-color',
|
|
45
51
|
radius: 'border'
|
|
46
52
|
};
|
|
47
|
-
function
|
|
48
|
-
|
|
53
|
+
function findOrCreateStyle(id, doc) {
|
|
54
|
+
doc = doc || document;
|
|
55
|
+
var varStyleTag = doc.getElementById(id);
|
|
49
56
|
if (!varStyleTag) {
|
|
50
|
-
varStyleTag =
|
|
57
|
+
varStyleTag = doc.createElement('style');
|
|
51
58
|
varStyleTag.id = id;
|
|
52
|
-
|
|
59
|
+
doc.body.appendChild(varStyleTag);
|
|
53
60
|
}
|
|
54
61
|
return varStyleTag;
|
|
55
62
|
}
|
|
56
|
-
function insertStyle(style, id) {
|
|
57
|
-
var varStyleTag =
|
|
63
|
+
function insertStyle(style, id, doc) {
|
|
64
|
+
var varStyleTag = findOrCreateStyle(id, doc);
|
|
58
65
|
// bca-disable-line
|
|
59
66
|
varStyleTag.innerHTML = style;
|
|
67
|
+
if (!style) {
|
|
68
|
+
varStyleTag.remove();
|
|
69
|
+
}
|
|
60
70
|
}
|
|
61
71
|
function addStyle(style, id) {
|
|
62
|
-
var varStyleTag =
|
|
72
|
+
var varStyleTag = findOrCreateStyle(id);
|
|
63
73
|
// bca-disable-line
|
|
64
74
|
varStyleTag.innerHTML += style;
|
|
65
75
|
}
|
|
@@ -70,9 +80,9 @@ function handleInheritData(statusMap, data) {
|
|
|
70
80
|
}
|
|
71
81
|
// 检查是否存在inherit
|
|
72
82
|
['hover', 'active'].forEach(function (status) {
|
|
73
|
-
|
|
83
|
+
Object.keys(statusMap[status]).forEach(function (key) {
|
|
74
84
|
if (typeof statusMap[status][key] === 'object') {
|
|
75
|
-
|
|
85
|
+
Object.keys(statusMap[status][key]).forEach(function (style) {
|
|
76
86
|
if (statusMap[status][key][style] === 'inherit') {
|
|
77
87
|
// 值为inherit时设置为default的值或者主题中的default值
|
|
78
88
|
if (statusMap['default'][key] && statusMap['default'][key][style]) {
|
|
@@ -84,7 +94,7 @@ function handleInheritData(statusMap, data) {
|
|
|
84
94
|
data['default'].body[value][style];
|
|
85
95
|
}
|
|
86
96
|
}
|
|
87
|
-
}
|
|
97
|
+
});
|
|
88
98
|
}
|
|
89
99
|
else {
|
|
90
100
|
if (statusMap[status][key] === 'inherit') {
|
|
@@ -97,13 +107,13 @@ function handleInheritData(statusMap, data) {
|
|
|
97
107
|
}
|
|
98
108
|
}
|
|
99
109
|
}
|
|
100
|
-
}
|
|
110
|
+
});
|
|
101
111
|
});
|
|
102
112
|
}
|
|
103
113
|
function formatStyle(themeCss, classNames, id, defaultData) {
|
|
104
114
|
var e_1, _a;
|
|
105
|
-
|
|
106
|
-
if (!themeCss) {
|
|
115
|
+
// 没有具体的样式,或者没有对应的classname
|
|
116
|
+
if (!themeCss || !classNames) {
|
|
107
117
|
return { value: '', origin: [] };
|
|
108
118
|
}
|
|
109
119
|
var res = [];
|
|
@@ -114,124 +124,97 @@ function formatStyle(themeCss, classNames, id, defaultData) {
|
|
|
114
124
|
disabled: '.is-disabled'
|
|
115
125
|
};
|
|
116
126
|
var _loop_1 = function (item) {
|
|
117
|
-
var e_2, _c;
|
|
118
127
|
var body = themeCss[item.key];
|
|
119
|
-
var list = (_b = item.value) === null || _b === void 0 ? void 0 : _b.split(' ');
|
|
120
|
-
var classNameList = [];
|
|
121
128
|
if (!body) {
|
|
122
129
|
return "continue";
|
|
123
130
|
}
|
|
124
|
-
|
|
125
|
-
if (/(\S*[C|c]lassName-\S*)/.test(n) &&
|
|
126
|
-
!!~n.indexOf((id === null || id === void 0 ? void 0 : id.replace('u:', '').replace('-label', '').replace('-description', '').replace('-addOn', '').replace('-icon', '').replace('-inner', '')) || '')) {
|
|
127
|
-
classNameList.push(n);
|
|
128
|
-
}
|
|
129
|
-
});
|
|
131
|
+
var className = item.key + '-' + (id === null || id === void 0 ? void 0 : id.replace('u:', ''));
|
|
130
132
|
var weightsList = item.weights || {};
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
for (var key in body) {
|
|
142
|
-
if (key === '$$id') {
|
|
143
|
-
continue;
|
|
144
|
-
}
|
|
145
|
-
if (!!~key.indexOf(':default')) {
|
|
146
|
-
statusMap.default[key.replace(':default', '')] = body[key];
|
|
147
|
-
}
|
|
148
|
-
else if (!!~key.indexOf(':hover')) {
|
|
149
|
-
statusMap.hover[key.replace(':hover', '')] = body[key];
|
|
150
|
-
}
|
|
151
|
-
else if (!!~key.indexOf(':active')) {
|
|
152
|
-
statusMap.active[key.replace(':active', '')] = body[key];
|
|
153
|
-
}
|
|
154
|
-
else if (!!~key.indexOf(':disabled')) {
|
|
155
|
-
statusMap.disabled[key.replace(':disabled', '')] = body[key];
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
statusMap.default[key] = body[key];
|
|
159
|
-
}
|
|
133
|
+
var statusMap = {
|
|
134
|
+
default: {},
|
|
135
|
+
hover: {},
|
|
136
|
+
active: {},
|
|
137
|
+
disabled: {}
|
|
138
|
+
};
|
|
139
|
+
Object.keys(body).forEach(function (key) {
|
|
140
|
+
if (key !== '$$id' && body[key]) {
|
|
141
|
+
if (!!~key.indexOf(':default')) {
|
|
142
|
+
statusMap.default[key.replace(':default', '')] = body[key];
|
|
160
143
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
144
|
+
else if (!!~key.indexOf(':hover')) {
|
|
145
|
+
statusMap.hover[key.replace(':hover', '')] = body[key];
|
|
146
|
+
}
|
|
147
|
+
else if (!!~key.indexOf(':active')) {
|
|
148
|
+
statusMap.active[key.replace(':active', '')] = body[key];
|
|
149
|
+
}
|
|
150
|
+
else if (!!~key.indexOf(':disabled')) {
|
|
151
|
+
statusMap.disabled[key.replace(':disabled', '')] = body[key];
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
statusMap.default[key] = body[key];
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
handleInheritData(statusMap, defaultData);
|
|
159
|
+
Object.keys(statusMap).forEach(function (status) {
|
|
160
|
+
var weights = weightsList[status];
|
|
161
|
+
var styles = [];
|
|
162
|
+
var fn = function (key, value) {
|
|
163
|
+
key = valueMap[key] || key;
|
|
164
|
+
styles.push("".concat(key, ": ").concat(value, ";"));
|
|
165
|
+
};
|
|
166
|
+
Object.keys(statusMap[status]).forEach(function (key) {
|
|
167
|
+
if (key !== '$$id') {
|
|
168
|
+
var style_1 = statusMap[status][key];
|
|
169
|
+
if (typeof style_1 === 'object') {
|
|
170
|
+
// 圆角特殊处理
|
|
171
|
+
if (key === 'radius') {
|
|
172
|
+
fn('border-radius', [
|
|
173
|
+
style_1['top-left-border-radius'] || 0,
|
|
174
|
+
style_1['top-right-border-radius'] || 0,
|
|
175
|
+
style_1['bottom-right-border-radius'] || 0,
|
|
176
|
+
style_1['bottom-left-border-radius'] || 0
|
|
177
|
+
].join(' '));
|
|
172
178
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
fn('border-radius', [
|
|
178
|
-
style['top-left-border-radius'],
|
|
179
|
-
style['top-right-border-radius'],
|
|
180
|
-
style['bottom-right-border-radius'],
|
|
181
|
-
style['bottom-left-border-radius']
|
|
182
|
-
].join(' '));
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
for (var k in style) {
|
|
186
|
-
if (k === '$$id') {
|
|
187
|
-
continue;
|
|
188
|
-
}
|
|
189
|
-
var value = style[k];
|
|
179
|
+
else {
|
|
180
|
+
Object.keys(style_1).forEach(function (k) {
|
|
181
|
+
if (k !== '$$id') {
|
|
182
|
+
var value = style_1[k];
|
|
190
183
|
value && fn(k, value);
|
|
191
184
|
}
|
|
192
|
-
}
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
var value = style_1;
|
|
190
|
+
if (key === 'iconSize') {
|
|
191
|
+
fn('width', value + ((weights === null || weights === void 0 ? void 0 : weights.important) ? ' !important' : ''));
|
|
192
|
+
fn('height', value + ((weights === null || weights === void 0 ? void 0 : weights.important) ? ' !important' : ''));
|
|
193
|
+
fn('font-size', value + ((weights === null || weights === void 0 ? void 0 : weights.important) ? ' !important' : ''));
|
|
193
194
|
}
|
|
194
195
|
else {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
fn('width', value + ((weights === null || weights === void 0 ? void 0 : weights.important) ? ' !important' : ''));
|
|
198
|
-
fn('height', value + ((weights === null || weights === void 0 ? void 0 : weights.important) ? ' !important' : ''));
|
|
199
|
-
fn('font-size', value + ((weights === null || weights === void 0 ? void 0 : weights.important) ? ' !important' : ''));
|
|
200
|
-
}
|
|
201
|
-
else {
|
|
202
|
-
value &&
|
|
203
|
-
fn(key, value + ((weights === null || weights === void 0 ? void 0 : weights.important) ? ' !important' : ''));
|
|
204
|
-
}
|
|
196
|
+
value &&
|
|
197
|
+
fn(key, value + ((weights === null || weights === void 0 ? void 0 : weights.important) ? ' !important' : ''));
|
|
205
198
|
}
|
|
206
199
|
}
|
|
207
|
-
if (styles.length > 0) {
|
|
208
|
-
var cx = ((weights === null || weights === void 0 ? void 0 : weights.pre) || '') + className + ((weights === null || weights === void 0 ? void 0 : weights.suf) || '');
|
|
209
|
-
var inner = (weights === null || weights === void 0 ? void 0 : weights.inner) || '';
|
|
210
|
-
res.push({
|
|
211
|
-
className: cx + status2string[status_1] + inner,
|
|
212
|
-
content: ".".concat(cx + status2string[status_1], " ").concat(inner, "{\n ").concat(styles.join('\n '), "\n}")
|
|
213
|
-
});
|
|
214
|
-
// TODO:切换状态暂时先不改变组件的样式
|
|
215
|
-
// if (['hover', 'active', 'disabled'].includes(status)) {
|
|
216
|
-
// res.push({
|
|
217
|
-
// className: cx + '.' + status,
|
|
218
|
-
// content: `.${cx}.${status} {\n ${styles.join('\n ')}\n}`
|
|
219
|
-
// });
|
|
220
|
-
// }
|
|
221
|
-
}
|
|
222
|
-
};
|
|
223
|
-
for (var status_1 in statusMap) {
|
|
224
|
-
_loop_2(status_1);
|
|
225
200
|
}
|
|
201
|
+
});
|
|
202
|
+
if (styles.length > 0) {
|
|
203
|
+
var cx = ((weights === null || weights === void 0 ? void 0 : weights.pre) || '') + className + ((weights === null || weights === void 0 ? void 0 : weights.suf) || '');
|
|
204
|
+
var inner = (weights === null || weights === void 0 ? void 0 : weights.inner) || '';
|
|
205
|
+
res.push({
|
|
206
|
+
className: cx + status2string[status] + inner,
|
|
207
|
+
content: ".".concat(cx + status2string[status], " ").concat(inner, "{\n ").concat(styles.join('\n '), "\n}")
|
|
208
|
+
});
|
|
209
|
+
// TODO:切换状态暂时先不改变组件的样式
|
|
210
|
+
// if (['hover', 'active', 'disabled'].includes(status)) {
|
|
211
|
+
// res.push({
|
|
212
|
+
// className: cx + '.' + status,
|
|
213
|
+
// content: `.${cx}.${status} {\n ${styles.join('\n ')}\n}`
|
|
214
|
+
// });
|
|
215
|
+
// }
|
|
226
216
|
}
|
|
227
|
-
}
|
|
228
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
229
|
-
finally {
|
|
230
|
-
try {
|
|
231
|
-
if (classNameList_1_1 && !classNameList_1_1.done && (_c = classNameList_1.return)) _c.call(classNameList_1);
|
|
232
|
-
}
|
|
233
|
-
finally { if (e_2) throw e_2.error; }
|
|
234
|
-
}
|
|
217
|
+
});
|
|
235
218
|
};
|
|
236
219
|
try {
|
|
237
220
|
for (var classNames_1 = tslib.__values(classNames), classNames_1_1 = classNames_1.next(); !classNames_1_1.done; classNames_1_1 = classNames_1.next()) {
|
|
@@ -251,7 +234,7 @@ function formatStyle(themeCss, classNames, id, defaultData) {
|
|
|
251
234
|
origin: res
|
|
252
235
|
};
|
|
253
236
|
}
|
|
254
|
-
function insertCustomStyle(themeCss, classNames, id, defaultData, customStyleClassPrefix) {
|
|
237
|
+
function insertCustomStyle(themeCss, classNames, id, defaultData, customStyleClassPrefix, doc) {
|
|
255
238
|
if (!themeCss) {
|
|
256
239
|
return;
|
|
257
240
|
}
|
|
@@ -260,7 +243,7 @@ function insertCustomStyle(themeCss, classNames, id, defaultData, customStyleCla
|
|
|
260
243
|
value = customStyleClassPrefix
|
|
261
244
|
? "".concat(customStyleClassPrefix, " ").concat(value)
|
|
262
245
|
: value;
|
|
263
|
-
insertStyle(value,
|
|
246
|
+
insertStyle(value, id.replace('u:', ''), doc);
|
|
264
247
|
}
|
|
265
248
|
}
|
|
266
249
|
/**
|
|
@@ -282,12 +265,97 @@ function getValueByPath(path, data) {
|
|
|
282
265
|
return null;
|
|
283
266
|
}
|
|
284
267
|
}
|
|
268
|
+
// 递归处理嵌套的样式,转化成一维对象
|
|
269
|
+
function traverseStyle(style, path, result) {
|
|
270
|
+
Object.keys(style).forEach(function (key) {
|
|
271
|
+
if (key !== '$$id') {
|
|
272
|
+
if (isObject__default["default"](style[key])) {
|
|
273
|
+
var nowPath = path ? "".concat(path, " ").concat(key) : key;
|
|
274
|
+
traverseStyle(style[key], nowPath, result);
|
|
275
|
+
}
|
|
276
|
+
else if (path === '') {
|
|
277
|
+
!result[key] && (result[key] = {});
|
|
278
|
+
result[key] = style[key];
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
!result[path] && (result[path] = {});
|
|
282
|
+
result[path][key] = style[key];
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* 设置源码编辑自定义样式
|
|
289
|
+
*/
|
|
290
|
+
function insertEditCustomStyle(customStyle, id, doc) {
|
|
291
|
+
var styles = {};
|
|
292
|
+
traverseStyle(customStyle, '', styles);
|
|
293
|
+
var content = '';
|
|
294
|
+
if (!isEmpty__default["default"](styles)) {
|
|
295
|
+
var className_1 = "wrapperCustomStyle-".concat(id === null || id === void 0 ? void 0 : id.replace('u:', ''));
|
|
296
|
+
Object.keys(styles).forEach(function (key) {
|
|
297
|
+
if (!isObject__default["default"](styles[key])) {
|
|
298
|
+
content += "\n.".concat(className_1, " {\n ").concat(key, ": ").concat(styles[key], "\n}");
|
|
299
|
+
}
|
|
300
|
+
else if (key === 'root') {
|
|
301
|
+
var res = map__default["default"](styles[key], function (value, key) { return "".concat(key, ": ").concat(value, ";"); });
|
|
302
|
+
content += "\n.".concat(className_1, " {\n ").concat(res.join('\n '), "\n}");
|
|
303
|
+
}
|
|
304
|
+
else if (/^root:/.test(key)) {
|
|
305
|
+
var res = map__default["default"](styles[key], function (value, key) { return "".concat(key, ": ").concat(value, ";"); });
|
|
306
|
+
var nowKey = key.replace('root', '');
|
|
307
|
+
content += "\n.".concat(className_1, " ").concat(nowKey, " {\n ").concat(res.join('\n '), "\n}");
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
var res = map__default["default"](styles[key], function (value, key) { return "".concat(key, ": ").concat(value, ";"); });
|
|
311
|
+
content += "\n.".concat(className_1, " ").concat(key, " {\n ").concat(res.join('\n '), "\n}");
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
insertStyle(content, 'wrapperCustomStyle-' + ((id === null || id === void 0 ? void 0 : id.replace('u:', '')) || helper.uuid()), doc);
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* 移除自定义样式
|
|
319
|
+
*/
|
|
320
|
+
function removeCustomStyle(type, id, doc) {
|
|
321
|
+
var style = (doc || document).getElementById((type ? type + '-' : '') + id.replace('u:', ''));
|
|
322
|
+
if (style) {
|
|
323
|
+
style.remove();
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
function formatInputThemeCss(themeCss) {
|
|
327
|
+
if (!themeCss) {
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
var inputFontThemeCss = { inputControlClassName: {} };
|
|
331
|
+
var inputControlClassNameObject = (themeCss === null || themeCss === void 0 ? void 0 : themeCss.inputControlClassName) || {};
|
|
332
|
+
Object.keys(inputControlClassNameObject).forEach(function (key) {
|
|
333
|
+
if (~key.indexOf('font')) {
|
|
334
|
+
inputFontThemeCss.inputControlClassName[key] =
|
|
335
|
+
inputControlClassNameObject[key];
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
return inputFontThemeCss;
|
|
339
|
+
}
|
|
340
|
+
function setThemeClassName(name, id, themeCss, extra) {
|
|
341
|
+
if (!id || !themeCss) {
|
|
342
|
+
return '';
|
|
343
|
+
}
|
|
344
|
+
if (name !== 'wrapperCustomStyle' && !themeCss[name]) {
|
|
345
|
+
return '';
|
|
346
|
+
}
|
|
347
|
+
return "".concat(name, "-").concat(id.replace('u:', '')) + (extra ? "-".concat(extra) : '');
|
|
348
|
+
}
|
|
285
349
|
|
|
286
350
|
exports.addStyle = addStyle;
|
|
287
|
-
exports.
|
|
351
|
+
exports.findOrCreateStyle = findOrCreateStyle;
|
|
352
|
+
exports.formatInputThemeCss = formatInputThemeCss;
|
|
288
353
|
exports.formatStyle = formatStyle;
|
|
289
354
|
exports.getValueByPath = getValueByPath;
|
|
290
355
|
exports.inheritValueMap = inheritValueMap;
|
|
291
356
|
exports.insertCustomStyle = insertCustomStyle;
|
|
357
|
+
exports.insertEditCustomStyle = insertEditCustomStyle;
|
|
292
358
|
exports.insertStyle = insertStyle;
|
|
359
|
+
exports.removeCustomStyle = removeCustomStyle;
|
|
360
|
+
exports.setThemeClassName = setThemeClassName;
|
|
293
361
|
exports.valueMap = valueMap;
|
package/lib/utils/style.js
CHANGED
package/lib/utils/toNumber.js
CHANGED