@pisell/materials 1.0.604 → 1.0.605

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.
Files changed (77) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/index.js +1 -1
  5. package/build/lowcode/meta.js +1 -1
  6. package/build/lowcode/preview.js +7 -7
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +36 -22
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +35 -21
  11. package/es/components/appVersionControl/index.js +49 -52
  12. package/es/components/appVersionControl/index.less +2 -4
  13. package/es/components/appVersionControl/types.d.ts +4 -1
  14. package/es/components/appVersionControl/utils.d.ts +13 -0
  15. package/es/components/appVersionControl/utils.js +30 -0
  16. package/es/components/customSelect/index.d.ts +2 -2
  17. package/es/components/customSelect/index.js +8 -2
  18. package/es/components/versionModal/index.d.ts +7 -0
  19. package/es/components/versionModal/index.js +36 -9
  20. package/es/components/versionSelect/index.d.ts +18 -0
  21. package/es/components/versionSelect/index.js +53 -0
  22. package/es/components/versionSelect/index.less +3 -0
  23. package/es/locales/en-US.d.ts +2 -0
  24. package/es/locales/en-US.js +3 -1
  25. package/es/locales/zh-CN.d.ts +2 -0
  26. package/es/locales/zh-CN.js +3 -1
  27. package/es/locales/zh-TW.d.ts +2 -0
  28. package/es/locales/zh-TW.js +3 -1
  29. package/lib/components/appVersionControl/index.js +26 -46
  30. package/lib/components/appVersionControl/index.less +2 -4
  31. package/lib/components/appVersionControl/types.d.ts +4 -1
  32. package/lib/components/appVersionControl/utils.d.ts +13 -0
  33. package/lib/components/appVersionControl/utils.js +52 -0
  34. package/lib/components/customSelect/index.d.ts +2 -2
  35. package/lib/components/customSelect/index.js +1 -0
  36. package/lib/components/versionModal/index.d.ts +7 -0
  37. package/lib/components/versionModal/index.js +33 -8
  38. package/lib/components/versionSelect/index.d.ts +18 -0
  39. package/lib/components/versionSelect/index.js +91 -0
  40. package/lib/components/versionSelect/index.less +3 -0
  41. package/lib/locales/en-US.d.ts +2 -0
  42. package/lib/locales/en-US.js +3 -1
  43. package/lib/locales/zh-CN.d.ts +2 -0
  44. package/lib/locales/zh-CN.js +3 -1
  45. package/lib/locales/zh-TW.d.ts +2 -0
  46. package/lib/locales/zh-TW.js +3 -1
  47. package/lowcode/data-source-form/meta.ts +1 -1
  48. package/lowcode/data-source-image/meta.ts +1 -1
  49. package/lowcode/data-source-qrcode/meta.ts +1 -1
  50. package/lowcode/data-source-table/meta.ts +1 -1
  51. package/lowcode/data-source-typography.text/meta.ts +1 -1
  52. package/lowcode/data-source-wrapper/meta.ts +1 -1
  53. package/lowcode/form-group/meta.ts +1 -1
  54. package/lowcode/form-item-checkbox/meta.ts +1 -1
  55. package/lowcode/form-item-checkbox.group/meta.ts +1 -1
  56. package/lowcode/form-item-color-picker/meta.ts +1 -1
  57. package/lowcode/form-item-date-picker/meta.ts +1 -1
  58. package/lowcode/form-item-icon-select/meta.ts +1 -1
  59. package/lowcode/form-item-input/meta.ts +1 -1
  60. package/lowcode/form-item-input-number/meta.ts +1 -1
  61. package/lowcode/form-item-input.email/meta.ts +1 -1
  62. package/lowcode/form-item-input.json/meta.ts +1 -1
  63. package/lowcode/form-item-input.mobile/meta.ts +1 -1
  64. package/lowcode/form-item-input.password/meta.ts +1 -1
  65. package/lowcode/form-item-input.phone/meta.ts +1 -1
  66. package/lowcode/form-item-input.subdomain/meta.ts +1 -1
  67. package/lowcode/form-item-input.text-area/meta.ts +1 -1
  68. package/lowcode/form-item-input.url/meta.ts +1 -1
  69. package/lowcode/form-item-radio/meta.ts +1 -1
  70. package/lowcode/form-item-radio.group/meta.ts +1 -1
  71. package/lowcode/form-item-select/meta.ts +1 -1
  72. package/lowcode/form-item-time-picker/meta.ts +1 -1
  73. package/lowcode/form-item-translation/meta.ts +1 -1
  74. package/lowcode/form-item-upload/meta.ts +1 -1
  75. package/lowcode/json-wrapper/meta.ts +1 -1
  76. package/lowcode/submit-button/meta.ts +1 -1
  77. package/package.json +1 -1
@@ -11,27 +11,16 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
11
11
  import classNames from 'classnames';
12
12
  import React, { useMemo, useState } from 'react';
13
13
  import Button from "../button";
14
- import CustomSelect from "../customSelect";
15
14
  import PisellCard from "../pisellCard";
16
15
  import PisellModal from "../pisellModal";
17
16
  import PisellAvatar from "../pisellAvatar";
18
17
  import Icon from "../icon";
19
- import PisellRow from "../pisellRow";
20
- import PisellTags from "../pisellTags";
21
18
  import PublishVersionModal from "../versionModal";
19
+ import VersionSelect from "../versionSelect";
20
+ import PisellToast from "../pisellToast";
22
21
  import { getText } from "../../locales";
22
+ import { getMaxVersion } from "./utils";
23
23
  import "./index.less";
24
- var getStatusColor = function getStatusColor(status) {
25
- if (status === 'live') return 'success';
26
- if (status === 'draft') return 'warning';
27
- if (status === 'deprecated') return 'error';
28
- return 'gray';
29
- };
30
- var getStatusText = function getStatusText(status) {
31
- if (status === 'live') return getText('pisell-lowcode-app-version-control-live');
32
- if (status === 'draft') return getText('pisell-lowcode-app-version-control-draft');
33
- if (status === 'deprecated') return getText('pisell-lowcode-app-version-control-deprecated');
34
- };
35
24
  var AppVersionControl = function AppVersionControl(props) {
36
25
  var value = props.value,
37
26
  _props$versions = props.versions,
@@ -69,12 +58,11 @@ var AppVersionControl = function AppVersionControl(props) {
69
58
  });
70
59
  }, [value, versions]);
71
60
 
72
- // 从versions中获取live版本信息
73
- var liveVersion = useMemo(function () {
74
- var _versions$find;
75
- return (_versions$find = versions.find(function (v) {
76
- return v.status === 'live';
77
- })) === null || _versions$find === void 0 ? void 0 : _versions$find.version;
61
+ // 获取最大版本
62
+ var maxVersion = useMemo(function () {
63
+ return getMaxVersion(versions.map(function (v) {
64
+ return v.version;
65
+ }));
78
66
  }, [versions]);
79
67
  var handlePromoteToLive = /*#__PURE__*/function () {
80
68
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
@@ -109,30 +97,50 @@ var AppVersionControl = function AppVersionControl(props) {
109
97
  }();
110
98
  var handlePublishVersion = /*#__PURE__*/function () {
111
99
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(data) {
100
+ var version;
112
101
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
113
102
  while (1) switch (_context2.prev = _context2.next) {
114
103
  case 0:
115
104
  setPublishLoading(true);
116
- _context2.prev = 1;
117
- _context2.next = 4;
118
- return onCreateVersion === null || onCreateVersion === void 0 ? void 0 : onCreateVersion(data.version);
119
- case 4:
105
+ if (!(data.versionType === 'custom')) {
106
+ _context2.next = 6;
107
+ break;
108
+ }
109
+ version = versions.find(function (v) {
110
+ return v.version === data.version;
111
+ });
112
+ if (!version) {
113
+ _context2.next = 6;
114
+ break;
115
+ }
116
+ setPublishLoading(false);
117
+ return _context2.abrupt("return", PisellToast({
118
+ content: getText('pisell-lowcode-app-version-control-version-exists')
119
+ }));
120
+ case 6:
121
+ _context2.prev = 6;
122
+ _context2.next = 9;
123
+ return onCreateVersion === null || onCreateVersion === void 0 ? void 0 : onCreateVersion({
124
+ version: data.version,
125
+ baseVersion: data.baseVersion || ''
126
+ });
127
+ case 9:
120
128
  setPublishVersionModal(false);
121
- _context2.next = 10;
129
+ _context2.next = 15;
122
130
  break;
123
- case 7:
124
- _context2.prev = 7;
125
- _context2.t0 = _context2["catch"](1);
131
+ case 12:
132
+ _context2.prev = 12;
133
+ _context2.t0 = _context2["catch"](6);
126
134
  console.error('Failed to create version:', _context2.t0);
127
- case 10:
128
- _context2.prev = 10;
135
+ case 15:
136
+ _context2.prev = 15;
129
137
  setPublishLoading(false);
130
- return _context2.finish(10);
131
- case 13:
138
+ return _context2.finish(15);
139
+ case 18:
132
140
  case "end":
133
141
  return _context2.stop();
134
142
  }
135
- }, _callee2, null, [[1, 7, 10, 13]]);
143
+ }, _callee2, null, [[6, 12, 15, 18]]);
136
144
  }));
137
145
  return function handlePublishVersion(_x2) {
138
146
  return _ref2.apply(this, arguments);
@@ -162,24 +170,10 @@ var AppVersionControl = function AppVersionControl(props) {
162
170
  className: "pisell-lowcode-app-version-control-avatar-icon"
163
171
  })), /*#__PURE__*/React.createElement("div", {
164
172
  className: "pisell-lowcode-app-version-control-title"
165
- }, currentVersion === null || currentVersion === void 0 ? void 0 : currentVersion.label), /*#__PURE__*/React.createElement(CustomSelect, {
166
- options: versions,
173
+ }, currentVersion === null || currentVersion === void 0 ? void 0 : currentVersion.label), /*#__PURE__*/React.createElement(VersionSelect, {
174
+ versions: versions,
167
175
  value: value,
168
- size: "large",
169
- onChange: handleVersionChange,
170
- style: {
171
- width: '100%'
172
- },
173
- renderItem: function renderItem(option) {
174
- return /*#__PURE__*/React.createElement(PisellRow, {
175
- leftContent: option.label,
176
- rightContent: /*#__PURE__*/React.createElement(PisellTags, {
177
- type: 'pill_color',
178
- color: getStatusColor(option.status),
179
- className: "pisell-lowcode-app-version-control-tag"
180
- }, getStatusText(option.status))
181
- });
182
- }
176
+ onChange: handleVersionChange
183
177
  }), allowCreate && /*#__PURE__*/React.createElement(Button, {
184
178
  icon: /*#__PURE__*/React.createElement(Icon, {
185
179
  type: "pisell2-plus"
@@ -208,14 +202,17 @@ var AppVersionControl = function AppVersionControl(props) {
208
202
  return setPromoteToLiveModal(false);
209
203
  }
210
204
  }), /*#__PURE__*/React.createElement(PublishVersionModal, {
211
- currentVersion: liveVersion || '',
205
+ currentVersion: maxVersion || '',
212
206
  visible: publishVersionModal,
213
207
  onCancel: function onCancel() {
214
208
  return setPublishVersionModal(false);
215
209
  },
216
210
  onConfirm: handlePublishVersion,
217
211
  isShowNote: false,
218
- confirmLoading: publishLoading
212
+ confirmLoading: publishLoading,
213
+ versions: versions,
214
+ isShowBasedOn: true,
215
+ isValidateVersion: false
219
216
  }));
220
217
  };
221
218
  export default AppVersionControl;
@@ -1,5 +1,6 @@
1
1
  .pisell-lowcode-app-version-control {
2
2
  background-color: #fff;
3
+ cursor: default;
3
4
  .pisell-lowcode-card-body {
4
5
  display: flex;
5
6
  flex-direction: column;
@@ -28,7 +29,4 @@
28
29
  &:hover {
29
30
  background: #fff !important;
30
31
  }
31
- }
32
- .pisell-lowcode-app-version-control-tag {
33
- line-height: 20px;
34
- }
32
+ }
@@ -11,7 +11,10 @@ export interface AppVersionControlProps {
11
11
  value: string;
12
12
  versions: Version[];
13
13
  onVersionChange: (value: string, version: Version) => void;
14
- onCreateVersion: (version: string) => Promise<boolean | undefined>;
14
+ onCreateVersion: (detail: {
15
+ version: string;
16
+ baseVersion: string;
17
+ }) => Promise<boolean | undefined>;
15
18
  onPromoteToLive: (value: string, version: Version) => Promise<boolean | undefined>;
16
19
  allowPublish?: boolean;
17
20
  allowCreate?: boolean;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * 比较两个版本号
3
+ * @param version1 版本号1
4
+ * @param version2 版本号2
5
+ * @returns 如果version1大于version2返回1,相等返回0,小于返回-1
6
+ */
7
+ export declare const compareVersions: (version1: string, version2: string) => number;
8
+ /**
9
+ * 从版本号列表中获取最大版本号
10
+ * @param versions 版本号列表
11
+ * @returns 最大的版本号,如果列表为空返回undefined
12
+ */
13
+ export declare const getMaxVersion: (versions: string[]) => string | undefined;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * 比较两个版本号
3
+ * @param version1 版本号1
4
+ * @param version2 版本号2
5
+ * @returns 如果version1大于version2返回1,相等返回0,小于返回-1
6
+ */
7
+ export var compareVersions = function compareVersions(version1, version2) {
8
+ var v1Parts = version1.split('.').map(Number);
9
+ var v2Parts = version2.split('.').map(Number);
10
+ for (var i = 0; i < Math.max(v1Parts.length, v2Parts.length); i++) {
11
+ var v1Part = v1Parts[i] || 0;
12
+ var v2Part = v2Parts[i] || 0;
13
+ if (v1Part > v2Part) return 1;
14
+ if (v1Part < v2Part) return -1;
15
+ }
16
+ return 0;
17
+ };
18
+
19
+ /**
20
+ * 从版本号列表中获取最大版本号
21
+ * @param versions 版本号列表
22
+ * @returns 最大的版本号,如果列表为空返回undefined
23
+ */
24
+ export var getMaxVersion = function getMaxVersion(versions) {
25
+ if (!versions || versions.length === 0) return undefined;
26
+ return versions.reduce(function (max, current) {
27
+ if (!max) return current;
28
+ return compareVersions(current, max) > 0 ? current : max;
29
+ }, versions[0]);
30
+ };
@@ -7,8 +7,8 @@ export interface BaseOption {
7
7
  }
8
8
  export interface CustomSelectProps<T extends BaseOption> extends Omit<SelectProps<T['value']>, 'options' | 'value' | 'onChange'> {
9
9
  options: T[];
10
- value: T['value'];
11
- onChange: (value: T['value']) => void;
10
+ value?: T['value'];
11
+ onChange?: (value: T['value']) => void;
12
12
  renderItem?: (option: T) => React.ReactNode;
13
13
  className?: string;
14
14
  style?: React.CSSProperties;
@@ -1,4 +1,10 @@
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); }
1
2
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3
+ 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; }
4
+ 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; }
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; }
6
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
7
+ 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); }
2
8
  import React, { useMemo } from 'react';
3
9
  import classNames from 'classnames';
4
10
  import Select from "../select";
@@ -10,10 +16,10 @@ var CustomSelect = function CustomSelect(props) {
10
16
  renderItem = props.renderItem;
11
17
  var options = useMemo(function () {
12
18
  return propsOptions.map(function (option) {
13
- return {
19
+ return _objectSpread(_objectSpread({}, option), {}, {
14
20
  label: renderItem ? renderItem(option) : option.label,
15
21
  value: option.value
16
- };
22
+ });
17
23
  });
18
24
  }, [propsOptions, renderItem]);
19
25
  return /*#__PURE__*/React.createElement(Select, _extends({}, props, {
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { Version } from '../versionSelect';
2
3
  import './index.less';
3
4
  interface PublishVersionModalProps {
4
5
  visible: boolean;
@@ -7,10 +8,16 @@ interface PublishVersionModalProps {
7
8
  onConfirm: (data: VersionData) => void;
8
9
  isShowNote?: boolean;
9
10
  confirmLoading?: boolean;
11
+ versions?: Version[];
12
+ isShowBasedOn?: boolean;
13
+ isShowCurrentVersion?: boolean;
14
+ isValidateVersion?: boolean;
10
15
  }
11
16
  interface VersionData {
12
17
  version: string;
13
18
  note: string;
19
+ baseVersion?: string;
20
+ versionType?: string;
14
21
  }
15
22
  declare const PublishVersionModal: React.FC<PublishVersionModalProps>;
16
23
  export default PublishVersionModal;
@@ -7,6 +7,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
7
  import React, { useEffect, useState } from 'react';
8
8
  import { Radio, Input, Form, Row, Col, message, InputNumber } from 'antd';
9
9
  import PisellModal from "../pisellModal";
10
+ import VersionSelect from "../versionSelect";
10
11
  import { getText } from "../../locales";
11
12
  import "./index.less";
12
13
  var style = {
@@ -58,14 +59,19 @@ var PublishVersionModal = function PublishVersionModal(_ref) {
58
59
  currentVersion = _ref$currentVersion === void 0 ? '1.0.0' : _ref$currentVersion,
59
60
  onCancel = _ref.onCancel,
60
61
  onConfirm = _ref.onConfirm,
61
- _ref$isShowNote = _ref.isShowNote,
62
- isShowNote = _ref$isShowNote === void 0 ? true : _ref$isShowNote,
62
+ isShowNote = _ref.isShowNote,
63
63
  _ref$confirmLoading = _ref.confirmLoading,
64
- confirmLoading = _ref$confirmLoading === void 0 ? false : _ref$confirmLoading;
64
+ confirmLoading = _ref$confirmLoading === void 0 ? false : _ref$confirmLoading,
65
+ _ref$versions = _ref.versions,
66
+ versions = _ref$versions === void 0 ? [] : _ref$versions,
67
+ isShowBasedOn = _ref.isShowBasedOn,
68
+ isShowCurrentVersion = _ref.isShowCurrentVersion,
69
+ _ref$isValidateVersio = _ref.isValidateVersion,
70
+ isValidateVersion = _ref$isValidateVersio === void 0 ? true : _ref$isValidateVersio;
65
71
  var _Form$useForm = Form.useForm(),
66
72
  _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
67
73
  form = _Form$useForm2[0];
68
- var _useState = useState('patch'),
74
+ var _useState = useState(''),
69
75
  _useState2 = _slicedToArray(_useState, 2),
70
76
  versionType = _useState2[0],
71
77
  setVersionType = _useState2[1];
@@ -79,9 +85,12 @@ var PublishVersionModal = function PublishVersionModal(_ref) {
79
85
  var handleSubmit = function handleSubmit() {
80
86
  form.validateFields().then(function (values) {
81
87
  var version = values.version,
82
- note = values.note;
88
+ note = values.note,
89
+ baseVersion = values.baseVersion;
90
+ var versionType = '';
83
91
  if (version === 'custom') {
84
- if (!isVersionValid("".concat(values.major, ".").concat(values.minor, ".").concat(values.patch), currentVersion)) {
92
+ versionType = 'custom';
93
+ if (isValidateVersion && !isVersionValid("".concat(values.major, ".").concat(values.minor, ".").concat(values.patch), currentVersion)) {
85
94
  message.error(getText('pisell-version-modal-version-error'));
86
95
  return;
87
96
  }
@@ -89,17 +98,21 @@ var PublishVersionModal = function PublishVersionModal(_ref) {
89
98
  }
90
99
  onConfirm({
91
100
  version: version,
92
- note: note
101
+ note: note,
102
+ baseVersion: baseVersion,
103
+ versionType: versionType
93
104
  });
94
105
  });
95
106
  };
96
107
  useEffect(function () {
97
108
  if (visible) {
109
+ setVersionType('');
98
110
  form.setFieldsValue({
99
111
  version: patch,
100
112
  major: parseVersion(patch)[0] || 0,
101
113
  minor: parseVersion(patch)[1] || 0,
102
- patch: parseVersion(patch)[2] || 0
114
+ patch: parseVersion(patch)[2] || 0,
115
+ baseVersion: currentVersion
103
116
  });
104
117
  }
105
118
  }, [visible]);
@@ -117,7 +130,21 @@ var PublishVersionModal = function PublishVersionModal(_ref) {
117
130
  layout: "vertical",
118
131
  preserve: false,
119
132
  className: "pisell-lowcode-version-modal-form"
120
- }, /*#__PURE__*/React.createElement("p", null, getText('pisell-version-modal-current-version'), ": ", currentVersion), /*#__PURE__*/React.createElement(Form.Item, {
133
+ }, isShowCurrentVersion && /*#__PURE__*/React.createElement("p", null, getText('pisell-version-modal-current-version'), ": ", currentVersion), isShowBasedOn && /*#__PURE__*/React.createElement(Form.Item, {
134
+ label: getText('pisell-version-modal-based-on-version'),
135
+ name: "baseVersion",
136
+ initialValue: currentVersion,
137
+ rules: [{
138
+ required: true
139
+ }]
140
+ }, /*#__PURE__*/React.createElement(VersionSelect, {
141
+ versions: versions,
142
+ fieldNames: {
143
+ label: 'label',
144
+ value: 'version',
145
+ options: 'options'
146
+ }
147
+ })), /*#__PURE__*/React.createElement(Form.Item, {
121
148
  label: getText('pisell-version-modal-version'),
122
149
  name: "version",
123
150
  initialValue: "patch",
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import { SelectProps } from 'antd';
3
+ import './index.less';
4
+ export interface Version {
5
+ id: string;
6
+ label: string;
7
+ value: string;
8
+ status: 'live' | 'draft' | 'deprecated';
9
+ version: string;
10
+ avatar?: string;
11
+ }
12
+ interface VersionSelectProps extends Omit<SelectProps<string>, 'onChange' | 'options'> {
13
+ versions: Version[];
14
+ value?: string;
15
+ onChange?: (value: string, version: Version) => void;
16
+ }
17
+ declare const VersionSelect: (props: VersionSelectProps) => React.JSX.Element;
18
+ export default VersionSelect;
@@ -0,0 +1,53 @@
1
+ var _excluded = ["versions", "value", "onChange"];
2
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3
+ 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; }
4
+ 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; }
5
+ import React from 'react';
6
+ import CustomSelect from "../customSelect";
7
+ import PisellRow from "../pisellRow";
8
+ import PisellTags from "../pisellTags";
9
+ import { getText } from "../../locales";
10
+ import "./index.less";
11
+ var getStatusColor = function getStatusColor(status) {
12
+ if (status === 'live') return 'success';
13
+ if (status === 'draft') return 'warning';
14
+ if (status === 'deprecated') return 'error';
15
+ return 'gray';
16
+ };
17
+ var getStatusText = function getStatusText(status) {
18
+ if (status === 'live') return getText('pisell-lowcode-app-version-control-live');
19
+ if (status === 'draft') return getText('pisell-lowcode-app-version-control-draft');
20
+ if (status === 'deprecated') return getText('pisell-lowcode-app-version-control-deprecated');
21
+ };
22
+ var VersionSelect = function VersionSelect(props) {
23
+ var versions = props.versions,
24
+ value = props.value,
25
+ onChange = props.onChange,
26
+ rest = _objectWithoutProperties(props, _excluded);
27
+ var handleVersionChange = function handleVersionChange(value) {
28
+ var version = versions.find(function (v) {
29
+ return v.value === value;
30
+ });
31
+ onChange === null || onChange === void 0 ? void 0 : onChange(value, version);
32
+ };
33
+ return /*#__PURE__*/React.createElement(CustomSelect, _extends({}, rest, {
34
+ options: versions,
35
+ value: value,
36
+ size: "large",
37
+ onChange: handleVersionChange,
38
+ style: {
39
+ width: '100%'
40
+ },
41
+ renderItem: function renderItem(option) {
42
+ return /*#__PURE__*/React.createElement(PisellRow, {
43
+ leftContent: option.label,
44
+ rightContent: /*#__PURE__*/React.createElement(PisellTags, {
45
+ type: 'pill_color',
46
+ color: getStatusColor(option.status),
47
+ className: "pisell-lowcode-version-select-tag"
48
+ }, getStatusText(option.status))
49
+ });
50
+ }
51
+ }));
52
+ };
53
+ export default VersionSelect;
@@ -0,0 +1,3 @@
1
+ .pisell-lowcode-version-select-tag {
2
+ line-height: 20px;
3
+ }
@@ -189,6 +189,7 @@ declare const _default: {
189
189
  'pisell-version-modal-describe-update-notes': string;
190
190
  'pisell-version-modal-version-error': string;
191
191
  'pisell-version-modal-version-required': string;
192
+ 'pisell-version-modal-based-on-version': string;
192
193
  'pisell-icon-select-outlined': string;
193
194
  'pisell-icon-select-filled': string;
194
195
  'pisell-icon-select-two-tone': string;
@@ -211,5 +212,6 @@ declare const _default: {
211
212
  'pisell-lowcode-app-version-control-promote-version-describe': string;
212
213
  'pisell-lowcode-app-version-control-promote-version-ok': string;
213
214
  'pisell-lowcode-app-version-control-promote-version-cancel': string;
215
+ 'pisell-lowcode-app-version-control-version-exists': string;
214
216
  };
215
217
  export default _default;
@@ -241,6 +241,7 @@ export default {
241
241
  'pisell-version-modal-describe-update-notes': 'Describe the main changes in this version...',
242
242
  'pisell-version-modal-version-error': 'Version number must be greater than the current version',
243
243
  'pisell-version-modal-version-required': 'Version number is required',
244
+ 'pisell-version-modal-based-on-version': 'Based on version',
244
245
  // 图标选择组件
245
246
  'pisell-icon-select-outlined': 'Outlined',
246
247
  'pisell-icon-select-filled': 'Filled',
@@ -267,5 +268,6 @@ export default {
267
268
  },
268
269
  'pisell-lowcode-app-version-control-promote-version-describe': 'Promoting this version will lock it further changes',
269
270
  'pisell-lowcode-app-version-control-promote-version-ok': 'Promote',
270
- 'pisell-lowcode-app-version-control-promote-version-cancel': 'Cancel'
271
+ 'pisell-lowcode-app-version-control-promote-version-cancel': 'Cancel',
272
+ 'pisell-lowcode-app-version-control-version-exists': 'Version already exists'
271
273
  };
@@ -189,6 +189,7 @@ declare const _default: {
189
189
  'pisell-version-modal-describe-update-notes': string;
190
190
  'pisell-version-modal-version-error': string;
191
191
  'pisell-version-modal-version-required': string;
192
+ 'pisell-version-modal-based-on-version': string;
192
193
  'pisell-icon-select-outlined': string;
193
194
  'pisell-icon-select-filled': string;
194
195
  'pisell-icon-select-two-tone': string;
@@ -210,5 +211,6 @@ declare const _default: {
210
211
  'pisell-lowcode-app-version-control-promote-version-describe': string;
211
212
  'pisell-lowcode-app-version-control-promote-version-ok': string;
212
213
  'pisell-lowcode-app-version-control-promote-version-cancel': string;
214
+ 'pisell-lowcode-app-version-control-version-exists': string;
213
215
  };
214
216
  export default _default;
@@ -240,6 +240,7 @@ export default {
240
240
  'pisell-version-modal-describe-update-notes': '描述此版本的主要更改...',
241
241
  'pisell-version-modal-version-error': '版本号必须大于当前版本',
242
242
  'pisell-version-modal-version-required': '版本号为必填项',
243
+ 'pisell-version-modal-based-on-version': '基于版本',
243
244
  'pisell-icon-select-outlined': '线框风格',
244
245
  'pisell-icon-select-filled': '实底风格',
245
246
  'pisell-icon-select-two-tone': '双色风格',
@@ -264,5 +265,6 @@ export default {
264
265
  },
265
266
  'pisell-lowcode-app-version-control-promote-version-describe': '发布版本后,该版本将无法再进行修改',
266
267
  'pisell-lowcode-app-version-control-promote-version-ok': '发布',
267
- 'pisell-lowcode-app-version-control-promote-version-cancel': '取消'
268
+ 'pisell-lowcode-app-version-control-promote-version-cancel': '取消',
269
+ 'pisell-lowcode-app-version-control-version-exists': '版本已存在'
268
270
  };
@@ -188,6 +188,7 @@ declare const _default: {
188
188
  'pisell-version-modal-describe-update-notes': string;
189
189
  'pisell-version-modal-version-error': string;
190
190
  'pisell-version-modal-version-required': string;
191
+ 'pisell-version-modal-based-on-version': string;
191
192
  'pisell-icon-select-placeholder': string;
192
193
  'pisell-icon-select-outlined': string;
193
194
  'pisell-icon-select-filled': string;
@@ -210,5 +211,6 @@ declare const _default: {
210
211
  'pisell-lowcode-app-version-control-promote-version-describe': string;
211
212
  'pisell-lowcode-app-version-control-promote-version-ok': string;
212
213
  'pisell-lowcode-app-version-control-promote-version-cancel': string;
214
+ 'pisell-lowcode-app-version-control-version-exists': string;
213
215
  };
214
216
  export default _default;
@@ -240,6 +240,7 @@ export default {
240
240
  'pisell-version-modal-describe-update-notes': '描述此版本的主要更改...',
241
241
  'pisell-version-modal-version-error': '版本號必須大於當前版本',
242
242
  'pisell-version-modal-version-required': '版本號為必填項',
243
+ 'pisell-version-modal-based-on-version': '基於版本',
243
244
  // 图标选择组件
244
245
  'pisell-icon-select-placeholder': '選擇圖標',
245
246
  'pisell-icon-select-outlined': '線框風格',
@@ -266,5 +267,6 @@ export default {
266
267
  },
267
268
  'pisell-lowcode-app-version-control-promote-version-describe': '發布版本後,該版本將無法再進行修改',
268
269
  'pisell-lowcode-app-version-control-promote-version-ok': '發布',
269
- 'pisell-lowcode-app-version-control-promote-version-cancel': '取消'
270
+ 'pisell-lowcode-app-version-control-promote-version-cancel': '取消',
271
+ 'pisell-lowcode-app-version-control-version-exists': '版本已存在'
270
272
  };