@sunggang/ui-lib 0.1.18 → 0.1.20

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.
package/index.esm.css CHANGED
@@ -634,6 +634,9 @@ video {
634
634
  .relative {
635
635
  position: relative;
636
636
  }
637
+ .bottom-0 {
638
+ bottom: 0px;
639
+ }
637
640
  .left-0 {
638
641
  left: 0px;
639
642
  }
@@ -1039,6 +1042,9 @@ video {
1039
1042
  .p-0 {
1040
1043
  padding: 0px;
1041
1044
  }
1045
+ .p-1 {
1046
+ padding: 0.25rem;
1047
+ }
1042
1048
  .p-2 {
1043
1049
  padding: 0.5rem;
1044
1050
  }
package/index.esm2.js CHANGED
@@ -5824,6 +5824,9 @@ function _array_like_to_array$3(arr, len) {
5824
5824
  function _array_with_holes$3(arr) {
5825
5825
  if (Array.isArray(arr)) return arr;
5826
5826
  }
5827
+ function _array_without_holes(arr) {
5828
+ if (Array.isArray(arr)) return _array_like_to_array$3(arr);
5829
+ }
5827
5830
  function _define_property$4(obj, key, value) {
5828
5831
  if (key in obj) {
5829
5832
  Object.defineProperty(obj, key, {
@@ -5837,6 +5840,9 @@ function _define_property$4(obj, key, value) {
5837
5840
  }
5838
5841
  return obj;
5839
5842
  }
5843
+ function _iterable_to_array(iter) {
5844
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
5845
+ }
5840
5846
  function _iterable_to_array_limit$3(arr, i) {
5841
5847
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
5842
5848
  if (_i == null) return;
@@ -5864,6 +5870,9 @@ function _iterable_to_array_limit$3(arr, i) {
5864
5870
  function _non_iterable_rest$3() {
5865
5871
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
5866
5872
  }
5873
+ function _non_iterable_spread() {
5874
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
5875
+ }
5867
5876
  function _object_spread$4(target) {
5868
5877
  for(var i = 1; i < arguments.length; i++){
5869
5878
  var source = arguments[i] != null ? arguments[i] : {};
@@ -5906,6 +5915,9 @@ function _object_spread_props$2(target, source) {
5906
5915
  function _sliced_to_array$3(arr, i) {
5907
5916
  return _array_with_holes$3(arr) || _iterable_to_array_limit$3(arr, i) || _unsupported_iterable_to_array$3(arr, i) || _non_iterable_rest$3();
5908
5917
  }
5918
+ function _to_consumable_array(arr) {
5919
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array$3(arr) || _non_iterable_spread();
5920
+ }
5909
5921
  function _unsupported_iterable_to_array$3(o, minLen) {
5910
5922
  if (!o) return;
5911
5923
  if (typeof o === "string") return _array_like_to_array$3(o, minLen);
@@ -5915,7 +5927,7 @@ function _unsupported_iterable_to_array$3(o, minLen) {
5915
5927
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$3(o, minLen);
5916
5928
  }
5917
5929
  var DropImage = function(param) {
5918
- var _param_preview = param.preview, preview = _param_preview === void 0 ? true : _param_preview, setFiles = param.setFiles, imageUrls = param.imageUrls;
5930
+ var _param_preview = param.preview, preview = _param_preview === void 0 ? true : _param_preview, setFiles = param.setFiles, imageUrls = param.imageUrls, setImageUrls = param.setImageUrls;
5919
5931
  var _useState = _sliced_to_array$3(useState([]), 2), previewFiles = _useState[0], setPreviewFiles = _useState[1];
5920
5932
  var _useDropzone = useDropzone({
5921
5933
  accept: {
@@ -5942,6 +5954,16 @@ var DropImage = function(param) {
5942
5954
  });
5943
5955
  }
5944
5956
  }), getRootProps = _useDropzone.getRootProps, getInputProps = _useDropzone.getInputProps; _useDropzone.isDragActive; _useDropzone.isDragAccept; _useDropzone.isDragReject;
5957
+ var removePreviewFile = function(file) {
5958
+ var currentItem = previewFiles === null || previewFiles === void 0 ? void 0 : previewFiles.indexOf(file);
5959
+ previewFiles.splice(currentItem, 1);
5960
+ setPreviewFiles(_to_consumable_array(previewFiles));
5961
+ };
5962
+ var removeImageUrls = function(item) {
5963
+ var currentItem = imageUrls === null || imageUrls === void 0 ? void 0 : imageUrls.indexOf(item);
5964
+ imageUrls.splice(currentItem, 1);
5965
+ setImageUrls(_to_consumable_array(imageUrls));
5966
+ };
5945
5967
  return /*#__PURE__*/ jsxs("section", {
5946
5968
  className: "w-full",
5947
5969
  children: [
@@ -5987,20 +6009,48 @@ var DropImage = function(param) {
5987
6009
  preview && /*#__PURE__*/ jsx("div", {
5988
6010
  className: "flex pt-2 gap-2",
5989
6011
  children: (previewFiles === null || previewFiles === void 0 ? void 0 : previewFiles.length) ? previewFiles.length > 0 ? previewFiles.map(function(item) {
5990
- return /*#__PURE__*/ jsx("div", {
5991
- children: /*#__PURE__*/ jsx("img", {
5992
- className: "w-24 h-24 object-cover",
5993
- src: item === null || item === void 0 ? void 0 : item.preview,
5994
- alt: ""
5995
- })
6012
+ return /*#__PURE__*/ jsxs("div", {
6013
+ className: "relative",
6014
+ children: [
6015
+ /*#__PURE__*/ jsx("button", {
6016
+ className: "absolute bottom-0 right-0 bg-white rounded-full p-1 shadow-md",
6017
+ onClick: function() {
6018
+ return removePreviewFile(item);
6019
+ },
6020
+ children: /*#__PURE__*/ jsx(Icon, {
6021
+ icon: "mingcute:delete-2-line",
6022
+ width: "1.5rem",
6023
+ height: "1.5rem"
6024
+ })
6025
+ }),
6026
+ /*#__PURE__*/ jsx("img", {
6027
+ className: "w-24 h-24 object-cover",
6028
+ src: item === null || item === void 0 ? void 0 : item.preview,
6029
+ alt: ""
6030
+ })
6031
+ ]
5996
6032
  }, item === null || item === void 0 ? void 0 : item.uuid);
5997
6033
  }) : null : imageUrls && imageUrls.length ? imageUrls.map(function(item) {
5998
- return /*#__PURE__*/ jsx("div", {
5999
- children: /*#__PURE__*/ jsx("img", {
6000
- className: "w-24 h-24 object-cover",
6001
- src: item === null || item === void 0 ? void 0 : item.url,
6002
- alt: ""
6003
- })
6034
+ return /*#__PURE__*/ jsxs("div", {
6035
+ className: "relative",
6036
+ children: [
6037
+ /*#__PURE__*/ jsx("button", {
6038
+ className: "absolute bottom-0 right-0 bg-white rounded-full p-1 shadow-md",
6039
+ onClick: function() {
6040
+ return removeImageUrls(item);
6041
+ },
6042
+ children: /*#__PURE__*/ jsx(Icon, {
6043
+ icon: "mingcute:delete-2-line",
6044
+ width: "1.5rem",
6045
+ height: "1.5rem"
6046
+ })
6047
+ }),
6048
+ /*#__PURE__*/ jsx("img", {
6049
+ className: "w-24 h-24 object-cover",
6050
+ src: item === null || item === void 0 ? void 0 : item.url,
6051
+ alt: ""
6052
+ })
6053
+ ]
6004
6054
  }, item === null || item === void 0 ? void 0 : item.url);
6005
6055
  }) : null
6006
6056
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sunggang/ui-lib",
3
- "version": "0.1.18",
3
+ "version": "0.1.20",
4
4
  "dependencies": {
5
5
  "@radix-ui/react-popover": "^1.0.7",
6
6
  "@radix-ui/react-slot": "^1.0.2",
@@ -1,14 +1,9 @@
1
1
  import React from 'react';
2
- interface ImageItem {
3
- map?: any;
4
- length?: ImageItem | undefined;
5
- url: string;
6
- book_items_category_id: string | null;
7
- }
8
2
  interface DropImageProps {
9
3
  preview?: boolean;
10
- imageUrls?: ImageItem[];
4
+ imageUrls?: any;
11
5
  setFiles: React.Dispatch<React.SetStateAction<File[]>>;
6
+ setImageUrls?: any;
12
7
  }
13
8
  export declare const DropImage: React.FC<DropImageProps>;
14
9
  export {};
@@ -0,0 +1,8 @@
1
+ interface DropImageProps {
2
+ className?: string;
3
+ item?: any;
4
+ config?: any;
5
+ }
6
+ declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-bf5e6555").R, import("@storybook/types").Args>;
7
+ export default _default;
8
+ export declare const Base: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-bf5e6555").R, DropImageProps>;
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ interface SelectProps {
3
+ className?: string;
4
+ item?: any;
5
+ config?: any;
6
+ }
7
+ export declare const MultipleSelect: React.FC<SelectProps>;
8
+ export default MultipleSelect;