@form-instant/react-input-mapping 1.7.3-rc.1 → 1.7.7-rc.1

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.
@@ -1,7 +1,7 @@
1
1
  import { FC } from 'react';
2
- import { INPUT_COMPONENTS_KEYS } from './types';
2
+ import { INPUT_COMPONENTS_KEYS, ParsedField } from './types';
3
3
  type InputComponentMap<Ob extends Record<string, any>> = {
4
- [K in keyof Ob]?: FC<Ob[K]>;
4
+ [K in keyof Ob]?: FC<ParsedField<Ob[K]>>;
5
5
  } & {
6
6
  [K in INPUT_COMPONENTS_KEYS]?: FC<any>;
7
7
  };
@@ -1,3 +1,2 @@
1
1
  import { InputMapping } from './class';
2
- import { ObBase } from './types';
3
- export declare function createInputMappingContext<Ob extends Record<ObBase, any>>(): import("react").Context<InputMapping<Ob> | null>;
2
+ export declare const InputMappingContext: React.Context<InputMapping<any>>;
@@ -1,16 +1,15 @@
1
- import { FC, ReactNode } from 'react';
1
+ import { Context, FC, ReactNode } from 'react';
2
2
  import { InputMapping } from './class';
3
- import { ParsedField, ObBase } from './types';
4
- import { createInputMappingHook } from './useInputMapping';
3
+ import { ObBase, ParsedField } from './types';
5
4
  type FCC = React.FC<{
6
5
  children: ReactNode;
7
6
  }>;
8
7
  interface createFormInstantContainerReturn<Ob extends Record<ObBase, any>> {
9
- useInputMapping: ReturnType<typeof createInputMappingHook<Ob>>;
8
+ useInputMapping: Context<InputMapping<Ob>>;
10
9
  FormInstantInputsProvider: FCC;
11
10
  }
12
- export declare const createFormInstantContainer: <Ob extends Record<ObBase, any>>(inputMapping: InputMapping<Ob>) => createFormInstantContainerReturn<Ob>;
11
+ export declare const createFormInstantContainer: <Ob extends Record<any, any>>(inputMapping: InputMapping<Ob>) => createFormInstantContainerReturn<Ob>;
13
12
  export declare const ElementMapping: FC<{
14
- formProps: ParsedField<unknown, string>;
13
+ formProps: ParsedField<any, string>;
15
14
  }>;
16
15
  export {};
@@ -16,4 +16,4 @@ export type FieldConfig<AdditionalRenderable = object, FieldTypes = string> = {
16
16
  min?: number;
17
17
  max?: number;
18
18
  } & AdditionalRenderable;
19
- export type ObBase = INPUT_COMPONENTS_KEYS & string;
19
+ export type ObBase = INPUT_COMPONENTS_KEYS;
@@ -172,54 +172,32 @@ var InputMapping = /*#__PURE__*/function (_Map) {
172
172
  return InputMapping;
173
173
  }(/*#__PURE__*/_wrapNativeSuper(Map));
174
174
 
175
- function createInputMappingContext() {
176
- return react.createContext(null);
177
- }
178
-
179
- function createInputMappingHook(InputMappingContext) {
180
- return function useInputMapping() {
181
- var initialState = react.useContext(InputMappingContext);
182
- if (!initialState) throw new Error('InputMappingContext not found');
183
- var mapRef = react.useRef(initialState);
184
- var _useReducer = react.useReducer(function (x) {
185
- return x + 1;
186
- }, 0),
187
- reRender = _useReducer[1];
188
- return _extends({}, mapRef.current, {
189
- set: function set(key, value) {
190
- var result = mapRef.current.set(key, value);
191
- reRender();
192
- return result;
193
- },
194
- clear: function clear() {
195
- mapRef.current.clear();
196
- reRender();
197
- },
198
- "delete": function _delete(key) {
199
- var result = mapRef.current["delete"](key);
200
- reRender();
201
- return result;
202
- }
203
- });
204
- };
205
- }
175
+ var InputMappingContext = /*#__PURE__*/react.createContext(null);
206
176
 
207
177
  var createFormInstantContainer = function createFormInstantContainer(inputMapping) {
208
- var InputMappingContext = createInputMappingContext();
209
178
  var FormInstantInputsProvider = function FormInstantInputsProvider(props) {
210
179
  return react.createElement(InputMappingContext.Provider, {
211
180
  value: inputMapping,
212
181
  children: props.children
213
182
  });
214
183
  };
184
+ var useInputMapping = function useInputMapping() {
185
+ return react.useContext(InputMappingContext);
186
+ };
215
187
  return {
216
188
  FormInstantInputsProvider: FormInstantInputsProvider,
217
- useInputMapping: createInputMappingHook(InputMappingContext)
189
+ useInputMapping: useInputMapping
218
190
  };
219
191
  };
220
192
  var ElementMapping = function ElementMapping(_ref) {
221
- // Este componente no puede ser genérico, así que se mantiene igual
222
- return null;
193
+ var _formProps$fieldConfi;
194
+ var formProps = _ref.formProps;
195
+ if (!InputMappingContext) return null;
196
+ var InputMapping = react.useContext(InputMappingContext);
197
+ var type = ((_formProps$fieldConfi = formProps.fieldConfig) == null ? void 0 : _formProps$fieldConfi.type) || formProps.type;
198
+ var Element = InputMapping.get(type);
199
+ if (!Element) return null;
200
+ return react.createElement(Element, formProps);
223
201
  };
224
202
 
225
203
  var _excluded = ["fieldConfig", "name"];
@@ -252,10 +230,38 @@ var useFormInstantField = function useFormInstantField(_ref) {
252
230
  }, prop);
253
231
  };
254
232
 
233
+ function createInputMappingHook(InputMappingContext) {
234
+ return function useInputMapping() {
235
+ var initialState = react.useContext(InputMappingContext);
236
+ if (!initialState) throw new Error('InputMappingContext not found');
237
+ var mapRef = react.useRef(initialState);
238
+ var _useReducer = react.useReducer(function (x) {
239
+ return x + 1;
240
+ }, 0),
241
+ reRender = _useReducer[1];
242
+ return _extends({}, mapRef.current, {
243
+ set: function set(key, value) {
244
+ var result = mapRef.current.set(key, value);
245
+ reRender();
246
+ return result;
247
+ },
248
+ clear: function clear() {
249
+ mapRef.current.clear();
250
+ reRender();
251
+ },
252
+ "delete": function _delete(key) {
253
+ var result = mapRef.current["delete"](key);
254
+ reRender();
255
+ return result;
256
+ }
257
+ });
258
+ };
259
+ }
260
+
255
261
  exports.ElementMapping = ElementMapping;
256
262
  exports.InputMapping = InputMapping;
263
+ exports.InputMappingContext = InputMappingContext;
257
264
  exports.createFormInstantContainer = createFormInstantContainer;
258
- exports.createInputMappingContext = createInputMappingContext;
259
265
  exports.createInputMappingHook = createInputMappingHook;
260
266
  exports.useFormInstantField = useFormInstantField;
261
267
  //# sourceMappingURL=react-input-mapping.cjs.development.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"react-input-mapping.cjs.development.js","sources":["../src/InputMapping/class.ts","../src/InputMapping/context.tsx","../src/InputMapping/useInputMapping.tsx","../src/InputMapping/provider.tsx","../src/InputMapping/useFormInstantField.tsx"],"sourcesContent":["import { FC } from 'react';\nimport { INPUT_COMPONENTS_KEYS } from './types';\n\n// Nuevo tipo auxiliar para mapear cada clave a su componente correspondiente\n// Ahora el value depende de la key: si es de Ob, es FC<Ob[K]>; si es de INPUT_COMPONENTS_KEYS, es FC<any>\ntype InputComponentMap<Ob extends Record<string, any>> = {\n [K in keyof Ob]?: FC<Ob[K]>;\n} & {\n [K in INPUT_COMPONENTS_KEYS]?: FC<any>;\n};\n\nexport class InputMapping<Ob extends Record<string, any>> extends Map<\n keyof Ob | INPUT_COMPONENTS_KEYS,\n FC<any>\n> {\n private zodAdacter() {\n return Object.entries({\n ZodBoolean: 'checkbox',\n ZodDate: 'date',\n ZodEnum: 'select',\n ZodNativeEnum: 'select',\n ZodNumber: 'number',\n string: 'text',\n });\n }\n\n private appendObj(obj: Partial<InputComponentMap<Ob>>) {\n const keys = Object.keys(obj) as Array<keyof typeof obj>;\n\n for (const key of keys) {\n const value = obj[key];\n if (value && (key as string) in ({} as Ob)) {\n this.set(key as keyof Ob, value as FC<Ob[keyof Ob]>);\n } else if (value) {\n this.set(key as INPUT_COMPONENTS_KEYS, value as FC<any>);\n }\n }\n\n for (const [k, v] of this.zodAdacter()) {\n const existingValue = this.get(v as INPUT_COMPONENTS_KEYS);\n if (existingValue) {\n this.set(k as INPUT_COMPONENTS_KEYS, existingValue);\n }\n }\n }\n\n constructor(obj?: Partial<InputComponentMap<Ob>>) {\n super();\n if (!obj) return;\n this.appendObj(obj);\n }\n\n exists(k: string) {\n const isHas = super.has(k as keyof Ob | INPUT_COMPONENTS_KEYS);\n if (!isHas) return 'fallback';\n return k as keyof Ob | INPUT_COMPONENTS_KEYS;\n }\n\n get<Ky extends keyof Ob | INPUT_COMPONENTS_KEYS>(k: Ky) {\n return super.get(k);\n }\n\n set<K extends keyof Ob>(k: K, v: FC<Ob[K]>): this;\n set<K extends INPUT_COMPONENTS_KEYS>(k: K, v: FC<any>): this;\n set(k: keyof Ob | INPUT_COMPONENTS_KEYS, v: FC<any>): this {\n if (!super.has(k)) super.set(k, v);\n return this;\n }\n\n extends<Ext extends Record<string, FC<any>>>(\n cb: (mapping: InputMapping<Ob & { [K in keyof Ext]: any }>) => Ext,\n ) {\n const obj = Object.fromEntries(super.entries()) as Record<string, FC<any>>;\n const extendObj = cb(this as InputMapping<Ob & { [K in keyof Ext]: any }>);\n return new InputMapping<Ob & { [K in keyof Ext]: any }>({\n ...obj,\n ...extendObj,\n } as Partial<\n Record<\n keyof (Ob & { [K in keyof Ext]: any }) | INPUT_COMPONENTS_KEYS,\n FC<(Ob & { [K in keyof Ext]: any })[keyof (Ob & { [K in keyof Ext]: any })]>\n >\n >);\n }\n}\n","import { createContext } from 'react';\nimport { InputMapping } from './class';\nimport { ObBase } from './types';\n\nexport function createInputMappingContext<Ob extends Record<ObBase, any>>() {\n return createContext<InputMapping<Ob> | null>(null);\n}\n","import { useReducer, useRef, useContext } from 'react';\nimport { InputMapping } from './class';\n\nexport function createInputMappingHook<Ob extends Record<string, any>>(\n InputMappingContext: React.Context<InputMapping<Ob> | null>,\n) {\n return function useInputMapping() {\n const initialState = useContext(InputMappingContext);\n if (!initialState) throw new Error('InputMappingContext not found');\n const mapRef = useRef(initialState);\n const [, reRender] = useReducer((x) => x + 1, 0);\n\n return {\n ...mapRef.current,\n set: (key: keyof Ob | string, value: React.FC<any>) => {\n const result = mapRef.current.set(key, value);\n reRender();\n return result;\n },\n clear: () => {\n mapRef.current.clear();\n reRender();\n },\n delete: (key: keyof Ob | string) => {\n const result = mapRef.current.delete(key);\n reRender();\n return result;\n },\n };\n };\n}\n","import { createElement, FC, ReactNode, Context } from 'react';\nimport { InputMapping } from './class';\nimport { createInputMappingContext } from './context';\nimport { ParsedField, ObBase } from './types';\nimport { createInputMappingHook } from './useInputMapping';\n\ntype FCC = React.FC<{ children: ReactNode }>;\n\ninterface createFormInstantContainerReturn<Ob extends Record<ObBase, any>> {\n useInputMapping: ReturnType<typeof createInputMappingHook<Ob>>;\n FormInstantInputsProvider: FCC;\n}\n\nexport const createFormInstantContainer = <Ob extends Record<ObBase, any>>(\n inputMapping: InputMapping<Ob>,\n) => {\n const InputMappingContext: Context<InputMapping<Ob> | null> = createInputMappingContext<Ob>();\n\n const FormInstantInputsProvider: FCC = (props) =>\n createElement(InputMappingContext.Provider, {\n value: inputMapping,\n children: props.children,\n });\n\n return {\n FormInstantInputsProvider,\n useInputMapping: createInputMappingHook(InputMappingContext),\n } as createFormInstantContainerReturn<Ob>;\n};\n\nexport const ElementMapping: FC<{ formProps: ParsedField<unknown, string> }> = ({\n formProps: _formProps,\n}) => {\n // Este componente no puede ser genérico, así que se mantiene igual\n return null;\n};\n","import { useCallback, useState } from 'react';\nimport { ParsedField } from './types';\n\nexport const useFormInstantField = <P extends ParsedField<unknown, string>>({\n fieldConfig,\n name,\n ...prop\n}: P) => {\n const [fiends, setFiends] = useState(Object.values((prop.schema as P['schema']) || {}));\n\n const append = useCallback(() => {\n if (![fieldConfig?.max].includes(fiends.length)) setFiends((pre) => [...pre, pre[0]]);\n }, [fiends, fieldConfig?.max]);\n\n const remove = useCallback(\n (index: number) => {\n if (![fieldConfig?.min].includes(fiends.length))\n setFiends((pre) => pre.filter((_, i) => i !== index));\n },\n [fiends, fieldConfig?.min],\n );\n\n return { fiends, append, remove, setFiends, fieldConfig, name, ...prop };\n};\n"],"names":["InputMapping","_Map","obj","_this","call","_assertThisInitialized","appendObj","_inheritsLoose","_proto","prototype","zodAdacter","Object","entries","ZodBoolean","ZodDate","ZodEnum","ZodNativeEnum","ZodNumber","string","keys","_i","_keys","length","key","value","set","_iterator","_createForOfIteratorHelperLoose","_step","done","_step$value","k","v","existingValue","get","exists","isHas","has","extends","cb","fromEntries","extendObj","_extends2","_wrapNativeSuper","Map","createInputMappingContext","createContext","createInputMappingHook","InputMappingContext","useInputMapping","initialState","useContext","Error","mapRef","useRef","_useReducer","useReducer","x","reRender","_extends","current","result","clear","delete","createFormInstantContainer","inputMapping","FormInstantInputsProvider","props","createElement","Provider","children","ElementMapping","_ref","useFormInstantField","fieldConfig","name","prop","_objectWithoutPropertiesLoose","_excluded","_useState","useState","values","schema","fiends","setFiends","append","useCallback","max","includes","pre","concat","remove","index","min","filter","_","i"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWaA,IAAAA,YAA6C,0BAAAC,IAAA,EAAA;EAmCtD,SAAAD,YAAAA,CAAYE,GAAoC,EAAA;AAAA,IAAA,IAAAC,KAAA,CAAA;AAC5CA,IAAAA,KAAA,GAAAF,IAAA,CAAAG,IAAA,MAAO,IAAA,IAAA,CAAA;AACP,IAAA,IAAI,CAACF,GAAG,EAAE,OAAAG,sBAAA,CAAAF,KAAA,CAAA,CAAA;AACVA,IAAAA,KAAA,CAAKG,SAAS,CAACJ,GAAG,CAAC,CAAA;AAAC,IAAA,OAAAC,KAAA,CAAA;AACxB,GAAA;EAACI,cAAA,CAAAP,YAAA,EAAAC,IAAA,CAAA,CAAA;AAAA,EAAA,IAAAO,MAAA,GAAAR,YAAA,CAAAS,SAAA,CAAA;AAAAD,EAAAA,MAAA,CAnCOE,UAAU,GAAV,SAAAA,UAAUA,GAAA;IACd,OAAOC,MAAM,CAACC,OAAO,CAAC;AAClBC,MAAAA,UAAU,EAAE,UAAU;AACtBC,MAAAA,OAAO,EAAE,MAAM;AACfC,MAAAA,OAAO,EAAE,QAAQ;AACjBC,MAAAA,aAAa,EAAE,QAAQ;AACvBC,MAAAA,SAAS,EAAE,QAAQ;AACnBC,MAAAA,MAAM,EAAE,MAAA;AACX,KAAA,CAAC,CAAA;GACL,CAAA;AAAAV,EAAAA,MAAA,CAEOF,SAAS,GAAT,SAAAA,SAASA,CAACJ,GAAmC,EAAA;AACjD,IAAA,IAAMiB,IAAI,GAAGR,MAAM,CAACQ,IAAI,CAACjB,GAAG,CAA4B,CAAA;AAExD,IAAA,KAA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A,CAAA;AAAA,KAAC,CAAC,CAAA;GACxF,EAAE,CAACN,MAAM,EAAET,WAAW,oBAAXA,WAAW,CAAEa,GAAG,CAAC,CAAC,CAAA;AAE9B,EAAA,IAAMI,MAAM,GAAGL,iBAAW,CACtB,UAACM,KAAa,EAAI;AACd,IAAA,IAAI,CAAC,CAAClB,WAAW,oBAAXA,WAAW,CAAEmB,GAAG,CAAC,CAACL,QAAQ,CAACL,MAAM,CAAC7D,MAAM,CAAC,EAC3C8D,SAAS,CAAC,UAACK,GAAG,EAAA;AAAA,MAAA,OAAKA,GAAG,CAACK,MAAM,CAAC,UAACC,CAAC,EAAEC,CAAC,EAAA;QAAA,OAAKA,CAAC,KAAKJ,KAAK,CAAA;OAAC,CAAA,CAAA;KAAC,CAAA,CAAA;GAC5D,EACD,CAACT,MAAM,EAAET,WAAW,oBAAXA,WAAW,CAAEmB,GAAG,CAAC,CAC7B,CAAA;AAED,EAAA,OAAAlC,QAAA,CAAA;AAASwB,IAAAA,MAAM,EAANA,MAAM;AAAEE,IAAAA,MAAM,EAANA,MAAM;AAAEM,IAAAA,MAAM,EAANA,MAAM;AAAEP,IAAAA,SAAS,EAATA,SAAS;AAAEV,IAAAA,WAAW,EAAXA,WAAW;AAAEC,IAAAA,IAAI,EAAJA,IAAAA;AAAI,GAAA,EAAKC,IAAI,CAAA,CAAA;AAC1E;;;;;;;;;"}
1
+ {"version":3,"file":"react-input-mapping.cjs.development.js","sources":["../src/InputMapping/class.ts","../src/InputMapping/context.tsx","../src/InputMapping/provider.tsx","../src/InputMapping/useFormInstantField.tsx","../src/InputMapping/useInputMapping.tsx"],"sourcesContent":["import { FC } from 'react';\nimport { INPUT_COMPONENTS_KEYS, ParsedField } from './types';\n\n// Nuevo tipo auxiliar para mapear cada clave a su componente correspondiente\n// Ahora el value depende de la key: si es de Ob, es FC<Ob[K]>; si es de INPUT_COMPONENTS_KEYS, es FC<any>\ntype InputComponentMap<Ob extends Record<string, any>> = {\n [K in keyof Ob]?: FC<ParsedField<Ob[K]>>;\n} & {\n [K in INPUT_COMPONENTS_KEYS]?: FC<any>;\n};\n\nexport class InputMapping<Ob extends Record<string, any>> extends Map<\n keyof Ob | INPUT_COMPONENTS_KEYS,\n FC<any>\n> {\n private zodAdacter() {\n return Object.entries({\n ZodBoolean: 'checkbox',\n ZodDate: 'date',\n ZodEnum: 'select',\n ZodNativeEnum: 'select',\n ZodNumber: 'number',\n string: 'text',\n });\n }\n\n private appendObj(obj: Partial<InputComponentMap<Ob>>) {\n const keys = Object.keys(obj) as Array<keyof typeof obj>;\n\n for (const key of keys) {\n const value = obj[key];\n if (value && (key as string) in ({} as Ob)) {\n this.set(key as keyof Ob, value as FC<Ob[keyof Ob]>);\n } else if (value) {\n this.set(key as INPUT_COMPONENTS_KEYS, value as FC<any>);\n }\n }\n\n for (const [k, v] of this.zodAdacter()) {\n const existingValue = this.get(v as INPUT_COMPONENTS_KEYS);\n if (existingValue) {\n this.set(k as INPUT_COMPONENTS_KEYS, existingValue);\n }\n }\n }\n\n constructor(obj?: Partial<InputComponentMap<Ob>>) {\n super();\n if (!obj) return;\n this.appendObj(obj);\n }\n\n exists(k: string) {\n const isHas = super.has(k as keyof Ob | INPUT_COMPONENTS_KEYS);\n if (!isHas) return 'fallback';\n return k as keyof Ob | INPUT_COMPONENTS_KEYS;\n }\n\n get<Ky extends keyof Ob | INPUT_COMPONENTS_KEYS>(k: Ky) {\n return super.get(k);\n }\n\n set<K extends keyof Ob>(k: K, v: FC<Ob[K]>): this;\n set<K extends INPUT_COMPONENTS_KEYS>(k: K, v: FC<any>): this;\n set(k: keyof Ob | INPUT_COMPONENTS_KEYS, v: FC<any>): this {\n if (!super.has(k)) super.set(k, v);\n return this;\n }\n\n extends<Ext extends Record<string, FC<any>>>(\n cb: (mapping: InputMapping<Ob & { [K in keyof Ext]: any }>) => Ext,\n ) {\n const obj = Object.fromEntries(super.entries()) as Partial<InputComponentMap<Ob>>;\n const extendObj = cb(this as InputMapping<Ob & { [K in keyof Ext]: any }>) as Partial<\n InputComponentMap<{ [K in keyof Ext]: any }>\n >;\n return new InputMapping<Ob & { [K in keyof Ext]: any }>({\n ...(obj as Partial<InputComponentMap<Ob & { [K in keyof Ext]: any }>>),\n ...(extendObj as Partial<InputComponentMap<Ob & { [K in keyof Ext]: any }>>),\n });\n }\n}\n","import { createContext } from 'react';\nimport { InputMapping } from './class';\n\nexport const InputMappingContext = createContext<InputMapping<any> | null>(null) as React.Context<\n InputMapping<any>\n>;\n","import { Context, createElement, FC, ReactNode, useContext } from 'react';\nimport { InputMapping } from './class';\nimport { InputMappingContext } from './context';\nimport { ObBase, ParsedField } from './types';\n\ntype FCC = React.FC<{ children: ReactNode }>;\n\ninterface createFormInstantContainerReturn<Ob extends Record<ObBase, any>> {\n useInputMapping: Context<InputMapping<Ob>>;\n FormInstantInputsProvider: FCC;\n}\n\nexport const createFormInstantContainer = <Ob extends Record<any, any>>(\n inputMapping: InputMapping<Ob>\n) => {\n const FormInstantInputsProvider: FCC = (props) =>\n createElement(InputMappingContext.Provider, {\n value: inputMapping,\n children: props.children,\n });\n\n const useInputMapping = () => useContext(InputMappingContext);\n\n return {\n FormInstantInputsProvider,\n useInputMapping,\n } as unknown as createFormInstantContainerReturn<Ob>;\n};\n\nexport const ElementMapping: FC<{ formProps: ParsedField<any, string> }> = ({ formProps }) => {\n if (!InputMappingContext) return null;\n\n const InputMapping = useContext(InputMappingContext);\n\n const type = formProps.fieldConfig?.type || formProps.type;\n\n const Element = InputMapping.get(type);\n\n if (!Element) return null;\n\n return createElement(Element, formProps);\n};\n","import { useCallback, useState } from 'react';\nimport { ParsedField } from './types';\n\nexport const useFormInstantField = <P extends ParsedField<unknown, string>>({\n fieldConfig,\n name,\n ...prop\n}: P) => {\n const [fiends, setFiends] = useState(Object.values((prop.schema as P['schema']) || {}));\n\n const append = useCallback(() => {\n if (![fieldConfig?.max].includes(fiends.length)) setFiends((pre) => [...pre, pre[0]]);\n }, [fiends, fieldConfig?.max]);\n\n const remove = useCallback(\n (index: number) => {\n if (![fieldConfig?.min].includes(fiends.length))\n setFiends((pre) => pre.filter((_, i) => i !== index));\n },\n [fiends, fieldConfig?.min],\n );\n\n return { fiends, append, remove, setFiends, fieldConfig, name, ...prop };\n};\n","import { useReducer, useRef, useContext } from 'react';\nimport { InputMapping } from './class';\n\nexport function createInputMappingHook<Ob extends Record<string, any>>(\n InputMappingContext: React.Context<InputMapping<Ob> | null>,\n) {\n return function useInputMapping() {\n const initialState = useContext(InputMappingContext);\n if (!initialState) throw new Error('InputMappingContext not found');\n const mapRef = useRef(initialState);\n const [, reRender] = useReducer((x) => x + 1, 0);\n\n return {\n ...mapRef.current,\n set: (key: keyof Ob | string, value: React.FC<any>) => {\n const result = mapRef.current.set(key, value);\n reRender();\n return result;\n },\n clear: () => {\n mapRef.current.clear();\n reRender();\n },\n delete: (key: keyof Ob | string) => {\n const result = mapRef.current.delete(key);\n reRender();\n return result;\n },\n };\n };\n}\n"],"names":["InputMapping","_Map","obj","_this","call","_assertThisInitialized","appendObj","_inheritsLoose","_proto","prototype","zodAdacter","Object","entries","ZodBoolean","ZodDate","ZodEnum","ZodNativeEnum","ZodNumber","string","keys","_i","_keys","length","key","value","set","_iterator","_createForOfIteratorHelperLoose","_step","done","_step$value","k","v","existingValue","get","exists","isHas","has","extends","cb","fromEntries","extendObj","_extends2","_wrapNativeSuper","Map","InputMappingContext","createContext","createFormInstantContainer","inputMapping","FormInstantInputsProvider","props","createElement","Provider","children","useInputMapping","useContext","ElementMapping","_ref","_formProps$fieldConfi","formProps","type","fieldConfig","Element","useFormInstantField","name","prop","_objectWithoutPropertiesLoose","_excluded","_useState","useState","values","schema","fiends","setFiends","append","useCallback","max","includes","pre","concat","remove","index","min","filter","_","i","_extends","createInputMappingHook","initialState","Error","mapRef","useRef","_useReducer","useReducer","x","reRender","current","result","clear","delete"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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1,2 @@
1
- "use strict";var t=require("react");function e(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function n(){return n=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},n.apply(null,arguments)}function r(t){return r=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},r(t)}function o(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(o=function(){return!!t})()}function u(t,e){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},u(t,e)}function i(t){var e="function"==typeof Map?new Map:void 0;return i=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return function(t,e,n){if(o())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,e);var i=new(t.bind.apply(t,r));return n&&u(i,n.prototype),i}(t,arguments,r(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),u(n,t)},i(t)}var a=function(t){function r(e){var n;return n=t.call(this)||this,e?(n.appendObj(e),n):function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(n)}var o,i;i=t,(o=r).prototype=Object.create(i.prototype),o.prototype.constructor=o,u(o,i);var a=r.prototype;return a.zodAdacter=function(){return Object.entries({ZodBoolean:"checkbox",ZodDate:"date",ZodEnum:"select",ZodNativeEnum:"select",ZodNumber:"number",string:"text"})},a.appendObj=function(t){for(var n=0,r=Object.keys(t);n<r.length;n++){var o=r[n],u=t[o];(u&&o in{}||u)&&this.set(o,u)}for(var i,a=function(t){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(n)return(n=n.call(t)).next.bind(n);if(Array.isArray(t)||(n=function(t,n){if(t){if("string"==typeof t)return e(t,n);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?e(t,n):void 0}}(t))){n&&(t=n);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(this.zodAdacter());!(i=a()).done;){var c=i.value,l=c[0],f=this.get(c[1]);f&&this.set(l,f)}},a.exists=function(e){return t.prototype.has.call(this,e)?e:"fallback"},a.get=function(e){return t.prototype.get.call(this,e)},a.set=function(e,n){return t.prototype.has.call(this,e)||t.prototype.set.call(this,e,n),this},a.extends=function(e){return new r(n({},Object.fromEntries(t.prototype.entries.call(this)),e(this)))},r}(i(Map));function c(){return t.createContext(null)}function l(e){return function(){var r=t.useContext(e);if(!r)throw new Error("InputMappingContext not found");var o=t.useRef(r),u=t.useReducer(function(t){return t+1},0)[1];return n({},o.current,{set:function(t,e){var n=o.current.set(t,e);return u(),n},clear:function(){o.current.clear(),u()},delete:function(t){var e=o.current.delete(t);return u(),e}})}}var f=["fieldConfig","name"];exports.ElementMapping=function(t){return null},exports.InputMapping=a,exports.createFormInstantContainer=function(e){var n=c();return{FormInstantInputsProvider:function(r){return t.createElement(n.Provider,{value:e,children:r.children})},useInputMapping:l(n)}},exports.createInputMappingContext=c,exports.createInputMappingHook=l,exports.useFormInstantField=function(e){var r=e.fieldConfig,o=e.name,u=function(t,e){if(null==t)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(-1!==e.indexOf(r))continue;n[r]=t[r]}return n}(e,f),i=t.useState(Object.values(u.schema||{})),a=i[0],c=i[1],l=t.useCallback(function(){[null==r?void 0:r.max].includes(a.length)||c(function(t){return[].concat(t,[t[0]])})},[a,null==r?void 0:r.max]),s=t.useCallback(function(t){[null==r?void 0:r.min].includes(a.length)||c(function(e){return e.filter(function(e,n){return n!==t})})},[a,null==r?void 0:r.min]);return n({fiends:a,append:l,remove:s,setFiends:c,fieldConfig:r,name:o},u)};
1
+ "use strict";var t=require("react");function e(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function n(){return n=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},n.apply(null,arguments)}function r(t){return r=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},r(t)}function o(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(o=function(){return!!t})()}function u(t,e){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},u(t,e)}function i(t){var e="function"==typeof Map?new Map:void 0;return i=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return function(t,e,n){if(o())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,e);var i=new(t.bind.apply(t,r));return n&&u(i,n.prototype),i}(t,arguments,r(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),u(n,t)},i(t)}var a=function(t){function r(e){var n;return n=t.call(this)||this,e?(n.appendObj(e),n):function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(n)}var o,i;i=t,(o=r).prototype=Object.create(i.prototype),o.prototype.constructor=o,u(o,i);var a=r.prototype;return a.zodAdacter=function(){return Object.entries({ZodBoolean:"checkbox",ZodDate:"date",ZodEnum:"select",ZodNativeEnum:"select",ZodNumber:"number",string:"text"})},a.appendObj=function(t){for(var n=0,r=Object.keys(t);n<r.length;n++){var o=r[n],u=t[o];(u&&o in{}||u)&&this.set(o,u)}for(var i,a=function(t){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(n)return(n=n.call(t)).next.bind(n);if(Array.isArray(t)||(n=function(t,n){if(t){if("string"==typeof t)return e(t,n);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?e(t,n):void 0}}(t))){n&&(t=n);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(this.zodAdacter());!(i=a()).done;){var c=i.value,l=c[0],f=this.get(c[1]);f&&this.set(l,f)}},a.exists=function(e){return t.prototype.has.call(this,e)?e:"fallback"},a.get=function(e){return t.prototype.get.call(this,e)},a.set=function(e,n){return t.prototype.has.call(this,e)||t.prototype.set.call(this,e,n),this},a.extends=function(e){return new r(n({},Object.fromEntries(t.prototype.entries.call(this)),e(this)))},r}(i(Map)),c=t.createContext(null),l=["fieldConfig","name"];exports.ElementMapping=function(e){var n,r=e.formProps;if(!c)return null;var o=t.useContext(c),u=(null==(n=r.fieldConfig)?void 0:n.type)||r.type,i=o.get(u);return i?t.createElement(i,r):null},exports.InputMapping=a,exports.InputMappingContext=c,exports.createFormInstantContainer=function(e){return{FormInstantInputsProvider:function(n){return t.createElement(c.Provider,{value:e,children:n.children})},useInputMapping:function(){return t.useContext(c)}}},exports.createInputMappingHook=function(e){return function(){var r=t.useContext(e);if(!r)throw new Error("InputMappingContext not found");var o=t.useRef(r),u=t.useReducer(function(t){return t+1},0)[1];return n({},o.current,{set:function(t,e){var n=o.current.set(t,e);return u(),n},clear:function(){o.current.clear(),u()},delete:function(t){var e=o.current.delete(t);return u(),e}})}},exports.useFormInstantField=function(e){var r=e.fieldConfig,o=e.name,u=function(t,e){if(null==t)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(-1!==e.indexOf(r))continue;n[r]=t[r]}return n}(e,l),i=t.useState(Object.values(u.schema||{})),a=i[0],c=i[1],f=t.useCallback(function(){[null==r?void 0:r.max].includes(a.length)||c(function(t){return[].concat(t,[t[0]])})},[a,null==r?void 0:r.max]),s=t.useCallback(function(t){[null==r?void 0:r.min].includes(a.length)||c(function(e){return e.filter(function(e,n){return n!==t})})},[a,null==r?void 0:r.min]);return n({fiends:a,append:f,remove:s,setFiends:c,fieldConfig:r,name:o},u)};
2
2
  //# sourceMappingURL=react-input-mapping.cjs.production.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"react-input-mapping.cjs.production.min.js","sources":["../src/InputMapping/class.ts","../src/InputMapping/context.tsx","../src/InputMapping/useInputMapping.tsx","../src/InputMapping/provider.tsx","../src/InputMapping/useFormInstantField.tsx"],"sourcesContent":["import { FC } from 'react';\nimport { INPUT_COMPONENTS_KEYS } from './types';\n\n// Nuevo tipo auxiliar para mapear cada clave a su componente correspondiente\n// Ahora el value depende de la key: si es de Ob, es FC<Ob[K]>; si es de INPUT_COMPONENTS_KEYS, es FC<any>\ntype InputComponentMap<Ob extends Record<string, any>> = {\n [K in keyof Ob]?: FC<Ob[K]>;\n} & {\n [K in INPUT_COMPONENTS_KEYS]?: FC<any>;\n};\n\nexport class InputMapping<Ob extends Record<string, any>> extends Map<\n keyof Ob | INPUT_COMPONENTS_KEYS,\n FC<any>\n> {\n private zodAdacter() {\n return Object.entries({\n ZodBoolean: 'checkbox',\n ZodDate: 'date',\n ZodEnum: 'select',\n ZodNativeEnum: 'select',\n ZodNumber: 'number',\n string: 'text',\n });\n }\n\n private appendObj(obj: Partial<InputComponentMap<Ob>>) {\n const keys = Object.keys(obj) as Array<keyof typeof obj>;\n\n for (const key of keys) {\n const value = obj[key];\n if (value && (key as string) in ({} as Ob)) {\n this.set(key as keyof Ob, value as FC<Ob[keyof Ob]>);\n } else if (value) {\n this.set(key as INPUT_COMPONENTS_KEYS, value as FC<any>);\n }\n }\n\n for (const [k, v] of this.zodAdacter()) {\n const existingValue = this.get(v as INPUT_COMPONENTS_KEYS);\n if (existingValue) {\n this.set(k as INPUT_COMPONENTS_KEYS, existingValue);\n }\n }\n }\n\n constructor(obj?: Partial<InputComponentMap<Ob>>) {\n super();\n if (!obj) return;\n this.appendObj(obj);\n }\n\n exists(k: string) {\n const isHas = super.has(k as keyof Ob | INPUT_COMPONENTS_KEYS);\n if (!isHas) return 'fallback';\n return k as keyof Ob | INPUT_COMPONENTS_KEYS;\n }\n\n get<Ky extends keyof Ob | INPUT_COMPONENTS_KEYS>(k: Ky) {\n return super.get(k);\n }\n\n set<K extends keyof Ob>(k: K, v: FC<Ob[K]>): this;\n set<K extends INPUT_COMPONENTS_KEYS>(k: K, v: FC<any>): this;\n set(k: keyof Ob | INPUT_COMPONENTS_KEYS, v: FC<any>): this {\n if (!super.has(k)) super.set(k, v);\n return this;\n }\n\n extends<Ext extends Record<string, FC<any>>>(\n cb: (mapping: InputMapping<Ob & { [K in keyof Ext]: any }>) => Ext,\n ) {\n const obj = Object.fromEntries(super.entries()) as Record<string, FC<any>>;\n const extendObj = cb(this as InputMapping<Ob & { [K in keyof Ext]: any }>);\n return new InputMapping<Ob & { [K in keyof Ext]: any }>({\n ...obj,\n ...extendObj,\n } as Partial<\n Record<\n keyof (Ob & { [K in keyof Ext]: any }) | INPUT_COMPONENTS_KEYS,\n FC<(Ob & { [K in keyof Ext]: any })[keyof (Ob & { [K in keyof Ext]: any })]>\n >\n >);\n }\n}\n","import { createContext } from 'react';\nimport { InputMapping } from './class';\nimport { ObBase } from './types';\n\nexport function createInputMappingContext<Ob extends Record<ObBase, any>>() {\n return createContext<InputMapping<Ob> | null>(null);\n}\n","import { useReducer, useRef, useContext } from 'react';\nimport { InputMapping } from './class';\n\nexport function createInputMappingHook<Ob extends Record<string, any>>(\n InputMappingContext: React.Context<InputMapping<Ob> | null>,\n) {\n return function useInputMapping() {\n const initialState = useContext(InputMappingContext);\n if (!initialState) throw new Error('InputMappingContext not found');\n const mapRef = useRef(initialState);\n const [, reRender] = useReducer((x) => x + 1, 0);\n\n return {\n ...mapRef.current,\n set: (key: keyof Ob | string, value: React.FC<any>) => {\n const result = mapRef.current.set(key, value);\n reRender();\n return result;\n },\n clear: () => {\n mapRef.current.clear();\n reRender();\n },\n delete: (key: keyof Ob | string) => {\n const result = mapRef.current.delete(key);\n reRender();\n return result;\n },\n };\n };\n}\n","import { createElement, FC, ReactNode, Context } from 'react';\nimport { InputMapping } from './class';\nimport { createInputMappingContext } from './context';\nimport { ParsedField, ObBase } from './types';\nimport { createInputMappingHook } from './useInputMapping';\n\ntype FCC = React.FC<{ children: ReactNode }>;\n\ninterface createFormInstantContainerReturn<Ob extends Record<ObBase, any>> {\n useInputMapping: ReturnType<typeof createInputMappingHook<Ob>>;\n FormInstantInputsProvider: FCC;\n}\n\nexport const createFormInstantContainer = <Ob extends Record<ObBase, any>>(\n inputMapping: InputMapping<Ob>,\n) => {\n const InputMappingContext: Context<InputMapping<Ob> | null> = createInputMappingContext<Ob>();\n\n const FormInstantInputsProvider: FCC = (props) =>\n createElement(InputMappingContext.Provider, {\n value: inputMapping,\n children: props.children,\n });\n\n return {\n FormInstantInputsProvider,\n useInputMapping: createInputMappingHook(InputMappingContext),\n } as createFormInstantContainerReturn<Ob>;\n};\n\nexport const ElementMapping: FC<{ formProps: ParsedField<unknown, string> }> = ({\n formProps: _formProps,\n}) => {\n // Este componente no puede ser genérico, así que se mantiene igual\n return null;\n};\n","import { useCallback, useState } from 'react';\nimport { ParsedField } from './types';\n\nexport const useFormInstantField = <P extends ParsedField<unknown, string>>({\n fieldConfig,\n name,\n ...prop\n}: P) => {\n const [fiends, setFiends] = useState(Object.values((prop.schema as P['schema']) || {}));\n\n const append = useCallback(() => {\n if (![fieldConfig?.max].includes(fiends.length)) setFiends((pre) => [...pre, pre[0]]);\n }, [fiends, fieldConfig?.max]);\n\n const remove = useCallback(\n (index: number) => {\n if (![fieldConfig?.min].includes(fiends.length))\n setFiends((pre) => pre.filter((_, i) => i !== index));\n },\n [fiends, fieldConfig?.min],\n );\n\n return { fiends, append, remove, setFiends, fieldConfig, name, ...prop };\n};\n"],"names":["InputMapping","_Map","obj","_this","call","this","appendObj","_assertThisInitialized","_proto","prototype","zodAdacter","Object","entries","ZodBoolean","ZodDate","ZodEnum","ZodNativeEnum","ZodNumber","string","_i","_keys","keys","length","key","value","set","_step","_iterator","_createForOfIteratorHelperLoose","done","_step$value","k","existingValue","get","exists","has","v","cb","_extends2","fromEntries","_wrapNativeSuper","Map","createInputMappingContext","createContext","createInputMappingHook","InputMappingContext","initialState","useContext","Error","mapRef","useRef","reRender","useReducer","x","_extends","current","result","clear","delete","_ref","inputMapping","FormInstantInputsProvider","props","createElement","Provider","children","useInputMapping","fieldConfig","name","prop","_objectWithoutPropertiesLoose","_excluded","_useState","useState","values","schema","fiends","setFiends","append","useCallback","max","includes","pre","concat","remove","index","min","filter","_","i"],"mappings":"07CAWaA,IAAAA,WAA6CC,GAmCtD,SAAAD,EAAYE,GAAoC,IAAAC,EAE5C,OADAA,EAAAF,EAAAG,YAAOC,KACFH,GACLC,EAAKG,UAAUJ,GAAKC,4HADVI,CAAAJ,EAEd,WAACF,KAAAD,yEAAA,IAAAQ,EAAAR,EAAAS,UAiCA,OAjCAD,EAnCOE,WAAA,WACJ,OAAOC,OAAOC,QAAQ,CAClBC,WAAY,WACZC,QAAS,OACTC,QAAS,SACTC,cAAe,SACfC,UAAW,SACXC,OAAQ,UAEfV,EAEOF,UAAA,SAAUJ,GAGd,IAFA,IAEAiB,EAAA,EAAAC,EAFaT,OAAOU,KAAKnB,GAEHiB,EAAAC,EA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,WACHR,EAAOM,QAAQE,QACfN,GACH,EACDO,OAAQ,SAACnC,GACL,IAAMiC,EAASP,EAAOM,QAAc,OAAChC,GAErC,OADA4B,IACOK,CACX,IAGZ,qDCA+E,SAApDG,GAIvB,OAAO,IACX,4DAtB0C,SACtCC,GAEA,IAAMf,EAAwDH,IAQ9D,MAAO,CACHmB,0BAPmC,SAACC,GAAK,OACzCC,EAAaA,cAAClB,EAAoBmB,SAAU,CACxCxC,MAAOoC,EACPK,SAAUH,EAAMG,UAClB,EAIFC,gBAAiBtB,EAAuBC,GAEhD,mGCzBmC,SAAHc,GAIxB,IAHJQ,EAAWR,EAAXQ,YACAC,EAAIT,EAAJS,KACGC,6IAAIC,CAAAX,EAAAY,GAEPC,EAA4BC,EAAAA,SAAS9D,OAAO+D,OAAQL,EAAKM,QAA0B,CAAA,IAA5EC,EAAMJ,EAAA,GAAEK,EAASL,EAAA,GAElBM,EAASC,EAAAA,YAAY,WAClB,OAACZ,SAAAA,EAAaa,KAAKC,SAASL,EAAOtD,SAASuD,EAAU,SAACK,GAAG,MAAA,GAAAC,OAASD,GAAKA,EAAI,IAAE,IACpF,CAACN,QAAQT,SAAAA,EAAaa,MAEnBI,EAASL,cACX,SAACM,GACQ,OAAClB,SAAAA,EAAamB,KAAKL,SAASL,EAAOtD,SACpCuD,EAAU,SAACK,GAAG,OAAKA,EAAIK,OAAO,SAACC,EAAGC,GAAC,OAAKA,IAAMJ,OAEtD,CAACT,QAAQT,SAAAA,EAAamB,MAG1B,OAAAhC,EAAA,CAASsB,OAAAA,EAAQE,OAAAA,EAAQM,OAAAA,EAAQP,UAAAA,EAAWV,YAAAA,EAAaC,KAAAA,GAASC,EACtE"}
1
+ {"version":3,"file":"react-input-mapping.cjs.production.min.js","sources":["../src/InputMapping/class.ts","../src/InputMapping/context.tsx","../src/InputMapping/provider.tsx","../src/InputMapping/useInputMapping.tsx","../src/InputMapping/useFormInstantField.tsx"],"sourcesContent":["import { FC } from 'react';\nimport { INPUT_COMPONENTS_KEYS, ParsedField } from './types';\n\n// Nuevo tipo auxiliar para mapear cada clave a su componente correspondiente\n// Ahora el value depende de la key: si es de Ob, es FC<Ob[K]>; si es de INPUT_COMPONENTS_KEYS, es FC<any>\ntype InputComponentMap<Ob extends Record<string, any>> = {\n [K in keyof Ob]?: FC<ParsedField<Ob[K]>>;\n} & {\n [K in INPUT_COMPONENTS_KEYS]?: FC<any>;\n};\n\nexport class InputMapping<Ob extends Record<string, any>> extends Map<\n keyof Ob | INPUT_COMPONENTS_KEYS,\n FC<any>\n> {\n private zodAdacter() {\n return Object.entries({\n ZodBoolean: 'checkbox',\n ZodDate: 'date',\n ZodEnum: 'select',\n ZodNativeEnum: 'select',\n ZodNumber: 'number',\n string: 'text',\n });\n }\n\n private appendObj(obj: Partial<InputComponentMap<Ob>>) {\n const keys = Object.keys(obj) as Array<keyof typeof obj>;\n\n for (const key of keys) {\n const value = obj[key];\n if (value && (key as string) in ({} as Ob)) {\n this.set(key as keyof Ob, value as FC<Ob[keyof Ob]>);\n } else if (value) {\n this.set(key as INPUT_COMPONENTS_KEYS, value as FC<any>);\n }\n }\n\n for (const [k, v] of this.zodAdacter()) {\n const existingValue = this.get(v as INPUT_COMPONENTS_KEYS);\n if (existingValue) {\n this.set(k as INPUT_COMPONENTS_KEYS, existingValue);\n }\n }\n }\n\n constructor(obj?: Partial<InputComponentMap<Ob>>) {\n super();\n if (!obj) return;\n this.appendObj(obj);\n }\n\n exists(k: string) {\n const isHas = super.has(k as keyof Ob | INPUT_COMPONENTS_KEYS);\n if (!isHas) return 'fallback';\n return k as keyof Ob | INPUT_COMPONENTS_KEYS;\n }\n\n get<Ky extends keyof Ob | INPUT_COMPONENTS_KEYS>(k: Ky) {\n return super.get(k);\n }\n\n set<K extends keyof Ob>(k: K, v: FC<Ob[K]>): this;\n set<K extends INPUT_COMPONENTS_KEYS>(k: K, v: FC<any>): this;\n set(k: keyof Ob | INPUT_COMPONENTS_KEYS, v: FC<any>): this {\n if (!super.has(k)) super.set(k, v);\n return this;\n }\n\n extends<Ext extends Record<string, FC<any>>>(\n cb: (mapping: InputMapping<Ob & { [K in keyof Ext]: any }>) => Ext,\n ) {\n const obj = Object.fromEntries(super.entries()) as Partial<InputComponentMap<Ob>>;\n const extendObj = cb(this as InputMapping<Ob & { [K in keyof Ext]: any }>) as Partial<\n InputComponentMap<{ [K in keyof Ext]: any }>\n >;\n return new InputMapping<Ob & { [K in keyof Ext]: any }>({\n ...(obj as Partial<InputComponentMap<Ob & { [K in keyof Ext]: any }>>),\n ...(extendObj as Partial<InputComponentMap<Ob & { [K in keyof Ext]: any }>>),\n });\n }\n}\n","import { createContext } from 'react';\nimport { InputMapping } from './class';\n\nexport const InputMappingContext = createContext<InputMapping<any> | null>(null) as React.Context<\n InputMapping<any>\n>;\n","import { Context, createElement, FC, ReactNode, useContext } from 'react';\nimport { InputMapping } from './class';\nimport { InputMappingContext } from './context';\nimport { ObBase, ParsedField } from './types';\n\ntype FCC = React.FC<{ children: ReactNode }>;\n\ninterface createFormInstantContainerReturn<Ob extends Record<ObBase, any>> {\n useInputMapping: Context<InputMapping<Ob>>;\n FormInstantInputsProvider: FCC;\n}\n\nexport const createFormInstantContainer = <Ob extends Record<any, any>>(\n inputMapping: InputMapping<Ob>\n) => {\n const FormInstantInputsProvider: FCC = (props) =>\n createElement(InputMappingContext.Provider, {\n value: inputMapping,\n children: props.children,\n });\n\n const useInputMapping = () => useContext(InputMappingContext);\n\n return {\n FormInstantInputsProvider,\n useInputMapping,\n } as unknown as createFormInstantContainerReturn<Ob>;\n};\n\nexport const ElementMapping: FC<{ formProps: ParsedField<any, string> }> = ({ formProps }) => {\n if (!InputMappingContext) return null;\n\n const InputMapping = useContext(InputMappingContext);\n\n const type = formProps.fieldConfig?.type || formProps.type;\n\n const Element = InputMapping.get(type);\n\n if (!Element) return null;\n\n return createElement(Element, formProps);\n};\n","import { useReducer, useRef, useContext } from 'react';\nimport { InputMapping } from './class';\n\nexport function createInputMappingHook<Ob extends Record<string, any>>(\n InputMappingContext: React.Context<InputMapping<Ob> | null>,\n) {\n return function useInputMapping() {\n const initialState = useContext(InputMappingContext);\n if (!initialState) throw new Error('InputMappingContext not found');\n const mapRef = useRef(initialState);\n const [, reRender] = useReducer((x) => x + 1, 0);\n\n return {\n ...mapRef.current,\n set: (key: keyof Ob | string, value: React.FC<any>) => {\n const result = mapRef.current.set(key, value);\n reRender();\n return result;\n },\n clear: () => {\n mapRef.current.clear();\n reRender();\n },\n delete: (key: keyof Ob | string) => {\n const result = mapRef.current.delete(key);\n reRender();\n return result;\n },\n };\n };\n}\n","import { useCallback, useState } from 'react';\nimport { ParsedField } from './types';\n\nexport const useFormInstantField = <P extends ParsedField<unknown, string>>({\n fieldConfig,\n name,\n ...prop\n}: P) => {\n const [fiends, setFiends] = useState(Object.values((prop.schema as P['schema']) || {}));\n\n const append = useCallback(() => {\n if (![fieldConfig?.max].includes(fiends.length)) setFiends((pre) => [...pre, pre[0]]);\n }, [fiends, fieldConfig?.max]);\n\n const remove = useCallback(\n (index: number) => {\n if (![fieldConfig?.min].includes(fiends.length))\n setFiends((pre) => pre.filter((_, i) => i !== index));\n },\n [fiends, fieldConfig?.min],\n );\n\n return { fiends, append, remove, setFiends, fieldConfig, name, ...prop };\n};\n"],"names":["InputMapping","_Map","obj","_this","call","this","appendObj","_assertThisInitialized","_proto","prototype","zodAdacter","Object","entries","ZodBoolean","ZodDate","ZodEnum","ZodNativeEnum","ZodNumber","string","_i","_keys","keys","length","key","value","set","_step","_iterator","_createForOfIteratorHelperLoose","done","_step$value","k","existingValue","get","exists","has","v","cb","_extends2","fromEntries","_wrapNativeSuper","Map","InputMappingContext","createContext","_ref","_formProps$fieldConfi","formProps","useContext","type","fieldConfig","Element","createElement","inputMapping","FormInstantInputsProvider","props","Provider","children","useInputMapping","initialState","Error","mapRef","useRef","reRender","useReducer","x","_extends","current","result","clear","delete","name","prop","_objectWithoutPropertiesLoose","_excluded","_useState","useState","values","schema","fiends","setFiends","append","useC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,EAAA,GAAEK,EAASL,EAAA,GAElBM,EAASC,EAAAA,YAAY,WAClB,OAAChC,SAAAA,EAAaiC,KAAKC,SAASL,EAAOxD,SAASyD,EAAU,SAACK,GAAG,MAAA,GAAAC,OAASD,GAAKA,EAAI,IAAE,IACpF,CAACN,QAAQ7B,SAAAA,EAAaiC,MAEnBI,EAASL,cACX,SAACM,GACQ,OAACtC,SAAAA,EAAauC,KAAKL,SAASL,EAAOxD,SACpCyD,EAAU,SAACK,GAAG,OAAKA,EAAIK,OAAO,SAACC,EAAGC,GAAC,OAAKA,IAAMJ,OAEtD,CAACT,QAAQ7B,SAAAA,EAAauC,MAG1B,OAAAvB,EAAA,CAASa,OAAAA,EAAQE,OAAAA,EAAQM,OAAAA,EAAQP,UAAAA,EAAW9B,YAAAA,EAAaqB,KAAAA,GAASC,EACtE"}
@@ -1,4 +1,4 @@
1
- import { createContext, useContext, useRef, useReducer, createElement, useState, useCallback } from 'react';
1
+ import { createContext, useContext, createElement, useState, useCallback, useRef, useReducer } from 'react';
2
2
 
3
3
  function _arrayLikeToArray(r, a) {
4
4
  (null == a || a > r.length) && (a = r.length);
@@ -170,54 +170,32 @@ var InputMapping = /*#__PURE__*/function (_Map) {
170
170
  return InputMapping;
171
171
  }(/*#__PURE__*/_wrapNativeSuper(Map));
172
172
 
173
- function createInputMappingContext() {
174
- return createContext(null);
175
- }
176
-
177
- function createInputMappingHook(InputMappingContext) {
178
- return function useInputMapping() {
179
- var initialState = useContext(InputMappingContext);
180
- if (!initialState) throw new Error('InputMappingContext not found');
181
- var mapRef = useRef(initialState);
182
- var _useReducer = useReducer(function (x) {
183
- return x + 1;
184
- }, 0),
185
- reRender = _useReducer[1];
186
- return _extends({}, mapRef.current, {
187
- set: function set(key, value) {
188
- var result = mapRef.current.set(key, value);
189
- reRender();
190
- return result;
191
- },
192
- clear: function clear() {
193
- mapRef.current.clear();
194
- reRender();
195
- },
196
- "delete": function _delete(key) {
197
- var result = mapRef.current["delete"](key);
198
- reRender();
199
- return result;
200
- }
201
- });
202
- };
203
- }
173
+ var InputMappingContext = /*#__PURE__*/createContext(null);
204
174
 
205
175
  var createFormInstantContainer = function createFormInstantContainer(inputMapping) {
206
- var InputMappingContext = createInputMappingContext();
207
176
  var FormInstantInputsProvider = function FormInstantInputsProvider(props) {
208
177
  return createElement(InputMappingContext.Provider, {
209
178
  value: inputMapping,
210
179
  children: props.children
211
180
  });
212
181
  };
182
+ var useInputMapping = function useInputMapping() {
183
+ return useContext(InputMappingContext);
184
+ };
213
185
  return {
214
186
  FormInstantInputsProvider: FormInstantInputsProvider,
215
- useInputMapping: createInputMappingHook(InputMappingContext)
187
+ useInputMapping: useInputMapping
216
188
  };
217
189
  };
218
190
  var ElementMapping = function ElementMapping(_ref) {
219
- // Este componente no puede ser genérico, así que se mantiene igual
220
- return null;
191
+ var _formProps$fieldConfi;
192
+ var formProps = _ref.formProps;
193
+ if (!InputMappingContext) return null;
194
+ var InputMapping = useContext(InputMappingContext);
195
+ var type = ((_formProps$fieldConfi = formProps.fieldConfig) == null ? void 0 : _formProps$fieldConfi.type) || formProps.type;
196
+ var Element = InputMapping.get(type);
197
+ if (!Element) return null;
198
+ return createElement(Element, formProps);
221
199
  };
222
200
 
223
201
  var _excluded = ["fieldConfig", "name"];
@@ -250,5 +228,33 @@ var useFormInstantField = function useFormInstantField(_ref) {
250
228
  }, prop);
251
229
  };
252
230
 
253
- export { ElementMapping, InputMapping, createFormInstantContainer, createInputMappingContext, createInputMappingHook, useFormInstantField };
231
+ function createInputMappingHook(InputMappingContext) {
232
+ return function useInputMapping() {
233
+ var initialState = useContext(InputMappingContext);
234
+ if (!initialState) throw new Error('InputMappingContext not found');
235
+ var mapRef = useRef(initialState);
236
+ var _useReducer = useReducer(function (x) {
237
+ return x + 1;
238
+ }, 0),
239
+ reRender = _useReducer[1];
240
+ return _extends({}, mapRef.current, {
241
+ set: function set(key, value) {
242
+ var result = mapRef.current.set(key, value);
243
+ reRender();
244
+ return result;
245
+ },
246
+ clear: function clear() {
247
+ mapRef.current.clear();
248
+ reRender();
249
+ },
250
+ "delete": function _delete(key) {
251
+ var result = mapRef.current["delete"](key);
252
+ reRender();
253
+ return result;
254
+ }
255
+ });
256
+ };
257
+ }
258
+
259
+ export { ElementMapping, InputMapping, InputMappingContext, createFormInstantContainer, createInputMappingHook, useFormInstantField };
254
260
  //# sourceMappingURL=react-input-mapping.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"react-input-mapping.esm.js","sources":["../src/InputMapping/class.ts","../src/InputMapping/context.tsx","../src/InputMapping/useInputMapping.tsx","../src/InputMapping/provider.tsx","../src/InputMapping/useFormInstantField.tsx"],"sourcesContent":["import { FC } from 'react';\nimport { INPUT_COMPONENTS_KEYS } from './types';\n\n// Nuevo tipo auxiliar para mapear cada clave a su componente correspondiente\n// Ahora el value depende de la key: si es de Ob, es FC<Ob[K]>; si es de INPUT_COMPONENTS_KEYS, es FC<any>\ntype InputComponentMap<Ob extends Record<string, any>> = {\n [K in keyof Ob]?: FC<Ob[K]>;\n} & {\n [K in INPUT_COMPONENTS_KEYS]?: FC<any>;\n};\n\nexport class InputMapping<Ob extends Record<string, any>> extends Map<\n keyof Ob | INPUT_COMPONENTS_KEYS,\n FC<any>\n> {\n private zodAdacter() {\n return Object.entries({\n ZodBoolean: 'checkbox',\n ZodDate: 'date',\n ZodEnum: 'select',\n ZodNativeEnum: 'select',\n ZodNumber: 'number',\n string: 'text',\n });\n }\n\n private appendObj(obj: Partial<InputComponentMap<Ob>>) {\n const keys = Object.keys(obj) as Array<keyof typeof obj>;\n\n for (const key of keys) {\n const value = obj[key];\n if (value && (key as string) in ({} as Ob)) {\n this.set(key as keyof Ob, value as FC<Ob[keyof Ob]>);\n } else if (value) {\n this.set(key as INPUT_COMPONENTS_KEYS, value as FC<any>);\n }\n }\n\n for (const [k, v] of this.zodAdacter()) {\n const existingValue = this.get(v as INPUT_COMPONENTS_KEYS);\n if (existingValue) {\n this.set(k as INPUT_COMPONENTS_KEYS, existingValue);\n }\n }\n }\n\n constructor(obj?: Partial<InputComponentMap<Ob>>) {\n super();\n if (!obj) return;\n this.appendObj(obj);\n }\n\n exists(k: string) {\n const isHas = super.has(k as keyof Ob | INPUT_COMPONENTS_KEYS);\n if (!isHas) return 'fallback';\n return k as keyof Ob | INPUT_COMPONENTS_KEYS;\n }\n\n get<Ky extends keyof Ob | INPUT_COMPONENTS_KEYS>(k: Ky) {\n return super.get(k);\n }\n\n set<K extends keyof Ob>(k: K, v: FC<Ob[K]>): this;\n set<K extends INPUT_COMPONENTS_KEYS>(k: K, v: FC<any>): this;\n set(k: keyof Ob | INPUT_COMPONENTS_KEYS, v: FC<any>): this {\n if (!super.has(k)) super.set(k, v);\n return this;\n }\n\n extends<Ext extends Record<string, FC<any>>>(\n cb: (mapping: InputMapping<Ob & { [K in keyof Ext]: any }>) => Ext,\n ) {\n const obj = Object.fromEntries(super.entries()) as Record<string, FC<any>>;\n const extendObj = cb(this as InputMapping<Ob & { [K in keyof Ext]: any }>);\n return new InputMapping<Ob & { [K in keyof Ext]: any }>({\n ...obj,\n ...extendObj,\n } as Partial<\n Record<\n keyof (Ob & { [K in keyof Ext]: any }) | INPUT_COMPONENTS_KEYS,\n FC<(Ob & { [K in keyof Ext]: any })[keyof (Ob & { [K in keyof Ext]: any })]>\n >\n >);\n }\n}\n","import { createContext } from 'react';\nimport { InputMapping } from './class';\nimport { ObBase } from './types';\n\nexport function createInputMappingContext<Ob extends Record<ObBase, any>>() {\n return createContext<InputMapping<Ob> | null>(null);\n}\n","import { useReducer, useRef, useContext } from 'react';\nimport { InputMapping } from './class';\n\nexport function createInputMappingHook<Ob extends Record<string, any>>(\n InputMappingContext: React.Context<InputMapping<Ob> | null>,\n) {\n return function useInputMapping() {\n const initialState = useContext(InputMappingContext);\n if (!initialState) throw new Error('InputMappingContext not found');\n const mapRef = useRef(initialState);\n const [, reRender] = useReducer((x) => x + 1, 0);\n\n return {\n ...mapRef.current,\n set: (key: keyof Ob | string, value: React.FC<any>) => {\n const result = mapRef.current.set(key, value);\n reRender();\n return result;\n },\n clear: () => {\n mapRef.current.clear();\n reRender();\n },\n delete: (key: keyof Ob | string) => {\n const result = mapRef.current.delete(key);\n reRender();\n return result;\n },\n };\n };\n}\n","import { createElement, FC, ReactNode, Context } from 'react';\nimport { InputMapping } from './class';\nimport { createInputMappingContext } from './context';\nimport { ParsedField, ObBase } from './types';\nimport { createInputMappingHook } from './useInputMapping';\n\ntype FCC = React.FC<{ children: ReactNode }>;\n\ninterface createFormInstantContainerReturn<Ob extends Record<ObBase, any>> {\n useInputMapping: ReturnType<typeof createInputMappingHook<Ob>>;\n FormInstantInputsProvider: FCC;\n}\n\nexport const createFormInstantContainer = <Ob extends Record<ObBase, any>>(\n inputMapping: InputMapping<Ob>,\n) => {\n const InputMappingContext: Context<InputMapping<Ob> | null> = createInputMappingContext<Ob>();\n\n const FormInstantInputsProvider: FCC = (props) =>\n createElement(InputMappingContext.Provider, {\n value: inputMapping,\n children: props.children,\n });\n\n return {\n FormInstantInputsProvider,\n useInputMapping: createInputMappingHook(InputMappingContext),\n } as createFormInstantContainerReturn<Ob>;\n};\n\nexport const ElementMapping: FC<{ formProps: ParsedField<unknown, string> }> = ({\n formProps: _formProps,\n}) => {\n // Este componente no puede ser genérico, así que se mantiene igual\n return null;\n};\n","import { useCallback, useState } from 'react';\nimport { ParsedField } from './types';\n\nexport const useFormInstantField = <P extends ParsedField<unknown, string>>({\n fieldConfig,\n name,\n ...prop\n}: P) => {\n const [fiends, setFiends] = useState(Object.values((prop.schema as P['schema']) || {}));\n\n const append = useCallback(() => {\n if (![fieldConfig?.max].includes(fiends.length)) setFiends((pre) => [...pre, pre[0]]);\n }, [fiends, fieldConfig?.max]);\n\n const remove = useCallback(\n (index: number) => {\n if (![fieldConfig?.min].includes(fiends.length))\n setFiends((pre) => pre.filter((_, i) => i !== index));\n },\n [fiends, fieldConfig?.min],\n );\n\n return { fiends, append, remove, setFiends, fieldConfig, name, ...prop };\n};\n"],"names":["InputMapping","_Map","obj","_this","call","_assertThisInitialized","appendObj","_inheritsLoose","_proto","prototype","zodAdacter","Object","entries","ZodBoolean","ZodDate","ZodEnum","ZodNativeEnum","ZodNumber","string","keys","_i","_keys","length","key","value","set","_iterator","_createForOfIteratorHelperLoose","_step","done","_step$value","k","v","existingValue","get","exists","isHas","has","extends","cb","fromEntries","extendObj","_extends2","_wrapNativeSuper","Map","createInputMappingContext","createContext","createInputMappingHook","InputMappingContext","useInputMapping","initialState","useContext","Error","mapRef","useRef","_useReducer","useReducer","x","reRender","_extends","current","result","clear","delete","createFormInstantContainer","inputMapping","FormInstantInputsProvider","props","createElement","Provider","children","ElementMapping","_ref","useFormInstantField","fieldConfig","name","prop","_objectWithoutPropertiesLoose","_excluded","_useState","useState","values","schema","fiends","setFiends","append","useCallback","max","includes","pre","concat","remove","index","min","filter","_","i"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWaA,IAAAA,YAA6C,0BAAAC,IAAA,EAAA;EAmCtD,SAAAD,YAAAA,CAAYE,GAAoC,EAAA;AAAA,IAAA,IAAAC,KAAA,CAAA;AAC5CA,IAAAA,KAAA,GAAAF,IAAA,CAAAG,IAAA,MAAO,IAAA,IAAA,CAAA;AACP,IAAA,IAAI,CAACF,GAAG,EAAE,OAAAG,sBAAA,CAAAF,KAAA,CAAA,CAAA;AACVA,IAAAA,KAAA,CAAKG,SAAS,CAACJ,GAAG,CAAC,CAAA;AAAC,IAAA,OAAAC,KAAA,CAAA;AACxB,GAAA;EAACI,cAAA,CAAAP,YAAA,EAAAC,IAAA,CAAA,CAAA;AAAA,EAAA,IAAAO,MAAA,GAAAR,YAAA,CAAAS,SAAA,CAAA;AAAAD,EAAAA,MAAA,CAnCOE,UAAU,GAAV,SAAAA,UAAUA,GAAA;IACd,OAAOC,MAAM,C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I,CAAA,CAAA;AAC1E;;;;"}
1
+ {"version":3,"file":"react-input-mapping.esm.js","sources":["../src/InputMapping/class.ts","../src/InputMapping/context.tsx","../src/InputMapping/provider.tsx","../src/InputMapping/useFormInstantField.tsx","../src/InputMapping/useInputMapping.tsx"],"sourcesContent":["import { FC } from 'react';\nimport { INPUT_COMPONENTS_KEYS, ParsedField } from './types';\n\n// Nuevo tipo auxiliar para mapear cada clave a su componente correspondiente\n// Ahora el value depende de la key: si es de Ob, es FC<Ob[K]>; si es de INPUT_COMPONENTS_KEYS, es FC<any>\ntype InputComponentMap<Ob extends Record<string, any>> = {\n [K in keyof Ob]?: FC<ParsedField<Ob[K]>>;\n} & {\n [K in INPUT_COMPONENTS_KEYS]?: FC<any>;\n};\n\nexport class InputMapping<Ob extends Record<string, any>> extends Map<\n keyof Ob | INPUT_COMPONENTS_KEYS,\n FC<any>\n> {\n private zodAdacter() {\n return Object.entries({\n ZodBoolean: 'checkbox',\n ZodDate: 'date',\n ZodEnum: 'select',\n ZodNativeEnum: 'select',\n ZodNumber: 'number',\n string: 'text',\n });\n }\n\n private appendObj(obj: Partial<InputComponentMap<Ob>>) {\n const keys = Object.keys(obj) as Array<keyof typeof obj>;\n\n for (const key of keys) {\n const value = obj[key];\n if (value && (key as string) in ({} as Ob)) {\n this.set(key as keyof Ob, value as FC<Ob[keyof Ob]>);\n } else if (value) {\n this.set(key as INPUT_COMPONENTS_KEYS, value as FC<any>);\n }\n }\n\n for (const [k, v] of this.zodAdacter()) {\n const existingValue = this.get(v as INPUT_COMPONENTS_KEYS);\n if (existingValue) {\n this.set(k as INPUT_COMPONENTS_KEYS, existingValue);\n }\n }\n }\n\n constructor(obj?: Partial<InputComponentMap<Ob>>) {\n super();\n if (!obj) return;\n this.appendObj(obj);\n }\n\n exists(k: string) {\n const isHas = super.has(k as keyof Ob | INPUT_COMPONENTS_KEYS);\n if (!isHas) return 'fallback';\n return k as keyof Ob | INPUT_COMPONENTS_KEYS;\n }\n\n get<Ky extends keyof Ob | INPUT_COMPONENTS_KEYS>(k: Ky) {\n return super.get(k);\n }\n\n set<K extends keyof Ob>(k: K, v: FC<Ob[K]>): this;\n set<K extends INPUT_COMPONENTS_KEYS>(k: K, v: FC<any>): this;\n set(k: keyof Ob | INPUT_COMPONENTS_KEYS, v: FC<any>): this {\n if (!super.has(k)) super.set(k, v);\n return this;\n }\n\n extends<Ext extends Record<string, FC<any>>>(\n cb: (mapping: InputMapping<Ob & { [K in keyof Ext]: any }>) => Ext,\n ) {\n const obj = Object.fromEntries(super.entries()) as Partial<InputComponentMap<Ob>>;\n const extendObj = cb(this as InputMapping<Ob & { [K in keyof Ext]: any }>) as Partial<\n InputComponentMap<{ [K in keyof Ext]: any }>\n >;\n return new InputMapping<Ob & { [K in keyof Ext]: any }>({\n ...(obj as Partial<InputComponentMap<Ob & { [K in keyof Ext]: any }>>),\n ...(extendObj as Partial<InputComponentMap<Ob & { [K in keyof Ext]: any }>>),\n });\n }\n}\n","import { createContext } from 'react';\nimport { InputMapping } from './class';\n\nexport const InputMappingContext = createContext<InputMapping<any> | null>(null) as React.Context<\n InputMapping<any>\n>;\n","import { Context, createElement, FC, ReactNode, useContext } from 'react';\nimport { InputMapping } from './class';\nimport { InputMappingContext } from './context';\nimport { ObBase, ParsedField } from './types';\n\ntype FCC = React.FC<{ children: ReactNode }>;\n\ninterface createFormInstantContainerReturn<Ob extends Record<ObBase, any>> {\n useInputMapping: Context<InputMapping<Ob>>;\n FormInstantInputsProvider: FCC;\n}\n\nexport const createFormInstantContainer = <Ob extends Record<any, any>>(\n inputMapping: InputMapping<Ob>\n) => {\n const FormInstantInputsProvider: FCC = (props) =>\n createElement(InputMappingContext.Provider, {\n value: inputMapping,\n children: props.children,\n });\n\n const useInputMapping = () => useContext(InputMappingContext);\n\n return {\n FormInstantInputsProvider,\n useInputMapping,\n } as unknown as createFormInstantContainerReturn<Ob>;\n};\n\nexport const ElementMapping: FC<{ formProps: ParsedField<any, string> }> = ({ formProps }) => {\n if (!InputMappingContext) return null;\n\n const InputMapping = useContext(InputMappingContext);\n\n const type = formProps.fieldConfig?.type || formProps.type;\n\n const Element = InputMapping.get(type);\n\n if (!Element) return null;\n\n return createElement(Element, formProps);\n};\n","import { useCallback, useState } from 'react';\nimport { ParsedField } from './types';\n\nexport const useFormInstantField = <P extends ParsedField<unknown, string>>({\n fieldConfig,\n name,\n ...prop\n}: P) => {\n const [fiends, setFiends] = useState(Object.values((prop.schema as P['schema']) || {}));\n\n const append = useCallback(() => {\n if (![fieldConfig?.max].includes(fiends.length)) setFiends((pre) => [...pre, pre[0]]);\n }, [fiends, fieldConfig?.max]);\n\n const remove = useCallback(\n (index: number) => {\n if (![fieldConfig?.min].includes(fiends.length))\n setFiends((pre) => pre.filter((_, i) => i !== index));\n },\n [fiends, fieldConfig?.min],\n );\n\n return { fiends, append, remove, setFiends, fieldConfig, name, ...prop };\n};\n","import { useReducer, useRef, useContext } from 'react';\nimport { InputMapping } from './class';\n\nexport function createInputMappingHook<Ob extends Record<string, any>>(\n InputMappingContext: React.Context<InputMapping<Ob> | null>,\n) {\n return function useInputMapping() {\n const initialState = useContext(InputMappingContext);\n if (!initialState) throw new Error('InputMappingContext not found');\n const mapRef = useRef(initialState);\n const [, reRender] = useReducer((x) => x + 1, 0);\n\n return {\n ...mapRef.current,\n set: (key: keyof Ob | string, value: React.FC<any>) => {\n const result = mapRef.current.set(key, value);\n reRender();\n return result;\n },\n clear: () => {\n mapRef.current.clear();\n reRender();\n },\n delete: (key: keyof Ob | string) => {\n const result = mapRef.current.delete(key);\n reRender();\n return result;\n },\n };\n };\n}\n"],"names":["InputMapping","_Map","obj","_this","call","_assertThisInitialized","appendObj","_inheritsLoose","_proto","prototype","zodAdacter","Object","entries","ZodBoolean","ZodDate","ZodEnum","ZodNativeEnum","ZodNumber","string","keys","_i","_keys","length","key","value","set","_iterator","_createForOfIteratorHelperLoose","_step","done","_step$value","k","v","existingValue","get","exists","isHas","has","extends","cb","fromEntries","extendObj","_extends2","_wrapNativeSuper","Map","InputMappingContext","createContext","createFormInstantContainer","inputMapping","FormInstantInputsProvider","props","createElement","Provider","children","useInputMapping","useContext","ElementMapping","_ref","_formProps$fieldConfi","formProps","type","fieldConfig","Element","useFormInstantField","name","prop","_objectWithoutPropertiesLoose","_excluded","_useState","useState","values","schema","fiends","setFiends","append","useCallback","max","includes","pre","concat","remove","index","min","filter","_","i","_extends","createInputMappingHook","initialState","Error","mapRef","useRef","_useReducer","useReducer","x","reRender","current","result","clear","delete"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWaA,IAAAA,YAA6C,0BAAAC,IAAA,EAAA;EAmCtD,SAAAD,YAAAA,CAAYE,GAAoC,EAAA;AAAA,IAAA,IAAAC,KAAA,CAAA;AAC5CA,IAAAA,KAAA,GAAAF,IAAA,CAAAG,IAAA,MAAO,IAAA,IAAA,CAAA;AACP,IAAA,IAAI,CAACF,GAAG,EAAE,OAAAG,sBAAA,CAAAF,KAAA,CAAA,CAAA;AACVA,IAAAA,KAAA,CAAKG,SAAS,CAACJ,GAAG,CAAC,CAAA;AAAC,IAAA,OAAAC,KAAA,CAAA;AACxB,GAAA;EAACI,cAAA,CAAAP,YAAA,EAAAC,IAAA,CAAA,CAAA;AAAA,EAAA,IAAAO,MAAA,GAAAR,YAAA,CAAAS,SAAA,CAAA;AAAAD,EAAAA,MAAA,CAnCOE,UAAU,GAAV,SAAAA,UAAUA,GAAA;IACd,OAAOC,MAAM,CAACC,OAAO,CAAC;AAClBC,MAAAA,UAAU,EAAE,UAAU;AACtBC,MAAAA,OAAO,EAAE,MAAM;AACfC,MAAAA,OAAO,EAAE,QAAQ;AACjBC,MAAAA,aAAa,EAAE,QAAQ;AACvBC,MAAAA,SAAS,EAAE,QAAQ;AACnBC,MAAAA,MAAM,EAAE,MAAA;AACX,KAAA,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O;AACRR,QAAAA,MAAM,CAACM,OAAO,CAACE,KAAK,EAAE,CAAA;AACtBH,QAAAA,QAAQ,EAAE,CAAA;OACb;AACD,MAAA,QAAA,EAAQ,SAARI,OAAMA,CAAG5E,GAAsB,EAAI;QAC/B,IAAM0E,MAAM,GAAGP,MAAM,CAACM,OAAO,CAAO,QAAA,CAAA,CAACzE,GAAG,CAAC,CAAA;AACzCwE,QAAAA,QAAQ,EAAE,CAAA;AACV,QAAA,OAAOE,MAAM,CAAA;AACjB,OAAA;AAAC,KAAA,CAAA,CAAA;GAER,CAAA;AACL;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@form-instant/react-input-mapping",
3
- "version": "1.7.3-rc.1",
3
+ "version": "1.7.7-rc.1",
4
4
  "author": {
5
5
  "name": "leomerida15",
6
6
  "email": "dimasmerida15@gmail.com",
@@ -76,7 +76,6 @@
76
76
  ],
77
77
  "typings": "dist/index.d.ts",
78
78
  "dependencies": {
79
- "minimatch": "^10.0.3",
80
- "use-context-selector": "^2.0.0"
79
+ "minimatch": "^10.0.3"
81
80
  }
82
81
  }