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,10 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v3.4.
|
|
2
|
+
* amis-core v3.4.2
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { __spreadArray, __read } from 'tslib';
|
|
7
|
-
|
|
8
6
|
/**
|
|
9
7
|
* @file resize-sensor.js.
|
|
10
8
|
* @author fex
|
|
@@ -13,16 +11,22 @@ var EventQueue = /** @class */ (function () {
|
|
|
13
11
|
function EventQueue() {
|
|
14
12
|
this.q = [];
|
|
15
13
|
}
|
|
16
|
-
EventQueue.prototype.add = function (cb) {
|
|
17
|
-
|
|
14
|
+
EventQueue.prototype.add = function (cb, type) {
|
|
15
|
+
if (type === void 0) { type = 'both'; }
|
|
16
|
+
this.q.push({
|
|
17
|
+
fn: cb,
|
|
18
|
+
type: type
|
|
19
|
+
});
|
|
18
20
|
};
|
|
19
|
-
EventQueue.prototype.call = function () {
|
|
21
|
+
EventQueue.prototype.call = function (type) {
|
|
20
22
|
var args = [];
|
|
21
|
-
for (var _i =
|
|
22
|
-
args[_i] = arguments[_i];
|
|
23
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
24
|
+
args[_i - 1] = arguments[_i];
|
|
23
25
|
}
|
|
24
|
-
this.q.forEach(function (
|
|
25
|
-
|
|
26
|
+
this.q.forEach(function (item) {
|
|
27
|
+
if (item.type === type || item.type === 'both' || type === 'both') {
|
|
28
|
+
item.fn.apply(null, args);
|
|
29
|
+
}
|
|
26
30
|
});
|
|
27
31
|
};
|
|
28
32
|
return EventQueue;
|
|
@@ -39,16 +43,17 @@ function getComputedStyle(element, prop) {
|
|
|
39
43
|
return element.style[prop];
|
|
40
44
|
}
|
|
41
45
|
}
|
|
42
|
-
function attachResizeEvent(element, resized) {
|
|
46
|
+
function attachResizeEvent(element, resized, type) {
|
|
47
|
+
if (type === void 0) { type = 'both'; }
|
|
43
48
|
if (!element) {
|
|
44
49
|
return;
|
|
45
50
|
}
|
|
46
51
|
if (!element.resizedAttached) {
|
|
47
52
|
element.resizedAttached = new EventQueue();
|
|
48
|
-
element.resizedAttached.add(resized);
|
|
53
|
+
element.resizedAttached.add(resized, type);
|
|
49
54
|
}
|
|
50
55
|
else if (element.resizedAttached) {
|
|
51
|
-
element.resizedAttached.add(resized);
|
|
56
|
+
element.resizedAttached.add(resized, type);
|
|
52
57
|
return;
|
|
53
58
|
}
|
|
54
59
|
var resizeSensor = (element.resizeSensor =
|
|
@@ -90,9 +95,10 @@ function attachResizeEvent(element, resized) {
|
|
|
90
95
|
}
|
|
91
96
|
};
|
|
92
97
|
reset();
|
|
93
|
-
var changed = function () {
|
|
98
|
+
var changed = function (type) {
|
|
99
|
+
if (type === void 0) { type = 'both'; }
|
|
94
100
|
if (element.resizedAttached) {
|
|
95
|
-
element.resizedAttached.call();
|
|
101
|
+
element.resizedAttached.call(type);
|
|
96
102
|
}
|
|
97
103
|
};
|
|
98
104
|
var addEvent = function (el, name, cb) {
|
|
@@ -112,9 +118,14 @@ function attachResizeEvent(element, resized) {
|
|
|
112
118
|
}
|
|
113
119
|
};
|
|
114
120
|
var onScroll = function (e) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
121
|
+
var widthChanged = element.offsetWidth != lastWidth;
|
|
122
|
+
var heightChanged = element.offsetHeight != lastHeight;
|
|
123
|
+
if (widthChanged || heightChanged) {
|
|
124
|
+
changed(widthChanged && heightChanged
|
|
125
|
+
? 'both'
|
|
126
|
+
: widthChanged
|
|
127
|
+
? 'width'
|
|
128
|
+
: 'height');
|
|
118
129
|
}
|
|
119
130
|
reset();
|
|
120
131
|
};
|
|
@@ -146,8 +157,9 @@ function detach(element) {
|
|
|
146
157
|
delete element.originPosition;
|
|
147
158
|
}
|
|
148
159
|
}
|
|
149
|
-
function resizeSensor(element, callback, once) {
|
|
160
|
+
function resizeSensor(element, callback, once, type) {
|
|
150
161
|
if (once === void 0) { once = false; }
|
|
162
|
+
if (type === void 0) { type = 'both'; }
|
|
151
163
|
if (!element) {
|
|
152
164
|
return function () { };
|
|
153
165
|
}
|
|
@@ -157,10 +169,10 @@ function resizeSensor(element, callback, once) {
|
|
|
157
169
|
callback.apply(this, arguments);
|
|
158
170
|
disposeEvent === null || disposeEvent === void 0 ? void 0 : disposeEvent();
|
|
159
171
|
detach(element);
|
|
160
|
-
});
|
|
161
|
-
return;
|
|
172
|
+
}, type);
|
|
173
|
+
return function () { };
|
|
162
174
|
}
|
|
163
|
-
disposeEvent = attachResizeEvent(element, callback);
|
|
175
|
+
disposeEvent = attachResizeEvent(element, callback, type);
|
|
164
176
|
var detached = false;
|
|
165
177
|
return function () {
|
|
166
178
|
if (detached)
|
package/esm/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,11 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v3.4.
|
|
2
|
+
* amis-core v3.4.2
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { __values } from 'tslib';
|
|
7
7
|
import { uuid } from './helper.js';
|
|
8
8
|
import cloneDeep from 'lodash/cloneDeep';
|
|
9
|
+
import isObject from 'lodash/isObject';
|
|
10
|
+
import map from 'lodash/map';
|
|
11
|
+
import isEmpty from 'lodash/isEmpty';
|
|
9
12
|
|
|
10
13
|
var valueMap = {
|
|
11
14
|
'marginTop': 'margin-top',
|
|
@@ -36,22 +39,26 @@ var inheritValueMap = {
|
|
|
36
39
|
background: 'bg-color',
|
|
37
40
|
radius: 'border'
|
|
38
41
|
};
|
|
39
|
-
function
|
|
40
|
-
|
|
42
|
+
function findOrCreateStyle(id, doc) {
|
|
43
|
+
doc = doc || document;
|
|
44
|
+
var varStyleTag = doc.getElementById(id);
|
|
41
45
|
if (!varStyleTag) {
|
|
42
|
-
varStyleTag =
|
|
46
|
+
varStyleTag = doc.createElement('style');
|
|
43
47
|
varStyleTag.id = id;
|
|
44
|
-
|
|
48
|
+
doc.body.appendChild(varStyleTag);
|
|
45
49
|
}
|
|
46
50
|
return varStyleTag;
|
|
47
51
|
}
|
|
48
|
-
function insertStyle(style, id) {
|
|
49
|
-
var varStyleTag =
|
|
52
|
+
function insertStyle(style, id, doc) {
|
|
53
|
+
var varStyleTag = findOrCreateStyle(id, doc);
|
|
50
54
|
// bca-disable-line
|
|
51
55
|
varStyleTag.innerHTML = style;
|
|
56
|
+
if (!style) {
|
|
57
|
+
varStyleTag.remove();
|
|
58
|
+
}
|
|
52
59
|
}
|
|
53
60
|
function addStyle(style, id) {
|
|
54
|
-
var varStyleTag =
|
|
61
|
+
var varStyleTag = findOrCreateStyle(id);
|
|
55
62
|
// bca-disable-line
|
|
56
63
|
varStyleTag.innerHTML += style;
|
|
57
64
|
}
|
|
@@ -62,9 +69,9 @@ function handleInheritData(statusMap, data) {
|
|
|
62
69
|
}
|
|
63
70
|
// 检查是否存在inherit
|
|
64
71
|
['hover', 'active'].forEach(function (status) {
|
|
65
|
-
|
|
72
|
+
Object.keys(statusMap[status]).forEach(function (key) {
|
|
66
73
|
if (typeof statusMap[status][key] === 'object') {
|
|
67
|
-
|
|
74
|
+
Object.keys(statusMap[status][key]).forEach(function (style) {
|
|
68
75
|
if (statusMap[status][key][style] === 'inherit') {
|
|
69
76
|
// 值为inherit时设置为default的值或者主题中的default值
|
|
70
77
|
if (statusMap['default'][key] && statusMap['default'][key][style]) {
|
|
@@ -76,7 +83,7 @@ function handleInheritData(statusMap, data) {
|
|
|
76
83
|
data['default'].body[value][style];
|
|
77
84
|
}
|
|
78
85
|
}
|
|
79
|
-
}
|
|
86
|
+
});
|
|
80
87
|
}
|
|
81
88
|
else {
|
|
82
89
|
if (statusMap[status][key] === 'inherit') {
|
|
@@ -89,13 +96,13 @@ function handleInheritData(statusMap, data) {
|
|
|
89
96
|
}
|
|
90
97
|
}
|
|
91
98
|
}
|
|
92
|
-
}
|
|
99
|
+
});
|
|
93
100
|
});
|
|
94
101
|
}
|
|
95
102
|
function formatStyle(themeCss, classNames, id, defaultData) {
|
|
96
103
|
var e_1, _a;
|
|
97
|
-
|
|
98
|
-
if (!themeCss) {
|
|
104
|
+
// 没有具体的样式,或者没有对应的classname
|
|
105
|
+
if (!themeCss || !classNames) {
|
|
99
106
|
return { value: '', origin: [] };
|
|
100
107
|
}
|
|
101
108
|
var res = [];
|
|
@@ -106,124 +113,97 @@ function formatStyle(themeCss, classNames, id, defaultData) {
|
|
|
106
113
|
disabled: '.is-disabled'
|
|
107
114
|
};
|
|
108
115
|
var _loop_1 = function (item) {
|
|
109
|
-
var e_2, _c;
|
|
110
116
|
var body = themeCss[item.key];
|
|
111
|
-
var list = (_b = item.value) === null || _b === void 0 ? void 0 : _b.split(' ');
|
|
112
|
-
var classNameList = [];
|
|
113
117
|
if (!body) {
|
|
114
118
|
return "continue";
|
|
115
119
|
}
|
|
116
|
-
|
|
117
|
-
if (/(\S*[C|c]lassName-\S*)/.test(n) &&
|
|
118
|
-
!!~n.indexOf((id === null || id === void 0 ? void 0 : id.replace('u:', '').replace('-label', '').replace('-description', '').replace('-addOn', '').replace('-icon', '').replace('-inner', '')) || '')) {
|
|
119
|
-
classNameList.push(n);
|
|
120
|
-
}
|
|
121
|
-
});
|
|
120
|
+
var className = item.key + '-' + (id === null || id === void 0 ? void 0 : id.replace('u:', ''));
|
|
122
121
|
var weightsList = item.weights || {};
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
for (var key in body) {
|
|
134
|
-
if (key === '$$id') {
|
|
135
|
-
continue;
|
|
136
|
-
}
|
|
137
|
-
if (!!~key.indexOf(':default')) {
|
|
138
|
-
statusMap.default[key.replace(':default', '')] = body[key];
|
|
139
|
-
}
|
|
140
|
-
else if (!!~key.indexOf(':hover')) {
|
|
141
|
-
statusMap.hover[key.replace(':hover', '')] = body[key];
|
|
142
|
-
}
|
|
143
|
-
else if (!!~key.indexOf(':active')) {
|
|
144
|
-
statusMap.active[key.replace(':active', '')] = body[key];
|
|
145
|
-
}
|
|
146
|
-
else if (!!~key.indexOf(':disabled')) {
|
|
147
|
-
statusMap.disabled[key.replace(':disabled', '')] = body[key];
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
statusMap.default[key] = body[key];
|
|
151
|
-
}
|
|
122
|
+
var statusMap = {
|
|
123
|
+
default: {},
|
|
124
|
+
hover: {},
|
|
125
|
+
active: {},
|
|
126
|
+
disabled: {}
|
|
127
|
+
};
|
|
128
|
+
Object.keys(body).forEach(function (key) {
|
|
129
|
+
if (key !== '$$id' && body[key]) {
|
|
130
|
+
if (!!~key.indexOf(':default')) {
|
|
131
|
+
statusMap.default[key.replace(':default', '')] = body[key];
|
|
152
132
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
133
|
+
else if (!!~key.indexOf(':hover')) {
|
|
134
|
+
statusMap.hover[key.replace(':hover', '')] = body[key];
|
|
135
|
+
}
|
|
136
|
+
else if (!!~key.indexOf(':active')) {
|
|
137
|
+
statusMap.active[key.replace(':active', '')] = body[key];
|
|
138
|
+
}
|
|
139
|
+
else if (!!~key.indexOf(':disabled')) {
|
|
140
|
+
statusMap.disabled[key.replace(':disabled', '')] = body[key];
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
statusMap.default[key] = body[key];
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
handleInheritData(statusMap, defaultData);
|
|
148
|
+
Object.keys(statusMap).forEach(function (status) {
|
|
149
|
+
var weights = weightsList[status];
|
|
150
|
+
var styles = [];
|
|
151
|
+
var fn = function (key, value) {
|
|
152
|
+
key = valueMap[key] || key;
|
|
153
|
+
styles.push("".concat(key, ": ").concat(value, ";"));
|
|
154
|
+
};
|
|
155
|
+
Object.keys(statusMap[status]).forEach(function (key) {
|
|
156
|
+
if (key !== '$$id') {
|
|
157
|
+
var style_1 = statusMap[status][key];
|
|
158
|
+
if (typeof style_1 === 'object') {
|
|
159
|
+
// 圆角特殊处理
|
|
160
|
+
if (key === 'radius') {
|
|
161
|
+
fn('border-radius', [
|
|
162
|
+
style_1['top-left-border-radius'] || 0,
|
|
163
|
+
style_1['top-right-border-radius'] || 0,
|
|
164
|
+
style_1['bottom-right-border-radius'] || 0,
|
|
165
|
+
style_1['bottom-left-border-radius'] || 0
|
|
166
|
+
].join(' '));
|
|
164
167
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
fn('border-radius', [
|
|
170
|
-
style['top-left-border-radius'],
|
|
171
|
-
style['top-right-border-radius'],
|
|
172
|
-
style['bottom-right-border-radius'],
|
|
173
|
-
style['bottom-left-border-radius']
|
|
174
|
-
].join(' '));
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
for (var k in style) {
|
|
178
|
-
if (k === '$$id') {
|
|
179
|
-
continue;
|
|
180
|
-
}
|
|
181
|
-
var value = style[k];
|
|
168
|
+
else {
|
|
169
|
+
Object.keys(style_1).forEach(function (k) {
|
|
170
|
+
if (k !== '$$id') {
|
|
171
|
+
var value = style_1[k];
|
|
182
172
|
value && fn(k, value);
|
|
183
173
|
}
|
|
184
|
-
}
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
var value = style_1;
|
|
179
|
+
if (key === 'iconSize') {
|
|
180
|
+
fn('width', value + ((weights === null || weights === void 0 ? void 0 : weights.important) ? ' !important' : ''));
|
|
181
|
+
fn('height', value + ((weights === null || weights === void 0 ? void 0 : weights.important) ? ' !important' : ''));
|
|
182
|
+
fn('font-size', value + ((weights === null || weights === void 0 ? void 0 : weights.important) ? ' !important' : ''));
|
|
185
183
|
}
|
|
186
184
|
else {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
fn('width', value + ((weights === null || weights === void 0 ? void 0 : weights.important) ? ' !important' : ''));
|
|
190
|
-
fn('height', value + ((weights === null || weights === void 0 ? void 0 : weights.important) ? ' !important' : ''));
|
|
191
|
-
fn('font-size', value + ((weights === null || weights === void 0 ? void 0 : weights.important) ? ' !important' : ''));
|
|
192
|
-
}
|
|
193
|
-
else {
|
|
194
|
-
value &&
|
|
195
|
-
fn(key, value + ((weights === null || weights === void 0 ? void 0 : weights.important) ? ' !important' : ''));
|
|
196
|
-
}
|
|
185
|
+
value &&
|
|
186
|
+
fn(key, value + ((weights === null || weights === void 0 ? void 0 : weights.important) ? ' !important' : ''));
|
|
197
187
|
}
|
|
198
188
|
}
|
|
199
|
-
if (styles.length > 0) {
|
|
200
|
-
var cx = ((weights === null || weights === void 0 ? void 0 : weights.pre) || '') + className + ((weights === null || weights === void 0 ? void 0 : weights.suf) || '');
|
|
201
|
-
var inner = (weights === null || weights === void 0 ? void 0 : weights.inner) || '';
|
|
202
|
-
res.push({
|
|
203
|
-
className: cx + status2string[status_1] + inner,
|
|
204
|
-
content: ".".concat(cx + status2string[status_1], " ").concat(inner, "{\n ").concat(styles.join('\n '), "\n}")
|
|
205
|
-
});
|
|
206
|
-
// TODO:切换状态暂时先不改变组件的样式
|
|
207
|
-
// if (['hover', 'active', 'disabled'].includes(status)) {
|
|
208
|
-
// res.push({
|
|
209
|
-
// className: cx + '.' + status,
|
|
210
|
-
// content: `.${cx}.${status} {\n ${styles.join('\n ')}\n}`
|
|
211
|
-
// });
|
|
212
|
-
// }
|
|
213
|
-
}
|
|
214
|
-
};
|
|
215
|
-
for (var status_1 in statusMap) {
|
|
216
|
-
_loop_2(status_1);
|
|
217
189
|
}
|
|
190
|
+
});
|
|
191
|
+
if (styles.length > 0) {
|
|
192
|
+
var cx = ((weights === null || weights === void 0 ? void 0 : weights.pre) || '') + className + ((weights === null || weights === void 0 ? void 0 : weights.suf) || '');
|
|
193
|
+
var inner = (weights === null || weights === void 0 ? void 0 : weights.inner) || '';
|
|
194
|
+
res.push({
|
|
195
|
+
className: cx + status2string[status] + inner,
|
|
196
|
+
content: ".".concat(cx + status2string[status], " ").concat(inner, "{\n ").concat(styles.join('\n '), "\n}")
|
|
197
|
+
});
|
|
198
|
+
// TODO:切换状态暂时先不改变组件的样式
|
|
199
|
+
// if (['hover', 'active', 'disabled'].includes(status)) {
|
|
200
|
+
// res.push({
|
|
201
|
+
// className: cx + '.' + status,
|
|
202
|
+
// content: `.${cx}.${status} {\n ${styles.join('\n ')}\n}`
|
|
203
|
+
// });
|
|
204
|
+
// }
|
|
218
205
|
}
|
|
219
|
-
}
|
|
220
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
221
|
-
finally {
|
|
222
|
-
try {
|
|
223
|
-
if (classNameList_1_1 && !classNameList_1_1.done && (_c = classNameList_1.return)) _c.call(classNameList_1);
|
|
224
|
-
}
|
|
225
|
-
finally { if (e_2) throw e_2.error; }
|
|
226
|
-
}
|
|
206
|
+
});
|
|
227
207
|
};
|
|
228
208
|
try {
|
|
229
209
|
for (var classNames_1 = __values(classNames), classNames_1_1 = classNames_1.next(); !classNames_1_1.done; classNames_1_1 = classNames_1.next()) {
|
|
@@ -243,7 +223,7 @@ function formatStyle(themeCss, classNames, id, defaultData) {
|
|
|
243
223
|
origin: res
|
|
244
224
|
};
|
|
245
225
|
}
|
|
246
|
-
function insertCustomStyle(themeCss, classNames, id, defaultData, customStyleClassPrefix) {
|
|
226
|
+
function insertCustomStyle(themeCss, classNames, id, defaultData, customStyleClassPrefix, doc) {
|
|
247
227
|
if (!themeCss) {
|
|
248
228
|
return;
|
|
249
229
|
}
|
|
@@ -252,7 +232,7 @@ function insertCustomStyle(themeCss, classNames, id, defaultData, customStyleCla
|
|
|
252
232
|
value = customStyleClassPrefix
|
|
253
233
|
? "".concat(customStyleClassPrefix, " ").concat(value)
|
|
254
234
|
: value;
|
|
255
|
-
insertStyle(value,
|
|
235
|
+
insertStyle(value, id.replace('u:', ''), doc);
|
|
256
236
|
}
|
|
257
237
|
}
|
|
258
238
|
/**
|
|
@@ -274,5 +254,86 @@ function getValueByPath(path, data) {
|
|
|
274
254
|
return null;
|
|
275
255
|
}
|
|
276
256
|
}
|
|
257
|
+
// 递归处理嵌套的样式,转化成一维对象
|
|
258
|
+
function traverseStyle(style, path, result) {
|
|
259
|
+
Object.keys(style).forEach(function (key) {
|
|
260
|
+
if (key !== '$$id') {
|
|
261
|
+
if (isObject(style[key])) {
|
|
262
|
+
var nowPath = path ? "".concat(path, " ").concat(key) : key;
|
|
263
|
+
traverseStyle(style[key], nowPath, result);
|
|
264
|
+
}
|
|
265
|
+
else if (path === '') {
|
|
266
|
+
!result[key] && (result[key] = {});
|
|
267
|
+
result[key] = style[key];
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
!result[path] && (result[path] = {});
|
|
271
|
+
result[path][key] = style[key];
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* 设置源码编辑自定义样式
|
|
278
|
+
*/
|
|
279
|
+
function insertEditCustomStyle(customStyle, id, doc) {
|
|
280
|
+
var styles = {};
|
|
281
|
+
traverseStyle(customStyle, '', styles);
|
|
282
|
+
var content = '';
|
|
283
|
+
if (!isEmpty(styles)) {
|
|
284
|
+
var className_1 = "wrapperCustomStyle-".concat(id === null || id === void 0 ? void 0 : id.replace('u:', ''));
|
|
285
|
+
Object.keys(styles).forEach(function (key) {
|
|
286
|
+
if (!isObject(styles[key])) {
|
|
287
|
+
content += "\n.".concat(className_1, " {\n ").concat(key, ": ").concat(styles[key], "\n}");
|
|
288
|
+
}
|
|
289
|
+
else if (key === 'root') {
|
|
290
|
+
var res = map(styles[key], function (value, key) { return "".concat(key, ": ").concat(value, ";"); });
|
|
291
|
+
content += "\n.".concat(className_1, " {\n ").concat(res.join('\n '), "\n}");
|
|
292
|
+
}
|
|
293
|
+
else if (/^root:/.test(key)) {
|
|
294
|
+
var res = map(styles[key], function (value, key) { return "".concat(key, ": ").concat(value, ";"); });
|
|
295
|
+
var nowKey = key.replace('root', '');
|
|
296
|
+
content += "\n.".concat(className_1, " ").concat(nowKey, " {\n ").concat(res.join('\n '), "\n}");
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
var res = map(styles[key], function (value, key) { return "".concat(key, ": ").concat(value, ";"); });
|
|
300
|
+
content += "\n.".concat(className_1, " ").concat(key, " {\n ").concat(res.join('\n '), "\n}");
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
insertStyle(content, 'wrapperCustomStyle-' + ((id === null || id === void 0 ? void 0 : id.replace('u:', '')) || uuid()), doc);
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* 移除自定义样式
|
|
308
|
+
*/
|
|
309
|
+
function removeCustomStyle(type, id, doc) {
|
|
310
|
+
var style = (doc || document).getElementById((type ? type + '-' : '') + id.replace('u:', ''));
|
|
311
|
+
if (style) {
|
|
312
|
+
style.remove();
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
function formatInputThemeCss(themeCss) {
|
|
316
|
+
if (!themeCss) {
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
var inputFontThemeCss = { inputControlClassName: {} };
|
|
320
|
+
var inputControlClassNameObject = (themeCss === null || themeCss === void 0 ? void 0 : themeCss.inputControlClassName) || {};
|
|
321
|
+
Object.keys(inputControlClassNameObject).forEach(function (key) {
|
|
322
|
+
if (~key.indexOf('font')) {
|
|
323
|
+
inputFontThemeCss.inputControlClassName[key] =
|
|
324
|
+
inputControlClassNameObject[key];
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
return inputFontThemeCss;
|
|
328
|
+
}
|
|
329
|
+
function setThemeClassName(name, id, themeCss, extra) {
|
|
330
|
+
if (!id || !themeCss) {
|
|
331
|
+
return '';
|
|
332
|
+
}
|
|
333
|
+
if (name !== 'wrapperCustomStyle' && !themeCss[name]) {
|
|
334
|
+
return '';
|
|
335
|
+
}
|
|
336
|
+
return "".concat(name, "-").concat(id.replace('u:', '')) + (extra ? "-".concat(extra) : '');
|
|
337
|
+
}
|
|
277
338
|
|
|
278
|
-
export { addStyle,
|
|
339
|
+
export { addStyle, findOrCreateStyle, formatInputThemeCss, formatStyle, getValueByPath, inheritValueMap, insertCustomStyle, insertEditCustomStyle, insertStyle, removeCustomStyle, setThemeClassName, valueMap };
|
package/esm/utils/style.js
CHANGED
package/esm/utils/toNumber.js
CHANGED
package/esm/utils/tokenize.js
CHANGED
package/esm/utils/tpl-builtin.js
CHANGED
package/esm/utils/tpl-lodash.js
CHANGED