@wirenboard/json-editor 2.5.3-wb13
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/.env-dist +2 -0
- package/.eslintrc +7 -0
- package/.gitattributes +1 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +9 -0
- package/.github/issue_template +25 -0
- package/.github/workflows/build.yml +58 -0
- package/.travis.yml +70 -0
- package/CHANGELOG.md +915 -0
- package/CONTRIBUTING.md +92 -0
- package/LICENSE +20 -0
- package/Makefile +26 -0
- package/README.md +1646 -0
- package/README_ADDON.md +573 -0
- package/UPGRADING.md +46 -0
- package/build/CssToJson.js +55 -0
- package/codecept.conf.js +35 -0
- package/config/.eslintrc +7 -0
- package/config/codeceptjs_helpers.js +139 -0
- package/config/helpers.js +10 -0
- package/config/karma.conf.js +93 -0
- package/config/readme.md +31 -0
- package/config/webpack.common.js +75 -0
- package/config/webpack.dev.js +15 -0
- package/config/webpack.nonmin.js +19 -0
- package/config/webpack.prod.js +25 -0
- package/dist/jsoneditor.js +14 -0
- package/dist/nonmin/jsoneditor.js +29097 -0
- package/dist/nonmin/jsoneditor.js.map +1 -0
- package/docs/ace_editor.html +56 -0
- package/docs/advanced.html +136 -0
- package/docs/basic.html +63 -0
- package/docs/basic_person.json +26 -0
- package/docs/choices.html +86 -0
- package/docs/cleave.html +132 -0
- package/docs/colorpicker.html +194 -0
- package/docs/css_integration.html +135 -0
- package/docs/datetime.html +305 -0
- package/docs/describedby.html +161 -0
- package/docs/enumsource.html +67 -0
- package/docs/images/categoriesDemo.png +0 -0
- package/docs/images/inheritance_tree.png +0 -0
- package/docs/images/jsoneditor.png +0 -0
- package/docs/imask.html +192 -0
- package/docs/index.html +579 -0
- package/docs/materialize_css.html +164 -0
- package/docs/meta_schema.json +705 -0
- package/docs/multiple_upload_base64.html +65 -0
- package/docs/person.json +73 -0
- package/docs/polyfills/assign.js +29 -0
- package/docs/radio.html +156 -0
- package/docs/recursive.html +170 -0
- package/docs/select2.html +99 -0
- package/docs/selectize.html +100 -0
- package/docs/signature.html +42 -0
- package/docs/starrating.html +137 -0
- package/docs/upload.html +131 -0
- package/docs/uuid.html +70 -0
- package/docs/wysiwyg.html +56 -0
- package/jasmine.json +11 -0
- package/json-editor-json-editor-2.5.3-wb13.tgz +0 -0
- package/package.json +100 -0
- package/release-notes.md +88 -0
- package/src/core.js +412 -0
- package/src/defaults.js +402 -0
- package/src/editor.js +707 -0
- package/src/editors/ace.js +89 -0
- package/src/editors/array/choices.js +103 -0
- package/src/editors/array/select2.js +110 -0
- package/src/editors/array/selectize.js +103 -0
- package/src/editors/array.css +9 -0
- package/src/editors/array.css.js +3 -0
- package/src/editors/array.js +818 -0
- package/src/editors/autocomplete.js +58 -0
- package/src/editors/base64.js +157 -0
- package/src/editors/button.js +97 -0
- package/src/editors/checkbox.js +95 -0
- package/src/editors/choices.css +3 -0
- package/src/editors/choices.css.js +3 -0
- package/src/editors/choices.js +69 -0
- package/src/editors/colorpicker.js +103 -0
- package/src/editors/datetime.js +141 -0
- package/src/editors/describedby.js +188 -0
- package/src/editors/enum.js +136 -0
- package/src/editors/hidden.js +127 -0
- package/src/editors/index.js +81 -0
- package/src/editors/info.js +20 -0
- package/src/editors/integer.js +19 -0
- package/src/editors/ip.js +36 -0
- package/src/editors/jodit.js +64 -0
- package/src/editors/multiple.js +409 -0
- package/src/editors/multiselect.js +218 -0
- package/src/editors/null.js +18 -0
- package/src/editors/number.js +51 -0
- package/src/editors/object.css +41 -0
- package/src/editors/object.css.js +3 -0
- package/src/editors/object.js +1290 -0
- package/src/editors/radio.js +111 -0
- package/src/editors/sceditor.js +72 -0
- package/src/editors/select.js +370 -0
- package/src/editors/select2.js +110 -0
- package/src/editors/selectize.js +112 -0
- package/src/editors/signature.js +113 -0
- package/src/editors/simplemde.js +100 -0
- package/src/editors/starrating.css +52 -0
- package/src/editors/starrating.css.js +3 -0
- package/src/editors/starrating.js +135 -0
- package/src/editors/stepper.js +27 -0
- package/src/editors/string.js +372 -0
- package/src/editors/table.js +516 -0
- package/src/editors/upload.js +321 -0
- package/src/editors/uuid.js +56 -0
- package/src/iconlib.js +24 -0
- package/src/iconlibs/bootstrap2.js +28 -0
- package/src/iconlibs/bootstrap3.js +28 -0
- package/src/iconlibs/fontawesome3.js +28 -0
- package/src/iconlibs/fontawesome4.js +28 -0
- package/src/iconlibs/fontawesome5.js +28 -0
- package/src/iconlibs/foundation2.js +24 -0
- package/src/iconlibs/foundation3.js +28 -0
- package/src/iconlibs/index.js +25 -0
- package/src/iconlibs/jqueryui.js +28 -0
- package/src/iconlibs/materialicons.js +49 -0
- package/src/iconlibs/openiconic.js +28 -0
- package/src/iconlibs/spectre.js +28 -0
- package/src/resolvers.js +128 -0
- package/src/schemaloader.js +408 -0
- package/src/style.css +150 -0
- package/src/style.css.js +3 -0
- package/src/templates/default.js +52 -0
- package/src/templates/ejs.js +13 -0
- package/src/templates/handlebars.js +1 -0
- package/src/templates/hogan.js +10 -0
- package/src/templates/index.js +21 -0
- package/src/templates/lodash.js +9 -0
- package/src/templates/markup.js +9 -0
- package/src/templates/mustache.js +9 -0
- package/src/templates/swig.js +1 -0
- package/src/templates/underscore.js +9 -0
- package/src/theme.js +659 -0
- package/src/themes/barebones.css +35 -0
- package/src/themes/barebones.css.js +3 -0
- package/src/themes/barebones.js +28 -0
- package/src/themes/bootstrap2.js +319 -0
- package/src/themes/bootstrap3.css +0 -0
- package/src/themes/bootstrap3.css.js +3 -0
- package/src/themes/bootstrap3.js +315 -0
- package/src/themes/bootstrap4.css +89 -0
- package/src/themes/bootstrap4.css.js +3 -0
- package/src/themes/bootstrap4.js +690 -0
- package/src/themes/bootstrap5.css.js +3 -0
- package/src/themes/foundation.js +569 -0
- package/src/themes/html.css +60 -0
- package/src/themes/html.css.js +3 -0
- package/src/themes/html.js +71 -0
- package/src/themes/index.js +28 -0
- package/src/themes/jqueryui.js +198 -0
- package/src/themes/materialize.js +426 -0
- package/src/themes/spectre.css +208 -0
- package/src/themes/spectre.css.js +3 -0
- package/src/themes/spectre.js +406 -0
- package/src/themes/tailwind.css +249 -0
- package/src/themes/tailwind.css.js +3 -0
- package/src/themes/tailwind.js +443 -0
- package/src/utilities.js +138 -0
- package/src/validator.js +877 -0
- package/src/validators/ip-validator.js +51 -0
- package/tests/Dockerfile +3 -0
- package/tests/README.md +48 -0
- package/tests/codeceptjs/codecept.json +42 -0
- package/tests/codeceptjs/constrains/if-then-else_test.js +143 -0
- package/tests/codeceptjs/core_test.js +217 -0
- package/tests/codeceptjs/editors/advanced_test.js +13 -0
- package/tests/codeceptjs/editors/array_any_of_test.js +50 -0
- package/tests/codeceptjs/editors/array_test.js +900 -0
- package/tests/codeceptjs/editors/button_test.js +35 -0
- package/tests/codeceptjs/editors/checkbox_test.js +21 -0
- package/tests/codeceptjs/editors/colorpicker_test.js +27 -0
- package/tests/codeceptjs/editors/datetime_test.js +33 -0
- package/tests/codeceptjs/editors/inheritance_test.js +11 -0
- package/tests/codeceptjs/editors/integer_test.js +84 -0
- package/tests/codeceptjs/editors/issues/issue-gh-812_test.js +32 -0
- package/tests/codeceptjs/editors/jodit_test.js +24 -0
- package/tests/codeceptjs/editors/multiselect_test.js +8 -0
- package/tests/codeceptjs/editors/number_test.js +82 -0
- package/tests/codeceptjs/editors/object_test.js +204 -0
- package/tests/codeceptjs/editors/option-no_default_values_test.js +42 -0
- package/tests/codeceptjs/editors/programmatic-changes_test.js +20 -0
- package/tests/codeceptjs/editors/radio_test.js +10 -0
- package/tests/codeceptjs/editors/rating_test.js +13 -0
- package/tests/codeceptjs/editors/select_test.js +22 -0
- package/tests/codeceptjs/editors/stepper_test.js +27 -0
- package/tests/codeceptjs/editors/string_test.js +118 -0
- package/tests/codeceptjs/editors/table-confirm-delete_test.js +67 -0
- package/tests/codeceptjs/editors/tabs_test.js +14 -0
- package/tests/codeceptjs/editors/uuid_test.js +21 -0
- package/tests/codeceptjs/editors/validation_test.js +14 -0
- package/tests/codeceptjs/meta-schema_test.js +17 -0
- package/tests/codeceptjs/schemaloader_test.js +13 -0
- package/tests/codeceptjs/steps.d.ts +13 -0
- package/tests/codeceptjs/steps_file.js +12 -0
- package/tests/codeceptjs/themes_test.js +519 -0
- package/tests/docker-compose.yml +34 -0
- package/tests/fixtures/basic_person.json +26 -0
- package/tests/fixtures/nested_object.json +26 -0
- package/tests/fixtures/person.json +55 -0
- package/tests/fixtures/recursive.json +8 -0
- package/tests/fixtures/some_types.json +32 -0
- package/tests/fixtures/string.json +3 -0
- package/tests/fixtures/validation.json +1140 -0
- package/tests/pages/_demo.html +475 -0
- package/tests/pages/advanced.html +137 -0
- package/tests/pages/anyof.html +80 -0
- package/tests/pages/array-anyof.html +142 -0
- package/tests/pages/array-checkboxes.html +41 -0
- package/tests/pages/array-choices.html +45 -0
- package/tests/pages/array-integers.html +37 -0
- package/tests/pages/array-move-events.html +61 -0
- package/tests/pages/array-multiselects.html +42 -0
- package/tests/pages/array-nested-arrays.html +40 -0
- package/tests/pages/array-numbers.html +37 -0
- package/tests/pages/array-objects.html +42 -0
- package/tests/pages/array-ratings.html +40 -0
- package/tests/pages/array-selectize.html +51 -0
- package/tests/pages/array-selects.html +36 -0
- package/tests/pages/array-strings.html +36 -0
- package/tests/pages/array.html +42 -0
- package/tests/pages/assets/pages.css +130 -0
- package/tests/pages/button-callbacks.html +77 -0
- package/tests/pages/checkbox-labels.html +114 -0
- package/tests/pages/colorpicker-no-3rd-party.html +43 -0
- package/tests/pages/colorpicker-use-vanilla-picker.html +50 -0
- package/tests/pages/core.html +118 -0
- package/tests/pages/datetime.html +76 -0
- package/tests/pages/form-name.html +108 -0
- package/tests/pages/grid-strict.html +311 -0
- package/tests/pages/grid.html +284 -0
- package/tests/pages/if-then-else-allOf.html +117 -0
- package/tests/pages/inheritance.html +76 -0
- package/tests/pages/integer.html +68 -0
- package/tests/pages/issues/_template.html +50 -0
- package/tests/pages/issues/issue-gh-812.html +110 -0
- package/tests/pages/issues/issue-gh-823-meta-schema.html +35 -0
- package/tests/pages/issues/issue-gh-848.html +81 -0
- package/tests/pages/meta_schema.json +705 -0
- package/tests/pages/number.html +89 -0
- package/tests/pages/object-no-additional-properties.html +65 -0
- package/tests/pages/object-no-duplicated-id.html +68 -0
- package/tests/pages/object-required-properties.html +236 -0
- package/tests/pages/object-with-dependencies-array.html +46 -0
- package/tests/pages/object-with-dependencies.html +60 -0
- package/tests/pages/object.html +79 -0
- package/tests/pages/oneof.html +103 -0
- package/tests/pages/option-no_default_values.html +58 -0
- package/tests/pages/programmatic-changes.html +120 -0
- package/tests/pages/read-only.html +105 -0
- package/tests/pages/select.html +41 -0
- package/tests/pages/stepper.html +59 -0
- package/tests/pages/string-ace-editor.html +52 -0
- package/tests/pages/string-cleave.html +46 -0
- package/tests/pages/string-custom-attributes.html +62 -0
- package/tests/pages/string-formats.html +52 -0
- package/tests/pages/string-formats2.html +57 -0
- package/tests/pages/string-jodit-editor.html +49 -0
- package/tests/pages/string-sceditor.html +62 -0
- package/tests/pages/table-move-events.html +56 -0
- package/tests/pages/table.html +46 -0
- package/tests/pages/tabs.html +131 -0
- package/tests/pages/themes.html +527 -0
- package/tests/pages/translate-property.html +247 -0
- package/tests/pages/urn.html +93 -0
- package/tests/pages/uuid.html +72 -0
- package/tests/pages/validation.html +99 -0
- package/tests/unit/.eslintrc +8 -0
- package/tests/unit/core.spec.js +309 -0
- package/tests/unit/defaults.spec.js +40 -0
- package/tests/unit/editor.spec.js +160 -0
- package/tests/unit/editors/array.spec.js +86 -0
- package/tests/unit/editors/object.spec.js +79 -0
- package/tests/unit/editors/table.spec.js +91 -0
- package/tests/unit/readme.md +35 -0
- package/tests/unit/schemaloader.spec.js +498 -0
- package/tests/unit/validator.spec.js +94 -0
- package/tests/unit/validators/ip-validator.spec.js +62 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
|
|
2
|
+
import { htmlTheme } from './html.js'
|
|
3
|
+
// import { bootstrap2Theme } from './bootstrap2'
|
|
4
|
+
import { bootstrap3Theme } from './bootstrap3.js'
|
|
5
|
+
import { bootstrap4Theme } from './bootstrap4.js'
|
|
6
|
+
// import { foundationTheme, foundation3Theme, foundation4Theme, foundation5Theme, foundation6Theme } from './foundation.js'
|
|
7
|
+
import { jqueryuiTheme } from './jqueryui.js'
|
|
8
|
+
import { barebonesTheme } from './barebones.js'
|
|
9
|
+
// import { materializeTheme } from './materialize'
|
|
10
|
+
import { spectreTheme } from './spectre.js'
|
|
11
|
+
import { tailwindTheme } from './tailwind.js'
|
|
12
|
+
|
|
13
|
+
export const themes = {
|
|
14
|
+
html: htmlTheme,
|
|
15
|
+
// bootstrap2: bootstrap2Theme,
|
|
16
|
+
bootstrap3: bootstrap3Theme,
|
|
17
|
+
bootstrap4: bootstrap4Theme,
|
|
18
|
+
// foundation: foundationTheme,
|
|
19
|
+
// foundation3: foundation3Theme,
|
|
20
|
+
// foundation4: foundation4Theme,
|
|
21
|
+
// foundation5: foundation5Theme,
|
|
22
|
+
// foundation6: foundation6Theme,
|
|
23
|
+
jqueryui: jqueryuiTheme,
|
|
24
|
+
barebones: barebonesTheme,
|
|
25
|
+
// materialize: materializeTheme,
|
|
26
|
+
spectre: spectreTheme,
|
|
27
|
+
tailwind: tailwindTheme
|
|
28
|
+
}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { AbstractTheme } from '../theme.js'
|
|
2
|
+
|
|
3
|
+
export class jqueryuiTheme extends AbstractTheme {
|
|
4
|
+
getTable () {
|
|
5
|
+
const el = super.getTable()
|
|
6
|
+
el.setAttribute('cellpadding', 5)
|
|
7
|
+
el.setAttribute('cellspacing', 0)
|
|
8
|
+
return el
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
getTableHeaderCell (text) {
|
|
12
|
+
const el = super.getTableHeaderCell(text)
|
|
13
|
+
el.classList.add('ui-state-active')
|
|
14
|
+
el.style.fontWeight = 'bold'
|
|
15
|
+
return el
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
getTableCell () {
|
|
19
|
+
const el = super.getTableCell()
|
|
20
|
+
el.classList.add('ui-widget-content')
|
|
21
|
+
return el
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
getHeaderButtonHolder () {
|
|
25
|
+
const el = this.getButtonHolder()
|
|
26
|
+
el.style.marginLeft = '10px'
|
|
27
|
+
el.style.fontSize = '.6em'
|
|
28
|
+
el.style.display = 'inline-block'
|
|
29
|
+
return el
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
getFormInputDescription (text) {
|
|
33
|
+
const el = this.getDescription(text)
|
|
34
|
+
el.style.marginLeft = '10px'
|
|
35
|
+
el.style.display = 'inline-block'
|
|
36
|
+
return el
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
getFormControl (label, input, description, infoText) {
|
|
40
|
+
const el = super.getFormControl(label, input, description, infoText)
|
|
41
|
+
if (input.type === 'checkbox') {
|
|
42
|
+
el.style.lineHeight = '25px'
|
|
43
|
+
|
|
44
|
+
el.style.padding = '3px 0'
|
|
45
|
+
} else {
|
|
46
|
+
el.style.padding = '4px 0 8px 0'
|
|
47
|
+
}
|
|
48
|
+
return el
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
getDescription (text) {
|
|
52
|
+
const el = document.createElement('span')
|
|
53
|
+
el.style.fontSize = '.8em'
|
|
54
|
+
el.style.fontStyle = 'italic'
|
|
55
|
+
if (window.DOMPurify) el.innerHTML = window.DOMPurify.sanitize(text)
|
|
56
|
+
else el.textContent = this.cleanText(text)
|
|
57
|
+
return el
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
getButtonHolder () {
|
|
61
|
+
const el = document.createElement('div')
|
|
62
|
+
el.classList.add('ui-buttonset')
|
|
63
|
+
el.style.fontSize = '.7em'
|
|
64
|
+
return el
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
getFormInputLabel (text, req) {
|
|
68
|
+
const el = document.createElement('label')
|
|
69
|
+
el.style.fontWeight = 'bold'
|
|
70
|
+
el.style.display = 'block'
|
|
71
|
+
el.textContent = text
|
|
72
|
+
if (req) el.classList.add('required')
|
|
73
|
+
return el
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
getButton (text, icon, title) {
|
|
77
|
+
const button = document.createElement('button')
|
|
78
|
+
button.classList.add('ui-button', 'ui-widget', 'ui-state-default', 'ui-corner-all')
|
|
79
|
+
|
|
80
|
+
/* Icon only */
|
|
81
|
+
if (icon && !text) {
|
|
82
|
+
button.classList.add('ui-button-icon-only')
|
|
83
|
+
icon.classList.add('ui-button-icon-primary', 'ui-icon-primary')
|
|
84
|
+
button.appendChild(icon)
|
|
85
|
+
/* Icon and Text */
|
|
86
|
+
} else if (icon) {
|
|
87
|
+
button.classList.add('ui-button-text-icon-primary')
|
|
88
|
+
icon.classList.add('ui-button-icon-primary', 'ui-icon-primary')
|
|
89
|
+
button.appendChild(icon)
|
|
90
|
+
/* Text only */
|
|
91
|
+
} else {
|
|
92
|
+
button.classList.add('ui-button-text-only')
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const el = document.createElement('span')
|
|
96
|
+
el.classList.add('ui-button-text')
|
|
97
|
+
el.textContent = text || title || '.'
|
|
98
|
+
button.appendChild(el)
|
|
99
|
+
|
|
100
|
+
button.setAttribute('title', title)
|
|
101
|
+
|
|
102
|
+
return button
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
setButtonText (button, text, icon, title) {
|
|
106
|
+
button.innerHTML = ''
|
|
107
|
+
button.classList.add('ui-button', 'ui-widget', 'ui-state-default', 'ui-corner-all')
|
|
108
|
+
|
|
109
|
+
/* Icon only */
|
|
110
|
+
if (icon && !text) {
|
|
111
|
+
button.classList.add('ui-button-icon-only')
|
|
112
|
+
icon.classList.add('ui-button-icon-primary', 'ui-icon-primary')
|
|
113
|
+
button.appendChild(icon)
|
|
114
|
+
/* Icon and Text */
|
|
115
|
+
} else if (icon) {
|
|
116
|
+
button.classList.add('ui-button-text-icon-primary')
|
|
117
|
+
icon.classList.add('ui-button-icon-primary', 'ui-icon-primary')
|
|
118
|
+
button.appendChild(icon)
|
|
119
|
+
/* Text only */
|
|
120
|
+
} else {
|
|
121
|
+
button.classList.add('ui-button-text-only')
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const el = document.createElement('span')
|
|
125
|
+
el.classList.add('ui-button-text')
|
|
126
|
+
el.textContent = text || title || '.'
|
|
127
|
+
button.appendChild(el)
|
|
128
|
+
|
|
129
|
+
button.setAttribute('title', title)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
getIndentedPanel () {
|
|
133
|
+
const el = document.createElement('div')
|
|
134
|
+
el.classList.add('ui-widget-content', 'ui-corner-all')
|
|
135
|
+
el.style.padding = '1em 1.4em'
|
|
136
|
+
el.style.marginBottom = '20px'
|
|
137
|
+
return el
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
afterInputReady (input) {
|
|
141
|
+
if (input.controls) return
|
|
142
|
+
input.controls = this.closest(input, '.form-control')
|
|
143
|
+
if (this.queuedInputErrorText) {
|
|
144
|
+
const text = this.queuedInputErrorText
|
|
145
|
+
delete this.queuedInputErrorText
|
|
146
|
+
this.addInputError(input, text)
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
addInputError (input, text) {
|
|
151
|
+
if (!input.controls) {
|
|
152
|
+
this.queuedInputErrorText = text
|
|
153
|
+
return
|
|
154
|
+
}
|
|
155
|
+
if (!input.errmsg) {
|
|
156
|
+
input.errmsg = document.createElement('div')
|
|
157
|
+
input.errmsg.classList.add('ui-state-error')
|
|
158
|
+
input.controls.appendChild(input.errmsg)
|
|
159
|
+
} else {
|
|
160
|
+
input.errmsg.style.display = ''
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
input.errmsg.textContent = text
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
removeInputError (input) {
|
|
167
|
+
if (!input.controls) {
|
|
168
|
+
delete this.queuedInputErrorText
|
|
169
|
+
}
|
|
170
|
+
if (!input.errmsg) return
|
|
171
|
+
input.errmsg.style.display = 'none'
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
markTabActive (row) {
|
|
175
|
+
row.tab.classList.remove('ui-widget-header')
|
|
176
|
+
row.tab.classList.add('ui-state-active')
|
|
177
|
+
|
|
178
|
+
if (typeof row.rowPane !== 'undefined') {
|
|
179
|
+
row.rowPane.style.display = ''
|
|
180
|
+
} else {
|
|
181
|
+
row.container.style.display = ''
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
markTabInactive (row) {
|
|
186
|
+
row.tab.classList.add('ui-widget-header')
|
|
187
|
+
row.tab.classList.remove('ui-state-active')
|
|
188
|
+
|
|
189
|
+
if (typeof row.rowPane !== 'undefined') {
|
|
190
|
+
row.rowPane.style.display = 'none'
|
|
191
|
+
} else {
|
|
192
|
+
row.container.style.display = 'none'
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/* Custom stylesheet rules. format: "selector" : "CSS rules" */
|
|
198
|
+
jqueryuiTheme.rules = { 'div[data-schemaid="root"]:after': 'position:relative;color:red;margin:10px 0;font-weight:600;display:block;width:100%;text-align:center;content:"This is an old JSON-Editor 1.x Theme and might not display elements correctly when used with the 2.x version"' }
|
|
@@ -0,0 +1,426 @@
|
|
|
1
|
+
import { AbstractTheme } from '../theme.js'
|
|
2
|
+
|
|
3
|
+
export class materializeTheme extends AbstractTheme {
|
|
4
|
+
/**
|
|
5
|
+
* Applies grid size to specified element.
|
|
6
|
+
*
|
|
7
|
+
* @param {HTMLElement} el The DOM element to have specified size applied.
|
|
8
|
+
* @param {Integer} size The grid column size.
|
|
9
|
+
* @see http://materializecss.com/grid.html
|
|
10
|
+
*/
|
|
11
|
+
setGridColumnSize (el, size) {
|
|
12
|
+
el.classList.add('col')
|
|
13
|
+
el.classList.add(`s${size}`)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Gets a wrapped button element for a header.
|
|
18
|
+
*
|
|
19
|
+
* @returns {HTMLElement} The wrapped button element.
|
|
20
|
+
*/
|
|
21
|
+
getHeaderButtonHolder () {
|
|
22
|
+
return this.getButtonHolder()
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Gets a wrapped button element.
|
|
27
|
+
*
|
|
28
|
+
* @returns {HTMLElement} The wrapped button element.
|
|
29
|
+
*/
|
|
30
|
+
getButtonHolder () {
|
|
31
|
+
return document.createElement('span')
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Gets a single button element.
|
|
36
|
+
*
|
|
37
|
+
* @param {string} text The button text.
|
|
38
|
+
* @param {HTMLElement} icon The icon object.
|
|
39
|
+
* @param {string} title The button title.
|
|
40
|
+
* @returns {HTMLElement} The button object.
|
|
41
|
+
* @see http://materializecss.com/buttons.html
|
|
42
|
+
*/
|
|
43
|
+
getButton (text, icon, title) {
|
|
44
|
+
/* Prepare icon. */
|
|
45
|
+
if (icon) {
|
|
46
|
+
icon.classList.add('left')
|
|
47
|
+
icon.style.marginRight = '5px'
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/* Create and return button. */
|
|
51
|
+
const el = super.getButton(text, icon, title)
|
|
52
|
+
el.classList.add('waves-effect', 'waves-light', 'btn')
|
|
53
|
+
el.style.fontSize = '0.75rem'
|
|
54
|
+
el.style.height = '24px'
|
|
55
|
+
el.style.lineHeight = '24px'
|
|
56
|
+
el.style.marginLeft = '5px'
|
|
57
|
+
el.style.padding = '0 0.5rem'
|
|
58
|
+
return el
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
afterInputReady (input) {
|
|
62
|
+
let label = input.previousSibling
|
|
63
|
+
|
|
64
|
+
if (input.type && input.type === 'range') {
|
|
65
|
+
label = input.parentElement.previousSibling
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (input.value || (input.dataset && input.dataset.containerFor && input.dataset.containerFor === 'radio')) {
|
|
69
|
+
if (label && label.localName === 'label') {
|
|
70
|
+
label.classList.add('active')
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Gets a form control object consisiting of several sub objects.
|
|
77
|
+
*
|
|
78
|
+
* @param {HTMLElement} label The label element.
|
|
79
|
+
* @param {HTMLElement} input The input element.
|
|
80
|
+
* @param {string} description The element description.
|
|
81
|
+
* @param {string} infoText The element information text.
|
|
82
|
+
* @returns {HTMLElement} The assembled DOM element.
|
|
83
|
+
* @see http://materializecss.com/forms.html
|
|
84
|
+
*/
|
|
85
|
+
getFormControl (label, input, description, infoText) {
|
|
86
|
+
let ctrl
|
|
87
|
+
const { type } = input
|
|
88
|
+
|
|
89
|
+
/* Checkboxes get wrapped in p elements. */
|
|
90
|
+
if (type && (type === 'checkbox' || type === 'radio')) {
|
|
91
|
+
ctrl = document.createElement('p')
|
|
92
|
+
if (label) {
|
|
93
|
+
const span = document.createElement('span')
|
|
94
|
+
span.innerHTML = label.innerHTML
|
|
95
|
+
label.innerHTML = ''
|
|
96
|
+
label.setAttribute('for', input.id)
|
|
97
|
+
ctrl.appendChild(label)
|
|
98
|
+
label.appendChild(input)
|
|
99
|
+
label.appendChild(span)
|
|
100
|
+
} else {
|
|
101
|
+
ctrl.appendChild(input)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return ctrl
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/* Anything else gets wrapped in divs. */
|
|
108
|
+
ctrl = super.getFormControl(label, input, description, infoText)
|
|
109
|
+
|
|
110
|
+
/* Color needs special attention. */
|
|
111
|
+
if (type && type === 'color') {
|
|
112
|
+
input.style.height = '3rem'
|
|
113
|
+
input.style.width = '100%'
|
|
114
|
+
input.style.margin = '5px 0 20px 0'
|
|
115
|
+
input.style.padding = '3px'
|
|
116
|
+
|
|
117
|
+
if (label) {
|
|
118
|
+
label.style.transform = 'translateY(-14px) scale(0.8)'
|
|
119
|
+
label.style['-webkit-transform'] = 'translateY(-14px) scale(0.8)'
|
|
120
|
+
label.style['-webkit-transform-origin'] = '0 0'
|
|
121
|
+
label.style['transform-origin'] = '0 0'
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return ctrl
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
getDescription (text) {
|
|
129
|
+
const el = document.createElement('div')
|
|
130
|
+
el.classList.add('grey-text')
|
|
131
|
+
/* el.style.marginTop = '-15px' */
|
|
132
|
+
if (window.DOMPurify) el.innerHTML = window.DOMPurify.sanitize(text)
|
|
133
|
+
else el.textContent = this.cleanText(text)
|
|
134
|
+
return el
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Gets a header element.
|
|
139
|
+
*
|
|
140
|
+
* @param {string|HTMLElement} text The header text or element.
|
|
141
|
+
* @returns {HTMLElement} The header element.
|
|
142
|
+
*/
|
|
143
|
+
getHeader (text, pathDepth) {
|
|
144
|
+
const el = document.createElement('h5')
|
|
145
|
+
|
|
146
|
+
if (typeof text === 'string') {
|
|
147
|
+
el.textContent = text
|
|
148
|
+
} else {
|
|
149
|
+
el.appendChild(text)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return el
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
getChildEditorHolder () {
|
|
156
|
+
const el = document.createElement('div')
|
|
157
|
+
el.marginBottom = '10px'
|
|
158
|
+
return el
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
getIndentedPanel () {
|
|
162
|
+
const el = document.createElement('div')
|
|
163
|
+
el.classList.add('card-panel')
|
|
164
|
+
return el
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
getTable () {
|
|
168
|
+
const el = document.createElement('table')
|
|
169
|
+
el.classList.add('striped', 'bordered')
|
|
170
|
+
el.style.marginBottom = '10px'
|
|
171
|
+
return el
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
getTableRow () {
|
|
175
|
+
return document.createElement('tr')
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
getTableHead () {
|
|
179
|
+
return document.createElement('thead')
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
getTableBody () {
|
|
183
|
+
return document.createElement('tbody')
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
getTableHeaderCell (text) {
|
|
187
|
+
const el = document.createElement('th')
|
|
188
|
+
el.textContent = text
|
|
189
|
+
return el
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
getTableCell () {
|
|
193
|
+
const el = document.createElement('td')
|
|
194
|
+
return el
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Gets the tab holder element.
|
|
199
|
+
*
|
|
200
|
+
* @returns {HTMLElement} The tab holder component.
|
|
201
|
+
* @see https://github.com/Dogfalo/materialize/issues/2542#issuecomment-233458602
|
|
202
|
+
*/
|
|
203
|
+
getTabHolder () {
|
|
204
|
+
const html = [
|
|
205
|
+
'<div class="col s2">',
|
|
206
|
+
' <ul class="tabs" style="height: auto; margin-top: 0.82rem; -ms-flex-direction: column; -webkit-flex-direction: column; flex-direction: column; display: -webkit-flex; display: flex;">',
|
|
207
|
+
' </ul>',
|
|
208
|
+
'</div>',
|
|
209
|
+
'<div class="col s10">',
|
|
210
|
+
'<div>'
|
|
211
|
+
].join('\n')
|
|
212
|
+
|
|
213
|
+
const el = document.createElement('div')
|
|
214
|
+
el.classList.add('row', 'card-panel')
|
|
215
|
+
el.innerHTML = html
|
|
216
|
+
return el
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Add specified tab to specified holder element.
|
|
221
|
+
*
|
|
222
|
+
* @param {HTMLElement} holder The tab holder element.
|
|
223
|
+
* @param {HTMLElement} tab The tab to add.
|
|
224
|
+
*/
|
|
225
|
+
addTab (holder, tab) {
|
|
226
|
+
holder.children[0].children[0].appendChild(tab)
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Gets a single tab element.
|
|
231
|
+
*
|
|
232
|
+
* @param {HTMLElement} span The tab's content.
|
|
233
|
+
* @returns {HTMLElement} The tab element.
|
|
234
|
+
* @see https://github.com/Dogfalo/materialize/issues/2542#issuecomment-233458602
|
|
235
|
+
*/
|
|
236
|
+
getTab (span) {
|
|
237
|
+
const el = document.createElement('li')
|
|
238
|
+
el.classList.add('tab')
|
|
239
|
+
el.style = el.style || {}
|
|
240
|
+
this.applyStyles(el,
|
|
241
|
+
{
|
|
242
|
+
width: '100%',
|
|
243
|
+
textAlign: 'left',
|
|
244
|
+
lineHeight: '24px',
|
|
245
|
+
height: '24px',
|
|
246
|
+
fontSize: '14px',
|
|
247
|
+
cursor: 'pointer'
|
|
248
|
+
}
|
|
249
|
+
)
|
|
250
|
+
el.appendChild(span)
|
|
251
|
+
return el
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Marks specified tab as active.
|
|
256
|
+
*
|
|
257
|
+
* @returns {HTMLElement} The tab element.
|
|
258
|
+
* @see https://github.com/Dogfalo/materialize/issues/2542#issuecomment-233458602
|
|
259
|
+
*/
|
|
260
|
+
markTabActive (tab) {
|
|
261
|
+
tab.style = tab.style || {}
|
|
262
|
+
this.applyStyles(tab,
|
|
263
|
+
{
|
|
264
|
+
width: '100%',
|
|
265
|
+
textAlign: 'left',
|
|
266
|
+
lineHeight: '24px',
|
|
267
|
+
height: '24px',
|
|
268
|
+
fontSize: '14px',
|
|
269
|
+
cursor: 'pointer',
|
|
270
|
+
color: 'rgba(238,110,115,1)',
|
|
271
|
+
transition: 'border-color .5s ease',
|
|
272
|
+
borderRight: '3px solid #424242'
|
|
273
|
+
}
|
|
274
|
+
)
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Marks specified tab as inactive.
|
|
279
|
+
*
|
|
280
|
+
* @returns {HTMLElement} The tab element.
|
|
281
|
+
* @see https://github.com/Dogfalo/materialize/issues/2542#issuecomment-233458602
|
|
282
|
+
*/
|
|
283
|
+
markTabInactive (tab) {
|
|
284
|
+
tab.style = tab.style || {}
|
|
285
|
+
this.applyStyles(tab,
|
|
286
|
+
{
|
|
287
|
+
width: '100%',
|
|
288
|
+
textAlign: 'left',
|
|
289
|
+
lineHeight: '24px',
|
|
290
|
+
height: '24px',
|
|
291
|
+
fontSize: '14px',
|
|
292
|
+
cursor: 'pointer',
|
|
293
|
+
color: 'rgba(238,110,115,0.7)'
|
|
294
|
+
}
|
|
295
|
+
)
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Returns the element that holds the tab contents.
|
|
300
|
+
*
|
|
301
|
+
* @param {HTMLElement} tabHolder The full tab holder element.
|
|
302
|
+
* @returns {HTMLElement} The content element inside specified tab holder.
|
|
303
|
+
*/
|
|
304
|
+
getTabContentHolder (tabHolder) {
|
|
305
|
+
return tabHolder.children[1]
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Creates and returns a tab content element.
|
|
310
|
+
*
|
|
311
|
+
* @returns {HTMLElement} The new tab content element.
|
|
312
|
+
*/
|
|
313
|
+
getTabContent () {
|
|
314
|
+
return document.createElement('div')
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Adds an error message to the specified input element.
|
|
319
|
+
*
|
|
320
|
+
* @param {HTMLElement} input The input element that caused the error.
|
|
321
|
+
* @param {string} text The error message.
|
|
322
|
+
*/
|
|
323
|
+
addInputError (input, text) {
|
|
324
|
+
/* Get the parent element. Should most likely be a <div class="input-field" ... />. */
|
|
325
|
+
const parent = input.parentNode
|
|
326
|
+
|
|
327
|
+
if (!parent) return
|
|
328
|
+
|
|
329
|
+
/* Remove any previous error. */
|
|
330
|
+
this.removeInputError(input)
|
|
331
|
+
|
|
332
|
+
/* Append an error message div. */
|
|
333
|
+
const el = document.createElement('div')
|
|
334
|
+
el.classList.add('error-text', 'red-text')
|
|
335
|
+
el.textContent = text
|
|
336
|
+
parent.appendChild(el)
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Removes any error message from the specified input element.
|
|
341
|
+
*
|
|
342
|
+
* @param {HTMLElement} input The input element that previously caused the error.
|
|
343
|
+
*/
|
|
344
|
+
removeInputError (input) {
|
|
345
|
+
/* Get the parent element. Should most likely be a <div class="input-field" ... />. */
|
|
346
|
+
const parent = input.parentElement
|
|
347
|
+
|
|
348
|
+
if (!parent) return
|
|
349
|
+
|
|
350
|
+
/* Remove all elements having class .error-text. */
|
|
351
|
+
const els = parent.getElementsByClassName('error-text')
|
|
352
|
+
for (let i = 0; i < els.length; i++) { parent.removeChild(els[i]) }
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
addTableRowError (row) {
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
removeTableRowError (row) {
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Gets a select DOM element.
|
|
363
|
+
*
|
|
364
|
+
* @param {object} options The option values.
|
|
365
|
+
* @return {HTMLElement} The DOM element.
|
|
366
|
+
* @see http://materializecss.com/forms.html#select
|
|
367
|
+
*/
|
|
368
|
+
getSelectInput (options, multiple) {
|
|
369
|
+
const select = super.getSelectInput(options)
|
|
370
|
+
select.classList.add('browser-default')
|
|
371
|
+
return select
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Gets a textarea DOM element.
|
|
376
|
+
*
|
|
377
|
+
* @returns {HTMLElement} The DOM element.
|
|
378
|
+
* @see http://materializecss.com/forms.html#textarea
|
|
379
|
+
*/
|
|
380
|
+
getTextareaInput () {
|
|
381
|
+
const el = document.createElement('textarea')
|
|
382
|
+
el.style.marginBottom = '5px'
|
|
383
|
+
el.style.fontSize = '1rem'
|
|
384
|
+
el.style.fontFamily = 'monospace'
|
|
385
|
+
return el
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
getCheckbox () {
|
|
389
|
+
const el = this.getFormInputField('checkbox')
|
|
390
|
+
el.id = this.createUuid()
|
|
391
|
+
return el
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Gets the modal element for displaying Edit JSON and Properties dialogs.
|
|
396
|
+
*
|
|
397
|
+
* @returns {HTMLElement} The modal DOM element.
|
|
398
|
+
* @see http://materializecss.com/cards.html
|
|
399
|
+
*/
|
|
400
|
+
getModal () {
|
|
401
|
+
const el = document.createElement('div')
|
|
402
|
+
el.classList.add('card-panel', 'z-depth-3')
|
|
403
|
+
el.style.padding = '5px'
|
|
404
|
+
el.style.position = 'absolute'
|
|
405
|
+
el.style.zIndex = '10'
|
|
406
|
+
el.style.display = 'none'
|
|
407
|
+
return el
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Creates and returns a RFC4122 version 4 compliant unique id.
|
|
412
|
+
*
|
|
413
|
+
* @returns {string} A GUID.
|
|
414
|
+
* @see https://stackoverflow.com/a/2117523
|
|
415
|
+
*/
|
|
416
|
+
createUuid () {
|
|
417
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
418
|
+
const r = Math.random() * 16 | 0; const v = c === 'x' ? r : (r & 0x3 | 0x8)
|
|
419
|
+
return v.toString(16)
|
|
420
|
+
}
|
|
421
|
+
)
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/* Custom stylesheet rules. format: "selector" : "CSS rules" */
|
|
426
|
+
materializeTheme.rules = { 'div[data-schemaid="root"]:after': 'position:relative;color:red;margin:10px 0;font-weight:600;display:block;width:100%;text-align:center;content:"This is an old JSON-Editor 1.x Theme and might not display elements correctly when used with the 2.x version"' }
|