iglooform 3.6.1 → 3.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dumi/tmp/dumi/theme/ContextWrapper.tsx +1 -1
- package/es/media/preview.d.ts +0 -1
- package/es/media/preview.js +34 -99
- package/es/select/attached-select.js +3 -0
- package/es/select/select.js +4 -3
- package/lib/media/preview.d.ts +0 -1
- package/lib/media/preview.js +33 -98
- package/lib/select/attached-select.js +3 -0
- package/lib/select/select.js +4 -3
- package/package.json +1 -1
- package/es/date-picker/index.d.ts +0 -13
- package/es/form/element/index.d.ts +0 -12
- package/es/select/select.d.ts +0 -13
- package/lib/date-picker/index.d.ts +0 -13
- package/lib/form/element/index.d.ts +0 -12
- package/lib/select/select.d.ts +0 -13
|
@@ -30,7 +30,7 @@ export default function DumiContextWrapper() {
|
|
|
30
30
|
|
|
31
31
|
return (
|
|
32
32
|
<SiteContext.Provider value={{
|
|
33
|
-
pkg: {"name":"iglooform","version":"3.
|
|
33
|
+
pkg: {"name":"iglooform","version":"3.7.0","license":"MIT"},
|
|
34
34
|
historyType: "browser",
|
|
35
35
|
entryExports,
|
|
36
36
|
demos,
|
package/es/media/preview.d.ts
CHANGED
package/es/media/preview.js
CHANGED
|
@@ -10,7 +10,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
10
10
|
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
11
|
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
12
12
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
-
import React, { useState, useRef, useContext, useReducer
|
|
13
|
+
import React, { useState, useRef, useContext, useReducer } from 'react';
|
|
14
14
|
import { Document, Page } from 'react-pdf/dist/esm/entry.webpack';
|
|
15
15
|
import classnames from 'classnames';
|
|
16
16
|
import { ArrowLeftOutlined, ArrowRightOutlined } from 'iglooicon';
|
|
@@ -29,31 +29,6 @@ var PasswordResponses = {
|
|
|
29
29
|
NEED_PASSWORD: 1,
|
|
30
30
|
INCORRECT_PASSWORD: 2
|
|
31
31
|
};
|
|
32
|
-
var useContainerWidth = function useContainerWidth() {
|
|
33
|
-
var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
34
|
-
var containerRef = useRef(null);
|
|
35
|
-
var _useState = useState(undefined),
|
|
36
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
37
|
-
containerWidth = _useState2[0],
|
|
38
|
-
setContainerWidth = _useState2[1];
|
|
39
|
-
useEffect(function () {
|
|
40
|
-
if (!enabled) return;
|
|
41
|
-
var updateWidth = function updateWidth() {
|
|
42
|
-
if (containerRef.current) {
|
|
43
|
-
setContainerWidth(containerRef.current.offsetWidth);
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
updateWidth();
|
|
47
|
-
var resizeObserver = new ResizeObserver(updateWidth);
|
|
48
|
-
if (containerRef.current) {
|
|
49
|
-
resizeObserver.observe(containerRef.current);
|
|
50
|
-
}
|
|
51
|
-
return function () {
|
|
52
|
-
resizeObserver.disconnect();
|
|
53
|
-
};
|
|
54
|
-
}, [enabled]);
|
|
55
|
-
return [containerRef, containerWidth];
|
|
56
|
-
};
|
|
57
32
|
var PdfViewer = function PdfViewer(_ref) {
|
|
58
33
|
var src = _ref.src,
|
|
59
34
|
left = _ref.left,
|
|
@@ -61,28 +36,22 @@ var PdfViewer = function PdfViewer(_ref) {
|
|
|
61
36
|
scale = _ref.scale,
|
|
62
37
|
isCurrent = _ref.isCurrent,
|
|
63
38
|
_ref$showAllPages = _ref.showAllPages,
|
|
64
|
-
showAllPages = _ref$showAllPages === void 0 ? true : _ref$showAllPages
|
|
65
|
-
_ref$autoWidth = _ref.autoWidth,
|
|
66
|
-
autoWidth = _ref$autoWidth === void 0 ? false : _ref$autoWidth;
|
|
39
|
+
showAllPages = _ref$showAllPages === void 0 ? true : _ref$showAllPages;
|
|
67
40
|
var _useContext = useContext(LocaleContext),
|
|
68
41
|
formatMessage = _useContext.formatMessage;
|
|
42
|
+
var _useState = useState(1),
|
|
43
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
44
|
+
pageSize = _useState2[0],
|
|
45
|
+
setPageSize = _useState2[1];
|
|
69
46
|
var _useState3 = useState(1),
|
|
70
47
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
var _useState5 = useState(1),
|
|
74
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
75
|
-
page = _useState6[0],
|
|
76
|
-
setPage = _useState6[1];
|
|
48
|
+
page = _useState4[0],
|
|
49
|
+
setPage = _useState4[1];
|
|
77
50
|
var documentRef = useRef(null);
|
|
78
|
-
var
|
|
79
|
-
|
|
80
|
-
needPassword =
|
|
81
|
-
setNeedPassword =
|
|
82
|
-
var _useState9 = useState(undefined),
|
|
83
|
-
_useState10 = _slicedToArray(_useState9, 2),
|
|
84
|
-
pdfOriginalWidth = _useState10[0],
|
|
85
|
-
setPdfOriginalWidth = _useState10[1];
|
|
51
|
+
var _useState5 = useState(false),
|
|
52
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
53
|
+
needPassword = _useState6[0],
|
|
54
|
+
setNeedPassword = _useState6[1];
|
|
86
55
|
var _useBreakpoint = useBreakpoint(),
|
|
87
56
|
md = _useBreakpoint.md;
|
|
88
57
|
var _useReducer = useReducer(function (a) {
|
|
@@ -95,10 +64,6 @@ var PdfViewer = function PdfViewer(_ref) {
|
|
|
95
64
|
_Modal$useModal2 = _slicedToArray(_Modal$useModal, 2),
|
|
96
65
|
modal = _Modal$useModal2[0],
|
|
97
66
|
modalHolder = _Modal$useModal2[1];
|
|
98
|
-
var _useContainerWidth = useContainerWidth(autoWidth),
|
|
99
|
-
_useContainerWidth2 = _slicedToArray(_useContainerWidth, 2),
|
|
100
|
-
containerRef = _useContainerWidth2[0],
|
|
101
|
-
containerWidth = _useContainerWidth2[1];
|
|
102
67
|
var handlePageInit = function handlePageInit(document) {
|
|
103
68
|
var _ref2 = document || {},
|
|
104
69
|
numPages = _ref2.numPages;
|
|
@@ -106,22 +71,6 @@ var PdfViewer = function PdfViewer(_ref) {
|
|
|
106
71
|
setPageSize(numPages);
|
|
107
72
|
}
|
|
108
73
|
};
|
|
109
|
-
var handlePageLoadSuccess = function handlePageLoadSuccess(pageData) {
|
|
110
|
-
if (autoWidth && !pdfOriginalWidth) {
|
|
111
|
-
var originalWidth = pageData.originalWidth;
|
|
112
|
-
if (originalWidth) {
|
|
113
|
-
setPdfOriginalWidth(originalWidth);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
var getOptimalPdfWidth = function getOptimalPdfWidth() {
|
|
118
|
-
var scale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
119
|
-
if (!autoWidth || !containerWidth) return undefined;
|
|
120
|
-
if (pdfOriginalWidth) {
|
|
121
|
-
return Math.min(containerWidth, pdfOriginalWidth);
|
|
122
|
-
}
|
|
123
|
-
return containerWidth * scale;
|
|
124
|
-
};
|
|
125
74
|
var handleCancelLoad = function handleCancelLoad() {
|
|
126
75
|
var current = documentRef === null || documentRef === void 0 ? void 0 : documentRef.current;
|
|
127
76
|
if (current) {
|
|
@@ -184,13 +133,10 @@ var PdfViewer = function PdfViewer(_ref) {
|
|
|
184
133
|
}
|
|
185
134
|
if (showAllPages) {
|
|
186
135
|
return /*#__PURE__*/_jsx("div", {
|
|
187
|
-
ref: autoWidth ? containerRef : undefined,
|
|
188
136
|
style: {
|
|
189
137
|
display: 'flex',
|
|
190
138
|
flexDirection: 'column',
|
|
191
|
-
alignItems: 'center',
|
|
192
139
|
maxWidth: "calc(100vw - ".concat(md ? 64 : 32, "px)"),
|
|
193
|
-
width: autoWidth ? '100%' : undefined,
|
|
194
140
|
maxHeight: '100%',
|
|
195
141
|
transform: "translate(".concat(left, "px, ").concat(top, "px)"),
|
|
196
142
|
position: 'absolute',
|
|
@@ -206,9 +152,7 @@ var PdfViewer = function PdfViewer(_ref) {
|
|
|
206
152
|
}).map(function (_, index) {
|
|
207
153
|
return /*#__PURE__*/_jsx(Page, {
|
|
208
154
|
pageNumber: index + 1,
|
|
209
|
-
|
|
210
|
-
scale: !autoWidth ? scale : undefined,
|
|
211
|
-
onLoadSuccess: index === 0 ? handlePageLoadSuccess : undefined
|
|
155
|
+
scale: scale
|
|
212
156
|
}, index);
|
|
213
157
|
})
|
|
214
158
|
})
|
|
@@ -216,10 +160,8 @@ var PdfViewer = function PdfViewer(_ref) {
|
|
|
216
160
|
}
|
|
217
161
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
218
162
|
children: [modalHolder, /*#__PURE__*/_jsx("div", {
|
|
219
|
-
ref: autoWidth ? containerRef : undefined,
|
|
220
163
|
style: {
|
|
221
164
|
maxWidth: "calc(100vw - ".concat(md ? 64 : 32, "px)"),
|
|
222
|
-
width: autoWidth ? '100%' : undefined,
|
|
223
165
|
maxHeight: '100%',
|
|
224
166
|
transform: "translate(".concat(left, "px, ").concat(top, "px)"),
|
|
225
167
|
position: 'absolute',
|
|
@@ -232,9 +174,7 @@ var PdfViewer = function PdfViewer(_ref) {
|
|
|
232
174
|
onPassword: onPassword,
|
|
233
175
|
children: /*#__PURE__*/_jsx(Page, {
|
|
234
176
|
pageNumber: page,
|
|
235
|
-
|
|
236
|
-
scale: !autoWidth ? scale : undefined,
|
|
237
|
-
onLoadSuccess: handlePageLoadSuccess
|
|
177
|
+
scale: scale
|
|
238
178
|
})
|
|
239
179
|
})
|
|
240
180
|
}, index), isCurrent && Boolean(pageSize > 1) && /*#__PURE__*/_jsxs("div", {
|
|
@@ -273,8 +213,7 @@ var MediaItem = function MediaItem(_ref3) {
|
|
|
273
213
|
scale = _ref3.scale,
|
|
274
214
|
offset = _ref3.offset,
|
|
275
215
|
isCurrent = _ref3.isCurrent,
|
|
276
|
-
showAllPages = _ref3.showAllPages
|
|
277
|
-
autoWidth = _ref3.autoWidth;
|
|
216
|
+
showAllPages = _ref3.showAllPages;
|
|
278
217
|
var top = offset.top,
|
|
279
218
|
left = offset.left;
|
|
280
219
|
var _useContext2 = useContext(LocaleContext),
|
|
@@ -296,8 +235,7 @@ var MediaItem = function MediaItem(_ref3) {
|
|
|
296
235
|
left: left,
|
|
297
236
|
scale: scale,
|
|
298
237
|
isCurrent: isCurrent,
|
|
299
|
-
showAllPages: showAllPages
|
|
300
|
-
autoWidth: autoWidth
|
|
238
|
+
showAllPages: showAllPages
|
|
301
239
|
});
|
|
302
240
|
case 'image':
|
|
303
241
|
return /*#__PURE__*/_jsx("img", {
|
|
@@ -334,34 +272,32 @@ var Media = function Media(_ref4) {
|
|
|
334
272
|
_ref4$isCurrent = _ref4.isCurrent,
|
|
335
273
|
isCurrent = _ref4$isCurrent === void 0 ? false : _ref4$isCurrent,
|
|
336
274
|
_ref4$showAllPages = _ref4.showAllPages,
|
|
337
|
-
showAllPages = _ref4$showAllPages === void 0 ? true : _ref4$showAllPages
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
setIsDrag = _useState12[1];
|
|
344
|
-
var _useState13 = useState({
|
|
275
|
+
showAllPages = _ref4$showAllPages === void 0 ? true : _ref4$showAllPages;
|
|
276
|
+
var _useState7 = useState(false),
|
|
277
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
278
|
+
isDrag = _useState8[0],
|
|
279
|
+
setIsDrag = _useState8[1];
|
|
280
|
+
var _useState9 = useState({
|
|
345
281
|
startX: 0,
|
|
346
282
|
startY: 0
|
|
347
283
|
}),
|
|
348
|
-
|
|
349
|
-
startPos =
|
|
350
|
-
setStartPos =
|
|
351
|
-
var
|
|
284
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
285
|
+
startPos = _useState10[0],
|
|
286
|
+
setStartPos = _useState10[1];
|
|
287
|
+
var _useState11 = useState({
|
|
352
288
|
top: 0,
|
|
353
289
|
left: 0
|
|
354
290
|
}),
|
|
355
|
-
|
|
356
|
-
offset =
|
|
357
|
-
setOffset =
|
|
358
|
-
var
|
|
291
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
292
|
+
offset = _useState12[0],
|
|
293
|
+
setOffset = _useState12[1];
|
|
294
|
+
var _useState13 = useState({
|
|
359
295
|
top: 0,
|
|
360
296
|
left: 0
|
|
361
297
|
}),
|
|
362
|
-
|
|
363
|
-
lastOffset =
|
|
364
|
-
setLastOffset =
|
|
298
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
299
|
+
lastOffset = _useState14[0],
|
|
300
|
+
setLastOffset = _useState14[1];
|
|
365
301
|
var handleMouseUp = function handleMouseUp(e) {
|
|
366
302
|
e.preventDefault();
|
|
367
303
|
var button = e.button;
|
|
@@ -422,8 +358,7 @@ var Media = function Media(_ref4) {
|
|
|
422
358
|
scale: scale,
|
|
423
359
|
offset: offset,
|
|
424
360
|
isCurrent: isCurrent,
|
|
425
|
-
showAllPages: showAllPages
|
|
426
|
-
autoWidth: autoWidth
|
|
361
|
+
showAllPages: showAllPages
|
|
427
362
|
})
|
|
428
363
|
});
|
|
429
364
|
};
|
|
@@ -99,6 +99,9 @@ var IglooSelect = function IglooSelect(_ref) {
|
|
|
99
99
|
var value = e.target.value;
|
|
100
100
|
var filteredOptions = options.filter(function (option) {
|
|
101
101
|
var _option$label, _option$label$toStrin;
|
|
102
|
+
if (typeof filterOption === 'function') {
|
|
103
|
+
return filterOption(value, option);
|
|
104
|
+
}
|
|
102
105
|
return Boolean(option === null || option === void 0 ? void 0 : (_option$label = option.label) === null || _option$label === void 0 ? void 0 : (_option$label$toStrin = _option$label.toString()) === null || _option$label$toStrin === void 0 ? void 0 : _option$label$toStrin.includes(value));
|
|
103
106
|
});
|
|
104
107
|
setDisplay(filteredOptions);
|
package/es/select/select.js
CHANGED
|
@@ -1,10 +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); }
|
|
2
1
|
var _excluded = ["options", "value", "className", "placeholder", "children", "onDropdownVisibleChange", "showSearch", "filterOption", "optionFilterProp"];
|
|
3
2
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
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; }
|
|
6
5
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
7
6
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
|
+
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); }
|
|
8
8
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
9
9
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
10
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -32,7 +32,7 @@ var IglooSelect = function IglooSelect(_ref) {
|
|
|
32
32
|
children = _ref.children,
|
|
33
33
|
_onDropdownVisibleChange = _ref.onDropdownVisibleChange,
|
|
34
34
|
showSearch = _ref.showSearch,
|
|
35
|
-
|
|
35
|
+
filterOptionProp = _ref.filterOption,
|
|
36
36
|
optionFilterProp = _ref.optionFilterProp,
|
|
37
37
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
38
38
|
var _useState = useState(false),
|
|
@@ -41,6 +41,7 @@ var IglooSelect = function IglooSelect(_ref) {
|
|
|
41
41
|
setOpen = _useState2[1];
|
|
42
42
|
var _useContext = useContext(LocaleContext),
|
|
43
43
|
formatMessage = _useContext.formatMessage;
|
|
44
|
+
var filterOption = _typeof(showSearch) === 'object' ? showSearch.filterOption : filterOptionProp;
|
|
44
45
|
return /*#__PURE__*/_jsx(Select, _objectSpread(_objectSpread({
|
|
45
46
|
placeholder: placeholder || formatMessage({
|
|
46
47
|
id: 'Please select'
|
|
@@ -75,7 +76,7 @@ var IglooSelect = function IglooSelect(_ref) {
|
|
|
75
76
|
setOpen(open);
|
|
76
77
|
_onDropdownVisibleChange && _onDropdownVisibleChange(open);
|
|
77
78
|
},
|
|
78
|
-
showSearch: showSearch,
|
|
79
|
+
showSearch: typeof showSearch === 'boolean' ? showSearch : !!showSearch,
|
|
79
80
|
filterOption: filterOption || (showSearch ? function (value, option) {
|
|
80
81
|
var _option$label, _option$label$toStrin;
|
|
81
82
|
return Boolean(option === null || option === void 0 ? void 0 : (_option$label = option.label) === null || _option$label === void 0 ? void 0 : (_option$label$toStrin = _option$label.toString()) === null || _option$label$toStrin === void 0 ? void 0 : _option$label$toStrin.includes(value));
|
package/lib/media/preview.d.ts
CHANGED
package/lib/media/preview.js
CHANGED
|
@@ -35,31 +35,6 @@ var PasswordResponses = {
|
|
|
35
35
|
NEED_PASSWORD: 1,
|
|
36
36
|
INCORRECT_PASSWORD: 2
|
|
37
37
|
};
|
|
38
|
-
var useContainerWidth = function useContainerWidth() {
|
|
39
|
-
var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
40
|
-
var containerRef = (0, _react.useRef)(null);
|
|
41
|
-
var _useState = (0, _react.useState)(undefined),
|
|
42
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
43
|
-
containerWidth = _useState2[0],
|
|
44
|
-
setContainerWidth = _useState2[1];
|
|
45
|
-
(0, _react.useEffect)(function () {
|
|
46
|
-
if (!enabled) return;
|
|
47
|
-
var updateWidth = function updateWidth() {
|
|
48
|
-
if (containerRef.current) {
|
|
49
|
-
setContainerWidth(containerRef.current.offsetWidth);
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
updateWidth();
|
|
53
|
-
var resizeObserver = new ResizeObserver(updateWidth);
|
|
54
|
-
if (containerRef.current) {
|
|
55
|
-
resizeObserver.observe(containerRef.current);
|
|
56
|
-
}
|
|
57
|
-
return function () {
|
|
58
|
-
resizeObserver.disconnect();
|
|
59
|
-
};
|
|
60
|
-
}, [enabled]);
|
|
61
|
-
return [containerRef, containerWidth];
|
|
62
|
-
};
|
|
63
38
|
var PdfViewer = function PdfViewer(_ref) {
|
|
64
39
|
var src = _ref.src,
|
|
65
40
|
left = _ref.left,
|
|
@@ -67,28 +42,22 @@ var PdfViewer = function PdfViewer(_ref) {
|
|
|
67
42
|
scale = _ref.scale,
|
|
68
43
|
isCurrent = _ref.isCurrent,
|
|
69
44
|
_ref$showAllPages = _ref.showAllPages,
|
|
70
|
-
showAllPages = _ref$showAllPages === void 0 ? true : _ref$showAllPages
|
|
71
|
-
_ref$autoWidth = _ref.autoWidth,
|
|
72
|
-
autoWidth = _ref$autoWidth === void 0 ? false : _ref$autoWidth;
|
|
45
|
+
showAllPages = _ref$showAllPages === void 0 ? true : _ref$showAllPages;
|
|
73
46
|
var _useContext = (0, _react.useContext)(_locale.LocaleContext),
|
|
74
47
|
formatMessage = _useContext.formatMessage;
|
|
48
|
+
var _useState = (0, _react.useState)(1),
|
|
49
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
50
|
+
pageSize = _useState2[0],
|
|
51
|
+
setPageSize = _useState2[1];
|
|
75
52
|
var _useState3 = (0, _react.useState)(1),
|
|
76
53
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
var _useState5 = (0, _react.useState)(1),
|
|
80
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
81
|
-
page = _useState6[0],
|
|
82
|
-
setPage = _useState6[1];
|
|
54
|
+
page = _useState4[0],
|
|
55
|
+
setPage = _useState4[1];
|
|
83
56
|
var documentRef = (0, _react.useRef)(null);
|
|
84
|
-
var
|
|
85
|
-
|
|
86
|
-
needPassword =
|
|
87
|
-
setNeedPassword =
|
|
88
|
-
var _useState9 = (0, _react.useState)(undefined),
|
|
89
|
-
_useState10 = _slicedToArray(_useState9, 2),
|
|
90
|
-
pdfOriginalWidth = _useState10[0],
|
|
91
|
-
setPdfOriginalWidth = _useState10[1];
|
|
57
|
+
var _useState5 = (0, _react.useState)(false),
|
|
58
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
59
|
+
needPassword = _useState6[0],
|
|
60
|
+
setNeedPassword = _useState6[1];
|
|
92
61
|
var _useBreakpoint = useBreakpoint(),
|
|
93
62
|
md = _useBreakpoint.md;
|
|
94
63
|
var _useReducer = (0, _react.useReducer)(function (a) {
|
|
@@ -101,10 +70,6 @@ var PdfViewer = function PdfViewer(_ref) {
|
|
|
101
70
|
_Modal$useModal2 = _slicedToArray(_Modal$useModal, 2),
|
|
102
71
|
modal = _Modal$useModal2[0],
|
|
103
72
|
modalHolder = _Modal$useModal2[1];
|
|
104
|
-
var _useContainerWidth = useContainerWidth(autoWidth),
|
|
105
|
-
_useContainerWidth2 = _slicedToArray(_useContainerWidth, 2),
|
|
106
|
-
containerRef = _useContainerWidth2[0],
|
|
107
|
-
containerWidth = _useContainerWidth2[1];
|
|
108
73
|
var handlePageInit = function handlePageInit(document) {
|
|
109
74
|
var _ref2 = document || {},
|
|
110
75
|
numPages = _ref2.numPages;
|
|
@@ -112,22 +77,6 @@ var PdfViewer = function PdfViewer(_ref) {
|
|
|
112
77
|
setPageSize(numPages);
|
|
113
78
|
}
|
|
114
79
|
};
|
|
115
|
-
var handlePageLoadSuccess = function handlePageLoadSuccess(pageData) {
|
|
116
|
-
if (autoWidth && !pdfOriginalWidth) {
|
|
117
|
-
var originalWidth = pageData.originalWidth;
|
|
118
|
-
if (originalWidth) {
|
|
119
|
-
setPdfOriginalWidth(originalWidth);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
var getOptimalPdfWidth = function getOptimalPdfWidth() {
|
|
124
|
-
var scale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
125
|
-
if (!autoWidth || !containerWidth) return undefined;
|
|
126
|
-
if (pdfOriginalWidth) {
|
|
127
|
-
return Math.min(containerWidth, pdfOriginalWidth);
|
|
128
|
-
}
|
|
129
|
-
return containerWidth * scale;
|
|
130
|
-
};
|
|
131
80
|
var handleCancelLoad = function handleCancelLoad() {
|
|
132
81
|
var current = documentRef === null || documentRef === void 0 ? void 0 : documentRef.current;
|
|
133
82
|
if (current) {
|
|
@@ -190,13 +139,10 @@ var PdfViewer = function PdfViewer(_ref) {
|
|
|
190
139
|
}
|
|
191
140
|
if (showAllPages) {
|
|
192
141
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
193
|
-
ref: autoWidth ? containerRef : undefined,
|
|
194
142
|
style: {
|
|
195
143
|
display: 'flex',
|
|
196
144
|
flexDirection: 'column',
|
|
197
|
-
alignItems: 'center',
|
|
198
145
|
maxWidth: "calc(100vw - ".concat(md ? 64 : 32, "px)"),
|
|
199
|
-
width: autoWidth ? '100%' : undefined,
|
|
200
146
|
maxHeight: '100%',
|
|
201
147
|
transform: "translate(".concat(left, "px, ").concat(top, "px)"),
|
|
202
148
|
position: 'absolute',
|
|
@@ -212,9 +158,7 @@ var PdfViewer = function PdfViewer(_ref) {
|
|
|
212
158
|
}).map(function (_, index) {
|
|
213
159
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_entry.Page, {
|
|
214
160
|
pageNumber: index + 1,
|
|
215
|
-
|
|
216
|
-
scale: !autoWidth ? scale : undefined,
|
|
217
|
-
onLoadSuccess: index === 0 ? handlePageLoadSuccess : undefined
|
|
161
|
+
scale: scale
|
|
218
162
|
}, index);
|
|
219
163
|
})
|
|
220
164
|
})
|
|
@@ -222,10 +166,8 @@ var PdfViewer = function PdfViewer(_ref) {
|
|
|
222
166
|
}
|
|
223
167
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
224
168
|
children: [modalHolder, /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
225
|
-
ref: autoWidth ? containerRef : undefined,
|
|
226
169
|
style: {
|
|
227
170
|
maxWidth: "calc(100vw - ".concat(md ? 64 : 32, "px)"),
|
|
228
|
-
width: autoWidth ? '100%' : undefined,
|
|
229
171
|
maxHeight: '100%',
|
|
230
172
|
transform: "translate(".concat(left, "px, ").concat(top, "px)"),
|
|
231
173
|
position: 'absolute',
|
|
@@ -238,9 +180,7 @@ var PdfViewer = function PdfViewer(_ref) {
|
|
|
238
180
|
onPassword: onPassword,
|
|
239
181
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_entry.Page, {
|
|
240
182
|
pageNumber: page,
|
|
241
|
-
|
|
242
|
-
scale: !autoWidth ? scale : undefined,
|
|
243
|
-
onLoadSuccess: handlePageLoadSuccess
|
|
183
|
+
scale: scale
|
|
244
184
|
})
|
|
245
185
|
})
|
|
246
186
|
}, index), isCurrent && Boolean(pageSize > 1) && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
@@ -279,8 +219,7 @@ var MediaItem = function MediaItem(_ref3) {
|
|
|
279
219
|
scale = _ref3.scale,
|
|
280
220
|
offset = _ref3.offset,
|
|
281
221
|
isCurrent = _ref3.isCurrent,
|
|
282
|
-
showAllPages = _ref3.showAllPages
|
|
283
|
-
autoWidth = _ref3.autoWidth;
|
|
222
|
+
showAllPages = _ref3.showAllPages;
|
|
284
223
|
var top = offset.top,
|
|
285
224
|
left = offset.left;
|
|
286
225
|
var _useContext2 = (0, _react.useContext)(_locale.LocaleContext),
|
|
@@ -302,8 +241,7 @@ var MediaItem = function MediaItem(_ref3) {
|
|
|
302
241
|
left: left,
|
|
303
242
|
scale: scale,
|
|
304
243
|
isCurrent: isCurrent,
|
|
305
|
-
showAllPages: showAllPages
|
|
306
|
-
autoWidth: autoWidth
|
|
244
|
+
showAllPages: showAllPages
|
|
307
245
|
});
|
|
308
246
|
case 'image':
|
|
309
247
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
|
|
@@ -340,34 +278,32 @@ var Media = function Media(_ref4) {
|
|
|
340
278
|
_ref4$isCurrent = _ref4.isCurrent,
|
|
341
279
|
isCurrent = _ref4$isCurrent === void 0 ? false : _ref4$isCurrent,
|
|
342
280
|
_ref4$showAllPages = _ref4.showAllPages,
|
|
343
|
-
showAllPages = _ref4$showAllPages === void 0 ? true : _ref4$showAllPages
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
setIsDrag = _useState12[1];
|
|
350
|
-
var _useState13 = (0, _react.useState)({
|
|
281
|
+
showAllPages = _ref4$showAllPages === void 0 ? true : _ref4$showAllPages;
|
|
282
|
+
var _useState7 = (0, _react.useState)(false),
|
|
283
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
284
|
+
isDrag = _useState8[0],
|
|
285
|
+
setIsDrag = _useState8[1];
|
|
286
|
+
var _useState9 = (0, _react.useState)({
|
|
351
287
|
startX: 0,
|
|
352
288
|
startY: 0
|
|
353
289
|
}),
|
|
354
|
-
|
|
355
|
-
startPos =
|
|
356
|
-
setStartPos =
|
|
357
|
-
var
|
|
290
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
291
|
+
startPos = _useState10[0],
|
|
292
|
+
setStartPos = _useState10[1];
|
|
293
|
+
var _useState11 = (0, _react.useState)({
|
|
358
294
|
top: 0,
|
|
359
295
|
left: 0
|
|
360
296
|
}),
|
|
361
|
-
|
|
362
|
-
offset =
|
|
363
|
-
setOffset =
|
|
364
|
-
var
|
|
297
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
298
|
+
offset = _useState12[0],
|
|
299
|
+
setOffset = _useState12[1];
|
|
300
|
+
var _useState13 = (0, _react.useState)({
|
|
365
301
|
top: 0,
|
|
366
302
|
left: 0
|
|
367
303
|
}),
|
|
368
|
-
|
|
369
|
-
lastOffset =
|
|
370
|
-
setLastOffset =
|
|
304
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
305
|
+
lastOffset = _useState14[0],
|
|
306
|
+
setLastOffset = _useState14[1];
|
|
371
307
|
var handleMouseUp = function handleMouseUp(e) {
|
|
372
308
|
e.preventDefault();
|
|
373
309
|
var button = e.button;
|
|
@@ -428,8 +364,7 @@ var Media = function Media(_ref4) {
|
|
|
428
364
|
scale: scale,
|
|
429
365
|
offset: offset,
|
|
430
366
|
isCurrent: isCurrent,
|
|
431
|
-
showAllPages: showAllPages
|
|
432
|
-
autoWidth: autoWidth
|
|
367
|
+
showAllPages: showAllPages
|
|
433
368
|
})
|
|
434
369
|
});
|
|
435
370
|
};
|
|
@@ -104,6 +104,9 @@ var IglooSelect = function IglooSelect(_ref) {
|
|
|
104
104
|
var value = e.target.value;
|
|
105
105
|
var filteredOptions = options.filter(function (option) {
|
|
106
106
|
var _option$label, _option$label$toStrin;
|
|
107
|
+
if (typeof filterOption === 'function') {
|
|
108
|
+
return filterOption(value, option);
|
|
109
|
+
}
|
|
107
110
|
return Boolean(option === null || option === void 0 ? void 0 : (_option$label = option.label) === null || _option$label === void 0 ? void 0 : (_option$label$toStrin = _option$label.toString()) === null || _option$label$toStrin === void 0 ? void 0 : _option$label$toStrin.includes(value));
|
|
108
111
|
});
|
|
109
112
|
setDisplay(filteredOptions);
|
package/lib/select/select.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
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); }
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
@@ -21,6 +20,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
21
20
|
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; }
|
|
22
21
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
23
22
|
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); }
|
|
23
|
+
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); }
|
|
24
24
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
25
25
|
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."); }
|
|
26
26
|
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); }
|
|
@@ -37,7 +37,7 @@ var IglooSelect = function IglooSelect(_ref) {
|
|
|
37
37
|
children = _ref.children,
|
|
38
38
|
_onDropdownVisibleChange = _ref.onDropdownVisibleChange,
|
|
39
39
|
showSearch = _ref.showSearch,
|
|
40
|
-
|
|
40
|
+
filterOptionProp = _ref.filterOption,
|
|
41
41
|
optionFilterProp = _ref.optionFilterProp,
|
|
42
42
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
43
43
|
var _useState = (0, _react.useState)(false),
|
|
@@ -46,6 +46,7 @@ var IglooSelect = function IglooSelect(_ref) {
|
|
|
46
46
|
setOpen = _useState2[1];
|
|
47
47
|
var _useContext = (0, _react.useContext)(_localeContext.default),
|
|
48
48
|
formatMessage = _useContext.formatMessage;
|
|
49
|
+
var filterOption = _typeof(showSearch) === 'object' ? showSearch.filterOption : filterOptionProp;
|
|
49
50
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Select, _objectSpread(_objectSpread({
|
|
50
51
|
placeholder: placeholder || formatMessage({
|
|
51
52
|
id: 'Please select'
|
|
@@ -80,7 +81,7 @@ var IglooSelect = function IglooSelect(_ref) {
|
|
|
80
81
|
setOpen(open);
|
|
81
82
|
_onDropdownVisibleChange && _onDropdownVisibleChange(open);
|
|
82
83
|
},
|
|
83
|
-
showSearch: showSearch,
|
|
84
|
+
showSearch: typeof showSearch === 'boolean' ? showSearch : !!showSearch,
|
|
84
85
|
filterOption: filterOption || (showSearch ? function (value, option) {
|
|
85
86
|
var _option$label, _option$label$toStrin;
|
|
86
87
|
return Boolean(option === null || option === void 0 ? void 0 : (_option$label = option.label) === null || _option$label === void 0 ? void 0 : (_option$label$toStrin = _option$label.toString()) === null || _option$label$toStrin === void 0 ? void 0 : _option$label$toStrin.includes(value));
|
package/package.json
CHANGED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { DatePickerProps, RangePickerProps, MonthPickerProps, WeekPickerProps } from 'antd/es/date-picker';
|
|
2
|
-
import { FC, IglooComponentProps } from '../types';
|
|
3
|
-
import { Dayjs } from 'dayjs';
|
|
4
|
-
import './style';
|
|
5
|
-
export { default as IglooBuddhistDatePicker } from './buddhist';
|
|
6
|
-
type Props = Omit<DatePickerProps, 'value'> & IglooComponentProps & {
|
|
7
|
-
value?: Dayjs | null | 0;
|
|
8
|
-
};
|
|
9
|
-
declare const IglooDatePicker: FC<Props>;
|
|
10
|
-
export default IglooDatePicker;
|
|
11
|
-
export declare const IglooRangePicker: FC<RangePickerProps & IglooComponentProps>;
|
|
12
|
-
export declare const IglooWeekPicker: FC<WeekPickerProps & IglooComponentProps>;
|
|
13
|
-
export declare const IglooMonthPicker: FC<MonthPickerProps & IglooComponentProps>;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
import { FormItemConfig, FormItemName } from '../../types';
|
|
3
|
-
import './style';
|
|
4
|
-
interface ElementProps {
|
|
5
|
-
config: FormItemConfig;
|
|
6
|
-
parentName?: FormItemName;
|
|
7
|
-
preview?: boolean;
|
|
8
|
-
disabled?: boolean;
|
|
9
|
-
setShowStepButton?: (showButton: boolean) => void;
|
|
10
|
-
}
|
|
11
|
-
declare const Element: FC<ElementProps>;
|
|
12
|
-
export default Element;
|
package/es/select/select.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Select } from 'antd';
|
|
2
|
-
import { SelectProps, SelectValue } from 'antd/es/select';
|
|
3
|
-
import { FC, IglooComponentProps } from '../types';
|
|
4
|
-
import './style';
|
|
5
|
-
type Props = SelectProps<SelectValue> & IglooComponentProps;
|
|
6
|
-
type OptionType = typeof Select.Option;
|
|
7
|
-
type OptGroupType = typeof Select.OptGroup;
|
|
8
|
-
interface IglooSelectType extends FC<Props> {
|
|
9
|
-
Option: OptionType;
|
|
10
|
-
OptGroup: OptGroupType;
|
|
11
|
-
}
|
|
12
|
-
declare const IglooSelect: IglooSelectType;
|
|
13
|
-
export default IglooSelect;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { DatePickerProps, RangePickerProps, MonthPickerProps, WeekPickerProps } from 'antd/es/date-picker';
|
|
2
|
-
import { FC, IglooComponentProps } from '../types';
|
|
3
|
-
import { Dayjs } from 'dayjs';
|
|
4
|
-
import './style';
|
|
5
|
-
export { default as IglooBuddhistDatePicker } from './buddhist';
|
|
6
|
-
type Props = Omit<DatePickerProps, 'value'> & IglooComponentProps & {
|
|
7
|
-
value?: Dayjs | null | 0;
|
|
8
|
-
};
|
|
9
|
-
declare const IglooDatePicker: FC<Props>;
|
|
10
|
-
export default IglooDatePicker;
|
|
11
|
-
export declare const IglooRangePicker: FC<RangePickerProps & IglooComponentProps>;
|
|
12
|
-
export declare const IglooWeekPicker: FC<WeekPickerProps & IglooComponentProps>;
|
|
13
|
-
export declare const IglooMonthPicker: FC<MonthPickerProps & IglooComponentProps>;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
import { FormItemConfig, FormItemName } from '../../types';
|
|
3
|
-
import './style';
|
|
4
|
-
interface ElementProps {
|
|
5
|
-
config: FormItemConfig;
|
|
6
|
-
parentName?: FormItemName;
|
|
7
|
-
preview?: boolean;
|
|
8
|
-
disabled?: boolean;
|
|
9
|
-
setShowStepButton?: (showButton: boolean) => void;
|
|
10
|
-
}
|
|
11
|
-
declare const Element: FC<ElementProps>;
|
|
12
|
-
export default Element;
|
package/lib/select/select.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Select } from 'antd';
|
|
2
|
-
import { SelectProps, SelectValue } from 'antd/es/select';
|
|
3
|
-
import { FC, IglooComponentProps } from '../types';
|
|
4
|
-
import './style';
|
|
5
|
-
type Props = SelectProps<SelectValue> & IglooComponentProps;
|
|
6
|
-
type OptionType = typeof Select.Option;
|
|
7
|
-
type OptGroupType = typeof Select.OptGroup;
|
|
8
|
-
interface IglooSelectType extends FC<Props> {
|
|
9
|
-
Option: OptionType;
|
|
10
|
-
OptGroup: OptGroupType;
|
|
11
|
-
}
|
|
12
|
-
declare const IglooSelect: IglooSelectType;
|
|
13
|
-
export default IglooSelect;
|