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.
Files changed (285) hide show
  1. package/esm/Root.js +1 -1
  2. package/esm/RootRenderer.js +8 -8
  3. package/esm/SchemaRenderer.js +16 -12
  4. package/esm/Scoped.js +3 -1
  5. package/esm/StatusScoped.js +1 -1
  6. package/esm/WithRootStore.js +1 -1
  7. package/esm/WithStore.js +9 -8
  8. package/esm/actions/Action.js +1 -1
  9. package/esm/actions/AjaxAction.js +2 -2
  10. package/esm/actions/BreakAction.js +1 -1
  11. package/esm/actions/BroadcastAction.js +1 -1
  12. package/esm/actions/CmptAction.js +1 -1
  13. package/esm/actions/ContinueAction.js +1 -1
  14. package/esm/actions/CopyAction.js +1 -1
  15. package/esm/actions/CustomAction.js +3 -1
  16. package/esm/actions/DialogAction.js +1 -1
  17. package/esm/actions/DrawerAction.js +5 -1
  18. package/esm/actions/EmailAction.js +1 -1
  19. package/esm/actions/LinkAction.js +1 -1
  20. package/esm/actions/LoopAction.js +1 -1
  21. package/esm/actions/PageAction.js +1 -1
  22. package/esm/actions/ParallelAction.js +1 -1
  23. package/esm/actions/StatusAction.js +1 -1
  24. package/esm/actions/SwitchAction.js +1 -1
  25. package/esm/actions/ToastAction.js +1 -1
  26. package/esm/components/CustomStyle.d.ts +5 -6
  27. package/esm/components/CustomStyle.js +47 -6
  28. package/esm/components/LazyComponent.d.ts +1 -2
  29. package/esm/components/LazyComponent.js +12 -8
  30. package/esm/components/Overlay.js +3 -1
  31. package/esm/components/PopOver.d.ts +12 -12
  32. package/esm/components/PopOver.js +3 -1
  33. package/esm/env.d.ts +2 -2
  34. package/esm/env.js +1 -1
  35. package/esm/envOverwrite.js +1 -1
  36. package/esm/factory.d.ts +7 -7
  37. package/esm/factory.js +1 -1
  38. package/esm/index.js +5 -5
  39. package/esm/locale.d.ts +1 -1
  40. package/esm/locale.js +3 -3
  41. package/esm/polyfills.js +1 -1
  42. package/esm/renderers/Form.d.ts +1 -1
  43. package/esm/renderers/Form.js +10 -8
  44. package/esm/renderers/Item.d.ts +24 -56
  45. package/esm/renderers/Item.js +25 -31
  46. package/esm/renderers/Options.js +14 -12
  47. package/esm/renderers/Placeholder.js +1 -1
  48. package/esm/renderers/builtin.js +1 -1
  49. package/esm/renderers/register.js +1 -1
  50. package/esm/renderers/wrapControl.js +70 -80
  51. package/esm/store/app.js +3 -1
  52. package/esm/store/combo.d.ts +384 -0
  53. package/esm/store/combo.js +1 -1
  54. package/esm/store/crud.js +31 -25
  55. package/esm/store/form.d.ts +160 -0
  56. package/esm/store/form.js +15 -13
  57. package/esm/store/formItem.d.ts +4 -0
  58. package/esm/store/formItem.js +42 -26
  59. package/esm/store/iRenderer.js +3 -1
  60. package/esm/store/index.js +1 -1
  61. package/esm/store/list.js +1 -1
  62. package/esm/store/manager.js +1 -1
  63. package/esm/store/modal.js +1 -1
  64. package/esm/store/node.js +1 -1
  65. package/esm/store/pagination.js +1 -1
  66. package/esm/store/root.d.ts +1 -1
  67. package/esm/store/root.js +12 -5
  68. package/esm/store/service.js +38 -33
  69. package/esm/store/status.js +1 -1
  70. package/esm/store/table.d.ts +760 -21
  71. package/esm/store/table.js +157 -57
  72. package/esm/store/table2.js +11 -8
  73. package/esm/theme.d.ts +18 -31
  74. package/esm/theme.js +1 -1
  75. package/esm/utils/Animation.js +1 -1
  76. package/esm/utils/ColorScale.js +1 -1
  77. package/esm/utils/DataSchema.js +1 -1
  78. package/esm/utils/DataScope.js +1 -1
  79. package/esm/utils/RootClose.js +1 -1
  80. package/esm/utils/SimpleMap.js +1 -1
  81. package/esm/utils/api.d.ts +3 -3
  82. package/esm/utils/api.js +3 -2
  83. package/esm/utils/arraySlice.js +1 -1
  84. package/esm/utils/attachmentAdpator.js +1 -1
  85. package/esm/utils/autobind.js +1 -1
  86. package/esm/utils/columnsSplit.js +1 -1
  87. package/esm/utils/dataMapping.js +1 -1
  88. package/esm/utils/date.js +1 -1
  89. package/esm/utils/debug.d.ts +1 -0
  90. package/esm/utils/debug.js +24 -2
  91. package/esm/utils/decodeEntity.js +1 -1
  92. package/esm/utils/dom.js +1 -1
  93. package/esm/utils/errors.js +1 -1
  94. package/esm/utils/escapeHtml.js +1 -1
  95. package/esm/utils/filter-schema.js +1 -1
  96. package/esm/utils/filter.js +1 -1
  97. package/esm/utils/formatDuration.js +1 -1
  98. package/esm/utils/formula.js +1 -1
  99. package/esm/utils/getVariable.js +1 -1
  100. package/esm/utils/grammar.js +1 -1
  101. package/esm/utils/handleAction.js +1 -1
  102. package/esm/utils/helper.d.ts +13 -1
  103. package/esm/utils/helper.js +99 -5
  104. package/esm/utils/highlight.js +1 -1
  105. package/esm/utils/icon.js +1 -1
  106. package/esm/utils/image.js +1 -1
  107. package/esm/utils/isPureVariable.js +1 -1
  108. package/esm/utils/json-schema-2-amis-schema.js +1 -1
  109. package/esm/utils/keyToPath.d.ts +1 -1
  110. package/esm/utils/keyToPath.js +2 -1
  111. package/esm/utils/makeSorter.js +1 -1
  112. package/esm/utils/math.js +1 -1
  113. package/esm/utils/memoryParse.js +1 -1
  114. package/esm/utils/normalizeLink.js +1 -1
  115. package/esm/utils/normalizeOptions.js +1 -1
  116. package/esm/utils/object.js +1 -1
  117. package/esm/utils/offset.js +1 -1
  118. package/esm/utils/offsetParent.js +1 -1
  119. package/esm/utils/optionValueCompare.js +1 -1
  120. package/esm/utils/position.js +1 -1
  121. package/esm/utils/prettyBytes.js +1 -1
  122. package/esm/utils/renderer-event.js +2 -2
  123. package/esm/utils/replaceText.js +1 -1
  124. package/esm/utils/resize-sensor.d.ts +3 -1
  125. package/esm/utils/resize-sensor.js +34 -22
  126. package/esm/utils/resolveCondition.js +1 -1
  127. package/esm/utils/resolveVariable.js +1 -1
  128. package/esm/utils/resolveVariableAndFilter.js +1 -1
  129. package/esm/utils/resolveVariableAndFilterForAsync.js +1 -1
  130. package/esm/utils/scrollPosition.js +1 -1
  131. package/esm/utils/string2regExp.js +1 -1
  132. package/esm/utils/stripNumber.js +1 -1
  133. package/esm/utils/style-helper.d.ts +22 -14
  134. package/esm/utils/style-helper.js +181 -120
  135. package/esm/utils/style.js +1 -1
  136. package/esm/utils/toNumber.js +1 -1
  137. package/esm/utils/tokenize.js +1 -1
  138. package/esm/utils/tpl-builtin.js +1 -1
  139. package/esm/utils/tpl-lodash.js +1 -1
  140. package/esm/utils/tpl.js +1 -1
  141. package/esm/utils/uncontrollable.js +1 -1
  142. package/esm/utils/validations.js +1 -1
  143. package/lib/Root.js +1 -1
  144. package/lib/RootRenderer.js +8 -8
  145. package/lib/SchemaRenderer.js +16 -12
  146. package/lib/Scoped.js +3 -1
  147. package/lib/StatusScoped.js +1 -1
  148. package/lib/WithRootStore.js +1 -1
  149. package/lib/WithStore.js +9 -8
  150. package/lib/actions/Action.js +1 -1
  151. package/lib/actions/AjaxAction.js +2 -2
  152. package/lib/actions/BreakAction.js +1 -1
  153. package/lib/actions/BroadcastAction.js +1 -1
  154. package/lib/actions/CmptAction.js +1 -1
  155. package/lib/actions/ContinueAction.js +1 -1
  156. package/lib/actions/CopyAction.js +1 -1
  157. package/lib/actions/CustomAction.js +3 -1
  158. package/lib/actions/DialogAction.js +1 -1
  159. package/lib/actions/DrawerAction.js +5 -1
  160. package/lib/actions/EmailAction.js +1 -1
  161. package/lib/actions/LinkAction.js +1 -1
  162. package/lib/actions/LoopAction.js +1 -1
  163. package/lib/actions/PageAction.js +1 -1
  164. package/lib/actions/ParallelAction.js +1 -1
  165. package/lib/actions/StatusAction.js +1 -1
  166. package/lib/actions/SwitchAction.js +1 -1
  167. package/lib/actions/ToastAction.js +1 -1
  168. package/lib/components/CustomStyle.d.ts +5 -6
  169. package/lib/components/CustomStyle.js +46 -4
  170. package/lib/components/LazyComponent.d.ts +1 -2
  171. package/lib/components/LazyComponent.js +12 -9
  172. package/lib/components/Overlay.js +3 -1
  173. package/lib/components/PopOver.d.ts +12 -12
  174. package/lib/components/PopOver.js +3 -1
  175. package/lib/env.d.ts +2 -2
  176. package/lib/env.js +1 -1
  177. package/lib/envOverwrite.js +1 -1
  178. package/lib/factory.d.ts +7 -7
  179. package/lib/factory.js +1 -1
  180. package/lib/index.js +11 -3
  181. package/lib/locale.d.ts +1 -1
  182. package/lib/locale.js +3 -3
  183. package/lib/polyfills.js +1 -1
  184. package/lib/renderers/Form.d.ts +1 -1
  185. package/lib/renderers/Form.js +10 -8
  186. package/lib/renderers/Item.d.ts +24 -56
  187. package/lib/renderers/Item.js +26 -31
  188. package/lib/renderers/Options.js +14 -12
  189. package/lib/renderers/Placeholder.js +1 -1
  190. package/lib/renderers/builtin.js +1 -1
  191. package/lib/renderers/register.js +1 -1
  192. package/lib/renderers/wrapControl.js +70 -79
  193. package/lib/store/app.js +3 -1
  194. package/lib/store/combo.d.ts +384 -0
  195. package/lib/store/combo.js +1 -1
  196. package/lib/store/crud.js +31 -25
  197. package/lib/store/form.d.ts +160 -0
  198. package/lib/store/form.js +15 -13
  199. package/lib/store/formItem.d.ts +4 -0
  200. package/lib/store/formItem.js +41 -25
  201. package/lib/store/iRenderer.js +3 -1
  202. package/lib/store/index.js +1 -1
  203. package/lib/store/list.js +1 -1
  204. package/lib/store/manager.js +1 -1
  205. package/lib/store/modal.js +1 -1
  206. package/lib/store/node.js +1 -1
  207. package/lib/store/pagination.js +1 -1
  208. package/lib/store/root.d.ts +1 -1
  209. package/lib/store/root.js +11 -4
  210. package/lib/store/service.js +38 -33
  211. package/lib/store/status.js +1 -1
  212. package/lib/store/table.d.ts +760 -21
  213. package/lib/store/table.js +157 -57
  214. package/lib/store/table2.js +11 -8
  215. package/lib/theme.d.ts +18 -31
  216. package/lib/theme.js +1 -1
  217. package/lib/utils/Animation.js +1 -1
  218. package/lib/utils/ColorScale.js +1 -1
  219. package/lib/utils/DataSchema.js +1 -1
  220. package/lib/utils/DataScope.js +1 -1
  221. package/lib/utils/RootClose.js +1 -1
  222. package/lib/utils/SimpleMap.js +1 -1
  223. package/lib/utils/api.d.ts +3 -3
  224. package/lib/utils/api.js +3 -2
  225. package/lib/utils/arraySlice.js +1 -1
  226. package/lib/utils/attachmentAdpator.js +1 -1
  227. package/lib/utils/autobind.js +1 -1
  228. package/lib/utils/columnsSplit.js +1 -1
  229. package/lib/utils/dataMapping.js +1 -1
  230. package/lib/utils/date.js +1 -1
  231. package/lib/utils/debug.d.ts +1 -0
  232. package/lib/utils/debug.js +24 -1
  233. package/lib/utils/decodeEntity.js +1 -1
  234. package/lib/utils/dom.js +1 -1
  235. package/lib/utils/errors.js +1 -1
  236. package/lib/utils/escapeHtml.js +1 -1
  237. package/lib/utils/filter-schema.js +1 -1
  238. package/lib/utils/filter.js +1 -1
  239. package/lib/utils/formatDuration.js +1 -1
  240. package/lib/utils/formula.js +1 -1
  241. package/lib/utils/getVariable.js +1 -1
  242. package/lib/utils/grammar.js +1 -1
  243. package/lib/utils/handleAction.js +1 -1
  244. package/lib/utils/helper.d.ts +13 -1
  245. package/lib/utils/helper.js +101 -4
  246. package/lib/utils/highlight.js +1 -1
  247. package/lib/utils/icon.js +1 -1
  248. package/lib/utils/image.js +1 -1
  249. package/lib/utils/isPureVariable.js +1 -1
  250. package/lib/utils/json-schema-2-amis-schema.js +1 -1
  251. package/lib/utils/keyToPath.d.ts +1 -1
  252. package/lib/utils/keyToPath.js +2 -1
  253. package/lib/utils/makeSorter.js +1 -1
  254. package/lib/utils/math.js +1 -1
  255. package/lib/utils/memoryParse.js +1 -1
  256. package/lib/utils/normalizeLink.js +1 -1
  257. package/lib/utils/normalizeOptions.js +1 -1
  258. package/lib/utils/object.js +1 -1
  259. package/lib/utils/offset.js +1 -1
  260. package/lib/utils/offsetParent.js +1 -1
  261. package/lib/utils/optionValueCompare.js +1 -1
  262. package/lib/utils/position.js +1 -1
  263. package/lib/utils/prettyBytes.js +1 -1
  264. package/lib/utils/renderer-event.js +2 -2
  265. package/lib/utils/replaceText.js +1 -1
  266. package/lib/utils/resize-sensor.d.ts +3 -1
  267. package/lib/utils/resize-sensor.js +34 -22
  268. package/lib/utils/resolveCondition.js +1 -1
  269. package/lib/utils/resolveVariable.js +1 -1
  270. package/lib/utils/resolveVariableAndFilter.js +1 -1
  271. package/lib/utils/resolveVariableAndFilterForAsync.js +1 -1
  272. package/lib/utils/scrollPosition.js +1 -1
  273. package/lib/utils/string2regExp.js +1 -1
  274. package/lib/utils/stripNumber.js +1 -1
  275. package/lib/utils/style-helper.d.ts +22 -14
  276. package/lib/utils/style-helper.js +188 -120
  277. package/lib/utils/style.js +1 -1
  278. package/lib/utils/toNumber.js +1 -1
  279. package/lib/utils/tokenize.js +1 -1
  280. package/lib/utils/tpl-builtin.js +1 -1
  281. package/lib/utils/tpl-lodash.js +1 -1
  282. package/lib/utils/tpl.js +1 -1
  283. package/lib/utils/uncontrollable.js +1 -1
  284. package/lib/utils/validations.js +1 -1
  285. package/package.json +5 -5
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.4.0
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
- this.q.push(cb);
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 = 0; _i < arguments.length; _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 (fn) {
29
- fn.apply(void 0, tslib.__spreadArray([], tslib.__read(args), false));
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
- if (element.offsetWidth != lastWidth ||
120
- element.offsetHeight != lastHeight) {
121
- changed();
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)
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.4.0
2
+ * amis-core v3.4.2
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.4.0
2
+ * amis-core v3.4.2
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.4.0
2
+ * amis-core v3.4.2
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.4.0
2
+ * amis-core v3.4.2
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.4.0
2
+ * amis-core v3.4.2
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.4.0
2
+ * amis-core v3.4.2
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.4.0
2
+ * amis-core v3.4.2
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -7,19 +7,10 @@ interface extra {
7
7
  pre?: string;
8
8
  suf?: string;
9
9
  }
10
- export declare function findOrCreactStyle(id: string): HTMLElement;
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?: string, defaultData?: any, customStyleClassPrefix?: string): void;
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.0
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 findOrCreactStyle(id) {
48
- var varStyleTag = document.getElementById(id);
53
+ function findOrCreateStyle(id, doc) {
54
+ doc = doc || document;
55
+ var varStyleTag = doc.getElementById(id);
49
56
  if (!varStyleTag) {
50
- varStyleTag = document.createElement('style');
57
+ varStyleTag = doc.createElement('style');
51
58
  varStyleTag.id = id;
52
- document.body.appendChild(varStyleTag);
59
+ doc.body.appendChild(varStyleTag);
53
60
  }
54
61
  return varStyleTag;
55
62
  }
56
- function insertStyle(style, id) {
57
- var varStyleTag = findOrCreactStyle(id);
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 = findOrCreactStyle(id);
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
- for (var key in statusMap[status]) {
83
+ Object.keys(statusMap[status]).forEach(function (key) {
74
84
  if (typeof statusMap[status][key] === 'object') {
75
- for (var style in statusMap[status][key]) {
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
- var _b;
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
- list === null || list === void 0 ? void 0 : list.forEach(function (n) {
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
- try {
132
- for (var classNameList_1 = (e_2 = void 0, tslib.__values(classNameList)), classNameList_1_1 = classNameList_1.next(); !classNameList_1_1.done; classNameList_1_1 = classNameList_1.next()) {
133
- var className = classNameList_1_1.value;
134
- // 没有具体的样式,或者没有对应的classname
135
- var statusMap = {
136
- default: {},
137
- hover: {},
138
- active: {},
139
- disabled: {}
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
- handleInheritData(statusMap, defaultData);
162
- var _loop_2 = function (status_1) {
163
- var weights = weightsList[status_1];
164
- var styles = [];
165
- var fn = function (key, value) {
166
- key = valueMap[key] || key;
167
- styles.push("".concat(key, ": ").concat(value, ";"));
168
- };
169
- for (var key in statusMap[status_1]) {
170
- if (key === '$$id') {
171
- continue;
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
- var style = statusMap[status_1][key];
174
- if (typeof style === 'object') {
175
- // 圆角特殊处理
176
- if (key === 'radius') {
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
- var value = style;
196
- if (key === 'iconSize') {
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, (id === null || id === void 0 ? void 0 : id.replace('u:', '')) || helper.uuid());
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.findOrCreactStyle = findOrCreactStyle;
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;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.4.0
2
+ * amis-core v3.4.2
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.4.0
2
+ * amis-core v3.4.2
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5