@kurocado-studio/formkit-ui-react-renderer 1.0.0-develop.6 → 1.0.0-develop.8
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/exports.js +1 -1
- package/dist/exports.js.map +1 -1
- package/dist/index.d.ts +120 -4
- package/dist/tsdoc-metadata.json +1 -1
- package/package.json +2 -2
package/dist/exports.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var x=(r=>(r.TEXT="TEXT",r))(x||{}),F=(o=>(o.TEXT="text",o.EMAIL="email",o.PASSWORD="password",o))(F||{}),N=(n=>(n.TEXT="text",n.NUMERIC="numeric",n.DECIMAL="decimal",n.EMAIL="email",n.TEL="tel",n.URL="url",n.SEARCH="search",n))(N||{}),E=(i=>(i.NONE="none",i.SENTENCES="sentences",i.WORDS="words",i.CHARACTERS="characters",i))(E||{});export*from"@kurocado-studio/web-forms-react";import{useAriaTextField as k}from"@kurocado-studio/web-forms-react";import m from"react";function b(e){let{labelProps:r,inputProps:t,descriptionProps:o,errorMessageProps:i}=k(e);return m.createElement(m.Fragment,null,m.createElement("label",{...r}),m.createElement("input",{...t}),m.createElement("p",{className:"block w-full",...o}),m.createElement("span",{className:"block w-full text-red-700",...i}))}import{HtmlForm as w}from"@kurocado-studio/web-forms-react";import B from"react";function K(e){return B.createElement(w,{...e})}import{useAriaTextArea as V}from"@kurocado-studio/web-forms-react";import d from"react";function me(e){let{labelProps:r,textAreaProps:t,descriptionProps:o,errorMessageProps:i}=V(e);return d.createElement(d.Fragment,null,d.createElement("label",{...r}),d.createElement("textarea",{...t}),d.createElement("p",{className:"block w-full",...o}),d.createElement("span",{className:"block w-full text-red-700",...i}))}import{get as H}from"lodash-es";import U from"react";import{get as M}from"lodash-es";import X from"react";function g(e){let{question:r,variant:t,variants:o,description:i}=e.question,s=M(o,[t,"id"],"unknown"),a=M(o,[t,"required"],!1);return X.createElement(b,{required:a,name:s,label:r,description:i})}var y={TEXT:g};import{get as G}from"lodash-es";import O from"react";function L({node:e}){return O.createElement("div",{style:{color:"gray",fontStyle:"italic"}},"Unsupported node type: ",e.variant)}function R({questionNode:e,componentMap:r}){let t=G(r,[e.variant],L);return O.createElement(t,{node:e,question:e})}function ge(e){return function({questionNode:t}){let o={TEXT:H(e,["TEXT"],y.TEXT)};return U.createElement(R,{questionNode:t,componentMap:o})}}import{get as j}from"lodash-es";import _ from"react";import{useAxios as Y}from"@kurocado-studio/axios-react";import{get as f}from"lodash-es";import Z from"react";var Oe="2305e7ed-b583-4ef7-9a4c-2bc094b34894",Re="2305e7ed-b583-4ef7-9a4c-2bc094b34894",he="5139da7c-5fc2-4140-8041-6caff89990b5",Se="821efcf2-cc16-4fa3-9ae9-b467738e2c4a",qe="821efcf2-cc16-4fa3-9ae9-b467738e2c4a",h=new Date().toISOString(),S=new Date().toISOString(),q={createdAt:h,description:"",id:"",sections:[],updatedAt:S,title:""},Ie={createdAt:h,description:"No description provided",id:"",order:0,questions:[],title:"",updatedAt:S},_e={hidden:!1,id:"",question:"No name provided",description:"No description provided",required:!1,variant:"TEXT",variants:{}};import W from"axios";function c(e={}){let{baseURL:r="https://html-forms-service-staging.fly.dev",timeout:t=9e3,headers:o={}}=e;return W.create({baseURL:r,timeout:t,headers:{"Content-Type":"application/json",...o}})}var Pe=c();var I=e=>{let r=Z.useMemo(()=>f(e,["axiosInstance"],c()),[e?.axiosInstance]),[t,o]=Y({axiosInstance:r});return[t,async({organizationId:s,formId:a})=>{try{let n=await o({url:`/api/v1/organizations/${s}/forms/${a}`,method:"GET"});return f(e,["onSuccessCallBack"],()=>{})({form:n}),n}catch(n){let p=q;return f(e,["onErrorCallBack"],()=>{})({error:n,fallbackEmptyForm:p}),p}}]};function Ue({children:e,organizationId:r,formId:t,...o}){let[{isLoading:i,data:s,error:a,resetState:n},p]=I();return _.useEffect(()=>(!i&&s===void 0&&a===void 0&&p({organizationId:r,formId:t}).then(),()=>n()),[r,t]),_.createElement(K,{...o},j(s,["sections",0,"questions"],[]).map((v,D)=>e({question:v,indexInCollection:D})))}import{useAriaTextField as $}from"@kurocado-studio/web-forms-react";import{get as C}from"lodash-es";var je=e=>{let{question:r,variant:t,variants:o,description:i}=e.question,s=C(o,[t,"id"],"unknown"),a=C(o,[t,"required"],!1);return $({label:r,description:i,name:s,required:a})};import{InputFieldTypeEnum as P,VariantEnum as Q}from"@kurocado-studio/formkit-ui-models";var u={id:"391a5218-2a40-4652-895b-683e2e25dd96",question:"What\u2019s the name of your form or project?",description:"Who is this description for?",hidden:!1,required:!1,variant:Q.TEXT,variants:{TEXT:{id:"10ae5f58-6de4-4aef-999e-d7b9df78056b",name:"unknown",type:P.TEXT,required:!1}},name:"4c9107e4-2a29-4460-ab77-648974e2634f"},l={id:"c2bb388c-e187-440b-b4d7-092c0be49c6f",question:"Who is this form for?",description:"Who is this description for?",hidden:!1,required:!1,variant:Q.TEXT,variants:{TEXT:{id:"01e3f9d0-d4c7-43f4-aa48-2987edcdafea",name:"unknown",type:P.TEXT,required:!1}},name:"e28e40c9-6821-43d7-a018-c81cf3a29dd6"},T={id:"821efcf2-cc16-4fa3-9ae9-b467738e2c4a",title:"Section 1",description:"This is a section",order:0,createdAt:"2025-11-11T16:05:23.351Z",updatedAt:"2025-11-11T16:05:23.351Z",questions:[u,l]},J={...T,questions:{[u.id]:u,[l.id]:l}},A={id:"2305e7ed-b583-4ef7-9a4c-2bc094b34894",title:"Welcome to FormKit",description:"This short demo introduces how FormKit lets you design and (soon) embed forms dynamically. You can edit any title, description, or question \u2014 just click and edit!",createdAt:"2025-11-11T16:05:23.351Z",updatedAt:"2025-11-11T16:05:23.351Z",sections:[T]},ze={[A.id]:{...A,sections:{[T.id]:J}}};export{g as BaseFormKitInputTextFieldNode,q as EMPTY_FORM_NODE,_e as EMPTY_QUESTION_NODE,Ie as EMPTY_SECTION_NODE,Oe as FORMKIT_DEMO_FORM_ID,Re as FORMKIT_DEMO_LONG_FORM_ID,qe as FORMKIT_DEMO_LONG_SECTION_ID,Se as FORMKIT_DEMO_SECTION_ID,he as FORMKIT_LOGIN_FORM_ID,Ue as FormKitConsumerForm,K as FormKitForm,me as FormKitInputTextArea,b as FormKitInputTextField,E as InputFieldAutocapitalizeEnum,N as InputFieldInputModeEnum,F as InputFieldTypeEnum,R as QuestionNodeRenderer,x as VariantEnum,Pe as axiosFormKitInstance,c as createFormKitClient,y as formKitBaseNodeVariantMap,ge as formRendererComposer,A as sampledForm,ze as sampledFormsNodeTree,u as sampledQuestion1,l as sampledQuestion2,T as sampledSection,J as sampledSectionNodeTree,je as useFormKitTextNode,I as useGetFormKitFormById};
|
|
2
2
|
//# sourceMappingURL=exports.js.map
|
package/dist/exports.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/enums/index.ts","../src/exports.ts","../src/components/controls/FormKitInputTextField.tsx","../src/components/controls/FormKitForm.tsx","../src/components/controls/FormKitInputTextArea.tsx","../src/components/nodes/BaseFormKitInputTextFieldNode.tsx","../src/components/FormRendererComposer.tsx","../src/config/formKitBaseNodeVariantMap.ts","../src/components/QuestionNodeRenderer.tsx","../src/utils/mocks.ts","../src/constants.ts"],"sourcesContent":["export enum VariantEnum {\n TEXT = 'TEXT',\n}\nexport enum InputFieldTypeEnum {\n TEXT = 'text',\n EMAIL = 'email',\n PASSWORD = 'password',\n}\n\nexport enum InputFieldInputModeEnum {\n TEXT = 'text',\n NUMERIC = 'numeric',\n DECIMAL = 'decimal',\n EMAIL = 'email',\n TEL = 'tel',\n URL = 'url',\n SEARCH = 'search',\n}\n\nexport enum InputFieldAutocapitalizeEnum {\n NONE = 'none',\n SENTENCES = 'sentences',\n WORDS = 'words',\n CHARACTERS = 'characters',\n}\n","export type Theme = Record<string, Record<string, unknown>>;\n\nexport {\n VariantEnum,\n InputFieldTypeEnum,\n InputFieldInputModeEnum,\n InputFieldAutocapitalizeEnum,\n} from './enums';\n\nexport * from '@kurocado-studio/web-forms-react';\nexport * from './components/controls';\nexport * from './components/nodes';\nexport * from './components/FormRendererComposer';\nexport * from './config/formKitBaseNodeVariantMap';\nexport * from './utils/mocks';\nexport * from './constants';\nexport * from './types';\n","import { useAriaTextField } from '@kurocado-studio/web-forms-react';\nimport React from 'react';\n\nexport function FormKitInputTextField(\n properties: {\n name: string;\n label?: string;\n description?: string;\n } & Partial<HTMLElementTagNameMap['input']>,\n): React.ReactNode {\n const { labelProps, inputProps, descriptionProps, errorMessageProps } =\n useAriaTextField(properties);\n\n return (\n <>\n <label {...labelProps} />\n <input {...inputProps} />\n <p className='block w-full' {...descriptionProps} />\n <span className='block w-full text-red-700' {...errorMessageProps} />\n </>\n );\n}\n","import { HtmlForm } from '@kurocado-studio/web-forms-react';\nimport React from 'react';\n\nimport { FormKitFormProperties } from '../../types';\n\nexport function FormKitForm<T extends Record<string, unknown>>(\n properties: FormKitFormProperties<T>,\n): React.ReactNode {\n return <HtmlForm<T> {...properties} />;\n}\n","import { useAriaTextArea } from '@kurocado-studio/web-forms-react';\nimport React from 'react';\n\nexport function FormKitInputTextArea(\n properties: { name: string } & Partial<HTMLElementTagNameMap['textarea']>,\n): React.ReactNode {\n const { labelProps, textAreaProps, descriptionProps, errorMessageProps } =\n useAriaTextArea(properties);\n\n return (\n <>\n <label {...labelProps} />\n <textarea {...textAreaProps} />\n <p className='block w-full' {...descriptionProps} />\n <span className='block w-full text-red-700' {...errorMessageProps} />\n </>\n );\n}\n","import type { Question } from '@kurocado-studio/formkit-ui-models';\nimport { get } from 'lodash-es';\nimport React from 'react';\n\nimport { FormKitInputTextField } from '../controls';\n\nexport function BaseFormKitInputTextFieldNode(properties: {\n question: Question;\n}): React.ReactNode {\n const { question, variant, variants, description } = properties.question;\n const name = get(variants, [variant, 'id'], 'unknown');\n const required = get(variants, [variant, 'required'], false);\n\n return (\n <FormKitInputTextField\n required={required}\n name={name}\n label={question}\n description={description}\n />\n );\n}\n","import { get } from 'lodash-es';\nimport React from 'react';\n\nimport { formKitBaseNodeVariantMap } from '../config/formKitBaseNodeVariantMap';\nimport { VariantEnum } from '../enums';\nimport { FormKitNodeVariantMap, Question } from '../types';\nimport { QuestionNodeRenderer } from './QuestionNodeRenderer';\n\nexport function formRendererComposer(defaultMap: FormKitNodeVariantMap) {\n return function FormRenderer({\n questionNode,\n }: {\n questionNode: Question;\n componentMap?: FormKitNodeVariantMap;\n }) {\n const nodeVariantMap: FormKitNodeVariantMap = {\n [VariantEnum.TEXT]: get(\n defaultMap,\n [VariantEnum.TEXT],\n formKitBaseNodeVariantMap.TEXT,\n ),\n };\n\n return (\n <QuestionNodeRenderer\n questionNode={questionNode}\n componentMap={nodeVariantMap}\n />\n );\n };\n}\n","import { BaseFormKitInputTextFieldNode } from '../components/nodes';\nimport { VariantEnum } from '../enums';\nimport { FormKitNodeVariantMap } from '../types';\n\nexport const formKitBaseNodeVariantMap: FormKitNodeVariantMap = {\n [VariantEnum.TEXT]: BaseFormKitInputTextFieldNode,\n};\n","import { get } from 'lodash-es';\nimport React from 'react';\n\nimport { FormKitNodeVariantMap, Question } from '../types';\n\nfunction DefaultFallback({ node }: { node: Question }) {\n return (\n <div style={{ color: 'gray', fontStyle: 'italic' }}>\n Unsupported node type: {node.variant}\n </div>\n );\n}\n\nexport function QuestionNodeRenderer({\n questionNode,\n componentMap,\n}: {\n questionNode: Question;\n componentMap: FormKitNodeVariantMap;\n}) {\n const Component = get(componentMap, [questionNode.variant], DefaultFallback);\n return <Component node={questionNode} question={questionNode} />;\n}\n","import {\n type Form,\n type FormsNodeTree,\n InputFieldTypeEnum,\n type Question,\n type Section,\n type SectionNodeTree,\n VariantEnum,\n} from '@kurocado-studio/formkit-ui-models';\n\nexport const sampledQuestion1: Question = {\n id: '391a5218-2a40-4652-895b-683e2e25dd96',\n question: 'What’s the name of your form or project?',\n description: 'Who is this description for?',\n hidden: false,\n required: false,\n variant: VariantEnum.TEXT,\n variants: {\n TEXT: {\n id: '10ae5f58-6de4-4aef-999e-d7b9df78056b',\n name: 'unknown',\n type: InputFieldTypeEnum.TEXT,\n required: false,\n },\n },\n name: '4c9107e4-2a29-4460-ab77-648974e2634f',\n};\n\nexport const sampledQuestion2: Question = {\n id: 'c2bb388c-e187-440b-b4d7-092c0be49c6f',\n question: 'Who is this form for?',\n description: 'Who is this description for?',\n hidden: false,\n required: false,\n variant: VariantEnum.TEXT,\n variants: {\n TEXT: {\n id: '01e3f9d0-d4c7-43f4-aa48-2987edcdafea',\n name: 'unknown',\n type: InputFieldTypeEnum.TEXT,\n required: false,\n },\n },\n name: 'e28e40c9-6821-43d7-a018-c81cf3a29dd6',\n};\n\nexport const sampledSection: Section = {\n id: '821efcf2-cc16-4fa3-9ae9-b467738e2c4a',\n title: 'Section 1',\n description: 'This is a section',\n order: 0,\n createdAt: '2025-11-11T16:05:23.351Z',\n updatedAt: '2025-11-11T16:05:23.351Z',\n questions: [sampledQuestion1, sampledQuestion2],\n};\n\nexport const sampledSectionNodeTree: SectionNodeTree = {\n ...sampledSection,\n questions: {\n [sampledQuestion1.id]: sampledQuestion1,\n [sampledQuestion2.id]: sampledQuestion2,\n },\n};\n\nexport const sampledForm: Form = {\n id: '2305e7ed-b583-4ef7-9a4c-2bc094b34894',\n title: 'Welcome to FormKit',\n description:\n 'This short demo introduces how FormKit lets you design and (soon) embed forms dynamically. You can edit any title, description, or question — just click and edit!',\n createdAt: '2025-11-11T16:05:23.351Z',\n updatedAt: '2025-11-11T16:05:23.351Z',\n sections: [sampledSection],\n};\n\nexport const sampledFormsNodeTree: FormsNodeTree = {\n [sampledForm.id]: {\n ...sampledForm,\n sections: {\n [sampledSection.id]: sampledSectionNodeTree,\n },\n },\n};\n","import { VariantEnum } from './enums';\nimport { Form, Question, Section } from './types';\n\nexport const FORMKIT_DEMO_FORM_ID = '2305e7ed-b583-4ef7-9a4c-2bc094b34894';\nexport const FORMKIT_DEMO_LONG_FORM_ID = '2305e7ed-b583-4ef7-9a4c-2bc094b34894';\nexport const FORMKIT_LOGIN_FORM_ID = '5139da7c-5fc2-4140-8041-6caff89990b5';\nexport const FORMKIT_DEMO_SECTION_ID = '821efcf2-cc16-4fa3-9ae9-b467738e2c4a';\nexport const FORMKIT_DEMO_LONG_SECTION_ID =\n '821efcf2-cc16-4fa3-9ae9-b467738e2c4a';\n\nconst createdAt = new Date().toISOString();\nconst updatedAt = new Date().toISOString();\n\nexport const EMPTY_FORM_NODE: Form = {\n createdAt,\n description: '',\n id: '',\n sections: [],\n updatedAt,\n title: '',\n};\n\nexport const EMPTY_SECTION_NODE: Section = {\n createdAt,\n description: 'No description provided',\n id: '',\n order: 0,\n questions: [],\n title: '',\n updatedAt,\n};\n\nexport const EMPTY_QUESTION_NODE: Question = {\n hidden: false,\n id: '',\n question: 'No name provided',\n description: 'No description provided',\n required: false,\n variant: VariantEnum.TEXT,\n variants: {},\n};\n"],"mappings":"AAAO,IAAKA,OACVA,EAAA,KAAO,OADGA,OAAA,IAGAC,OACVA,EAAA,KAAO,OACPA,EAAA,MAAQ,QACRA,EAAA,SAAW,WAHDA,OAAA,IAMAC,OACVA,EAAA,KAAO,OACPA,EAAA,QAAU,UACVA,EAAA,QAAU,UACVA,EAAA,MAAQ,QACRA,EAAA,IAAM,MACNA,EAAA,IAAM,MACNA,EAAA,OAAS,SAPCA,OAAA,IAUAC,OACVA,EAAA,KAAO,OACPA,EAAA,UAAY,YACZA,EAAA,MAAQ,QACRA,EAAA,WAAa,aAJHA,OAAA,ICVZ,WAAc,mCCTd,OAAS,oBAAAC,MAAwB,mCACjC,OAAOC,MAAW,QAEX,SAASC,EACdC,EAKiB,CACjB,GAAM,CAAE,WAAAC,EAAY,WAAAC,EAAY,iBAAAC,EAAkB,kBAAAC,CAAkB,EAClEP,EAAiBG,CAAU,EAE7B,OACEF,EAAA,cAAAA,EAAA,cACEA,EAAA,cAAC,SAAO,GAAGG,EAAY,EACvBH,EAAA,cAAC,SAAO,GAAGI,EAAY,EACvBJ,EAAA,cAAC,KAAE,UAAU,eAAgB,GAAGK,EAAkB,EAClDL,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jD,CAACD,EAAY,EAAE,EAAG,CAChB,GAAGA,EACH,SAAU,CACR,CAACF,EAAe,EAAE,EAAGC,CACvB,CACF,CACF,EC9EO,IAAMG,GAAuB,uCACvBC,GAA4B,uCAC5BC,GAAwB,uCACxBC,GAA0B,uCAC1BC,GACX,uCAEIC,EAAY,IAAI,KAAK,EAAE,YAAY,EACnCC,EAAY,IAAI,KAAK,EAAE,YAAY,EAE5BC,GAAwB,CACnC,UAAAF,EACA,YAAa,GACb,GAAI,GACJ,SAAU,CAAC,EACX,UAAAC,EACA,MAAO,EACT,EAEaE,GAA8B,CACzC,UAAAH,EACA,YAAa,0BACb,GAAI,GACJ,MAAO,EACP,UAAW,CAAC,EACZ,MAAO,GACP,UAAAC,CACF,EAEaG,GAAgC,CAC3C,OAAQ,GACR,GAAI,GACJ,SAAU,mBACV,YAAa,0BACb,SAAU,GACV,eACA,SAAU,CAAC,CACb","names":["VariantEnum","InputFieldTypeEnum","InputFieldInputModeEnum","InputFieldAutocapitalizeEnum","useAriaTextField","React","FormKitInputTextField","properties","labelProps","inputProps","descriptionProps","errorMessageProps","HtmlForm","React","FormKitForm","properties","useAriaTextArea","React","FormKitInputTextArea","properties","labelProps","textAreaProps","descriptionProps","errorMessageProps","get","React","BaseFormKitInputTextFieldNode","properties","question","variant","variants","description","name","get","required","React","FormKitInputTextField","get","React","formKitBaseNodeVariantMap","BaseFormKitInputTextFieldNode","get","React","DefaultFallback","node","QuestionNodeRenderer","questionNode","componentMap","Component","formRendererComposer","defaultMap","questionNode","nodeVariantMap","get","formKitBaseNodeVariantMap","React","QuestionNodeRenderer","InputFieldTypeEnum","VariantEnum","sampledQuestion1","sampledQuestion2","sampledSection","sampledSectionNodeTree","sampledForm","sampledFormsNodeTree","FORMKIT_DEMO_FORM_ID","FORMKIT_DEMO_LONG_FORM_ID","FORMKIT_LOGIN_FORM_ID","FORMKIT_DEMO_SECTION_ID","FORMKIT_DEMO_LONG_SECTION_ID","createdAt","updatedAt","EMPTY_FORM_NODE","EMPTY_SECTION_NODE","EMPTY_QUESTION_NODE"]}
|
|
1
|
+
{"version":3,"sources":["../src/enums/index.ts","../src/exports.ts","../src/components/controls/FormKitInputTextField.tsx","../src/components/controls/FormKitForm.tsx","../src/components/controls/FormKitInputTextArea.tsx","../src/components/FormRendererComposer.tsx","../src/components/nodes/BaseFormKitInputTextFieldNode.tsx","../src/config/formKitBaseNodeVariantMap.ts","../src/components/QuestionNodeRenderer.tsx","../src/components/FormKitConsumerForm.tsx","../src/components/hooks/useGetFormKitFormById.ts","../src/constants.ts","../src/components/api/createFormKitClient.ts","../src/components/hooks/useFormKitTextNode.ts","../src/utils/mocks.ts"],"sourcesContent":["export enum VariantEnum {\n TEXT = 'TEXT',\n}\nexport enum InputFieldTypeEnum {\n TEXT = 'text',\n EMAIL = 'email',\n PASSWORD = 'password',\n}\n\nexport enum InputFieldInputModeEnum {\n TEXT = 'text',\n NUMERIC = 'numeric',\n DECIMAL = 'decimal',\n EMAIL = 'email',\n TEL = 'tel',\n URL = 'url',\n SEARCH = 'search',\n}\n\nexport enum InputFieldAutocapitalizeEnum {\n NONE = 'none',\n SENTENCES = 'sentences',\n WORDS = 'words',\n CHARACTERS = 'characters',\n}\n","export type Theme = Record<string, Record<string, unknown>>;\n\nexport {\n VariantEnum,\n InputFieldTypeEnum,\n InputFieldInputModeEnum,\n InputFieldAutocapitalizeEnum,\n} from './enums';\n\nexport * from '@kurocado-studio/web-forms-react';\nexport * from './components/controls';\nexport * from './components/FormRendererComposer';\nexport * from './components/FormKitConsumerForm';\nexport * from './components/QuestionNodeRenderer';\nexport * from './components/nodes';\nexport * from './components/api/createFormKitClient';\nexport * from './components/nodes/index';\nexport * from './components/hooks/useGetFormKitFormById';\nexport * from './components/hooks/useFormKitTextNode';\nexport * from './components/FormRendererComposer';\nexport * from './config/formKitBaseNodeVariantMap';\nexport * from './utils/mocks';\nexport * from './constants';\nexport * from './types';\n","import { useAriaTextField } from '@kurocado-studio/web-forms-react';\nimport React from 'react';\n\nexport function FormKitInputTextField(\n properties: {\n name: string;\n label?: string;\n description?: string;\n } & Partial<HTMLElementTagNameMap['input']>,\n): React.ReactNode {\n const { labelProps, inputProps, descriptionProps, errorMessageProps } =\n useAriaTextField(properties);\n\n return (\n <>\n <label {...labelProps} />\n <input {...inputProps} />\n <p className='block w-full' {...descriptionProps} />\n <span className='block w-full text-red-700' {...errorMessageProps} />\n </>\n );\n}\n","import { HtmlForm } from '@kurocado-studio/web-forms-react';\nimport React from 'react';\n\nimport { FormKitFormProperties } from '../../types';\n\nexport function FormKitForm<T extends Record<string, unknown>>(\n properties: FormKitFormProperties<T>,\n): React.ReactNode {\n return <HtmlForm<T> {...properties} />;\n}\n","import { useAriaTextArea } from '@kurocado-studio/web-forms-react';\nimport React from 'react';\n\nexport function FormKitInputTextArea(\n properties: { name: string } & Partial<HTMLElementTagNameMap['textarea']>,\n): React.ReactNode {\n const { labelProps, textAreaProps, descriptionProps, errorMessageProps } =\n useAriaTextArea(properties);\n\n return (\n <>\n <label {...labelProps} />\n <textarea {...textAreaProps} />\n <p className='block w-full' {...descriptionProps} />\n <span className='block w-full text-red-700' {...errorMessageProps} />\n </>\n );\n}\n","import { get } from 'lodash-es';\nimport React from 'react';\n\nimport { formKitBaseNodeVariantMap } from '../config/formKitBaseNodeVariantMap';\nimport { VariantEnum } from '../enums';\nimport { FormKitNodeVariantMap, Question } from '../types';\nimport { QuestionNodeRenderer } from './QuestionNodeRenderer';\n\nexport function formRendererComposer(defaultMap: FormKitNodeVariantMap) {\n return function FormRenderer({\n questionNode,\n }: {\n questionNode: Question;\n componentMap?: FormKitNodeVariantMap;\n }) {\n const nodeVariantMap: FormKitNodeVariantMap = {\n [VariantEnum.TEXT]: get(\n defaultMap,\n [VariantEnum.TEXT],\n formKitBaseNodeVariantMap.TEXT,\n ),\n };\n\n return (\n <QuestionNodeRenderer\n questionNode={questionNode}\n componentMap={nodeVariantMap}\n />\n );\n };\n}\n","import type { Question } from '@kurocado-studio/formkit-ui-models';\nimport { get } from 'lodash-es';\nimport React from 'react';\n\nimport { FormKitInputTextField } from '../controls';\n\nexport function BaseFormKitInputTextFieldNode(properties: {\n question: Question;\n}): React.ReactNode {\n const { question, variant, variants, description } = properties.question;\n const name = get(variants, [variant, 'id'], 'unknown');\n const required = get(variants, [variant, 'required'], false);\n\n return (\n <FormKitInputTextField\n required={required}\n name={name}\n label={question}\n description={description}\n />\n );\n}\n","import { BaseFormKitInputTextFieldNode } from '../components/nodes';\nimport { VariantEnum } from '../enums';\nimport { FormKitNodeVariantMap } from '../types';\n\nexport const formKitBaseNodeVariantMap: FormKitNodeVariantMap = {\n [VariantEnum.TEXT]: BaseFormKitInputTextFieldNode,\n};\n","import { get } from 'lodash-es';\nimport React from 'react';\n\nimport { FormKitNodeVariantMap, Question } from '../types';\n\nfunction DefaultFallback({ node }: { node: Question }) {\n return (\n <div style={{ color: 'gray', fontStyle: 'italic' }}>\n Unsupported node type: {node.variant}\n </div>\n );\n}\n\nexport function QuestionNodeRenderer({\n questionNode,\n componentMap,\n}: {\n questionNode: Question;\n componentMap: FormKitNodeVariantMap;\n}) {\n const Component = get(componentMap, [questionNode.variant], DefaultFallback);\n return <Component node={questionNode} question={questionNode} />;\n}\n","import { get } from 'lodash-es';\nimport React from 'react';\n\nimport { FormKitConsumerFormProperties, Question } from '../types';\nimport { FormKitForm } from './controls';\nimport { useGetFormKitFormById } from './hooks/useGetFormKitFormById';\n\nexport function FormKitConsumerForm<T extends Record<string, unknown>>({\n children,\n organizationId,\n formId,\n ...properties\n}: FormKitConsumerFormProperties<T>): React.ReactNode {\n const [{ isLoading, data, error, resetState }, handleGetForm] =\n useGetFormKitFormById();\n\n React.useEffect(() => {\n if (!isLoading && data === undefined && error === undefined) {\n handleGetForm({ organizationId, formId }).then();\n }\n return () => resetState();\n }, [organizationId, formId]);\n\n return (\n <FormKitForm<T> {...properties}>\n {get(data, ['sections', 0, 'questions'], []).map(\n (question: Question, index: number): React.ReactNode =>\n children({ question, indexInCollection: index }),\n )}\n </FormKitForm>\n );\n}\n","import { useAxios } from '@kurocado-studio/axios-react';\nimport { get } from 'lodash-es';\nimport React from 'react';\n\nimport { EMPTY_FORM_NODE } from '../../constants';\nimport { Form, GetFormByIdHandler, UseGetFormKitFormById } from '../../types';\nimport { createFormKitClient } from '../api/createFormKitClient';\n\nexport const useGetFormKitFormById: UseGetFormKitFormById = (payload) => {\n const axiosInstance = React.useMemo(\n () => get(payload, ['axiosInstance'], createFormKitClient()),\n [payload?.axiosInstance],\n );\n\n const [getFormByIdState, getFormByIdHandler] = useAxios<Form>({\n axiosInstance,\n });\n\n const handleGetFormById: GetFormByIdHandler = async ({\n organizationId,\n formId,\n }) => {\n try {\n const form = await getFormByIdHandler({\n url: `/api/v1/organizations/${organizationId}/forms/${formId}`,\n method: 'GET',\n });\n get(payload, ['onSuccessCallBack'], () => {})({ form });\n return form;\n } catch (error) {\n const fallbackEmptyForm = EMPTY_FORM_NODE;\n get(payload, ['onErrorCallBack'], () => {})({ error, fallbackEmptyForm });\n return fallbackEmptyForm;\n }\n };\n\n return [getFormByIdState, handleGetFormById];\n};\n","import { VariantEnum } from './enums';\nimport { Form, Question, Section } from './types';\n\nexport const FORMKIT_DEMO_FORM_ID = '2305e7ed-b583-4ef7-9a4c-2bc094b34894';\nexport const FORMKIT_DEMO_LONG_FORM_ID = '2305e7ed-b583-4ef7-9a4c-2bc094b34894';\nexport const FORMKIT_LOGIN_FORM_ID = '5139da7c-5fc2-4140-8041-6caff89990b5';\nexport const FORMKIT_DEMO_SECTION_ID = '821efcf2-cc16-4fa3-9ae9-b467738e2c4a';\nexport const FORMKIT_DEMO_LONG_SECTION_ID =\n '821efcf2-cc16-4fa3-9ae9-b467738e2c4a';\n\nconst createdAt = new Date().toISOString();\nconst updatedAt = new Date().toISOString();\n\nexport const EMPTY_FORM_NODE: Form = {\n createdAt,\n description: '',\n id: '',\n sections: [],\n updatedAt,\n title: '',\n};\n\nexport const EMPTY_SECTION_NODE: Section = {\n createdAt,\n description: 'No description provided',\n id: '',\n order: 0,\n questions: [],\n title: '',\n updatedAt,\n};\n\nexport const EMPTY_QUESTION_NODE: Question = {\n hidden: false,\n id: '',\n question: 'No name provided',\n description: 'No description provided',\n required: false,\n variant: VariantEnum.TEXT,\n variants: {},\n};\n","import axios, { type AxiosInstance } from 'axios';\n\nexport interface FormKitClientOptions {\n baseURL?: string;\n timeout?: number;\n headers?: Record<string, string>;\n}\n\nexport function createFormKitClient(\n options: FormKitClientOptions = {},\n): AxiosInstance {\n const {\n baseURL = 'https://html-forms-service-staging.fly.dev',\n timeout = 9000,\n headers = {},\n } = options;\n\n return axios.create({\n baseURL,\n timeout,\n headers: {\n 'Content-Type': 'application/json',\n ...headers,\n },\n });\n}\n\nexport const axiosFormKitInstance = createFormKitClient();\n","import {\n type TextFieldApi,\n type TextFieldProperties,\n useAriaTextField,\n} from '@kurocado-studio/web-forms-react';\nimport { get } from 'lodash-es';\n\nimport { Question } from '../../types';\n\nexport const useFormKitTextNode = (payload: {\n question: Question;\n}): TextFieldApi => {\n const { question, variant, variants, description } = payload.question;\n const name = get(variants, [variant, 'id'], 'unknown');\n const required = get(variants, [variant, 'required'], false);\n\n const ariaTextFieldConfig: TextFieldProperties = {\n label: question,\n description,\n name,\n required,\n };\n\n return useAriaTextField(ariaTextFieldConfig);\n};\n","import {\n type Form,\n type FormsNodeTree,\n InputFieldTypeEnum,\n type Question,\n type Section,\n type SectionNodeTree,\n VariantEnum,\n} from '@kurocado-studio/formkit-ui-models';\n\nexport const sampledQuestion1: Question = {\n id: '391a5218-2a40-4652-895b-683e2e25dd96',\n question: 'What’s the name of your form or project?',\n description: 'Who is this description for?',\n hidden: false,\n required: false,\n variant: VariantEnum.TEXT,\n variants: {\n TEXT: {\n id: '10ae5f58-6de4-4aef-999e-d7b9df78056b',\n name: 'unknown',\n type: InputFieldTypeEnum.TEXT,\n required: false,\n },\n },\n name: '4c9107e4-2a29-4460-ab77-648974e2634f',\n};\n\nexport const sampledQuestion2: Question = {\n id: 'c2bb388c-e187-440b-b4d7-092c0be49c6f',\n question: 'Who is this form for?',\n description: 'Who is this description for?',\n hidden: false,\n required: false,\n variant: VariantEnum.TEXT,\n variants: {\n TEXT: {\n id: '01e3f9d0-d4c7-43f4-aa48-2987edcdafea',\n name: 'unknown',\n type: InputFieldTypeEnum.TEXT,\n required: false,\n },\n },\n name: 'e28e40c9-6821-43d7-a018-c81cf3a29dd6',\n};\n\nexport const sampledSection: Section = {\n id: '821efcf2-cc16-4fa3-9ae9-b467738e2c4a',\n title: 'Section 1',\n description: 'This is a section',\n order: 0,\n createdAt: '2025-11-11T16:05:23.351Z',\n updatedAt: '2025-11-11T16:05:23.351Z',\n questions: [sampledQuestion1, sampledQuestion2],\n};\n\nexport const sampledSectionNodeTree: SectionNodeTree = {\n ...sampledSection,\n questions: {\n [sampledQuestion1.id]: sampledQuestion1,\n [sampledQuestion2.id]: sampledQuestion2,\n },\n};\n\nexport const sampledForm: Form = {\n id: '2305e7ed-b583-4ef7-9a4c-2bc094b34894',\n title: 'Welcome to FormKit',\n description:\n 'This short demo introduces how FormKit lets you design and (soon) embed forms dynamically. You can edit any title, description, or question — just click and edit!',\n createdAt: '2025-11-11T16:05:23.351Z',\n updatedAt: '2025-11-11T16:05:23.351Z',\n sections: [sampledSection],\n};\n\nexport const sampledFormsNodeTree: FormsNodeTree = {\n [sampledForm.id]: {\n ...sampledForm,\n sections: {\n [sampledSection.id]: sampledSectionNodeTree,\n },\n },\n};\n"],"mappings":"AAAO,IAAKA,OACVA,EAAA,KAAO,OADGA,OAAA,IAGAC,OACVA,EAAA,KAAO,OACPA,EAAA,MAAQ,QACRA,EAAA,SAAW,WAHDA,OAAA,IAMAC,OACVA,EAAA,KAAO,OACPA,EAAA,QAAU,UACVA,EAAA,QAAU,UACVA,EAAA,MAAQ,QACRA,EAAA,IAAM,MACNA,EAAA,IAAM,MACNA,EAAA,OAAS,SAPCA,OAAA,IAUAC,OACVA,EAAA,KAAO,OACPA,EA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,KAAM,CACJ,GAAI,uCACJ,KAAM,UACN,KAAMD,EAAmB,KACzB,SAAU,EACZ,CACF,EACA,KAAM,sCACR,EAEaI,EAA0B,CACrC,GAAI,uCACJ,MAAO,YACP,YAAa,oBACb,MAAO,EACP,UAAW,2BACX,UAAW,2BACX,UAAW,CAACF,EAAkBC,CAAgB,CAChD,EAEaE,EAA0C,CACrD,GAAGD,EACH,UAAW,CACT,CAACF,EAAiB,EAAE,EAAGA,EACvB,CAACC,EAAiB,EAAE,EAAGA,CACzB,CACF,EAEaG,EAAoB,CAC/B,GAAI,uCACJ,MAAO,qBACP,YACE,0KACF,UAAW,2BACX,UAAW,2BACX,SAAU,CAACF,CAAc,CAC3B,EAEaG,GAAsC,CACjD,CAACD,EAAY,EAAE,EAAG,CAChB,GAAGA,EACH,SAAU,CACR,CAACF,EAAe,EAAE,EAAGC,CACvB,CACF,CACF","names":["VariantEnum","InputFieldTypeEnum","InputFieldInputModeEnum","InputFieldAutocapitalizeEnum","useAriaTextField","React","FormKitInputTextField","properties","labelProps","inputProps","descriptionProps","errorMessageProps","HtmlForm","React","FormKitForm","properties","useAriaTextArea","React","FormKitInputTextArea","properties","labelProps","textAreaProps","descriptionProps","errorMessageProps","get","React","get","React","BaseFormKitInputTextFieldNode","properties","question","variant","variants","description","name","get","required","React","FormKitInputTextField","formKitBaseNodeVariantMap","BaseFormKitInputTextFieldNode","get","React","DefaultFallback","node","QuestionNodeRenderer","questionNode","componentMap","Component","formRendererComposer","defaultMap","questionNode","nodeVariantMap","get","formKitBaseNodeVariantMap","React","QuestionNodeRenderer","get","React","useAxios","get","React","FORMKIT_DEMO_FORM_ID","FORMKIT_DEMO_LONG_FORM_ID","FORMKIT_LOGIN_FORM_ID","FORMKIT_DEMO_SECTION_ID","FORMKIT_DEMO_LONG_SECTION_ID","createdAt","updatedAt","EMPTY_FORM_NODE","EMPTY_SECTION_NODE","EMPTY_QUESTION_NODE","axios","createFormKitClient","options","baseURL","timeout","headers","axiosFormKitInstance","useGetFormKitFormById","payload","axiosInstance","React","get","createFormKitClient","getFormByIdState","getFormByIdHandler","useAxios","organizationId","formId","form","error","fallbackEmptyForm","EMPTY_FORM_NODE","FormKitConsumerForm","children","organizationId","formId","properties","isLoading","data","error","resetState","handleGetForm","useGetFormKitFormById","React","FormKitForm","get","question","index","useAriaTextField","get","useFormKitTextNode","payload","question","variant","variants","description","name","required","InputFieldTypeEnum","VariantEnum","sampledQuestion1","sampledQuestion2","sampledSection","sampledSectionNodeTree","sampledForm","sampledFormsNodeTree"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,29 @@
|
|
|
1
1
|
import { AxiosInstance } from 'axios';
|
|
2
2
|
import { AxiosState } from '@kurocado-studio/axios-react';
|
|
3
|
-
import {
|
|
3
|
+
import { DefaultValue } from '@conform-to/react';
|
|
4
|
+
import { FieldName } from '@conform-to/react';
|
|
5
|
+
import { FormId } from '@conform-to/react';
|
|
6
|
+
import { LabelHTMLAttributes } from 'react';
|
|
4
7
|
import { default as React_2 } from 'react';
|
|
8
|
+
import { ReactNode } from 'react';
|
|
9
|
+
import { SubmissionResult } from '@conform-to/dom';
|
|
10
|
+
import { useForm } from '@conform-to/react';
|
|
11
|
+
import { ZodObject } from 'zod';
|
|
12
|
+
import { ZodRawShape } from 'zod';
|
|
13
|
+
|
|
14
|
+
export declare interface AdditionalAriaTextFieldProperties {
|
|
15
|
+
htmlFor?: string;
|
|
16
|
+
required?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export declare const axiosFormKitInstance: AxiosInstance;
|
|
5
20
|
|
|
6
21
|
export declare function BaseFormKitInputTextFieldNode(properties: {
|
|
7
22
|
question: Question_2;
|
|
8
23
|
}): React_2.ReactNode;
|
|
9
24
|
|
|
25
|
+
export declare function createFormKitClient(options?: FormKitClientOptions): AxiosInstance;
|
|
26
|
+
|
|
10
27
|
export declare const EMPTY_FORM_NODE: Form;
|
|
11
28
|
|
|
12
29
|
export declare const EMPTY_QUESTION_NODE: Question;
|
|
@@ -43,6 +60,14 @@ export declare const FORMKIT_LOGIN_FORM_ID = "5139da7c-5fc2-4140-8041-6caff89990
|
|
|
43
60
|
|
|
44
61
|
export declare const formKitBaseNodeVariantMap: FormKitNodeVariantMap;
|
|
45
62
|
|
|
63
|
+
export declare interface FormKitClientOptions {
|
|
64
|
+
baseURL?: string;
|
|
65
|
+
timeout?: number;
|
|
66
|
+
headers?: Record<string, string>;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export declare function FormKitConsumerForm<T extends Record<string, unknown>>({ children, organizationId, formId, ...properties }: FormKitConsumerFormProperties<T>): React_2.ReactNode;
|
|
70
|
+
|
|
46
71
|
export declare interface FormKitConsumerFormProperties<T extends Record<string, unknown> = Record<string, unknown>> extends Omit<FormKitFormProperties<T>, 'children'> {
|
|
47
72
|
organizationId: string;
|
|
48
73
|
formId: string;
|
|
@@ -88,6 +113,23 @@ export declare type GetFormByIdHandler = (payload: {
|
|
|
88
113
|
formId: string;
|
|
89
114
|
}) => Promise<Form>;
|
|
90
115
|
|
|
116
|
+
export declare interface HTMLErrorSubmissionResult<T extends Record<string, unknown>> extends Omit<SubmissionResult, 'error'> {
|
|
117
|
+
error: {
|
|
118
|
+
[K in keyof T]?: Array<string> | null;
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export declare function HtmlForm<T extends Record<string, unknown>>({ children, className, schema, onSuccess, onError, ...useFormOptions }: HtmlFormProperties<T>): React_2.ReactNode;
|
|
123
|
+
|
|
124
|
+
export declare type HtmlFormProperties<T extends Record<string, unknown>> = {
|
|
125
|
+
children?: React_2.ReactNode;
|
|
126
|
+
schema?: ZodObject<ZodRawShape>;
|
|
127
|
+
className?: string;
|
|
128
|
+
defaultValue?: DefaultValue<T>;
|
|
129
|
+
onSuccess?: (payload: T) => void;
|
|
130
|
+
onError?: (payload: HTMLErrorSubmissionResult<T>) => void;
|
|
131
|
+
} & Omit<Parameters<typeof useForm>[0], 'onValidate' | 'defaultValue'>;
|
|
132
|
+
|
|
91
133
|
export declare enum InputFieldAutocapitalizeEnum {
|
|
92
134
|
NONE = "none",
|
|
93
135
|
SENTENCES = "sentences",
|
|
@@ -134,6 +176,12 @@ declare enum InputFieldTypeEnum_2 {
|
|
|
134
176
|
PASSWORD = "password"
|
|
135
177
|
}
|
|
136
178
|
|
|
179
|
+
export declare type LabelProperties = LabelHTMLAttributes<HTMLLabelElement> & {
|
|
180
|
+
htmlFor: string;
|
|
181
|
+
required?: boolean;
|
|
182
|
+
children?: ReactNode;
|
|
183
|
+
};
|
|
184
|
+
|
|
137
185
|
export declare interface Question extends Record<string, unknown> {
|
|
138
186
|
id: string;
|
|
139
187
|
question: string;
|
|
@@ -176,6 +224,11 @@ export declare interface QuestionCreatorPayload<T extends VariantEnum = VariantE
|
|
|
176
224
|
variant: VariantCreatorDto<T>;
|
|
177
225
|
}
|
|
178
226
|
|
|
227
|
+
export declare function QuestionNodeRenderer({ questionNode, componentMap, }: {
|
|
228
|
+
questionNode: Question;
|
|
229
|
+
componentMap: FormKitNodeVariantMap;
|
|
230
|
+
}): React_2.JSX.Element;
|
|
231
|
+
|
|
179
232
|
export declare const sampledForm: Form_2;
|
|
180
233
|
|
|
181
234
|
export declare const sampledFormsNodeTree: FormsNodeTree;
|
|
@@ -214,6 +267,60 @@ declare interface SectionNodeTree extends Omit<Section_2, 'questions'> {
|
|
|
214
267
|
};
|
|
215
268
|
}
|
|
216
269
|
|
|
270
|
+
export declare interface TextAreaApi {
|
|
271
|
+
descriptionProps?: React_2.HTMLAttributes<HTMLDivElement>;
|
|
272
|
+
errorMessageProps?: React_2.HTMLAttributes<HTMLDivElement>;
|
|
273
|
+
textAreaProps: React_2.TextareaHTMLAttributes<HTMLTextAreaElement> & {
|
|
274
|
+
ref: React_2.Ref<HTMLTextAreaElement>;
|
|
275
|
+
};
|
|
276
|
+
isInvalid: boolean;
|
|
277
|
+
labelProps: React_2.LabelHTMLAttributes<HTMLLabelElement> & AdditionalAriaTextFieldProperties;
|
|
278
|
+
validationDetails: ValidityState;
|
|
279
|
+
validationErrors: Array<string>;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
export declare interface TextAreaMeta<FormSchema extends Record<string, unknown>, FormError> {
|
|
283
|
+
formId?: FormId<FormSchema, FormError>;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export declare type TextAreaProperties<FieldSchema = string, FormSchema extends Record<string, unknown> = Record<string, unknown>, FormError extends string[] = string[]> = {
|
|
287
|
+
description?: string;
|
|
288
|
+
errorMessage?: string;
|
|
289
|
+
autoCapitalize?: 'none' | 'off' | 'on' | 'sentences' | 'words' | 'characters' | undefined;
|
|
290
|
+
onChange?: React_2.Dispatch<React_2.SetStateAction<string | Array<string> | undefined>>;
|
|
291
|
+
name: FieldName<FieldSchema, FormSchema, FormError> | string;
|
|
292
|
+
label?: string;
|
|
293
|
+
type?: string;
|
|
294
|
+
required?: boolean;
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
export declare interface TextFieldApi {
|
|
298
|
+
descriptionProps?: React_2.HTMLAttributes<HTMLDivElement>;
|
|
299
|
+
errorMessageProps?: React_2.HTMLAttributes<HTMLDivElement>;
|
|
300
|
+
inputProps: React_2.InputHTMLAttributes<HTMLInputElement> & {
|
|
301
|
+
ref: React_2.Ref<HTMLInputElement>;
|
|
302
|
+
};
|
|
303
|
+
isInvalid: boolean;
|
|
304
|
+
labelProps: React_2.LabelHTMLAttributes<HTMLLabelElement> & AdditionalAriaTextFieldProperties;
|
|
305
|
+
validationDetails: ValidityState;
|
|
306
|
+
validationErrors: Array<string>;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
export declare interface TextFieldMeta<FormSchema extends Record<string, unknown>, FormError> {
|
|
310
|
+
formId?: FormId<FormSchema, FormError>;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
export declare type TextFieldProperties<FieldSchema = string, FormSchema extends Record<string, unknown> = Record<string, unknown>, FormError extends string[] = string[]> = {
|
|
314
|
+
description?: string;
|
|
315
|
+
errorMessage?: string;
|
|
316
|
+
autoCapitalize?: 'none' | 'off' | 'on' | 'sentences' | 'words' | 'characters' | undefined;
|
|
317
|
+
onChange?: React_2.Dispatch<React_2.SetStateAction<string | Array<string> | undefined>>;
|
|
318
|
+
name: FieldName<FieldSchema, FormSchema, FormError> | string;
|
|
319
|
+
label?: string;
|
|
320
|
+
type?: string;
|
|
321
|
+
required?: boolean;
|
|
322
|
+
};
|
|
323
|
+
|
|
217
324
|
export declare interface TextFieldQuestionNode extends Record<string, unknown> {
|
|
218
325
|
id: string;
|
|
219
326
|
name: string;
|
|
@@ -254,6 +361,14 @@ declare interface TextFieldQuestionNode_2 extends Record<string, unknown> {
|
|
|
254
361
|
|
|
255
362
|
export declare type Theme = Record<string, Record<string, unknown>>;
|
|
256
363
|
|
|
364
|
+
export declare const useAriaTextArea: <FieldSchema = string, FormSchema extends Record<string, unknown> = Record<string, unknown>, FormError extends string[] = string[]>(config: TextAreaProperties<FieldSchema, FormSchema, FormError>, formMeta?: TextAreaMeta<FormSchema, FormError>) => TextAreaApi;
|
|
365
|
+
|
|
366
|
+
export declare const useAriaTextField: <FieldSchema = string, FormSchema extends Record<string, unknown> = Record<string, unknown>, FormError extends string[] = string[]>(config: TextFieldProperties<FieldSchema, FormSchema, FormError>, formMeta?: TextFieldMeta<FormSchema, FormError>) => TextFieldApi;
|
|
367
|
+
|
|
368
|
+
export declare const useFormKitTextNode: (payload: {
|
|
369
|
+
question: Question;
|
|
370
|
+
}) => TextFieldApi;
|
|
371
|
+
|
|
257
372
|
export declare type UseGetFormKitFormById = (payload?: {
|
|
258
373
|
axiosInstance?: AxiosInstance;
|
|
259
374
|
onSuccessCallBack?: (payload: {
|
|
@@ -268,6 +383,10 @@ formKitFormByIdState: AxiosState<Form>,
|
|
|
268
383
|
handleGetFormById: GetFormByIdHandler
|
|
269
384
|
];
|
|
270
385
|
|
|
386
|
+
export declare const useGetFormKitFormById: UseGetFormKitFormById;
|
|
387
|
+
|
|
388
|
+
export declare type ValidityStateProperties = ValidityState;
|
|
389
|
+
|
|
271
390
|
export declare interface VariantCreatorDto<T extends VariantEnum = VariantEnum.TEXT> {
|
|
272
391
|
variantPayload: Record<string, unknown>;
|
|
273
392
|
variantType: T;
|
|
@@ -289,7 +408,4 @@ declare type VariantMap_2 = {
|
|
|
289
408
|
[VariantEnum_2.TEXT]?: TextFieldQuestionNode_2;
|
|
290
409
|
};
|
|
291
410
|
|
|
292
|
-
|
|
293
|
-
export * from "@kurocado-studio/web-forms-react";
|
|
294
|
-
|
|
295
411
|
export { }
|
package/dist/tsdoc-metadata.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kurocado-studio/formkit-ui-react-renderer",
|
|
3
|
-
"version": "1.0.0-develop.
|
|
3
|
+
"version": "1.0.0-develop.8",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "@kurocado-studio",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@kurocado-studio/axios-react": "^1.0.2",
|
|
38
38
|
"@kurocado-studio/systemhaus-react": "1.1.0-develop.12",
|
|
39
|
-
"@kurocado-studio/web-forms-react": "1.1.0-develop.
|
|
39
|
+
"@kurocado-studio/web-forms-react": "1.1.0-develop.2",
|
|
40
40
|
"axios": "^1.13.2",
|
|
41
41
|
"lodash-es": "^4.17.21",
|
|
42
42
|
"react": "19",
|