@pdg/react-form 1.0.3 → 1.0.5
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.
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { FormFileCommands, FormFileProps } from '../FormFile';
|
|
2
|
-
export interface
|
|
2
|
+
export interface FormImageFileImageSize {
|
|
3
3
|
width: number;
|
|
4
4
|
height: number;
|
|
5
5
|
}
|
|
6
6
|
export interface FormImageFileProps extends Omit<FormFileProps, 'preview'> {
|
|
7
|
-
|
|
7
|
+
imageSize?: FormImageFileImageSize | FormImageFileImageSize[];
|
|
8
8
|
preview?: boolean;
|
|
9
9
|
previewMaxHeight?: number;
|
|
10
10
|
}
|
package/dist/index.esm.js
CHANGED
|
@@ -16247,7 +16247,7 @@ styleInject(css_248z$1);var FormFile = React__default.forwardRef(function (_a, r
|
|
|
16247
16247
|
FormFile.displayName = 'FormFile';
|
|
16248
16248
|
FormFile.defaultProps = FormFileDefaultProps;var FormImageFileDefaultProps = __assign$4(__assign$4({}, FormFileDefaultProps), { accept: '.jpg,.jpeg,.png' });var css_248z = ".FormImageFile .preview-img {\n max-width: 100%;\n}\n.FormImageFile:not(.hide-file-name):not(.variant-standard) .preview-img {\n padding-right: 14px;\n}";
|
|
16249
16249
|
styleInject(css_248z);var FormImageFile = React__default.forwardRef(function (_a, ref) {
|
|
16250
|
-
var className = _a.className,
|
|
16250
|
+
var className = _a.className, imageSize = _a.imageSize, preview = _a.preview, previewMaxHeight = _a.previewMaxHeight, initValue = _a.value, onChange = _a.onChange, onFile = _a.onFile, onLink = _a.onLink, props = __rest$2(_a, ["className", "imageSize", "preview", "previewMaxHeight", "value", "onChange", "onFile", "onLink"]);
|
|
16251
16251
|
var _b = useAutoUpdateState$1(initValue), value = _b[0], setValue = _b[1];
|
|
16252
16252
|
var _c = useState(), previewNode = _c[0], setPreviewNode = _c[1];
|
|
16253
16253
|
var _d = useState({
|
|
@@ -16265,7 +16265,7 @@ styleInject(css_248z);var FormImageFile = React__default.forwardRef(function (_a
|
|
|
16265
16265
|
}, [value, preview, previewMaxHeight]);
|
|
16266
16266
|
// Function --------------------------------------------------------------------------------------------------------
|
|
16267
16267
|
var imageSizeCheck = useCallback(function (file) {
|
|
16268
|
-
if (
|
|
16268
|
+
if (imageSize && urlKit) {
|
|
16269
16269
|
return new Promise(function (resolve, reject) {
|
|
16270
16270
|
var img = new Image();
|
|
16271
16271
|
img.onload = function () {
|
|
@@ -16274,8 +16274,8 @@ styleInject(css_248z);var FormImageFile = React__default.forwardRef(function (_a
|
|
|
16274
16274
|
urlKit.revokeObjectURL(img.src);
|
|
16275
16275
|
var sizeOk = false;
|
|
16276
16276
|
var sizeText = '';
|
|
16277
|
-
if (Array.isArray(
|
|
16278
|
-
|
|
16277
|
+
if (Array.isArray(imageSize)) {
|
|
16278
|
+
imageSize.forEach(function (a) {
|
|
16279
16279
|
if (width === a.width && height === a.height) {
|
|
16280
16280
|
sizeOk = true;
|
|
16281
16281
|
}
|
|
@@ -16285,8 +16285,8 @@ styleInject(css_248z);var FormImageFile = React__default.forwardRef(function (_a
|
|
|
16285
16285
|
});
|
|
16286
16286
|
}
|
|
16287
16287
|
else {
|
|
16288
|
-
sizeOk = width ===
|
|
16289
|
-
sizeText = "".concat(
|
|
16288
|
+
sizeOk = width === imageSize.width && height === imageSize.height;
|
|
16289
|
+
sizeText = "".concat(imageSize.width, "*").concat(imageSize.height);
|
|
16290
16290
|
}
|
|
16291
16291
|
if (sizeOk) {
|
|
16292
16292
|
resolve();
|
|
@@ -16321,7 +16321,7 @@ styleInject(css_248z);var FormImageFile = React__default.forwardRef(function (_a
|
|
|
16321
16321
|
});
|
|
16322
16322
|
}
|
|
16323
16323
|
return Promise.resolve();
|
|
16324
|
-
}, [urlKit,
|
|
16324
|
+
}, [urlKit, imageSize]);
|
|
16325
16325
|
// Event Handler ---------------------------------------------------------------------------------------------------
|
|
16326
16326
|
var handleChange = useCallback(function (value) {
|
|
16327
16327
|
setValue(value);
|
|
@@ -16448,7 +16448,9 @@ Search.defaultProps = SearchDefaultProps;var SearchGroupDefaultProps = {
|
|
|
16448
16448
|
}, [align]))[0];
|
|
16449
16449
|
// Render ----------------------------------------------------------------------------------------------------------
|
|
16450
16450
|
return (React__default.createElement(Grid, { item: true, className: classNames$1(className, 'SearchGroup'), style: { flex: max ? 1 : undefined, display: hidden ? 'none' : undefined } },
|
|
16451
|
-
React__default.createElement(Grid, { container: true, wrap: 'wrap', spacing: spacing, justifyContent: justifyContent, alignItems: 'start', style: style, sx: sx }, React__default.Children.map(children, function (child, idx) {
|
|
16451
|
+
React__default.createElement(Grid, { container: true, wrap: 'wrap', spacing: spacing, justifyContent: justifyContent, alignItems: 'start', style: style, sx: sx }, React__default.Children.map(children, function (child, idx) {
|
|
16452
|
+
return React__default.isValidElement(child) ? (React__default.createElement(Grid, { key: idx, item: true }, child)) : undefined;
|
|
16453
|
+
}))));
|
|
16452
16454
|
};
|
|
16453
16455
|
SearchGroup.defaultProps = SearchGroupDefaultProps;var SearchButtonDefaultProps = {};var SearchButton = function (_a) {
|
|
16454
16456
|
// State -----------------------------------------------------------------------------------------------------------
|