mainstack-design-system 1.16.1 → 1.16.3
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/assets/styles.css +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/mainstack-design-system16.cjs +1 -1
- package/dist/mainstack-design-system16.js +43 -40
- package/dist/mainstack-design-system18.cjs +1 -1
- package/dist/mainstack-design-system18.js +47 -45
- package/dist/mainstack-design-system20.cjs +1 -1
- package/dist/mainstack-design-system20.js +27 -20
- package/dist/mainstack-design-system27.cjs +1 -1
- package/dist/mainstack-design-system27.js +44 -41
- package/dist/mainstack-design-system34.cjs +1 -1
- package/dist/mainstack-design-system34.js +24 -15
- package/dist/mainstack-design-system403.cjs +1 -1
- package/dist/mainstack-design-system403.js +29 -29
- package/dist/mainstack-design-system404.cjs +1 -1
- package/dist/mainstack-design-system404.js +2 -5
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -4312,6 +4312,7 @@ declare type FileUploaderContextType = {
|
|
|
4312
4312
|
onError?: (error: unknown) => void;
|
|
4313
4313
|
error: string | null;
|
|
4314
4314
|
setError: (error: string | null) => void;
|
|
4315
|
+
isError?: boolean;
|
|
4315
4316
|
} & Pick<DropzoneOptions, "accept" | "maxFiles" | "minSize" | "maxSize">;
|
|
4316
4317
|
|
|
4317
4318
|
export declare const FileUploaderDropzone: {
|
|
@@ -4356,7 +4357,7 @@ export declare type FileUploaderFileType = {
|
|
|
4356
4357
|
|
|
4357
4358
|
export declare const FileUploaderGroup: {
|
|
4358
4359
|
Root: {
|
|
4359
|
-
({ values: controlledValues, onValuesChange: controlledonValuesChange, defaultValues, isDisabled, accept, maxFiles, maxSize, multiple, onError: externalOnError, children, className, ...props }: FileUploaderRootProps): JSX.Element;
|
|
4360
|
+
({ values: controlledValues, onValuesChange: controlledonValuesChange, defaultValues, isDisabled, accept, maxFiles, maxSize, multiple, onError: externalOnError, children, className, isError, ...props }: FileUploaderRootProps): JSX.Element;
|
|
4360
4361
|
displayName: string;
|
|
4361
4362
|
};
|
|
4362
4363
|
DropZone: {
|
|
@@ -4417,7 +4418,7 @@ export declare interface FileUploaderPreviewProps extends Omit<ComponentPropsWit
|
|
|
4417
4418
|
}
|
|
4418
4419
|
|
|
4419
4420
|
export declare const FileUploaderRoot: {
|
|
4420
|
-
({ values: controlledValues, onValuesChange: controlledonValuesChange, defaultValues, isDisabled, accept, maxFiles, maxSize, multiple, onError: externalOnError, children, className, ...props }: FileUploaderRootProps): JSX.Element;
|
|
4421
|
+
({ values: controlledValues, onValuesChange: controlledonValuesChange, defaultValues, isDisabled, accept, maxFiles, maxSize, multiple, onError: externalOnError, children, className, isError, ...props }: FileUploaderRootProps): JSX.Element;
|
|
4421
4422
|
displayName: string;
|
|
4422
4423
|
};
|
|
4423
4424
|
|
|
@@ -4646,6 +4647,7 @@ declare type ImageUploaderContextType = {
|
|
|
4646
4647
|
setMainPreviewFile: Dispatch<SetStateAction<ImageUploaderFileType | null>>;
|
|
4647
4648
|
onValuesChange: (values: Array<ImageUploaderFileType>) => void;
|
|
4648
4649
|
onError?: (error: unknown) => void;
|
|
4650
|
+
isError?: boolean;
|
|
4649
4651
|
} & Pick<DropzoneOptions, "accept" | "maxFiles" | "minSize" | "maxSize">;
|
|
4650
4652
|
|
|
4651
4653
|
export declare const ImageUploaderDropzone: {
|
|
@@ -4680,7 +4682,7 @@ export declare interface ImageUploaderFileType extends FileUploaderFileType {
|
|
|
4680
4682
|
|
|
4681
4683
|
export declare const ImageUploaderGroup: {
|
|
4682
4684
|
Root: {
|
|
4683
|
-
({ values: controlledValues, onValuesChange: controlledonValuesChange, defaultValues, isDisabled, accept, maxFiles, maxSize, onError: externalOnError, children, className, ...props }: ImageUploaderRootProps): JSX.Element;
|
|
4685
|
+
({ values: controlledValues, onValuesChange: controlledonValuesChange, defaultValues, isDisabled, accept, maxFiles, maxSize, onError: externalOnError, children, className, isError, ...props }: ImageUploaderRootProps): JSX.Element;
|
|
4684
4686
|
displayName: string;
|
|
4685
4687
|
};
|
|
4686
4688
|
MainPreview: {
|
|
@@ -4763,7 +4765,7 @@ export declare interface ImageUploaderPreviewProps extends Omit<ComponentPropsWi
|
|
|
4763
4765
|
}
|
|
4764
4766
|
|
|
4765
4767
|
export declare const ImageUploaderRoot: {
|
|
4766
|
-
({ values: controlledValues, onValuesChange: controlledonValuesChange, defaultValues, isDisabled, accept, maxFiles, maxSize, onError: externalOnError, children, className, ...props }: ImageUploaderRootProps): JSX.Element;
|
|
4768
|
+
({ values: controlledValues, onValuesChange: controlledonValuesChange, defaultValues, isDisabled, accept, maxFiles, maxSize, onError: externalOnError, children, className, isError, ...props }: ImageUploaderRootProps): JSX.Element;
|
|
4767
4769
|
displayName: string;
|
|
4768
4770
|
};
|
|
4769
4771
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("react/jsx-runtime"),a=require("react"),y=require("./mainstack-design-system25.cjs"),P=require("./index-C8aODXfJ.cjs"),R=require("./utils-s-0cOrOT.cjs"),m=({values:l,onValuesChange:p,defaultValues:t=[],isDisabled:n,accept:v={"image/png":[".png",".jpeg",".jpg",".webp"]},maxFiles:b=4,maxSize:h,onError:r,children:C,className:f,isError:i,...j})=>{const[o,c]=P.useControllableState({prop:l,defaultProp:t,onChange:p}),[d,u]=a.useState(()=>{const e=l||t;return e&&e.length>0?e[e.length-1]:null});o&&o.length>0&&!d&&u(o[o.length-1]);const[x,s]=a.useState(null),I=a.useCallback(e=>{s(null),c(e)},[c]),U=a.useCallback(e=>{const q=e instanceof Error?e.message:"An error occurred";s(q),r&&r(e)},[r]);return g.jsx(y.ImageUploaderContext.Provider,{value:{values:o,defaultValues:t,mainPreviewFile:d,isDisabled:n,accept:v,maxFiles:b,maxSize:h,setMainPreviewFile:u,onValuesChange:I,error:x,setError:s,onError:U,isError:i},children:g.jsx("div",{"data-disabled":n,"aria-disabled":n,"data-error":i,"data-slot":"image-uploader-root",className:R.cn("mds:relative mds:flex mds:flex-col mds:gap-12 mds:body-font-family",f),...j,children:C})})};m.displayName="ImageUploaderRoot";exports.ImageUploaderRoot=m;
|
|
@@ -1,78 +1,81 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { useState as
|
|
4
|
-
import { ImageUploaderContext as
|
|
5
|
-
import { u as
|
|
6
|
-
import { c as
|
|
7
|
-
const
|
|
2
|
+
import { jsx as g } from "react/jsx-runtime";
|
|
3
|
+
import { useState as d, useCallback as c } from "react";
|
|
4
|
+
import { ImageUploaderContext as I } from "./mainstack-design-system25.js";
|
|
5
|
+
import { u as U } from "./index-437EL2iq.js";
|
|
6
|
+
import { c as F } from "./utils-Z5JtG_Bc.js";
|
|
7
|
+
const N = ({
|
|
8
8
|
values: s,
|
|
9
|
-
onValuesChange:
|
|
9
|
+
onValuesChange: u,
|
|
10
10
|
defaultValues: a = [],
|
|
11
11
|
isDisabled: r,
|
|
12
|
-
accept:
|
|
13
|
-
maxFiles:
|
|
14
|
-
maxSize:
|
|
12
|
+
accept: f = { "image/png": [".png", ".jpeg", ".jpg", ".webp"] },
|
|
13
|
+
maxFiles: h = 4,
|
|
14
|
+
maxSize: v,
|
|
15
15
|
onError: t,
|
|
16
|
-
children:
|
|
17
|
-
className:
|
|
18
|
-
|
|
16
|
+
children: C,
|
|
17
|
+
className: b,
|
|
18
|
+
isError: l,
|
|
19
|
+
...P
|
|
19
20
|
}) => {
|
|
20
|
-
const [o,
|
|
21
|
+
const [o, m] = U({
|
|
21
22
|
prop: s,
|
|
22
23
|
defaultProp: a,
|
|
23
|
-
onChange:
|
|
24
|
-
}), [
|
|
24
|
+
onChange: u
|
|
25
|
+
}), [i, p] = d(() => {
|
|
25
26
|
const e = s || a;
|
|
26
27
|
return e && e.length > 0 ? e[e.length - 1] : null;
|
|
27
28
|
});
|
|
28
|
-
o && o.length > 0 && !
|
|
29
|
-
const [
|
|
29
|
+
o && o.length > 0 && !i && p(o[o.length - 1]);
|
|
30
|
+
const [j, n] = d(null), w = c(
|
|
30
31
|
(e) => {
|
|
31
|
-
n(null),
|
|
32
|
+
n(null), m(e);
|
|
32
33
|
},
|
|
33
|
-
[
|
|
34
|
-
),
|
|
34
|
+
[m]
|
|
35
|
+
), x = c(
|
|
35
36
|
(e) => {
|
|
36
|
-
const
|
|
37
|
-
n(
|
|
37
|
+
const y = e instanceof Error ? e.message : "An error occurred";
|
|
38
|
+
n(y), t && t(e);
|
|
38
39
|
},
|
|
39
40
|
[t]
|
|
40
41
|
);
|
|
41
|
-
return /* @__PURE__ */
|
|
42
|
-
|
|
42
|
+
return /* @__PURE__ */ g(
|
|
43
|
+
I.Provider,
|
|
43
44
|
{
|
|
44
45
|
value: {
|
|
45
46
|
values: o,
|
|
46
47
|
defaultValues: a,
|
|
47
|
-
mainPreviewFile:
|
|
48
|
+
mainPreviewFile: i,
|
|
48
49
|
isDisabled: r,
|
|
49
|
-
accept:
|
|
50
|
-
maxFiles:
|
|
51
|
-
maxSize:
|
|
52
|
-
setMainPreviewFile:
|
|
53
|
-
onValuesChange:
|
|
54
|
-
error:
|
|
50
|
+
accept: f,
|
|
51
|
+
maxFiles: h,
|
|
52
|
+
maxSize: v,
|
|
53
|
+
setMainPreviewFile: p,
|
|
54
|
+
onValuesChange: w,
|
|
55
|
+
error: j,
|
|
55
56
|
setError: n,
|
|
56
|
-
onError:
|
|
57
|
+
onError: x,
|
|
58
|
+
isError: l
|
|
57
59
|
},
|
|
58
|
-
children: /* @__PURE__ */
|
|
60
|
+
children: /* @__PURE__ */ g(
|
|
59
61
|
"div",
|
|
60
62
|
{
|
|
61
63
|
"data-disabled": r,
|
|
62
64
|
"aria-disabled": r,
|
|
65
|
+
"data-error": l,
|
|
63
66
|
"data-slot": "image-uploader-root",
|
|
64
|
-
className:
|
|
67
|
+
className: F(
|
|
65
68
|
"mds:relative mds:flex mds:flex-col mds:gap-12 mds:body-font-family",
|
|
66
|
-
|
|
69
|
+
b
|
|
67
70
|
),
|
|
68
|
-
...
|
|
69
|
-
children:
|
|
71
|
+
...P,
|
|
72
|
+
children: C
|
|
70
73
|
}
|
|
71
74
|
)
|
|
72
75
|
}
|
|
73
76
|
);
|
|
74
77
|
};
|
|
75
|
-
|
|
78
|
+
N.displayName = "ImageUploaderRoot";
|
|
76
79
|
export {
|
|
77
|
-
|
|
80
|
+
N as ImageUploaderRoot
|
|
78
81
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),I=require("react"),c=require("./utils-s-0cOrOT.cjs");require("./mainstack-design-system366.cjs");const E=require("./mainstack-design-system55.cjs"),L=require("./mainstack-design-system225.cjs"),R=require("./mainstack-design-system241.cjs"),q=require("./mainstack-design-system286.cjs");require("./player-CocaNyQC.cjs");const T=require("./mainstack-design-system25.cjs"),A=require("./mainstack-design-system629.cjs"),h=require("./index-4R9KShCu.cjs"),x=require("./mainstack-design-system401.cjs"),C=require("./mainstack-design-system402.cjs"),v=require("./mainstack-design-system403.cjs");require("./mainstack-design-system404.cjs");require("./mainstack-design-system405.cjs");const z=({className:w,children:B,previewImgSrc:f,previewId:t,isPlaceholder:N,onClick:k,...U})=>{const{values:a,maxFiles:l,accept:D,maxSize:m,onValuesChange:u,onError:s,setMainPreviewFile:n,mainPreviewFile:d,isError:O}=T.useImageUploaderContext(),[M,y]=I.useState(!1),j=d?.id===t,P=I.useCallback(()=>{const r=[...a],i=r.findIndex(p=>p.id===t),_=d?.id===t;i>-1&&(r.splice(i,1),u(r),_&&n(r[0]||null))},[u,t,n,a,d]),S=I.useCallback(async(r,i)=>{const _=a.length,p=(l||0)-_;if(r.length>p||i.length>0){if(s){if(r.length>p||i.some(o=>o.errors.some(b=>b.code==="too-many-files")))return s(new Error(`You can only upload a maximum of ${l} images.`));if(i.some(o=>o.errors.some(b=>b.code==="file-too-large"))){const o=m?(m/1048576).toFixed(0):"0";return s(new Error(`Image size exceeds the ${o}MB limit.`))}return s(new Error("Invalid image type or criteria."))}return}try{const g=await c.generateImageFilePreview(r),o=[...a,...g];u(o),d||n(o[o.length-1]||null)}catch(g){s&&s(g)}},[a,l,m,u,s,d,n]);return B||(N?e.jsx(A.DropzoneUploadArea,{"data-slot":"image-uploader-preview-item-placeholder",className:"mds:w-fit",noDrag:!0,accept:D,maxFiles:l,maxSize:m,onDrop:S,children:e.jsx("button",{className:c.cn("mds:border mds:border-dashed mds:border-border-interactive-neutral mds:rounded-16 mds:h-88 mds:shrink-0 mds:w-117 mds:flex mds:justify-center mds:items-center mds:cursor-pointer mds:hover:bg-interactive-secondary",O&&"mds:ring-2 mds:bg-surface-error-l1 mds:ring-border-surface-error-l1",w),onClick:k,...U,children:e.jsx(E,{variant:"filled"})})}):e.jsxs("div",{"data-slot":"image-uploader-preview-item","data-active-preview":j,className:c.cn("mds:relative mds:h-88 mds:rounded-16 mds:shrink-0 mds:w-117 mds:overflow-hidden mds:cursor-pointer mds:data-[active-preview=true]:outline-2 mds:data-[active-preview=true]:outline-offset-2 mds:data-[active-preview=true]:outline-border-interactive-neutral-active"),children:[e.jsx("img",{className:c.cn("mds:object-cover mds:h-full mds:w-full ",w),src:f,alt:`Image uploaded with id ${t}`,onClick:()=>{j||n({id:t,previewSrc:f})}}),j?e.jsx(v.ButtonRoot,{className:"mds:absolute mds:top-4 mds:right-4",size:"tiny",variant:"secondary",rounded:"sm",iconOnly:!0,onClick:r=>{r.stopPropagation(),P()},children:e.jsx(x.ButtonIcon,{children:e.jsx(q,{className:"mds:size-16 mds:text-interactive-error"})})}):e.jsxs(h.Popover,{open:M,onOpenChange:y,children:[e.jsx(h.PopoverTrigger,{asChild:!0,children:e.jsx(v.ButtonRoot,{className:"mds:absolute mds:top-4 mds:right-4",size:"tiny",variant:"secondary",rounded:"sm",iconOnly:!0,onClick:r=>r.stopPropagation(),children:e.jsx(x.ButtonIcon,{children:e.jsx(L,{className:"mds:size-16"})})})}),e.jsx(h.PopoverPortal,{children:e.jsxs(h.PopoverContent,{side:"bottom",sideOffset:2,align:"end",className:c.cn("mds:flex mds:flex-col mds:p-8 mds:bg-surface-neutral-l1 mds:rounded-18 mds:will-change-transform mds:data-[state=open]:animate-content-fade-in mds:animate-content-fade-out "),children:[e.jsxs(v.ButtonRoot,{onClick:()=>{n({id:t,previewSrc:f}),y(!1)},size:"xs",variant:"ghost",children:[e.jsx(x.ButtonIcon,{children:e.jsx(R,{className:"mds:size-20 mds:text-tertiary"})}),e.jsx(C.ButtonLabel,{children:"Set as cover image"})]}),e.jsxs(v.ButtonRoot,{className:"mds:justify-start ",size:"xs",variant:"ghost",onClick:P,children:[e.jsx(x.ButtonIcon,{children:e.jsx(q,{className:"mds:size-20 mds:text-interactive-error"})}),e.jsx(C.ButtonLabel,{className:" mds:text-interactive-error",children:"Delete"})]})]})})]})]}))};z.displayName="ImageUploaderPreviewItem";exports.ImageUploaderPreviewItem=z;
|
|
@@ -1,54 +1,55 @@
|
|
|
1
1
|
import { jsx as e, jsxs as d } from "react/jsx-runtime";
|
|
2
|
-
import { useState as
|
|
3
|
-
import { g as
|
|
2
|
+
import { useState as _, useCallback as I } from "react";
|
|
3
|
+
import { g as j, c as h } from "./utils-Z5JtG_Bc.js";
|
|
4
4
|
import "./mainstack-design-system366.js";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
5
|
+
import A from "./mainstack-design-system55.js";
|
|
6
|
+
import F from "./mainstack-design-system225.js";
|
|
7
|
+
import H from "./mainstack-design-system241.js";
|
|
8
8
|
import k from "./mainstack-design-system286.js";
|
|
9
9
|
import "./player-Chgv-hOU.js";
|
|
10
|
-
import { useImageUploaderContext as
|
|
11
|
-
import { DropzoneUploadArea as
|
|
12
|
-
import { P as
|
|
13
|
-
import { ButtonIcon as
|
|
10
|
+
import { useImageUploaderContext as L } from "./mainstack-design-system25.js";
|
|
11
|
+
import { DropzoneUploadArea as $ } from "./mainstack-design-system629.js";
|
|
12
|
+
import { P as V, a as Y, b as q, c as G } from "./index-RoCFhqzC.js";
|
|
13
|
+
import { ButtonIcon as g } from "./mainstack-design-system401.js";
|
|
14
14
|
import { ButtonLabel as B } from "./mainstack-design-system402.js";
|
|
15
|
-
import { ButtonRoot as
|
|
15
|
+
import { ButtonRoot as v } from "./mainstack-design-system403.js";
|
|
16
16
|
import "./mainstack-design-system404.js";
|
|
17
17
|
import "./mainstack-design-system405.js";
|
|
18
|
-
const
|
|
19
|
-
className:
|
|
18
|
+
const J = ({
|
|
19
|
+
className: y,
|
|
20
20
|
children: z,
|
|
21
21
|
previewImgSrc: x,
|
|
22
22
|
previewId: t,
|
|
23
23
|
isPlaceholder: D,
|
|
24
24
|
onClick: O,
|
|
25
|
-
...
|
|
25
|
+
...E
|
|
26
26
|
}) => {
|
|
27
27
|
const {
|
|
28
28
|
values: n,
|
|
29
29
|
maxFiles: l,
|
|
30
|
-
accept:
|
|
30
|
+
accept: M,
|
|
31
31
|
maxSize: c,
|
|
32
32
|
onValuesChange: u,
|
|
33
33
|
onError: s,
|
|
34
34
|
setMainPreviewFile: i,
|
|
35
|
-
mainPreviewFile: m
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
mainPreviewFile: m,
|
|
36
|
+
isError: S
|
|
37
|
+
} = L(), [T, C] = _(!1), w = m?.id === t, N = I(() => {
|
|
38
|
+
const r = [...n], a = r.findIndex((p) => p.id === t), b = m?.id === t;
|
|
39
|
+
a > -1 && (r.splice(a, 1), u(r), b && i(r[0] || null));
|
|
40
|
+
}, [u, t, i, n, m]), U = I(
|
|
40
41
|
async (r, a) => {
|
|
41
|
-
const
|
|
42
|
+
const b = n.length, p = (l || 0) - b;
|
|
42
43
|
if (r.length > p || a.length > 0) {
|
|
43
44
|
if (s) {
|
|
44
45
|
if (r.length > p || a.some(
|
|
45
|
-
(o) => o.errors.some((
|
|
46
|
+
(o) => o.errors.some((P) => P.code === "too-many-files")
|
|
46
47
|
))
|
|
47
48
|
return s(
|
|
48
49
|
new Error(`You can only upload a maximum of ${l} images.`)
|
|
49
50
|
);
|
|
50
51
|
if (a.some(
|
|
51
|
-
(o) => o.errors.some((
|
|
52
|
+
(o) => o.errors.some((P) => P.code === "file-too-large")
|
|
52
53
|
)) {
|
|
53
54
|
const o = c ? (c / 1048576).toFixed(0) : "0";
|
|
54
55
|
return s(
|
|
@@ -60,7 +61,7 @@ const G = ({
|
|
|
60
61
|
return;
|
|
61
62
|
}
|
|
62
63
|
try {
|
|
63
|
-
const f = await
|
|
64
|
+
const f = await j(r), o = [...n, ...f];
|
|
64
65
|
u(o), m || i(o[o.length - 1] || null);
|
|
65
66
|
} catch (f) {
|
|
66
67
|
s && s(f);
|
|
@@ -77,25 +78,26 @@ const G = ({
|
|
|
77
78
|
]
|
|
78
79
|
);
|
|
79
80
|
return z || (D ? /* @__PURE__ */ e(
|
|
80
|
-
|
|
81
|
+
$,
|
|
81
82
|
{
|
|
82
83
|
"data-slot": "image-uploader-preview-item-placeholder",
|
|
83
84
|
className: "mds:w-fit",
|
|
84
85
|
noDrag: !0,
|
|
85
|
-
accept:
|
|
86
|
+
accept: M,
|
|
86
87
|
maxFiles: l,
|
|
87
88
|
maxSize: c,
|
|
88
|
-
onDrop:
|
|
89
|
+
onDrop: U,
|
|
89
90
|
children: /* @__PURE__ */ e(
|
|
90
91
|
"button",
|
|
91
92
|
{
|
|
92
93
|
className: h(
|
|
93
94
|
"mds:border mds:border-dashed mds:border-border-interactive-neutral mds:rounded-16 mds:h-88 mds:shrink-0 mds:w-117 mds:flex mds:justify-center mds:items-center mds:cursor-pointer mds:hover:bg-interactive-secondary",
|
|
94
|
-
|
|
95
|
+
S && "mds:ring-2 mds:bg-surface-error-l1 mds:ring-border-surface-error-l1",
|
|
96
|
+
y
|
|
95
97
|
),
|
|
96
98
|
onClick: O,
|
|
97
|
-
...
|
|
98
|
-
children: /* @__PURE__ */ e(
|
|
99
|
+
...E,
|
|
100
|
+
children: /* @__PURE__ */ e(A, { variant: "filled" })
|
|
99
101
|
}
|
|
100
102
|
)
|
|
101
103
|
}
|
|
@@ -111,7 +113,7 @@ const G = ({
|
|
|
111
113
|
/* @__PURE__ */ e(
|
|
112
114
|
"img",
|
|
113
115
|
{
|
|
114
|
-
className: h("mds:object-cover mds:h-full mds:w-full ",
|
|
116
|
+
className: h("mds:object-cover mds:h-full mds:w-full ", y),
|
|
115
117
|
src: x,
|
|
116
118
|
alt: `Image uploaded with id ${t}`,
|
|
117
119
|
onClick: () => {
|
|
@@ -120,7 +122,7 @@ const G = ({
|
|
|
120
122
|
}
|
|
121
123
|
),
|
|
122
124
|
w ? /* @__PURE__ */ e(
|
|
123
|
-
|
|
125
|
+
v,
|
|
124
126
|
{
|
|
125
127
|
className: "mds:absolute mds:top-4 mds:right-4",
|
|
126
128
|
size: "tiny",
|
|
@@ -130,16 +132,16 @@ const G = ({
|
|
|
130
132
|
onClick: (r) => {
|
|
131
133
|
r.stopPropagation(), N();
|
|
132
134
|
},
|
|
133
|
-
children: /* @__PURE__ */ e(
|
|
135
|
+
children: /* @__PURE__ */ e(g, { children: /* @__PURE__ */ e(k, { className: "mds:size-16 mds:text-interactive-error" }) })
|
|
134
136
|
}
|
|
135
137
|
) : /* @__PURE__ */ d(
|
|
136
|
-
|
|
138
|
+
V,
|
|
137
139
|
{
|
|
138
|
-
open:
|
|
140
|
+
open: T,
|
|
139
141
|
onOpenChange: C,
|
|
140
142
|
children: [
|
|
141
|
-
/* @__PURE__ */ e(
|
|
142
|
-
|
|
143
|
+
/* @__PURE__ */ e(Y, { asChild: !0, children: /* @__PURE__ */ e(
|
|
144
|
+
v,
|
|
143
145
|
{
|
|
144
146
|
className: "mds:absolute mds:top-4 mds:right-4",
|
|
145
147
|
size: "tiny",
|
|
@@ -147,11 +149,11 @@ const G = ({
|
|
|
147
149
|
rounded: "sm",
|
|
148
150
|
iconOnly: !0,
|
|
149
151
|
onClick: (r) => r.stopPropagation(),
|
|
150
|
-
children: /* @__PURE__ */ e(
|
|
152
|
+
children: /* @__PURE__ */ e(g, { children: /* @__PURE__ */ e(F, { className: "mds:size-16" }) })
|
|
151
153
|
}
|
|
152
154
|
) }),
|
|
153
|
-
/* @__PURE__ */ e(
|
|
154
|
-
|
|
155
|
+
/* @__PURE__ */ e(q, { children: /* @__PURE__ */ d(
|
|
156
|
+
G,
|
|
155
157
|
{
|
|
156
158
|
side: "bottom",
|
|
157
159
|
sideOffset: 2,
|
|
@@ -161,7 +163,7 @@ const G = ({
|
|
|
161
163
|
),
|
|
162
164
|
children: [
|
|
163
165
|
/* @__PURE__ */ d(
|
|
164
|
-
|
|
166
|
+
v,
|
|
165
167
|
{
|
|
166
168
|
onClick: () => {
|
|
167
169
|
i({
|
|
@@ -172,20 +174,20 @@ const G = ({
|
|
|
172
174
|
size: "xs",
|
|
173
175
|
variant: "ghost",
|
|
174
176
|
children: [
|
|
175
|
-
/* @__PURE__ */ e(
|
|
177
|
+
/* @__PURE__ */ e(g, { children: /* @__PURE__ */ e(H, { className: "mds:size-20 mds:text-tertiary" }) }),
|
|
176
178
|
/* @__PURE__ */ e(B, { children: "Set as cover image" })
|
|
177
179
|
]
|
|
178
180
|
}
|
|
179
181
|
),
|
|
180
182
|
/* @__PURE__ */ d(
|
|
181
|
-
|
|
183
|
+
v,
|
|
182
184
|
{
|
|
183
185
|
className: "mds:justify-start ",
|
|
184
186
|
size: "xs",
|
|
185
187
|
variant: "ghost",
|
|
186
188
|
onClick: N,
|
|
187
189
|
children: [
|
|
188
|
-
/* @__PURE__ */ e(
|
|
190
|
+
/* @__PURE__ */ e(g, { children: /* @__PURE__ */ e(k, { className: "mds:size-20 mds:text-interactive-error" }) }),
|
|
189
191
|
/* @__PURE__ */ e(B, { className: " mds:text-interactive-error", children: "Delete" })
|
|
190
192
|
]
|
|
191
193
|
}
|
|
@@ -200,7 +202,7 @@ const G = ({
|
|
|
200
202
|
}
|
|
201
203
|
));
|
|
202
204
|
};
|
|
203
|
-
|
|
205
|
+
J.displayName = "ImageUploaderPreviewItem";
|
|
204
206
|
export {
|
|
205
|
-
|
|
207
|
+
J as ImageUploaderPreviewItem
|
|
206
208
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),v=require("./mainstack-design-system401.cjs");require("./mainstack-design-system402.cjs");const g=require("./mainstack-design-system403.cjs");require("./mainstack-design-system404.cjs");require("./mainstack-design-system405.cjs");require("./mainstack-design-system366.cjs");const p=require("./mainstack-design-system286.cjs");require("react");require("./player-CocaNyQC.cjs");const b=require("./utils-s-0cOrOT.cjs"),w=require("./mainstack-design-system25.cjs"),o=({className:i,children:n,...a})=>{const{mainPreviewFile:r,onValuesChange:d,values:l,setMainPreviewFile:m,isError:c}=w.useImageUploaderContext();return e.jsx("div",{role:"region","data-slot":"image-uploader-dropzone","data-active-preview":!!r?.id,className:b.cn("mds:relative mds:border mds:border-dashed mds:border-border-interactive-neutral mds:rounded-20 mds:bg-surface-neutral-l1 mds:w-504 mds:data-[active-preview=true]:overflow-hidden mds:h-378 mds:cursor-pointer mds:hover:bg-interactive-secondary mds:data-dragging:border-border-interactive-neutral mds:active:ring-2 mds:active:ring-border-interactive-neutral-pressed ",c&&"mds:ring-2 mds:bg-surface-error-l1 mds:ring-border-surface-error-l1",i),...a,children:r?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:r.previewSrc,alt:"Image Uploader Main Preview image ",className:"mds:absolute mds:top-0 mds:left-0 mds:w-full mds:h-full mds:object-cover"}),e.jsx(g.ButtonRoot,{rounded:"sm",size:"tiny",status:"default",variant:"secondary",iconOnly:!0,className:"mds:absolute mds:right-20 mds:top-20 mds:z-10",onClick:()=>{const s=[...l],t=s.findIndex(u=>u.id===r.id);t>-1&&(s.splice(t,1),d(s),m(s[0]||null))},children:e.jsx(v.ButtonIcon,{children:e.jsx(p,{variant:"outlined",className:"mds:h-16 mds:w-16 mds:text-error"})})})]}):n})};o.displayName="ImageUploaderMainPreview";exports.ImageUploaderMainPreview=o;
|
|
@@ -1,33 +1,40 @@
|
|
|
1
|
-
import { jsx as e, jsxs as
|
|
2
|
-
import { ButtonIcon as
|
|
1
|
+
import { jsx as e, jsxs as p, Fragment as u } from "react/jsx-runtime";
|
|
2
|
+
import { ButtonIcon as v } from "./mainstack-design-system401.js";
|
|
3
3
|
import "./mainstack-design-system402.js";
|
|
4
|
-
import { ButtonRoot as
|
|
4
|
+
import { ButtonRoot as g } from "./mainstack-design-system403.js";
|
|
5
5
|
import "./mainstack-design-system404.js";
|
|
6
6
|
import "./mainstack-design-system405.js";
|
|
7
7
|
import "./mainstack-design-system366.js";
|
|
8
|
-
import
|
|
8
|
+
import f from "./mainstack-design-system286.js";
|
|
9
9
|
import "react";
|
|
10
10
|
import "./player-Chgv-hOU.js";
|
|
11
|
-
import { c as
|
|
11
|
+
import { c as b } from "./utils-Z5JtG_Bc.js";
|
|
12
12
|
import { useImageUploaderContext as h } from "./mainstack-design-system25.js";
|
|
13
13
|
const w = ({
|
|
14
|
-
className:
|
|
15
|
-
children:
|
|
16
|
-
...
|
|
14
|
+
className: o,
|
|
15
|
+
children: s,
|
|
16
|
+
...a
|
|
17
17
|
}) => {
|
|
18
|
-
const {
|
|
18
|
+
const {
|
|
19
|
+
mainPreviewFile: r,
|
|
20
|
+
onValuesChange: t,
|
|
21
|
+
values: m,
|
|
22
|
+
setMainPreviewFile: n,
|
|
23
|
+
isError: l
|
|
24
|
+
} = h();
|
|
19
25
|
return /* @__PURE__ */ e(
|
|
20
26
|
"div",
|
|
21
27
|
{
|
|
22
28
|
role: "region",
|
|
23
29
|
"data-slot": "image-uploader-dropzone",
|
|
24
30
|
"data-active-preview": !!r?.id,
|
|
25
|
-
className:
|
|
31
|
+
className: b(
|
|
26
32
|
"mds:relative mds:border mds:border-dashed mds:border-border-interactive-neutral mds:rounded-20 mds:bg-surface-neutral-l1 mds:w-504 mds:data-[active-preview=true]:overflow-hidden mds:h-378 mds:cursor-pointer mds:hover:bg-interactive-secondary mds:data-dragging:border-border-interactive-neutral mds:active:ring-2 mds:active:ring-border-interactive-neutral-pressed ",
|
|
27
|
-
|
|
33
|
+
l && "mds:ring-2 mds:bg-surface-error-l1 mds:ring-border-surface-error-l1",
|
|
34
|
+
o
|
|
28
35
|
),
|
|
29
|
-
...
|
|
30
|
-
children: r ? /* @__PURE__ */
|
|
36
|
+
...a,
|
|
37
|
+
children: r ? /* @__PURE__ */ p(u, { children: [
|
|
31
38
|
/* @__PURE__ */ e(
|
|
32
39
|
"img",
|
|
33
40
|
{
|
|
@@ -37,7 +44,7 @@ const w = ({
|
|
|
37
44
|
}
|
|
38
45
|
),
|
|
39
46
|
/* @__PURE__ */ e(
|
|
40
|
-
|
|
47
|
+
g,
|
|
41
48
|
{
|
|
42
49
|
rounded: "sm",
|
|
43
50
|
size: "tiny",
|
|
@@ -46,13 +53,13 @@ const w = ({
|
|
|
46
53
|
iconOnly: !0,
|
|
47
54
|
className: "mds:absolute mds:right-20 mds:top-20 mds:z-10",
|
|
48
55
|
onClick: () => {
|
|
49
|
-
const
|
|
50
|
-
(
|
|
56
|
+
const d = [...m], i = d.findIndex(
|
|
57
|
+
(c) => c.id === r.id
|
|
51
58
|
);
|
|
52
|
-
|
|
59
|
+
i > -1 && (d.splice(i, 1), t(d), n(d[0] || null));
|
|
53
60
|
},
|
|
54
|
-
children: /* @__PURE__ */ e(
|
|
55
|
-
|
|
61
|
+
children: /* @__PURE__ */ e(v, { children: /* @__PURE__ */ e(
|
|
62
|
+
f,
|
|
56
63
|
{
|
|
57
64
|
variant: "outlined",
|
|
58
65
|
className: "mds:h-16 mds:w-16 mds:text-error"
|
|
@@ -60,7 +67,7 @@ const w = ({
|
|
|
60
67
|
) })
|
|
61
68
|
}
|
|
62
69
|
)
|
|
63
|
-
] }) :
|
|
70
|
+
] }) : s
|
|
64
71
|
}
|
|
65
72
|
);
|
|
66
73
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("react/jsx-runtime"),z=require("./mainstack-design-system35.cjs"),S=require("./index-C8aODXfJ.cjs"),_=require("./utils-s-0cOrOT.cjs"),o=require("react"),m=({values:f,onValuesChange:C,defaultValues:a=[],isDisabled:r,accept:g={"file/*":[".pdf",".txt",".docx"]},maxFiles:s=4,maxSize:y,multiple:d=!0,onError:t,children:b,className:h,isError:i,...v})=>{const[n,u]=S.useControllableState({prop:f,defaultProp:a,onChange:C}),[x,l]=o.useState(null),U=o.useCallback(e=>{l(null),u(e)},[u]),F=o.useCallback(e=>{const c=e instanceof Error?e.message:"An error occurred";l(c),t&&t(e)},[t]),q=!d||n.length>=s,R=n.length>0&&q,j=o.Children.map(b,e=>o.isValidElement(e)&&e.type?.displayName==="FileUploaderDropzone"&&R?null:e);return p.jsx(z.FileUploaderContext.Provider,{value:{values:n,defaultValues:a,isDisabled:r,accept:g,maxFiles:s,maxSize:y,multiple:d,error:x,setError:l,onValuesChange:U,onError:F,isError:i},children:p.jsx("div",{"data-disabled":r,"aria-disabled":r,"data-error":i,"data-slot":"file-uploader-root",className:_.cn("mds:relative mds:flex mds:flex-col mds:gap-12 mds:body-font-family",h),...v,children:j})})};m.displayName="FileUploaderRoot";exports.FileUploaderRoot=m;
|