@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.
Files changed (183) hide show
  1. package/package.json +5 -13
  2. package/src/atoms/gv-autocomplete.js +422 -1
  3. package/src/atoms/gv-button.js +397 -1
  4. package/src/atoms/gv-checkbox.js +178 -1
  5. package/src/atoms/gv-date-picker-calendar.js +812 -1
  6. package/src/atoms/gv-date-picker-cell.js +174 -1
  7. package/src/atoms/gv-date-picker.js +638 -1
  8. package/src/atoms/gv-file-upload.js +348 -1
  9. package/src/atoms/gv-icon.js +93 -1
  10. package/src/atoms/gv-image.js +135 -1
  11. package/src/atoms/gv-input-message.js +78 -1
  12. package/src/atoms/gv-input.js +508 -1
  13. package/src/atoms/gv-link.js +204 -1
  14. package/src/atoms/gv-message.js +133 -1
  15. package/src/atoms/gv-metric.js +112 -1
  16. package/src/atoms/gv-relative-time.js +143 -1
  17. package/src/atoms/gv-select-native.js +363 -1
  18. package/src/atoms/gv-select.js +413 -1
  19. package/src/atoms/gv-spinner.js +54 -1
  20. package/src/atoms/gv-state.js +125 -1
  21. package/src/atoms/gv-switch.js +235 -1
  22. package/src/atoms/gv-tag.js +162 -1
  23. package/src/atoms/gv-text.js +160 -1
  24. package/src/charts/gv-chart-bar.js +101 -1
  25. package/src/charts/gv-chart-gauge.js +92 -1
  26. package/src/charts/gv-chart-histogram.js +78 -1
  27. package/src/charts/gv-chart-line.js +218 -1
  28. package/src/charts/gv-chart-map.js +111 -1
  29. package/src/charts/gv-chart-pie.js +89 -1
  30. package/src/index.js +77 -1
  31. package/src/lib/cron-expression.js +176 -1
  32. package/src/lib/date.js +43 -1
  33. package/src/lib/events.js +26 -1
  34. package/src/lib/http-client-schema-form.js +67 -1
  35. package/src/lib/http.js +237 -1
  36. package/src/lib/i18n.js +93 -1
  37. package/src/lib/item.js +110 -1
  38. package/src/lib/properties.js +171 -1
  39. package/src/lib/schema-form.js +39 -1
  40. package/src/lib/studio.js +144 -1
  41. package/src/lib/style.js +39 -1
  42. package/src/lib/text-format.js +65 -1
  43. package/src/lib/theme.js +60 -1
  44. package/src/lib/utils.js +106 -1
  45. package/src/mixins/chart-element.js +153 -1
  46. package/src/mixins/input-element.js +136 -1
  47. package/src/mixins/item-resource.js +102 -1
  48. package/src/mixins/keyboard-element.js +62 -1
  49. package/src/mixins/update-after-browser.js +30 -1
  50. package/src/mixins/with-resize-observer.js +62 -1
  51. package/src/mixins/with-skeleton-attribute.js +109 -1
  52. package/src/molecules/gv-card-full.js +209 -1
  53. package/src/molecules/gv-card-list.js +101 -1
  54. package/src/molecules/gv-card.js +130 -1
  55. package/src/molecules/gv-category-list.js +56 -1
  56. package/src/molecules/gv-category.js +163 -1
  57. package/src/molecules/gv-code.js +334 -1
  58. package/src/molecules/gv-confirm.js +175 -1
  59. package/src/molecules/gv-cron-editor.js +685 -1
  60. package/src/molecules/gv-dropdown-menu.js +108 -1
  61. package/src/molecules/gv-expandable.js +116 -1
  62. package/src/molecules/gv-expression-language.js +263 -1
  63. package/src/molecules/gv-identity-picture.js +139 -1
  64. package/src/molecules/gv-list.js +214 -1
  65. package/src/molecules/gv-metrics.js +147 -1
  66. package/src/molecules/gv-modal.js +203 -1
  67. package/src/molecules/gv-nav.js +180 -1
  68. package/src/molecules/gv-option.js +230 -1
  69. package/src/molecules/gv-plans.js +400 -1
  70. package/src/molecules/gv-popover.js +323 -1
  71. package/src/molecules/gv-promote.js +203 -1
  72. package/src/molecules/gv-rating-list.js +341 -1
  73. package/src/molecules/gv-rating.js +234 -1
  74. package/src/molecules/gv-row-expandable.js +42 -1
  75. package/src/molecules/gv-row.js +205 -1
  76. package/src/molecules/gv-stats.js +110 -1
  77. package/src/molecules/gv-stepper.js +274 -1
  78. package/src/molecules/gv-table.js +644 -1
  79. package/src/molecules/gv-tree.js +238 -1
  80. package/src/organisms/gv-documentation.js +205 -1
  81. package/src/organisms/gv-header.js +276 -1
  82. package/src/organisms/gv-http-client.js +258 -1
  83. package/src/organisms/gv-menu.js +258 -1
  84. package/src/organisms/gv-newsletter-subscription.js +258 -1
  85. package/src/organisms/gv-pagination.js +179 -1
  86. package/src/organisms/gv-properties.js +860 -1
  87. package/src/organisms/gv-resizable-views.js +371 -1
  88. package/src/organisms/gv-resources.js +496 -1
  89. package/src/organisms/gv-schema-form-array.js +237 -1
  90. package/src/organisms/gv-schema-form-control-object.js +141 -1
  91. package/src/organisms/gv-schema-form-control.js +419 -1
  92. package/src/organisms/gv-schema-form.js +700 -1
  93. package/src/organisms/gv-tabs.js +201 -1
  94. package/src/organisms/gv-user-menu.js +298 -1
  95. package/src/organisms/gv-vertical-menu.js +119 -1
  96. package/src/policy-studio/gv-flow-step.js +443 -1
  97. package/src/policy-studio/gv-flow.js +595 -1
  98. package/src/policy-studio/gv-policy-studio-menu.js +689 -1
  99. package/src/policy-studio/gv-policy-studio.js +1712 -1
  100. package/src/styles/empty.js +35 -1
  101. package/src/styles/input.js +262 -1
  102. package/src/styles/link.js +31 -1
  103. package/src/styles/shapes.js +17 -1
  104. package/src/styles/skeleton.js +52 -1
  105. package/src/styles/zoom.js +39 -1
  106. package/src/theme/gv-theme.js +197 -1
  107. package/wc/gv-autocomplete.js +1 -1
  108. package/wc/gv-button.js +1 -1
  109. package/wc/gv-card-full.js +1 -1
  110. package/wc/gv-card-list.js +1 -1
  111. package/wc/gv-card.js +1 -1
  112. package/wc/gv-category-list.js +1 -1
  113. package/wc/gv-category.js +1 -1
  114. package/wc/gv-chart-bar.js +1 -1
  115. package/wc/gv-chart-gauge.js +1 -1
  116. package/wc/gv-chart-histogram.js +1 -1
  117. package/wc/gv-chart-line.js +1 -1
  118. package/wc/gv-chart-map.js +1 -1
  119. package/wc/gv-chart-pie.js +1 -1
  120. package/wc/gv-checkbox.js +1 -1
  121. package/wc/gv-code.js +1 -1
  122. package/wc/gv-confirm.js +1 -1
  123. package/wc/gv-cron-editor.js +1 -1
  124. package/wc/gv-date-picker-calendar.js +1 -1
  125. package/wc/gv-date-picker-cell.js +1 -1
  126. package/wc/gv-date-picker.js +1 -1
  127. package/wc/gv-documentation.js +1 -1
  128. package/wc/gv-dropdown-menu.js +1 -1
  129. package/wc/gv-expandable.js +1 -1
  130. package/wc/gv-expression-language.js +1 -1
  131. package/wc/gv-file-upload.js +1 -1
  132. package/wc/gv-flow-step.js +1 -1
  133. package/wc/gv-flow.js +1 -1
  134. package/wc/gv-header.js +1 -1
  135. package/wc/gv-http-client.js +1 -1
  136. package/wc/gv-icon.js +1 -1
  137. package/wc/gv-identity-picture.js +1 -1
  138. package/wc/gv-image.js +1 -1
  139. package/wc/gv-input-message.js +1 -1
  140. package/wc/gv-input.js +1 -1
  141. package/wc/gv-link.js +1 -1
  142. package/wc/gv-list.js +1 -1
  143. package/wc/gv-menu.js +1 -1
  144. package/wc/gv-message.js +1 -1
  145. package/wc/gv-metric.js +1 -1
  146. package/wc/gv-metrics.js +1 -1
  147. package/wc/gv-modal.js +1 -1
  148. package/wc/gv-nav.js +1 -1
  149. package/wc/gv-newsletter-subscription.js +1 -1
  150. package/wc/gv-option.js +1 -1
  151. package/wc/gv-pagination.js +1 -1
  152. package/wc/gv-plans.js +1 -1
  153. package/wc/gv-policy-studio-menu.js +1 -1
  154. package/wc/gv-policy-studio.js +1 -1
  155. package/wc/gv-popover.js +1 -1
  156. package/wc/gv-promote.js +1 -1
  157. package/wc/gv-properties.js +1 -1
  158. package/wc/gv-rating-list.js +1 -1
  159. package/wc/gv-rating.js +1 -1
  160. package/wc/gv-relative-time.js +1 -1
  161. package/wc/gv-resizable-views.js +1 -1
  162. package/wc/gv-resources.js +1 -1
  163. package/wc/gv-row-expandable.js +1 -1
  164. package/wc/gv-row.js +1 -1
  165. package/wc/gv-schema-form-array.js +1 -1
  166. package/wc/gv-schema-form-control-object.js +1 -1
  167. package/wc/gv-schema-form-control.js +1 -1
  168. package/wc/gv-schema-form.js +1 -1
  169. package/wc/gv-select-native.js +1 -1
  170. package/wc/gv-select.js +1 -1
  171. package/wc/gv-spinner.js +1 -1
  172. package/wc/gv-state.js +1 -1
  173. package/wc/gv-stats.js +1 -1
  174. package/wc/gv-stepper.js +1 -1
  175. package/wc/gv-switch.js +1 -1
  176. package/wc/gv-table.js +1 -1
  177. package/wc/gv-tabs.js +1 -1
  178. package/wc/gv-tag.js +1 -1
  179. package/wc/gv-text.js +1 -1
  180. package/wc/gv-theme.js +1 -1
  181. package/wc/gv-tree.js +1 -1
  182. package/wc/gv-user-menu.js +1 -1
  183. package/wc/gv-vertical-menu.js +1 -1
package/src/lib/i18n.js CHANGED
@@ -1 +1,93 @@
1
- function n(t,e){const a=function(t){try{return t.split(".").reduce(((n,t)=>n&&n[t]),n._translations[n._lang])}catch(n){return null}}(t);if(null==a)return"unknown";if(e){return n._messageFormatter.compile(a)(e)}return a}Object.defineProperty(exports,"__esModule",{value:!0}),exports.loadDefaultTranslations=exports.getAvailableLanguages=exports.addTranslations=exports.getLanguage=exports.setLanguage=exports.i18n=void 0,require("whatwg-fetch"),exports.i18n=n,n._translations={};const t=require("messageformat");function e(t){n._lang=t}function a(t,e,a){n._translations[t]={LANGUAGE:a,...e}}n._messageFormatter=new t(n._lang),exports.setLanguage=e,exports.getLanguage=function(){return n._lang},exports.addTranslations=a,exports.getAvailableLanguages=function(){const t={};for(const e in n._translations){const{LANGUAGE:a}=n._translations[e];t[a]=e}return t},exports.loadDefaultTranslations=function(){return e("en"),fetch(`i18n/${n._lang}.json`).then((n=>n.json())).then((t=>{a(n._lang,t)})).catch((n=>{console.error("[ui-components] loadDefaultTranslations - parsing failed ",n)}))};
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
- Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPictureDisplayName=exports.getNbApisInView=exports.getOwner=exports.getDescription=exports.getEntrypoints=exports.getRating=exports.getLabels=exports.getStates=exports.getBackground=exports.getPicture=exports.getTitle=exports.getVersion=void 0;const t=require("./theme"),e=require("lit");function r(t){return t?t.name:""}function n(t){return t&&t.owner?t.owner.display_name:""}exports.getVersion=function(r){if(r){if(r.version)return r.version;if(r.applicationType){const n=(0,t.getApplicationTypeIcon)(r.applicationType);return e.html`<gv-icon shape="${n}"></gv-icon>`}}return null},exports.getTitle=r,exports.getPicture=function(t){if(t){if(t.picture)return t.picture;if(t._links&&t._links.picture)return t._links.picture}return null},exports.getBackground=function(t){if(t){if(t.background)return t.background;if(t._links&&t._links.background)return t._links.background}return null},exports.getStates=function(t){return t?t.states:null},exports.getLabels=function(t){return t?t.labels:null},exports.getRating=function(t){return t?t.rating_summary:null},exports.getEntrypoints=function(t){return t&&t.entrypoints||[]},exports.getDescription=function(t){return t?t.description:""},exports.getOwner=n,exports.getNbApisInView=function(t){return t&&null!=t.total_apis?t.total_apis:null},exports.getPictureDisplayName=function(t){if(t){if(t.version)return`${r(t)} ${t.version}`;if(t.applicationType)return`${r(t)} ${t.applicationType} ${n(t)}`}return r(t)};
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
+ }
@@ -1 +1,171 @@
1
- function e(e){return!0}Object.defineProperty(exports,"__esModule",{value:!0}),exports.toNameValueObject=exports.toNameEqualsValueString=exports.parseRaw=exports.ERROR_TYPES=exports.validateName=exports.ENV_VAR_NAME_REGEX=void 0,exports.ENV_VAR_NAME_REGEX=/^[a-zA-Z0-9-_.]+$/,exports.validateName=e,exports.ERROR_TYPES={INVALID_NAME:0,DUPLICATED_NAME:1,INVALID_LINE:2,INVALID_VALUE:3};const t=/([\\]*)'/g,r=/([\\]*)"/g;function n(e,t,r=0){let n=r,s=!1;for(;n<e.length;){if(e[n]===t&&!s)return n;s="\\"===e[n],n+=1}return n}function s(e){return""===e.trim()}function o(e){return e.trim().startsWith("#")}function a(e,t){const r=e.substring(0,t).split("\n");return{line:r.length,column:r.slice(-1)[0].length}}exports.parseRaw=function(e=""){const u=[],p=[],l=new Set;let i=0;for(;i<e.length;){const R=n(e,"\n",i),_=e.substring(i,R);if(s(_)||o(_)){i=R+1;continue}if(!_.includes("=")){p.push({type:exports.ERROR_TYPES.INVALID_LINE,pos:a(e,i)}),i=R+1;continue}const N=n(e,"=",i),x=e.substring(i,N);l.has(x)?p.push({type:exports.ERROR_TYPES.DUPLICATED_NAME,key:x,pos:a(e,i)}):l.add(x);const f=e[N+1];if("'"===f||'"'===f){const s=n(e,f,N+2),o=e.substring(N+2,s),l=(E=o,"'"===(c=f)?E.replace(t,((e,t)=>"\\".repeat((t.length-1)/2)+"'")):'"'===c?E.replace(r,((e,t)=>"\\".repeat((t.length-1)/2)+'"')):E);u.push({key:x,value:l}),R>s+1||s+1>e.length?(p.push({type:exports.ERROR_TYPES.INVALID_VALUE,key:x,pos:a(e,s+1)}),i=R+1):i=s+1}else{const t=e.substring(N+1,R);u.push({key:x,value:t}),i=R+1}}var c,E;return u.sort(((e,t)=>e.key.localeCompare(t.key))),{variables:u,errors:p}},exports.toNameEqualsValueString=function(e,t={}){const{addExports:n=!1}=t;return e.sort(((e,t)=>e.key.localeCompare(t.key))).map((({key:e,value:t})=>{const s=`${e}=${'"'+t.replace(r,((e,t)=>"\\".repeat(2*t.length+1)+'"'))+'"'}`;return n?`export ${s};`:s})).join("\n")},exports.toNameValueObject=function(e){const t={};return e.filter((({name:e})=>!0)).forEach((({name:e,value:r})=>{t[e]=r})),t};
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
+ }
@@ -1 +1,39 @@
1
- function e(e){return e["x-schema-form"]&&"codemirror"===e["x-schema-form"].type}function r(e){return"object"===e.type}function t(e){return"array"===e.type&&!e.items.enum}function n(n,o){const s=n.properties[o];return!e(s)&&!r(s)&&!t(s)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.canGrid=exports.canInline=exports.isComplexArray=exports.isObject=exports.isCodemirror=void 0,exports.isCodemirror=e,exports.isObject=r,exports.isComplexArray=t,exports.canInline=function(e){if(e.properties){const r=Object.keys(e.properties);return 2===r.length&&r.filter((r=>n(e,r))).length===r.length}return!0},exports.canGrid=function(e){const r=Object.keys(e.properties);return r.length>2&&r.filter((r=>n(e,r))).length===r.length};
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
- Object.defineProperty(exports,"__esModule",{value:!0}),exports.getFlowName=exports.methods=void 0;const t=require("lit"),e=require("lit/directives/class-map");require("../atoms/gv-icon"),require("../atoms/gv-tag"),exports.methods=t.css`gv-tag{font-family:monospace}gv-tag.ALL{--gv-tag--bdc:#262626;--gv-tag--bgc:#262626;--gv-tag--c:white}gv-tag.POST{--gv-tag--bdc:#fb8c00;--gv-tag--bgc:#fb8c00;--gv-tag--c:white}gv-tag.PUT{--gv-tag--bdc:#039be5;--gv-tag--bgc:#039be5;--gv-tag--c:white}gv-tag.GET{--gv-tag--bdc:#43a047;--gv-tag--bgc:#43a047;--gv-tag--c:white}gv-tag.DELETE{--gv-tag--bdc:#e53935;--gv-tag--bgc:#e53935;--gv-tag--c:white}.flow-path,.plan-name{margin-left:.2rem;display:flex;align-items:center}.collection-name{margin-right:.5rem;--gv-icon--s:26px;--gv-icon--c:#5a7684;--gv-icon-opacity--c:#5a7684}.icon-type{--gv-icon--s:26px;--gv-icon--c:#383e3f;--gv-icon-opacity--c:#5a7684}`,exports.getFlowName=function(a,g,s=!0,i=!1,c=!0){let l=[];if(a){i&&l.push(t.html`<gv-icon title="Drag for reorder" class="draggable-icon" shape="general:sort"></gv-icon>`);const o=a.methods||[];if(null!=a.type){let e=null;"ROOT"===a.type.toUpperCase()?e="home:earth":"LOGIN"===a.type.toUpperCase()?e="general:shield-protected":"CONSENT"===a.type.toUpperCase()?e="general:shield-check":"REGISTER"===a.type.toUpperCase()&&(e="communication:shield-user"),null!=e&&(l=[...l,t.html`<gv-icon title="${a.type}" shape="${e}" class="icon-type"></gv-icon>`])}else if(s){const e=o.map((e=>t.html`<gv-tag class="${e.toUpperCase()}">${e.toUpperCase()}</gv-tag>`));if(!c||9!==e.length&&0!==e.length)if(c&&e.length>=3){const a=e.slice(0,2);a.push(t.html`<gv-tag minor title="${o.join("\n")}">+${e.length-2}</gv-tag>`),l=[...l,...a]}else l=[...l,...e];else l=[...l,t.html`<gv-tag major title="${o.join("\n")}">ALL</gv-tag>`]}const n={"flow-path":!0,disabled:a.disabled};if(null!=a.name&&""!==a.name.trim())a._dirty?l.push(t.html`<div class="${(0,e.classMap)(n)}"><mark>${a.name}</mark></div>`):l.push(t.html`<div class="${(0,e.classMap)(n)}">${a.name}</div>`);else if(a["path-operator"]){const g=a["path-operator"].path||"/";if(g){const s="STARTS_WITH"===a["path-operator"].operator?`${g.endsWith("/")?g:`${g}/`}**`:g;a._dirty?l.push(t.html`<div class="${(0,e.classMap)(n)}"><mark>${s}</mark></div>`):l.push(t.html`<div class="${(0,e.classMap)(n)}">${s}</div>`)}}g&&l.push(t.html`<div class="collection-name">${g}</div>`)}return l};
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
- function e(e,t,r){return getComputedStyle(e).getPropertyValue(t).trim()||r}Object.defineProperty(exports,"__esModule",{value:!0}),exports.hexToRGB=exports.getCssVar=void 0;exports.getCssVar=function(t,r,o){return t?r.startsWith("--")?e(t,r,o):e(t,`--${r}`,o):o},exports.hexToRGB=function(e){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e.trim());return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:null};
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
+ }