@servicetitan/ko-bridge 36.3.0 → 36.4.0
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.
|
@@ -4,8 +4,8 @@ import ReactDOM from 'react-dom';
|
|
|
4
4
|
let createRoot;
|
|
5
5
|
try {
|
|
6
6
|
/**
|
|
7
|
-
* Note,
|
|
8
|
-
* @see {@link file://./../../startup/src/
|
|
7
|
+
* Note, bundlers must be configured to ignore this dependency.
|
|
8
|
+
* @see {@link file://./../../startup/src/core/check-resource/is-managed-react-dom-client-dependency.ts}
|
|
9
9
|
*/ createRoot = require('react-dom/client').createRoot;
|
|
10
10
|
} catch (unused) {
|
|
11
11
|
// ignore
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ko-binding-handlers.tsx"],"sourcesContent":["import { ComponentType, Fragment, ReactElement, useEffect } from 'react';\nimport ReactDOM from 'react-dom';\nimport type ReactDOMClient from 'react-dom/client';\n\ntype KO = typeof import('knockout');\n\nlet createRoot: typeof ReactDOMClient.createRoot;\ntry {\n /**\n * Note,
|
|
1
|
+
{"version":3,"sources":["../src/ko-binding-handlers.tsx"],"sourcesContent":["import { ComponentType, Fragment, ReactElement, useEffect } from 'react';\nimport ReactDOM from 'react-dom';\nimport type ReactDOMClient from 'react-dom/client';\n\ntype KO = typeof import('knockout');\n\nlet createRoot: typeof ReactDOMClient.createRoot;\ntry {\n /**\n * Note, bundlers must be configured to ignore this dependency.\n * @see {@link file://./../../startup/src/core/check-resource/is-managed-react-dom-client-dependency.ts}\n */\n createRoot = require('react-dom/client').createRoot;\n} catch {\n // ignore\n}\n\nexport const koBindingHandlers = {\n // reactUncontrolled\n reactUncontrolled: (ko: KO): KnockoutBindingHandler => ({\n init: (\n el: Element,\n valueAccessor: () => any,\n allBindings: KnockoutAllBindingsAccessor,\n _viewModel: any,\n bindingContext: KnockoutBindingContext\n ) => {\n initRoot(ko, el, allBindings);\n const Component = ko.unwrap<ComponentType>(valueAccessor());\n render(\n ko,\n el,\n <Fragment>\n <Component />\n <ApplyBindings bindingContext={bindingContext} el={el} ko={ko} />\n </Fragment>\n );\n return { controlsDescendantBindings: true };\n },\n }),\n // React component renderer for knockout\n react: (ko: KO): KnockoutBindingHandler => ({\n init: (\n el: Element,\n _valueAccessor: () => any,\n allBindings: KnockoutAllBindingsAccessor\n ) => {\n initRoot(ko, el, allBindings);\n return { controlsDescendantBindings: true }; // important\n },\n update: (\n el: Element,\n valueAccessor: () => any,\n allBindings: KnockoutAllBindingsAccessor,\n viewModel: any\n ) => {\n const Component = ko.unwrap<ComponentType>(valueAccessor());\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n const props = allBindings.get('props') || viewModel || null;\n render(ko, el, <Component {...props} />);\n },\n }),\n};\n\nfunction ApplyBindings({ bindingContext, el, ko }: { bindingContext: any; el: Element; ko: KO }) {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useEffect(() => ko.applyBindingsToDescendants(bindingContext, el), []);\n return null;\n}\n\nconst ROOT_KEY = 'ko-binding-handler-root';\n\nfunction disposalCallback(el: Element, ko: KO) {\n const root = ko.utils.domData.get(el, ROOT_KEY);\n if (root) {\n return () => {\n root.unmount();\n ko.utils.domData.clear(el);\n };\n }\n // eslint-disable-next-line react/no-deprecated\n return () => ReactDOM.unmountComponentAtNode(el);\n}\nfunction initRoot(ko: KO, el: Element, allBindings: KnockoutAllBindingsAccessor) {\n if (createRoot && allBindings.get('legacyRoot') !== true) {\n const root = createRoot(el);\n ko.utils.domData.set(el, ROOT_KEY, root);\n }\n\n ko.utils.domNodeDisposal.addDisposeCallback(el, disposalCallback(el, ko));\n}\n\nfunction render(ko: KO, container: Element, element: ReactElement) {\n const root = ko.utils.domData.get(container, ROOT_KEY);\n if (root) {\n root.render(element);\n } else {\n // eslint-disable-next-line react/no-deprecated\n ReactDOM.render(element, container);\n }\n}\n"],"names":["Fragment","useEffect","ReactDOM","createRoot","require","koBindingHandlers","reactUncontrolled","ko","init","el","valueAccessor","allBindings","_viewModel","bindingContext","initRoot","Component","unwrap","render","ApplyBindings","controlsDescendantBindings","react","_valueAccessor","update","viewModel","props","get","applyBindingsToDescendants","ROOT_KEY","disposalCallback","root","utils","domData","unmount","clear","unmountComponentAtNode","set","domNodeDisposal","addDisposeCallback","container","element"],"mappings":";AAAA,SAAwBA,QAAQ,EAAgBC,SAAS,QAAQ,QAAQ;AACzE,OAAOC,cAAc,YAAY;AAKjC,IAAIC;AACJ,IAAI;IACA;;;KAGC,GACDA,aAAaC,QAAQ,oBAAoBD,UAAU;AACvD,EAAE,eAAM;AACJ,SAAS;AACb;AAEA,OAAO,MAAME,oBAAoB;IAC7B,oBAAoB;IACpBC,mBAAmB,CAACC,KAAoC,CAAA;YACpDC,MAAM,CACFC,IACAC,eACAC,aACAC,YACAC;gBAEAC,SAASP,IAAIE,IAAIE;gBACjB,MAAMI,YAAYR,GAAGS,MAAM,CAAgBN;gBAC3CO,OACIV,IACAE,kBACA,MAACT;;sCACG,KAACe;sCACD,KAACG;4BAAcL,gBAAgBA;4BAAgBJ,IAAIA;4BAAIF,IAAIA;;;;gBAGnE,OAAO;oBAAEY,4BAA4B;gBAAK;YAC9C;QACJ,CAAA;IACA,wCAAwC;IACxCC,OAAO,CAACb,KAAoC,CAAA;YACxCC,MAAM,CACFC,IACAY,gBACAV;gBAEAG,SAASP,IAAIE,IAAIE;gBACjB,OAAO;oBAAEQ,4BAA4B;gBAAK,GAAG,YAAY;YAC7D;YACAG,QAAQ,CACJb,IACAC,eACAC,aACAY;gBAEA,MAAMR,YAAYR,GAAGS,MAAM,CAAgBN;gBAC3C,wEAAwE;gBACxE,MAAMc,QAAQb,YAAYc,GAAG,CAAC,YAAYF,aAAa;gBACvDN,OAAOV,IAAIE,kBAAI,KAACM;oBAAW,GAAGS,KAAK;;YACvC;QACJ,CAAA;AACJ,EAAE;AAEF,SAASN,cAAc,EAAEL,cAAc,EAAEJ,EAAE,EAAEF,EAAE,EAAgD;IAC3F,uDAAuD;IACvDN,UAAU,IAAMM,GAAGmB,0BAA0B,CAACb,gBAAgBJ,KAAK,EAAE;IACrE,OAAO;AACX;AAEA,MAAMkB,WAAW;AAEjB,SAASC,iBAAiBnB,EAAW,EAAEF,EAAM;IACzC,MAAMsB,OAAOtB,GAAGuB,KAAK,CAACC,OAAO,CAACN,GAAG,CAAChB,IAAIkB;IACtC,IAAIE,MAAM;QACN,OAAO;YACHA,KAAKG,OAAO;YACZzB,GAAGuB,KAAK,CAACC,OAAO,CAACE,KAAK,CAACxB;QAC3B;IACJ;IACA,+CAA+C;IAC/C,OAAO,IAAMP,SAASgC,sBAAsB,CAACzB;AACjD;AACA,SAASK,SAASP,EAAM,EAAEE,EAAW,EAAEE,WAAwC;IAC3E,IAAIR,cAAcQ,YAAYc,GAAG,CAAC,kBAAkB,MAAM;QACtD,MAAMI,OAAO1B,WAAWM;QACxBF,GAAGuB,KAAK,CAACC,OAAO,CAACI,GAAG,CAAC1B,IAAIkB,UAAUE;IACvC;IAEAtB,GAAGuB,KAAK,CAACM,eAAe,CAACC,kBAAkB,CAAC5B,IAAImB,iBAAiBnB,IAAIF;AACzE;AAEA,SAASU,OAAOV,EAAM,EAAE+B,SAAkB,EAAEC,OAAqB;IAC7D,MAAMV,OAAOtB,GAAGuB,KAAK,CAACC,OAAO,CAACN,GAAG,CAACa,WAAWX;IAC7C,IAAIE,MAAM;QACNA,KAAKZ,MAAM,CAACsB;IAChB,OAAO;QACH,+CAA+C;QAC/CrC,SAASe,MAAM,CAACsB,SAASD;IAC7B;AACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicetitan/ko-bridge",
|
|
3
|
-
"version": "36.
|
|
3
|
+
"version": "36.4.0",
|
|
4
4
|
"description": "Collection of components and utils to connect Knockout and React codebase",
|
|
5
5
|
"homepage": "https://docs.st.dev/docs/frontend/uikit/ko-bridge",
|
|
6
6
|
"repository": {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"@types/react": "~18.3.3",
|
|
24
24
|
"@types/react-dom": "~18.3.0",
|
|
25
25
|
"knockout": "~3.0.0",
|
|
26
|
-
"mobx": "~6.15.
|
|
26
|
+
"mobx": "~6.15.4",
|
|
27
27
|
"react": "~18.3.1",
|
|
28
28
|
"react-dom": "~18.3.1"
|
|
29
29
|
},
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"cli": {
|
|
40
40
|
"webpack": false
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "8beab9ae3a70ce381e8cd53f2de8691640e96c6e"
|
|
43
43
|
}
|
|
@@ -7,8 +7,8 @@ type KO = typeof import('knockout');
|
|
|
7
7
|
let createRoot: typeof ReactDOMClient.createRoot;
|
|
8
8
|
try {
|
|
9
9
|
/**
|
|
10
|
-
* Note,
|
|
11
|
-
* @see {@link file://./../../startup/src/
|
|
10
|
+
* Note, bundlers must be configured to ignore this dependency.
|
|
11
|
+
* @see {@link file://./../../startup/src/core/check-resource/is-managed-react-dom-client-dependency.ts}
|
|
12
12
|
*/
|
|
13
13
|
createRoot = require('react-dom/client').createRoot;
|
|
14
14
|
} catch {
|