@webiny/react-properties 5.39.1-beta.0 → 5.39.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.
|
@@ -22,7 +22,7 @@ function createConfigurableComponent(name) {
|
|
|
22
22
|
/**
|
|
23
23
|
* This component is used when we want to mount all composed configs.
|
|
24
24
|
*/
|
|
25
|
-
var ConfigApply = (0, _reactComposition.
|
|
25
|
+
var ConfigApply = (0, _reactComposition.makeDecoratable)("".concat(name, "ConfigApply"), function (_ref2) {
|
|
26
26
|
var children = _ref2.children;
|
|
27
27
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children);
|
|
28
28
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactComposition","_index","createHOC","newChildren","BaseComponent","ConfigHOC","_ref","children","default","createElement","createConfigurableComponent","name","ConfigApply","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactComposition","_index","createHOC","newChildren","BaseComponent","ConfigHOC","_ref","children","default","createElement","createConfigurableComponent","name","ConfigApply","makeDecoratable","concat","_ref2","Fragment","Config","_ref3","Compose","component","with","defaultContext","properties","ViewContext","React","createContext","WithConfig","_ref4","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 function createConfigurableComponent<TConfig>(name: string) {\n /**\n * This component is used when we want to mount all composed configs.\n */\n const ConfigApply = makeDecoratable(`${name}ConfigApply`, ({ children }: ConfigApplyProps) => {\n return <>{children}</>;\n });\n\n /**\n * This component is used to configure the component (it can be mounted many times).\n */\n const Config = ({ children }: { children: React.ReactNode }) => {\n return <Compose component={ConfigApply} 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 <ConfigApply />\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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N,UAAU,CAAC;MAC5B;IACJ,CAAC,EAAE,CAACA,UAAU,CAAC,CAAC;IAEhB,IAAMc,YAAY,GAAG,SAAfA,YAAYA,CAAId,UAAsB,EAAK;MAC7CW,aAAa,CAACX,UAAU,CAAC;IAC7B,CAAC;IAED,oBACI1B,MAAA,CAAAW,OAAA,CAAAC,aAAA,CAACe,WAAW,CAACc,QAAQ;MAACC,KAAK,EAAEJ;IAAQ,gBACjCtC,MAAA,CAAAW,OAAA,CAAAC,aAAA,CAACR,MAAA,CAAAuC,UAAU;MAACC,QAAQ,EAAEJ;IAAa,gBAC/BxC,MAAA,CAAAW,OAAA,CAAAC,aAAA,CAACG,WAAW,MAAE,CAAC,EACdL,QACO,CACM,CAAC;EAE/B,CAAC;EAED,SAASmC,SAASA,CAAA,EAA4C;IAC1D,IAAAC,WAAA,GAAuB,IAAAC,iBAAU,EAACpB,WAAW,CAAC;MAAtCD,UAAU,GAAAoB,WAAA,CAAVpB,UAAU;IAClB,OAAO,IAAAsB,cAAO,EAAC;MAAA,OAAM,IAAAC,eAAQ,EAAmBvB,UAAU,CAAC;IAAA,GAAE,CAACA,UAAU,CAAC,CAAC;EAC9E;EAEA,OAAO;IACHI,UAAU,EAAVA,UAAU;IACVV,MAAM,EAANA,MAAM;IACNyB,SAAS,EAATA;EACJ,CAAC;AACL"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/react-properties",
|
|
3
|
-
"version": "5.39.1
|
|
3
|
+
"version": "5.39.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,14 +12,14 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@babel/runtime": "7.22.6",
|
|
14
14
|
"@types/react": "17.0.39",
|
|
15
|
-
"@webiny/react-composition": "5.39.1
|
|
15
|
+
"@webiny/react-composition": "5.39.1",
|
|
16
16
|
"nanoid": "3.3.4",
|
|
17
17
|
"react": "17.0.2"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@testing-library/react": "12.1.5",
|
|
21
|
-
"@webiny/cli": "5.39.1
|
|
22
|
-
"@webiny/project-utils": "5.39.1
|
|
21
|
+
"@webiny/cli": "5.39.1",
|
|
22
|
+
"@webiny/project-utils": "5.39.1",
|
|
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": "
|
|
33
|
+
"gitHead": "6fc74b45740bd4123dcf9b5890bfacee594208bf"
|
|
34
34
|
}
|