@gravitee/ui-components 3.25.3-typescript-50960c3 → 3.25.3-typescript-9d19b68
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/package.json +5 -13
- package/src/atoms/gv-autocomplete.js +422 -1
- package/src/atoms/gv-button.js +397 -1
- package/src/atoms/gv-checkbox.js +178 -1
- package/src/atoms/gv-date-picker-calendar.js +812 -1
- package/src/atoms/gv-date-picker-cell.js +174 -1
- package/src/atoms/gv-date-picker.js +638 -1
- package/src/atoms/gv-file-upload.js +348 -1
- package/src/atoms/gv-icon.js +93 -1
- package/src/atoms/gv-image.js +135 -1
- package/src/atoms/gv-input-message.js +78 -1
- package/src/atoms/gv-input.js +508 -1
- package/src/atoms/gv-link.js +204 -1
- package/src/atoms/gv-message.js +133 -1
- package/src/atoms/gv-metric.js +112 -1
- package/src/atoms/gv-relative-time.js +143 -1
- package/src/atoms/gv-select-native.js +363 -1
- package/src/atoms/gv-select.js +413 -1
- package/src/atoms/gv-spinner.js +54 -1
- package/src/atoms/gv-state.js +125 -1
- package/src/atoms/gv-switch.js +235 -1
- package/src/atoms/gv-tag.js +162 -1
- package/src/atoms/gv-text.js +160 -1
- package/src/charts/gv-chart-bar.js +101 -1
- package/src/charts/gv-chart-gauge.js +92 -1
- package/src/charts/gv-chart-histogram.js +78 -1
- package/src/charts/gv-chart-line.js +218 -1
- package/src/charts/gv-chart-map.js +111 -1
- package/src/charts/gv-chart-pie.js +89 -1
- package/src/index.js +77 -1
- package/src/lib/cron-expression.js +176 -1
- package/src/lib/date.js +43 -1
- package/src/lib/events.js +26 -1
- package/src/lib/http-client-schema-form.js +67 -1
- package/src/lib/http.js +237 -1
- package/src/lib/i18n.js +93 -1
- package/src/lib/item.js +110 -1
- package/src/lib/properties.js +171 -1
- package/src/lib/schema-form.js +39 -1
- package/src/lib/studio.js +144 -1
- package/src/lib/style.js +39 -1
- package/src/lib/text-format.js +65 -1
- package/src/lib/theme.js +60 -1
- package/src/lib/utils.js +106 -1
- package/src/mixins/chart-element.js +153 -1
- package/src/mixins/input-element.js +136 -1
- package/src/mixins/item-resource.js +102 -1
- package/src/mixins/keyboard-element.js +62 -1
- package/src/mixins/update-after-browser.js +30 -1
- package/src/mixins/with-resize-observer.js +62 -1
- package/src/mixins/with-skeleton-attribute.js +109 -1
- package/src/molecules/gv-card-full.js +209 -1
- package/src/molecules/gv-card-list.js +101 -1
- package/src/molecules/gv-card.js +130 -1
- package/src/molecules/gv-category-list.js +56 -1
- package/src/molecules/gv-category.js +163 -1
- package/src/molecules/gv-code.js +334 -1
- package/src/molecules/gv-confirm.js +175 -1
- package/src/molecules/gv-cron-editor.js +685 -1
- package/src/molecules/gv-dropdown-menu.js +108 -1
- package/src/molecules/gv-expandable.js +116 -1
- package/src/molecules/gv-expression-language.js +263 -1
- package/src/molecules/gv-identity-picture.js +139 -1
- package/src/molecules/gv-list.js +214 -1
- package/src/molecules/gv-metrics.js +147 -1
- package/src/molecules/gv-modal.js +203 -1
- package/src/molecules/gv-nav.js +180 -1
- package/src/molecules/gv-option.js +230 -1
- package/src/molecules/gv-plans.js +400 -1
- package/src/molecules/gv-popover.js +323 -1
- package/src/molecules/gv-promote.js +203 -1
- package/src/molecules/gv-rating-list.js +341 -1
- package/src/molecules/gv-rating.js +234 -1
- package/src/molecules/gv-row-expandable.js +42 -1
- package/src/molecules/gv-row.js +205 -1
- package/src/molecules/gv-stats.js +110 -1
- package/src/molecules/gv-stepper.js +274 -1
- package/src/molecules/gv-table.js +644 -1
- package/src/molecules/gv-tree.js +238 -1
- package/src/organisms/gv-documentation.js +205 -1
- package/src/organisms/gv-header.js +276 -1
- package/src/organisms/gv-http-client.js +258 -1
- package/src/organisms/gv-menu.js +258 -1
- package/src/organisms/gv-newsletter-subscription.js +258 -1
- package/src/organisms/gv-pagination.js +179 -1
- package/src/organisms/gv-properties.js +860 -1
- package/src/organisms/gv-resizable-views.js +371 -1
- package/src/organisms/gv-resources.js +496 -1
- package/src/organisms/gv-schema-form-array.js +237 -1
- package/src/organisms/gv-schema-form-control-object.js +141 -1
- package/src/organisms/gv-schema-form-control.js +419 -1
- package/src/organisms/gv-schema-form.js +700 -1
- package/src/organisms/gv-tabs.js +201 -1
- package/src/organisms/gv-user-menu.js +298 -1
- package/src/organisms/gv-vertical-menu.js +119 -1
- package/src/policy-studio/gv-flow-step.js +443 -1
- package/src/policy-studio/gv-flow.js +595 -1
- package/src/policy-studio/gv-policy-studio-menu.js +689 -1
- package/src/policy-studio/gv-policy-studio.js +1712 -1
- package/src/styles/empty.js +35 -1
- package/src/styles/input.js +262 -1
- package/src/styles/link.js +31 -1
- package/src/styles/shapes.js +17 -1
- package/src/styles/skeleton.js +52 -1
- package/src/styles/zoom.js +39 -1
- package/src/theme/gv-theme.js +197 -1
- package/wc/gv-autocomplete.js +1 -1
- package/wc/gv-button.js +1 -1
- package/wc/gv-card-full.js +1 -1
- package/wc/gv-card-list.js +1 -1
- package/wc/gv-card.js +1 -1
- package/wc/gv-category-list.js +1 -1
- package/wc/gv-category.js +1 -1
- package/wc/gv-chart-bar.js +1 -1
- package/wc/gv-chart-gauge.js +1 -1
- package/wc/gv-chart-histogram.js +1 -1
- package/wc/gv-chart-line.js +1 -1
- package/wc/gv-chart-map.js +1 -1
- package/wc/gv-chart-pie.js +1 -1
- package/wc/gv-checkbox.js +1 -1
- package/wc/gv-code.js +1 -1
- package/wc/gv-confirm.js +1 -1
- package/wc/gv-cron-editor.js +1 -1
- package/wc/gv-date-picker-calendar.js +1 -1
- package/wc/gv-date-picker-cell.js +1 -1
- package/wc/gv-date-picker.js +1 -1
- package/wc/gv-documentation.js +1 -1
- package/wc/gv-dropdown-menu.js +1 -1
- package/wc/gv-expandable.js +1 -1
- package/wc/gv-expression-language.js +1 -1
- package/wc/gv-file-upload.js +1 -1
- package/wc/gv-flow-step.js +1 -1
- package/wc/gv-flow.js +1 -1
- package/wc/gv-header.js +1 -1
- package/wc/gv-http-client.js +1 -1
- package/wc/gv-icon.js +1 -1
- package/wc/gv-identity-picture.js +1 -1
- package/wc/gv-image.js +1 -1
- package/wc/gv-input-message.js +1 -1
- package/wc/gv-input.js +1 -1
- package/wc/gv-link.js +1 -1
- package/wc/gv-list.js +1 -1
- package/wc/gv-menu.js +1 -1
- package/wc/gv-message.js +1 -1
- package/wc/gv-metric.js +1 -1
- package/wc/gv-metrics.js +1 -1
- package/wc/gv-modal.js +1 -1
- package/wc/gv-nav.js +1 -1
- package/wc/gv-newsletter-subscription.js +1 -1
- package/wc/gv-option.js +1 -1
- package/wc/gv-pagination.js +1 -1
- package/wc/gv-plans.js +1 -1
- package/wc/gv-policy-studio-menu.js +1 -1
- package/wc/gv-policy-studio.js +1 -1
- package/wc/gv-popover.js +1 -1
- package/wc/gv-promote.js +1 -1
- package/wc/gv-properties.js +1 -1
- package/wc/gv-rating-list.js +1 -1
- package/wc/gv-rating.js +1 -1
- package/wc/gv-relative-time.js +1 -1
- package/wc/gv-resizable-views.js +1 -1
- package/wc/gv-resources.js +1 -1
- package/wc/gv-row-expandable.js +1 -1
- package/wc/gv-row.js +1 -1
- package/wc/gv-schema-form-array.js +1 -1
- package/wc/gv-schema-form-control-object.js +1 -1
- package/wc/gv-schema-form-control.js +1 -1
- package/wc/gv-schema-form.js +1 -1
- package/wc/gv-select-native.js +1 -1
- package/wc/gv-select.js +1 -1
- package/wc/gv-spinner.js +1 -1
- package/wc/gv-state.js +1 -1
- package/wc/gv-stats.js +1 -1
- package/wc/gv-stepper.js +1 -1
- package/wc/gv-switch.js +1 -1
- package/wc/gv-table.js +1 -1
- package/wc/gv-tabs.js +1 -1
- package/wc/gv-tag.js +1 -1
- package/wc/gv-text.js +1 -1
- package/wc/gv-theme.js +1 -1
- package/wc/gv-tree.js +1 -1
- package/wc/gv-user-menu.js +1 -1
- package/wc/gv-vertical-menu.js +1 -1
package/src/lib/i18n.js
CHANGED
|
@@ -1 +1,93 @@
|
|
|
1
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import 'whatwg-fetch';
|
|
17
|
+
/**
|
|
18
|
+
* @param {string} key - The translation key
|
|
19
|
+
* @param {object} data - The translation data
|
|
20
|
+
* @returns {string} - The translated
|
|
21
|
+
*/
|
|
22
|
+
export function i18n(key, data) {
|
|
23
|
+
const translation = getTranslation(key);
|
|
24
|
+
if (translation == null) {
|
|
25
|
+
return 'unknown';
|
|
26
|
+
}
|
|
27
|
+
if (data) {
|
|
28
|
+
const msg = i18n._messageFormatter.compile(translation);
|
|
29
|
+
return msg(data);
|
|
30
|
+
}
|
|
31
|
+
return translation;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* @param {string} key - The translation key
|
|
35
|
+
* @returns {null|string|function} - The translation string or function
|
|
36
|
+
*/
|
|
37
|
+
function getTranslation(key) {
|
|
38
|
+
try {
|
|
39
|
+
return key.split('.').reduce((prev, curr) => prev && prev[curr], i18n._translations[i18n._lang]);
|
|
40
|
+
}
|
|
41
|
+
catch (e) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// Init private translation storage
|
|
46
|
+
i18n._translations = {};
|
|
47
|
+
const MessageFormat = require('messageformat');
|
|
48
|
+
i18n._messageFormatter = new MessageFormat(i18n._lang);
|
|
49
|
+
/**
|
|
50
|
+
* @param {string} lang - Translation language code
|
|
51
|
+
*/
|
|
52
|
+
export function setLanguage(lang) {
|
|
53
|
+
i18n._lang = lang;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* @returns {string} - Translation language code
|
|
57
|
+
*/
|
|
58
|
+
export function getLanguage() {
|
|
59
|
+
return i18n._lang;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* @param {string} lang - Translation language code
|
|
63
|
+
* @param {object} translations - Translation values by key
|
|
64
|
+
* @param {object} label - Lang label
|
|
65
|
+
*/
|
|
66
|
+
export function addTranslations(lang, translations, label) {
|
|
67
|
+
i18n._translations[lang] = { ...{ LANGUAGE: label }, ...translations };
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* @returns {object} - All defined languages (key: human name and value: code)
|
|
71
|
+
*/
|
|
72
|
+
export function getAvailableLanguages() {
|
|
73
|
+
const availableLanguages = {};
|
|
74
|
+
for (const lang in i18n._translations) {
|
|
75
|
+
const { LANGUAGE } = i18n._translations[lang];
|
|
76
|
+
availableLanguages[LANGUAGE] = lang;
|
|
77
|
+
}
|
|
78
|
+
return availableLanguages;
|
|
79
|
+
}
|
|
80
|
+
export function loadDefaultTranslations() {
|
|
81
|
+
setLanguage('en');
|
|
82
|
+
return fetch(`i18n/${i18n._lang}.json`)
|
|
83
|
+
.then((response) => {
|
|
84
|
+
return response.json();
|
|
85
|
+
})
|
|
86
|
+
.then((translations) => {
|
|
87
|
+
addTranslations(i18n._lang, translations);
|
|
88
|
+
})
|
|
89
|
+
.catch((ex) => {
|
|
90
|
+
// eslint-disable-next-line no-console
|
|
91
|
+
console.error('[ui-components] loadDefaultTranslations - parsing failed ', ex);
|
|
92
|
+
});
|
|
93
|
+
}
|
package/src/lib/item.js
CHANGED
|
@@ -1 +1,110 @@
|
|
|
1
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { getApplicationTypeIcon } from './theme';
|
|
17
|
+
import { html } from 'lit';
|
|
18
|
+
export function getVersion(item) {
|
|
19
|
+
if (item) {
|
|
20
|
+
if (item.version) {
|
|
21
|
+
return item.version;
|
|
22
|
+
}
|
|
23
|
+
else if (item.applicationType) {
|
|
24
|
+
const icon = getApplicationTypeIcon(item.applicationType);
|
|
25
|
+
return html `<gv-icon shape="${icon}"></gv-icon>`;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
export function getTitle(item) {
|
|
31
|
+
if (item) {
|
|
32
|
+
return item.name;
|
|
33
|
+
}
|
|
34
|
+
return '';
|
|
35
|
+
}
|
|
36
|
+
export function getPicture(item) {
|
|
37
|
+
if (item) {
|
|
38
|
+
if (item.picture) {
|
|
39
|
+
return item.picture;
|
|
40
|
+
}
|
|
41
|
+
else if (item._links && item._links.picture) {
|
|
42
|
+
return item._links.picture;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
export function getBackground(item) {
|
|
48
|
+
if (item) {
|
|
49
|
+
if (item.background) {
|
|
50
|
+
return item.background;
|
|
51
|
+
}
|
|
52
|
+
else if (item._links && item._links.background) {
|
|
53
|
+
return item._links.background;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
export function getStates(item) {
|
|
59
|
+
if (item) {
|
|
60
|
+
return item.states;
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
export function getLabels(item) {
|
|
65
|
+
if (item) {
|
|
66
|
+
return item.labels;
|
|
67
|
+
}
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
export function getRating(item) {
|
|
71
|
+
if (item) {
|
|
72
|
+
return item.rating_summary;
|
|
73
|
+
}
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
export function getEntrypoints(item) {
|
|
77
|
+
if (item) {
|
|
78
|
+
return item.entrypoints || [];
|
|
79
|
+
}
|
|
80
|
+
return [];
|
|
81
|
+
}
|
|
82
|
+
export function getDescription(item) {
|
|
83
|
+
if (item) {
|
|
84
|
+
return item.description;
|
|
85
|
+
}
|
|
86
|
+
return '';
|
|
87
|
+
}
|
|
88
|
+
export function getOwner(item) {
|
|
89
|
+
if (item && item.owner) {
|
|
90
|
+
return item.owner.display_name;
|
|
91
|
+
}
|
|
92
|
+
return '';
|
|
93
|
+
}
|
|
94
|
+
export function getNbApisInView(item) {
|
|
95
|
+
if (item && item.total_apis != null) {
|
|
96
|
+
return item.total_apis;
|
|
97
|
+
}
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
export function getPictureDisplayName(item) {
|
|
101
|
+
if (item) {
|
|
102
|
+
if (item.version) {
|
|
103
|
+
return `${getTitle(item)} ${item.version}`;
|
|
104
|
+
}
|
|
105
|
+
else if (item.applicationType) {
|
|
106
|
+
return `${getTitle(item)} ${item.applicationType} ${getOwner(item)}`;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return getTitle(item);
|
|
110
|
+
}
|
package/src/lib/properties.js
CHANGED
|
@@ -1 +1,171 @@
|
|
|
1
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Thanks to https://github.com/CleverCloud/clever-client.js
|
|
18
|
+
*
|
|
19
|
+
* https://stackoverflow.com/questions/2821043/allowed-characters-in-linux-environment-variable-names
|
|
20
|
+
* Default bash/Linux rules are:
|
|
21
|
+
* letters (upper case only)
|
|
22
|
+
* digits (but not for first char)
|
|
23
|
+
* underscores
|
|
24
|
+
* nothing else
|
|
25
|
+
* /^[a-zA-Z_][a-zA-Z0-9_]*$/
|
|
26
|
+
*/
|
|
27
|
+
export const ENV_VAR_NAME_REGEX = /^[a-zA-Z0-9-_.]+$/;
|
|
28
|
+
export function validateName(name) {
|
|
29
|
+
// return ENV_VAR_NAME_REGEX.test(name);
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
export const ERROR_TYPES = {
|
|
33
|
+
INVALID_NAME: 0,
|
|
34
|
+
DUPLICATED_NAME: 1,
|
|
35
|
+
INVALID_LINE: 2,
|
|
36
|
+
INVALID_VALUE: 3,
|
|
37
|
+
};
|
|
38
|
+
const NEW_LINE = '\n';
|
|
39
|
+
const SIMPLE_QUOTE = "'";
|
|
40
|
+
const EQUAL = '=';
|
|
41
|
+
const SLASH = '\\';
|
|
42
|
+
const SIMPLE_QUOTE_REPLACE = /([\\]*)'/g;
|
|
43
|
+
const DOUBLE_QUOTE = '"';
|
|
44
|
+
const DOUBLE_QUOTE_REPLACE = /([\\]*)"/g;
|
|
45
|
+
function nextIndex(text, char, start = 0) {
|
|
46
|
+
let i = start;
|
|
47
|
+
let escaped = false;
|
|
48
|
+
while (i < text.length) {
|
|
49
|
+
if (text[i] === char && !escaped) {
|
|
50
|
+
return i;
|
|
51
|
+
}
|
|
52
|
+
escaped = text[i] === '\\';
|
|
53
|
+
i += 1;
|
|
54
|
+
}
|
|
55
|
+
return i;
|
|
56
|
+
}
|
|
57
|
+
function isEmptyLine(line) {
|
|
58
|
+
return line.trim() === '';
|
|
59
|
+
}
|
|
60
|
+
function isCommentLine(line) {
|
|
61
|
+
return line.trim().startsWith('#');
|
|
62
|
+
}
|
|
63
|
+
function getPosition(text, index) {
|
|
64
|
+
const lines = text.substring(0, index).split(NEW_LINE);
|
|
65
|
+
const line = lines.length;
|
|
66
|
+
const column = lines.slice(-1)[0].length;
|
|
67
|
+
return { line, column };
|
|
68
|
+
}
|
|
69
|
+
// Here we surround a string with double quotes,
|
|
70
|
+
// it means we need to escape existing double quotes,
|
|
71
|
+
// we need to do so in a way that is compatible with shells and environment variables,
|
|
72
|
+
// this is why we have (slashes * 2 + 1).
|
|
73
|
+
function doubleQuoteString(str) {
|
|
74
|
+
const escapedString = str.replace(DOUBLE_QUOTE_REPLACE, (m, slashes) => {
|
|
75
|
+
return SLASH.repeat(slashes.length * 2 + 1) + DOUBLE_QUOTE;
|
|
76
|
+
});
|
|
77
|
+
return DOUBLE_QUOTE + escapedString + DOUBLE_QUOTE;
|
|
78
|
+
}
|
|
79
|
+
// Here we must be able to reverse what doubleQuoteString() does,
|
|
80
|
+
// with the same logic,
|
|
81
|
+
// we also want it to work with simple quotes.
|
|
82
|
+
function unquoteString(firstChar, str) {
|
|
83
|
+
if (firstChar === SIMPLE_QUOTE) {
|
|
84
|
+
return str.replace(SIMPLE_QUOTE_REPLACE, (match, slashes) => {
|
|
85
|
+
return SLASH.repeat((slashes.length - 1) / 2) + SIMPLE_QUOTE;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
if (firstChar === DOUBLE_QUOTE) {
|
|
89
|
+
return str.replace(DOUBLE_QUOTE_REPLACE, (match, slashes) => {
|
|
90
|
+
return SLASH.repeat((slashes.length - 1) / 2) + DOUBLE_QUOTE;
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
return str;
|
|
94
|
+
}
|
|
95
|
+
export function parseRaw(rawInput = '') {
|
|
96
|
+
const parsedVariables = [];
|
|
97
|
+
const parsingErrors = [];
|
|
98
|
+
const allNames = new Set();
|
|
99
|
+
let startIdx = 0;
|
|
100
|
+
while (startIdx < rawInput.length) {
|
|
101
|
+
const nextNewLineIdx = nextIndex(rawInput, NEW_LINE, startIdx);
|
|
102
|
+
const line = rawInput.substring(startIdx, nextNewLineIdx);
|
|
103
|
+
if (isEmptyLine(line) || isCommentLine(line)) {
|
|
104
|
+
startIdx = nextNewLineIdx + 1;
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
if (!line.includes(EQUAL)) {
|
|
108
|
+
parsingErrors.push({ type: ERROR_TYPES.INVALID_LINE, pos: getPosition(rawInput, startIdx) });
|
|
109
|
+
startIdx = nextNewLineIdx + 1;
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
const nextEqualIdx = nextIndex(rawInput, EQUAL, startIdx);
|
|
113
|
+
const key = rawInput.substring(startIdx, nextEqualIdx);
|
|
114
|
+
if (!validateName(key)) {
|
|
115
|
+
parsingErrors.push({ type: ERROR_TYPES.INVALID_NAME, key, pos: getPosition(rawInput, startIdx) });
|
|
116
|
+
}
|
|
117
|
+
if (allNames.has(key)) {
|
|
118
|
+
parsingErrors.push({ type: ERROR_TYPES.DUPLICATED_NAME, key, pos: getPosition(rawInput, startIdx) });
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
allNames.add(key);
|
|
122
|
+
}
|
|
123
|
+
const valueFirstChar = rawInput[nextEqualIdx + 1];
|
|
124
|
+
if (valueFirstChar === SIMPLE_QUOTE || valueFirstChar === DOUBLE_QUOTE) {
|
|
125
|
+
const nextQuoteIdx = nextIndex(rawInput, valueFirstChar, nextEqualIdx + 2);
|
|
126
|
+
const rawValue = rawInput.substring(nextEqualIdx + 2, nextQuoteIdx);
|
|
127
|
+
const value = unquoteString(valueFirstChar, rawValue);
|
|
128
|
+
parsedVariables.push({ key, value });
|
|
129
|
+
if (nextNewLineIdx > nextQuoteIdx + 1 || nextQuoteIdx + 1 > rawInput.length) {
|
|
130
|
+
parsingErrors.push({ type: ERROR_TYPES.INVALID_VALUE, key, pos: getPosition(rawInput, nextQuoteIdx + 1) });
|
|
131
|
+
startIdx = nextNewLineIdx + 1;
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
startIdx = nextQuoteIdx + 1;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
const value = rawInput.substring(nextEqualIdx + 1, nextNewLineIdx);
|
|
139
|
+
parsedVariables.push({ key, value });
|
|
140
|
+
startIdx = nextNewLineIdx + 1;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
// WARN: Array.prototype.sort edits in place
|
|
144
|
+
parsedVariables.sort((a, b) => a.key.localeCompare(b.key));
|
|
145
|
+
return { variables: parsedVariables, errors: parsingErrors };
|
|
146
|
+
}
|
|
147
|
+
// automatically merges duplicated named (keeps last value)
|
|
148
|
+
// automatically removes variables with invalid names
|
|
149
|
+
// always double quote values (with proper escaping)
|
|
150
|
+
export function toNameEqualsValueString(variables, options = {}) {
|
|
151
|
+
const { addExports = false } = options;
|
|
152
|
+
return variables
|
|
153
|
+
.sort((a, b) => a.key.localeCompare(b.key))
|
|
154
|
+
.map(({ key, value }) => {
|
|
155
|
+
const quotedValue = doubleQuoteString(value);
|
|
156
|
+
const nameValue = `${key}=${quotedValue}`;
|
|
157
|
+
return addExports ? `export ${nameValue};` : nameValue;
|
|
158
|
+
})
|
|
159
|
+
.join('\n');
|
|
160
|
+
}
|
|
161
|
+
// automatically merges duplicated named (keeps last value)
|
|
162
|
+
// automatically removes variables with invalid names
|
|
163
|
+
export function toNameValueObject(variables) {
|
|
164
|
+
const keyValueObject = {};
|
|
165
|
+
variables
|
|
166
|
+
.filter(({ name }) => validateName(name))
|
|
167
|
+
.forEach(({ name, value }) => {
|
|
168
|
+
keyValueObject[name] = value;
|
|
169
|
+
});
|
|
170
|
+
return keyValueObject;
|
|
171
|
+
}
|
package/src/lib/schema-form.js
CHANGED
|
@@ -1 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export function isCodemirror(control) {
|
|
17
|
+
return control['x-schema-form'] && control['x-schema-form'].type === 'codemirror';
|
|
18
|
+
}
|
|
19
|
+
export function isObject(control) {
|
|
20
|
+
return control.type === 'object';
|
|
21
|
+
}
|
|
22
|
+
export function isComplexArray(control) {
|
|
23
|
+
return control.type === 'array' && !control.items.enum;
|
|
24
|
+
}
|
|
25
|
+
export function canInline(schema) {
|
|
26
|
+
if (schema.properties) {
|
|
27
|
+
const keys = Object.keys(schema.properties);
|
|
28
|
+
return keys.length === 2 && keys.filter((key) => _canInline(schema, key)).length === keys.length;
|
|
29
|
+
}
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
function _canInline(schema, key) {
|
|
33
|
+
const property = schema.properties[key];
|
|
34
|
+
return !isCodemirror(property) && !isObject(property) && !isComplexArray(property);
|
|
35
|
+
}
|
|
36
|
+
export function canGrid(schema) {
|
|
37
|
+
const keys = Object.keys(schema.properties);
|
|
38
|
+
return keys.length > 2 && keys.filter((key) => _canInline(schema, key)).length === keys.length;
|
|
39
|
+
}
|
package/src/lib/studio.js
CHANGED
|
@@ -1 +1,144 @@
|
|
|
1
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { html, css } from 'lit';
|
|
17
|
+
import { classMap } from 'lit/directives/class-map';
|
|
18
|
+
import '../atoms/gv-icon';
|
|
19
|
+
import '../atoms/gv-tag';
|
|
20
|
+
// language=CSS
|
|
21
|
+
export const methods = css `
|
|
22
|
+
gv-tag {
|
|
23
|
+
font-family: monospace;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
gv-tag.ALL {
|
|
27
|
+
--gv-tag--bdc: #262626;
|
|
28
|
+
--gv-tag--bgc: #262626;
|
|
29
|
+
--gv-tag--c: white;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
gv-tag.POST {
|
|
33
|
+
--gv-tag--bdc: #fb8c00;
|
|
34
|
+
--gv-tag--bgc: #fb8c00;
|
|
35
|
+
--gv-tag--c: white;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
gv-tag.PUT {
|
|
39
|
+
--gv-tag--bdc: #039be5;
|
|
40
|
+
--gv-tag--bgc: #039be5;
|
|
41
|
+
--gv-tag--c: white;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
gv-tag.GET {
|
|
45
|
+
--gv-tag--bdc: #43a047;
|
|
46
|
+
--gv-tag--bgc: #43a047;
|
|
47
|
+
--gv-tag--c: white;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
gv-tag.DELETE {
|
|
51
|
+
--gv-tag--bdc: #e53935;
|
|
52
|
+
--gv-tag--bgc: #e53935;
|
|
53
|
+
--gv-tag--c: white;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.flow-path,
|
|
57
|
+
.plan-name {
|
|
58
|
+
margin-left: 0.2rem;
|
|
59
|
+
display: flex;
|
|
60
|
+
align-items: center;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.collection-name {
|
|
64
|
+
margin-right: 0.5rem;
|
|
65
|
+
--gv-icon--s: 26px;
|
|
66
|
+
--gv-icon--c: #5a7684;
|
|
67
|
+
--gv-icon-opacity--c: #5a7684;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.icon-type {
|
|
71
|
+
--gv-icon--s: 26px;
|
|
72
|
+
--gv-icon--c: #383e3f;
|
|
73
|
+
--gv-icon-opacity--c: #5a7684;
|
|
74
|
+
}
|
|
75
|
+
`;
|
|
76
|
+
export function getFlowName(flow, collectionName, withMethods = true, draggable = false, compact = true) {
|
|
77
|
+
let rendering = [];
|
|
78
|
+
if (flow) {
|
|
79
|
+
if (draggable) {
|
|
80
|
+
rendering.push(html `<gv-icon title="Drag for reorder" class="draggable-icon" shape="general:sort"></gv-icon>`);
|
|
81
|
+
}
|
|
82
|
+
const methods = flow.methods || [];
|
|
83
|
+
if (flow.type != null) {
|
|
84
|
+
let shape = null;
|
|
85
|
+
if (flow.type.toUpperCase() === 'ROOT') {
|
|
86
|
+
shape = 'home:earth';
|
|
87
|
+
}
|
|
88
|
+
else if (flow.type.toUpperCase() === 'LOGIN') {
|
|
89
|
+
shape = 'general:shield-protected';
|
|
90
|
+
}
|
|
91
|
+
else if (flow.type.toUpperCase() === 'CONSENT') {
|
|
92
|
+
shape = 'general:shield-check';
|
|
93
|
+
}
|
|
94
|
+
else if (flow.type.toUpperCase() === 'REGISTER') {
|
|
95
|
+
shape = 'communication:shield-user';
|
|
96
|
+
}
|
|
97
|
+
if (shape != null) {
|
|
98
|
+
rendering = [...rendering, html `<gv-icon title="${flow.type}" shape="${shape}" class="icon-type"></gv-icon>`];
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
else if (withMethods) {
|
|
102
|
+
const renderingMethods = methods.map((method) => html `<gv-tag class="${method.toUpperCase()}">${method.toUpperCase()}</gv-tag>`);
|
|
103
|
+
if (compact && (renderingMethods.length === 9 || renderingMethods.length === 0)) {
|
|
104
|
+
rendering = [...rendering, html `<gv-tag major title="${methods.join('\n')}">ALL</gv-tag>`];
|
|
105
|
+
}
|
|
106
|
+
else if (compact && renderingMethods.length >= 3) {
|
|
107
|
+
const renderingMethodsCompact = renderingMethods.slice(0, 2);
|
|
108
|
+
renderingMethodsCompact.push(html `<gv-tag minor title="${methods.join('\n')}">+${renderingMethods.length - 2}</gv-tag>`);
|
|
109
|
+
rendering = [...rendering, ...renderingMethodsCompact];
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
rendering = [...rendering, ...renderingMethods];
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const classes = {
|
|
116
|
+
'flow-path': true,
|
|
117
|
+
disabled: flow.disabled,
|
|
118
|
+
};
|
|
119
|
+
if (flow.name != null && flow.name.trim() !== '') {
|
|
120
|
+
if (flow._dirty) {
|
|
121
|
+
rendering.push(html `<div class="${classMap(classes)}"><mark>${flow.name}</mark></div>`);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
rendering.push(html `<div class="${classMap(classes)}">${flow.name}</div>`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
else if (flow['path-operator']) {
|
|
128
|
+
const path = flow['path-operator'].path || '/';
|
|
129
|
+
if (path) {
|
|
130
|
+
const pathWithOperator = flow['path-operator'].operator === 'STARTS_WITH' ? `${path.endsWith('/') ? path : `${path}/`}**` : path;
|
|
131
|
+
if (flow._dirty) {
|
|
132
|
+
rendering.push(html `<div class="${classMap(classes)}"><mark>${pathWithOperator}</mark></div>`);
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
rendering.push(html `<div class="${classMap(classes)}">${pathWithOperator}</div>`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (collectionName) {
|
|
140
|
+
rendering.push(html `<div class="collection-name">${collectionName}</div>`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return rendering;
|
|
144
|
+
}
|
package/src/lib/style.js
CHANGED
|
@@ -1 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
function getPropertyValue(element, propertyName, defaultValue) {
|
|
17
|
+
/* global getComputedStyle */
|
|
18
|
+
const value = getComputedStyle(element).getPropertyValue(propertyName);
|
|
19
|
+
return value.trim() || defaultValue;
|
|
20
|
+
}
|
|
21
|
+
export const getCssVar = function getCssVar(element, variableName, defaultValue) {
|
|
22
|
+
if (element) {
|
|
23
|
+
if (variableName.startsWith('--')) {
|
|
24
|
+
return getPropertyValue(element, variableName, defaultValue);
|
|
25
|
+
}
|
|
26
|
+
return getPropertyValue(element, `--${variableName}`, defaultValue);
|
|
27
|
+
}
|
|
28
|
+
return defaultValue;
|
|
29
|
+
};
|
|
30
|
+
export function hexToRGB(hex) {
|
|
31
|
+
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex.trim());
|
|
32
|
+
return result
|
|
33
|
+
? {
|
|
34
|
+
r: parseInt(result[1], 16),
|
|
35
|
+
g: parseInt(result[2], 16),
|
|
36
|
+
b: parseInt(result[3], 16),
|
|
37
|
+
}
|
|
38
|
+
: null;
|
|
39
|
+
}
|