From be61222225ddd5dd42f9d8ea27420fbb42b75cfc Mon Sep 17 00:00:00 2001 From: jos Date: Thu, 29 Aug 2019 17:03:09 +0200 Subject: [PATCH] Partial refactor to ES modules --- .babelrc | 5 + gulpfile.js | 5 +- package-lock.json | 35 ++++++ package.json | 3 +- src/js/ContextMenu.js | 18 +-- src/js/ErrorTable.js | 4 +- src/js/Highlighter.js | 4 +- src/js/History.js | 4 +- src/js/ModeSwitcher.js | 2 +- src/js/Node.js | 8 +- src/js/NodeHistory.js | 8 +- src/js/SearchBox.js | 4 +- src/js/TreePath.js | 14 +-- src/js/appendNodeFactory.js | 2 +- src/js/autocomplete.js | 4 +- src/js/constants.js | 10 +- src/js/createAbsoluteAnchor.js | 14 +-- src/js/i18n.js | 82 +++++++------- src/js/jsonUtils.js | 7 +- src/js/previewmode.js | 11 +- src/js/showMoreNodeFactory.js | 6 +- src/js/showSortModal.js | 14 +-- src/js/showTransformModal.js | 29 +++-- src/js/textmode.js | 6 +- src/js/treemode.js | 12 +- src/js/util.js | 195 ++++++++++++++++++--------------- src/js/validationUtils.js | 10 +- 27 files changed, 268 insertions(+), 248 deletions(-) create mode 100644 .babelrc diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..b18b30c --- /dev/null +++ b/.babelrc @@ -0,0 +1,5 @@ +{ + "presets": [ + ["@babel/preset-env"] + ] +} \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index cb02d8d..eca11a7 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -40,10 +40,7 @@ var webpackConfigModule = { test: /\.m?js$/, exclude: /node_modules/, use: { - loader: 'babel-loader', - options: { - presets: ['@babel/preset-env'] - } + loader: 'babel-loader' } } ] diff --git a/package-lock.json b/package-lock.json index 03bb3f5..c66490b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -758,6 +758,20 @@ "semver": "^5.5.0" } }, + "@babel/register": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/register/-/register-7.5.5.tgz", + "integrity": "sha512-pdd5nNR+g2qDkXZlW1yRCWFlNrAn2PPdnZUB72zjX4l1Vv4fMRRLwyf+n/idFCLI1UgVGboUU8oVziwTBiyNKQ==", + "dev": true, + "requires": { + "core-js": "^3.0.0", + "find-cache-dir": "^2.0.0", + "lodash": "^4.17.13", + "mkdirp": "^0.5.1", + "pirates": "^4.0.0", + "source-map-support": "^0.5.9" + } + }, "@babel/template": { "version": "7.4.4", "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.4.4.tgz", @@ -2233,6 +2247,12 @@ "is-plain-object": "^2.0.1" } }, + "core-js": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.2.1.tgz", + "integrity": "sha512-Qa5XSVefSVPRxy2XfUC13WbvqkxhkwB3ve+pgCQveNgYzbM/UxZeu1dcOX/xr4UmfUd+muuvsaxilQzCyUurMw==", + "dev": true + }, "core-js-compat": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.2.1.tgz", @@ -6569,6 +6589,12 @@ } } }, + "node-modules-regexp": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/node-modules-regexp/-/node-modules-regexp-1.0.0.tgz", + "integrity": "sha1-jZ2+KJZKSsVxLpExZCEHxx6Q7EA=", + "dev": true + }, "node-releases": { "version": "1.1.28", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.28.tgz", @@ -7216,6 +7242,15 @@ "pinkie": "^2.0.0" } }, + "pirates": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.1.tgz", + "integrity": "sha512-WuNqLTbMI3tmfef2TKxlQmAiLHKtFhlsCZnPIpuv2Ow0RDVO8lfy1Opf4NUzlMXLjPl+Men7AuVdX6TA+s+uGA==", + "dev": true, + "requires": { + "node-modules-regexp": "^1.0.0" + } + }, "pkg-conf": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/pkg-conf/-/pkg-conf-3.1.0.tgz", diff --git a/package.json b/package.json index bb7c45d..5b6f095 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "build": "gulp", "minify": "gulp minify", "start": "gulp watch", - "test": "mocha test", + "test": "mocha test --require @babel/register", "lint": "standard --env=mocha" }, "dependencies": { @@ -37,6 +37,7 @@ "devDependencies": { "@babel/core": "7.5.5", "@babel/preset-env": "7.5.5", + "@babel/register": "7.5.5", "babel-loader": "8.0.6", "date-format": "2.1.0", "fancy-log": "1.3.3", diff --git a/src/js/ContextMenu.js b/src/js/ContextMenu.js index de0d00f..51a660f 100644 --- a/src/js/ContextMenu.js +++ b/src/js/ContextMenu.js @@ -1,8 +1,8 @@ 'use strict' -const createAbsoluteAnchor = require('./createAbsoluteAnchor').createAbsoluteAnchor -const util = require('./util') -const translate = require('./i18n').translate +import { createAbsoluteAnchor } from './createAbsoluteAnchor' +import { addClassName, getSelection, removeClassName, setSelection } from './util' +import { translate } from './i18n' /** * A context menu @@ -13,7 +13,7 @@ const translate = require('./i18n').translate * context menu is being closed. * @constructor */ -function ContextMenu (items, options) { +export function ContextMenu (items, options) { this.dom = {} const me = this @@ -241,7 +241,7 @@ ContextMenu.prototype.show = function (anchor, frame, ignoreParent) { this.dom.absoluteAnchor.appendChild(this.dom.root) // move focus to the first button in the context menu - this.selection = util.getSelection() + this.selection = getSelection() this.anchor = anchor setTimeout(() => { me.dom.focusButton.focus() @@ -295,7 +295,7 @@ ContextMenu.prototype._onExpandItem = function (domItem) { setTimeout(() => { if (me.expandedItem !== expandedItem) { expandedItem.ul.style.display = '' - util.removeClassName(expandedItem.ul.parentNode, 'jsoneditor-selected') + removeClassName(expandedItem.ul.parentNode, 'jsoneditor-selected') } }, 300) // timeout duration must match the css transition duration this.expandedItem = undefined @@ -316,7 +316,7 @@ ContextMenu.prototype._onExpandItem = function (domItem) { ul.style.padding = '5px 10px' } }, 0) - util.addClassName(ul.parentNode, 'jsoneditor-selected') + addClassName(ul.parentNode, 'jsoneditor-selected') this.expandedItem = domItem } } @@ -337,7 +337,7 @@ ContextMenu.prototype._onKeyDown = function (event) { // restore previous selection and focus if (this.selection) { - util.setSelection(this.selection) + setSelection(this.selection) } if (this.anchor) { this.anchor.focus() @@ -424,4 +424,4 @@ ContextMenu.prototype._onKeyDown = function (event) { } } -module.exports = ContextMenu +export default ContextMenu; diff --git a/src/js/ErrorTable.js b/src/js/ErrorTable.js index 3675467..5d68ee0 100644 --- a/src/js/ErrorTable.js +++ b/src/js/ErrorTable.js @@ -7,7 +7,7 @@ * @property {function (number)} onChangeHeight * @constructor */ -function ErrorTable (config) { +export function ErrorTable (config) { this.errorTableVisible = config.errorTableVisible this.onToggleVisibility = config.onToggleVisibility this.onFocusLine = config.onFocusLine || (() => {}) @@ -166,5 +166,3 @@ ErrorTable.prototype.setErrors = function (errors, errorLocations) { this.dom.parseErrorIndication.style.display = 'none' } } - -module.exports = ErrorTable diff --git a/src/js/Highlighter.js b/src/js/Highlighter.js index ba18b98..0081d1b 100644 --- a/src/js/Highlighter.js +++ b/src/js/Highlighter.js @@ -5,7 +5,7 @@ * animate the visibility of a context menu. * @constructor Highlighter */ -function Highlighter () { +export function Highlighter () { this.locked = false } @@ -82,5 +82,3 @@ Highlighter.prototype.lock = function () { Highlighter.prototype.unlock = function () { this.locked = false } - -module.exports = Highlighter diff --git a/src/js/History.js b/src/js/History.js index f7b2a2c..a7e0756 100644 --- a/src/js/History.js +++ b/src/js/History.js @@ -6,7 +6,7 @@ * @param {number} limit Maximum size of all items in history * @constructor */ -function History (onChange, calculateItemSize, limit) { +export function History (onChange, calculateItemSize, limit) { this.onChange = onChange this.calculateItemSize = calculateItemSize || (() => 1) this.limit = limit @@ -81,5 +81,3 @@ History.prototype.clear = function () { this.onChange() } - -module.exports = History diff --git a/src/js/ModeSwitcher.js b/src/js/ModeSwitcher.js index 4e0e5e8..5f946ec 100644 --- a/src/js/ModeSwitcher.js +++ b/src/js/ModeSwitcher.js @@ -1,6 +1,6 @@ 'use strict' -const ContextMenu = require('./ContextMenu') +const ContextMenu = require('./ContextMenu').ContextMenu const translate = require('./i18n').translate /** diff --git a/src/js/Node.js b/src/js/Node.js index 5e7b1d2..9da1e6c 100644 --- a/src/js/Node.js +++ b/src/js/Node.js @@ -3,11 +3,11 @@ const jmespath = require('jmespath') const naturalSort = require('javascript-natural-sort') const createAbsoluteAnchor = require('./createAbsoluteAnchor').createAbsoluteAnchor -const ContextMenu = require('./ContextMenu') +const ContextMenu = require('./ContextMenu').ContextMenu const appendNodeFactory = require('./appendNodeFactory') -const showMoreNodeFactory = require('./showMoreNodeFactory') -const showSortModal = require('./showSortModal') -const showTransformModal = require('./showTransformModal') +const showMoreNodeFactory = require('./showMoreNodeFactory').showMoreNodeFactory +const showSortModal = require('./showSortModal').showSortModal +const showTransformModal = require('./showTransformModal').showTransformModal const util = require('./util') const translate = require('./i18n').translate const DEFAULT_MODAL_ANCHOR = require('./constants').DEFAULT_MODAL_ANCHOR diff --git a/src/js/NodeHistory.js b/src/js/NodeHistory.js index 711c2ed..1457cfa 100644 --- a/src/js/NodeHistory.js +++ b/src/js/NodeHistory.js @@ -1,13 +1,13 @@ 'use strict' -const util = require('./util') +import { findUniqueName } from './util' /** * @constructor History * Store action history, enables undo and redo * @param {JSONEditor} editor */ -function NodeHistory (editor) { +export function NodeHistory (editor) { this.editor = editor this.history = [] this.index = -1 @@ -125,7 +125,7 @@ function NodeHistory (editor) { const clone = node.clone() if (parentNode.type === 'object') { const existingFieldNames = parentNode.getFieldNames() - clone.field = util.findUniqueName(node.field, existingFieldNames) + clone.field = findUniqueName(node.field, existingFieldNames) } parentNode.insertAfter(clone, afterNode) afterNode = clone @@ -329,5 +329,3 @@ NodeHistory.prototype.destroy = function () { this.history = [] this.index = -1 } - -module.exports = NodeHistory diff --git a/src/js/SearchBox.js b/src/js/SearchBox.js index 4a2513f..1447399 100644 --- a/src/js/SearchBox.js +++ b/src/js/SearchBox.js @@ -7,7 +7,7 @@ * @param {Element} container HTML container element of where to * create the search box */ -function SearchBox (editor, container) { +export function SearchBox (editor, container) { const searchBox = this this.editor = editor @@ -319,5 +319,3 @@ SearchBox.prototype.destroy = function () { this._clearDelay() } - -module.exports = SearchBox diff --git a/src/js/TreePath.js b/src/js/TreePath.js index 6035174..0b3983d 100644 --- a/src/js/TreePath.js +++ b/src/js/TreePath.js @@ -1,8 +1,8 @@ 'use strict' -const ContextMenu = require('./ContextMenu') -const translate = require('./i18n').translate -const util = require('./util') +import { ContextMenu } from './ContextMenu' +import { translate } from './i18n' +import { addClassName, removeClassName } from './util' /** * Creates a component that visualize path selection in tree based editors @@ -10,7 +10,7 @@ const util = require('./util') * @param {HTMLElement} root * @constructor */ -function TreePath (container, root) { +export function TreePath (container, root) { if (container) { this.root = root this.path = document.createElement('div') @@ -91,7 +91,7 @@ TreePath.prototype.setPath = function (pathObjs) { function _onShowAllClick (pathObjs) { me.contentMenuClicked = false - util.addClassName(me.path, 'show-all') + addClassName(me.path, 'show-all') me.path.style.width = me.path.parentNode.getBoundingClientRect().width - 10 + 'px' me.path.onblur = () => { if (me.contentMenuClicked) { @@ -99,7 +99,7 @@ TreePath.prototype.setPath = function (pathObjs) { me.path.focus() return } - util.removeClassName(me.path, 'show-all') + removeClassName(me.path, 'show-all') me.path.onblur = undefined me.path.style.width = '' me.setPath(pathObjs) @@ -138,5 +138,3 @@ TreePath.prototype.onContextMenuItemSelected = function (callback) { this.contextMenuCallback = callback } } - -module.exports = TreePath diff --git a/src/js/appendNodeFactory.js b/src/js/appendNodeFactory.js index 65a7f8d..d013c60 100644 --- a/src/js/appendNodeFactory.js +++ b/src/js/appendNodeFactory.js @@ -1,7 +1,7 @@ 'use strict' const util = require('./util') -const ContextMenu = require('./ContextMenu') +const ContextMenu = require('./ContextMenu').ContextMenu const translate = require('./i18n').translate /** diff --git a/src/js/autocomplete.js b/src/js/autocomplete.js index b03f65f..692f84b 100644 --- a/src/js/autocomplete.js +++ b/src/js/autocomplete.js @@ -9,7 +9,7 @@ const defaultFilterFunction = { } } -function completely (config) { +export function autocomplete (config) { config = config || {} config.filter = config.filter || 'start' config.trigger = config.trigger || 'keydown' @@ -379,5 +379,3 @@ function completely (config) { return rs } - -module.exports = completely diff --git a/src/js/constants.js b/src/js/constants.js index 8a11c58..7bd6484 100644 --- a/src/js/constants.js +++ b/src/js/constants.js @@ -1,7 +1,5 @@ -exports.DEFAULT_MODAL_ANCHOR = document.body -exports.SIZE_LARGE = 10 * 1024 * 1024 // 10 MB - -exports.MAX_PREVIEW_CHARACTERS = 20000 - -exports.PREVIEW_HISTORY_LIMIT = 2 * 1024 * 1024 * 1024 // 2 GB +export var DEFAULT_MODAL_ANCHOR = document.body; +export var SIZE_LARGE = 10 * 1024 * 1024; // 10 MB +export var MAX_PREVIEW_CHARACTERS = 20000; +export var PREVIEW_HISTORY_LIMIT = 2 * 1024 * 1024 * 1024; // 2 GB diff --git a/src/js/createAbsoluteAnchor.js b/src/js/createAbsoluteAnchor.js index 614caae..cdfc18e 100644 --- a/src/js/createAbsoluteAnchor.js +++ b/src/js/createAbsoluteAnchor.js @@ -1,4 +1,4 @@ -const util = require('./util') +import { isChildOf, removeEventListener, addEventListener } from './util' /** * Create an anchor element absolutely positioned in the `parent` @@ -8,7 +8,7 @@ const util = require('./util') * @param [onDestroy(function(anchor)] Callback when the anchor is destroyed * @returns {HTMLElement} */ -exports.createAbsoluteAnchor = (anchor, parent, onDestroy) => { +export function createAbsoluteAnchor(anchor, parent, onDestroy) { const root = getRootNode(anchor) const eventListeners = {} @@ -36,7 +36,7 @@ exports.createAbsoluteAnchor = (anchor, parent, onDestroy) => { if (hasOwnProperty(eventListeners, name)) { const fn = eventListeners[name] if (fn) { - util.removeEventListener(root, name, fn) + removeEventListener(root, name, fn) } delete eventListeners[name] } @@ -51,14 +51,14 @@ exports.createAbsoluteAnchor = (anchor, parent, onDestroy) => { // create and attach event listeners const destroyIfOutside = event => { const target = event.target - if ((target !== absoluteAnchor) && !util.isChildOf(target, absoluteAnchor)) { + if ((target !== absoluteAnchor) && !isChildOf(target, absoluteAnchor)) { destroy() } } - eventListeners.mousedown = util.addEventListener(root, 'mousedown', destroyIfOutside) - eventListeners.mousewheel = util.addEventListener(root, 'mousewheel', destroyIfOutside) - // eventListeners.scroll = util.addEventListener(root, 'scroll', destroyIfOutside); + eventListeners.mousedown = addEventListener(root, 'mousedown', destroyIfOutside) + eventListeners.mousewheel = addEventListener(root, 'mousewheel', destroyIfOutside) + // eventListeners.scroll = addEventListener(root, 'scroll', destroyIfOutside); absoluteAnchor.destroy = destroy diff --git a/src/js/i18n.js b/src/js/i18n.js index 0fdf20e..e916abe 100644 --- a/src/js/i18n.js +++ b/src/js/i18n.js @@ -2,7 +2,7 @@ /* eslint-disable no-template-curly-in-string */ -require('./polyfills') +import './polyfills' const _locales = ['en', 'pt-BR', 'zh-CN', 'tr'] const _defs = { @@ -377,53 +377,45 @@ const _defs = { } const _defaultLang = 'en' -let _lang const userLang = typeof navigator !== 'undefined' ? navigator.language || navigator.userLanguage : undefined -_lang = _locales.find(l => l === userLang) -if (!_lang) { - _lang = _defaultLang -} +let _lang = _locales.find(l => l === userLang) || _defaultLang -module.exports = { - // supported locales - _locales: _locales, - _defs: _defs, - _lang: _lang, - setLanguage: function (lang) { - if (!lang) { - return - } - const langFound = _locales.find(l => l === lang) - if (langFound) { - _lang = langFound - } else { - console.error('Language not found') - } - }, - setLanguages: function (languages) { - if (!languages) { - return - } - for (const key in languages) { - const langFound = _locales.find(l => l === key) - if (!langFound) { - _locales.push(key) - } - _defs[key] = Object.assign({}, _defs[_defaultLang], _defs[key], languages[key]) - } - }, - translate: function (key, data, lang) { - if (!lang) { - lang = _lang - } - let text = _defs[lang][key] - if (data) { - for (key in data) { - text = text.replace('${' + key + '}', data[key]) - } - } - return text || key +export function setLanguage (lang) { + if (!lang) { + return + } + const langFound = _locales.find(l => l === lang) + if (langFound) { + _lang = langFound + } else { + console.error('Language not found') } } + +export function setLanguages (languages) { + if (!languages) { + return + } + for (const key in languages) { + const langFound = _locales.find(l => l === key) + if (!langFound) { + _locales.push(key) + } + _defs[key] = Object.assign({}, _defs[_defaultLang], _defs[key], languages[key]) + } +} + +export function translate (key, data, lang) { + if (!lang) { + lang = _lang + } + let text = _defs[lang][key] + if (data) { + for (key in data) { + text = text.replace('${' + key + '}', data[key]) + } + } + return text || key +} diff --git a/src/js/jsonUtils.js b/src/js/jsonUtils.js index ebb6281..f6d2a29 100644 --- a/src/js/jsonUtils.js +++ b/src/js/jsonUtils.js @@ -21,7 +21,7 @@ * * @returns {string | undefined} Returns the string representation of the JSON object. */ -function stringifyPartial (value, space, limit) { +export function stringifyPartial (value, space, limit) { let _space // undefined by default if (typeof space === 'number') { if (space > 10) { @@ -188,13 +188,10 @@ function slice (text, limit) { * @param {string} jsonText * @return {boolean} */ -function containsArray (jsonText) { +export function containsArray (jsonText) { return /^\s*\[/.test(jsonText) } function hasOwnProperty (object, key) { return Object.prototype.hasOwnProperty.call(object, key) } - -exports.stringifyPartial = stringifyPartial -exports.containsArray = containsArray diff --git a/src/js/previewmode.js b/src/js/previewmode.js index 9fbb350..51fc1c4 100644 --- a/src/js/previewmode.js +++ b/src/js/previewmode.js @@ -5,14 +5,14 @@ const translate = require('./i18n').translate const ModeSwitcher = require('./ModeSwitcher') const ErrorTable = require('./ErrorTable') const textmode = require('./textmode')[0].mixin -const showSortModal = require('./showSortModal') -const showTransformModal = require('./showTransformModal') +const showSortModal = require('./showSortModal').showSortModal +const showTransformModal = require('./showTransformModal').showTransformModal const MAX_PREVIEW_CHARACTERS = require('./constants').MAX_PREVIEW_CHARACTERS const DEFAULT_MODAL_ANCHOR = require('./constants').DEFAULT_MODAL_ANCHOR const SIZE_LARGE = require('./constants').SIZE_LARGE const PREVIEW_HISTORY_LIMIT = require('./constants').PREVIEW_HISTORY_LIMIT const util = require('./util') -const History = require('./History') +const History = require('./History').History // create a mixin with the functions for text mode const previewmode = {} @@ -23,10 +23,7 @@ const previewmode = {} * @param {Object} [options] Object with options. See docs for details. * @private */ -previewmode.create = function (container, options) { - // read options - options = options || {} - +previewmode.create = function (container, options = {}) { if (typeof options.statusBar === 'undefined') { options.statusBar = true } diff --git a/src/js/showMoreNodeFactory.js b/src/js/showMoreNodeFactory.js index 33cdd3b..2f2e5a7 100644 --- a/src/js/showMoreNodeFactory.js +++ b/src/js/showMoreNodeFactory.js @@ -1,12 +1,12 @@ 'use strict' -const translate = require('./i18n').translate +import {translate} from './i18n'; /** * A factory function to create an ShowMoreNode, which depends on a Node * @param {function} Node */ -function showMoreNodeFactory (Node) { +export function showMoreNodeFactory (Node) { /** * @constructor ShowMoreNode * @extends Node @@ -152,5 +152,3 @@ function showMoreNodeFactory (Node) { return ShowMoreNode } - -module.exports = showMoreNodeFactory diff --git a/src/js/showSortModal.js b/src/js/showSortModal.js index 3aa2da6..64baafb 100644 --- a/src/js/showSortModal.js +++ b/src/js/showSortModal.js @@ -1,6 +1,6 @@ -const picoModal = require('picomodal') -const translate = require('./i18n').translate -const util = require('./util') +import picoModal from 'picomodal'; +import {translate} from './i18n'; +import { contains, getChildPaths } from './util' /** * Show advanced sorting modal @@ -15,11 +15,11 @@ const util = require('./util') * - {string} path The selected path * - {'asc' | 'desc'} direction The selected direction */ -function showSortModal (container, json, onSort, options) { +export function showSortModal (container, json, onSort, options) { const paths = Array.isArray(json) - ? util.getChildPaths(json) + ? getChildPaths(json) : [''] - const selectedPath = options && options.path && util.contains(paths, options.path) + const selectedPath = options && options.path && contains(paths, options.path) ? options.path : paths[0] const selectedDirection = (options && options.direction) || 'asc' @@ -129,5 +129,3 @@ function showSortModal (container, json, onSort, options) { }) .show() } - -module.exports = showSortModal diff --git a/src/js/showTransformModal.js b/src/js/showTransformModal.js index 2db2e59..eb5ba9d 100644 --- a/src/js/showTransformModal.js +++ b/src/js/showTransformModal.js @@ -1,11 +1,10 @@ -const jmespath = require('jmespath') -const picoModal = require('picomodal') -const Selectr = require('./assets/selectr/selectr') -const translate = require('./i18n').translate -const stringifyPartial = require('./jsonUtils').stringifyPartial -const util = require('./util') -const MAX_PREVIEW_CHARACTERS = require('./constants').MAX_PREVIEW_CHARACTERS -const debounce = util.debounce +import jmespath from 'jmespath'; +import picoModal from 'picomodal'; +import Selectr from './assets/selectr/selectr'; +import {translate} from './i18n'; +import {stringifyPartial} from './jsonUtils'; +import { getChildPaths, get, parsePath, parseString, debounce } from './util' +import {MAX_PREVIEW_CHARACTERS} from './constants'; /** * Show advanced filter and transform modal using JMESPath @@ -15,7 +14,7 @@ const debounce = util.debounce * @param {function} onTransform Callback invoked with the created * query as callback */ -function showTransformModal (container, json, onTransform) { +export function showTransformModal (container, json, onTransform) { const value = json const content = '