@elliemae/ds-decision-graph 3.35.0 → 3.36.0-next.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.
- package/dist/cjs/config/useValidateProps.js.map +1 -1
- package/dist/cjs/index.js +0 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/parts/mermaid/MermaidDecisionChart.js.map +1 -1
- package/dist/cjs/parts/mermaid/decisionTreeToMermaidMD.js +1 -2
- package/dist/cjs/parts/mermaid/decisionTreeToMermaidMD.js.map +1 -1
- package/dist/cjs/react-desc-prop-types.js.map +1 -1
- package/dist/esm/config/useValidateProps.js.map +1 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/parts/mermaid/MermaidDecisionChart.js.map +1 -1
- package/dist/esm/parts/mermaid/decisionTreeToMermaidMD.js +1 -2
- package/dist/esm/parts/mermaid/decisionTreeToMermaidMD.js.map +1 -1
- package/dist/esm/react-desc-prop-types.js.map +1 -1
- package/dist/types/config/useDecisionGraph.d.ts +18 -18
- package/package.json +7 -7
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/config/useValidateProps.ts", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
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,
|
|
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,CAAC,EAAE;AAAA,IACpE;AAAA,EACF,GAAG,CAAC,MAAM,SAAS,CAAC;AACtB;",
|
|
6
6
|
"names": ["React", "Ajv"]
|
|
7
7
|
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -36,6 +36,5 @@ __export(src_exports, {
|
|
|
36
36
|
module.exports = __toCommonJS(src_exports);
|
|
37
37
|
var React = __toESM(require("react"));
|
|
38
38
|
var import_DSDecisionGraph = require("./DSDecisionGraph.js");
|
|
39
|
-
var import_react_desc_prop_types = require("./react-desc-prop-types.js");
|
|
40
39
|
var import_constants = require("./constants/index.js");
|
|
41
40
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
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;
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADGvB,6BAA2D;AAE3D,uBAAiE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/parts/mermaid/MermaidDecisionChart.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
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,
|
|
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,GAAG,IAAI,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
6
|
"names": ["React", "mermaid"]
|
|
7
7
|
}
|
|
@@ -91,8 +91,7 @@ title: ${rootNode.chartTitle}
|
|
|
91
91
|
`;
|
|
92
92
|
const decisionNodes = flattenDecisionTree(rootNode);
|
|
93
93
|
decisionNodes.forEach((node, nodePath) => {
|
|
94
|
-
if (nodePath === "s")
|
|
95
|
-
return;
|
|
94
|
+
if (nodePath === "s") return;
|
|
96
95
|
const parentNodeId = nodePath.slice(0, -1);
|
|
97
96
|
const parentNode = decisionNodes.get(parentNodeId);
|
|
98
97
|
if (parentNode) {
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/parts/mermaid/decisionTreeToMermaidMD.ts", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
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,
|
|
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,QAAQ,MAAM,KAAK,QAAQ;AAAA,EACnE,OAAO;AACL,mBAAe,GAAG,MAAM,cAAc,QAAQ,KAAK,KAAK,QAAQ;AAAA,EAClE;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,QAAQ,GAAG;AAAA,EACtD;AACA,MAAI,KAAK,WAAW;AAClB,YAAQ,KAAK,WAAW,eAAe,GAAG,QAAQ,GAAG;AAAA,EACvD;AACA,MAAI,KAAK,mBAAmB;AAC1B,YAAQ,KAAK,mBAAmB,eAAe,GAAG,QAAQ,GAAG;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,UAAU;AAAA;AAAA;AAChD,MAAI,YAAY,GAAG,KAAK,aAAa,SAAS;AAAA;AAE9C,QAAM,gBAAgB,oBAAoB,QAAQ;AAClD,gBAAc,QAAQ,CAAC,MAAM,aAAa;AACxC,QAAI,aAAa,IAAK;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,YAAY,GAAG,YAAY,GAAG,KAAK,YAAY;AAAA;AAAA,IAC9E;AAAA,EACF,CAAC;AAED,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/react-desc-prop-types.ts", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-redundant-type-constituents */\n/* eslint-disable @typescript-eslint/no-empty-interface */\nimport type { GlobalAttributesT, XstyledProps, DSPropTypesSchema } from '@elliemae/ds-props-helpers';\nimport { PropTypes, globalAttributesPropTypes, xstyledPropTypes } from '@elliemae/ds-props-helpers';\nimport type { WeakValidationMap } from 'react';\nimport { JSON_SCHEMA } from './constants/index.js';\n\nexport declare namespace DSDecisionGraphT {\n export type Directions = 'LR' | 'TD'; // left to right | top down\n export type SemanticMeaning = 'question' | 'conclusion';\n export type NodePath = `${string}${'t' | 'f' | 'o' | 's'}`; // Node ID for a decision node, doubles as the path to the node | T true | F false | O (other) not applicable | S start\n export type ConclusionMarkdown = `${string | NodePath}(${string})`; // Mermaid Markdown for a conclusion node | A node with round edges\n export type QuestionMarkdown = `${string | NodePath}{{${string}}}`; // Mermaid Markdown for a question node | A hexagon node\n export type NodeMarkdown = ConclusionMarkdown | QuestionMarkdown;\n export type TrueLinkMarkdown = `-->|true|`; // Mermaid Markdown for a true path link\n export type FalseLinkMarkdown = `-->|false|`; // Mermaid Markdown for a false path link\n export type NALinkMarkdown = `-->|N/A|`; // Mermaid Markdown for a not applicable path link\n export type LinkMarkdown = TrueLinkMarkdown | FalseLinkMarkdown | NALinkMarkdown | '';\n\n /**\n * Node polymorphism for the \"meaning\" the node has in the decision tree.\n * this influence the node shape in the decision chart.\n */\n // common properties for all nodes\n export interface BaseNode {\n nodeText: string; // Text representing a conclusion or question\n truePath?: DecisionNode; // Decision node for the true path\n falsePath?: DecisionNode; // Decision node for the false path\n notApplicablePath?: DecisionNode; // Decision node for the not applicable path\n repeatedId?: string; // Id of the node if it is repeated in the decision tree and we want to show it only once in the decision chart\n }\n // polymorphism for node with the semantic meaning of \"question\"\n export interface QuestionNode extends BaseNode {\n semanticMeaning: 'question';\n }\n // polymorphism for node with the semantic meaning of \"conclusion\"\n export interface ConclusionNode extends BaseNode {\n semanticMeaning: 'conclusion';\n }\n // polymorphism for all nodes\n export type DecisionNode = QuestionNode | ConclusionNode;\n /**\n * yes, polymorphism in typescript is this verbose and this hard to handle correctly.\n */\n\n export type RootNode = {\n chartTitle: string; // Title of the decision chart\n subtree: DecisionNode; // The root of the decision tree\n };\n\n export interface RequiredProps {\n chartJson: RootNode;\n }\n\n export interface DefaultProps {\n direction: Directions;\n }\n\n export interface OptionalProps {}\n\n export interface Props\n extends Partial<DefaultProps>,\n OptionalProps,\n Omit<GlobalAttributesT<HTMLButtonElement>, keyof DefaultProps | keyof RequiredProps | keyof XstyledProps>,\n XstyledProps,\n RequiredProps {}\n\n export interface InternalProps\n extends DefaultProps,\n OptionalProps,\n Omit<GlobalAttributesT<HTMLButtonElement>, keyof DefaultProps | keyof RequiredProps | keyof XstyledProps>,\n XstyledProps,\n RequiredProps {}\n}\n\nexport const defaultProps: DSDecisionGraphT.DefaultProps = {\n direction: 'LR',\n};\n\nexport const DSDecisionGraphPropTypes: DSPropTypesSchema<DSDecisionGraphT.Props> = {\n ...globalAttributesPropTypes,\n ...xstyledPropTypes,\n chartJson: PropTypes.object.description(\n `the json representing the decision chart. must comply with the following json_schema:\\n${JSON.stringify(\n JSON_SCHEMA,\n )}`,\n ).isRequired,\n direction: PropTypes.oneOf(['LR', 'TD'])\n .description('direction of the flowchart, default is LR (left to right)')\n .defaultValue('LR'),\n};\n\nexport const DSDecisionGraphPropTypesSchema =\n DSDecisionGraphPropTypes as unknown as WeakValidationMap<DSDecisionGraphT.Props>;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADGvB,8BAAuE;AAEvE,uBAA4B;AAsErB,MAAM,eAA8C;AAAA,EACzD,WAAW;AACb;AAEO,MAAM,2BAAsE;AAAA,EACjF,GAAG;AAAA,EACH,GAAG;AAAA,EACH,WAAW,kCAAU,OAAO;AAAA,IAC1B;AAAA,EAA0F,KAAK;AAAA,MAC7F;AAAA,IACF;AAAA,
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADGvB,8BAAuE;AAEvE,uBAA4B;AAsErB,MAAM,eAA8C;AAAA,EACzD,WAAW;AACb;AAEO,MAAM,2BAAsE;AAAA,EACjF,GAAG;AAAA,EACH,GAAG;AAAA,EACH,WAAW,kCAAU,OAAO;AAAA,IAC1B;AAAA,EAA0F,KAAK;AAAA,MAC7F;AAAA,IACF,CAAC;AAAA,EACH,EAAE;AAAA,EACF,WAAW,kCAAU,MAAM,CAAC,MAAM,IAAI,CAAC,EACpC,YAAY,2DAA2D,EACvE,aAAa,IAAI;AACtB;AAEO,MAAM,iCACX;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/config/useValidateProps.ts"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB,OAAOA,YAAW;AAElB,SAAS,sCAAsC;AAE/C,SAAS,qBAAqB,mBAAmB;AACjD,OAAO,SAAS;AAET,MAAM,mBAAmB,CAC9B,OACA,cACS;AAET,iCAA+B,OAAO,WAAW,mBAAmB;AACpE,EAAAA,OAAM,UAAU,MAAM;AACpB,UAAM,MAAM,IAAI,IAAI;AACpB,UAAM,WAAW,IAAI,QAAQ,WAAW;AACxC,UAAM,QAAQ,SAAS,MAAM,SAAS;AACtC,QAAI,CAAC,OAAO;AACV,YAAM,IAAI,MAAM,iBAAiB,KAAK,UAAU,SAAS,MAAM,
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,OAAOA,YAAW;AAElB,SAAS,sCAAsC;AAE/C,SAAS,qBAAqB,mBAAmB;AACjD,OAAO,SAAS;AAET,MAAM,mBAAmB,CAC9B,OACA,cACS;AAET,iCAA+B,OAAO,WAAW,mBAAmB;AACpE,EAAAA,OAAM,UAAU,MAAM;AACpB,UAAM,MAAM,IAAI,IAAI;AACpB,UAAM,WAAW,IAAI,QAAQ,WAAW;AACxC,UAAM,QAAQ,SAAS,MAAM,SAAS;AACtC,QAAI,CAAC,OAAO;AACV,YAAM,IAAI,MAAM,iBAAiB,KAAK,UAAU,SAAS,MAAM,CAAC,EAAE;AAAA,IACpE;AAAA,EACF,GAAG,CAAC,MAAM,SAAS,CAAC;AACtB;",
|
|
6
6
|
"names": ["React"]
|
|
7
7
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { DSDecisionGraph, DSDecisionGraphWithSchema } from "./DSDecisionGraph.js";
|
|
3
|
-
import {} from "./react-desc-prop-types.js";
|
|
4
3
|
import { DECISION_GRAPH_SLOTS, DECISION_GRAPH_DATA_TESTID } from "./constants/index.js";
|
|
5
4
|
export {
|
|
6
5
|
DECISION_GRAPH_DATA_TESTID,
|
package/dist/esm/index.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/index.ts"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "// 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"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACGvB,SAAS,iBAAiB,iCAAiC;
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACGvB,SAAS,iBAAiB,iCAAiC;AAE3D,SAAS,sBAAsB,kCAAkC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/mermaid/MermaidDecisionChart.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACsCd;AAtCT,OAAOA,YAAW;AAElB,SAAS,+BAA+B;AAExC,OAAO,aAAa;AAQb,MAAM,uBAAuB,CAAC,UAAwB;AAC3D,QAAM,EAAE,WAAW,KAAK,UAAU,IAAI;AACtC,QAAM,aAAaA,OAAM,OAAuB,IAAI;AAGpD,QAAM,YAAYA,OAAM,QAAQ,MAAM,wBAAwB,WAAW,SAAS,GAAG,CAAC,WAAW,SAAS,CAAC;AAG3G,EAAAA,OAAM,UAAU,MAAM;AACpB,YAAQ,WAAW;AAAA,MACjB,aAAa;AAAA,IACf,CAAC;AAAA,EACH,GAAG,CAAC,CAAC;AAEL,EAAAA,OAAM,UAAU,MAAM;AACpB,eAAW,MAAM;AACf,YAAM,cAAc,YAAY;AAC9B,cAAM,EAAE,IAAI,IAAI,MAAM,QAAQ,OAAO,eAAe,
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACsCd;AAtCT,OAAOA,YAAW;AAElB,SAAS,+BAA+B;AAExC,OAAO,aAAa;AAQb,MAAM,uBAAuB,CAAC,UAAwB;AAC3D,QAAM,EAAE,WAAW,KAAK,UAAU,IAAI;AACtC,QAAM,aAAaA,OAAM,OAAuB,IAAI;AAGpD,QAAM,YAAYA,OAAM,QAAQ,MAAM,wBAAwB,WAAW,SAAS,GAAG,CAAC,WAAW,SAAS,CAAC;AAG3G,EAAAA,OAAM,UAAU,MAAM;AACpB,YAAQ,WAAW;AAAA,MACjB,aAAa;AAAA,IACf,CAAC;AAAA,EACH,GAAG,CAAC,CAAC;AAEL,EAAAA,OAAM,UAAU,MAAM;AACpB,eAAW,MAAM;AACf,YAAM,cAAc,YAAY;AAC9B,cAAM,EAAE,IAAI,IAAI,MAAM,QAAQ,OAAO,eAAe,GAAG,IAAI,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,oBAAC,SAAI,KAAK,YAAY;AAC/B;",
|
|
6
6
|
"names": ["React"]
|
|
7
7
|
}
|
|
@@ -58,8 +58,7 @@ title: ${rootNode.chartTitle}
|
|
|
58
58
|
`;
|
|
59
59
|
const decisionNodes = flattenDecisionTree(rootNode);
|
|
60
60
|
decisionNodes.forEach((node, nodePath) => {
|
|
61
|
-
if (nodePath === "s")
|
|
62
|
-
return;
|
|
61
|
+
if (nodePath === "s") return;
|
|
63
62
|
const parentNodeId = nodePath.slice(0, -1);
|
|
64
63
|
const parentNode = decisionNodes.get(parentNodeId);
|
|
65
64
|
if (parentNode) {
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/mermaid/decisionTreeToMermaidMD.ts"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACWvB,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,
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACWvB,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,QAAQ,MAAM,KAAK,QAAQ;AAAA,EACnE,OAAO;AACL,mBAAe,GAAG,MAAM,cAAc,QAAQ,KAAK,KAAK,QAAQ;AAAA,EAClE;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,QAAQ,GAAG;AAAA,EACtD;AACA,MAAI,KAAK,WAAW;AAClB,YAAQ,KAAK,WAAW,eAAe,GAAG,QAAQ,GAAG;AAAA,EACvD;AACA,MAAI,KAAK,mBAAmB;AAC1B,YAAQ,KAAK,mBAAmB,eAAe,GAAG,QAAQ,GAAG;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,UAAU;AAAA;AAAA;AAChD,MAAI,YAAY,GAAG,KAAK,aAAa,SAAS;AAAA;AAE9C,QAAM,gBAAgB,oBAAoB,QAAQ;AAClD,gBAAc,QAAQ,CAAC,MAAM,aAAa;AACxC,QAAI,aAAa,IAAK;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,YAAY,GAAG,YAAY,GAAG,KAAK,YAAY;AAAA;AAAA,IAC9E;AAAA,EACF,CAAC;AAED,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/react-desc-prop-types.ts"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-redundant-type-constituents */\n/* eslint-disable @typescript-eslint/no-empty-interface */\nimport type { GlobalAttributesT, XstyledProps, DSPropTypesSchema } from '@elliemae/ds-props-helpers';\nimport { PropTypes, globalAttributesPropTypes, xstyledPropTypes } from '@elliemae/ds-props-helpers';\nimport type { WeakValidationMap } from 'react';\nimport { JSON_SCHEMA } from './constants/index.js';\n\nexport declare namespace DSDecisionGraphT {\n export type Directions = 'LR' | 'TD'; // left to right | top down\n export type SemanticMeaning = 'question' | 'conclusion';\n export type NodePath = `${string}${'t' | 'f' | 'o' | 's'}`; // Node ID for a decision node, doubles as the path to the node | T true | F false | O (other) not applicable | S start\n export type ConclusionMarkdown = `${string | NodePath}(${string})`; // Mermaid Markdown for a conclusion node | A node with round edges\n export type QuestionMarkdown = `${string | NodePath}{{${string}}}`; // Mermaid Markdown for a question node | A hexagon node\n export type NodeMarkdown = ConclusionMarkdown | QuestionMarkdown;\n export type TrueLinkMarkdown = `-->|true|`; // Mermaid Markdown for a true path link\n export type FalseLinkMarkdown = `-->|false|`; // Mermaid Markdown for a false path link\n export type NALinkMarkdown = `-->|N/A|`; // Mermaid Markdown for a not applicable path link\n export type LinkMarkdown = TrueLinkMarkdown | FalseLinkMarkdown | NALinkMarkdown | '';\n\n /**\n * Node polymorphism for the \"meaning\" the node has in the decision tree.\n * this influence the node shape in the decision chart.\n */\n // common properties for all nodes\n export interface BaseNode {\n nodeText: string; // Text representing a conclusion or question\n truePath?: DecisionNode; // Decision node for the true path\n falsePath?: DecisionNode; // Decision node for the false path\n notApplicablePath?: DecisionNode; // Decision node for the not applicable path\n repeatedId?: string; // Id of the node if it is repeated in the decision tree and we want to show it only once in the decision chart\n }\n // polymorphism for node with the semantic meaning of \"question\"\n export interface QuestionNode extends BaseNode {\n semanticMeaning: 'question';\n }\n // polymorphism for node with the semantic meaning of \"conclusion\"\n export interface ConclusionNode extends BaseNode {\n semanticMeaning: 'conclusion';\n }\n // polymorphism for all nodes\n export type DecisionNode = QuestionNode | ConclusionNode;\n /**\n * yes, polymorphism in typescript is this verbose and this hard to handle correctly.\n */\n\n export type RootNode = {\n chartTitle: string; // Title of the decision chart\n subtree: DecisionNode; // The root of the decision tree\n };\n\n export interface RequiredProps {\n chartJson: RootNode;\n }\n\n export interface DefaultProps {\n direction: Directions;\n }\n\n export interface OptionalProps {}\n\n export interface Props\n extends Partial<DefaultProps>,\n OptionalProps,\n Omit<GlobalAttributesT<HTMLButtonElement>, keyof DefaultProps | keyof RequiredProps | keyof XstyledProps>,\n XstyledProps,\n RequiredProps {}\n\n export interface InternalProps\n extends DefaultProps,\n OptionalProps,\n Omit<GlobalAttributesT<HTMLButtonElement>, keyof DefaultProps | keyof RequiredProps | keyof XstyledProps>,\n XstyledProps,\n RequiredProps {}\n}\n\nexport const defaultProps: DSDecisionGraphT.DefaultProps = {\n direction: 'LR',\n};\n\nexport const DSDecisionGraphPropTypes: DSPropTypesSchema<DSDecisionGraphT.Props> = {\n ...globalAttributesPropTypes,\n ...xstyledPropTypes,\n chartJson: PropTypes.object.description(\n `the json representing the decision chart. must comply with the following json_schema:\\n${JSON.stringify(\n JSON_SCHEMA,\n )}`,\n ).isRequired,\n direction: PropTypes.oneOf(['LR', 'TD'])\n .description('direction of the flowchart, default is LR (left to right)')\n .defaultValue('LR'),\n};\n\nexport const DSDecisionGraphPropTypesSchema =\n DSDecisionGraphPropTypes as unknown as WeakValidationMap<DSDecisionGraphT.Props>;\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACGvB,SAAS,WAAW,2BAA2B,wBAAwB;AAEvE,SAAS,mBAAmB;AAsErB,MAAM,eAA8C;AAAA,EACzD,WAAW;AACb;AAEO,MAAM,2BAAsE;AAAA,EACjF,GAAG;AAAA,EACH,GAAG;AAAA,EACH,WAAW,UAAU,OAAO;AAAA,IAC1B;AAAA,EAA0F,KAAK;AAAA,MAC7F;AAAA,IACF;AAAA,
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACGvB,SAAS,WAAW,2BAA2B,wBAAwB;AAEvE,SAAS,mBAAmB;AAsErB,MAAM,eAA8C;AAAA,EACzD,WAAW;AACb;AAEO,MAAM,2BAAsE;AAAA,EACjF,GAAG;AAAA,EACH,GAAG;AAAA,EACH,WAAW,UAAU,OAAO;AAAA,IAC1B;AAAA,EAA0F,KAAK;AAAA,MAC7F;AAAA,IACF,CAAC;AAAA,EACH,EAAE;AAAA,EACF,WAAW,UAAU,MAAM,CAAC,MAAM,IAAI,CAAC,EACpC,YAAY,2DAA2D,EACvE,aAAa,IAAI;AACtB;AAEO,MAAM,iCACX;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -11,13 +11,14 @@ export interface DecisionGraphCTX {
|
|
|
11
11
|
export declare const useDecisionGraph: (propsFromUser: DSDecisionGraphT.Props) => {
|
|
12
12
|
propsWithDefault: DSDecisionGraphT.InternalProps;
|
|
13
13
|
globalProps: Partial<Pick<DSGridT.Props, "form" | "list" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-braillelabel" | "aria-brailleroledescription" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colindextext" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-description" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowindextext" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onResize" | "onResizeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerLeave" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "autoFocus" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "nonce" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "content" | "datatype" | "inlist" | "prefix" | "property" | "rel" | "resource" | "rev" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "accept" | "acceptCharset" | "action" | "allowFullScreen" | "allowTransparency" | "alt" | "async" | "autoComplete" | "autoPlay" | "capture" | "cellPadding" | "cellSpacing" | "charSet" | "challenge" | "checked" | "cite" | "classID" | "cols" | "colSpan" | "controls" | "coords" | "crossOrigin" | "data" | "dateTime" | "default" | "defer" | "disabled" | "download" | "encType" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "frameBorder" | "headers" | "height" | "high" | "href" | "hrefLang" | "htmlFor" | "httpEquiv" | "integrity" | "keyParams" | "keyType" | "kind" | "label" | "loop" | "low" | "manifest" | "marginHeight" | "marginWidth" | "max" | "maxLength" | "media" | "mediaGroup" | "method" | "min" | "minLength" | "multiple" | "muted" | "name" | "noValidate" | "open" | "optimum" | "pattern" | "placeholder" | "playsInline" | "poster" | "preload" | "readOnly" | "required" | "reversed" | "rows" | "rowSpan" | "sandbox" | "scope" | "scoped" | "scrolling" | "seamless" | "selected" | "shape" | "size" | "sizes" | "span" | "src" | "srcDoc" | "srcLang" | "srcSet" | "start" | "step" | "summary" | "target" | "type" | "useMap" | "value" | "width" | "wmode" | "wrap"> & Omit<{
|
|
14
|
-
|
|
14
|
+
form?: string | undefined;
|
|
15
|
+
list?: string | undefined;
|
|
15
16
|
"aria-activedescendant"?: string | undefined;
|
|
16
|
-
"aria-atomic"?: boolean | "true" | "false" | undefined;
|
|
17
|
+
"aria-atomic"?: (boolean | "true" | "false") | undefined;
|
|
17
18
|
"aria-autocomplete"?: "list" | "none" | "inline" | "both" | undefined;
|
|
18
19
|
"aria-braillelabel"?: string | undefined;
|
|
19
20
|
"aria-brailleroledescription"?: string | undefined;
|
|
20
|
-
"aria-busy"?: boolean | "true" | "false" | undefined;
|
|
21
|
+
"aria-busy"?: (boolean | "true" | "false") | undefined;
|
|
21
22
|
"aria-checked"?: boolean | "true" | "false" | "mixed" | undefined;
|
|
22
23
|
"aria-colcount"?: number | undefined;
|
|
23
24
|
"aria-colindex"?: number | undefined;
|
|
@@ -28,37 +29,37 @@ export declare const useDecisionGraph: (propsFromUser: DSDecisionGraphT.Props) =
|
|
|
28
29
|
"aria-describedby"?: string | undefined;
|
|
29
30
|
"aria-description"?: string | undefined;
|
|
30
31
|
"aria-details"?: string | undefined;
|
|
31
|
-
"aria-disabled"?: boolean | "true" | "false" | undefined;
|
|
32
|
+
"aria-disabled"?: (boolean | "true" | "false") | undefined;
|
|
32
33
|
"aria-dropeffect"?: "link" | "none" | "copy" | "execute" | "move" | "popup" | undefined;
|
|
33
34
|
"aria-errormessage"?: string | undefined;
|
|
34
|
-
"aria-expanded"?: boolean | "true" | "false" | undefined;
|
|
35
|
+
"aria-expanded"?: (boolean | "true" | "false") | undefined;
|
|
35
36
|
"aria-flowto"?: string | undefined;
|
|
36
|
-
"aria-grabbed"?: boolean | "true" | "false" | undefined;
|
|
37
|
+
"aria-grabbed"?: (boolean | "true" | "false") | undefined;
|
|
37
38
|
"aria-haspopup"?: boolean | "true" | "false" | "dialog" | "grid" | "listbox" | "menu" | "tree" | undefined;
|
|
38
|
-
"aria-hidden"?: boolean | "true" | "false" | undefined;
|
|
39
|
+
"aria-hidden"?: (boolean | "true" | "false") | undefined;
|
|
39
40
|
"aria-invalid"?: boolean | "true" | "false" | "grammar" | "spelling" | undefined;
|
|
40
41
|
"aria-keyshortcuts"?: string | undefined;
|
|
41
42
|
"aria-label"?: string | undefined;
|
|
42
43
|
"aria-labelledby"?: string | undefined;
|
|
43
44
|
"aria-level"?: number | undefined;
|
|
44
45
|
"aria-live"?: "off" | "assertive" | "polite" | undefined;
|
|
45
|
-
"aria-modal"?: boolean | "true" | "false" | undefined;
|
|
46
|
-
"aria-multiline"?: boolean | "true" | "false" | undefined;
|
|
47
|
-
"aria-multiselectable"?: boolean | "true" | "false" | undefined;
|
|
46
|
+
"aria-modal"?: (boolean | "true" | "false") | undefined;
|
|
47
|
+
"aria-multiline"?: (boolean | "true" | "false") | undefined;
|
|
48
|
+
"aria-multiselectable"?: (boolean | "true" | "false") | undefined;
|
|
48
49
|
"aria-orientation"?: "horizontal" | "vertical" | undefined;
|
|
49
50
|
"aria-owns"?: string | undefined;
|
|
50
51
|
"aria-placeholder"?: string | undefined;
|
|
51
52
|
"aria-posinset"?: number | undefined;
|
|
52
53
|
"aria-pressed"?: boolean | "true" | "false" | "mixed" | undefined;
|
|
53
|
-
"aria-readonly"?: boolean | "true" | "false" | undefined;
|
|
54
|
+
"aria-readonly"?: (boolean | "true" | "false") | undefined;
|
|
54
55
|
"aria-relevant"?: "text" | "additions" | "additions removals" | "additions text" | "all" | "removals" | "removals additions" | "removals text" | "text additions" | "text removals" | undefined;
|
|
55
|
-
"aria-required"?: boolean | "true" | "false" | undefined;
|
|
56
|
+
"aria-required"?: (boolean | "true" | "false") | undefined;
|
|
56
57
|
"aria-roledescription"?: string | undefined;
|
|
57
58
|
"aria-rowcount"?: number | undefined;
|
|
58
59
|
"aria-rowindex"?: number | undefined;
|
|
59
60
|
"aria-rowindextext"?: string | undefined;
|
|
60
61
|
"aria-rowspan"?: number | undefined;
|
|
61
|
-
"aria-selected"?: boolean | "true" | "false" | undefined;
|
|
62
|
+
"aria-selected"?: (boolean | "true" | "false") | undefined;
|
|
62
63
|
"aria-setsize"?: number | undefined;
|
|
63
64
|
"aria-sort"?: "none" | "ascending" | "descending" | "other" | undefined;
|
|
64
65
|
"aria-valuemax"?: number | undefined;
|
|
@@ -226,8 +227,6 @@ export declare const useDecisionGraph: (propsFromUser: DSDecisionGraphT.Props) =
|
|
|
226
227
|
onAnimationIterationCapture?: React.AnimationEventHandler<HTMLDivElement> | undefined;
|
|
227
228
|
onTransitionEnd?: React.TransitionEventHandler<HTMLDivElement> | undefined;
|
|
228
229
|
onTransitionEndCapture?: React.TransitionEventHandler<HTMLDivElement> | undefined;
|
|
229
|
-
form?: string | undefined;
|
|
230
|
-
list?: string | undefined;
|
|
231
230
|
defaultChecked?: boolean | undefined;
|
|
232
231
|
defaultValue?: string | number | readonly string[] | undefined;
|
|
233
232
|
suppressContentEditableWarning?: boolean | undefined;
|
|
@@ -235,16 +234,16 @@ export declare const useDecisionGraph: (propsFromUser: DSDecisionGraphT.Props) =
|
|
|
235
234
|
accessKey?: string | undefined;
|
|
236
235
|
autoFocus?: boolean | undefined;
|
|
237
236
|
className?: string | undefined;
|
|
238
|
-
contentEditable?: boolean | "true" | "false" | "inherit" | "plaintext-only" | undefined;
|
|
237
|
+
contentEditable?: (boolean | "true" | "false") | "inherit" | "plaintext-only" | undefined;
|
|
239
238
|
contextMenu?: string | undefined;
|
|
240
239
|
dir?: string | undefined;
|
|
241
|
-
draggable?: boolean | "true" | "false" | undefined;
|
|
240
|
+
draggable?: (boolean | "true" | "false") | undefined;
|
|
242
241
|
hidden?: boolean | undefined;
|
|
243
242
|
id?: string | undefined;
|
|
244
243
|
lang?: string | undefined;
|
|
245
244
|
nonce?: string | undefined;
|
|
246
245
|
slot?: string | undefined;
|
|
247
|
-
spellCheck?: boolean | "true" | "false" | undefined;
|
|
246
|
+
spellCheck?: (boolean | "true" | "false") | undefined;
|
|
248
247
|
style?: React.CSSProperties | undefined;
|
|
249
248
|
tabIndex?: 0 | -1 | undefined;
|
|
250
249
|
title?: string | undefined;
|
|
@@ -337,6 +336,7 @@ export declare const useDecisionGraph: (propsFromUser: DSDecisionGraphT.Props) =
|
|
|
337
336
|
minLength?: number | undefined;
|
|
338
337
|
multiple?: boolean | undefined;
|
|
339
338
|
muted?: boolean | undefined;
|
|
339
|
+
name?: string | undefined;
|
|
340
340
|
noValidate?: boolean | undefined;
|
|
341
341
|
open?: boolean | undefined;
|
|
342
342
|
optimum?: number | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-decision-graph",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.36.0-next.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Decision Graph",
|
|
6
6
|
"files": [
|
|
@@ -40,18 +40,18 @@
|
|
|
40
40
|
"ajv": "^8.12.0",
|
|
41
41
|
"mermaid": "^10.9.0",
|
|
42
42
|
"uid": "~2.0.1",
|
|
43
|
-
"@elliemae/ds-button": "3.
|
|
44
|
-
"@elliemae/ds-
|
|
45
|
-
"@elliemae/ds-system": "3.
|
|
46
|
-
"@elliemae/ds-utilities": "3.
|
|
47
|
-
"@elliemae/ds-
|
|
43
|
+
"@elliemae/ds-button": "3.36.0-next.1",
|
|
44
|
+
"@elliemae/ds-grid": "3.36.0-next.1",
|
|
45
|
+
"@elliemae/ds-system": "3.36.0-next.1",
|
|
46
|
+
"@elliemae/ds-utilities": "3.36.0-next.1",
|
|
47
|
+
"@elliemae/ds-props-helpers": "3.36.0-next.1"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@elliemae/pui-cli": "~9.0.0-next.31",
|
|
51
51
|
"@xstyled/system": "3.7.0",
|
|
52
52
|
"lodash": "^4.17.21",
|
|
53
53
|
"styled-components": "~5.3.9",
|
|
54
|
-
"@elliemae/ds-monorepo-devops": "3.
|
|
54
|
+
"@elliemae/ds-monorepo-devops": "3.36.0-next.1"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"lodash": "^4.17.21",
|