@infinityfx/fluid 1.4.23 → 1.4.24
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/bin/compile.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"fs";import{unlink as s}from"fs/promises";import{compileFile as o,emitCss as t}from"./core.js";import{getContext as r,printProgress as i}from"./utils.js";import{glob as c}from"glob";async function a(e){const{theme:s}=await r();let o=Array.from(new Set([...Object.keys(s.palettes),"light","dark","system"]).keys()),t=e.source("./types/src/types.d.ts");t=t.replace(/(FluidColorScheme\s*=\s*).+?(;)/,`$1${o.map((e=>`'${e}'`)).join(" | ")}$2`),e.override("./types/src/types.d.ts",t)}async function n(e){const{icons:s,rawConfig:o}=await r();let t=e.source("./core/icons.js");for(const e in s)t=t.replace(new RegExp(`${e}:\\w+(,|\\})`),`${e}:${s[e].name}$1`);t=Array.from(o.matchAll(/import\s*(.+?)from\s*(?:"|')([^"']+)(?:"|')/g)).concat(Array.from(o.matchAll(/(?:const|let|var)\s*(.+?)\s*=\s*require\((?:'|")([^"']+)(?:"|')/g))).map((([e,s,o])
|
|
1
|
+
import e from"fs";import{unlink as s}from"fs/promises";import{compileFile as o,emitCss as t}from"./core.js";import{getContext as r,printProgress as i}from"./utils.js";import{glob as c}from"glob";async function a(e){const{theme:s}=await r();let o=Array.from(new Set([...Object.keys(s.palettes),"light","dark","system"]).keys()),t=e.source("./types/src/types.d.ts");t=t.replace(/(FluidColorScheme\s*=\s*).+?(;)/,`$1${o.map((e=>`'${e}'`)).join(" | ")}$2`),e.override("./types/src/types.d.ts",t)}async function n(e){const{icons:s,rawConfig:o}=await r();let t=e.source("./core/icons.js");for(const e in s)t=t.replace(new RegExp(`${e}:\\w+(,|\\})`),`${e}:${s[e].name}$1`);t=Array.from(o.matchAll(/import\s*(.+?)from\s*(?:"|')([^"']+)(?:"|')/g)).concat(Array.from(o.matchAll(/(?:const|let|var)\s*(.+?)\s*=\s*require\((?:'|")([^"']+)(?:"|')/g))).map((([e,s,o])=>/^(\.|\\|\/)/.test(o)?null:`import ${s.replace(/:/g," as ")} from "${o}";`)).filter((e=>null!==e)).join("")+t,e.output("./core/icons.js",t)}async function l(o,t){for(const{file:e}of t){const s=o.source(e).replace(/\.\/compiled/g,"");o.override(e,s)}const r=await c(o.root+"compiled/*.css");await Promise.all(r.map(s)),e.cpSync(o.root+"dist/",o.root+"compiled/",{recursive:!0,filter:e=>!/((bin|styles|types)$|\.map$)/.test(e)})}async function m(e,s,c){(await r()).styles={};for(const{file:t,shallow:r,inject:a}of s){const s=e.source(t);if(!r){let t,r=Array.from(s.matchAll(/as\s*(.+?)\s*\}\s*from\s*(?:'|")(.+?)(?:'|");/g)),n=0,l=r.length;for(;t=r.shift();){const[s,m,f]=t;if(r.length>0&&m===a)r.push(t);else{if(/index.js$/.test(f)){const s=await e.module(f);for(const t in s)await o(e,`${m}.${t}`,f.replace(/index\.js$/,`${t.toLowerCase()}.js`))}else await o(e,m,f,m===a);i(c.index/c.entries+ ++n/l/c.entries)}}}e.override(t,s.replace(/(from\s*(?:'|"))\.\/(.*?(?:'|");)/g,"$1../compiled/$2"))}await t(e,c,"fluid"!==e.parent)}export{m as compileComponents,n as compileIcons,a as compileTypes,l as purge};
|
|
2
2
|
//# sourceMappingURL=compile.js.map
|
package/dist/bin/compile.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile.js","sources":["../../../bin/compile.ts"],"sourcesContent":[null],"names":["async","compileTypes","io","theme","getContext","palettes","Array","from","Set","Object","keys","types","source","replace","map","name","join","override","compileIcons","icons","rawConfig","contents","icon","RegExp","matchAll","concat","_","value","path","output","purge","entries","file","content","files","glob","root","Promise","all","unlink","fs","cpSync","recursive","
|
|
1
|
+
{"version":3,"file":"compile.js","sources":["../../../bin/compile.ts"],"sourcesContent":[null],"names":["async","compileTypes","io","theme","getContext","palettes","Array","from","Set","Object","keys","types","source","replace","map","name","join","override","compileIcons","icons","rawConfig","contents","icon","RegExp","matchAll","concat","_","value","path","test","filter","val","output","purge","entries","file","content","files","glob","root","Promise","all","unlink","fs","cpSync","recursive","src","compileComponents","stats","styles","shallow","inject","entry","imports","j","len","length","shift","push","parent","module","subName","compileFile","toLowerCase","printProgress","index","emitCss"],"mappings":"mMAOOA,eAAeC,EAAaC,GAC/B,MAAMC,MAAEA,SAAgBC,IAExB,IAAIC,EAAWC,MAAMC,KAAK,IAAIC,IAAI,IAAIC,OAAOC,KAAKP,EAAME,UAAW,QAAS,OAAQ,WAAWK,QAC3FC,EAAQT,EAAGU,OAAO,0BAEtBD,EAAQA,EAAME,QAAQ,kCAAmC,KAAKR,EAASS,KAAIC,GAAQ,IAAIA,OAASC,KAAK,YAErGd,EAAGe,SAAS,yBAA0BN,EAC1C,CAEOX,eAAekB,EAAahB,GAC/B,MAAMiB,MAAEA,EAAKC,UAAEA,SAAoBhB,IAEnC,IAAIiB,EAAWnB,EAAGU,OAAO,mBAEzB,IAAK,MAAMU,KAAQH,EACfE,EAAWA,EAASR,QAAQ,IAAIU,OAAO,GAAGD,iBAAqB,GAAGA,KAASH,EAAMG,GAA2BP,UAMhHM,EAHgBf,MAAMC,KAAKa,EAAUI,SAAS,iDACzCC,OAAOnB,MAAMC,KAAKa,EAAUI,SAAS,sEAGrCV,KAAI,EAAEY,EAAGC,EAAOC,KACN,cAAcC,KAAKD,GAAQ,KAAO,UAAUD,EAAMd,QAAQ,KAAM,iBAAiBe,QAE3FE,QAAOC,GAAe,OAARA,IACdf,KAAK,IAAMK,EAEhBnB,EAAG8B,OAAO,kBAAmBX,EACjC,CAEOrB,eAAeiC,EAAM/B,EAAcgC,GAGtC,IAAK,MAAMC,KAAEA,KAAUD,EAAS,CAC5B,MAAME,EAAUlC,EAAGU,OAAOuB,GAAMtB,QAAQ,gBAAiB,IACzDX,EAAGe,SAASkB,EAAMC,EACtB,CAEA,MAAMC,QAAcC,EAAKpC,EAAGqC,KAAO,wBAC7BC,QAAQC,IAAIJ,EAAMvB,IAAI4B,IAE5BC,EAAGC,OAAO1C,EAAGqC,KAAO,QAASrC,EAAGqC,KAAO,YAAa,CAChDM,WAAW,EACXf,OAAOgB,IACK,+BAA+BjB,KAAKiB,IAGxD,CAEO9C,eAAe+C,EAAkB7C,EAAcgC,EAIjDc,UACqB5C,KACd6C,OAAS,CAAA,EAEjB,IAAK,MAAMd,KAAEA,EAAIe,QAAEA,EAAOC,OAAEA,KAAYjB,EAAS,CAC7C,MAAME,EAAUlC,EAAGU,OAAOuB,GAE1B,IAAKe,EAAS,CACV,IACIE,EADAC,EAAU/C,MAAMC,KAAK6B,EAAQZ,SAAS,mDAC/B8B,EAAI,EAAGC,EAAMF,EAAQG,OAEhC,KAAOJ,EAAQC,EAAQI,SAAS,CAC5B,MAAO/B,EAAGX,EAAMa,GAAQwB,EAExB,GAAIC,EAAQG,OAAS,GAAKzC,IAASoC,EAC/BE,EAAQK,KAAKN,OADjB,CAKA,GAAI,YAAYvB,KAAKD,GAAO,CACxB,MAAM+B,QAAezD,EAAG0D,OAAOhC,GAE/B,IAAK,MAAMiC,KAAWF,QACZG,EAAY5D,EAAI,GAAGa,KAAQ8C,IAAWjC,EAAKf,QAAQ,aAAc,GAAGgD,EAAQE,oBAE1F,YACUD,EAAY5D,EAAIa,EAAMa,EAAMb,IAASoC,GAG/Ca,EAAehB,EAAMiB,MAAQjB,EAAMd,WAAcoB,EAAIC,EAAOP,EAAMd,QAZlE,CAaJ,CACJ,CAEAhC,EAAGe,SAASkB,EAAMC,EAAQvB,QAAQ,qCAAsC,oBAC5E,OAEMqD,EAAQhE,EAAI8C,EAAqB,UAAd9C,EAAGyD,OAChC"}
|
package/dist/bin/utils.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import o from"fs";import{readFile as e}from"fs/promises";import t from"readline";import{glob as n}from"glob";import{mergeRecursive as s}from"../core/utils.js";import{GLOBAL_CONTEXT as i}from"../core/shared.js";function r(o){t.cursorTo(process.stdout,0),process.stdout.write(`${(100*o).toFixed(1)}% `+new Array(Math.round(40*o)).fill("=").join(""))}const c=o=>({index:0,entries:o,start:performance.now(),compiled:0,files:[]});function a(o){console.log("\n"),console.log(`Compiled [1m${o.compiled}[0m components in [1m${((performance.now()-o.start)/1e3).toFixed(2)}[0m sec.`),console.log(),console.log("[4mFile[0m [4mSize[0m"),o.files.forEach((({name:o,size:e})=>console.log(`${o.padEnd(41," ")}${(e/1024).toFixed(1)}kb`))),console.log("")}function l(o,e,t="{}"){let n=1;for(;n>0;)o.charAt(e)==t.charAt(0)&&n++,o.charAt(e)==t.charAt(1)&&n--,n>0&&e++;return e}function m(o,e,t,n){return o.slice(0,e)+n+o.slice(t)}function p(o){return["core(\\/|\\\\)style\\.js","(\\/|\\\\)fluid(\\/|\\\\)css","styles(\\/|\\\\).+?"].map((o=>new RegExp(`import[^;]*?${o}("|');?`,"g"))).forEach((e=>o=o.replace(e,""))),o}const d=o=>o.replace(/^\s+|\s+(as\s+.+)?$/g,"").replace(/\.\w+$/,"").replace(/([a-z])([A-Z])/,"$1-$2").toLowerCase();function f(o,e){return Array.from(o.matchAll(new RegExp(`import\\s*(?:\\{([^\\}]+)\\}|\\*\\s+as.*|\\w+)\\s*from\\s*(?:'|")@infinityfx\\/${e}(?:'|")`,"g"))).map((([o,e])=>e?e.split(",").map(d):null)).flat()}let u;async function g(t){if(!u){const[t]=await n("./fluid.config.{js,mjs}");try{const[r,c,a]=await Promise.all([t&&import(`file://${process.cwd()}/${t}?nonce=${Math.random()}`),t&&e(process.cwd()+`/${t}`,{encoding:"ascii"}),n(["./node_modules/@infinityfx/fluid/package.json","./package.json"])]);r&&c&&(u=r.default,i.theme=s(u.theme,i.theme),i.components=u.components||{},i.paths=u.paths||i.paths,i.cssOutput=u.cssOutput||i.cssOutput,i.icons=u.icons||{},i.rawConfig=c);const l=a.length>1?a.find((o=>o.startsWith("node_modules"))):a[0],{name:m,version:p}=JSON.parse(o.readFileSync(l,{encoding:"ascii"}));i.name=m,i.version=p,i.isInternal=a.length<2}catch{console.log(),console.log(`Your ${t} could not be loaded.`)}}return void 0!==t&&(i.isDev=t),i}function h(e,t=!1){const n=t&&/@infinityfx\/fluid\/$/.test(e)?"./":e;return o.existsSync(n)?{root:n,parent:e.match(/.+\/(.+)\/$/)?.[1]||"",timestamp:Date.now(),module:async o=>(await import(`file://${process.cwd()}/${n}dist/${o}?nonce=${Math.random()}`)).default,source:e=>o.readFileSync(n+"dist/"+e,{encoding:"ascii"}),output(e,t){o.writeFileSync(n+"compiled/"+e,t)},override(e,t){o.writeFileSync(n+"dist/"+e,t)}}:null}export{c as emptyStats,f as extractImports,g as getContext,h as getIOHelper,d as keyFromImport,l as matchBrackets,r as printProgress,a as printStats,m as replace,p as stripImports};
|
|
2
2
|
//# sourceMappingURL=utils.js.map
|
package/dist/bin/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../bin/utils.ts"],"sourcesContent":[null],"names":["printProgress","progress","readline","cursorTo","process","stdout","write","toFixed","Array","Math","round","fill","join","emptyStats","entries","index","start","performance","now","compiled","files","printStats","stats","console","log","forEach","name","size","padEnd","matchBrackets","content","type","count","charAt","replace","from","to","by","slice","stripImports","map","val","RegExp","pattern","keyFromImport","str","toLowerCase","extractImports","namespace","matchAll","_","names","split","flat","config","async","getContext","isDev","configFile","glob","conf","rawConfig","Promise","all","import","cwd","random","readFile","encoding","default","GLOBAL_CONTEXT","theme","mergeRecursive","components","paths","cssOutput","icons","file","length","find","startsWith","version","JSON","parse","fs","readFileSync","isInternal","undefined","getIOHelper","base","root","test","existsSync","parent","match","timestamp","Date","source","output","writeFileSync","override"],"mappings":"kNAOM,SAAUA,EAAcC,GAC1BC,EAASC,SAASC,QAAQC,OAAQ,GAClCD,QAAQC,OAAOC,MAAM,IAAe,IAAXL,GAAgBM,QAAQ,OAAS,IAAIC,MAAMC,KAAKC,MAAiB,GAAXT,IAAgBU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,IAAIC,EAEGC,eAAeC,EAAWC,GAC7B,IAAKH,EAAQ,CACT,MAAOI,SAAoBC,EAAK,2BAEhC,IACI,MAAOC,EAAMC,EAAWzC,SAAe0C,QAAQC,IAAI,CAC/CL,GAAcM,OAAO,UAAU5D,QAAQ6D,SAASP,WAAoBjD,KAAKyD,YACzER,GAAcS,EAAS/D,QAAQ6D,MAAQ,IAAIP,IAAc,CAAEU,SAAU,UACrET,EAAK,CAAC,gDAAiD,qBAGvDC,GAAQC,IACRP,EAASM,EAAKS,QACdC,EAAeC,MAAQC,EAAelB,EAAOiB,MAAOD,EAAeC,OACnED,EAAeG,WAAanB,EAAOmB,YAAc,CAAA,EACjDH,EAAeI,MAAQpB,EAAOoB,OAASJ,EAAeI,MACtDJ,EAAeK,UAAYrB,EAAOqB,WAAaL,EAAeK,UAC9DL,EAAeM,MAAQtB,EAAOsB,OAAS,CAAA,EACvCN,EAAeT,UAAYA,GAG/B,MAAMgB,EAAOzD,EAAM0D,OAAS,EACxB1D,EAAM2D,MAAKF,GAAQA,EAAKG,WAAW,kBACnC5D,EAAM,IACJM,KAAEA,EAAIuD,QAAEA,GAAYC,KAAKC,MAAMC,EAAGC,aAAaR,EAAM,CAAET,SAAU,WAEvEE,EAAe5C,KAAOA,EACtB4C,EAAeW,QAAUA,EACzBX,EAAegB,WAAalE,EAAM0D,OAAS,CAC/C,CAAE,
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../bin/utils.ts"],"sourcesContent":[null],"names":["printProgress","progress","readline","cursorTo","process","stdout","write","toFixed","Array","Math","round","fill","join","emptyStats","entries","index","start","performance","now","compiled","files","printStats","stats","console","log","forEach","name","size","padEnd","matchBrackets","content","type","count","charAt","replace","from","to","by","slice","stripImports","map","val","RegExp","pattern","keyFromImport","str","toLowerCase","extractImports","namespace","matchAll","_","names","split","flat","config","async","getContext","isDev","configFile","glob","conf","rawConfig","Promise","all","import","cwd","random","readFile","encoding","default","GLOBAL_CONTEXT","theme","mergeRecursive","components","paths","cssOutput","icons","file","length","find","startsWith","version","JSON","parse","fs","readFileSync","isInternal","undefined","getIOHelper","base","root","test","existsSync","parent","match","timestamp","Date","source","output","writeFileSync","override"],"mappings":"kNAOM,SAAUA,EAAcC,GAC1BC,EAASC,SAASC,QAAQC,OAAQ,GAClCD,QAAQC,OAAOC,MAAM,IAAe,IAAXL,GAAgBM,QAAQ,OAAS,IAAIC,MAAMC,KAAKC,MAAiB,GAAXT,IAAgBU,KAAK,KAAKC,KAAK,IAClH,OAaaC,EAAcC,IAAe,CACtCC,MAAO,EACPD,UACAE,MAAOC,YAAYC,MACnBC,SAAU,EACVC,MAAO,KAGL,SAAUC,EAAWC,GACvBC,QAAQC,IAAI,MACZD,QAAQC,IAAI,gBAAmBF,EAAMH,oCAA0CF,YAAYC,MAAQI,EAAMN,OAAS,KAAMT,QAAQ,eAChIgB,QAAQC,MACRD,QAAQC,IAAI,iEACZF,EAAMF,MAAMK,SAAQ,EAAGC,OAAMC,UAAWJ,QAAQC,IAAI,GAAGE,EAAKE,OAAO,GAAI,QAAQD,EAAO,MAAMpB,QAAQ,UACpGgB,QAAQC,IAAI,GAChB,CAEM,SAAUK,EAAcC,EAAiBd,EAAee,EAA2B,MACrF,IAAIC,EAAQ,EAEZ,KAAOA,EAAQ,GACPF,EAAQG,OAAOjB,IAAUe,EAAKE,OAAO,IAAID,IACzCF,EAAQG,OAAOjB,IAAUe,EAAKE,OAAO,IAAID,IACzCA,EAAQ,GAAGhB,IAGnB,OAAOA,CACX,CAEM,SAAUkB,EAAQJ,EAAiBK,EAAcC,EAAYC,GAC/D,OAAOP,EAAQQ,MAAM,EAAGH,GAAQE,EAAKP,EAAQQ,MAAMF,EACvD,CAEM,SAAUG,EAAaT,GAKzB,MAJA,CAAC,2BAA4B,+BAAgC,uBACxDU,KAAIC,GAAO,IAAIC,OAAO,eAAeD,WAAc,OACnDhB,SAAQkB,GAAWb,EAAUA,EAAQI,QAAQS,EAAS,MAEpDb,CACX,OAEac,EAAiB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b,MAAQA,GAEzCa,CACX,UAYgBkB,EAAYC,EAAcH,GAAa,GACnD,MAAMI,EAAOJ,GAAc,wBAAwBK,KAAKF,GAAQ,KAAOA,EAEvE,OAAKL,EAAGQ,WAAWF,GAEZ,CACHA,OACAG,OAAQJ,EAAKK,MAAM,iBAAiB,IAAM,GAC1CC,UAAWC,KAAK9E,MAChBqC,OAAY,MAACsB,UACKb,OAAO,UAAU5D,QAAQ6D,SAASyB,SAAYb,WAAcpE,KAAKyD,aAAaG,QAEhG4B,OAAOpB,GACIO,EAAGC,aAAaK,EAAO,QAAUb,EAAM,CAAET,SAAU,UAE9D,MAAA8B,CAAOrB,EAAc/C,GACjBsD,EAAGe,cAAcT,EAAO,YAAcb,EAAM/C,EAChD,EACA,QAAAsE,CAASvB,EAAc/C,GACnBsD,EAAGe,cAAcT,EAAO,QAAUb,EAAM/C,EAC5C,GAjB6B,IAmBrC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as r,Fragment as o}from"react/jsx-runtime";import{useRef as n,useState as i}from"react";import a from"./button.js";import t from"../../hooks/use-input-props.js";import{combineClasses as l,classes as c,combineRefs as s}from"../../core/utils.js";import{createStyles as d}from"../../core/style.js";import{Icon as p}from"../../core/icons.js";import"../feedback/progress-bar.js";import"../feedback/circular-progress.js";import f from"../feedback/spinner.js";import m from"../feedback/halo.js";import"../feedback/indicator.js";import"../feedback/skeleton.js";const g=d("drop-zone",{".zone":{overflow:"hidden",position:"relative",display:"grid",backgroundColor:"var(--f-clr-fg-100)",border:"dashed 1px var(--f-clr-fg-200)",borderRadius:"var(--f-radius-med)",transition:"background-color .25s, border-color .25s, color .25s",userSelect:"none",WebkitTapHighlightColor:"transparent"},'.zone[aria-disabled="false"]':{cursor:"pointer"},".zone.hovering":{backgroundColor:"var(--f-clr-primary-600)",borderColor:"var(--f-clr-primary-100)"},".zone.filled":{borderStyle:"solid"},".zone.error, .zone.rejected":{borderColor:"var(--f-clr-error-100)",color:"var(--f-clr-error-100)"},".zone.rejected":{backgroundColor:"var(--f-clr-error-400)"},".zone.disabled":{color:"var(--f-clr-grey-500)"},".container":{display:"flex",flexDirection:"column",gridArea:"1 / 1"},".preview":{position:"relative",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"var(--f-clr-bg-100)",padding:"var(--f-spacing-med)",flexGrow:1},".footer":{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"var(--f-spacing-sml)",gap:"var(--f-spacing-sml)"},".text":{display:"flex",alignItems:"baseline",gap:"var(--f-spacing-xsm)"},".annotation":{paddingTop:"var(--f-spacing-xxs)",color:"var(--f-clr-grey-600)",fontSize:"var(--f-font-size-xsm)"},".icon":{paddingBottom:"var(--f-spacing-sml)"},".image":{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover",zIndex:1},".container.centered":{alignItems:"center",justifyContent:"center",textAlign:"center",padding:"var(--f-spacing-lrg)"},".input":{position:"absolute",opacity:0,pointerEvents:"none"}});function v(e,r){const o=r?r.split(","):[];return!o.length||o.some((r=>e.type.includes(r.trim().replace(/\/\*$/,""))))}function u({cc:d={},loading:u=!1,error:b,text:h="Drop files or click to browse",annotation:y,icon:x,previewImages:j=!1,inputRef:
|
|
2
|
+
import{jsx as e,jsxs as r,Fragment as o}from"react/jsx-runtime";import{useRef as n,useState as i}from"react";import a from"./button.js";import t from"../../hooks/use-input-props.js";import{combineClasses as l,classes as c,combineRefs as s}from"../../core/utils.js";import{createStyles as d}from"../../core/style.js";import{Icon as p}from"../../core/icons.js";import"../feedback/progress-bar.js";import"../feedback/circular-progress.js";import f from"../feedback/spinner.js";import m from"../feedback/halo.js";import"../feedback/indicator.js";import"../feedback/skeleton.js";const g=d("drop-zone",{".zone":{overflow:"hidden",position:"relative",display:"grid",backgroundColor:"var(--f-clr-fg-100)",border:"dashed 1px var(--f-clr-fg-200)",borderRadius:"var(--f-radius-med)",transition:"background-color .25s, border-color .25s, color .25s",userSelect:"none",WebkitTapHighlightColor:"transparent"},'.zone[aria-disabled="false"]':{cursor:"pointer"},".zone.hovering":{backgroundColor:"var(--f-clr-primary-600)",borderColor:"var(--f-clr-primary-100)"},".zone.filled":{borderStyle:"solid"},".zone.error, .zone.rejected":{borderColor:"var(--f-clr-error-100)",color:"var(--f-clr-error-100)"},".zone.rejected":{backgroundColor:"var(--f-clr-error-400)"},".zone.disabled":{color:"var(--f-clr-grey-500)"},".container":{display:"flex",flexDirection:"column",gridArea:"1 / 1"},".preview":{position:"relative",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"var(--f-clr-bg-100)",padding:"var(--f-spacing-med)",flexGrow:1},".footer":{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"var(--f-spacing-sml)",gap:"var(--f-spacing-sml)"},".text":{display:"flex",alignItems:"baseline",gap:"var(--f-spacing-xsm)"},".annotation":{paddingTop:"var(--f-spacing-xxs)",color:"var(--f-clr-grey-600)",fontSize:"var(--f-font-size-xsm)"},".icon":{paddingBottom:"var(--f-spacing-sml)"},".image":{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover",zIndex:1},".container.centered":{alignItems:"center",justifyContent:"center",textAlign:"center",padding:"var(--f-spacing-lrg)"},".input":{position:"absolute",opacity:0,pointerEvents:"none"}});function v(e,r){const o=r?r.split(","):[];return!o.length||o.some((r=>e.type.includes(r.trim().replace(/\/\*$/,""))))}function u({cc:d={},loading:u=!1,error:b,text:h="Drop files or click to browse",annotation:y,icon:x,previewImages:j=!1,previewImageUrl:k,inputRef:C,...z}){const N=l(g,d),w=n(null),[D,I]=i(!1),[T,E]=i(!1),[L,O]=i(null),[R,B]=t(z);function F(e){if(!w.current)return;const r=new DataTransfer;e&&r.items.add(e),O(e),w.current.files=r.files,w.current.dispatchEvent(new Event("change",{bubbles:!0}))}const S=!!(j&&L&&v(L,"image/*")),U=z.disabled||z.readOnly||u;return e(m,{color:"var(--f-clr-grey-300)",disabled:!!L||U,children:r("div",{...B,tabIndex:0,role:"button","aria-disabled":!!L||U,className:c(N.zone,D&&N.hovering,b&&N.error,T&&N.rejected,L&&N.filled,z.disabled&&N.disabled,z.className),onClick:e=>{z.onClick?.(e),L||U||!w.current||w.current.click()},onDragOver:e=>{z.onDragOver?.(e),e.preventDefault(),U||I(!0)},onDragLeave:e=>{z.onDragLeave?.(e),I(!1)},onDrop:e=>{if(z.onDrop?.(e),U)return;e.preventDefault(),I(!1);const r=e.dataTransfer.files[0];r&&!v(r,z.accept||"")?(E(!0),setTimeout((()=>E(!1)),250)):r&&F(r)},children:[u&&e("div",{className:c(N.container,N.centered),children:e(f,{})}),L&&!u&&e(o,{children:r("div",{className:N.container,children:[r("div",{className:N.preview,children:[e(p,{type:"file"}),S&&e("img",{src:k||URL.createObjectURL(L),className:N.image})]}),r("div",{className:N.footer,children:[r("div",{children:[e("div",{className:N.text,children:L.name}),e("div",{className:N.annotation,children:($=L.size,($/=1024)<1e3?`${$.toFixed(1)} KB`:`${($/1024).toFixed(1)} MB`)})]}),e(a,{compact:!0,variant:"minimal",disabled:U,onClick:()=>F(null),children:e(p,{type:"close"})})]})]})}),r("div",{style:L||u?{opacity:0,pointerEvents:"none"}:void 0,className:c(N.container,N.centered),children:[e("div",{className:N.icon,children:x||e(p,{type:"upload"})}),e("div",{className:N.text,children:h}),y&&e("div",{className:N.annotation,children:y})]}),e("input",{...R,ref:s(w,C),type:"file",disabled:z.disabled||u,"aria-invalid":!!b,className:N.input,onChange:e=>{z.onChange?.(e),O(e.target.files?.[0]||null)}})]})});var $}export{u as default};
|
|
3
3
|
//# sourceMappingURL=drop-zone.js.map
|
|
@@ -5,7 +5,7 @@ export type DropZoneSelectors = Selectors<'zone' | 'hovering' | 'filled' | 'erro
|
|
|
5
5
|
*
|
|
6
6
|
* @see {@link https://fluid.infinityfx.dev/docs/components/drop-zone}
|
|
7
7
|
*/
|
|
8
|
-
export default function DropZone({ cc, loading, error, text, annotation, icon, previewImages, inputRef, ...props }: {
|
|
8
|
+
export default function DropZone({ cc, loading, error, text, annotation, icon, previewImages, previewImageUrl, inputRef, ...props }: {
|
|
9
9
|
ref?: React.Ref<HTMLDivElement>;
|
|
10
10
|
cc?: DropZoneSelectors;
|
|
11
11
|
loading?: boolean;
|
|
@@ -19,6 +19,12 @@ export default function DropZone({ cc, loading, error, text, annotation, icon, p
|
|
|
19
19
|
* @default false
|
|
20
20
|
*/
|
|
21
21
|
previewImages?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Optional URL to an image to preview.
|
|
24
|
+
*
|
|
25
|
+
* If not provided will default to the currently selected file.
|
|
26
|
+
*/
|
|
27
|
+
previewImageUrl?: string;
|
|
22
28
|
inputRef?: React.Ref<HTMLInputElement>;
|
|
23
29
|
onChange?: React.ChangeEventHandler<HTMLInputElement>;
|
|
24
30
|
} & Omit<React.InputHTMLAttributes<HTMLDivElement>, 'defaultValue' | 'children' | 'onChange'>): import("react/jsx-runtime").JSX.Element;
|