shineout 1.12.6-beta.4 → 1.12.6-beta.6

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.
@@ -223,8 +223,7 @@ export interface CascaderProps<Item, Value> extends StandardProps, FormItemStand
223
223
  }
224
224
 
225
225
  interface componentRef {
226
- close: () => void;
227
- [propName: string]: any;
226
+ close: () => void
228
227
  }
229
228
 
230
229
  declare class Cascader<Item = any, Value = string[]> extends React.Component<CascaderProps<Item, Value>, {}> {
@@ -317,10 +317,11 @@ function (_Component) {
317
317
  type = _this$props3.type,
318
318
  visible = _this$props3.visible,
319
319
  showArrow = _this$props3.showArrow,
320
- useTextStyle = _this$props3.useTextStyle;
320
+ useTextStyle = _this$props3.useTextStyle,
321
+ destroy = _this$props3.destroy;
321
322
  var show = typeof visible === 'boolean' ? visible : this.state.show;
322
323
 
323
- if (!this.isRendered && !show || !this.parentElement || !children) {
324
+ if ((!this.isRendered || destroy) && !show || !this.parentElement || !children) {
324
325
  return _react.default.createElement("noscript", {
325
326
  ref: this.placeholderRef
326
327
  });
@@ -396,7 +397,8 @@ Panel.propTypes = {
396
397
  bindChain: _propTypes.default.func,
397
398
  zIndex: _propTypes.default.number,
398
399
  clickToCancelDelay: _propTypes.default.bool,
399
- useTextStyle: _propTypes.default.bool
400
+ useTextStyle: _propTypes.default.bool,
401
+ destroy: _propTypes.default.bool
400
402
  };
401
403
  Panel.defaultProps = {
402
404
  background: '',
@@ -29,8 +29,11 @@ function hide(delay) {
29
29
  }
30
30
 
31
31
  timer = setTimeout(function () {
32
- div.style.display = 'none';
33
- div.className = '';
32
+ if (div) {
33
+ div.style.display = 'none';
34
+ div.className = '';
35
+ }
36
+
34
37
  currentId = undefined;
35
38
  }, delay);
36
39
  }
@@ -235,6 +235,14 @@ export interface PopoverConfirmProps extends PopoverProps{
235
235
  * default: -
236
236
  */
237
237
  useTextStyle?: boolean;
238
+ /**
239
+ * delete dom when close
240
+ *
241
+ * 关闭 Popover 后销毁 dom
242
+ *
243
+ * default: -
244
+ */
245
+ destroy?: boolean;
238
246
  }
239
247
 
240
248
  declare class PopoverConfirm extends React.Component<PopoverConfirmProps, {}> {
package/css/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import * as utils from './utils'
3
3
 
4
4
  declare const __default: {
5
5
  utils: typeof utils,
6
- version: '1.12.6-beta.4'
6
+ version: '1.12.6-beta.6'
7
7
  }
8
8
 
9
9
  export default __default
package/css/index.js CHANGED
@@ -224,6 +224,6 @@ exports.Upload = _Upload.default;
224
224
  // Created by scripts/src-index.js.
225
225
  var _default = {
226
226
  utils: utils,
227
- version: '1.12.6-beta.4'
227
+ version: '1.12.6-beta.6'
228
228
  };
229
229
  exports.default = _default;
@@ -64,7 +64,12 @@ function resetTheme() {
64
64
  });
65
65
  }
66
66
 
67
- function setStyleWithTag(options, custom) {
67
+ function setStyle(options, custom, config) {
68
+ if (config === void 0) {
69
+ config = {};
70
+ }
71
+
72
+ (0, _varsInject.setThemeConfig)(config);
68
73
  (0, _varsInject.cleanStyleObj)();
69
74
 
70
75
  if (!options) {
@@ -90,45 +95,19 @@ function setStyleWithTag(options, custom) {
90
95
  }
91
96
  }
92
97
 
93
- (0, _varsInject.injectTag)(custom);
98
+ if (config.injectType === 'tag') {
99
+ var id = (0, _varsInject.injectTag)(custom);
100
+ return function () {
101
+ document.getElementById(id).remove();
102
+ };
103
+ }
104
+
105
+ return function () {};
94
106
  }
95
107
 
96
108
  var style = {
97
109
  getClassname: getClassname,
98
- setStyle: function setStyle(options, custom) {
99
- if (custom === void 0) {
100
- custom = {};
101
- }
102
-
103
- if ((0, _varsInject.getInjectType)() === 'tag') {
104
- setStyleWithTag(options, custom);
105
- return;
106
- }
107
-
108
- if (!options) {
109
- resetTheme();
110
- return;
111
- }
112
-
113
- for (var _iterator2 = (0, _objects.entries)(options), _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
114
- var _ref3;
115
-
116
- if (_isArray2) {
117
- if (_i2 >= _iterator2.length) break;
118
- _ref3 = _iterator2[_i2++];
119
- } else {
120
- _i2 = _iterator2.next();
121
- if (_i2.done) break;
122
- _ref3 = _i2.value;
123
- }
124
-
125
- var _ref4 = _ref3,
126
- key = _ref4[0],
127
- values = _ref4[1];
128
- var setterName = "set" + (0, _strings.capitalize)(key);
129
- if (_cssAccessors.default[key] && _cssAccessors.default[key][setterName]) _cssAccessors.default[key][setterName](values);
130
- }
131
- },
110
+ setStyle: setStyle,
132
111
  cleanCache: _cssAccessors.cleanCache,
133
112
  setInjectType: _varsInject.setInjectType,
134
113
  getInjectType: _varsInject.getInjectType
@@ -5,6 +5,9 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  exports.__esModule = true;
6
6
  exports.getInjectType = getInjectType;
7
7
  exports.setInjectType = setInjectType;
8
+ exports.setThemeConfig = setThemeConfig;
9
+ exports.getThemeConfig = getThemeConfig;
10
+ exports.getThemeTarget = getThemeTarget;
8
11
  exports.cleanStyleObj = cleanStyleObj;
9
12
  exports.injectTag = injectTag;
10
13
  exports.default = void 0;
@@ -17,6 +20,10 @@ var _config = require("../config");
17
20
 
18
21
  var _objects = require("./objects");
19
22
 
23
+ var _is = require("./is");
24
+
25
+ var _hash = _interopRequireDefault(require("./hash"));
26
+
20
27
  var _styles = require("../Pagination/styles");
21
28
 
22
29
  var _styles2 = require("../Checkbox/styles");
@@ -53,16 +60,50 @@ var _styles17 = require("../Tag/styles");
53
60
 
54
61
  var _expose = require("../styles/expose");
55
62
 
63
+ var config = {
64
+ injectType: 'body',
65
+ target: undefined
66
+ };
56
67
  var computedCache = {};
57
- var injectType = 'body';
58
68
  var styleObj = {};
59
69
 
60
70
  function getInjectType() {
61
- return injectType;
71
+ return config.injectType;
62
72
  }
63
73
 
64
74
  function setInjectType(type) {
65
- injectType = type;
75
+ config.injectType = type;
76
+ }
77
+
78
+ function setThemeConfig(c) {
79
+ if (c === void 0) {
80
+ c = {};
81
+ }
82
+
83
+ Object.keys(c).forEach(function (key) {
84
+ if (key in config) {
85
+ config[key] = c[key];
86
+ }
87
+ });
88
+ }
89
+
90
+ function getThemeConfig(name) {
91
+ return config[name];
92
+ }
93
+
94
+ function getThemeTarget() {
95
+ var target = config.target;
96
+ if (!target) return document.body;
97
+
98
+ if ((0, _is.isFunc)(target)) {
99
+ target = config.target();
100
+ } else if (typeof target === 'string') {
101
+ target = document.querySelector(target);
102
+ }
103
+
104
+ if (target instanceof HTMLElement) return target;
105
+ console.error("can not find theme target dom from \"" + config.target + "\"");
106
+ return document.body;
66
107
  }
67
108
 
68
109
  function cleanStyleObj() {
@@ -74,9 +115,15 @@ function injectTag(custom) {
74
115
  custom = {};
75
116
  }
76
117
 
77
- var id = '__shineoutThemeStyleContainer__';
78
- var styleText = "body{" + Object.keys((0, _objectSpread2.default)({}, styleObj, custom)).map(function (key) {
79
- return key + ": " + styleObj[key];
118
+ if (config.target && typeof config.target !== 'string') {
119
+ console.error('The target of themeConfig must use string when injectType = "tag"');
120
+ }
121
+
122
+ var selector = config.target || 'body';
123
+ var id = "__shineoutThemeStyleContainer__" + (0, _hash.default)(selector);
124
+ var varObj = (0, _objectSpread2.default)({}, styleObj, custom);
125
+ var styleText = selector + "{" + Object.keys(varObj).map(function (key) {
126
+ return key + ": " + varObj[key];
80
127
  }).join(';') + "}";
81
128
  var el = document.getElementById(id);
82
129
 
@@ -89,6 +136,8 @@ function injectTag(custom) {
89
136
  stylee.innerText = styleText;
90
137
  document.head.appendChild(stylee);
91
138
  }
139
+
140
+ return id;
92
141
  }
93
142
 
94
143
  function getProperty(name, cache) {
@@ -122,15 +171,17 @@ function setBodyProperty(colors, value) {
122
171
  cssVar = _ref2[0],
123
172
  cssValue = _ref2[1];
124
173
 
125
- if (injectType === 'body') {
174
+ if (config.injectType === 'body') {
175
+ var target = getThemeTarget();
176
+
126
177
  if (value === undefined) {
127
- document.body.style.removeProperty(cssVar);
178
+ target.style.removeProperty(cssVar);
128
179
  } else {
129
- document.body.style.setProperty(cssVar, cssValue);
180
+ target.style.setProperty(cssVar, cssValue);
130
181
  }
131
182
  }
132
183
 
133
- if (injectType === 'tag') {
184
+ if (config.injectType === 'tag') {
134
185
  if (value === undefined) {
135
186
  delete styleObj[cssVar];
136
187
  } else {