GithubHelp home page GithubHelp logo

na2hiro / namespaced-fieldset Goto Github PK

View Code? Open in Web Editor NEW
13.0 13.0 0.0 1.03 MB

A tiny React utils which gives uncontrolled `<input>` elements a power of namespaces, and allows constructing complex objects

TypeScript 100.00%

namespaced-fieldset's People

Contributors

dependabot[bot] avatar na2hiro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

namespaced-fieldset's Issues

Make sure the module works universally

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?

Importing `Fieldset` throws module-related error

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.