shineout 1.9.6 → 1.9.7

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.
@@ -77,21 +77,7 @@ function (_PureComponent) {
77
77
  };
78
78
 
79
79
  _proto.componentDidUpdate = function componentDidUpdate(preProps) {
80
- var _this$props = this.props,
81
- compressed = _this$props.compressed,
82
- _this$props$value = _this$props.value,
83
- value = _this$props$value === void 0 ? [] : _this$props$value,
84
- onFilter = _this$props.onFilter;
85
-
86
- if (compressed) {
87
- if ((preProps.value || []).join('') !== (value || []).join('')) {
88
- this.resetMore();
89
- } else if (value.length && this.shouldResetMore) {
90
- this.shouldResetMore = false;
91
- this.state.more = getResetMore(onFilter, this.resultEl, this.resultEl.querySelectorAll("." + cascaderClass('item')));
92
- this.forceUpdate();
93
- }
94
- }
80
+ this.updateMore(preProps);
95
81
  };
96
82
 
97
83
  _proto.componentWillUnmount = function componentWillUnmount() {
@@ -108,6 +94,27 @@ function (_PureComponent) {
108
94
  this.resultEl = el;
109
95
  };
110
96
 
97
+ _proto.updateMore = function updateMore(preProps) {
98
+ var _this$props = this.props,
99
+ compressed = _this$props.compressed,
100
+ _this$props$value = _this$props.value,
101
+ value = _this$props$value === void 0 ? [] : _this$props$value,
102
+ onFilter = _this$props.onFilter,
103
+ data = _this$props.data;
104
+
105
+ if (compressed) {
106
+ if ((preProps.value || []).join('') !== (value || []).join('')) {
107
+ this.resetMore();
108
+ } else if ((preProps.data || []).length !== (data || []).length) {
109
+ this.resetMore();
110
+ } else if (value.length && this.shouldResetMore) {
111
+ this.shouldResetMore = false;
112
+ this.state.more = getResetMore(onFilter, this.resultEl, this.resultEl.querySelectorAll("." + cascaderClass('item')));
113
+ this.forceUpdate();
114
+ }
115
+ }
116
+ };
117
+
111
118
  _proto.resetMore = function resetMore() {
112
119
  if (!this.props.compressed) return;
113
120
  this.shouldResetMore = true;
@@ -361,7 +368,8 @@ Result.propTypes = {
361
368
  selectId: PropTypes.string,
362
369
  showList: PropTypes.func,
363
370
  size: PropTypes.string,
364
- showArrow: PropTypes.bool
371
+ showArrow: PropTypes.bool,
372
+ data: PropTypes.array
365
373
  };
366
374
  Result.defaultProps = {
367
375
  value: []
@@ -263,7 +263,14 @@ export interface DatePickerProps<T =DatePickerValue > extends StandardProps,
263
263
  * default: -
264
264
  */
265
265
  innerTitle?: ReactNode;
266
- name: string | string[]
266
+ /**
267
+ * The name of a Form that accesses data
268
+ *
269
+ * Form 存取数据的名称
270
+ *
271
+ * default: -
272
+ */
273
+ name?: string | string[]
267
274
  }
268
275
 
269
276
  declare class DatePicker extends React.Component<DatePickerProps, {}> {
@@ -62,7 +62,7 @@ export interface RuleResult {
62
62
 
63
63
  range(min?: number, max?: number, message?: string): Range;
64
64
 
65
- regExp(reg?: RegExp | string): RegExpParams;
65
+ regExp(reg?: RegExp | string, message?: string): RegExpParams;
66
66
 
67
67
  email(message?: string): Type;
68
68
 
package/es/Select/More.js CHANGED
@@ -4,7 +4,8 @@ import React, { Component } from 'react';
4
4
  import PropTypes from 'prop-types';
5
5
  import classnames from 'classnames';
6
6
  import { parsePxToNumber } from '../utils/dom/element';
7
- import Popover from '../Popover';
7
+ import Popover from '../Popover'; // if num = -1 display all else display num
8
+
8
9
  export function getResetMore(onFilter, container, doms) {
9
10
  if (!container || !doms || !doms.length) return -1;
10
11
  var items = Array.from(doms);
@@ -34,10 +35,18 @@ export function getResetMore(onFilter, container, doms) {
34
35
  for (var i = 0; i < itemWidthArr.length; i++) {
35
36
  var itemLen = itemWidthArr[i]; // number length
36
37
 
37
- var reset = "+" + (items.length - 1 - i);
38
- hideEl.childNodes[0].innerText = reset; // (+num) width
38
+ var resetNum = items.length - 1 - i;
39
+ var moreWidth = void 0;
40
+
41
+ if (resetNum <= 0) {
42
+ moreWidth = 0;
43
+ } else {
44
+ var reset = "+" + resetNum;
45
+ hideEl.childNodes[0].innerText = reset; // (+num) width
46
+
47
+ moreWidth = hideEl.offsetWidth + hideMargin;
48
+ }
39
49
 
40
- var moreWidth = hideEl.offsetWidth + hideMargin;
41
50
  len += itemLen;
42
51
 
43
52
  if (len > contentWidth - moreWidth) {
@@ -97,7 +106,7 @@ function (_Component) {
97
106
  cls = _this$props.cls,
98
107
  showNum = _this$props.showNum;
99
108
  var status = this.state.status;
100
- if (showNum < 0 || showNum > data.length) return React.createElement(React.Fragment, null, data, React.createElement("a", {
109
+ if (showNum < 0 || showNum >= data.length) return React.createElement(React.Fragment, null, data, React.createElement("a", {
101
110
  key: "hidden",
102
111
  className: className,
103
112
  style: {
@@ -99,13 +99,47 @@ function (_PureComponent) {
99
99
  };
100
100
 
101
101
  _proto.componentDidUpdate = function componentDidUpdate(preProps) {
102
+ this.updateMore(preProps);
103
+ };
104
+
105
+ _proto.componentWillUnmount = function componentWillUnmount() {
106
+ if (this.cancelResizeObserver) this.cancelResizeObserver();
107
+ };
108
+
109
+ _proto.bindResult = function bindResult(el) {
110
+ this.resultEl = el;
111
+ };
112
+
113
+ _proto.updateMore = function updateMore(preProps) {
102
114
  var _this$props = this.props,
103
115
  result = _this$props.result,
104
116
  compressed = _this$props.compressed,
105
- onFilter = _this$props.onFilter;
117
+ onFilter = _this$props.onFilter,
118
+ renderResult = _this$props.renderResult,
119
+ renderUnmatched = _this$props.renderUnmatched;
106
120
 
107
121
  if (compressed) {
108
- if ((preProps.result || []).join('') !== (result || []).join('')) {
122
+ var shouldRest = false;
123
+
124
+ if (preProps.result.length !== result.length) {
125
+ shouldRest = true;
126
+ } else {
127
+ var i = preProps.result.length - 1;
128
+
129
+ while (i >= 0) {
130
+ var before = getResultContent(preProps.result[i], preProps.renderResult, preProps.renderUnmatched);
131
+ var now = getResultContent(result[i], renderResult, renderUnmatched);
132
+
133
+ if (before !== now) {
134
+ shouldRest = true;
135
+ break;
136
+ }
137
+
138
+ i -= 1;
139
+ }
140
+ }
141
+
142
+ if (shouldRest) {
109
143
  this.resetMore();
110
144
  } else if (result.length && this.shouldResetMore) {
111
145
  this.shouldResetMore = false;
@@ -115,14 +149,6 @@ function (_PureComponent) {
115
149
  }
116
150
  };
117
151
 
118
- _proto.componentWillUnmount = function componentWillUnmount() {
119
- if (this.cancelResizeObserver) this.cancelResizeObserver();
120
- };
121
-
122
- _proto.bindResult = function bindResult(el) {
123
- this.resultEl = el;
124
- };
125
-
126
152
  _proto.resetMore = function resetMore() {
127
153
  if (!this.props.compressed) return;
128
154
  this.shouldResetMore = true;
@@ -124,7 +124,7 @@ export interface ColumnItem<T> {
124
124
  *
125
125
  * default: none
126
126
  */
127
- sorter?: ((order: ColumnOrder) => (prevRowData: T, nextRowData: T) => boolean) | string;
127
+ sorter?: ((order: ColumnOrder) => (prevRowData: T, nextRowData: T) => number) | string;
128
128
 
129
129
  /**
130
130
  * The content of the header
@@ -552,7 +552,7 @@ export interface TableProps<Value, TRD> extends StandardProps, ListItemStandardP
552
552
  * default: false
553
553
  */
554
554
  changedByExpand?: boolean
555
-
555
+
556
556
  /*
557
557
  * customize sort icons
558
558
  *
@@ -76,13 +76,47 @@ function (_PureComponent) {
76
76
  };
77
77
 
78
78
  _proto.componentDidUpdate = function componentDidUpdate(preProps) {
79
+ this.updateMore(preProps);
80
+ };
81
+
82
+ _proto.componentWillUnmount = function componentWillUnmount() {
83
+ if (this.cancelResizeObserver) this.cancelResizeObserver();
84
+ };
85
+
86
+ _proto.bindResult = function bindResult(el) {
87
+ this.resultEl = el;
88
+ };
89
+
90
+ _proto.updateMore = function updateMore(preProps) {
79
91
  var _this$props = this.props,
80
92
  result = _this$props.result,
81
93
  compressed = _this$props.compressed,
82
- onFilter = _this$props.onFilter;
94
+ onFilter = _this$props.onFilter,
95
+ renderResult = _this$props.renderResult,
96
+ renderUnmatched = _this$props.renderUnmatched;
83
97
 
84
98
  if (compressed) {
85
- if ((preProps.result || []).join('') !== (result || []).join('')) {
99
+ var shouldRest = false;
100
+
101
+ if (preProps.result.length !== result.length) {
102
+ shouldRest = true;
103
+ } else {
104
+ var i = preProps.result.length - 1;
105
+
106
+ while (i >= 0) {
107
+ var before = getResultContent(preProps.result[i], preProps.renderResult, preProps.renderUnmatched);
108
+ var now = getResultContent(result[i], renderResult, renderUnmatched);
109
+
110
+ if (before !== now) {
111
+ shouldRest = true;
112
+ break;
113
+ }
114
+
115
+ i -= 1;
116
+ }
117
+ }
118
+
119
+ if (shouldRest) {
86
120
  this.resetMore();
87
121
  } else if (result.length && this.shouldResetMore) {
88
122
  this.shouldResetMore = false;
@@ -92,14 +126,6 @@ function (_PureComponent) {
92
126
  }
93
127
  };
94
128
 
95
- _proto.componentWillUnmount = function componentWillUnmount() {
96
- if (this.cancelResizeObserver) this.cancelResizeObserver();
97
- };
98
-
99
- _proto.bindResult = function bindResult(el) {
100
- this.resultEl = el;
101
- };
102
-
103
129
  _proto.resetMore = function resetMore() {
104
130
  if (!this.props.compressed) return;
105
131
  this.shouldResetMore = true;
package/es/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  // Created by scripts/src-index.js.
2
2
  import * as utils from './utils'
3
3
 
4
- export default { utils, version: '1.9.6' }
4
+ export default { utils, version: '1.9.7' }
5
5
  export { utils }
6
6
  export { setLocale } from './locale'
7
7
  export { color, style } from './utils/expose'
package/es/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import * as utils from './utils';
3
3
  export default {
4
4
  utils: utils,
5
- version: '1.9.6'
5
+ version: '1.9.7'
6
6
  };
7
7
  export { utils };
8
8
  export { setLocale } from './locale';
@@ -103,21 +103,7 @@ function (_PureComponent) {
103
103
  };
104
104
 
105
105
  _proto.componentDidUpdate = function componentDidUpdate(preProps) {
106
- var _this$props = this.props,
107
- compressed = _this$props.compressed,
108
- _this$props$value = _this$props.value,
109
- value = _this$props$value === void 0 ? [] : _this$props$value,
110
- onFilter = _this$props.onFilter;
111
-
112
- if (compressed) {
113
- if ((preProps.value || []).join('') !== (value || []).join('')) {
114
- this.resetMore();
115
- } else if (value.length && this.shouldResetMore) {
116
- this.shouldResetMore = false;
117
- this.state.more = (0, _More.getResetMore)(onFilter, this.resultEl, this.resultEl.querySelectorAll("." + (0, _styles3.cascaderClass)('item')));
118
- this.forceUpdate();
119
- }
120
- }
106
+ this.updateMore(preProps);
121
107
  };
122
108
 
123
109
  _proto.componentWillUnmount = function componentWillUnmount() {
@@ -134,6 +120,27 @@ function (_PureComponent) {
134
120
  this.resultEl = el;
135
121
  };
136
122
 
123
+ _proto.updateMore = function updateMore(preProps) {
124
+ var _this$props = this.props,
125
+ compressed = _this$props.compressed,
126
+ _this$props$value = _this$props.value,
127
+ value = _this$props$value === void 0 ? [] : _this$props$value,
128
+ onFilter = _this$props.onFilter,
129
+ data = _this$props.data;
130
+
131
+ if (compressed) {
132
+ if ((preProps.value || []).join('') !== (value || []).join('')) {
133
+ this.resetMore();
134
+ } else if ((preProps.data || []).length !== (data || []).length) {
135
+ this.resetMore();
136
+ } else if (value.length && this.shouldResetMore) {
137
+ this.shouldResetMore = false;
138
+ this.state.more = (0, _More.getResetMore)(onFilter, this.resultEl, this.resultEl.querySelectorAll("." + (0, _styles3.cascaderClass)('item')));
139
+ this.forceUpdate();
140
+ }
141
+ }
142
+ };
143
+
137
144
  _proto.resetMore = function resetMore() {
138
145
  if (!this.props.compressed) return;
139
146
  this.shouldResetMore = true;
@@ -386,7 +393,8 @@ Result.propTypes = {
386
393
  selectId: _propTypes.default.string,
387
394
  showList: _propTypes.default.func,
388
395
  size: _propTypes.default.string,
389
- showArrow: _propTypes.default.bool
396
+ showArrow: _propTypes.default.bool,
397
+ data: _propTypes.default.array
390
398
  };
391
399
  Result.defaultProps = {
392
400
  value: []
@@ -263,7 +263,14 @@ export interface DatePickerProps<T =DatePickerValue > extends StandardProps,
263
263
  * default: -
264
264
  */
265
265
  innerTitle?: ReactNode;
266
- name: string | string[]
266
+ /**
267
+ * The name of a Form that accesses data
268
+ *
269
+ * Form 存取数据的名称
270
+ *
271
+ * default: -
272
+ */
273
+ name?: string | string[]
267
274
  }
268
275
 
269
276
  declare class DatePicker extends React.Component<DatePickerProps, {}> {
@@ -62,7 +62,7 @@ export interface RuleResult {
62
62
 
63
63
  range(min?: number, max?: number, message?: string): Range;
64
64
 
65
- regExp(reg?: RegExp | string): RegExpParams;
65
+ regExp(reg?: RegExp | string, message?: string): RegExpParams;
66
66
 
67
67
  email(message?: string): Type;
68
68
 
@@ -22,6 +22,7 @@ var _element = require("../utils/dom/element");
22
22
 
23
23
  var _Popover = _interopRequireDefault(require("../Popover"));
24
24
 
25
+ // if num = -1 display all else display num
25
26
  function getResetMore(onFilter, container, doms) {
26
27
  if (!container || !doms || !doms.length) return -1;
27
28
  var items = Array.from(doms);
@@ -51,10 +52,18 @@ function getResetMore(onFilter, container, doms) {
51
52
  for (var i = 0; i < itemWidthArr.length; i++) {
52
53
  var itemLen = itemWidthArr[i]; // number length
53
54
 
54
- var reset = "+" + (items.length - 1 - i);
55
- hideEl.childNodes[0].innerText = reset; // (+num) width
55
+ var resetNum = items.length - 1 - i;
56
+ var moreWidth = void 0;
57
+
58
+ if (resetNum <= 0) {
59
+ moreWidth = 0;
60
+ } else {
61
+ var reset = "+" + resetNum;
62
+ hideEl.childNodes[0].innerText = reset; // (+num) width
63
+
64
+ moreWidth = hideEl.offsetWidth + hideMargin;
65
+ }
56
66
 
57
- var moreWidth = hideEl.offsetWidth + hideMargin;
58
67
  len += itemLen;
59
68
 
60
69
  if (len > contentWidth - moreWidth) {
@@ -114,7 +123,7 @@ function (_Component) {
114
123
  cls = _this$props.cls,
115
124
  showNum = _this$props.showNum;
116
125
  var status = this.state.status;
117
- if (showNum < 0 || showNum > data.length) return _react.default.createElement(_react.default.Fragment, null, data, _react.default.createElement("a", {
126
+ if (showNum < 0 || showNum >= data.length) return _react.default.createElement(_react.default.Fragment, null, data, _react.default.createElement("a", {
118
127
  key: "hidden",
119
128
  className: className,
120
129
  style: {
@@ -125,13 +125,47 @@ function (_PureComponent) {
125
125
  };
126
126
 
127
127
  _proto.componentDidUpdate = function componentDidUpdate(preProps) {
128
+ this.updateMore(preProps);
129
+ };
130
+
131
+ _proto.componentWillUnmount = function componentWillUnmount() {
132
+ if (this.cancelResizeObserver) this.cancelResizeObserver();
133
+ };
134
+
135
+ _proto.bindResult = function bindResult(el) {
136
+ this.resultEl = el;
137
+ };
138
+
139
+ _proto.updateMore = function updateMore(preProps) {
128
140
  var _this$props = this.props,
129
141
  result = _this$props.result,
130
142
  compressed = _this$props.compressed,
131
- onFilter = _this$props.onFilter;
143
+ onFilter = _this$props.onFilter,
144
+ renderResult = _this$props.renderResult,
145
+ renderUnmatched = _this$props.renderUnmatched;
132
146
 
133
147
  if (compressed) {
134
- if ((preProps.result || []).join('') !== (result || []).join('')) {
148
+ var shouldRest = false;
149
+
150
+ if (preProps.result.length !== result.length) {
151
+ shouldRest = true;
152
+ } else {
153
+ var i = preProps.result.length - 1;
154
+
155
+ while (i >= 0) {
156
+ var before = getResultContent(preProps.result[i], preProps.renderResult, preProps.renderUnmatched);
157
+ var now = getResultContent(result[i], renderResult, renderUnmatched);
158
+
159
+ if (before !== now) {
160
+ shouldRest = true;
161
+ break;
162
+ }
163
+
164
+ i -= 1;
165
+ }
166
+ }
167
+
168
+ if (shouldRest) {
135
169
  this.resetMore();
136
170
  } else if (result.length && this.shouldResetMore) {
137
171
  this.shouldResetMore = false;
@@ -141,14 +175,6 @@ function (_PureComponent) {
141
175
  }
142
176
  };
143
177
 
144
- _proto.componentWillUnmount = function componentWillUnmount() {
145
- if (this.cancelResizeObserver) this.cancelResizeObserver();
146
- };
147
-
148
- _proto.bindResult = function bindResult(el) {
149
- this.resultEl = el;
150
- };
151
-
152
178
  _proto.resetMore = function resetMore() {
153
179
  if (!this.props.compressed) return;
154
180
  this.shouldResetMore = true;
@@ -124,7 +124,7 @@ export interface ColumnItem<T> {
124
124
  *
125
125
  * default: none
126
126
  */
127
- sorter?: ((order: ColumnOrder) => (prevRowData: T, nextRowData: T) => boolean) | string;
127
+ sorter?: ((order: ColumnOrder) => (prevRowData: T, nextRowData: T) => number) | string;
128
128
 
129
129
  /**
130
130
  * The content of the header
@@ -552,7 +552,7 @@ export interface TableProps<Value, TRD> extends StandardProps, ListItemStandardP
552
552
  * default: false
553
553
  */
554
554
  changedByExpand?: boolean
555
-
555
+
556
556
  /*
557
557
  * customize sort icons
558
558
  *
@@ -100,13 +100,47 @@ function (_PureComponent) {
100
100
  };
101
101
 
102
102
  _proto.componentDidUpdate = function componentDidUpdate(preProps) {
103
+ this.updateMore(preProps);
104
+ };
105
+
106
+ _proto.componentWillUnmount = function componentWillUnmount() {
107
+ if (this.cancelResizeObserver) this.cancelResizeObserver();
108
+ };
109
+
110
+ _proto.bindResult = function bindResult(el) {
111
+ this.resultEl = el;
112
+ };
113
+
114
+ _proto.updateMore = function updateMore(preProps) {
103
115
  var _this$props = this.props,
104
116
  result = _this$props.result,
105
117
  compressed = _this$props.compressed,
106
- onFilter = _this$props.onFilter;
118
+ onFilter = _this$props.onFilter,
119
+ renderResult = _this$props.renderResult,
120
+ renderUnmatched = _this$props.renderUnmatched;
107
121
 
108
122
  if (compressed) {
109
- if ((preProps.result || []).join('') !== (result || []).join('')) {
123
+ var shouldRest = false;
124
+
125
+ if (preProps.result.length !== result.length) {
126
+ shouldRest = true;
127
+ } else {
128
+ var i = preProps.result.length - 1;
129
+
130
+ while (i >= 0) {
131
+ var before = getResultContent(preProps.result[i], preProps.renderResult, preProps.renderUnmatched);
132
+ var now = getResultContent(result[i], renderResult, renderUnmatched);
133
+
134
+ if (before !== now) {
135
+ shouldRest = true;
136
+ break;
137
+ }
138
+
139
+ i -= 1;
140
+ }
141
+ }
142
+
143
+ if (shouldRest) {
110
144
  this.resetMore();
111
145
  } else if (result.length && this.shouldResetMore) {
112
146
  this.shouldResetMore = false;
@@ -116,14 +150,6 @@ function (_PureComponent) {
116
150
  }
117
151
  };
118
152
 
119
- _proto.componentWillUnmount = function componentWillUnmount() {
120
- if (this.cancelResizeObserver) this.cancelResizeObserver();
121
- };
122
-
123
- _proto.bindResult = function bindResult(el) {
124
- this.resultEl = el;
125
- };
126
-
127
153
  _proto.resetMore = function resetMore() {
128
154
  if (!this.props.compressed) return;
129
155
  this.shouldResetMore = true;
package/lib/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  // Created by scripts/src-index.js.
2
2
  import * as utils from './utils'
3
3
 
4
- export default { utils, version: '1.9.6' }
4
+ export default { utils, version: '1.9.7' }
5
5
  export { utils }
6
6
  export { setLocale } from './locale'
7
7
  export { color, style } from './utils/expose'
package/lib/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.9.6'
227
+ version: '1.9.7'
228
228
  };
229
229
  exports.default = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shineout",
3
- "version": "1.9.6",
3
+ "version": "1.9.7",
4
4
  "description": "Shein 前端组件库",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./es/index.js",