@ccs-ui/rc-pro 2.2.3 → 2.2.4-beta-2

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.
@@ -84,7 +84,6 @@ function CcsButton(_ref2) {
84
84
  okText: '确认',
85
85
  cancelText: '取消',
86
86
  onOk: function onOk() {
87
- console.log('inputConfirm', inputConfirm);
88
87
  if (inputConfirm) {
89
88
  return new Promise(function (resolve, reject) {
90
89
  var _ref$current;
@@ -1,16 +1,3 @@
1
- import { RGBColor } from 'react-color';
2
- import { PropsWithCss } from '../ccs';
1
+ import { ColorPickerProps } from 'antd';
3
2
  import './index.less';
4
- export type PropsType = PropsWithCss & {
5
- /** 指定选中项 */
6
- value?: RGBColor;
7
- /** 占位 */
8
- placeholder?: string;
9
- /** 选择完成后的回调 */
10
- onChange?: (value: RGBColor) => void;
11
- };
12
- /**
13
- * 颜色选择组件
14
- */
15
- declare const ColorPicker: ({ onChange, value, style }: PropsType) => import("react/jsx-runtime").JSX.Element;
16
- export default ColorPicker;
3
+ export default function CcsColorPicker({ mode, children, onChange, ...otherProps }: ColorPickerProps): import("react/jsx-runtime").JSX.Element;
@@ -1,67 +1,122 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ var _excluded = ["mode", "children", "onChange"];
2
3
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
5
  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
6
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
7
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
+ 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; }
9
+ 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; }
7
10
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
11
  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."); }
9
12
  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); }
10
13
  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; }
11
14
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
12
15
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
- /* eslint-disable @typescript-eslint/ban-types */
14
- import { Popover } from 'antd';
15
- import { useState } from 'react';
16
- import { SketchPicker } from 'react-color';
16
+ import { blue, cyan, gray, green, magenta, orange, presetPalettes, red } from '@ant-design/colors';
17
+ import { Col, ColorPicker, Divider, Row, Select } from 'antd';
17
18
  import "./index.less";
18
19
  import { jsx as _jsx } from "react/jsx-runtime";
19
- /**
20
- * 颜色选择组件
21
- */
22
- var ColorPicker = function ColorPicker(_ref) {
23
- var onChange = _ref.onChange,
24
- value = _ref.value,
25
- style = _ref.style;
26
- var _useState = useState(false),
27
- _useState2 = _slicedToArray(_useState, 2),
28
- open = _useState2[0],
29
- setOpen = _useState2[1];
30
- var handleChange = function handleChange(e) {
31
- if (onChange) onChange(e.rgb);
32
- setOpen(false);
20
+ import { jsxs as _jsxs } from "react/jsx-runtime";
21
+ import { Fragment as _Fragment } from "react/jsx-runtime";
22
+ function genPresets() {
23
+ var presets = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : presetPalettes;
24
+ return Object.entries(presets).map(function (_ref) {
25
+ var _ref2 = _slicedToArray(_ref, 2),
26
+ label = _ref2[0],
27
+ colors = _ref2[1];
28
+ return {
29
+ label: label,
30
+ colors: colors,
31
+ key: label
32
+ };
33
+ });
34
+ }
35
+ var presets = genPresets({
36
+ blue: blue,
37
+ red: red,
38
+ green: green,
39
+ cyan: cyan,
40
+ orange: orange,
41
+ magenta: magenta,
42
+ gray: gray
43
+ });
44
+ presets.forEach(function (f) {
45
+ f.colors = f.colors.slice(0, 6);
46
+ });
47
+ export default function CcsColorPicker(_ref3) {
48
+ var _ref3$mode = _ref3.mode,
49
+ mode = _ref3$mode === void 0 ? 'single' : _ref3$mode,
50
+ children = _ref3.children,
51
+ _onChange = _ref3.onChange,
52
+ otherProps = _objectWithoutProperties(_ref3, _excluded);
53
+ var customPanelRender = function customPanelRender(_, _ref4) {
54
+ var _ref4$components = _ref4.components,
55
+ Picker = _ref4$components.Picker,
56
+ Presets = _ref4$components.Presets;
57
+ return /*#__PURE__*/_jsxs(Row, {
58
+ justify: "space-between",
59
+ wrap: false,
60
+ style: {
61
+ width: 360
62
+ },
63
+ children: [/*#__PURE__*/_jsx(Col, {
64
+ span: 12,
65
+ children: /*#__PURE__*/_jsx(Presets, {})
66
+ }), /*#__PURE__*/_jsx(Divider, {
67
+ type: "vertical",
68
+ style: {
69
+ height: 'auto'
70
+ }
71
+ }), /*#__PURE__*/_jsx(Col, {
72
+ flex: "auto",
73
+ children: /*#__PURE__*/_jsx(Picker, {})
74
+ })]
75
+ });
76
+ };
77
+ var renderValue = function renderValue() {
78
+ if (!otherProps.value) {
79
+ return /*#__PURE__*/_jsx(Select, {
80
+ popupClassName: "ccs-color-picker-select",
81
+ placeholder: "\u8BF7\u9009\u62E9",
82
+ dropdownRender: function dropdownRender() {
83
+ return /*#__PURE__*/_jsx(_Fragment, {});
84
+ }
85
+ });
86
+ }
87
+ return undefined;
33
88
  };
34
- return /*#__PURE__*/_jsx("div", {
35
- style: {
36
- position: 'relative'
89
+ return /*#__PURE__*/_jsx(ColorPicker, _objectSpread(_objectSpread({
90
+ className: "ccs-color-picker",
91
+ allowClear: true,
92
+ showText: true,
93
+ mode: mode,
94
+ onChange: function onChange(value, css) {
95
+ if (!_onChange) return;
96
+ var colors = value.getColors();
97
+
98
+ // 渐变色
99
+ if (colors.length > 1) {
100
+ var gradientColors = colors.map(function (c) {
101
+ return {
102
+ color: c.color.toRgbString(),
103
+ percent: c.percent
104
+ };
105
+ });
106
+ _onChange(gradientColors, css);
107
+ return;
108
+ }
109
+ if (colors.length === 1) {
110
+ _onChange(value.toCssString(), css);
111
+ return;
112
+ }
37
113
  },
38
- children: /*#__PURE__*/_jsx(Popover, {
39
- open: open,
40
- content: /*#__PURE__*/_jsx(SketchPicker, {
41
- color: value,
42
- onChange: handleChange
43
- }),
44
- children: /*#__PURE__*/_jsx("div", {
45
- style: _objectSpread({
46
- height: 32,
47
- padding: '4px 11px',
48
- border: '1px solid #d9d9d9',
49
- borderRadius: 3,
50
- display: 'flex'
51
- }, style),
52
- children: /*#__PURE__*/_jsx("div", {
53
- onClick: function onClick() {
54
- return setOpen(!open);
55
- },
56
- style: {
57
- border: '1px solid #777',
58
- background: "rgb(".concat(value === null || value === void 0 ? void 0 : value.r, ",").concat(value === null || value === void 0 ? void 0 : value.g, ",").concat(value === null || value === void 0 ? void 0 : value.b, ",").concat(value === null || value === void 0 ? void 0 : value.a, ")"),
59
- width: '100%',
60
- margin: '4px 0'
61
- }
62
- })
63
- })
64
- })
65
- });
66
- };
67
- export default ColorPicker;
114
+ onClear: function onClear() {
115
+ if (_onChange) _onChange(undefined, '');
116
+ },
117
+ presets: presets,
118
+ panelRender: customPanelRender
119
+ }, otherProps), {}, {
120
+ children: children || renderValue()
121
+ }));
122
+ }
@@ -1,9 +1,8 @@
1
- .sketch-picker {
2
- width: 250px !important;
3
- box-shadow: none !important;
4
- padding: 0 !important;
1
+ .ccs-color-picker {
2
+ display: flex;
3
+ justify-content: start;
5
4
  }
6
5
 
7
- .flexbox-fix div {
8
- padding-left: 0 !important;
6
+ .ccs-color-picker-select {
7
+ display: none !important;
9
8
  }
@@ -1,4 +1,4 @@
1
- var _excluded = ["auth", "form", "title", "content", "extraBtn", "className", "hideFooter", "preventRequestHandle", "requestFieldNames", "onOk", "request", "onClose"];
1
+ var _excluded = ["auth", "form", "title", "content", "extraBtn", "className", "footer", "preventRequestHandle", "requestFieldNames", "onOk", "request", "onClose"];
2
2
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
3
3
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
4
4
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
@@ -100,7 +100,7 @@ var HookModal = function HookModal(props) {
100
100
  content = innerConfig.content,
101
101
  extraBtn = innerConfig.extraBtn,
102
102
  className = innerConfig.className,
103
- hideFooter = innerConfig.hideFooter,
103
+ footer = innerConfig.footer,
104
104
  preventRequestHandle = innerConfig.preventRequestHandle,
105
105
  requestFieldNames = innerConfig.requestFieldNames,
106
106
  onOk = innerConfig.onOk,
@@ -160,7 +160,7 @@ var HookModal = function HookModal(props) {
160
160
  afterClose: afterClose
161
161
  }, otherInnerConfig), {}, {
162
162
  className: classNames('ccs-dialog-modal', className),
163
- footer: hideFooter ? undefined : renderFooter,
163
+ footer: footer === null ? null : renderFooter,
164
164
  title: /*#__PURE__*/_jsx("div", {
165
165
  style: {
166
166
  width: '100%',
@@ -16,7 +16,7 @@ export type DialogButtonsProps<T> = Pick<CcsDialogModalProps, 'okText' | 'onClos
16
16
  export type DialogButtonRef = {
17
17
  onSetButtons: (e: React.ReactElement) => void;
18
18
  };
19
- export declare const DialogButtonHolder: <TParams, TData>({ auth, extraBtn, formRef, request, onOk, onClose, buttonRef, requestFieldNames, formInitialValues, preventRequestHandle, }: Pick<CcsDialogModalProps<TParams, TData>, "onOk" | "onClose" | "auth" | "extraBtn" | "request" | "requestFieldNames" | "preventRequestHandle"> & {
19
+ export declare const DialogButtonHolder: <TParams, TData>({ auth, extraBtn, formRef, request, onOk, onClose, buttonRef, requestFieldNames, formInitialValues, preventRequestHandle, }: Pick<CcsDialogModalProps<TParams, TData>, "onOk" | "onClose" | "auth" | "extraBtn" | "preventRequestHandle" | "requestFieldNames" | "request"> & {
20
20
  formRef: React.RefObject<DialogFormRef<TParams>>;
21
21
  formInitialValues: FormProps['initialValues'];
22
22
  buttonRef: RefObject<DialogButtonRef>;
@@ -47,10 +47,9 @@ type DialogProps<TParams, TData> = {
47
47
  /** 弹框关闭回调 */
48
48
  onClose?: () => void;
49
49
  };
50
- export type CcsDialogModalProps<TParams = any, TData = any> = DialogProps<TParams, TData> & Omit<ModalFuncProps, 'onCancel' | 'afterOpenChange' | 'onOk' | 'footer'> & {
50
+ export type CcsDialogModalProps<TParams = any, TData = any> = DialogProps<TParams, TData> & Omit<ModalFuncProps, 'onCancel' | 'afterOpenChange' | 'onOk'> & {
51
51
  /** 关闭后销毁组件,默认true */
52
52
  destroyOnClose?: boolean;
53
- hideFooter?: boolean;
54
53
  };
55
54
  export type CcsDialogDrawerProps<TParams = any, TData = any> = DialogProps<TParams, TData> & Omit<DrawerProps, 'onClose' | 'onOk' | 'afterOpenChange' | 'footer'> & {
56
55
  /** 抽屉内容 */
@@ -1,13 +1,33 @@
1
1
  import { UploadProps } from 'antd';
2
+ import { UploadChangeParam } from 'antd/es/upload';
2
3
  import { RecordType } from '../ccs';
3
4
  import { ImageUpload } from './upload-image';
5
+ type FileValue = {
6
+ /** 文件ID */
7
+ fileId: string;
8
+ /** 文件名称 */
9
+ name: string;
10
+ };
4
11
  export type CcsUploadProps = Pick<UploadProps, 'maxCount' | 'data' | 'multiple' | 'accept' | 'name' | 'headers'> & {
12
+ /** 最大文件数 */
5
13
  maxFileSize?: number;
14
+ /** 上传按钮文本 */
6
15
  uploadText?: string;
16
+ /** 图片下载地址 */
17
+ fileDownloadUrl?: string;
18
+ /** 文件id */
19
+ value?: string | string[] | FileValue[];
20
+ /** 上传change事件 */
7
21
  onChange?: (value: any) => void;
22
+ /** 上传请求 */
8
23
  uploadRequest: <T = any>(file: File, options?: RecordType) => Promise<T>;
9
24
  };
10
- declare function CcsUpload({ uploadText, maxCount, maxFileSize, uploadRequest, onChange, ...otherProps }: CcsUploadProps): import("react/jsx-runtime").JSX.Element;
25
+ export type FileUploadList = UploadChangeParam['fileList'][0] & {
26
+ fileId?: string;
27
+ };
28
+ /** 生成图片默认值 */
29
+ export declare function uploadDefaultFlies(value: CcsUploadProps['value'], fileDownloadUrl: string): FileUploadList[];
30
+ declare function CcsUpload({ value, uploadText, maxCount, maxFileSize, fileDownloadUrl, uploadRequest, onChange, ...otherProps }: CcsUploadProps): import("react/jsx-runtime").JSX.Element;
11
31
  declare namespace CcsUpload {
12
32
  var Image: typeof ImageUpload;
13
33
  }
@@ -1,5 +1,4 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- var _excluded = ["uploadText", "maxCount", "maxFileSize", "uploadRequest", "onChange"];
1
+ var _excluded = ["value", "uploadText", "maxCount", "maxFileSize", "fileDownloadUrl", "uploadRequest", "onChange"];
3
2
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
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; }
@@ -16,27 +15,73 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
16
15
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
17
16
  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; }
18
17
  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; }
18
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
19
19
  import { UploadOutlined } from '@ant-design/icons';
20
20
  import { Button, Upload, message } from 'antd';
21
21
  import { useState } from 'react';
22
22
  import { ImageUpload } from "./upload-image";
23
23
  import { jsx as _jsx } from "react/jsx-runtime";
24
+ /** 生成图片默认值 */
25
+ export function uploadDefaultFlies(value, fileDownloadUrl) {
26
+ if (Array.isArray(value)) {
27
+ return value.map(function (v) {
28
+ if (typeof v === 'string') {
29
+ return {
30
+ uid: v,
31
+ name: v,
32
+ url: "".concat(fileDownloadUrl).concat(v),
33
+ fileId: v
34
+ };
35
+ }
36
+
37
+ // 文件列表
38
+ if (_typeof(v) === 'object') {
39
+ return {
40
+ uid: v.fileId,
41
+ name: v.name,
42
+ url: "".concat(fileDownloadUrl).concat(v.fileId),
43
+ fileId: v.fileId
44
+ };
45
+ }
46
+ return undefined;
47
+ }).filter(function (f) {
48
+ return f;
49
+ });
50
+ }
51
+ if (typeof value === 'string') {
52
+ return [{
53
+ uid: value,
54
+ name: value,
55
+ url: "".concat(fileDownloadUrl).concat(value),
56
+ fileId: value
57
+ }];
58
+ }
59
+ return [];
60
+ }
24
61
  function CcsUpload(_ref) {
25
- var uploadText = _ref.uploadText,
62
+ var _ref$value = _ref.value,
63
+ value = _ref$value === void 0 ? [{
64
+ fileId: 'aaaa',
65
+ name: 'daaaa.txt'
66
+ }] : _ref$value,
67
+ uploadText = _ref.uploadText,
26
68
  _ref$maxCount = _ref.maxCount,
27
69
  maxCount = _ref$maxCount === void 0 ? 1 : _ref$maxCount,
28
70
  _ref$maxFileSize = _ref.maxFileSize,
29
71
  maxFileSize = _ref$maxFileSize === void 0 ? 10 : _ref$maxFileSize,
72
+ _ref$fileDownloadUrl = _ref.fileDownloadUrl,
73
+ fileDownloadUrl = _ref$fileDownloadUrl === void 0 ? '' : _ref$fileDownloadUrl,
30
74
  uploadRequest = _ref.uploadRequest,
31
75
  onChange = _ref.onChange,
32
76
  otherProps = _objectWithoutProperties(_ref, _excluded);
33
- var _useState = useState([]),
77
+ var _useState = useState(function () {
78
+ return uploadDefaultFlies(value, fileDownloadUrl);
79
+ }),
34
80
  _useState2 = _slicedToArray(_useState, 2),
35
81
  files = _useState2[0],
36
82
  setFiles = _useState2[1];
37
83
  var handleOnChange = function handleOnChange(_ref2) {
38
84
  var fileList = _ref2.fileList;
39
- console.log('fileList', fileList);
40
85
  setFiles(fileList);
41
86
  if (!onChange) return;
42
87
 
@@ -44,17 +89,16 @@ function CcsUpload(_ref) {
44
89
  if (fileList.find(function (f) {
45
90
  return f.status === 'uploading';
46
91
  })) return;
47
- if (maxFileSize === 1) {
92
+ if (maxCount === 1) {
48
93
  var _fileList$;
49
94
  // 只能上传一个文件
50
- onChange((_fileList$ = fileList[0]) === null || _fileList$ === void 0 || (_fileList$ = _fileList$.response) === null || _fileList$ === void 0 ? void 0 : _fileList$.data);
95
+ onChange((_fileList$ = fileList[0]) === null || _fileList$ === void 0 ? void 0 : _fileList$.fileId);
51
96
  } else {
52
97
  // 上传完成的文件,返回上传结果集
53
98
  onChange(fileList.filter(function (f) {
54
- return f.status === 'done';
99
+ return !!f.fileId;
55
100
  }).map(function (f) {
56
- var _f$response;
57
- return (_f$response = f.response) === null || _f$response === void 0 ? void 0 : _f$response.data;
101
+ return f.fileId;
58
102
  }));
59
103
  }
60
104
  };
@@ -67,6 +111,8 @@ function CcsUpload(_ref) {
67
111
  }
68
112
  return isLt2M;
69
113
  };
114
+
115
+ // 自定义上传
70
116
  var onCustomRequest = /*#__PURE__*/function () {
71
117
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref3) {
72
118
  var file, onSuccess, onError, result;
@@ -1,7 +1,6 @@
1
1
  import { CcsUploadProps } from './index';
2
2
  type CcsImageUploadProps = CcsUploadProps & {
3
3
  crop?: boolean;
4
- tokenKey?: string;
5
4
  };
6
- export declare function ImageUpload({ uploadText, maxCount, maxFileSize, crop, uploadRequest, onChange, ...otherProps }: CcsImageUploadProps): import("react/jsx-runtime").JSX.Element;
5
+ export declare function ImageUpload({ uploadText, maxCount, maxFileSize, crop, value, fileDownloadUrl, uploadRequest, onChange, ...otherProps }: CcsImageUploadProps): import("react/jsx-runtime").JSX.Element;
7
6
  export {};
@@ -1,5 +1,5 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- var _excluded = ["uploadText", "maxCount", "maxFileSize", "crop", "uploadRequest", "onChange"];
2
+ var _excluded = ["uploadText", "maxCount", "maxFileSize", "crop", "value", "fileDownloadUrl", "uploadRequest", "onChange"];
3
3
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
5
  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; }
@@ -21,6 +21,7 @@ import { message, Upload } from 'antd';
21
21
  import ImgCrop from 'antd-img-crop';
22
22
  import { useState } from 'react';
23
23
  import CcsDialog from "../dialog";
24
+ import { uploadDefaultFlies } from "./index";
24
25
  import { jsx as _jsx } from "react/jsx-runtime";
25
26
  import { jsxs as _jsxs } from "react/jsx-runtime";
26
27
  import { Fragment as _Fragment } from "react/jsx-runtime";
@@ -37,27 +38,35 @@ var getBase64 = function getBase64(file) {
37
38
  });
38
39
  };
39
40
  export function ImageUpload(_ref) {
40
- var uploadText = _ref.uploadText,
41
+ var _ref$uploadText = _ref.uploadText,
42
+ uploadText = _ref$uploadText === void 0 ? '上传' : _ref$uploadText,
41
43
  _ref$maxCount = _ref.maxCount,
42
44
  maxCount = _ref$maxCount === void 0 ? 1 : _ref$maxCount,
43
45
  _ref$maxFileSize = _ref.maxFileSize,
44
46
  maxFileSize = _ref$maxFileSize === void 0 ? 10 : _ref$maxFileSize,
45
47
  crop = _ref.crop,
48
+ value = _ref.value,
49
+ _ref$fileDownloadUrl = _ref.fileDownloadUrl,
50
+ fileDownloadUrl = _ref$fileDownloadUrl === void 0 ? '' : _ref$fileDownloadUrl,
46
51
  uploadRequest = _ref.uploadRequest,
47
52
  onChange = _ref.onChange,
48
53
  otherProps = _objectWithoutProperties(_ref, _excluded);
49
- var _useState = useState([]),
54
+ var _useState = useState(function () {
55
+ return uploadDefaultFlies(value, fileDownloadUrl);
56
+ }),
50
57
  _useState2 = _slicedToArray(_useState, 2),
51
58
  files = _useState2[0],
52
59
  setFiles = _useState2[1];
53
60
  var _CcsDialog$useDialog = CcsDialog.useDialog(),
54
- contextHolder = _CcsDialog$useDialog.contextHolder,
55
61
  openModal = _CcsDialog$useDialog.openModal;
56
62
  var handleOnChange = function handleOnChange(_ref2) {
57
63
  var fileList = _ref2.fileList;
58
- setFiles(fileList.filter(function (f) {
59
- return f.status;
60
- }));
64
+ fileList.forEach(function (f) {
65
+ if (!f.fileId && f.response) {
66
+ f.fileId = f.response.data;
67
+ }
68
+ });
69
+ setFiles(fileList);
61
70
  if (!onChange) return;
62
71
 
63
72
  // 文件上传中,不更新结果
@@ -67,14 +76,13 @@ export function ImageUpload(_ref) {
67
76
  if (maxCount === 1) {
68
77
  var _fileList$;
69
78
  // 只能上传一个文件
70
- onChange((_fileList$ = fileList[0]) === null || _fileList$ === void 0 || (_fileList$ = _fileList$.response) === null || _fileList$ === void 0 ? void 0 : _fileList$.data);
79
+ onChange((_fileList$ = fileList[0]) === null || _fileList$ === void 0 ? void 0 : _fileList$.fileId);
71
80
  } else {
72
81
  // 上传完成的文件,返回上传结果集
73
82
  onChange(fileList.filter(function (f) {
74
- return f.status === 'done';
83
+ return !!f.fileId;
75
84
  }).map(function (f) {
76
- var _f$response;
77
- return (_f$response = f.response) === null || _f$response === void 0 ? void 0 : _f$response.data;
85
+ return f.fileId;
78
86
  }));
79
87
  }
80
88
  };
@@ -87,31 +95,42 @@ export function ImageUpload(_ref) {
87
95
  }
88
96
  return isLt2M;
89
97
  };
98
+
99
+ // 预览
90
100
  var handlePreview = /*#__PURE__*/function () {
91
101
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(file) {
92
102
  return _regeneratorRuntime().wrap(function _callee$(_context) {
93
103
  while (1) switch (_context.prev = _context.next) {
94
104
  case 0:
95
105
  if (file.preview) {
96
- _context.next = 4;
106
+ _context.next = 8;
107
+ break;
108
+ }
109
+ if (!file.originFileObj) {
110
+ _context.next = 7;
97
111
  break;
98
112
  }
99
- _context.next = 3;
113
+ _context.next = 4;
100
114
  return getBase64(file.originFileObj);
101
- case 3:
102
- file.preview = _context.sent;
103
115
  case 4:
116
+ file.preview = _context.sent;
117
+ _context.next = 8;
118
+ break;
119
+ case 7:
120
+ file.preview = "".concat(fileDownloadUrl).concat(file.fileId);
121
+ case 8:
104
122
  openModal({
105
123
  title: file.name || file.url.substring(file.url.lastIndexOf('/') + 1),
106
124
  content: /*#__PURE__*/_jsx("img", {
107
- alt: "example",
125
+ alt: file.name,
108
126
  style: {
109
127
  width: '100%'
110
128
  },
111
129
  src: file.preview
112
- })
130
+ }),
131
+ footer: null
113
132
  });
114
- case 5:
133
+ case 9:
115
134
  case "end":
116
135
  return _context.stop();
117
136
  }
@@ -121,6 +140,8 @@ export function ImageUpload(_ref) {
121
140
  return _ref3.apply(this, arguments);
122
141
  };
123
142
  }();
143
+
144
+ // 自定义上传
124
145
  var onCustomRequest = /*#__PURE__*/function () {
125
146
  var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref4) {
126
147
  var file, onSuccess, onError, result;
@@ -173,11 +194,11 @@ export function ImageUpload(_ref) {
173
194
  })]
174
195
  })
175
196
  }));
176
- return /*#__PURE__*/_jsxs(_Fragment, {
177
- children: [contextHolder, crop ? /*#__PURE__*/_jsx(ImgCrop, {
197
+ return /*#__PURE__*/_jsx(_Fragment, {
198
+ children: crop ? /*#__PURE__*/_jsx(ImgCrop, {
178
199
  minZoom: 0.5,
179
200
  rotationSlider: true,
180
201
  children: renderUpload
181
- }) : renderUpload]
202
+ }) : renderUpload
182
203
  });
183
204
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ccs-ui/rc-pro",
3
- "version": "2.2.3",
3
+ "version": "2.2.4-beta-2",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -65,12 +65,12 @@
65
65
  "lodash.isarray": "^4.0.0",
66
66
  "lodash.isnil": "^4.0.0",
67
67
  "lodash.uniqueid": "^4.0.1",
68
- "react-color": "^2.19.3",
69
68
  "react-custom-scrollbars": "^4.2.1",
70
69
  "react-draggable": "^4.4.5",
71
70
  "react-error-overlay": "^6.0.11",
72
71
  "react-lines-ellipsis": "^0.15.4",
73
- "react-resizable": "^3.0.5"
72
+ "react-resizable": "^3.0.5",
73
+ "@ant-design/colors": "^8.0.0"
74
74
  },
75
75
  "devDependencies": {
76
76
  "@ant-design/compatible": "^5.1.2",
@@ -84,7 +84,6 @@
84
84
  "@types/lodash.isnil": "^4.0.9",
85
85
  "@types/lodash.uniqueid": "^4.0.9",
86
86
  "@types/react": "^18.0.0",
87
- "@types/react-color": "^3.0.6",
88
87
  "@types/react-custom-scrollbars": "^4.0.10",
89
88
  "@types/react-dom": "^18.0.0",
90
89
  "@types/react-lines-ellipsis": "^0.15.6",