@bpmn-io/form-js-playground 0.10.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -16,6 +16,9 @@ var view = require('@codemirror/view');
16
16
  var state = require('@codemirror/state');
17
17
  var lint = require('@codemirror/lint');
18
18
  var langJson = require('@codemirror/lang-json');
19
+ var commands = require('@codemirror/commands');
20
+ var autocomplete = require('@codemirror/autocomplete');
21
+ var language = require('@codemirror/language');
19
22
 
20
23
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
21
24
 
@@ -118,18 +121,56 @@ function serializeValue(obj) {
118
121
  return JSON.stringify(JSON.stringify(obj)).replace(/</g, '&lt;').replace(/>/g, '&gt;');
119
122
  }
120
123
 
124
+ /**
125
+ * @type {Facet<import('..').Variables>} Variables
126
+ */
127
+ const variablesFacet = state.Facet.define();
128
+
129
+ function autocompletion () {
130
+ return [autocomplete.autocompletion({
131
+ override: [completions]
132
+ })];
133
+ }
134
+ function completions(context) {
135
+ const variables = context.state.facet(variablesFacet)[0];
136
+ const options = variables.map(v => ({
137
+ label: v,
138
+ type: 'variable'
139
+ }));
140
+ let nodeBefore = language.syntaxTree(context.state).resolve(context.pos, -1);
141
+
142
+ // handle inside property name as explicit call
143
+ if (nodeBefore.type.name === 'PropertyName') {
144
+ context.explicit = true;
145
+ }
146
+ let word = context.matchBefore(/\w*/);
147
+ if (word.from == word.to && !context.explicit) {
148
+ return null;
149
+ }
150
+ return {
151
+ from: word.from,
152
+ options
153
+ };
154
+ }
155
+
121
156
  function JSONEditor(options = {}) {
122
- const emitter = mitt__default['default']();
123
157
  const {
124
158
  readonly = false
125
159
  } = options;
160
+ const emitter = mitt__default['default']();
126
161
  let language = new state.Compartment().of(langJson.json());
127
162
  let tabSize = new state.Compartment().of(state.EditorState.tabSize.of(2));
163
+
164
+ /**
165
+ * @typedef {Array<string>} Variables
166
+ */
167
+
168
+ const autocompletionConf = new state.Compartment();
128
169
  const linterExtension = lint.linter(langJson.jsonParseLinter());
129
- function createState(doc, extensions = []) {
170
+ function createState(doc, extensions = [], variables = []) {
130
171
  return state.EditorState.create({
131
172
  doc,
132
- extensions: [codemirror.basicSetup, language, tabSize, linterExtension, lint.lintGutter(), ...extensions]
173
+ extensions: [codemirror.basicSetup, language, tabSize, linterExtension, lint.lintGutter(), autocompletionConf.of(variablesFacet.of(variables)), autocompletion(), view.keymap.of([commands.indentWithTab]), ...extensions]
133
174
  });
134
175
  }
135
176
  function createView(readonly) {
@@ -147,15 +188,25 @@ function JSONEditor(options = {}) {
147
188
  view$1.setValue = function (value) {
148
189
  this.setState(createState(value, [updateListener, editable]));
149
190
  };
191
+ view$1.setVariables = function (variables) {
192
+ this.setState(createState(view$1.state.doc.toString(), [updateListener, editable], variables));
193
+ };
150
194
  return view$1;
151
195
  }
152
- const view$1 = createView(readonly);
196
+ const view$1 = this._view = createView(readonly);
153
197
  this.setValue = function (value) {
154
198
  view$1.setValue(value);
155
199
  };
156
200
  this.getValue = function () {
157
201
  return view$1.state.doc.toString();
158
202
  };
203
+
204
+ /**
205
+ * @param {Variables} variables
206
+ */
207
+ this.setVariables = function (variables) {
208
+ view$1.setVariables(variables);
209
+ };
159
210
  this.on = emitter.on;
160
211
  this.off = emitter.off;
161
212
  this.emit = emitter.emit;
@@ -204,16 +255,12 @@ Section.HeaderItem = function (props) {
204
255
  function PlaygroundRoot(props) {
205
256
  const {
206
257
  actions: actionsConfig = {},
207
- editor: editorConfig = {},
208
258
  emit,
209
259
  exporter: exporterConfig = {}
210
260
  } = props;
211
261
  const {
212
262
  display: displayActions = true
213
263
  } = actionsConfig;
214
- const {
215
- inlinePropertiesPanel = true
216
- } = editorConfig;
217
264
  const paletteContainerRef = hooks.useRef();
218
265
  const editorContainerRef = hooks.useRef();
219
266
  const formContainerRef = hooks.useRef();
@@ -257,11 +304,11 @@ function PlaygroundRoot(props) {
257
304
  }, [props.schema]);
258
305
  hooks.useEffect(() => {
259
306
  const dataEditor = dataEditorRef.current = new JSONEditor({
260
- value: toJSON(data)
307
+ value: toString(data)
261
308
  });
262
309
  const resultView = resultViewRef.current = new JSONEditor({
263
310
  readonly: true,
264
- value: toJSON(resultData)
311
+ value: toString(resultData)
265
312
  });
266
313
  const form = formRef.current = new formJsViewer.Form();
267
314
  const formEditor = formEditorRef.current = new formJsEditor.FormEditor({
@@ -272,7 +319,7 @@ function PlaygroundRoot(props) {
272
319
  parent: paletteContainerRef.current
273
320
  },
274
321
  propertiesPanel: {
275
- parent: !inlinePropertiesPanel && propertiesPanelContainerRef.current
322
+ parent: propertiesPanelContainerRef.current
276
323
  },
277
324
  exporter: exporterConfig
278
325
  });
@@ -312,16 +359,25 @@ function PlaygroundRoot(props) {
312
359
  };
313
360
  }, []);
314
361
  hooks.useEffect(() => {
315
- dataEditorRef.current.setValue(toJSON(initialData));
362
+ dataEditorRef.current.setValue(toString(initialData));
316
363
  }, [initialData]);
317
364
  hooks.useEffect(() => {
318
- initialSchema && formEditorRef.current.importSchema(initialSchema);
365
+ if (initialSchema) {
366
+ formEditorRef.current.importSchema(initialSchema);
367
+ dataEditorRef.current.setVariables(formJsViewer.getSchemaVariables(initialSchema));
368
+ }
319
369
  }, [initialSchema]);
370
+ hooks.useEffect(() => {
371
+ if (schema && dataContainerRef.current) {
372
+ const variables = formJsViewer.getSchemaVariables(schema);
373
+ dataEditorRef.current.setVariables(variables);
374
+ }
375
+ }, [schema]);
320
376
  hooks.useEffect(() => {
321
377
  schema && formRef.current.importSchema(schema, data);
322
378
  }, [schema, data]);
323
379
  hooks.useEffect(() => {
324
- resultViewRef.current.setValue(toJSON(resultData));
380
+ resultViewRef.current.setValue(toString(resultData));
325
381
  }, [resultData]);
326
382
  hooks.useEffect(() => {
327
383
  props.onStateChanged({
@@ -339,9 +395,7 @@ function PlaygroundRoot(props) {
339
395
  setShowEmbed(true);
340
396
  }, []);
341
397
  return jsxRuntime.jsxs("div", {
342
- class: classNames__default['default']('fjs-container', 'fjs-pgl-root', {
343
- 'fjs-pgl-inline-editor-panel': inlinePropertiesPanel
344
- }),
398
+ class: classNames__default['default']('fjs-container', 'fjs-pgl-root'),
345
399
  children: [jsxRuntime.jsx("div", {
346
400
  class: "fjs-pgl-modals",
347
401
  children: showEmbed ? jsxRuntime.jsx(EmbedModal, {
@@ -380,13 +434,13 @@ function PlaygroundRoot(props) {
380
434
  class: "fjs-pgl-form-container"
381
435
  })
382
436
  }), jsxRuntime.jsx(Section, {
383
- name: "Form Data (Input)",
437
+ name: "Form Input",
384
438
  children: jsxRuntime.jsx("div", {
385
439
  ref: dataContainerRef,
386
440
  class: "fjs-pgl-text-container"
387
441
  })
388
442
  }), jsxRuntime.jsx(Section, {
389
- name: "Form Data (Submit)",
443
+ name: "Form Output",
390
444
  children: jsxRuntime.jsx("div", {
391
445
  ref: resultContainerRef,
392
446
  class: "fjs-pgl-text-container"
@@ -401,7 +455,7 @@ function PlaygroundRoot(props) {
401
455
 
402
456
  // helpers ///////////////
403
457
 
404
- function toJSON(obj) {
458
+ function toString(obj) {
405
459
  return JSON.stringify(obj, null, ' ');
406
460
  }
407
461
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/components/Modal.js","../src/components/EmbedModal.js","../src/components/JSONEditor.js","../src/components/Section.js","../src/components/PlaygroundRoot.js","../src/Playground.js"],"sourcesContent":["import { useEffect } from 'preact/hooks';\n\nexport function Modal(props) {\n\n useEffect(() => {\n function handleKey(event) {\n\n if (event.key === 'Escape') {\n event.stopPropagation();\n\n props.onClose();\n }\n }\n\n document.addEventListener('keydown', handleKey);\n\n return () => {\n document.removeEventListener('keydown', handleKey);\n };\n });\n\n return (\n <div class=\"fjs-pgl-modal\">\n <div class=\"fjs-pgl-modal-backdrop\" onClick={ props.onClose }></div>\n <div class=\"fjs-pgl-modal-content\">\n <h1 class=\"fjs-pgl-modal-header\">{ props.name }</h1>\n <div class=\"fjs-pgl-modal-body\">\n { props.children }\n </div>\n <div class=\"fjs-pgl-modal-footer\">\n <button class=\"fjs-pgl-button fjs-pgl-button-default\" onClick={ props.onClose }>Close</button>\n </div>\n </div>\n </div>\n );\n}\n","import { useEffect, useRef } from 'preact/hooks';\n\nimport { Modal } from './Modal';\n\n\nexport function EmbedModal(props) {\n\n const schema = serializeValue(props.schema);\n const data = serializeValue(props.data || {});\n\n const fieldRef = useRef();\n\n const snippet = `<!-- styles needed for rendering -->\n<link rel=\"stylesheet\" href=\"https://unpkg.com/@bpmn-io/form-js@0.2.4/dist/assets/form-js.css\">\n\n<!-- container to render the form into -->\n<div class=\"fjs-pgl-form-container\"></div>\n\n<!-- scripts needed for embedding -->\n<script src=\"https://unpkg.com/@bpmn-io/form-js@0.2.4/dist/form-viewer.umd.js\"></script>\n\n<!-- actual script to instantiate the form and load form schema + data -->\n<script>\n const data = JSON.parse(${data});\n const schema = JSON.parse(${schema});\n\n const form = new FormViewer.Form({\n container: document.querySelector(\".fjs-pgl-form-container\")\n });\n\n form.on(\"submit\", (event) => {\n console.log(event.data, event.errors);\n });\n\n form.importSchema(schema, data).catch(err => {\n console.error(\"Failed to render form\", err);\n });\n</script>\n `.trim();\n\n useEffect(() => {\n fieldRef.current.select();\n });\n\n return (\n <Modal name=\"Embed form\" onClose={ props.onClose }>\n <p>Use the following HTML snippet to embed your form with <a href=\"https://github.com/bpmn-io/form-js\">form-js</a>:</p>\n\n <textarea spellCheck=\"false\" ref={ fieldRef }>{snippet}</textarea>\n </Modal>\n );\n}\n\n\n// helpers ///////////\n\nfunction serializeValue(obj) {\n return JSON.stringify(JSON.stringify(obj)).replace(/</g, '&lt;').replace(/>/g, '&gt;');\n}","import mitt from 'mitt';\n\nimport { basicSetup } from 'codemirror';\nimport { EditorView } from '@codemirror/view';\nimport { EditorState, Compartment } from '@codemirror/state';\nimport { lintGutter, linter } from '@codemirror/lint';\nimport { json, jsonParseLinter } from '@codemirror/lang-json';\n\n\nexport function JSONEditor(options = {}) {\n\n const emitter = mitt();\n\n const {\n readonly = false\n } = options;\n\n let language = new Compartment().of(json());\n let tabSize = new Compartment().of(EditorState.tabSize.of(2));\n\n const linterExtension = linter(jsonParseLinter());\n\n function createState(doc, extensions = []) {\n return EditorState.create({\n doc,\n extensions: [\n basicSetup,\n language,\n tabSize,\n linterExtension,\n lintGutter(),\n ...extensions\n ]\n });\n }\n\n function createView(readonly) {\n\n const updateListener = EditorView.updateListener.of(update => {\n if (update.docChanged) {\n emitter.emit('changed', {\n value: update.view.state.doc.toString()\n });\n }\n });\n\n const editable = EditorView.editable.of(!readonly);\n\n const view = new EditorView({\n state: createState('', [ updateListener, editable ])\n });\n\n view.setValue = function(value) {\n this.setState(createState(value, [ updateListener, editable ]));\n };\n\n return view;\n }\n\n const view = createView(readonly);\n\n this.setValue = function(value) {\n view.setValue(value);\n };\n\n this.getValue = function() {\n return view.state.doc.toString();\n };\n\n this.on = emitter.on;\n this.off = emitter.off;\n this.emit = emitter.emit;\n\n this.attachTo = function(container) {\n container.appendChild(view.dom);\n };\n\n this.destroy = function() {\n if (view.dom.parentNode) {\n view.dom.parentNode.removeChild(view.dom);\n }\n\n view.destroy();\n };\n}\n","export function Section(props) {\n\n const elements =\n Array.isArray(props.children)\n ? props.children :\n [ props.children ];\n\n const {\n headerItems,\n children\n } = elements.reduce((_, child) => {\n const bucket =\n child.type === Section.HeaderItem\n ? _.headerItems\n : _.children;\n\n bucket.push(child);\n\n return _;\n }, { headerItems: [], children: [] });\n\n return (\n <div class=\"fjs-pgl-section\">\n <h1 class=\"header\">{ props.name } { headerItems.length ? <span class=\"header-items\">{ headerItems }</span> : null }</h1>\n <div class=\"body\">\n { children }\n </div>\n </div>\n );\n}\n\nSection.HeaderItem = function(props) {\n return props.children;\n};","import { useRef, useEffect, useState, useCallback } from 'preact/hooks';\n\nimport download from 'downloadjs';\n\nimport classNames from 'classnames';\n\nimport {\n Form\n} from '@bpmn-io/form-js-viewer';\n\nimport {\n FormEditor\n} from '@bpmn-io/form-js-editor';\n\nimport { EmbedModal } from './EmbedModal';\nimport { JSONEditor } from './JSONEditor';\nimport { Section } from './Section';\n\n\nimport './FileDrop.css';\nimport './PlaygroundRoot.css';\n\n\nexport function PlaygroundRoot(props) {\n\n const {\n actions: actionsConfig = {},\n editor: editorConfig = {},\n emit,\n exporter: exporterConfig = {}\n } = props;\n\n const {\n display: displayActions = true\n } = actionsConfig;\n\n const {\n inlinePropertiesPanel = true\n } = editorConfig;\n\n const paletteContainerRef = useRef();\n const editorContainerRef = useRef();\n const formContainerRef = useRef();\n const dataContainerRef = useRef();\n const resultContainerRef = useRef();\n const propertiesPanelContainerRef = useRef();\n\n const paletteRef = useRef();\n const formEditorRef = useRef();\n const formRef = useRef();\n const dataEditorRef = useRef();\n const resultViewRef = useRef();\n const propertiesPanelRef = useRef();\n\n const [ showEmbed, setShowEmbed ] = useState(false);\n\n const [ initialData ] = useState(props.data || {});\n const [ initialSchema, setInitialSchema ] = useState(props.schema);\n\n const [ data, setData ] = useState(props.data || {});\n const [ schema, setSchema ] = useState(props.schema);\n\n const [ resultData, setResultData ] = useState({});\n\n // pipe to playground API\n useEffect(() => {\n props.onInit({\n attachDataContainer: (node) => dataEditorRef.current.attachTo(node),\n attachEditorContainer: (node) => formEditorRef.current.attachTo(node),\n attachFormContainer: (node) => formRef.current.attachTo(node),\n attachPaletteContainer: (node) => paletteRef.current.attachTo(node),\n attachPropertiesPanelContainer: (node) => propertiesPanelRef.current.attachTo(node),\n attachResultContainer: (node) => resultViewRef.current.attachTo(node),\n get: (name, strict) => formEditorRef.current.get(name, strict),\n getDataEditor: () => dataEditorRef.current,\n getEditor: () => formEditorRef.current,\n getForm: () => formRef.current,\n getResultView: () => resultViewRef.current,\n getSchema: () => formEditorRef.current.getSchema(),\n setSchema: setInitialSchema,\n saveSchema: () => formEditorRef.current.saveSchema()\n });\n });\n\n useEffect(() => {\n setInitialSchema(props.schema || {});\n }, [ props.schema ]);\n\n useEffect(() => {\n const dataEditor = dataEditorRef.current = new JSONEditor({\n value: toJSON(data)\n });\n\n const resultView = resultViewRef.current = new JSONEditor({\n readonly: true,\n value: toJSON(resultData)\n });\n\n const form = formRef.current = new Form();\n const formEditor = formEditorRef.current = new FormEditor({\n renderer: {\n compact: true\n },\n palette: {\n parent: paletteContainerRef.current\n },\n propertiesPanel: {\n parent: !inlinePropertiesPanel && propertiesPanelContainerRef.current\n },\n exporter: exporterConfig\n });\n\n paletteRef.current = formEditor.get('palette');\n propertiesPanelRef.current = formEditor.get('propertiesPanel');\n\n formEditor.on('changed', () => {\n setSchema(formEditor.getSchema());\n });\n\n formEditor.on('formEditor.rendered', () => {\n\n // notifiy interested parties after render\n emit('formPlayground.rendered');\n });\n\n form.on('changed', () => {\n setResultData(form._getSubmitData());\n });\n\n dataEditor.on('changed', event => {\n try {\n setData(JSON.parse(event.value));\n } catch (error) {\n\n // notify interested about input data error\n emit('formPlayground.inputDataError', error);\n }\n });\n\n const formContainer = formContainerRef.current;\n const editorContainer = editorContainerRef.current;\n const dataContainer = dataContainerRef.current;\n const resultContainer = resultContainerRef.current;\n\n dataEditor.attachTo(dataContainer);\n resultView.attachTo(resultContainer);\n form.attachTo(formContainer);\n formEditor.attachTo(editorContainer);\n\n return () => {\n dataEditor.destroy();\n resultView.destroy();\n form.destroy();\n formEditor.destroy();\n };\n }, []);\n\n useEffect(() => {\n dataEditorRef.current.setValue(toJSON(initialData));\n }, [ initialData ]);\n\n useEffect(() => {\n initialSchema && formEditorRef.current.importSchema(initialSchema);\n }, [ initialSchema ]);\n\n useEffect(() => {\n schema && formRef.current.importSchema(schema, data);\n }, [ schema, data ]);\n\n useEffect(() => {\n resultViewRef.current.setValue(toJSON(resultData));\n }, [ resultData ]);\n\n useEffect(() => {\n props.onStateChanged({\n schema,\n data\n });\n }, [ schema, data ]);\n\n const handleDownload = useCallback(() => {\n\n download(JSON.stringify(schema, null, ' '), 'form.json', 'text/json');\n }, [ schema ]);\n\n const hideEmbedModal = useCallback(() => {\n setShowEmbed(false);\n }, []);\n\n const showEmbedModal = useCallback(() => {\n setShowEmbed(true);\n }, []);\n\n return (\n <div class={ classNames(\n 'fjs-container',\n 'fjs-pgl-root',\n { 'fjs-pgl-inline-editor-panel': inlinePropertiesPanel }) }>\n <div class=\"fjs-pgl-modals\">\n { showEmbed ? <EmbedModal schema={ schema } data={ data } onClose={ hideEmbedModal } /> : null }\n </div>\n <div class=\"fjs-pgl-palette-container\" ref={ paletteContainerRef } />\n <div class=\"fjs-pgl-main\">\n\n <Section name=\"Form Definition\">\n\n {\n displayActions && <Section.HeaderItem>\n <button\n class=\"fjs-pgl-button\"\n title=\"Download form definition\"\n onClick={ handleDownload }\n >Download</button>\n </Section.HeaderItem>\n }\n\n {\n displayActions && <Section.HeaderItem>\n <button\n class=\"fjs-pgl-button\"\n onClick={ showEmbedModal }\n >Embed</button>\n </Section.HeaderItem>\n }\n\n <div ref={ editorContainerRef } class=\"fjs-pgl-form-container\"></div>\n </Section>\n <Section name=\"Form Preview\">\n <div ref={ formContainerRef } class=\"fjs-pgl-form-container\"></div>\n </Section>\n <Section name=\"Form Data (Input)\">\n <div ref={ dataContainerRef } class=\"fjs-pgl-text-container\"></div>\n </Section>\n <Section name=\"Form Data (Submit)\">\n <div ref={ resultContainerRef } class=\"fjs-pgl-text-container\"></div>\n </Section>\n </div>\n <div class=\"fjs-pgl-properties-container\" ref={ propertiesPanelContainerRef } />\n </div>\n );\n}\n\n\n// helpers ///////////////\n\nfunction toJSON(obj) {\n return JSON.stringify(obj, null, ' ');\n}","import { render } from 'preact';\n\nimport fileDrop from 'file-drops';\n\nimport mitt from 'mitt';\n\nimport { PlaygroundRoot } from './components/PlaygroundRoot';\n\n/**\n * @typedef { {\n * actions?: { display: Boolean }\n * container?: Element\n * data: any\n * editor?: { inlinePropertiesPanel: Boolean }\n * exporter?: { name: String, version: String }\n * schema: any\n * } } FormPlaygroundOptions\n */\n\n/**\n * @param {FormPlaygroundOptions} options\n */\nexport default function Playground(options) {\n\n const {\n container: parent,\n schema,\n data,\n ...rest\n } = options;\n\n const emitter = mitt();\n\n let state = { data, schema };\n let ref;\n\n const container = document.createElement('div');\n\n container.classList.add('fjs-pgl-parent');\n\n if (parent) {\n parent.appendChild(container);\n }\n\n const handleDrop = fileDrop('Drop a form file', function(files) {\n const file = files[0];\n\n if (file) {\n try {\n ref.setSchema(JSON.parse(file.contents));\n } catch (err) {\n\n // TODO(nikku): indicate JSON parse error\n }\n }\n });\n\n const withRef = function(fn) {\n return function(...args) {\n if (!ref) {\n throw new Error('Playground is not initialized.');\n }\n\n return fn(...args);\n };\n };\n\n const onInit = function(_ref) {\n ref = _ref;\n emitter.emit('formPlayground.init');\n };\n\n container.addEventListener('dragover', handleDrop);\n\n render(\n <PlaygroundRoot\n data={ data }\n emit={ emitter.emit }\n onInit={ onInit }\n onStateChanged={ (_state) => state = _state }\n schema={ schema }\n { ...rest }\n />,\n container\n );\n\n this.on = emitter.on;\n this.off = emitter.off;\n\n this.emit = emitter.emit;\n\n this.on('destroy', function() {\n render(null, container);\n });\n\n this.on('destroy', function() {\n parent.removeChild(container);\n });\n\n this.getState = function() {\n return state;\n };\n\n this.getSchema = withRef(() => ref.getSchema());\n\n this.setSchema = withRef((schema) => ref.setSchema(schema));\n\n this.saveSchema = withRef(() => ref.saveSchema());\n\n this.get = withRef((name, strict) => ref.get(name, strict));\n\n this.getDataEditor = withRef(() => ref.getDataEditor());\n\n this.getEditor = withRef(() => ref.getEditor());\n\n this.getForm = withRef((name, strict) => ref.getForm(name, strict));\n\n this.getResultView = withRef(() => ref.getResultView());\n\n this.destroy = function() {\n this.emit('destroy');\n };\n\n this.attachEditorContainer = withRef((node) => ref.attachEditorContainer(node));\n\n this.attachPreviewContainer = withRef((node) => ref.attachFormContainer(node));\n\n this.attachDataContainer = withRef((node) => ref.attachDataContainer(node));\n\n this.attachResultContainer = withRef((node) => ref.attachResultContainer(node));\n\n this.attachPaletteContainer = withRef((node) => ref.attachPaletteContainer(node));\n\n this.attachPropertiesPanelContainer = withRef((node) => ref.attachPropertiesPanelContainer(node));\n}"],"names":["Modal","props","useEffect","handleKey","event","key","stopPropagation","onClose","document","addEventListener","removeEventListener","_jsxs","_jsx","name","children","EmbedModal","schema","serializeValue","data","fieldRef","useRef","snippet","trim","current","select","obj","JSON","stringify","replace","JSONEditor","options","emitter","mitt","readonly","language","Compartment","of","json","tabSize","EditorState","linterExtension","linter","jsonParseLinter","createState","doc","extensions","create","basicSetup","lintGutter","createView","updateListener","EditorView","update","docChanged","emit","value","view","state","toString","editable","setValue","setState","getValue","on","off","attachTo","container","appendChild","dom","destroy","parentNode","removeChild","Section","elements","Array","isArray","headerItems","reduce","_","child","bucket","type","HeaderItem","push","length","PlaygroundRoot","actions","actionsConfig","editor","editorConfig","exporter","exporterConfig","display","displayActions","inlinePropertiesPanel","paletteContainerRef","editorContainerRef","formContainerRef","dataContainerRef","resultContainerRef","propertiesPanelContainerRef","paletteRef","formEditorRef","formRef","dataEditorRef","resultViewRef","propertiesPanelRef","showEmbed","setShowEmbed","useState","initialData","initialSchema","setInitialSchema","setData","setSchema","resultData","setResultData","onInit","attachDataContainer","node","attachEditorContainer","attachFormContainer","attachPaletteContainer","attachPropertiesPanelContainer","attachResultContainer","get","strict","getDataEditor","getEditor","getForm","getResultView","getSchema","saveSchema","dataEditor","toJSON","resultView","form","Form","formEditor","FormEditor","renderer","compact","palette","parent","propertiesPanel","_getSubmitData","parse","error","formContainer","editorContainer","dataContainer","resultContainer","importSchema","onStateChanged","handleDownload","useCallback","download","hideEmbedModal","showEmbedModal","classNames","Playground","rest","ref","createElement","classList","add","handleDrop","fileDrop","files","file","contents","err","withRef","fn","args","Error","_ref","render","_state","getState","attachPreviewContainer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,SAASA,KAAK,CAACC,KAAK,EAAE;EAE3BC,eAAS,CAAC,MAAM;IACd,SAASC,SAAS,CAACC,KAAK,EAAE;MAExB,IAAIA,KAAK,CAACC,GAAG,KAAK,QAAQ,EAAE;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mBAAmB,CAACC,IAAI,CAAC,CAAC;EAE3E,IAAI,CAACK,qBAAqB,GAAGgD,OAAO,CAAErD,IAAI,IAAK2C,GAAG,CAACtC,qBAAqB,CAACL,IAAI,CAAC,CAAC;EAE/E,IAAI,CAACG,sBAAsB,GAAGkD,OAAO,CAAErD,IAAI,IAAK2C,GAAG,CAACxC,sBAAsB,CAACH,IAAI,CAAC,CAAC;EAEjF,IAAI,CAACI,8BAA8B,GAAGiD,OAAO,CAAErD,IAAI,IAAK2C,GAAG,CAACvC,8BAA8B,CAACJ,IAAI,CAAC,CAAC;AACnG;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/components/Modal.js","../src/components/EmbedModal.js","../src/components/autocompletion/VariablesFacet.js","../src/components/autocompletion/index.js","../src/components/JSONEditor.js","../src/components/Section.js","../src/components/PlaygroundRoot.js","../src/Playground.js"],"sourcesContent":["import { useEffect } from 'preact/hooks';\n\nexport function Modal(props) {\n\n useEffect(() => {\n function handleKey(event) {\n\n if (event.key === 'Escape') {\n event.stopPropagation();\n\n props.onClose();\n }\n }\n\n document.addEventListener('keydown', handleKey);\n\n return () => {\n document.removeEventListener('keydown', handleKey);\n };\n });\n\n return (\n <div class=\"fjs-pgl-modal\">\n <div class=\"fjs-pgl-modal-backdrop\" onClick={ props.onClose }></div>\n <div class=\"fjs-pgl-modal-content\">\n <h1 class=\"fjs-pgl-modal-header\">{ props.name }</h1>\n <div class=\"fjs-pgl-modal-body\">\n { props.children }\n </div>\n <div class=\"fjs-pgl-modal-footer\">\n <button class=\"fjs-pgl-button fjs-pgl-button-default\" onClick={ props.onClose }>Close</button>\n </div>\n </div>\n </div>\n );\n}\n","import { useEffect, useRef } from 'preact/hooks';\n\nimport { Modal } from './Modal';\n\n\nexport function EmbedModal(props) {\n\n const schema = serializeValue(props.schema);\n const data = serializeValue(props.data || {});\n\n const fieldRef = useRef();\n\n const snippet = `<!-- styles needed for rendering -->\n<link rel=\"stylesheet\" href=\"https://unpkg.com/@bpmn-io/form-js@0.2.4/dist/assets/form-js.css\">\n\n<!-- container to render the form into -->\n<div class=\"fjs-pgl-form-container\"></div>\n\n<!-- scripts needed for embedding -->\n<script src=\"https://unpkg.com/@bpmn-io/form-js@0.2.4/dist/form-viewer.umd.js\"></script>\n\n<!-- actual script to instantiate the form and load form schema + data -->\n<script>\n const data = JSON.parse(${data});\n const schema = JSON.parse(${schema});\n\n const form = new FormViewer.Form({\n container: document.querySelector(\".fjs-pgl-form-container\")\n });\n\n form.on(\"submit\", (event) => {\n console.log(event.data, event.errors);\n });\n\n form.importSchema(schema, data).catch(err => {\n console.error(\"Failed to render form\", err);\n });\n</script>\n `.trim();\n\n useEffect(() => {\n fieldRef.current.select();\n });\n\n return (\n <Modal name=\"Embed form\" onClose={ props.onClose }>\n <p>Use the following HTML snippet to embed your form with <a href=\"https://github.com/bpmn-io/form-js\">form-js</a>:</p>\n\n <textarea spellCheck=\"false\" ref={ fieldRef }>{snippet}</textarea>\n </Modal>\n );\n}\n\n\n// helpers ///////////\n\nfunction serializeValue(obj) {\n return JSON.stringify(JSON.stringify(obj)).replace(/</g, '&lt;').replace(/>/g, '&gt;');\n}","import { Facet } from '@codemirror/state';\n\n/**\n * @type {Facet<import('..').Variables>} Variables\n */\nexport const variablesFacet = Facet.define();","import { autocompletion } from '@codemirror/autocomplete';\n\nimport { syntaxTree } from '@codemirror/language';\n\nimport { variablesFacet } from './VariablesFacet';\n\nexport default function() {\n return [\n autocompletion({\n override: [\n completions\n ]\n })\n ];\n}\n\nfunction completions(context) {\n\n const variables = context.state.facet(variablesFacet)[0];\n\n const options = variables.map(v => ({\n label: v,\n type: 'variable'\n }));\n\n let nodeBefore = syntaxTree(context.state).resolve(context.pos, -1);\n\n // handle inside property name as explicit call\n if (nodeBefore.type.name === 'PropertyName') {\n context.explicit = true;\n }\n\n let word = context.matchBefore(/\\w*/);\n\n if (word.from == word.to && !context.explicit) {\n return null;\n }\n\n return {\n from: word.from,\n options\n };\n}","import mitt from 'mitt';\n\nimport { basicSetup } from 'codemirror';\nimport { EditorView, keymap } from '@codemirror/view';\nimport { EditorState, Compartment } from '@codemirror/state';\nimport { lintGutter, linter } from '@codemirror/lint';\nimport { json, jsonParseLinter } from '@codemirror/lang-json';\nimport { indentWithTab } from '@codemirror/commands';\n\nimport autocompletion from './autocompletion/index';\nimport { variablesFacet } from './autocompletion/VariablesFacet';\n\n\nexport function JSONEditor(options = {}) {\n const {\n readonly = false\n } = options;\n\n const emitter = mitt();\n\n let language = new Compartment().of(json());\n let tabSize = new Compartment().of(EditorState.tabSize.of(2));\n\n\n /**\n * @typedef {Array<string>} Variables\n */\n\n const autocompletionConf = new Compartment();\n\n const linterExtension = linter(jsonParseLinter());\n\n function createState(doc, extensions = [], variables = []) {\n return EditorState.create({\n doc,\n extensions: [\n basicSetup,\n language,\n tabSize,\n linterExtension,\n lintGutter(),\n autocompletionConf.of(variablesFacet.of(variables)),\n autocompletion(),\n keymap.of([ indentWithTab ]),\n ...extensions\n ]\n });\n }\n\n function createView(readonly) {\n\n const updateListener = EditorView.updateListener.of(update => {\n if (update.docChanged) {\n emitter.emit('changed', {\n value: update.view.state.doc.toString()\n });\n }\n });\n\n const editable = EditorView.editable.of(!readonly);\n\n const view = new EditorView({\n state: createState('', [ updateListener, editable ])\n });\n\n view.setValue = function(value) {\n this.setState(createState(value, [ updateListener, editable ]));\n };\n\n view.setVariables = function(variables) {\n this.setState(createState(\n view.state.doc.toString(),\n [ updateListener, editable ],\n variables\n ));\n };\n\n return view;\n }\n\n const view = this._view = createView(readonly);\n\n this.setValue = function(value) {\n view.setValue(value);\n };\n\n this.getValue = function() {\n return view.state.doc.toString();\n };\n\n /**\n * @param {Variables} variables\n */\n this.setVariables = function(variables) {\n view.setVariables(variables);\n };\n\n this.on = emitter.on;\n this.off = emitter.off;\n this.emit = emitter.emit;\n\n this.attachTo = function(container) {\n container.appendChild(view.dom);\n };\n\n this.destroy = function() {\n if (view.dom.parentNode) {\n view.dom.parentNode.removeChild(view.dom);\n }\n\n view.destroy();\n };\n}\n","export function Section(props) {\n\n const elements =\n Array.isArray(props.children)\n ? props.children :\n [ props.children ];\n\n const {\n headerItems,\n children\n } = elements.reduce((_, child) => {\n const bucket =\n child.type === Section.HeaderItem\n ? _.headerItems\n : _.children;\n\n bucket.push(child);\n\n return _;\n }, { headerItems: [], children: [] });\n\n return (\n <div class=\"fjs-pgl-section\">\n <h1 class=\"header\">{ props.name } { headerItems.length ? <span class=\"header-items\">{ headerItems }</span> : null }</h1>\n <div class=\"body\">\n { children }\n </div>\n </div>\n );\n}\n\nSection.HeaderItem = function(props) {\n return props.children;\n};","import { useRef, useEffect, useState, useCallback } from 'preact/hooks';\n\nimport download from 'downloadjs';\n\nimport classNames from 'classnames';\n\nimport {\n Form,\n getSchemaVariables\n} from '@bpmn-io/form-js-viewer';\n\nimport {\n FormEditor\n} from '@bpmn-io/form-js-editor';\n\nimport { EmbedModal } from './EmbedModal';\nimport { JSONEditor } from './JSONEditor';\nimport { Section } from './Section';\n\n\nimport './FileDrop.css';\nimport './PlaygroundRoot.css';\n\n\nexport function PlaygroundRoot(props) {\n\n const {\n actions: actionsConfig = {},\n emit,\n exporter: exporterConfig = {}\n } = props;\n\n const {\n display: displayActions = true\n } = actionsConfig;\n\n const paletteContainerRef = useRef();\n const editorContainerRef = useRef();\n const formContainerRef = useRef();\n const dataContainerRef = useRef();\n const resultContainerRef = useRef();\n const propertiesPanelContainerRef = useRef();\n\n const paletteRef = useRef();\n const formEditorRef = useRef();\n const formRef = useRef();\n const dataEditorRef = useRef();\n const resultViewRef = useRef();\n const propertiesPanelRef = useRef();\n\n const [ showEmbed, setShowEmbed ] = useState(false);\n\n const [ initialData ] = useState(props.data || {});\n const [ initialSchema, setInitialSchema ] = useState(props.schema);\n\n const [ data, setData ] = useState(props.data || {});\n const [ schema, setSchema ] = useState(props.schema);\n\n const [ resultData, setResultData ] = useState({});\n\n // pipe to playground API\n useEffect(() => {\n props.onInit({\n attachDataContainer: (node) => dataEditorRef.current.attachTo(node),\n attachEditorContainer: (node) => formEditorRef.current.attachTo(node),\n attachFormContainer: (node) => formRef.current.attachTo(node),\n attachPaletteContainer: (node) => paletteRef.current.attachTo(node),\n attachPropertiesPanelContainer: (node) => propertiesPanelRef.current.attachTo(node),\n attachResultContainer: (node) => resultViewRef.current.attachTo(node),\n get: (name, strict) => formEditorRef.current.get(name, strict),\n getDataEditor: () => dataEditorRef.current,\n getEditor: () => formEditorRef.current,\n getForm: () => formRef.current,\n getResultView: () => resultViewRef.current,\n getSchema: () => formEditorRef.current.getSchema(),\n setSchema: setInitialSchema,\n saveSchema: () => formEditorRef.current.saveSchema()\n });\n });\n\n useEffect(() => {\n setInitialSchema(props.schema || {});\n }, [ props.schema ]);\n\n useEffect(() => {\n const dataEditor = dataEditorRef.current = new JSONEditor({\n value: toString(data)\n });\n\n const resultView = resultViewRef.current = new JSONEditor({\n readonly: true,\n value: toString(resultData)\n });\n\n const form = formRef.current = new Form();\n const formEditor = formEditorRef.current = new FormEditor({\n renderer: {\n compact: true\n },\n palette: {\n parent: paletteContainerRef.current\n },\n propertiesPanel: {\n parent: propertiesPanelContainerRef.current\n },\n exporter: exporterConfig\n });\n\n paletteRef.current = formEditor.get('palette');\n propertiesPanelRef.current = formEditor.get('propertiesPanel');\n\n formEditor.on('changed', () => {\n setSchema(formEditor.getSchema());\n });\n\n formEditor.on('formEditor.rendered', () => {\n\n // notifiy interested parties after render\n emit('formPlayground.rendered');\n });\n\n form.on('changed', () => {\n setResultData(form._getSubmitData());\n });\n\n dataEditor.on('changed', event => {\n try {\n setData(JSON.parse(event.value));\n } catch (error) {\n\n // notify interested about input data error\n emit('formPlayground.inputDataError', error);\n }\n });\n\n const formContainer = formContainerRef.current;\n const editorContainer = editorContainerRef.current;\n const dataContainer = dataContainerRef.current;\n const resultContainer = resultContainerRef.current;\n\n dataEditor.attachTo(dataContainer);\n resultView.attachTo(resultContainer);\n form.attachTo(formContainer);\n formEditor.attachTo(editorContainer);\n\n return () => {\n dataEditor.destroy();\n resultView.destroy();\n form.destroy();\n formEditor.destroy();\n };\n }, []);\n\n useEffect(() => {\n dataEditorRef.current.setValue(toString(initialData));\n }, [ initialData ]);\n\n useEffect(() => {\n if (initialSchema) {\n formEditorRef.current.importSchema(initialSchema);\n dataEditorRef.current.setVariables(getSchemaVariables(initialSchema));\n }\n }, [ initialSchema ]);\n\n useEffect(() => {\n if (schema && dataContainerRef.current) {\n const variables = getSchemaVariables(schema);\n dataEditorRef.current.setVariables(variables);\n }\n }, [ schema ]);\n\n useEffect(() => {\n schema && formRef.current.importSchema(schema, data);\n }, [ schema, data ]);\n\n useEffect(() => {\n resultViewRef.current.setValue(toString(resultData));\n }, [ resultData ]);\n\n useEffect(() => {\n props.onStateChanged({\n schema,\n data\n });\n }, [ schema, data ]);\n\n const handleDownload = useCallback(() => {\n\n download(JSON.stringify(schema, null, ' '), 'form.json', 'text/json');\n }, [ schema ]);\n\n const hideEmbedModal = useCallback(() => {\n setShowEmbed(false);\n }, []);\n\n const showEmbedModal = useCallback(() => {\n setShowEmbed(true);\n }, []);\n\n return (\n <div class={ classNames(\n 'fjs-container',\n 'fjs-pgl-root'\n ) }>\n <div class=\"fjs-pgl-modals\">\n { showEmbed ? <EmbedModal schema={ schema } data={ data } onClose={ hideEmbedModal } /> : null }\n </div>\n <div class=\"fjs-pgl-palette-container\" ref={ paletteContainerRef } />\n <div class=\"fjs-pgl-main\">\n\n <Section name=\"Form Definition\">\n\n {\n displayActions && <Section.HeaderItem>\n <button\n class=\"fjs-pgl-button\"\n title=\"Download form definition\"\n onClick={ handleDownload }\n >Download</button>\n </Section.HeaderItem>\n }\n\n {\n displayActions && <Section.HeaderItem>\n <button\n class=\"fjs-pgl-button\"\n onClick={ showEmbedModal }\n >Embed</button>\n </Section.HeaderItem>\n }\n\n <div ref={ editorContainerRef } class=\"fjs-pgl-form-container\"></div>\n </Section>\n <Section name=\"Form Preview\">\n <div ref={ formContainerRef } class=\"fjs-pgl-form-container\"></div>\n </Section>\n <Section name=\"Form Input\">\n <div ref={ dataContainerRef } class=\"fjs-pgl-text-container\"></div>\n </Section>\n <Section name=\"Form Output\">\n <div ref={ resultContainerRef } class=\"fjs-pgl-text-container\"></div>\n </Section>\n </div>\n <div class=\"fjs-pgl-properties-container\" ref={ propertiesPanelContainerRef } />\n </div>\n );\n}\n\n\n// helpers ///////////////\n\nfunction toString(obj) {\n return JSON.stringify(obj, null, ' ');\n}","import { render } from 'preact';\n\nimport fileDrop from 'file-drops';\n\nimport mitt from 'mitt';\n\nimport { PlaygroundRoot } from './components/PlaygroundRoot';\n\n/**\n * @typedef { {\n * actions?: { display: Boolean }\n * container?: Element\n * data: any\n * editor?: { inlinePropertiesPanel: Boolean }\n * exporter?: { name: String, version: String }\n * schema: any\n * } } FormPlaygroundOptions\n */\n\n/**\n * @param {FormPlaygroundOptions} options\n */\nexport default function Playground(options) {\n\n const {\n container: parent,\n schema,\n data,\n ...rest\n } = options;\n\n const emitter = mitt();\n\n let state = { data, schema };\n let ref;\n\n const container = document.createElement('div');\n\n container.classList.add('fjs-pgl-parent');\n\n if (parent) {\n parent.appendChild(container);\n }\n\n const handleDrop = fileDrop('Drop a form file', function(files) {\n const file = files[0];\n\n if (file) {\n try {\n ref.setSchema(JSON.parse(file.contents));\n } catch (err) {\n\n // TODO(nikku): indicate JSON parse error\n }\n }\n });\n\n const withRef = function(fn) {\n return function(...args) {\n if (!ref) {\n throw new Error('Playground is not initialized.');\n }\n\n return fn(...args);\n };\n };\n\n const onInit = function(_ref) {\n ref = _ref;\n emitter.emit('formPlayground.init');\n };\n\n container.addEventListener('dragover', handleDrop);\n\n render(\n <PlaygroundRoot\n data={ data }\n emit={ emitter.emit }\n onInit={ onInit }\n onStateChanged={ (_state) => state = _state }\n schema={ schema }\n { ...rest }\n />,\n container\n );\n\n this.on = emitter.on;\n this.off = emitter.off;\n\n this.emit = emitter.emit;\n\n this.on('destroy', function() {\n render(null, container);\n });\n\n this.on('destroy', function() {\n parent.removeChild(container);\n });\n\n this.getState = function() {\n return state;\n };\n\n this.getSchema = withRef(() => ref.getSchema());\n\n this.setSchema = withRef((schema) => ref.setSchema(schema));\n\n this.saveSchema = withRef(() => ref.saveSchema());\n\n this.get = withRef((name, strict) => ref.get(name, strict));\n\n this.getDataEditor = withRef(() => ref.getDataEditor());\n\n this.getEditor = withRef(() => ref.getEditor());\n\n this.getForm = withRef((name, strict) => ref.getForm(name, strict));\n\n this.getResultView = withRef(() => ref.getResultView());\n\n this.destroy = function() {\n this.emit('destroy');\n };\n\n this.attachEditorContainer = withRef((node) => ref.attachEditorContainer(node));\n\n this.attachPreviewContainer = withRef((node) => ref.attachFormContainer(node));\n\n this.attachDataContainer = withRef((node) => ref.attachDataContainer(node));\n\n this.attachResultContainer = withRef((node) => ref.attachResultContainer(node));\n\n this.attachPaletteContainer = withRef((node) => ref.attachPaletteContainer(node));\n\n this.attachPropertiesPanelContainer = withRef((node) => ref.attachPropertiesPanelContainer(node));\n}"],"names":["Modal","props","useEffect","handleKey","event","key","stopPropagation","onClose","document","addEventListener","removeEventListener","_jsxs","_jsx","name","children","EmbedModal","schema","serializeValue","data","fieldRef","useRef","snippet","trim","current","select","obj","JSON","stringify","replace","variablesFacet","Facet","define","autocompletion","override","completions","context","variables","state","facet","options","map","v","label","type","nodeBefore","syntaxTree","resolve","pos","explicit","word","matchBefore","from","to","JSONEditor","readonly","emitter","mitt","language","Compartment","of","json","tabSize","EditorState","autocompletionConf","linterExtension","linter","jsonParseLinter","createState","doc","extensions","create","basicSetup","lintGutter","keymap","indentWithTab","createView","updateListener","EditorView","update","docChanged","emit","value","view","toString","editable","setValue","setState","setVariables","_view","getValue","on","off","attachTo","container","appendChild","dom","destroy","parentNode","removeChild","Section","elements","Array","isArray","headerItems","reduce","_","child","bucket","HeaderItem","push","length","PlaygroundRoot","actions","actionsConfig","exporter","exporterConfig","display","displayActions","paletteContainerRef","editorContainerRef","formContainerRef","dataContainerRef","resultContainerRef","propertiesPanelContainerRef","paletteRef","formEditorRef","formRef","dataEditorRef","resultViewRef","propertiesPanelRef","showEmbed","setShowEmbed","useState","initialData","initialSchema","setInitialSchema","setData","setSchema","resultData","setResultData","onInit","attachDataContainer","node","attachEditorContainer","attachFormContainer","attachPaletteContainer","attachPropertiesPanelContainer","attachResultContainer","get","strict","getDataEditor","getEditor","getForm","getResultView","getSchema","saveSchema","dataEditor","resultView","form","Form","formEditor","FormEditor","renderer","compact","palette","parent","propertiesPanel","_getSubmitData","parse","error","formContainer","editorContainer","dataContainer","resultContainer","importSchema","getSchemaVariables","onStateChanged","handleDownload","useCallback","download","hideEmbedModal","showEmbedModal","classNames","Playground","rest","ref","createElement","classList","add","handleDrop","fileDrop","files","file","contents","err","withRef","fn","args","Error","_ref","render","_state","getState","attachPreviewContainer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,SAASA,KAAK,CAACC,KAAK,EAAE;EAE3BC,eAAS,CAAC,MAAM;IACd,SAASC,SAAS,CAACC,KAAK,EAAE;MAExB,IAAIA,KAAK,CAACC,GAAG,KAAK,QAAQ,EAAE;QAC1BD,KAAK,CAACE,eAAe,EAAE;QAEvBL,KAAK,CAACM,OAAO,EAAE;;;IAInBC,QAAQ,CAACC,gBAAgB,CAAC,SAAS,EAAEN,SAAS,CAAC;IAE/C,OAAO,MAAM;MACXK,QAAQ,CAACE,mBAAmB,CAAC,SAAS,EAAEP,SAAS,CAAC;KACnD;GACF,CAAC;EAEF,OACEQ;IAAK,KAAK,EAAC,eAAe;IAAA,WACxBC;MAAK,KAAK,EAAC,wBAAwB;MAAC,OAAO,EAAGX,KAAK,CAACM;MAAgB,EACpEI;MAAK,KAAK,EAAC,uBAAuB;MAAA,WAChCC;QAAI,KAAK,EAAC,sBAAsB;QAAA,UAAGX,KAAK,CAACY;QAAW,EACpDD;QAAK,KAAK,EAAC,oBAAoB;QAAA,UAC3BX,KAAK,CAACa;QACJ,EACNF;QAAK,KAAK,EAAC,sBAAsB;QAAA,UAC/BA;UAA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AAErD,IAAI,IAAK2C,GAAG,CAACtC,qBAAqB,CAACL,IAAI,CAAC,CAAC;EAE/E,IAAI,CAACG,sBAAsB,GAAGkD,OAAO,CAAErD,IAAI,IAAK2C,GAAG,CAACxC,sBAAsB,CAACH,IAAI,CAAC,CAAC;EAEjF,IAAI,CAACI,8BAA8B,GAAGiD,OAAO,CAAErD,IAAI,IAAK2C,GAAG,CAACvC,8BAA8B,CAACJ,IAAI,CAAC,CAAC;AACnG;;;;"}
package/dist/index.es.js CHANGED
@@ -4,14 +4,17 @@ import mitt from 'mitt';
4
4
  import { useEffect, useRef, useState, useCallback } from 'preact/hooks';
5
5
  import download from 'downloadjs';
6
6
  import classNames from 'classnames';
7
- import { Form } from '@bpmn-io/form-js-viewer';
7
+ import { Form, getSchemaVariables } from '@bpmn-io/form-js-viewer';
8
8
  import { FormEditor } from '@bpmn-io/form-js-editor';
9
9
  import { jsxs, jsx } from 'preact/jsx-runtime';
10
10
  import { basicSetup } from 'codemirror';
11
- import { EditorView } from '@codemirror/view';
12
- import { Compartment, EditorState } from '@codemirror/state';
11
+ import { EditorView, keymap } from '@codemirror/view';
12
+ import { Facet, Compartment, EditorState } from '@codemirror/state';
13
13
  import { linter, lintGutter } from '@codemirror/lint';
14
14
  import { json, jsonParseLinter } from '@codemirror/lang-json';
15
+ import { indentWithTab } from '@codemirror/commands';
16
+ import { autocompletion as autocompletion$1 } from '@codemirror/autocomplete';
17
+ import { syntaxTree } from '@codemirror/language';
15
18
 
16
19
  function Modal(props) {
17
20
  useEffect(() => {
@@ -107,18 +110,56 @@ function serializeValue(obj) {
107
110
  return JSON.stringify(JSON.stringify(obj)).replace(/</g, '&lt;').replace(/>/g, '&gt;');
108
111
  }
109
112
 
113
+ /**
114
+ * @type {Facet<import('..').Variables>} Variables
115
+ */
116
+ const variablesFacet = Facet.define();
117
+
118
+ function autocompletion () {
119
+ return [autocompletion$1({
120
+ override: [completions]
121
+ })];
122
+ }
123
+ function completions(context) {
124
+ const variables = context.state.facet(variablesFacet)[0];
125
+ const options = variables.map(v => ({
126
+ label: v,
127
+ type: 'variable'
128
+ }));
129
+ let nodeBefore = syntaxTree(context.state).resolve(context.pos, -1);
130
+
131
+ // handle inside property name as explicit call
132
+ if (nodeBefore.type.name === 'PropertyName') {
133
+ context.explicit = true;
134
+ }
135
+ let word = context.matchBefore(/\w*/);
136
+ if (word.from == word.to && !context.explicit) {
137
+ return null;
138
+ }
139
+ return {
140
+ from: word.from,
141
+ options
142
+ };
143
+ }
144
+
110
145
  function JSONEditor(options = {}) {
111
- const emitter = mitt();
112
146
  const {
113
147
  readonly = false
114
148
  } = options;
149
+ const emitter = mitt();
115
150
  let language = new Compartment().of(json());
116
151
  let tabSize = new Compartment().of(EditorState.tabSize.of(2));
152
+
153
+ /**
154
+ * @typedef {Array<string>} Variables
155
+ */
156
+
157
+ const autocompletionConf = new Compartment();
117
158
  const linterExtension = linter(jsonParseLinter());
118
- function createState(doc, extensions = []) {
159
+ function createState(doc, extensions = [], variables = []) {
119
160
  return EditorState.create({
120
161
  doc,
121
- extensions: [basicSetup, language, tabSize, linterExtension, lintGutter(), ...extensions]
162
+ extensions: [basicSetup, language, tabSize, linterExtension, lintGutter(), autocompletionConf.of(variablesFacet.of(variables)), autocompletion(), keymap.of([indentWithTab]), ...extensions]
122
163
  });
123
164
  }
124
165
  function createView(readonly) {
@@ -136,15 +177,25 @@ function JSONEditor(options = {}) {
136
177
  view.setValue = function (value) {
137
178
  this.setState(createState(value, [updateListener, editable]));
138
179
  };
180
+ view.setVariables = function (variables) {
181
+ this.setState(createState(view.state.doc.toString(), [updateListener, editable], variables));
182
+ };
139
183
  return view;
140
184
  }
141
- const view = createView(readonly);
185
+ const view = this._view = createView(readonly);
142
186
  this.setValue = function (value) {
143
187
  view.setValue(value);
144
188
  };
145
189
  this.getValue = function () {
146
190
  return view.state.doc.toString();
147
191
  };
192
+
193
+ /**
194
+ * @param {Variables} variables
195
+ */
196
+ this.setVariables = function (variables) {
197
+ view.setVariables(variables);
198
+ };
148
199
  this.on = emitter.on;
149
200
  this.off = emitter.off;
150
201
  this.emit = emitter.emit;
@@ -193,16 +244,12 @@ Section.HeaderItem = function (props) {
193
244
  function PlaygroundRoot(props) {
194
245
  const {
195
246
  actions: actionsConfig = {},
196
- editor: editorConfig = {},
197
247
  emit,
198
248
  exporter: exporterConfig = {}
199
249
  } = props;
200
250
  const {
201
251
  display: displayActions = true
202
252
  } = actionsConfig;
203
- const {
204
- inlinePropertiesPanel = true
205
- } = editorConfig;
206
253
  const paletteContainerRef = useRef();
207
254
  const editorContainerRef = useRef();
208
255
  const formContainerRef = useRef();
@@ -246,11 +293,11 @@ function PlaygroundRoot(props) {
246
293
  }, [props.schema]);
247
294
  useEffect(() => {
248
295
  const dataEditor = dataEditorRef.current = new JSONEditor({
249
- value: toJSON(data)
296
+ value: toString(data)
250
297
  });
251
298
  const resultView = resultViewRef.current = new JSONEditor({
252
299
  readonly: true,
253
- value: toJSON(resultData)
300
+ value: toString(resultData)
254
301
  });
255
302
  const form = formRef.current = new Form();
256
303
  const formEditor = formEditorRef.current = new FormEditor({
@@ -261,7 +308,7 @@ function PlaygroundRoot(props) {
261
308
  parent: paletteContainerRef.current
262
309
  },
263
310
  propertiesPanel: {
264
- parent: !inlinePropertiesPanel && propertiesPanelContainerRef.current
311
+ parent: propertiesPanelContainerRef.current
265
312
  },
266
313
  exporter: exporterConfig
267
314
  });
@@ -301,16 +348,25 @@ function PlaygroundRoot(props) {
301
348
  };
302
349
  }, []);
303
350
  useEffect(() => {
304
- dataEditorRef.current.setValue(toJSON(initialData));
351
+ dataEditorRef.current.setValue(toString(initialData));
305
352
  }, [initialData]);
306
353
  useEffect(() => {
307
- initialSchema && formEditorRef.current.importSchema(initialSchema);
354
+ if (initialSchema) {
355
+ formEditorRef.current.importSchema(initialSchema);
356
+ dataEditorRef.current.setVariables(getSchemaVariables(initialSchema));
357
+ }
308
358
  }, [initialSchema]);
359
+ useEffect(() => {
360
+ if (schema && dataContainerRef.current) {
361
+ const variables = getSchemaVariables(schema);
362
+ dataEditorRef.current.setVariables(variables);
363
+ }
364
+ }, [schema]);
309
365
  useEffect(() => {
310
366
  schema && formRef.current.importSchema(schema, data);
311
367
  }, [schema, data]);
312
368
  useEffect(() => {
313
- resultViewRef.current.setValue(toJSON(resultData));
369
+ resultViewRef.current.setValue(toString(resultData));
314
370
  }, [resultData]);
315
371
  useEffect(() => {
316
372
  props.onStateChanged({
@@ -328,9 +384,7 @@ function PlaygroundRoot(props) {
328
384
  setShowEmbed(true);
329
385
  }, []);
330
386
  return jsxs("div", {
331
- class: classNames('fjs-container', 'fjs-pgl-root', {
332
- 'fjs-pgl-inline-editor-panel': inlinePropertiesPanel
333
- }),
387
+ class: classNames('fjs-container', 'fjs-pgl-root'),
334
388
  children: [jsx("div", {
335
389
  class: "fjs-pgl-modals",
336
390
  children: showEmbed ? jsx(EmbedModal, {
@@ -369,13 +423,13 @@ function PlaygroundRoot(props) {
369
423
  class: "fjs-pgl-form-container"
370
424
  })
371
425
  }), jsx(Section, {
372
- name: "Form Data (Input)",
426
+ name: "Form Input",
373
427
  children: jsx("div", {
374
428
  ref: dataContainerRef,
375
429
  class: "fjs-pgl-text-container"
376
430
  })
377
431
  }), jsx(Section, {
378
- name: "Form Data (Submit)",
432
+ name: "Form Output",
379
433
  children: jsx("div", {
380
434
  ref: resultContainerRef,
381
435
  class: "fjs-pgl-text-container"
@@ -390,7 +444,7 @@ function PlaygroundRoot(props) {
390
444
 
391
445
  // helpers ///////////////
392
446
 
393
- function toJSON(obj) {
447
+ function toString(obj) {
394
448
  return JSON.stringify(obj, null, ' ');
395
449
  }
396
450