dynamic-mui 2.2.0 → 2.3.0
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/README.md +142 -5
- package/dist/accordion-DqBdGRim.mjs +23 -0
- package/dist/accordion-lvbD_BpX.js +1 -0
- package/dist/addressfield-CGX3UppE.mjs +152 -0
- package/dist/addressfield-DDG15fqJ.js +1 -0
- package/dist/asyncautocomplete-BAfBR9P7.mjs +89 -0
- package/dist/asyncautocomplete-w9q_1DWt.js +1 -0
- package/dist/bar-BzO7tvYJ.mjs +20 -0
- package/dist/bar-DEVxyUVS.js +1 -0
- package/dist/cascadeselect-C3QVfoig.mjs +64 -0
- package/dist/cascadeselect-DzbhK9en.js +1 -0
- package/dist/colorpicker-5qmEq7ZI.js +1 -0
- package/dist/colorpicker-DhNZulJY.mjs +98 -0
- package/dist/components/DynamicComponent.d.ts +2 -0
- package/dist/components/FormGenerator.d.ts +99 -10
- package/dist/components/controls/index.d.ts +45 -79
- package/dist/consentfield-B7Rm8d3U.js +1 -0
- package/dist/consentfield-CBQUR4J5.mjs +78 -0
- package/dist/datatable-BIQznwQe.mjs +20 -0
- package/dist/datatable-BWlcUP0M.js +1 -0
- package/dist/dynamic-mui.cjs +1 -0
- package/dist/dynamic-mui.mjs +32 -0
- package/dist/editabletable-DCoRmsEO.js +1 -0
- package/dist/editabletable-DRlBV8lk.mjs +126 -0
- package/dist/fileupload-ByBv1UjT.mjs +172 -0
- package/dist/fileupload-Cze3Oc_2.js +1 -0
- package/dist/formrepeater-BBkKGLFJ.mjs +71 -0
- package/dist/formrepeater-BxJzXoHx.js +1 -0
- package/dist/formwizard-BDZE1UDD.js +1 -0
- package/dist/formwizard-D2u1bMvK.mjs +83 -0
- package/dist/geofield-8WTeZk0Z.mjs +104 -0
- package/dist/geofield-Bw3p4NLJ.js +1 -0
- package/dist/group-B2mSylHd.mjs +23 -0
- package/dist/group-BlfO3ZZf.js +1 -0
- package/dist/imagelist-Bn9QhIv7.js +1 -0
- package/dist/imagelist-rqmJajHt.mjs +18 -0
- package/dist/index-CddjLTWF.mjs +12499 -0
- package/dist/index-D08GIfqF.js +43 -0
- package/dist/index.d.ts +9 -1
- package/dist/intlphone-B_Xn98pU.js +1 -0
- package/dist/intlphone-DtQZ12xk.mjs +140 -0
- package/dist/keyvaluefield-B_1NeGuP.mjs +125 -0
- package/dist/keyvaluefield-DyKCGd32.js +1 -0
- package/dist/line-B-DwR1hm.mjs +20 -0
- package/dist/line-BkymZu31.js +1 -0
- package/dist/lineitemlist-DGo8UOZC.js +1 -0
- package/dist/lineitemlist-vGKzJlQx.mjs +166 -0
- package/dist/list-7uNWrepS.mjs +20 -0
- package/dist/list-C0FgmtQw.js +1 -0
- package/dist/locationfield-CeUgxLkQ.mjs +119 -0
- package/dist/locationfield-Duyw1ZEz.js +1 -0
- package/dist/markdowneditor-B1y-hfny.mjs +90 -0
- package/dist/markdowneditor-Db0Un1_Z.js +2 -0
- package/dist/matrixfield-C7Sc-YpI.mjs +117 -0
- package/dist/matrixfield-CckODuPn.js +1 -0
- package/dist/mixChart-C3o184UT.js +1 -0
- package/dist/mixChart-ISf3Kbr-.mjs +75 -0
- package/dist/multitextbox-BYazIAeG.js +1 -0
- package/dist/multitextbox-ide2lvJ6.mjs +78 -0
- package/dist/npsscale-C2e88qk_.js +1 -0
- package/dist/npsscale-lndz7GEq.mjs +87 -0
- package/dist/numberstepper-DitbcvV9.mjs +128 -0
- package/dist/numberstepper-DyRjQM_K.js +1 -0
- package/dist/pie-CJSL8Sv5.js +1 -0
- package/dist/pie-CL29dlh5.mjs +20 -0
- package/dist/richtexteditor-CVg-MnKp.js +1 -0
- package/dist/richtexteditor-DsC1XC7h.mjs +141 -0
- package/dist/s3Upload-B0JeoLkS.js +1 -0
- package/dist/s3Upload-dpioZ2c8.mjs +51 -0
- package/dist/signature-14OrZriO.mjs +1225 -0
- package/dist/signature-D582X6tB.js +2 -0
- package/dist/stepper-B-FpcZvT.js +1 -0
- package/dist/stepper-CDfEy_C6.mjs +140 -0
- package/dist/summaryfield-B08ZmVHh.js +1 -0
- package/dist/summaryfield-CTpPlZBG.mjs +96 -0
- package/dist/tabs-BIliqFOs.js +1 -0
- package/dist/tabs-DDeJCFt8.mjs +39 -0
- package/dist/tagsinput-D-q6rRZS.mjs +58 -0
- package/dist/tagsinput-qh_lhdFb.js +1 -0
- package/dist/util/registry.d.ts +29 -0
- package/dist/util/resolvers.d.ts +45 -0
- package/dist/util/useFormEngine.d.ts +74 -0
- package/dist/util/validateSchema.d.ts +23 -0
- package/dist/v4-BysszJq8.mjs +30 -0
- package/dist/v4-CqdK_b8Y.js +1 -0
- package/package.json +36 -11
- package/dist/AxisSharedComponents-BbsKw1BT.js +0 -3
- package/dist/AxisSharedComponents-xLtpOLH_.mjs +0 -605
- package/dist/ChartsAxis-CANvBdY9.mjs +0 -47
- package/dist/ChartsAxis-EZ7m_KrU.js +0 -1
- package/dist/ChartsGrid-BCRTvNTr.js +0 -3
- package/dist/ChartsGrid-C_HT7qpL.mjs +0 -381
- package/dist/ChartsWrapper-CM7EDyAK.js +0 -5
- package/dist/ChartsWrapper-CO5_Z6BD.mjs +0 -1878
- package/dist/ChartsXAxis-CPmuCRhq.mjs +0 -487
- package/dist/ChartsXAxis-DFFY1sPg.js +0 -3
- package/dist/ChartsYAxis-DLUMr9vG.mjs +0 -392
- package/dist/ChartsYAxis-fpevi1sP.js +0 -1
- package/dist/XmlShapeDeserializer-3yQdm0b0.mjs +0 -237
- package/dist/XmlShapeDeserializer-XKJAoqLc.js +0 -1
- package/dist/clampAngle-BvZjnf53.mjs +0 -11
- package/dist/clampAngle-DpAsDoeT.js +0 -1
- package/dist/createSelector-B-9FwV16.mjs +0 -430
- package/dist/createSelector-f0oqn8Lr.js +0 -7
- package/dist/date-utils-CFUUt6NL.js +0 -4
- package/dist/date-utils-pGzaKb0p.mjs +0 -477
- package/dist/dynamic-mui.cjs.js +0 -1
- package/dist/dynamic-mui.es.js +0 -22
- package/dist/index--8Zky9Oh.js +0 -299
- package/dist/index-6WTs1Xy_.js +0 -1
- package/dist/index-B1R1akM2.js +0 -1
- package/dist/index-BW8_rRff.js +0 -7
- package/dist/index-BXFVK_GX.js +0 -1
- package/dist/index-B_KNUTjy.js +0 -1
- package/dist/index-BhaKvHkU.mjs +0 -62051
- package/dist/index-Bif92ima.js +0 -1
- package/dist/index-BnZOu8CL.js +0 -1
- package/dist/index-CDxpgRlR.mjs +0 -7
- package/dist/index-CThMfvtJ.mjs +0 -2555
- package/dist/index-CVqLvm8B.js +0 -1
- package/dist/index-CodJBIn6.mjs +0 -1665
- package/dist/index-Cr6Wp_S-.mjs +0 -3141
- package/dist/index-CslPwsrf.mjs +0 -4
- package/dist/index-CuV0MQzZ.mjs +0 -1173
- package/dist/index-DA0XouZs.mjs +0 -153
- package/dist/index-DKS5Sz9e.js +0 -14
- package/dist/index-DSkYYZuW.mjs +0 -4
- package/dist/index-DU78_FiA.js +0 -1
- package/dist/index-D_mYhgJ0.js +0 -10
- package/dist/index-DcWfyXJp.mjs +0 -92
- package/dist/index-Dlimbnxj.mjs +0 -2965
- package/dist/index-MllWgTJ5.mjs +0 -9372
- package/dist/index-in5z9hUb.js +0 -133
- package/dist/index-qUW7FnZ-.mjs +0 -20540
- package/dist/index.browser-BSu11T_q.mjs +0 -363
- package/dist/index.browser-By7-GABP.js +0 -4
- package/dist/isDeepEqual-BHfPvf9U.mjs +0 -393
- package/dist/isDeepEqual-CqxZGVRk.js +0 -1
- package/dist/loadCognitoIdentity-DtYTy-DW.js +0 -1
- package/dist/loadCognitoIdentity-DzdR91GB.mjs +0 -872
- package/dist/loadSts-Cic6UToN.mjs +0 -593
- package/dist/loadSts-csbFP6zX.js +0 -1
- package/dist/main.d.ts +0 -1
- package/dist/noAuth-B8ui2kBg.mjs +0 -71
- package/dist/noAuth-JPA2o4dt.js +0 -1
- package/dist/playground/AIContext.d.ts +0 -18
- package/dist/playground/AIPanel.d.ts +0 -10
- package/dist/playground/Builder.d.ts +0 -1
- package/dist/playground/Canvas.d.ts +0 -9
- package/dist/playground/DemoGallery.d.ts +0 -6
- package/dist/playground/PropertiesEditor.d.ts +0 -10
- package/dist/playground/Sidebar.d.ts +0 -9
- package/dist/playground/demoForms.d.ts +0 -3
- package/dist/playground/demoRecipes.d.ts +0 -15
- package/dist/playground/demoVariants.d.ts +0 -11
- package/dist/playground/documentation.d.ts +0 -6
- package/dist/playground/templates.d.ts +0 -7
- package/dist/playground/testData.d.ts +0 -2
- package/dist/test/setup.d.ts +0 -0
- package/dist/theme/theme.d.ts +0 -6
- package/dist/useAxis-DSbfEtO7.js +0 -3
- package/dist/useAxis-SiNBMMWq.mjs +0 -3010
- package/dist/useChartContainerProps-Bl3hO-r1.mjs +0 -5418
- package/dist/useChartContainerProps-C_C_PZoi.js +0 -12
- package/dist/useItemHighlightedGetter-9CIwqsGj.js +0 -1
- package/dist/useItemHighlightedGetter-CTISrNdV.mjs +0 -88
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),m=require("react"),p=require("@mui/material/Box"),h=require("@mui/material/Paper"),x=require("@mui/material/Divider"),g=require("@mui/material/IconButton"),j=require("@mui/material/Tooltip"),M=require("@mui/material/FormLabel"),q=require("@mui/material/FormControl"),S=require("@mui/icons-material/FormatBold"),R=require("@mui/icons-material/FormatItalic"),y=require("@mui/icons-material/FormatUnderlined"),E=require("@mui/icons-material/FormatListBulleted"),C=require("@mui/icons-material/FormatListNumbered"),L=require("@mui/icons-material/Link"),v=require("@mui/icons-material/FormatClear"),n=require("@mui/material/styles"),o=require("./index-D08GIfqF.js"),U=[{command:"bold",label:"Bold",icon:r.jsx(S,{fontSize:"small"})},{command:"italic",label:"Italic",icon:r.jsx(R,{fontSize:"small"})},{command:"underline",label:"Underline",icon:r.jsx(y,{fontSize:"small"})},{command:"insertUnorderedList",label:"Bulleted list",icon:r.jsx(E,{fontSize:"small"})},{command:"insertOrderedList",label:"Numbered list",icon:r.jsx(C,{fontSize:"small"})},{command:"createLink",label:"Insert link",icon:r.jsx(L,{fontSize:"small"}),prompt:!0},{command:"removeFormat",label:"Clear formatting",icon:r.jsx(v,{fontSize:"small"})}];function k({attributes:a={},onChange:u}){const{id:i="",label:s,minHeight:b=160,MuiAttributes:d={}}=a,l=m.useRef(null);m.useEffect(()=>{const e=l.current;if(!e)return;const t=a.value??"";e.innerHTML!==t&&(e.innerHTML=t)},[a.value]);const f=e=>{l.current?.focus();try{if(e.prompt){const t=window.prompt("Enter a URL");t&&document.execCommand(e.command,!1,t)}else document.execCommand(e.command)}catch{}l.current&&u?.({id:i,value:l.current.innerHTML})},I=e=>{u?.({id:i,value:e.currentTarget.innerHTML})};return r.jsxs(q,{fullWidth:!0,children:[s&&r.jsx(M,{sx:{mb:.75,fontWeight:500},component:"legend",children:s}),r.jsxs(h,{variant:"outlined",sx:e=>({borderRadius:`${o.PREMIUM_RADIUS+2}px`,borderColor:n.alpha(e.palette.text.primary,.12),overflow:"hidden",transition:`box-shadow .2s ${o.PREMIUM_EASING}, border-color .2s ${o.PREMIUM_EASING}`,"&:hover":{borderColor:n.alpha(e.palette.primary.main,.5),boxShadow:`0 2px 10px ${n.alpha(e.palette.common.black,.06)}`},"&:focus-within":{borderColor:e.palette.primary.main,boxShadow:`0 0 0 3px ${n.alpha(e.palette.primary.main,.16)}`}}),children:[r.jsx(p,{sx:e=>({display:"flex",flexWrap:"wrap",alignItems:"center",gap:.25,px:.75,py:.5,backgroundColor:n.alpha(e.palette.text.primary,.03)}),children:U.map((e,t)=>r.jsxs(m.Fragment,{children:[(t===3||t===5)&&r.jsx(x,{orientation:"vertical",flexItem:!0,sx:{mx:.25,my:.5}}),r.jsx(j,{title:e.label,children:r.jsx(g,{size:"small","aria-label":e.label,onMouseDown:c=>c.preventDefault(),onClick:()=>f(e),sx:c=>({borderRadius:`${o.PREMIUM_RADIUS-2}px`,transition:`background-color .18s ${o.PREMIUM_EASING}, transform .18s ${o.PREMIUM_EASING}`,"&:hover":{backgroundColor:n.alpha(c.palette.primary.main,.1),transform:"translateY(-1px)"}}),children:e.icon})})]},e.command))}),r.jsx(x,{}),r.jsx(p,{id:i,ref:l,role:"textbox","aria-multiline":"true","aria-label":s||"rich text",contentEditable:!0,suppressContentEditableWarning:!0,onInput:I,...d,sx:e=>({minHeight:b,px:1.75,py:1.25,outline:"none",lineHeight:1.6,color:e.palette.text.primary,backgroundColor:e.palette.background.paper,"& p":{margin:"0 0 0.5em"},"& ul, & ol":{paddingLeft:"1.5em",margin:"0 0 0.5em"},"& a":{color:e.palette.primary.main},...d.sx||{}})})]})]})}exports.default=k;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { jsxs as d, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import c from "react";
|
|
3
|
+
import u from "@mui/material/Box";
|
|
4
|
+
import I from "@mui/material/Paper";
|
|
5
|
+
import x from "@mui/material/Divider";
|
|
6
|
+
import L from "@mui/material/IconButton";
|
|
7
|
+
import y from "@mui/material/Tooltip";
|
|
8
|
+
import v from "@mui/material/FormLabel";
|
|
9
|
+
import S from "@mui/material/FormControl";
|
|
10
|
+
import R from "@mui/icons-material/FormatBold";
|
|
11
|
+
import k from "@mui/icons-material/FormatItalic";
|
|
12
|
+
import F from "@mui/icons-material/FormatUnderlined";
|
|
13
|
+
import M from "@mui/icons-material/FormatListBulleted";
|
|
14
|
+
import w from "@mui/icons-material/FormatListNumbered";
|
|
15
|
+
import T from "@mui/icons-material/Link";
|
|
16
|
+
import z from "@mui/icons-material/FormatClear";
|
|
17
|
+
import { alpha as t } from "@mui/material/styles";
|
|
18
|
+
import { P as l, d as b } from "./index-CddjLTWF.mjs";
|
|
19
|
+
const E = [
|
|
20
|
+
{ command: "bold", label: "Bold", icon: /* @__PURE__ */ o(R, { fontSize: "small" }) },
|
|
21
|
+
{ command: "italic", label: "Italic", icon: /* @__PURE__ */ o(k, { fontSize: "small" }) },
|
|
22
|
+
{ command: "underline", label: "Underline", icon: /* @__PURE__ */ o(F, { fontSize: "small" }) },
|
|
23
|
+
{ command: "insertUnorderedList", label: "Bulleted list", icon: /* @__PURE__ */ o(M, { fontSize: "small" }) },
|
|
24
|
+
{ command: "insertOrderedList", label: "Numbered list", icon: /* @__PURE__ */ o(w, { fontSize: "small" }) },
|
|
25
|
+
{ command: "createLink", label: "Insert link", icon: /* @__PURE__ */ o(T, { fontSize: "small" }), prompt: !0 },
|
|
26
|
+
{ command: "removeFormat", label: "Clear formatting", icon: /* @__PURE__ */ o(z, { fontSize: "small" }) }
|
|
27
|
+
];
|
|
28
|
+
function V({ attributes: a = {}, onChange: s }) {
|
|
29
|
+
const { id: i = "", label: m, minHeight: g = 160, MuiAttributes: f = {} } = a, n = c.useRef(null);
|
|
30
|
+
c.useEffect(() => {
|
|
31
|
+
const r = n.current;
|
|
32
|
+
if (!r) return;
|
|
33
|
+
const e = a.value ?? "";
|
|
34
|
+
r.innerHTML !== e && (r.innerHTML = e);
|
|
35
|
+
}, [a.value]);
|
|
36
|
+
const h = (r) => {
|
|
37
|
+
n.current?.focus();
|
|
38
|
+
try {
|
|
39
|
+
if (r.prompt) {
|
|
40
|
+
const e = window.prompt("Enter a URL");
|
|
41
|
+
e && document.execCommand(r.command, !1, e);
|
|
42
|
+
} else
|
|
43
|
+
document.execCommand(r.command);
|
|
44
|
+
} catch {
|
|
45
|
+
}
|
|
46
|
+
n.current && s?.({ id: i, value: n.current.innerHTML });
|
|
47
|
+
}, C = (r) => {
|
|
48
|
+
s?.({ id: i, value: r.currentTarget.innerHTML });
|
|
49
|
+
};
|
|
50
|
+
return /* @__PURE__ */ d(S, { fullWidth: !0, children: [
|
|
51
|
+
m && /* @__PURE__ */ o(v, { sx: { mb: 0.75, fontWeight: 500 }, component: "legend", children: m }),
|
|
52
|
+
/* @__PURE__ */ d(
|
|
53
|
+
I,
|
|
54
|
+
{
|
|
55
|
+
variant: "outlined",
|
|
56
|
+
sx: (r) => ({
|
|
57
|
+
borderRadius: `${b + 2}px`,
|
|
58
|
+
borderColor: t(r.palette.text.primary, 0.12),
|
|
59
|
+
overflow: "hidden",
|
|
60
|
+
transition: `box-shadow .2s ${l}, border-color .2s ${l}`,
|
|
61
|
+
"&:hover": {
|
|
62
|
+
borderColor: t(r.palette.primary.main, 0.5),
|
|
63
|
+
boxShadow: `0 2px 10px ${t(r.palette.common.black, 0.06)}`
|
|
64
|
+
},
|
|
65
|
+
"&:focus-within": {
|
|
66
|
+
borderColor: r.palette.primary.main,
|
|
67
|
+
boxShadow: `0 0 0 3px ${t(r.palette.primary.main, 0.16)}`
|
|
68
|
+
}
|
|
69
|
+
}),
|
|
70
|
+
children: [
|
|
71
|
+
/* @__PURE__ */ o(
|
|
72
|
+
u,
|
|
73
|
+
{
|
|
74
|
+
sx: (r) => ({
|
|
75
|
+
display: "flex",
|
|
76
|
+
flexWrap: "wrap",
|
|
77
|
+
alignItems: "center",
|
|
78
|
+
gap: 0.25,
|
|
79
|
+
px: 0.75,
|
|
80
|
+
py: 0.5,
|
|
81
|
+
backgroundColor: t(r.palette.text.primary, 0.03)
|
|
82
|
+
}),
|
|
83
|
+
children: E.map((r, e) => /* @__PURE__ */ d(c.Fragment, { children: [
|
|
84
|
+
(e === 3 || e === 5) && /* @__PURE__ */ o(x, { orientation: "vertical", flexItem: !0, sx: { mx: 0.25, my: 0.5 } }),
|
|
85
|
+
/* @__PURE__ */ o(y, { title: r.label, children: /* @__PURE__ */ o(
|
|
86
|
+
L,
|
|
87
|
+
{
|
|
88
|
+
size: "small",
|
|
89
|
+
"aria-label": r.label,
|
|
90
|
+
onMouseDown: (p) => p.preventDefault(),
|
|
91
|
+
onClick: () => h(r),
|
|
92
|
+
sx: (p) => ({
|
|
93
|
+
borderRadius: `${b - 2}px`,
|
|
94
|
+
transition: `background-color .18s ${l}, transform .18s ${l}`,
|
|
95
|
+
"&:hover": {
|
|
96
|
+
backgroundColor: t(p.palette.primary.main, 0.1),
|
|
97
|
+
transform: "translateY(-1px)"
|
|
98
|
+
}
|
|
99
|
+
}),
|
|
100
|
+
children: r.icon
|
|
101
|
+
}
|
|
102
|
+
) })
|
|
103
|
+
] }, r.command))
|
|
104
|
+
}
|
|
105
|
+
),
|
|
106
|
+
/* @__PURE__ */ o(x, {}),
|
|
107
|
+
/* @__PURE__ */ o(
|
|
108
|
+
u,
|
|
109
|
+
{
|
|
110
|
+
id: i,
|
|
111
|
+
ref: n,
|
|
112
|
+
role: "textbox",
|
|
113
|
+
"aria-multiline": "true",
|
|
114
|
+
"aria-label": m || "rich text",
|
|
115
|
+
contentEditable: !0,
|
|
116
|
+
suppressContentEditableWarning: !0,
|
|
117
|
+
onInput: C,
|
|
118
|
+
...f,
|
|
119
|
+
sx: (r) => ({
|
|
120
|
+
minHeight: g,
|
|
121
|
+
px: 1.75,
|
|
122
|
+
py: 1.25,
|
|
123
|
+
outline: "none",
|
|
124
|
+
lineHeight: 1.6,
|
|
125
|
+
color: r.palette.text.primary,
|
|
126
|
+
backgroundColor: r.palette.background.paper,
|
|
127
|
+
"& p": { margin: "0 0 0.5em" },
|
|
128
|
+
"& ul, & ol": { paddingLeft: "1.5em", margin: "0 0 0.5em" },
|
|
129
|
+
"& a": { color: r.palette.primary.main },
|
|
130
|
+
...f.sx || {}
|
|
131
|
+
})
|
|
132
|
+
}
|
|
133
|
+
)
|
|
134
|
+
]
|
|
135
|
+
}
|
|
136
|
+
)
|
|
137
|
+
] });
|
|
138
|
+
}
|
|
139
|
+
export {
|
|
140
|
+
V as default
|
|
141
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var y=Object.create;var u=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var f=Object.getPrototypeOf,R=Object.prototype.hasOwnProperty;var E=(t,o,e,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of C(o))!R.call(t,n)&&n!==e&&u(t,n,{get:()=>o[n],enumerable:!(r=S(o,n))||r.enumerable});return t};var h=(t,o,e)=>(e=t!=null?y(f(t)):{},E(o||!t||!t.__esModule?u(e,"default",{value:t,enumerable:!0}):e,t));function P(t){const o=(t||"").split(","),e=o[0]?.match(/:(.*?);/);if(o.length<2||!e)throw new Error('uploadToS3: expected a base64 data URL (e.g. "data:image/png;base64,…").');const r=e[1],n=atob(o[1]);let s=n.length;const a=new Uint8Array(s);for(;s--;)a[s]=n.charCodeAt(s);return new Blob([a],{type:r})}async function U(t,o,e,r,n,s=""){if(!n||!e||!r)return console.warn("Missing AWS Config (Pool ID, Bucket, or Region). Returning data URL as fallback."),t;try{let a,i;try{[a,i]=await Promise.all([import("@aws-sdk/client-s3"),import("@aws-sdk/credential-providers")])}catch{throw new Error("uploadToS3 needs the optional AWS SDK. Install it with: npm i @aws-sdk/client-s3 @aws-sdk/credential-providers")}const{S3Client:p,PutObjectCommand:w}=a,{fromCognitoIdentityPool:m}=i,b=new p({region:r,credentials:m({clientConfig:{region:r},identityPoolId:n}),requestChecksumCalculation:"WHEN_REQUIRED",forcePathStyle:!0}),l=P(t);let c=s.trim();c&&!c.endsWith("/")&&(c+="/");const d=c?`${c}${o}`:`signatures/${o}`,g=new w({Bucket:e,Key:d,Body:l,ContentType:l.type});return await b.send(g),`https://${e}/${d}`}catch(a){throw console.error("Error uploading to S3:",a),a}}exports.uploadToS3=U;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
function b(c) {
|
|
2
|
+
const e = (c || "").split(","), o = e[0]?.match(/:(.*?);/);
|
|
3
|
+
if (e.length < 2 || !o)
|
|
4
|
+
throw new Error('uploadToS3: expected a base64 data URL (e.g. "data:image/png;base64,…").');
|
|
5
|
+
const r = o[1], a = atob(e[1]);
|
|
6
|
+
let n = a.length;
|
|
7
|
+
const t = new Uint8Array(n);
|
|
8
|
+
for (; n--; )
|
|
9
|
+
t[n] = a.charCodeAt(n);
|
|
10
|
+
return new Blob([t], { type: r });
|
|
11
|
+
}
|
|
12
|
+
async function y(c, e, o, r, a, n = "") {
|
|
13
|
+
if (!a || !o || !r)
|
|
14
|
+
return console.warn("Missing AWS Config (Pool ID, Bucket, or Region). Returning data URL as fallback."), c;
|
|
15
|
+
try {
|
|
16
|
+
let t, i;
|
|
17
|
+
try {
|
|
18
|
+
[t, i] = await Promise.all([
|
|
19
|
+
import("@aws-sdk/client-s3"),
|
|
20
|
+
import("@aws-sdk/credential-providers")
|
|
21
|
+
]);
|
|
22
|
+
} catch {
|
|
23
|
+
throw new Error("uploadToS3 needs the optional AWS SDK. Install it with: npm i @aws-sdk/client-s3 @aws-sdk/credential-providers");
|
|
24
|
+
}
|
|
25
|
+
const { S3Client: u, PutObjectCommand: h } = t, { fromCognitoIdentityPool: p } = i, w = new u({
|
|
26
|
+
region: r,
|
|
27
|
+
credentials: p({
|
|
28
|
+
clientConfig: { region: r },
|
|
29
|
+
identityPoolId: a
|
|
30
|
+
}),
|
|
31
|
+
requestChecksumCalculation: "WHEN_REQUIRED",
|
|
32
|
+
forcePathStyle: !0
|
|
33
|
+
}), l = b(c);
|
|
34
|
+
let s = n.trim();
|
|
35
|
+
s && !s.endsWith("/") && (s += "/");
|
|
36
|
+
const d = s ? `${s}${e}` : `signatures/${e}`, m = new h({
|
|
37
|
+
Bucket: o,
|
|
38
|
+
Key: d,
|
|
39
|
+
Body: l,
|
|
40
|
+
ContentType: l.type
|
|
41
|
+
// Depending on your bucket policy, you might need ACL: 'public-read'
|
|
42
|
+
// ACL: 'public-read',
|
|
43
|
+
});
|
|
44
|
+
return await w.send(m), `https://${o}/${d}`;
|
|
45
|
+
} catch (t) {
|
|
46
|
+
throw console.error("Error uploading to S3:", t), t;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
y as u
|
|
51
|
+
};
|