@vitrosoftware/common-ui-ts 1.1.41 → 1.1.42

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,8 +1,8 @@
1
- import { MutableRefObject } from 'react';
1
+ /// <reference types="react" />
2
2
  import { DropdownItem } from '../DropdownButton/DropdownItem';
3
3
  interface ImagePickerProps {
4
- inputFileRef: MutableRefObject<HTMLInputElement | null>;
5
4
  label: string;
5
+ name?: string;
6
6
  itemList?: DropdownItem[];
7
7
  defaultUrl?: string;
8
8
  classNameRoot?: string;
@@ -10,7 +10,7 @@ interface ImagePickerProps {
10
10
  classNameDefaultIcon?: string;
11
11
  imgUrlUpload?: string;
12
12
  imgUrlDelete?: string;
13
- onDelete: () => void;
13
+ onChange: (file: File | null, name?: string) => void;
14
14
  }
15
15
  export declare const ImagePicker: (props: ImagePickerProps) => JSX.Element;
16
16
  export {};
package/dist/index.js CHANGED
@@ -64220,7 +64220,8 @@ var LOCALE$7;
64220
64220
 
64221
64221
  var ImagePicker = function ImagePicker(props) {
64222
64222
  var localeService = inversifyReact.useInjection(SERVICE.LOCALE);
64223
- var renderPrevie = function renderPrevie() {
64223
+ var inputFileRef = React.useRef(null);
64224
+ var renderPreview = function renderPreview() {
64224
64225
  if (props.defaultUrl) {
64225
64226
  return React__default.createElement("div", {
64226
64227
  className: props.classNameDefaultIcon ? props.classNameDefaultIcon : styles$J['vitro-image-picker-icon-wrapper']
@@ -64236,12 +64237,16 @@ var ImagePicker = function ImagePicker(props) {
64236
64237
  }));
64237
64238
  }
64238
64239
  };
64240
+ var onChange = function onChange(e) {
64241
+ var _e$target$files$, _e$target$files;
64242
+ props.onChange((_e$target$files$ = e === null || e === void 0 ? void 0 : (_e$target$files = e.target.files) === null || _e$target$files === void 0 ? void 0 : _e$target$files[0]) != null ? _e$target$files$ : null, props.name);
64243
+ };
64239
64244
  var defaultItemList = React.useMemo(function () {
64240
64245
  var _props$itemList;
64241
64246
  var result = [{
64242
64247
  onClick: function onClick() {
64243
- var _props$inputFileRef, _props$inputFileRef$c;
64244
- return (_props$inputFileRef = props.inputFileRef) === null || _props$inputFileRef === void 0 ? void 0 : (_props$inputFileRef$c = _props$inputFileRef.current) === null || _props$inputFileRef$c === void 0 ? void 0 : _props$inputFileRef$c.click();
64248
+ var _inputFileRef$current;
64249
+ return inputFileRef === null || inputFileRef === void 0 ? void 0 : (_inputFileRef$current = inputFileRef.current) === null || _inputFileRef$current === void 0 ? void 0 : _inputFileRef$current.click();
64245
64250
  },
64246
64251
  text: localeService.create(LOCALE$7.ACTION_UPLOAD),
64247
64252
  value: ACTION$1.UPLOAD,
@@ -64253,7 +64258,9 @@ var ImagePicker = function ImagePicker(props) {
64253
64258
  }];
64254
64259
  if (props.defaultUrl) {
64255
64260
  result.push({
64256
- onClick: props.onDelete,
64261
+ onClick: function onClick() {
64262
+ return onChange(null);
64263
+ },
64257
64264
  text: localeService.create(LOCALE$7.ACTION_DELETE),
64258
64265
  value: ACTION$1.DELETE,
64259
64266
  key: ACTION$1.DELETE,
@@ -64277,9 +64284,10 @@ var ImagePicker = function ImagePicker(props) {
64277
64284
  }), React__default.createElement("input", {
64278
64285
  type: 'file',
64279
64286
  className: styles$J['vitro-image-picker-input'],
64280
- ref: props.inputFileRef,
64287
+ ref: inputFileRef,
64288
+ onChange: onChange,
64281
64289
  accept: "image/*"
64282
- }), renderPrevie()));
64290
+ }), renderPreview()));
64283
64291
  };
64284
64292
 
64285
64293
  var styles$K = {"vitro-criterion-container":"_criterion_vitro-criterion-container_2cYcSkL","vitro-block":"_criterion_vitro-block_3E9-RXM","vitro-control":"_criterion_vitro-control_2JLaybj","vitro-label":"_criterion_vitro-label_3F6a8dj","vitro-operator-select-container":"_criterion_vitro-operator-select-container_3OkjzXG","vitro-operator-select":"_criterion_vitro-operator-select_1guNlk9","vitro-operator-list":"_criterion_vitro-operator-list_3A2VZsd","vitro-button-cancel":"_criterion_vitro-button-cancel_2C2G0sL","vitro-focus":"_criterion_vitro-focus_3FNLsoN","vitro-error":"_criterion_vitro-error_3pvFrlW","vitro-condition-select":"_criterion_vitro-condition-select_1hTBBg-","vitro-icon":"_criterion_vitro-icon_1DmS0jh","vitro-condition-list":"_criterion_vitro-condition-list_10UIxJI"};