@elliemae/ds-decision-graph 3.22.0-next.26

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.
Files changed (44) hide show
  1. package/dist/cjs/DSDecisionGraph.js +73 -0
  2. package/dist/cjs/DSDecisionGraph.js.map +7 -0
  3. package/dist/cjs/config/useDecisionGraph.js +62 -0
  4. package/dist/cjs/config/useDecisionGraph.js.map +7 -0
  5. package/dist/cjs/config/useValidateProps.js +50 -0
  6. package/dist/cjs/config/useValidateProps.js.map +7 -0
  7. package/dist/cjs/constants/index.js +88 -0
  8. package/dist/cjs/constants/index.js.map +7 -0
  9. package/dist/cjs/index.js +41 -0
  10. package/dist/cjs/index.js.map +7 -0
  11. package/dist/cjs/package.json +7 -0
  12. package/dist/cjs/parts/mermaid/MermaidDecisionChart.js +61 -0
  13. package/dist/cjs/parts/mermaid/MermaidDecisionChart.js.map +7 -0
  14. package/dist/cjs/parts/mermaid/decisionTreeToMermaidMD.js +106 -0
  15. package/dist/cjs/parts/mermaid/decisionTreeToMermaidMD.js.map +7 -0
  16. package/dist/cjs/react-desc-prop-types.js +54 -0
  17. package/dist/cjs/react-desc-prop-types.js.map +7 -0
  18. package/dist/esm/DSDecisionGraph.js +43 -0
  19. package/dist/esm/DSDecisionGraph.js.map +7 -0
  20. package/dist/esm/config/useDecisionGraph.js +32 -0
  21. package/dist/esm/config/useDecisionGraph.js.map +7 -0
  22. package/dist/esm/config/useValidateProps.js +20 -0
  23. package/dist/esm/config/useValidateProps.js.map +7 -0
  24. package/dist/esm/constants/index.js +58 -0
  25. package/dist/esm/constants/index.js.map +7 -0
  26. package/dist/esm/index.js +11 -0
  27. package/dist/esm/index.js.map +7 -0
  28. package/dist/esm/package.json +7 -0
  29. package/dist/esm/parts/mermaid/MermaidDecisionChart.js +31 -0
  30. package/dist/esm/parts/mermaid/MermaidDecisionChart.js.map +7 -0
  31. package/dist/esm/parts/mermaid/decisionTreeToMermaidMD.js +76 -0
  32. package/dist/esm/parts/mermaid/decisionTreeToMermaidMD.js.map +7 -0
  33. package/dist/esm/react-desc-prop-types.js +24 -0
  34. package/dist/esm/react-desc-prop-types.js.map +7 -0
  35. package/dist/types/DSDecisionGraph.d.ts +5 -0
  36. package/dist/types/config/useDecisionGraph.d.ts +15 -0
  37. package/dist/types/config/useValidateProps.d.ts +3 -0
  38. package/dist/types/constants/index.d.ts +52 -0
  39. package/dist/types/index.d.ts +3 -0
  40. package/dist/types/parts/mermaid/MermaidDecisionChart.d.ts +8 -0
  41. package/dist/types/parts/mermaid/decisionTreeToMermaidMD.d.ts +8 -0
  42. package/dist/types/react-desc-prop-types.d.ts +54 -0
  43. package/dist/types/tests/DSDecisionGraph.test.d.ts +1 -0
  44. package/package.json +77 -0
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var DSDecisionGraph_exports = {};
30
+ __export(DSDecisionGraph_exports, {
31
+ DSDecisionGraph: () => DSDecisionGraph,
32
+ DSDecisionGraphWithSchema: () => DSDecisionGraphWithSchema
33
+ });
34
+ module.exports = __toCommonJS(DSDecisionGraph_exports);
35
+ var React = __toESM(require("react"));
36
+ var import_jsx_runtime = require("react/jsx-runtime");
37
+ var import_react = __toESM(require("react"));
38
+ var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
39
+ var import_ds_system = require("@elliemae/ds-system");
40
+ var import_ds_grid = require("@elliemae/ds-grid");
41
+ var import_react_desc_prop_types = require("./react-desc-prop-types.js");
42
+ var import_useDecisionGraph = require("./config/useDecisionGraph.js");
43
+ var import_constants = require("./constants/index.js");
44
+ var import_MermaidDecisionChart = require("./parts/mermaid/MermaidDecisionChart.js");
45
+ const StyledWrapper = (0, import_ds_system.styled)(import_ds_grid.Grid, { name: "ds-decision-graph", slot: import_constants.DECISION_GRAPH_SLOTS.WRAPPER })``;
46
+ const mainContentCols = ["1fr"];
47
+ const getOwnerPropsArgumentsNoOp = () => ({});
48
+ const DSDecisionGraph = (props) => {
49
+ const { propsWithDefault, globalProps, xstyledProps, instanceUid } = (0, import_useDecisionGraph.useDecisionGraph)(props);
50
+ const getOwnerProps = import_react.default.useCallback(() => propsWithDefault, [propsWithDefault]);
51
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
52
+ StyledWrapper,
53
+ {
54
+ cols: mainContentCols,
55
+ getOwnerProps,
56
+ getOwnerPropsArguments: getOwnerPropsArgumentsNoOp,
57
+ ...globalProps,
58
+ ...xstyledProps,
59
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
60
+ import_MermaidDecisionChart.MermaidDecisionChart,
61
+ {
62
+ uid: instanceUid,
63
+ chartJson: propsWithDefault.chartJson,
64
+ direction: propsWithDefault.direction
65
+ }
66
+ )
67
+ }
68
+ );
69
+ };
70
+ DSDecisionGraph.displayName = import_constants.DSDecisionGraphName;
71
+ const DSDecisionGraphWithSchema = (0, import_ds_props_helpers.describe)(DSDecisionGraph);
72
+ DSDecisionGraphWithSchema.propTypes = import_react_desc_prop_types.DSDecisionGraphPropTypesSchema;
73
+ //# sourceMappingURL=DSDecisionGraph.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/DSDecisionGraph.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["import React from 'react';\nimport { describe } from '@elliemae/ds-props-helpers';\nimport { styled } from '@elliemae/ds-system';\nimport { Grid } from '@elliemae/ds-grid';\nimport { type DSDecisionGraphT, DSDecisionGraphPropTypesSchema } from './react-desc-prop-types.js';\nimport { useDecisionGraph } from './config/useDecisionGraph.js';\nimport { DECISION_GRAPH_SLOTS, DSDecisionGraphName } from './constants/index.js';\nimport { MermaidDecisionChart } from './parts/mermaid/MermaidDecisionChart.js';\n\nconst StyledWrapper = styled(Grid, { name: 'ds-decision-graph', slot: DECISION_GRAPH_SLOTS.WRAPPER })``;\nconst mainContentCols = ['1fr'];\n\nconst getOwnerPropsArgumentsNoOp = () => ({});\nconst DSDecisionGraph: React.ComponentType<DSDecisionGraphT.Props> = (props) => {\n const { propsWithDefault, globalProps, xstyledProps, instanceUid } = useDecisionGraph(props);\n const getOwnerProps = React.useCallback(() => propsWithDefault, [propsWithDefault]);\n return (\n <StyledWrapper\n cols={mainContentCols}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={getOwnerPropsArgumentsNoOp}\n {...globalProps}\n {...xstyledProps}\n >\n <MermaidDecisionChart\n uid={instanceUid}\n chartJson={propsWithDefault.chartJson}\n direction={propsWithDefault.direction}\n />\n </StyledWrapper>\n );\n};\n\nDSDecisionGraph.displayName = DSDecisionGraphName;\nconst DSDecisionGraphWithSchema = describe(DSDecisionGraph);\nDSDecisionGraphWithSchema.propTypes = DSDecisionGraphPropTypesSchema;\n\nexport { DSDecisionGraph, DSDecisionGraphWithSchema };\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADwBjB;AAxBN,mBAAkB;AAClB,8BAAyB;AACzB,uBAAuB;AACvB,qBAAqB;AACrB,mCAAsE;AACtE,8BAAiC;AACjC,uBAA0D;AAC1D,kCAAqC;AAErC,MAAM,oBAAgB,yBAAO,qBAAM,EAAE,MAAM,qBAAqB,MAAM,sCAAqB,QAAQ,CAAC;AACpG,MAAM,kBAAkB,CAAC,KAAK;AAE9B,MAAM,6BAA6B,OAAO,CAAC;AAC3C,MAAM,kBAA+D,CAAC,UAAU;AAC9E,QAAM,EAAE,kBAAkB,aAAa,cAAc,YAAY,QAAI,0CAAiB,KAAK;AAC3F,QAAM,gBAAgB,aAAAA,QAAM,YAAY,MAAM,kBAAkB,CAAC,gBAAgB,CAAC;AAClF,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAM;AAAA,MACN;AAAA,MACA,wBAAwB;AAAA,MACvB,GAAG;AAAA,MACH,GAAG;AAAA,MAEJ;AAAA,QAAC;AAAA;AAAA,UACC,KAAK;AAAA,UACL,WAAW,iBAAiB;AAAA,UAC5B,WAAW,iBAAiB;AAAA;AAAA,MAC9B;AAAA;AAAA,EACF;AAEJ;AAEA,gBAAgB,cAAc;AAC9B,MAAM,gCAA4B,kCAAS,eAAe;AAC1D,0BAA0B,YAAY;",
6
+ "names": ["React"]
7
+ }
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var useDecisionGraph_exports = {};
30
+ __export(useDecisionGraph_exports, {
31
+ useDecisionGraph: () => useDecisionGraph
32
+ });
33
+ module.exports = __toCommonJS(useDecisionGraph_exports);
34
+ var React = __toESM(require("react"));
35
+ var import_react = __toESM(require("react"));
36
+ var import_lodash = require("lodash");
37
+ var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
38
+ var import_uid = require("uid");
39
+ var import_react_desc_prop_types = require("../react-desc-prop-types.js");
40
+ var import_useValidateProps = require("./useValidateProps.js");
41
+ const useDecisionGraph = (propsFromUser) => {
42
+ const propsWithDefault = (0, import_ds_props_helpers.useMemoMergePropsWithDefault)(propsFromUser, import_react_desc_prop_types.defaultProps);
43
+ (0, import_useValidateProps.useValidateProps)(propsWithDefault, import_react_desc_prop_types.DSDecisionGraphPropTypes);
44
+ const globalProps = (0, import_lodash.omit)((0, import_ds_props_helpers.useGetGlobalAttributes)(propsWithDefault), [
45
+ "cols",
46
+ "rows",
47
+ "wrap"
48
+ ]);
49
+ const xstyledProps = (0, import_ds_props_helpers.useGetXstyledProps)(propsWithDefault);
50
+ const { id } = propsWithDefault;
51
+ const instanceUid = import_react.default.useMemo(() => id || (0, import_uid.uid)(5), [id]);
52
+ return import_react.default.useMemo(
53
+ () => ({
54
+ propsWithDefault,
55
+ globalProps,
56
+ xstyledProps,
57
+ instanceUid
58
+ }),
59
+ [propsWithDefault, globalProps, xstyledProps, instanceUid]
60
+ );
61
+ };
62
+ //# sourceMappingURL=useDecisionGraph.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/config/useDecisionGraph.ts", "../../../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["import React from 'react';\nimport { omit } from 'lodash';\nimport { useGetGlobalAttributes, useGetXstyledProps, useMemoMergePropsWithDefault } from '@elliemae/ds-props-helpers';\nimport { uid } from 'uid';\nimport { type DSDecisionGraphT, DSDecisionGraphPropTypes, defaultProps } from '../react-desc-prop-types.js';\nimport { useValidateProps } from './useValidateProps.js';\n\nexport interface DecisionGraphCTX {\n propsWithDefault: DSDecisionGraphT.InternalProps;\n globalProps: ReturnType<typeof useGetGlobalAttributes>;\n xstyledProps: ReturnType<typeof useGetXstyledProps>;\n instanceUid: string;\n}\n\nexport const useDecisionGraph = (propsFromUser: DSDecisionGraphT.Props) => {\n // =============================================================================\n // MERGE WITH DEFAULT AND VALIDATE PROPS\n // =============================================================================\n const propsWithDefault = useMemoMergePropsWithDefault<DSDecisionGraphT.InternalProps>(propsFromUser, defaultProps);\n useValidateProps(propsWithDefault, DSDecisionGraphPropTypes);\n // =============================================================================\n // GLOBAL ATTRIBUTES & XSTYLED PROPS\n // =============================================================================\n const globalProps = omit(useGetGlobalAttributes<DSDecisionGraphT.InternalProps>(propsWithDefault), [\n 'cols',\n 'rows',\n 'wrap',\n ]);\n const xstyledProps = useGetXstyledProps(propsWithDefault);\n // =============================================================================\n // AD HOC PER COMPONENT LOGIC\n // =============================================================================\n // custom code goes here, this is an example\n const { id } = propsWithDefault;\n const instanceUid = React.useMemo(() => id || uid(5), [id]);\n\n // =============================================================================\n // HELPERS HOOKS CONFIGS\n // =============================================================================\n // const eventHandlers = useEventHandlers({ propsWithDefault, instanceUid }); // <-- complex logic should be made atomics this way\n\n return React.useMemo(\n () => ({\n propsWithDefault,\n globalProps,\n xstyledProps,\n instanceUid,\n }),\n [propsWithDefault, globalProps, xstyledProps, instanceUid],\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAkB;AAClB,oBAAqB;AACrB,8BAAyF;AACzF,iBAAoB;AACpB,mCAA8E;AAC9E,8BAAiC;AAS1B,MAAM,mBAAmB,CAAC,kBAA0C;AAIzE,QAAM,uBAAmB,sDAA6D,eAAe,yCAAY;AACjH,gDAAiB,kBAAkB,qDAAwB;AAI3D,QAAM,kBAAc,wBAAK,gDAAuD,gBAAgB,GAAG;AAAA,IACjG;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACD,QAAM,mBAAe,4CAAmB,gBAAgB;AAKxD,QAAM,EAAE,GAAG,IAAI;AACf,QAAM,cAAc,aAAAA,QAAM,QAAQ,MAAM,UAAM,gBAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AAO1D,SAAO,aAAAA,QAAM;AAAA,IACX,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,CAAC,kBAAkB,aAAa,cAAc,WAAW;AAAA,EAC3D;AACF;",
6
+ "names": ["React"]
7
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var useValidateProps_exports = {};
30
+ __export(useValidateProps_exports, {
31
+ useValidateProps: () => useValidateProps
32
+ });
33
+ module.exports = __toCommonJS(useValidateProps_exports);
34
+ var React = __toESM(require("react"));
35
+ var import_react = __toESM(require("react"));
36
+ var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
37
+ var import_constants = require("../constants/index.js");
38
+ var import_ajv = __toESM(require("ajv"));
39
+ const useValidateProps = (props, propTypes) => {
40
+ (0, import_ds_props_helpers.useValidateTypescriptPropTypes)(props, propTypes, import_constants.DSDecisionGraphName);
41
+ import_react.default.useEffect(() => {
42
+ const ajv = new import_ajv.default();
43
+ const validate = ajv.compile(import_constants.JSON_SCHEMA);
44
+ const valid = validate(props.chartJson);
45
+ if (!valid) {
46
+ throw new Error(`Invalid JSON: ${JSON.stringify(validate.errors)}`);
47
+ }
48
+ }, [props.chartJson]);
49
+ };
50
+ //# sourceMappingURL=useValidateProps.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/config/useValidateProps.ts", "../../../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["import React from 'react';\nimport type { WeakValidationMap } from 'react';\nimport { useValidateTypescriptPropTypes } from '@elliemae/ds-props-helpers';\nimport { type DSDecisionGraphT } from '../react-desc-prop-types.js';\nimport { DSDecisionGraphName, JSON_SCHEMA } from '../constants/index.js';\nimport Ajv from 'ajv';\n\nexport const useValidateProps = (\n props: DSDecisionGraphT.InternalProps,\n propTypes: WeakValidationMap<unknown>,\n): void => {\n // we validate the \"required if\" via 'isRequiredIf from our custom PropTypes\n useValidateTypescriptPropTypes(props, propTypes, DSDecisionGraphName);\n React.useEffect(() => {\n const ajv = new Ajv();\n const validate = ajv.compile(JSON_SCHEMA);\n const valid = validate(props.chartJson);\n if (!valid) {\n throw new Error(`Invalid JSON: ${JSON.stringify(validate.errors)}`);\n }\n }, [props.chartJson]);\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAkB;AAElB,8BAA+C;AAE/C,uBAAiD;AACjD,iBAAgB;AAET,MAAM,mBAAmB,CAC9B,OACA,cACS;AAET,8DAA+B,OAAO,WAAW,oCAAmB;AACpE,eAAAA,QAAM,UAAU,MAAM;AACpB,UAAM,MAAM,IAAI,WAAAC,QAAI;AACpB,UAAM,WAAW,IAAI,QAAQ,4BAAW;AACxC,UAAM,QAAQ,SAAS,MAAM,SAAS;AACtC,QAAI,CAAC,OAAO;AACV,YAAM,IAAI,MAAM,iBAAiB,KAAK,UAAU,SAAS,MAAM,GAAG;AAAA,IACpE;AAAA,EACF,GAAG,CAAC,MAAM,SAAS,CAAC;AACtB;",
6
+ "names": ["React", "Ajv"]
7
+ }
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var constants_exports = {};
30
+ __export(constants_exports, {
31
+ DECISION_GRAPH_DATA_TESTID: () => DECISION_GRAPH_DATA_TESTID,
32
+ DECISION_GRAPH_SLOTS: () => DECISION_GRAPH_SLOTS,
33
+ DSDecisionGraphName: () => DSDecisionGraphName,
34
+ JSON_SCHEMA: () => JSON_SCHEMA
35
+ });
36
+ module.exports = __toCommonJS(constants_exports);
37
+ var React = __toESM(require("react"));
38
+ var import_ds_system = require("@elliemae/ds-system");
39
+ const DSDecisionGraphName = "DSDecisionGraph";
40
+ const DECISION_GRAPH_SLOTS = {
41
+ WRAPPER: "wrapper"
42
+ };
43
+ const DECISION_GRAPH_DATA_TESTID = (0, import_ds_system.slotObjectToDataTestIds)(DSDecisionGraphName, DECISION_GRAPH_SLOTS);
44
+ const JSON_SCHEMA = {
45
+ $schema: "http://json-schema.org/draft-07/schema#",
46
+ type: "object",
47
+ properties: {
48
+ chartTitle: {
49
+ type: "string",
50
+ description: "Title of the decision chart"
51
+ },
52
+ subtree: {
53
+ $ref: "#/definitions/DecisionNode",
54
+ description: "The root of the decision tree"
55
+ }
56
+ },
57
+ required: ["chartTitle", "subtree"],
58
+ definitions: {
59
+ DecisionNode: {
60
+ type: "object",
61
+ properties: {
62
+ nodeText: {
63
+ type: "string",
64
+ description: "Text representing a conclusion or question"
65
+ },
66
+ semanticMeaning: { type: "string", enum: ["question", "conclusion"] },
67
+ repeatedId: {
68
+ type: "string",
69
+ description: "optional unique identifier for the node, used to allow pointing multiple paths to the same node in the chart"
70
+ },
71
+ truePath: {
72
+ $ref: "#/definitions/DecisionNode",
73
+ description: "Decision node for the true path"
74
+ },
75
+ falsePath: {
76
+ $ref: "#/definitions/DecisionNode",
77
+ description: "Decision node for the false path"
78
+ },
79
+ notApplicablePath: {
80
+ $ref: "#/definitions/DecisionNode",
81
+ description: "Decision node for the not applicable path"
82
+ }
83
+ },
84
+ required: ["nodeText", "semanticMeaning"]
85
+ }
86
+ }
87
+ };
88
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/constants/index.ts", "../../../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["import { slotObjectToDataTestIds } from '@elliemae/ds-system';\n// carefull to not implement dependency cycles, especially in react-desc-prop-types.ts\n// this file is meant to host \"simple\" constants\n// this file should never need to refeer the typescript namespace\n// if you need the typescript namespace in this file, you are probably not having to define a constant ?\n// if you are sure it's actually a constant declare a new file like `complex-constants.ts` or something like that to avoid cycle\n\nexport const DSDecisionGraphName = 'DSDecisionGraph';\n\n// we are giving \"component_name_slots\" to avoid errors on duplicate exports variables in aggregators\nexport const DECISION_GRAPH_SLOTS = {\n WRAPPER: 'wrapper',\n} as const;\n\n// we are giving \"component_name_data_testid\" to avoid errors on duplicate exports variables in aggregators\nexport const DECISION_GRAPH_DATA_TESTID = slotObjectToDataTestIds(DSDecisionGraphName, DECISION_GRAPH_SLOTS);\n\nexport const JSON_SCHEMA = {\n $schema: 'http://json-schema.org/draft-07/schema#',\n type: 'object',\n properties: {\n chartTitle: {\n type: 'string',\n description: 'Title of the decision chart',\n },\n subtree: {\n $ref: '#/definitions/DecisionNode',\n description: 'The root of the decision tree',\n },\n },\n required: ['chartTitle', 'subtree'],\n definitions: {\n DecisionNode: {\n type: 'object',\n properties: {\n nodeText: {\n type: 'string',\n description: 'Text representing a conclusion or question',\n },\n semanticMeaning: { type: 'string', enum: ['question', 'conclusion'] },\n repeatedId: {\n type: 'string',\n description:\n 'optional unique identifier for the node, used to allow pointing multiple paths to the same node in the chart',\n },\n truePath: {\n $ref: '#/definitions/DecisionNode',\n description: 'Decision node for the true path',\n },\n falsePath: {\n $ref: '#/definitions/DecisionNode',\n description: 'Decision node for the false path',\n },\n notApplicablePath: {\n $ref: '#/definitions/DecisionNode',\n description: 'Decision node for the not applicable path',\n },\n },\n required: ['nodeText', 'semanticMeaning'],\n },\n },\n} as const;\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,uBAAwC;AAOjC,MAAM,sBAAsB;AAG5B,MAAM,uBAAuB;AAAA,EAClC,SAAS;AACX;AAGO,MAAM,iCAA6B,0CAAwB,qBAAqB,oBAAoB;AAEpG,MAAM,cAAc;AAAA,EACzB,SAAS;AAAA,EACT,MAAM;AAAA,EACN,YAAY;AAAA,IACV,YAAY;AAAA,MACV,MAAM;AAAA,MACN,aAAa;AAAA,IACf;AAAA,IACA,SAAS;AAAA,MACP,MAAM;AAAA,MACN,aAAa;AAAA,IACf;AAAA,EACF;AAAA,EACA,UAAU,CAAC,cAAc,SAAS;AAAA,EAClC,aAAa;AAAA,IACX,cAAc;AAAA,MACZ,MAAM;AAAA,MACN,YAAY;AAAA,QACV,UAAU;AAAA,UACR,MAAM;AAAA,UACN,aAAa;AAAA,QACf;AAAA,QACA,iBAAiB,EAAE,MAAM,UAAU,MAAM,CAAC,YAAY,YAAY,EAAE;AAAA,QACpE,YAAY;AAAA,UACV,MAAM;AAAA,UACN,aACE;AAAA,QACJ;AAAA,QACA,UAAU;AAAA,UACR,MAAM;AAAA,UACN,aAAa;AAAA,QACf;AAAA,QACA,WAAW;AAAA,UACT,MAAM;AAAA,UACN,aAAa;AAAA,QACf;AAAA,QACA,mBAAmB;AAAA,UACjB,MAAM;AAAA,UACN,aAAa;AAAA,QACf;AAAA,MACF;AAAA,MACA,UAAU,CAAC,YAAY,iBAAiB;AAAA,IAC1C;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var src_exports = {};
30
+ __export(src_exports, {
31
+ DECISION_GRAPH_DATA_TESTID: () => import_constants.DECISION_GRAPH_DATA_TESTID,
32
+ DECISION_GRAPH_SLOTS: () => import_constants.DECISION_GRAPH_SLOTS,
33
+ DSDecisionGraph: () => import_DSDecisionGraph.DSDecisionGraph,
34
+ DSDecisionGraphWithSchema: () => import_DSDecisionGraph.DSDecisionGraphWithSchema
35
+ });
36
+ module.exports = __toCommonJS(src_exports);
37
+ var React = __toESM(require("react"));
38
+ var import_DSDecisionGraph = require("./DSDecisionGraph.js");
39
+ var import_react_desc_prop_types = require("./react-desc-prop-types.js");
40
+ var import_constants = require("./constants/index.js");
41
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts", "../../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["// this is a workaround to typescript error TS2742\n// https://github.com/microsoft/TypeScript/issues/47663\nimport type {} from '@xstyled/system';\nexport { DSDecisionGraph, DSDecisionGraphWithSchema } from './DSDecisionGraph.js';\nexport { type DSDecisionGraphT } from './react-desc-prop-types.js';\nexport { DECISION_GRAPH_SLOTS, DECISION_GRAPH_DATA_TESTID } from './constants/index.js';\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADGvB,6BAA2D;AAC3D,mCAAsC;AACtC,uBAAiE;",
6
+ "names": []
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "type": "commonjs",
3
+ "sideEffects": [
4
+ "*.css",
5
+ "*.scss"
6
+ ]
7
+ }
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var MermaidDecisionChart_exports = {};
30
+ __export(MermaidDecisionChart_exports, {
31
+ MermaidDecisionChart: () => MermaidDecisionChart
32
+ });
33
+ module.exports = __toCommonJS(MermaidDecisionChart_exports);
34
+ var React = __toESM(require("react"));
35
+ var import_jsx_runtime = require("react/jsx-runtime");
36
+ var import_react = __toESM(require("react"));
37
+ var import_decisionTreeToMermaidMD = require("./decisionTreeToMermaidMD.js");
38
+ var import_mermaid = __toESM(require("mermaid"));
39
+ const MermaidDecisionChart = (props) => {
40
+ const { chartJson, uid, direction } = props;
41
+ const mermaidRef = import_react.default.useRef(null);
42
+ const mermaidMD = import_react.default.useMemo(() => (0, import_decisionTreeToMermaidMD.decisionTreeToMermaidMD)(chartJson, direction), [chartJson, direction]);
43
+ import_react.default.useEffect(() => {
44
+ import_mermaid.default.initialize({
45
+ startOnLoad: false
46
+ });
47
+ }, []);
48
+ import_react.default.useEffect(() => {
49
+ setTimeout(() => {
50
+ const renderAsync = async () => {
51
+ const { svg } = await import_mermaid.default.render(`mermaid-svg-${uid}`, mermaidMD);
52
+ if (mermaidRef.current) {
53
+ mermaidRef.current.innerHTML = svg;
54
+ }
55
+ };
56
+ void renderAsync();
57
+ }, 0);
58
+ }, [mermaidMD, uid]);
59
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { ref: mermaidRef });
60
+ };
61
+ //# sourceMappingURL=MermaidDecisionChart.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/parts/mermaid/MermaidDecisionChart.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["import React from 'react';\nimport type { DSDecisionGraphT } from '../../react-desc-prop-types.js';\nimport { decisionTreeToMermaidMD } from './decisionTreeToMermaidMD.js';\n// https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/mermaid.ts#L367\nimport mermaid from 'mermaid';\n\ntype MermaidProps = {\n chartJson: DSDecisionGraphT.Props['chartJson'];\n uid: string;\n direction: DSDecisionGraphT.Directions;\n};\n\nexport const MermaidDecisionChart = (props: MermaidProps) => {\n const { chartJson, uid, direction } = props;\n const mermaidRef = React.useRef<HTMLPreElement>(null);\n // this operation should be O(1), but depending on the size of the decision tree,\n // it is still potentially beneficial to memoize it...\n const mermaidMD = React.useMemo(() => decisionTreeToMermaidMD(chartJson, direction), [chartJson, direction]);\n\n // on mount initialize mermaid\n React.useEffect(() => {\n mermaid.initialize({\n startOnLoad: false,\n });\n }, []);\n\n React.useEffect(() => {\n setTimeout(() => {\n const renderAsync = async () => {\n const { svg } = await mermaid.render(`mermaid-svg-${uid}`, mermaidMD);\n if (mermaidRef.current) {\n mermaidRef.current.innerHTML = svg;\n }\n };\n void renderAsync();\n }, 0);\n }, [mermaidMD, uid]);\n\n return <pre ref={mermaidRef} />;\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADsCd;AAtCT,mBAAkB;AAElB,qCAAwC;AAExC,qBAAoB;AAQb,MAAM,uBAAuB,CAAC,UAAwB;AAC3D,QAAM,EAAE,WAAW,KAAK,UAAU,IAAI;AACtC,QAAM,aAAa,aAAAA,QAAM,OAAuB,IAAI;AAGpD,QAAM,YAAY,aAAAA,QAAM,QAAQ,UAAM,wDAAwB,WAAW,SAAS,GAAG,CAAC,WAAW,SAAS,CAAC;AAG3G,eAAAA,QAAM,UAAU,MAAM;AACpB,mBAAAC,QAAQ,WAAW;AAAA,MACjB,aAAa;AAAA,IACf,CAAC;AAAA,EACH,GAAG,CAAC,CAAC;AAEL,eAAAD,QAAM,UAAU,MAAM;AACpB,eAAW,MAAM;AACf,YAAM,cAAc,YAAY;AAC9B,cAAM,EAAE,IAAI,IAAI,MAAM,eAAAC,QAAQ,OAAO,eAAe,OAAO,SAAS;AACpE,YAAI,WAAW,SAAS;AACtB,qBAAW,QAAQ,YAAY;AAAA,QACjC;AAAA,MACF;AACA,WAAK,YAAY;AAAA,IACnB,GAAG,CAAC;AAAA,EACN,GAAG,CAAC,WAAW,GAAG,CAAC;AAEnB,SAAO,4CAAC,SAAI,KAAK,YAAY;AAC/B;",
6
+ "names": ["React", "mermaid"]
7
+ }
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var decisionTreeToMermaidMD_exports = {};
30
+ __export(decisionTreeToMermaidMD_exports, {
31
+ decisionTreeToMermaidMD: () => decisionTreeToMermaidMD
32
+ });
33
+ module.exports = __toCommonJS(decisionTreeToMermaidMD_exports);
34
+ var React = __toESM(require("react"));
35
+ function nodePathToLinkMarkdown(nodePath) {
36
+ let linkMarkdown = "";
37
+ switch (nodePath.charAt(nodePath.length - 1)) {
38
+ case "t":
39
+ linkMarkdown = `-->|true|`;
40
+ break;
41
+ case "f":
42
+ linkMarkdown = `-->|false|`;
43
+ break;
44
+ case "o":
45
+ linkMarkdown = `-->|N/A|`;
46
+ break;
47
+ }
48
+ return linkMarkdown;
49
+ }
50
+ function isQuestionText(node) {
51
+ return (node.semanticMeaning && node.semanticMeaning === "question") ?? false;
52
+ }
53
+ function nodeToMermaidMD(node, nodePath) {
54
+ let nodeMarkdown;
55
+ if (isQuestionText(node)) {
56
+ nodeMarkdown = `${node?.repeatedId ?? nodePath}{{"${node.nodeText}"}}`;
57
+ } else {
58
+ nodeMarkdown = `${node?.repeatedId ?? nodePath}("${node.nodeText}")`;
59
+ }
60
+ return nodeMarkdown;
61
+ }
62
+ const flatten = (node, decisionNodes, nodePath = "s") => {
63
+ const decisionNode = {
64
+ nodeText: node.nodeText,
65
+ path: nodePath,
66
+ nodeMarkdown: nodeToMermaidMD(node, nodePath)
67
+ };
68
+ decisionNodes.set(nodePath, decisionNode);
69
+ if (node.truePath) {
70
+ flatten(node.truePath, decisionNodes, `${nodePath}t`);
71
+ }
72
+ if (node.falsePath) {
73
+ flatten(node.falsePath, decisionNodes, `${nodePath}f`);
74
+ }
75
+ if (node.notApplicablePath) {
76
+ flatten(node.notApplicablePath, decisionNodes, `${nodePath}o`);
77
+ }
78
+ };
79
+ const flattenDecisionTree = (rootNode) => {
80
+ const decisionNodes = /* @__PURE__ */ new Map();
81
+ const treeToFlatten = rootNode.subtree;
82
+ flatten(treeToFlatten, decisionNodes);
83
+ return decisionNodes;
84
+ };
85
+ const decisionTreeToMermaidMD = (rootNode, direction = "LR") => {
86
+ const title = `---
87
+ title: ${rootNode.chartTitle}
88
+ ---
89
+ `;
90
+ let mermaidMD = `${title}flowchart ${direction};
91
+ `;
92
+ const decisionNodes = flattenDecisionTree(rootNode);
93
+ decisionNodes.forEach((node, nodePath) => {
94
+ if (nodePath === "s")
95
+ return;
96
+ const parentNodeId = nodePath.slice(0, -1);
97
+ const parentNode = decisionNodes.get(parentNodeId);
98
+ if (parentNode) {
99
+ const linkMarkdown = nodePathToLinkMarkdown(nodePath);
100
+ mermaidMD += ` ${parentNode.nodeMarkdown}${linkMarkdown}${node.nodeMarkdown}
101
+ `;
102
+ }
103
+ });
104
+ return mermaidMD;
105
+ };
106
+ //# sourceMappingURL=decisionTreeToMermaidMD.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/parts/mermaid/decisionTreeToMermaidMD.ts", "../../../../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["import type { DSDecisionGraphT } from '../../react-desc-prop-types.js';\n\n/**************************************************************\n ***************** Mermaid Markdown Generator *****************\n ************************************************************ */\n\ntype FlatDecisionNode = {\n nodeText: string;\n path: DSDecisionGraphT.NodePath;\n nodeMarkdown?: DSDecisionGraphT.NodeMarkdown;\n};\nfunction nodePathToLinkMarkdown(nodePath: DSDecisionGraphT.NodePath): DSDecisionGraphT.LinkMarkdown {\n let linkMarkdown: DSDecisionGraphT.LinkMarkdown = '';\n switch (nodePath.charAt(nodePath.length - 1)) {\n case 't':\n linkMarkdown = `-->|true|`;\n break;\n case 'f':\n linkMarkdown = `-->|false|`;\n break;\n case 'o':\n linkMarkdown = `-->|N/A|`;\n break;\n }\n return linkMarkdown;\n}\nfunction isQuestionText(node: DSDecisionGraphT.DecisionNode): node is DSDecisionGraphT.QuestionNode {\n return (node.semanticMeaning && node.semanticMeaning === 'question') ?? false;\n}\n\nfunction nodeToMermaidMD(\n node: DSDecisionGraphT.DecisionNode,\n nodePath: DSDecisionGraphT.NodePath,\n): DSDecisionGraphT.NodeMarkdown {\n let nodeMarkdown: DSDecisionGraphT.NodeMarkdown;\n\n if (isQuestionText(node)) {\n nodeMarkdown = `${node?.repeatedId ?? nodePath}{{\"${node.nodeText}\"}}`;\n } else {\n nodeMarkdown = `${node?.repeatedId ?? nodePath}(\"${node.nodeText}\")`;\n }\n\n return nodeMarkdown;\n}\n\n/**\n * Recursively flattens a decision tree node and its children.\n * @param {DSDecisionGraphT.DecisionNode} node - The decision tree node to flatten.\n * @param { Map<DSDecisionGraphT.NodePath, FlatDecisionNode>} decisionNodes - the map to track the flattened nodes.\n * @param {DSDecisionGraphT.NodePath} nodePath - The path of the current node in the decision tree.\n */\nconst flatten = (\n node: DSDecisionGraphT.DecisionNode,\n decisionNodes: Map<DSDecisionGraphT.NodePath, FlatDecisionNode>,\n nodePath: DSDecisionGraphT.NodePath = 's' as DSDecisionGraphT.NodePath,\n) => {\n const decisionNode: FlatDecisionNode = {\n nodeText: node.nodeText,\n path: nodePath,\n nodeMarkdown: nodeToMermaidMD(node, nodePath),\n };\n decisionNodes.set(nodePath, decisionNode);\n if (node.truePath) {\n flatten(node.truePath, decisionNodes, `${nodePath}t`);\n }\n if (node.falsePath) {\n flatten(node.falsePath, decisionNodes, `${nodePath}f`);\n }\n if (node.notApplicablePath) {\n flatten(node.notApplicablePath, decisionNodes, `${nodePath}o`);\n }\n};\n\n/**\n * Flattens a decision tree into a map of flat decision nodes.\n * @param {DSDecisionGraphT.RootNode} rootNode - The root node of the decision tree to flatten.\n * @returns {Map<DSDecisionGraphT.NodePath, FlatDecisionNode>} A map of flat decision nodes, where each node is identified by its node ID.\n */\nconst flattenDecisionTree = (rootNode: DSDecisionGraphT.RootNode): Map<DSDecisionGraphT.NodePath, FlatDecisionNode> => {\n const decisionNodes: Map<DSDecisionGraphT.NodePath, FlatDecisionNode> = new Map();\n const treeToFlatten: DSDecisionGraphT.DecisionNode = rootNode.subtree;\n\n flatten(treeToFlatten, decisionNodes);\n return decisionNodes;\n};\n\n/**\n * Flattens a decision tree into a map of flat decision nodes.\n * @param {DSDecisionGraphT.RootNode} rootNode - The root node of the decision tree to flatten.\n * @param {DSDecisionGraphT.Directions} direction - direction of the flowchart, default is LR (left to right)\n * @returns {string} A map of flat decision nodes, where each node is identified by its node ID.\n */\nexport const decisionTreeToMermaidMD = (\n rootNode: DSDecisionGraphT.RootNode,\n direction: DSDecisionGraphT.Directions = 'LR',\n) => {\n const title = `---\\ntitle: ${rootNode.chartTitle}\\n---\\n`;\n let mermaidMD = `${title}flowchart ${direction};\\n`;\n // let mermaidMD = `flowchart LR;\\n subgraph ${rootNode.chartTitle};\\n`; // this add an highlight to the chart and the title\n const decisionNodes = flattenDecisionTree(rootNode);\n decisionNodes.forEach((node, nodePath) => {\n if (nodePath === 's') return;\n const parentNodeId = nodePath.slice(0, -1) as DSDecisionGraphT.NodePath;\n const parentNode = decisionNodes.get(parentNodeId);\n if (parentNode) {\n const linkMarkdown = nodePathToLinkMarkdown(nodePath);\n mermaidMD += `\\t${parentNode.nodeMarkdown}${linkMarkdown}${node.nodeMarkdown}\\n`;\n }\n });\n // mermaidMD += 'end;\\n';\n return mermaidMD;\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADWvB,SAAS,uBAAuB,UAAoE;AAClG,MAAI,eAA8C;AAClD,UAAQ,SAAS,OAAO,SAAS,SAAS,CAAC,GAAG;AAAA,IAC5C,KAAK;AACH,qBAAe;AACf;AAAA,IACF,KAAK;AACH,qBAAe;AACf;AAAA,IACF,KAAK;AACH,qBAAe;AACf;AAAA,EACJ;AACA,SAAO;AACT;AACA,SAAS,eAAe,MAA4E;AAClG,UAAQ,KAAK,mBAAmB,KAAK,oBAAoB,eAAe;AAC1E;AAEA,SAAS,gBACP,MACA,UAC+B;AAC/B,MAAI;AAEJ,MAAI,eAAe,IAAI,GAAG;AACxB,mBAAe,GAAG,MAAM,cAAc,cAAc,KAAK;AAAA,EAC3D,OAAO;AACL,mBAAe,GAAG,MAAM,cAAc,aAAa,KAAK;AAAA,EAC1D;AAEA,SAAO;AACT;AAQA,MAAM,UAAU,CACd,MACA,eACA,WAAsC,QACnC;AACH,QAAM,eAAiC;AAAA,IACrC,UAAU,KAAK;AAAA,IACf,MAAM;AAAA,IACN,cAAc,gBAAgB,MAAM,QAAQ;AAAA,EAC9C;AACA,gBAAc,IAAI,UAAU,YAAY;AACxC,MAAI,KAAK,UAAU;AACjB,YAAQ,KAAK,UAAU,eAAe,GAAG,WAAW;AAAA,EACtD;AACA,MAAI,KAAK,WAAW;AAClB,YAAQ,KAAK,WAAW,eAAe,GAAG,WAAW;AAAA,EACvD;AACA,MAAI,KAAK,mBAAmB;AAC1B,YAAQ,KAAK,mBAAmB,eAAe,GAAG,WAAW;AAAA,EAC/D;AACF;AAOA,MAAM,sBAAsB,CAAC,aAA0F;AACrH,QAAM,gBAAkE,oBAAI,IAAI;AAChF,QAAM,gBAA+C,SAAS;AAE9D,UAAQ,eAAe,aAAa;AACpC,SAAO;AACT;AAQO,MAAM,0BAA0B,CACrC,UACA,YAAyC,SACtC;AACH,QAAM,QAAQ;AAAA,SAAe,SAAS;AAAA;AAAA;AACtC,MAAI,YAAY,GAAG,kBAAkB;AAAA;AAErC,QAAM,gBAAgB,oBAAoB,QAAQ;AAClD,gBAAc,QAAQ,CAAC,MAAM,aAAa;AACxC,QAAI,aAAa;AAAK;AACtB,UAAM,eAAe,SAAS,MAAM,GAAG,EAAE;AACzC,UAAM,aAAa,cAAc,IAAI,YAAY;AACjD,QAAI,YAAY;AACd,YAAM,eAAe,uBAAuB,QAAQ;AACpD,mBAAa,IAAK,WAAW,eAAe,eAAe,KAAK;AAAA;AAAA,IAClE;AAAA,EACF,CAAC;AAED,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var react_desc_prop_types_exports = {};
30
+ __export(react_desc_prop_types_exports, {
31
+ DSDecisionGraphPropTypes: () => DSDecisionGraphPropTypes,
32
+ DSDecisionGraphPropTypesSchema: () => DSDecisionGraphPropTypesSchema,
33
+ defaultProps: () => defaultProps
34
+ });
35
+ module.exports = __toCommonJS(react_desc_prop_types_exports);
36
+ var React = __toESM(require("react"));
37
+ var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
38
+ var import_constants = require("./constants/index.js");
39
+ const defaultProps = {
40
+ direction: "LR"
41
+ };
42
+ const DSDecisionGraphPropTypes = {
43
+ ...import_ds_props_helpers.globalAttributesPropTypes,
44
+ ...import_ds_props_helpers.xstyledPropTypes,
45
+ chartJson: import_ds_props_helpers.PropTypes.object.description(
46
+ `the json representing the decision chart. must comply with the following json_schema:
47
+ ${JSON.stringify(
48
+ import_constants.JSON_SCHEMA
49
+ )}`
50
+ ).isRequired,
51
+ direction: import_ds_props_helpers.PropTypes.oneOf(["LR", "TD"]).description("direction of the flowchart, default is LR (left to right)").defaultValue("LR")
52
+ };
53
+ const DSDecisionGraphPropTypesSchema = DSDecisionGraphPropTypes;
54
+ //# sourceMappingURL=react-desc-prop-types.js.map