@easyv/react-components 0.0.3 → 0.0.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.
- package/README.md +47 -1
- package/dist/Collapse/index.d.ts +9 -3
- package/dist/Collapse/index.js +15 -1
- package/dist/Collapse/index.less +5 -0
- package/dist/ColorPicker/ColorPreview.d.ts +19 -0
- package/dist/ColorPicker/ColorPreview.js +27 -0
- package/dist/ColorPicker/ColorPreview.less +5 -0
- package/dist/ColorPicker/index.js +25 -7
- package/dist/Input/index.js +55 -15
- package/dist/Input/interface.d.ts +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -2
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -7,7 +7,53 @@ a react component library base on arco design
|
|
|
7
7
|
|
|
8
8
|
## Usage
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
### 安装包
|
|
11
|
+
|
|
12
|
+
基础包
|
|
13
|
+
|
|
14
|
+
```shell
|
|
15
|
+
pnpm add @arco-design/web-react @arco-plugins/vite-react
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
主题包,例如 `@arco-themes/react-easytwin`
|
|
19
|
+
|
|
20
|
+
```shell
|
|
21
|
+
pnpm add @arco-themes/react-easytwin
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### 配置
|
|
25
|
+
|
|
26
|
+
以 vite 为例
|
|
27
|
+
|
|
28
|
+
配置 `vite.config.ts`
|
|
29
|
+
|
|
30
|
+
```js
|
|
31
|
+
import { vitePluginForArco } from '@arco-plugins/vite-react';
|
|
32
|
+
|
|
33
|
+
export default defineConfig({
|
|
34
|
+
// ...
|
|
35
|
+
plugins: [
|
|
36
|
+
// ...
|
|
37
|
+
vitePluginForArco({
|
|
38
|
+
theme: '@arco-themes/react-easytwin',
|
|
39
|
+
}),
|
|
40
|
+
],
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
如果是应用的暗色主题,请在 `index.html` 的 body 上添加 `arco-theme="dark"`,如果是亮色的,可以不加。
|
|
45
|
+
|
|
46
|
+
### 使用
|
|
47
|
+
|
|
48
|
+
可以统一在 `components` 目录下新建一个 `ui.ts` 文件,这个文件的主要作用就是从 `@easyv/react-components` 中导入组件并导出
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
export { Input } from '@easyv/react-components';
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
这样方便统一管理,后面如果要迁移组件库,只需要修改这个文件即可。
|
|
55
|
+
|
|
56
|
+
注意:不要引 `@arco-design/web-react`,这是依赖的基础库,但不是直接使用的库。`@easyv/react-components` 会基于它做一些定制。
|
|
11
57
|
|
|
12
58
|
## Options
|
|
13
59
|
|
package/dist/Collapse/index.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import React, { PropsWithChildren } from 'react';
|
|
2
|
+
import type { CollapseProps } from '@arco-design/web-react';
|
|
2
3
|
import './index.less';
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
declare function XCollapse(props: PropsWithChildren<CollapseProps>): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
declare namespace XCollapse {
|
|
6
|
+
var Item: React.ForwardRefExoticComponent<import("@arco-design/web-react").CollapseItemProps & {
|
|
7
|
+
children?: any;
|
|
8
|
+
} & React.RefAttributes<unknown>>;
|
|
9
|
+
}
|
|
10
|
+
export default XCollapse;
|
package/dist/Collapse/index.js
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
|
+
import React from 'react';
|
|
1
8
|
import { Collapse } from '@arco-design/web-react';
|
|
9
|
+
import { RightOutlined } from '@easyv/react-icons';
|
|
2
10
|
import "./index.less";
|
|
3
|
-
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
export default function XCollapse(props) {
|
|
13
|
+
return /*#__PURE__*/_jsx(Collapse, _objectSpread({
|
|
14
|
+
expandIcon: /*#__PURE__*/_jsx(RightOutlined, {})
|
|
15
|
+
}, props));
|
|
16
|
+
}
|
|
17
|
+
XCollapse.Item = Collapse.Item;
|
package/dist/Collapse/index.less
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import './ColorPreview.less';
|
|
2
|
+
declare type ColorPreviewProps = PureColorProps | LinearColorProps;
|
|
3
|
+
interface PureColorProps {
|
|
4
|
+
type: 'pure';
|
|
5
|
+
value: string;
|
|
6
|
+
}
|
|
7
|
+
interface LinearColorProps {
|
|
8
|
+
type: 'linear';
|
|
9
|
+
value: {
|
|
10
|
+
stops: {
|
|
11
|
+
color: string;
|
|
12
|
+
offset: number;
|
|
13
|
+
}[];
|
|
14
|
+
angle: number;
|
|
15
|
+
opacity: number;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export default function ColorPreview({ type, value }: ColorPreviewProps): import("react/jsx-runtime").JSX.Element | null;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import "./ColorPreview.less";
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
export default function ColorPreview(_ref) {
|
|
5
|
+
var type = _ref.type,
|
|
6
|
+
value = _ref.value;
|
|
7
|
+
switch (type) {
|
|
8
|
+
case 'pure':
|
|
9
|
+
{
|
|
10
|
+
return /*#__PURE__*/_jsx("div", {
|
|
11
|
+
className: "arco-color-picker-preview",
|
|
12
|
+
style: {
|
|
13
|
+
backgroundColor: value
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
case 'linear':
|
|
18
|
+
{
|
|
19
|
+
return /*#__PURE__*/_jsx("div", {
|
|
20
|
+
children: "\u6E10\u53D8"
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
default:
|
|
24
|
+
console.error('未知的颜色类型' + type);
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -4,13 +4,15 @@ import 'rc-color-picker/assets/index.css';
|
|
|
4
4
|
import Color from 'rc-color-picker/lib/helpers/color';
|
|
5
5
|
import { useDebounceFn } from 'ahooks';
|
|
6
6
|
import "./index.less";
|
|
7
|
+
import ColorPreview from "./ColorPreview";
|
|
7
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
10
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
11
|
export default function ColorPicker(_ref) {
|
|
9
12
|
var _ref$value = _ref.value,
|
|
10
13
|
value = _ref$value === void 0 ? 'rgba(255,0,255,0.5)' : _ref$value,
|
|
11
14
|
onChange = _ref.onChange;
|
|
12
15
|
var colorObj = new Color(value);
|
|
13
|
-
console.log('colorObj', colorObj, colorObj.toRgbString());
|
|
14
16
|
var _useDebounceFn = useDebounceFn(function (_ref2) {
|
|
15
17
|
var color = _ref2.color,
|
|
16
18
|
alpha = _ref2.alpha;
|
|
@@ -29,11 +31,27 @@ export default function ColorPicker(_ref) {
|
|
|
29
31
|
trailing: false
|
|
30
32
|
}),
|
|
31
33
|
run = _useDebounceFn.run;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
var linearValue = {
|
|
35
|
+
stops: [{
|
|
36
|
+
offset: 0,
|
|
37
|
+
color: '#fff'
|
|
38
|
+
}, {
|
|
39
|
+
offset: 100,
|
|
40
|
+
color: '#000'
|
|
41
|
+
}],
|
|
42
|
+
angle: 0,
|
|
43
|
+
opacity: 100
|
|
44
|
+
};
|
|
45
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
46
|
+
children: [/*#__PURE__*/_jsx(ColorPreview, {
|
|
47
|
+
type: "linear",
|
|
48
|
+
value: linearValue
|
|
49
|
+
}), /*#__PURE__*/_jsx(ColorPickerPanel, {
|
|
50
|
+
className: "arco-color-picker",
|
|
51
|
+
mode: "RGB",
|
|
52
|
+
color: colorObj.toHexString(),
|
|
53
|
+
alpha: colorObj.alpha,
|
|
54
|
+
onChange: run
|
|
55
|
+
})]
|
|
38
56
|
});
|
|
39
57
|
}
|
package/dist/Input/index.js
CHANGED
|
@@ -6,32 +6,72 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
6
6
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
7
7
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
8
8
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
9
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
10
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
11
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
12
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
13
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
14
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
9
15
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
10
16
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
11
|
-
import React, { forwardRef } from 'react';
|
|
17
|
+
import React, { forwardRef, useCallback, useEffect, useRef, useState } from 'react';
|
|
12
18
|
import { Input } from '@arco-design/web-react';
|
|
13
19
|
import classNames from 'classnames';
|
|
14
20
|
import { SearchCircleOutlined } from '@easyv/react-icons';
|
|
15
21
|
import "./index.less";
|
|
16
22
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
|
-
var XInput = /*#__PURE__*/forwardRef(function (
|
|
18
|
-
var
|
|
19
|
-
bordered =
|
|
20
|
-
className =
|
|
21
|
-
restProps = _objectWithoutProperties(
|
|
22
|
-
|
|
23
|
+
var XInput = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
24
|
+
var _props$bordered = props.bordered,
|
|
25
|
+
bordered = _props$bordered === void 0 ? true : _props$bordered,
|
|
26
|
+
className = props.className,
|
|
27
|
+
restProps = _objectWithoutProperties(props, _excluded);
|
|
28
|
+
var isHalfControll = ('onBlurChange' in props);
|
|
29
|
+
var _useState = useState('value' in props ? props.value : undefined),
|
|
30
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
31
|
+
localValue = _useState2[0],
|
|
32
|
+
setLocalValue = _useState2[1];
|
|
33
|
+
var refValue = useRef(localValue);
|
|
34
|
+
refValue.current = localValue;
|
|
35
|
+
useEffect(function () {
|
|
36
|
+
if (isHalfControll && props.value !== localValue) {
|
|
37
|
+
setLocalValue(props.value);
|
|
38
|
+
}
|
|
39
|
+
}, [props.value, isHalfControll]);
|
|
40
|
+
var handlePressEnter = useCallback(function (e) {
|
|
41
|
+
return e.currentTarget.blur();
|
|
42
|
+
}, []);
|
|
43
|
+
var handleChange = useCallback(function (value) {
|
|
44
|
+
setLocalValue(value);
|
|
45
|
+
}, []);
|
|
46
|
+
var handleBlur = useCallback(function () {
|
|
47
|
+
if (refValue.current !== undefined && refValue.current !== props.value) {
|
|
48
|
+
if (props.enableEmpty) {
|
|
49
|
+
var _props$onBlurChange;
|
|
50
|
+
(_props$onBlurChange = props.onBlurChange) === null || _props$onBlurChange === void 0 ? void 0 : _props$onBlurChange.call(props, refValue.current);
|
|
51
|
+
} else {
|
|
52
|
+
setLocalValue(props.value);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}, []);
|
|
56
|
+
var halfControlledProps = {
|
|
57
|
+
value: localValue,
|
|
58
|
+
onChange: handleChange,
|
|
59
|
+
onBlur: handleBlur
|
|
60
|
+
};
|
|
61
|
+
return /*#__PURE__*/_jsx(Input, _objectSpread(_objectSpread({
|
|
23
62
|
ref: ref,
|
|
24
63
|
className: classNames(className, {
|
|
25
64
|
'arco-input-borderless': !bordered
|
|
26
|
-
})
|
|
27
|
-
|
|
65
|
+
}),
|
|
66
|
+
onPressEnter: handlePressEnter
|
|
67
|
+
}, isHalfControll ? halfControlledProps : {}), restProps));
|
|
28
68
|
});
|
|
29
|
-
var InputSearch = /*#__PURE__*/forwardRef(function (
|
|
30
|
-
var
|
|
31
|
-
bordered =
|
|
32
|
-
className =
|
|
33
|
-
onSearch =
|
|
34
|
-
restProps = _objectWithoutProperties(
|
|
69
|
+
var InputSearch = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
70
|
+
var _ref$bordered = _ref.bordered,
|
|
71
|
+
bordered = _ref$bordered === void 0 ? true : _ref$bordered,
|
|
72
|
+
className = _ref.className,
|
|
73
|
+
onSearch = _ref.onSearch,
|
|
74
|
+
restProps = _objectWithoutProperties(_ref, _excluded2);
|
|
35
75
|
return /*#__PURE__*/_jsx(Input, _objectSpread({
|
|
36
76
|
ref: ref,
|
|
37
77
|
className: classNames(className, {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { InputProps } from '@arco-design/web-react';
|
|
2
2
|
import type { InputSearchProps, RefInputType } from '@arco-design/web-react/es/Input';
|
|
3
3
|
interface XInputProps extends InputProps {
|
|
4
|
+
enableEmpty?: boolean;
|
|
4
5
|
bordered?: boolean;
|
|
6
|
+
onBlurChange?: (value: string) => void;
|
|
5
7
|
}
|
|
6
8
|
interface XInputSearchProps extends InputSearchProps {
|
|
7
9
|
bordered?: boolean;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -65,5 +65,4 @@ export { default as Radio } from "./Radio";
|
|
|
65
65
|
export { default as Select } from "./Select";
|
|
66
66
|
export { default as Space } from "./Space";
|
|
67
67
|
export { default as Tag } from "./Tag";
|
|
68
|
-
|
|
69
|
-
// export { default as ColorPicker } from './ColorPicker';
|
|
68
|
+
export { default as ColorPicker } from "./ColorPicker";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easyv/react-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "a react component library base on arco design",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
"rc-color-picker": "^1.2.6"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@arco-design/web-react": "2.
|
|
57
|
-
"@arco-themes/react-dtable": "0.0.
|
|
56
|
+
"@arco-design/web-react": "2.55.1",
|
|
57
|
+
"@arco-themes/react-dtable": "0.0.31",
|
|
58
58
|
"@commitlint/cli": "^17.1.2",
|
|
59
59
|
"@commitlint/config-conventional": "^17.1.0",
|
|
60
60
|
"@easyv/sync-to-mirror": "^0.0.2",
|
|
@@ -97,6 +97,6 @@
|
|
|
97
97
|
"registry": "https://registry.npmjs.org"
|
|
98
98
|
},
|
|
99
99
|
"authors": [
|
|
100
|
-
"
|
|
100
|
+
"xiaoyao@dtstack.com"
|
|
101
101
|
]
|
|
102
102
|
}
|