@chaoswise/ui 2.3.12 → 2.3.14

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,94 @@
1
+
2
+ .color-picker-select {
3
+ position: relative;
4
+
5
+ .color-picker-select-value {
6
+ width: 18px;
7
+ height: 18px;
8
+ margin-right: 20px;
9
+ border: 1px solid @border-color-base;
10
+ }
11
+ }
12
+
13
+ .color-picker-dropdown {
14
+ background: @form-back-font;
15
+ width: 240px;
16
+ border-radius: 4px;
17
+ outline: none;
18
+ -webkit-box-shadow: @box-shadow-base;
19
+ box-shadow: @box-shadow-base;
20
+
21
+ .@{ant-prefix}-tabs-nav {
22
+ margin: 0;
23
+ padding: 0 10px;
24
+ }
25
+ }
26
+
27
+ .color-picker {
28
+ // background-color:aquamarine;
29
+ padding: 0 10px;
30
+ width: 100%;
31
+
32
+ .color-picker-input {
33
+ margin-top: 10px;
34
+ }
35
+
36
+ .gradient-active {
37
+ border: 1px solid @primary-color !important;
38
+ }
39
+
40
+ .gradient {
41
+ width: 100%;
42
+ height: 12px;
43
+ position: relative;
44
+ margin-top: 10px;
45
+ border: 1px solid @border-color-base;
46
+ }
47
+
48
+ .gradient-l,
49
+ .gradient-r {
50
+ width: 16px;
51
+ height: 16px;
52
+ border-radius: 50%;
53
+ background-color: #fff;
54
+ // display:inline-block;
55
+ border: 1px solid @border-color-base;
56
+ display: flex;
57
+ justify-content: center;
58
+ align-items: center;
59
+ cursor: pointer;
60
+
61
+ .gradient-btn {
62
+ width: 10px;
63
+ height: 10px;
64
+ border-radius: 50%;
65
+ border: 1px solid @border-color-base;
66
+ display: inline-block;
67
+ }
68
+ }
69
+
70
+ .gradient-l {
71
+ position: absolute;
72
+ left: -3px;
73
+ top: -3px;
74
+ }
75
+
76
+ .gradient-r {
77
+ position: absolute;
78
+ right: -3px;
79
+ top: -3px;
80
+ }
81
+
82
+ .sketch-picker {
83
+ >div:nth-child(3) {
84
+ display: none !important;
85
+ }
86
+
87
+ padding: 10px 0 0 0 !important;
88
+ box-sizing: border-box !important;
89
+ background: @form-back-font !important;
90
+ border-radius: 0px !important;
91
+ box-shadow: none !important;
92
+ width: 100% !important;
93
+ }
94
+ }
@@ -0,0 +1,4 @@
1
+ export default {
2
+ "color-picker-single": "single color",
3
+ "color-picker-gradient": "Gradient"
4
+ };
@@ -0,0 +1,12 @@
1
+ import zhCN from './zh_CN.js';
2
+ import enUS from './en_US.js';
3
+ export var getLocale = function getLocale(locale) {
4
+ switch (locale) {
5
+ case 'zh':
6
+ return zhCN;
7
+ case 'en':
8
+ return enUS;
9
+ default:
10
+ return zhCN;
11
+ }
12
+ };
@@ -0,0 +1,4 @@
1
+ export default {
2
+ "color-picker-single": "单色",
3
+ "color-picker-gradient": "渐变"
4
+ };
@@ -0,0 +1,15 @@
1
+ //16进制转rgba
2
+ export var hexToRgba = function hexToRgba(c) {
3
+ var alpha = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
4
+ var color = c.slice(1);
5
+ var rgb = color.match(/.{2}/g).map(function (d) {
6
+ return parseInt("0x".concat(d));
7
+ });
8
+ return "rgba(".concat(rgb.join(","), ",").concat(alpha, ")");
9
+ };
10
+
11
+ //rgba对象转颜色字符串
12
+ export var formatRgbaObj = function formatRgbaObj(obj) {
13
+ var rgbaStrig = "rgba(".concat(obj.r, ",").concat(obj.g, ",").concat(obj.b, ",").concat(obj.a, ")");
14
+ return rgbaStrig;
15
+ };
@@ -0,0 +1,93 @@
1
+ import "@chaoswise/ui/lib/Upload/index.less";
2
+ import _Upload from "@chaoswise/ui/lib/Upload";
3
+ import "@chaoswise/ui/lib/Button/index.less";
4
+ import _Button from "@chaoswise/ui/lib/Button";
5
+ import "@chaoswise/ui/lib/message/index.less";
6
+ import _message from "@chaoswise/ui/lib/message";
7
+ import _ConfigProvider from "@chaoswise/ui/lib/ConfigProvider";
8
+ import React from "react";
9
+ import { getLocale } from "../../locale";
10
+ import "./index.less";
11
+ var CustomImg = function CustomImg(_ref) {
12
+ var onChange = _ref.onChange,
13
+ iconInfo = _ref.iconInfo,
14
+ setCustomFileInfo = _ref.setCustomFileInfo,
15
+ customFileInfo = _ref.customFileInfo;
16
+ var _ConfigProvider$useLo = _ConfigProvider.useLocale(),
17
+ _ConfigProvider$useLo2 = _ConfigProvider$useLo.locale,
18
+ locale = _ConfigProvider$useLo2 === void 0 ? "zh" : _ConfigProvider$useLo2;
19
+ var localeObj = getLocale(locale);
20
+ var beforeUpload = function beforeUpload(file) {
21
+ var type = file.type,
22
+ size = file.size;
23
+ var checkTypeIsImage = function checkTypeIsImage() {
24
+ return !(type !== null && type !== void 0 && type.startsWith("image"));
25
+ };
26
+ var checkSizeIsNull = function checkSizeIsNull() {
27
+ return size == 0;
28
+ };
29
+ var checkSizeIsBig = function checkSizeIsBig() {
30
+ return size > 2 * 1024 * 1024;
31
+ };
32
+ if (checkTypeIsImage()) {
33
+ _message.error(localeObj["icon-select-custom-type"]);
34
+ return false;
35
+ }
36
+ if (checkSizeIsNull()) {
37
+ _message.error(localeObj["icon-select-custom-null"]);
38
+ return false;
39
+ }
40
+ if (checkSizeIsBig()) {
41
+ _message.error(localeObj["icon-select-custom-length"]);
42
+ return false;
43
+ }
44
+ var reader = new FileReader();
45
+ reader.readAsDataURL(file);
46
+ reader.onload = function () {
47
+ var _customFileInfo = {
48
+ baseCode: reader.result,
49
+ name: file.name,
50
+ id: file.uid
51
+ };
52
+ var fileInfo = {
53
+ iconInfo: iconInfo,
54
+ customFileInfo: _customFileInfo
55
+ };
56
+ setCustomFileInfo(_customFileInfo);
57
+ onChange(fileInfo);
58
+ // console.log(reader.result, "reader.result");
59
+ };
60
+
61
+ reader.onerror = function () {
62
+ _message.error(localeObj["icon-select-custom-fail"]);
63
+ };
64
+ return false;
65
+ };
66
+ return /*#__PURE__*/React.createElement("div", {
67
+ className: "link-upload-box"
68
+ }, /*#__PURE__*/React.createElement(_Upload, {
69
+ className: "upload-custom",
70
+ accept: ".png,.svg,.jpg,.jpeg",
71
+ dropSingleFileUpload: true,
72
+ beforeUpload: beforeUpload,
73
+ fileList: customFileInfo ? [customFileInfo] : [],
74
+ onRemove: function onRemove(e) {
75
+ var fileInfo = {
76
+ iconInfo: iconInfo,
77
+ customFileInfo: null
78
+ };
79
+ setCustomFileInfo(null);
80
+ onChange(fileInfo);
81
+ },
82
+ showUploadList: {
83
+ showDownloadIcon: true
84
+ }
85
+ }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
86
+ className: "custom-img"
87
+ }, /*#__PURE__*/React.createElement(_Button, {
88
+ icon: "upload"
89
+ }, localeObj["icon-select-custom-upload"]), /*#__PURE__*/React.createElement("div", {
90
+ className: "custom-img-tip"
91
+ }, localeObj["icon-select-custom-img-tip"])))));
92
+ };
93
+ export default CustomImg;
@@ -0,0 +1,17 @@
1
+ .link-upload-box {
2
+ height: 200px;
3
+ padding: 20px 5px;
4
+ }
5
+
6
+ .custom-img{
7
+ display: flex;
8
+ >button{
9
+ height: 30px;
10
+ }
11
+ }
12
+ .custom-img-tip{
13
+ font-size: 12px;
14
+ line-height: 15px;
15
+ color: #ccc;
16
+ margin-left: 5px;
17
+ }
@@ -0,0 +1,98 @@
1
+ import "@chaoswise/ui/lib/Empty/index.less";
2
+ import _Empty from "@chaoswise/ui/lib/Empty";
3
+ import "@chaoswise/ui/lib/Tooltip/index.less";
4
+ import _Tooltip from "@chaoswise/ui/lib/Tooltip";
5
+ import "@chaoswise/ui/lib/Input/index.less";
6
+ import _Input from "@chaoswise/ui/lib/Input";
7
+ import _ConfigProvider from "@chaoswise/ui/lib/ConfigProvider";
8
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
9
+ 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."); }
10
+ 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); }
11
+ 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; }
12
+ 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; } }
13
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
14
+ import React, { useEffect, useState, useMemo } from "react";
15
+ import Icon from "@icon-park/react/es/all";
16
+ import { getLocale } from "../../locale";
17
+ import { iconData } from "../../constants/icon";
18
+ import classnames from "classnames";
19
+ import "./index.less";
20
+ var SearchIcon = function SearchIcon(_ref) {
21
+ var iconInfo = _ref.iconInfo,
22
+ onChange = _ref.onChange,
23
+ _ref$category = _ref.category,
24
+ category = _ref$category === void 0 ? [] : _ref$category,
25
+ setIconInfo = _ref.setIconInfo,
26
+ customFileInfo = _ref.customFileInfo;
27
+ var _useState = useState([]),
28
+ _useState2 = _slicedToArray(_useState, 2),
29
+ iconList = _useState2[0],
30
+ setIconList = _useState2[1];
31
+ var _ConfigProvider$useLo = _ConfigProvider.useLocale(),
32
+ _ConfigProvider$useLo2 = _ConfigProvider$useLo.locale,
33
+ locale = _ConfigProvider$useLo2 === void 0 ? "zh" : _ConfigProvider$useLo2;
34
+ var localeObj = getLocale(locale);
35
+ var iconSelectList = useMemo(function () {
36
+ return iconData.filter(function (item) {
37
+ return category.includes(item.category);
38
+ });
39
+ }, [category]);
40
+
41
+ //选中
42
+ var _onClick = function onClick(e, item) {
43
+ var fileInfo = {
44
+ customFileInfo: customFileInfo,
45
+ iconInfo: item
46
+ };
47
+ setIconInfo(item);
48
+ onChange(fileInfo);
49
+ };
50
+
51
+ //搜索
52
+ var onSearch = function onSearch(e) {
53
+ console.log(e);
54
+ if (!e.target.value) {
55
+ setIconList(iconSelectList);
56
+ return;
57
+ }
58
+ var searchValue = e.target.value;
59
+ var iconSearchList = iconSelectList.filter(function (item) {
60
+ return item.title.includes(searchValue);
61
+ });
62
+ setIconList(iconSearchList);
63
+ };
64
+ useEffect(function () {
65
+ setIconList(iconSelectList);
66
+ }, []);
67
+ return /*#__PURE__*/React.createElement("div", {
68
+ className: "icon-selsect-box"
69
+ }, /*#__PURE__*/React.createElement("div", {
70
+ className: "icon-selsect-search"
71
+ }, /*#__PURE__*/React.createElement(_Input.Search, {
72
+ placeholder: localeObj["icon-select-store-icon-search"],
73
+ onChange: onSearch,
74
+ allowClear: true
75
+ })), /*#__PURE__*/React.createElement("div", {
76
+ className: "icon-selsect-content"
77
+ }, iconList.length > 0 ? iconList.map(function (item) {
78
+ return /*#__PURE__*/React.createElement(_Tooltip, {
79
+ title: locale === "zh" ? item.title : item.name,
80
+ key: item.name
81
+ }, /*#__PURE__*/React.createElement("div", {
82
+ key: item.name,
83
+ onClick: function onClick(e) {
84
+ return _onClick(e, item);
85
+ },
86
+ className: classnames("icon-selsect-item", {
87
+ "icon-selsect-item-active": (iconInfo === null || iconInfo === void 0 ? void 0 : iconInfo.name) === item.name
88
+ })
89
+ }, /*#__PURE__*/React.createElement(Icon, {
90
+ type: item.name,
91
+ theme: "filled",
92
+ size: "14"
93
+ })));
94
+ }) : /*#__PURE__*/React.createElement("div", {
95
+ className: "icon-selsect-content-empty"
96
+ }, /*#__PURE__*/React.createElement(_Empty, null))));
97
+ };
98
+ export default SearchIcon;
@@ -0,0 +1,35 @@
1
+ .icon-selsect-box{
2
+ width: 100%;
3
+ .icon-selsect-search{
4
+ margin: 12px 5px;
5
+ }
6
+ .icon-selsect-content{
7
+ overflow-y: scroll;
8
+ height: 150px;
9
+ width: 100%;
10
+ padding-left: 10px;
11
+ .icon-selsect-item{
12
+ padding: 10px;
13
+ display: inline-block;
14
+ cursor: pointer;
15
+ &:hover{
16
+ background-color: #e6f7ff;
17
+ }
18
+ }
19
+
20
+ .icon-selsect-item-active{
21
+ background-color: #e6f7ff;
22
+ }
23
+
24
+ .icon-selsect-content-empty{
25
+ width: 100%;
26
+ height: 150px;
27
+ display: flex;
28
+ align-items: center;
29
+ justify-content: center;
30
+ overflow: hidden;
31
+ }
32
+
33
+ }
34
+
35
+ }