na2hiro / namespaced-fieldset Goto Github PK
View Code? Open in Web Editor NEWA tiny React utils which gives uncontrolled `<input>` elements a power of namespaces, and allows constructing complex objects
A tiny React utils which gives uncontrolled `<input>` elements a power of namespaces, and allows constructing complex objects
I think I set up the build with microbundle so the npm module is universal, namely as ESM, CJS and UMD. However, it still needs some config in Remix usage: #4. This suggests our module is recognized only as ESM module.
Is there some better setup for the package so it works universally?
Tried importing Fieldset
in a work project and a fresh Stackblitz and got the following error:
/app/node_modules/namespaced-fieldset/dist/index.cjs:1
import e,{createContext as t,Fragment as r,useContext as n}from"react";import a from"qs";function c(){return c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},c.apply(this,arguments)}const o=["namespace"],l=t("");function s(e){if(void 0===e)return;const t=n(l);return t?`${t}.${e}`:e}const i=t=>r=>{let{namespace:n}=r,a=function(e,t){if(null==e)return{};var r,n,a={},c=Object.keys(e);for(n=0;n<c.length;n++)t.indexOf(r=c[n])>=0||(a[r]=e[r]);return a}(r,o);const i=s(n);return e.createElement(l.Provider,{value:i},e.createElement(t,c({},a)))},m=i(t=>e.createElement("fieldset",c({},t)));m.Headless=i(r);const u=t=>r=>{const n=s(r.name);return e.createElement(t,c({},r,{name:n}))},f=u(t=>e.createElement("input",c({},t))),p=u(t=>e.createElement("button",c({},t))),E=u(t=>e.createElement("select",c({},t))),v=u(t=>e.createElement("textarea",c({},t))),d=e=>a.parse(e,{allowDots:!0,depth:1e3}),h=e=>{const t=new URLSearchParams(e);return d(t.toString())};export{p as Button,m as Fieldset,f as Input,E as Select,v as Textarea,h as constructFromFormData,d as constructFromQueryString,u as namespaceAware};
^^^^^^
SyntaxError: Cannot use import statement outside a module
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1032:15)
at Module._compile (node:internal/modules/cjs/loader:1067:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/app/app/lib/tenant.ts:3:55)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
Add namespaced-aware components for these 3 elements which participate in constructing FormData
.
These are not directly recognized by form: Don't care
ref. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form#see_also
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.