1.4.3 • Published 7 days ago

@gorules/jdm-editor v1.4.3

Weekly downloads
-
License
MIT
Repository
-
Last release
7 days ago

JDM Editor

JDM Editor is an open-source React component for crafting and designing JDM (JSON Decision model) files. Whether you’re a developer, data analyst, or decision model expert, JDM Editor can help you harness the full potential of decision modeling, making it more accessible and manageable than ever before

A JDM Editor Live demo and usage at https://gorules.github.io/jdm-editor/

Installation

npm i @gorules/jdm-editor

Usage

...
import '@gorules/jdm-editor/dist/style.css';
import { DecisionGraph, JdmConfigProvider } from '@gorules/jdm-editor';
...

<JdmConfigProvider>
  <DecisionGraph
    value={graph}
    onChange={(val) => setGraph(val as any)}
  />
</JdmConfigProvider>

Decision Graph

export type DecisionGraphProps = {
  id?: string;
  forwardedRef?: (instance: DecisionGraphRef) => void;
  defaultValue?: DecisionGraphType;
  value?: DecisionGraphType;
  disabled?: boolean;
  configurable?: boolean;
  components?: CustomNodeType[];
  onChange?: (val: DecisionGraphType) => void;
  manager?: DragDropManager;
  reactFlowProOptions?: ProOptions;
  defaultOpenMenu?: boolean;
  onReactFlowInit?: () => void;
  onSimulatorOpen?: (opened: boolean) => void;
  onSimulationRun?: ({ context: any, decisionGraph: DecisionGraphType }) => Promise<Trace>;
};

Decision Table

API

export type DecisionTableProps = {
  id?: string;
  defaultValue?: DecisionTableType;
  value?: DecisionTableType;
  onChange?: (decisionTable: DecisionTableType) => void;
  activeRules?: string[];
  configurable?: boolean;
  disabled?: boolean;
  disableHitPolicy?: boolean;
  minColWidth?: number;
  colWidth?: number;
  inputsSchema?: SchemaSelectProps[];
  outputsSchema?: SchemaSelectProps[];
  cellRenderer?: (props: CellProps) => JSX.Element | null | undefined;
};

Self-hosting Monaco Editor

To self-host monaco editor in Vite.

import type { Monaco } from '@monaco-editor/react';
import { loader } from '@monaco-editor/react';
import * as monaco from 'monaco-editor';
import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker';
import cssWorker from 'monaco-editor/esm/vs/language/css/css.worker?worker';
import htmlWorker from 'monaco-editor/esm/vs/language/html/html.worker?worker';
import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker';
import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker';

declare global {
  interface Window {
    monaco?: Monaco;
  }
}

self.monaco = monaco;

self.MonacoEnvironment = {
  getWorker(workerId: string, label: string): Promise<Worker> | Worker {
    if (label === 'json') {
      return new jsonWorker();
    }
    if (label === 'css' || label === 'scss' || label === 'less') {
      return new cssWorker();
    }
    if (label === 'html' || label === 'handlebars' || label === 'razor') {
      return new htmlWorker();
    }
    if (label === 'typescript' || label === 'javascript') {
      return new tsWorker();
    }

    return new editorWorker();
  },
};

loader.config({ monaco });

For webpack and other configurations, you may require some additional loaders, such as https://www.npmjs.com/package/monaco-editor-webpack-plugin.

License

MIT © GoRules

1.4.3

7 days ago

1.4.2

7 days ago

1.4.1

7 days ago

1.4.0

10 days ago

1.3.0-beta.2

14 days ago

1.3.0-beta.1

15 days ago

1.3.0-beta.0

15 days ago

1.2.1

26 days ago

1.2.0

1 month ago

1.0.4

1 month ago

1.0.3

1 month ago

1.1.0

1 month ago

1.0.2

2 months ago

1.0.1

2 months ago

1.0.0

3 months ago

1.0.0-beta.6

3 months ago

1.0.0-beta.7

3 months ago

1.0.0-beta.8

3 months ago

1.0.0-beta.4

3 months ago

1.0.0-beta.5

3 months ago

1.0.0-beta.2

3 months ago

1.0.0-beta.3

3 months ago

1.0.0-beta.1

3 months ago

0.5.1

4 months ago

0.5.0

5 months ago

0.4.1-beta.2

5 months ago

0.4.1-beta.1

5 months ago

0.1.6-beta.1

10 months ago

0.4.0-beta.0

5 months ago

0.4.0-beta.1

5 months ago

0.4.0-beta.2

5 months ago

0.4.0-beta.3

5 months ago

0.2.2-beta.2

9 months ago

0.2.0-beta.2

10 months ago

0.2.2-beta.1

9 months ago

0.2.0-beta.1

10 months ago

0.2.2-beta.15

8 months ago

0.2.2-beta.4

8 months ago

0.2.2-beta.14

8 months ago

0.2.2-beta.3

8 months ago

0.2.2-beta.6

8 months ago

0.2.2-beta.12

8 months ago

0.2.2-beta.5

8 months ago

0.2.0-beta.5

10 months ago

0.2.2-beta.11

8 months ago

0.2.2-beta.8

8 months ago

0.2.0-beta.4

10 months ago

0.2.2-beta.10

8 months ago

0.2.2-beta.7

8 months ago

0.2.0-beta.3

10 months ago

0.1.0

10 months ago

0.2.2-beta.9

8 months ago

0.3.0

8 months ago

0.1.2

10 months ago

0.2.0

9 months ago

0.1.1

10 months ago

0.1.4

10 months ago

0.4.0

5 months ago

0.3.1

8 months ago

0.1.3

10 months ago

0.1.6

10 months ago

0.1.5

10 months ago

0.0.10

11 months ago

0.0.11

11 months ago

0.0.9

11 months ago

0.0.8

11 months ago

0.0.7

12 months ago

0.0.6

12 months ago

0.0.5

12 months ago

0.0.4

12 months ago

0.0.3

12 months ago

0.0.2

12 months ago

0.0.1

12 months ago