@rahmatsaputra-my-id/react-js-library 0.0.18 → 0.0.19

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,4 +1,4 @@
1
- import { ImageInputProps } from './ImageInput.component.types';
2
1
  import React from 'react';
2
+ import { ImageInputProps } from './ImageInput.component.types';
3
3
  declare const ImageInput: React.FC<ImageInputProps>;
4
4
  export default ImageInput;
@@ -1,10 +1,9 @@
1
1
  export interface ImageInputProps {
2
2
  label?: string;
3
3
  subLabel?: string;
4
- imageUrl?: string | null;
5
- handleOnUpload: () => void;
6
- handleOnPreview: () => void;
4
+ imageUrl?: string;
7
5
  containerStyle?: any;
8
6
  isMandatory?: boolean;
9
7
  isEditAble?: boolean;
8
+ handleOnPickImage: () => void;
10
9
  }
package/dist/index.es.js CHANGED
@@ -840,7 +840,7 @@ var Text = function (_a) {
840
840
  };
841
841
 
842
842
  var BottomSheetPhoto = function (_a) {
843
- var visible = _a.visible, onClose = _a.onClose, _b = _a.title, title = _b === void 0 ? '' : _b, onUploadBase64 = _a.onUploadBase64;
843
+ var visible = _a.visible, onClose = _a.onClose, _b = _a.title, title = _b === void 0 ? 'Pilihan' : _b, onUploadBase64 = _a.onUploadBase64;
844
844
  var fileInputRef = useRef(null);
845
845
  var _c = useState(false), cameraVisible = _c[0], setCameraVisible = _c[1];
846
846
  var _d = useState(20), paddingBottom = _d[0], setPaddingBottom = _d[1];
@@ -1176,12 +1176,6 @@ var styles$7 = {
1176
1176
  },
1177
1177
  };
1178
1178
 
1179
- var ImageInput = function (_a) {
1180
- var label = _a.label, subLabel = _a.subLabel, _b = _a.imageUrl, imageUrl = _b === void 0 ? null : _b, handleOnUpload = _a.handleOnUpload, handleOnPreview = _a.handleOnPreview, containerStyle = _a.containerStyle, _c = _a.isMandatory, isMandatory = _c === void 0 ? false : _c, _d = _a.isEditAble, isEditAble = _d === void 0 ? false : _d;
1181
- var renderScreen = function () { return (jsxs(View, __assign({ style: __assign(__assign({}, styles$7.container), containerStyle) }, { children: [jsx(TouchableOpacity, __assign({ style: styles$7.containerImage, onPress: imageUrl ? handleOnPreview : handleOnUpload }, { children: jsx(Images, { src: imageUrl ? imageUrl : Icons.camera, style: imageUrl ? styles$7.image : styles$7.iconCamera }) })), jsxs(View, __assign({ style: styles$7.containerText }, { children: [label && (jsx(Text, __assign({ type: "bold_16", style: styles$7.label }, { children: label }))), subLabel && jsx(Text, { children: subLabel }), isMandatory && jsx(Text, __assign({ type: "normal_14_red" }, { children: '*Wajib' }))] })), isEditAble && imageUrl && (jsx(TouchableOpacity, __assign({ onPress: handleOnUpload }, { children: jsx(Images, { src: Icons.edit, style: styles$7.iconEdit }) })))] }))); };
1182
- return renderScreen();
1183
- };
1184
-
1185
1179
  var styles$6 = {
1186
1180
  backdrop: {
1187
1181
  position: 'fixed',
@@ -1240,6 +1234,23 @@ var PhotoPreviewModal = function (_a) {
1240
1234
  }, style: styles$6.image })) : (jsx("p", __assign({ style: styles$6.noImageContainer }, { children: "No image provided" }))) })) })), document.body);
1241
1235
  };
1242
1236
 
1237
+ var ImageInput = function (_a) {
1238
+ var label = _a.label, subLabel = _a.subLabel, _b = _a.imageUrl, imageUrl = _b === void 0 ? null : _b, containerStyle = _a.containerStyle, _c = _a.isMandatory, isMandatory = _c === void 0 ? false : _c, _d = _a.isEditAble, isEditAble = _d === void 0 ? false : _d, _e = _a.handleOnPickImage, handleOnPickImage = _e === void 0 ? function (_base64) { } : _e;
1239
+ var _f = useState(imageUrl !== null && imageUrl !== void 0 ? imageUrl : undefined), imagePreview = _f[0], setImagePreview = _f[1];
1240
+ var _g = useState(false), isVisibleBottomSheet = _g[0], setIsVisibleBottomSheet = _g[1];
1241
+ var _h = useState(false), isPreviewVisible = _h[0], setIsPreviewVisible = _h[1];
1242
+ var handleOnUpload = function () { return setIsVisibleBottomSheet(true); };
1243
+ var handleOnPreview = function () { return setIsPreviewVisible(true); };
1244
+ return (jsxs(View, __assign({ style: __assign(__assign({}, styles$7.container), containerStyle) }, { children: [jsx(TouchableOpacity, __assign({ style: styles$7.containerImage, onPress: imagePreview ? handleOnPreview : handleOnUpload }, { children: jsx(Images, { src: imagePreview ? imagePreview : Icons.camera, style: imagePreview ? styles$7.image : styles$7.iconCamera }) })), jsxs(View, __assign({ style: styles$7.containerText }, { children: [label && (jsx(Text, __assign({ type: "bold_16", style: styles$7.label }, { children: label }))), subLabel && jsx(Text, { children: subLabel }), isMandatory && jsx(Text, __assign({ type: "normal_14_red" }, { children: '*Wajib' }))] })), isEditAble && imagePreview && (jsx(TouchableOpacity, __assign({ onPress: handleOnUpload }, { children: jsx(Images, { src: Icons.edit, style: styles$7.iconEdit }) }))), jsx(PhotoPreviewModal, { visible: isPreviewVisible, onDismiss: function () { return setIsPreviewVisible(false); }, imageUrl: imagePreview }), jsx(BottomSheetPhoto, { visible: isVisibleBottomSheet, onClose: function () { return setIsVisibleBottomSheet(false); }, onUploadBase64: function (base64) {
1245
+ if (typeof base64 === 'string') {
1246
+ setImagePreview(base64);
1247
+ if (typeof handleOnPickImage === 'function') {
1248
+ handleOnPickImage(base64);
1249
+ }
1250
+ }
1251
+ } })] })));
1252
+ };
1253
+
1243
1254
  var styles$5 = {
1244
1255
  sliderContainer: {
1245
1256
  position: 'relative',