@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.
package/dist/index.cjs ADDED
@@ -0,0 +1,419 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var preact = require('preact');
6
+ var fileDrop = require('file-drops');
7
+ var mitt = require('mitt');
8
+ var hooks = require('preact/hooks');
9
+ var download = require('downloadjs');
10
+ var formJs = require('@bpmn-io/form-js');
11
+ var jsxRuntime = require('preact/jsx-runtime');
12
+ var basicSetup = require('@codemirror/basic-setup');
13
+ var state = require('@codemirror/state');
14
+ var langJson = require('@codemirror/lang-json');
15
+
16
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
17
+
18
+ var fileDrop__default = /*#__PURE__*/_interopDefaultLegacy(fileDrop);
19
+ var mitt__default = /*#__PURE__*/_interopDefaultLegacy(mitt);
20
+ var download__default = /*#__PURE__*/_interopDefaultLegacy(download);
21
+
22
+ function Modal(props) {
23
+ hooks.useEffect(() => {
24
+ function handleKey(event) {
25
+ if (event.key === 'Escape') {
26
+ event.stopPropagation();
27
+ props.onClose();
28
+ }
29
+ }
30
+
31
+ document.addEventListener('keydown', handleKey);
32
+ return () => {
33
+ document.removeEventListener('keydown', handleKey);
34
+ };
35
+ });
36
+ return jsxRuntime.jsxs("div", {
37
+ class: "fjs-pgl-modal",
38
+ children: [jsxRuntime.jsx("div", {
39
+ class: "fjs-pgl-modal-backdrop",
40
+ onClick: props.onClose
41
+ }), jsxRuntime.jsxs("div", {
42
+ class: "fjs-pgl-modal-content",
43
+ children: [jsxRuntime.jsx("h1", {
44
+ class: "fjs-pgl-modal-header",
45
+ children: props.name
46
+ }), jsxRuntime.jsx("div", {
47
+ class: "fjs-pgl-modal-body",
48
+ children: props.children
49
+ }), jsxRuntime.jsx("div", {
50
+ class: "fjs-pgl-modal-footer",
51
+ children: jsxRuntime.jsx("button", {
52
+ class: "fjs-pgl-button fjs-pgl-button-default",
53
+ onClick: props.onClose,
54
+ children: "Close"
55
+ })
56
+ })]
57
+ })]
58
+ });
59
+ }
60
+
61
+ function EmbedModal(props) {
62
+ const schema = serializeValue(props.schema);
63
+ const data = serializeValue(props.data || {});
64
+ const fieldRef = hooks.useRef();
65
+ const snippet = `<!-- styles needed for rendering -->
66
+ <link rel="stylesheet" href="https://unpkg.com/@bpmn-io/form-js@0.2.4/dist/assets/form-js.css">
67
+
68
+ <!-- container to render the form into -->
69
+ <div class="fjs-pgl-form-container"></div>
70
+
71
+ <!-- scripts needed for embedding -->
72
+ <script src="https://unpkg.com/@bpmn-io/form-js@0.2.4/dist/form-viewer.umd.js"></script>
73
+
74
+ <!-- actual script to instantiate the form and load form schema + data -->
75
+ <script>
76
+ const data = JSON.parse(${data});
77
+ const schema = JSON.parse(${schema});
78
+
79
+ const form = new FormViewer.Form({
80
+ container: document.querySelector(".fjs-pgl-form-container")
81
+ });
82
+
83
+ form.on("submit", (event) => {
84
+ console.log(event.data, event.errors);
85
+ });
86
+
87
+ form.importSchema(schema, data).catch(err => {
88
+ console.error("Failed to render form", err);
89
+ });
90
+ </script>
91
+ `.trim();
92
+ hooks.useEffect(() => {
93
+ fieldRef.current.select();
94
+ });
95
+ return jsxRuntime.jsxs(Modal, {
96
+ name: "Embed form",
97
+ onClose: props.onClose,
98
+ children: [jsxRuntime.jsxs("p", {
99
+ children: ["Use the following HTML snippet to embed your form with ", jsxRuntime.jsx("a", {
100
+ href: "https://github.com/bpmn-io/form-js",
101
+ children: "form-js"
102
+ }), ":"]
103
+ }), jsxRuntime.jsx("textarea", {
104
+ spellCheck: "false",
105
+ ref: fieldRef,
106
+ children: snippet
107
+ })]
108
+ });
109
+ } // helpers ///////////
110
+
111
+ function serializeValue(obj) {
112
+ return JSON.stringify(JSON.stringify(obj)).replace(/</g, '&lt;').replace(/>/g, '&gt;');
113
+ }
114
+
115
+ function JSONEditor(options = {}) {
116
+ const emitter = mitt__default['default']();
117
+ const {
118
+ readonly = false
119
+ } = options;
120
+ let language = new state.Compartment().of(langJson.json());
121
+ let tabSize = new state.Compartment().of(state.EditorState.tabSize.of(2));
122
+
123
+ function createState(doc, extensions = []) {
124
+ return state.EditorState.create({
125
+ doc,
126
+ extensions: [basicSetup.basicSetup, language, tabSize, ...extensions]
127
+ });
128
+ }
129
+
130
+ function createView(readonly) {
131
+ const updateListener = basicSetup.EditorView.updateListener.of(update => {
132
+ if (update.docChanged) {
133
+ emitter.emit('changed', {
134
+ value: update.view.state.doc.toString()
135
+ });
136
+ }
137
+ });
138
+ const editable = basicSetup.EditorView.editable.of(!readonly);
139
+ const view = new basicSetup.EditorView({
140
+ state: createState('', [updateListener, editable])
141
+ });
142
+
143
+ view.setValue = function (value) {
144
+ this.setState(createState(value, [updateListener, editable]));
145
+ };
146
+
147
+ return view;
148
+ }
149
+
150
+ const view = createView(readonly);
151
+
152
+ this.setValue = function (value) {
153
+ view.setValue(value);
154
+ };
155
+
156
+ this.getValue = function () {
157
+ return view.state.doc.toString();
158
+ };
159
+
160
+ this.on = emitter.on;
161
+ this.off = emitter.off;
162
+
163
+ this.attachTo = function (container) {
164
+ container.appendChild(view.dom);
165
+ };
166
+
167
+ this.destroy = function () {
168
+ if (view.dom.parentNode) {
169
+ view.dom.parentNode.removeChild(view.dom);
170
+ }
171
+
172
+ view.destroy();
173
+ };
174
+ }
175
+
176
+ function Section(props) {
177
+ const elements = Array.isArray(props.children) ? props.children : [props.children];
178
+ const {
179
+ headerItems,
180
+ children
181
+ } = elements.reduce((_, child) => {
182
+ const bucket = child.type === Section.HeaderItem ? _.headerItems : _.children;
183
+ bucket.push(child);
184
+ return _;
185
+ }, {
186
+ headerItems: [],
187
+ children: []
188
+ });
189
+ return jsxRuntime.jsxs("div", {
190
+ class: "fjs-pgl-section",
191
+ children: [jsxRuntime.jsxs("h1", {
192
+ class: "header",
193
+ children: [props.name, " ", headerItems.length ? jsxRuntime.jsx("span", {
194
+ class: "header-items",
195
+ children: headerItems
196
+ }) : null]
197
+ }), jsxRuntime.jsx("div", {
198
+ class: "body",
199
+ children: children
200
+ })]
201
+ });
202
+ }
203
+
204
+ Section.HeaderItem = function (props) {
205
+ return props.children;
206
+ };
207
+
208
+ function PlaygroundRoot(props) {
209
+ const paletteContainerRef = hooks.useRef();
210
+ const editorContainerRef = hooks.useRef();
211
+ const formContainerRef = hooks.useRef();
212
+ const dataContainerRef = hooks.useRef();
213
+ const resultContainerRef = hooks.useRef();
214
+ const formEditorRef = hooks.useRef();
215
+ const formRef = hooks.useRef();
216
+ const dataEditorRef = hooks.useRef();
217
+ const resultViewRef = hooks.useRef();
218
+ const [showEmbed, setShowEmbed] = hooks.useState(false);
219
+ const [initialData] = hooks.useState(props.data || {});
220
+ const [initialSchema, setInitialSchema] = hooks.useState(props.schema);
221
+ const [data, setData] = hooks.useState(props.data || {});
222
+ const [schema, setSchema] = hooks.useState(props.schema);
223
+ const [resultData, setResultData] = hooks.useState(props.data || {});
224
+ hooks.useEffect(() => {
225
+ props.onInit({
226
+ setSchema: setInitialSchema
227
+ });
228
+ });
229
+ hooks.useEffect(() => {
230
+ setInitialSchema(props.schema || {});
231
+ }, [props.schema]);
232
+ hooks.useEffect(() => {
233
+ const dataEditor = dataEditorRef.current = new JSONEditor({
234
+ value: toJSON(data)
235
+ });
236
+ const resultView = resultViewRef.current = new JSONEditor({
237
+ readonly: true,
238
+ value: toJSON(resultData)
239
+ });
240
+ const form = formRef.current = new formJs.Form();
241
+ const formEditor = formEditorRef.current = new formJs.FormEditor({
242
+ renderer: {
243
+ compact: true
244
+ },
245
+ palette: {
246
+ parent: paletteContainerRef.current
247
+ }
248
+ });
249
+ formEditor.on('changed', () => {
250
+ setSchema(formEditor.getSchema());
251
+ });
252
+ form.on('changed', event => {
253
+ setResultData(event.data);
254
+ });
255
+ dataEditor.on('changed', event => {
256
+ try {
257
+ setData(JSON.parse(event.value));
258
+ } catch (err) {// TODO(nikku): indicate JSON parse error
259
+ }
260
+ });
261
+ const formContainer = formContainerRef.current;
262
+ const editorContainer = editorContainerRef.current;
263
+ const dataContainer = dataContainerRef.current;
264
+ const resultContainer = resultContainerRef.current;
265
+ dataEditor.attachTo(dataContainer);
266
+ resultView.attachTo(resultContainer);
267
+ form.attachTo(formContainer);
268
+ formEditor.attachTo(editorContainer);
269
+ return () => {
270
+ dataEditor.destroy();
271
+ resultView.destroy();
272
+ form.destroy();
273
+ formEditor.destroy();
274
+ };
275
+ }, []);
276
+ hooks.useEffect(() => {
277
+ dataEditorRef.current.setValue(toJSON(initialData));
278
+ }, [initialData]);
279
+ hooks.useEffect(() => {
280
+ formEditorRef.current.importSchema(initialSchema);
281
+ }, [initialSchema]);
282
+ hooks.useEffect(() => {
283
+ formRef.current.importSchema(schema, data);
284
+ }, [schema, data]);
285
+ hooks.useEffect(() => {
286
+ resultViewRef.current.setValue(toJSON(resultData));
287
+ }, [resultData]);
288
+ hooks.useEffect(() => {
289
+ props.onStateChanged({
290
+ schema,
291
+ data
292
+ });
293
+ }, [schema, data]);
294
+ const handleDownload = hooks.useCallback(() => {
295
+ download__default['default'](JSON.stringify(schema, null, ' '), 'form.json', 'text/json');
296
+ }, [schema]);
297
+ const hideEmbedModal = hooks.useCallback(() => {
298
+ setShowEmbed(false);
299
+ }, []);
300
+ const showEmbedModal = hooks.useCallback(() => {
301
+ setShowEmbed(true);
302
+ }, []);
303
+ return jsxRuntime.jsxs("div", {
304
+ class: "fjs-container fjs-pgl-root",
305
+ children: [jsxRuntime.jsx("div", {
306
+ class: "fjs-pgl-modals",
307
+ children: showEmbed ? jsxRuntime.jsx(EmbedModal, {
308
+ schema: schema,
309
+ data: data,
310
+ onClose: hideEmbedModal
311
+ }) : null
312
+ }), jsxRuntime.jsx("div", {
313
+ class: "fjs-pgl-palette-container",
314
+ ref: paletteContainerRef
315
+ }), jsxRuntime.jsxs("div", {
316
+ class: "fjs-pgl-main",
317
+ children: [jsxRuntime.jsxs(Section, {
318
+ name: "Form Definition",
319
+ children: [jsxRuntime.jsx(Section.HeaderItem, {
320
+ children: jsxRuntime.jsx("button", {
321
+ class: "fjs-pgl-button",
322
+ title: "Download form definition",
323
+ onClick: handleDownload,
324
+ children: "Download"
325
+ })
326
+ }), jsxRuntime.jsx(Section.HeaderItem, {
327
+ children: jsxRuntime.jsx("button", {
328
+ class: "fjs-pgl-button",
329
+ onClick: showEmbedModal,
330
+ children: "Embed"
331
+ })
332
+ }), jsxRuntime.jsx("div", {
333
+ ref: editorContainerRef,
334
+ class: "fjs-pgl-form-container"
335
+ })]
336
+ }), jsxRuntime.jsx(Section, {
337
+ name: "Form Preview",
338
+ children: jsxRuntime.jsx("div", {
339
+ ref: formContainerRef,
340
+ class: "fjs-pgl-form-container"
341
+ })
342
+ }), jsxRuntime.jsx(Section, {
343
+ name: "Form Data (Input)",
344
+ children: jsxRuntime.jsx("div", {
345
+ ref: dataContainerRef,
346
+ class: "fjs-pgl-text-container"
347
+ })
348
+ }), jsxRuntime.jsx(Section, {
349
+ name: "Form Data (Submit)",
350
+ children: jsxRuntime.jsx("div", {
351
+ ref: resultContainerRef,
352
+ class: "fjs-pgl-text-container"
353
+ })
354
+ })]
355
+ })]
356
+ });
357
+ } // helpers ///////////////
358
+
359
+ function toJSON(obj) {
360
+ return JSON.stringify(obj, null, ' ');
361
+ }
362
+
363
+ function Playground(options) {
364
+ const {
365
+ container: parent,
366
+ schema,
367
+ data
368
+ } = options;
369
+ const emitter = mitt__default['default']();
370
+ let state = {
371
+ data,
372
+ schema
373
+ };
374
+ let ref;
375
+ const container = document.createElement('div');
376
+ container.classList.add('fjs-pgl-parent');
377
+ parent.appendChild(container);
378
+ const handleDrop = fileDrop__default['default']('Drop a form file', function (files) {
379
+ const file = files[0];
380
+
381
+ if (file) {
382
+ try {
383
+ ref.setSchema(JSON.parse(file.contents));
384
+ } catch (err) {// TODO(nikku): indicate JSON parse error
385
+ }
386
+ }
387
+ });
388
+ container.addEventListener('dragover', handleDrop);
389
+ preact.render(jsxRuntime.jsx(PlaygroundRoot, {
390
+ schema: schema,
391
+ data: data,
392
+ onStateChanged: _state => state = _state,
393
+ onInit: _ref => ref = _ref
394
+ }), container);
395
+ this.on = emitter.on;
396
+ this.off = emitter.off;
397
+ this.emit = emitter.emit;
398
+ this.on('destroy', function () {
399
+ preact.render(null, container);
400
+ });
401
+ this.on('destroy', function () {
402
+ parent.removeChild(container);
403
+ });
404
+
405
+ this.getState = function () {
406
+ return state;
407
+ };
408
+
409
+ this.setSchema = function (schema) {
410
+ return ref.setSchema(schema);
411
+ };
412
+
413
+ this.destroy = function () {
414
+ this.emit('destroy');
415
+ };
416
+ }
417
+
418
+ exports.Playground = Playground;
419
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +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, 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,eAAS,CAAC,MAAM;AACd,aAASC,SAAT,CAAmBC,KAAnB,EAA0B;AAExB,UAAIA,KAAK,CAACC,GAAN,KAAc,QAAlB,EAA4B;AAC1BD,QAAAA,KAAK,CAACE,eAAN;AAEAL,QAAAA,KAA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