@bpmn-io/form-js-playground 0.7.1 → 0.8.0-alpha.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.
@@ -0,0 +1,409 @@
1
+ import { render } from 'preact';
2
+ import fileDrop from 'file-drops';
3
+ import mitt from 'mitt';
4
+ import { useEffect, useRef, useState, useCallback } from 'preact/hooks';
5
+ import download from 'downloadjs';
6
+ import { Form, FormEditor } from '@bpmn-io/form-js';
7
+ import { jsxs, jsx } from 'preact/jsx-runtime';
8
+ import { EditorView, basicSetup } from '@codemirror/basic-setup';
9
+ import { Compartment, EditorState } from '@codemirror/state';
10
+ import { json } from '@codemirror/lang-json';
11
+
12
+ function Modal(props) {
13
+ useEffect(() => {
14
+ function handleKey(event) {
15
+ if (event.key === 'Escape') {
16
+ event.stopPropagation();
17
+ props.onClose();
18
+ }
19
+ }
20
+
21
+ document.addEventListener('keydown', handleKey);
22
+ return () => {
23
+ document.removeEventListener('keydown', handleKey);
24
+ };
25
+ });
26
+ return jsxs("div", {
27
+ class: "fjs-pgl-modal",
28
+ children: [jsx("div", {
29
+ class: "fjs-pgl-modal-backdrop",
30
+ onClick: props.onClose
31
+ }), jsxs("div", {
32
+ class: "fjs-pgl-modal-content",
33
+ children: [jsx("h1", {
34
+ class: "fjs-pgl-modal-header",
35
+ children: props.name
36
+ }), jsx("div", {
37
+ class: "fjs-pgl-modal-body",
38
+ children: props.children
39
+ }), jsx("div", {
40
+ class: "fjs-pgl-modal-footer",
41
+ children: jsx("button", {
42
+ class: "fjs-pgl-button fjs-pgl-button-default",
43
+ onClick: props.onClose,
44
+ children: "Close"
45
+ })
46
+ })]
47
+ })]
48
+ });
49
+ }
50
+
51
+ function EmbedModal(props) {
52
+ const schema = serializeValue(props.schema);
53
+ const data = serializeValue(props.data || {});
54
+ const fieldRef = useRef();
55
+ const snippet = `<!-- styles needed for rendering -->
56
+ <link rel="stylesheet" href="https://unpkg.com/@bpmn-io/form-js@0.2.4/dist/assets/form-js.css">
57
+
58
+ <!-- container to render the form into -->
59
+ <div class="fjs-pgl-form-container"></div>
60
+
61
+ <!-- scripts needed for embedding -->
62
+ <script src="https://unpkg.com/@bpmn-io/form-js@0.2.4/dist/form-viewer.umd.js"></script>
63
+
64
+ <!-- actual script to instantiate the form and load form schema + data -->
65
+ <script>
66
+ const data = JSON.parse(${data});
67
+ const schema = JSON.parse(${schema});
68
+
69
+ const form = new FormViewer.Form({
70
+ container: document.querySelector(".fjs-pgl-form-container")
71
+ });
72
+
73
+ form.on("submit", (event) => {
74
+ console.log(event.data, event.errors);
75
+ });
76
+
77
+ form.importSchema(schema, data).catch(err => {
78
+ console.error("Failed to render form", err);
79
+ });
80
+ </script>
81
+ `.trim();
82
+ useEffect(() => {
83
+ fieldRef.current.select();
84
+ });
85
+ return jsxs(Modal, {
86
+ name: "Embed form",
87
+ onClose: props.onClose,
88
+ children: [jsxs("p", {
89
+ children: ["Use the following HTML snippet to embed your form with ", jsx("a", {
90
+ href: "https://github.com/bpmn-io/form-js",
91
+ children: "form-js"
92
+ }), ":"]
93
+ }), jsx("textarea", {
94
+ spellCheck: "false",
95
+ ref: fieldRef,
96
+ children: snippet
97
+ })]
98
+ });
99
+ } // helpers ///////////
100
+
101
+ function serializeValue(obj) {
102
+ return JSON.stringify(JSON.stringify(obj)).replace(/</g, '&lt;').replace(/>/g, '&gt;');
103
+ }
104
+
105
+ function JSONEditor(options = {}) {
106
+ const emitter = mitt();
107
+ const {
108
+ readonly = false
109
+ } = options;
110
+ let language = new Compartment().of(json());
111
+ let tabSize = new Compartment().of(EditorState.tabSize.of(2));
112
+
113
+ function createState(doc, extensions = []) {
114
+ return EditorState.create({
115
+ doc,
116
+ extensions: [basicSetup, language, tabSize, ...extensions]
117
+ });
118
+ }
119
+
120
+ function createView(readonly) {
121
+ const updateListener = EditorView.updateListener.of(update => {
122
+ if (update.docChanged) {
123
+ emitter.emit('changed', {
124
+ value: update.view.state.doc.toString()
125
+ });
126
+ }
127
+ });
128
+ const editable = EditorView.editable.of(!readonly);
129
+ const view = new EditorView({
130
+ state: createState('', [updateListener, editable])
131
+ });
132
+
133
+ view.setValue = function (value) {
134
+ this.setState(createState(value, [updateListener, editable]));
135
+ };
136
+
137
+ return view;
138
+ }
139
+
140
+ const view = createView(readonly);
141
+
142
+ this.setValue = function (value) {
143
+ view.setValue(value);
144
+ };
145
+
146
+ this.getValue = function () {
147
+ return view.state.doc.toString();
148
+ };
149
+
150
+ this.on = emitter.on;
151
+ this.off = emitter.off;
152
+
153
+ this.attachTo = function (container) {
154
+ container.appendChild(view.dom);
155
+ };
156
+
157
+ this.destroy = function () {
158
+ if (view.dom.parentNode) {
159
+ view.dom.parentNode.removeChild(view.dom);
160
+ }
161
+
162
+ view.destroy();
163
+ };
164
+ }
165
+
166
+ function Section(props) {
167
+ const elements = Array.isArray(props.children) ? props.children : [props.children];
168
+ const {
169
+ headerItems,
170
+ children
171
+ } = elements.reduce((_, child) => {
172
+ const bucket = child.type === Section.HeaderItem ? _.headerItems : _.children;
173
+ bucket.push(child);
174
+ return _;
175
+ }, {
176
+ headerItems: [],
177
+ children: []
178
+ });
179
+ return jsxs("div", {
180
+ class: "fjs-pgl-section",
181
+ children: [jsxs("h1", {
182
+ class: "header",
183
+ children: [props.name, " ", headerItems.length ? jsx("span", {
184
+ class: "header-items",
185
+ children: headerItems
186
+ }) : null]
187
+ }), jsx("div", {
188
+ class: "body",
189
+ children: children
190
+ })]
191
+ });
192
+ }
193
+
194
+ Section.HeaderItem = function (props) {
195
+ return props.children;
196
+ };
197
+
198
+ function PlaygroundRoot(props) {
199
+ const paletteContainerRef = useRef();
200
+ const editorContainerRef = useRef();
201
+ const formContainerRef = useRef();
202
+ const dataContainerRef = useRef();
203
+ const resultContainerRef = useRef();
204
+ const formEditorRef = useRef();
205
+ const formRef = useRef();
206
+ const dataEditorRef = useRef();
207
+ const resultViewRef = useRef();
208
+ const [showEmbed, setShowEmbed] = useState(false);
209
+ const [initialData] = useState(props.data || {});
210
+ const [initialSchema, setInitialSchema] = useState(props.schema);
211
+ const [data, setData] = useState(props.data || {});
212
+ const [schema, setSchema] = useState(props.schema);
213
+ const [resultData, setResultData] = useState(props.data || {});
214
+ useEffect(() => {
215
+ props.onInit({
216
+ setSchema: setInitialSchema
217
+ });
218
+ });
219
+ useEffect(() => {
220
+ setInitialSchema(props.schema || {});
221
+ }, [props.schema]);
222
+ useEffect(() => {
223
+ const dataEditor = dataEditorRef.current = new JSONEditor({
224
+ value: toJSON(data)
225
+ });
226
+ const resultView = resultViewRef.current = new JSONEditor({
227
+ readonly: true,
228
+ value: toJSON(resultData)
229
+ });
230
+ const form = formRef.current = new Form();
231
+ const formEditor = formEditorRef.current = new FormEditor({
232
+ renderer: {
233
+ compact: true
234
+ },
235
+ palette: {
236
+ parent: paletteContainerRef.current
237
+ }
238
+ });
239
+ formEditor.on('changed', () => {
240
+ setSchema(formEditor.getSchema());
241
+ });
242
+ form.on('changed', event => {
243
+ setResultData(event.data);
244
+ });
245
+ dataEditor.on('changed', event => {
246
+ try {
247
+ setData(JSON.parse(event.value));
248
+ } catch (err) {// TODO(nikku): indicate JSON parse error
249
+ }
250
+ });
251
+ const formContainer = formContainerRef.current;
252
+ const editorContainer = editorContainerRef.current;
253
+ const dataContainer = dataContainerRef.current;
254
+ const resultContainer = resultContainerRef.current;
255
+ dataEditor.attachTo(dataContainer);
256
+ resultView.attachTo(resultContainer);
257
+ form.attachTo(formContainer);
258
+ formEditor.attachTo(editorContainer);
259
+ return () => {
260
+ dataEditor.destroy();
261
+ resultView.destroy();
262
+ form.destroy();
263
+ formEditor.destroy();
264
+ };
265
+ }, []);
266
+ useEffect(() => {
267
+ dataEditorRef.current.setValue(toJSON(initialData));
268
+ }, [initialData]);
269
+ useEffect(() => {
270
+ formEditorRef.current.importSchema(initialSchema);
271
+ }, [initialSchema]);
272
+ useEffect(() => {
273
+ formRef.current.importSchema(schema, data);
274
+ }, [schema, data]);
275
+ useEffect(() => {
276
+ resultViewRef.current.setValue(toJSON(resultData));
277
+ }, [resultData]);
278
+ useEffect(() => {
279
+ props.onStateChanged({
280
+ schema,
281
+ data
282
+ });
283
+ }, [schema, data]);
284
+ const handleDownload = useCallback(() => {
285
+ download(JSON.stringify(schema, null, ' '), 'form.json', 'text/json');
286
+ }, [schema]);
287
+ const hideEmbedModal = useCallback(() => {
288
+ setShowEmbed(false);
289
+ }, []);
290
+ const showEmbedModal = useCallback(() => {
291
+ setShowEmbed(true);
292
+ }, []);
293
+ return jsxs("div", {
294
+ class: "fjs-container fjs-pgl-root",
295
+ children: [jsx("div", {
296
+ class: "fjs-pgl-modals",
297
+ children: showEmbed ? jsx(EmbedModal, {
298
+ schema: schema,
299
+ data: data,
300
+ onClose: hideEmbedModal
301
+ }) : null
302
+ }), jsx("div", {
303
+ class: "fjs-pgl-palette-container",
304
+ ref: paletteContainerRef
305
+ }), jsxs("div", {
306
+ class: "fjs-pgl-main",
307
+ children: [jsxs(Section, {
308
+ name: "Form Definition",
309
+ children: [jsx(Section.HeaderItem, {
310
+ children: jsx("button", {
311
+ class: "fjs-pgl-button",
312
+ title: "Download form definition",
313
+ onClick: handleDownload,
314
+ children: "Download"
315
+ })
316
+ }), jsx(Section.HeaderItem, {
317
+ children: jsx("button", {
318
+ class: "fjs-pgl-button",
319
+ onClick: showEmbedModal,
320
+ children: "Embed"
321
+ })
322
+ }), jsx("div", {
323
+ ref: editorContainerRef,
324
+ class: "fjs-pgl-form-container"
325
+ })]
326
+ }), jsx(Section, {
327
+ name: "Form Preview",
328
+ children: jsx("div", {
329
+ ref: formContainerRef,
330
+ class: "fjs-pgl-form-container"
331
+ })
332
+ }), jsx(Section, {
333
+ name: "Form Data (Input)",
334
+ children: jsx("div", {
335
+ ref: dataContainerRef,
336
+ class: "fjs-pgl-text-container"
337
+ })
338
+ }), jsx(Section, {
339
+ name: "Form Data (Submit)",
340
+ children: jsx("div", {
341
+ ref: resultContainerRef,
342
+ class: "fjs-pgl-text-container"
343
+ })
344
+ })]
345
+ })]
346
+ });
347
+ } // helpers ///////////////
348
+
349
+ function toJSON(obj) {
350
+ return JSON.stringify(obj, null, ' ');
351
+ }
352
+
353
+ function Playground(options) {
354
+ const {
355
+ container: parent,
356
+ schema,
357
+ data
358
+ } = options;
359
+ const emitter = mitt();
360
+ let state = {
361
+ data,
362
+ schema
363
+ };
364
+ let ref;
365
+ const container = document.createElement('div');
366
+ container.classList.add('fjs-pgl-parent');
367
+ parent.appendChild(container);
368
+ const handleDrop = fileDrop('Drop a form file', function (files) {
369
+ const file = files[0];
370
+
371
+ if (file) {
372
+ try {
373
+ ref.setSchema(JSON.parse(file.contents));
374
+ } catch (err) {// TODO(nikku): indicate JSON parse error
375
+ }
376
+ }
377
+ });
378
+ container.addEventListener('dragover', handleDrop);
379
+ render(jsx(PlaygroundRoot, {
380
+ schema: schema,
381
+ data: data,
382
+ onStateChanged: _state => state = _state,
383
+ onInit: _ref => ref = _ref
384
+ }), container);
385
+ this.on = emitter.on;
386
+ this.off = emitter.off;
387
+ this.emit = emitter.emit;
388
+ this.on('destroy', function () {
389
+ render(null, container);
390
+ });
391
+ this.on('destroy', function () {
392
+ parent.removeChild(container);
393
+ });
394
+
395
+ this.getState = function () {
396
+ return state;
397
+ };
398
+
399
+ this.setSchema = function (schema) {
400
+ return ref.setSchema(schema);
401
+ };
402
+
403
+ this.destroy = function () {
404
+ this.emit('destroy');
405
+ };
406
+ }
407
+
408
+ export { Playground };
409
+ //# sourceMappingURL=index.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.es.js","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, EditorView } from '@codemirror/basic-setup';\nimport { EditorState, Compartment } from '@codemirror/state';\nimport { json } 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 function createState(doc, extensions = []) {\n return EditorState.create({\n doc,\n extensions: [\n basicSetup,\n language,\n tabSize,\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\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 {\n Form,\n FormEditor\n} from '@bpmn-io/form-js';\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 paletteContainerRef = useRef();\n const editorContainerRef = useRef();\n const formContainerRef = useRef();\n const dataContainerRef = useRef();\n const resultContainerRef = useRef();\n\n const formEditorRef = useRef();\n const formRef = useRef();\n const dataEditorRef = useRef();\n const resultViewRef = 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(props.data || {});\n\n useEffect(() => {\n props.onInit({\n setSchema: setInitialSchema\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 });\n\n formEditor.on('changed', () => {\n setSchema(formEditor.getSchema());\n });\n\n form.on('changed', event => {\n setResultData(event.data);\n });\n\n dataEditor.on('changed', event => {\n try {\n setData(JSON.parse(event.value));\n } catch (err) {\n\n // TODO(nikku): indicate JSON parse 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 formEditorRef.current.importSchema(initialSchema);\n }, [ initialSchema ]);\n\n useEffect(() => {\n 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=\"fjs-container fjs-pgl-root\">\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 <Section.HeaderItem>\n <button\n class=\"fjs-pgl-button\"\n title=\"Download form definition\"\n onClick={ handleDownload }\n >Download</button>\n </Section.HeaderItem>\n <Section.HeaderItem>\n <button\n class=\"fjs-pgl-button\"\n onClick={ showEmbedModal }\n >Embed</button>\n </Section.HeaderItem>\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>\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\nexport default function Playground(options) {\n\n const {\n container: parent,\n schema,\n data\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 parent.appendChild(container);\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 container.addEventListener('dragover', handleDrop);\n\n render(\n <PlaygroundRoot\n schema={ schema }\n data={ data }\n onStateChanged={ (_state) => state = _state }\n onInit={ _ref => ref = _ref }\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.setSchema = function(schema) {\n return ref.setSchema(schema);\n };\n\n this.destroy = function() {\n this.emit('destroy');\n };\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","createState","doc","extensions","create","basicSetup","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","paletteContainerRef","editorContainerRef","formContainerRef","dataContainerRef","resultContainerRef","formEditorRef","formRef","dataEditorRef","resultViewRef","showEmbed","setShowEmbed","useState","initialData","initialSchema","setInitialSchema","setData","setSchema","resultData","setResultData","onInit","dataEditor","toJSON","resultView","form","Form","formEditor","FormEditor","renderer","compact","palette","parent","getSchema","parse","err","formContainer","editorContainer","dataContainer","resultContainer","importSchema","onStateChanged","handleDownload","useCallback","download","hideEmbedModal","showEmbedModal","Playground","ref","createElement","classList","add","handleDrop","fileDrop","files","file","contents","render","_state","_ref","getState"],"mappings":";;;;;;;;;;;AAEO,SAASA,KAAT,CAAeC,KAAf,EAAsB;AAE3BC,EAAAA,SAAS,CAAC,MAAM;AACd,aAASC,SAAT,CAAmBC,KAAnB,EAA0B;AAExB,UAAIA,KAAK,CAACC,GAAN,KAAc,QAAlB,EAA4B;AAC1BD,QAAAA,KAAK,CAACE,eAAN;AAEAL,QAAAA,KAAK,CAACM,OAAN;AACD;AACF;;AAEDC,IAAAA,QAAQ,CAACC,gBAAT,CAA0B,SAA1B,EAAqCN,SAArC;AAEA,WAAO,MAAM;AACXK,MAAAA,QAAQ,CAACE,mBAAT,CAA6B,SAA7B,EAAwCP,SAAxC;AACD,KAFD;AAGD,GAfQ,CAAT;AAiBA,SACEQ;AAAK,IAAA,KAAK,EAAC,eAAX;AAAA,eACEC;AAAK,MAAA,KAAK,EAAC,wBAAX;AAAoC,MAAA,OAAO,EAAGX,KAAK,CAACM;AAApD,MADF,EAEEI;AAAK,MAAA,KAAK,EAAC,uBAAX;AAAA,iBACEC;AAAI,QAAA,KAAK,EAAC,sBAAV;AAAA,kBAAmCX,KAAK,CAACY;AAAzC,QADF,EAEED;AAAK,QAAA,KAAK,EAAC,oBAAX;AAAA,kBACIX,KAAK,CAACa;AADV,QAFF,EAKEF;AAAK,QAAA,KAAK,EAAC,sBAAX;AAAA,kBACEA;AAAQ,UAAA,KAAK,EAAC,uCAAd;AAAsD,UAAA,OAAO,EAAGX,KAAK,CAACM,OAAtE;AAAA;AAAA;AADF,QALF;AAAA,MAFF;AAAA,IADF;AAcD;;AC9BM,SAASQ,UAAT,CAAoBd,KAApB,EAA2B;AAEhC,QAAMe,MAAM,GAAGC,cAAc,CAAChB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AC5B8E,IAAAA,MAAM,CAAC,IAAD,EAAO3E,SAAP,CAAN;AACD,GAFD;AAIA,OAAKH,EAAL,CAAQ,SAAR,EAAmB,YAAW;AAC5BqD,IAAAA,MAAM,CAAC7C,WAAP,CAAmBL,SAAnB;AACD,GAFD;;AAIA,OAAK8E,QAAL,GAAgB,YAAW;AACzB,WAAOvF,KAAP;AACD,GAFD;;AAIA,OAAK6C,SAAL,GAAiB,UAASlF,MAAT,EAAiB;AAChC,WAAOgH,GAAG,CAAC9B,SAAJ,CAAclF,MAAd,CAAP;AACD,GAFD;;AAIA,OAAKiD,OAAL,GAAe,YAAW;AACxB,SAAKf,IAAL,CAAU,SAAV;AACD,GAFD;AAGD;;;;"}
package/package.json CHANGED
@@ -1,7 +1,10 @@
1
1
  {
2
2
  "name": "@bpmn-io/form-js-playground",
3
- "version": "0.7.1",
3
+ "version": "0.8.0-alpha.1",
4
4
  "description": "A form-js playground",
5
+ "files": [
6
+ "dist"
7
+ ],
5
8
  "exports": {
6
9
  ".": {
7
10
  "import": "./dist/index.es.js",
@@ -16,10 +19,12 @@
16
19
  "module": "dist/index.es.js",
17
20
  "umd:main": "dist/form-playground.umd.js",
18
21
  "scripts": {
19
- "all": "run-s test",
22
+ "all": "run-s test build",
23
+ "build": "rollup -c --failAfterWarnings",
20
24
  "start": "SINGLE_START=basic npm run dev",
21
25
  "dev": "npm test -- --auto-watch --no-single-run",
22
- "test": "karma start"
26
+ "test": "karma start",
27
+ "prepublishOnly": "npm run build"
23
28
  },
24
29
  "license": "SEE LICENSE IN LICENSE",
25
30
  "repository": {
@@ -32,7 +37,7 @@
32
37
  "url": "https://github.com/bpmn-io"
33
38
  },
34
39
  "dependencies": {
35
- "@bpmn-io/form-js": "^0.7.1",
40
+ "@bpmn-io/form-js": "^0.8.0-alpha.1",
36
41
  "@codemirror/basic-setup": "^0.18.2",
37
42
  "@codemirror/lang-json": "^0.18.0",
38
43
  "@codemirror/state": "^0.18.7",
@@ -49,5 +54,5 @@
49
54
  "rollup-plugin-css-only": "^3.1.0",
50
55
  "style-loader": "^3.3.0"
51
56
  },
52
- "gitHead": "75a12520e4a55c2d3b4fcab6464fe86026ba40b2"
57
+ "gitHead": "2be914efeefa050fb4692ac1a644557fc424917f"
53
58
  }
package/karma.conf.js DELETED
@@ -1,100 +0,0 @@
1
- const coverage = process.env.COVERAGE;
2
-
3
- // configures browsers to run test against
4
- // any of [ 'ChromeHeadless', 'Chrome', 'Firefox', 'IE', 'PhantomJS' ]
5
- const browsers = (process.env.TEST_BROWSERS || 'ChromeHeadless').split(',');
6
-
7
- const singleStart = process.env.SINGLE_START;
8
-
9
- // use puppeteer provided Chrome for testing
10
- process.env.CHROME_BIN = require('puppeteer').executablePath();
11
-
12
- const suite = coverage ? 'test/coverageBundle.js' : 'test/testBundle.js';
13
-
14
- module.exports = function(karma) {
15
-
16
- const config = {
17
-
18
- frameworks: [
19
- 'webpack',
20
- 'mocha',
21
- 'sinon-chai'
22
- ],
23
-
24
- files: [
25
- suite
26
- ],
27
-
28
- preprocessors: {
29
- [ suite ]: [ 'webpack', 'env' ]
30
- },
31
-
32
- reporters: [ 'progress' ].concat(coverage ? 'coverage' : []),
33
-
34
- coverageReporter: {
35
- reporters: [
36
- { type: 'lcovonly', subdir: '.' },
37
- ]
38
- },
39
-
40
- browsers,
41
-
42
- singleRun: true,
43
- autoWatch: false,
44
-
45
- webpack: {
46
- mode: 'development',
47
- resolve: {
48
- modules: [
49
- 'node_modules',
50
- __dirname
51
- ]
52
- },
53
- module: {
54
- rules: [
55
- {
56
- test: /\.css$/i,
57
- use: [
58
- 'style-loader',
59
- 'css-loader'
60
- ]
61
- },
62
- {
63
- test: /\.m?js$/,
64
- exclude: /node_modules/,
65
- use: {
66
- loader: 'babel-loader',
67
- options: {
68
- plugins: [
69
- [ '@babel/plugin-transform-react-jsx', {
70
- 'importSource': 'preact',
71
- 'runtime': 'automatic'
72
- } ]
73
- ]
74
- }
75
- }
76
- }
77
- ].concat(coverage ?
78
- {
79
- test: /\.js$/,
80
- use: {
81
- loader: 'istanbul-instrumenter-loader',
82
- options: { esModules: true }
83
- },
84
- enforce: 'post',
85
- include: /src\.*/,
86
- exclude: /node_modules/
87
- } : []
88
- )
89
- },
90
- devtool: 'eval-source-map'
91
- }
92
- };
93
-
94
- if (singleStart) {
95
- config.browsers = [].concat(config.browsers, 'Debug');
96
- config.envPreprocessor = [].concat(config.envPreprocessor || [], 'SINGLE_START');
97
- }
98
-
99
- karma.set(config);
100
- };
Binary file
package/rollup.config.js DELETED
@@ -1,60 +0,0 @@
1
- import css from 'rollup-plugin-css-only';
2
-
3
- import babel from '@rollup/plugin-babel';
4
-
5
- import commonjs from '@rollup/plugin-commonjs';
6
- import resolve from '@rollup/plugin-node-resolve';
7
-
8
- import pkg from './package.json';
9
-
10
- function pgl(plugins=[]) {
11
- return [
12
- babel({
13
- babelHelpers: 'bundled',
14
- plugins: [
15
- [ '@babel/plugin-transform-react-jsx', {
16
- 'importSource': 'preact',
17
- 'runtime': 'automatic'
18
- } ]
19
- ]
20
- }),
21
- css({
22
- output: 'assets/form-js-playground.css'
23
- }),
24
- ...plugins
25
- ];
26
-
27
- }
28
-
29
- export default [
30
- {
31
- input: 'src/index.js',
32
- output: [
33
- {
34
- sourcemap: true,
35
- format: 'commonjs',
36
- file: pkg.main
37
- },
38
- {
39
- sourcemap: true,
40
- format: 'esm',
41
- file: pkg.module
42
- }
43
- ],
44
- plugins: pgl()
45
- },
46
- {
47
- input: 'src/index.js',
48
- output: [
49
- {
50
- format: 'umd',
51
- file: pkg['umd:main'],
52
- name: 'FormPlayground'
53
- }
54
- ],
55
- plugins: pgl([
56
- resolve(),
57
- commonjs()
58
- ])
59
- }
60
- ];