assui 2.0.84 → 2.0.88

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.
@@ -8,7 +8,7 @@ export interface CopyToClipboardProps {
8
8
  /** 文本被复制时候的回调 */
9
9
  onCopy?: (text: string, result: boolean) => void;
10
10
  /** ant design Tooltip props */
11
- tooltipProps: TooltipProps;
11
+ tooltipProps?: Omit<TooltipProps, 'title'>;
12
12
  /** 复制成功的Tooltip提示文案 */
13
13
  tooltipTitle?: React.ReactNode;
14
14
  /** 依赖底层组件 https://github.com/sudodoki/copy-to-clipboard 的 options */
@@ -43,7 +43,9 @@ var LabelInput = function LabelInput(props) {
43
43
  focused = _a[0],
44
44
  setFocused = _a[1];
45
45
 
46
- var _b = __read(useControllableValue(props), 2),
46
+ var _b = __read(useControllableValue(props, {
47
+ defaultValue: ''
48
+ }), 2),
47
49
  value = _b[0],
48
50
  setValue = _b[1];
49
51
 
@@ -1,2 +1,21 @@
1
- declare const LabelTextArea: () => JSX.Element;
1
+ import React from 'react';
2
+ export interface LabelTextAreaProps extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'size' | 'type' | 'onChange' | 'onFocus' | 'onBlur'> {
3
+ /** 自定义class */
4
+ className?: string;
5
+ /** label 标签的文本 */
6
+ label?: React.ReactNode;
7
+ /** 输入框内容 */
8
+ value?: string;
9
+ /** 指定输入框展示值的格式 */
10
+ formatter?: (value: string) => string;
11
+ /** 输入框内容变化时的回调 */
12
+ onChange?: (value: string) => void;
13
+ /** 输入框失去焦点的回调 */
14
+ onBlur?: (value: string) => void;
15
+ /** 输入框获取焦点的回调 */
16
+ onFocus?: (value: string) => void;
17
+ /** 组件dom id */
18
+ id?: string;
19
+ }
20
+ declare const LabelTextArea: React.FC<LabelTextAreaProps>;
2
21
  export default LabelTextArea;
@@ -1,7 +1,100 @@
1
+ var __read = this && this.__read || function (o, n) {
2
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
3
+ if (!m) return o;
4
+ var i = m.call(o),
5
+ r,
6
+ ar = [],
7
+ e;
8
+
9
+ try {
10
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
11
+ ar.push(r.value);
12
+ }
13
+ } catch (error) {
14
+ e = {
15
+ error: error
16
+ };
17
+ } finally {
18
+ try {
19
+ if (r && !r.done && (m = i["return"])) m.call(i);
20
+ } finally {
21
+ if (e) throw e.error;
22
+ }
23
+ }
24
+
25
+ return ar;
26
+ };
27
+
1
28
  import React from 'react';
29
+ import classNames from 'classnames';
30
+ import { useControllableValue } from 'ahooks';
31
+ import { trimStart } from 'lodash';
32
+
33
+ var LabelTextArea = function LabelTextArea(props) {
34
+ var className = props.className,
35
+ label = props.label,
36
+ id = props.id,
37
+ formatter = props.formatter,
38
+ onFocus = props.onFocus,
39
+ onBlur = props.onBlur;
40
+
41
+ var _a = __read(React.useState(false), 2),
42
+ focused = _a[0],
43
+ setFocused = _a[1];
44
+
45
+ var _b = __read(useControllableValue(props), 2),
46
+ value = _b[0],
47
+ setValue = _b[1];
48
+
49
+ var TextAreaDomRef = React.useRef(null);
50
+
51
+ var handleFocus = function handleFocus() {
52
+ setFocused(true);
53
+ onFocus === null || onFocus === void 0 ? void 0 : onFocus(value);
54
+ };
55
+
56
+ var handleBlur = function handleBlur() {
57
+ setFocused(false);
58
+ onBlur === null || onBlur === void 0 ? void 0 : onBlur(value);
59
+ };
60
+
61
+ var handleLabelClick = function handleLabelClick() {
62
+ var _a;
63
+
64
+ (_a = TextAreaDomRef.current) === null || _a === void 0 ? void 0 : _a.focus();
65
+ };
66
+
67
+ var handleChange = function handleChange(e) {
68
+ var finallyValue = trimStart(e.target.value);
69
+
70
+ if (formatter) {
71
+ finallyValue = formatter(finallyValue);
72
+ }
73
+
74
+ setValue(finallyValue);
75
+ };
2
76
 
3
- var LabelTextArea = function LabelTextArea() {
4
- return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("textarea", null));
77
+ return /*#__PURE__*/React.createElement("div", {
78
+ className: classNames('label-input-control', className),
79
+ id: id
80
+ }, /*#__PURE__*/React.createElement("div", {
81
+ className: classNames('label-textarea-warper', {
82
+ 'textarea-warper-focused': focused
83
+ }),
84
+ onClick: handleLabelClick
85
+ }, /*#__PURE__*/React.createElement("textarea", {
86
+ ref: function ref(el) {
87
+ return TextAreaDomRef.current = el;
88
+ },
89
+ "data-value": value ? value.length : 0,
90
+ className: "label-textarea",
91
+ value: value,
92
+ onFocus: handleFocus,
93
+ onChange: handleChange,
94
+ onBlur: handleBlur
95
+ }), /*#__PURE__*/React.createElement("label", {
96
+ className: "label-textarea-text"
97
+ }, label)));
5
98
  };
6
99
 
7
100
  export default LabelTextArea;
@@ -0,0 +1,44 @@
1
+ .label-textarea {
2
+ z-index: 1;
3
+ width: 100%;
4
+ height: 100%;
5
+ min-height: 28px;
6
+ margin-bottom: -4px;
7
+ padding: 0 15px 0 15px;
8
+ color: #263241;
9
+ font-size: 16px;
10
+ border: 0;
11
+ border-radius: 12px;
12
+ outline: 0;
13
+ transition: border 0.3s;
14
+ }
15
+ .label-textarea:focus + label,
16
+ .label-textarea:not([data-value='0']) + label {
17
+ transform: translateY(-10px) scale(0.86);
18
+ }
19
+ .label-textarea-warper {
20
+ position: relative;
21
+ width: 100%;
22
+ height: 100%;
23
+ padding-top: 24px;
24
+ border: 1px solid #e5e5e5;
25
+ border-radius: 12px;
26
+ outline: 0;
27
+ cursor: text;
28
+ }
29
+ .label-textarea-text {
30
+ position: absolute;
31
+ top: 16px;
32
+ left: 16px;
33
+ z-index: 2;
34
+ height: 20px;
35
+ color: #9aa5b5;
36
+ font-size: 14px;
37
+ line-height: 20px;
38
+ transform-origin: top left;
39
+ cursor: text;
40
+ transition: all 0.2s ease-out;
41
+ }
42
+ .textarea-warper-focused {
43
+ border-color: #ff6b00;
44
+ }
@@ -1 +1 @@
1
-
1
+ import './index.less';
@@ -0,0 +1 @@
1
+ import './index.less';
@@ -0,0 +1,59 @@
1
+ @primary-color: #ff6b00;
2
+ @color_dfe2e7: #dfe2e7;
3
+ @color_9aa5b5: #9aa5b5;
4
+ @color_b3b3b3: #b3b3b3;
5
+ @color_e5e5e5: #e5e5e5;
6
+
7
+ @font-size-base: 14px;
8
+ @font-size-lg: @font-size-base + 2px;
9
+
10
+ @font-weight-500: 500;
11
+
12
+ .label-textarea {
13
+ z-index: 1;
14
+ width: 100%;
15
+ height: 100%;
16
+ min-height: 28px;
17
+ margin-bottom: -4px;
18
+ padding: 0 15px 0 15px;
19
+ color: #263241;
20
+ font-size: @font-size-lg;
21
+ border: 0;
22
+ border-radius: 12px;
23
+ outline: 0;
24
+ transition: border 0.3s;
25
+
26
+ &:focus + label,
27
+ &:not([data-value='0']) + label {
28
+ transform: translateY(-10px) scale(0.86);
29
+ }
30
+
31
+ &-warper {
32
+ position: relative;
33
+ width: 100%;
34
+ height: 100%;
35
+ padding-top: 24px;
36
+ border: 1px solid @color_e5e5e5;
37
+ border-radius: 12px;
38
+ outline: 0;
39
+ cursor: text;
40
+ }
41
+
42
+ &-text {
43
+ position: absolute;
44
+ top: 16px;
45
+ left: 16px;
46
+ z-index: 2;
47
+ height: 20px;
48
+ color: @color_9aa5b5;
49
+ font-size: @font-size-base;
50
+ line-height: 20px;
51
+ transform-origin: top left;
52
+ cursor: text;
53
+ transition: all 0.2s ease-out;
54
+ }
55
+ }
56
+
57
+ .textarea-warper-focused {
58
+ border-color: @primary-color;
59
+ }
@@ -8,7 +8,7 @@ export interface CopyToClipboardProps {
8
8
  /** 文本被复制时候的回调 */
9
9
  onCopy?: (text: string, result: boolean) => void;
10
10
  /** ant design Tooltip props */
11
- tooltipProps: TooltipProps;
11
+ tooltipProps?: Omit<TooltipProps, 'title'>;
12
12
  /** 复制成功的Tooltip提示文案 */
13
13
  tooltipTitle?: React.ReactNode;
14
14
  /** 依赖底层组件 https://github.com/sudodoki/copy-to-clipboard 的 options */
@@ -58,7 +58,9 @@ var LabelInput = function LabelInput(props) {
58
58
  focused = _a[0],
59
59
  setFocused = _a[1];
60
60
 
61
- var _b = __read(ahooks_1.useControllableValue(props), 2),
61
+ var _b = __read(ahooks_1.useControllableValue(props, {
62
+ defaultValue: ''
63
+ }), 2),
62
64
  value = _b[0],
63
65
  setValue = _b[1];
64
66
 
@@ -1,2 +1,21 @@
1
- declare const LabelTextArea: () => JSX.Element;
1
+ import React from 'react';
2
+ export interface LabelTextAreaProps extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'size' | 'type' | 'onChange' | 'onFocus' | 'onBlur'> {
3
+ /** 自定义class */
4
+ className?: string;
5
+ /** label 标签的文本 */
6
+ label?: React.ReactNode;
7
+ /** 输入框内容 */
8
+ value?: string;
9
+ /** 指定输入框展示值的格式 */
10
+ formatter?: (value: string) => string;
11
+ /** 输入框内容变化时的回调 */
12
+ onChange?: (value: string) => void;
13
+ /** 输入框失去焦点的回调 */
14
+ onBlur?: (value: string) => void;
15
+ /** 输入框获取焦点的回调 */
16
+ onFocus?: (value: string) => void;
17
+ /** 组件dom id */
18
+ id?: string;
19
+ }
20
+ declare const LabelTextArea: React.FC<LabelTextAreaProps>;
2
21
  export default LabelTextArea;
@@ -1,5 +1,32 @@
1
1
  "use strict";
2
2
 
3
+ var __read = this && this.__read || function (o, n) {
4
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
5
+ if (!m) return o;
6
+ var i = m.call(o),
7
+ r,
8
+ ar = [],
9
+ e;
10
+
11
+ try {
12
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
13
+ ar.push(r.value);
14
+ }
15
+ } catch (error) {
16
+ e = {
17
+ error: error
18
+ };
19
+ } finally {
20
+ try {
21
+ if (r && !r.done && (m = i["return"])) m.call(i);
22
+ } finally {
23
+ if (e) throw e.error;
24
+ }
25
+ }
26
+
27
+ return ar;
28
+ };
29
+
3
30
  var __importDefault = this && this.__importDefault || function (mod) {
4
31
  return mod && mod.__esModule ? mod : {
5
32
  "default": mod
@@ -12,8 +39,77 @@ Object.defineProperty(exports, "__esModule", {
12
39
 
13
40
  var react_1 = __importDefault(require("react"));
14
41
 
15
- var LabelTextArea = function LabelTextArea() {
16
- return react_1["default"].createElement("div", null, react_1["default"].createElement("textarea", null));
42
+ var classnames_1 = __importDefault(require("classnames"));
43
+
44
+ var ahooks_1 = require("ahooks");
45
+
46
+ var lodash_1 = require("lodash");
47
+
48
+ var LabelTextArea = function LabelTextArea(props) {
49
+ var className = props.className,
50
+ label = props.label,
51
+ id = props.id,
52
+ formatter = props.formatter,
53
+ onFocus = props.onFocus,
54
+ onBlur = props.onBlur;
55
+
56
+ var _a = __read(react_1["default"].useState(false), 2),
57
+ focused = _a[0],
58
+ setFocused = _a[1];
59
+
60
+ var _b = __read(ahooks_1.useControllableValue(props), 2),
61
+ value = _b[0],
62
+ setValue = _b[1];
63
+
64
+ var TextAreaDomRef = react_1["default"].useRef(null);
65
+
66
+ var handleFocus = function handleFocus() {
67
+ setFocused(true);
68
+ onFocus === null || onFocus === void 0 ? void 0 : onFocus(value);
69
+ };
70
+
71
+ var handleBlur = function handleBlur() {
72
+ setFocused(false);
73
+ onBlur === null || onBlur === void 0 ? void 0 : onBlur(value);
74
+ };
75
+
76
+ var handleLabelClick = function handleLabelClick() {
77
+ var _a;
78
+
79
+ (_a = TextAreaDomRef.current) === null || _a === void 0 ? void 0 : _a.focus();
80
+ };
81
+
82
+ var handleChange = function handleChange(e) {
83
+ var finallyValue = lodash_1.trimStart(e.target.value);
84
+
85
+ if (formatter) {
86
+ finallyValue = formatter(finallyValue);
87
+ }
88
+
89
+ setValue(finallyValue);
90
+ };
91
+
92
+ return react_1["default"].createElement("div", {
93
+ className: classnames_1["default"]('label-input-control', className),
94
+ id: id
95
+ }, react_1["default"].createElement("div", {
96
+ className: classnames_1["default"]('label-textarea-warper', {
97
+ 'textarea-warper-focused': focused
98
+ }),
99
+ onClick: handleLabelClick
100
+ }, react_1["default"].createElement("textarea", {
101
+ ref: function ref(el) {
102
+ return TextAreaDomRef.current = el;
103
+ },
104
+ "data-value": value ? value.length : 0,
105
+ className: "label-textarea",
106
+ value: value,
107
+ onFocus: handleFocus,
108
+ onChange: handleChange,
109
+ onBlur: handleBlur
110
+ }), react_1["default"].createElement("label", {
111
+ className: "label-textarea-text"
112
+ }, label)));
17
113
  };
18
114
 
19
115
  exports["default"] = LabelTextArea;
@@ -0,0 +1,44 @@
1
+ .label-textarea {
2
+ z-index: 1;
3
+ width: 100%;
4
+ height: 100%;
5
+ min-height: 28px;
6
+ margin-bottom: -4px;
7
+ padding: 0 15px 0 15px;
8
+ color: #263241;
9
+ font-size: 16px;
10
+ border: 0;
11
+ border-radius: 12px;
12
+ outline: 0;
13
+ transition: border 0.3s;
14
+ }
15
+ .label-textarea:focus + label,
16
+ .label-textarea:not([data-value='0']) + label {
17
+ transform: translateY(-10px) scale(0.86);
18
+ }
19
+ .label-textarea-warper {
20
+ position: relative;
21
+ width: 100%;
22
+ height: 100%;
23
+ padding-top: 24px;
24
+ border: 1px solid #e5e5e5;
25
+ border-radius: 12px;
26
+ outline: 0;
27
+ cursor: text;
28
+ }
29
+ .label-textarea-text {
30
+ position: absolute;
31
+ top: 16px;
32
+ left: 16px;
33
+ z-index: 2;
34
+ height: 20px;
35
+ color: #9aa5b5;
36
+ font-size: 14px;
37
+ line-height: 20px;
38
+ transform-origin: top left;
39
+ cursor: text;
40
+ transition: all 0.2s ease-out;
41
+ }
42
+ .textarea-warper-focused {
43
+ border-color: #ff6b00;
44
+ }
@@ -1 +1 @@
1
-
1
+ import './index.less';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ require("./index.less");
@@ -0,0 +1,59 @@
1
+ @primary-color: #ff6b00;
2
+ @color_dfe2e7: #dfe2e7;
3
+ @color_9aa5b5: #9aa5b5;
4
+ @color_b3b3b3: #b3b3b3;
5
+ @color_e5e5e5: #e5e5e5;
6
+
7
+ @font-size-base: 14px;
8
+ @font-size-lg: @font-size-base + 2px;
9
+
10
+ @font-weight-500: 500;
11
+
12
+ .label-textarea {
13
+ z-index: 1;
14
+ width: 100%;
15
+ height: 100%;
16
+ min-height: 28px;
17
+ margin-bottom: -4px;
18
+ padding: 0 15px 0 15px;
19
+ color: #263241;
20
+ font-size: @font-size-lg;
21
+ border: 0;
22
+ border-radius: 12px;
23
+ outline: 0;
24
+ transition: border 0.3s;
25
+
26
+ &:focus + label,
27
+ &:not([data-value='0']) + label {
28
+ transform: translateY(-10px) scale(0.86);
29
+ }
30
+
31
+ &-warper {
32
+ position: relative;
33
+ width: 100%;
34
+ height: 100%;
35
+ padding-top: 24px;
36
+ border: 1px solid @color_e5e5e5;
37
+ border-radius: 12px;
38
+ outline: 0;
39
+ cursor: text;
40
+ }
41
+
42
+ &-text {
43
+ position: absolute;
44
+ top: 16px;
45
+ left: 16px;
46
+ z-index: 2;
47
+ height: 20px;
48
+ color: @color_9aa5b5;
49
+ font-size: @font-size-base;
50
+ line-height: 20px;
51
+ transform-origin: top left;
52
+ cursor: text;
53
+ transition: all 0.2s ease-out;
54
+ }
55
+ }
56
+
57
+ .textarea-warper-focused {
58
+ border-color: @primary-color;
59
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "assui",
3
- "version": "2.0.84",
3
+ "version": "2.0.88",
4
4
  "description": "react ui library",
5
5
  "author": "jason <usochen@gmail.com>",
6
6
  "main": "./lib/index.js",
@@ -33,7 +33,7 @@
33
33
  "@ahooksjs/use-url-state": "^2.5.8",
34
34
  "@tinymce/tinymce-react": "^3.13.0",
35
35
  "@types/react-beautiful-dnd": "^13.1.2",
36
- "a-icons": "^1.0.45",
36
+ "a-icons": "^1.0.47",
37
37
  "ahooks": "^3.0.8",
38
38
  "bignumber.js": "^9.0.1",
39
39
  "copy-to-clipboard": "^3.3.1",
@@ -69,5 +69,5 @@
69
69
  "node": ">=10.0.0"
70
70
  },
71
71
  "license": "MIT",
72
- "gitHead": "2619749456cbd30c3f9f0980a00b9acb31c1aea0"
72
+ "gitHead": "0d17776f46e9cc203479dee452206b0798fd1bba"
73
73
  }