dtable-ui-component 6.0.24-beta.2 → 6.0.24-beta.3

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.
@@ -0,0 +1,231 @@
1
+ .am-list .am-list-item.am-textarea-item {
2
+ display: -webkit-box;
3
+ display: -webkit-flex;
4
+ display: -ms-flexbox;
5
+ display: flex;
6
+ -webkit-box-align: start;
7
+ -webkit-align-items: flex-start;
8
+ -ms-flex-align: start;
9
+ align-items: flex-start;
10
+ -webkit-box-sizing: border-box;
11
+ box-sizing: border-box;
12
+ min-height: 44px;
13
+ padding-left: 15px;
14
+ padding-right: 15px;
15
+ border-bottom: 1PX solid #ddd;
16
+ }
17
+
18
+ @media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 2dppx) {
19
+ html:not([data-scale]) .am-list .am-list-item.am-textarea-item {
20
+ border-bottom: none;
21
+ }
22
+
23
+ html:not([data-scale]) .am-list .am-list-item.am-textarea-item::after {
24
+ content: '';
25
+ position: absolute;
26
+ background-color: #ddd;
27
+ display: block;
28
+ z-index: 1;
29
+ top: auto;
30
+ right: auto;
31
+ bottom: 0;
32
+ left: 0;
33
+ width: 100%;
34
+ height: 1PX;
35
+ -webkit-transform-origin: 50% 100%;
36
+ -ms-transform-origin: 50% 100%;
37
+ transform-origin: 50% 100%;
38
+ -webkit-transform: scaleY(0.5);
39
+ -ms-transform: scaleY(0.5);
40
+ transform: scaleY(0.5);
41
+ }
42
+ }
43
+
44
+ @media (-webkit-min-device-pixel-ratio: 2) and (-webkit-min-device-pixel-ratio: 3), (min-resolution: 2dppx) and (min-resolution: 3dppx) {
45
+ html:not([data-scale]) .am-list .am-list-item.am-textarea-item::after {
46
+ -webkit-transform: scaleY(0.33);
47
+ -ms-transform: scaleY(0.33);
48
+ transform: scaleY(0.33);
49
+ }
50
+ }
51
+
52
+ .am-list .am-list-item.am-textarea-item.am-textarea-item-single-line {
53
+ -webkit-box-align: center;
54
+ -webkit-align-items: center;
55
+ -ms-flex-align: center;
56
+ align-items: center;
57
+ }
58
+
59
+ .am-list .am-list-item.am-textarea-item.am-textarea-item-single-line .am-textarea-label {
60
+ -webkit-align-self: center;
61
+ -ms-flex-item-align: center;
62
+ align-self: center;
63
+ }
64
+
65
+ .am-list .am-list-item.am-textarea-item.am-textarea-item-single-line .am-textarea-control {
66
+ padding-top: 0;
67
+ padding-bottom: 0;
68
+ }
69
+
70
+ .am-list .am-list-item.am-textarea-item.am-textarea-item-single-line .am-textarea-control textarea {
71
+ line-height: 25.5px;
72
+ }
73
+
74
+ .am-list .am-list-item.am-textarea-item.am-textarea-item-single-line .am-textarea-clear {
75
+ margin-top: 0;
76
+ }
77
+
78
+ .am-list .am-list-item.am-textarea-item.am-textarea-item-single-line.am-textarea-error .am-textarea-error-extra {
79
+ margin-top: 0;
80
+ }
81
+
82
+ .am-textarea-label {
83
+ -webkit-align-self: flex-start;
84
+ -ms-flex-item-align: start;
85
+ align-self: flex-start;
86
+ color: #000;
87
+ text-align: left;
88
+ min-height: 44px;
89
+ font-size: 17px;
90
+ line-height: 44px;
91
+ margin-left: 0;
92
+ margin-right: 5px;
93
+ white-space: nowrap;
94
+ overflow: hidden;
95
+ }
96
+
97
+ .am-textarea-label.am-textarea-label-2 {
98
+ width: 34px;
99
+ }
100
+
101
+ .am-textarea-label.am-textarea-label-3 {
102
+ width: 51px;
103
+ }
104
+
105
+ .am-textarea-label.am-textarea-label-4 {
106
+ width: 68px;
107
+ }
108
+
109
+ .am-textarea-label.am-textarea-label-5 {
110
+ width: 85px;
111
+ }
112
+
113
+ .am-textarea-label.am-textarea-label-6 {
114
+ width: 102px;
115
+ }
116
+
117
+ .am-textarea-label.am-textarea-label-7 {
118
+ width: 119px;
119
+ }
120
+
121
+ .am-textarea-control {
122
+ -webkit-box-flex: 1;
123
+ -webkit-flex: 1;
124
+ -ms-flex: 1;
125
+ flex: 1;
126
+ padding-top: 10px;
127
+ padding-bottom: 9px;
128
+ }
129
+
130
+ .am-textarea-control textarea {
131
+ color: #000;
132
+ font-size: 17px;
133
+ line-height: 25.5px;
134
+ -webkit-appearance: none;
135
+ -moz-appearance: none;
136
+ appearance: none;
137
+ width: 100%;
138
+ padding: 0;
139
+ border: 0;
140
+ background-color: transparent;
141
+ overflow: visible;
142
+ display: block;
143
+ resize: none;
144
+ word-break: break-word;
145
+ word-wrap: break-word;
146
+ }
147
+
148
+ .am-textarea-control textarea::-webkit-input-placeholder {
149
+ color: #bbb;
150
+ }
151
+
152
+ .am-textarea-control textarea::-moz-placeholder {
153
+ color: #bbb;
154
+ }
155
+
156
+ .am-textarea-control textarea::-ms-input-placeholder {
157
+ color: #bbb;
158
+ }
159
+
160
+ .am-textarea-control textarea::placeholder {
161
+ color: #bbb;
162
+ }
163
+
164
+ .am-textarea-control textarea:disabled {
165
+ color: #bbb;
166
+ background-color: #fff;
167
+ }
168
+
169
+ .am-textarea-clear {
170
+ display: none;
171
+ width: 21px;
172
+ height: 21px;
173
+ margin-top: 12px;
174
+ border-radius: 50%;
175
+ overflow: hidden;
176
+ font-style: normal;
177
+ color: #fff;
178
+ background-color: #ccc;
179
+ background-repeat: no-repeat;
180
+ background-size: 21px auto;
181
+ background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20fill%3D'%23fff'%20width%3D'24'%20height%3D'24'%20viewBox%3D'0%200%2024%2024'%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%3E%3Cpath%20d%3D'M19%206.41L17.59%205%2012%2010.59%206.41%205%205%206.41%2010.59%2012%205%2017.59%206.41%2019%2012%2013.41%2017.59%2019%2019%2017.59%2013.41%2012z'%2F%3E%3Cpath%20d%3D'M0%200h24v24H0z'%20fill%3D'none'%2F%3E%3C%2Fsvg%3E");
182
+ }
183
+
184
+ .am-textarea-clear-active {
185
+ background-color: #108ee9;
186
+ }
187
+
188
+ .am-textarea-focus .am-textarea-clear {
189
+ display: block;
190
+ }
191
+
192
+ .am-textarea-has-count {
193
+ padding-bottom: 14px;
194
+ }
195
+
196
+ .am-textarea-count {
197
+ position: absolute;
198
+ bottom: 6px;
199
+ right: 5px;
200
+ color: #bbb;
201
+ font-size: 14px;
202
+ }
203
+
204
+ .am-textarea-count span {
205
+ color: #000;
206
+ }
207
+
208
+ .am-textarea-error .am-textarea-control textarea {
209
+ color: #f50;
210
+ }
211
+
212
+ .am-textarea-error .am-textarea-error-extra {
213
+ margin-top: 12px;
214
+ width: 21px;
215
+ height: 21px;
216
+ margin-left: 8px;
217
+ background-size: 21px 21px;
218
+ background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20width%3D'18'%20height%3D'18'%20viewBox%3D'0%200%2018%2018'%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%3E%3Cg%20stroke%3D'none'%20stroke-width%3D'1'%20fill%3D'none'%20fill-rule%3D'evenodd'%3E%3Cg%20transform%3D'translate(-300.000000%2C%20-1207.000000)'%20fill%3D'%23FF5500'%3E%3Cg%20id%3D'exclamation-circle-o'%20transform%3D'translate(300.000000%2C%201207.000000)'%3E%3Cpath%20d%3D'M9%2C16.734375%20C10.0441406%2C16.734375%2011.0566406%2C16.5304688%2012.009375%2C16.1279297%20C12.9304688%2C15.7376953%2013.7566406%2C15.1804687%2014.4685547%2C14.4703125%20C15.1787109%2C13.7601563%2015.7376953%2C12.9322266%2016.1261719%2C12.0111328%20C16.5304688%2C11.0566406%2016.734375%2C10.0441406%2016.734375%2C9%20C16.734375%2C7.95585938%2016.5304688%2C6.94335938%2016.1279297%2C5.990625%20C15.7376953%2C5.06953125%2015.1804687%2C4.24335938%2014.4703125%2C3.53144531%20C13.7601563%2C2.82128906%2012.9322266%2C2.26230469%2012.0111328%2C1.87382813%20C11.0566406%2C1.46953125%2010.0441406%2C1.265625%209%2C1.265625%20C7.95585938%2C1.265625%206.94335938%2C1.46953125%205.990625%2C1.87207031%20C5.06953125%2C2.26230469%204.24335938%2C2.81953125%203.53144531%2C3.5296875%20C2.82128906%2C4.23984375%202.26230469%2C5.06777344%201.87382813%2C5.98886719%20C1.46953125%2C6.94335938%201.265625%2C7.95585938%201.265625%2C9%20C1.265625%2C10.0441406%201.46953125%2C11.0566406%201.87207031%2C12.009375%20C2.26230469%2C12.9304688%202.81953125%2C13.7566406%203.5296875%2C14.4685547%20C4.23984375%2C15.1787109%205.06777344%2C15.7376953%205.98886719%2C16.1261719%20C6.94335938%2C16.5304688%207.95585938%2C16.734375%209%2C16.734375%20L9%2C16.734375%20Z%20M9%2C18%20C4.02890625%2C18%200%2C13.9710937%200%2C9%20C0%2C4.02890625%204.02890625%2C0%209%2C0%20C13.9710937%2C0%2018%2C4.02890625%2018%2C9%20C18%2C13.9710937%2013.9710937%2C18%209%2C18%20L9%2C18%20L9%2C18%20Z%20M9%2C6.75%20C8.61152344%2C6.75%208.296875%2C7.06464844%208.296875%2C7.453125%20L8.296875%2C13.9394531%20C8.296875%2C14.3279297%208.61152344%2C14.6425781%209%2C14.6425781%20C9.38847656%2C14.6425781%209.703125%2C14.3279297%209.703125%2C13.9394531%20L9.703125%2C7.453125%20C9.703125%2C7.06464844%209.38847656%2C6.75%209%2C6.75%20L9%2C6.75%20Z%20M8.20898438%2C4.83398438%20C8.20898438%2C5.27085024%208.56313413%2C5.625%209%2C5.625%20C9.43686587%2C5.625%209.79101562%2C5.27085024%209.79101562%2C4.83398438%20C9.79101562%2C4.39711851%209.43686587%2C4.04296875%209%2C4.04296875%20C8.56313413%2C4.04296875%208.20898438%2C4.39711851%208.20898438%2C4.83398438%20L8.20898438%2C4.83398438%20Z'%20id%3D'Shape'%20transform%3D'translate(9.000000%2C%209.000000)%20scale(1%2C%20-1)%20translate(-9.000000%2C%20-9.000000)%20'%3E%3C%2Fpath%3E%3C%2Fg%3E%3C%2Fg%3E%3C%2Fg%3E%3C%2Fsvg%3E");
219
+ }
220
+
221
+ .am-textarea-disabled .am-textarea-label {
222
+ color: #bbb;
223
+ }
224
+
225
+ .am-list-body .am-list-item:last-child {
226
+ border-bottom: 0;
227
+ }
228
+
229
+ .am-list-body .am-list-item:last-child:after {
230
+ display: none !important;
231
+ }
@@ -0,0 +1,231 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+ var _classnames = _interopRequireDefault(require("classnames"));
10
+ var React = _interopRequireWildcard(require("react"));
11
+ var _rmcFeedback = _interopRequireDefault(require("rmc-feedback"));
12
+ var _exenv = require("../_util/exenv");
13
+ require("./index.css");
14
+ /* tslint:disable:jsx-no-multiline-js */
15
+
16
+ function noop() {}
17
+ function fixControlledValue(value) {
18
+ if (typeof value === 'undefined' || value === null) {
19
+ return '';
20
+ }
21
+ return value;
22
+ }
23
+ const regexAstralSymbols = /[\uD800-\uDBFF][\uDC00-\uDFFF]|\n/g;
24
+ function countSymbols() {
25
+ let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
26
+ return text.replace(regexAstralSymbols, '_').length;
27
+ }
28
+ class TextareaItem extends React.Component {
29
+ constructor(props) {
30
+ super(props);
31
+ this.focus = () => {
32
+ this.textareaRef.focus();
33
+ };
34
+ this.reAlignHeight = () => {
35
+ const textareaDom = this.textareaRef;
36
+ textareaDom.style.height = ''; // 字数减少时能自动减小高度
37
+ textareaDom.style.height = "".concat(textareaDom.scrollHeight, "px");
38
+ };
39
+ this.onChange = e => {
40
+ const value = e.target.value;
41
+ if ('value' in this.props) {
42
+ this.setState({
43
+ value: this.props.value
44
+ });
45
+ } else {
46
+ this.setState({
47
+ value
48
+ });
49
+ }
50
+ const {
51
+ onChange
52
+ } = this.props;
53
+ if (onChange) {
54
+ onChange(value);
55
+ }
56
+ // 设置 defaultValue 时,用户输入不会触发 componentDidUpdate ,此处手工调用
57
+ this.componentDidUpdate();
58
+ };
59
+ this.onBlur = e => {
60
+ this.debounceTimeout = setTimeout(() => {
61
+ if (document.activeElement !== this.textareaRef) {
62
+ this.setState({
63
+ focus: false
64
+ });
65
+ }
66
+ }, 100);
67
+ const value = e.currentTarget.value;
68
+ if (this.props.onBlur) {
69
+ // fix autoFocus item blur with flash
70
+ setTimeout(() => {
71
+ // fix ios12 wechat browser click failure after input
72
+ if (document.body) {
73
+ // eslint-disable-next-line no-self-assign
74
+ document.body.scrollTop = document.body.scrollTop;
75
+ }
76
+ }, 100);
77
+ this.props.onBlur(value);
78
+ }
79
+ };
80
+ this.onFocus = e => {
81
+ if (this.debounceTimeout) {
82
+ clearTimeout(this.debounceTimeout);
83
+ this.debounceTimeout = null;
84
+ }
85
+ this.setState({
86
+ focus: true
87
+ });
88
+ const value = e.currentTarget.value;
89
+ if (this.props.onFocus) {
90
+ this.props.onFocus(value);
91
+ }
92
+ };
93
+ this.onErrorClick = () => {
94
+ if (this.props.onErrorClick) {
95
+ this.props.onErrorClick();
96
+ }
97
+ };
98
+ this.clearInput = () => {
99
+ this.setState({
100
+ value: ''
101
+ });
102
+ if (this.props.onChange) {
103
+ this.props.onChange('');
104
+ }
105
+ };
106
+ this.state = {
107
+ focus: false,
108
+ value: props.value || props.defaultValue || ''
109
+ };
110
+ }
111
+ componentWillReceiveProps(nextProps) {
112
+ if ('value' in nextProps) {
113
+ this.setState({
114
+ value: fixControlledValue(nextProps.value)
115
+ });
116
+ }
117
+ }
118
+ componentDidMount() {
119
+ if (this.props.autoHeight) {
120
+ this.reAlignHeight();
121
+ }
122
+ }
123
+ componentDidUpdate() {
124
+ if (this.props.autoHeight) {
125
+ this.reAlignHeight();
126
+ }
127
+ }
128
+ componentWillUnmount() {
129
+ if (this.debounceTimeout) {
130
+ clearTimeout(this.debounceTimeout);
131
+ this.debounceTimeout = null;
132
+ }
133
+ }
134
+ render() {
135
+ const {
136
+ prefixCls,
137
+ prefixListCls,
138
+ editable,
139
+ style,
140
+ clear,
141
+ children,
142
+ error,
143
+ className,
144
+ count,
145
+ labelNumber,
146
+ title,
147
+ onErrorClick,
148
+ autoHeight,
149
+ defaultValue,
150
+ ...otherProps
151
+ } = this.props;
152
+ const {
153
+ disabled
154
+ } = otherProps;
155
+ const {
156
+ value,
157
+ focus
158
+ } = this.state;
159
+ const hasCount = count > 0 && this.props.rows > 1;
160
+ const wrapCls = (0, _classnames.default)(className, "".concat(prefixListCls, "-item"), "".concat(prefixCls, "-item"), {
161
+ ["".concat(prefixCls, "-disabled")]: disabled,
162
+ ["".concat(prefixCls, "-item-single-line")]: this.props.rows === 1 && !autoHeight,
163
+ ["".concat(prefixCls, "-error")]: error,
164
+ ["".concat(prefixCls, "-focus")]: focus,
165
+ ["".concat(prefixCls, "-has-count")]: hasCount
166
+ });
167
+ const labelCls = (0, _classnames.default)("".concat(prefixCls, "-label"), {
168
+ ["".concat(prefixCls, "-label-2")]: labelNumber === 2,
169
+ ["".concat(prefixCls, "-label-3")]: labelNumber === 3,
170
+ ["".concat(prefixCls, "-label-4")]: labelNumber === 4,
171
+ ["".concat(prefixCls, "-label-5")]: labelNumber === 5,
172
+ ["".concat(prefixCls, "-label-6")]: labelNumber === 6,
173
+ ["".concat(prefixCls, "-label-7")]: labelNumber === 7
174
+ });
175
+ const characterLength = countSymbols(value);
176
+ const lengthCtrlProps = {};
177
+ if (count > 0) {
178
+ // Note: If in the iOS environment of dev-tools, It will fail.
179
+ if (_exenv.IS_IOS) {
180
+ const entValue = value ? value.replace(regexAstralSymbols, '_') : '';
181
+ const entLen = entValue ? entValue.split('_').length - 1 : 0;
182
+ lengthCtrlProps.maxLength = count + entLen - characterLength + (value ? value.length : 0);
183
+ } else {
184
+ lengthCtrlProps.maxLength = count - characterLength + (value ? value.length : 0);
185
+ }
186
+ }
187
+ return /*#__PURE__*/React.createElement("div", {
188
+ className: wrapCls
189
+ }, title && /*#__PURE__*/React.createElement("div", {
190
+ className: labelCls
191
+ }, title), /*#__PURE__*/React.createElement("div", {
192
+ className: "".concat(prefixCls, "-control")
193
+ }, /*#__PURE__*/React.createElement("textarea", Object.assign({
194
+ ref: el => this.textareaRef = el
195
+ }, lengthCtrlProps, otherProps, {
196
+ value: value,
197
+ onChange: this.onChange,
198
+ onBlur: this.onBlur,
199
+ onFocus: this.onFocus,
200
+ readOnly: !editable,
201
+ style: style
202
+ }))), clear && editable && value && characterLength > 0 && /*#__PURE__*/React.createElement(_rmcFeedback.default, {
203
+ activeClassName: "".concat(prefixCls, "-clear-active")
204
+ }, /*#__PURE__*/React.createElement("div", {
205
+ className: "".concat(prefixCls, "-clear"),
206
+ onClick: this.clearInput
207
+ })), error && /*#__PURE__*/React.createElement("div", {
208
+ className: "".concat(prefixCls, "-error-extra"),
209
+ onClick: this.onErrorClick
210
+ }), hasCount && /*#__PURE__*/React.createElement("span", {
211
+ className: "".concat(prefixCls, "-count")
212
+ }, /*#__PURE__*/React.createElement("span", null, value ? characterLength : 0), "/", count));
213
+ }
214
+ }
215
+ exports.default = TextareaItem;
216
+ TextareaItem.defaultProps = {
217
+ prefixCls: 'am-textarea',
218
+ prefixListCls: 'am-list',
219
+ autoHeight: false,
220
+ editable: true,
221
+ disabled: false,
222
+ placeholder: '',
223
+ clear: false,
224
+ rows: 1,
225
+ onChange: noop,
226
+ onBlur: noop,
227
+ onFocus: noop,
228
+ onErrorClick: noop,
229
+ error: false,
230
+ labelNumber: 5
231
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtable-ui-component",
3
- "version": "6.0.24-beta.2",
3
+ "version": "6.0.24-beta.3",
4
4
  "main": "./lib/index.js",
5
5
  "dependencies": {
6
6
  "@seafile/react-image-lightbox": "4.0.2",