@bbki.ng/components 1.5.19 → 1.5.22
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/dist/index.d.ts +39 -1
- package/dist/index.js +211 -2
- package/dist/index.mjs +209 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -225,4 +225,42 @@ interface NoiseCoverProps {
|
|
|
225
225
|
}
|
|
226
226
|
declare const NoiseCover: (props: NoiseCoverProps) => JSX.Element;
|
|
227
227
|
|
|
228
|
-
|
|
228
|
+
declare enum ossProcessType {
|
|
229
|
+
THUMBNAIL = "thumbnail",
|
|
230
|
+
WEBP = "webp",
|
|
231
|
+
NULL = "null",
|
|
232
|
+
oWEBP = "owebp",
|
|
233
|
+
PROG = "prog"
|
|
234
|
+
}
|
|
235
|
+
interface Photo {
|
|
236
|
+
src: string;
|
|
237
|
+
width: number;
|
|
238
|
+
height: number;
|
|
239
|
+
processType?: ossProcessType;
|
|
240
|
+
avgColor?: string;
|
|
241
|
+
thumbnailSrc?: string;
|
|
242
|
+
renderedWidth?: number;
|
|
243
|
+
}
|
|
244
|
+
interface ImgProps extends Photo {
|
|
245
|
+
className?: string;
|
|
246
|
+
size?: "large" | "normal";
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
declare const Img: (props: ImgProps) => JSX.Element;
|
|
250
|
+
|
|
251
|
+
interface RandomRowsLayoutProps {
|
|
252
|
+
classNames?: string;
|
|
253
|
+
cellWrapperClsGenerator?: (colNum: number, randBoolean: boolean) => string;
|
|
254
|
+
cellsCount: number;
|
|
255
|
+
cellRenderer: (index: number, randomBool: boolean, col: number) => React.ReactNode;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
declare type ImageRenderer = (Img: ReactElement, index: number, col: number, randBool: boolean) => ReactNode;
|
|
259
|
+
interface GalleryProps extends Omit<RandomRowsLayoutProps, "classNames" | "cellsCount" | "cellRenderer"> {
|
|
260
|
+
images: ImgProps[];
|
|
261
|
+
children?: ReactNode;
|
|
262
|
+
imageRenderer?: ImageRenderer;
|
|
263
|
+
}
|
|
264
|
+
declare const Gallery: (props: GalleryProps) => JSX.Element;
|
|
265
|
+
|
|
266
|
+
export { Article, ArticleProps, ArticleSkeleton, ArticleSkeletonProps, BLinkDotProps, BlinkDot, Breadcrumb, BreadcrumbProps, Button, ButtonProps, ButtonType, DropImage, Error, ErrorBoundary, Gallery, GalleryProps, ImageDropProps, ImagePreviewerProps, ImageRenderer, Img, Link, LinkColor, LinkList, LinkListProps, LinkListSkeleton, LinkListSkeletonProps, LinkProps, List, Logo, LogoProps, Nav, NavProps, NoiseCover, NoiseCoverProps, NotFound, Page, Panel, PanelProps, PathObj, PopConfirm, PopConfirmProps, Skeleton, SkeletonColor, SkeletonProps, Table, TableProps, Tag, TagProps, Tags, ThreeColLayout, TitledList, TitledListProps, listProps, threeColLayoutProps };
|
package/dist/index.js
CHANGED
|
@@ -67,6 +67,8 @@ __export(src_exports, {
|
|
|
67
67
|
DropImage: () => DropImage,
|
|
68
68
|
Error: () => Error2,
|
|
69
69
|
ErrorBoundary: () => ErrorBoundary,
|
|
70
|
+
Gallery: () => Gallery,
|
|
71
|
+
Img: () => Img,
|
|
70
72
|
Link: () => Link,
|
|
71
73
|
LinkColor: () => LinkColor,
|
|
72
74
|
LinkList: () => LinkList,
|
|
@@ -576,7 +578,7 @@ var useDropImage = (params) => {
|
|
|
576
578
|
setIsDragOver(false);
|
|
577
579
|
imageFile.current = null;
|
|
578
580
|
};
|
|
579
|
-
const
|
|
581
|
+
const calcDefaultImgSize2 = (img, defaultWidth) => {
|
|
580
582
|
const { width, height } = img;
|
|
581
583
|
const whRatio = width / height;
|
|
582
584
|
const isHorizontal = width > height;
|
|
@@ -619,7 +621,7 @@ var useDropImage = (params) => {
|
|
|
619
621
|
await p();
|
|
620
622
|
} catch (e) {
|
|
621
623
|
}
|
|
622
|
-
setImageSize(
|
|
624
|
+
setImageSize(calcDefaultImgSize2({
|
|
623
625
|
width: img.naturalWidth,
|
|
624
626
|
height: img.naturalHeight
|
|
625
627
|
}));
|
|
@@ -832,6 +834,211 @@ var ThreeColLayout = (props) => {
|
|
|
832
834
|
className: (0, import_classnames9.default)("hidden", colCls)
|
|
833
835
|
}, rightRenderer && rightRenderer()));
|
|
834
836
|
};
|
|
837
|
+
|
|
838
|
+
// src/img/Img.tsx
|
|
839
|
+
var import_classnames10 = __toESM(require("classnames"));
|
|
840
|
+
var import_react19 = __toESM(require("react"));
|
|
841
|
+
|
|
842
|
+
// src/img/utils.ts
|
|
843
|
+
var addOssWebpProcessStyle = (originUrl, style) => {
|
|
844
|
+
const OSS_ADDRESS = "https://zjh-im-res.oss-cn-shenzhen.aliyuncs.com";
|
|
845
|
+
const isInvalidOSSImgUrl = !originUrl.startsWith(OSS_ADDRESS);
|
|
846
|
+
const isProcessedOssImg = /x-oss-process=style\/\w+/.test(originUrl);
|
|
847
|
+
const isWebpImg = /webp$/.test(originUrl);
|
|
848
|
+
if (isInvalidOSSImgUrl || isProcessedOssImg || isWebpImg && style === "webp" /* WEBP */ || style === "null" /* NULL */) {
|
|
849
|
+
return originUrl;
|
|
850
|
+
}
|
|
851
|
+
return `${originUrl}?x-oss-process=style/${style}`;
|
|
852
|
+
};
|
|
853
|
+
var calcDefaultImgSize = (img, defaultWidth, scale) => {
|
|
854
|
+
const { width, height } = img;
|
|
855
|
+
const whRatio = width / height;
|
|
856
|
+
const isHorizontal = width > height;
|
|
857
|
+
const finalWidth = (defaultWidth || (isHorizontal ? 576 : 384)) * (scale || 1);
|
|
858
|
+
return {
|
|
859
|
+
width: finalWidth,
|
|
860
|
+
height: finalWidth / whRatio
|
|
861
|
+
};
|
|
862
|
+
};
|
|
863
|
+
var delay = (time) => {
|
|
864
|
+
return new Promise((resolve) => {
|
|
865
|
+
setTimeout(resolve, time);
|
|
866
|
+
});
|
|
867
|
+
};
|
|
868
|
+
|
|
869
|
+
// src/img/Img.tsx
|
|
870
|
+
var emptyDataURL = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
|
|
871
|
+
var Img = (props) => {
|
|
872
|
+
const {
|
|
873
|
+
src,
|
|
874
|
+
className,
|
|
875
|
+
renderedWidth,
|
|
876
|
+
avgColor,
|
|
877
|
+
thumbnailSrc,
|
|
878
|
+
processType,
|
|
879
|
+
size
|
|
880
|
+
} = props;
|
|
881
|
+
const { width, height } = calcDefaultImgSize(props, renderedWidth, size === "normal" ? 0.6 : 1);
|
|
882
|
+
const [loaded, setLoaded] = (0, import_react19.useState)(false);
|
|
883
|
+
const [decoded, setDecoded] = (0, import_react19.useState)(false);
|
|
884
|
+
const baseWrapperStyle = {
|
|
885
|
+
width: "initial",
|
|
886
|
+
height: "initial",
|
|
887
|
+
backgroundColor: avgColor || "unset"
|
|
888
|
+
};
|
|
889
|
+
const dynamicWrapperStyle = loaded ? {
|
|
890
|
+
backgroundImage: "none"
|
|
891
|
+
} : {
|
|
892
|
+
backgroundSize: "cover",
|
|
893
|
+
backgroundPosition: "0% 0%",
|
|
894
|
+
backgroundImage: `url(${thumbnailSrc ? thumbnailSrc : addOssWebpProcessStyle(src, "thumbnail" /* THUMBNAIL */)})`
|
|
895
|
+
};
|
|
896
|
+
const handleImgLoad = (img) => {
|
|
897
|
+
const updateFunc = async () => {
|
|
898
|
+
const p = "decode" in img ? img.decode : Promise.resolve;
|
|
899
|
+
try {
|
|
900
|
+
await p();
|
|
901
|
+
} catch (e) {
|
|
902
|
+
}
|
|
903
|
+
await delay(500);
|
|
904
|
+
setDecoded(true);
|
|
905
|
+
await delay(500);
|
|
906
|
+
setLoaded(true);
|
|
907
|
+
};
|
|
908
|
+
img.onload = updateFunc;
|
|
909
|
+
};
|
|
910
|
+
return /* @__PURE__ */ import_react19.default.createElement("span", {
|
|
911
|
+
className: (0, import_classnames10.default)(className, "inline-block", "relative", "overflow-hidden", "leading-none", "align-bottom", "border-0"),
|
|
912
|
+
style: Object.assign({}, baseWrapperStyle, dynamicWrapperStyle)
|
|
913
|
+
}, /* @__PURE__ */ import_react19.default.createElement("img", {
|
|
914
|
+
ref: (input) => {
|
|
915
|
+
if (!input) {
|
|
916
|
+
return;
|
|
917
|
+
}
|
|
918
|
+
handleImgLoad(input);
|
|
919
|
+
},
|
|
920
|
+
width,
|
|
921
|
+
height,
|
|
922
|
+
src: addOssWebpProcessStyle(src, processType || "webp" /* WEBP */),
|
|
923
|
+
decoding: "async",
|
|
924
|
+
loading: "lazy",
|
|
925
|
+
style: {
|
|
926
|
+
contentVisibility: "auto"
|
|
927
|
+
},
|
|
928
|
+
className: (0, import_classnames10.default)("transition-opacity", "opacity-100", {
|
|
929
|
+
"opacity-0": !decoded
|
|
930
|
+
})
|
|
931
|
+
}), /* @__PURE__ */ import_react19.default.createElement("img", {
|
|
932
|
+
src: emptyDataURL,
|
|
933
|
+
className: (0, import_classnames10.default)("lqip-blur", "absolute", "h-full", "w-full", "transition-opacity", "opacity-100", {
|
|
934
|
+
"opacity-0": decoded
|
|
935
|
+
}),
|
|
936
|
+
style: { top: 0, left: 0 }
|
|
937
|
+
}));
|
|
938
|
+
};
|
|
939
|
+
|
|
940
|
+
// src/img/Gallery.tsx
|
|
941
|
+
var import_classnames12 = __toESM(require("classnames"));
|
|
942
|
+
var import_react21 = __toESM(require("react"));
|
|
943
|
+
|
|
944
|
+
// src/img/RandomRowsLayout.tsx
|
|
945
|
+
var import_classnames11 = __toESM(require("classnames"));
|
|
946
|
+
var import_react20 = __toESM(require("react"));
|
|
947
|
+
var last = (arr) => {
|
|
948
|
+
if (arr.length < 2) {
|
|
949
|
+
return arr[0];
|
|
950
|
+
}
|
|
951
|
+
return arr[arr.length - 1];
|
|
952
|
+
};
|
|
953
|
+
var defaultCellClsGenerator = (colNum, isCenterSingleCell) => {
|
|
954
|
+
const isSingleCell = colNum === 1;
|
|
955
|
+
const singleCellWidth = isCenterSingleCell ? "full" : "1/2";
|
|
956
|
+
const cellWidth = isSingleCell ? singleCellWidth : "1/2";
|
|
957
|
+
return `md:basis-${cellWidth}`;
|
|
958
|
+
};
|
|
959
|
+
var generateRandomBoolean = (p = 0.5) => Math.random() < p;
|
|
960
|
+
var generateRandomColNum = (total) => {
|
|
961
|
+
const colNumArr = [];
|
|
962
|
+
if (total <= 2) {
|
|
963
|
+
return [total];
|
|
964
|
+
}
|
|
965
|
+
let colSum = 0;
|
|
966
|
+
while (colSum < total) {
|
|
967
|
+
const p = last(colNumArr) === 2 ? 0.9 : 0.5;
|
|
968
|
+
const num = generateRandomBoolean(p) ? 1 : 2;
|
|
969
|
+
colNumArr.push(num);
|
|
970
|
+
colSum += num;
|
|
971
|
+
}
|
|
972
|
+
return colNumArr;
|
|
973
|
+
};
|
|
974
|
+
var RandomRowsLayout = (props) => {
|
|
975
|
+
const {
|
|
976
|
+
cellsCount,
|
|
977
|
+
cellRenderer,
|
|
978
|
+
classNames: classNames7 = "",
|
|
979
|
+
cellWrapperClsGenerator = defaultCellClsGenerator
|
|
980
|
+
} = props;
|
|
981
|
+
const colNums = generateRandomColNum(cellsCount);
|
|
982
|
+
const indexRef = import_react20.default.useRef(0);
|
|
983
|
+
import_react20.default.useEffect(() => {
|
|
984
|
+
indexRef.current = 0;
|
|
985
|
+
});
|
|
986
|
+
return /* @__PURE__ */ import_react20.default.createElement("div", {
|
|
987
|
+
className: classNames7
|
|
988
|
+
}, colNums.map((colNum, row) => {
|
|
989
|
+
const randBool = generateRandomBoolean(colNum < 2 ? 0.6 : 0.5);
|
|
990
|
+
const randBoolArr = [randBool, !randBool];
|
|
991
|
+
return /* @__PURE__ */ import_react20.default.createElement("div", {
|
|
992
|
+
className: "flex items-center flex-wrap",
|
|
993
|
+
key: row
|
|
994
|
+
}, new Array(colNum).fill(null).map((_, col) => {
|
|
995
|
+
indexRef.current += 1;
|
|
996
|
+
const generatedCls = cellWrapperClsGenerator(colNum, generateRandomBoolean());
|
|
997
|
+
const cls4 = (0, import_classnames11.default)("flex items-center justify-center flex-shrink-0 flex-grow-0", "basis-full", generatedCls);
|
|
998
|
+
return /* @__PURE__ */ import_react20.default.createElement("div", {
|
|
999
|
+
className: cls4,
|
|
1000
|
+
key: col
|
|
1001
|
+
}, cellRenderer(indexRef.current - 1, randBoolArr[col], col));
|
|
1002
|
+
}));
|
|
1003
|
+
}));
|
|
1004
|
+
};
|
|
1005
|
+
|
|
1006
|
+
// src/img/Gallery.tsx
|
|
1007
|
+
var defaultImageRenderer = (img, index, col) => {
|
|
1008
|
+
return /* @__PURE__ */ import_react21.default.createElement("div", {
|
|
1009
|
+
className: (0, import_classnames12.default)("mb-256", {
|
|
1010
|
+
"md:mr-64": col === 0,
|
|
1011
|
+
"md:ml-64": col !== 0
|
|
1012
|
+
})
|
|
1013
|
+
}, img);
|
|
1014
|
+
};
|
|
1015
|
+
var Gallery = (props) => {
|
|
1016
|
+
const _a = props, {
|
|
1017
|
+
images,
|
|
1018
|
+
children,
|
|
1019
|
+
imageRenderer = defaultImageRenderer
|
|
1020
|
+
} = _a, rest = __objRest(_a, [
|
|
1021
|
+
"images",
|
|
1022
|
+
"children",
|
|
1023
|
+
"imageRenderer"
|
|
1024
|
+
]);
|
|
1025
|
+
const renderImage = (index, isLargeImage, col) => {
|
|
1026
|
+
const image = images[index];
|
|
1027
|
+
if (!image) {
|
|
1028
|
+
return null;
|
|
1029
|
+
}
|
|
1030
|
+
return imageRenderer(/* @__PURE__ */ import_react21.default.createElement(Img, __spreadProps(__spreadValues({}, image), {
|
|
1031
|
+
size: isLargeImage ? "large" : "normal"
|
|
1032
|
+
})), index, col, isLargeImage);
|
|
1033
|
+
};
|
|
1034
|
+
return /* @__PURE__ */ import_react21.default.createElement("div", {
|
|
1035
|
+
className: "w-full flex justify-center"
|
|
1036
|
+
}, /* @__PURE__ */ import_react21.default.createElement(RandomRowsLayout, __spreadValues({
|
|
1037
|
+
classNames: "mx-32 mt-128 max-w-screen-xl",
|
|
1038
|
+
cellsCount: images.length,
|
|
1039
|
+
cellRenderer: renderImage
|
|
1040
|
+
}, rest)), children);
|
|
1041
|
+
};
|
|
835
1042
|
module.exports = __toCommonJS(src_exports);
|
|
836
1043
|
// Annotate the CommonJS export names for ESM import in node:
|
|
837
1044
|
0 && (module.exports = {
|
|
@@ -844,6 +1051,8 @@ module.exports = __toCommonJS(src_exports);
|
|
|
844
1051
|
DropImage,
|
|
845
1052
|
Error,
|
|
846
1053
|
ErrorBoundary,
|
|
1054
|
+
Gallery,
|
|
1055
|
+
Img,
|
|
847
1056
|
Link,
|
|
848
1057
|
LinkColor,
|
|
849
1058
|
LinkList,
|
package/dist/index.mjs
CHANGED
|
@@ -521,7 +521,7 @@ var useDropImage = (params) => {
|
|
|
521
521
|
setIsDragOver(false);
|
|
522
522
|
imageFile.current = null;
|
|
523
523
|
};
|
|
524
|
-
const
|
|
524
|
+
const calcDefaultImgSize2 = (img, defaultWidth) => {
|
|
525
525
|
const { width, height } = img;
|
|
526
526
|
const whRatio = width / height;
|
|
527
527
|
const isHorizontal = width > height;
|
|
@@ -564,7 +564,7 @@ var useDropImage = (params) => {
|
|
|
564
564
|
await p();
|
|
565
565
|
} catch (e) {
|
|
566
566
|
}
|
|
567
|
-
setImageSize(
|
|
567
|
+
setImageSize(calcDefaultImgSize2({
|
|
568
568
|
width: img.naturalWidth,
|
|
569
569
|
height: img.naturalHeight
|
|
570
570
|
}));
|
|
@@ -777,6 +777,211 @@ var ThreeColLayout = (props) => {
|
|
|
777
777
|
className: cls3("hidden", colCls)
|
|
778
778
|
}, rightRenderer && rightRenderer()));
|
|
779
779
|
};
|
|
780
|
+
|
|
781
|
+
// src/img/Img.tsx
|
|
782
|
+
import classnames from "classnames";
|
|
783
|
+
import React18, { useState as useState5 } from "react";
|
|
784
|
+
|
|
785
|
+
// src/img/utils.ts
|
|
786
|
+
var addOssWebpProcessStyle = (originUrl, style) => {
|
|
787
|
+
const OSS_ADDRESS = "https://zjh-im-res.oss-cn-shenzhen.aliyuncs.com";
|
|
788
|
+
const isInvalidOSSImgUrl = !originUrl.startsWith(OSS_ADDRESS);
|
|
789
|
+
const isProcessedOssImg = /x-oss-process=style\/\w+/.test(originUrl);
|
|
790
|
+
const isWebpImg = /webp$/.test(originUrl);
|
|
791
|
+
if (isInvalidOSSImgUrl || isProcessedOssImg || isWebpImg && style === "webp" /* WEBP */ || style === "null" /* NULL */) {
|
|
792
|
+
return originUrl;
|
|
793
|
+
}
|
|
794
|
+
return `${originUrl}?x-oss-process=style/${style}`;
|
|
795
|
+
};
|
|
796
|
+
var calcDefaultImgSize = (img, defaultWidth, scale) => {
|
|
797
|
+
const { width, height } = img;
|
|
798
|
+
const whRatio = width / height;
|
|
799
|
+
const isHorizontal = width > height;
|
|
800
|
+
const finalWidth = (defaultWidth || (isHorizontal ? 576 : 384)) * (scale || 1);
|
|
801
|
+
return {
|
|
802
|
+
width: finalWidth,
|
|
803
|
+
height: finalWidth / whRatio
|
|
804
|
+
};
|
|
805
|
+
};
|
|
806
|
+
var delay = (time) => {
|
|
807
|
+
return new Promise((resolve) => {
|
|
808
|
+
setTimeout(resolve, time);
|
|
809
|
+
});
|
|
810
|
+
};
|
|
811
|
+
|
|
812
|
+
// src/img/Img.tsx
|
|
813
|
+
var emptyDataURL = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
|
|
814
|
+
var Img = (props) => {
|
|
815
|
+
const {
|
|
816
|
+
src,
|
|
817
|
+
className,
|
|
818
|
+
renderedWidth,
|
|
819
|
+
avgColor,
|
|
820
|
+
thumbnailSrc,
|
|
821
|
+
processType,
|
|
822
|
+
size
|
|
823
|
+
} = props;
|
|
824
|
+
const { width, height } = calcDefaultImgSize(props, renderedWidth, size === "normal" ? 0.6 : 1);
|
|
825
|
+
const [loaded, setLoaded] = useState5(false);
|
|
826
|
+
const [decoded, setDecoded] = useState5(false);
|
|
827
|
+
const baseWrapperStyle = {
|
|
828
|
+
width: "initial",
|
|
829
|
+
height: "initial",
|
|
830
|
+
backgroundColor: avgColor || "unset"
|
|
831
|
+
};
|
|
832
|
+
const dynamicWrapperStyle = loaded ? {
|
|
833
|
+
backgroundImage: "none"
|
|
834
|
+
} : {
|
|
835
|
+
backgroundSize: "cover",
|
|
836
|
+
backgroundPosition: "0% 0%",
|
|
837
|
+
backgroundImage: `url(${thumbnailSrc ? thumbnailSrc : addOssWebpProcessStyle(src, "thumbnail" /* THUMBNAIL */)})`
|
|
838
|
+
};
|
|
839
|
+
const handleImgLoad = (img) => {
|
|
840
|
+
const updateFunc = async () => {
|
|
841
|
+
const p = "decode" in img ? img.decode : Promise.resolve;
|
|
842
|
+
try {
|
|
843
|
+
await p();
|
|
844
|
+
} catch (e) {
|
|
845
|
+
}
|
|
846
|
+
await delay(500);
|
|
847
|
+
setDecoded(true);
|
|
848
|
+
await delay(500);
|
|
849
|
+
setLoaded(true);
|
|
850
|
+
};
|
|
851
|
+
img.onload = updateFunc;
|
|
852
|
+
};
|
|
853
|
+
return /* @__PURE__ */ React18.createElement("span", {
|
|
854
|
+
className: classnames(className, "inline-block", "relative", "overflow-hidden", "leading-none", "align-bottom", "border-0"),
|
|
855
|
+
style: Object.assign({}, baseWrapperStyle, dynamicWrapperStyle)
|
|
856
|
+
}, /* @__PURE__ */ React18.createElement("img", {
|
|
857
|
+
ref: (input) => {
|
|
858
|
+
if (!input) {
|
|
859
|
+
return;
|
|
860
|
+
}
|
|
861
|
+
handleImgLoad(input);
|
|
862
|
+
},
|
|
863
|
+
width,
|
|
864
|
+
height,
|
|
865
|
+
src: addOssWebpProcessStyle(src, processType || "webp" /* WEBP */),
|
|
866
|
+
decoding: "async",
|
|
867
|
+
loading: "lazy",
|
|
868
|
+
style: {
|
|
869
|
+
contentVisibility: "auto"
|
|
870
|
+
},
|
|
871
|
+
className: classnames("transition-opacity", "opacity-100", {
|
|
872
|
+
"opacity-0": !decoded
|
|
873
|
+
})
|
|
874
|
+
}), /* @__PURE__ */ React18.createElement("img", {
|
|
875
|
+
src: emptyDataURL,
|
|
876
|
+
className: classnames("lqip-blur", "absolute", "h-full", "w-full", "transition-opacity", "opacity-100", {
|
|
877
|
+
"opacity-0": decoded
|
|
878
|
+
}),
|
|
879
|
+
style: { top: 0, left: 0 }
|
|
880
|
+
}));
|
|
881
|
+
};
|
|
882
|
+
|
|
883
|
+
// src/img/Gallery.tsx
|
|
884
|
+
import classnames3 from "classnames";
|
|
885
|
+
import React20 from "react";
|
|
886
|
+
|
|
887
|
+
// src/img/RandomRowsLayout.tsx
|
|
888
|
+
import classnames2 from "classnames";
|
|
889
|
+
import React19 from "react";
|
|
890
|
+
var last = (arr) => {
|
|
891
|
+
if (arr.length < 2) {
|
|
892
|
+
return arr[0];
|
|
893
|
+
}
|
|
894
|
+
return arr[arr.length - 1];
|
|
895
|
+
};
|
|
896
|
+
var defaultCellClsGenerator = (colNum, isCenterSingleCell) => {
|
|
897
|
+
const isSingleCell = colNum === 1;
|
|
898
|
+
const singleCellWidth = isCenterSingleCell ? "full" : "1/2";
|
|
899
|
+
const cellWidth = isSingleCell ? singleCellWidth : "1/2";
|
|
900
|
+
return `md:basis-${cellWidth}`;
|
|
901
|
+
};
|
|
902
|
+
var generateRandomBoolean = (p = 0.5) => Math.random() < p;
|
|
903
|
+
var generateRandomColNum = (total) => {
|
|
904
|
+
const colNumArr = [];
|
|
905
|
+
if (total <= 2) {
|
|
906
|
+
return [total];
|
|
907
|
+
}
|
|
908
|
+
let colSum = 0;
|
|
909
|
+
while (colSum < total) {
|
|
910
|
+
const p = last(colNumArr) === 2 ? 0.9 : 0.5;
|
|
911
|
+
const num = generateRandomBoolean(p) ? 1 : 2;
|
|
912
|
+
colNumArr.push(num);
|
|
913
|
+
colSum += num;
|
|
914
|
+
}
|
|
915
|
+
return colNumArr;
|
|
916
|
+
};
|
|
917
|
+
var RandomRowsLayout = (props) => {
|
|
918
|
+
const {
|
|
919
|
+
cellsCount,
|
|
920
|
+
cellRenderer,
|
|
921
|
+
classNames: classNames7 = "",
|
|
922
|
+
cellWrapperClsGenerator = defaultCellClsGenerator
|
|
923
|
+
} = props;
|
|
924
|
+
const colNums = generateRandomColNum(cellsCount);
|
|
925
|
+
const indexRef = React19.useRef(0);
|
|
926
|
+
React19.useEffect(() => {
|
|
927
|
+
indexRef.current = 0;
|
|
928
|
+
});
|
|
929
|
+
return /* @__PURE__ */ React19.createElement("div", {
|
|
930
|
+
className: classNames7
|
|
931
|
+
}, colNums.map((colNum, row) => {
|
|
932
|
+
const randBool = generateRandomBoolean(colNum < 2 ? 0.6 : 0.5);
|
|
933
|
+
const randBoolArr = [randBool, !randBool];
|
|
934
|
+
return /* @__PURE__ */ React19.createElement("div", {
|
|
935
|
+
className: "flex items-center flex-wrap",
|
|
936
|
+
key: row
|
|
937
|
+
}, new Array(colNum).fill(null).map((_, col) => {
|
|
938
|
+
indexRef.current += 1;
|
|
939
|
+
const generatedCls = cellWrapperClsGenerator(colNum, generateRandomBoolean());
|
|
940
|
+
const cls4 = classnames2("flex items-center justify-center flex-shrink-0 flex-grow-0", "basis-full", generatedCls);
|
|
941
|
+
return /* @__PURE__ */ React19.createElement("div", {
|
|
942
|
+
className: cls4,
|
|
943
|
+
key: col
|
|
944
|
+
}, cellRenderer(indexRef.current - 1, randBoolArr[col], col));
|
|
945
|
+
}));
|
|
946
|
+
}));
|
|
947
|
+
};
|
|
948
|
+
|
|
949
|
+
// src/img/Gallery.tsx
|
|
950
|
+
var defaultImageRenderer = (img, index, col) => {
|
|
951
|
+
return /* @__PURE__ */ React20.createElement("div", {
|
|
952
|
+
className: classnames3("mb-256", {
|
|
953
|
+
"md:mr-64": col === 0,
|
|
954
|
+
"md:ml-64": col !== 0
|
|
955
|
+
})
|
|
956
|
+
}, img);
|
|
957
|
+
};
|
|
958
|
+
var Gallery = (props) => {
|
|
959
|
+
const _a = props, {
|
|
960
|
+
images,
|
|
961
|
+
children,
|
|
962
|
+
imageRenderer = defaultImageRenderer
|
|
963
|
+
} = _a, rest = __objRest(_a, [
|
|
964
|
+
"images",
|
|
965
|
+
"children",
|
|
966
|
+
"imageRenderer"
|
|
967
|
+
]);
|
|
968
|
+
const renderImage = (index, isLargeImage, col) => {
|
|
969
|
+
const image = images[index];
|
|
970
|
+
if (!image) {
|
|
971
|
+
return null;
|
|
972
|
+
}
|
|
973
|
+
return imageRenderer(/* @__PURE__ */ React20.createElement(Img, __spreadProps(__spreadValues({}, image), {
|
|
974
|
+
size: isLargeImage ? "large" : "normal"
|
|
975
|
+
})), index, col, isLargeImage);
|
|
976
|
+
};
|
|
977
|
+
return /* @__PURE__ */ React20.createElement("div", {
|
|
978
|
+
className: "w-full flex justify-center"
|
|
979
|
+
}, /* @__PURE__ */ React20.createElement(RandomRowsLayout, __spreadValues({
|
|
980
|
+
classNames: "mx-32 mt-128 max-w-screen-xl",
|
|
981
|
+
cellsCount: images.length,
|
|
982
|
+
cellRenderer: renderImage
|
|
983
|
+
}, rest)), children);
|
|
984
|
+
};
|
|
780
985
|
export {
|
|
781
986
|
Article,
|
|
782
987
|
ArticleSkeleton,
|
|
@@ -787,6 +992,8 @@ export {
|
|
|
787
992
|
DropImage,
|
|
788
993
|
Error2 as Error,
|
|
789
994
|
ErrorBoundary,
|
|
995
|
+
Gallery,
|
|
996
|
+
Img,
|
|
790
997
|
Link,
|
|
791
998
|
LinkColor,
|
|
792
999
|
LinkList,
|