@webiny/react-properties 5.40.0-beta.1 → 5.40.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Properties.d.ts CHANGED
@@ -22,7 +22,7 @@ interface PropertiesProps {
22
22
  onChange?(properties: Property[]): void;
23
23
  children: React.ReactNode;
24
24
  }
25
- export declare const Properties: ({ onChange, children }: PropertiesProps) => JSX.Element;
25
+ export declare const Properties: ({ onChange, children }: PropertiesProps) => React.JSX.Element;
26
26
  export declare function useProperties(): PropertiesContext;
27
27
  interface PropertyProps {
28
28
  id?: string;
@@ -42,5 +42,5 @@ interface AncestorMatch {
42
42
  [key: string]: string | boolean | number | null | undefined;
43
43
  }
44
44
  export declare function useAncestor(params: AncestorMatch): Property | undefined;
45
- export declare const Property: ({ id, name, value, children, after, before, replace, remove, array, root, parent }: PropertyProps) => JSX.Element | null;
45
+ export declare const Property: ({ id, name, value, children, after, before, replace, remove, array, root, parent }: PropertyProps) => React.JSX.Element | null;
46
46
  export {};
package/Properties.js CHANGED
@@ -70,7 +70,7 @@ function mergeProperty(properties, property) {
70
70
  return properties;
71
71
  }
72
72
  var PropertiesContext = /*#__PURE__*/(0, _react.createContext)(undefined);
73
- var Properties = function Properties(_ref) {
73
+ var Properties = exports.Properties = function Properties(_ref) {
74
74
  var onChange = _ref.onChange,
75
75
  children = _ref.children;
76
76
  var _useState = (0, _react.useState)([]),
@@ -138,7 +138,6 @@ var Properties = function Properties(_ref) {
138
138
  value: context
139
139
  }, children);
140
140
  };
141
- exports.Properties = Properties;
142
141
  function useProperties() {
143
142
  var properties = (0, _react.useContext)(PropertiesContext);
144
143
  if (!properties) {
@@ -170,7 +169,7 @@ function useAncestor(params) {
170
169
  };
171
170
  return property ? matchOrGetAncestor(property, params) : undefined;
172
171
  }
173
- var Property = function Property(_ref2) {
172
+ var Property = exports.Property = function Property(_ref2) {
174
173
  var id = _ref2.id,
175
174
  name = _ref2.name,
176
175
  value = _ref2.value,
@@ -232,6 +231,5 @@ var Property = function Property(_ref2) {
232
231
  }
233
232
  return null;
234
233
  };
235
- exports.Property = Property;
236
234
 
237
235
  //# sourceMappingURL=Properties.js.map
package/Properties.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_utils","removeByParent","id","properties","filter","prop","parent","reduce","acc","item","putPropertyBefore","property","before","existingIndex","findIndex","existingProperty","newProperties","p","targetIndex","endsWith","concat","_toConsumableArray2","default","slice","putPropertyAfter","after","_properties$splice","splice","_properties$splice2","_slicedToArray2","removedProperty","length","mergeProperty","index","_objectSpread2","PropertiesContext","createContext","undefined","Properties","_ref","onChange","children","_useState","useState","_useState2","setProperties","useEffect","context","useMemo","getObject","toObject","addProperty","options","arguments","removeProperty","replaceProperty","toReplace","createElement","Provider","value","exports","useProperties","useContext","Error","PropertyContext","useParentProperty","useAncestor","params","_useProperties","matchOrGetAncestor","matchedProps","name","Object","keys","newParent","find","Property","_ref2","_ref2$after","_ref2$before","_ref2$replace","replace","_ref2$remove","remove","_ref2$array","array","_ref2$root","root","_ref2$parent","uniqueId","getUniqueId","parentProperty","parentId"],"sources":["Properties.tsx"],"sourcesContent":["import React, { createContext, useContext, useEffect, useMemo, useState } from \"react\";\nimport { getUniqueId, toObject } from \"./utils\";\n\nexport interface Property {\n id: string;\n parent: string;\n name: string;\n value?: unknown;\n array?: boolean;\n}\n\nfunction removeByParent(id: string, properties: Property[]): Property[] {\n return properties\n .filter(prop => prop.parent === id)\n .reduce((acc, item) => {\n return removeByParent(\n item.id,\n acc.filter(prop => prop.id !== item.id)\n );\n }, properties);\n}\n\ninterface AddPropertyOptions {\n after?: string;\n before?: string;\n}\n\ninterface PropertiesContext {\n properties: Property[];\n getObject<T = unknown>(): T;\n addProperty(property: Property, options?: AddPropertyOptions): void;\n removeProperty(id: string): void;\n replaceProperty(id: string, property: Property): void;\n}\n\nfunction putPropertyBefore(properties: Property[], property: Property, before: string) {\n const existingIndex = properties.findIndex(prop => prop.id === property.id);\n if (existingIndex > -1) {\n const existingProperty = properties[existingIndex];\n const newProperties = properties.filter(p => p.id !== property.id);\n const targetIndex = before.endsWith(\"$first\")\n ? 0\n : newProperties.findIndex(prop => prop.id === before);\n return [\n ...newProperties.slice(0, targetIndex),\n existingProperty,\n ...newProperties.slice(targetIndex)\n ];\n }\n\n const targetIndex = properties.findIndex(prop => prop.id === before);\n\n return [...properties.slice(0, targetIndex), property, ...properties.slice(targetIndex)];\n}\n\nfunction putPropertyAfter(properties: Property[], property: Property, after: string) {\n const existingIndex = properties.findIndex(prop => prop.id === property.id);\n\n if (existingIndex > -1) {\n const [removedProperty] = properties.splice(existingIndex, 1);\n const targetIndex = after.endsWith(\"$last\")\n ? properties.length - 1\n : properties.findIndex(prop => prop.id === after);\n return [\n ...properties.slice(0, targetIndex + 1),\n removedProperty,\n ...properties.slice(targetIndex + 1)\n ];\n }\n\n const targetIndex = properties.findIndex(prop => prop.id === after);\n\n return [\n ...properties.slice(0, targetIndex + 1),\n property,\n ...properties.slice(targetIndex + 1)\n ];\n}\n\nfunction mergeProperty(properties: Property[], property: Property) {\n const index = properties.findIndex(prop => prop.id === property.id);\n if (index > -1) {\n return [\n ...properties.slice(0, index),\n { ...properties[index], ...property },\n ...properties.slice(index + 1)\n ];\n }\n return properties;\n}\n\nconst PropertiesContext = createContext<PropertiesContext | undefined>(undefined);\n\ninterface PropertiesProps {\n onChange?(properties: Property[]): void;\n children: React.ReactNode;\n}\n\nexport const Properties = ({ onChange, children }: PropertiesProps) => {\n const [properties, setProperties] = useState<Property[]>([]);\n\n useEffect(() => {\n if (onChange) {\n onChange(properties);\n }\n }, [properties]);\n\n const context: PropertiesContext = useMemo(\n () => ({\n properties,\n getObject<T>() {\n return toObject(properties) as T;\n },\n addProperty(property, options = {}) {\n setProperties(properties => {\n const index = properties.findIndex(prop => prop.id === property.id);\n\n if (index > -1) {\n const newProperties = mergeProperty(properties, property);\n if (options.after) {\n return putPropertyAfter(newProperties, property, options.after);\n }\n if (options.before) {\n return putPropertyBefore(newProperties, property, options.before);\n }\n\n return newProperties;\n }\n\n if (options.after) {\n return putPropertyAfter(properties, property, options.after);\n }\n\n if (options.before) {\n return putPropertyBefore(properties, property, options.before);\n }\n\n return [...properties, property];\n });\n },\n removeProperty(id) {\n setProperties(properties => {\n return removeByParent(\n id,\n properties.filter(prop => prop.id !== id)\n );\n });\n },\n replaceProperty(id, property) {\n setProperties(properties => {\n const toReplace = properties.findIndex(prop => prop.id === id);\n\n if (toReplace > -1) {\n // Replace the property and remove all remaining child properties.\n return removeByParent(id, [\n ...properties.slice(0, toReplace),\n property,\n ...properties.slice(toReplace + 1)\n ]);\n }\n return properties;\n });\n }\n }),\n [properties]\n );\n\n return <PropertiesContext.Provider value={context}>{children}</PropertiesContext.Provider>;\n};\n\nexport function useProperties() {\n const properties = useContext(PropertiesContext);\n if (!properties) {\n throw Error(\"Properties context provider is missing!\");\n }\n\n return properties;\n}\n\ninterface PropertyProps {\n id?: string;\n name: string;\n value?: unknown;\n array?: boolean;\n after?: string;\n before?: string;\n replace?: string;\n remove?: boolean;\n parent?: string;\n root?: boolean;\n children?: React.ReactNode;\n}\n\nconst PropertyContext = createContext<Property | undefined>(undefined);\n\nexport function useParentProperty() {\n return useContext(PropertyContext);\n}\n\ninterface AncestorMatch {\n [key: string]: string | boolean | number | null | undefined;\n}\n\nexport function useAncestor(params: AncestorMatch) {\n const property = useParentProperty();\n const { properties } = useProperties();\n\n const matchOrGetAncestor = (\n property: Property,\n params: AncestorMatch\n ): Property | undefined => {\n const matchedProps = properties\n .filter(prop => prop.parent === property.id)\n .filter(prop => prop.name in params && prop.value === params[prop.name]);\n\n if (matchedProps.length === Object.keys(params).length) {\n return property;\n }\n\n const newParent = property.parent\n ? properties.find(prop => prop.id === property.parent)\n : undefined;\n\n return newParent ? matchOrGetAncestor(newParent, params) : undefined;\n };\n\n return property ? matchOrGetAncestor(property, params) : undefined;\n}\n\nexport const Property = ({\n id,\n name,\n value,\n children,\n after = undefined,\n before = undefined,\n replace = undefined,\n remove = false,\n array = false,\n root = false,\n parent = undefined\n}: PropertyProps) => {\n const uniqueId = useMemo(() => id || getUniqueId(), []);\n const parentProperty = useParentProperty();\n const properties = useProperties();\n\n if (!properties) {\n throw Error(\"<Properties> provider is missing higher in the hierarchy!\");\n }\n\n const { addProperty, removeProperty, replaceProperty } = properties;\n const parentId = parent ? parent : root ? \"\" : parentProperty?.id || \"\";\n const property = { id: uniqueId, name, value, parent: parentId, array };\n\n useEffect(() => {\n if (remove) {\n removeProperty(uniqueId);\n return;\n }\n\n if (replace) {\n replaceProperty(replace, property);\n return;\n }\n\n addProperty(property, { after, before });\n\n return () => {\n removeProperty(uniqueId);\n };\n }, []);\n\n if (children) {\n return <PropertyContext.Provider value={property}>{children}</PropertyContext.Provider>;\n }\n\n return null;\n};\n"],"mappings":";;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAUA,SAASE,cAAcA,CAACC,EAAU,EAAEC,UAAsB,EAAc;EACpE,OAAOA,UAAU,CACZC,MAAM,CAAC,UAAAC,IAAI;IAAA,OAAIA,IAAI,CAACC,MAAM,KAAKJ,EAAE;EAAA,EAAC,CAClCK,MAAM,CAAC,UAACC,GAAG,EAAEC,IAAI,EAAK;IACnB,OAAOR,cAAc,CACjBQ,IAAI,CAACP,EAAE,EACPM,GAAG,CAACJ,MAAM,CAAC,UAAAC,IAAI;MAAA,OAAIA,IAAI,CAACH,EAAE,KAAKO,IAAI,CAACP,EAAE;IAAA,EAC1C,CAAC;EACL,CAAC,EAAEC,UAAU,CAAC;AACtB;AAeA,SAASO,iBAAiBA,CAACP,UAAsB,EAAEQ,QAAkB,EAAEC,MAAc,EAAE;EACnF,IAAMC,aAAa,GAAGV,UAAU,CAACW,SAAS,CAAC,UAAAT,IAAI;IAAA,OAAIA,IAAI,CAACH,EAAE,KAAKS,QAAQ,CAACT,EAAE;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7B,cAAc,CAACmC,QAAQ,CAAC;MACxB;IACJ;IAEA,IAAIR,OAAO,EAAE;MACT1B,eAAe,CAAC0B,OAAO,EAAEtE,QAAQ,CAAC;MAClC;IACJ;IAEAwC,WAAW,CAACxC,QAAQ,EAAE;MAAEc,KAAK,EAALA,KAAK;MAAEb,MAAM,EAANA;IAAO,CAAC,CAAC;IAExC,OAAO,YAAM;MACT0C,cAAc,CAACmC,QAAQ,CAAC;IAC5B,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EAEN,IAAIhD,QAAQ,EAAE;IACV,oBAAO5C,MAAA,CAAAyB,OAAA,CAAAmC,aAAA,CAACO,eAAe,CAACN,QAAQ;MAACC,KAAK,EAAEhD;IAAS,GAAE8B,QAAmC,CAAC;EAC3F;EAEA,OAAO,IAAI;AACf,CAAC;AAACmB,OAAA,CAAAgB,QAAA,GAAAA,QAAA"}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_utils","removeByParent","id","properties","filter","prop","parent","reduce","acc","item","putPropertyBefore","property","before","existingIndex","findIndex","existingProperty","newProperties","p","targetIndex","endsWith","concat","_toConsumableArray2","default","slice","putPropertyAfter","after","_properties$splice","splice","_properties$splice2","_slicedToArray2","removedProperty","length","mergeProperty","index","_objectSpread2","PropertiesContext","createContext","undefined","Properties","exports","_ref","onChange","children","_useState","useState","_useState2","setProperties","useEffect","context","useMemo","getObject","toObject","addProperty","options","arguments","removeProperty","replaceProperty","toReplace","createElement","Provider","value","useProperties","useContext","Error","PropertyContext","useParentProperty","useAncestor","params","_useProperties","matchOrGetAncestor","matchedProps","name","Object","keys","newParent","find","Property","_ref2","_ref2$after","_ref2$before","_ref2$replace","replace","_ref2$remove","remove","_ref2$array","array","_ref2$root","root","_ref2$parent","uniqueId","getUniqueId","parentProperty","parentId"],"sources":["Properties.tsx"],"sourcesContent":["import React, { createContext, useContext, useEffect, useMemo, useState } from \"react\";\nimport { getUniqueId, toObject } from \"./utils\";\n\nexport interface Property {\n id: string;\n parent: string;\n name: string;\n value?: unknown;\n array?: boolean;\n}\n\nfunction removeByParent(id: string, properties: Property[]): Property[] {\n return properties\n .filter(prop => prop.parent === id)\n .reduce((acc, item) => {\n return removeByParent(\n item.id,\n acc.filter(prop => prop.id !== item.id)\n );\n }, properties);\n}\n\ninterface AddPropertyOptions {\n after?: string;\n before?: string;\n}\n\ninterface PropertiesContext {\n properties: Property[];\n getObject<T = unknown>(): T;\n addProperty(property: Property, options?: AddPropertyOptions): void;\n removeProperty(id: string): void;\n replaceProperty(id: string, property: Property): void;\n}\n\nfunction putPropertyBefore(properties: Property[], property: Property, before: string) {\n const existingIndex = properties.findIndex(prop => prop.id === property.id);\n if (existingIndex > -1) {\n const existingProperty = properties[existingIndex];\n const newProperties = properties.filter(p => p.id !== property.id);\n const targetIndex = before.endsWith(\"$first\")\n ? 0\n : newProperties.findIndex(prop => prop.id === before);\n return [\n ...newProperties.slice(0, targetIndex),\n existingProperty,\n ...newProperties.slice(targetIndex)\n ];\n }\n\n const targetIndex = properties.findIndex(prop => prop.id === before);\n\n return [...properties.slice(0, targetIndex), property, ...properties.slice(targetIndex)];\n}\n\nfunction putPropertyAfter(properties: Property[], property: Property, after: string) {\n const existingIndex = properties.findIndex(prop => prop.id === property.id);\n\n if (existingIndex > -1) {\n const [removedProperty] = properties.splice(existingIndex, 1);\n const targetIndex = after.endsWith(\"$last\")\n ? properties.length - 1\n : properties.findIndex(prop => prop.id === after);\n return [\n ...properties.slice(0, targetIndex + 1),\n removedProperty,\n ...properties.slice(targetIndex + 1)\n ];\n }\n\n const targetIndex = properties.findIndex(prop => prop.id === after);\n\n return [\n ...properties.slice(0, targetIndex + 1),\n property,\n ...properties.slice(targetIndex + 1)\n ];\n}\n\nfunction mergeProperty(properties: Property[], property: Property) {\n const index = properties.findIndex(prop => prop.id === property.id);\n if (index > -1) {\n return [\n ...properties.slice(0, index),\n { ...properties[index], ...property },\n ...properties.slice(index + 1)\n ];\n }\n return properties;\n}\n\nconst PropertiesContext = createContext<PropertiesContext | undefined>(undefined);\n\ninterface PropertiesProps {\n onChange?(properties: Property[]): void;\n children: React.ReactNode;\n}\n\nexport const Properties = ({ onChange, children }: PropertiesProps) => {\n const [properties, setProperties] = useState<Property[]>([]);\n\n useEffect(() => {\n if (onChange) {\n onChange(properties);\n }\n }, [properties]);\n\n const context: PropertiesContext = useMemo(\n () => ({\n properties,\n getObject<T>() {\n return toObject(properties) as T;\n },\n addProperty(property, options = {}) {\n setProperties(properties => {\n const index = properties.findIndex(prop => prop.id === property.id);\n\n if (index > -1) {\n const newProperties = mergeProperty(properties, property);\n if (options.after) {\n return putPropertyAfter(newProperties, property, options.after);\n }\n if (options.before) {\n return putPropertyBefore(newProperties, property, options.before);\n }\n\n return newProperties;\n }\n\n if (options.after) {\n return putPropertyAfter(properties, property, options.after);\n }\n\n if (options.before) {\n return putPropertyBefore(properties, property, options.before);\n }\n\n return [...properties, property];\n });\n },\n removeProperty(id) {\n setProperties(properties => {\n return removeByParent(\n id,\n properties.filter(prop => prop.id !== id)\n );\n });\n },\n replaceProperty(id, property) {\n setProperties(properties => {\n const toReplace = properties.findIndex(prop => prop.id === id);\n\n if (toReplace > -1) {\n // Replace the property and remove all remaining child properties.\n return removeByParent(id, [\n ...properties.slice(0, toReplace),\n property,\n ...properties.slice(toReplace + 1)\n ]);\n }\n return properties;\n });\n }\n }),\n [properties]\n );\n\n return <PropertiesContext.Provider value={context}>{children}</PropertiesContext.Provider>;\n};\n\nexport function useProperties() {\n const properties = useContext(PropertiesContext);\n if (!properties) {\n throw Error(\"Properties context provider is missing!\");\n }\n\n return properties;\n}\n\ninterface PropertyProps {\n id?: string;\n name: string;\n value?: unknown;\n array?: boolean;\n after?: string;\n before?: string;\n replace?: string;\n remove?: boolean;\n parent?: string;\n root?: boolean;\n children?: React.ReactNode;\n}\n\nconst PropertyContext = createContext<Property | undefined>(undefined);\n\nexport function useParentProperty() {\n return useContext(PropertyContext);\n}\n\ninterface AncestorMatch {\n [key: string]: string | boolean | number | null | undefined;\n}\n\nexport function useAncestor(params: AncestorMatch) {\n const property = useParentProperty();\n const { properties } = useProperties();\n\n const matchOrGetAncestor = (\n property: Property,\n params: AncestorMatch\n ): Property | undefined => {\n const matchedProps = properties\n .filter(prop => prop.parent === property.id)\n .filter(prop => prop.name in params && prop.value === params[prop.name]);\n\n if (matchedProps.length === Object.keys(params).length) {\n return property;\n }\n\n const newParent = property.parent\n ? properties.find(prop => prop.id === property.parent)\n : undefined;\n\n return newParent ? matchOrGetAncestor(newParent, params) : undefined;\n };\n\n return property ? matchOrGetAncestor(property, params) : undefined;\n}\n\nexport const Property = ({\n id,\n name,\n value,\n children,\n after = undefined,\n before = undefined,\n replace = undefined,\n remove = false,\n array = false,\n root = false,\n parent = undefined\n}: PropertyProps) => {\n const uniqueId = useMemo(() => id || getUniqueId(), []);\n const parentProperty = useParentProperty();\n const properties = useProperties();\n\n if (!properties) {\n throw Error(\"<Properties> provider is missing higher in the hierarchy!\");\n }\n\n const { addProperty, removeProperty, replaceProperty } = properties;\n const parentId = parent ? parent : root ? \"\" : parentProperty?.id || \"\";\n const property = { id: uniqueId, name, value, parent: parentId, array };\n\n useEffect(() => {\n if (remove) {\n removeProperty(uniqueId);\n return;\n }\n\n if (replace) {\n replaceProperty(replace, property);\n return;\n }\n\n addProperty(property, { after, before });\n\n return () => {\n removeProperty(uniqueId);\n };\n }, []);\n\n if (children) {\n return <PropertyContext.Provider value={property}>{children}</PropertyContext.Provider>;\n }\n\n return null;\n};\n"],"mappings":";;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAUA,SAASE,cAAcA,CAACC,EAAU,EAAEC,UAAsB,EAAc;EACpE,OAAOA,UAAU,CACZC,MAAM,CAAC,UAAAC,IAAI;IAAA,OAAIA,IAAI,CAACC,MAAM,KAAKJ,EAAE;EAAA,EAAC,CAClCK,MAAM,CAAC,UAACC,GAAG,EAAEC,IAAI,EAA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CAA9CoD,cAAc;IAAEC,eAAe,GAAKrD,UAAU,CAA9BqD,eAAe;EACpD,IAAMoC,QAAQ,GAAGtF,MAAM,GAAGA,MAAM,GAAGiF,IAAI,GAAG,EAAE,GAAGI,cAAc,EAAEzF,EAAE,IAAI,EAAE;EACvE,IAAMS,QAAQ,GAAG;IAAET,EAAE,EAAEuF,QAAQ;IAAElB,IAAI,EAAJA,IAAI;IAAEX,KAAK,EAALA,KAAK;IAAEtD,MAAM,EAAEsF,QAAQ;IAAEP,KAAK,EAALA;EAAM,CAAC;EAEvE,IAAAtC,gBAAS,EAAC,YAAM;IACZ,IAAIoC,MAAM,EAAE;MACR5B,cAAc,CAACkC,QAAQ,CAAC;MACxB;IACJ;IAEA,IAAIR,OAAO,EAAE;MACTzB,eAAe,CAACyB,OAAO,EAAEtE,QAAQ,CAAC;MAClC;IACJ;IAEAyC,WAAW,CAACzC,QAAQ,EAAE;MAAEc,KAAK,EAALA,KAAK;MAAEb,MAAM,EAANA;IAAO,CAAC,CAAC;IAExC,OAAO,YAAM;MACT2C,cAAc,CAACkC,QAAQ,CAAC;IAC5B,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EAEN,IAAI/C,QAAQ,EAAE;IACV,oBAAO7C,MAAA,CAAAyB,OAAA,CAAAoC,aAAA,CAACM,eAAe,CAACL,QAAQ;MAACC,KAAK,EAAEjD;IAAS,GAAE+B,QAAmC,CAAC;EAC3F;EAEA,OAAO,IAAI;AACf,CAAC","ignoreList":[]}
@@ -9,7 +9,7 @@ export interface ConfigProps {
9
9
  priority?: "primary" | "secondary";
10
10
  }
11
11
  export declare function createConfigurableComponent<TConfig>(name: string): {
12
- WithConfig: ({ onProperties, children }: WithConfigProps) => JSX.Element;
13
- Config: ({ priority, children }: ConfigProps) => JSX.Element;
12
+ WithConfig: ({ onProperties, children }: WithConfigProps) => React.JSX.Element;
13
+ Config: ({ priority, children }: ConfigProps) => React.JSX.Element;
14
14
  useConfig: <TExtra extends object>() => TConfig & TExtra;
15
15
  };
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_reactComposition","_index","createHOC","newChildren","BaseComponent","ConfigHOC","_ref","children","default","createElement","createConfigurableComponent","name","ConfigApplyPrimary","makeDecoratable","concat","_ref2","Fragment","ConfigApplySecondary","_ref3","Config","_ref4","_ref4$priority","priority","Compose","component","with","defaultContext","properties","ViewContext","React","createContext","WithConfig","_ref5","onProperties","_useState","useState","_useState2","_slicedToArray2","setProperties","context","useEffect","stateUpdater","Provider","value","Properties","onChange","useConfig","_useContext","useContext","useMemo","toObject"],"sources":["createConfigurableComponent.tsx"],"sourcesContent":["import React, { useContext, useEffect, useMemo, useState } from \"react\";\nimport { Compose, Decorator, makeDecoratable } from \"@webiny/react-composition\";\nimport { Property, Properties, toObject } from \"~/index\";\nimport { GenericComponent } from \"@webiny/react-composition/types\";\n\nconst createHOC =\n (newChildren: React.ReactNode): Decorator<GenericComponent<{ children?: React.ReactNode }>> =>\n BaseComponent => {\n return function ConfigHOC({ children }) {\n return (\n <BaseComponent>\n {newChildren}\n {children}\n </BaseComponent>\n );\n };\n };\n\nexport interface WithConfigProps {\n children: React.ReactNode;\n onProperties?(properties: Property[]): void;\n}\n\ninterface ConfigApplyProps {\n children?: React.ReactNode;\n}\n\nexport interface ConfigProps {\n children: React.ReactNode;\n priority?: \"primary\" | \"secondary\";\n}\n\nexport function createConfigurableComponent<TConfig>(name: string) {\n /**\n * This component is used when we want to mount all composed configs.\n */\n const ConfigApplyPrimary = makeDecoratable(\n `${name}ConfigApply<Primary>`,\n ({ children }: ConfigApplyProps) => {\n return <>{children}</>;\n }\n );\n\n const ConfigApplySecondary = makeDecoratable(\n `${name}ConfigApply<Secondary>`,\n ({ children }: ConfigApplyProps) => {\n return <>{children}</>;\n }\n );\n\n /**\n * This component is used to configure the component (it can be mounted many times).\n */\n const Config = ({ priority = \"primary\", children }: ConfigProps) => {\n if (priority === \"primary\") {\n return <Compose component={ConfigApplyPrimary} with={createHOC(children)} />;\n }\n return <Compose component={ConfigApplySecondary} with={createHOC(children)} />;\n };\n\n interface ViewContext {\n properties: Property[];\n }\n\n const defaultContext = { properties: [] };\n\n const ViewContext = React.createContext<ViewContext>(defaultContext);\n\n const WithConfig = ({ onProperties, children }: WithConfigProps) => {\n const [properties, setProperties] = useState<Property[]>([]);\n const context = { properties };\n\n useEffect(() => {\n if (typeof onProperties === \"function\") {\n onProperties(properties);\n }\n }, [properties]);\n\n const stateUpdater = (properties: Property[]) => {\n setProperties(properties);\n };\n\n return (\n <ViewContext.Provider value={context}>\n <Properties onChange={stateUpdater}>\n <ConfigApplyPrimary />\n <ConfigApplySecondary />\n {children}\n </Properties>\n </ViewContext.Provider>\n );\n };\n\n function useConfig<TExtra extends object>(): TConfig & TExtra {\n const { properties } = useContext(ViewContext);\n return useMemo(() => toObject<TConfig & TExtra>(properties), [properties]);\n }\n\n return {\n WithConfig,\n Config,\n useConfig\n };\n}\n"],"mappings":";;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAGA,IAAMG,SAAS,GACX,SADEA,SAASA,CACVC,WAA4B;EAAA,OAC7B,UAAAC,aAAa,EAAI;IACb,OAAO,SAASC,SAASA,CAAAC,IAAA,EAAe;MAAA,IAAZC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;MAChC,oBACIV,MAAA,CAAAW,OAAA,CAAAC,aAAA,CAACL,aAAa,QACTD,WAAW,EACXI,QACU,CAAC;IAExB,CAAC;EACL,CAAC;AAAA;AAgBE,SAASG,2BAA2BA,CAAUC,IAAY,EAAE;EAC/D;AACJ;AACA;EACI,IAAMC,kBAAkB,GAAG,IAAAC,iCAAe,KAAAC,MAAA,CACnCH,IAAI,2BACP,UAAAI,KAAA,EAAoC;IAAA,IAAjCR,QAAQ,GAAAQ,KAAA,CAARR,QAAQ;IACP,oBAAOV,MAAA,CAAAW,OA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+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactComposition","_index","createHOC","newChildren","BaseComponent","ConfigHOC","_ref","children","default","createElement","createConfigurableComponent","name","ConfigApplyPrimary","makeDecoratable","concat","_ref2","Fragment","ConfigApplySecondary","_ref3","Config","_ref4","_ref4$priority","priority","Compose","component","with","defaultContext","properties","ViewContext","React","createContext","WithConfig","_ref5","onProperties","_useState","useState","_useState2","_slicedToArray2","setProperties","context","useEffect","stateUpdater","Provider","value","Properties","onChange","useConfig","_useContext","useContext","useMemo","toObject"],"sources":["createConfigurableComponent.tsx"],"sourcesContent":["import React, { useContext, useEffect, useMemo, useState } from \"react\";\nimport { Compose, Decorator, makeDecoratable } from \"@webiny/react-composition\";\nimport { Property, Properties, toObject } from \"~/index\";\nimport { GenericComponent } from \"@webiny/react-composition/types\";\n\nconst createHOC =\n (newChildren: React.ReactNode): Decorator<GenericComponent<{ children?: React.ReactNode }>> =>\n BaseComponent => {\n return function ConfigHOC({ children }) {\n return (\n <BaseComponent>\n {newChildren}\n {children}\n </BaseComponent>\n );\n };\n };\n\nexport interface WithConfigProps {\n children: React.ReactNode;\n onProperties?(properties: Property[]): void;\n}\n\ninterface ConfigApplyProps {\n children?: React.ReactNode;\n}\n\nexport interface ConfigProps {\n children: React.ReactNode;\n priority?: \"primary\" | \"secondary\";\n}\n\nexport function createConfigurableComponent<TConfig>(name: string) {\n /**\n * This component is used when we want to mount all composed configs.\n */\n const ConfigApplyPrimary = makeDecoratable(\n `${name}ConfigApply<Primary>`,\n ({ children }: ConfigApplyProps) => {\n return <>{children}</>;\n }\n );\n\n const ConfigApplySecondary = makeDecoratable(\n `${name}ConfigApply<Secondary>`,\n ({ children }: ConfigApplyProps) => {\n return <>{children}</>;\n }\n );\n\n /**\n * This component is used to configure the component (it can be mounted many times).\n */\n const Config = ({ priority = \"primary\", children }: ConfigProps) => {\n if (priority === \"primary\") {\n return <Compose component={ConfigApplyPrimary} with={createHOC(children)} />;\n }\n return <Compose component={ConfigApplySecondary} with={createHOC(children)} />;\n };\n\n interface ViewContext {\n properties: Property[];\n }\n\n const defaultContext = { properties: [] };\n\n const ViewContext = React.createContext<ViewContext>(defaultContext);\n\n const WithConfig = ({ onProperties, children }: WithConfigProps) => {\n const [properties, setProperties] = useState<Property[]>([]);\n const context = { properties };\n\n useEffect(() => {\n if (typeof onProperties === \"function\") {\n onProperties(properties);\n }\n }, [properties]);\n\n const stateUpdater = (properties: Property[]) => {\n setProperties(properties);\n };\n\n return (\n <ViewContext.Provider value={context}>\n <Properties onChange={stateUpdater}>\n <ConfigApplyPrimary />\n <ConfigApplySecondary />\n {children}\n </Properties>\n </ViewContext.Provider>\n );\n };\n\n function useConfig<TExtra extends object>(): TConfig & TExtra {\n const { properties } = useContext(ViewContext);\n return useMemo(() => toObject<TConfig & TExtra>(properties), [properties]);\n }\n\n return {\n WithConfig,\n Config,\n useConfig\n };\n}\n"],"mappings":";;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAGA,IAAMG,SAAS,GACX,SADEA,SAASA,CACVC,WAA4B;EAAA,OAC7B,UAAAC,aAAa,EAAI;IACb,OAAO,SAASC,SAASA,CAAAC,IAAA,EAAe;MAAA,IAAZC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;MAChC,oBACIV,MAAA,CAAAW,OAAA,CAAAC,aAAA,CAACL,aAAa,QACTD,WAAW,EACXI,QACU,CAAC;IAExB,CAAC;EACL,CAAC;AAAA;AAgBE,SAASG,2BAA2BA,CAAUC,IAAY,EAAE;EAC/D;AACJ;AACA;EACI,IAAMC,kBAAkB,GAAG,IAAAC,iCAAe,KAAAC,MAAA,CACnCH,IAAI,2BACP,UAAAI,KAAA,EAAoC;IAAA,IAAjCR,QAAQ,GAAAQ,KAAA,CAARR,QAAQ;IACP,oBAAOV,MAAA,CAAAW,OAAA,CAAAC,aAAA,CAAAZ,MA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1 +1 @@
1
- {"version":3,"names":["_utils","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_Properties","_useIdGenerator","_createConfigurableComponent"],"sources":["index.ts"],"sourcesContent":["export * from \"./utils\";\nexport * from \"./Properties\";\nexport * from \"./useIdGenerator\";\nexport * from \"./createConfigurableComponent\";\n"],"mappings":";;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,MAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,MAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAT,MAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,WAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,WAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,WAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAC,WAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,eAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,eAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,eAAA,CAAAN,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAE,eAAA,CAAAN,GAAA;IAAA;EAAA;AAAA;AACA,IAAAO,4BAAA,GAAAX,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAS,4BAAA,EAAAR,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAO,4BAAA,CAAAP,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAG,4BAAA,CAAAP,GAAA;IAAA;EAAA;AAAA"}
1
+ {"version":3,"names":["_utils","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_Properties","_useIdGenerator","_createConfigurableComponent"],"sources":["index.ts"],"sourcesContent":["export * from \"./utils\";\nexport * from \"./Properties\";\nexport * from \"./useIdGenerator\";\nexport * from \"./createConfigurableComponent\";\n"],"mappings":";;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,MAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,MAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAT,MAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,WAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,WAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,WAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAC,WAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,eAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,eAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,eAAA,CAAAN,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAE,eAAA,CAAAN,GAAA;IAAA;EAAA;AAAA;AACA,IAAAO,4BAAA,GAAAX,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAS,4BAAA,EAAAR,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAO,4BAAA,CAAAP,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAG,4BAAA,CAAAP,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/react-properties",
3
- "version": "5.40.0-beta.1",
3
+ "version": "5.40.0-beta.3",
4
4
  "main": "index.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -10,16 +10,16 @@
10
10
  "author": "Webiny Ltd",
11
11
  "license": "MIT",
12
12
  "dependencies": {
13
- "@babel/runtime": "7.22.6",
14
- "@types/react": "17.0.39",
15
- "@webiny/react-composition": "5.40.0-beta.1",
16
- "nanoid": "3.3.4",
17
- "react": "17.0.2"
13
+ "@babel/runtime": "7.24.1",
14
+ "@types/react": "18.2.79",
15
+ "@webiny/react-composition": "5.40.0-beta.3",
16
+ "nanoid": "3.3.7",
17
+ "react": "18.2.0"
18
18
  },
19
19
  "devDependencies": {
20
- "@testing-library/react": "12.1.5",
21
- "@webiny/cli": "5.40.0-beta.1",
22
- "@webiny/project-utils": "5.40.0-beta.1",
20
+ "@testing-library/react": "15.0.7",
21
+ "@webiny/cli": "5.40.0-beta.3",
22
+ "@webiny/project-utils": "5.40.0-beta.3",
23
23
  "prettier": "2.8.8"
24
24
  },
25
25
  "publishConfig": {
@@ -30,5 +30,5 @@
30
30
  "build": "yarn webiny run build",
31
31
  "watch": "yarn webiny run watch"
32
32
  },
33
- "gitHead": "cadaa7aa80ddff01df7ecb3b356f2be9432e14e0"
33
+ "gitHead": "638d8b84063906cd1aa979ed6e0487ad26fbcf2f"
34
34
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","_Properties","useIdGenerator","name","parentProperty","useParentProperty","useCallback","_len","arguments","length","parts","Array","_key","id","concat","filter","Boolean","join"],"sources":["useIdGenerator.ts"],"sourcesContent":["import { useCallback } from \"react\";\nimport { useParentProperty } from \"~/Properties\";\n\nexport function useIdGenerator(name: string) {\n const parentProperty = useParentProperty();\n\n return useCallback(\n (...parts: string[]) => {\n return [parentProperty?.id, name, ...parts].filter(Boolean).join(\":\");\n },\n [name, parentProperty]\n );\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAEO,SAASE,cAAcA,CAACC,IAAY,EAAE;EACzC,IAAMC,cAAc,GAAG,IAAAC,6BAAiB,EAAC,CAAC;EAE1C,OAAO,IAAAC,kBAAW,EACd,YAAwB;IAAA,SAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAApBC,KAAK,OAAAC,KAAA,CAAAJ,IAAA,GAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;MAALF,KAAK,CAAAE,IAAA,IAAAJ,SAAA,CAAAI,IAAA;IAAA;IACL,OAAO,CAACR,cAAc,EAAES,EAAE,EAAEV,IAAI,EAAAW,MAAA,CAAKJ,KAAK,EAAEK,MAAM,CAACC,OAAO,CAAC,CAACC,IAAI,CAAC,GAAG,CAAC;EACzE,CAAC,EACD,CAACd,IAAI,EAAEC,cAAc,CACzB,CAAC;AACL"}
1
+ {"version":3,"names":["_react","require","_Properties","useIdGenerator","name","parentProperty","useParentProperty","useCallback","_len","arguments","length","parts","Array","_key","id","concat","filter","Boolean","join"],"sources":["useIdGenerator.ts"],"sourcesContent":["import { useCallback } from \"react\";\nimport { useParentProperty } from \"~/Properties\";\n\nexport function useIdGenerator(name: string) {\n const parentProperty = useParentProperty();\n\n return useCallback(\n (...parts: string[]) => {\n return [parentProperty?.id, name, ...parts].filter(Boolean).join(\":\");\n },\n [name, parentProperty]\n );\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAEO,SAASE,cAAcA,CAACC,IAAY,EAAE;EACzC,IAAMC,cAAc,GAAG,IAAAC,6BAAiB,EAAC,CAAC;EAE1C,OAAO,IAAAC,kBAAW,EACd,YAAwB;IAAA,SAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAApBC,KAAK,OAAAC,KAAA,CAAAJ,IAAA,GAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;MAALF,KAAK,CAAAE,IAAA,IAAAJ,SAAA,CAAAI,IAAA;IAAA;IACL,OAAO,CAACR,cAAc,EAAES,EAAE,EAAEV,IAAI,EAAAW,MAAA,CAAKJ,KAAK,EAAEK,MAAM,CAACC,OAAO,CAAC,CAACC,IAAI,CAAC,GAAG,CAAC;EACzE,CAAC,EACD,CAACd,IAAI,EAAEC,cAAc,CACzB,CAAC;AACL","ignoreList":[]}
package/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_nanoid","require","nanoid","customAlphabet","buildRoots","roots","properties","obj","reduce","acc","item","isArray","array","filter","r","name","length","_objectSpread3","default","_defineProperty2","forEach","root","Array","value","undefined","concat","_toConsumableArray2","nextRoots","p","parent","id","toObject","prop","getUniqueId","arguments"],"sources":["utils.ts"],"sourcesContent":["import { customAlphabet } from \"nanoid\";\nconst nanoid = customAlphabet(\"1234567890abcdef\");\nimport { Property } from \"./Properties\";\n\nfunction buildRoots(roots: Property[], properties: Property[]) {\n const obj: Record<string, unknown> = roots.reduce((acc, item) => {\n const isArray = item.array === true || roots.filter(r => r.name === item.name).length > 1;\n return { ...acc, [item.name]: isArray ? [] : {} };\n }, {});\n\n roots.forEach(root => {\n const isArray = root.array === true || Array.isArray(obj[root.name]);\n if (root.value !== undefined) {\n obj[root.name] = isArray ? [...(obj[root.name] as Array<any>), root.value] : root.value;\n return;\n }\n\n const nextRoots = properties.filter(p => p.parent === root.id);\n const value = buildRoots(nextRoots, properties);\n obj[root.name] = isArray ? [...(obj[root.name] as Property[]), value] : value;\n });\n\n return obj;\n}\n\nexport function toObject<T = unknown>(properties: Property[]): T {\n const roots = properties.filter(prop => prop.parent === \"\");\n return buildRoots(roots, properties) as T;\n}\n\nexport function getUniqueId(length = 12) {\n return nanoid(length);\n}\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAMC,MAAM,GAAG,IAAAC,sBAAc,EAAC,kBAAkB,CAAC;AAGjD,SAASC,UAAUA,CAACC,KAAiB,EAAEC,UAAsB,EAAE;EAC3D,IAAMC,GAA4B,GAAGF,KAAK,CAACG,MAAM,CAAC,UAACC,GAAG,EAAEC,IAAI,EAAK;IAC7D,IAAMC,OAAO,GAAGD,IAAI,CAACE,KAAK,KAAK,IAAI,IAAIP,KAAK,CAACQ,MAAM,CAAC,UAAAC,CAAC;MAAA,OAAIA,CAAC,CAACC,IAAI,KAAKL,IAAI,CAACK,IAAI;IAAA,EAAC,CAACC,MAAM,GAAG,CAAC;IACzF,WAAAC,cAAA,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KAAK,EAAEC,UAAU,CAAC;AACxC;AAEO,SAAS2B,WAAWA,CAAA,EAAc;EAAA,IAAbjB,MAAM,GAAAkB,SAAA,CAAAlB,MAAA,QAAAkB,SAAA,QAAAV,SAAA,GAAAU,SAAA,MAAG,EAAE;EACnC,OAAOhC,MAAM,CAACc,MAAM,CAAC;AACzB"}
1
+ {"version":3,"names":["_nanoid","require","nanoid","customAlphabet","buildRoots","roots","properties","obj","reduce","acc","item","isArray","array","filter","r","name","length","_objectSpread3","default","_defineProperty2","forEach","root","Array","value","undefined","concat","_toConsumableArray2","nextRoots","p","parent","id","toObject","prop","getUniqueId","arguments"],"sources":["utils.ts"],"sourcesContent":["import { customAlphabet } from \"nanoid\";\nconst nanoid = customAlphabet(\"1234567890abcdef\");\nimport { Property } from \"./Properties\";\n\nfunction buildRoots(roots: Property[], properties: Property[]) {\n const obj: Record<string, unknown> = roots.reduce((acc, item) => {\n const isArray = item.array === true || roots.filter(r => r.name === item.name).length > 1;\n return { ...acc, [item.name]: isArray ? [] : {} };\n }, {});\n\n roots.forEach(root => {\n const isArray = root.array === true || Array.isArray(obj[root.name]);\n if (root.value !== undefined) {\n obj[root.name] = isArray ? [...(obj[root.name] as Array<any>), root.value] : root.value;\n return;\n }\n\n const nextRoots = properties.filter(p => p.parent === root.id);\n const value = buildRoots(nextRoots, properties);\n obj[root.name] = isArray ? [...(obj[root.name] as Property[]), value] : value;\n });\n\n return obj;\n}\n\nexport function toObject<T = unknown>(properties: Property[]): T {\n const roots = properties.filter(prop => prop.parent === \"\");\n return buildRoots(roots, properties) as T;\n}\n\nexport function getUniqueId(length = 12) {\n return nanoid(length);\n}\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAMC,MAAM,GAAG,IAAAC,sBAAc,EAAC,kBAAkB,CAAC;AAGjD,SAASC,UAAUA,CAACC,KAAiB,EAAEC,UAAsB,EAAE;EAC3D,IAAMC,GAA4B,GAAGF,KAAK,CAACG,MA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