@appcorp/stellar-solutions-modules 0.1.44 → 0.1.45
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/global-modules/payment-mode/form.js +1 -77
- package/package.json +1 -1
- package/components/ui/carousel.d.ts +0 -19
- package/components/ui/carousel.js +0 -168
- package/components/ui/dropzone-enhanced/index.d.ts +0 -22
- package/components/ui/dropzone-enhanced/index.js +0 -226
- package/components/ui/shadcn-io/dropzone/index.d.ts +0 -19
- package/components/ui/shadcn-io/dropzone/index.js +0 -131
|
@@ -12,89 +12,21 @@
|
|
|
12
12
|
* - Accessibility-compliant form structure
|
|
13
13
|
* - Real-time validation feedback
|
|
14
14
|
*/
|
|
15
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
16
|
-
if (k2 === undefined) k2 = k;
|
|
17
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
18
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
19
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
20
|
-
}
|
|
21
|
-
Object.defineProperty(o, k2, desc);
|
|
22
|
-
}) : (function(o, m, k, k2) {
|
|
23
|
-
if (k2 === undefined) k2 = k;
|
|
24
|
-
o[k2] = m[k];
|
|
25
|
-
}));
|
|
26
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
27
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
28
|
-
}) : function(o, v) {
|
|
29
|
-
o["default"] = v;
|
|
30
|
-
});
|
|
31
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
32
|
-
var ownKeys = function(o) {
|
|
33
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
34
|
-
var ar = [];
|
|
35
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
36
|
-
return ar;
|
|
37
|
-
};
|
|
38
|
-
return ownKeys(o);
|
|
39
|
-
};
|
|
40
|
-
return function (mod) {
|
|
41
|
-
if (mod && mod.__esModule) return mod;
|
|
42
|
-
var result = {};
|
|
43
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
44
|
-
__setModuleDefault(result, mod);
|
|
45
|
-
return result;
|
|
46
|
-
};
|
|
47
|
-
})();
|
|
48
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
49
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
50
|
-
if (ar || !(i in from)) {
|
|
51
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
52
|
-
ar[i] = from[i];
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
56
|
-
};
|
|
57
15
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
58
16
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
59
17
|
};
|
|
60
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
61
19
|
exports.PaymentModeForm = void 0;
|
|
62
|
-
var react_1 =
|
|
20
|
+
var react_1 = __importDefault(require("react"));
|
|
63
21
|
var next_intl_1 = require("next-intl");
|
|
64
22
|
var input_1 = require("../../components/ui/input");
|
|
65
23
|
var switch_1 = require("../../components/ui/switch");
|
|
66
24
|
var context_1 = require("./context");
|
|
67
|
-
var dropzone_enhanced_1 = __importDefault(require("../../components/ui/dropzone-enhanced"));
|
|
68
|
-
var images = [
|
|
69
|
-
"https://images.unsplash.com/photo-1624555130581-1d9cca783bc0?q=80&w=1171&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
|
|
70
|
-
"https://cdn.pixabay.com/photo/2016/11/21/06/53/beautiful-natural-image-1844362_640.jpg",
|
|
71
|
-
"https://thumbs.dreamstime.com/b/beautiful-rain-forest-ang-ka-nature-trail-doi-inthanon-national-park-thailand-36703721.jpg",
|
|
72
|
-
"https://images.ctfassets.net/hrltx12pl8hq/28ECAQiPJZ78hxatLTa7Ts/2f695d869736ae3b0de3e56ceaca3958/free-nature-images.jpg?fit=fill&w=1200&h=630",
|
|
73
|
-
"https://cdn.pixabay.com/photo/2024/05/26/10/15/bird-8788491_1280.jpg",
|
|
74
|
-
"https://letsenhance.io/static/73136da51c245e80edc6ccfe44888a99/396e9/MainBefore.jpg",
|
|
75
|
-
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcS92eisuWOx3tEjeW14mT9ACVgXDwIRBGtnww&s",
|
|
76
|
-
"https://img.freepik.com/free-photo/woman-beach-with-her-baby-enjoying-sunset_52683-144131.jpg?size=626&ext=jpg",
|
|
77
|
-
];
|
|
78
25
|
var PaymentModeForm = function (_a) {
|
|
79
26
|
var isRTL = _a.isRTL, translationMap = _a.translationMap;
|
|
80
27
|
var t = (0, next_intl_1.useTranslations)("paymentModePage");
|
|
81
28
|
var ui = (0, next_intl_1.useTranslations)("ui");
|
|
82
29
|
var _b = (0, context_1.usePaymentModeStateContext)(), enabled = _b.enabled, errors = _b.errors, handleInputChange = _b.handleInputChange, isDefault = _b.isDefault, label = _b.label;
|
|
83
|
-
var _c = (0, react_1.useState)(__spreadArray([], images, true)), previews = _c[0], setPreviews = _c[1];
|
|
84
|
-
var filesRef = (0, react_1.useRef)([]);
|
|
85
|
-
(0, react_1.useEffect)(function () {
|
|
86
|
-
return function () {
|
|
87
|
-
previews.forEach(function (p) {
|
|
88
|
-
try {
|
|
89
|
-
URL.revokeObjectURL(p);
|
|
90
|
-
}
|
|
91
|
-
catch (_a) {
|
|
92
|
-
// ignore
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
};
|
|
96
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
97
|
-
}, []);
|
|
98
30
|
// Helper function to translate validation error keys
|
|
99
31
|
var getTranslatedError = function (key) {
|
|
100
32
|
if (!errors[key])
|
|
@@ -110,14 +42,6 @@ var PaymentModeForm = function (_a) {
|
|
|
110
42
|
react_1.default.createElement("div", { className: "space-y-2" },
|
|
111
43
|
react_1.default.createElement(input_1.Input, { id: "label", type: "text", label: (translationMap === null || translationMap === void 0 ? void 0 : translationMap.formLabelLabel) || "Payment Mode Name", value: label || "", onChange: function (e) { return handleInputChange("label", e.target.value); }, placeholder: "Enter payment mode name", info: "Enter a descriptive name for this payment method", error: getTranslatedError("label"), required: true })),
|
|
112
44
|
react_1.default.createElement("div", { className: "space-y-4" },
|
|
113
|
-
react_1.default.createElement("div", { className: "space-y-2" },
|
|
114
|
-
react_1.default.createElement(dropzone_enhanced_1.default, { id: "", label: (translationMap === null || translationMap === void 0 ? void 0 : translationMap.formLabelIcon) || "Upload Images", accept: { "image/*": [] }, maxFiles: 1, initial: previews, onChange: function (files) {
|
|
115
|
-
var previews = files.map(function (f) { return URL.createObjectURL(f); });
|
|
116
|
-
setPreviews(previews);
|
|
117
|
-
filesRef.current = files;
|
|
118
|
-
}, onRemoveUrl: function (url) {
|
|
119
|
-
setPreviews(function (p) { return p.filter(function (x) { return x !== url; }); });
|
|
120
|
-
}, info: (translationMap === null || translationMap === void 0 ? void 0 : translationMap.formInfoIcon) || t("formInfoIcon") })),
|
|
121
45
|
react_1.default.createElement(switch_1.Switch, { id: "enabled", label: (translationMap === null || translationMap === void 0 ? void 0 : translationMap.enabled) || "Enabled", checked: enabled || false, onCheckedChange: function (checked) { return handleInputChange("enabled", checked); }, info: enabled ? ui("switch.infoEnabled") : ui("switch.infoDisabled"), error: getTranslatedError("enabled") }),
|
|
122
46
|
react_1.default.createElement(switch_1.Switch, { id: "isDefault", label: (translationMap === null || translationMap === void 0 ? void 0 : translationMap.setAsDefault) || "Set as Default", checked: isDefault || false, onCheckedChange: function (checked) {
|
|
123
47
|
return handleInputChange("isDefault", checked);
|
package/package.json
CHANGED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import useEmblaCarousel, { type UseEmblaCarouselType } from "embla-carousel-react";
|
|
3
|
-
import { Button } from "@/components/ui/button";
|
|
4
|
-
type CarouselApi = UseEmblaCarouselType[1];
|
|
5
|
-
type UseCarouselParameters = Parameters<typeof useEmblaCarousel>;
|
|
6
|
-
type CarouselOptions = UseCarouselParameters[0];
|
|
7
|
-
type CarouselPlugin = UseCarouselParameters[1];
|
|
8
|
-
type CarouselProps = {
|
|
9
|
-
opts?: CarouselOptions;
|
|
10
|
-
plugins?: CarouselPlugin;
|
|
11
|
-
orientation?: "horizontal" | "vertical";
|
|
12
|
-
setApi?: (api: CarouselApi) => void;
|
|
13
|
-
};
|
|
14
|
-
declare function Carousel({ orientation, opts, setApi, plugins, className, children, ...props }: React.ComponentProps<"div"> & CarouselProps): React.JSX.Element;
|
|
15
|
-
declare function CarouselContent({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
16
|
-
declare function CarouselItem({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
17
|
-
declare function CarouselPrevious({ className, variant, size, ...props }: React.ComponentProps<typeof Button>): React.JSX.Element;
|
|
18
|
-
declare function CarouselNext({ className, variant, size, ...props }: React.ComponentProps<typeof Button>): React.JSX.Element;
|
|
19
|
-
export { type CarouselApi, Carousel, CarouselContent, CarouselItem, CarouselPrevious, CarouselNext, };
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
var __assign = (this && this.__assign) || function () {
|
|
4
|
-
__assign = Object.assign || function(t) {
|
|
5
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
-
s = arguments[i];
|
|
7
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
8
|
-
t[p] = s[p];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
return __assign.apply(this, arguments);
|
|
13
|
-
};
|
|
14
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
15
|
-
if (k2 === undefined) k2 = k;
|
|
16
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
17
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
18
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
19
|
-
}
|
|
20
|
-
Object.defineProperty(o, k2, desc);
|
|
21
|
-
}) : (function(o, m, k, k2) {
|
|
22
|
-
if (k2 === undefined) k2 = k;
|
|
23
|
-
o[k2] = m[k];
|
|
24
|
-
}));
|
|
25
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
26
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
27
|
-
}) : function(o, v) {
|
|
28
|
-
o["default"] = v;
|
|
29
|
-
});
|
|
30
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
31
|
-
var ownKeys = function(o) {
|
|
32
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
33
|
-
var ar = [];
|
|
34
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
35
|
-
return ar;
|
|
36
|
-
};
|
|
37
|
-
return ownKeys(o);
|
|
38
|
-
};
|
|
39
|
-
return function (mod) {
|
|
40
|
-
if (mod && mod.__esModule) return mod;
|
|
41
|
-
var result = {};
|
|
42
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
43
|
-
__setModuleDefault(result, mod);
|
|
44
|
-
return result;
|
|
45
|
-
};
|
|
46
|
-
})();
|
|
47
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
48
|
-
var t = {};
|
|
49
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
50
|
-
t[p] = s[p];
|
|
51
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
52
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
53
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
54
|
-
t[p[i]] = s[p[i]];
|
|
55
|
-
}
|
|
56
|
-
return t;
|
|
57
|
-
};
|
|
58
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
59
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
60
|
-
};
|
|
61
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
|
-
exports.Carousel = Carousel;
|
|
63
|
-
exports.CarouselContent = CarouselContent;
|
|
64
|
-
exports.CarouselItem = CarouselItem;
|
|
65
|
-
exports.CarouselPrevious = CarouselPrevious;
|
|
66
|
-
exports.CarouselNext = CarouselNext;
|
|
67
|
-
var React = __importStar(require("react"));
|
|
68
|
-
var embla_carousel_react_1 = __importDefault(require("embla-carousel-react"));
|
|
69
|
-
var lucide_react_1 = require("lucide-react");
|
|
70
|
-
var utils_1 = require("@/lib/utils");
|
|
71
|
-
var button_1 = require("@/components/ui/button");
|
|
72
|
-
var CarouselContext = React.createContext(null);
|
|
73
|
-
function useCarousel() {
|
|
74
|
-
var context = React.useContext(CarouselContext);
|
|
75
|
-
if (!context) {
|
|
76
|
-
throw new Error("useCarousel must be used within a <Carousel />");
|
|
77
|
-
}
|
|
78
|
-
return context;
|
|
79
|
-
}
|
|
80
|
-
function Carousel(_a) {
|
|
81
|
-
var _b = _a.orientation, orientation = _b === void 0 ? "horizontal" : _b, opts = _a.opts, setApi = _a.setApi, plugins = _a.plugins, className = _a.className, children = _a.children, props = __rest(_a, ["orientation", "opts", "setApi", "plugins", "className", "children"]);
|
|
82
|
-
var _c = (0, embla_carousel_react_1.default)(__assign(__assign({}, opts), { axis: orientation === "horizontal" ? "x" : "y" }), plugins), carouselRef = _c[0], api = _c[1];
|
|
83
|
-
var _d = React.useState(false), canScrollPrev = _d[0], setCanScrollPrev = _d[1];
|
|
84
|
-
var _e = React.useState(false), canScrollNext = _e[0], setCanScrollNext = _e[1];
|
|
85
|
-
var onSelect = React.useCallback(function (api) {
|
|
86
|
-
if (!api)
|
|
87
|
-
return;
|
|
88
|
-
setCanScrollPrev(api.canScrollPrev());
|
|
89
|
-
setCanScrollNext(api.canScrollNext());
|
|
90
|
-
}, []);
|
|
91
|
-
var scrollPrev = React.useCallback(function () {
|
|
92
|
-
api === null || api === void 0 ? void 0 : api.scrollPrev();
|
|
93
|
-
}, [api]);
|
|
94
|
-
var scrollNext = React.useCallback(function () {
|
|
95
|
-
api === null || api === void 0 ? void 0 : api.scrollNext();
|
|
96
|
-
}, [api]);
|
|
97
|
-
var handleKeyDown = React.useCallback(function (event) {
|
|
98
|
-
if (event.key === "ArrowLeft") {
|
|
99
|
-
event.preventDefault();
|
|
100
|
-
scrollPrev();
|
|
101
|
-
}
|
|
102
|
-
else if (event.key === "ArrowRight") {
|
|
103
|
-
event.preventDefault();
|
|
104
|
-
scrollNext();
|
|
105
|
-
}
|
|
106
|
-
}, [scrollPrev, scrollNext]);
|
|
107
|
-
React.useEffect(function () {
|
|
108
|
-
if (!api || !setApi)
|
|
109
|
-
return;
|
|
110
|
-
setApi(api);
|
|
111
|
-
}, [api, setApi]);
|
|
112
|
-
React.useEffect(function () {
|
|
113
|
-
if (!api)
|
|
114
|
-
return;
|
|
115
|
-
onSelect(api);
|
|
116
|
-
api.on("reInit", onSelect);
|
|
117
|
-
api.on("select", onSelect);
|
|
118
|
-
return function () {
|
|
119
|
-
api === null || api === void 0 ? void 0 : api.off("select", onSelect);
|
|
120
|
-
};
|
|
121
|
-
}, [api, onSelect]);
|
|
122
|
-
return (React.createElement(CarouselContext.Provider, { value: {
|
|
123
|
-
carouselRef: carouselRef,
|
|
124
|
-
api: api,
|
|
125
|
-
opts: opts,
|
|
126
|
-
orientation: orientation || ((opts === null || opts === void 0 ? void 0 : opts.axis) === "y" ? "vertical" : "horizontal"),
|
|
127
|
-
scrollPrev: scrollPrev,
|
|
128
|
-
scrollNext: scrollNext,
|
|
129
|
-
canScrollPrev: canScrollPrev,
|
|
130
|
-
canScrollNext: canScrollNext,
|
|
131
|
-
} },
|
|
132
|
-
React.createElement("div", __assign({ onKeyDownCapture: handleKeyDown, className: (0, utils_1.cn)("relative", className), role: "region", "aria-roledescription": "carousel", "data-slot": "carousel" }, props), children)));
|
|
133
|
-
}
|
|
134
|
-
function CarouselContent(_a) {
|
|
135
|
-
var className = _a.className, props = __rest(_a, ["className"]);
|
|
136
|
-
var _b = useCarousel(), carouselRef = _b.carouselRef, orientation = _b.orientation;
|
|
137
|
-
return (React.createElement("div", { ref: carouselRef, className: "overflow-hidden", "data-slot": "carousel-content" },
|
|
138
|
-
React.createElement("div", __assign({ className: (0, utils_1.cn)("flex", orientation === "horizontal" ? "-ml-4" : "-mt-4 flex-col", className) }, props))));
|
|
139
|
-
}
|
|
140
|
-
function CarouselItem(_a) {
|
|
141
|
-
var className = _a.className, props = __rest(_a, ["className"]);
|
|
142
|
-
var orientation = useCarousel().orientation;
|
|
143
|
-
return (React.createElement("div", __assign({ role: "group", "aria-roledescription": "slide", "data-slot": "carousel-item", className: (0, utils_1.cn)("min-w-0 shrink-0 grow-0 basis-full", orientation === "horizontal" ? "pl-4" : "pt-4", className) }, props)));
|
|
144
|
-
}
|
|
145
|
-
function CarouselPrevious(_a) {
|
|
146
|
-
var className = _a.className, _b = _a.variant, variant = _b === void 0 ? "outline" : _b, _c = _a.size, size = _c === void 0 ? "icon" : _c, props = __rest(_a, ["className", "variant", "size"]);
|
|
147
|
-
var _d = useCarousel(), orientation = _d.orientation, scrollPrev = _d.scrollPrev, canScrollPrev = _d.canScrollPrev;
|
|
148
|
-
return (React.createElement(button_1.Button, __assign({}, props, { "data-slot": "carousel-previous", variant: variant, size: size, className: (0, utils_1.cn)("absolute size-8 rounded-full", orientation === "horizontal"
|
|
149
|
-
? "top-1/2 -left-12 -translate-y-1/2"
|
|
150
|
-
: "-top-12 left-1/2 -translate-x-1/2 rotate-90", className), disabled: !canScrollPrev, onClick: function (e) {
|
|
151
|
-
e.stopPropagation();
|
|
152
|
-
scrollPrev();
|
|
153
|
-
} }),
|
|
154
|
-
React.createElement(lucide_react_1.ArrowLeft, null),
|
|
155
|
-
React.createElement("span", { className: "sr-only" }, "Previous slide")));
|
|
156
|
-
}
|
|
157
|
-
function CarouselNext(_a) {
|
|
158
|
-
var className = _a.className, _b = _a.variant, variant = _b === void 0 ? "outline" : _b, _c = _a.size, size = _c === void 0 ? "icon" : _c, props = __rest(_a, ["className", "variant", "size"]);
|
|
159
|
-
var _d = useCarousel(), orientation = _d.orientation, scrollNext = _d.scrollNext, canScrollNext = _d.canScrollNext;
|
|
160
|
-
return (React.createElement(button_1.Button, __assign({}, props, { "data-slot": "carousel-next", variant: variant, size: size, className: (0, utils_1.cn)("absolute size-8 rounded-full", orientation === "horizontal"
|
|
161
|
-
? "top-1/2 -right-12 -translate-y-1/2"
|
|
162
|
-
: "-bottom-12 left-1/2 -translate-x-1/2 rotate-90", className), disabled: !canScrollNext, onClick: function (e) {
|
|
163
|
-
e.stopPropagation();
|
|
164
|
-
scrollNext();
|
|
165
|
-
} }),
|
|
166
|
-
React.createElement(lucide_react_1.ArrowRight, null),
|
|
167
|
-
React.createElement("span", { className: "sr-only" }, "Next slide")));
|
|
168
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import type { DropzoneOptions } from "react-dropzone";
|
|
3
|
-
export type DropzoneEnhancedProps = {
|
|
4
|
-
id?: string;
|
|
5
|
-
className?: string;
|
|
6
|
-
label?: string;
|
|
7
|
-
info?: string;
|
|
8
|
-
error?: string;
|
|
9
|
-
accept?: DropzoneOptions["accept"] | string[];
|
|
10
|
-
maxFiles?: number;
|
|
11
|
-
maxSize?: number;
|
|
12
|
-
minSize?: number;
|
|
13
|
-
disabled?: boolean;
|
|
14
|
-
/** initial list of files or urls to show as previews */
|
|
15
|
-
initial?: Array<File | string>;
|
|
16
|
-
/** Called when selected File[] changes */
|
|
17
|
-
onChange?: (files: File[]) => void;
|
|
18
|
-
/** Called when a provided remote URL preview is removed (if provided) */
|
|
19
|
-
onRemoveUrl?: (url: string) => void;
|
|
20
|
-
};
|
|
21
|
-
export declare const DropzoneEnhanced: React.FC<DropzoneEnhancedProps>;
|
|
22
|
-
export default DropzoneEnhanced;
|
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
var __assign = (this && this.__assign) || function () {
|
|
4
|
-
__assign = Object.assign || function(t) {
|
|
5
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
-
s = arguments[i];
|
|
7
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
8
|
-
t[p] = s[p];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
return __assign.apply(this, arguments);
|
|
13
|
-
};
|
|
14
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
15
|
-
if (k2 === undefined) k2 = k;
|
|
16
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
17
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
18
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
19
|
-
}
|
|
20
|
-
Object.defineProperty(o, k2, desc);
|
|
21
|
-
}) : (function(o, m, k, k2) {
|
|
22
|
-
if (k2 === undefined) k2 = k;
|
|
23
|
-
o[k2] = m[k];
|
|
24
|
-
}));
|
|
25
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
26
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
27
|
-
}) : function(o, v) {
|
|
28
|
-
o["default"] = v;
|
|
29
|
-
});
|
|
30
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
31
|
-
var ownKeys = function(o) {
|
|
32
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
33
|
-
var ar = [];
|
|
34
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
35
|
-
return ar;
|
|
36
|
-
};
|
|
37
|
-
return ownKeys(o);
|
|
38
|
-
};
|
|
39
|
-
return function (mod) {
|
|
40
|
-
if (mod && mod.__esModule) return mod;
|
|
41
|
-
var result = {};
|
|
42
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
43
|
-
__setModuleDefault(result, mod);
|
|
44
|
-
return result;
|
|
45
|
-
};
|
|
46
|
-
})();
|
|
47
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
48
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
49
|
-
if (ar || !(i in from)) {
|
|
50
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
51
|
-
ar[i] = from[i];
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
55
|
-
};
|
|
56
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
|
-
exports.DropzoneEnhanced = void 0;
|
|
58
|
-
var react_1 = __importStar(require("react"));
|
|
59
|
-
var react_dropzone_1 = require("react-dropzone");
|
|
60
|
-
var utils_1 = require("@/lib/utils");
|
|
61
|
-
var carousel_1 = require("@/components/ui/carousel");
|
|
62
|
-
var button_1 = require("@/components/ui/button");
|
|
63
|
-
var lucide_react_1 = require("lucide-react");
|
|
64
|
-
var dropzone_1 = require("../shadcn-io/dropzone");
|
|
65
|
-
var DropzoneEnhanced = function (_a) {
|
|
66
|
-
var id = _a.id, label = _a.label, info = _a.info, error = _a.error, accept = _a.accept, _b = _a.maxFiles, maxFiles = _b === void 0 ? 10 : _b, maxSize = _a.maxSize, minSize = _a.minSize, disabled = _a.disabled, _c = _a.initial, initial = _c === void 0 ? [] : _c, onChange = _a.onChange, onRemoveUrl = _a.onRemoveUrl, className = _a.className;
|
|
67
|
-
// Files selected locally (File objects)
|
|
68
|
-
var _d = (0, react_1.useState)([]), files = _d[0], setFiles = _d[1];
|
|
69
|
-
// Previews array contains strings (object URLs or provided URLs) in display order
|
|
70
|
-
var _e = (0, react_1.useState)([]), previews = _e[0], setPreviews = _e[1];
|
|
71
|
-
// Track which previews are remote (came from initial string URLs)
|
|
72
|
-
var _f = (0, react_1.useState)({}), remotePreviews = _f[0], setRemotePreviews = _f[1];
|
|
73
|
-
var createdUrlsRef = (0, react_1.useRef)([]);
|
|
74
|
-
// Track remote URLs removed by the user so they don't reappear when
|
|
75
|
-
// previews are rebuilt from the unchanged `initial` prop.
|
|
76
|
-
var removedRemoteRef = (0, react_1.useRef)(new Set());
|
|
77
|
-
var dropzoneOptions = {
|
|
78
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
79
|
-
accept: (Array.isArray(accept) ? undefined : accept) || undefined,
|
|
80
|
-
maxFiles: maxFiles,
|
|
81
|
-
maxSize: maxSize,
|
|
82
|
-
minSize: minSize,
|
|
83
|
-
disabled: disabled,
|
|
84
|
-
onDrop: function (acceptedFiles) {
|
|
85
|
-
// append files, respecting maxFiles
|
|
86
|
-
var nextFiles = __spreadArray(__spreadArray([], files, true), acceptedFiles, true);
|
|
87
|
-
if (maxFiles && nextFiles.length > maxFiles)
|
|
88
|
-
nextFiles = nextFiles.slice(0, maxFiles);
|
|
89
|
-
setFiles(nextFiles);
|
|
90
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(nextFiles);
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
var _g = (0, react_dropzone_1.useDropzone)(dropzoneOptions), getRootProps = _g.getRootProps, getInputProps = _g.getInputProps, isDragActive = _g.isDragActive;
|
|
94
|
-
// Build previews from initial and files
|
|
95
|
-
(0, react_1.useEffect)(function () {
|
|
96
|
-
// cleanup previous object URLs
|
|
97
|
-
(createdUrlsRef.current || []).forEach(function (u) {
|
|
98
|
-
try {
|
|
99
|
-
URL.revokeObjectURL(u);
|
|
100
|
-
}
|
|
101
|
-
catch (_a) { }
|
|
102
|
-
});
|
|
103
|
-
createdUrlsRef.current = [];
|
|
104
|
-
var next = [];
|
|
105
|
-
var remoteMap = {};
|
|
106
|
-
// start with initial items (may be File or string)
|
|
107
|
-
initial.forEach(function (item) {
|
|
108
|
-
if (typeof item === "string") {
|
|
109
|
-
// skip any remote URL the user removed earlier
|
|
110
|
-
if (removedRemoteRef.current.has(item))
|
|
111
|
-
return;
|
|
112
|
-
next.push(item);
|
|
113
|
-
remoteMap[item] = true;
|
|
114
|
-
}
|
|
115
|
-
else if (item instanceof File) {
|
|
116
|
-
try {
|
|
117
|
-
var url = URL.createObjectURL(item);
|
|
118
|
-
next.push(url);
|
|
119
|
-
createdUrlsRef.current.push(url);
|
|
120
|
-
}
|
|
121
|
-
catch (_a) {
|
|
122
|
-
next.push("");
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
next.push("");
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
// then local files
|
|
130
|
-
files.forEach(function (f) {
|
|
131
|
-
try {
|
|
132
|
-
var url = URL.createObjectURL(f);
|
|
133
|
-
next.push(url);
|
|
134
|
-
createdUrlsRef.current.push(url);
|
|
135
|
-
}
|
|
136
|
-
catch (_a) {
|
|
137
|
-
next.push("");
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
setPreviews(next);
|
|
141
|
-
setRemotePreviews(remoteMap);
|
|
142
|
-
return function () {
|
|
143
|
-
(createdUrlsRef.current || []).forEach(function (u) {
|
|
144
|
-
try {
|
|
145
|
-
URL.revokeObjectURL(u);
|
|
146
|
-
}
|
|
147
|
-
catch (_a) { }
|
|
148
|
-
});
|
|
149
|
-
createdUrlsRef.current = [];
|
|
150
|
-
};
|
|
151
|
-
// files and initial are the dependencies
|
|
152
|
-
}, [files, initial]);
|
|
153
|
-
// Remove a local file by index (index relative to files slice after initial length)
|
|
154
|
-
var handleRemoveLocal = function (index) {
|
|
155
|
-
var next = files.filter(function (_, i) { return i !== index; });
|
|
156
|
-
setFiles(next);
|
|
157
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(next);
|
|
158
|
-
};
|
|
159
|
-
// Remove a preview by its absolute preview index (index within `previews`)
|
|
160
|
-
// If the preview is remote (string from `initial`), call onRemoveUrl and
|
|
161
|
-
// remove only that single occurrence. If it's a local file, delegate to
|
|
162
|
-
// handleRemoveLocal with the computed files index.
|
|
163
|
-
var handleRemoveByPreviewIndex = function (previewIndex) {
|
|
164
|
-
var entry = previews[previewIndex];
|
|
165
|
-
if (entry === undefined)
|
|
166
|
-
return;
|
|
167
|
-
var isRemote = Boolean(remotePreviews[entry]);
|
|
168
|
-
if (isRemote) {
|
|
169
|
-
// notify parent
|
|
170
|
-
onRemoveUrl === null || onRemoveUrl === void 0 ? void 0 : onRemoveUrl(entry);
|
|
171
|
-
// record removal locally so the value isn't re-added from the `initial`
|
|
172
|
-
// prop on the next rebuild
|
|
173
|
-
removedRemoteRef.current.add(entry);
|
|
174
|
-
// remove only the specific preview at previewIndex
|
|
175
|
-
setPreviews(function (p) {
|
|
176
|
-
var next = __spreadArray([], p, true);
|
|
177
|
-
next.splice(previewIndex, 1);
|
|
178
|
-
return next;
|
|
179
|
-
});
|
|
180
|
-
setRemotePreviews(function (m) {
|
|
181
|
-
var next = __assign({}, m);
|
|
182
|
-
delete next[entry];
|
|
183
|
-
return next;
|
|
184
|
-
});
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
// local file - compute index relative to files array and remove
|
|
188
|
-
var fileIndex = previewIndex - initial.length;
|
|
189
|
-
if (fileIndex >= 0 && fileIndex < files.length) {
|
|
190
|
-
handleRemoveLocal(fileIndex);
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
// (handleRemoveRemote removed) - use handleRemoveByPreviewIndex instead so we
|
|
194
|
-
// can remove single occurrences by index.
|
|
195
|
-
// carousel (embla) handles scrolling via CarouselPrevious/Next
|
|
196
|
-
return (react_1.default.createElement("div", { className: (0, utils_1.cn)("w-full border-red-300", className) },
|
|
197
|
-
label && (react_1.default.createElement("label", { className: "mb-2 block text-sm font-medium" }, label)),
|
|
198
|
-
react_1.default.createElement("div", __assign({}, getRootProps(), { className: (0, utils_1.cn)("relative w-full rounded-md border border-dashed p-6 text-center mx-auto", isDragActive && "ring-1 ring-ring", disabled && "opacity-60 pointer-events-none") }),
|
|
199
|
-
react_1.default.createElement("input", __assign({}, getInputProps(), { id: id })),
|
|
200
|
-
previews && previews.length > 0 ? (react_1.default.createElement("div", { className: "flex flex-col items-center" },
|
|
201
|
-
react_1.default.createElement("div", { className: "relative w-60" },
|
|
202
|
-
react_1.default.createElement("div", { className: "relative w-60" },
|
|
203
|
-
react_1.default.createElement(carousel_1.Carousel, { className: "w-60" },
|
|
204
|
-
react_1.default.createElement(carousel_1.CarouselPrevious, { onPointerDown: function (e) { return e.stopPropagation(); }, onMouseDown: function (e) { return e.stopPropagation(); } }),
|
|
205
|
-
react_1.default.createElement(carousel_1.CarouselNext, { onPointerDown: function (e) { return e.stopPropagation(); }, onMouseDown: function (e) { return e.stopPropagation(); } }),
|
|
206
|
-
react_1.default.createElement(carousel_1.CarouselContent, { className: "no-scrollbar flex gap-2 px-4 py-2", onPointerDown: function (e) { return e.stopPropagation(); }, onClick: function (e) { return e.stopPropagation(); } }, previews.map(function (p, idx) {
|
|
207
|
-
return (react_1.default.createElement(carousel_1.CarouselItem, { key: "".concat(String(p), "-").concat(idx), className: "max-w-30 max-auto" }, p ? (react_1.default.createElement("div", { className: "relative" },
|
|
208
|
-
react_1.default.createElement("img", { src: p, alt: "preview-".concat(idx), className: "h-28 w-28 rounded-md object-cover" }),
|
|
209
|
-
react_1.default.createElement(button_1.Button, { size: "icon", variant: "ghost", onClick: function (e) {
|
|
210
|
-
e.stopPropagation();
|
|
211
|
-
handleRemoveByPreviewIndex(idx);
|
|
212
|
-
}, className: "absolute right-1 top-1 rounded bg-white/80 p-0", "aria-label": "Remove image" },
|
|
213
|
-
react_1.default.createElement(lucide_react_1.XIcon, { size: 7 })))) : (react_1.default.createElement("div", { className: "flex h-28 w-40 items-center justify-center rounded-md bg-muted text-muted-foreground" },
|
|
214
|
-
react_1.default.createElement("span", { className: "text-xs" }, "File")))));
|
|
215
|
-
}))))),
|
|
216
|
-
react_1.default.createElement("p", { className: "mt-2 w-full truncate text-sm font-medium" },
|
|
217
|
-
previews.length,
|
|
218
|
-
" selected"))) : (
|
|
219
|
-
// <div className="text-sm">
|
|
220
|
-
// Drag & drop files here, or click to select
|
|
221
|
-
// </div>
|
|
222
|
-
react_1.default.createElement(dropzone_1.DropzoneEmptyState, null))),
|
|
223
|
-
(error || info) && (react_1.default.createElement("div", { className: "mt-2" }, error ? (react_1.default.createElement("p", { className: "text-xs text-destructive" }, error)) : info ? (react_1.default.createElement("p", { className: "text-xs text-blue-600 dark:text-blue-400" }, info)) : null))));
|
|
224
|
-
};
|
|
225
|
-
exports.DropzoneEnhanced = DropzoneEnhanced;
|
|
226
|
-
exports.default = exports.DropzoneEnhanced;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode } from "react";
|
|
2
|
-
import type { DropEvent, DropzoneOptions, FileRejection } from "react-dropzone";
|
|
3
|
-
export type DropzoneProps = Omit<DropzoneOptions, "onDrop"> & {
|
|
4
|
-
src?: File[];
|
|
5
|
-
className?: string;
|
|
6
|
-
onDrop?: (acceptedFiles: File[], fileRejections: FileRejection[], event: DropEvent) => void;
|
|
7
|
-
children?: ReactNode;
|
|
8
|
-
};
|
|
9
|
-
export declare const Dropzone: ({ accept, maxFiles, maxSize, minSize, onDrop, onError, disabled, src, className, children, ...props }: DropzoneProps) => React.JSX.Element;
|
|
10
|
-
export type DropzoneContentProps = {
|
|
11
|
-
children?: ReactNode;
|
|
12
|
-
className?: string;
|
|
13
|
-
};
|
|
14
|
-
export declare const DropzoneContent: ({ children, className, }: DropzoneContentProps) => string | number | bigint | true | React.JSX.Element | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | null;
|
|
15
|
-
export type DropzoneEmptyStateProps = {
|
|
16
|
-
children?: ReactNode;
|
|
17
|
-
className?: string;
|
|
18
|
-
};
|
|
19
|
-
export declare const DropzoneEmptyState: ({ children, className, }: DropzoneEmptyStateProps) => string | number | bigint | true | React.JSX.Element | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | null;
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
var __assign = (this && this.__assign) || function () {
|
|
4
|
-
__assign = Object.assign || function(t) {
|
|
5
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
-
s = arguments[i];
|
|
7
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
8
|
-
t[p] = s[p];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
return __assign.apply(this, arguments);
|
|
13
|
-
};
|
|
14
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
15
|
-
var t = {};
|
|
16
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
17
|
-
t[p] = s[p];
|
|
18
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
19
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
20
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
21
|
-
t[p[i]] = s[p[i]];
|
|
22
|
-
}
|
|
23
|
-
return t;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.DropzoneEmptyState = exports.DropzoneContent = exports.Dropzone = void 0;
|
|
30
|
-
var lucide_react_1 = require("lucide-react");
|
|
31
|
-
var react_1 = __importDefault(require("react"));
|
|
32
|
-
var react_2 = require("react");
|
|
33
|
-
var react_dropzone_1 = require("react-dropzone");
|
|
34
|
-
var button_1 = require("@/components/ui/button");
|
|
35
|
-
var utils_1 = require("@/lib/utils");
|
|
36
|
-
var renderBytes = function (bytes) {
|
|
37
|
-
var units = ["B", "KB", "MB", "GB", "TB", "PB"];
|
|
38
|
-
var size = bytes;
|
|
39
|
-
var unitIndex = 0;
|
|
40
|
-
while (size >= 1024 && unitIndex < units.length - 1) {
|
|
41
|
-
size /= 1024;
|
|
42
|
-
unitIndex++;
|
|
43
|
-
}
|
|
44
|
-
return "".concat(size.toFixed(2)).concat(units[unitIndex]);
|
|
45
|
-
};
|
|
46
|
-
var DropzoneContext = (0, react_2.createContext)(undefined);
|
|
47
|
-
var Dropzone = function (_a) {
|
|
48
|
-
var accept = _a.accept, _b = _a.maxFiles, maxFiles = _b === void 0 ? 1 : _b, maxSize = _a.maxSize, minSize = _a.minSize, onDrop = _a.onDrop, onError = _a.onError, disabled = _a.disabled, src = _a.src, className = _a.className, children = _a.children, props = __rest(_a, ["accept", "maxFiles", "maxSize", "minSize", "onDrop", "onError", "disabled", "src", "className", "children"]);
|
|
49
|
-
var _c = (0, react_dropzone_1.useDropzone)(__assign({ accept: accept, maxFiles: maxFiles, maxSize: maxSize, minSize: minSize, onError: onError, disabled: disabled, onDrop: function (acceptedFiles, fileRejections, event) {
|
|
50
|
-
var _a, _b;
|
|
51
|
-
if (fileRejections.length > 0) {
|
|
52
|
-
var message = (_b = (_a = fileRejections.at(0)) === null || _a === void 0 ? void 0 : _a.errors.at(0)) === null || _b === void 0 ? void 0 : _b.message;
|
|
53
|
-
onError === null || onError === void 0 ? void 0 : onError(new Error(message));
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
onDrop === null || onDrop === void 0 ? void 0 : onDrop(acceptedFiles, fileRejections, event);
|
|
57
|
-
} }, props)), getRootProps = _c.getRootProps, getInputProps = _c.getInputProps, isDragActive = _c.isDragActive;
|
|
58
|
-
return (react_1.default.createElement(DropzoneContext.Provider, { key: JSON.stringify(src), value: { src: src, accept: accept, maxSize: maxSize, minSize: minSize, maxFiles: maxFiles } },
|
|
59
|
-
react_1.default.createElement(button_1.Button, __assign({ className: (0, utils_1.cn)("relative h-auto w-full flex-col overflow-hidden p-8", isDragActive && "outline-none ring-1 ring-ring", className), disabled: disabled, type: "button", variant: "outline" }, getRootProps()),
|
|
60
|
-
react_1.default.createElement("input", __assign({}, getInputProps(), { disabled: disabled })),
|
|
61
|
-
children)));
|
|
62
|
-
};
|
|
63
|
-
exports.Dropzone = Dropzone;
|
|
64
|
-
var maxLabelItems = 3;
|
|
65
|
-
var DropzoneContent = function (_a) {
|
|
66
|
-
var children = _a.children, className = _a.className;
|
|
67
|
-
// Use useContext directly here so the component is safe to render even when
|
|
68
|
-
// there is no surrounding <Dropzone /> provider (avoids an exception during
|
|
69
|
-
// SSR or when a consumer imports DropzoneContent standalone).
|
|
70
|
-
var context = (0, react_2.useContext)(DropzoneContext);
|
|
71
|
-
if (!context) {
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
var src = context.src;
|
|
75
|
-
if (!src) {
|
|
76
|
-
return null;
|
|
77
|
-
}
|
|
78
|
-
if (children) {
|
|
79
|
-
return children;
|
|
80
|
-
}
|
|
81
|
-
return (react_1.default.createElement("div", { className: (0, utils_1.cn)("flex flex-col items-center justify-center", className) },
|
|
82
|
-
react_1.default.createElement("div", { className: "flex size-8 items-center justify-center rounded-md bg-muted text-muted-foreground" },
|
|
83
|
-
react_1.default.createElement(lucide_react_1.UploadIcon, { size: 16 })),
|
|
84
|
-
react_1.default.createElement("p", { className: "my-2 w-full truncate font-medium text-sm" }, src.length > maxLabelItems
|
|
85
|
-
? "".concat(new Intl.ListFormat("en").format(src.slice(0, maxLabelItems).map(function (file) { return file.name; })), " and ").concat(src.length - maxLabelItems, " more")
|
|
86
|
-
: new Intl.ListFormat("en").format(src.map(function (file) { return file.name; }))),
|
|
87
|
-
react_1.default.createElement("p", { className: "w-full text-wrap text-muted-foreground text-xs" }, "Drag and drop or click to replace")));
|
|
88
|
-
};
|
|
89
|
-
exports.DropzoneContent = DropzoneContent;
|
|
90
|
-
var DropzoneEmptyState = function (_a) {
|
|
91
|
-
var children = _a.children, className = _a.className;
|
|
92
|
-
// Read context directly and return null when a Dropzone provider isn't
|
|
93
|
-
// present. This keeps the empty state component safe to import and render
|
|
94
|
-
// without requiring the wrapping Dropzone component.
|
|
95
|
-
var context = (0, react_2.useContext)(DropzoneContext);
|
|
96
|
-
if (!context) {
|
|
97
|
-
return null;
|
|
98
|
-
}
|
|
99
|
-
var src = context.src, accept = context.accept, maxSize = context.maxSize, minSize = context.minSize, maxFiles = context.maxFiles;
|
|
100
|
-
if (src) {
|
|
101
|
-
return null;
|
|
102
|
-
}
|
|
103
|
-
if (children) {
|
|
104
|
-
return children;
|
|
105
|
-
}
|
|
106
|
-
var caption = "";
|
|
107
|
-
if (accept) {
|
|
108
|
-
caption += "Accepts ";
|
|
109
|
-
caption += new Intl.ListFormat("en").format(Object.keys(accept));
|
|
110
|
-
}
|
|
111
|
-
if (minSize && maxSize) {
|
|
112
|
-
caption += " between ".concat(renderBytes(minSize), " and ").concat(renderBytes(maxSize));
|
|
113
|
-
}
|
|
114
|
-
else if (minSize) {
|
|
115
|
-
caption += " at least ".concat(renderBytes(minSize));
|
|
116
|
-
}
|
|
117
|
-
else if (maxSize) {
|
|
118
|
-
caption += " less than ".concat(renderBytes(maxSize));
|
|
119
|
-
}
|
|
120
|
-
return (react_1.default.createElement("div", { className: (0, utils_1.cn)("flex flex-col items-center justify-center", className) },
|
|
121
|
-
react_1.default.createElement("div", { className: "flex size-8 items-center justify-center rounded-md bg-muted text-muted-foreground" },
|
|
122
|
-
react_1.default.createElement(lucide_react_1.UploadIcon, { size: 16 })),
|
|
123
|
-
react_1.default.createElement("p", { className: "my-2 w-full truncate text-wrap font-medium text-sm" },
|
|
124
|
-
"Upload ",
|
|
125
|
-
maxFiles === 1 ? "a file" : "files"),
|
|
126
|
-
react_1.default.createElement("p", { className: "w-full truncate text-wrap text-muted-foreground text-xs" }, "Drag and drop or click to upload"),
|
|
127
|
-
caption && (react_1.default.createElement("p", { className: "text-wrap text-muted-foreground text-xs" },
|
|
128
|
-
caption,
|
|
129
|
-
"."))));
|
|
130
|
-
};
|
|
131
|
-
exports.DropzoneEmptyState = DropzoneEmptyState;
|