@luscii-healthtech/web-ui 8.1.3 → 8.3.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.
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { IconProps } from "./types/IconProps.type";
3
+ declare const _default: (props: IconProps) => JSX.Element;
4
+ export default _default;
@@ -17,6 +17,7 @@ export { default as EditIcon } from "./EditIcon";
17
17
  export { default as EmptyIcon } from "./EmptyIcon";
18
18
  export { default as EmptyStateDashboardIcon } from "./EmptyStateDashboardIcon";
19
19
  export { default as ExclamationMarkIcon } from "./ExclamationMarkIcon";
20
+ export { default as EyeIconSlashed } from "./EyeIconSlashed";
20
21
  export { default as EyeIcon } from "./EyeIcon";
21
22
  export { default as GearColoredIcon } from "./GearColoredIcon";
22
23
  export { default as GearIcon } from "./GearIcon";
@@ -30,6 +30,10 @@ export interface ImagePickerProps {
30
30
  * ```
31
31
  */
32
32
  acceptedMimeTypes?: string[];
33
+ /**
34
+ * Maximum file size allowed to be uploaded in MB. If undefined, a default limit of 100mb is applied.
35
+ */
36
+ maxFileSize?: number;
33
37
  clearImageIndex?: number;
34
38
  type?: "normal" | "compact";
35
39
  isDisabled?: boolean;
@@ -76,6 +80,10 @@ export interface MediaPickerProps {
76
80
  * ```
77
81
  */
78
82
  acceptedMimeTypes?: string[];
83
+ /**
84
+ * Maximum file size allowed to be uploaded in MB. If undefined, a default limit of 100mb is applied.
85
+ */
86
+ maxFileSize?: number;
79
87
  isDisabled?: boolean;
80
88
  onChange: (target: TargetProps) => void;
81
89
  isUploadButtonVisible?: boolean;
@@ -450,6 +450,13 @@ const SvgExclamationMarkIcon = (props) => React__namespace.default.createElement
450
450
  );
451
451
  var ExclamationMarkIcon = IconWrapper(SvgExclamationMarkIcon);
452
452
 
453
+ const SvgEyeIconSlashed = (props) => React__namespace.default.createElement(
454
+ "svg",
455
+ Object.assign({ xmlns: "http://www.w3.org/2000/svg", width: 22, height: 20, fill: "none", viewBox: "0 0 22 20" }, props),
456
+ React__namespace.default.createElement("path", { fill: "#9CA3AF", d: "M11 4.5c2.76 0 5 2.24 5 5 0 .51-.1 1-.24 1.46l3.06 3.06c1.39-1.23 2.49-2.77 3.18-4.53C20.27 5.11 16 2 11 2c-1.27 0-2.49.2-3.64.57l2.17 2.17c.47-.14.96-.24 1.47-.24ZM1.71 1.16a.996.996 0 0 0 0 1.41l1.97 1.97A11.892 11.892 0 0 0 0 9.5C1.73 13.89 6 17 11 17c1.52 0 2.97-.3 4.31-.82l2.72 2.72a.996.996 0 1 0 1.41-1.41L3.13 1.16c-.39-.39-1.03-.39-1.42 0ZM11 14.5c-2.76 0-5-2.24-5-5 0-.77.18-1.5.49-2.14l1.57 1.57c-.03.18-.06.37-.06.57 0 1.66 1.34 3 3 3 .2 0 .38-.03.57-.07L13.14 14c-.65.32-1.37.5-2.14.5Zm2.97-5.33a2.97 2.97 0 0 0-2.64-2.64l2.64 2.64Z" })
457
+ );
458
+ var EyeIconSlashed = IconWrapper(SvgEyeIconSlashed);
459
+
453
460
  const SvgEyeIcon = (props) => React__namespace.default.createElement(
454
461
  "svg",
455
462
  Object.assign({ xmlns: "http://www.w3.org/2000/svg", width: 22, height: 15, fill: "none", viewBox: "0 0 22 15" }, props),
@@ -687,6 +694,7 @@ var Icons = /*#__PURE__*/Object.freeze({
687
694
  EmptyStateDashboardIcon: EmptyStateDashboardIcon,
688
695
  ExclamationMarkIcon: ExclamationMarkIcon,
689
696
  EyeIcon: EyeIcon,
697
+ EyeIconSlashed: EyeIconSlashed,
690
698
  GearColoredIcon: GearColoredIcon,
691
699
  GearIcon: GearIcon,
692
700
  GroupColoredIcon: GroupColoredIcon,
@@ -4633,7 +4641,26 @@ const ImageCategory = (props) => {
4633
4641
  );
4634
4642
  };
4635
4643
 
4636
- const ImagePickerInner = ({ categories, clearImageIndex, handleChange, images, isDisabled = false, name, preselectedImage, preselectedMediaType = "image", acceptedMimeTypes = ["image/svg+xml"], type = "normal", isUploadButtonVisible = false, isClearButtonVisible = false, isUploading = false, isErrorUploading = false, localisation, innerRef }) => {
4644
+ const ImagePickerInner = ({
4645
+ categories,
4646
+ clearImageIndex,
4647
+ handleChange,
4648
+ images,
4649
+ isDisabled = false,
4650
+ name,
4651
+ preselectedImage,
4652
+ preselectedMediaType = "image",
4653
+ acceptedMimeTypes = ["image/svg+xml"],
4654
+ maxFileSize = 100,
4655
+ //100mb
4656
+ type = "normal",
4657
+ isUploadButtonVisible = false,
4658
+ isClearButtonVisible = false,
4659
+ isUploading = false,
4660
+ isErrorUploading = false,
4661
+ localisation,
4662
+ innerRef
4663
+ }) => {
4637
4664
  var _a;
4638
4665
  const placeholderImage = clearImageIndex !== void 0 && images[clearImageIndex] ? images[clearImageIndex] : img;
4639
4666
  const isTypeCompact = type === "compact";
@@ -4670,6 +4697,7 @@ const ImagePickerInner = ({ categories, clearImageIndex, handleChange, images, i
4670
4697
  handleDeleteClick();
4671
4698
  }
4672
4699
  setHighlightedImage(event.currentTarget.src);
4700
+ setError(null);
4673
4701
  };
4674
4702
  const handleDeleteClick = () => {
4675
4703
  handleChange({ target: { name, value: "" } });
@@ -4679,10 +4707,12 @@ const ImagePickerInner = ({ categories, clearImageIndex, handleChange, images, i
4679
4707
  setSelectedMedia(placeholderImage);
4680
4708
  setSelectedMediaType("image");
4681
4709
  setHighlightedImage(null);
4710
+ setError(null);
4682
4711
  };
4683
4712
  function handleConfirmSelection() {
4684
4713
  setSelectedMedia(highlightedImage !== null && highlightedImage !== void 0 ? highlightedImage : placeholderImage);
4685
4714
  setSelectedMediaType("image");
4715
+ setError(null);
4686
4716
  handleChange({
4687
4717
  target: { name, value: highlightedImage }
4688
4718
  });
@@ -4691,14 +4721,14 @@ const ImagePickerInner = ({ categories, clearImageIndex, handleChange, images, i
4691
4721
  const handleCloseModal = () => {
4692
4722
  setIsImagesPanelOpen(false);
4693
4723
  };
4694
- const mediaType = (mimeType) => {
4695
- return mimeType.split("/")[0];
4696
- };
4724
+ const mediaType = (mimeType) => mimeType.split("/")[0];
4725
+ const maxFileSizeInBytes = maxFileSize * 1e3 * 1e3;
4726
+ const isValidFile = (file) => acceptedMimeTypes.includes(file.type) && file.size < maxFileSizeInBytes;
4697
4727
  const uploadImage = (event) => __awaiter(void 0, void 0, void 0, function* () {
4698
4728
  var _b;
4699
- if (event.currentTarget.files) {
4729
+ if (event.currentTarget.files && event.currentTarget.files.length > 0) {
4700
4730
  const file = event.currentTarget.files[0];
4701
- if (acceptedMimeTypes.includes(file.type)) {
4731
+ if (isValidFile(file)) {
4702
4732
  setSelectedMedia(URL.createObjectURL(file));
4703
4733
  setSelectedMediaType(mediaType(file.type));
4704
4734
  const data = new FormData();
@@ -4742,14 +4772,14 @@ const ImagePickerInner = ({ categories, clearImageIndex, handleChange, images, i
4742
4772
  isUploadButtonVisible && React__namespace.default.createElement(
4743
4773
  "span",
4744
4774
  { className: "cweb-imagePicker-upload" },
4745
- React__namespace.default.createElement(SecondaryButton, { text: localisation.uploadImage, isDisabled, id: `upload-image-${name}`, onClick: () => {
4775
+ React__namespace.default.createElement(SecondaryButton, { text: localisation.uploadImage, isDisabled, isPending: isUploading, id: `upload-image-${name}`, onClick: () => {
4746
4776
  var _a2;
4747
4777
  setIsImagesPanelOpen(false);
4748
4778
  (_a2 = fileInputRef.current) === null || _a2 === void 0 ? void 0 : _a2.click();
4749
4779
  } }),
4750
4780
  React__namespace.default.createElement("input", { ref: fileInputRef, type: "file", disabled: isDisabled, name: `uploaded-${name}`, accept: acceptedMimeTypes.join(","), onChange: uploadImage, className: "ui-hidden" })
4751
4781
  ),
4752
- isClearButtonVisible && selectedMedia !== placeholderImage && React__namespace.default.createElement(SecondaryButton, { text: localisation.clearSelection, isDisabled, onClick: handleDeleteClick })
4782
+ isClearButtonVisible && selectedMedia !== placeholderImage && !isUploading && React__namespace.default.createElement(SecondaryButton, { text: localisation.clearSelection, isDisabled, isPending: isUploading, onClick: handleDeleteClick })
4753
4783
  )
4754
4784
  ),
4755
4785
  React__namespace.default.createElement(
@@ -5524,6 +5554,7 @@ exports.EmptyStateDashboardIcon = EmptyStateDashboardIcon;
5524
5554
  exports.ErrorBlock = ErrorBlock;
5525
5555
  exports.ExclamationMarkIcon = ExclamationMarkIcon;
5526
5556
  exports.EyeIcon = EyeIcon;
5557
+ exports.EyeIconSlashed = EyeIconSlashed;
5527
5558
  exports.FilterBar = FilterBar;
5528
5559
  exports.FilterBarUtils = FilterBar_utils;
5529
5560
  exports.FlexColumn = FlexColumn;