iglooform 2.5.13 → 2.5.16

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.
@@ -2,5 +2,7 @@ import { FC } from 'react';
2
2
  declare const Documents: FC<{
3
3
  docList: string[];
4
4
  docNames?: string[];
5
+ showAllPages?: boolean;
6
+ destroyOnClose?: boolean;
5
7
  }>;
6
8
  export default Documents;
@@ -26,7 +26,11 @@ var Documents = function Documents(_ref) {
26
26
  var _ref$docList = _ref.docList,
27
27
  docList = _ref$docList === void 0 ? [] : _ref$docList,
28
28
  _ref$docNames = _ref.docNames,
29
- docNames = _ref$docNames === void 0 ? [] : _ref$docNames;
29
+ docNames = _ref$docNames === void 0 ? [] : _ref$docNames,
30
+ _ref$showAllPages = _ref.showAllPages,
31
+ showAllPages = _ref$showAllPages === void 0 ? true : _ref$showAllPages,
32
+ _ref$destroyOnClose = _ref.destroyOnClose,
33
+ destroyOnClose = _ref$destroyOnClose === void 0 ? true : _ref$destroyOnClose;
30
34
 
31
35
  var _useState = useState(0),
32
36
  _useState2 = _slicedToArray(_useState, 2),
@@ -109,7 +113,9 @@ var Documents = function Documents(_ref) {
109
113
  src: src,
110
114
  type: type,
111
115
  docNames: docNames,
112
- name: docNames[index]
116
+ name: docNames[index],
117
+ showAllPages: showAllPages,
118
+ destroyOnClose: destroyOnClose
113
119
  })
114
120
  }, index);
115
121
  })
@@ -6,7 +6,9 @@ export interface AmountProps extends InputProps, IglooComponentProps {
6
6
  currencyProps?: InputProps;
7
7
  amount?: number;
8
8
  amountProps?: InputProps;
9
- seperator?: ',';
9
+ seperator?: ',' | '.';
10
+ separator?: ',' | '.';
11
+ decimalSeparator?: ',' | '.';
10
12
  }
11
13
  declare const Amount: FC<AmountProps>;
12
14
  export default Amount;
@@ -1,6 +1,6 @@
1
1
  import "antd/es/input/style";
2
2
  import _Input from "antd/es/input";
3
- var _excluded = ["className", "currency", "currencyProps", "amountProps", "value", "seperator", "disabled"];
3
+ var _excluded = ["className", "currency", "currencyProps", "amountProps", "value", "seperator", "separator", "decimalSeparator", "disabled"];
4
4
 
5
5
  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; }
6
6
 
@@ -19,16 +19,16 @@ import classnames from 'classnames';
19
19
  import { staticFormatMessage } from '../locale';
20
20
  import './style/index.less';
21
21
 
22
- var thousands = function thousands(number) {
22
+ var thousands = function thousands(number, decimalSeparator, separator) {
23
23
  if (number === null || number === undefined) return undefined;
24
- var arr = String(number).split('.');
24
+ var arr = String(number).replace('.', decimalSeparator).split(decimalSeparator);
25
25
  return arr.map(function (s, index) {
26
26
  if (index === 0) {
27
- return s.replace(/(?=(?!\b)(\d{3})+$)/g, ',');
27
+ return s.replace(/(?=(?!\b)(\d{3})+$)/g, separator);
28
28
  }
29
29
 
30
- return s.replace(/(\d{3})(?=[^$])/g, '$1,');
31
- }).join('.');
30
+ return s.replace(/(\d{3})(?=[^$])/g, "$1".concat(separator));
31
+ }).join(decimalSeparator);
32
32
  };
33
33
 
34
34
  var Amount = function Amount(_ref) {
@@ -39,8 +39,11 @@ var Amount = function Amount(_ref) {
39
39
  _ref$amountProps = _ref.amountProps,
40
40
  amountProps = _ref$amountProps === void 0 ? {} : _ref$amountProps,
41
41
  value = _ref.value,
42
- _ref$seperator = _ref.seperator,
43
- seperator = _ref$seperator === void 0 ? ',' : _ref$seperator,
42
+ seperator = _ref.seperator,
43
+ _ref$separator = _ref.separator,
44
+ separator = _ref$separator === void 0 ? seperator || ',' : _ref$separator,
45
+ _ref$decimalSeparator = _ref.decimalSeparator,
46
+ decimalSeparator = _ref$decimalSeparator === void 0 ? '.' : _ref$decimalSeparator,
44
47
  disabled = _ref.disabled,
45
48
  rest = _objectWithoutProperties(_ref, _excluded);
46
49
 
@@ -48,11 +51,11 @@ var Amount = function Amount(_ref) {
48
51
  var onChange = rest.onChange;
49
52
 
50
53
  if (typeof value === 'string') {
51
- if (value.endsWith('.')) {
52
- e.target.value = value.replace('.', '');
54
+ if (value.endsWith(decimalSeparator)) {
55
+ e.target.value = value.replace(decimalSeparator, '');
53
56
  }
54
57
 
55
- if (value.endsWith('0') && value.includes('.')) {
58
+ if (value.endsWith('0') && value.includes(decimalSeparator)) {
56
59
  e.target.value = value.replace(/[0]+$/, '');
57
60
  }
58
61
 
@@ -67,7 +70,7 @@ var Amount = function Amount(_ref) {
67
70
  className: classnames('igloo-input-amount', {
68
71
  'igloo-input-disable': disabled
69
72
  }, className),
70
- value: thousands(value),
73
+ value: thousands(value, decimalSeparator, separator),
71
74
  addonBefore: currency ? _jsx("span", {
72
75
  className: "igloo-input-areacode",
73
76
  children: currency
@@ -76,24 +79,31 @@ var Amount = function Amount(_ref) {
76
79
  };
77
80
 
78
81
  Amount.formItemPropsHandler = function (_ref2) {
79
- var _ref2$seperator = _ref2.seperator,
80
- seperator = _ref2$seperator === void 0 ? ',' : _ref2$seperator;
82
+ var _ref2$separator = _ref2.separator,
83
+ separator = _ref2$separator === void 0 ? ',' : _ref2$separator,
84
+ _ref2$decimalSeparato = _ref2.decimalSeparator,
85
+ decimalSeparator = _ref2$decimalSeparato === void 0 ? '.' : _ref2$decimalSeparato;
81
86
  return {
82
87
  getValueFromEvent: function getValueFromEvent(e) {
83
88
  var value = e.target.value;
84
- var str = value.replaceAll(seperator, '').replaceAll(/[^0-9\.]/g, '');
89
+ console.log('======', separator, decimalSeparator);
90
+ var str = value.replaceAll(separator, '').replaceAll(/[^0-9\.,]/g, '');
85
91
 
86
- if (str.endsWith('.') || str.includes('.') && str.endsWith('0')) {
92
+ if (str.endsWith(decimalSeparator) || str.includes(decimalSeparator) && str.endsWith('0')) {
87
93
  return str;
88
94
  }
89
95
 
96
+ if (decimalSeparator === ',') {
97
+ str = str.replace(',', '.');
98
+ }
99
+
90
100
  return str ? parseFloat(str) : undefined;
91
101
  },
92
102
  rules: [{
93
103
  validator: function validator(_, value) {
94
104
  if (!value) return Promise.resolve();
95
- var seperatorArr = String(value).split('.');
96
- return seperatorArr.length > 2 ? Promise.reject(staticFormatMessage({
105
+ var separatorArr = String(value).split(decimalSeparator);
106
+ return separatorArr.length > 2 ? Promise.reject(staticFormatMessage({
97
107
  id: 'Please enter a valid amount.'
98
108
  })) : Promise.resolve();
99
109
  }
@@ -12,6 +12,8 @@ interface Props {
12
12
  docNames?: string[];
13
13
  className?: any;
14
14
  style?: CSSProperties;
15
+ showAllPages?: boolean;
16
+ destroyOnClose?: boolean;
15
17
  }
16
18
  declare const MediaWithPreview: FC<Props>;
17
19
  export default MediaWithPreview;
package/es/media/index.js CHANGED
@@ -50,7 +50,11 @@ var MediaWithPreview = function MediaWithPreview(_ref) {
50
50
  _ref$type = _ref.type,
51
51
  type = _ref$type === void 0 ? '' : _ref$type,
52
52
  _ref$docNames = _ref.docNames,
53
- docNames = _ref$docNames === void 0 ? [] : _ref$docNames;
53
+ docNames = _ref$docNames === void 0 ? [] : _ref$docNames,
54
+ _ref$showAllPages = _ref.showAllPages,
55
+ showAllPages = _ref$showAllPages === void 0 ? true : _ref$showAllPages,
56
+ _ref$destroyOnClose = _ref.destroyOnClose,
57
+ destroyOnClose = _ref$destroyOnClose === void 0 ? true : _ref$destroyOnClose;
54
58
 
55
59
  var _useState = useState(1),
56
60
  _useState2 = _slicedToArray(_useState, 2),
@@ -225,7 +229,7 @@ var MediaWithPreview = function MediaWithPreview(_ref) {
225
229
  }),
226
230
  wrapClassName: "igloo-media-preview",
227
231
  width: "100%",
228
- destroyOnClose: true,
232
+ destroyOnClose: destroyOnClose,
229
233
  children: [Boolean(docNames && docNames.length) && _jsxs("div", {
230
234
  className: "igloo-document-name",
231
235
  children: [_jsx("div", {
@@ -262,7 +266,8 @@ var MediaWithPreview = function MediaWithPreview(_ref) {
262
266
  type: mediaType,
263
267
  src: src,
264
268
  scale: scale,
265
- isCurrent: true
269
+ isCurrent: true,
270
+ showAllPages: showAllPages
266
271
  })
267
272
  }, index), _jsx(MinusOutlined, {
268
273
  onClick: zoomIn,
@@ -6,6 +6,7 @@ interface MediaProps {
6
6
  isCurrent?: boolean;
7
7
  className?: any;
8
8
  style?: CSSProperties;
9
+ showAllPages?: boolean;
9
10
  }
10
11
  declare const Media: FC<MediaProps>;
11
12
  export default Media;
@@ -1,3 +1,6 @@
1
+ import "antd/es/grid/style";
2
+ import _Grid from "antd/es/grid";
3
+
1
4
  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; }
2
5
 
3
6
  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; }
@@ -16,22 +19,35 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
16
19
 
17
20
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18
21
 
19
- import { jsx as _jsx } from "react/jsx-runtime";
22
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
20
23
  import { useState } from 'react';
21
24
  import { Document, Page } from 'react-pdf/dist/esm/entry.webpack';
25
+ import classnames from 'classnames';
26
+ import { ArrowLeftOutlined, ArrowRightOutlined } from 'iglooicon';
27
+ var useBreakpoint = _Grid.useBreakpoint;
22
28
 
23
29
  var PdfViewer = function PdfViewer(_ref) {
24
30
  var src = _ref.src,
25
31
  left = _ref.left,
26
32
  top = _ref.top,
27
33
  scale = _ref.scale,
28
- isCurrent = _ref.isCurrent;
34
+ isCurrent = _ref.isCurrent,
35
+ _ref$showAllPages = _ref.showAllPages,
36
+ showAllPages = _ref$showAllPages === void 0 ? true : _ref$showAllPages;
29
37
 
30
38
  var _useState = useState(1),
31
39
  _useState2 = _slicedToArray(_useState, 2),
32
40
  pageSize = _useState2[0],
33
41
  setPageSize = _useState2[1];
34
42
 
43
+ var _useState3 = useState(1),
44
+ _useState4 = _slicedToArray(_useState3, 2),
45
+ page = _useState4[0],
46
+ setPage = _useState4[1];
47
+
48
+ var _useBreakpoint = useBreakpoint(),
49
+ md = _useBreakpoint.md;
50
+
35
51
  var handlePageInit = function handlePageInit(document) {
36
52
  var _ref2 = document || {},
37
53
  numPages = _ref2.numPages;
@@ -41,27 +57,77 @@ var PdfViewer = function PdfViewer(_ref) {
41
57
  }
42
58
  };
43
59
 
44
- return _jsx("div", {
45
- style: {
46
- display: 'flex',
47
- flexDirection: 'column',
48
- maxWidth: '100%',
49
- maxHeight: '100%',
50
- transform: "translate(".concat(left, "px, ").concat(top, "px)"),
51
- position: 'absolute'
52
- },
53
- children: _jsx(Document, {
54
- file: src,
55
- onLoadSuccess: handlePageInit,
56
- children: Array.from({
57
- length: pageSize
58
- }).map(function (_, index) {
59
- return _jsx(Page, {
60
- pageNumber: index + 1,
60
+ if (showAllPages) {
61
+ return _jsx("div", {
62
+ style: {
63
+ display: 'flex',
64
+ flexDirection: 'column',
65
+ maxWidth: "calc(100vw - ".concat(md ? 64 : 32, "px)"),
66
+ maxHeight: '100%',
67
+ transform: "translate(".concat(left, "px, ").concat(top, "px)"),
68
+ position: 'absolute',
69
+ overflow: 'auto'
70
+ },
71
+ children: _jsx(Document, {
72
+ file: src,
73
+ onLoadSuccess: handlePageInit,
74
+ children: Array.from({
75
+ length: pageSize
76
+ }).map(function (_, index) {
77
+ return _jsx(Page, {
78
+ pageNumber: index + 1,
79
+ scale: scale
80
+ }, index);
81
+ })
82
+ })
83
+ });
84
+ }
85
+
86
+ return _jsxs(_Fragment, {
87
+ children: [_jsx("div", {
88
+ style: {
89
+ maxWidth: "calc(100vw - ".concat(md ? 64 : 32, "px)"),
90
+ maxHeight: '100%',
91
+ transform: "translate(".concat(left, "px, ").concat(top, "px)"),
92
+ position: 'absolute',
93
+ overflow: 'auto'
94
+ },
95
+ children: _jsx(Document, {
96
+ file: src,
97
+ onLoadSuccess: handlePageInit,
98
+ children: _jsx(Page, {
99
+ pageNumber: page,
61
100
  scale: scale
62
- }, index);
101
+ })
63
102
  })
64
- })
103
+ }), isCurrent && Boolean(pageSize > 1) && _jsxs("div", {
104
+ style: {
105
+ position: 'fixed',
106
+ bottom: 0,
107
+ right: 96,
108
+ height: 48,
109
+ zIndex: 2
110
+ },
111
+ children: [_jsx(ArrowLeftOutlined, {
112
+ onClick: function onClick() {
113
+ return setPage(page - 1);
114
+ },
115
+ className: classnames({
116
+ 'igloo-preview-page-btn': true,
117
+ 'igloo-preview-previous': true,
118
+ 'igloo-preview-disabled': page === 1
119
+ })
120
+ }), _jsx(ArrowRightOutlined, {
121
+ onClick: function onClick() {
122
+ return setPage(page + 1);
123
+ },
124
+ className: classnames({
125
+ 'igloo-preview-page-btn': true,
126
+ 'igloo-preview-next': true,
127
+ 'igloo-preview-disabled': page === pageSize
128
+ })
129
+ })]
130
+ })]
65
131
  });
66
132
  };
67
133
 
@@ -70,7 +136,8 @@ var MediaItem = function MediaItem(_ref3) {
70
136
  src = _ref3.src,
71
137
  scale = _ref3.scale,
72
138
  offset = _ref3.offset,
73
- isCurrent = _ref3.isCurrent;
139
+ isCurrent = _ref3.isCurrent,
140
+ showAllPages = _ref3.showAllPages;
74
141
  var top = offset.top,
75
142
  left = offset.left;
76
143
 
@@ -91,7 +158,8 @@ var MediaItem = function MediaItem(_ref3) {
91
158
  top: top,
92
159
  left: left,
93
160
  scale: scale,
94
- isCurrent: isCurrent
161
+ isCurrent: isCurrent,
162
+ showAllPages: showAllPages
95
163
  });
96
164
 
97
165
  default:
@@ -115,36 +183,38 @@ var Media = function Media(_ref4) {
115
183
  scale = _ref4$scale === void 0 ? 1 : _ref4$scale,
116
184
  type = _ref4.type,
117
185
  _ref4$isCurrent = _ref4.isCurrent,
118
- isCurrent = _ref4$isCurrent === void 0 ? false : _ref4$isCurrent;
186
+ isCurrent = _ref4$isCurrent === void 0 ? false : _ref4$isCurrent,
187
+ _ref4$showAllPages = _ref4.showAllPages,
188
+ showAllPages = _ref4$showAllPages === void 0 ? true : _ref4$showAllPages;
119
189
 
120
- var _useState3 = useState(false),
121
- _useState4 = _slicedToArray(_useState3, 2),
122
- isDrag = _useState4[0],
123
- setIsDrag = _useState4[1];
190
+ var _useState5 = useState(false),
191
+ _useState6 = _slicedToArray(_useState5, 2),
192
+ isDrag = _useState6[0],
193
+ setIsDrag = _useState6[1];
124
194
 
125
- var _useState5 = useState({
195
+ var _useState7 = useState({
126
196
  startX: 0,
127
197
  startY: 0
128
198
  }),
129
- _useState6 = _slicedToArray(_useState5, 2),
130
- startPos = _useState6[0],
131
- setStartPos = _useState6[1];
199
+ _useState8 = _slicedToArray(_useState7, 2),
200
+ startPos = _useState8[0],
201
+ setStartPos = _useState8[1];
132
202
 
133
- var _useState7 = useState({
203
+ var _useState9 = useState({
134
204
  top: 0,
135
205
  left: 0
136
206
  }),
137
- _useState8 = _slicedToArray(_useState7, 2),
138
- offset = _useState8[0],
139
- setOffset = _useState8[1];
207
+ _useState10 = _slicedToArray(_useState9, 2),
208
+ offset = _useState10[0],
209
+ setOffset = _useState10[1];
140
210
 
141
- var _useState9 = useState({
211
+ var _useState11 = useState({
142
212
  top: 0,
143
213
  left: 0
144
214
  }),
145
- _useState10 = _slicedToArray(_useState9, 2),
146
- lastOffset = _useState10[0],
147
- setLastOffset = _useState10[1];
215
+ _useState12 = _slicedToArray(_useState11, 2),
216
+ lastOffset = _useState12[0],
217
+ setLastOffset = _useState12[1];
148
218
 
149
219
  var handleMouseUp = function handleMouseUp(e) {
150
220
  e.preventDefault();
@@ -212,7 +282,8 @@ var Media = function Media(_ref4) {
212
282
  src: src,
213
283
  scale: scale,
214
284
  offset: offset,
215
- isCurrent: isCurrent
285
+ isCurrent: isCurrent,
286
+ showAllPages: showAllPages
216
287
  })
217
288
  });
218
289
  };
@@ -77,7 +77,7 @@
77
77
  position: absolute;
78
78
  width: 100%;
79
79
  height: calc(100% - 200px);
80
- top: 68px;
80
+ top: 92px;
81
81
 
82
82
  .image {
83
83
  max-width: 100%;
@@ -142,12 +142,12 @@
142
142
  }
143
143
 
144
144
  .igloo-preview-next {
145
- right: 24px;
145
+ right: 136px;
146
146
  user-select: none;
147
147
  }
148
148
 
149
149
  .igloo-preview-previous {
150
- right: 80px;
150
+ right: 192px;
151
151
  user-select: none;
152
152
  }
153
153
 
@@ -72,7 +72,7 @@ export var compareSelected = function compareSelected(newValue, oldValue) {
72
72
  return true;
73
73
  }
74
74
 
75
- return newValue.every(function (v) {
75
+ return !newValue.every(function (v) {
76
76
  return oldValue.find(function (ov) {
77
77
  return v === ov;
78
78
  });
@@ -2,5 +2,7 @@ import { FC } from 'react';
2
2
  declare const Documents: FC<{
3
3
  docList: string[];
4
4
  docNames?: string[];
5
+ showAllPages?: boolean;
6
+ destroyOnClose?: boolean;
5
7
  }>;
6
8
  export default Documents;
@@ -39,7 +39,11 @@ var Documents = function Documents(_ref) {
39
39
  var _ref$docList = _ref.docList,
40
40
  docList = _ref$docList === void 0 ? [] : _ref$docList,
41
41
  _ref$docNames = _ref.docNames,
42
- docNames = _ref$docNames === void 0 ? [] : _ref$docNames;
42
+ docNames = _ref$docNames === void 0 ? [] : _ref$docNames,
43
+ _ref$showAllPages = _ref.showAllPages,
44
+ showAllPages = _ref$showAllPages === void 0 ? true : _ref$showAllPages,
45
+ _ref$destroyOnClose = _ref.destroyOnClose,
46
+ destroyOnClose = _ref$destroyOnClose === void 0 ? true : _ref$destroyOnClose;
43
47
 
44
48
  var _useState = (0, _react.useState)(0),
45
49
  _useState2 = _slicedToArray(_useState, 2),
@@ -122,7 +126,9 @@ var Documents = function Documents(_ref) {
122
126
  src: src,
123
127
  type: type,
124
128
  docNames: docNames,
125
- name: docNames[index]
129
+ name: docNames[index],
130
+ showAllPages: showAllPages,
131
+ destroyOnClose: destroyOnClose
126
132
  })
127
133
  }, index);
128
134
  })
@@ -6,7 +6,9 @@ export interface AmountProps extends InputProps, IglooComponentProps {
6
6
  currencyProps?: InputProps;
7
7
  amount?: number;
8
8
  amountProps?: InputProps;
9
- seperator?: ',';
9
+ seperator?: ',' | '.';
10
+ separator?: ',' | '.';
11
+ decimalSeparator?: ',' | '.';
10
12
  }
11
13
  declare const Amount: FC<AmountProps>;
12
14
  export default Amount;
@@ -21,7 +21,7 @@ var _locale = require("../locale");
21
21
 
22
22
  require("./style/index.less");
23
23
 
24
- var _excluded = ["className", "currency", "currencyProps", "amountProps", "value", "seperator", "disabled"];
24
+ var _excluded = ["className", "currency", "currencyProps", "amountProps", "value", "seperator", "separator", "decimalSeparator", "disabled"];
25
25
 
26
26
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
27
 
@@ -35,16 +35,16 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
35
35
 
36
36
  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; }
37
37
 
38
- var thousands = function thousands(number) {
38
+ var thousands = function thousands(number, decimalSeparator, separator) {
39
39
  if (number === null || number === undefined) return undefined;
40
- var arr = String(number).split('.');
40
+ var arr = String(number).replace('.', decimalSeparator).split(decimalSeparator);
41
41
  return arr.map(function (s, index) {
42
42
  if (index === 0) {
43
- return s.replace(/(?=(?!\b)(\d{3})+$)/g, ',');
43
+ return s.replace(/(?=(?!\b)(\d{3})+$)/g, separator);
44
44
  }
45
45
 
46
- return s.replace(/(\d{3})(?=[^$])/g, '$1,');
47
- }).join('.');
46
+ return s.replace(/(\d{3})(?=[^$])/g, "$1".concat(separator));
47
+ }).join(decimalSeparator);
48
48
  };
49
49
 
50
50
  var Amount = function Amount(_ref) {
@@ -55,8 +55,11 @@ var Amount = function Amount(_ref) {
55
55
  _ref$amountProps = _ref.amountProps,
56
56
  amountProps = _ref$amountProps === void 0 ? {} : _ref$amountProps,
57
57
  value = _ref.value,
58
- _ref$seperator = _ref.seperator,
59
- seperator = _ref$seperator === void 0 ? ',' : _ref$seperator,
58
+ seperator = _ref.seperator,
59
+ _ref$separator = _ref.separator,
60
+ separator = _ref$separator === void 0 ? seperator || ',' : _ref$separator,
61
+ _ref$decimalSeparator = _ref.decimalSeparator,
62
+ decimalSeparator = _ref$decimalSeparator === void 0 ? '.' : _ref$decimalSeparator,
60
63
  disabled = _ref.disabled,
61
64
  rest = _objectWithoutProperties(_ref, _excluded);
62
65
 
@@ -64,11 +67,11 @@ var Amount = function Amount(_ref) {
64
67
  var onChange = rest.onChange;
65
68
 
66
69
  if (typeof value === 'string') {
67
- if (value.endsWith('.')) {
68
- e.target.value = value.replace('.', '');
70
+ if (value.endsWith(decimalSeparator)) {
71
+ e.target.value = value.replace(decimalSeparator, '');
69
72
  }
70
73
 
71
- if (value.endsWith('0') && value.includes('.')) {
74
+ if (value.endsWith('0') && value.includes(decimalSeparator)) {
72
75
  e.target.value = value.replace(/[0]+$/, '');
73
76
  }
74
77
 
@@ -83,7 +86,7 @@ var Amount = function Amount(_ref) {
83
86
  className: (0, _classnames.default)('igloo-input-amount', {
84
87
  'igloo-input-disable': disabled
85
88
  }, className),
86
- value: thousands(value),
89
+ value: thousands(value, decimalSeparator, separator),
87
90
  addonBefore: currency ? (0, _jsxRuntime.jsx)("span", {
88
91
  className: "igloo-input-areacode",
89
92
  children: currency
@@ -92,24 +95,31 @@ var Amount = function Amount(_ref) {
92
95
  };
93
96
 
94
97
  Amount.formItemPropsHandler = function (_ref2) {
95
- var _ref2$seperator = _ref2.seperator,
96
- seperator = _ref2$seperator === void 0 ? ',' : _ref2$seperator;
98
+ var _ref2$separator = _ref2.separator,
99
+ separator = _ref2$separator === void 0 ? ',' : _ref2$separator,
100
+ _ref2$decimalSeparato = _ref2.decimalSeparator,
101
+ decimalSeparator = _ref2$decimalSeparato === void 0 ? '.' : _ref2$decimalSeparato;
97
102
  return {
98
103
  getValueFromEvent: function getValueFromEvent(e) {
99
104
  var value = e.target.value;
100
- var str = value.replaceAll(seperator, '').replaceAll(/[^0-9\.]/g, '');
105
+ console.log('======', separator, decimalSeparator);
106
+ var str = value.replaceAll(separator, '').replaceAll(/[^0-9\.,]/g, '');
101
107
 
102
- if (str.endsWith('.') || str.includes('.') && str.endsWith('0')) {
108
+ if (str.endsWith(decimalSeparator) || str.includes(decimalSeparator) && str.endsWith('0')) {
103
109
  return str;
104
110
  }
105
111
 
112
+ if (decimalSeparator === ',') {
113
+ str = str.replace(',', '.');
114
+ }
115
+
106
116
  return str ? parseFloat(str) : undefined;
107
117
  },
108
118
  rules: [{
109
119
  validator: function validator(_, value) {
110
120
  if (!value) return Promise.resolve();
111
- var seperatorArr = String(value).split('.');
112
- return seperatorArr.length > 2 ? Promise.reject((0, _locale.staticFormatMessage)({
121
+ var separatorArr = String(value).split(decimalSeparator);
122
+ return separatorArr.length > 2 ? Promise.reject((0, _locale.staticFormatMessage)({
113
123
  id: 'Please enter a valid amount.'
114
124
  })) : Promise.resolve();
115
125
  }
@@ -12,6 +12,8 @@ interface Props {
12
12
  docNames?: string[];
13
13
  className?: any;
14
14
  style?: CSSProperties;
15
+ showAllPages?: boolean;
16
+ destroyOnClose?: boolean;
15
17
  }
16
18
  declare const MediaWithPreview: FC<Props>;
17
19
  export default MediaWithPreview;
@@ -67,7 +67,11 @@ var MediaWithPreview = function MediaWithPreview(_ref) {
67
67
  _ref$type = _ref.type,
68
68
  type = _ref$type === void 0 ? '' : _ref$type,
69
69
  _ref$docNames = _ref.docNames,
70
- docNames = _ref$docNames === void 0 ? [] : _ref$docNames;
70
+ docNames = _ref$docNames === void 0 ? [] : _ref$docNames,
71
+ _ref$showAllPages = _ref.showAllPages,
72
+ showAllPages = _ref$showAllPages === void 0 ? true : _ref$showAllPages,
73
+ _ref$destroyOnClose = _ref.destroyOnClose,
74
+ destroyOnClose = _ref$destroyOnClose === void 0 ? true : _ref$destroyOnClose;
71
75
 
72
76
  var _useState = (0, _react.useState)(1),
73
77
  _useState2 = _slicedToArray(_useState, 2),
@@ -242,7 +246,7 @@ var MediaWithPreview = function MediaWithPreview(_ref) {
242
246
  }),
243
247
  wrapClassName: "igloo-media-preview",
244
248
  width: "100%",
245
- destroyOnClose: true,
249
+ destroyOnClose: destroyOnClose,
246
250
  children: [Boolean(docNames && docNames.length) && (0, _jsxRuntime.jsxs)("div", {
247
251
  className: "igloo-document-name",
248
252
  children: [(0, _jsxRuntime.jsx)("div", {
@@ -279,7 +283,8 @@ var MediaWithPreview = function MediaWithPreview(_ref) {
279
283
  type: mediaType,
280
284
  src: src,
281
285
  scale: scale,
282
- isCurrent: true
286
+ isCurrent: true,
287
+ showAllPages: showAllPages
283
288
  })
284
289
  }, index), (0, _jsxRuntime.jsx)(_iglooicon.MinusOutlined, {
285
290
  onClick: zoomIn,
@@ -6,6 +6,7 @@ interface MediaProps {
6
6
  isCurrent?: boolean;
7
7
  className?: any;
8
8
  style?: CSSProperties;
9
+ showAllPages?: boolean;
9
10
  }
10
11
  declare const Media: FC<MediaProps>;
11
12
  export default Media;
@@ -5,12 +5,22 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
+ require("antd/es/grid/style");
9
+
10
+ var _grid = _interopRequireDefault(require("antd/es/grid"));
11
+
8
12
  var _jsxRuntime = require("react/jsx-runtime");
9
13
 
10
14
  var _react = require("react");
11
15
 
12
16
  var _entry = require("react-pdf/dist/esm/entry.webpack");
13
17
 
18
+ var _classnames = _interopRequireDefault(require("classnames"));
19
+
20
+ var _iglooicon = require("iglooicon");
21
+
22
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
+
14
24
  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; }
15
25
 
16
26
  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; }
@@ -29,18 +39,30 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
29
39
 
30
40
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
31
41
 
42
+ var useBreakpoint = _grid.default.useBreakpoint;
43
+
32
44
  var PdfViewer = function PdfViewer(_ref) {
33
45
  var src = _ref.src,
34
46
  left = _ref.left,
35
47
  top = _ref.top,
36
48
  scale = _ref.scale,
37
- isCurrent = _ref.isCurrent;
49
+ isCurrent = _ref.isCurrent,
50
+ _ref$showAllPages = _ref.showAllPages,
51
+ showAllPages = _ref$showAllPages === void 0 ? true : _ref$showAllPages;
38
52
 
39
53
  var _useState = (0, _react.useState)(1),
40
54
  _useState2 = _slicedToArray(_useState, 2),
41
55
  pageSize = _useState2[0],
42
56
  setPageSize = _useState2[1];
43
57
 
58
+ var _useState3 = (0, _react.useState)(1),
59
+ _useState4 = _slicedToArray(_useState3, 2),
60
+ page = _useState4[0],
61
+ setPage = _useState4[1];
62
+
63
+ var _useBreakpoint = useBreakpoint(),
64
+ md = _useBreakpoint.md;
65
+
44
66
  var handlePageInit = function handlePageInit(document) {
45
67
  var _ref2 = document || {},
46
68
  numPages = _ref2.numPages;
@@ -50,27 +72,77 @@ var PdfViewer = function PdfViewer(_ref) {
50
72
  }
51
73
  };
52
74
 
53
- return (0, _jsxRuntime.jsx)("div", {
54
- style: {
55
- display: 'flex',
56
- flexDirection: 'column',
57
- maxWidth: '100%',
58
- maxHeight: '100%',
59
- transform: "translate(".concat(left, "px, ").concat(top, "px)"),
60
- position: 'absolute'
61
- },
62
- children: (0, _jsxRuntime.jsx)(_entry.Document, {
63
- file: src,
64
- onLoadSuccess: handlePageInit,
65
- children: Array.from({
66
- length: pageSize
67
- }).map(function (_, index) {
68
- return (0, _jsxRuntime.jsx)(_entry.Page, {
69
- pageNumber: index + 1,
75
+ if (showAllPages) {
76
+ return (0, _jsxRuntime.jsx)("div", {
77
+ style: {
78
+ display: 'flex',
79
+ flexDirection: 'column',
80
+ maxWidth: "calc(100vw - ".concat(md ? 64 : 32, "px)"),
81
+ maxHeight: '100%',
82
+ transform: "translate(".concat(left, "px, ").concat(top, "px)"),
83
+ position: 'absolute',
84
+ overflow: 'auto'
85
+ },
86
+ children: (0, _jsxRuntime.jsx)(_entry.Document, {
87
+ file: src,
88
+ onLoadSuccess: handlePageInit,
89
+ children: Array.from({
90
+ length: pageSize
91
+ }).map(function (_, index) {
92
+ return (0, _jsxRuntime.jsx)(_entry.Page, {
93
+ pageNumber: index + 1,
94
+ scale: scale
95
+ }, index);
96
+ })
97
+ })
98
+ });
99
+ }
100
+
101
+ return (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
102
+ children: [(0, _jsxRuntime.jsx)("div", {
103
+ style: {
104
+ maxWidth: "calc(100vw - ".concat(md ? 64 : 32, "px)"),
105
+ maxHeight: '100%',
106
+ transform: "translate(".concat(left, "px, ").concat(top, "px)"),
107
+ position: 'absolute',
108
+ overflow: 'auto'
109
+ },
110
+ children: (0, _jsxRuntime.jsx)(_entry.Document, {
111
+ file: src,
112
+ onLoadSuccess: handlePageInit,
113
+ children: (0, _jsxRuntime.jsx)(_entry.Page, {
114
+ pageNumber: page,
70
115
  scale: scale
71
- }, index);
116
+ })
72
117
  })
73
- })
118
+ }), isCurrent && Boolean(pageSize > 1) && (0, _jsxRuntime.jsxs)("div", {
119
+ style: {
120
+ position: 'fixed',
121
+ bottom: 0,
122
+ right: 96,
123
+ height: 48,
124
+ zIndex: 2
125
+ },
126
+ children: [(0, _jsxRuntime.jsx)(_iglooicon.ArrowLeftOutlined, {
127
+ onClick: function onClick() {
128
+ return setPage(page - 1);
129
+ },
130
+ className: (0, _classnames.default)({
131
+ 'igloo-preview-page-btn': true,
132
+ 'igloo-preview-previous': true,
133
+ 'igloo-preview-disabled': page === 1
134
+ })
135
+ }), (0, _jsxRuntime.jsx)(_iglooicon.ArrowRightOutlined, {
136
+ onClick: function onClick() {
137
+ return setPage(page + 1);
138
+ },
139
+ className: (0, _classnames.default)({
140
+ 'igloo-preview-page-btn': true,
141
+ 'igloo-preview-next': true,
142
+ 'igloo-preview-disabled': page === pageSize
143
+ })
144
+ })]
145
+ })]
74
146
  });
75
147
  };
76
148
 
@@ -79,7 +151,8 @@ var MediaItem = function MediaItem(_ref3) {
79
151
  src = _ref3.src,
80
152
  scale = _ref3.scale,
81
153
  offset = _ref3.offset,
82
- isCurrent = _ref3.isCurrent;
154
+ isCurrent = _ref3.isCurrent,
155
+ showAllPages = _ref3.showAllPages;
83
156
  var top = offset.top,
84
157
  left = offset.left;
85
158
 
@@ -100,7 +173,8 @@ var MediaItem = function MediaItem(_ref3) {
100
173
  top: top,
101
174
  left: left,
102
175
  scale: scale,
103
- isCurrent: isCurrent
176
+ isCurrent: isCurrent,
177
+ showAllPages: showAllPages
104
178
  });
105
179
 
106
180
  default:
@@ -124,36 +198,38 @@ var Media = function Media(_ref4) {
124
198
  scale = _ref4$scale === void 0 ? 1 : _ref4$scale,
125
199
  type = _ref4.type,
126
200
  _ref4$isCurrent = _ref4.isCurrent,
127
- isCurrent = _ref4$isCurrent === void 0 ? false : _ref4$isCurrent;
201
+ isCurrent = _ref4$isCurrent === void 0 ? false : _ref4$isCurrent,
202
+ _ref4$showAllPages = _ref4.showAllPages,
203
+ showAllPages = _ref4$showAllPages === void 0 ? true : _ref4$showAllPages;
128
204
 
129
- var _useState3 = (0, _react.useState)(false),
130
- _useState4 = _slicedToArray(_useState3, 2),
131
- isDrag = _useState4[0],
132
- setIsDrag = _useState4[1];
205
+ var _useState5 = (0, _react.useState)(false),
206
+ _useState6 = _slicedToArray(_useState5, 2),
207
+ isDrag = _useState6[0],
208
+ setIsDrag = _useState6[1];
133
209
 
134
- var _useState5 = (0, _react.useState)({
210
+ var _useState7 = (0, _react.useState)({
135
211
  startX: 0,
136
212
  startY: 0
137
213
  }),
138
- _useState6 = _slicedToArray(_useState5, 2),
139
- startPos = _useState6[0],
140
- setStartPos = _useState6[1];
214
+ _useState8 = _slicedToArray(_useState7, 2),
215
+ startPos = _useState8[0],
216
+ setStartPos = _useState8[1];
141
217
 
142
- var _useState7 = (0, _react.useState)({
218
+ var _useState9 = (0, _react.useState)({
143
219
  top: 0,
144
220
  left: 0
145
221
  }),
146
- _useState8 = _slicedToArray(_useState7, 2),
147
- offset = _useState8[0],
148
- setOffset = _useState8[1];
222
+ _useState10 = _slicedToArray(_useState9, 2),
223
+ offset = _useState10[0],
224
+ setOffset = _useState10[1];
149
225
 
150
- var _useState9 = (0, _react.useState)({
226
+ var _useState11 = (0, _react.useState)({
151
227
  top: 0,
152
228
  left: 0
153
229
  }),
154
- _useState10 = _slicedToArray(_useState9, 2),
155
- lastOffset = _useState10[0],
156
- setLastOffset = _useState10[1];
230
+ _useState12 = _slicedToArray(_useState11, 2),
231
+ lastOffset = _useState12[0],
232
+ setLastOffset = _useState12[1];
157
233
 
158
234
  var handleMouseUp = function handleMouseUp(e) {
159
235
  e.preventDefault();
@@ -221,7 +297,8 @@ var Media = function Media(_ref4) {
221
297
  src: src,
222
298
  scale: scale,
223
299
  offset: offset,
224
- isCurrent: isCurrent
300
+ isCurrent: isCurrent,
301
+ showAllPages: showAllPages
225
302
  })
226
303
  });
227
304
  };
@@ -77,7 +77,7 @@
77
77
  position: absolute;
78
78
  width: 100%;
79
79
  height: calc(100% - 200px);
80
- top: 68px;
80
+ top: 92px;
81
81
 
82
82
  .image {
83
83
  max-width: 100%;
@@ -142,12 +142,12 @@
142
142
  }
143
143
 
144
144
  .igloo-preview-next {
145
- right: 24px;
145
+ right: 136px;
146
146
  user-select: none;
147
147
  }
148
148
 
149
149
  .igloo-preview-previous {
150
- right: 80px;
150
+ right: 192px;
151
151
  user-select: none;
152
152
  }
153
153
 
@@ -89,7 +89,7 @@ var compareSelected = function compareSelected(newValue, oldValue) {
89
89
  return true;
90
90
  }
91
91
 
92
- return newValue.every(function (v) {
92
+ return !newValue.every(function (v) {
93
93
  return oldValue.find(function (ov) {
94
94
  return v === ov;
95
95
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iglooform",
3
- "version": "2.5.13",
3
+ "version": "2.5.16",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "build-dev": "dumi build",