@luscii-healthtech/web-ui 18.1.1 → 19.0.0

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,9 +1,9 @@
1
1
  import React from "react";
2
2
  import { Control, RegisterOptions } from "react-hook-form/dist/index.ie11";
3
- import { ImagePickerFieldConfiguration, FormFieldLabelerWithFormProps } from "./form.types";
4
- interface FormImagePickerProps extends ImagePickerFieldConfiguration, FormFieldLabelerWithFormProps {
3
+ import { MediaPickerFieldConfiguration, FormFieldLabelerWithFormProps } from "./form.types";
4
+ interface FormMediaPickerProps extends MediaPickerFieldConfiguration, FormFieldLabelerWithFormProps {
5
5
  control: Control;
6
6
  rules?: Exclude<RegisterOptions, "valueAsNumber" | "valueAsDate" | "setValueAs">;
7
7
  }
8
- export declare const FormImagePicker: React.ForwardRefExoticComponent<FormImagePickerProps & React.RefAttributes<any>>;
8
+ export declare const FormImagePicker: React.ForwardRefExoticComponent<FormMediaPickerProps & React.RefAttributes<any>>;
9
9
  export {};
@@ -3,7 +3,7 @@ import React, { HTMLInputTypeAttribute } from "react";
3
3
  import { InputProps } from "../Input/Input";
4
4
  import { RadioGroupProps } from "../RadioGroup/RadioGroupV2";
5
5
  import { SelectProps } from "../Select/Select";
6
- import { ImagePickerProps } from "../MediaPicker/MediaPicker";
6
+ import { MediaPickerProps } from "../MediaPicker/MediaPicker";
7
7
  import { PartialProperties } from "../../types/general.types";
8
8
  import { CheckboxProps } from "../Checkbox/Checkbox";
9
9
  import { TextareaProps } from "../Textarea/Textarea";
@@ -32,7 +32,7 @@ export interface FormFieldLabelerProps {
32
32
  interface FieldVoidConfiguration extends Partial<FormFieldBaseConfiguration<never>> {
33
33
  type: "void";
34
34
  }
35
- export type FormFieldConfiguration<TFieldValues> = FieldInputConfiguration | FieldSelectConfiguration | FieldImagePickerConfiguration | FieldRadioGroupConfiguration | FieldRowConfiguration<TFieldValues> | FieldCheckboxConfiguration | FieldCheckboxListConfiguration | FieldTextareaConfiguration | FieldTitleConfiguration | FieldVoidConfiguration;
35
+ export type FormFieldConfiguration<TFieldValues> = FieldInputConfiguration | FieldSelectConfiguration | FieldMediaPickerConfiguration | FieldRadioGroupConfiguration | FieldRowConfiguration<TFieldValues> | FieldCheckboxConfiguration | FieldCheckboxListConfiguration | FieldTextareaConfiguration | FieldTitleConfiguration | FieldVoidConfiguration;
36
36
  /**
37
37
  * @backwardscompatibility
38
38
  * @deprecated - this is an alias for `FormFieldConfiguration`, for backwards compatibility the name can remain for now, but
@@ -60,10 +60,10 @@ export interface FieldSelectConfiguration extends FormFieldBaseConfiguration<Sel
60
60
  type: "select";
61
61
  fieldProps: SelectProps;
62
62
  }
63
- export type ImagePickerFieldConfiguration = PartialProperties<Omit<ImagePickerProps, "name">, "handleChange">;
64
- export interface FieldImagePickerConfiguration extends FormFieldBaseConfiguration<ImagePickerFieldConfiguration> {
65
- type: "imagePicker";
66
- fieldProps: ImagePickerFieldConfiguration;
63
+ export type MediaPickerFieldConfiguration = PartialProperties<Omit<MediaPickerProps, "name">, "onChange">;
64
+ export interface FieldMediaPickerConfiguration extends FormFieldBaseConfiguration<MediaPickerFieldConfiguration> {
65
+ type: "mediaPicker";
66
+ fieldProps: MediaPickerFieldConfiguration;
67
67
  }
68
68
  export interface FieldCheckboxConfiguration extends FormFieldBaseConfiguration<Omit<CheckboxProps, "name" | "type">> {
69
69
  type: "checkbox";
@@ -47,10 +47,6 @@ export interface ImagePickerProps {
47
47
  export declare const ImagePickerInner: React.FC<ImagePickerProps & {
48
48
  innerRef?: React.Ref<HTMLButtonElement>;
49
49
  }>;
50
- /**
51
- * @deprecated Use MediaPicker instead
52
- */
53
- export declare const ImagePicker: React.ForwardRefExoticComponent<ImagePickerProps & React.RefAttributes<HTMLButtonElement>>;
54
50
  export interface MediaPickerProps {
55
51
  name: string;
56
52
  media: string[];
@@ -92,4 +88,4 @@ export interface MediaPickerProps {
92
88
  isErrorUploading?: boolean;
93
89
  localisation: Partial<Record<"openModalButton" | "selectButton" | "error" | "upload" | "clearSelection" | "cancel" | "search" | "unsupportedMediaType" | "modalTitle", string>>;
94
90
  }
95
- export declare const MediaPicker: (props: MediaPickerProps) => React.JSX.Element;
91
+ export declare const MediaPicker: React.ForwardRefExoticComponent<MediaPickerProps & React.RefAttributes<HTMLButtonElement>>;
package/dist/index.d.ts CHANGED
@@ -52,7 +52,6 @@ export { Spinner } from "./components/Spinner/Spinner";
52
52
  export { Steps } from "./components/Steps/Steps";
53
53
  export { default as Switcher } from "./components/Switcher/Switcher";
54
54
  export { default as Image } from "./components/Image/Image";
55
- export { ImagePicker } from "./components/MediaPicker/MediaPicker";
56
55
  export { MediaPicker, TargetProps } from "./components/MediaPicker/MediaPicker";
57
56
  export { default as Tabbar, TabbarProps, TabItemDetails, } from "./components/Tabbar/Tabbar";
58
57
  export { Breadcrumbs, BreadcrumbProps } from "./components/Breadcrumbs";
@@ -4812,12 +4812,11 @@ const ImagePickerInner = ({
4812
4812
  )
4813
4813
  );
4814
4814
  };
4815
- const ImagePicker = React__namespace.default.forwardRef((props, ref) => React__namespace.default.createElement(ImagePickerInner, Object.assign({}, props, { innerRef: ref })));
4816
- const MediaPicker = (props) => {
4815
+ const MediaPicker = React__namespace.default.forwardRef((props, ref) => {
4817
4816
  var _a, _b;
4818
4817
  const mappedProps = Object.assign(Object.assign({}, props), { preselectedImage: props.preselectedMedia, images: props.media, handleChange: props.onChange, clearImageIndex: props.clearIndex, localisation: Object.assign(Object.assign({}, props.localisation), { uploadImage: (_b = (_a = props.localisation) === null || _a === void 0 ? void 0 : _a.upload) !== null && _b !== void 0 ? _b : "Upload file" }) });
4819
- return React__namespace.default.createElement(ImagePicker, Object.assign({}, mappedProps));
4820
- };
4818
+ return React__namespace.default.createElement(ImagePickerInner, Object.assign({}, mappedProps, { innerRef: ref }));
4819
+ });
4821
4820
 
4822
4821
  const TagGroup = ({ children, tags, tagSize = "base", className }) => React__namespace.default.createElement(
4823
4822
  "div",
@@ -5123,18 +5122,16 @@ const FormImagePicker = React__namespace.default.forwardRef((_a, innerRef) => {
5123
5122
  { name, fieldErrors, fieldRequired, label, info, decoratorClassname },
5124
5123
  React__namespace.default.createElement(index_ie11.Controller, { name, control, rules, render: (field) => {
5125
5124
  var _a2;
5126
- React.useEffect(() => {
5127
- if (fieldProps.preselectedImage && !field.value) {
5128
- field.onChange({
5129
- target: { name, value: fieldProps.preselectedImage }
5130
- });
5131
- }
5132
- }, []);
5133
- return React__namespace.default.createElement(ImagePicker, Object.assign({}, fieldProps, field, { handleChange: (e) => {
5125
+ if (fieldProps.preselectedMedia && !field.value) {
5126
+ field.onChange({
5127
+ target: { name, value: fieldProps.preselectedMedia }
5128
+ });
5129
+ }
5130
+ return React__namespace.default.createElement(MediaPicker, Object.assign({}, fieldProps, field, { media: fieldProps.media, onChange: (e) => {
5134
5131
  var _a3;
5135
5132
  field.onChange(e.target.value);
5136
- (_a3 = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.handleChange) === null || _a3 === void 0 ? void 0 : _a3.call(fieldProps, e);
5137
- }, preselectedImage: (_a2 = field.value) !== null && _a2 !== void 0 ? _a2 : fieldProps.preselectedImage, ref: innerRef }));
5133
+ (_a3 = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.onChange) === null || _a3 === void 0 ? void 0 : _a3.call(fieldProps, e);
5134
+ }, preselectedMedia: (_a2 = field.value) !== null && _a2 !== void 0 ? _a2 : fieldProps.preselectedMedia, ref: innerRef }));
5138
5135
  } })
5139
5136
  );
5140
5137
  });
@@ -5243,7 +5240,7 @@ function FormFieldMapper(formFieldProps, useFormReturn) {
5243
5240
  return React__namespace.default.createElement(FormInput, Object.assign({ key: name, name }, decoratorProps, { fieldRequired: isRequired(options), fieldErrors: errors }, fieldProps, { control, rules: options, type }));
5244
5241
  case "select":
5245
5242
  return React__namespace.default.createElement(FormSelect, Object.assign({ key: name }, decoratorProps, { fieldRequired: isRequired(options), fieldErrors: errors }, fieldProps, { control, rules: options, name }));
5246
- case "imagePicker":
5243
+ case "mediaPicker":
5247
5244
  return React__namespace.default.createElement(FormImagePicker, Object.assign({ key: name }, decoratorProps, { fieldRequired: isRequired(options), fieldErrors: errors }, fieldProps, { control, rules: options, name }));
5248
5245
  case "radioGroup": {
5249
5246
  return React__namespace.default.createElement(FormRadioGroup, Object.assign({ key: name }, decoratorProps, { fieldRequired: isRequired(options), fieldErrors: errors }, fieldProps, { name, rules: options, control }));
@@ -5765,7 +5762,6 @@ exports.HeartIcon = HeartIcon;
5765
5762
  exports.Icon = Icon;
5766
5763
  exports.Image = Image$1;
5767
5764
  exports.ImageIcon = ImageIcon;
5768
- exports.ImagePicker = ImagePicker;
5769
5765
  exports.InfoField = InfoField;
5770
5766
  exports.InfoIcon = InfoIcon;
5771
5767
  exports.Input = Input;