@bbki.ng/components 1.5.4 → 1.5.7
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 +21 -3
- package/dist/index.js +126 -10
- package/dist/index.mjs +129 -11
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { EventHandler, ReactElement, CSSProperties, FunctionComponent } from 'react';
|
|
1
|
+
import React, { EventHandler, ReactElement, CSSProperties, Ref, ReactNode, FunctionComponent } from 'react';
|
|
2
2
|
import { LinkProps as LinkProps$1 } from 'react-router-dom';
|
|
3
3
|
|
|
4
4
|
declare type ArticleProps = {
|
|
@@ -123,8 +123,18 @@ declare type SkeletonProps = {
|
|
|
123
123
|
};
|
|
124
124
|
declare const Skeleton: (props: SkeletonProps) => JSX.Element;
|
|
125
125
|
|
|
126
|
+
interface ImagePreviewerProps {
|
|
127
|
+
className?: string;
|
|
128
|
+
visible: boolean;
|
|
129
|
+
imageRef: Ref<HTMLImageElement>;
|
|
130
|
+
imageSrc: string;
|
|
131
|
+
imageSize: {
|
|
132
|
+
width: number;
|
|
133
|
+
height: number;
|
|
134
|
+
};
|
|
135
|
+
}
|
|
126
136
|
interface ImageDropProps<T> {
|
|
127
|
-
uploader: (file: File, img
|
|
137
|
+
uploader: (file: File, img?: HTMLImageElement) => Promise<T>;
|
|
128
138
|
onDrop?: (events: Event, file: File) => void;
|
|
129
139
|
onUploadFinish?: (result: T) => void;
|
|
130
140
|
waitTimeAfterFinish?: number;
|
|
@@ -132,7 +142,15 @@ interface ImageDropProps<T> {
|
|
|
132
142
|
dragOverBgColor?: string;
|
|
133
143
|
dropAreaStyle?: CSSStyleDeclaration;
|
|
134
144
|
placeholder?: any;
|
|
145
|
+
className?: string;
|
|
146
|
+
ghost?: boolean;
|
|
147
|
+
children?: (props: ImagePreviewerProps) => ReactNode;
|
|
135
148
|
}
|
|
136
149
|
declare const DropImage: FunctionComponent<ImageDropProps<any>>;
|
|
137
150
|
|
|
138
|
-
|
|
151
|
+
declare type BLinkDotProps = {
|
|
152
|
+
className?: string;
|
|
153
|
+
};
|
|
154
|
+
declare const BlinkDot: (props: BLinkDotProps) => JSX.Element;
|
|
155
|
+
|
|
156
|
+
export { Article, ArticleProps, BLinkDotProps, BlinkDot, Breadcrumb, BreadcrumbProps, Button, ButtonProps, ButtonType, DropImage, ImageDropProps, ImagePreviewerProps, Link, LinkColor, LinkProps, Logo, LogoProps, Nav, NavProps, Page, Panel, PanelProps, PathObj, PopConfirm, PopConfirmProps, Skeleton, SkeletonColor, SkeletonProps, Table, TableProps, Tag, TagProps, Tags };
|
package/dist/index.js
CHANGED
|
@@ -59,6 +59,7 @@ var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
|
59
59
|
var src_exports = {};
|
|
60
60
|
__export(src_exports, {
|
|
61
61
|
Article: () => Article,
|
|
62
|
+
BlinkDot: () => BlinkDot,
|
|
62
63
|
Breadcrumb: () => Breadcrumb,
|
|
63
64
|
Button: () => Button,
|
|
64
65
|
ButtonType: () => ButtonType,
|
|
@@ -392,7 +393,11 @@ var useDropImage = (params) => {
|
|
|
392
393
|
};
|
|
393
394
|
};
|
|
394
395
|
const setPreviewImageSrcByFile = (file) => {
|
|
395
|
-
|
|
396
|
+
try {
|
|
397
|
+
setImageSrc(URL.createObjectURL(file));
|
|
398
|
+
} catch (e) {
|
|
399
|
+
setImageSrc("");
|
|
400
|
+
}
|
|
396
401
|
};
|
|
397
402
|
const handleDragOver = (0, import_react12.useCallback)((ev) => {
|
|
398
403
|
ev.preventDefault();
|
|
@@ -451,6 +456,96 @@ var useDropImage = (params) => {
|
|
|
451
456
|
};
|
|
452
457
|
|
|
453
458
|
// src/drop-image/DropImage.tsx
|
|
459
|
+
var ImagePreviewer = (props) => {
|
|
460
|
+
const {
|
|
461
|
+
visible: showImagePreviewer,
|
|
462
|
+
imageRef,
|
|
463
|
+
imageSize,
|
|
464
|
+
imageSrc,
|
|
465
|
+
className
|
|
466
|
+
} = props;
|
|
467
|
+
return /* @__PURE__ */ import_react13.default.createElement("img", {
|
|
468
|
+
className: (0, import_classnames6.default)(className, "max-w-[100%]", "h-[auto]", "duration-300", "transition-opacity", "opacity-100", {
|
|
469
|
+
"opacity-0": !showImagePreviewer,
|
|
470
|
+
"!m-0": !showImagePreviewer,
|
|
471
|
+
"!p-0": !showImagePreviewer
|
|
472
|
+
}),
|
|
473
|
+
ref: imageRef,
|
|
474
|
+
src: imageSrc,
|
|
475
|
+
width: imageSize.width,
|
|
476
|
+
height: imageSize.height
|
|
477
|
+
});
|
|
478
|
+
};
|
|
479
|
+
var GhostDropImage = (props) => {
|
|
480
|
+
const {
|
|
481
|
+
onDrop = noop,
|
|
482
|
+
onUploadFinish = noop,
|
|
483
|
+
uploader,
|
|
484
|
+
waitTimeAfterFinish = 2e3,
|
|
485
|
+
className = "",
|
|
486
|
+
children,
|
|
487
|
+
placeholder
|
|
488
|
+
} = props;
|
|
489
|
+
const [coverVisible, setCoverVisible] = (0, import_react14.useState)(false);
|
|
490
|
+
const [imageVisible, setImageVisible] = (0, import_react14.useState)(false);
|
|
491
|
+
const handleDocDragEnter = (0, import_react13.useCallback)(() => {
|
|
492
|
+
setCoverVisible(true);
|
|
493
|
+
}, []);
|
|
494
|
+
const {
|
|
495
|
+
handleDragLeave,
|
|
496
|
+
handleDragOver,
|
|
497
|
+
handleDrop,
|
|
498
|
+
imageRef,
|
|
499
|
+
imageSize,
|
|
500
|
+
imageSrc,
|
|
501
|
+
reset
|
|
502
|
+
} = useDropImage({
|
|
503
|
+
onImageLoad: () => {
|
|
504
|
+
setImageVisible(true);
|
|
505
|
+
},
|
|
506
|
+
onDrop: async (e, file) => {
|
|
507
|
+
onDrop(e, file);
|
|
508
|
+
setCoverVisible(false);
|
|
509
|
+
const result = await uploader(file);
|
|
510
|
+
await wait(waitTimeAfterFinish);
|
|
511
|
+
onUploadFinish(result);
|
|
512
|
+
setImageVisible(false);
|
|
513
|
+
reset();
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
(0, import_react13.useEffect)(() => {
|
|
517
|
+
document.addEventListener("dragenter", handleDocDragEnter);
|
|
518
|
+
return () => {
|
|
519
|
+
document.removeEventListener("dragenter", handleDocDragEnter);
|
|
520
|
+
};
|
|
521
|
+
}, []);
|
|
522
|
+
const coverCls = (0, import_classnames6.default)("fixed", "top-0", "left-0", "h-full", "w-full", {
|
|
523
|
+
"lqip-blur": coverVisible,
|
|
524
|
+
"z-[999]": coverVisible,
|
|
525
|
+
block: coverVisible,
|
|
526
|
+
hidden: !coverVisible
|
|
527
|
+
});
|
|
528
|
+
return /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, /* @__PURE__ */ import_react13.default.createElement("div", {
|
|
529
|
+
className: coverCls,
|
|
530
|
+
onDragLeave: () => {
|
|
531
|
+
handleDragLeave();
|
|
532
|
+
setCoverVisible(false);
|
|
533
|
+
},
|
|
534
|
+
onDragOver: handleDragOver,
|
|
535
|
+
onDrop: handleDrop
|
|
536
|
+
}), !imageVisible && placeholder, children ? children({
|
|
537
|
+
visible: imageVisible,
|
|
538
|
+
imageRef,
|
|
539
|
+
imageSize,
|
|
540
|
+
imageSrc
|
|
541
|
+
}) : /* @__PURE__ */ import_react13.default.createElement(ImagePreviewer, {
|
|
542
|
+
className,
|
|
543
|
+
visible: imageVisible,
|
|
544
|
+
imageRef,
|
|
545
|
+
imageSrc,
|
|
546
|
+
imageSize
|
|
547
|
+
}));
|
|
548
|
+
};
|
|
454
549
|
var DropImage = (props) => {
|
|
455
550
|
const {
|
|
456
551
|
uploader,
|
|
@@ -459,12 +554,18 @@ var DropImage = (props) => {
|
|
|
459
554
|
dragOverBgColor = "#EFF6FF",
|
|
460
555
|
waitTimeAfterFinish = 2e3,
|
|
461
556
|
placeholder = "",
|
|
557
|
+
className = "",
|
|
462
558
|
onUploadFinish = noop,
|
|
559
|
+
ghost,
|
|
560
|
+
children,
|
|
463
561
|
dropAreaStyle = {
|
|
464
562
|
width: 300,
|
|
465
563
|
height: 300
|
|
466
564
|
}
|
|
467
565
|
} = props;
|
|
566
|
+
if (ghost) {
|
|
567
|
+
return /* @__PURE__ */ import_react13.default.createElement(GhostDropImage, __spreadValues({}, props));
|
|
568
|
+
}
|
|
468
569
|
const [showImagePreviewer, setShowImagePreviewer] = (0, import_react14.useState)(false);
|
|
469
570
|
const {
|
|
470
571
|
handleDragLeave,
|
|
@@ -495,7 +596,7 @@ var DropImage = (props) => {
|
|
|
495
596
|
});
|
|
496
597
|
};
|
|
497
598
|
return /* @__PURE__ */ import_react13.default.createElement("div", {
|
|
498
|
-
className: (0, import_classnames6.default)("transition-all items-center justify-center flex duration-200 ease-in-out", {
|
|
599
|
+
className: (0, import_classnames6.default)(className, "transition-all items-center justify-center flex duration-200 ease-in-out", {
|
|
499
600
|
"shadow-input": !imageSrc,
|
|
500
601
|
"shadow-empty": imageSrc
|
|
501
602
|
}),
|
|
@@ -503,20 +604,35 @@ var DropImage = (props) => {
|
|
|
503
604
|
onDragOver: handleDragOver,
|
|
504
605
|
onDrop: handleDrop,
|
|
505
606
|
style: getDropAreaStyle()
|
|
506
|
-
},
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
607
|
+
}, children ? children({
|
|
608
|
+
visible: showImagePreviewer,
|
|
609
|
+
imageRef,
|
|
610
|
+
imageSize,
|
|
611
|
+
imageSrc
|
|
612
|
+
}) : /* @__PURE__ */ import_react13.default.createElement(ImagePreviewer, {
|
|
613
|
+
visible: showImagePreviewer,
|
|
614
|
+
imageRef,
|
|
615
|
+
imageSrc,
|
|
616
|
+
imageSize
|
|
514
617
|
}), !imageSrc && placeholder);
|
|
515
618
|
};
|
|
619
|
+
|
|
620
|
+
// src/blink-dot/BlinkDot.tsx
|
|
621
|
+
var import_classnames7 = __toESM(require("classnames"));
|
|
622
|
+
var import_react15 = __toESM(require("react"));
|
|
623
|
+
var BlinkDot = (props) => {
|
|
624
|
+
const { className } = props;
|
|
625
|
+
return /* @__PURE__ */ import_react15.default.createElement("span", {
|
|
626
|
+
className: (0, import_classnames7.default)("inline-flex h-1 w-1 justify-center items-center relative", className)
|
|
627
|
+
}, /* @__PURE__ */ import_react15.default.createElement("span", {
|
|
628
|
+
className: "animate-ping-fast absolute inline-flex h-full w-full rounded-full bg-red-600"
|
|
629
|
+
}));
|
|
630
|
+
};
|
|
516
631
|
module.exports = __toCommonJS(src_exports);
|
|
517
632
|
// Annotate the CommonJS export names for ESM import in node:
|
|
518
633
|
0 && (module.exports = {
|
|
519
634
|
Article,
|
|
635
|
+
BlinkDot,
|
|
520
636
|
Breadcrumb,
|
|
521
637
|
Button,
|
|
522
638
|
ButtonType,
|
package/dist/index.mjs
CHANGED
|
@@ -305,7 +305,10 @@ var Skeleton = (props) => {
|
|
|
305
305
|
|
|
306
306
|
// src/drop-image/DropImage.tsx
|
|
307
307
|
import cls from "classnames";
|
|
308
|
-
import React13
|
|
308
|
+
import React13, {
|
|
309
|
+
useEffect as useEffect2,
|
|
310
|
+
useCallback as useCallback2
|
|
311
|
+
} from "react";
|
|
309
312
|
import { useState as useState3 } from "react";
|
|
310
313
|
|
|
311
314
|
// src/drop-image/utils.ts
|
|
@@ -345,7 +348,11 @@ var useDropImage = (params) => {
|
|
|
345
348
|
};
|
|
346
349
|
};
|
|
347
350
|
const setPreviewImageSrcByFile = (file) => {
|
|
348
|
-
|
|
351
|
+
try {
|
|
352
|
+
setImageSrc(URL.createObjectURL(file));
|
|
353
|
+
} catch (e) {
|
|
354
|
+
setImageSrc("");
|
|
355
|
+
}
|
|
349
356
|
};
|
|
350
357
|
const handleDragOver = useCallback((ev) => {
|
|
351
358
|
ev.preventDefault();
|
|
@@ -404,6 +411,96 @@ var useDropImage = (params) => {
|
|
|
404
411
|
};
|
|
405
412
|
|
|
406
413
|
// src/drop-image/DropImage.tsx
|
|
414
|
+
var ImagePreviewer = (props) => {
|
|
415
|
+
const {
|
|
416
|
+
visible: showImagePreviewer,
|
|
417
|
+
imageRef,
|
|
418
|
+
imageSize,
|
|
419
|
+
imageSrc,
|
|
420
|
+
className
|
|
421
|
+
} = props;
|
|
422
|
+
return /* @__PURE__ */ React13.createElement("img", {
|
|
423
|
+
className: cls(className, "max-w-[100%]", "h-[auto]", "duration-300", "transition-opacity", "opacity-100", {
|
|
424
|
+
"opacity-0": !showImagePreviewer,
|
|
425
|
+
"!m-0": !showImagePreviewer,
|
|
426
|
+
"!p-0": !showImagePreviewer
|
|
427
|
+
}),
|
|
428
|
+
ref: imageRef,
|
|
429
|
+
src: imageSrc,
|
|
430
|
+
width: imageSize.width,
|
|
431
|
+
height: imageSize.height
|
|
432
|
+
});
|
|
433
|
+
};
|
|
434
|
+
var GhostDropImage = (props) => {
|
|
435
|
+
const {
|
|
436
|
+
onDrop = noop,
|
|
437
|
+
onUploadFinish = noop,
|
|
438
|
+
uploader,
|
|
439
|
+
waitTimeAfterFinish = 2e3,
|
|
440
|
+
className = "",
|
|
441
|
+
children,
|
|
442
|
+
placeholder
|
|
443
|
+
} = props;
|
|
444
|
+
const [coverVisible, setCoverVisible] = useState3(false);
|
|
445
|
+
const [imageVisible, setImageVisible] = useState3(false);
|
|
446
|
+
const handleDocDragEnter = useCallback2(() => {
|
|
447
|
+
setCoverVisible(true);
|
|
448
|
+
}, []);
|
|
449
|
+
const {
|
|
450
|
+
handleDragLeave,
|
|
451
|
+
handleDragOver,
|
|
452
|
+
handleDrop,
|
|
453
|
+
imageRef,
|
|
454
|
+
imageSize,
|
|
455
|
+
imageSrc,
|
|
456
|
+
reset
|
|
457
|
+
} = useDropImage({
|
|
458
|
+
onImageLoad: () => {
|
|
459
|
+
setImageVisible(true);
|
|
460
|
+
},
|
|
461
|
+
onDrop: async (e, file) => {
|
|
462
|
+
onDrop(e, file);
|
|
463
|
+
setCoverVisible(false);
|
|
464
|
+
const result = await uploader(file);
|
|
465
|
+
await wait(waitTimeAfterFinish);
|
|
466
|
+
onUploadFinish(result);
|
|
467
|
+
setImageVisible(false);
|
|
468
|
+
reset();
|
|
469
|
+
}
|
|
470
|
+
});
|
|
471
|
+
useEffect2(() => {
|
|
472
|
+
document.addEventListener("dragenter", handleDocDragEnter);
|
|
473
|
+
return () => {
|
|
474
|
+
document.removeEventListener("dragenter", handleDocDragEnter);
|
|
475
|
+
};
|
|
476
|
+
}, []);
|
|
477
|
+
const coverCls = cls("fixed", "top-0", "left-0", "h-full", "w-full", {
|
|
478
|
+
"lqip-blur": coverVisible,
|
|
479
|
+
"z-[999]": coverVisible,
|
|
480
|
+
block: coverVisible,
|
|
481
|
+
hidden: !coverVisible
|
|
482
|
+
});
|
|
483
|
+
return /* @__PURE__ */ React13.createElement(React13.Fragment, null, /* @__PURE__ */ React13.createElement("div", {
|
|
484
|
+
className: coverCls,
|
|
485
|
+
onDragLeave: () => {
|
|
486
|
+
handleDragLeave();
|
|
487
|
+
setCoverVisible(false);
|
|
488
|
+
},
|
|
489
|
+
onDragOver: handleDragOver,
|
|
490
|
+
onDrop: handleDrop
|
|
491
|
+
}), !imageVisible && placeholder, children ? children({
|
|
492
|
+
visible: imageVisible,
|
|
493
|
+
imageRef,
|
|
494
|
+
imageSize,
|
|
495
|
+
imageSrc
|
|
496
|
+
}) : /* @__PURE__ */ React13.createElement(ImagePreviewer, {
|
|
497
|
+
className,
|
|
498
|
+
visible: imageVisible,
|
|
499
|
+
imageRef,
|
|
500
|
+
imageSrc,
|
|
501
|
+
imageSize
|
|
502
|
+
}));
|
|
503
|
+
};
|
|
407
504
|
var DropImage = (props) => {
|
|
408
505
|
const {
|
|
409
506
|
uploader,
|
|
@@ -412,12 +509,18 @@ var DropImage = (props) => {
|
|
|
412
509
|
dragOverBgColor = "#EFF6FF",
|
|
413
510
|
waitTimeAfterFinish = 2e3,
|
|
414
511
|
placeholder = "",
|
|
512
|
+
className = "",
|
|
415
513
|
onUploadFinish = noop,
|
|
514
|
+
ghost,
|
|
515
|
+
children,
|
|
416
516
|
dropAreaStyle = {
|
|
417
517
|
width: 300,
|
|
418
518
|
height: 300
|
|
419
519
|
}
|
|
420
520
|
} = props;
|
|
521
|
+
if (ghost) {
|
|
522
|
+
return /* @__PURE__ */ React13.createElement(GhostDropImage, __spreadValues({}, props));
|
|
523
|
+
}
|
|
421
524
|
const [showImagePreviewer, setShowImagePreviewer] = useState3(false);
|
|
422
525
|
const {
|
|
423
526
|
handleDragLeave,
|
|
@@ -448,7 +551,7 @@ var DropImage = (props) => {
|
|
|
448
551
|
});
|
|
449
552
|
};
|
|
450
553
|
return /* @__PURE__ */ React13.createElement("div", {
|
|
451
|
-
className: cls("transition-all items-center justify-center flex duration-200 ease-in-out", {
|
|
554
|
+
className: cls(className, "transition-all items-center justify-center flex duration-200 ease-in-out", {
|
|
452
555
|
"shadow-input": !imageSrc,
|
|
453
556
|
"shadow-empty": imageSrc
|
|
454
557
|
}),
|
|
@@ -456,18 +559,33 @@ var DropImage = (props) => {
|
|
|
456
559
|
onDragOver: handleDragOver,
|
|
457
560
|
onDrop: handleDrop,
|
|
458
561
|
style: getDropAreaStyle()
|
|
459
|
-
},
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
562
|
+
}, children ? children({
|
|
563
|
+
visible: showImagePreviewer,
|
|
564
|
+
imageRef,
|
|
565
|
+
imageSize,
|
|
566
|
+
imageSrc
|
|
567
|
+
}) : /* @__PURE__ */ React13.createElement(ImagePreviewer, {
|
|
568
|
+
visible: showImagePreviewer,
|
|
569
|
+
imageRef,
|
|
570
|
+
imageSrc,
|
|
571
|
+
imageSize
|
|
467
572
|
}), !imageSrc && placeholder);
|
|
468
573
|
};
|
|
574
|
+
|
|
575
|
+
// src/blink-dot/BlinkDot.tsx
|
|
576
|
+
import classNames6 from "classnames";
|
|
577
|
+
import React14 from "react";
|
|
578
|
+
var BlinkDot = (props) => {
|
|
579
|
+
const { className } = props;
|
|
580
|
+
return /* @__PURE__ */ React14.createElement("span", {
|
|
581
|
+
className: classNames6("inline-flex h-1 w-1 justify-center items-center relative", className)
|
|
582
|
+
}, /* @__PURE__ */ React14.createElement("span", {
|
|
583
|
+
className: "animate-ping-fast absolute inline-flex h-full w-full rounded-full bg-red-600"
|
|
584
|
+
}));
|
|
585
|
+
};
|
|
469
586
|
export {
|
|
470
587
|
Article,
|
|
588
|
+
BlinkDot,
|
|
471
589
|
Breadcrumb,
|
|
472
590
|
Button,
|
|
473
591
|
ButtonType,
|