@form-instant/react-input-mapping 1.6.0 → 1.7.5-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,15 +1,20 @@
1
1
  import { FC } from 'react';
2
- import { INPUT_COMPONENTS_KEYS } from './types';
3
- type MergeKeys<T, U> = {
4
- [K in keyof T | keyof U]: K extends keyof T ? T[K] : K extends keyof U ? U[K] : never;
2
+ import { INPUT_COMPONENTS_KEYS, ParsedField } from './types';
3
+ type InputComponentMap<Ob extends Record<string, any>> = {
4
+ [K in keyof Ob]?: FC<ParsedField<Ob[K]>>;
5
+ } & {
6
+ [K in INPUT_COMPONENTS_KEYS]?: FC<any>;
5
7
  };
6
- export declare class InputMapping<P = object, K extends string = INPUT_COMPONENTS_KEYS> extends Map<MergeKeys<K, INPUT_COMPONENTS_KEYS>, FC<P>> {
8
+ export declare class InputMapping<Ob extends Record<string, any>> extends Map<keyof Ob | INPUT_COMPONENTS_KEYS, FC<any>> {
7
9
  private zodAdacter;
8
10
  private appendObj;
9
- constructor(obj?: Partial<Record<K | INPUT_COMPONENTS_KEYS, FC<P>>>);
10
- exists(k: string): "fallback" | MergeKeys<K, INPUT_COMPONENTS_KEYS>;
11
- get(k: MergeKeys<K, INPUT_COMPONENTS_KEYS> | string): FC<P> | undefined;
12
- set(k: MergeKeys<K, INPUT_COMPONENTS_KEYS>, v: FC<P>): this;
13
- extends(cb: (mapingp: InputMapping<P, K | INPUT_COMPONENTS_KEYS>) => Record<never, FC<P>>): InputMapping<P, INPUT_COMPONENTS_KEYS | K>;
11
+ constructor(obj?: Partial<InputComponentMap<Ob>>);
12
+ exists(k: string): INPUT_COMPONENTS_KEYS | keyof Ob;
13
+ get<Ky extends keyof Ob | INPUT_COMPONENTS_KEYS>(k: Ky): FC<any> | undefined;
14
+ set<K extends keyof Ob>(k: K, v: FC<Ob[K]>): this;
15
+ set<K extends INPUT_COMPONENTS_KEYS>(k: K, v: FC<any>): this;
16
+ extends<Ext extends Record<string, FC<any>>>(cb: (mapping: InputMapping<Ob & {
17
+ [K in keyof Ext]: any;
18
+ }>) => Ext): InputMapping<Ob & { [K in keyof Ext]: any; }>;
14
19
  }
15
20
  export {};
@@ -1,2 +1,2 @@
1
1
  import { InputMapping } from './class';
2
- export declare const InputMappingContext: import("use-context-selector").Context<InputMapping<object, import("./types").INPUT_COMPONENTS_KEYS>>;
2
+ export declare const InputMappingContext: React.Context<InputMapping<any>>;
@@ -1,10 +1,14 @@
1
+ import { Context, FC, ReactNode } from 'react';
1
2
  import { InputMapping } from './class';
2
- import { INPUT_COMPONENTS_KEYS, ParsedField } from './types';
3
- interface createFormInstantContainerRetuen<P = object, K extends string = INPUT_COMPONENTS_KEYS> {
4
- useInputMapping: () => InputMapping<P, K>;
3
+ import { ObBase, ParsedField } from './types';
4
+ type FCC = React.FC<{
5
+ children: ReactNode;
6
+ }>;
7
+ interface createFormInstantContainerReturn<Ob extends Record<ObBase, any>> {
8
+ useInputMapping: Context<InputMapping<Ob>>;
5
9
  FormInstantInputsProvider: FCC;
6
10
  }
7
- export declare const createFormInstantContainer: <P = object, K extends string = INPUT_COMPONENTS_KEYS>(inputMapping: InputMapping<P, K>) => createFormInstantContainerRetuen<P, K>;
11
+ export declare const createFormInstantContainer: <Ob extends Record<any, any>>(inputMapping: InputMapping<Ob>) => createFormInstantContainerReturn<Ob>;
8
12
  export declare const ElementMapping: FC<{
9
13
  formProps: ParsedField<any, string>;
10
14
  }>;
@@ -6,7 +6,7 @@ export interface ParsedField<AdditionalRenderable, FieldTypes = string> {
6
6
  };
7
7
  type: string;
8
8
  required: boolean;
9
- default?: any;
9
+ default?: unknown;
10
10
  fieldConfig?: FieldConfig<AdditionalRenderable, FieldTypes>;
11
11
  options?: [string, string][];
12
12
  schema?: ParsedField<AdditionalRenderable, FieldTypes>[];
@@ -16,3 +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;
@@ -1,10 +1,14 @@
1
1
  import { ParsedField } from './types';
2
- export declare const useFormInstantField: <P extends ParsedField<any, string>>({ fieldConfig, name, ...prop }: P) => {
3
- fiends: ParsedField<any, string>[];
2
+ export declare const useFormInstantField: <P extends ParsedField<unknown, string>>({ fieldConfig, name, ...prop }: P) => {
3
+ fiends: ParsedField<unknown, string>[];
4
4
  append: () => void;
5
5
  remove: (index: number) => void;
6
- setFiends: import("react").Dispatch<import("react").SetStateAction<ParsedField<any, string>[]>>;
7
- fieldConfig: any;
6
+ setFiends: import("react").Dispatch<import("react").SetStateAction<ParsedField<unknown, string>[]>>;
7
+ fieldConfig: {
8
+ fieldType?: string | undefined;
9
+ min?: number;
10
+ max?: number;
11
+ } | undefined;
8
12
  name: {
9
13
  current: string;
10
14
  history: string;
@@ -1,2 +1,14 @@
1
1
  import { InputMapping } from './class';
2
- export declare const useInputMapping: () => InputMapping<object, import("./types").INPUT_COMPONENTS_KEYS>;
2
+ export declare function createInputMappingHook<Ob extends Record<string, any>>(InputMappingContext: React.Context<InputMapping<Ob> | null>): () => {
3
+ set: (key: keyof Ob | string, value: React.FC<any>) => InputMapping<Ob>;
4
+ clear: () => void;
5
+ delete: (key: keyof Ob | string) => boolean;
6
+ forEach(callbackfn: (value: import("react").FC<any>, key: import("./types").INPUT_COMPONENTS_KEYS | keyof Ob, map: Map<import("./types").INPUT_COMPONENTS_KEYS | keyof Ob, import("react").FC<any>>) => void, thisArg?: any): void;
7
+ has(key: import("./types").INPUT_COMPONENTS_KEYS | keyof Ob): boolean;
8
+ size: number;
9
+ entries(): MapIterator<[import("./types").INPUT_COMPONENTS_KEYS | keyof Ob, import("react").FC<any>]>;
10
+ keys(): MapIterator<import("./types").INPUT_COMPONENTS_KEYS | keyof Ob>;
11
+ values(): MapIterator<import("react").FC<any>>;
12
+ [Symbol.iterator](): MapIterator<[import("./types").INPUT_COMPONENTS_KEYS | keyof Ob, import("react").FC<any>]>;
13
+ [Symbol.toStringTag]: string;
14
+ };
@@ -1,6 +1,5 @@
1
1
  'use strict';
2
2
 
3
- var useContextSelector = require('use-context-selector');
4
3
  var react = require('react');
5
4
 
6
5
  function _arrayLikeToArray(r, a) {
@@ -72,7 +71,7 @@ function _objectWithoutPropertiesLoose(r, e) {
72
71
  if (null == r) return {};
73
72
  var t = {};
74
73
  for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
75
- if (e.includes(n)) continue;
74
+ if (-1 !== e.indexOf(n)) continue;
76
75
  t[n] = r[n];
77
76
  }
78
77
  return t;
@@ -112,7 +111,6 @@ function _wrapNativeSuper(t) {
112
111
  }, _wrapNativeSuper(t);
113
112
  }
114
113
 
115
- // K extiende de INPUT_COMPONENTS_KEYS y puede incluir más claves personalizadas
116
114
  var InputMapping = /*#__PURE__*/function (_Map) {
117
115
  function InputMapping(obj) {
118
116
  var _this;
@@ -135,17 +133,23 @@ var InputMapping = /*#__PURE__*/function (_Map) {
135
133
  };
136
134
  _proto.appendObj = function appendObj(obj) {
137
135
  var keys = Object.keys(obj);
138
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
139
136
  for (var _i = 0, _keys = keys; _i < _keys.length; _i++) {
140
137
  var key = _keys[_i];
141
- this.set(key, obj[key]);
138
+ var value = obj[key];
139
+ if (value && key in {}) {
140
+ this.set(key, value);
141
+ } else if (value) {
142
+ this.set(key, value);
143
+ }
142
144
  }
143
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
144
145
  for (var _iterator = _createForOfIteratorHelperLoose(this.zodAdacter()), _step; !(_step = _iterator()).done;) {
145
146
  var _step$value = _step.value,
146
147
  k = _step$value[0],
147
148
  v = _step$value[1];
148
- this.set(k, this.get(v));
149
+ var existingValue = this.get(v);
150
+ if (existingValue) {
151
+ this.set(k, existingValue);
152
+ }
149
153
  }
150
154
  };
151
155
  _proto.exists = function exists(k) {
@@ -168,40 +172,7 @@ var InputMapping = /*#__PURE__*/function (_Map) {
168
172
  return InputMapping;
169
173
  }(/*#__PURE__*/_wrapNativeSuper(Map));
170
174
 
171
- var InputMappingContext = /*#__PURE__*/useContextSelector.createContext(/*#__PURE__*/new InputMapping());
172
-
173
- var useInputMapping = function useInputMapping() {
174
- var initialState = useContextSelector.useContext(InputMappingContext);
175
- var mapRef = react.useRef(initialState);
176
- var _useReducer = react.useReducer(function (x) {
177
- return x + 1;
178
- }, 0),
179
- reRender = _useReducer[1];
180
- mapRef.current.set = function () {
181
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
182
- args[_key] = arguments[_key];
183
- }
184
- InputMapping.prototype.set.apply(mapRef.current, args);
185
- reRender();
186
- return mapRef.current;
187
- };
188
- mapRef.current.clear = function () {
189
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
190
- args[_key2] = arguments[_key2];
191
- }
192
- InputMapping.prototype.clear.apply(mapRef.current, args);
193
- reRender();
194
- };
195
- mapRef.current["delete"] = function () {
196
- for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
197
- args[_key3] = arguments[_key3];
198
- }
199
- var res = InputMapping.prototype["delete"].apply(mapRef.current, args);
200
- reRender();
201
- return res;
202
- };
203
- return mapRef.current;
204
- };
175
+ var InputMappingContext = /*#__PURE__*/react.createContext(null);
205
176
 
206
177
  var createFormInstantContainer = function createFormInstantContainer(inputMapping) {
207
178
  var FormInstantInputsProvider = function FormInstantInputsProvider(props) {
@@ -210,6 +181,9 @@ var createFormInstantContainer = function createFormInstantContainer(inputMappin
210
181
  children: props.children
211
182
  });
212
183
  };
184
+ var useInputMapping = function useInputMapping() {
185
+ return react.useContext(InputMappingContext);
186
+ };
213
187
  return {
214
188
  FormInstantInputsProvider: FormInstantInputsProvider,
215
189
  useInputMapping: useInputMapping
@@ -218,7 +192,8 @@ var createFormInstantContainer = function createFormInstantContainer(inputMappin
218
192
  var ElementMapping = function ElementMapping(_ref) {
219
193
  var _formProps$fieldConfi;
220
194
  var formProps = _ref.formProps;
221
- var InputMapping = useInputMapping();
195
+ if (!InputMappingContext) return null;
196
+ var InputMapping = react.useContext(InputMappingContext);
222
197
  var type = ((_formProps$fieldConfi = formProps.fieldConfig) == null ? void 0 : _formProps$fieldConfi.type) || formProps.type;
223
198
  var Element = InputMapping.get(type);
224
199
  if (!Element) return null;
@@ -234,17 +209,17 @@ var useFormInstantField = function useFormInstantField(_ref) {
234
209
  fiends = _useState[0],
235
210
  setFiends = _useState[1];
236
211
  var append = react.useCallback(function () {
237
- if (![fieldConfig == null ? void 0 : fieldConfig.max, Number(fieldConfig == null ? void 0 : fieldConfig.maxLength)].includes(fiends.length)) setFiends(function (pre) {
212
+ if (![fieldConfig == null ? void 0 : fieldConfig.max].includes(fiends.length)) setFiends(function (pre) {
238
213
  return [].concat(pre, [pre[0]]);
239
214
  });
240
- }, [fiends, fieldConfig == null ? void 0 : fieldConfig.max, fieldConfig == null ? void 0 : fieldConfig.maxLength]);
215
+ }, [fiends, fieldConfig == null ? void 0 : fieldConfig.max]);
241
216
  var remove = react.useCallback(function (index) {
242
- if (![fieldConfig == null ? void 0 : fieldConfig.min, Number(fieldConfig == null ? void 0 : fieldConfig.minLength)].includes(fiends.length)) setFiends(function (pre) {
217
+ if (![fieldConfig == null ? void 0 : fieldConfig.min].includes(fiends.length)) setFiends(function (pre) {
243
218
  return pre.filter(function (_, i) {
244
219
  return i !== index;
245
220
  });
246
221
  });
247
- }, [fiends, fieldConfig == null ? void 0 : fieldConfig.min, fieldConfig == null ? void 0 : fieldConfig.minLength]);
222
+ }, [fiends, fieldConfig == null ? void 0 : fieldConfig.min]);
248
223
  return _extends({
249
224
  fiends: fiends,
250
225
  append: append,
@@ -255,10 +230,38 @@ var useFormInstantField = function useFormInstantField(_ref) {
255
230
  }, prop);
256
231
  };
257
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
+
258
261
  exports.ElementMapping = ElementMapping;
259
262
  exports.InputMapping = InputMapping;
260
263
  exports.InputMappingContext = InputMappingContext;
261
264
  exports.createFormInstantContainer = createFormInstantContainer;
265
+ exports.createInputMappingHook = createInputMappingHook;
262
266
  exports.useFormInstantField = useFormInstantField;
263
- exports.useInputMapping = useInputMapping;
264
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\ntype MergeKeys<T, U> = {\n [K in keyof T | keyof U]: K extends keyof T ? T[K] : K extends keyof U ? U[K] : never;\n};\n\n// K extiende de INPUT_COMPONENTS_KEYS y puede incluir más claves personalizadas\nexport class InputMapping<P = object, K extends string = INPUT_COMPONENTS_KEYS> extends Map<\n MergeKeys<K, INPUT_COMPONENTS_KEYS>,\n FC<P>\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<Record<K | INPUT_COMPONENTS_KEYS, FC<P>>>) {\n const keys = Object.keys(obj) as Array<K | INPUT_COMPONENTS_KEYS>;\n\n type Ky = MergeKeys<K, INPUT_COMPONENTS_KEYS>;\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n for (const key of keys) this.set(key as Ky, obj[key]!);\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n for (const [k, v] of this.zodAdacter()) this.set(k as Ky, this.get(v)!);\n }\n\n constructor(obj?: Partial<Record<K | INPUT_COMPONENTS_KEYS, FC<P>>>) {\n super();\n\n if (!obj) return;\n\n this.appendObj(obj);\n }\n\n exists(k: string) {\n const isHas = super.has(k as MergeKeys<K, INPUT_COMPONENTS_KEYS>);\n\n if (!isHas) return 'fallback';\n\n return k as MergeKeys<K, INPUT_COMPONENTS_KEYS>;\n }\n\n get(k: MergeKeys<K, INPUT_COMPONENTS_KEYS> | string) {\n return super.get(k as MergeKeys<K, INPUT_COMPONENTS_KEYS>);\n }\n\n set(k: MergeKeys<K, INPUT_COMPONENTS_KEYS>, v: FC<P>) {\n if (!super.has(k)) super.set(k, v);\n\n return this;\n }\n\n extends(cb: (mapingp: InputMapping<P, K | INPUT_COMPONENTS_KEYS>) => Record<never, FC<P>>) {\n const obj = Object.fromEntries(super.entries()) as Record<string, FC<P>>;\n\n const extendObj = cb(this as unknown as InputMapping<P, K | INPUT_COMPONENTS_KEYS>);\n\n return new InputMapping<P, K | INPUT_COMPONENTS_KEYS>({\n ...obj,\n ...extendObj,\n } as Record<K | INPUT_COMPONENTS_KEYS, FC<P>>);\n }\n}\n","import { createContext } from 'use-context-selector';\nimport { InputMapping } from './class';\n\nexport const InputMappingContext = createContext<InputMapping>(new InputMapping());\n","import { useReducer, useRef } from 'react';\nimport { InputMapping } from './class';\nimport { InputMappingContext } from './context';\nimport { useContext } from 'use-context-selector';\n\nexport const useInputMapping = () => {\n const initialState = useContext(InputMappingContext);\n const mapRef = useRef(initialState);\n const [, reRender] = useReducer((x) => x + 1, 0);\n\n mapRef.current.set = (...args) => {\n InputMapping.prototype.set.apply(mapRef.current, args);\n reRender();\n return mapRef.current;\n };\n\n mapRef.current.clear = (...args) => {\n InputMapping.prototype.clear.apply(mapRef.current, args);\n reRender();\n };\n\n mapRef.current.delete = (...args) => {\n const res = InputMapping.prototype.delete.apply(mapRef.current, args);\n reRender();\n\n return res;\n };\n\n return mapRef.current;\n};\n","import { createElement } from 'react';\nimport { InputMapping } from './class';\nimport { InputMappingContext } from './context';\nimport { INPUT_COMPONENTS_KEYS, ParsedField } from './types';\nimport { useInputMapping } from './useInputMapping';\n\ninterface createFormInstantContainerRetuen<P = object, K extends string = INPUT_COMPONENTS_KEYS> {\n useInputMapping: () => InputMapping<P, K>;\n FormInstantInputsProvider: FCC;\n}\n\nexport const createFormInstantContainer = <P = object, K extends string = INPUT_COMPONENTS_KEYS>(\n inputMapping: InputMapping<P, K>,\n) => {\n const FormInstantInputsProvider: FCC = (props) =>\n createElement(InputMappingContext.Provider, {\n value: inputMapping as InputMapping,\n children: props.children,\n });\n\n return {\n FormInstantInputsProvider,\n useInputMapping,\n } as createFormInstantContainerRetuen<P, K>;\n};\n\nexport const ElementMapping: FC<{ formProps: ParsedField<any, string> }> = ({ formProps }) => {\n const InputMapping = useInputMapping();\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<any, string>>({\n fieldConfig,\n name,\n ...prop\n}: P) => {\n const [fiends, setFiends] = useState(Object.values(prop.schema || {}));\n\n const append = useCallback(() => {\n if (![fieldConfig?.max, Number(fieldConfig?.maxLength)].includes(fiends.length))\n setFiends((pre) => [...pre, pre[0]]);\n }, [fiends, fieldConfig?.max, fieldConfig?.maxLength]);\n\n const remove = useCallback(\n (index: number) => {\n if (![fieldConfig?.min, Number(fieldConfig?.minLength)].includes(fiends.length))\n setFiends((pre) => pre.filter((_, i) => i !== index));\n },\n [fiends, fieldConfig?.min, fieldConfig?.minLength],\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","set","_iterator","_createForOfIteratorHelperLoose","_step","done","_step$value","value","k","v","get","exists","isHas","has","extends","cb","fromEntries","extendObj","_extends2","_wrapNativeSuper","Map","InputMappingContext","createContext","useInputMapping","initialState","useContext","mapRef","useRef","_useReducer","useReducer","x","reRender","current","_len","arguments","args","Array","_key","apply","clear","_len2","_key2","_len3","_key3","res","createFormInstantContainer","inputMapping","FormInstantInputsProvider","props","createElement","Provider","children","ElementMapping","_ref","_formProps$fieldConfi","formProps","type","fieldConfig","Element","useFormInstantField","name","prop","_objectWithoutPropertiesLoose","_excluded","_useState","useState","values","schema","fiends","setFiends","append","useCallback","max","Number","maxLength","includes","pre","concat","remove","index","min","minLength","filter","_","i","_extends"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA;AACaA,IAAAA,YAAmE,0BAAAC,IAAA,EAAA;EA2B5E,SAAAD,YAAAA,CAAYE,GAAuD,EAAA;AAAA,IAAA,IAAAC,KAAA,CAAA;AAC/DA,IAAAA,KAAA,GAAAF,IAAA,CAAAG,IAAA,MAAO,IAAA,IAAA,CAAA;AAEP,IAAA,IAAI,CAACF,GAAG,EAAE,OAAAG,sBAAA,CAAAF,KAAA,CAAA,CAAA;AAEVA,IAAAA,KAAA,CAAKG,SAAS,CAACJ,GAAG,CAAC,CAAA;AAAC,IAAA,OAAAC,KAAA,CAAA;AACxB,GAAA;EAACI,cAAA,CA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QAAA,CAAA;AAASjB,IAAAA,MAAM,EAANA,MAAM;AAAEE,IAAAA,MAAM,EAANA,MAAM;AAAEQ,IAAAA,MAAM,EAANA,MAAM;AAAET,IAAAA,SAAS,EAATA,SAAS;AAAEZ,IAAAA,WAAW,EAAXA,WAAW;AAAEG,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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,GAA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ALA,GAAGA,CAAGF,GAAsB,EAAEC,KAAoB,EAAI;QAClD,IAAMyE,MAAM,GAAGP,MAAM,CAACM,OAAO,CAACvE,GAAG,CAACF,GAAG,EAAEC,KAAK,CAAC,CAAA;AAC7CuE,QAAAA,QAAQ,EAAE,CAAA;AACV,QAAA,OAAOE,MAAM,CAAA;OAChB;AACDC,MAAAA,KAAK,EAAE,SAAPA,KAAKA,GAAO;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;;;;;;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";var t=require("use-context-selector"),e=require("react");function n(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 r(){return r=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},r.apply(null,arguments)}function o(t){return o=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},o(t)}function u(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(u=function(){return!!t})()}function i(t,e){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},i(t,e)}function a(t){var e="function"==typeof Map?new Map:void 0;return a=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(u())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,e);var o=new(t.bind.apply(t,r));return n&&i(o,n.prototype),o}(t,arguments,o(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),i(n,t)},a(t)}var c=function(t){function e(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,u;u=t,(o=e).prototype=Object.create(u.prototype),o.prototype.constructor=o,i(o,u);var a=e.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 e=0,r=Object.keys(t);e<r.length;e++){var o=r[e];this.set(o,t[o])}for(var u,i=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(e)return(e=e.call(t)).next.bind(e);if(Array.isArray(t)||(e=function(t,e){if(t){if("string"==typeof t)return n(t,e);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)?n(t,e):void 0}}(t))){e&&(t=e);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());!(u=i()).done;){var a=u.value;this.set(a[0],this.get(a[1]))}},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(n){return new e(r({},Object.fromEntries(t.prototype.entries.call(this)),n(this)))},e}(a(Map)),l=t.createContext(new c),p=function(){var n=t.useContext(l),r=e.useRef(n),o=e.useReducer((function(t){return t+1}),0)[1];return r.current.set=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return c.prototype.set.apply(r.current,e),o(),r.current},r.current.clear=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];c.prototype.clear.apply(r.current,e),o()},r.current.delete=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var u=c.prototype.delete.apply(r.current,e);return o(),u},r.current},f=["fieldConfig","name"];exports.ElementMapping=function(t){var n,r=t.formProps,o=p(),u=(null==(n=r.fieldConfig)?void 0:n.type)||r.type,i=o.get(u);return i?e.createElement(i,r):null},exports.InputMapping=c,exports.InputMappingContext=l,exports.createFormInstantContainer=function(t){return{FormInstantInputsProvider:function(n){return e.createElement(l.Provider,{value:t,children:n.children})},useInputMapping:p}},exports.useFormInstantField=function(t){var n=t.fieldConfig,o=t.name,u=function(t,e){if(null==t)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.includes(r))continue;n[r]=t[r]}return n}(t,f),i=e.useState(Object.values(u.schema||{})),a=i[0],c=i[1],l=e.useCallback((function(){[null==n?void 0:n.max,Number(null==n?void 0:n.maxLength)].includes(a.length)||c((function(t){return[].concat(t,[t[0]])}))}),[a,null==n?void 0:n.max,null==n?void 0:n.maxLength]),p=e.useCallback((function(t){[null==n?void 0:n.min,Number(null==n?void 0:n.minLength)].includes(a.length)||c((function(e){return e.filter((function(e,n){return n!==t}))}))}),[a,null==n?void 0:n.min,null==n?void 0:n.minLength]);return r({fiends:a,append:l,remove:p,setFiends:c,fieldConfig:n,name:o},u)},exports.useInputMapping=p;
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\ntype MergeKeys<T, U> = {\n [K in keyof T | keyof U]: K extends keyof T ? T[K] : K extends keyof U ? U[K] : never;\n};\n\n// K extiende de INPUT_COMPONENTS_KEYS y puede incluir más claves personalizadas\nexport class InputMapping<P = object, K extends string = INPUT_COMPONENTS_KEYS> extends Map<\n MergeKeys<K, INPUT_COMPONENTS_KEYS>,\n FC<P>\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<Record<K | INPUT_COMPONENTS_KEYS, FC<P>>>) {\n const keys = Object.keys(obj) as Array<K | INPUT_COMPONENTS_KEYS>;\n\n type Ky = MergeKeys<K, INPUT_COMPONENTS_KEYS>;\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n for (const key of keys) this.set(key as Ky, obj[key]!);\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n for (const [k, v] of this.zodAdacter()) this.set(k as Ky, this.get(v)!);\n }\n\n constructor(obj?: Partial<Record<K | INPUT_COMPONENTS_KEYS, FC<P>>>) {\n super();\n\n if (!obj) return;\n\n this.appendObj(obj);\n }\n\n exists(k: string) {\n const isHas = super.has(k as MergeKeys<K, INPUT_COMPONENTS_KEYS>);\n\n if (!isHas) return 'fallback';\n\n return k as MergeKeys<K, INPUT_COMPONENTS_KEYS>;\n }\n\n get(k: MergeKeys<K, INPUT_COMPONENTS_KEYS> | string) {\n return super.get(k as MergeKeys<K, INPUT_COMPONENTS_KEYS>);\n }\n\n set(k: MergeKeys<K, INPUT_COMPONENTS_KEYS>, v: FC<P>) {\n if (!super.has(k)) super.set(k, v);\n\n return this;\n }\n\n extends(cb: (mapingp: InputMapping<P, K | INPUT_COMPONENTS_KEYS>) => Record<never, FC<P>>) {\n const obj = Object.fromEntries(super.entries()) as Record<string, FC<P>>;\n\n const extendObj = cb(this as unknown as InputMapping<P, K | INPUT_COMPONENTS_KEYS>);\n\n return new InputMapping<P, K | INPUT_COMPONENTS_KEYS>({\n ...obj,\n ...extendObj,\n } as Record<K | INPUT_COMPONENTS_KEYS, FC<P>>);\n }\n}\n","import { createContext } from 'use-context-selector';\nimport { InputMapping } from './class';\n\nexport const InputMappingContext = createContext<InputMapping>(new InputMapping());\n","import { useReducer, useRef } from 'react';\nimport { InputMapping } from './class';\nimport { InputMappingContext } from './context';\nimport { useContext } from 'use-context-selector';\n\nexport const useInputMapping = () => {\n const initialState = useContext(InputMappingContext);\n const mapRef = useRef(initialState);\n const [, reRender] = useReducer((x) => x + 1, 0);\n\n mapRef.current.set = (...args) => {\n InputMapping.prototype.set.apply(mapRef.current, args);\n reRender();\n return mapRef.current;\n };\n\n mapRef.current.clear = (...args) => {\n InputMapping.prototype.clear.apply(mapRef.current, args);\n reRender();\n };\n\n mapRef.current.delete = (...args) => {\n const res = InputMapping.prototype.delete.apply(mapRef.current, args);\n reRender();\n\n return res;\n };\n\n return mapRef.current;\n};\n","import { createElement } from 'react';\nimport { InputMapping } from './class';\nimport { InputMappingContext } from './context';\nimport { INPUT_COMPONENTS_KEYS, ParsedField } from './types';\nimport { useInputMapping } from './useInputMapping';\n\ninterface createFormInstantContainerRetuen<P = object, K extends string = INPUT_COMPONENTS_KEYS> {\n useInputMapping: () => InputMapping<P, K>;\n FormInstantInputsProvider: FCC;\n}\n\nexport const createFormInstantContainer = <P = object, K extends string = INPUT_COMPONENTS_KEYS>(\n inputMapping: InputMapping<P, K>,\n) => {\n const FormInstantInputsProvider: FCC = (props) =>\n createElement(InputMappingContext.Provider, {\n value: inputMapping as InputMapping,\n children: props.children,\n });\n\n return {\n FormInstantInputsProvider,\n useInputMapping,\n } as createFormInstantContainerRetuen<P, K>;\n};\n\nexport const ElementMapping: FC<{ formProps: ParsedField<any, string> }> = ({ formProps }) => {\n const InputMapping = useInputMapping();\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<any, string>>({\n fieldConfig,\n name,\n ...prop\n}: P) => {\n const [fiends, setFiends] = useState(Object.values(prop.schema || {}));\n\n const append = useCallback(() => {\n if (![fieldConfig?.max, Number(fieldConfig?.maxLength)].includes(fiends.length))\n setFiends((pre) => [...pre, pre[0]]);\n }, [fiends, fieldConfig?.max, fieldConfig?.maxLength]);\n\n const remove = useCallback(\n (index: number) => {\n if (![fieldConfig?.min, Number(fieldConfig?.minLength)].includes(fiends.length))\n setFiends((pre) => pre.filter((_, i) => i !== index));\n },\n [fiends, fieldConfig?.min, fieldConfig?.minLength],\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","set","_step","_iterator","_createForOfIteratorHelperLoose","done","_step$value","value","get","exists","k","has","v","cb","_extends2","fromEntries","_wrapNativeSuper","Map","InputMappingContext","createContext","useInputMapping","initialState","useContext","mapRef","useRef","reRender","useReducer","x","current","_len","arguments","args","Array","_key","apply","clear","_len2","_key2","_len3","_key3","res","_ref","_formProps$fieldConfi","formProps","type","fieldConfig","Element","createElement","inputMapping","FormInstantInputsProvider","props","Provider","children","name","prop","_objectWithoutPropertiesLoose","_excluded","_useState","useState","values","schema","fiends","setFiends","append","useCallback","max","Number","maxLength","includes","pre","concat","remove","index","min","minLength","filter","_","i","_extends"],"mappings":"89CAQaA,IAAAA,WAAmEC,GA2B5E,SAAAD,EAAYE,GAAuD,IAAAC,EAG/D,OAFAA,EAAAF,EAAAG,YAAOC,KAEFH,GAELC,EAAKG,UAAUJ,GAAKC,4HAFVI,CAAAJ,EAGd,WAACF,KAAAD,yEAAA,IAAAQ,EAAAR,EAAAS,UA6BA,OA7BAD,EA7BOE,WAAA,WACJ,OAAOC,OAAOC,QAAQ,CAClBC,WAAY,WACZC,QAAS,OACTC,QAAS,SACTC,cAAe,SACfC,UAAW,SACXC,OAAQ,UAEfV,EAEOF,UAAA,SAAUJ,GAMd,IALA,IAKAiB,EAAA,EAAAC,EALaT,OAAOU,KAAKnB,GAKHiB,EAAAC,EAAAE,OAAAH,IAAA,CAAjB,IAAMI,EAAGH,EAAAD,GAAUd,KAAKmB,IAAID,EAAWrB,EAAIqB,GAAO,CAGvD,IAAA,IAAsCE,EAAtCC,2pBAAAC,CAAqBtB,KAAKK,gBAAYe,EAAAC,KAAAE,MAAE,CAAA,IAAAC,EAAAJ,EAAAK,MAAAzB,KAAKmB,IAAhCK,EAAA,GAA6CxB,KAAK0B,IAA/CF,EAAA,IAAuD,GAC1ErB,EAUDwB,OAAA,SAAOC,GAGH,OAFWhC,EAAAQ,UAASyB,IAAG9B,KAAC6B,KAAAA,GAIjBA,EAFY,YAGtBzB,EAEDuB,IAAA,SAAIE,GACA,OAAAhC,EAAAQ,UAAasB,IAAG3B,UAAC6B,IACpBzB,EAEDgB,IAAA,SAAIS,EAAwCE,GAGxC,OAFIlC,EAAAQ,UAAOyB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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","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,UA8BA,OA9BAD,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,EAAAE,OAAAH,IAAE,CAAnB,IAAMI,EAAGH,EAAAD,GACJK,EAAQtB,EAAIqB,IACdC,GAAUD,IAAmB,IAEtBC,IADPnB,KAAKoB,IAAIF,EAAiBC,EAIlC,CAEA,IAAA,IAAsCE,EAAtCC,2pBAAAC,CAAqBvB,KAAKK,gBAAYgB,EAAAC,KAAAE,MAAE,CAAA,IAAAC,EAAAJ,EAAAF,MAA5BO,EAACD,EAAA,GACHE,EAAgB3B,KAAK4B,IADfH,EAAA,IAERE,GACA3B,KAAKoB,IAAIM,EAA4BC,EAE7C,GACHxB,EAQD0B,OAAA,SAAOH,GAEH,OADW9B,EAAAQ,UAAS0B,IAAG/B,KAAC2B,KAAAA,GAEjBA,EADY,YAEtBvB,EAEDyB,IAAA,SAAiDF,GAC7C,OAAA9B,EAAAQ,UAAawB,IAAG7B,UAAC2B,IACpBvB,EAIDiB,IAAA,SAAIM,EAAqCK,GAErC,OADInC,EAAAQ,UAAO0B,IA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IAHJK,EAAWL,EAAXK,YACAqB,EAAI1B,EAAJ0B,KACGC,6IAAIC,CAAA5B,EAAA6B,GAEPC,EAA4BC,EAAAA,SAAShE,OAAOiE,OAAQL,EAAKM,QAA0B,CAAA,IAA5EC,EAAMJ,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,5 +1,4 @@
1
- import { createContext, useContext } from 'use-context-selector';
2
- import { useRef, useReducer, createElement, useState, useCallback } from 'react';
1
+ import { createContext, useContext, createElement, useState, useCallback, useRef, useReducer } from 'react';
3
2
 
4
3
  function _arrayLikeToArray(r, a) {
5
4
  (null == a || a > r.length) && (a = r.length);
@@ -70,7 +69,7 @@ function _objectWithoutPropertiesLoose(r, e) {
70
69
  if (null == r) return {};
71
70
  var t = {};
72
71
  for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
73
- if (e.includes(n)) continue;
72
+ if (-1 !== e.indexOf(n)) continue;
74
73
  t[n] = r[n];
75
74
  }
76
75
  return t;
@@ -110,7 +109,6 @@ function _wrapNativeSuper(t) {
110
109
  }, _wrapNativeSuper(t);
111
110
  }
112
111
 
113
- // K extiende de INPUT_COMPONENTS_KEYS y puede incluir más claves personalizadas
114
112
  var InputMapping = /*#__PURE__*/function (_Map) {
115
113
  function InputMapping(obj) {
116
114
  var _this;
@@ -133,17 +131,23 @@ var InputMapping = /*#__PURE__*/function (_Map) {
133
131
  };
134
132
  _proto.appendObj = function appendObj(obj) {
135
133
  var keys = Object.keys(obj);
136
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
137
134
  for (var _i = 0, _keys = keys; _i < _keys.length; _i++) {
138
135
  var key = _keys[_i];
139
- this.set(key, obj[key]);
136
+ var value = obj[key];
137
+ if (value && key in {}) {
138
+ this.set(key, value);
139
+ } else if (value) {
140
+ this.set(key, value);
141
+ }
140
142
  }
141
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
142
143
  for (var _iterator = _createForOfIteratorHelperLoose(this.zodAdacter()), _step; !(_step = _iterator()).done;) {
143
144
  var _step$value = _step.value,
144
145
  k = _step$value[0],
145
146
  v = _step$value[1];
146
- this.set(k, this.get(v));
147
+ var existingValue = this.get(v);
148
+ if (existingValue) {
149
+ this.set(k, existingValue);
150
+ }
147
151
  }
148
152
  };
149
153
  _proto.exists = function exists(k) {
@@ -166,40 +170,7 @@ var InputMapping = /*#__PURE__*/function (_Map) {
166
170
  return InputMapping;
167
171
  }(/*#__PURE__*/_wrapNativeSuper(Map));
168
172
 
169
- var InputMappingContext = /*#__PURE__*/createContext(/*#__PURE__*/new InputMapping());
170
-
171
- var useInputMapping = function useInputMapping() {
172
- var initialState = useContext(InputMappingContext);
173
- var mapRef = useRef(initialState);
174
- var _useReducer = useReducer(function (x) {
175
- return x + 1;
176
- }, 0),
177
- reRender = _useReducer[1];
178
- mapRef.current.set = function () {
179
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
180
- args[_key] = arguments[_key];
181
- }
182
- InputMapping.prototype.set.apply(mapRef.current, args);
183
- reRender();
184
- return mapRef.current;
185
- };
186
- mapRef.current.clear = function () {
187
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
188
- args[_key2] = arguments[_key2];
189
- }
190
- InputMapping.prototype.clear.apply(mapRef.current, args);
191
- reRender();
192
- };
193
- mapRef.current["delete"] = function () {
194
- for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
195
- args[_key3] = arguments[_key3];
196
- }
197
- var res = InputMapping.prototype["delete"].apply(mapRef.current, args);
198
- reRender();
199
- return res;
200
- };
201
- return mapRef.current;
202
- };
173
+ var InputMappingContext = /*#__PURE__*/createContext(null);
203
174
 
204
175
  var createFormInstantContainer = function createFormInstantContainer(inputMapping) {
205
176
  var FormInstantInputsProvider = function FormInstantInputsProvider(props) {
@@ -208,6 +179,9 @@ var createFormInstantContainer = function createFormInstantContainer(inputMappin
208
179
  children: props.children
209
180
  });
210
181
  };
182
+ var useInputMapping = function useInputMapping() {
183
+ return useContext(InputMappingContext);
184
+ };
211
185
  return {
212
186
  FormInstantInputsProvider: FormInstantInputsProvider,
213
187
  useInputMapping: useInputMapping
@@ -216,7 +190,8 @@ var createFormInstantContainer = function createFormInstantContainer(inputMappin
216
190
  var ElementMapping = function ElementMapping(_ref) {
217
191
  var _formProps$fieldConfi;
218
192
  var formProps = _ref.formProps;
219
- var InputMapping = useInputMapping();
193
+ if (!InputMappingContext) return null;
194
+ var InputMapping = useContext(InputMappingContext);
220
195
  var type = ((_formProps$fieldConfi = formProps.fieldConfig) == null ? void 0 : _formProps$fieldConfi.type) || formProps.type;
221
196
  var Element = InputMapping.get(type);
222
197
  if (!Element) return null;
@@ -232,17 +207,17 @@ var useFormInstantField = function useFormInstantField(_ref) {
232
207
  fiends = _useState[0],
233
208
  setFiends = _useState[1];
234
209
  var append = useCallback(function () {
235
- if (![fieldConfig == null ? void 0 : fieldConfig.max, Number(fieldConfig == null ? void 0 : fieldConfig.maxLength)].includes(fiends.length)) setFiends(function (pre) {
210
+ if (![fieldConfig == null ? void 0 : fieldConfig.max].includes(fiends.length)) setFiends(function (pre) {
236
211
  return [].concat(pre, [pre[0]]);
237
212
  });
238
- }, [fiends, fieldConfig == null ? void 0 : fieldConfig.max, fieldConfig == null ? void 0 : fieldConfig.maxLength]);
213
+ }, [fiends, fieldConfig == null ? void 0 : fieldConfig.max]);
239
214
  var remove = useCallback(function (index) {
240
- if (![fieldConfig == null ? void 0 : fieldConfig.min, Number(fieldConfig == null ? void 0 : fieldConfig.minLength)].includes(fiends.length)) setFiends(function (pre) {
215
+ if (![fieldConfig == null ? void 0 : fieldConfig.min].includes(fiends.length)) setFiends(function (pre) {
241
216
  return pre.filter(function (_, i) {
242
217
  return i !== index;
243
218
  });
244
219
  });
245
- }, [fiends, fieldConfig == null ? void 0 : fieldConfig.min, fieldConfig == null ? void 0 : fieldConfig.minLength]);
220
+ }, [fiends, fieldConfig == null ? void 0 : fieldConfig.min]);
246
221
  return _extends({
247
222
  fiends: fiends,
248
223
  append: append,
@@ -253,5 +228,33 @@ var useFormInstantField = function useFormInstantField(_ref) {
253
228
  }, prop);
254
229
  };
255
230
 
256
- export { ElementMapping, InputMapping, InputMappingContext, createFormInstantContainer, useFormInstantField, useInputMapping };
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 };
257
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\ntype MergeKeys<T, U> = {\n [K in keyof T | keyof U]: K extends keyof T ? T[K] : K extends keyof U ? U[K] : never;\n};\n\n// K extiende de INPUT_COMPONENTS_KEYS y puede incluir más claves personalizadas\nexport class InputMapping<P = object, K extends string = INPUT_COMPONENTS_KEYS> extends Map<\n MergeKeys<K, INPUT_COMPONENTS_KEYS>,\n FC<P>\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<Record<K | INPUT_COMPONENTS_KEYS, FC<P>>>) {\n const keys = Object.keys(obj) as Array<K | INPUT_COMPONENTS_KEYS>;\n\n type Ky = MergeKeys<K, INPUT_COMPONENTS_KEYS>;\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n for (const key of keys) this.set(key as Ky, obj[key]!);\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n for (const [k, v] of this.zodAdacter()) this.set(k as Ky, this.get(v)!);\n }\n\n constructor(obj?: Partial<Record<K | INPUT_COMPONENTS_KEYS, FC<P>>>) {\n super();\n\n if (!obj) return;\n\n this.appendObj(obj);\n }\n\n exists(k: string) {\n const isHas = super.has(k as MergeKeys<K, INPUT_COMPONENTS_KEYS>);\n\n if (!isHas) return 'fallback';\n\n return k as MergeKeys<K, INPUT_COMPONENTS_KEYS>;\n }\n\n get(k: MergeKeys<K, INPUT_COMPONENTS_KEYS> | string) {\n return super.get(k as MergeKeys<K, INPUT_COMPONENTS_KEYS>);\n }\n\n set(k: MergeKeys<K, INPUT_COMPONENTS_KEYS>, v: FC<P>) {\n if (!super.has(k)) super.set(k, v);\n\n return this;\n }\n\n extends(cb: (mapingp: InputMapping<P, K | INPUT_COMPONENTS_KEYS>) => Record<never, FC<P>>) {\n const obj = Object.fromEntries(super.entries()) as Record<string, FC<P>>;\n\n const extendObj = cb(this as unknown as InputMapping<P, K | INPUT_COMPONENTS_KEYS>);\n\n return new InputMapping<P, K | INPUT_COMPONENTS_KEYS>({\n ...obj,\n ...extendObj,\n } as Record<K | INPUT_COMPONENTS_KEYS, FC<P>>);\n }\n}\n","import { createContext } from 'use-context-selector';\nimport { InputMapping } from './class';\n\nexport const InputMappingContext = createContext<InputMapping>(new InputMapping());\n","import { useReducer, useRef } from 'react';\nimport { InputMapping } from './class';\nimport { InputMappingContext } from './context';\nimport { useContext } from 'use-context-selector';\n\nexport const useInputMapping = () => {\n const initialState = useContext(InputMappingContext);\n const mapRef = useRef(initialState);\n const [, reRender] = useReducer((x) => x + 1, 0);\n\n mapRef.current.set = (...args) => {\n InputMapping.prototype.set.apply(mapRef.current, args);\n reRender();\n return mapRef.current;\n };\n\n mapRef.current.clear = (...args) => {\n InputMapping.prototype.clear.apply(mapRef.current, args);\n reRender();\n };\n\n mapRef.current.delete = (...args) => {\n const res = InputMapping.prototype.delete.apply(mapRef.current, args);\n reRender();\n\n return res;\n };\n\n return mapRef.current;\n};\n","import { createElement } from 'react';\nimport { InputMapping } from './class';\nimport { InputMappingContext } from './context';\nimport { INPUT_COMPONENTS_KEYS, ParsedField } from './types';\nimport { useInputMapping } from './useInputMapping';\n\ninterface createFormInstantContainerRetuen<P = object, K extends string = INPUT_COMPONENTS_KEYS> {\n useInputMapping: () => InputMapping<P, K>;\n FormInstantInputsProvider: FCC;\n}\n\nexport const createFormInstantContainer = <P = object, K extends string = INPUT_COMPONENTS_KEYS>(\n inputMapping: InputMapping<P, K>,\n) => {\n const FormInstantInputsProvider: FCC = (props) =>\n createElement(InputMappingContext.Provider, {\n value: inputMapping as InputMapping,\n children: props.children,\n });\n\n return {\n FormInstantInputsProvider,\n useInputMapping,\n } as createFormInstantContainerRetuen<P, K>;\n};\n\nexport const ElementMapping: FC<{ formProps: ParsedField<any, string> }> = ({ formProps }) => {\n const InputMapping = useInputMapping();\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<any, string>>({\n fieldConfig,\n name,\n ...prop\n}: P) => {\n const [fiends, setFiends] = useState(Object.values(prop.schema || {}));\n\n const append = useCallback(() => {\n if (![fieldConfig?.max, Number(fieldConfig?.maxLength)].includes(fiends.length))\n setFiends((pre) => [...pre, pre[0]]);\n }, [fiends, fieldConfig?.max, fieldConfig?.maxLength]);\n\n const remove = useCallback(\n (index: number) => {\n if (![fieldConfig?.min, Number(fieldConfig?.minLength)].includes(fiends.length))\n setFiends((pre) => pre.filter((_, i) => i !== index));\n },\n [fiends, fieldConfig?.min, fieldConfig?.minLength],\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","set","_iterator","_createForOfIteratorHelperLoose","_step","done","_step$value","value","k","v","get","exists","isHas","has","extends","cb","fromEntries","extendObj","_extends2","_wrapNativeSuper","Map","InputMappingContext","createContext","useInputMapping","initialState","useContext","mapRef","useRef","_useReducer","useReducer","x","reRender","current","_len","arguments","args","Array","_key","apply","clear","_len2","_key2","_len3","_key3","res","createFormInstantContainer","inputMapping","FormInstantInputsProvider","props","createElement","Provider","children","ElementMapping","_ref","_formProps$fieldConfi","formProps","type","fieldConfig","Element","useFormInstantField","name","prop","_objectWithoutPropertiesLoose","_excluded","_useState","useState","values","schema","fiends","setFiends","append","useCallback","max","Number","maxLength","includes","pre","concat","remove","index","min","minLength","filter","_","i","_extends"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA;AACaA,IAAAA,YAAmE,0BAAAC,IAAA,EAAA;EA2B5E,SAAAD,YAAAA,CAAYE,GAAuD,EAAA;AAAA,IAAA,IAAAC,KAAA,CAAA;AAC/DA,IAAAA,KAAA,GAAAF,IAAA,CAAAG,IAAA,MAAO,IAAA,IAAA,CAAA;AAEP,IAAA,IAAI,CAACF,GAAG,EAAE,OAAAG,sBAAA,CAAAF,KAAA,CAAA,CAAA;AAEVA,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,CA7BOE,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,GAAsD,EAAA;AACpE,IAAA,IAAMiB,IAAI,GAAGR,MAAM,CAACQ,IAAI,CAACjB,GAAG,CAAqC,CAAA;AAIjE;AACA,IAAA,KAAA,IAAAkB,EAAA,GAAA,CAAA,EAAAC,KAAA,GAAkB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AAW,IAAA,IAAA,GAAA,KAAA,CAAA,GAAXA,WAAW,CAAEuB,GAAG,EAAEP,MAAM,CAAChB,WAAW,IAAA,IAAA,GAAA,KAAA,CAAA,GAAXA,WAAW,CAAEwB,SAAS,CAAC,CAAC,CAACN,QAAQ,CAACP,MAAM,CAACrE,MAAM,CAAC,EAC3EsE,SAAS,CAAC,UAACO,GAAG,EAAA;AAAA,MAAA,OAAKA,GAAG,CAACM,MAAM,CAAC,UAACC,CAAC,EAAEC,CAAC,EAAA;QAAA,OAAKA,CAAC,KAAKL,KAAK,CAAA;OAAC,CAAA,CAAA;KAAC,CAAA,CAAA;AAC7D,GAAC,EACD,CAACX,MAAM,EAAEX,WAAW,oBAAXA,WAAW,CAAEuB,GAAG,EAAEvB,WAAW,IAAXA,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,WAAW,CAAEwB,SAAS,CAAC,CACrD,CAAA;AAED,EAAA,OAAAI,QAAA,CAAA;AAASjB,IAAAA,MAAM,EAANA,MAAM;AAAEE,IAAAA,MAAM,EAANA,MAAM;AAAEQ,IAAAA,MAAM,EAANA,MAAM;AAAET,IAAAA,SAAS,EAATA,SAAS;AAAEZ,IAAAA,WAAW,EAAXA,WAAW;AAAEG,IAAAA,IAAI,EAAJA,IAAAA;AAAI,GAAA,EAAKC,IAAI,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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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": "@form-instant/react-input-mapping",
3
- "version": "1.6.0",
3
+ "version": "1.7.5-rc.1",
4
4
  "author": {
5
5
  "name": "leomerida15",
6
6
  "email": "dimasmerida15@gmail.com",
@@ -17,6 +17,7 @@
17
17
  "@tsconfig/recommended": "^1.0.7",
18
18
  "@tsconfig/vite-react": "^3.0.2",
19
19
  "@types/bun": "^1.1.8",
20
+ "@types/minimatch": "^5.1.2",
20
21
  "@types/react": "^18.3.12",
21
22
  "dts-cli": "^2.0.5",
22
23
  "eslint-plugin-prettier": "^5.2.1",
@@ -60,6 +61,7 @@
60
61
  "start": "dts watch",
61
62
  "test": "dts test --passWithNoTests",
62
63
  "Up": "npm publish --access public",
64
+ "Up:rc": "npm publish --access public --tag rc",
63
65
  "doc:build": "bun nodemon --config docs/nodemon.json"
64
66
  },
65
67
  "size-limit": [
@@ -74,6 +76,7 @@
74
76
  ],
75
77
  "typings": "dist/index.d.ts",
76
78
  "dependencies": {
79
+ "minimatch": "^10.0.3",
77
80
  "use-context-selector": "^2.0.0"
78
81
  }
79
82
  }